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

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

Issue 11967012: Optimized loads/stores for scalar list: Uint8Clamped, Int8, Int16, Uint16. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: addressed comments Created 7 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 | « runtime/vm/flow_graph_compiler_x64.h ('k') | runtime/vm/intermediate_language.cc » ('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/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 580 matching lines...) Expand 10 before | Expand all | Expand 10 after
591 bool FlowGraphOptimizer::TryReplaceWithStoreIndexed(InstanceCallInstr* call) { 591 bool FlowGraphOptimizer::TryReplaceWithStoreIndexed(InstanceCallInstr* call) {
592 const intptr_t class_id = ReceiverClassId(call); 592 const intptr_t class_id = ReceiverClassId(call);
593 ICData& value_check = ICData::ZoneHandle(); 593 ICData& value_check = ICData::ZoneHandle();
594 switch (class_id) { 594 switch (class_id) {
595 case kArrayCid: 595 case kArrayCid:
596 case kGrowableObjectArrayCid: 596 case kGrowableObjectArrayCid:
597 if (ArgIsAlwaysSmi(*call->ic_data(), 2)) { 597 if (ArgIsAlwaysSmi(*call->ic_data(), 2)) {
598 value_check = call->ic_data()->AsUnaryClassChecksForArgNr(2); 598 value_check = call->ic_data()->AsUnaryClassChecksForArgNr(2);
599 } 599 }
600 break; 600 break;
601 case kInt8ArrayCid:
601 case kUint8ArrayCid: 602 case kUint8ArrayCid:
603 case kUint8ClampedArrayCid:
604 case kInt16ArrayCid:
605 case kUint16ArrayCid:
602 // Check that value is always smi. 606 // Check that value is always smi.
603 value_check = call->ic_data()->AsUnaryClassChecksForArgNr(2); 607 value_check = call->ic_data()->AsUnaryClassChecksForArgNr(2);
604 if ((value_check.NumberOfChecks() != 1) || 608 if ((value_check.NumberOfChecks() != 1) ||
605 (value_check.GetReceiverClassIdAt(0) != kSmiCid)) { 609 (value_check.GetReceiverClassIdAt(0) != kSmiCid)) {
606 return false; 610 return false;
607 } 611 }
608 break; 612 break;
609 613
610 case kFloat32ArrayCid: 614 case kFloat32ArrayCid:
611 case kFloat64ArrayCid: { 615 case kFloat64ArrayCid: {
(...skipping 30 matching lines...) Expand all
642 instantiator_class.type_arguments_field_offset(); 646 instantiator_class.type_arguments_field_offset();
643 LoadFieldInstr* load_type_args = 647 LoadFieldInstr* load_type_args =
644 new LoadFieldInstr(array->Copy(), 648 new LoadFieldInstr(array->Copy(),
645 type_arguments_field_offset, 649 type_arguments_field_offset,
646 Type::ZoneHandle()); // No type. 650 Type::ZoneHandle()); // No type.
647 InsertBefore(call, load_type_args, NULL, Definition::kValue); 651 InsertBefore(call, load_type_args, NULL, Definition::kValue);
648 instantiator = array->Copy(); 652 instantiator = array->Copy();
649 type_args = new Value(load_type_args); 653 type_args = new Value(load_type_args);
650 break; 654 break;
651 } 655 }
656 case kInt8ArrayCid:
652 case kUint8ArrayCid: 657 case kUint8ArrayCid:
658 case kUint8ClampedArrayCid:
659 case kInt16ArrayCid:
660 case kUint16ArrayCid:
661 ASSERT(value_type.IsIntType());
662 // Fall through.
653 case kFloat32ArrayCid: 663 case kFloat32ArrayCid:
654 case kFloat64ArrayCid: { 664 case kFloat64ArrayCid: {
655 ConstantInstr* null_constant = new ConstantInstr(Object::ZoneHandle()); 665 ConstantInstr* null_constant = new ConstantInstr(Object::ZoneHandle());
656 InsertBefore(call, null_constant, NULL, Definition::kValue); 666 InsertBefore(call, null_constant, NULL, Definition::kValue);
657 instantiator = new Value(null_constant); 667 instantiator = new Value(null_constant);
658 type_args = new Value(null_constant); 668 type_args = new Value(null_constant);
659 ASSERT((class_id != kUint8ArrayCid) || value_type.IsIntType());
660 ASSERT((class_id != kFloat32ArrayCid && class_id != kFloat64ArrayCid) || 669 ASSERT((class_id != kFloat32ArrayCid && class_id != kFloat64ArrayCid) ||
661 value_type.IsDoubleType()); 670 value_type.IsDoubleType());
662 ASSERT(value_type.IsInstantiated()); 671 ASSERT(value_type.IsInstantiated());
663 break; 672 break;
664 } 673 }
665 default: 674 default:
666 // TODO(fschneider): Add support for other array types. 675 // TODO(fschneider): Add support for other array types.
667 UNREACHABLE(); 676 UNREACHABLE();
668 } 677 }
669 AssertAssignableInstr* assert_value = 678 AssertAssignableInstr* assert_value =
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
713 722
714 723
715 bool FlowGraphOptimizer::TryReplaceWithLoadIndexed(InstanceCallInstr* call) { 724 bool FlowGraphOptimizer::TryReplaceWithLoadIndexed(InstanceCallInstr* call) {
716 const intptr_t class_id = ReceiverClassId(call); 725 const intptr_t class_id = ReceiverClassId(call);
717 switch (class_id) { 726 switch (class_id) {
718 case kArrayCid: 727 case kArrayCid:
719 case kImmutableArrayCid: 728 case kImmutableArrayCid:
720 case kGrowableObjectArrayCid: 729 case kGrowableObjectArrayCid:
721 case kFloat32ArrayCid: 730 case kFloat32ArrayCid:
722 case kFloat64ArrayCid: 731 case kFloat64ArrayCid:
732 case kInt8ArrayCid:
723 case kUint8ArrayCid: 733 case kUint8ArrayCid:
724 case kUint8ClampedArrayCid: 734 case kUint8ClampedArrayCid:
725 case kExternalUint8ArrayCid: 735 case kExternalUint8ArrayCid:
736 case kInt16ArrayCid:
737 case kUint16ArrayCid:
726 // Acceptable load index classes. 738 // Acceptable load index classes.
727 break; 739 break;
728 default: 740 default:
729 return false; 741 return false;
730 } 742 }
731 Value* array = NULL; 743 Value* array = NULL;
732 Value* index = NULL; 744 Value* index = NULL;
733 intptr_t array_cid = PrepareIndexedOp(call, class_id, &array, &index); 745 intptr_t array_cid = PrepareIndexedOp(call, class_id, &array, &index);
734 Definition* array_op = new LoadIndexedInstr(array, index, array_cid); 746 Definition* array_op = new LoadIndexedInstr(array, index, array_cid);
735 call->ReplaceWith(array_op, current_iterator()); 747 call->ReplaceWith(array_op, current_iterator());
(...skipping 3763 matching lines...) Expand 10 before | Expand all | Expand 10 after
4499 4511
4500 if (FLAG_trace_constant_propagation) { 4512 if (FLAG_trace_constant_propagation) {
4501 OS::Print("\n==== After constant propagation ====\n"); 4513 OS::Print("\n==== After constant propagation ====\n");
4502 FlowGraphPrinter printer(*graph_); 4514 FlowGraphPrinter printer(*graph_);
4503 printer.PrintBlocks(); 4515 printer.PrintBlocks();
4504 } 4516 }
4505 } 4517 }
4506 4518
4507 4519
4508 } // namespace dart 4520 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/flow_graph_compiler_x64.h ('k') | runtime/vm/intermediate_language.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698