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

Side by Side Diff: src/debug.cc

Issue 300773002: Do not break in native code (including non-builtin debugger code). (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 6 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/objects.h » ('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 // 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 "v8.h" 5 #include "v8.h"
6 6
7 #include "api.h" 7 #include "api.h"
8 #include "arguments.h" 8 #include "arguments.h"
9 #include "bootstrapper.h" 9 #include "bootstrapper.h"
10 #include "code-stubs.h" 10 #include "code-stubs.h"
(...skipping 787 matching lines...) Expand 10 before | Expand all | Expand 10 after
798 if (caught_exception) return false; 798 if (caught_exception) return false;
799 799
800 debug_context_ = Handle<Context>::cast( 800 debug_context_ = Handle<Context>::cast(
801 isolate_->global_handles()->Create(*context)); 801 isolate_->global_handles()->Create(*context));
802 return true; 802 return true;
803 } 803 }
804 804
805 805
806 void Debug::Unload() { 806 void Debug::Unload() {
807 ClearAllBreakPoints(); 807 ClearAllBreakPoints();
808 ClearStepping();
808 809
809 // Match unmatched PromiseHandlePrologue calls. 810 // Match unmatched PromiseHandlePrologue calls.
810 while (thread_local_.promise_on_stack_) PromiseHandleEpilogue(); 811 while (thread_local_.promise_on_stack_) PromiseHandleEpilogue();
811 812
812 // Return debugger is not loaded. 813 // Return debugger is not loaded.
813 if (!IsLoaded()) return; 814 if (!IsLoaded()) return;
814 815
815 // Clear the script cache. 816 // Clear the script cache.
816 DestroyScriptCache(); 817 DestroyScriptCache();
817 818
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after
1202 } 1203 }
1203 } 1204 }
1204 1205
1205 1206
1206 void Debug::FloodBoundFunctionWithOneShot(Handle<JSFunction> function) { 1207 void Debug::FloodBoundFunctionWithOneShot(Handle<JSFunction> function) {
1207 Handle<FixedArray> new_bindings(function->function_bindings()); 1208 Handle<FixedArray> new_bindings(function->function_bindings());
1208 Handle<Object> bindee(new_bindings->get(JSFunction::kBoundFunctionIndex), 1209 Handle<Object> bindee(new_bindings->get(JSFunction::kBoundFunctionIndex),
1209 isolate_); 1210 isolate_);
1210 1211
1211 if (!bindee.is_null() && bindee->IsJSFunction() && 1212 if (!bindee.is_null() && bindee->IsJSFunction() &&
1212 !JSFunction::cast(*bindee)->IsBuiltin()) { 1213 !JSFunction::cast(*bindee)->IsNative()) {
1213 Handle<JSFunction> bindee_function(JSFunction::cast(*bindee)); 1214 Handle<JSFunction> bindee_function(JSFunction::cast(*bindee));
1214 Debug::FloodWithOneShot(bindee_function); 1215 Debug::FloodWithOneShot(bindee_function);
1215 } 1216 }
1216 } 1217 }
1217 1218
1218 1219
1219 void Debug::FloodHandlerWithOneShot() { 1220 void Debug::FloodHandlerWithOneShot() {
1220 // Iterate through the JavaScript stack looking for handlers. 1221 // Iterate through the JavaScript stack looking for handlers.
1221 StackFrame::Id id = break_frame_id(); 1222 StackFrame::Id id = break_frame_id();
1222 if (id == StackFrame::NO_ID) { 1223 if (id == StackFrame::NO_ID) {
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
1423 if (step_action == StepOut) { 1424 if (step_action == StepOut) {
1424 // Skip step_count frames starting with the current one. 1425 // Skip step_count frames starting with the current one.
1425 while (step_count-- > 0 && !frames_it.done()) { 1426 while (step_count-- > 0 && !frames_it.done()) {
1426 frames_it.Advance(); 1427 frames_it.Advance();
1427 } 1428 }
1428 } else { 1429 } else {
1429 ASSERT(it.IsExit()); 1430 ASSERT(it.IsExit());
1430 frames_it.Advance(); 1431 frames_it.Advance();
1431 } 1432 }
1432 // Skip builtin functions on the stack. 1433 // Skip builtin functions on the stack.
1433 while (!frames_it.done() && frames_it.frame()->function()->IsBuiltin()) { 1434 while (!frames_it.done() && frames_it.frame()->function()->IsNative()) {
1434 frames_it.Advance(); 1435 frames_it.Advance();
1435 } 1436 }
1436 // Step out: If there is a JavaScript caller frame, we need to 1437 // Step out: If there is a JavaScript caller frame, we need to
1437 // flood it with breakpoints. 1438 // flood it with breakpoints.
1438 if (!frames_it.done()) { 1439 if (!frames_it.done()) {
1439 // Fill the function to return to with one-shot break points. 1440 // Fill the function to return to with one-shot break points.
1440 JSFunction* function = frames_it.frame()->function(); 1441 JSFunction* function = frames_it.frame()->function();
1441 FloodWithOneShot(Handle<JSFunction>(function)); 1442 FloodWithOneShot(Handle<JSFunction>(function));
1442 // Set target frame pointer. 1443 // Set target frame pointer.
1443 ActivateStepOut(frames_it.frame()); 1444 ActivateStepOut(frames_it.frame());
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
1510 if (code != apply && code != call) break; 1511 if (code != apply && code != call) break;
1511 fun = frame->GetExpression( 1512 fun = frame->GetExpression(
1512 expressions_count - 1 - call_function_arg_count); 1513 expressions_count - 1 - call_function_arg_count);
1513 } 1514 }
1514 } 1515 }
1515 1516
1516 if (fun->IsJSFunction()) { 1517 if (fun->IsJSFunction()) {
1517 Handle<JSFunction> js_function(JSFunction::cast(fun)); 1518 Handle<JSFunction> js_function(JSFunction::cast(fun));
1518 if (js_function->shared()->bound()) { 1519 if (js_function->shared()->bound()) {
1519 Debug::FloodBoundFunctionWithOneShot(js_function); 1520 Debug::FloodBoundFunctionWithOneShot(js_function);
1520 } else if (!js_function->IsBuiltin()) { 1521 } else if (!js_function->IsNative()) {
1521 // Don't step into builtins. 1522 // Don't step into builtins.
1522 // It will also compile target function if it's not compiled yet. 1523 // It will also compile target function if it's not compiled yet.
1523 FloodWithOneShot(js_function); 1524 FloodWithOneShot(js_function);
1524 } 1525 }
1525 } 1526 }
1526 } 1527 }
1527 1528
1528 // Fill the current function with one-shot break points even for step in on 1529 // Fill the current function with one-shot break points even for step in on
1529 // a call target as the function called might be a native function for 1530 // a call target as the function called might be a native function for
1530 // which step in will not stop. It also prepares for stepping in 1531 // which step in will not stop. It also prepares for stepping in
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
1724 } 1725 }
1725 fp = it.frame()->fp(); 1726 fp = it.frame()->fp();
1726 } 1727 }
1727 1728
1728 // Flood the function with one-shot break points if it is called from where 1729 // Flood the function with one-shot break points if it is called from where
1729 // step into was requested. 1730 // step into was requested.
1730 if (fp == step_in_fp()) { 1731 if (fp == step_in_fp()) {
1731 if (function->shared()->bound()) { 1732 if (function->shared()->bound()) {
1732 // Handle Function.prototype.bind 1733 // Handle Function.prototype.bind
1733 Debug::FloodBoundFunctionWithOneShot(function); 1734 Debug::FloodBoundFunctionWithOneShot(function);
1734 } else if (!function->IsBuiltin()) { 1735 } else if (!function->IsNative()) {
1735 // Don't allow step into functions in the native context. 1736 // Don't allow step into functions in the native context.
1736 if (function->shared()->code() == 1737 if (function->shared()->code() ==
1737 isolate->builtins()->builtin(Builtins::kFunctionApply) || 1738 isolate->builtins()->builtin(Builtins::kFunctionApply) ||
1738 function->shared()->code() == 1739 function->shared()->code() ==
1739 isolate->builtins()->builtin(Builtins::kFunctionCall)) { 1740 isolate->builtins()->builtin(Builtins::kFunctionCall)) {
1740 // Handle function.apply and function.call separately to flood the 1741 // Handle function.apply and function.call separately to flood the
1741 // function to be called and not the code for Builtins::FunctionApply or 1742 // function to be called and not the code for Builtins::FunctionApply or
1742 // Builtins::FunctionCall. The receiver of call/apply is the target 1743 // Builtins::FunctionCall. The receiver of call/apply is the target
1743 // function. 1744 // function.
1744 if (!holder.is_null() && holder->IsJSFunction()) { 1745 if (!holder.is_null() && holder->IsJSFunction()) {
1745 Handle<JSFunction> js_function = Handle<JSFunction>::cast(holder); 1746 Handle<JSFunction> js_function = Handle<JSFunction>::cast(holder);
1746 if (!js_function->IsBuiltin()) { 1747 if (!js_function->IsNative()) {
1747 Debug::FloodWithOneShot(js_function); 1748 Debug::FloodWithOneShot(js_function);
1748 } else if (js_function->shared()->bound()) { 1749 } else if (js_function->shared()->bound()) {
1749 // Handle Function.prototype.bind 1750 // Handle Function.prototype.bind
1750 Debug::FloodBoundFunctionWithOneShot(js_function); 1751 Debug::FloodBoundFunctionWithOneShot(js_function);
1751 } 1752 }
1752 } 1753 }
1753 } else { 1754 } else {
1754 Debug::FloodWithOneShot(function); 1755 Debug::FloodWithOneShot(function);
1755 } 1756 }
1756 } 1757 }
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
2078 // debug break slots and are not active or inlined into an active 2079 // debug break slots and are not active or inlined into an active
2079 // function and mark them for lazy compilation. 2080 // function and mark them for lazy compilation.
2080 HeapObject* obj = NULL; 2081 HeapObject* obj = NULL;
2081 while (((obj = iterator.next()) != NULL)) { 2082 while (((obj = iterator.next()) != NULL)) {
2082 if (obj->IsJSFunction()) { 2083 if (obj->IsJSFunction()) {
2083 JSFunction* function = JSFunction::cast(obj); 2084 JSFunction* function = JSFunction::cast(obj);
2084 SharedFunctionInfo* shared = function->shared(); 2085 SharedFunctionInfo* shared = function->shared();
2085 2086
2086 if (!shared->allows_lazy_compilation()) continue; 2087 if (!shared->allows_lazy_compilation()) continue;
2087 if (!shared->script()->IsScript()) continue; 2088 if (!shared->script()->IsScript()) continue;
2088 if (function->IsBuiltin()) continue; 2089 if (function->IsNative()) continue;
2089 if (shared->code()->gc_metadata() == active_code_marker) continue; 2090 if (shared->code()->gc_metadata() == active_code_marker) continue;
2090 2091
2091 if (shared->is_generator()) { 2092 if (shared->is_generator()) {
2092 generator_functions.Add(Handle<JSFunction>(function, isolate_)); 2093 generator_functions.Add(Handle<JSFunction>(function, isolate_));
2093 continue; 2094 continue;
2094 } 2095 }
2095 2096
2096 Code::Kind kind = function->code()->kind(); 2097 Code::Kind kind = function->code()->kind();
2097 if (kind == Code::FUNCTION && 2098 if (kind == Code::FUNCTION &&
2098 !function->code()->has_debug_break_slots()) { 2099 !function->code()->has_debug_break_slots()) {
(...skipping 1443 matching lines...) Expand 10 before | Expand all | Expand 10 after
3542 logger_->DebugEvent("Put", message.text()); 3543 logger_->DebugEvent("Put", message.text());
3543 } 3544 }
3544 3545
3545 3546
3546 void LockingCommandMessageQueue::Clear() { 3547 void LockingCommandMessageQueue::Clear() {
3547 LockGuard<Mutex> lock_guard(&mutex_); 3548 LockGuard<Mutex> lock_guard(&mutex_);
3548 queue_.Clear(); 3549 queue_.Clear();
3549 } 3550 }
3550 3551
3551 } } // namespace v8::internal 3552 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698