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

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

Issue 11414136: Implement proposed new identity spec. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 1 month 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
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/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/flow_graph_builder.h" 9 #include "vm/flow_graph_builder.h"
10 #include "vm/flow_graph_compiler.h" 10 #include "vm/flow_graph_compiler.h"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 ForwardInstructionIterator it(entry); 49 ForwardInstructionIterator it(entry);
50 current_iterator_ = ⁢ 50 current_iterator_ = ⁢
51 for (; !it.Done(); it.Advance()) { 51 for (; !it.Done(); it.Advance()) {
52 if (it.Current()->IsInstanceCall()) { 52 if (it.Current()->IsInstanceCall()) {
53 InstanceCallInstr* call = it.Current()->AsInstanceCall(); 53 InstanceCallInstr* call = it.Current()->AsInstanceCall();
54 if (call->HasICData()) { 54 if (call->HasICData()) {
55 if (TryCreateICData(call)) { 55 if (TryCreateICData(call)) {
56 VisitInstanceCall(call); 56 VisitInstanceCall(call);
57 } 57 }
58 } 58 }
59 } else if (it.Current()->IsStrictCompare()) {
60 VisitStrictCompare(it.Current()->AsStrictCompare());
61 } else if (it.Current()->IsBranch()) {
62 ComparisonInstr* compare = it.Current()->AsBranch()->comparison();
63 if (compare->IsStrictCompare()) {
64 VisitStrictCompare(compare->AsStrictCompare());
65 }
59 } 66 }
60 } 67 }
61 current_iterator_ = NULL; 68 current_iterator_ = NULL;
62 } 69 }
63 } 70 }
64 71
65 72
66 // Attempt to build ICData for call using propagated class-ids. 73 // Attempt to build ICData for call using propagated class-ids.
67 bool FlowGraphOptimizer::TryCreateICData(InstanceCallInstr* call) { 74 bool FlowGraphOptimizer::TryCreateICData(InstanceCallInstr* call) {
68 ASSERT(call->HasICData()); 75 ASSERT(call->HasICData());
(...skipping 1436 matching lines...) Expand 10 before | Expand all | Expand 10 after
1505 } else if (comparison->IsEqualityCompare()) { 1512 } else if (comparison->IsEqualityCompare()) {
1506 HandleEqualityCompare(this, comparison->AsEqualityCompare(), instr, 1513 HandleEqualityCompare(this, comparison->AsEqualityCompare(), instr,
1507 current_iterator()); 1514 current_iterator());
1508 } else { 1515 } else {
1509 ASSERT(comparison->IsStrictCompare()); 1516 ASSERT(comparison->IsStrictCompare());
1510 // Nothing to do. 1517 // Nothing to do.
1511 } 1518 }
1512 } 1519 }
1513 1520
1514 1521
1522 static bool MayBeBoxableNumber(intptr_t cid) {
1523 return (cid == kDynamicCid) ||
1524 (cid == kMintCid) ||
1525 (cid == kBigintCid) ||
1526 (cid == kDoubleCid);
1527 }
1528
1529
1530 // Check if number check is not needed.
1531 void FlowGraphOptimizer::VisitStrictCompare(StrictCompareInstr* instr) {
1532 if (!instr->needs_number_check()) return;
1533
1534 // If one of the input is not a boxable number (Mint, Double, Bigint), no
1535 // need for number checks.
1536 if (!MayBeBoxableNumber(instr->left()->ResultCid()) ||
1537 !MayBeBoxableNumber(instr->right()->ResultCid())) {
1538 instr->set_needs_number_check(false);
1539 }
1540 }
1541
1542
1515 // SminessPropagator ensures that CheckSmis are eliminated across phis. 1543 // SminessPropagator ensures that CheckSmis are eliminated across phis.
1516 class SminessPropagator : public ValueObject { 1544 class SminessPropagator : public ValueObject {
1517 public: 1545 public:
1518 explicit SminessPropagator(FlowGraph* flow_graph) 1546 explicit SminessPropagator(FlowGraph* flow_graph)
1519 : flow_graph_(flow_graph), 1547 : flow_graph_(flow_graph),
1520 known_smis_(new BitVector(flow_graph_->current_ssa_temp_index())), 1548 known_smis_(new BitVector(flow_graph_->current_ssa_temp_index())),
1521 rollback_checks_(10), 1549 rollback_checks_(10),
1522 in_worklist_(NULL), 1550 in_worklist_(NULL),
1523 worklist_(0) { } 1551 worklist_(0) { }
1524 1552
(...skipping 2232 matching lines...) Expand 10 before | Expand all | Expand 10 after
3757 3785
3758 if (FLAG_trace_constant_propagation) { 3786 if (FLAG_trace_constant_propagation) {
3759 OS::Print("\n==== After constant propagation ====\n"); 3787 OS::Print("\n==== After constant propagation ====\n");
3760 FlowGraphPrinter printer(*graph_); 3788 FlowGraphPrinter printer(*graph_);
3761 printer.PrintBlocks(); 3789 printer.PrintBlocks();
3762 } 3790 }
3763 } 3791 }
3764 3792
3765 3793
3766 } // namespace dart 3794 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698