Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(49)

Side by Side Diff: runtime/vm/code_generator.cc

Issue 11363141: Improve smi shift operations and avoid repeated deoptimizations. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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) {
1757 const intptr_t len = deopt_info.TranslationLength(); 1758 const intptr_t len = deopt_info.TranslationLength();
1758 GrowableArray<DeoptInstr*> deopt_instructions(len); 1759 GrowableArray<DeoptInstr*> deopt_instructions(len);
1759 const Array& deopt_table = Array::Handle(code.deopt_info_array()); 1760 const Array& deopt_table = Array::Handle(code.deopt_info_array());
1760 ASSERT(!deopt_table.IsNull()); 1761 ASSERT(!deopt_table.IsNull());
1761 deopt_info.ToInstructions(deopt_table, &deopt_instructions); 1762 deopt_info.ToInstructions(deopt_table, &deopt_instructions);
1762 1763
1763 intptr_t* start = reinterpret_cast<intptr_t*>(caller_frame.sp() - kWordSize); 1764 intptr_t* start = reinterpret_cast<intptr_t*>(caller_frame.sp() - kWordSize);
1764 const Function& function = Function::Handle(code.function()); 1765 const Function& function = Function::Handle(code.function());
1765 const intptr_t num_args = 1766 const intptr_t num_args =
1766 function.HasOptionalParameters() ? 0 : function.num_fixed_parameters(); 1767 function.HasOptionalParameters() ? 0 : function.num_fixed_parameters();
1767 intptr_t to_frame_size = 1768 intptr_t to_frame_size =
1768 1 // Deoptimized function's return address. 1769 1 // Deoptimized function's return address.
1769 + (caller_frame.fp() - caller_frame.sp()) / kWordSize 1770 + (caller_frame.fp() - caller_frame.sp()) / kWordSize
1770 + 3 // caller-fp, pc, pc-marker. 1771 + 3 // caller-fp, pc, pc-marker.
1771 + num_args; 1772 + num_args;
1772 DeoptimizationContext deopt_context(start, 1773 DeoptimizationContext deopt_context(start,
1773 to_frame_size, 1774 to_frame_size,
1774 Array::Handle(code.object_table()), 1775 Array::Handle(code.object_table()),
1775 num_args); 1776 num_args,
1777 deopt_reason);
1776 for (intptr_t to_index = len - 1; to_index >= 0; to_index--) { 1778 for (intptr_t to_index = len - 1; to_index >= 0; to_index--) {
1777 deopt_instructions[to_index]->Execute(&deopt_context, to_index); 1779 deopt_instructions[to_index]->Execute(&deopt_context, to_index);
1778 } 1780 }
1779 if (FLAG_trace_deoptimization_verbose) { 1781 if (FLAG_trace_deoptimization_verbose) {
1780 for (intptr_t i = 0; i < len; i++) { 1782 for (intptr_t i = 0; i < len; i++) {
1781 OS::Print("*%"Pd". [%p] %#014"Px" [%s]\n", 1783 OS::Print("*%"Pd". [%p] %#014"Px" [%s]\n",
1782 i, 1784 i,
1783 &start[i], 1785 &start[i],
1784 start[i], 1786 start[i],
1785 deopt_instructions[i]->ToCString()); 1787 deopt_instructions[i]->ToCString());
(...skipping 24 matching lines...) Expand all
1810 intptr_t* cpu_registers_copy = isolate->deopt_cpu_registers_copy(); 1812 intptr_t* cpu_registers_copy = isolate->deopt_cpu_registers_copy();
1811 double* xmm_registers_copy = isolate->deopt_xmm_registers_copy(); 1813 double* xmm_registers_copy = isolate->deopt_xmm_registers_copy();
1812 1814
1813 DeoptInfo& deopt_info = DeoptInfo::Handle(); 1815 DeoptInfo& deopt_info = DeoptInfo::Handle();
1814 DeoptReasonId deopt_reason = kDeoptUnknown; 1816 DeoptReasonId deopt_reason = kDeoptUnknown;
1815 GetDeoptInfoAtPc(optimized_code, caller_frame->pc(), &deopt_info, 1817 GetDeoptInfoAtPc(optimized_code, caller_frame->pc(), &deopt_info,
1816 &deopt_reason); 1818 &deopt_reason);
1817 ASSERT(!deopt_info.IsNull()); 1819 ASSERT(!deopt_info.IsNull());
1818 1820
1819 const intptr_t caller_fp = 1821 const intptr_t caller_fp =
1820 DeoptimizeWithDeoptInfo(optimized_code, deopt_info, *caller_frame); 1822 DeoptimizeWithDeoptInfo(optimized_code, deopt_info, *caller_frame,
1823 deopt_reason);
1821 1824
1822 isolate->SetDeoptFrameCopy(NULL, 0); 1825 isolate->SetDeoptFrameCopy(NULL, 0);
1823 isolate->set_deopt_cpu_registers_copy(NULL); 1826 isolate->set_deopt_cpu_registers_copy(NULL);
1824 isolate->set_deopt_xmm_registers_copy(NULL); 1827 isolate->set_deopt_xmm_registers_copy(NULL);
1825 delete[] frame_copy; 1828 delete[] frame_copy;
1826 delete[] cpu_registers_copy; 1829 delete[] cpu_registers_copy;
1827 delete[] xmm_registers_copy; 1830 delete[] xmm_registers_copy;
1828 1831
1829 return caller_fp; 1832 return caller_fp;
1830 } 1833 }
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
1882 intptr_t line, column; 1885 intptr_t line, column;
1883 script.GetTokenLocation(token_pos, &line, &column); 1886 script.GetTokenLocation(token_pos, &line, &column);
1884 String& line_string = String::Handle(script.GetLine(line)); 1887 String& line_string = String::Handle(script.GetLine(line));
1885 OS::Print(" Function: %s\n", top_function.ToFullyQualifiedCString()); 1888 OS::Print(" Function: %s\n", top_function.ToFullyQualifiedCString());
1886 OS::Print(" Line %"Pd": '%s'\n", line, line_string.ToCString()); 1889 OS::Print(" Line %"Pd": '%s'\n", line, line_string.ToCString());
1887 } 1890 }
1888 } 1891 }
1889 1892
1890 1893
1891 } // namespace dart 1894 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698