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

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

Issue 128113003: Fix bug in specialization of IC-data. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 11 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 | « no previous file | runtime/vm/intermediate_language.cc » ('j') | runtime/vm/intermediate_language.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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/flow_graph_optimizer.h" 5 #include "vm/flow_graph_optimizer.h"
6 6
7 #include "vm/bit_vector.h" 7 #include "vm/bit_vector.h"
8 #include "vm/cha.h" 8 #include "vm/cha.h"
9 #include "vm/dart_entry.h" 9 #include "vm/dart_entry.h"
10 #include "vm/flow_graph_builder.h" 10 #include "vm/flow_graph_builder.h"
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 179
180 180
181 static const ICData& SpecializeICData(const ICData& ic_data, intptr_t cid) { 181 static const ICData& SpecializeICData(const ICData& ic_data, intptr_t cid) {
182 ASSERT(ic_data.num_args_tested() == 1); 182 ASSERT(ic_data.num_args_tested() == 1);
183 183
184 if ((ic_data.NumberOfChecks() == 1) && 184 if ((ic_data.NumberOfChecks() == 1) &&
185 (ic_data.GetReceiverClassIdAt(0) == cid)) { 185 (ic_data.GetReceiverClassIdAt(0) == cid)) {
186 return ic_data; // Nothing to do 186 return ic_data; // Nothing to do
187 } 187 }
188 188
189 const ICData& new_ic_data = ICData::ZoneHandle(ICData::New(
190 Function::Handle(ic_data.function()),
191 String::Handle(ic_data.target_name()),
192 Object::empty_array(), // Dummy argument descriptor.
193 ic_data.deopt_id(),
194 ic_data.num_args_tested()));
195 new_ic_data.set_deopt_reason(ic_data.deopt_reason());
196
197 const Function& function = 189 const Function& function =
198 Function::Handle(ic_data.GetTargetForReceiverClassId(cid)); 190 Function::Handle(ic_data.GetTargetForReceiverClassId(cid));
199 if (!function.IsNull()) { 191 if (!function.IsNull()) {
192 const ICData& new_ic_data = ICData::ZoneHandle(ICData::New(
Vyacheslav Egorov (Google) 2014/01/08 13:00:00 You can actually look up target function on the cl
Florian Schneider 2014/01/08 14:12:43 Added a TODO.
193 Function::Handle(ic_data.function()),
194 String::Handle(ic_data.target_name()),
195 Object::empty_array(), // Dummy argument descriptor.
196 ic_data.deopt_id(),
197 ic_data.num_args_tested()));
198 new_ic_data.set_deopt_reason(ic_data.deopt_reason());
200 new_ic_data.AddReceiverCheck(cid, function); 199 new_ic_data.AddReceiverCheck(cid, function);
200 return new_ic_data;
201 } 201 }
202 202 return ic_data;
Vyacheslav Egorov (Google) 2014/01/08 13:00:00 add empty line before return for readability.
Florian Schneider 2014/01/08 14:12:43 Done.
203 return new_ic_data;
204 } 203 }
205 204
206 205
207 void FlowGraphOptimizer::SpecializePolymorphicInstanceCall( 206 void FlowGraphOptimizer::SpecializePolymorphicInstanceCall(
208 PolymorphicInstanceCallInstr* call) { 207 PolymorphicInstanceCallInstr* call) {
209 if (!call->with_checks()) { 208 if (!call->with_checks()) {
210 return; // Already specialized. 209 return; // Already specialized.
211 } 210 }
212 211
213 const intptr_t receiver_cid = 212 const intptr_t receiver_cid =
214 call->PushArgumentAt(0)->value()->Type()->ToCid(); 213 call->PushArgumentAt(0)->value()->Type()->ToCid();
215 if (receiver_cid == kDynamicCid) { 214 if (receiver_cid == kDynamicCid) {
216 return; // No information about receiver was infered. 215 return; // No information about receiver was infered.
217 } 216 }
218 217
219 const ICData& ic_data = SpecializeICData(call->ic_data(), receiver_cid); 218 const ICData& ic_data = SpecializeICData(call->ic_data(), receiver_cid);
Vyacheslav Egorov (Google) 2014/01/08 13:00:00 I would rename SpecializeICData to TrySpecializeIC
Florian Schneider 2014/01/08 14:12:43 Done.
220 219 if (ic_data.raw() != call->ic_data().raw()) {
Vyacheslav Egorov (Google) 2014/01/08 13:00:00 You can change this to match the early exit patter
Florian Schneider 2014/01/08 14:12:43 Done.
221 const bool with_checks = false; 220 // Only replace the call if ICData were specialized.
222 PolymorphicInstanceCallInstr* specialized = 221 const bool with_checks = false;
223 new PolymorphicInstanceCallInstr(call->instance_call(), 222 PolymorphicInstanceCallInstr* specialized =
224 ic_data, 223 new PolymorphicInstanceCallInstr(call->instance_call(),
225 with_checks); 224 ic_data,
226 call->ReplaceWith(specialized, current_iterator()); 225 with_checks);
226 call->ReplaceWith(specialized, current_iterator());
227 }
227 } 228 }
228 229
229 230
230 static BinarySmiOpInstr* AsSmiShiftLeftInstruction(Definition* d) { 231 static BinarySmiOpInstr* AsSmiShiftLeftInstruction(Definition* d) {
231 BinarySmiOpInstr* instr = d->AsBinarySmiOp(); 232 BinarySmiOpInstr* instr = d->AsBinarySmiOp();
232 if ((instr != NULL) && (instr->op_kind() == Token::kSHL)) { 233 if ((instr != NULL) && (instr->op_kind() == Token::kSHL)) {
233 return instr; 234 return instr;
234 } 235 }
235 return NULL; 236 return NULL;
236 } 237 }
(...skipping 8078 matching lines...) Expand 10 before | Expand all | Expand 10 after
8315 } 8316 }
8316 8317
8317 // Insert materializations at environment uses. 8318 // Insert materializations at environment uses.
8318 for (intptr_t i = 0; i < exits.length(); i++) { 8319 for (intptr_t i = 0; i < exits.length(); i++) {
8319 CreateMaterializationAt(exits[i], alloc, alloc->cls(), *fields); 8320 CreateMaterializationAt(exits[i], alloc, alloc->cls(), *fields);
8320 } 8321 }
8321 } 8322 }
8322 8323
8323 8324
8324 } // namespace dart 8325 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/intermediate_language.cc » ('j') | runtime/vm/intermediate_language.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698