| OLD | NEW |
| 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 21 matching lines...) Expand all Loading... |
| 32 #include "bootstrapper.h" | 32 #include "bootstrapper.h" |
| 33 #include "code-stubs.h" | 33 #include "code-stubs.h" |
| 34 #include "codegen.h" | 34 #include "codegen.h" |
| 35 #include "compilation-cache.h" | 35 #include "compilation-cache.h" |
| 36 #include "compiler.h" | 36 #include "compiler.h" |
| 37 #include "debug.h" | 37 #include "debug.h" |
| 38 #include "execution.h" | 38 #include "execution.h" |
| 39 #include "global-handles.h" | 39 #include "global-handles.h" |
| 40 #include "ic.h" | 40 #include "ic.h" |
| 41 #include "ic-inl.h" | 41 #include "ic-inl.h" |
| 42 #include "messages.h" |
| 42 #include "natives.h" | 43 #include "natives.h" |
| 43 #include "stub-cache.h" | 44 #include "stub-cache.h" |
| 44 #include "log.h" | 45 #include "log.h" |
| 45 | 46 |
| 46 #include "../include/v8-debug.h" | 47 #include "../include/v8-debug.h" |
| 47 | 48 |
| 48 namespace v8 { | 49 namespace v8 { |
| 49 namespace internal { | 50 namespace internal { |
| 50 | 51 |
| 51 #ifdef ENABLE_DEBUGGER_SUPPORT | 52 #ifdef ENABLE_DEBUGGER_SUPPORT |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 ASSERT(position_ >= 0); | 117 ASSERT(position_ >= 0); |
| 117 ASSERT(statement_position_ >= 0); | 118 ASSERT(statement_position_ >= 0); |
| 118 } | 119 } |
| 119 | 120 |
| 120 // Check for breakable code target. Look in the original code as setting | 121 // Check for breakable code target. Look in the original code as setting |
| 121 // break points can cause the code targets in the running (debugged) code to | 122 // break points can cause the code targets in the running (debugged) code to |
| 122 // be of a different kind than in the original code. | 123 // be of a different kind than in the original code. |
| 123 if (RelocInfo::IsCodeTarget(rmode())) { | 124 if (RelocInfo::IsCodeTarget(rmode())) { |
| 124 Address target = original_rinfo()->target_address(); | 125 Address target = original_rinfo()->target_address(); |
| 125 Code* code = Code::GetCodeFromTargetAddress(target); | 126 Code* code = Code::GetCodeFromTargetAddress(target); |
| 126 if (code->is_inline_cache_stub() || RelocInfo::IsConstructCall(rmode())) { | 127 if ((code->is_inline_cache_stub() && |
| 128 code->kind() != Code::BINARY_OP_IC) || |
| 129 RelocInfo::IsConstructCall(rmode())) { |
| 127 break_point_++; | 130 break_point_++; |
| 128 return; | 131 return; |
| 129 } | 132 } |
| 130 if (code->kind() == Code::STUB) { | 133 if (code->kind() == Code::STUB) { |
| 131 if (IsDebuggerStatement()) { | 134 if (IsDebuggerStatement()) { |
| 132 break_point_++; | 135 break_point_++; |
| 133 return; | 136 return; |
| 134 } | 137 } |
| 135 if (type_ == ALL_BREAK_LOCATIONS) { | 138 if (type_ == ALL_BREAK_LOCATIONS) { |
| 136 if (Debug::IsBreakStub(code)) { | 139 if (Debug::IsBreakStub(code)) { |
| (...skipping 616 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 753 // Expose the builtins object in the debugger context. | 756 // Expose the builtins object in the debugger context. |
| 754 Handle<String> key = Factory::LookupAsciiSymbol("builtins"); | 757 Handle<String> key = Factory::LookupAsciiSymbol("builtins"); |
| 755 Handle<GlobalObject> global = Handle<GlobalObject>(context->global()); | 758 Handle<GlobalObject> global = Handle<GlobalObject>(context->global()); |
| 756 SetProperty(global, key, Handle<Object>(global->builtins()), NONE); | 759 SetProperty(global, key, Handle<Object>(global->builtins()), NONE); |
| 757 | 760 |
| 758 // Compile the JavaScript for the debugger in the debugger context. | 761 // Compile the JavaScript for the debugger in the debugger context. |
| 759 Debugger::set_compiling_natives(true); | 762 Debugger::set_compiling_natives(true); |
| 760 bool caught_exception = | 763 bool caught_exception = |
| 761 !CompileDebuggerScript(Natives::GetIndex("mirror")) || | 764 !CompileDebuggerScript(Natives::GetIndex("mirror")) || |
| 762 !CompileDebuggerScript(Natives::GetIndex("debug")); | 765 !CompileDebuggerScript(Natives::GetIndex("debug")); |
| 766 |
| 767 if (FLAG_enable_liveedit) { |
| 768 caught_exception = caught_exception || |
| 769 !CompileDebuggerScript(Natives::GetIndex("liveedit")); |
| 770 } |
| 771 |
| 763 Debugger::set_compiling_natives(false); | 772 Debugger::set_compiling_natives(false); |
| 764 | 773 |
| 765 // Make sure we mark the debugger as not loading before we might | 774 // Make sure we mark the debugger as not loading before we might |
| 766 // return. | 775 // return. |
| 767 Debugger::set_loading_debugger(false); | 776 Debugger::set_loading_debugger(false); |
| 768 | 777 |
| 769 // Check for caught exceptions. | 778 // Check for caught exceptions. |
| 770 if (caught_exception) return false; | 779 if (caught_exception) return false; |
| 771 | 780 |
| 772 // Debugger loaded. | 781 // Debugger loaded. |
| (...skipping 562 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1335 return major_key == CodeStub::CallFunction || | 1344 return major_key == CodeStub::CallFunction || |
| 1336 major_key == CodeStub::StackCheck; | 1345 major_key == CodeStub::StackCheck; |
| 1337 } | 1346 } |
| 1338 | 1347 |
| 1339 | 1348 |
| 1340 // Find the builtin to use for invoking the debug break | 1349 // Find the builtin to use for invoking the debug break |
| 1341 Handle<Code> Debug::FindDebugBreak(Handle<Code> code, RelocInfo::Mode mode) { | 1350 Handle<Code> Debug::FindDebugBreak(Handle<Code> code, RelocInfo::Mode mode) { |
| 1342 // Find the builtin debug break function matching the calling convention | 1351 // Find the builtin debug break function matching the calling convention |
| 1343 // used by the call site. | 1352 // used by the call site. |
| 1344 if (code->is_inline_cache_stub()) { | 1353 if (code->is_inline_cache_stub()) { |
| 1345 if (code->is_call_stub()) { | 1354 switch (code->kind()) { |
| 1346 return ComputeCallDebugBreak(code->arguments_count()); | 1355 case Code::CALL_IC: |
| 1347 } | 1356 return ComputeCallDebugBreak(code->arguments_count()); |
| 1348 if (code->is_load_stub()) { | 1357 |
| 1349 return Handle<Code>(Builtins::builtin(Builtins::LoadIC_DebugBreak)); | 1358 case Code::LOAD_IC: |
| 1350 } | 1359 return Handle<Code>(Builtins::builtin(Builtins::LoadIC_DebugBreak)); |
| 1351 if (code->is_store_stub()) { | 1360 |
| 1352 return Handle<Code>(Builtins::builtin(Builtins::StoreIC_DebugBreak)); | 1361 case Code::STORE_IC: |
| 1353 } | 1362 return Handle<Code>(Builtins::builtin(Builtins::StoreIC_DebugBreak)); |
| 1354 if (code->is_keyed_load_stub()) { | 1363 |
| 1355 Handle<Code> result = | 1364 case Code::KEYED_LOAD_IC: |
| 1356 Handle<Code>(Builtins::builtin(Builtins::KeyedLoadIC_DebugBreak)); | 1365 return Handle<Code>( |
| 1357 return result; | 1366 Builtins::builtin(Builtins::KeyedLoadIC_DebugBreak)); |
| 1358 } | 1367 |
| 1359 if (code->is_keyed_store_stub()) { | 1368 case Code::KEYED_STORE_IC: |
| 1360 Handle<Code> result = | 1369 return Handle<Code>( |
| 1361 Handle<Code>(Builtins::builtin(Builtins::KeyedStoreIC_DebugBreak)); | 1370 Builtins::builtin(Builtins::KeyedStoreIC_DebugBreak)); |
| 1362 return result; | 1371 |
| 1372 default: |
| 1373 UNREACHABLE(); |
| 1363 } | 1374 } |
| 1364 } | 1375 } |
| 1365 if (RelocInfo::IsConstructCall(mode)) { | 1376 if (RelocInfo::IsConstructCall(mode)) { |
| 1366 Handle<Code> result = | 1377 Handle<Code> result = |
| 1367 Handle<Code>(Builtins::builtin(Builtins::ConstructCall_DebugBreak)); | 1378 Handle<Code>(Builtins::builtin(Builtins::ConstructCall_DebugBreak)); |
| 1368 return result; | 1379 return result; |
| 1369 } | 1380 } |
| 1370 if (code->kind() == Code::STUB) { | 1381 if (code->kind() == Code::STUB) { |
| 1371 ASSERT(code->major_key() == CodeStub::CallFunction || | 1382 ASSERT(code->major_key() == CodeStub::CallFunction || |
| 1372 code->major_key() == CodeStub::StackCheck); | 1383 code->major_key() == CodeStub::StackCheck); |
| (...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1957 } | 1968 } |
| 1958 | 1969 |
| 1959 // Process debug event. | 1970 // Process debug event. |
| 1960 ProcessDebugEvent(v8::BeforeCompile, | 1971 ProcessDebugEvent(v8::BeforeCompile, |
| 1961 Handle<JSObject>::cast(event_data), | 1972 Handle<JSObject>::cast(event_data), |
| 1962 true); | 1973 true); |
| 1963 } | 1974 } |
| 1964 | 1975 |
| 1965 | 1976 |
| 1966 // Handle debugger actions when a new script is compiled. | 1977 // Handle debugger actions when a new script is compiled. |
| 1967 void Debugger::OnAfterCompile(Handle<Script> script, Handle<JSFunction> fun) { | 1978 void Debugger::OnAfterCompile(Handle<Script> script, |
| 1979 AfterCompileFlags after_compile_flags) { |
| 1968 HandleScope scope; | 1980 HandleScope scope; |
| 1969 | 1981 |
| 1970 // Add the newly compiled script to the script cache. | 1982 // Add the newly compiled script to the script cache. |
| 1971 Debug::AddScriptToScriptCache(script); | 1983 Debug::AddScriptToScriptCache(script); |
| 1972 | 1984 |
| 1973 // No more to do if not debugging. | 1985 // No more to do if not debugging. |
| 1974 if (!IsDebuggerActive()) return; | 1986 if (!IsDebuggerActive()) return; |
| 1975 | 1987 |
| 1976 // No compile events while compiling natives. | 1988 // No compile events while compiling natives. |
| 1977 if (compiling_natives()) return; | 1989 if (compiling_natives()) return; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 2004 const int argc = 1; | 2016 const int argc = 1; |
| 2005 Object** argv[argc] = { reinterpret_cast<Object**>(wrapper.location()) }; | 2017 Object** argv[argc] = { reinterpret_cast<Object**>(wrapper.location()) }; |
| 2006 Handle<Object> result = Execution::TryCall( | 2018 Handle<Object> result = Execution::TryCall( |
| 2007 Handle<JSFunction>::cast(update_script_break_points), | 2019 Handle<JSFunction>::cast(update_script_break_points), |
| 2008 Top::builtins(), argc, argv, | 2020 Top::builtins(), argc, argv, |
| 2009 &caught_exception); | 2021 &caught_exception); |
| 2010 if (caught_exception) { | 2022 if (caught_exception) { |
| 2011 return; | 2023 return; |
| 2012 } | 2024 } |
| 2013 // Bail out based on state or if there is no listener for this event | 2025 // Bail out based on state or if there is no listener for this event |
| 2014 if (in_debugger) return; | 2026 if (in_debugger && (after_compile_flags & SEND_WHEN_DEBUGGING) == 0) return; |
| 2015 if (!Debugger::EventActive(v8::AfterCompile)) return; | 2027 if (!Debugger::EventActive(v8::AfterCompile)) return; |
| 2016 | 2028 |
| 2017 // Create the compile state object. | 2029 // Create the compile state object. |
| 2018 Handle<Object> event_data = MakeCompileEvent(script, | 2030 Handle<Object> event_data = MakeCompileEvent(script, |
| 2019 false, | 2031 false, |
| 2020 &caught_exception); | 2032 &caught_exception); |
| 2021 // Bail out and don't call debugger if exception. | 2033 // Bail out and don't call debugger if exception. |
| 2022 if (caught_exception) { | 2034 if (caught_exception) { |
| 2023 return; | 2035 return; |
| 2024 } | 2036 } |
| (...skipping 768 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2793 { | 2805 { |
| 2794 Locker locker; | 2806 Locker locker; |
| 2795 Debugger::CallMessageDispatchHandler(); | 2807 Debugger::CallMessageDispatchHandler(); |
| 2796 } | 2808 } |
| 2797 } | 2809 } |
| 2798 } | 2810 } |
| 2799 | 2811 |
| 2800 #endif // ENABLE_DEBUGGER_SUPPORT | 2812 #endif // ENABLE_DEBUGGER_SUPPORT |
| 2801 | 2813 |
| 2802 } } // namespace v8::internal | 2814 } } // namespace v8::internal |
| OLD | NEW |