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

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

Issue 11198072: Inline load and store index on Float32Arrays. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Codereview fixes. Created 8 years, 2 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/bit_vector.h" 7 #include "vm/bit_vector.h"
8 #include "vm/cha.h" 8 #include "vm/cha.h"
9 #include "vm/flow_graph_builder.h" 9 #include "vm/flow_graph_builder.h"
10 #include "vm/flow_graph_compiler.h" 10 #include "vm/flow_graph_compiler.h"
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 bool FlowGraphOptimizer::TryReplaceWithStoreIndexed(InstanceCallInstr* call) { 420 bool FlowGraphOptimizer::TryReplaceWithStoreIndexed(InstanceCallInstr* call) {
421 // TODO(fschneider): Optimize []= operator in checked mode as well. 421 // TODO(fschneider): Optimize []= operator in checked mode as well.
422 if (FLAG_enable_type_checks) return false; 422 if (FLAG_enable_type_checks) return false;
423 const intptr_t class_id = ReceiverClassId(call); 423 const intptr_t class_id = ReceiverClassId(call);
424 ICData& value_check = ICData::Handle(); 424 ICData& value_check = ICData::Handle();
425 switch (class_id) { 425 switch (class_id) {
426 case kArrayCid: 426 case kArrayCid:
427 case kGrowableObjectArrayCid: 427 case kGrowableObjectArrayCid:
428 // Acceptable store index classes. 428 // Acceptable store index classes.
429 break; 429 break;
430 case kFloat32ArrayCid:
430 case kFloat64ArrayCid: { 431 case kFloat64ArrayCid: {
431 // Check that value is always double. 432 // Check that value is always double.
432 value_check = call->ic_data()->AsUnaryClassChecksForArgNr(2); 433 value_check = call->ic_data()->AsUnaryClassChecksForArgNr(2);
433 if ((value_check.NumberOfChecks() != 1) || 434 if ((value_check.NumberOfChecks() != 1) ||
434 (value_check.GetReceiverClassIdAt(0) != kDoubleCid)) { 435 (value_check.GetReceiverClassIdAt(0) != kDoubleCid)) {
435 return false; 436 return false;
436 } 437 }
437 break; 438 break;
438 } 439 }
439 default: 440 default:
440 return false; 441 return false;
441 } 442 }
442 Value* array = NULL; 443 Value* array = NULL;
443 Value* index = NULL; 444 Value* index = NULL;
444 intptr_t array_cid = PrepareIndexedOp(call, class_id, &array, &index); 445 intptr_t array_cid = PrepareIndexedOp(call, class_id, &array, &index);
445 Value* value = call->ArgumentAt(2)->value(); 446 Value* value = call->ArgumentAt(2)->value();
446 // Check if store barrier is needed. 447 // Check if store barrier is needed.
447 bool needs_store_barrier = true; 448 bool needs_store_barrier = true;
448 if (class_id == kFloat64ArrayCid) { 449 if (class_id == kFloat32ArrayCid || class_id == kFloat64ArrayCid) {
srdjan 2012/10/19 00:58:33 Use parenthesis around == expressions.
449 ASSERT(!value_check.IsNull()); 450 ASSERT(!value_check.IsNull());
450 InsertBefore(call, 451 InsertBefore(call,
451 new CheckClassInstr(value->Copy(), 452 new CheckClassInstr(value->Copy(),
452 call->deopt_id(), 453 call->deopt_id(),
453 value_check), 454 value_check),
454 call->env(), 455 call->env(),
455 Definition::kEffect); 456 Definition::kEffect);
456 needs_store_barrier = false; 457 needs_store_barrier = false;
457 } else if (ArgIsAlwaysSmi(*call->ic_data(), 2)) { 458 } else if (ArgIsAlwaysSmi(*call->ic_data(), 2)) {
458 InsertBefore(call, 459 InsertBefore(call,
(...skipping 12 matching lines...) Expand all
471 } 472 }
472 473
473 474
474 475
475 bool FlowGraphOptimizer::TryReplaceWithLoadIndexed(InstanceCallInstr* call) { 476 bool FlowGraphOptimizer::TryReplaceWithLoadIndexed(InstanceCallInstr* call) {
476 const intptr_t class_id = ReceiverClassId(call); 477 const intptr_t class_id = ReceiverClassId(call);
477 switch (class_id) { 478 switch (class_id) {
478 case kArrayCid: 479 case kArrayCid:
479 case kImmutableArrayCid: 480 case kImmutableArrayCid:
480 case kGrowableObjectArrayCid: 481 case kGrowableObjectArrayCid:
482 case kFloat32ArrayCid:
481 case kFloat64ArrayCid: 483 case kFloat64ArrayCid:
482 // Acceptable load index classes. 484 // Acceptable load index classes.
483 break; 485 break;
484 default: 486 default:
485 return false; 487 return false;
486 } 488 }
487 Value* array = NULL; 489 Value* array = NULL;
488 Value* index = NULL; 490 Value* index = NULL;
489 intptr_t array_cid = PrepareIndexedOp(call, class_id, &array, &index); 491 intptr_t array_cid = PrepareIndexedOp(call, class_id, &array, &index);
490 Definition* array_op = new LoadIndexedInstr(array, index, array_cid); 492 Definition* array_op = new LoadIndexedInstr(array, index, array_cid);
(...skipping 2844 matching lines...) Expand 10 before | Expand all | Expand 10 after
3335 3337
3336 if (FLAG_trace_constant_propagation) { 3338 if (FLAG_trace_constant_propagation) {
3337 OS::Print("\n==== After constant propagation ====\n"); 3339 OS::Print("\n==== After constant propagation ====\n");
3338 FlowGraphPrinter printer(*graph_); 3340 FlowGraphPrinter printer(*graph_);
3339 printer.PrintBlocks(); 3341 printer.PrintBlocks();
3340 } 3342 }
3341 } 3343 }
3342 3344
3343 3345
3344 } // namespace dart 3346 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698