Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(157)

Side by Side Diff: src/debug.cc

Issue 238753003: Remove assertion from callers of TryCall. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: fix Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | src/execution.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 1109 matching lines...) Expand 10 before | Expand all | Expand 10 after
1120 Handle<JSFunction> check_break_point = 1120 Handle<JSFunction> check_break_point =
1121 Handle<JSFunction>::cast(Object::GetProperty( 1121 Handle<JSFunction>::cast(Object::GetProperty(
1122 debug_global, is_break_point_triggered_string).ToHandleChecked()); 1122 debug_global, is_break_point_triggered_string).ToHandleChecked());
1123 1123
1124 // Get the break id as an object. 1124 // Get the break id as an object.
1125 Handle<Object> break_id = factory->NewNumberFromInt(Debug::break_id()); 1125 Handle<Object> break_id = factory->NewNumberFromInt(Debug::break_id());
1126 1126
1127 // Call HandleBreakPointx. 1127 // Call HandleBreakPointx.
1128 Handle<Object> argv[] = { break_id, break_point_object }; 1128 Handle<Object> argv[] = { break_id, break_point_object };
1129 Handle<Object> result; 1129 Handle<Object> result;
1130 ASSIGN_RETURN_ON_EXCEPTION_VALUE( 1130 if (!Execution::TryCall(check_break_point,
1131 isolate_, result, 1131 isolate_->js_builtins_object(),
1132 Execution::TryCall(check_break_point, 1132 ARRAY_SIZE(argv),
1133 isolate_->js_builtins_object(), 1133 argv).ToHandle(&result)) {
1134 ARRAY_SIZE(argv), 1134 return false;
1135 argv), 1135 }
1136 false);
1137 1136
1138 // Return whether the break point is triggered. 1137 // Return whether the break point is triggered.
1139 return result->IsTrue(); 1138 return result->IsTrue();
1140 } 1139 }
1141 1140
1142 1141
1143 // Check whether the function has debug information. 1142 // Check whether the function has debug information.
1144 bool Debug::HasDebugInfo(Handle<SharedFunctionInfo> shared) { 1143 bool Debug::HasDebugInfo(Handle<SharedFunctionInfo> shared) {
1145 return !shared->debug_info()->IsUndefined(); 1144 return !shared->debug_info()->IsUndefined();
1146 } 1145 }
(...skipping 1466 matching lines...) Expand 10 before | Expand all | Expand 10 after
2613 // Create the execution state object. 2612 // Create the execution state object.
2614 Handle<Object> break_id = isolate_->factory()->NewNumberFromInt( 2613 Handle<Object> break_id = isolate_->factory()->NewNumberFromInt(
2615 isolate_->debug()->break_id()); 2614 isolate_->debug()->break_id());
2616 Handle<Object> argv[] = { break_id }; 2615 Handle<Object> argv[] = { break_id };
2617 return MakeJSObject(CStrVector("MakeExecutionState"), ARRAY_SIZE(argv), argv); 2616 return MakeJSObject(CStrVector("MakeExecutionState"), ARRAY_SIZE(argv), argv);
2618 } 2617 }
2619 2618
2620 2619
2621 MaybeHandle<Object> Debugger::MakeBreakEvent(Handle<Object> break_points_hit) { 2620 MaybeHandle<Object> Debugger::MakeBreakEvent(Handle<Object> break_points_hit) {
2622 Handle<Object> exec_state; 2621 Handle<Object> exec_state;
2623 ASSIGN_RETURN_ON_EXCEPTION( 2622 if (!MakeExecutionState().ToHandle(&exec_state)) return MaybeHandle<Object>();
2624 isolate_, exec_state, MakeExecutionState(), Object);
2625 // Create the new break event object. 2623 // Create the new break event object.
2626 Handle<Object> argv[] = { exec_state, break_points_hit }; 2624 Handle<Object> argv[] = { exec_state, break_points_hit };
2627 return MakeJSObject(CStrVector("MakeBreakEvent"), ARRAY_SIZE(argv), argv); 2625 return MakeJSObject(CStrVector("MakeBreakEvent"), ARRAY_SIZE(argv), argv);
2628 } 2626 }
2629 2627
2630 2628
2631 MaybeHandle<Object> Debugger::MakeExceptionEvent(Handle<Object> exception, 2629 MaybeHandle<Object> Debugger::MakeExceptionEvent(Handle<Object> exception,
2632 bool uncaught) { 2630 bool uncaught) {
2633 Handle<Object> exec_state; 2631 Handle<Object> exec_state;
2634 ASSIGN_RETURN_ON_EXCEPTION( 2632 if (!MakeExecutionState().ToHandle(&exec_state)) return MaybeHandle<Object>();
2635 isolate_, exec_state, MakeExecutionState(), Object);
2636 // Create the new exception event object. 2633 // Create the new exception event object.
2637 Handle<Object> argv[] = { exec_state, 2634 Handle<Object> argv[] = { exec_state,
2638 exception, 2635 exception,
2639 isolate_->factory()->ToBoolean(uncaught) }; 2636 isolate_->factory()->ToBoolean(uncaught) };
2640 return MakeJSObject(CStrVector("MakeExceptionEvent"), ARRAY_SIZE(argv), argv); 2637 return MakeJSObject(CStrVector("MakeExceptionEvent"), ARRAY_SIZE(argv), argv);
2641 } 2638 }
2642 2639
2643 2640
2644 MaybeHandle<Object> Debugger::MakeCompileEvent(Handle<Script> script, 2641 MaybeHandle<Object> Debugger::MakeCompileEvent(Handle<Script> script,
2645 bool before) { 2642 bool before) {
2646 Factory* factory = isolate_->factory(); 2643 Handle<Object> exec_state;
2644 if (!MakeExecutionState().ToHandle(&exec_state)) return MaybeHandle<Object>();
2647 // Create the compile event object. 2645 // Create the compile event object.
2648 Handle<Object> exec_state;
2649 ASSIGN_RETURN_ON_EXCEPTION(
2650 isolate_, exec_state, MakeExecutionState(), Object);
2651 Handle<Object> script_wrapper = GetScriptWrapper(script); 2646 Handle<Object> script_wrapper = GetScriptWrapper(script);
2652 Handle<Object> argv[] = { exec_state, 2647 Handle<Object> argv[] = { exec_state,
2653 script_wrapper, 2648 script_wrapper,
2654 factory->ToBoolean(before) }; 2649 isolate_->factory()->ToBoolean(before) };
2655 return MakeJSObject(CStrVector("MakeCompileEvent"), ARRAY_SIZE(argv), argv); 2650 return MakeJSObject(CStrVector("MakeCompileEvent"), ARRAY_SIZE(argv), argv);
2656 } 2651 }
2657 2652
2658 2653
2659 MaybeHandle<Object> Debugger::MakeScriptCollectedEvent(int id) { 2654 MaybeHandle<Object> Debugger::MakeScriptCollectedEvent(int id) {
2655 Handle<Object> exec_state;
2656 if (!MakeExecutionState().ToHandle(&exec_state)) return MaybeHandle<Object>();
2660 // Create the script collected event object. 2657 // Create the script collected event object.
2661 Handle<Object> exec_state;
2662 ASSIGN_RETURN_ON_EXCEPTION(
2663 isolate_, exec_state, MakeExecutionState(), Object);
2664 Handle<Object> id_object = Handle<Smi>(Smi::FromInt(id), isolate_); 2658 Handle<Object> id_object = Handle<Smi>(Smi::FromInt(id), isolate_);
2665 Handle<Object> argv[] = { exec_state, id_object }; 2659 Handle<Object> argv[] = { exec_state, id_object };
2666 2660
2667 return MakeJSObject( 2661 return MakeJSObject(
2668 CStrVector("MakeScriptCollectedEvent"), ARRAY_SIZE(argv), argv); 2662 CStrVector("MakeScriptCollectedEvent"), ARRAY_SIZE(argv), argv);
2669 } 2663 }
2670 2664
2671 2665
2672 void Debugger::OnException(Handle<Object> exception, bool uncaught) { 2666 void Debugger::OnException(Handle<Object> exception, bool uncaught) {
2673 HandleScope scope(isolate_); 2667 HandleScope scope(isolate_);
(...skipping 15 matching lines...) Expand all
2689 2683
2690 // Enter the debugger. 2684 // Enter the debugger.
2691 EnterDebugger debugger(isolate_); 2685 EnterDebugger debugger(isolate_);
2692 if (debugger.FailedToEnter()) return; 2686 if (debugger.FailedToEnter()) return;
2693 2687
2694 // Clear all current stepping setup. 2688 // Clear all current stepping setup.
2695 debug->ClearStepping(); 2689 debug->ClearStepping();
2696 // Create the event data object. 2690 // Create the event data object.
2697 Handle<Object> event_data; 2691 Handle<Object> event_data;
2698 // Bail out and don't call debugger if exception. 2692 // Bail out and don't call debugger if exception.
2699 ASSIGN_RETURN_ON_EXCEPTION_VALUE( 2693 if (!MakeExceptionEvent(exception, uncaught).ToHandle(&event_data)) return;
2700 isolate_, event_data, MakeExceptionEvent(exception, uncaught),
2701 /* void */ ;);
2702 2694
2703 // Process debug event. 2695 // Process debug event.
2704 ProcessDebugEvent(v8::Exception, Handle<JSObject>::cast(event_data), false); 2696 ProcessDebugEvent(v8::Exception, Handle<JSObject>::cast(event_data), false);
2705 // Return to continue execution from where the exception was thrown. 2697 // Return to continue execution from where the exception was thrown.
2706 } 2698 }
2707 2699
2708 2700
2709 void Debugger::OnDebugBreak(Handle<Object> break_points_hit, 2701 void Debugger::OnDebugBreak(Handle<Object> break_points_hit,
2710 bool auto_continue) { 2702 bool auto_continue) {
2711 HandleScope scope(isolate_); 2703 HandleScope scope(isolate_);
2712 2704
2713 // Debugger has already been entered by caller. 2705 // Debugger has already been entered by caller.
2714 ASSERT(isolate_->context() == *isolate_->debug()->debug_context()); 2706 ASSERT(isolate_->context() == *isolate_->debug()->debug_context());
2715 2707
2716 // Bail out if there is no listener for this event 2708 // Bail out if there is no listener for this event
2717 if (!Debugger::EventActive(v8::Break)) return; 2709 if (!Debugger::EventActive(v8::Break)) return;
2718 2710
2719 // Debugger must be entered in advance. 2711 // Debugger must be entered in advance.
2720 ASSERT(isolate_->context() == *isolate_->debug()->debug_context()); 2712 ASSERT(isolate_->context() == *isolate_->debug()->debug_context());
2721 2713
2722 // Create the event data object. 2714 // Create the event data object.
2723 Handle<Object> event_data; 2715 Handle<Object> event_data;
2724 // Bail out and don't call debugger if exception. 2716 // Bail out and don't call debugger if exception.
2725 ASSIGN_RETURN_ON_EXCEPTION_VALUE( 2717 if (!MakeBreakEvent(break_points_hit).ToHandle(&event_data)) return;
2726 isolate_, event_data, MakeBreakEvent(break_points_hit), /* void */ ;);
2727 2718
2728 // Process debug event. 2719 // Process debug event.
2729 ProcessDebugEvent(v8::Break, 2720 ProcessDebugEvent(v8::Break,
2730 Handle<JSObject>::cast(event_data), 2721 Handle<JSObject>::cast(event_data),
2731 auto_continue); 2722 auto_continue);
2732 } 2723 }
2733 2724
2734 2725
2735 void Debugger::OnBeforeCompile(Handle<Script> script) { 2726 void Debugger::OnBeforeCompile(Handle<Script> script) {
2736 HandleScope scope(isolate_); 2727 HandleScope scope(isolate_);
2737 2728
2738 // Bail out based on state or if there is no listener for this event 2729 // Bail out based on state or if there is no listener for this event
2739 if (isolate_->debug()->InDebugger()) return; 2730 if (isolate_->debug()->InDebugger()) return;
2740 if (compiling_natives()) return; 2731 if (compiling_natives()) return;
2741 if (!EventActive(v8::BeforeCompile)) return; 2732 if (!EventActive(v8::BeforeCompile)) return;
2742 2733
2743 // Enter the debugger. 2734 // Enter the debugger.
2744 EnterDebugger debugger(isolate_); 2735 EnterDebugger debugger(isolate_);
2745 if (debugger.FailedToEnter()) return; 2736 if (debugger.FailedToEnter()) return;
2746 2737
2747 // Create the event data object. 2738 // Create the event data object.
2748 Handle<Object> event_data; 2739 Handle<Object> event_data;
2749 // Bail out and don't call debugger if exception. 2740 // Bail out and don't call debugger if exception.
2750 ASSIGN_RETURN_ON_EXCEPTION_VALUE( 2741 if (!MakeCompileEvent(script, true).ToHandle(&event_data)) return;
2751 isolate_, event_data, MakeCompileEvent(script, true), /* void */ ;);
2752 2742
2753 // Process debug event. 2743 // Process debug event.
2754 ProcessDebugEvent(v8::BeforeCompile, 2744 ProcessDebugEvent(v8::BeforeCompile,
2755 Handle<JSObject>::cast(event_data), 2745 Handle<JSObject>::cast(event_data),
2756 true); 2746 true);
2757 } 2747 }
2758 2748
2759 2749
2760 // Handle debugger actions when a new script is compiled. 2750 // Handle debugger actions when a new script is compiled.
2761 void Debugger::OnAfterCompile(Handle<Script> script, 2751 void Debugger::OnAfterCompile(Handle<Script> script,
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
2807 argv).is_null()) { 2797 argv).is_null()) {
2808 return; 2798 return;
2809 } 2799 }
2810 // Bail out based on state or if there is no listener for this event 2800 // Bail out based on state or if there is no listener for this event
2811 if (in_debugger && (after_compile_flags & SEND_WHEN_DEBUGGING) == 0) return; 2801 if (in_debugger && (after_compile_flags & SEND_WHEN_DEBUGGING) == 0) return;
2812 if (!Debugger::EventActive(v8::AfterCompile)) return; 2802 if (!Debugger::EventActive(v8::AfterCompile)) return;
2813 2803
2814 // Create the compile state object. 2804 // Create the compile state object.
2815 Handle<Object> event_data; 2805 Handle<Object> event_data;
2816 // Bail out and don't call debugger if exception. 2806 // Bail out and don't call debugger if exception.
2817 ASSIGN_RETURN_ON_EXCEPTION_VALUE( 2807 if (!MakeCompileEvent(script, false).ToHandle(&event_data)) return;
2818 isolate_, event_data, MakeCompileEvent(script, false), /* void */ ;);
2819 2808
2820 // Process debug event. 2809 // Process debug event.
2821 ProcessDebugEvent(v8::AfterCompile, Handle<JSObject>::cast(event_data), true); 2810 ProcessDebugEvent(v8::AfterCompile, Handle<JSObject>::cast(event_data), true);
2822 } 2811 }
2823 2812
2824 2813
2825 void Debugger::OnScriptCollected(int id) { 2814 void Debugger::OnScriptCollected(int id) {
2826 HandleScope scope(isolate_); 2815 HandleScope scope(isolate_);
2827 2816
2828 // No more to do if not debugging. 2817 // No more to do if not debugging.
2829 if (isolate_->debug()->InDebugger()) return; 2818 if (isolate_->debug()->InDebugger()) return;
2830 if (!IsDebuggerActive()) return; 2819 if (!IsDebuggerActive()) return;
2831 if (!Debugger::EventActive(v8::ScriptCollected)) return; 2820 if (!Debugger::EventActive(v8::ScriptCollected)) return;
2832 2821
2833 // Enter the debugger. 2822 // Enter the debugger.
2834 EnterDebugger debugger(isolate_); 2823 EnterDebugger debugger(isolate_);
2835 if (debugger.FailedToEnter()) return; 2824 if (debugger.FailedToEnter()) return;
2836 2825
2837 // Create the script collected state object. 2826 // Create the script collected state object.
2838 Handle<Object> event_data; 2827 Handle<Object> event_data;
2839 // Bail out and don't call debugger if exception. 2828 // Bail out and don't call debugger if exception.
2840 ASSIGN_RETURN_ON_EXCEPTION_VALUE( 2829 if (!MakeScriptCollectedEvent(id).ToHandle(&event_data)) return;
2841 isolate_, event_data, MakeScriptCollectedEvent(id), /* void */ ;);
2842 2830
2843 // Process debug event. 2831 // Process debug event.
2844 ProcessDebugEvent(v8::ScriptCollected, 2832 ProcessDebugEvent(v8::ScriptCollected,
2845 Handle<JSObject>::cast(event_data), 2833 Handle<JSObject>::cast(event_data),
2846 true); 2834 true);
2847 } 2835 }
2848 2836
2849 2837
2850 void Debugger::ProcessDebugEvent(v8::DebugEvent event, 2838 void Debugger::ProcessDebugEvent(v8::DebugEvent event,
2851 Handle<JSObject> event_data, 2839 Handle<JSObject> event_data,
2852 bool auto_continue) { 2840 bool auto_continue) {
2853 HandleScope scope(isolate_); 2841 HandleScope scope(isolate_);
2854 2842
2855 // Clear any pending debug break if this is a real break. 2843 // Clear any pending debug break if this is a real break.
2856 if (!auto_continue) { 2844 if (!auto_continue) {
2857 isolate_->debug()->clear_interrupt_pending(DEBUGBREAK); 2845 isolate_->debug()->clear_interrupt_pending(DEBUGBREAK);
2858 } 2846 }
2859 2847
2860 // Create the execution state. 2848 // Create the execution state.
2861 Handle<Object> exec_state; 2849 Handle<Object> exec_state;
2862 // Bail out and don't call debugger if exception. 2850 // Bail out and don't call debugger if exception.
2863 ASSIGN_RETURN_ON_EXCEPTION_VALUE( 2851 if (!MakeExecutionState().ToHandle(&exec_state)) return;
2864 isolate_, exec_state, MakeExecutionState(), /* void */ ;); 2852
2865 // First notify the message handler if any. 2853 // First notify the message handler if any.
2866 if (message_handler_ != NULL) { 2854 if (message_handler_ != NULL) {
2867 NotifyMessageHandler(event, 2855 NotifyMessageHandler(event,
2868 Handle<JSObject>::cast(exec_state), 2856 Handle<JSObject>::cast(exec_state),
2869 event_data, 2857 event_data,
2870 auto_continue); 2858 auto_continue);
2871 } 2859 }
2872 // Notify registered debug event listener. This can be either a C or 2860 // Notify registered debug event listener. This can be either a C or
2873 // a JavaScript function. Don't call event listener for v8::Break 2861 // a JavaScript function. Don't call event listener for v8::Break
2874 // here, if it's only a debug command -- they will be processed later. 2862 // here, if it's only a debug command -- they will be processed later.
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after
3295 Debugger::never_unload_debugger_ = true; 3283 Debugger::never_unload_debugger_ = true;
3296 3284
3297 // Enter the debugger. 3285 // Enter the debugger.
3298 EnterDebugger debugger(isolate_); 3286 EnterDebugger debugger(isolate_);
3299 if (debugger.FailedToEnter()) { 3287 if (debugger.FailedToEnter()) {
3300 return isolate_->factory()->undefined_value(); 3288 return isolate_->factory()->undefined_value();
3301 } 3289 }
3302 3290
3303 // Create the execution state. 3291 // Create the execution state.
3304 Handle<Object> exec_state; 3292 Handle<Object> exec_state;
3305 ASSIGN_RETURN_ON_EXCEPTION_VALUE( 3293 if (!MakeExecutionState().ToHandle(&exec_state)) {
3306 isolate_, exec_state, 3294 return isolate_->factory()->undefined_value();
3307 MakeExecutionState(), 3295 }
3308 isolate_->factory()->undefined_value());
3309 3296
3310 Handle<Object> argv[] = { exec_state, data }; 3297 Handle<Object> argv[] = { exec_state, data };
3311 return Execution::Call( 3298 return Execution::Call(
3312 isolate_, 3299 isolate_,
3313 fun, 3300 fun,
3314 Handle<Object>(isolate_->debug()->debug_context_->global_proxy(), 3301 Handle<Object>(isolate_->debug()->debug_context_->global_proxy(),
3315 isolate_), 3302 isolate_),
3316 ARRAY_SIZE(argv), 3303 ARRAY_SIZE(argv),
3317 argv); 3304 argv);
3318 } 3305 }
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after
3748 { 3735 {
3749 Locker locker(reinterpret_cast<v8::Isolate*>(isolate_)); 3736 Locker locker(reinterpret_cast<v8::Isolate*>(isolate_));
3750 isolate_->debugger()->CallMessageDispatchHandler(); 3737 isolate_->debugger()->CallMessageDispatchHandler();
3751 } 3738 }
3752 } 3739 }
3753 } 3740 }
3754 3741
3755 #endif // ENABLE_DEBUGGER_SUPPORT 3742 #endif // ENABLE_DEBUGGER_SUPPORT
3756 3743
3757 } } // namespace v8::internal 3744 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/execution.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698