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 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 | 246 |
247 Iterator it(debug_info, type); | 247 Iterator it(debug_info, type); |
248 it.SkipTo(closest_break); | 248 it.SkipTo(closest_break); |
249 return it.GetBreakLocation(); | 249 return it.GetBreakLocation(); |
250 } | 250 } |
251 | 251 |
252 | 252 |
253 void BreakLocation::SetBreakPoint(Handle<Object> break_point_object) { | 253 void BreakLocation::SetBreakPoint(Handle<Object> break_point_object) { |
254 // If there is not already a real break point here patch code with debug | 254 // If there is not already a real break point here patch code with debug |
255 // break. | 255 // break. |
| 256 DCHECK(code()->has_debug_break_slots()); |
256 if (!HasBreakPoint()) SetDebugBreak(); | 257 if (!HasBreakPoint()) SetDebugBreak(); |
257 DCHECK(IsDebugBreak() || IsDebuggerStatement()); | 258 DCHECK(IsDebugBreak() || IsDebuggerStatement()); |
258 // Set the break point information. | 259 // Set the break point information. |
259 DebugInfo::SetBreakPoint(debug_info_, pc_offset_, position_, | 260 DebugInfo::SetBreakPoint(debug_info_, pc_offset_, position_, |
260 statement_position_, break_point_object); | 261 statement_position_, break_point_object); |
261 } | 262 } |
262 | 263 |
263 | 264 |
264 void BreakLocation::ClearBreakPoint(Handle<Object> break_point_object) { | 265 void BreakLocation::ClearBreakPoint(Handle<Object> break_point_object) { |
265 // Clear the break point information. | 266 // Clear the break point information. |
(...skipping 810 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1076 } | 1077 } |
1077 // Remove all debug info. | 1078 // Remove all debug info. |
1078 while (debug_info_list_ != NULL) { | 1079 while (debug_info_list_ != NULL) { |
1079 RemoveDebugInfoAndClearFromShared(debug_info_list_->debug_info()); | 1080 RemoveDebugInfoAndClearFromShared(debug_info_list_->debug_info()); |
1080 } | 1081 } |
1081 } | 1082 } |
1082 | 1083 |
1083 | 1084 |
1084 void Debug::FloodWithOneShot(Handle<JSFunction> function, | 1085 void Debug::FloodWithOneShot(Handle<JSFunction> function, |
1085 BreakLocatorType type) { | 1086 BreakLocatorType type) { |
1086 // Do not ever break in native functions. | 1087 // Do not ever break in native and extension functions. |
1087 if (function->IsFromNativeScript()) return; | 1088 if (!function->IsSubjectToDebugging()) return; |
1088 | 1089 |
1089 PrepareForBreakPoints(); | 1090 PrepareForBreakPoints(); |
1090 | 1091 |
1091 // Make sure the function is compiled and has set up the debug info. | 1092 // Make sure the function is compiled and has set up the debug info. |
1092 Handle<SharedFunctionInfo> shared(function->shared()); | 1093 Handle<SharedFunctionInfo> shared(function->shared()); |
1093 if (!EnsureDebugInfo(shared, function)) { | 1094 if (!EnsureDebugInfo(shared, function)) { |
1094 // Return if we failed to retrieve the debug info. | 1095 // Return if we failed to retrieve the debug info. |
1095 return; | 1096 return; |
1096 } | 1097 } |
1097 | 1098 |
1098 // Flood the function with break points. | 1099 // Flood the function with break points. |
1099 for (BreakLocation::Iterator it(GetDebugInfo(shared), type); !it.Done(); | 1100 for (BreakLocation::Iterator it(GetDebugInfo(shared), type); !it.Done(); |
1100 it.Next()) { | 1101 it.Next()) { |
1101 it.GetBreakLocation().SetOneShot(); | 1102 it.GetBreakLocation().SetOneShot(); |
1102 } | 1103 } |
1103 } | 1104 } |
1104 | 1105 |
1105 | 1106 |
1106 void Debug::FloodBoundFunctionWithOneShot(Handle<JSFunction> function) { | 1107 void Debug::FloodBoundFunctionWithOneShot(Handle<JSFunction> function) { |
1107 Handle<FixedArray> new_bindings(function->function_bindings()); | 1108 Handle<FixedArray> new_bindings(function->function_bindings()); |
1108 Handle<Object> bindee(new_bindings->get(JSFunction::kBoundFunctionIndex), | 1109 Handle<Object> bindee(new_bindings->get(JSFunction::kBoundFunctionIndex), |
1109 isolate_); | 1110 isolate_); |
1110 | 1111 |
1111 if (!bindee.is_null() && bindee->IsJSFunction() && | 1112 if (!bindee.is_null() && bindee->IsJSFunction() && |
1112 !JSFunction::cast(*bindee)->IsFromNativeScript()) { | 1113 JSFunction::cast(*bindee)->IsSubjectToDebugging()) { |
1113 Handle<JSFunction> bindee_function(JSFunction::cast(*bindee)); | 1114 Handle<JSFunction> bindee_function(JSFunction::cast(*bindee)); |
1114 FloodWithOneShotGeneric(bindee_function); | 1115 FloodWithOneShotGeneric(bindee_function); |
1115 } | 1116 } |
1116 } | 1117 } |
1117 | 1118 |
1118 | 1119 |
1119 void Debug::FloodDefaultConstructorWithOneShot(Handle<JSFunction> function) { | 1120 void Debug::FloodDefaultConstructorWithOneShot(Handle<JSFunction> function) { |
1120 DCHECK(function->shared()->is_default_constructor()); | 1121 DCHECK(function->shared()->is_default_constructor()); |
1121 // Instead of stepping into the function we directly step into the super class | 1122 // Instead of stepping into the function we directly step into the super class |
1122 // constructor. | 1123 // constructor. |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1300 if (location.IsExit() || step_action == StepOut) { | 1301 if (location.IsExit() || step_action == StepOut) { |
1301 if (step_action == StepOut) { | 1302 if (step_action == StepOut) { |
1302 // Skip step_count frames starting with the current one. | 1303 // Skip step_count frames starting with the current one. |
1303 while (step_count-- > 0 && !frames_it.done()) { | 1304 while (step_count-- > 0 && !frames_it.done()) { |
1304 frames_it.Advance(); | 1305 frames_it.Advance(); |
1305 } | 1306 } |
1306 } else { | 1307 } else { |
1307 DCHECK(location.IsExit()); | 1308 DCHECK(location.IsExit()); |
1308 frames_it.Advance(); | 1309 frames_it.Advance(); |
1309 } | 1310 } |
1310 // Skip builtin functions on the stack. | 1311 // Skip native and extension functions on the stack. |
1311 while (!frames_it.done() && | 1312 while (!frames_it.done() && |
1312 frames_it.frame()->function()->IsFromNativeScript()) { | 1313 !frames_it.frame()->function()->IsSubjectToDebugging()) { |
1313 frames_it.Advance(); | 1314 frames_it.Advance(); |
1314 } | 1315 } |
1315 // Step out: If there is a JavaScript caller frame, we need to | 1316 // Step out: If there is a JavaScript caller frame, we need to |
1316 // flood it with breakpoints. | 1317 // flood it with breakpoints. |
1317 if (!frames_it.done()) { | 1318 if (!frames_it.done()) { |
1318 // Fill the function to return to with one-shot break points. | 1319 // Fill the function to return to with one-shot break points. |
1319 JSFunction* function = frames_it.frame()->function(); | 1320 JSFunction* function = frames_it.frame()->function(); |
1320 FloodWithOneShot(Handle<JSFunction>(function)); | 1321 FloodWithOneShot(Handle<JSFunction>(function)); |
1321 // Set target frame pointer. | 1322 // Set target frame pointer. |
1322 ActivateStepOut(frames_it.frame()); | 1323 ActivateStepOut(frames_it.frame()); |
(...skipping 635 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1958 } | 1959 } |
1959 | 1960 |
1960 // Now recompile all functions with activation frames and and | 1961 // Now recompile all functions with activation frames and and |
1961 // patch the return address to run in the new compiled code. It could be | 1962 // patch the return address to run in the new compiled code. It could be |
1962 // that some active functions were recompiled already by the suspended | 1963 // that some active functions were recompiled already by the suspended |
1963 // generator recompilation pass above; a generator with suspended | 1964 // generator recompilation pass above; a generator with suspended |
1964 // activations could also have active activations. That's fine. | 1965 // activations could also have active activations. That's fine. |
1965 for (int i = 0; i < active_functions.length(); i++) { | 1966 for (int i = 0; i < active_functions.length(); i++) { |
1966 Handle<JSFunction> function = active_functions[i]; | 1967 Handle<JSFunction> function = active_functions[i]; |
1967 Handle<SharedFunctionInfo> shared(function->shared()); | 1968 Handle<SharedFunctionInfo> shared(function->shared()); |
1968 | 1969 if (!shared->allows_lazy_compilation()) { |
1969 // If recompilation is not possible just skip it. | 1970 // Ignore functions that cannot be recompiled. Fortunately, those are |
1970 if (!shared->allows_lazy_compilation()) continue; | 1971 // only ones that are not subject to debugging in the first place. |
| 1972 DCHECK(!function->IsSubjectToDebugging()); |
| 1973 continue; |
| 1974 } |
1971 if (shared->code()->kind() == Code::BUILTIN) continue; | 1975 if (shared->code()->kind() == Code::BUILTIN) continue; |
1972 | 1976 |
1973 EnsureFunctionHasDebugBreakSlots(function); | 1977 EnsureFunctionHasDebugBreakSlots(function); |
1974 } | 1978 } |
1975 | 1979 |
1976 RedirectActivationsToRecompiledCodeOnThread(isolate_, | 1980 RedirectActivationsToRecompiledCodeOnThread(isolate_, |
1977 isolate_->thread_local_top()); | 1981 isolate_->thread_local_top()); |
1978 | 1982 |
1979 ActiveFunctionsRedirector active_functions_redirector; | 1983 ActiveFunctionsRedirector active_functions_redirector; |
1980 isolate_->thread_manager()->IterateArchivedThreads( | 1984 isolate_->thread_manager()->IterateArchivedThreads( |
(...skipping 1405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3386 } | 3390 } |
3387 | 3391 |
3388 | 3392 |
3389 void LockingCommandMessageQueue::Clear() { | 3393 void LockingCommandMessageQueue::Clear() { |
3390 base::LockGuard<base::Mutex> lock_guard(&mutex_); | 3394 base::LockGuard<base::Mutex> lock_guard(&mutex_); |
3391 queue_.Clear(); | 3395 queue_.Clear(); |
3392 } | 3396 } |
3393 | 3397 |
3394 } // namespace internal | 3398 } // namespace internal |
3395 } // namespace v8 | 3399 } // namespace v8 |
OLD | NEW |