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

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

Issue 10826285: Optimize equality for case when all targets are Object.equals. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 4 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/intermediate_language.h ('k') | runtime/vm/intermediate_language_ia32.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/intermediate_language.h" 5 #include "vm/intermediate_language.h"
6 6
7 #include "vm/bit_vector.h" 7 #include "vm/bit_vector.h"
8 #include "vm/dart_entry.h" 8 #include "vm/dart_entry.h"
9 #include "vm/flow_graph_allocator.h" 9 #include "vm/flow_graph_allocator.h"
10 #include "vm/flow_graph_builder.h" 10 #include "vm/flow_graph_builder.h"
(...skipping 631 matching lines...) Expand 10 before | Expand all | Expand 10 after
642 RawAbstractType* StoreLocalComp::CompileType() const { 642 RawAbstractType* StoreLocalComp::CompileType() const {
643 return value()->CompileType(); 643 return value()->CompileType();
644 } 644 }
645 645
646 646
647 RawAbstractType* StrictCompareComp::CompileType() const { 647 RawAbstractType* StrictCompareComp::CompileType() const {
648 return Type::BoolInterface(); 648 return Type::BoolInterface();
649 } 649 }
650 650
651 651
652 // Only known == targets return a Boolean.
652 RawAbstractType* EqualityCompareComp::CompileType() const { 653 RawAbstractType* EqualityCompareComp::CompileType() const {
653 return receiver_class_id() != kObjectCid 654 if ((receiver_class_id() == kSmiCid) ||
654 ? Type::BoolInterface() 655 (receiver_class_id() == kDoubleCid) ||
655 : Type::DynamicType(); 656 (receiver_class_id() == kNumberCid)) {
657 return Type::BoolInterface();
658 }
659 if (HasICData() && ic_data()->AllTargetsHaveSameOwner(kInstanceCid)) {
660 return Type::BoolInterface();
661 }
662 return Type::DynamicType();
656 } 663 }
657 664
658 665
659 RawAbstractType* RelationalOpComp::CompileType() const { 666 RawAbstractType* RelationalOpComp::CompileType() const {
660 return operands_class_id() != kObjectCid 667 if ((operands_class_id() == kSmiCid) ||
661 ? Type::BoolInterface() 668 (operands_class_id() == kDoubleCid) ||
662 : Type::DynamicType(); 669 (operands_class_id() == kNumberCid)) {
670 return Type::BoolInterface();
671 }
672 return Type::DynamicType();
663 } 673 }
664 674
665 675
666 RawAbstractType* NativeCallComp::CompileType() const { 676 RawAbstractType* NativeCallComp::CompileType() const {
667 // The result type of the native function is identical to the result type of 677 // The result type of the native function is identical to the result type of
668 // the enclosing native Dart function. However, we prefer to check the type 678 // the enclosing native Dart function. However, we prefer to check the type
669 // of the value returned from the native call. 679 // of the value returned from the native call.
670 return Type::DynamicType(); 680 return Type::DynamicType();
671 } 681 }
672 682
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
1028 1038
1029 void StoreContextComp::EmitNativeCode(FlowGraphCompiler* compiler) { 1039 void StoreContextComp::EmitNativeCode(FlowGraphCompiler* compiler) {
1030 // Nothing to do. Context register were loaded by register allocator. 1040 // Nothing to do. Context register were loaded by register allocator.
1031 ASSERT(locs()->in(0).reg() == CTX); 1041 ASSERT(locs()->in(0).reg() == CTX);
1032 } 1042 }
1033 1043
1034 1044
1035 Definition* StrictCompareComp::TryReplace(BindInstr* instr) { 1045 Definition* StrictCompareComp::TryReplace(BindInstr* instr) {
1036 UseVal* left_use = left()->AsUse(); 1046 UseVal* left_use = left()->AsUse();
1037 UseVal* right_use = right()->AsUse(); 1047 UseVal* right_use = right()->AsUse();
1038 if (right_use == NULL || left_use == NULL) return NULL; 1048 if ((right_use == NULL) || (left_use == NULL)) return NULL;
1039 Definition* left = left_use->definition(); 1049 Definition* left = left_use->definition();
1040 BindInstr* right = right_use->definition()->AsBind(); 1050 BindInstr* right = right_use->definition()->AsBind();
1041 if (right == NULL) return NULL; 1051 if (right == NULL) return NULL;
1042 ConstantVal* right_constant = right->computation()->AsConstant(); 1052 ConstantVal* right_constant = right->computation()->AsConstant();
1043 if (right_constant == NULL) return NULL; 1053 if (right_constant == NULL) return NULL;
1044 // TODO(fschneider): Handle other cases: e === false and e !== true/false. 1054 // TODO(fschneider): Handle other cases: e === false and e !== true/false.
1045 const AbstractType& left_type = 1055 // Handles e === true.
1046 AbstractType::Handle(left->HasPropagatedType() 1056 const AbstractType& left_type = AbstractType::Handle(left->CompileType());
1047 ? left->PropagatedType() 1057 if ((kind() == Token::kEQ_STRICT) &&
1048 : left->CompileType()); 1058 (right_constant->value().raw() == Bool::True()) &&
1049 if ((left_type.raw() == Type::BoolInterface()) && 1059 left_type.IsSubtypeOf(Type::Handle(Type::BoolInterface()), NULL)) {
regis 2012/08/13 23:06:19 You should be using Value::CompileTypeIsMoreSpecif
srdjan 2012/08/15 13:54:24 Done.
1050 (kind() == Token::kEQ_STRICT) &&
1051 (right_constant->value().raw() == Bool::True())) {
1052 // Remove the constant from the graph. 1060 // Remove the constant from the graph.
1053 right->RemoveFromGraph(); 1061 right->RemoveFromGraph();
1054 // Return left subexpression as the replacement for this instruction. 1062 // Return left subexpression as the replacement for this instruction.
1055 return left; 1063 return left;
1056 } 1064 }
1057 return NULL; 1065 return NULL;
1058 } 1066 }
1059 1067
1060 1068
1061 LocationSummary* StrictCompareComp::MakeLocationSummary() const { 1069 LocationSummary* StrictCompareComp::MakeLocationSummary() const {
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
1294 if (compiler->is_ssa()) { 1302 if (compiler->is_ssa()) {
1295 ASSERT(locs()->in(0).IsRegister()); 1303 ASSERT(locs()->in(0).IsRegister());
1296 __ PushRegister(locs()->in(0).reg()); 1304 __ PushRegister(locs()->in(0).reg());
1297 } 1305 }
1298 } 1306 }
1299 1307
1300 1308
1301 #undef __ 1309 #undef __
1302 1310
1303 } // namespace dart 1311 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/intermediate_language.h ('k') | runtime/vm/intermediate_language_ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698