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

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

Issue 11191002: Optimize type checks for boolean expressions using class-id information. (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 1318 matching lines...) Expand 10 before | Expand all | Expand 10 after
1329 Instruction* Instruction::Canonicalize() { 1329 Instruction* Instruction::Canonicalize() {
1330 return this; 1330 return this;
1331 } 1331 }
1332 1332
1333 1333
1334 Definition* Definition::Canonicalize() { 1334 Definition* Definition::Canonicalize() {
1335 return this; 1335 return this;
1336 } 1336 }
1337 1337
1338 1338
1339 Definition* AssertBooleanInstr::Canonicalize() {
1340 const intptr_t value_cid = value()->ResultCid();
1341 return (value_cid == kBoolCid) ? value()->definition() : this;
1342 }
1343
1344
1339 Definition* StrictCompareInstr::Canonicalize() { 1345 Definition* StrictCompareInstr::Canonicalize() {
1340 if (!right()->BindsToConstant()) return this; 1346 if (!right()->BindsToConstant()) return this;
1341 const Object& right_constant = right()->BoundConstant(); 1347 const Object& right_constant = right()->BoundConstant();
1342 Definition* left_defn = left()->definition(); 1348 Definition* left_defn = left()->definition();
1343 // TODO(fschneider): Handle other cases: e === false and e !== true/false. 1349 // TODO(fschneider): Handle other cases: e === false and e !== true/false.
1344 // Handles e === true. 1350 // Handles e === true.
1345 if ((kind() == Token::kEQ_STRICT) && 1351 if ((kind() == Token::kEQ_STRICT) &&
1346 (right_constant.raw() == Bool::True()) && 1352 (right_constant.raw() == Bool::True()) &&
1347 (left()->ResultCid() == kBoolCid)) { 1353 (left()->ResultCid() == kBoolCid)) {
1348 // Return left subexpression as the replacement for this instruction. 1354 // Return left subexpression as the replacement for this instruction.
1349 return left_defn; 1355 return left_defn;
1350 } 1356 }
1351 return this; 1357 return this;
1352 } 1358 }
1353 1359
1354 1360
1355 Instruction* CheckClassInstr::Canonicalize() { 1361 Instruction* CheckClassInstr::Canonicalize() {
1356 const intptr_t v_cid = value()->ResultCid(); 1362 const intptr_t value_cid = value()->ResultCid();
1357 const intptr_t num_checks = unary_checks().NumberOfChecks(); 1363 const intptr_t num_checks = unary_checks().NumberOfChecks();
1358 if ((num_checks == 1) && 1364 if ((num_checks == 1) &&
1359 (v_cid == unary_checks().GetReceiverClassIdAt(0))) { 1365 (value_cid == unary_checks().GetReceiverClassIdAt(0))) {
1360 // No checks needed. 1366 // No checks needed.
1361 return NULL; 1367 return NULL;
1362 } 1368 }
1363 return this; 1369 return this;
1364 } 1370 }
1365 1371
1366 1372
1367 Instruction* CheckSmiInstr::Canonicalize() { 1373 Instruction* CheckSmiInstr::Canonicalize() {
1368 return (value()->ResultCid() == kSmiCid) ? NULL : this; 1374 return (value()->ResultCid() == kSmiCid) ? NULL : this;
1369 } 1375 }
(...skipping 716 matching lines...) Expand 10 before | Expand all | Expand 10 after
2086 new_max = new_max.Clamp(); 2092 new_max = new_max.Clamp();
2087 } 2093 }
2088 2094
2089 return Range::Update(&range_, new_min, new_max); 2095 return Range::Update(&range_, new_min, new_max);
2090 } 2096 }
2091 2097
2092 2098
2093 #undef __ 2099 #undef __
2094 2100
2095 } // namespace dart 2101 } // 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