diff options
Diffstat (limited to 'deps/v8/src/isolate.cc')
-rw-r--r-- | deps/v8/src/isolate.cc | 109 |
1 files changed, 47 insertions, 62 deletions
diff --git a/deps/v8/src/isolate.cc b/deps/v8/src/isolate.cc index 1b44ee6834..3fff6b2ef7 100644 --- a/deps/v8/src/isolate.cc +++ b/deps/v8/src/isolate.cc @@ -2,13 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "src/isolate.h" + #include <stdlib.h> #include <fstream> // NOLINT(readability/streams) #include <sstream> -#include "src/v8.h" - #include "src/ast.h" #include "src/base/platform/platform.h" #include "src/base/sys-info.h" @@ -18,24 +18,25 @@ #include "src/codegen.h" #include "src/compilation-cache.h" #include "src/compilation-statistics.h" -#include "src/cpu-profiler.h" #include "src/debug/debug.h" #include "src/deoptimizer.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/isolate-inl.h" #include "src/lithium-allocator.h" #include "src/log.h" #include "src/messages.h" +#include "src/profiler/cpu-profiler.h" +#include "src/profiler/sampler.h" #include "src/prototype.h" #include "src/regexp/regexp-stack.h" #include "src/runtime-profiler.h" -#include "src/sampler.h" #include "src/scopeinfo.h" #include "src/simulator.h" #include "src/snapshot/serialize.h" +#include "src/v8.h" #include "src/version.h" #include "src/vm-state-inl.h" @@ -312,18 +313,13 @@ static bool IsVisibleInStackTrace(JSFunction* fun, } // Skip all frames until we've seen the caller. if (!(*seen_caller)) return false; - // Also, skip non-visible built-in functions and any call with the builtins - // object as receiver, so as to not reveal either the builtins object or - // an internal function. + // Functions defined in native scripts are not visible unless directly + // exposed, in which case the native flag is set. // The --builtins-in-stack-traces command line flag allows including // internal call sites in the stack trace for debugging purposes. if (!FLAG_builtins_in_stack_traces) { if (receiver->IsJSBuiltinsObject()) return false; - if (fun->IsBuiltin()) { - return fun->shared()->native(); - } else if (!fun->IsSubjectToDebugging()) { - return false; - } + if (fun->IsBuiltin()) return fun->shared()->native(); } return true; } @@ -504,7 +500,7 @@ class CaptureStackTraceHelper { Handle<Script> script(Script::cast(fun->shared()->script())); if (!line_key_.is_null()) { - int script_line_offset = script->line_offset()->value(); + int script_line_offset = script->line_offset(); int line_number = Script::GetLineNumber(script, position); // line_number is already shifted by the script_line_offset. int relative_line_number = line_number - script_line_offset; @@ -516,7 +512,7 @@ class CaptureStackTraceHelper { if (relative_line_number == 0) { // For the case where the code is on the same line as the script // tag. - column_offset += script->column_offset()->value(); + column_offset += script->column_offset(); } JSObject::AddProperty(stack_frame, column_key_, handle(Smi::FromInt(column_offset + 1), isolate_), @@ -529,7 +525,7 @@ class CaptureStackTraceHelper { if (!script_id_key_.is_null()) { JSObject::AddProperty(stack_frame, script_id_key_, - handle(script->id(), isolate_), NONE); + handle(Smi::FromInt(script->id()), isolate_), NONE); } if (!script_name_key_.is_null()) { @@ -997,11 +993,10 @@ Object* Isolate::Throw(Object* exception, MessageLocation* location) { // Generate the message if required. if (requires_message && !rethrowing_message) { - MessageLocation potential_computed_location; - if (location == NULL) { - // If no location was specified we use a computed one instead. - ComputeLocation(&potential_computed_location); - location = &potential_computed_location; + MessageLocation computed_location; + // If no location was specified we try to use a computed one instead. + if (location == NULL && ComputeLocation(&computed_location)) { + location = &computed_location; } if (bootstrapper()->IsActive()) { @@ -1013,21 +1008,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); @@ -1270,8 +1257,7 @@ void Isolate::PrintCurrentStackTrace(FILE* out) { } -void Isolate::ComputeLocation(MessageLocation* target) { - *target = MessageLocation(Handle<Script>(heap_.empty_script()), -1, -1); +bool Isolate::ComputeLocation(MessageLocation* target) { StackTraceFrameIterator it(this); if (!it.done()) { JavaScriptFrame* frame = it.frame(); @@ -1288,8 +1274,10 @@ void Isolate::ComputeLocation(MessageLocation* target) { FrameSummary& summary = frames.last(); int pos = summary.code()->SourcePosition(summary.pc()); *target = MessageLocation(casted_script, pos, pos + 1, handle(fun)); + return true; } } + return false; } @@ -1322,8 +1310,6 @@ bool Isolate::ComputeLocationFromException(MessageLocation* target, bool Isolate::ComputeLocationFromStackTrace(MessageLocation* target, Handle<Object> exception) { - *target = MessageLocation(Handle<Script>(heap_.empty_script()), -1, -1); - if (!exception->IsJSObject()) return false; Handle<Name> key = factory()->stack_trace_symbol(); Handle<Object> property = @@ -1361,7 +1347,7 @@ bool Isolate::IsErrorObject(Handle<Object> obj) { for (PrototypeIterator iter(this, *obj, PrototypeIterator::START_AT_RECEIVER); !iter.IsAtEnd(); iter.Advance()) { if (iter.GetCurrent()->IsJSProxy()) return false; - if (JSObject::cast(iter.GetCurrent())->map()->GetConstructor() == + if (iter.GetCurrent<JSObject>()->map()->GetConstructor() == *error_constructor) { return true; } @@ -1373,7 +1359,6 @@ bool Isolate::IsErrorObject(Handle<Object> obj) { Handle<JSMessageObject> Isolate::CreateMessage(Handle<Object> exception, MessageLocation* location) { Handle<JSArray> stack_trace_object; - MessageLocation potential_computed_location; if (capture_stack_trace_for_uncaught_exceptions_) { if (IsErrorObject(exception)) { // We fetch the stack trace that corresponds to this error object. @@ -1390,15 +1375,12 @@ Handle<JSMessageObject> Isolate::CreateMessage(Handle<Object> exception, stack_trace_for_uncaught_exceptions_options_); } } - if (!location) { - if (!ComputeLocationFromException(&potential_computed_location, - exception)) { - if (!ComputeLocationFromStackTrace(&potential_computed_location, - exception)) { - ComputeLocation(&potential_computed_location); - } - } - location = &potential_computed_location; + MessageLocation computed_location; + if (location == NULL && + (ComputeLocationFromException(&computed_location, exception) || + ComputeLocationFromStackTrace(&computed_location, exception) || + ComputeLocation(&computed_location))) { + location = &computed_location; } return MessageHandler::MakeMessageObject( @@ -1620,12 +1602,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()); } @@ -1788,13 +1764,13 @@ Isolate::Isolate(bool enable_serializer) deferred_handles_head_(NULL), optimizing_compile_dispatcher_(NULL), stress_deopt_count_(0), + vector_store_virtual_register_(NULL), next_optimization_id_(0), #if TRACE_MAPS 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_); @@ -2098,7 +2074,7 @@ bool Isolate::Init(Deserializer* des) { } // The initialization process does not handle memory exhaustion. - DisallowAllocationFailure disallow_allocation_failure(this); + AlwaysAllocateScope always_allocate(this); memory_allocator_ = new MemoryAllocator(this); code_range_ = new CodeRange(this); @@ -2580,9 +2556,6 @@ Handle<JSObject> Isolate::GetSymbolRegistry() { SetUpSubregistry(registry, map, "for"); SetUpSubregistry(registry, map, "for_api"); SetUpSubregistry(registry, map, "keyFor"); - SetUpSubregistry(registry, map, "private_api"); - heap()->AddPrivateGlobalSymbols( - SetUpSubregistry(registry, map, "private_intern")); } return Handle<JSObject>::cast(factory()->symbol_registry()); } @@ -2831,6 +2804,18 @@ SaveContext::SaveContext(Isolate* isolate) } +SaveContext::~SaveContext() { + isolate_->set_context(context_.is_null() ? NULL : *context_); + isolate_->set_save_context(prev_); +} + + +#ifdef DEBUG +AssertNoContextChange::AssertNoContextChange(Isolate* isolate) + : isolate_(isolate), context_(isolate->context(), isolate) {} +#endif // DEBUG + + bool PostponeInterruptsScope::Intercept(StackGuard::InterruptFlag flag) { // First check whether the previous scope intercepts. if (prev_ && prev_->Intercept(flag)) return true; |