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

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

Issue 10972010: Check for a NULL value before passing it to a function that assumes non-NULL. (Closed) Base URL: https://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 | « no previous file | 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/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/hash_map.h" 10 #include "vm/hash_map.h"
(...skipping 1442 matching lines...) Expand 10 before | Expand all | Expand 10 after
1453 return new Range(RangeBoundary::FromDefinition(boundary), 1453 return new Range(RangeBoundary::FromDefinition(boundary),
1454 RangeBoundary::MaxSmi()); 1454 RangeBoundary::MaxSmi());
1455 default: 1455 default:
1456 UNREACHABLE(); 1456 UNREACHABLE();
1457 return Range::Unknown(); 1457 return Range::Unknown();
1458 } 1458 }
1459 } 1459 }
1460 1460
1461 1461
1462 ConstraintInstr* RangeAnalysis::InsertConstraintFor(Definition* defn, 1462 ConstraintInstr* RangeAnalysis::InsertConstraintFor(Definition* defn,
1463 Range* constraint_range, 1463 Range* constraint_range,
1464 Instruction* after) { 1464 Instruction* after) {
1465 // No need to constrain constants. 1465 // No need to constrain constants.
1466 if (defn->IsConstant()) return NULL; 1466 if (defn->IsConstant()) return NULL;
1467 1467
1468 ConstraintInstr* constraint = 1468 ConstraintInstr* constraint =
1469 new ConstraintInstr(new Value(defn), constraint_range); 1469 new ConstraintInstr(new Value(defn), constraint_range);
1470 constraint->InsertAfter(after); 1470 constraint->InsertAfter(after);
1471 constraint->set_ssa_temp_index(flow_graph_->alloc_ssa_temp_index()); 1471 constraint->set_ssa_temp_index(flow_graph_->alloc_ssa_temp_index());
1472 RenameDominatedUses(defn, after, constraint); 1472 RenameDominatedUses(defn, after, constraint);
1473 constraints_.Add(constraint); 1473 constraints_.Add(constraint);
1474 constraint->value()->set_instruction(constraint); 1474 constraint->value()->set_instruction(constraint);
(...skipping 22 matching lines...) Expand all
1497 ASSERT(use->use_index() == 1); // Right operand. 1497 ASSERT(use->use_index() == 1); // Right operand.
1498 boundary = rel_op->InputAt(0)->definition(); 1498 boundary = rel_op->InputAt(0)->definition();
1499 // InsertConstraintFor assumes that defn is left operand of a 1499 // InsertConstraintFor assumes that defn is left operand of a
1500 // comparison if it is right operand flip the comparison. 1500 // comparison if it is right operand flip the comparison.
1501 op_kind = FlipComparison(rel_op->kind()); 1501 op_kind = FlipComparison(rel_op->kind());
1502 } 1502 }
1503 1503
1504 // Constrain definition at the true successor. 1504 // Constrain definition at the true successor.
1505 ConstraintInstr* true_constraint = 1505 ConstraintInstr* true_constraint =
1506 InsertConstraintFor(defn, 1506 InsertConstraintFor(defn,
1507 ConstraintRange(op_kind, boundary), 1507 ConstraintRange(op_kind, boundary),
1508 branch->true_successor()); 1508 branch->true_successor());
1509 // Mark true_constraint an artificial use of boundary. This ensures 1509 // Mark true_constraint an artificial use of boundary. This ensures
1510 // that constraint's range is recalculated if boundary's range changes. 1510 // that constraint's range is recalculated if boundary's range changes.
1511 if (true_constraint != NULL) true_constraint->AddDependency(boundary); 1511 if (true_constraint != NULL) true_constraint->AddDependency(boundary);
1512 1512
1513 // Constrain definition with a negated condition at the false successor. 1513 // Constrain definition with a negated condition at the false successor.
1514 ConstraintInstr* false_constraint = 1514 ConstraintInstr* false_constraint =
1515 InsertConstraintFor( 1515 InsertConstraintFor(
1516 defn, 1516 defn,
1517 ConstraintRange(NegateComparison(op_kind), boundary), 1517 ConstraintRange(NegateComparison(op_kind), boundary),
1518 branch->false_successor()); 1518 branch->false_successor());
1519 // Mark false_constraint an artificial use of boundary. This ensures 1519 // Mark false_constraint an artificial use of boundary. This ensures
1520 // that constraint's range is recalculated if boundary's range changes. 1520 // that constraint's range is recalculated if boundary's range changes.
1521 if (false_constraint != NULL) false_constraint->AddDependency(boundary); 1521 if (false_constraint != NULL) false_constraint->AddDependency(boundary);
1522 } 1522 }
1523 } 1523 }
1524 } 1524 }
1525 } 1525 }
1526 1526
1527 1527
1528 void RangeAnalysis::InsertConstraints() { 1528 void RangeAnalysis::InsertConstraints() {
1529 for (intptr_t i = 0; i < smi_checks_.length(); i++) { 1529 for (intptr_t i = 0; i < smi_checks_.length(); i++) {
1530 CheckSmiInstr* check = smi_checks_[i]; 1530 CheckSmiInstr* check = smi_checks_[i];
1531 ConstraintInstr* constraint = 1531 ConstraintInstr* constraint =
1532 InsertConstraintFor(check->value()->definition(), 1532 InsertConstraintFor(check->value()->definition(),
1533 Range::Unknown(), 1533 Range::Unknown(),
1534 check); 1534 check);
1535 InsertConstraintsFor(constraint); // Constrain uses further. 1535 if (constraint != NULL) {
1536 InsertConstraintsFor(constraint); // Constrain uses further.
1537 }
1536 } 1538 }
1537 1539
1538 for (intptr_t i = 0; i < smi_values_.length(); i++) { 1540 for (intptr_t i = 0; i < smi_values_.length(); i++) {
1539 InsertConstraintsFor(smi_values_[i]); 1541 InsertConstraintsFor(smi_values_[i]);
1540 } 1542 }
1541 } 1543 }
1542 1544
1543 1545
1544 void RangeAnalysis::InitializeRangesRecursive(BlockEntryInstr* block) { 1546 void RangeAnalysis::InitializeRangesRecursive(BlockEntryInstr* block) {
1545 JoinEntryInstr* join = block->AsJoinEntry(); 1547 JoinEntryInstr* join = block->AsJoinEntry();
(...skipping 1471 matching lines...) Expand 10 before | Expand all | Expand 10 after
3017 } 3019 }
3018 3020
3019 graph_->DiscoverBlocks(); 3021 graph_->DiscoverBlocks();
3020 GrowableArray<BitVector*> dominance_frontier; 3022 GrowableArray<BitVector*> dominance_frontier;
3021 graph_->ComputeDominators(&dominance_frontier); 3023 graph_->ComputeDominators(&dominance_frontier);
3022 graph_->ComputeUseLists(); 3024 graph_->ComputeUseLists();
3023 } 3025 }
3024 3026
3025 3027
3026 } // namespace dart 3028 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698