| 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 1766 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1777 | 1777 |
| 1778 | 1778 |
| 1779 void Debug::ClearStepNext() { | 1779 void Debug::ClearStepNext() { |
| 1780 thread_local_.last_step_action_ = StepNone; | 1780 thread_local_.last_step_action_ = StepNone; |
| 1781 thread_local_.last_statement_position_ = RelocInfo::kNoPosition; | 1781 thread_local_.last_statement_position_ = RelocInfo::kNoPosition; |
| 1782 thread_local_.last_fp_ = 0; | 1782 thread_local_.last_fp_ = 0; |
| 1783 } | 1783 } |
| 1784 | 1784 |
| 1785 | 1785 |
| 1786 // Helper function to compile full code for debugging. This code will | 1786 // Helper function to compile full code for debugging. This code will |
| 1787 // have debug break slots and deoptimization | 1787 // have debug break slots and deoptimization information. Deoptimization |
| 1788 // information. Deoptimization information is required in case that an | 1788 // information is required in case that an optimized version of this |
| 1789 // optimized version of this function is still activated on the | 1789 // function is still activated on the stack. It will also make sure that |
| 1790 // stack. It will also make sure that the full code is compiled with | 1790 // the full code is compiled with the same flags as the previous version, |
| 1791 // the same flags as the previous version - that is flags which can | 1791 // that is flags which can change the code generated. The current method |
| 1792 // change the code generated. The current method of mapping from | 1792 // of mapping from already compiled full code without debug break slots |
| 1793 // already compiled full code without debug break slots to full code | 1793 // to full code with debug break slots depends on the generated code is |
| 1794 // with debug break slots depends on the generated code is otherwise | 1794 // otherwise exactly the same. |
| 1795 // exactly the same. | 1795 static bool CompileFullCodeForDebugging(Handle<JSFunction> function, |
| 1796 static bool CompileFullCodeForDebugging(Handle<SharedFunctionInfo> shared, | |
| 1797 Handle<Code> current_code) { | 1796 Handle<Code> current_code) { |
| 1798 ASSERT(!current_code->has_debug_break_slots()); | 1797 ASSERT(!current_code->has_debug_break_slots()); |
| 1799 | 1798 |
| 1800 CompilationInfo info(shared); | 1799 CompilationInfo info(function); |
| 1801 info.MarkCompilingForDebugging(current_code); | 1800 info.MarkCompilingForDebugging(current_code); |
| 1802 ASSERT(!info.shared_info()->is_compiled()); | 1801 ASSERT(!info.shared_info()->is_compiled()); |
| 1803 ASSERT(!info.isolate()->has_pending_exception()); | 1802 ASSERT(!info.isolate()->has_pending_exception()); |
| 1804 | 1803 |
| 1805 // Use compile lazy which will end up compiling the full code in the | 1804 // Use compile lazy which will end up compiling the full code in the |
| 1806 // configuration configured above. | 1805 // configuration configured above. |
| 1807 bool result = Compiler::CompileLazy(&info); | 1806 bool result = Compiler::CompileLazy(&info); |
| 1808 ASSERT(result != Isolate::Current()->has_pending_exception()); | 1807 ASSERT(result != Isolate::Current()->has_pending_exception()); |
| 1809 info.isolate()->clear_pending_exception(); | 1808 info.isolate()->clear_pending_exception(); |
| 1810 #if DEBUG | 1809 #if DEBUG |
| 1811 if (result) { | 1810 if (result) { |
| 1812 Handle<Code> new_code(shared->code()); | 1811 Handle<Code> new_code(function->shared()->code()); |
| 1813 ASSERT(new_code->has_debug_break_slots()); | 1812 ASSERT(new_code->has_debug_break_slots()); |
| 1814 ASSERT(current_code->is_compiled_optimizable() == | 1813 ASSERT(current_code->is_compiled_optimizable() == |
| 1815 new_code->is_compiled_optimizable()); | 1814 new_code->is_compiled_optimizable()); |
| 1816 } | 1815 } |
| 1817 #endif | 1816 #endif |
| 1818 return result; | 1817 return result; |
| 1819 } | 1818 } |
| 1820 | 1819 |
| 1821 | 1820 |
| 1822 static void CollectActiveFunctionsFromThread( | 1821 static void CollectActiveFunctionsFromThread( |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2006 for (int i = 0; i < active_functions.length(); i++) { | 2005 for (int i = 0; i < active_functions.length(); i++) { |
| 2007 Handle<JSFunction> function = active_functions[i]; | 2006 Handle<JSFunction> function = active_functions[i]; |
| 2008 function->shared()->code()->set_gc_metadata(Smi::FromInt(0)); | 2007 function->shared()->code()->set_gc_metadata(Smi::FromInt(0)); |
| 2009 } | 2008 } |
| 2010 } | 2009 } |
| 2011 | 2010 |
| 2012 // Now recompile all functions with activation frames and and | 2011 // Now recompile all functions with activation frames and and |
| 2013 // patch the return address to run in the new compiled code. | 2012 // patch the return address to run in the new compiled code. |
| 2014 for (int i = 0; i < active_functions.length(); i++) { | 2013 for (int i = 0; i < active_functions.length(); i++) { |
| 2015 Handle<JSFunction> function = active_functions[i]; | 2014 Handle<JSFunction> function = active_functions[i]; |
| 2015 Handle<SharedFunctionInfo> shared(function->shared()); |
| 2016 | 2016 |
| 2017 if (function->code()->kind() == Code::FUNCTION && | 2017 if (function->code()->kind() == Code::FUNCTION && |
| 2018 function->code()->has_debug_break_slots()) { | 2018 function->code()->has_debug_break_slots()) { |
| 2019 // Nothing to do. Function code already had debug break slots. | 2019 // Nothing to do. Function code already had debug break slots. |
| 2020 continue; | 2020 continue; |
| 2021 } | 2021 } |
| 2022 | 2022 |
| 2023 Handle<SharedFunctionInfo> shared(function->shared()); | |
| 2024 // If recompilation is not possible just skip it. | 2023 // If recompilation is not possible just skip it. |
| 2025 if (shared->is_toplevel() || | 2024 if (shared->is_toplevel() || |
| 2026 !shared->allows_lazy_compilation() || | 2025 !shared->allows_lazy_compilation() || |
| 2027 shared->code()->kind() == Code::BUILTIN) { | 2026 shared->code()->kind() == Code::BUILTIN) { |
| 2028 continue; | 2027 continue; |
| 2029 } | 2028 } |
| 2030 | 2029 |
| 2031 // Make sure that the shared full code is compiled with debug | 2030 // Make sure that the shared full code is compiled with debug |
| 2032 // break slots. | 2031 // break slots. |
| 2033 if (!shared->code()->has_debug_break_slots()) { | 2032 if (!shared->code()->has_debug_break_slots()) { |
| 2034 // Try to compile the full code with debug break slots. If it | 2033 // Try to compile the full code with debug break slots. If it |
| 2035 // fails just keep the current code. | 2034 // fails just keep the current code. |
| 2036 Handle<Code> current_code(function->shared()->code()); | 2035 Handle<Code> current_code(function->shared()->code()); |
| 2037 ZoneScope zone_scope(isolate_, DELETE_ON_EXIT); | 2036 ZoneScope zone_scope(isolate_, DELETE_ON_EXIT); |
| 2038 shared->set_code(*lazy_compile); | 2037 shared->set_code(*lazy_compile); |
| 2039 bool prev_force_debugger_active = | 2038 bool prev_force_debugger_active = |
| 2040 isolate_->debugger()->force_debugger_active(); | 2039 isolate_->debugger()->force_debugger_active(); |
| 2041 isolate_->debugger()->set_force_debugger_active(true); | 2040 isolate_->debugger()->set_force_debugger_active(true); |
| 2042 ASSERT(current_code->kind() == Code::FUNCTION); | 2041 ASSERT(current_code->kind() == Code::FUNCTION); |
| 2043 CompileFullCodeForDebugging(shared, current_code); | 2042 CompileFullCodeForDebugging(function, current_code); |
| 2044 isolate_->debugger()->set_force_debugger_active( | 2043 isolate_->debugger()->set_force_debugger_active( |
| 2045 prev_force_debugger_active); | 2044 prev_force_debugger_active); |
| 2046 if (!shared->is_compiled()) { | 2045 if (!shared->is_compiled()) { |
| 2047 shared->set_code(*current_code); | 2046 shared->set_code(*current_code); |
| 2048 continue; | 2047 continue; |
| 2049 } | 2048 } |
| 2050 } | 2049 } |
| 2051 | 2050 |
| 2052 // Keep function code in sync with shared function info. | 2051 // Keep function code in sync with shared function info. |
| 2053 function->set_code(shared->code()); | 2052 function->set_code(shared->code()); |
| (...skipping 1568 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3622 { | 3621 { |
| 3623 Locker locker; | 3622 Locker locker; |
| 3624 Isolate::Current()->debugger()->CallMessageDispatchHandler(); | 3623 Isolate::Current()->debugger()->CallMessageDispatchHandler(); |
| 3625 } | 3624 } |
| 3626 } | 3625 } |
| 3627 } | 3626 } |
| 3628 | 3627 |
| 3629 #endif // ENABLE_DEBUGGER_SUPPORT | 3628 #endif // ENABLE_DEBUGGER_SUPPORT |
| 3630 | 3629 |
| 3631 } } // namespace v8::internal | 3630 } } // namespace v8::internal |
| OLD | NEW |