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

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 630 matching lines...) Expand 10 before | Expand all | Expand 10 after
641 RawAbstractType* StoreLocalComp::CompileType() const { 641 RawAbstractType* StoreLocalComp::CompileType() const {
642 return value()->CompileType(); 642 return value()->CompileType();
643 } 643 }
644 644
645 645
646 RawAbstractType* StrictCompareComp::CompileType() const { 646 RawAbstractType* StrictCompareComp::CompileType() const {
647 return Type::BoolInterface(); 647 return Type::BoolInterface();
648 } 648 }
649 649
650 650
651 // Only known == targets return a Boolean.
651 RawAbstractType* EqualityCompareComp::CompileType() const { 652 RawAbstractType* EqualityCompareComp::CompileType() const {
652 return receiver_class_id() != kObjectCid 653 if ((receiver_class_id() == kSmiCid) ||
653 ? Type::BoolInterface() 654 (receiver_class_id() == kDoubleCid) ||
654 : Type::DynamicType(); 655 (receiver_class_id() == kNumberCid)) {
656 return Type::BoolInterface();
657 }
658 if (HasICData() && ic_data()->AllTargetsHaveSameOwner(kInstanceCid)) {
659 return Type::BoolInterface();
660 }
661 return Type::DynamicType();
655 } 662 }
656 663
657 664
658 RawAbstractType* RelationalOpComp::CompileType() const { 665 RawAbstractType* RelationalOpComp::CompileType() const {
659 return operands_class_id() != kObjectCid 666 if ((operands_class_id() == kSmiCid) ||
660 ? Type::BoolInterface() 667 (operands_class_id() == kDoubleCid) ||
661 : Type::DynamicType(); 668 (operands_class_id() == kNumberCid)) {
669 return Type::BoolInterface();
670 }
671 return Type::DynamicType();
662 } 672 }
663 673
664 674
665 RawAbstractType* NativeCallComp::CompileType() const { 675 RawAbstractType* NativeCallComp::CompileType() const {
666 // The result type of the native function is identical to the result type of 676 // The result type of the native function is identical to the result type of
667 // the enclosing native Dart function. However, we prefer to check the type 677 // the enclosing native Dart function. However, we prefer to check the type
668 // of the value returned from the native call. 678 // of the value returned from the native call.
669 return Type::DynamicType(); 679 return Type::DynamicType();
670 } 680 }
671 681
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after
1025 } 1035 }
1026 1036
1027 1037
1028 void StoreContextComp::EmitNativeCode(FlowGraphCompiler* compiler) { 1038 void StoreContextComp::EmitNativeCode(FlowGraphCompiler* compiler) {
1029 // Nothing to do. Context register were loaded by register allocator. 1039 // Nothing to do. Context register were loaded by register allocator.
1030 ASSERT(locs()->in(0).reg() == CTX); 1040 ASSERT(locs()->in(0).reg() == CTX);
1031 } 1041 }
1032 1042
1033 1043
1034 Definition* StrictCompareComp::TryReplace(BindInstr* instr) { 1044 Definition* StrictCompareComp::TryReplace(BindInstr* instr) {
1045 return NULL;
Florian Schneider 2012/08/15 11:29:57 Accidental edit? I don't see why this should be di
srdjan 2012/08/15 13:54:25 Yes, accidental edit, but correct. See other email
Florian Schneider 2012/08/15 14:15:56 I'm not convinced: This optimization relies only o
srdjan 2012/08/15 15:36:06 If the left expression's CompileType says that it
1035 UseVal* left_use = left()->AsUse(); 1046 UseVal* left_use = left()->AsUse();
1036 UseVal* right_use = right()->AsUse(); 1047 UseVal* right_use = right()->AsUse();
1037 if (right_use == NULL || left_use == NULL) return NULL; 1048 if ((right_use == NULL) || (left_use == NULL)) return NULL;
1038 Definition* left = left_use->definition(); 1049 Definition* left = left_use->definition();
1039 BindInstr* right = right_use->definition()->AsBind(); 1050 BindInstr* right = right_use->definition()->AsBind();
1040 if (right == NULL) return NULL; 1051 if (right == NULL) return NULL;
1041 ConstantVal* right_constant = right->computation()->AsConstant(); 1052 ConstantVal* right_constant = right->computation()->AsConstant();
1042 if (right_constant == NULL) return NULL; 1053 if (right_constant == NULL) return NULL;
1043 // TODO(fschneider): Handle other cases: e === false and e !== true/false. 1054 // TODO(fschneider): Handle other cases: e === false and e !== true/false.
1044 const AbstractType& left_type = 1055 // Handles e === true.
1045 AbstractType::Handle(left->HasPropagatedType() 1056 // const AbstractType& left_type = AbstractType::Handle(left->CompileType());
1046 ? left->PropagatedType() 1057 if ((kind() == Token::kEQ_STRICT) &&
1047 : left->CompileType()); 1058 (right_constant->value().raw() == Bool::True()) &&
1048 if ((left_type.raw() == Type::BoolInterface()) && 1059 left_use->CompileTypeIsMoreSpecificThan(
Florian Schneider 2012/08/15 14:15:56 Not sure if this works with null: Which other type
srdjan 2012/08/15 15:36:06 The only type more specific than bool interface is
1049 (kind() == Token::kEQ_STRICT) && 1060 Type::Handle(Type::BoolInterface()))) {
1050 (right_constant->value().raw() == Bool::True())) {
1051 // Remove the constant from the graph. 1061 // Remove the constant from the graph.
1052 right->RemoveFromGraph(); 1062 right->RemoveFromGraph();
1053 // Return left subexpression as the replacement for this instruction. 1063 // Return left subexpression as the replacement for this instruction.
1054 return left; 1064 return left;
1055 } 1065 }
1056 return NULL; 1066 return NULL;
1057 } 1067 }
1058 1068
1059 1069
1060 LocationSummary* StrictCompareComp::MakeLocationSummary() const { 1070 LocationSummary* StrictCompareComp::MakeLocationSummary() const {
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
1293 if (compiler->is_ssa()) { 1303 if (compiler->is_ssa()) {
1294 ASSERT(locs()->in(0).IsRegister()); 1304 ASSERT(locs()->in(0).IsRegister());
1295 __ PushRegister(locs()->in(0).reg()); 1305 __ PushRegister(locs()->in(0).reg());
1296 } 1306 }
1297 } 1307 }
1298 1308
1299 1309
1300 #undef __ 1310 #undef __
1301 1311
1302 } // namespace dart 1312 } // 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