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

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

Issue 10963027: Use the inner deoptimization frame when setting incoming arguments. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Review update Created 8 years, 3 months 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
« no previous file with comments | « runtime/vm/compiler.cc ('k') | tests/language/deopt_inlined_function_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/globals.h" // Needed here to get TARGET_ARCH_XXX. 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_XXX.
6 6
7 #include "vm/flow_graph_compiler.h" 7 #include "vm/flow_graph_compiler.h"
8 8
9 #include "vm/dart_entry.h" 9 #include "vm/dart_entry.h"
10 #include "vm/debugger.h" 10 #include "vm/debugger.h"
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 AllocateIncomingParametersRecursive(deoptimization_env_, &stack_height); 69 AllocateIncomingParametersRecursive(deoptimization_env_, &stack_height);
70 70
71 const Function& function = compiler->parsed_function().function(); 71 const Function& function = compiler->parsed_function().function();
72 // For functions with optional arguments, all incoming arguments are copied 72 // For functions with optional arguments, all incoming arguments are copied
73 // to spill slots. The deoptimization environment does not track them. 73 // to spill slots. The deoptimization environment does not track them.
74 const intptr_t incoming_arg_count = 74 const intptr_t incoming_arg_count =
75 function.HasOptionalParameters() ? 0 : function.num_fixed_parameters(); 75 function.HasOptionalParameters() ? 0 : function.num_fixed_parameters();
76 DeoptInfoBuilder builder(compiler->object_table(), incoming_arg_count); 76 DeoptInfoBuilder builder(compiler->object_table(), incoming_arg_count);
77 77
78 intptr_t slot_ix = 0; 78 intptr_t slot_ix = 0;
79 Environment* env = deoptimization_env_; 79 Environment* inner = deoptimization_env_;
80 while (env != NULL) {
81 const Function& function = env->function();
82 const intptr_t fixed_parameter_count = env->fixed_parameter_count();
83 80
84 if (slot_ix == 0) { 81 // For the innermost environment, call the virtual return builder.
85 // For the innermost environment call the virtual return builder. 82 BuildReturnAddress(&builder, inner->function(), slot_ix++);
86 BuildReturnAddress(&builder, function, slot_ix++); 83
87 } else { 84 // For the innermost environment, set outgoing arguments and the locals.
88 // For any outer environment the deopt id is that of the call instruction 85 for (intptr_t i = inner->Length() - 1;
89 // which is recorded in the outer environment. 86 i >= inner->fixed_parameter_count();
90 builder.AddReturnAddressAfter(function, env->deopt_id(), slot_ix++); 87 i--) {
88 builder.AddCopy(inner->LocationAt(i), *inner->ValueAt(i), slot_ix++);
89 }
90
91 // PC marker and caller FP.
92 builder.AddPcMarker(inner->function(), slot_ix++);
93 builder.AddCallerFp(slot_ix++);
94
95 while (inner->outer() != NULL) {
96 // Write the frame for an outer environment.
97 const Environment* current = inner->outer();
98
99 // For any outer environment the deopt id is that of the call instruction
100 // which is recorded in the outer environment.
101 builder.AddReturnAddressAfter(current->function(),
102 current->deopt_id(),
103 slot_ix++);
104
105 // The values of outgoing arguments can be changed from the inlined call so
106 // we must read them from the inner environment.
107 for (intptr_t i = inner->fixed_parameter_count() - 1; i >= 0; i--) {
108 builder.AddCopy(inner->LocationAt(i), *inner->ValueAt(i), slot_ix++);
91 } 109 }
92 110
93 for (intptr_t i = env->Length() - 1; i >= fixed_parameter_count; i--) { 111 // Set the locals, not including the outgoing arguments.
94 builder.AddCopy(env->LocationAt(i), *env->ValueAt(i), slot_ix++); 112 ASSERT(current->Length() > inner->fixed_parameter_count());
113 for (intptr_t i = current->Length() - inner->fixed_parameter_count() - 1;
114 i >= current->fixed_parameter_count();
115 i--) {
116 builder.AddCopy(current->LocationAt(i), *current->ValueAt(i), slot_ix++);
95 } 117 }
96 118
97 // PC marker and caller FP. 119 // PC marker and caller FP.
98 builder.AddPcMarker(function, slot_ix++); 120 builder.AddPcMarker(current->function(), slot_ix++);
99 builder.AddCallerFp(slot_ix++); 121 builder.AddCallerFp(slot_ix++);
100 122
101 // On the outermost environment set caller PC and incoming arguments. 123 // Iterate on the outer environment.
102 if (env->outer() == NULL) { 124 inner = inner->outer();
103 builder.AddCallerPc(slot_ix++); 125 }
104 for (intptr_t i = fixed_parameter_count - 1; i >= 0; i--) { 126 ASSERT(inner != NULL); // The inner pointer is now the outermost environment.
105 builder.AddCopy(env->LocationAt(i), *env->ValueAt(i), slot_ix++);
106 }
107 }
108 127
109 // Iterate on the outer environment. 128 // For the outermost environment, set caller PC.
110 env = env->outer(); 129 builder.AddCallerPc(slot_ix++);
130
131 // For the outermost environment, set the incoming arguments.
132 for (intptr_t i = inner->fixed_parameter_count() - 1; i >= 0; i--) {
133 builder.AddCopy(inner->LocationAt(i), *inner->ValueAt(i), slot_ix++);
111 } 134 }
112 135
113 const DeoptInfo& deopt_info = DeoptInfo::Handle(builder.CreateDeoptInfo()); 136 const DeoptInfo& deopt_info = DeoptInfo::Handle(builder.CreateDeoptInfo());
114 return deopt_info.raw(); 137 return deopt_info.raw();
115 } 138 }
116 139
117 140
118 FlowGraphCompiler::FlowGraphCompiler(Assembler* assembler, 141 FlowGraphCompiler::FlowGraphCompiler(Assembler* assembler,
119 const FlowGraph& flow_graph, 142 const FlowGraph& flow_graph,
120 bool is_optimizing, 143 bool is_optimizing,
(...skipping 755 matching lines...) Expand 10 before | Expand all | Expand 10 after
876 case ABOVE: return unsigned_left > unsigned_right; 899 case ABOVE: return unsigned_left > unsigned_right;
877 case ABOVE_EQUAL: return unsigned_left >= unsigned_right; 900 case ABOVE_EQUAL: return unsigned_left >= unsigned_right;
878 default: 901 default:
879 UNIMPLEMENTED(); 902 UNIMPLEMENTED();
880 return false; 903 return false;
881 } 904 }
882 } 905 }
883 906
884 907
885 } // namespace dart 908 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/compiler.cc ('k') | tests/language/deopt_inlined_function_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698