OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "src/api.h" | 7 #include "src/api.h" |
8 #include "src/arguments.h" | 8 #include "src/arguments.h" |
9 #include "src/bootstrapper.h" | 9 #include "src/bootstrapper.h" |
10 #include "src/code-stubs.h" | 10 #include "src/code-stubs.h" |
(...skipping 741 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
752 return false; | 752 return false; |
753 } | 753 } |
754 | 754 |
755 // Execute the shared function in the debugger context. | 755 // Execute the shared function in the debugger context. |
756 Handle<JSFunction> function = | 756 Handle<JSFunction> function = |
757 factory->NewFunctionFromSharedFunctionInfo(function_info, context); | 757 factory->NewFunctionFromSharedFunctionInfo(function_info, context); |
758 | 758 |
759 Handle<Object> exception; | 759 Handle<Object> exception; |
760 MaybeHandle<Object> result = | 760 MaybeHandle<Object> result = |
761 Execution::TryCall(function, | 761 Execution::TryCall(function, |
762 Handle<Object>(context->global_object(), isolate), | 762 handle(context->global_proxy()), |
763 0, | 763 0, |
764 NULL, | 764 NULL, |
765 &exception); | 765 &exception); |
766 | 766 |
767 // Check for caught exceptions. | 767 // Check for caught exceptions. |
768 if (result.is_null()) { | 768 if (result.is_null()) { |
769 ASSERT(!isolate->has_pending_exception()); | 769 ASSERT(!isolate->has_pending_exception()); |
770 MessageLocation computed_location; | 770 MessageLocation computed_location; |
771 isolate->ComputeLocation(&computed_location); | 771 isolate->ComputeLocation(&computed_location); |
772 Handle<Object> message = MessageHandler::MakeMessageObject( | 772 Handle<Object> message = MessageHandler::MakeMessageObject( |
(...skipping 27 matching lines...) Expand all Loading... |
800 // Disable breakpoints and interrupts while compiling and running the | 800 // Disable breakpoints and interrupts while compiling and running the |
801 // debugger scripts including the context creation code. | 801 // debugger scripts including the context creation code. |
802 DisableBreak disable(this, true); | 802 DisableBreak disable(this, true); |
803 PostponeInterruptsScope postpone(isolate_); | 803 PostponeInterruptsScope postpone(isolate_); |
804 | 804 |
805 // Create the debugger context. | 805 // Create the debugger context. |
806 HandleScope scope(isolate_); | 806 HandleScope scope(isolate_); |
807 ExtensionConfiguration no_extensions; | 807 ExtensionConfiguration no_extensions; |
808 Handle<Context> context = | 808 Handle<Context> context = |
809 isolate_->bootstrapper()->CreateEnvironment( | 809 isolate_->bootstrapper()->CreateEnvironment( |
810 Handle<Object>::null(), | 810 MaybeHandle<JSGlobalProxy>(), |
811 v8::Handle<ObjectTemplate>(), | 811 v8::Handle<ObjectTemplate>(), |
812 &no_extensions); | 812 &no_extensions); |
813 | 813 |
814 // Fail if no context could be created. | 814 // Fail if no context could be created. |
815 if (context.is_null()) return false; | 815 if (context.is_null()) return false; |
816 | 816 |
817 // Use the debugger context. | 817 // Use the debugger context. |
818 SaveContext save(isolate_); | 818 SaveContext save(isolate_); |
819 isolate_->set_context(*context); | 819 isolate_->set_context(*context); |
820 | 820 |
(...skipping 1618 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2439 bool Debug::IsDebugGlobal(GlobalObject* global) { | 2439 bool Debug::IsDebugGlobal(GlobalObject* global) { |
2440 return is_loaded() && global == debug_context()->global_object(); | 2440 return is_loaded() && global == debug_context()->global_object(); |
2441 } | 2441 } |
2442 | 2442 |
2443 | 2443 |
2444 void Debug::ClearMirrorCache() { | 2444 void Debug::ClearMirrorCache() { |
2445 PostponeInterruptsScope postpone(isolate_); | 2445 PostponeInterruptsScope postpone(isolate_); |
2446 HandleScope scope(isolate_); | 2446 HandleScope scope(isolate_); |
2447 AssertDebugContext(); | 2447 AssertDebugContext(); |
2448 Factory* factory = isolate_->factory(); | 2448 Factory* factory = isolate_->factory(); |
2449 JSObject::SetProperty(isolate_->global_object(), | 2449 Handle<GlobalObject> global(isolate_->global_object()); |
| 2450 JSObject::SetProperty(global, |
2450 factory->NewStringFromAsciiChecked("next_handle_"), | 2451 factory->NewStringFromAsciiChecked("next_handle_"), |
2451 handle(Smi::FromInt(0), isolate_), | 2452 handle(Smi::FromInt(0), isolate_), |
2452 NONE, | 2453 NONE, |
2453 SLOPPY).Check(); | 2454 SLOPPY).Check(); |
2454 JSObject::SetProperty(isolate_->global_object(), | 2455 JSObject::SetProperty(global, |
2455 factory->NewStringFromAsciiChecked("mirror_cache_"), | 2456 factory->NewStringFromAsciiChecked("mirror_cache_"), |
2456 factory->NewJSArray(0, FAST_ELEMENTS), | 2457 factory->NewJSArray(0, FAST_ELEMENTS), |
2457 NONE, | 2458 NONE, |
2458 SLOPPY).Check(); | 2459 SLOPPY).Check(); |
2459 } | 2460 } |
2460 | 2461 |
2461 | 2462 |
2462 Handle<FixedArray> Debug::GetLoadedScripts() { | 2463 Handle<FixedArray> Debug::GetLoadedScripts() { |
2463 // Create and fill the script cache when the loaded scripts is requested for | 2464 // Create and fill the script cache when the loaded scripts is requested for |
2464 // the first time. | 2465 // the first time. |
(...skipping 22 matching lines...) Expand all Loading... |
2487 script->set_eval_from_instructions_offset(Smi::FromInt(offset)); | 2488 script->set_eval_from_instructions_offset(Smi::FromInt(offset)); |
2488 } | 2489 } |
2489 } | 2490 } |
2490 | 2491 |
2491 | 2492 |
2492 MaybeHandle<Object> Debug::MakeJSObject(const char* constructor_name, | 2493 MaybeHandle<Object> Debug::MakeJSObject(const char* constructor_name, |
2493 int argc, | 2494 int argc, |
2494 Handle<Object> argv[]) { | 2495 Handle<Object> argv[]) { |
2495 AssertDebugContext(); | 2496 AssertDebugContext(); |
2496 // Create the execution state object. | 2497 // Create the execution state object. |
| 2498 Handle<GlobalObject> global(isolate_->global_object()); |
2497 Handle<Object> constructor = Object::GetProperty( | 2499 Handle<Object> constructor = Object::GetProperty( |
2498 isolate_, isolate_->global_object(), constructor_name).ToHandleChecked(); | 2500 isolate_, global, constructor_name).ToHandleChecked(); |
2499 ASSERT(constructor->IsJSFunction()); | 2501 ASSERT(constructor->IsJSFunction()); |
2500 if (!constructor->IsJSFunction()) return MaybeHandle<Object>(); | 2502 if (!constructor->IsJSFunction()) return MaybeHandle<Object>(); |
2501 // We do not handle interrupts here. In particular, termination interrupts. | 2503 // We do not handle interrupts here. In particular, termination interrupts. |
2502 PostponeInterruptsScope no_interrupts(isolate_); | 2504 PostponeInterruptsScope no_interrupts(isolate_); |
2503 return Execution::TryCall(Handle<JSFunction>::cast(constructor), | 2505 return Execution::TryCall(Handle<JSFunction>::cast(constructor), |
2504 Handle<JSObject>(debug_context()->global_object()), | 2506 handle(debug_context()->global_proxy()), |
2505 argc, | 2507 argc, |
2506 argv); | 2508 argv); |
2507 } | 2509 } |
2508 | 2510 |
2509 | 2511 |
2510 MaybeHandle<Object> Debug::MakeExecutionState() { | 2512 MaybeHandle<Object> Debug::MakeExecutionState() { |
2511 // Create the execution state object. | 2513 // Create the execution state object. |
2512 Handle<Object> argv[] = { isolate_->factory()->NewNumberFromInt(break_id()) }; | 2514 Handle<Object> argv[] = { isolate_->factory()->NewNumberFromInt(break_id()) }; |
2513 return MakeJSObject("MakeExecutionState", ARRAY_SIZE(argv), argv); | 2515 return MakeJSObject("MakeExecutionState", ARRAY_SIZE(argv), argv); |
2514 } | 2516 } |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2744 client_data); | 2746 client_data); |
2745 callback(event_details); | 2747 callback(event_details); |
2746 ASSERT(!isolate_->has_scheduled_exception()); | 2748 ASSERT(!isolate_->has_scheduled_exception()); |
2747 } else { | 2749 } else { |
2748 // Invoke the JavaScript debug event listener. | 2750 // Invoke the JavaScript debug event listener. |
2749 ASSERT(event_listener_->IsJSFunction()); | 2751 ASSERT(event_listener_->IsJSFunction()); |
2750 Handle<Object> argv[] = { Handle<Object>(Smi::FromInt(event), isolate_), | 2752 Handle<Object> argv[] = { Handle<Object>(Smi::FromInt(event), isolate_), |
2751 exec_state, | 2753 exec_state, |
2752 event_data, | 2754 event_data, |
2753 event_listener_data_ }; | 2755 event_listener_data_ }; |
| 2756 Handle<JSReceiver> global(isolate_->global_proxy()); |
2754 Execution::TryCall(Handle<JSFunction>::cast(event_listener_), | 2757 Execution::TryCall(Handle<JSFunction>::cast(event_listener_), |
2755 isolate_->global_object(), | 2758 global, ARRAY_SIZE(argv), argv); |
2756 ARRAY_SIZE(argv), | |
2757 argv); | |
2758 } | 2759 } |
2759 } | 2760 } |
2760 | 2761 |
2761 | 2762 |
2762 Handle<Context> Debug::GetDebugContext() { | 2763 Handle<Context> Debug::GetDebugContext() { |
2763 DebugScope debug_scope(this); | 2764 DebugScope debug_scope(this); |
2764 // The global handle may be destroyed soon after. Return it reboxed. | 2765 // The global handle may be destroyed soon after. Return it reboxed. |
2765 return handle(*debug_context(), isolate_); | 2766 return handle(*debug_context(), isolate_); |
2766 } | 2767 } |
2767 | 2768 |
(...skipping 576 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3344 logger_->DebugEvent("Put", message.text()); | 3345 logger_->DebugEvent("Put", message.text()); |
3345 } | 3346 } |
3346 | 3347 |
3347 | 3348 |
3348 void LockingCommandMessageQueue::Clear() { | 3349 void LockingCommandMessageQueue::Clear() { |
3349 LockGuard<Mutex> lock_guard(&mutex_); | 3350 LockGuard<Mutex> lock_guard(&mutex_); |
3350 queue_.Clear(); | 3351 queue_.Clear(); |
3351 } | 3352 } |
3352 | 3353 |
3353 } } // namespace v8::internal | 3354 } } // namespace v8::internal |
OLD | NEW |