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

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

Issue 10536086: Add stack check in loops so that loops can be stopped. Optimize relational operations. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 6 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
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/flow_graph_optimizer.h" 5 #include "vm/flow_graph_optimizer.h"
6 6
7 #include "vm/flow_graph_builder.h" 7 #include "vm/flow_graph_builder.h"
8 #include "vm/il_printer.h" 8 #include "vm/il_printer.h"
9 #include "vm/object_store.h" 9 #include "vm/object_store.h"
10 10
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 unary_op->set_instr(comp->instr()); 169 unary_op->set_instr(comp->instr());
170 comp->instr()->replace_computation(unary_op); 170 comp->instr()->replace_computation(unary_op);
171 } 171 }
172 } 172 }
173 173
174 174
175 // Returns true if all targets are the same. 175 // Returns true if all targets are the same.
176 static bool HasOneTarget(const ICData& ic_data) { 176 static bool HasOneTarget(const ICData& ic_data) {
177 ASSERT(ic_data.NumberOfChecks() > 0); 177 ASSERT(ic_data.NumberOfChecks() > 0);
178 Function& prev_target = Function::Handle(); 178 Function& prev_target = Function::Handle();
179 Class& cls = Class::Handle(); 179 GrowableArray<const Class*> classes;
180 ic_data.GetOneClassCheckAt(0, &cls, &prev_target); 180 ic_data.GetCheckAt(0, &classes, &prev_target);
181 ASSERT(!prev_target.IsNull()); 181 ASSERT(!prev_target.IsNull());
182 Function& target = Function::Handle(); 182 Function& target = Function::Handle();
183 for (intptr_t i = 1; i < ic_data.NumberOfChecks(); i++) { 183 for (intptr_t i = 1; i < ic_data.NumberOfChecks(); i++) {
184 ic_data.GetOneClassCheckAt(i, &cls, &target); 184 ic_data.GetCheckAt(i, &classes, &target);
185 ASSERT(!target.IsNull()); 185 ASSERT(!target.IsNull());
186 if (prev_target.raw() != target.raw()) { 186 if (prev_target.raw() != target.raw()) {
187 return false; 187 return false;
188 } 188 }
189 prev_target = target.raw(); 189 prev_target = target.raw();
190 } 190 }
191 return true; 191 return true;
192 } 192 }
193 193
194 194
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 TryInlineInstanceSetter(comp); 328 TryInlineInstanceSetter(comp);
329 } 329 }
330 } 330 }
331 331
332 332
333 void FlowGraphOptimizer::VisitLoadIndexed(LoadIndexedComp* comp) { 333 void FlowGraphOptimizer::VisitLoadIndexed(LoadIndexedComp* comp) {
334 if (!comp->HasICData()) return; 334 if (!comp->HasICData()) return;
335 335
336 const ICData& ic_data = *comp->ic_data(); 336 const ICData& ic_data = *comp->ic_data();
337 if (ic_data.NumberOfChecks() == 0) return; 337 if (ic_data.NumberOfChecks() == 0) return;
338 if (!HasOneTarget(ic_data)) return; 338 // TODO(vegorov): Add multiple receiver type support.
339 if (ic_data.NumberOfChecks() != 1) return;
340 ASSERT(HasOneTarget(ic_data));
339 341
340 Function& target = Function::Handle(); 342 Function& target = Function::Handle();
341 Class& cls = Class::Handle(); 343 Class& cls = Class::Handle();
342 ic_data.GetOneClassCheckAt(0, &cls, &target); 344 ic_data.GetOneClassCheckAt(0, &cls, &target);
343 345
344 switch (cls.id()) { 346 switch (cls.id()) {
345 case kArray: 347 case kArray:
346 case kImmutableArray: 348 case kImmutableArray:
347 case kGrowableObjectArray: 349 case kGrowableObjectArray:
348 comp->set_receiver_type(static_cast<ObjectKind>(cls.id())); 350 comp->set_receiver_type(static_cast<ObjectKind>(cls.id()));
349 } 351 }
350 } 352 }
351 353
352 354
355 void FlowGraphOptimizer::VisitRelationalOp(RelationalOpComp* comp) {
356 if (!comp->HasICData()) return;
357
358 const ICData& ic_data = *comp->ic_data();
359 if (ic_data.NumberOfChecks() == 0) return;
360 // TODO(srdjan): Add multiple receiver type support.
361 if (ic_data.NumberOfChecks() != 1) return;
362 ASSERT(HasOneTarget(ic_data));
363
364 if (HasTwoSmi(ic_data)) {
365 comp->set_operands_class_id(kSmi);
366 } else if (HasTwoDouble(ic_data)) {
367 comp->set_operands_class_id(kDouble);
368 }
369 }
370
371
353 void FlowGraphOptimizer::VisitDo(DoInstr* instr) { 372 void FlowGraphOptimizer::VisitDo(DoInstr* instr) {
354 instr->computation()->Accept(this); 373 instr->computation()->Accept(this);
355 } 374 }
356 375
357 376
358 void FlowGraphOptimizer::VisitBind(BindInstr* instr) { 377 void FlowGraphOptimizer::VisitBind(BindInstr* instr) {
359 instr->computation()->Accept(this); 378 instr->computation()->Accept(this);
360 } 379 }
361 380
362 381
363 } // namespace dart 382 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698