diff options
author | Michaƫl Zasso <mic.besace@gmail.com> | 2015-10-06 08:42:38 +0200 |
---|---|---|
committer | Ali Ijaz Sheikh <ofrobots@google.com> | 2015-10-14 11:20:34 -0700 |
commit | d8011d1683fe0d977de2bea1147f5213d4490c5a (patch) | |
tree | 54967df8dc1732e59eef39e5c5b39fe99ad88977 /deps/v8/src/isolate.cc | |
parent | d1a2e5357ef0357cec9b516fa9ac78cc38a984aa (diff) | |
download | node-new-d8011d1683fe0d977de2bea1147f5213d4490c5a.tar.gz |
deps: upgrade V8 to 4.6.85.23
PR-URL: https://github.com/nodejs/node/pull/3351
Reviewed-By: indutny - Fedor Indutny <fedor.indutny@gmail.com>
Reviewed-By: bnoordhuis - Ben Noordhuis <info@bnoordhuis.nl>
Diffstat (limited to 'deps/v8/src/isolate.cc')
-rw-r--r-- | deps/v8/src/isolate.cc | 131 |
1 files changed, 66 insertions, 65 deletions
diff --git a/deps/v8/src/isolate.cc b/deps/v8/src/isolate.cc index 2c83faac4f..155e9ead08 100644 --- a/deps/v8/src/isolate.cc +++ b/deps/v8/src/isolate.cc @@ -19,17 +19,18 @@ #include "src/compilation-cache.h" #include "src/compilation-statistics.h" #include "src/cpu-profiler.h" -#include "src/debug.h" +#include "src/debug/debug.h" #include "src/deoptimizer.h" -#include "src/heap/spaces.h" +#include "src/frames-inl.h" #include "src/heap-profiler.h" #include "src/hydrogen.h" #include "src/ic/stub-cache.h" +#include "src/interpreter/interpreter.h" #include "src/lithium-allocator.h" #include "src/log.h" #include "src/messages.h" #include "src/prototype.h" -#include "src/regexp-stack.h" +#include "src/regexp/regexp-stack.h" #include "src/runtime-profiler.h" #include "src/sampler.h" #include "src/scopeinfo.h" @@ -331,15 +332,12 @@ static bool IsVisibleInStackTrace(JSFunction* fun, Handle<Object> Isolate::CaptureSimpleStackTrace(Handle<JSObject> error_object, Handle<Object> caller) { // Get stack trace limit. - Handle<Object> error = Object::GetProperty( - this, js_builtins_object(), "$Error").ToHandleChecked(); - if (!error->IsJSObject()) return factory()->undefined_value(); - + Handle<JSObject> error = error_function(); Handle<String> stackTraceLimit = factory()->InternalizeUtf8String("stackTraceLimit"); DCHECK(!stackTraceLimit.is_null()); - Handle<Object> stack_trace_limit = JSReceiver::GetDataProperty( - Handle<JSObject>::cast(error), stackTraceLimit); + Handle<Object> stack_trace_limit = + JSReceiver::GetDataProperty(error, stackTraceLimit); if (!stack_trace_limit->IsNumber()) return factory()->undefined_value(); int limit = FastD2IChecked(stack_trace_limit->Number()); limit = Max(limit, 0); // Ensure that limit is not negative. @@ -847,17 +845,19 @@ Object* Isolate::StackOverflow() { // At this point we cannot create an Error object using its javascript // constructor. Instead, we copy the pre-constructed boilerplate and // attach the stack trace as a hidden property. - Handle<String> key = factory()->stack_overflow_string(); - Handle<Object> boilerplate = - Object::GetProperty(js_builtins_object(), key).ToHandleChecked(); - if (boilerplate->IsUndefined()) { - return Throw(heap()->undefined_value(), nullptr); - } - Handle<JSObject> exception = - factory()->CopyJSObject(Handle<JSObject>::cast(boilerplate)); + Handle<Object> exception; + if (bootstrapper()->IsActive()) { + // There is no boilerplate to use during bootstrapping. + exception = factory()->NewStringFromAsciiChecked( + MessageTemplate::TemplateString(MessageTemplate::kStackOverflow)); + } else { + Handle<JSObject> boilerplate = stack_overflow_boilerplate(); + Handle<JSObject> copy = factory()->CopyJSObject(boilerplate); + CaptureAndSetSimpleStackTrace(copy, factory()->undefined_value()); + exception = copy; + } Throw(*exception, nullptr); - CaptureAndSetSimpleStackTrace(exception, factory()->undefined_value()); #ifdef VERIFY_HEAP if (FLAG_verify_heap && FLAG_stress_compaction) { heap()->CollectAllAvailableGarbage("trigger compaction"); @@ -1013,21 +1013,13 @@ Object* Isolate::Throw(Object* exception, MessageLocation* location) { Handle<Object> message_obj = CreateMessage(exception_handle, location); thread_local_top()->pending_message_obj_ = *message_obj; - // For any exception not caught by JavaScript, even when an external - // handler is present: - // If the abort-on-uncaught-exception flag is specified, and if the - // embedder didn't specify a custom uncaught exception callback, - // or if the custom callback determined that V8 should abort, then - // abort. + // If the abort-on-uncaught-exception flag is specified, abort on any + // exception not caught by JavaScript, even when an external handler is + // present. This flag is intended for use by JavaScript developers, so + // print a user-friendly stack trace (not an internal one). if (FLAG_abort_on_uncaught_exception && - PredictExceptionCatcher() != CAUGHT_BY_JAVASCRIPT && - (!abort_on_uncaught_exception_callback_ || - abort_on_uncaught_exception_callback_( - reinterpret_cast<v8::Isolate*>(this)))) { - // Prevent endless recursion. - FLAG_abort_on_uncaught_exception = false; - // This flag is intended for use by JavaScript developers, so - // print a user-friendly stack trace (not an internal one). + PredictExceptionCatcher() != CAUGHT_BY_JAVASCRIPT) { + FLAG_abort_on_uncaught_exception = false; // Prevent endless recursion. PrintF(stderr, "%s\n\nFROM\n", MessageHandler::GetLocalizedMessage(this, message_obj).get()); PrintCurrentStackTrace(stderr); @@ -1351,12 +1343,7 @@ bool Isolate::ComputeLocationFromStackTrace(MessageLocation* target, // the Error object. bool Isolate::IsErrorObject(Handle<Object> obj) { if (!obj->IsJSObject()) return false; - - Handle<String> error_key = - factory()->InternalizeOneByteString(STATIC_CHAR_VECTOR("$Error")); - Handle<Object> error_constructor = Object::GetProperty( - js_builtins_object(), error_key).ToHandleChecked(); - + Handle<Object> error_constructor = error_function(); DisallowHeapAllocation no_gc; for (PrototypeIterator iter(this, *obj, PrototypeIterator::START_AT_RECEIVER); !iter.IsAtEnd(); iter.Advance()) { @@ -1620,12 +1607,6 @@ void Isolate::SetCaptureStackTraceForUncaughtExceptions( } -void Isolate::SetAbortOnUncaughtExceptionCallback( - v8::Isolate::AbortOnUncaughtExceptionCallback callback) { - abort_on_uncaught_exception_callback_ = callback; -} - - Handle<Context> Isolate::native_context() { return handle(context()->native_context()); } @@ -1773,15 +1754,12 @@ Isolate::Isolate(bool enable_serializer) eternal_handles_(NULL), thread_manager_(NULL), has_installed_extensions_(false), - string_tracker_(NULL), regexp_stack_(NULL), date_cache_(NULL), call_descriptor_data_(NULL), // TODO(bmeurer) Initialized lazily because it depends on flags; can // be fixed once the default isolate cleanup is done. random_number_generator_(NULL), - store_buffer_hash_set_1_address_(NULL), - store_buffer_hash_set_2_address_(NULL), serializer_enabled_(enable_serializer), has_fatal_error_(false), initialized_from_snapshot_(false), @@ -1796,8 +1774,7 @@ Isolate::Isolate(bool enable_serializer) next_unique_sfi_id_(0), #endif use_counter_callback_(NULL), - basic_block_profiler_(NULL), - abort_on_uncaught_exception_callback_(NULL) { + basic_block_profiler_(NULL) { { base::LockGuard<base::Mutex> lock_guard(thread_data_table_mutex_.Pointer()); CHECK(thread_data_table_); @@ -1906,6 +1883,9 @@ void Isolate::Deinit() { Sampler* sampler = logger_->sampler(); if (sampler && sampler->IsActive()) sampler->Stop(); + delete interpreter_; + interpreter_ = NULL; + delete deoptimizer_data_; deoptimizer_data_ = NULL; builtins_.TearDown(); @@ -1919,6 +1899,11 @@ void Isolate::Deinit() { delete basic_block_profiler_; basic_block_profiler_ = NULL; + for (Cancelable* task : cancelable_tasks_) { + task->Cancel(); + } + cancelable_tasks_.clear(); + heap_.TearDown(); logger_->TearDown(); @@ -2001,9 +1986,6 @@ Isolate::~Isolate() { delete thread_manager_; thread_manager_ = NULL; - delete string_tracker_; - string_tracker_ = NULL; - delete memory_allocator_; memory_allocator_ = NULL; delete code_range_; @@ -2110,8 +2092,6 @@ bool Isolate::Init(Deserializer* des) { FOR_EACH_ISOLATE_ADDRESS_NAME(ASSIGN_ELEMENT) #undef ASSIGN_ELEMENT - string_tracker_ = new StringTracker(); - string_tracker_->isolate_ = this; compilation_cache_ = new CompilationCache(this); keyed_lookup_cache_ = new KeyedLookupCache(); context_slot_cache_ = new ContextSlotCache(); @@ -2131,6 +2111,7 @@ bool Isolate::Init(Deserializer* des) { new CallInterfaceDescriptorData[CallDescriptors::NUMBER_OF_DESCRIPTORS]; cpu_profiler_ = new CpuProfiler(this); heap_profiler_ = new HeapProfiler(heap()); + interpreter_ = new interpreter::Interpreter(this); // Enable logging before setting up the heap logger_->SetUp(this); @@ -2192,12 +2173,22 @@ bool Isolate::Init(Deserializer* des) { // occur, clearing/updating ICs. runtime_profiler_ = new RuntimeProfiler(this); + if (create_heap_objects) { + if (!bootstrapper_->CreateCodeStubContext(this)) { + return false; + } + } + // If we are deserializing, read the state into the now-empty heap. if (!create_heap_objects) { des->Deserialize(this); } stub_cache_->Initialize(); + if (FLAG_ignition) { + interpreter_->Initialize(); + } + // Finish initialization of ThreadLocal after deserialization is done. clear_pending_exception(); clear_pending_message(); @@ -2446,7 +2437,9 @@ bool Isolate::IsFastArrayConstructorPrototypeChainIntact() { return cell_reports_intact; } - if (initial_array_proto->elements() != heap()->empty_fixed_array()) { + FixedArrayBase* elements = initial_array_proto->elements(); + if (elements != heap()->empty_fixed_array() && + elements != heap()->empty_slow_element_dictionary()) { DCHECK_EQ(false, cell_reports_intact); return cell_reports_intact; } @@ -2457,7 +2450,10 @@ bool Isolate::IsFastArrayConstructorPrototypeChainIntact() { DCHECK_EQ(false, cell_reports_intact); return cell_reports_intact; } - if (initial_object_proto->elements() != heap()->empty_fixed_array()) { + + elements = initial_object_proto->elements(); + if (elements != heap()->empty_fixed_array() && + elements != heap()->empty_slow_element_dictionary()) { DCHECK_EQ(false, cell_reports_intact); return cell_reports_intact; } @@ -2633,7 +2629,7 @@ void Isolate::EnqueueMicrotask(Handle<Object> microtask) { queue = factory()->NewFixedArray(8); heap()->set_microtask_queue(*queue); } else if (num_tasks == queue->length()) { - queue = FixedArray::CopySize(queue, num_tasks * 2); + queue = factory()->CopyFixedArrayAndGrow(queue, num_tasks); heap()->set_microtask_queue(*queue); } DCHECK(queue->get(num_tasks)->IsUndefined()); @@ -2643,13 +2639,6 @@ void Isolate::EnqueueMicrotask(Handle<Object> microtask) { void Isolate::RunMicrotasks() { - // %RunMicrotasks may be called in mjsunit tests, which violates - // this assertion, hence the check for --allow-natives-syntax. - // TODO(adamk): However, this also fails some layout tests. - // - // DCHECK(FLAG_allow_natives_syntax || - // handle_scope_implementer()->CallDepthIsZero()); - // Increase call depth to prevent recursive callbacks. v8::Isolate::SuppressMicrotaskExecutionScope suppress( reinterpret_cast<v8::Isolate*>(this)); @@ -2741,7 +2730,7 @@ void Isolate::AddDetachedContext(Handle<Context> context) { Handle<WeakCell> cell = factory()->NewWeakCell(context); Handle<FixedArray> detached_contexts(heap()->detached_contexts()); int length = detached_contexts->length(); - detached_contexts = FixedArray::CopySize(detached_contexts, length + 2); + detached_contexts = factory()->CopyFixedArrayAndGrow(detached_contexts, 2); detached_contexts->set(length, Smi::FromInt(0)); detached_contexts->set(length + 1, *cell); heap()->set_detached_contexts(*detached_contexts); @@ -2787,6 +2776,18 @@ void Isolate::CheckDetachedContextsAfterGC() { } +void Isolate::RegisterCancelableTask(Cancelable* task) { + cancelable_tasks_.insert(task); +} + + +void Isolate::RemoveCancelableTask(Cancelable* task) { + auto removed = cancelable_tasks_.erase(task); + USE(removed); + DCHECK(removed == 1); +} + + bool StackLimitCheck::JsHasOverflowed(uintptr_t gap) const { StackGuard* stack_guard = isolate_->stack_guard(); #ifdef USE_SIMULATOR |