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 1594 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1605 function.deoptimization_counter()); | 1605 function.deoptimization_counter()); |
1606 } | 1606 } |
1607 | 1607 |
1608 // Compute the stack size of the unoptimized frame. For functions with | 1608 // Compute the stack size of the unoptimized frame. For functions with |
1609 // optional arguments the deoptimization info does not describe the | 1609 // optional arguments the deoptimization info does not describe the |
1610 // incoming arguments. | 1610 // incoming arguments. |
1611 const Function& function = Function::Handle(optimized_code.function()); | 1611 const Function& function = Function::Handle(optimized_code.function()); |
1612 const intptr_t num_args = | 1612 const intptr_t num_args = |
1613 function.HasOptionalParameters() ? 0 : function.num_fixed_parameters(); | 1613 function.HasOptionalParameters() ? 0 : function.num_fixed_parameters(); |
1614 intptr_t unoptimized_stack_size = | 1614 intptr_t unoptimized_stack_size = |
1615 + deopt_info.Length() - num_args | 1615 + deopt_info.TranslationLength() - num_args |
1616 - 2; // Subtract caller FP and PC. | 1616 - 2; // Subtract caller FP and PC. |
1617 return unoptimized_stack_size * kWordSize; | 1617 return unoptimized_stack_size * kWordSize; |
1618 } | 1618 } |
1619 END_LEAF_RUNTIME_ENTRY | 1619 END_LEAF_RUNTIME_ENTRY |
1620 | 1620 |
1621 | 1621 |
1622 | 1622 |
1623 static intptr_t DeoptimizeWithDeoptInfo(const Code& code, | 1623 static intptr_t DeoptimizeWithDeoptInfo(const Code& code, |
1624 const DeoptInfo& deopt_info, | 1624 const DeoptInfo& deopt_info, |
1625 const StackFrame& caller_frame) { | 1625 const StackFrame& caller_frame) { |
1626 const intptr_t len = deopt_info.Length(); | 1626 const intptr_t len = deopt_info.TranslationLength(); |
1627 GrowableArray<DeoptInstr*> deopt_instructions(len); | 1627 GrowableArray<DeoptInstr*> deopt_instructions(len); |
1628 for (intptr_t i = 0; i < len; i++) { | 1628 const Array& deopt_table = Array::Handle(code.deopt_info_array()); |
1629 deopt_instructions.Add(DeoptInstr::Create(deopt_info.Instruction(i), | 1629 ASSERT(!deopt_table.IsNull()); |
1630 deopt_info.FromIndex(i))); | 1630 deopt_info.ToInstructions(deopt_table, &deopt_instructions); |
1631 } | |
1632 | 1631 |
1633 intptr_t* start = reinterpret_cast<intptr_t*>(caller_frame.sp() - kWordSize); | 1632 intptr_t* start = reinterpret_cast<intptr_t*>(caller_frame.sp() - kWordSize); |
1634 const Function& function = Function::Handle(code.function()); | 1633 const Function& function = Function::Handle(code.function()); |
1635 const intptr_t num_args = | 1634 const intptr_t num_args = |
1636 function.HasOptionalParameters() ? 0 : function.num_fixed_parameters(); | 1635 function.HasOptionalParameters() ? 0 : function.num_fixed_parameters(); |
1637 intptr_t to_frame_size = | 1636 intptr_t to_frame_size = |
1638 1 // Deoptimized function's return address. | 1637 1 // Deoptimized function's return address. |
1639 + (caller_frame.fp() - caller_frame.sp()) / kWordSize | 1638 + (caller_frame.fp() - caller_frame.sp()) / kWordSize |
1640 + 3 // caller-fp, pc, pc-marker. | 1639 + 3 // caller-fp, pc, pc-marker. |
1641 + num_args; | 1640 + num_args; |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1752 intptr_t line, column; | 1751 intptr_t line, column; |
1753 script.GetTokenLocation(token_pos, &line, &column); | 1752 script.GetTokenLocation(token_pos, &line, &column); |
1754 String& line_string = String::Handle(script.GetLine(line)); | 1753 String& line_string = String::Handle(script.GetLine(line)); |
1755 OS::Print(" Function: %s\n", top_function.ToFullyQualifiedCString()); | 1754 OS::Print(" Function: %s\n", top_function.ToFullyQualifiedCString()); |
1756 OS::Print(" Line %"Pd": '%s'\n", line, line_string.ToCString()); | 1755 OS::Print(" Line %"Pd": '%s'\n", line, line_string.ToCString()); |
1757 } | 1756 } |
1758 } | 1757 } |
1759 | 1758 |
1760 | 1759 |
1761 } // namespace dart | 1760 } // namespace dart |
OLD | NEW |