| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "vm/code_generator.h" | 5 #include "vm/code_generator.h" |
| 6 | 6 |
| 7 #include "vm/assembler_macros.h" | 7 #include "vm/assembler_macros.h" |
| 8 #include "vm/ast.h" | 8 #include "vm/ast.h" |
| 9 #include "vm/code_patcher.h" | 9 #include "vm/code_patcher.h" |
| 10 #include "vm/compiler.h" | 10 #include "vm/compiler.h" |
| (...skipping 1735 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1746 + deopt_info.TranslationLength() - num_args | 1746 + deopt_info.TranslationLength() - num_args |
| 1747 - 2; // Subtract caller FP and PC. | 1747 - 2; // Subtract caller FP and PC. |
| 1748 return unoptimized_stack_size * kWordSize; | 1748 return unoptimized_stack_size * kWordSize; |
| 1749 } | 1749 } |
| 1750 END_LEAF_RUNTIME_ENTRY | 1750 END_LEAF_RUNTIME_ENTRY |
| 1751 | 1751 |
| 1752 | 1752 |
| 1753 | 1753 |
| 1754 static intptr_t DeoptimizeWithDeoptInfo(const Code& code, | 1754 static intptr_t DeoptimizeWithDeoptInfo(const Code& code, |
| 1755 const DeoptInfo& deopt_info, | 1755 const DeoptInfo& deopt_info, |
| 1756 const StackFrame& caller_frame, | 1756 const StackFrame& caller_frame) { |
| 1757 DeoptReasonId deopt_reason) { | |
| 1758 const intptr_t len = deopt_info.TranslationLength(); | 1757 const intptr_t len = deopt_info.TranslationLength(); |
| 1759 GrowableArray<DeoptInstr*> deopt_instructions(len); | 1758 GrowableArray<DeoptInstr*> deopt_instructions(len); |
| 1760 const Array& deopt_table = Array::Handle(code.deopt_info_array()); | 1759 const Array& deopt_table = Array::Handle(code.deopt_info_array()); |
| 1761 ASSERT(!deopt_table.IsNull()); | 1760 ASSERT(!deopt_table.IsNull()); |
| 1762 deopt_info.ToInstructions(deopt_table, &deopt_instructions); | 1761 deopt_info.ToInstructions(deopt_table, &deopt_instructions); |
| 1763 | 1762 |
| 1764 intptr_t* start = reinterpret_cast<intptr_t*>(caller_frame.sp() - kWordSize); | 1763 intptr_t* start = reinterpret_cast<intptr_t*>(caller_frame.sp() - kWordSize); |
| 1765 const Function& function = Function::Handle(code.function()); | 1764 const Function& function = Function::Handle(code.function()); |
| 1766 const intptr_t num_args = | 1765 const intptr_t num_args = |
| 1767 function.HasOptionalParameters() ? 0 : function.num_fixed_parameters(); | 1766 function.HasOptionalParameters() ? 0 : function.num_fixed_parameters(); |
| 1768 intptr_t to_frame_size = | 1767 intptr_t to_frame_size = |
| 1769 1 // Deoptimized function's return address. | 1768 1 // Deoptimized function's return address. |
| 1770 + (caller_frame.fp() - caller_frame.sp()) / kWordSize | 1769 + (caller_frame.fp() - caller_frame.sp()) / kWordSize |
| 1771 + 3 // caller-fp, pc, pc-marker. | 1770 + 3 // caller-fp, pc, pc-marker. |
| 1772 + num_args; | 1771 + num_args; |
| 1773 DeoptimizationContext deopt_context(start, | 1772 DeoptimizationContext deopt_context(start, |
| 1774 to_frame_size, | 1773 to_frame_size, |
| 1775 Array::Handle(code.object_table()), | 1774 Array::Handle(code.object_table()), |
| 1776 num_args, | 1775 num_args); |
| 1777 deopt_reason); | |
| 1778 for (intptr_t to_index = len - 1; to_index >= 0; to_index--) { | 1776 for (intptr_t to_index = len - 1; to_index >= 0; to_index--) { |
| 1779 deopt_instructions[to_index]->Execute(&deopt_context, to_index); | 1777 deopt_instructions[to_index]->Execute(&deopt_context, to_index); |
| 1780 } | 1778 } |
| 1781 if (FLAG_trace_deoptimization_verbose) { | 1779 if (FLAG_trace_deoptimization_verbose) { |
| 1782 for (intptr_t i = 0; i < len; i++) { | 1780 for (intptr_t i = 0; i < len; i++) { |
| 1783 OS::Print("*%"Pd". [%p] %#014"Px" [%s]\n", | 1781 OS::Print("*%"Pd". [%p] %#014"Px" [%s]\n", |
| 1784 i, | 1782 i, |
| 1785 &start[i], | 1783 &start[i], |
| 1786 start[i], | 1784 start[i], |
| 1787 deopt_instructions[i]->ToCString()); | 1785 deopt_instructions[i]->ToCString()); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1812 intptr_t* cpu_registers_copy = isolate->deopt_cpu_registers_copy(); | 1810 intptr_t* cpu_registers_copy = isolate->deopt_cpu_registers_copy(); |
| 1813 double* xmm_registers_copy = isolate->deopt_xmm_registers_copy(); | 1811 double* xmm_registers_copy = isolate->deopt_xmm_registers_copy(); |
| 1814 | 1812 |
| 1815 DeoptInfo& deopt_info = DeoptInfo::Handle(); | 1813 DeoptInfo& deopt_info = DeoptInfo::Handle(); |
| 1816 DeoptReasonId deopt_reason = kDeoptUnknown; | 1814 DeoptReasonId deopt_reason = kDeoptUnknown; |
| 1817 GetDeoptInfoAtPc(optimized_code, caller_frame->pc(), &deopt_info, | 1815 GetDeoptInfoAtPc(optimized_code, caller_frame->pc(), &deopt_info, |
| 1818 &deopt_reason); | 1816 &deopt_reason); |
| 1819 ASSERT(!deopt_info.IsNull()); | 1817 ASSERT(!deopt_info.IsNull()); |
| 1820 | 1818 |
| 1821 const intptr_t caller_fp = | 1819 const intptr_t caller_fp = |
| 1822 DeoptimizeWithDeoptInfo(optimized_code, deopt_info, *caller_frame, | 1820 DeoptimizeWithDeoptInfo(optimized_code, deopt_info, *caller_frame); |
| 1823 deopt_reason); | |
| 1824 | 1821 |
| 1825 isolate->SetDeoptFrameCopy(NULL, 0); | 1822 isolate->SetDeoptFrameCopy(NULL, 0); |
| 1826 isolate->set_deopt_cpu_registers_copy(NULL); | 1823 isolate->set_deopt_cpu_registers_copy(NULL); |
| 1827 isolate->set_deopt_xmm_registers_copy(NULL); | 1824 isolate->set_deopt_xmm_registers_copy(NULL); |
| 1828 delete[] frame_copy; | 1825 delete[] frame_copy; |
| 1829 delete[] cpu_registers_copy; | 1826 delete[] cpu_registers_copy; |
| 1830 delete[] xmm_registers_copy; | 1827 delete[] xmm_registers_copy; |
| 1831 | 1828 |
| 1832 return caller_fp; | 1829 return caller_fp; |
| 1833 } | 1830 } |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1885 intptr_t line, column; | 1882 intptr_t line, column; |
| 1886 script.GetTokenLocation(token_pos, &line, &column); | 1883 script.GetTokenLocation(token_pos, &line, &column); |
| 1887 String& line_string = String::Handle(script.GetLine(line)); | 1884 String& line_string = String::Handle(script.GetLine(line)); |
| 1888 OS::Print(" Function: %s\n", top_function.ToFullyQualifiedCString()); | 1885 OS::Print(" Function: %s\n", top_function.ToFullyQualifiedCString()); |
| 1889 OS::Print(" Line %"Pd": '%s'\n", line, line_string.ToCString()); | 1886 OS::Print(" Line %"Pd": '%s'\n", line, line_string.ToCString()); |
| 1890 } | 1887 } |
| 1891 } | 1888 } |
| 1892 | 1889 |
| 1893 | 1890 |
| 1894 } // namespace dart | 1891 } // namespace dart |
| OLD | NEW |