| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 745 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 756 Handle<String> script_name = factory->NewStringFromAscii(name); | 756 Handle<String> script_name = factory->NewStringFromAscii(name); |
| 757 Handle<Context> context = isolate->native_context(); | 757 Handle<Context> context = isolate->native_context(); |
| 758 | 758 |
| 759 // Compile the script. | 759 // Compile the script. |
| 760 Handle<SharedFunctionInfo> function_info; | 760 Handle<SharedFunctionInfo> function_info; |
| 761 function_info = Compiler::CompileScript(source_code, | 761 function_info = Compiler::CompileScript(source_code, |
| 762 script_name, 0, 0, | 762 script_name, 0, 0, |
| 763 false, | 763 false, |
| 764 context, | 764 context, |
| 765 NULL, NULL, | 765 NULL, NULL, |
| 766 Handle<String>::null(), | |
| 767 NATIVES_CODE); | 766 NATIVES_CODE); |
| 768 | 767 |
| 769 // Silently ignore stack overflows during compilation. | 768 // Silently ignore stack overflows during compilation. |
| 770 if (function_info.is_null()) { | 769 if (function_info.is_null()) { |
| 771 ASSERT(isolate->has_pending_exception()); | 770 ASSERT(isolate->has_pending_exception()); |
| 772 isolate->clear_pending_exception(); | 771 isolate->clear_pending_exception(); |
| 773 return false; | 772 return false; |
| 774 } | 773 } |
| 775 | 774 |
| 776 // Execute the shared function in the debugger context. | 775 // Execute the shared function in the debugger context. |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 846 // Expose the builtins object in the debugger context. | 845 // Expose the builtins object in the debugger context. |
| 847 Handle<String> key = isolate_->factory()->InternalizeOneByteString( | 846 Handle<String> key = isolate_->factory()->InternalizeOneByteString( |
| 848 STATIC_ASCII_VECTOR("builtins")); | 847 STATIC_ASCII_VECTOR("builtins")); |
| 849 Handle<GlobalObject> global = Handle<GlobalObject>(context->global_object()); | 848 Handle<GlobalObject> global = Handle<GlobalObject>(context->global_object()); |
| 850 RETURN_IF_EMPTY_HANDLE_VALUE( | 849 RETURN_IF_EMPTY_HANDLE_VALUE( |
| 851 isolate_, | 850 isolate_, |
| 852 JSReceiver::SetProperty(global, | 851 JSReceiver::SetProperty(global, |
| 853 key, | 852 key, |
| 854 Handle<Object>(global->builtins(), isolate_), | 853 Handle<Object>(global->builtins(), isolate_), |
| 855 NONE, | 854 NONE, |
| 856 kNonStrictMode), | 855 SLOPPY), |
| 857 false); | 856 false); |
| 858 | 857 |
| 859 // Compile the JavaScript for the debugger in the debugger context. | 858 // Compile the JavaScript for the debugger in the debugger context. |
| 860 debugger->set_compiling_natives(true); | 859 debugger->set_compiling_natives(true); |
| 861 bool caught_exception = | 860 bool caught_exception = |
| 862 !CompileDebuggerScript(isolate_, Natives::GetIndex("mirror")) || | 861 !CompileDebuggerScript(isolate_, Natives::GetIndex("mirror")) || |
| 863 !CompileDebuggerScript(isolate_, Natives::GetIndex("debug")); | 862 !CompileDebuggerScript(isolate_, Natives::GetIndex("debug")); |
| 864 | 863 |
| 865 if (FLAG_enable_liveedit) { | 864 if (FLAG_enable_liveedit) { |
| 866 caught_exception = caught_exception || | 865 caught_exception = caught_exception || |
| (...skipping 1026 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1893 Handle<Code> frame_code(frame->LookupCode()); | 1892 Handle<Code> frame_code(frame->LookupCode()); |
| 1894 if (frame_code->has_debug_break_slots()) continue; | 1893 if (frame_code->has_debug_break_slots()) continue; |
| 1895 | 1894 |
| 1896 Handle<Code> new_code(function->shared()->code()); | 1895 Handle<Code> new_code(function->shared()->code()); |
| 1897 if (new_code->kind() != Code::FUNCTION || | 1896 if (new_code->kind() != Code::FUNCTION || |
| 1898 !new_code->has_debug_break_slots()) { | 1897 !new_code->has_debug_break_slots()) { |
| 1899 continue; | 1898 continue; |
| 1900 } | 1899 } |
| 1901 | 1900 |
| 1902 // Iterate over the RelocInfo in the original code to compute the sum of the | 1901 // Iterate over the RelocInfo in the original code to compute the sum of the |
| 1903 // constant pools sizes. (See Assembler::CheckConstPool()) | 1902 // constant pools and veneer pools sizes. (See Assembler::CheckConstPool() |
| 1904 // Note that this is only useful for architectures using constant pools. | 1903 // and Assembler::CheckVeneerPool()) |
| 1905 int constpool_mask = RelocInfo::ModeMask(RelocInfo::CONST_POOL); | 1904 // Note that this is only useful for architectures using constant pools or |
| 1906 int frame_const_pool_size = 0; | 1905 // veneer pools. |
| 1907 for (RelocIterator it(*frame_code, constpool_mask); !it.done(); it.next()) { | 1906 int pool_mask = RelocInfo::ModeMask(RelocInfo::CONST_POOL) | |
| 1907 RelocInfo::ModeMask(RelocInfo::VENEER_POOL); |
| 1908 int frame_pool_size = 0; |
| 1909 for (RelocIterator it(*frame_code, pool_mask); !it.done(); it.next()) { |
| 1908 RelocInfo* info = it.rinfo(); | 1910 RelocInfo* info = it.rinfo(); |
| 1909 if (info->pc() >= frame->pc()) break; | 1911 if (info->pc() >= frame->pc()) break; |
| 1910 frame_const_pool_size += static_cast<int>(info->data()); | 1912 frame_pool_size += static_cast<int>(info->data()); |
| 1911 } | 1913 } |
| 1912 intptr_t frame_offset = | 1914 intptr_t frame_offset = |
| 1913 frame->pc() - frame_code->instruction_start() - frame_const_pool_size; | 1915 frame->pc() - frame_code->instruction_start() - frame_pool_size; |
| 1914 | 1916 |
| 1915 // Iterate over the RelocInfo for new code to find the number of bytes | 1917 // Iterate over the RelocInfo for new code to find the number of bytes |
| 1916 // generated for debug slots and constant pools. | 1918 // generated for debug slots and constant pools. |
| 1917 int debug_break_slot_bytes = 0; | 1919 int debug_break_slot_bytes = 0; |
| 1918 int new_code_const_pool_size = 0; | 1920 int new_code_pool_size = 0; |
| 1919 int mask = RelocInfo::ModeMask(RelocInfo::DEBUG_BREAK_SLOT) | | 1921 int mask = RelocInfo::ModeMask(RelocInfo::DEBUG_BREAK_SLOT) | |
| 1920 RelocInfo::ModeMask(RelocInfo::CONST_POOL); | 1922 RelocInfo::ModeMask(RelocInfo::CONST_POOL) | |
| 1923 RelocInfo::ModeMask(RelocInfo::VENEER_POOL); |
| 1921 for (RelocIterator it(*new_code, mask); !it.done(); it.next()) { | 1924 for (RelocIterator it(*new_code, mask); !it.done(); it.next()) { |
| 1922 // Check if the pc in the new code with debug break | 1925 // Check if the pc in the new code with debug break |
| 1923 // slots is before this slot. | 1926 // slots is before this slot. |
| 1924 RelocInfo* info = it.rinfo(); | 1927 RelocInfo* info = it.rinfo(); |
| 1925 intptr_t new_offset = info->pc() - new_code->instruction_start() - | 1928 intptr_t new_offset = info->pc() - new_code->instruction_start() - |
| 1926 new_code_const_pool_size - debug_break_slot_bytes; | 1929 new_code_pool_size - debug_break_slot_bytes; |
| 1927 if (new_offset >= frame_offset) { | 1930 if (new_offset >= frame_offset) { |
| 1928 break; | 1931 break; |
| 1929 } | 1932 } |
| 1930 | 1933 |
| 1931 if (RelocInfo::IsDebugBreakSlot(info->rmode())) { | 1934 if (RelocInfo::IsDebugBreakSlot(info->rmode())) { |
| 1932 debug_break_slot_bytes += Assembler::kDebugBreakSlotLength; | 1935 debug_break_slot_bytes += Assembler::kDebugBreakSlotLength; |
| 1933 } else { | 1936 } else { |
| 1934 ASSERT(RelocInfo::IsConstPool(info->rmode())); | 1937 ASSERT(RelocInfo::IsConstPool(info->rmode())); |
| 1935 // The size of the constant pool is encoded in the data. | 1938 // The size of the pools is encoded in the data. |
| 1936 new_code_const_pool_size += static_cast<int>(info->data()); | 1939 new_code_pool_size += static_cast<int>(info->data()); |
| 1937 } | 1940 } |
| 1938 } | 1941 } |
| 1939 | 1942 |
| 1940 // Compute the equivalent pc in the new code. | 1943 // Compute the equivalent pc in the new code. |
| 1941 byte* new_pc = new_code->instruction_start() + frame_offset + | 1944 byte* new_pc = new_code->instruction_start() + frame_offset + |
| 1942 debug_break_slot_bytes + new_code_const_pool_size; | 1945 debug_break_slot_bytes + new_code_pool_size; |
| 1943 | 1946 |
| 1944 if (FLAG_trace_deopt) { | 1947 if (FLAG_trace_deopt) { |
| 1945 PrintF("Replacing code %08" V8PRIxPTR " - %08" V8PRIxPTR " (%d) " | 1948 PrintF("Replacing code %08" V8PRIxPTR " - %08" V8PRIxPTR " (%d) " |
| 1946 "with %08" V8PRIxPTR " - %08" V8PRIxPTR " (%d) " | 1949 "with %08" V8PRIxPTR " - %08" V8PRIxPTR " (%d) " |
| 1947 "for debugging, " | 1950 "for debugging, " |
| 1948 "changing pc from %08" V8PRIxPTR " to %08" V8PRIxPTR "\n", | 1951 "changing pc from %08" V8PRIxPTR " to %08" V8PRIxPTR "\n", |
| 1949 reinterpret_cast<intptr_t>( | 1952 reinterpret_cast<intptr_t>( |
| 1950 frame_code->instruction_start()), | 1953 frame_code->instruction_start()), |
| 1951 reinterpret_cast<intptr_t>( | 1954 reinterpret_cast<intptr_t>( |
| 1952 frame_code->instruction_start()) + | 1955 frame_code->instruction_start()) + |
| (...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2353 | 2356 |
| 2354 // Move back to where the call instruction sequence started. | 2357 // Move back to where the call instruction sequence started. |
| 2355 thread_local_.after_break_target_ = | 2358 thread_local_.after_break_target_ = |
| 2356 addr - Assembler::kPatchReturnSequenceAddressOffset; | 2359 addr - Assembler::kPatchReturnSequenceAddressOffset; |
| 2357 } else if (at_debug_break_slot) { | 2360 } else if (at_debug_break_slot) { |
| 2358 // Address of where the debug break slot starts. | 2361 // Address of where the debug break slot starts. |
| 2359 addr = addr - Assembler::kPatchDebugBreakSlotAddressOffset; | 2362 addr = addr - Assembler::kPatchDebugBreakSlotAddressOffset; |
| 2360 | 2363 |
| 2361 // Continue just after the slot. | 2364 // Continue just after the slot. |
| 2362 thread_local_.after_break_target_ = addr + Assembler::kDebugBreakSlotLength; | 2365 thread_local_.after_break_target_ = addr + Assembler::kDebugBreakSlotLength; |
| 2363 } else if (IsDebugBreak(Assembler::target_address_at(addr))) { | 2366 } else if (IsDebugBreak(Assembler::target_address_at(addr, *code))) { |
| 2364 // We now know that there is still a debug break call at the target address, | 2367 // We now know that there is still a debug break call at the target address, |
| 2365 // so the break point is still there and the original code will hold the | 2368 // so the break point is still there and the original code will hold the |
| 2366 // address to jump to in order to complete the call which is replaced by a | 2369 // address to jump to in order to complete the call which is replaced by a |
| 2367 // call to DebugBreakXXX. | 2370 // call to DebugBreakXXX. |
| 2368 | 2371 |
| 2369 // Find the corresponding address in the original code. | 2372 // Find the corresponding address in the original code. |
| 2370 addr += original_code->instruction_start() - code->instruction_start(); | 2373 addr += original_code->instruction_start() - code->instruction_start(); |
| 2371 | 2374 |
| 2372 // Install jump to the call address in the original code. This will be the | 2375 // Install jump to the call address in the original code. This will be the |
| 2373 // call which was overwritten by the call to DebugBreakXXX. | 2376 // call which was overwritten by the call to DebugBreakXXX. |
| 2374 thread_local_.after_break_target_ = Assembler::target_address_at(addr); | 2377 thread_local_.after_break_target_ = |
| 2378 Assembler::target_address_at(addr, *original_code); |
| 2375 } else { | 2379 } else { |
| 2376 // There is no longer a break point present. Don't try to look in the | 2380 // There is no longer a break point present. Don't try to look in the |
| 2377 // original code as the running code will have the right address. This takes | 2381 // original code as the running code will have the right address. This takes |
| 2378 // care of the case where the last break point is removed from the function | 2382 // care of the case where the last break point is removed from the function |
| 2379 // and therefore no "original code" is available. | 2383 // and therefore no "original code" is available. |
| 2380 thread_local_.after_break_target_ = Assembler::target_address_at(addr); | 2384 thread_local_.after_break_target_ = |
| 2385 Assembler::target_address_at(addr, *code); |
| 2381 } | 2386 } |
| 2382 } | 2387 } |
| 2383 | 2388 |
| 2384 | 2389 |
| 2385 bool Debug::IsBreakAtReturn(JavaScriptFrame* frame) { | 2390 bool Debug::IsBreakAtReturn(JavaScriptFrame* frame) { |
| 2386 HandleScope scope(isolate_); | 2391 HandleScope scope(isolate_); |
| 2387 | 2392 |
| 2388 // If there are no break points this cannot be break at return, as | 2393 // If there are no break points this cannot be break at return, as |
| 2389 // the debugger statement and stack guard bebug break cannot be at | 2394 // the debugger statement and stack guard bebug break cannot be at |
| 2390 // return. | 2395 // return. |
| (...skipping 1413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3804 { | 3809 { |
| 3805 Locker locker(reinterpret_cast<v8::Isolate*>(isolate_)); | 3810 Locker locker(reinterpret_cast<v8::Isolate*>(isolate_)); |
| 3806 isolate_->debugger()->CallMessageDispatchHandler(); | 3811 isolate_->debugger()->CallMessageDispatchHandler(); |
| 3807 } | 3812 } |
| 3808 } | 3813 } |
| 3809 } | 3814 } |
| 3810 | 3815 |
| 3811 #endif // ENABLE_DEBUGGER_SUPPORT | 3816 #endif // ENABLE_DEBUGGER_SUPPORT |
| 3812 | 3817 |
| 3813 } } // namespace v8::internal | 3818 } } // namespace v8::internal |
| OLD | NEW |