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

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

Issue 27727002: Optimize identical-comparisons based on propagated type information. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 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/flow_graph_optimizer.h ('k') | runtime/vm/il_printer.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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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/dart_entry.h" 9 #include "vm/dart_entry.h"
10 #include "vm/flow_graph_builder.h" 10 #include "vm/flow_graph_builder.h"
(...skipping 3205 matching lines...) Expand 10 before | Expand all | Expand 10 after
3216 ComparisonInstr* comparison = instr->comparison(); 3216 ComparisonInstr* comparison = instr->comparison();
3217 if (comparison->IsEqualityCompare()) { 3217 if (comparison->IsEqualityCompare()) {
3218 HandleEqualityCompare(comparison->AsEqualityCompare(), instr); 3218 HandleEqualityCompare(comparison->AsEqualityCompare(), instr);
3219 } else { 3219 } else {
3220 ASSERT(comparison->IsStrictCompare()); 3220 ASSERT(comparison->IsStrictCompare());
3221 // Nothing to do. 3221 // Nothing to do.
3222 } 3222 }
3223 } 3223 }
3224 3224
3225 3225
3226 static bool MayBeBoxableNumber(intptr_t cid) {
3227 return (cid == kDynamicCid) ||
3228 (cid == kMintCid) ||
3229 (cid == kBigintCid) ||
3230 (cid == kDoubleCid);
3231 }
3232
3233
3234 // Check if number check is not needed.
3235 void FlowGraphOptimizer::VisitStrictCompare(StrictCompareInstr* instr) {
3236 if (!instr->needs_number_check()) return;
3237
3238 // If one of the input is not a boxable number (Mint, Double, Bigint), no
3239 // need for number checks.
3240 if (!MayBeBoxableNumber(instr->left()->Type()->ToCid()) ||
3241 !MayBeBoxableNumber(instr->right()->Type()->ToCid())) {
3242 instr->set_needs_number_check(false);
3243 }
3244 }
3245
3246
3247 // Range analysis for smi values. 3226 // Range analysis for smi values.
3248 class RangeAnalysis : public ValueObject { 3227 class RangeAnalysis : public ValueObject {
3249 public: 3228 public:
3250 explicit RangeAnalysis(FlowGraph* flow_graph) 3229 explicit RangeAnalysis(FlowGraph* flow_graph)
3251 : flow_graph_(flow_graph), 3230 : flow_graph_(flow_graph),
3252 marked_defns_(NULL) { } 3231 marked_defns_(NULL) { }
3253 3232
3254 // Infer ranges for all values and remove overflow checks from binary smi 3233 // Infer ranges for all values and remove overflow checks from binary smi
3255 // operations when proven redundant. 3234 // operations when proven redundant.
3256 void Analyze(); 3235 void Analyze();
(...skipping 4496 matching lines...) Expand 10 before | Expand all | Expand 10 after
7753 } 7732 }
7754 7733
7755 // Insert materializations at environment uses. 7734 // Insert materializations at environment uses.
7756 for (intptr_t i = 0; i < exits.length(); i++) { 7735 for (intptr_t i = 0; i < exits.length(); i++) {
7757 CreateMaterializationAt(exits[i], alloc, alloc->cls(), *fields); 7736 CreateMaterializationAt(exits[i], alloc, alloc->cls(), *fields);
7758 } 7737 }
7759 } 7738 }
7760 7739
7761 7740
7762 } // namespace dart 7741 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/flow_graph_optimizer.h ('k') | runtime/vm/il_printer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698