diff options
author | Ben Murdoch <benm@google.com> | 2011-08-04 19:25:22 +0100 |
---|---|---|
committer | Ben Murdoch <benm@google.com> | 2011-08-04 19:25:22 +0100 |
commit | 6d7cb000ed533f52d745e60663019ff891bb19a8 (patch) | |
tree | 42903ccb2153c0a9dba45ed01c567940b2b6b3c6 /src | |
parent | 18a6f57610d404676fb0db2114fd7ad91e0402b0 (diff) | |
download | android_external_v8-6d7cb000ed533f52d745e60663019ff891bb19a8.tar.gz android_external_v8-6d7cb000ed533f52d745e60663019ff891bb19a8.tar.bz2 android_external_v8-6d7cb000ed533f52d745e60663019ff891bb19a8.zip |
Merge V8 at r8836: Pick up V8 3.2.10.34
Bug: 5095592
Change-Id: I955924aac6e0bdba591798526c33c4d59fd3dc4f
Diffstat (limited to 'src')
-rwxr-xr-x | src/SConscript | 5 | ||||
-rw-r--r-- | src/api.cc | 11 | ||||
-rw-r--r-- | src/api.h | 7 | ||||
-rw-r--r-- | src/arm/lithium-codegen-arm.cc | 2 | ||||
-rw-r--r-- | src/debug.cc | 9 | ||||
-rw-r--r-- | src/debug.h | 2 | ||||
-rw-r--r-- | src/execution.cc | 2 | ||||
-rw-r--r-- | src/global-handles.h | 2 | ||||
-rw-r--r-- | src/heap.cc | 2 | ||||
-rw-r--r-- | src/isolate.cc | 160 | ||||
-rw-r--r-- | src/isolate.h | 54 | ||||
-rw-r--r-- | src/log.cc | 6 | ||||
-rw-r--r-- | src/objects.cc | 9 | ||||
-rw-r--r-- | src/objects.h | 2 | ||||
-rw-r--r-- | src/runtime.cc | 5 | ||||
-rw-r--r-- | src/spaces.cc | 16 | ||||
-rw-r--r-- | src/spaces.h | 22 | ||||
-rw-r--r-- | src/top.cc | 9 | ||||
-rw-r--r-- | src/version.cc | 2 |
19 files changed, 175 insertions, 152 deletions
diff --git a/src/SConscript b/src/SConscript index a68ee3e3..06ee907c 100755 --- a/src/SConscript +++ b/src/SConscript @@ -307,10 +307,7 @@ def ConfigureObjectFiles(): env.Replace(**context.flags['v8']) context.ApplyEnvOverrides(env) env['BUILDERS']['JS2C'] = Builder(action=js2c.JS2C) - if 'ENABLE_LOGGING_AND_PROFILING' in env['CPPDEFINES']: - env['BUILDERS']['Snapshot'] = Builder(action='$SOURCE $TARGET --logfile "$LOGFILE" --log-snapshot-positions') - else: - env['BUILDERS']['Snapshot'] = Builder(action='$SOURCE $TARGET') + env['BUILDERS']['Snapshot'] = Builder(action='$SOURCE $TARGET --logfile "$LOGFILE" --log-snapshot-positions') # Build the standard platform-independent source files. source_files = context.GetRelevantSources(SOURCES) @@ -89,7 +89,7 @@ namespace v8 { if (has_pending_exception) { \ if (handle_scope_implementer->CallDepthIsZero() && \ (isolate)->is_out_of_memory()) { \ - if (!handle_scope_implementer->ignore_out_of_memory()) \ + if (!(isolate)->ignore_out_of_memory()) \ i::V8::FatalProcessOutOfMemory(NULL); \ } \ bool call_depth_is_zero = handle_scope_implementer->CallDepthIsZero(); \ @@ -856,7 +856,6 @@ Local<TypeSwitch> TypeSwitch::New(int argc, Handle<FunctionTemplate> types[]) { int TypeSwitch::match(v8::Handle<Value> value) { i::Isolate* isolate = i::Isolate::Current(); LOG_API(isolate, "TypeSwitch::match"); - USE(isolate); i::Handle<i::Object> obj = Utils::OpenHandle(*value); i::Handle<i::TypeSwitchInfo> info = Utils::OpenHandle(this); i::FixedArray* types = i::FixedArray::cast(info->types()); @@ -3234,7 +3233,6 @@ Local<v8::Value> Function::Call(v8::Handle<v8::Object> recv, int argc, void Function::SetName(v8::Handle<v8::String> name) { i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); ENTER_V8(isolate); - USE(isolate); i::Handle<i::JSFunction> func = Utils::OpenHandle(this); func->shared()->set_name(*Utils::OpenHandle(*name)); } @@ -3908,8 +3906,8 @@ static void* ExternalValueImpl(i::Handle<i::Object> obj) { Local<Value> v8::External::Wrap(void* data) { i::Isolate* isolate = i::Isolate::Current(); STATIC_ASSERT(sizeof(data) == sizeof(i::Address)); - LOG_API(isolate, "External::Wrap"); EnsureInitializedForIsolate(isolate, "v8::External::Wrap()"); + LOG_API(isolate, "External::Wrap"); ENTER_V8(isolate); v8::Local<v8::Value> result = CanBeEncodedAsSmi(data) @@ -3953,8 +3951,8 @@ void* v8::External::FullUnwrap(v8::Handle<v8::Value> wrapper) { Local<External> v8::External::New(void* data) { STATIC_ASSERT(sizeof(data) == sizeof(i::Address)); i::Isolate* isolate = i::Isolate::Current(); - LOG_API(isolate, "External::New"); EnsureInitializedForIsolate(isolate, "v8::External::New()"); + LOG_API(isolate, "External::New"); ENTER_V8(isolate); return ExternalNewImpl(data); } @@ -4373,8 +4371,7 @@ Local<Integer> Integer::NewFromUnsigned(uint32_t value) { void V8::IgnoreOutOfMemoryException() { - EnterIsolateIfNeeded()->handle_scope_implementer()->set_ignore_out_of_memory( - true); + EnterIsolateIfNeeded()->set_ignore_out_of_memory(true); } @@ -404,7 +404,6 @@ ISOLATED_CLASS HandleScopeImplementer { entered_contexts_(0), saved_contexts_(0), spare_(NULL), - ignore_out_of_memory_(false), call_depth_(0) { } // Threading support for handle data. @@ -437,10 +436,6 @@ ISOLATED_CLASS HandleScopeImplementer { inline bool HasSavedContexts(); inline List<internal::Object**>* blocks() { return &blocks_; } - inline bool ignore_out_of_memory() { return ignore_out_of_memory_; } - inline void set_ignore_out_of_memory(bool value) { - ignore_out_of_memory_ = value; - } private: void ResetAfterArchive() { @@ -448,7 +443,6 @@ ISOLATED_CLASS HandleScopeImplementer { entered_contexts_.Initialize(0); saved_contexts_.Initialize(0); spare_ = NULL; - ignore_out_of_memory_ = false; call_depth_ = 0; } @@ -472,7 +466,6 @@ ISOLATED_CLASS HandleScopeImplementer { // Used as a stack to keep track of saved contexts. List<Context*> saved_contexts_; Object** spare_; - bool ignore_out_of_memory_; int call_depth_; // This is only used for threading support. v8::ImplementationUtilities::HandleScopeData handle_scope_data_; diff --git a/src/arm/lithium-codegen-arm.cc b/src/arm/lithium-codegen-arm.cc index 06f3a4eb..3dcd4278 100644 --- a/src/arm/lithium-codegen-arm.cc +++ b/src/arm/lithium-codegen-arm.cc @@ -1422,7 +1422,7 @@ void LCodeGen::DoBranch(LBranch* instr) { // Test the double value. Zero and NaN are false. __ VFPCompareAndLoadFlags(reg, 0.0, scratch); __ tst(scratch, Operand(kVFPZConditionFlagBit | kVFPVConditionFlagBit)); - EmitBranch(true_block, false_block, ne); + EmitBranch(true_block, false_block, eq); } else { ASSERT(r.IsTagged()); Register reg = ToRegister(instr->InputAt(0)); diff --git a/src/debug.cc b/src/debug.cc index 093f38ee..6f0431c9 100644 --- a/src/debug.cc +++ b/src/debug.cc @@ -1986,8 +1986,8 @@ void Debug::AfterGarbageCollection() { } -Debugger::Debugger() - : debugger_access_(OS::CreateMutex()), +Debugger::Debugger(Isolate* isolate) + : debugger_access_(isolate->debugger_access()), event_listener_(Handle<Object>()), event_listener_data_(Handle<Object>()), compiling_natives_(false), @@ -2003,13 +2003,12 @@ Debugger::Debugger() agent_(NULL), command_queue_(kQueueInitialSize), command_received_(OS::CreateSemaphore(0)), - event_command_queue_(kQueueInitialSize) { + event_command_queue_(kQueueInitialSize), + isolate_(isolate) { } Debugger::~Debugger() { - delete debugger_access_; - debugger_access_ = 0; delete dispatch_handler_access_; dispatch_handler_access_ = 0; delete command_received_; diff --git a/src/debug.h b/src/debug.h index 9366fc30..6be33a66 100644 --- a/src/debug.h +++ b/src/debug.h @@ -809,7 +809,7 @@ class Debugger { bool IsDebuggerActive(); private: - Debugger(); + explicit Debugger(Isolate* isolate); void CallEventCallback(v8::DebugEvent event, Handle<Object> exec_state, diff --git a/src/execution.cc b/src/execution.cc index eb26438f..7a2bbc67 100644 --- a/src/execution.cc +++ b/src/execution.cc @@ -132,7 +132,7 @@ static Handle<Object> Invoke(bool construct, if (*has_pending_exception) { isolate->ReportPendingMessages(); if (isolate->pending_exception() == Failure::OutOfMemoryException()) { - if (!isolate->handle_scope_implementer()->ignore_out_of_memory()) { + if (!isolate->ignore_out_of_memory()) { V8::FatalProcessOutOfMemory("JS", true); } } diff --git a/src/global-handles.h b/src/global-handles.h index a1a269ff..2171b2cf 100644 --- a/src/global-handles.h +++ b/src/global-handles.h @@ -32,8 +32,6 @@ #include "list-inl.h" -#include "../include/v8-profiler.h" - namespace v8 { namespace internal { diff --git a/src/heap.cc b/src/heap.cc index 0b4abf30..2b6c11f7 100644 --- a/src/heap.cc +++ b/src/heap.cc @@ -1518,7 +1518,6 @@ static void InitializeScavengingVisitorsTables() { void Heap::SwitchScavengingVisitorsTableIfProfilingWasEnabled() { -#ifdef ENABLE_LOGGING_AND_PROFILING if (scavenging_visitors_table_mode_ == LOGGING_AND_PROFILING_ENABLED) { // Table was already updated by some isolate. return; @@ -1544,7 +1543,6 @@ void Heap::SwitchScavengingVisitorsTableIfProfilingWasEnabled() { Release_Store(&scavenging_visitors_table_mode_, LOGGING_AND_PROFILING_ENABLED); } -#endif } diff --git a/src/isolate.cc b/src/isolate.cc index e42d78ec..5b3438f9 100644 --- a/src/isolate.cc +++ b/src/isolate.cc @@ -70,6 +70,7 @@ int ThreadId::GetCurrentThreadId() { return thread_id; } + // Create a dummy thread that will wait forever on a semaphore. The only // purpose for this thread is to have some stack area to save essential data // into for use by a stacks only core dump (aka minidump). @@ -323,7 +324,6 @@ void Isolate::EnsureDefaultIsolate() { // Can't use SetIsolateThreadLocals(default_isolate_, NULL) here // becase a non-null thread data may be already set. Thread::SetThreadLocal(isolate_key_, default_isolate_); - CHECK(default_isolate_->PreInit()); } @@ -417,11 +417,15 @@ Isolate::Isolate() bootstrapper_(NULL), runtime_profiler_(NULL), compilation_cache_(NULL), - counters_(new Counters()), + counters_(NULL), code_range_(NULL), + // Must be initialized early to allow v8::SetResourceConstraints calls. break_access_(OS::CreateMutex()), - logger_(new Logger()), - stats_table_(new StatsTable()), + debugger_initialized_(false), + // Must be initialized early to allow v8::Debug calls. + debugger_access_(OS::CreateMutex()), + logger_(NULL), + stats_table_(NULL), stub_cache_(NULL), deoptimizer_data_(NULL), capture_stack_trace_for_uncaught_exceptions_(false), @@ -463,6 +467,9 @@ Isolate::Isolate() simulator_redirection_ = NULL; #endif + thread_manager_ = new ThreadManager(); + thread_manager_->isolate_ = this; + #ifdef DEBUG // heap_histograms_ initializes itself. memset(&js_spill_information_, 0, sizeof(js_spill_information_)); @@ -548,7 +555,7 @@ void Isolate::Deinit() { logger_->TearDown(); // The default isolate is re-initializable due to legacy API. - state_ = PREINITIALIZED; + state_ = UNINITIALIZED; } } @@ -635,68 +642,6 @@ Isolate::~Isolate() { } -bool Isolate::PreInit() { - if (state_ != UNINITIALIZED) return true; - - TRACE_ISOLATE(preinit); - - ASSERT(Isolate::Current() == this); - -#ifdef ENABLE_DEBUGGER_SUPPORT - debug_ = new Debug(this); - debugger_ = new Debugger(); - debugger_->isolate_ = this; -#endif - - memory_allocator_ = new MemoryAllocator(); - memory_allocator_->isolate_ = this; - code_range_ = new CodeRange(); - code_range_->isolate_ = this; - - // Safe after setting Heap::isolate_, initializing StackGuard and - // ensuring that Isolate::Current() == this. - heap_.SetStackLimits(); - -#ifdef DEBUG - DisallowAllocationFailure disallow_allocation_failure; -#endif - -#define C(name) isolate_addresses_[Isolate::k_##name] = \ - reinterpret_cast<Address>(name()); - ISOLATE_ADDRESS_LIST(C) - ISOLATE_ADDRESS_LIST_PROF(C) -#undef C - - string_tracker_ = new StringTracker(); - string_tracker_->isolate_ = this; - thread_manager_ = new ThreadManager(); - thread_manager_->isolate_ = this; - compilation_cache_ = new CompilationCache(this); - transcendental_cache_ = new TranscendentalCache(); - keyed_lookup_cache_ = new KeyedLookupCache(); - context_slot_cache_ = new ContextSlotCache(); - descriptor_lookup_cache_ = new DescriptorLookupCache(); - unicode_cache_ = new UnicodeCache(); - pc_to_code_cache_ = new PcToCodeCache(this); - write_input_buffer_ = new StringInputBuffer(); - global_handles_ = new GlobalHandles(this); - bootstrapper_ = new Bootstrapper(); - handle_scope_implementer_ = new HandleScopeImplementer(); - stub_cache_ = new StubCache(this); - ast_sentinels_ = new AstSentinels(); - regexp_stack_ = new RegExpStack(); - regexp_stack_->isolate_ = this; - -#ifdef ENABLE_LOGGING_AND_PROFILING - producer_heap_profile_ = new ProducerHeapProfile(); - producer_heap_profile_->isolate_ = this; -#endif - - state_ = PREINITIALIZED; - return true; -} - - void Isolate::InitializeThreadLocal() { thread_local_top_.Initialize(); clear_pending_exception(); @@ -732,19 +677,77 @@ void Isolate::PropagatePendingExceptionToExternalTryCatch() { } +void Isolate::InitializeLoggingAndCounters() { + if (logger_ == NULL) { + logger_ = new Logger; + } + if (counters_ == NULL) { + counters_ = new Counters; + } +} + + +void Isolate::InitializeDebugger() { +#ifdef ENABLE_DEBUGGER_SUPPORT + ScopedLock lock(debugger_access_); + if (NoBarrier_Load(&debugger_initialized_)) return; + InitializeLoggingAndCounters(); + debug_ = new Debug(this); + debugger_ = new Debugger(this); + Release_Store(&debugger_initialized_, true); +#endif +} + + bool Isolate::Init(Deserializer* des) { ASSERT(state_ != INITIALIZED); - + ASSERT(Isolate::Current() == this); TRACE_ISOLATE(init); - bool create_heap_objects = des == NULL; - #ifdef DEBUG // The initialization process does not handle memory exhaustion. DisallowAllocationFailure disallow_allocation_failure; #endif - if (state_ == UNINITIALIZED && !PreInit()) return false; + InitializeLoggingAndCounters(); + + InitializeDebugger(); + + memory_allocator_ = new MemoryAllocator(this); + code_range_ = new CodeRange(this); + + // Safe after setting Heap::isolate_, initializing StackGuard and + // ensuring that Isolate::Current() == this. + heap_.SetStackLimits(); + +#define C(name) isolate_addresses_[Isolate::k_##name] = \ + reinterpret_cast<Address>(name()); + ISOLATE_ADDRESS_LIST(C) + ISOLATE_ADDRESS_LIST_PROF(C) +#undef C + + string_tracker_ = new StringTracker(); + string_tracker_->isolate_ = this; + compilation_cache_ = new CompilationCache(this); + transcendental_cache_ = new TranscendentalCache(); + keyed_lookup_cache_ = new KeyedLookupCache(); + context_slot_cache_ = new ContextSlotCache(); + descriptor_lookup_cache_ = new DescriptorLookupCache(); + unicode_cache_ = new UnicodeCache(); + pc_to_code_cache_ = new PcToCodeCache(this); + write_input_buffer_ = new StringInputBuffer(); + global_handles_ = new GlobalHandles(this); + bootstrapper_ = new Bootstrapper(); + handle_scope_implementer_ = new HandleScopeImplementer(); + stub_cache_ = new StubCache(this); + ast_sentinels_ = new AstSentinels(); + regexp_stack_ = new RegExpStack(); + regexp_stack_->isolate_ = this; + +#ifdef ENABLE_LOGGING_AND_PROFILING + producer_heap_profile_ = new ProducerHeapProfile(); + producer_heap_profile_->isolate_ = this; +#endif // Enable logging before setting up the heap logger_->Setup(); @@ -767,7 +770,8 @@ bool Isolate::Init(Deserializer* des) { stack_guard_.InitThread(lock); } - // Setup the object heap + // Setup the object heap. + const bool create_heap_objects = (des == NULL); ASSERT(!heap_.HasBeenSetup()); if (!heap_.Setup(create_heap_objects)) { V8::SetFatalError(); @@ -827,6 +831,16 @@ bool Isolate::Init(Deserializer* des) { } +// Initialized lazily to allow early +// v8::V8::SetAddHistogramSampleFunction calls. +StatsTable* Isolate::stats_table() { + if (stats_table_ == NULL) { + stats_table_ = new StatsTable; + } + return stats_table_; +} + + void Isolate::Enter() { Isolate* current_isolate = NULL; PerIsolateThreadData* current_data = CurrentPerIsolateThreadData(); @@ -866,8 +880,6 @@ void Isolate::Enter() { SetIsolateThreadLocals(this, data); - CHECK(PreInit()); - // In case it's the first time some thread enters the isolate. set_thread_id(data->thread_id()); } diff --git a/src/isolate.h b/src/isolate.h index 35ffcb44..167c8ef0 100644 --- a/src/isolate.h +++ b/src/isolate.h @@ -267,6 +267,9 @@ class ThreadLocalTop BASE_EMBEDDED { // Call back function to report unsafe JS accesses. v8::FailedAccessCheckCallback failed_access_check_callback_; + // Whether out of memory exceptions should be ignored. + bool ignore_out_of_memory_; + private: void InitializeInternal(); @@ -466,6 +469,13 @@ class Isolate { return reinterpret_cast<Isolate*>(Thread::GetThreadLocal(isolate_key_)); } + // Usually called by Init(), but can be called early e.g. to allow + // testing components that require logging but not the whole + // isolate. + // + // Safe to call more than once. + void InitializeLoggingAndCounters(); + bool Init(Deserializer* des); bool IsInitialized() { return state_ == INITIALIZED; } @@ -512,10 +522,12 @@ class Isolate { // switched to non-legacy behavior). static void EnterDefaultIsolate(); - // Debug. // Mutex for serializing access to break control structures. Mutex* break_access() { return break_access_; } + // Mutex for serializing access to debugger. + Mutex* debugger_access() { return debugger_access_; } + Address get_address_from_id(AddressId id); // Access to top context (where the current function object was created). @@ -676,6 +688,12 @@ class Isolate { // Tells whether the current context has experienced an out of memory // exception. bool is_out_of_memory(); + bool ignore_out_of_memory() { + return thread_local_top_.ignore_out_of_memory_; + } + void set_ignore_out_of_memory(bool value) { + thread_local_top_.ignore_out_of_memory_ = value; + } void PrintCurrentStackTrace(FILE* out); void PrintStackTrace(FILE* out, char* thread_data); @@ -784,14 +802,24 @@ class Isolate { #undef GLOBAL_CONTEXT_FIELD_ACCESSOR Bootstrapper* bootstrapper() { return bootstrapper_; } - Counters* counters() { return counters_; } + Counters* counters() { + // Call InitializeLoggingAndCounters() if logging is needed before + // the isolate is fully initialized. + ASSERT(counters_ != NULL); + return counters_; + } CodeRange* code_range() { return code_range_; } RuntimeProfiler* runtime_profiler() { return runtime_profiler_; } CompilationCache* compilation_cache() { return compilation_cache_; } - Logger* logger() { return logger_; } + Logger* logger() { + // Call InitializeLoggingAndCounters() if logging is needed before + // the isolate is fully initialized. + ASSERT(logger_ != NULL); + return logger_; + } StackGuard* stack_guard() { return &stack_guard_; } Heap* heap() { return &heap_; } - StatsTable* stats_table() { return stats_table_; } + StatsTable* stats_table(); StubCache* stub_cache() { return stub_cache_; } DeoptimizerData* deoptimizer_data() { return deoptimizer_data_; } ThreadLocalTop* thread_local_top() { return &thread_local_top_; } @@ -908,8 +936,14 @@ class Isolate { void PreallocatedStorageInit(size_t size); #ifdef ENABLE_DEBUGGER_SUPPORT - Debugger* debugger() { return debugger_; } - Debug* debug() { return debug_; } + Debugger* debugger() { + if (!NoBarrier_Load(&debugger_initialized_)) InitializeDebugger(); + return debugger_; + } + Debug* debug() { + if (!NoBarrier_Load(&debugger_initialized_)) InitializeDebugger(); + return debug_; + } #endif #ifdef ENABLE_LOGGING_AND_PROFILING @@ -1045,8 +1079,6 @@ class Isolate { static Isolate* default_isolate_; static ThreadDataTable* thread_data_table_; - bool PreInit(); - void Deinit(); static void SetIsolateThreadLocals(Isolate* isolate, @@ -1054,7 +1086,6 @@ class Isolate { enum State { UNINITIALIZED, // Some components may not have been allocated. - PREINITIALIZED, // Components have been allocated but not initialized. INITIALIZED // All components are fully initialized. }; @@ -1098,6 +1129,8 @@ class Isolate { void PropagatePendingExceptionToExternalTryCatch(); + void InitializeDebugger(); + int stack_trace_nesting_level_; StringStream* incomplete_message_; // The preallocated memory thread singleton. @@ -1111,6 +1144,8 @@ class Isolate { Counters* counters_; CodeRange* code_range_; Mutex* break_access_; + Atomic32 debugger_initialized_; + Mutex* debugger_access_; Heap heap_; Logger* logger_; StackGuard stack_guard_; @@ -1204,6 +1239,7 @@ class Isolate { friend class ExecutionAccess; friend class IsolateInitializer; friend class ThreadId; + friend class TestMemoryAllocatorScope; friend class v8::Isolate; friend class v8::Locker; @@ -1550,11 +1550,7 @@ bool Logger::Setup() { Sampler* Logger::sampler() { -#ifdef ENABLE_LOGGING_AND_PROFILING return ticker_; -#else - return NULL; -#endif } @@ -1631,10 +1627,8 @@ bool SamplerRegistry::IterateActiveSamplers(VisitSampler func, void* param) { static void ComputeCpuProfiling(Sampler* sampler, void* flag_ptr) { -#ifdef ENABLE_LOGGING_AND_PROFILING bool* flag = reinterpret_cast<bool*>(flag_ptr); *flag |= sampler->IsProfiling(); -#endif } diff --git a/src/objects.cc b/src/objects.cc index 8491d588..fac83f19 100644 --- a/src/objects.cc +++ b/src/objects.cc @@ -8342,7 +8342,8 @@ void JSObject::GetLocalPropertyNames(FixedArray* storage, int index) { } ASSERT(storage->length() >= index); } else { - property_dictionary()->CopyKeysTo(storage); + property_dictionary()->CopyKeysTo(storage, + index); } } @@ -8926,7 +8927,7 @@ template Object* Dictionary<NumberDictionaryShape, uint32_t>::DeleteProperty( int, JSObject::DeleteMode); template void Dictionary<StringDictionaryShape, String*>::CopyKeysTo( - FixedArray*); + FixedArray*, int); template int Dictionary<StringDictionaryShape, String*>::NumberOfElementsFilterAttributes( @@ -9982,11 +9983,11 @@ void StringDictionary::CopyEnumKeysTo(FixedArray* storage, template<typename Shape, typename Key> -void Dictionary<Shape, Key>::CopyKeysTo(FixedArray* storage) { +void Dictionary<Shape, Key>::CopyKeysTo( + FixedArray* storage, int index) { ASSERT(storage->length() >= NumberOfElementsFilterAttributes( static_cast<PropertyAttributes>(NONE))); int capacity = HashTable<Shape, Key>::Capacity(); - int index = 0; for (int i = 0; i < capacity; i++) { Object* k = HashTable<Shape, Key>::KeyAt(i); if (HashTable<Shape, Key>::IsKey(k)) { diff --git a/src/objects.h b/src/objects.h index e966b3de..bc8f42c1 100644 --- a/src/objects.h +++ b/src/objects.h @@ -2554,7 +2554,7 @@ class Dictionary: public HashTable<Shape, Key> { // Copies keys to preallocated fixed array. void CopyKeysTo(FixedArray* storage, PropertyAttributes filter); // Fill in details for properties into storage. - void CopyKeysTo(FixedArray* storage); + void CopyKeysTo(FixedArray* storage, int index); // Accessors for next enumeration index. void SetNextEnumerationIndex(int index) { diff --git a/src/runtime.cc b/src/runtime.cc index 7335da89..855bd41c 100644 --- a/src/runtime.cc +++ b/src/runtime.cc @@ -4339,9 +4339,10 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_GetLocalPropertyNames) { // Get the property names. jsproto = obj; int proto_with_hidden_properties = 0; + int next_copy_index = 0; for (int i = 0; i < length; i++) { - jsproto->GetLocalPropertyNames(*names, - i == 0 ? 0 : local_property_count[i - 1]); + jsproto->GetLocalPropertyNames(*names, next_copy_index); + next_copy_index += local_property_count[i]; if (!GetHiddenProperties(jsproto, false)->IsUndefined()) { proto_with_hidden_properties++; } diff --git a/src/spaces.cc b/src/spaces.cc index 674078c4..3db9306c 100644 --- a/src/spaces.cc +++ b/src/spaces.cc @@ -148,12 +148,12 @@ PageIterator::PageIterator(PagedSpace* space, Mode mode) : space_(space) { // CodeRange -CodeRange::CodeRange() - : code_range_(NULL), +CodeRange::CodeRange(Isolate* isolate) + : isolate_(isolate), + code_range_(NULL), free_list_(0), allocation_list_(0), - current_allocation_block_index_(0), - isolate_(NULL) { + current_allocation_block_index_(0) { } @@ -279,8 +279,9 @@ void CodeRange::TearDown() { const int kEstimatedNumberOfChunks = 270; -MemoryAllocator::MemoryAllocator() - : capacity_(0), +MemoryAllocator::MemoryAllocator(Isolate* isolate) + : isolate_(isolate), + capacity_(0), capacity_executable_(0), size_(0), size_executable_(0), @@ -288,8 +289,7 @@ MemoryAllocator::MemoryAllocator() chunks_(kEstimatedNumberOfChunks), free_chunk_ids_(kEstimatedNumberOfChunks), max_nof_chunks_(0), - top_(0), - isolate_(NULL) { + top_(0) { } diff --git a/src/spaces.h b/src/spaces.h index bd939d1e..f323f85e 100644 --- a/src/spaces.h +++ b/src/spaces.h @@ -413,6 +413,8 @@ class Space : public Malloced { // manages a range of virtual memory. class CodeRange { public: + explicit CodeRange(Isolate* isolate); + // Reserves a range of virtual memory, but does not commit any of it. // Can only be called once, at heap initialization time. // Returns false on failure. @@ -422,9 +424,9 @@ class CodeRange { // manage it. void TearDown(); - bool exists() { return code_range_ != NULL; } + bool exists() { return this != NULL && code_range_ != NULL; } bool contains(Address address) { - if (code_range_ == NULL) return false; + if (this == NULL || code_range_ == NULL) return false; Address start = static_cast<Address>(code_range_->address()); return start <= address && address < start + code_range_->size(); } @@ -437,7 +439,7 @@ class CodeRange { void FreeRawMemory(void* buf, size_t length); private: - CodeRange(); + Isolate* isolate_; // The reserved range of virtual memory that all code objects are put in. VirtualMemory* code_range_; @@ -471,10 +473,6 @@ class CodeRange { static int CompareFreeBlockAddress(const FreeBlock* left, const FreeBlock* right); - friend class Isolate; - - Isolate* isolate_; - DISALLOW_COPY_AND_ASSIGN(CodeRange); }; @@ -505,6 +503,8 @@ class CodeRange { class MemoryAllocator { public: + explicit MemoryAllocator(Isolate* isolate); + // Initializes its internal bookkeeping structures. // Max capacity of the total space and executable memory limit. bool Setup(intptr_t max_capacity, intptr_t capacity_executable); @@ -675,11 +675,11 @@ class MemoryAllocator { #endif private: - MemoryAllocator(); - static const int kChunkSize = kPagesPerChunk * Page::kPageSize; static const int kChunkSizeLog2 = kPagesPerChunkLog2 + kPageSizeBits; + Isolate* isolate_; + // Maximum space size in bytes. intptr_t capacity_; // Maximum subset of capacity_ that can be executable @@ -772,10 +772,6 @@ class MemoryAllocator { Page* prev, Page** last_page_in_use); - friend class Isolate; - - Isolate* isolate_; - DISALLOW_COPY_AND_ASSIGN(MemoryAllocator); }; @@ -47,6 +47,10 @@ namespace internal { ThreadLocalTop::ThreadLocalTop() { InitializeInternal(); + // This flag may be set using v8::V8::IgnoreOutOfMemoryException() + // before an isolate is initialized. The initialize methods below do + // not touch it to preserve its value. + ignore_out_of_memory_ = false; } @@ -327,6 +331,7 @@ void Isolate::PrintStack() { incomplete_message_ = &accumulator; PrintStack(&accumulator); accumulator.OutputToStdOut(); + InitializeLoggingAndCounters(); accumulator.Log(); incomplete_message_ = NULL; stack_trace_nesting_level_ = 0; @@ -947,11 +952,9 @@ Handle<Context> Isolate::GetCallingGlobalContext() { char* Isolate::ArchiveThread(char* to) { -#ifdef ENABLE_LOGGING_AND_PROFILING if (RuntimeProfiler::IsEnabled() && current_vm_state() == JS) { RuntimeProfiler::IsolateExitedJS(this); } -#endif memcpy(to, reinterpret_cast<char*>(thread_local_top()), sizeof(ThreadLocalTop)); InitializeThreadLocal(); @@ -971,11 +974,9 @@ char* Isolate::RestoreThread(char* from) { thread_local_top()->simulator_ = Simulator::current(this); #endif #endif -#ifdef ENABLE_LOGGING_AND_PROFILING if (RuntimeProfiler::IsEnabled() && current_vm_state() == JS) { RuntimeProfiler::IsolateEnteredJS(this); } -#endif return from + sizeof(ThreadLocalTop); } diff --git a/src/version.cc b/src/version.cc index 7e18e6d4..d72a3550 100644 --- a/src/version.cc +++ b/src/version.cc @@ -35,7 +35,7 @@ #define MAJOR_VERSION 3 #define MINOR_VERSION 2 #define BUILD_NUMBER 10 -#define PATCH_LEVEL 31 +#define PATCH_LEVEL 34 // Use 1 for candidates and 0 otherwise. // (Boolean macro values are not supported by all preprocessors.) #define IS_CANDIDATE_VERSION 0 |