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

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: Test suites pass 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) {
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(),
453 call->deopt_id(),
454 value_check),
455 call->env(),
456 Definition::kEffect);
457 needs_store_barrier = false;
458 } else if (class_id == kFloat64ArrayCid) {
srdjan 2012/10/19 00:41:53 Aren't the kFloat64ArrayCid and kFloat32ArrayCid t
459 ASSERT(!value_check.IsNull());
460 InsertBefore(call,
461 new CheckClassInstr(value->Copy(),
452 call->deopt_id(), 462 call->deopt_id(),
453 value_check), 463 value_check),
454 call->env(), 464 call->env(),
455 Definition::kEffect); 465 Definition::kEffect);
456 needs_store_barrier = false; 466 needs_store_barrier = false;
457 } else if (ArgIsAlwaysSmi(*call->ic_data(), 2)) { 467 } else if (ArgIsAlwaysSmi(*call->ic_data(), 2)) {
458 InsertBefore(call, 468 InsertBefore(call,
459 new CheckSmiInstr(value->Copy(), call->deopt_id()), 469 new CheckSmiInstr(value->Copy(), call->deopt_id()),
460 call->env(), 470 call->env(),
461 Definition::kEffect); 471 Definition::kEffect);
462 needs_store_barrier = false; 472 needs_store_barrier = false;
463 } 473 }
464 474
465 Definition* array_op = 475 Definition* array_op =
466 new StoreIndexedInstr(array, index, value, 476 new StoreIndexedInstr(array, index, value,
467 needs_store_barrier, array_cid, call->deopt_id()); 477 needs_store_barrier, array_cid, call->deopt_id());
468 call->ReplaceWith(array_op, current_iterator()); 478 call->ReplaceWith(array_op, current_iterator());
469 RemovePushArguments(call); 479 RemovePushArguments(call);
470 return true; 480 return true;
471 } 481 }
472 482
473 483
474 484
475 bool FlowGraphOptimizer::TryReplaceWithLoadIndexed(InstanceCallInstr* call) { 485 bool FlowGraphOptimizer::TryReplaceWithLoadIndexed(InstanceCallInstr* call) {
476 const intptr_t class_id = ReceiverClassId(call); 486 const intptr_t class_id = ReceiverClassId(call);
477 switch (class_id) { 487 switch (class_id) {
478 case kArrayCid: 488 case kArrayCid:
479 case kImmutableArrayCid: 489 case kImmutableArrayCid:
480 case kGrowableObjectArrayCid: 490 case kGrowableObjectArrayCid:
491 case kFloat32ArrayCid:
481 case kFloat64ArrayCid: 492 case kFloat64ArrayCid:
482 // Acceptable load index classes. 493 // Acceptable load index classes.
483 break; 494 break;
484 default: 495 default:
485 return false; 496 return false;
486 } 497 }
487 Value* array = NULL; 498 Value* array = NULL;
488 Value* index = NULL; 499 Value* index = NULL;
489 intptr_t array_cid = PrepareIndexedOp(call, class_id, &array, &index); 500 intptr_t array_cid = PrepareIndexedOp(call, class_id, &array, &index);
490 Definition* array_op = new LoadIndexedInstr(array, index, array_cid); 501 Definition* array_op = new LoadIndexedInstr(array, index, array_cid);
(...skipping 2844 matching lines...) Expand 10 before | Expand all | Expand 10 after
3335 3346
3336 if (FLAG_trace_constant_propagation) { 3347 if (FLAG_trace_constant_propagation) {
3337 OS::Print("\n==== After constant propagation ====\n"); 3348 OS::Print("\n==== After constant propagation ====\n");
3338 FlowGraphPrinter printer(*graph_); 3349 FlowGraphPrinter printer(*graph_);
3339 printer.PrintBlocks(); 3350 printer.PrintBlocks();
3340 } 3351 }
3341 } 3352 }
3342 3353
3343 3354
3344 } // namespace dart 3355 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698