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

Unified Diff: runtime/vm/flow_graph_type_propagator.cc

Issue 1491373005: VM: Fix bug in type propagation at conditionals. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/flow_graph_type_propagator.h ('k') | tests/language/vm/type_propagation_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/flow_graph_type_propagator.cc
diff --git a/runtime/vm/flow_graph_type_propagator.cc b/runtime/vm/flow_graph_type_propagator.cc
index 986615f1b669b0924a459b550a725f229b3ea327..11df98a1d3f75a2b8e5578cf8d8878fe776fb32d 100644
--- a/runtime/vm/flow_graph_type_propagator.cc
+++ b/runtime/vm/flow_graph_type_propagator.cc
@@ -149,8 +149,6 @@ void FlowGraphTypePropagator::PropagateRecursive(BlockEntryInstr* block) {
}
}
- HandleBranchOnStrictCompare(block);
-
for (intptr_t i = 0; i < block->dominated_blocks().length(); ++i) {
PropagateRecursive(block->dominated_blocks()[i]);
}
@@ -159,61 +157,6 @@ void FlowGraphTypePropagator::PropagateRecursive(BlockEntryInstr* block) {
}
-void FlowGraphTypePropagator::HandleBranchOnStrictCompare(
- BlockEntryInstr* block) {
- BranchInstr* branch = block->last_instruction()->AsBranch();
- if (branch == NULL) {
- return;
- }
-
- StrictCompareInstr* compare = branch->comparison()->AsStrictCompare();
- if ((compare == NULL) || !compare->right()->BindsToConstant()) {
- return;
- }
-
- const intptr_t rollback_point = rollback_.length();
-
- Definition* defn = compare->left()->definition();
- const Object& right = compare->right()->BoundConstant();
- intptr_t cid = right.GetClassId();
-
- if (defn->IsLoadClassId() && right.IsSmi()) {
- defn = defn->AsLoadClassId()->object()->definition();
- cid = Smi::Cast(right).Value();
- }
-
- if (!CheckClassInstr::IsImmutableClassId(cid)) {
- if ((cid == kOneByteStringCid) || (cid == kTwoByteStringCid)) {
- SetTypeOf(defn, ZoneCompileType::Wrap(CompileType::String()));
- PropagateRecursive((compare->kind() == Token::kEQ_STRICT) ?
- branch->true_successor() : branch->false_successor());
- RollbackTo(rollback_point);
- }
- return;
- }
-
- if (compare->kind() == Token::kEQ_STRICT) {
- if (cid == kNullCid) {
- branch->set_constrained_type(MarkNonNullable(defn));
- PropagateRecursive(branch->false_successor());
- }
-
- SetCid(defn, cid);
- PropagateRecursive(branch->true_successor());
- } else if (compare->kind() == Token::kNE_STRICT) {
- if (cid == kNullCid) {
- branch->set_constrained_type(MarkNonNullable(defn));
- PropagateRecursive(branch->true_successor());
- }
-
- SetCid(defn, cid);
- PropagateRecursive(branch->false_successor());
- }
-
- RollbackTo(rollback_point);
-}
-
-
void FlowGraphTypePropagator::RollbackTo(intptr_t rollback_point) {
for (intptr_t i = rollback_.length() - 1; i >= rollback_point; i--) {
types_[rollback_[i].index()] = rollback_[i].type();
« no previous file with comments | « runtime/vm/flow_graph_type_propagator.h ('k') | tests/language/vm/type_propagation_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698