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 1762 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1773 | 1773 |
1774 { | 1774 { |
1775 // We are going to iterate heap to find all functions without | 1775 // We are going to iterate heap to find all functions without |
1776 // debug break slots. | 1776 // debug break slots. |
1777 isolate_->heap()->CollectAllGarbage(Heap::kMakeHeapIterableMask); | 1777 isolate_->heap()->CollectAllGarbage(Heap::kMakeHeapIterableMask); |
1778 | 1778 |
1779 // Ensure no GC in this scope as we are comparing raw pointer | 1779 // Ensure no GC in this scope as we are comparing raw pointer |
1780 // values and performing a heap iteration. | 1780 // values and performing a heap iteration. |
1781 AssertNoAllocation no_allocation; | 1781 AssertNoAllocation no_allocation; |
1782 | 1782 |
1783 // Find all non-optimized code functions with activation frames on | 1783 // Find all non-optimized code functions with activation frames |
1784 // the stack. | 1784 // on the stack. This includes functions which have optimized |
| 1785 // activations (including inlined functions) on the stack as the |
| 1786 // non-optimized code is needed for the lazy deoptimization. |
1785 for (JavaScriptFrameIterator it(isolate_); !it.done(); it.Advance()) { | 1787 for (JavaScriptFrameIterator it(isolate_); !it.done(); it.Advance()) { |
1786 JavaScriptFrame* frame = it.frame(); | 1788 JavaScriptFrame* frame = it.frame(); |
1787 if (frame->function()->IsJSFunction()) { | 1789 if (frame->is_optimized()) { |
| 1790 List<JSFunction*> functions(Compiler::kMaxInliningLevels + 1); |
| 1791 frame->GetFunctions(&functions); |
| 1792 for (int i = 0; i < functions.length(); i++) { |
| 1793 if (!functions[i]->shared()->code()->has_debug_break_slots()) { |
| 1794 active_functions.Add(Handle<JSFunction>(functions[i])); |
| 1795 } |
| 1796 } |
| 1797 } else if (frame->function()->IsJSFunction()) { |
1788 JSFunction* function = JSFunction::cast(frame->function()); | 1798 JSFunction* function = JSFunction::cast(frame->function()); |
1789 if (function->code()->kind() == Code::FUNCTION && | 1799 if (function->code()->kind() == Code::FUNCTION && |
1790 !function->code()->has_debug_break_slots()) | 1800 !function->code()->has_debug_break_slots()) { |
1791 active_functions.Add(Handle<JSFunction>(function)); | 1801 active_functions.Add(Handle<JSFunction>(function)); |
| 1802 } |
1792 } | 1803 } |
1793 } | 1804 } |
| 1805 |
1794 // Sort the functions on the object pointer value to prepare for | 1806 // Sort the functions on the object pointer value to prepare for |
1795 // the binary search below. | 1807 // the binary search below. |
1796 active_functions.Sort(HandleObjectPointerCompare<JSFunction>); | 1808 active_functions.Sort(HandleObjectPointerCompare<JSFunction>); |
1797 | 1809 |
1798 // Scan the heap for all non-optimized functions which has no | 1810 // Scan the heap for all non-optimized functions which has no |
1799 // debug break slots. | 1811 // debug break slots. |
1800 HeapIterator iterator; | 1812 HeapIterator iterator; |
1801 HeapObject* obj = NULL; | 1813 HeapObject* obj = NULL; |
1802 while (((obj = iterator.next()) != NULL)) { | 1814 while (((obj = iterator.next()) != NULL)) { |
1803 if (obj->IsJSFunction()) { | 1815 if (obj->IsJSFunction()) { |
(...skipping 27 matching lines...) Expand all Loading... |
1831 Handle<SharedFunctionInfo> shared(function->shared()); | 1843 Handle<SharedFunctionInfo> shared(function->shared()); |
1832 // If recompilation is not possible just skip it. | 1844 // If recompilation is not possible just skip it. |
1833 if (shared->is_toplevel() || | 1845 if (shared->is_toplevel() || |
1834 !shared->allows_lazy_compilation() || | 1846 !shared->allows_lazy_compilation() || |
1835 shared->code()->kind() == Code::BUILTIN) { | 1847 shared->code()->kind() == Code::BUILTIN) { |
1836 continue; | 1848 continue; |
1837 } | 1849 } |
1838 | 1850 |
1839 // Make sure that the shared full code is compiled with debug | 1851 // Make sure that the shared full code is compiled with debug |
1840 // break slots. | 1852 // break slots. |
| 1853 if (function->code() == *lazy_compile) { |
| 1854 function->set_code(shared->code()); |
| 1855 } |
1841 Handle<Code> current_code(function->code()); | 1856 Handle<Code> current_code(function->code()); |
1842 if (shared->code()->has_debug_break_slots()) { | 1857 if (shared->code()->has_debug_break_slots()) { |
1843 // if the code is already recompiled to have break slots skip | 1858 // if the code is already recompiled to have break slots skip |
1844 // recompilation. | 1859 // recompilation. |
1845 ASSERT(!function->code()->has_debug_break_slots()); | 1860 ASSERT(!function->code()->has_debug_break_slots()); |
1846 } else { | 1861 } else { |
1847 // Try to compile the full code with debug break slots. If it | 1862 // Try to compile the full code with debug break slots. If it |
1848 // fails just keep the current code. | 1863 // fails just keep the current code. |
1849 ASSERT(shared->code() == *current_code); | 1864 ASSERT(shared->code() == *current_code); |
1850 ZoneScope zone_scope(isolate_, DELETE_ON_EXIT); | 1865 ZoneScope zone_scope(isolate_, DELETE_ON_EXIT); |
1851 shared->set_code(*lazy_compile); | 1866 shared->set_code(*lazy_compile); |
1852 bool prev_force_debugger_active = | 1867 bool prev_force_debugger_active = |
1853 isolate_->debugger()->force_debugger_active(); | 1868 isolate_->debugger()->force_debugger_active(); |
1854 isolate_->debugger()->set_force_debugger_active(true); | 1869 isolate_->debugger()->set_force_debugger_active(true); |
1855 CompileFullCodeForDebugging(shared, current_code); | 1870 CompileFullCodeForDebugging(shared, current_code); |
1856 isolate_->debugger()->set_force_debugger_active( | 1871 isolate_->debugger()->set_force_debugger_active( |
1857 prev_force_debugger_active); | 1872 prev_force_debugger_active); |
1858 if (!shared->is_compiled()) { | 1873 if (!shared->is_compiled()) { |
1859 shared->set_code(*current_code); | 1874 shared->set_code(*current_code); |
1860 continue; | 1875 continue; |
1861 } | 1876 } |
1862 } | 1877 } |
1863 Handle<Code> new_code(shared->code()); | 1878 Handle<Code> new_code(shared->code()); |
1864 | 1879 |
1865 // Find the function and patch return address. | 1880 // Find the function and patch the return address. |
1866 for (JavaScriptFrameIterator it(isolate_); !it.done(); it.Advance()) { | 1881 for (JavaScriptFrameIterator it(isolate_); !it.done(); it.Advance()) { |
1867 JavaScriptFrame* frame = it.frame(); | 1882 JavaScriptFrame* frame = it.frame(); |
1868 // If the current frame is for this function in its | 1883 // If the current frame is for this function in its |
1869 // non-optimized form rewrite the return address to continue | 1884 // non-optimized form rewrite the return address to continue |
1870 // in the newly compiled full code with debug break slots. | 1885 // in the newly compiled full code with debug break slots. |
1871 if (frame->function()->IsJSFunction() && | 1886 if (frame->function()->IsJSFunction() && |
1872 frame->function() == *function && | 1887 frame->function() == *function && |
1873 frame->LookupCode()->kind() == Code::FUNCTION) { | 1888 frame->LookupCode()->kind() == Code::FUNCTION) { |
1874 intptr_t delta = frame->pc() - current_code->instruction_start(); | 1889 intptr_t delta = frame->pc() - current_code->instruction_start(); |
1875 int debug_break_slot_count = 0; | 1890 int debug_break_slot_count = 0; |
(...skipping 1599 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3475 { | 3490 { |
3476 Locker locker; | 3491 Locker locker; |
3477 Isolate::Current()->debugger()->CallMessageDispatchHandler(); | 3492 Isolate::Current()->debugger()->CallMessageDispatchHandler(); |
3478 } | 3493 } |
3479 } | 3494 } |
3480 } | 3495 } |
3481 | 3496 |
3482 #endif // ENABLE_DEBUGGER_SUPPORT | 3497 #endif // ENABLE_DEBUGGER_SUPPORT |
3483 | 3498 |
3484 } } // namespace v8::internal | 3499 } } // namespace v8::internal |
OLD | NEW |