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

Unified Diff: runtime/vm/flow_graph_optimizer.cc

Issue 23480005: Change Bool::Get to return a handle instead of a pointer to a raw object. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: runtime/vm/flow_graph_optimizer.cc
diff --git a/runtime/vm/flow_graph_optimizer.cc b/runtime/vm/flow_graph_optimizer.cc
index dee0f58a564b39a27c0cd0116965d7ab6cbc4176..ff732c097c6a6e51d50d2cf5ce0013dc30020243 100644
--- a/runtime/vm/flow_graph_optimizer.cc
+++ b/runtime/vm/flow_graph_optimizer.cc
@@ -2539,7 +2539,7 @@ RawBool* FlowGraphOptimizer::InstanceOfAsBool(const ICData& ic_data,
TypeArguments::Handle(),
NULL);
if (prev.IsNull()) {
- prev = is_subtype ? Bool::True().raw() : Bool::False().raw();
+ prev = Bool::Get(is_subtype).raw();
} else {
if (is_subtype != prev.value()) return Bool::null();
}
@@ -2565,7 +2565,7 @@ void FlowGraphOptimizer::ReplaceWithInstanceOf(InstanceCallInstr* call) {
if (!as_bool.IsNull()) {
AddReceiverCheck(call);
if (negate) {
- as_bool = Bool::Get(!as_bool.value());
+ as_bool = Bool::Get(!as_bool.value()).raw();
}
ConstantInstr* bool_const = flow_graph()->GetConstant(as_bool);
for (intptr_t i = 0; i < call->ArgumentCount(); ++i) {
@@ -5998,10 +5998,7 @@ void ConstantPropagator::VisitStrictCompare(StrictCompareInstr* instr) {
if (instr->left()->definition() == instr->right()->definition()) {
// Fold x === x, and x !== x to true/false.
- SetValue(instr,
- (instr->kind() == Token::kEQ_STRICT)
- ? Bool::True()
- : Bool::False());
+ SetValue(instr, Bool::Get(instr->kind() == Token::kEQ_STRICT));
return;
}
@@ -6012,14 +6009,14 @@ void ConstantPropagator::VisitStrictCompare(StrictCompareInstr* instr) {
bool result = left.IsNull() ? instr->right()->Type()->IsNull()
: instr->left()->Type()->IsNull();
if (instr->kind() == Token::kNE_STRICT) result = !result;
- SetValue(instr, result ? Bool::True() : Bool::False());
+ SetValue(instr, Bool::Get(result));
} else {
SetValue(instr, non_constant_);
}
} else if (IsConstant(left) && IsConstant(right)) {
bool result = (left.raw() == right.raw());
if (instr->kind() == Token::kNE_STRICT) result = !result;
- SetValue(instr, result ? Bool::True() : Bool::False());
+ SetValue(instr, Bool::Get(result));
}
}
@@ -6051,10 +6048,7 @@ void ConstantPropagator::VisitEqualityCompare(EqualityCompareInstr* instr) {
// comparisons.
if (instr->IsCheckedStrictEqual() ||
RawObject::IsIntegerClassId(instr->operation_cid())) {
- return SetValue(instr,
- (instr->kind() == Token::kEQ)
- ? Bool::True()
- : Bool::False());
+ return SetValue(instr, Bool::Get(instr->kind() == Token::kEQ));
}
}
@@ -6065,13 +6059,10 @@ void ConstantPropagator::VisitEqualityCompare(EqualityCompareInstr* instr) {
const bool result = CompareIntegers(instr->kind(),
Integer::Cast(left),
Integer::Cast(right));
- SetValue(instr, result ? Bool::True() : Bool::False());
+ SetValue(instr, Bool::Get(result));
} else if (left.IsString() && right.IsString()) {
const bool result = String::Cast(left).Equals(String::Cast(right));
- SetValue(instr,
- ((instr->kind() == Token::kEQ) == result)
- ? Bool::True()
- : Bool::False());
+ SetValue(instr, Bool::Get((instr->kind() == Token::kEQ) == result));
} else {
SetValue(instr, non_constant_);
}
@@ -6089,7 +6080,7 @@ void ConstantPropagator::VisitRelationalOp(RelationalOpInstr* instr) {
const bool result = CompareIntegers(instr->kind(),
Integer::Cast(left),
Integer::Cast(right));
- SetValue(instr, result ? Bool::True() : Bool::False());
+ SetValue(instr, Bool::Get(result));
} else {
SetValue(instr, non_constant_);
}
@@ -6149,7 +6140,7 @@ void ConstantPropagator::VisitBooleanNegate(BooleanNegateInstr* instr) {
SetValue(instr, non_constant_);
} else if (IsConstant(value)) {
bool val = value.raw() != Bool::True().raw();
- SetValue(instr, val ? Bool::True() : Bool::False());
+ SetValue(instr, Bool::Get(val));
}
}

Powered by Google App Engine
This is Rietveld 408576698