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

Side by Side Diff: src/debug.cc

Issue 8133020: Simplify calling generated code from the runtime. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 years, 2 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 | « src/debug.h ('k') | src/execution.h » ('j') | src/execution.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 1088 matching lines...) Expand 10 before | Expand all | Expand 10 after
1099 Handle<JSFunction> check_break_point = 1099 Handle<JSFunction> check_break_point =
1100 Handle<JSFunction>(JSFunction::cast( 1100 Handle<JSFunction>(JSFunction::cast(
1101 debug_context()->global()->GetPropertyNoExceptionThrown( 1101 debug_context()->global()->GetPropertyNoExceptionThrown(
1102 *is_break_point_triggered_symbol))); 1102 *is_break_point_triggered_symbol)));
1103 1103
1104 // Get the break id as an object. 1104 // Get the break id as an object.
1105 Handle<Object> break_id = factory->NewNumberFromInt(Debug::break_id()); 1105 Handle<Object> break_id = factory->NewNumberFromInt(Debug::break_id());
1106 1106
1107 // Call HandleBreakPointx. 1107 // Call HandleBreakPointx.
1108 bool caught_exception; 1108 bool caught_exception;
1109 const int argc = 2; 1109 Handle<Object> argv[] = { break_id, break_point_object };
1110 Object** argv[argc] = {
1111 break_id.location(),
1112 reinterpret_cast<Object**>(break_point_object.location())
1113 };
1114 Handle<Object> result = Execution::TryCall(check_break_point, 1110 Handle<Object> result = Execution::TryCall(check_break_point,
1115 isolate_->js_builtins_object(), argc, argv, &caught_exception); 1111 isolate_->js_builtins_object(),
1112 ARRAY_SIZE(argv),
1113 argv,
1114 &caught_exception);
1116 1115
1117 // If exception or non boolean result handle as not triggered 1116 // If exception or non boolean result handle as not triggered
1118 if (caught_exception || !result->IsBoolean()) { 1117 if (caught_exception || !result->IsBoolean()) {
1119 return false; 1118 return false;
1120 } 1119 }
1121 1120
1122 // Return whether the break point is triggered. 1121 // Return whether the break point is triggered.
1123 ASSERT(!result.is_null()); 1122 ASSERT(!result.is_null());
1124 return (*result)->IsTrue(); 1123 return (*result)->IsTrue();
1125 } 1124 }
(...skipping 969 matching lines...) Expand 10 before | Expand all | Expand 10 after
2095 2094
2096 Debugger::~Debugger() { 2095 Debugger::~Debugger() {
2097 delete dispatch_handler_access_; 2096 delete dispatch_handler_access_;
2098 dispatch_handler_access_ = 0; 2097 dispatch_handler_access_ = 0;
2099 delete command_received_; 2098 delete command_received_;
2100 command_received_ = 0; 2099 command_received_ = 0;
2101 } 2100 }
2102 2101
2103 2102
2104 Handle<Object> Debugger::MakeJSObject(Vector<const char> constructor_name, 2103 Handle<Object> Debugger::MakeJSObject(Vector<const char> constructor_name,
2105 int argc, Object*** argv, 2104 int argc,
2105 Handle<Object> argv[],
2106 bool* caught_exception) { 2106 bool* caught_exception) {
2107 ASSERT(isolate_->context() == *isolate_->debug()->debug_context()); 2107 ASSERT(isolate_->context() == *isolate_->debug()->debug_context());
2108 2108
2109 // Create the execution state object. 2109 // Create the execution state object.
2110 Handle<String> constructor_str = 2110 Handle<String> constructor_str =
2111 isolate_->factory()->LookupSymbol(constructor_name); 2111 isolate_->factory()->LookupSymbol(constructor_name);
2112 Handle<Object> constructor( 2112 Handle<Object> constructor(
2113 isolate_->global()->GetPropertyNoExceptionThrown(*constructor_str)); 2113 isolate_->global()->GetPropertyNoExceptionThrown(*constructor_str));
2114 ASSERT(constructor->IsJSFunction()); 2114 ASSERT(constructor->IsJSFunction());
2115 if (!constructor->IsJSFunction()) { 2115 if (!constructor->IsJSFunction()) {
2116 *caught_exception = true; 2116 *caught_exception = true;
2117 return isolate_->factory()->undefined_value(); 2117 return isolate_->factory()->undefined_value();
2118 } 2118 }
2119 Handle<Object> js_object = Execution::TryCall( 2119 Handle<Object> js_object = Execution::TryCall(
2120 Handle<JSFunction>::cast(constructor), 2120 Handle<JSFunction>::cast(constructor),
2121 Handle<JSObject>(isolate_->debug()->debug_context()->global()), 2121 Handle<JSObject>(isolate_->debug()->debug_context()->global()),
2122 argc, argv, caught_exception); 2122 argc,
2123 argv,
2124 caught_exception);
2123 return js_object; 2125 return js_object;
2124 } 2126 }
2125 2127
2126 2128
2127 Handle<Object> Debugger::MakeExecutionState(bool* caught_exception) { 2129 Handle<Object> Debugger::MakeExecutionState(bool* caught_exception) {
2128 // Create the execution state object. 2130 // Create the execution state object.
2129 Handle<Object> break_id = isolate_->factory()->NewNumberFromInt( 2131 Handle<Object> break_id = isolate_->factory()->NewNumberFromInt(
2130 isolate_->debug()->break_id()); 2132 isolate_->debug()->break_id());
2131 const int argc = 1; 2133 Handle<Object> argv[] = { break_id };
2132 Object** argv[argc] = { break_id.location() };
2133 return MakeJSObject(CStrVector("MakeExecutionState"), 2134 return MakeJSObject(CStrVector("MakeExecutionState"),
2134 argc, argv, caught_exception); 2135 ARRAY_SIZE(argv),
2136 argv,
2137 caught_exception);
2135 } 2138 }
2136 2139
2137 2140
2138 Handle<Object> Debugger::MakeBreakEvent(Handle<Object> exec_state, 2141 Handle<Object> Debugger::MakeBreakEvent(Handle<Object> exec_state,
2139 Handle<Object> break_points_hit, 2142 Handle<Object> break_points_hit,
2140 bool* caught_exception) { 2143 bool* caught_exception) {
2141 // Create the new break event object. 2144 // Create the new break event object.
2142 const int argc = 2; 2145 Handle<Object> argv[] = { exec_state, break_points_hit };
2143 Object** argv[argc] = { exec_state.location(),
2144 break_points_hit.location() };
2145 return MakeJSObject(CStrVector("MakeBreakEvent"), 2146 return MakeJSObject(CStrVector("MakeBreakEvent"),
2146 argc, 2147 ARRAY_SIZE(argv),
2147 argv, 2148 argv,
2148 caught_exception); 2149 caught_exception);
2149 } 2150 }
2150 2151
2151 2152
2152 Handle<Object> Debugger::MakeExceptionEvent(Handle<Object> exec_state, 2153 Handle<Object> Debugger::MakeExceptionEvent(Handle<Object> exec_state,
2153 Handle<Object> exception, 2154 Handle<Object> exception,
2154 bool uncaught, 2155 bool uncaught,
2155 bool* caught_exception) { 2156 bool* caught_exception) {
2156 Factory* factory = isolate_->factory(); 2157 Factory* factory = isolate_->factory();
2157 // Create the new exception event object. 2158 // Create the new exception event object.
2158 const int argc = 3; 2159 Handle<Object> argv[] = { exec_state,
2159 Object** argv[argc] = { exec_state.location(), 2160 exception,
2160 exception.location(), 2161 uncaught ? factory->true_value()
2161 uncaught ? factory->true_value().location() : 2162 : factory->false_value() };
2162 factory->false_value().location()};
2163 return MakeJSObject(CStrVector("MakeExceptionEvent"), 2163 return MakeJSObject(CStrVector("MakeExceptionEvent"),
2164 argc, argv, caught_exception); 2164 ARRAY_SIZE(argv),
2165 argv,
2166 caught_exception);
2165 } 2167 }
2166 2168
2167 2169
2168 Handle<Object> Debugger::MakeNewFunctionEvent(Handle<Object> function, 2170 Handle<Object> Debugger::MakeNewFunctionEvent(Handle<Object> function,
2169 bool* caught_exception) { 2171 bool* caught_exception) {
2170 // Create the new function event object. 2172 // Create the new function event object.
2171 const int argc = 1; 2173 Handle<Object> argv[] = { function };
2172 Object** argv[argc] = { function.location() };
2173 return MakeJSObject(CStrVector("MakeNewFunctionEvent"), 2174 return MakeJSObject(CStrVector("MakeNewFunctionEvent"),
2174 argc, argv, caught_exception); 2175 ARRAY_SIZE(argv),
2176 argv,
2177 caught_exception);
2175 } 2178 }
2176 2179
2177 2180
2178 Handle<Object> Debugger::MakeCompileEvent(Handle<Script> script, 2181 Handle<Object> Debugger::MakeCompileEvent(Handle<Script> script,
2179 bool before, 2182 bool before,
2180 bool* caught_exception) { 2183 bool* caught_exception) {
2181 Factory* factory = isolate_->factory(); 2184 Factory* factory = isolate_->factory();
2182 // Create the compile event object. 2185 // Create the compile event object.
2183 Handle<Object> exec_state = MakeExecutionState(caught_exception); 2186 Handle<Object> exec_state = MakeExecutionState(caught_exception);
2184 Handle<Object> script_wrapper = GetScriptWrapper(script); 2187 Handle<Object> script_wrapper = GetScriptWrapper(script);
2185 const int argc = 3; 2188 Handle<Object> argv[] = { exec_state,
2186 Object** argv[argc] = { exec_state.location(), 2189 script_wrapper,
2187 script_wrapper.location(), 2190 before ? factory->true_value()
2188 before ? factory->true_value().location() : 2191 : factory->false_value() };
2189 factory->false_value().location() };
2190 2192
2191 return MakeJSObject(CStrVector("MakeCompileEvent"), 2193 return MakeJSObject(CStrVector("MakeCompileEvent"),
2192 argc, 2194 ARRAY_SIZE(argv),
2193 argv, 2195 argv,
2194 caught_exception); 2196 caught_exception);
2195 } 2197 }
2196 2198
2197 2199
2198 Handle<Object> Debugger::MakeScriptCollectedEvent(int id, 2200 Handle<Object> Debugger::MakeScriptCollectedEvent(int id,
2199 bool* caught_exception) { 2201 bool* caught_exception) {
2200 // Create the script collected event object. 2202 // Create the script collected event object.
2201 Handle<Object> exec_state = MakeExecutionState(caught_exception); 2203 Handle<Object> exec_state = MakeExecutionState(caught_exception);
2202 Handle<Object> id_object = Handle<Smi>(Smi::FromInt(id)); 2204 Handle<Object> id_object = Handle<Smi>(Smi::FromInt(id));
2203 const int argc = 2; 2205 Handle<Object> argv[] = { exec_state, id_object };
2204 Object** argv[argc] = { exec_state.location(), id_object.location() };
2205 2206
2206 return MakeJSObject(CStrVector("MakeScriptCollectedEvent"), 2207 return MakeJSObject(CStrVector("MakeScriptCollectedEvent"),
2207 argc, 2208 ARRAY_SIZE(argv),
2208 argv, 2209 argv,
2209 caught_exception); 2210 caught_exception);
2210 } 2211 }
2211 2212
2212 2213
2213 void Debugger::OnException(Handle<Object> exception, bool uncaught) { 2214 void Debugger::OnException(Handle<Object> exception, bool uncaught) {
2214 HandleScope scope(isolate_); 2215 HandleScope scope(isolate_);
2215 Debug* debug = isolate_->debug(); 2216 Debug* debug = isolate_->debug();
2216 2217
2217 // Bail out based on state or if there is no listener for this event 2218 // Bail out based on state or if there is no listener for this event
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
2348 return; 2349 return;
2349 } 2350 }
2350 ASSERT(update_script_break_points->IsJSFunction()); 2351 ASSERT(update_script_break_points->IsJSFunction());
2351 2352
2352 // Wrap the script object in a proper JS object before passing it 2353 // Wrap the script object in a proper JS object before passing it
2353 // to JavaScript. 2354 // to JavaScript.
2354 Handle<JSValue> wrapper = GetScriptWrapper(script); 2355 Handle<JSValue> wrapper = GetScriptWrapper(script);
2355 2356
2356 // Call UpdateScriptBreakPoints expect no exceptions. 2357 // Call UpdateScriptBreakPoints expect no exceptions.
2357 bool caught_exception; 2358 bool caught_exception;
2358 const int argc = 1; 2359 Handle<Object> argv[] = { wrapper };
2359 Object** argv[argc] = { reinterpret_cast<Object**>(wrapper.location()) };
2360 Execution::TryCall(Handle<JSFunction>::cast(update_script_break_points), 2360 Execution::TryCall(Handle<JSFunction>::cast(update_script_break_points),
2361 Isolate::Current()->js_builtins_object(), argc, argv, 2361 Isolate::Current()->js_builtins_object(),
2362 &caught_exception); 2362 ARRAY_SIZE(argv),
2363 argv,
2364 &caught_exception);
2363 if (caught_exception) { 2365 if (caught_exception) {
2364 return; 2366 return;
2365 } 2367 }
2366 // Bail out based on state or if there is no listener for this event 2368 // Bail out based on state or if there is no listener for this event
2367 if (in_debugger && (after_compile_flags & SEND_WHEN_DEBUGGING) == 0) return; 2369 if (in_debugger && (after_compile_flags & SEND_WHEN_DEBUGGING) == 0) return;
2368 if (!Debugger::EventActive(v8::AfterCompile)) return; 2370 if (!Debugger::EventActive(v8::AfterCompile)) return;
2369 2371
2370 // Create the compile state object. 2372 // Create the compile state object.
2371 Handle<Object> event_data = MakeCompileEvent(script, 2373 Handle<Object> event_data = MakeCompileEvent(script,
2372 false, 2374 false,
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
2483 } 2485 }
2484 2486
2485 2487
2486 void Debugger::CallJSEventCallback(v8::DebugEvent event, 2488 void Debugger::CallJSEventCallback(v8::DebugEvent event,
2487 Handle<Object> exec_state, 2489 Handle<Object> exec_state,
2488 Handle<Object> event_data) { 2490 Handle<Object> event_data) {
2489 ASSERT(event_listener_->IsJSFunction()); 2491 ASSERT(event_listener_->IsJSFunction());
2490 Handle<JSFunction> fun(Handle<JSFunction>::cast(event_listener_)); 2492 Handle<JSFunction> fun(Handle<JSFunction>::cast(event_listener_));
2491 2493
2492 // Invoke the JavaScript debug event listener. 2494 // Invoke the JavaScript debug event listener.
2493 const int argc = 4; 2495 Handle<Object> argv[] = { Handle<Object>(Smi::FromInt(event)),
2494 Object** argv[argc] = { Handle<Object>(Smi::FromInt(event)).location(), 2496 exec_state,
2495 exec_state.location(), 2497 event_data,
2496 Handle<Object>::cast(event_data).location(), 2498 event_listener_data_ };
2497 event_listener_data_.location() };
2498 bool caught_exception; 2499 bool caught_exception;
2499 Execution::TryCall(fun, isolate_->global(), argc, argv, &caught_exception); 2500 Execution::TryCall(fun,
2501 isolate_->global(),
2502 ARRAY_SIZE(argv),
2503 argv,
2504 &caught_exception);
2500 // Silently ignore exceptions from debug event listeners. 2505 // Silently ignore exceptions from debug event listeners.
2501 } 2506 }
2502 2507
2503 2508
2504 Handle<Context> Debugger::GetDebugContext() { 2509 Handle<Context> Debugger::GetDebugContext() {
2505 never_unload_debugger_ = true; 2510 never_unload_debugger_ = true;
2506 EnterDebugger debugger; 2511 EnterDebugger debugger;
2507 return isolate_->debug()->debug_context(); 2512 return isolate_->debug()->debug_context();
2508 } 2513 }
2509 2514
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
2858 return isolate_->factory()->undefined_value(); 2863 return isolate_->factory()->undefined_value();
2859 } 2864 }
2860 2865
2861 // Create the execution state. 2866 // Create the execution state.
2862 bool caught_exception = false; 2867 bool caught_exception = false;
2863 Handle<Object> exec_state = MakeExecutionState(&caught_exception); 2868 Handle<Object> exec_state = MakeExecutionState(&caught_exception);
2864 if (caught_exception) { 2869 if (caught_exception) {
2865 return isolate_->factory()->undefined_value(); 2870 return isolate_->factory()->undefined_value();
2866 } 2871 }
2867 2872
2868 static const int kArgc = 2; 2873 Handle<Object> argv[] = { exec_state, data };
2869 Object** argv[kArgc] = { exec_state.location(), data.location() };
2870 Handle<Object> result = Execution::Call( 2874 Handle<Object> result = Execution::Call(
2871 fun, 2875 fun,
2872 Handle<Object>(isolate_->debug()->debug_context_->global_proxy()), 2876 Handle<Object>(isolate_->debug()->debug_context_->global_proxy()),
2873 kArgc, 2877 ARRAY_SIZE(argv),
2874 argv, 2878 argv,
2875 pending_exception); 2879 pending_exception);
2876 return result; 2880 return result;
2877 } 2881 }
2878 2882
2879 2883
2880 static void StubMessageHandler2(const v8::Debug::Message& message) { 2884 static void StubMessageHandler2(const v8::Debug::Message& message) {
2881 // Simply ignore message. 2885 // Simply ignore message.
2882 } 2886 }
2883 2887
(...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after
3321 { 3325 {
3322 Locker locker; 3326 Locker locker;
3323 Isolate::Current()->debugger()->CallMessageDispatchHandler(); 3327 Isolate::Current()->debugger()->CallMessageDispatchHandler();
3324 } 3328 }
3325 } 3329 }
3326 } 3330 }
3327 3331
3328 #endif // ENABLE_DEBUGGER_SUPPORT 3332 #endif // ENABLE_DEBUGGER_SUPPORT
3329 3333
3330 } } // namespace v8::internal 3334 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/debug.h ('k') | src/execution.h » ('j') | src/execution.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698