diff options
Diffstat (limited to 'deps/v8/src/debug.cc')
-rw-r--r-- | deps/v8/src/debug.cc | 164 |
1 files changed, 96 insertions, 68 deletions
diff --git a/deps/v8/src/debug.cc b/deps/v8/src/debug.cc index 48c5519f79..7a876e71fd 100644 --- a/deps/v8/src/debug.cc +++ b/deps/v8/src/debug.cc @@ -261,8 +261,12 @@ void BreakLocationIterator::Reset() { // Create relocation iterators for the two code objects. if (reloc_iterator_ != NULL) delete reloc_iterator_; if (reloc_iterator_original_ != NULL) delete reloc_iterator_original_; - reloc_iterator_ = new RelocIterator(debug_info_->code()); - reloc_iterator_original_ = new RelocIterator(debug_info_->original_code()); + reloc_iterator_ = new RelocIterator( + debug_info_->code(), + ~RelocInfo::ModeMask(RelocInfo::CODE_AGE_SEQUENCE)); + reloc_iterator_original_ = new RelocIterator( + debug_info_->original_code(), + ~RelocInfo::ModeMask(RelocInfo::CODE_AGE_SEQUENCE)); // Position at the first break point. break_point_ = -1; @@ -385,8 +389,8 @@ void BreakLocationIterator::ClearDebugBreak() { } -void BreakLocationIterator::PrepareStepIn() { - HandleScope scope; +void BreakLocationIterator::PrepareStepIn(Isolate* isolate) { + HandleScope scope(isolate); // Step in can only be prepared if currently positioned on an IC call, // construct call or CallFunction stub call. @@ -613,10 +617,10 @@ void ScriptCache::Add(Handle<Script> script) { Handle<Script> script_ = Handle<Script>::cast( (global_handles->Create(*script))); - global_handles->MakeWeak( - reinterpret_cast<Object**>(script_.location()), - this, - ScriptCache::HandleWeakScript); + global_handles->MakeWeak(reinterpret_cast<Object**>(script_.location()), + this, + NULL, + ScriptCache::HandleWeakScript); entry->value = script_.location(); } @@ -659,7 +663,9 @@ void ScriptCache::Clear() { } -void ScriptCache::HandleWeakScript(v8::Persistent<v8::Value> obj, void* data) { +void ScriptCache::HandleWeakScript(v8::Isolate* isolate, + v8::Persistent<v8::Value> obj, + void* data) { ScriptCache* script_cache = reinterpret_cast<ScriptCache*>(data); // Find the location of the global handle. Script** location = @@ -672,7 +678,7 @@ void ScriptCache::HandleWeakScript(v8::Persistent<v8::Value> obj, void* data) { script_cache->collected_scripts_.Add(id); // Clear the weak handle. - obj.Dispose(); + obj.Dispose(isolate); obj.Clear(); } @@ -692,8 +698,10 @@ void Debug::SetUp(bool create_heap_objects) { } -void Debug::HandleWeakDebugInfo(v8::Persistent<v8::Value> obj, void* data) { - Debug* debug = Isolate::Current()->debug(); +void Debug::HandleWeakDebugInfo(v8::Isolate* isolate, + v8::Persistent<v8::Value> obj, + void* data) { + Debug* debug = reinterpret_cast<Isolate*>(isolate)->debug(); DebugInfoListNode* node = reinterpret_cast<DebugInfoListNode*>(data); // We need to clear all breakpoints associated with the function to restore // original code and avoid patching the code twice later because @@ -717,10 +725,10 @@ DebugInfoListNode::DebugInfoListNode(DebugInfo* debug_info): next_(NULL) { // Globalize the request debug info object and make it weak. debug_info_ = Handle<DebugInfo>::cast( (global_handles->Create(debug_info))); - global_handles->MakeWeak( - reinterpret_cast<Object**>(debug_info_.location()), - this, - Debug::HandleWeakDebugInfo); + global_handles->MakeWeak(reinterpret_cast<Object**>(debug_info_.location()), + this, + NULL, + Debug::HandleWeakDebugInfo); } @@ -770,8 +778,11 @@ bool Debug::CompileDebuggerScript(int index) { factory->NewFunctionFromSharedFunctionInfo(function_info, context); Handle<Object> exception = - Execution::TryCall(function, Handle<Object>(context->global_object()), - 0, NULL, &caught_exception); + Execution::TryCall(function, + Handle<Object>(context->global_object(), isolate), + 0, + NULL, + &caught_exception); // Check for caught exceptions. if (caught_exception) { @@ -782,9 +793,11 @@ bool Debug::CompileDebuggerScript(int index) { "error_loading_debugger", &computed_location, Vector<Handle<Object> >::empty(), Handle<String>(), Handle<JSArray>()); ASSERT(!isolate->has_pending_exception()); - isolate->set_pending_exception(*exception); - MessageHandler::ReportMessage(Isolate::Current(), NULL, message); - isolate->clear_pending_exception(); + if (!exception.is_null()) { + isolate->set_pending_exception(*exception); + MessageHandler::ReportMessage(Isolate::Current(), NULL, message); + isolate->clear_pending_exception(); + } return false; } @@ -817,7 +830,6 @@ bool Debug::Load() { HandleScope scope(isolate_); Handle<Context> context = isolate_->bootstrapper()->CreateEnvironment( - isolate_, Handle<Object>::null(), v8::Handle<ObjectTemplate>(), NULL); @@ -830,12 +842,16 @@ bool Debug::Load() { isolate_->set_context(*context); // Expose the builtins object in the debugger context. - Handle<String> key = isolate_->factory()->LookupAsciiSymbol("builtins"); + Handle<String> key = isolate_->factory()->InternalizeOneByteString( + STATIC_ASCII_VECTOR("builtins")); Handle<GlobalObject> global = Handle<GlobalObject>(context->global_object()); RETURN_IF_EMPTY_HANDLE_VALUE( isolate_, - JSReceiver::SetProperty(global, key, Handle<Object>(global->builtins()), - NONE, kNonStrictMode), + JSReceiver::SetProperty(global, + key, + Handle<Object>(global->builtins(), isolate_), + NONE, + kNonStrictMode), false); // Compile the JavaScript for the debugger in the debugger context. @@ -940,10 +956,10 @@ Object* Debug::Break(Arguments args) { // If there is one or more real break points check whether any of these are // triggered. - Handle<Object> break_points_hit(heap->undefined_value()); + Handle<Object> break_points_hit(heap->undefined_value(), isolate_); if (break_location_iterator.HasBreakPoint()) { Handle<Object> break_point_objects = - Handle<Object>(break_location_iterator.BreakPointObjects()); + Handle<Object>(break_location_iterator.BreakPointObjects(), isolate_); break_points_hit = CheckBreakPoints(break_point_objects); } @@ -1061,7 +1077,7 @@ Handle<Object> Debug::CheckBreakPoints(Handle<Object> break_point_objects) { Handle<FixedArray> array(FixedArray::cast(*break_point_objects)); break_points_hit = factory->NewFixedArray(array->length()); for (int i = 0; i < array->length(); i++) { - Handle<Object> o(array->get(i)); + Handle<Object> o(array->get(i), isolate_); if (CheckBreakPoint(o)) { break_points_hit->set(break_points_hit_count++, *o); } @@ -1093,12 +1109,13 @@ bool Debug::CheckBreakPoint(Handle<Object> break_point_object) { if (!break_point_object->IsJSObject()) return true; // Get the function IsBreakPointTriggered (defined in debug-debugger.js). - Handle<String> is_break_point_triggered_symbol = - factory->LookupAsciiSymbol("IsBreakPointTriggered"); + Handle<String> is_break_point_triggered_string = + factory->InternalizeOneByteString( + STATIC_ASCII_VECTOR("IsBreakPointTriggered")); Handle<JSFunction> check_break_point = Handle<JSFunction>(JSFunction::cast( debug_context()->global_object()->GetPropertyNoExceptionThrown( - *is_break_point_triggered_symbol))); + *is_break_point_triggered_string))); // Get the break id as an object. Handle<Object> break_id = factory->NewNumberFromInt(Debug::break_id()); @@ -1283,7 +1300,8 @@ void Debug::FloodWithOneShot(Handle<JSFunction> function) { void Debug::FloodBoundFunctionWithOneShot(Handle<JSFunction> function) { Handle<FixedArray> new_bindings(function->function_bindings()); - Handle<Object> bindee(new_bindings->get(JSFunction::kBoundFunctionIndex)); + Handle<Object> bindee(new_bindings->get(JSFunction::kBoundFunctionIndex), + isolate_); if (!bindee.is_null() && bindee->IsJSFunction() && !JSFunction::cast(*bindee)->IsBuiltin()) { @@ -1481,7 +1499,8 @@ void Debug::PrepareStep(StepAction step_action, int step_count) { // from the code object. Handle<Object> obj( isolate_->heap()->code_stubs()->SlowReverseLookup( - *call_function_stub)); + *call_function_stub), + isolate_); ASSERT(!obj.is_null()); ASSERT(!(*obj)->IsUndefined()); ASSERT(obj->IsSmi()); @@ -1535,7 +1554,7 @@ void Debug::PrepareStep(StepAction step_action, int step_count) { } // Step in or Step in min - it.PrepareStepIn(); + it.PrepareStepIn(isolate_); ActivateStepIn(frame); } } @@ -1579,7 +1598,7 @@ bool Debug::StepNextContinue(BreakLocationIterator* break_location_iterator, // object. bool Debug::IsDebugBreak(Address addr) { Code* code = Code::GetCodeFromTargetAddress(addr); - return code->ic_state() == DEBUG_BREAK; + return code->is_debug_break(); } @@ -1654,10 +1673,12 @@ Handle<Object> Debug::GetSourceBreakLocations( Handle<SharedFunctionInfo> shared) { Isolate* isolate = Isolate::Current(); Heap* heap = isolate->heap(); - if (!HasDebugInfo(shared)) return Handle<Object>(heap->undefined_value()); + if (!HasDebugInfo(shared)) { + return Handle<Object>(heap->undefined_value(), isolate); + } Handle<DebugInfo> debug_info = GetDebugInfo(shared); if (debug_info->GetBreakPointCount() == 0) { - return Handle<Object>(heap->undefined_value()); + return Handle<Object>(heap->undefined_value(), isolate); } Handle<FixedArray> locations = isolate->factory()->NewFixedArray(debug_info->GetBreakPointCount()); @@ -1692,9 +1713,10 @@ void Debug::HandleStepIn(Handle<JSFunction> function, Handle<Object> holder, Address fp, bool is_constructor) { + Isolate* isolate = function->GetIsolate(); // If the frame pointer is not supplied by the caller find it. if (fp == 0) { - StackFrameIterator it; + StackFrameIterator it(isolate); it.Advance(); // For constructor functions skip another frame. if (is_constructor) { @@ -1713,9 +1735,9 @@ void Debug::HandleStepIn(Handle<JSFunction> function, } else if (!function->IsBuiltin()) { // Don't allow step into functions in the native context. if (function->shared()->code() == - Isolate::Current()->builtins()->builtin(Builtins::kFunctionApply) || + isolate->builtins()->builtin(Builtins::kFunctionApply) || function->shared()->code() == - Isolate::Current()->builtins()->builtin(Builtins::kFunctionCall)) { + isolate->builtins()->builtin(Builtins::kFunctionCall)) { // Handle function.apply and function.call separately to flood the // function to be called and not the code for Builtins::FunctionApply or // Builtins::FunctionCall. The receiver of call/apply is the target @@ -1978,7 +2000,7 @@ void Debug::PrepareForBreakPoints() { // If preparing for the first break point make sure to deoptimize all // functions as debugging does not work with optimized code. if (!has_break_points_) { - Deoptimizer::DeoptimizeAll(); + Deoptimizer::DeoptimizeAll(isolate_); Handle<Code> lazy_compile = Handle<Code>(isolate_->builtins()->builtin(Builtins::kLazyCompile)); @@ -1993,14 +2015,15 @@ void Debug::PrepareForBreakPoints() { { // We are going to iterate heap to find all functions without // debug break slots. - isolate_->heap()->CollectAllGarbage(Heap::kMakeHeapIterableMask, - "preparing for breakpoints"); + Heap* heap = isolate_->heap(); + heap->CollectAllGarbage(Heap::kMakeHeapIterableMask, + "preparing for breakpoints"); // Ensure no GC in this scope as we are going to use gc_metadata // field in the Code object to mark active functions. AssertNoAllocation no_allocation; - Object* active_code_marker = isolate_->heap()->the_hole_value(); + Object* active_code_marker = heap->the_hole_value(); CollectActiveFunctionsFromThread(isolate_, isolate_->thread_local_top(), @@ -2014,7 +2037,7 @@ void Debug::PrepareForBreakPoints() { // Scan the heap for all non-optimized functions which have no // debug break slots and are not active or inlined into an active // function and mark them for lazy compilation. - HeapIterator iterator; + HeapIterator iterator(heap); HeapObject* obj = NULL; while (((obj = iterator.next()) != NULL)) { if (obj->IsJSFunction()) { @@ -2109,11 +2132,12 @@ Object* Debug::FindSharedFunctionInfoInScript(Handle<Script> script, int target_start_position = RelocInfo::kNoPosition; Handle<JSFunction> target_function; Handle<SharedFunctionInfo> target; + Heap* heap = isolate_->heap(); while (!done) { { // Extra scope for iterator and no-allocation. - isolate_->heap()->EnsureHeapIsIterable(); + heap->EnsureHeapIsIterable(); AssertNoAllocation no_alloc_during_heap_iteration; - HeapIterator iterator; + HeapIterator iterator(heap); for (HeapObject* obj = iterator.next(); obj != NULL; obj = iterator.next()) { bool found_next_candidate = false; @@ -2173,9 +2197,7 @@ Object* Debug::FindSharedFunctionInfoInScript(Handle<Script> script, } // End for loop. } // End no-allocation scope. - if (target.is_null()) { - return isolate_->heap()->undefined_value(); - } + if (target.is_null()) return heap->undefined_value(); // There will be at least one break point when we are done. has_break_points_ = true; @@ -2419,11 +2441,11 @@ void Debug::ClearMirrorCache() { ASSERT(isolate_->context() == *Debug::debug_context()); // Clear the mirror cache. - Handle<String> function_name = - isolate_->factory()->LookupSymbol(CStrVector("ClearMirrorCache")); + Handle<String> function_name = isolate_->factory()->InternalizeOneByteString( + STATIC_ASCII_VECTOR("ClearMirrorCache")); Handle<Object> fun( - Isolate::Current()->global_object()->GetPropertyNoExceptionThrown( - *function_name)); + isolate_->global_object()->GetPropertyNoExceptionThrown(*function_name), + isolate_); ASSERT(fun->IsJSFunction()); bool caught_exception; Execution::TryCall(Handle<JSFunction>::cast(fun), @@ -2449,7 +2471,7 @@ void Debug::CreateScriptCache() { // Scan heap for Script objects. int count = 0; - HeapIterator iterator; + HeapIterator iterator(heap); AssertNoAllocation no_allocation; for (HeapObject* obj = iterator.next(); obj != NULL; obj = iterator.next()) { @@ -2548,10 +2570,10 @@ Handle<Object> Debugger::MakeJSObject(Vector<const char> constructor_name, // Create the execution state object. Handle<String> constructor_str = - isolate_->factory()->LookupSymbol(constructor_name); + isolate_->factory()->InternalizeUtf8String(constructor_name); Handle<Object> constructor( - isolate_->global_object()->GetPropertyNoExceptionThrown( - *constructor_str)); + isolate_->global_object()->GetPropertyNoExceptionThrown(*constructor_str), + isolate_); ASSERT(constructor->IsJSFunction()); if (!constructor->IsJSFunction()) { *caught_exception = true; @@ -2639,7 +2661,7 @@ Handle<Object> Debugger::MakeScriptCollectedEvent(int id, bool* caught_exception) { // Create the script collected event object. Handle<Object> exec_state = MakeExecutionState(caught_exception); - Handle<Object> id_object = Handle<Smi>(Smi::FromInt(id)); + Handle<Object> id_object = Handle<Smi>(Smi::FromInt(id), isolate_); Handle<Object> argv[] = { exec_state, id_object }; return MakeJSObject(CStrVector("MakeScriptCollectedEvent"), @@ -2778,11 +2800,14 @@ void Debugger::OnAfterCompile(Handle<Script> script, // script. Make sure that these break points are set. // Get the function UpdateScriptBreakPoints (defined in debug-debugger.js). - Handle<String> update_script_break_points_symbol = - isolate_->factory()->LookupAsciiSymbol("UpdateScriptBreakPoints"); + Handle<String> update_script_break_points_string = + isolate_->factory()->InternalizeOneByteString( + STATIC_ASCII_VECTOR("UpdateScriptBreakPoints")); Handle<Object> update_script_break_points = - Handle<Object>(debug->debug_context()->global_object()-> - GetPropertyNoExceptionThrown(*update_script_break_points_symbol)); + Handle<Object>( + debug->debug_context()->global_object()->GetPropertyNoExceptionThrown( + *update_script_break_points_string), + isolate_); if (!update_script_break_points->IsJSFunction()) { return; } @@ -2932,7 +2957,7 @@ void Debugger::CallJSEventCallback(v8::DebugEvent event, Handle<JSFunction> fun(Handle<JSFunction>::cast(event_listener_)); // Invoke the JavaScript debug event listener. - Handle<Object> argv[] = { Handle<Object>(Smi::FromInt(event)), + Handle<Object> argv[] = { Handle<Object>(Smi::FromInt(event), isolate_), exec_state, event_data, event_listener_data_ }; @@ -3315,7 +3340,8 @@ Handle<Object> Debugger::Call(Handle<JSFunction> fun, Handle<Object> argv[] = { exec_state, data }; Handle<Object> result = Execution::Call( fun, - Handle<Object>(isolate_->debug()->debug_context_->global_proxy()), + Handle<Object>(isolate_->debug()->debug_context_->global_proxy(), + isolate_), ARRAY_SIZE(argv), argv, pending_exception); @@ -3541,7 +3567,8 @@ v8::Handle<v8::Object> MessageImpl::GetEventData() const { v8::Handle<v8::String> MessageImpl::GetJSON() const { - v8::HandleScope scope; + v8::HandleScope scope( + reinterpret_cast<v8::Isolate*>(event_data_->GetIsolate())); if (IsEvent()) { // Call toJSONProtocol on the debug event object. @@ -3758,6 +3785,7 @@ void MessageDispatchHelperThread::Schedule() { void MessageDispatchHelperThread::Run() { + Isolate* isolate = Isolate::Current(); while (true) { sem_->Wait(); { @@ -3765,8 +3793,8 @@ void MessageDispatchHelperThread::Run() { already_signalled_ = false; } { - Locker locker; - Isolate::Current()->debugger()->CallMessageDispatchHandler(); + Locker locker(reinterpret_cast<v8::Isolate*>(isolate)); + isolate->debugger()->CallMessageDispatchHandler(); } } } |