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 800 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
811 | 811 |
812 // Fail if no context could be created. | 812 // Fail if no context could be created. |
813 if (context.is_null()) return false; | 813 if (context.is_null()) return false; |
814 | 814 |
815 // Use the debugger context. | 815 // Use the debugger context. |
816 SaveContext save(isolate_); | 816 SaveContext save(isolate_); |
817 isolate_->set_context(*context); | 817 isolate_->set_context(*context); |
818 | 818 |
819 // Expose the builtins object in the debugger context. | 819 // Expose the builtins object in the debugger context. |
820 Handle<String> key = isolate_->factory()->InternalizeOneByteString( | 820 Handle<String> key = isolate_->factory()->InternalizeOneByteString( |
821 STATIC_ASCII_VECTOR("builtins")); | 821 STATIC_CHAR_VECTOR("builtins")); |
822 Handle<GlobalObject> global = | 822 Handle<GlobalObject> global = |
823 Handle<GlobalObject>(context->global_object(), isolate_); | 823 Handle<GlobalObject>(context->global_object(), isolate_); |
824 Handle<JSBuiltinsObject> builtin = | 824 Handle<JSBuiltinsObject> builtin = |
825 Handle<JSBuiltinsObject>(global->builtins(), isolate_); | 825 Handle<JSBuiltinsObject>(global->builtins(), isolate_); |
826 RETURN_ON_EXCEPTION_VALUE( | 826 RETURN_ON_EXCEPTION_VALUE( |
827 isolate_, Object::SetProperty(global, key, builtin, SLOPPY), false); | 827 isolate_, Object::SetProperty(global, key, builtin, SLOPPY), false); |
828 | 828 |
829 // Compile the JavaScript for the debugger in the debugger context. | 829 // Compile the JavaScript for the debugger in the debugger context. |
830 bool caught_exception = | 830 bool caught_exception = |
831 !CompileDebuggerScript(isolate_, Natives::GetIndex("mirror")) || | 831 !CompileDebuggerScript(isolate_, Natives::GetIndex("mirror")) || |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1027 bool Debug::CheckBreakPoint(Handle<Object> break_point_object) { | 1027 bool Debug::CheckBreakPoint(Handle<Object> break_point_object) { |
1028 Factory* factory = isolate_->factory(); | 1028 Factory* factory = isolate_->factory(); |
1029 HandleScope scope(isolate_); | 1029 HandleScope scope(isolate_); |
1030 | 1030 |
1031 // Ignore check if break point object is not a JSObject. | 1031 // Ignore check if break point object is not a JSObject. |
1032 if (!break_point_object->IsJSObject()) return true; | 1032 if (!break_point_object->IsJSObject()) return true; |
1033 | 1033 |
1034 // Get the function IsBreakPointTriggered (defined in debug-debugger.js). | 1034 // Get the function IsBreakPointTriggered (defined in debug-debugger.js). |
1035 Handle<String> is_break_point_triggered_string = | 1035 Handle<String> is_break_point_triggered_string = |
1036 factory->InternalizeOneByteString( | 1036 factory->InternalizeOneByteString( |
1037 STATIC_ASCII_VECTOR("IsBreakPointTriggered")); | 1037 STATIC_CHAR_VECTOR("IsBreakPointTriggered")); |
1038 Handle<GlobalObject> debug_global(debug_context()->global_object()); | 1038 Handle<GlobalObject> debug_global(debug_context()->global_object()); |
1039 Handle<JSFunction> check_break_point = | 1039 Handle<JSFunction> check_break_point = |
1040 Handle<JSFunction>::cast(Object::GetProperty( | 1040 Handle<JSFunction>::cast(Object::GetProperty( |
1041 debug_global, is_break_point_triggered_string).ToHandleChecked()); | 1041 debug_global, is_break_point_triggered_string).ToHandleChecked()); |
1042 | 1042 |
1043 // Get the break id as an object. | 1043 // Get the break id as an object. |
1044 Handle<Object> break_id = factory->NewNumberFromInt(Debug::break_id()); | 1044 Handle<Object> break_id = factory->NewNumberFromInt(Debug::break_id()); |
1045 | 1045 |
1046 // Call HandleBreakPointx. | 1046 // Call HandleBreakPointx. |
1047 Handle<Object> argv[] = { break_id, break_point_object }; | 1047 Handle<Object> argv[] = { break_id, break_point_object }; |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1258 return break_on_uncaught_exception_; | 1258 return break_on_uncaught_exception_; |
1259 } else { | 1259 } else { |
1260 return break_on_exception_; | 1260 return break_on_exception_; |
1261 } | 1261 } |
1262 } | 1262 } |
1263 | 1263 |
1264 | 1264 |
1265 bool Debug::PromiseHasRejectHandler(Handle<JSObject> promise) { | 1265 bool Debug::PromiseHasRejectHandler(Handle<JSObject> promise) { |
1266 Handle<JSFunction> fun = Handle<JSFunction>::cast( | 1266 Handle<JSFunction> fun = Handle<JSFunction>::cast( |
1267 JSObject::GetDataProperty(isolate_->js_builtins_object(), | 1267 JSObject::GetDataProperty(isolate_->js_builtins_object(), |
1268 isolate_->factory()->NewStringFromStaticAscii( | 1268 isolate_->factory()->NewStringFromStaticChars( |
1269 "PromiseHasRejectHandler"))); | 1269 "PromiseHasRejectHandler"))); |
1270 Handle<Object> result = | 1270 Handle<Object> result = |
1271 Execution::Call(isolate_, fun, promise, 0, NULL).ToHandleChecked(); | 1271 Execution::Call(isolate_, fun, promise, 0, NULL).ToHandleChecked(); |
1272 return result->IsTrue(); | 1272 return result->IsTrue(); |
1273 } | 1273 } |
1274 | 1274 |
1275 | 1275 |
1276 void Debug::PrepareStep(StepAction step_action, | 1276 void Debug::PrepareStep(StepAction step_action, |
1277 int step_count, | 1277 int step_count, |
1278 StackFrame::Id frame_id) { | 1278 StackFrame::Id frame_id) { |
(...skipping 1107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2386 } | 2386 } |
2387 | 2387 |
2388 | 2388 |
2389 void Debug::ClearMirrorCache() { | 2389 void Debug::ClearMirrorCache() { |
2390 PostponeInterruptsScope postpone(isolate_); | 2390 PostponeInterruptsScope postpone(isolate_); |
2391 HandleScope scope(isolate_); | 2391 HandleScope scope(isolate_); |
2392 AssertDebugContext(); | 2392 AssertDebugContext(); |
2393 Factory* factory = isolate_->factory(); | 2393 Factory* factory = isolate_->factory(); |
2394 Handle<GlobalObject> global(isolate_->global_object()); | 2394 Handle<GlobalObject> global(isolate_->global_object()); |
2395 JSObject::SetProperty(global, | 2395 JSObject::SetProperty(global, |
2396 factory->NewStringFromAsciiChecked("next_handle_"), | 2396 factory->NewStringFromAsciiChecked("next_handle_"), |
2397 handle(Smi::FromInt(0), isolate_), | 2397 handle(Smi::FromInt(0), isolate_), SLOPPY).Check(); |
2398 SLOPPY).Check(); | |
2399 JSObject::SetProperty(global, | 2398 JSObject::SetProperty(global, |
2400 factory->NewStringFromAsciiChecked("mirror_cache_"), | 2399 factory->NewStringFromAsciiChecked("mirror_cache_"), |
2401 factory->NewJSArray(0, FAST_ELEMENTS), | 2400 factory->NewJSArray(0, FAST_ELEMENTS), SLOPPY).Check(); |
2402 SLOPPY).Check(); | |
2403 } | 2401 } |
2404 | 2402 |
2405 | 2403 |
2406 Handle<FixedArray> Debug::GetLoadedScripts() { | 2404 Handle<FixedArray> Debug::GetLoadedScripts() { |
2407 // Create and fill the script cache when the loaded scripts is requested for | 2405 // Create and fill the script cache when the loaded scripts is requested for |
2408 // the first time. | 2406 // the first time. |
2409 if (script_cache_ == NULL) script_cache_ = new ScriptCache(isolate_); | 2407 if (script_cache_ == NULL) script_cache_ = new ScriptCache(isolate_); |
2410 | 2408 |
2411 // Perform GC to get unreferenced scripts evicted from the cache before | 2409 // Perform GC to get unreferenced scripts evicted from the cache before |
2412 // returning the content. | 2410 // returning the content. |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2620 HandleScope scope(isolate_); | 2618 HandleScope scope(isolate_); |
2621 DebugScope debug_scope(this); | 2619 DebugScope debug_scope(this); |
2622 if (debug_scope.failed()) return; | 2620 if (debug_scope.failed()) return; |
2623 | 2621 |
2624 // If debugging there might be script break points registered for this | 2622 // If debugging there might be script break points registered for this |
2625 // script. Make sure that these break points are set. | 2623 // script. Make sure that these break points are set. |
2626 | 2624 |
2627 // Get the function UpdateScriptBreakPoints (defined in debug-debugger.js). | 2625 // Get the function UpdateScriptBreakPoints (defined in debug-debugger.js). |
2628 Handle<String> update_script_break_points_string = | 2626 Handle<String> update_script_break_points_string = |
2629 isolate_->factory()->InternalizeOneByteString( | 2627 isolate_->factory()->InternalizeOneByteString( |
2630 STATIC_ASCII_VECTOR("UpdateScriptBreakPoints")); | 2628 STATIC_CHAR_VECTOR("UpdateScriptBreakPoints")); |
2631 Handle<GlobalObject> debug_global(debug_context()->global_object()); | 2629 Handle<GlobalObject> debug_global(debug_context()->global_object()); |
2632 Handle<Object> update_script_break_points = | 2630 Handle<Object> update_script_break_points = |
2633 Object::GetProperty( | 2631 Object::GetProperty( |
2634 debug_global, update_script_break_points_string).ToHandleChecked(); | 2632 debug_global, update_script_break_points_string).ToHandleChecked(); |
2635 if (!update_script_break_points->IsJSFunction()) { | 2633 if (!update_script_break_points->IsJSFunction()) { |
2636 return; | 2634 return; |
2637 } | 2635 } |
2638 DCHECK(update_script_break_points->IsJSFunction()); | 2636 DCHECK(update_script_break_points->IsJSFunction()); |
2639 | 2637 |
2640 // Wrap the script object in a proper JS object before passing it | 2638 // Wrap the script object in a proper JS object before passing it |
(...skipping 721 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3362 logger_->DebugEvent("Put", message.text()); | 3360 logger_->DebugEvent("Put", message.text()); |
3363 } | 3361 } |
3364 | 3362 |
3365 | 3363 |
3366 void LockingCommandMessageQueue::Clear() { | 3364 void LockingCommandMessageQueue::Clear() { |
3367 base::LockGuard<base::Mutex> lock_guard(&mutex_); | 3365 base::LockGuard<base::Mutex> lock_guard(&mutex_); |
3368 queue_.Clear(); | 3366 queue_.Clear(); |
3369 } | 3367 } |
3370 | 3368 |
3371 } } // namespace v8::internal | 3369 } } // namespace v8::internal |
OLD | NEW |