OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 1778 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1789 if (frame->is_optimized()) { | 1789 if (frame->is_optimized()) { |
1790 List<JSFunction*> functions(Compiler::kMaxInliningLevels + 1); | 1790 List<JSFunction*> functions(Compiler::kMaxInliningLevels + 1); |
1791 frame->GetFunctions(&functions); | 1791 frame->GetFunctions(&functions); |
1792 for (int i = 0; i < functions.length(); i++) { | 1792 for (int i = 0; i < functions.length(); i++) { |
1793 if (!functions[i]->shared()->code()->has_debug_break_slots()) { | 1793 if (!functions[i]->shared()->code()->has_debug_break_slots()) { |
1794 active_functions.Add(Handle<JSFunction>(functions[i])); | 1794 active_functions.Add(Handle<JSFunction>(functions[i])); |
1795 } | 1795 } |
1796 } | 1796 } |
1797 } else if (frame->function()->IsJSFunction()) { | 1797 } else if (frame->function()->IsJSFunction()) { |
1798 JSFunction* function = JSFunction::cast(frame->function()); | 1798 JSFunction* function = JSFunction::cast(frame->function()); |
1799 if (function->code()->kind() == Code::FUNCTION && | 1799 ASSERT(frame->LookupCode()->kind() == Code::FUNCTION); |
1800 !function->code()->has_debug_break_slots()) { | 1800 if (!frame->LookupCode()->has_debug_break_slots() || |
| 1801 !function->shared()->code()->has_debug_break_slots()) { |
1801 active_functions.Add(Handle<JSFunction>(function)); | 1802 active_functions.Add(Handle<JSFunction>(function)); |
1802 } | 1803 } |
1803 } | 1804 } |
1804 } | 1805 } |
1805 | 1806 |
1806 // Sort the functions on the object pointer value to prepare for | 1807 // Sort the functions on the object pointer value to prepare for |
1807 // the binary search below. | 1808 // the binary search below. |
1808 active_functions.Sort(HandleObjectPointerCompare<JSFunction>); | 1809 active_functions.Sort(HandleObjectPointerCompare<JSFunction>); |
1809 | 1810 |
1810 // Scan the heap for all non-optimized functions which has no | 1811 // Scan the heap for all non-optimized functions which has no |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1846 !shared->allows_lazy_compilation() || | 1847 !shared->allows_lazy_compilation() || |
1847 shared->code()->kind() == Code::BUILTIN) { | 1848 shared->code()->kind() == Code::BUILTIN) { |
1848 continue; | 1849 continue; |
1849 } | 1850 } |
1850 | 1851 |
1851 // Make sure that the shared full code is compiled with debug | 1852 // Make sure that the shared full code is compiled with debug |
1852 // break slots. | 1853 // break slots. |
1853 if (function->code() == *lazy_compile) { | 1854 if (function->code() == *lazy_compile) { |
1854 function->set_code(shared->code()); | 1855 function->set_code(shared->code()); |
1855 } | 1856 } |
1856 Handle<Code> current_code(function->code()); | 1857 if (!shared->code()->has_debug_break_slots()) { |
1857 if (shared->code()->has_debug_break_slots()) { | |
1858 // if the code is already recompiled to have break slots skip | |
1859 // recompilation. | |
1860 ASSERT(!function->code()->has_debug_break_slots()); | |
1861 } else { | |
1862 // Try to compile the full code with debug break slots. If it | 1858 // Try to compile the full code with debug break slots. If it |
1863 // fails just keep the current code. | 1859 // fails just keep the current code. |
1864 ASSERT(shared->code() == *current_code); | 1860 Handle<Code> current_code(function->shared()->code()); |
1865 ZoneScope zone_scope(isolate_, DELETE_ON_EXIT); | 1861 ZoneScope zone_scope(isolate_, DELETE_ON_EXIT); |
1866 shared->set_code(*lazy_compile); | 1862 shared->set_code(*lazy_compile); |
1867 bool prev_force_debugger_active = | 1863 bool prev_force_debugger_active = |
1868 isolate_->debugger()->force_debugger_active(); | 1864 isolate_->debugger()->force_debugger_active(); |
1869 isolate_->debugger()->set_force_debugger_active(true); | 1865 isolate_->debugger()->set_force_debugger_active(true); |
| 1866 ASSERT(current_code->kind() == Code::FUNCTION); |
1870 CompileFullCodeForDebugging(shared, current_code); | 1867 CompileFullCodeForDebugging(shared, current_code); |
1871 isolate_->debugger()->set_force_debugger_active( | 1868 isolate_->debugger()->set_force_debugger_active( |
1872 prev_force_debugger_active); | 1869 prev_force_debugger_active); |
1873 if (!shared->is_compiled()) { | 1870 if (!shared->is_compiled()) { |
1874 shared->set_code(*current_code); | 1871 shared->set_code(*current_code); |
1875 continue; | 1872 continue; |
1876 } | 1873 } |
1877 } | 1874 } |
1878 Handle<Code> new_code(shared->code()); | 1875 Handle<Code> new_code(shared->code()); |
1879 | 1876 |
1880 // Find the function and patch the return address. | 1877 // Find the function and patch the return address. |
1881 for (JavaScriptFrameIterator it(isolate_); !it.done(); it.Advance()) { | 1878 for (JavaScriptFrameIterator it(isolate_); !it.done(); it.Advance()) { |
1882 JavaScriptFrame* frame = it.frame(); | 1879 JavaScriptFrame* frame = it.frame(); |
1883 // If the current frame is for this function in its | 1880 // If the current frame is for this function in its |
1884 // non-optimized form rewrite the return address to continue | 1881 // non-optimized form rewrite the return address to continue |
1885 // in the newly compiled full code with debug break slots. | 1882 // in the newly compiled full code with debug break slots. |
1886 if (frame->function()->IsJSFunction() && | 1883 if (!frame->is_optimized() && |
1887 frame->function() == *function && | 1884 frame->function()->IsJSFunction() && |
1888 frame->LookupCode()->kind() == Code::FUNCTION) { | 1885 frame->function() == *function) { |
1889 intptr_t delta = frame->pc() - current_code->instruction_start(); | 1886 ASSERT(frame->LookupCode()->kind() == Code::FUNCTION); |
| 1887 Handle<Code> frame_code(frame->LookupCode()); |
| 1888 if (frame_code->has_debug_break_slots()) continue; |
| 1889 intptr_t delta = frame->pc() - frame_code->instruction_start(); |
1890 int debug_break_slot_count = 0; | 1890 int debug_break_slot_count = 0; |
1891 int mask = RelocInfo::ModeMask(RelocInfo::DEBUG_BREAK_SLOT); | 1891 int mask = RelocInfo::ModeMask(RelocInfo::DEBUG_BREAK_SLOT); |
1892 for (RelocIterator it(*new_code, mask); !it.done(); it.next()) { | 1892 for (RelocIterator it(*new_code, mask); !it.done(); it.next()) { |
1893 // Check if the pc in the new code with debug break | 1893 // Check if the pc in the new code with debug break |
1894 // slots is before this slot. | 1894 // slots is before this slot. |
1895 RelocInfo* info = it.rinfo(); | 1895 RelocInfo* info = it.rinfo(); |
1896 int debug_break_slot_bytes = | 1896 int debug_break_slot_bytes = |
1897 debug_break_slot_count * Assembler::kDebugBreakSlotLength; | 1897 debug_break_slot_count * Assembler::kDebugBreakSlotLength; |
1898 intptr_t new_delta = | 1898 intptr_t new_delta = |
1899 info->pc() - | 1899 info->pc() - |
1900 new_code->instruction_start() - | 1900 new_code->instruction_start() - |
1901 debug_break_slot_bytes; | 1901 debug_break_slot_bytes; |
1902 if (new_delta > delta) { | 1902 if (new_delta > delta) { |
1903 break; | 1903 break; |
1904 } | 1904 } |
1905 | 1905 |
1906 // Passed a debug break slot in the full code with debug | 1906 // Passed a debug break slot in the full code with debug |
1907 // break slots. | 1907 // break slots. |
1908 debug_break_slot_count++; | 1908 debug_break_slot_count++; |
1909 } | 1909 } |
1910 int debug_break_slot_bytes = | 1910 int debug_break_slot_bytes = |
1911 debug_break_slot_count * Assembler::kDebugBreakSlotLength; | 1911 debug_break_slot_count * Assembler::kDebugBreakSlotLength; |
1912 if (FLAG_trace_deopt) { | 1912 if (FLAG_trace_deopt) { |
1913 PrintF("Replacing code %08" V8PRIxPTR " - %08" V8PRIxPTR " (%d) " | 1913 PrintF("Replacing code %08" V8PRIxPTR " - %08" V8PRIxPTR " (%d) " |
1914 "with %08" V8PRIxPTR " - %08" V8PRIxPTR " (%d) " | 1914 "with %08" V8PRIxPTR " - %08" V8PRIxPTR " (%d) " |
1915 "for debugging, " | 1915 "for debugging, " |
1916 "changing pc from %08" V8PRIxPTR " to %08" V8PRIxPTR "\n", | 1916 "changing pc from %08" V8PRIxPTR " to %08" V8PRIxPTR "\n", |
1917 reinterpret_cast<intptr_t>( | 1917 reinterpret_cast<intptr_t>( |
1918 current_code->instruction_start()), | 1918 frame_code->instruction_start()), |
1919 reinterpret_cast<intptr_t>( | 1919 reinterpret_cast<intptr_t>( |
1920 current_code->instruction_start()) + | 1920 frame_code->instruction_start()) + |
1921 current_code->instruction_size(), | 1921 frame_code->instruction_size(), |
1922 current_code->instruction_size(), | 1922 frame_code->instruction_size(), |
1923 reinterpret_cast<intptr_t>(new_code->instruction_start()), | 1923 reinterpret_cast<intptr_t>(new_code->instruction_start()), |
1924 reinterpret_cast<intptr_t>(new_code->instruction_start()) + | 1924 reinterpret_cast<intptr_t>(new_code->instruction_start()) + |
1925 new_code->instruction_size(), | 1925 new_code->instruction_size(), |
1926 new_code->instruction_size(), | 1926 new_code->instruction_size(), |
1927 reinterpret_cast<intptr_t>(frame->pc()), | 1927 reinterpret_cast<intptr_t>(frame->pc()), |
1928 reinterpret_cast<intptr_t>(new_code->instruction_start()) + | 1928 reinterpret_cast<intptr_t>(new_code->instruction_start()) + |
1929 delta + debug_break_slot_bytes); | 1929 delta + debug_break_slot_bytes); |
1930 } | 1930 } |
1931 | 1931 |
1932 // Patch the return address to return into the code with | 1932 // Patch the return address to return into the code with |
(...skipping 1557 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3490 { | 3490 { |
3491 Locker locker; | 3491 Locker locker; |
3492 Isolate::Current()->debugger()->CallMessageDispatchHandler(); | 3492 Isolate::Current()->debugger()->CallMessageDispatchHandler(); |
3493 } | 3493 } |
3494 } | 3494 } |
3495 } | 3495 } |
3496 | 3496 |
3497 #endif // ENABLE_DEBUGGER_SUPPORT | 3497 #endif // ENABLE_DEBUGGER_SUPPORT |
3498 | 3498 |
3499 } } // namespace v8::internal | 3499 } } // namespace v8::internal |
OLD | NEW |