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

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

Issue 11186023: Enable more redundancy elimination for checked mode asserts. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: 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
« no previous file with comments | « runtime/vm/intermediate_language.h ('k') | no next file » | 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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 } 79 }
80 80
81 81
82 bool CheckArrayBoundInstr::AttributesEqual(Instruction* other) const { 82 bool CheckArrayBoundInstr::AttributesEqual(Instruction* other) const {
83 CheckArrayBoundInstr* other_check = other->AsCheckArrayBound(); 83 CheckArrayBoundInstr* other_check = other->AsCheckArrayBound();
84 ASSERT(other_check != NULL); 84 ASSERT(other_check != NULL);
85 return array_type() == other_check->array_type(); 85 return array_type() == other_check->array_type();
86 } 86 }
87 87
88 88
89 bool AssertAssignableInstr::AttributesEqual(Instruction* other) const {
90 AssertAssignableInstr* other_assert = other->AsAssertAssignable();
91 ASSERT(other_assert != NULL);
92 // This predicate has to be commutative for DominatorBasedCSE to work.
93 // TODO(fschneider): Eliminate more asserts with subtype relation.
94 return dst_type().raw() == other_assert->dst_type().raw();
95 }
96
97
89 bool StrictCompareInstr::AttributesEqual(Instruction* other) const { 98 bool StrictCompareInstr::AttributesEqual(Instruction* other) const {
90 StrictCompareInstr* other_op = other->AsStrictCompare(); 99 StrictCompareInstr* other_op = other->AsStrictCompare();
91 ASSERT(other_op != NULL); 100 ASSERT(other_op != NULL);
92 return kind() == other_op->kind(); 101 return kind() == other_op->kind();
93 } 102 }
94 103
95 104
96 bool BinarySmiOpInstr::AttributesEqual(Instruction* other) const { 105 bool BinarySmiOpInstr::AttributesEqual(Instruction* other) const {
97 BinarySmiOpInstr* other_op = other->AsBinarySmiOp(); 106 BinarySmiOpInstr* other_op = other->AsBinarySmiOp();
98 ASSERT(other_op != NULL); 107 ASSERT(other_op != NULL);
(...skipping 1298 matching lines...) Expand 10 before | Expand all | Expand 10 after
1397 return this; 1406 return this;
1398 } 1407 }
1399 1408
1400 1409
1401 Definition* AssertBooleanInstr::Canonicalize() { 1410 Definition* AssertBooleanInstr::Canonicalize() {
1402 const intptr_t value_cid = value()->ResultCid(); 1411 const intptr_t value_cid = value()->ResultCid();
1403 return (value_cid == kBoolCid) ? value()->definition() : this; 1412 return (value_cid == kBoolCid) ? value()->definition() : this;
1404 } 1413 }
1405 1414
1406 1415
1416 Definition* AssertAssignableInstr::Canonicalize() {
1417 // (1) Replace the assert with its input if the input has a known compatible
1418 // class-id. The class-ids handled here are those that are known to be
1419 // results of IL instructions.
1420 intptr_t cid = value()->ResultCid();
1421 bool is_redundant = false;
1422 if (dst_type().IsIntType()) {
1423 is_redundant = (cid == kSmiCid) || (cid == kMintCid);
1424 } else if (dst_type().IsDoubleType()) {
1425 is_redundant = (cid == kDoubleCid);
1426 } else if (dst_type().IsBoolType()) {
1427 is_redundant = (cid == kBoolCid);
1428 }
1429 if (is_redundant) return value()->definition();
1430
1431 // (2) Replace the assert with its input if the input is the result of a
1432 // compatible assert itself.
1433 AssertAssignableInstr* check = value()->definition()->AsAssertAssignable();
1434 if ((check != NULL) && (check->dst_type().raw() == dst_type().raw())) {
1435 // TODO(fschneider): Eliminate more asserts with subtype relation.
1436 return check;
1437 }
1438 return this;
1439 }
1440
1407 Definition* StrictCompareInstr::Canonicalize() { 1441 Definition* StrictCompareInstr::Canonicalize() {
1408 if (!right()->BindsToConstant()) return this; 1442 if (!right()->BindsToConstant()) return this;
1409 const Object& right_constant = right()->BoundConstant(); 1443 const Object& right_constant = right()->BoundConstant();
1410 Definition* left_defn = left()->definition(); 1444 Definition* left_defn = left()->definition();
1411 // TODO(fschneider): Handle other cases: e === false and e !== true/false. 1445 // TODO(fschneider): Handle other cases: e === false and e !== true/false.
1412 // Handles e === true. 1446 // Handles e === true.
1413 if ((kind() == Token::kEQ_STRICT) && 1447 if ((kind() == Token::kEQ_STRICT) &&
1414 (right_constant.raw() == Bool::True()) && 1448 (right_constant.raw() == Bool::True()) &&
1415 (left()->ResultCid() == kBoolCid)) { 1449 (left()->ResultCid() == kBoolCid)) {
1416 // Return left subexpression as the replacement for this instruction. 1450 // Return left subexpression as the replacement for this instruction.
(...skipping 751 matching lines...) Expand 10 before | Expand all | Expand 10 after
2168 new_max = new_max.Clamp(); 2202 new_max = new_max.Clamp();
2169 } 2203 }
2170 2204
2171 return Range::Update(&range_, new_min, new_max); 2205 return Range::Update(&range_, new_min, new_max);
2172 } 2206 }
2173 2207
2174 2208
2175 #undef __ 2209 #undef __
2176 2210
2177 } // namespace dart 2211 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/intermediate_language.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698