| 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/debug/debug.h" | 5 #include "src/debug/debug.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 927 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 938 return; | 938 return; |
| 939 } | 939 } |
| 940 | 940 |
| 941 if (step_action != StepNext && step_action != StepMin) { | 941 if (step_action != StepNext && step_action != StepMin) { |
| 942 // If there's restarter frame on top of the stack, just get the pointer | 942 // If there's restarter frame on top of the stack, just get the pointer |
| 943 // to function which is going to be restarted. | 943 // to function which is going to be restarted. |
| 944 if (thread_local_.restarter_frame_function_pointer_ != NULL) { | 944 if (thread_local_.restarter_frame_function_pointer_ != NULL) { |
| 945 Handle<JSFunction> restarted_function( | 945 Handle<JSFunction> restarted_function( |
| 946 JSFunction::cast(*thread_local_.restarter_frame_function_pointer_)); | 946 JSFunction::cast(*thread_local_.restarter_frame_function_pointer_)); |
| 947 FloodWithOneShot(restarted_function); | 947 FloodWithOneShot(restarted_function); |
| 948 } else if (location.IsCall()) { | 948 } else if (location.IsStepInLocation()) { |
| 949 // Find target function on the expression stack. | 949 // Find target function on the expression stack. |
| 950 // Expression stack looks like this (top to bottom): | 950 // Expression stack looks like this (top to bottom): |
| 951 // argN | 951 // argN |
| 952 // ... | 952 // ... |
| 953 // arg0 | 953 // arg0 |
| 954 // Receiver | 954 // Receiver (only present for calls, not for construct). |
| 955 // Function to call | 955 // Function to call |
| 956 int base = location.IsCall() ? 2 : 1; |
| 956 int num_expressions_without_args = | 957 int num_expressions_without_args = |
| 957 frame->ComputeExpressionsCount() - location.CallArgumentsCount(); | 958 frame->ComputeExpressionsCount() - location.CallArgumentsCount(); |
| 958 DCHECK(num_expressions_without_args >= 2); | 959 DCHECK(num_expressions_without_args >= base); |
| 959 Object* fun = frame->GetExpression(num_expressions_without_args - 2); | 960 Object* fun = frame->GetExpression(num_expressions_without_args - base); |
| 960 | 961 |
| 961 // Flood the actual target of call/apply. | 962 // Flood the actual target of call/apply. |
| 962 if (fun->IsJSFunction()) { | 963 if (location.IsCall() && fun->IsJSFunction()) { |
| 963 Isolate* isolate = JSFunction::cast(fun)->GetIsolate(); | 964 Isolate* isolate = JSFunction::cast(fun)->GetIsolate(); |
| 964 Code* apply = isolate->builtins()->builtin(Builtins::kFunctionApply); | 965 Code* apply = isolate->builtins()->builtin(Builtins::kFunctionApply); |
| 965 Code* call = isolate->builtins()->builtin(Builtins::kFunctionCall); | 966 Code* call = isolate->builtins()->builtin(Builtins::kFunctionCall); |
| 966 // Find target function on the expression stack for expression like | 967 // Find target function on the expression stack for expression like |
| 967 // Function.call.call...apply(...) | 968 // Function.call.call...apply(...) |
| 968 int i = 1; | 969 int i = 1; |
| 969 while (fun->IsJSFunction()) { | 970 while (fun->IsJSFunction()) { |
| 970 Code* code = JSFunction::cast(fun)->shared()->code(); | 971 Code* code = JSFunction::cast(fun)->shared()->code(); |
| 971 if (code != apply && code != call) break; | 972 if (code != apply && code != call) break; |
| 972 DCHECK(num_expressions_without_args >= i); | 973 DCHECK(num_expressions_without_args >= i); |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1078 break; | 1079 break; |
| 1079 } | 1080 } |
| 1080 for (int j = 0; j < break_points; ++j) locations->set(count++, position); | 1081 for (int j = 0; j < break_points; ++j) locations->set(count++, position); |
| 1081 } | 1082 } |
| 1082 } | 1083 } |
| 1083 return locations; | 1084 return locations; |
| 1084 } | 1085 } |
| 1085 | 1086 |
| 1086 | 1087 |
| 1087 // Handle stepping into a function. | 1088 // Handle stepping into a function. |
| 1088 void Debug::HandleStepIn(Handle<Object> function_obj, bool is_constructor) { | 1089 void Debug::HandleStepIn(Handle<Object> function_obj) { |
| 1089 // Flood getter/setter if we either step in or step to another frame. | 1090 // Flood getter/setter if we either step in or step to another frame. |
| 1090 bool step_frame = thread_local_.last_step_action_ == StepFrame; | 1091 bool step_frame = thread_local_.last_step_action_ == StepFrame; |
| 1091 if (!StepInActive() && !step_frame) return; | 1092 if (!StepInActive() && !step_frame) return; |
| 1092 if (!function_obj->IsJSFunction()) return; | 1093 if (!function_obj->IsJSFunction()) return; |
| 1093 Handle<JSFunction> function = Handle<JSFunction>::cast(function_obj); | 1094 Handle<JSFunction> function = Handle<JSFunction>::cast(function_obj); |
| 1094 Isolate* isolate = function->GetIsolate(); | 1095 Isolate* isolate = function->GetIsolate(); |
| 1095 | 1096 |
| 1096 StackFrameIterator it(isolate); | 1097 StackFrameIterator it(isolate); |
| 1097 it.Advance(); | 1098 it.Advance(); |
| 1098 // For constructor functions skip another frame. | |
| 1099 if (is_constructor) { | |
| 1100 DCHECK(it.frame()->is_construct()); | |
| 1101 it.Advance(); | |
| 1102 } | |
| 1103 Address fp = it.frame()->fp(); | 1099 Address fp = it.frame()->fp(); |
| 1104 | 1100 |
| 1105 // Flood the function with one-shot break points if it is called from where | 1101 // Flood the function with one-shot break points if it is called from where |
| 1106 // step into was requested, or when stepping into a new frame. | 1102 // step into was requested, or when stepping into a new frame. |
| 1107 if (fp == thread_local_.step_into_fp_ || step_frame) { | 1103 if (fp == thread_local_.step_into_fp_ || step_frame) { |
| 1108 FloodWithOneShotGeneric(function, Handle<Object>()); | 1104 FloodWithOneShotGeneric(function, Handle<Object>()); |
| 1109 } | 1105 } |
| 1110 } | 1106 } |
| 1111 | 1107 |
| 1112 | 1108 |
| (...skipping 1476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2589 } | 2585 } |
| 2590 | 2586 |
| 2591 | 2587 |
| 2592 void LockingCommandMessageQueue::Clear() { | 2588 void LockingCommandMessageQueue::Clear() { |
| 2593 base::LockGuard<base::Mutex> lock_guard(&mutex_); | 2589 base::LockGuard<base::Mutex> lock_guard(&mutex_); |
| 2594 queue_.Clear(); | 2590 queue_.Clear(); |
| 2595 } | 2591 } |
| 2596 | 2592 |
| 2597 } // namespace internal | 2593 } // namespace internal |
| 2598 } // namespace v8 | 2594 } // namespace v8 |
| OLD | NEW |