Author: sgje...@chromium.org Date: Tue Mar 10 05:05:20 2009 New Revision: 1474
Modified: branches/bleeding_edge/src/factory.cc branches/bleeding_edge/src/heap-inl.h branches/bleeding_edge/src/heap.cc branches/bleeding_edge/src/heap.h branches/bleeding_edge/test/mjsunit/debug-setbreakpoint.js Log: Moved the storage of the last script id into the heap to make it part of the serialized data when starting V8 on a snapshot. Currently the script ids wrap when positive smi value is exhausted. Review URL: http://codereview.chromium.org/43008 Modified: branches/bleeding_edge/src/factory.cc ============================================================================== --- branches/bleeding_edge/src/factory.cc (original) +++ branches/bleeding_edge/src/factory.cc Tue Mar 10 05:05:20 2009 @@ -153,17 +153,32 @@ Handle<Script> Factory::NewScript(Handle<String> source) { - static uint32_t next_id = 1; - + // Generate id for this script. + int id; + if (Heap::last_script_id()->IsUndefined()) { + // Script ids start from one. + id = 1; + } else { + // Increment id, wrap when positive smi is exhausted. + id = Smi::cast(Heap::last_script_id())->value(); + id++; + if (!Smi::IsValid(id)) { + id = 0; + } + } + Heap::SetLastScriptId(Smi::FromInt(id)); + + // Create and initialize script object. Handle<Script> script = Handle<Script>::cast(NewStruct(SCRIPT_TYPE)); script->set_source(*source); script->set_name(Heap::undefined_value()); - script->set_id(*Factory::NewNumberFromUint(next_id++)); + script->set_id(Heap::last_script_id()); script->set_line_offset(Smi::FromInt(0)); script->set_column_offset(Smi::FromInt(0)); script->set_type(Smi::FromInt(SCRIPT_TYPE_NORMAL)); script->set_wrapper(*Factory::NewProxy(0, TENURED)); script->set_line_ends(Heap::undefined_value()); + return script; } Modified: branches/bleeding_edge/src/heap-inl.h ============================================================================== --- branches/bleeding_edge/src/heap-inl.h (original) +++ branches/bleeding_edge/src/heap-inl.h Tue Mar 10 05:05:20 2009 @@ -211,6 +211,11 @@ } +void Heap::SetLastScriptId(Object* last_script_id) { + last_script_id_ = last_script_id; +} + + #define GC_GREEDY_CHECK() \ ASSERT(!FLAG_gc_greedy || v8::internal::Heap::GarbageCollectionGreedyCheck()) Modified: branches/bleeding_edge/src/heap.cc ============================================================================== --- branches/bleeding_edge/src/heap.cc (original) +++ branches/bleeding_edge/src/heap.cc Tue Mar 10 05:05:20 2009 @@ -1238,6 +1238,9 @@ if (obj->IsFailure()) return false; natives_source_cache_ = FixedArray::cast(obj); + // Handling of script id generation is in Factory::NewScript. + last_script_id_ = undefined_value(); + // Initialize keyed lookup cache. ClearKeyedLookupCache(); Modified: branches/bleeding_edge/src/heap.h ============================================================================== --- branches/bleeding_edge/src/heap.h (original) +++ branches/bleeding_edge/src/heap.h Tue Mar 10 05:05:20 2009 @@ -123,7 +123,8 @@ V(FixedArray, number_string_cache) \ V(FixedArray, single_character_string_cache) \ V(FixedArray, natives_source_cache) \ - V(Object, keyed_lookup_cache) + V(Object, keyed_lookup_cache) \ + V(Object, last_script_id) #define ROOT_LIST(V) \ @@ -689,6 +690,9 @@ static inline Object* GetKeyedLookupCache(); static inline void SetKeyedLookupCache(LookupCache* cache); static inline void ClearKeyedLookupCache(); + + // Update the next script id. + static inline void SetLastScriptId(Object* last_script_id); #ifdef DEBUG static void Print(); Modified: branches/bleeding_edge/test/mjsunit/debug-setbreakpoint.js ============================================================================== --- branches/bleeding_edge/test/mjsunit/debug-setbreakpoint.js (original) +++ branches/bleeding_edge/test/mjsunit/debug-setbreakpoint.js Tue Mar 10 05:05:20 2009 @@ -59,7 +59,6 @@ assertEquals('scriptName', response.body.type, json_response); } else { assertEquals('scriptId', response.body.type, json_response); - print(response.body.script_id); } } else { assertFalse(response.success, json_response); --~--~---------~--~----~------------~-------~--~----~ v8-dev mailing list v8-dev@googlegroups.com http://groups.google.com/group/v8-dev -~----------~----~----~----~------~----~------~--~---