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

Unified Diff: runtime/vm/flow_graph_builder.cc

Issue 10829451: Make Value not a subclass of Computation. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: rebased Created 8 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_builder.cc
===================================================================
--- runtime/vm/flow_graph_builder.cc (revision 11037)
+++ runtime/vm/flow_graph_builder.cc (working copy)
@@ -116,6 +116,11 @@
}
+MaterializeComp* EffectGraphVisitor::Constant(const Object& value) {
+ return new MaterializeComp(new ConstantVal(value));
+}
+
+
// Appends a graph fragment to a block entry instruction. Returns the entry
// instruction if the fragment was empty or else the exit of the fragment if
// it was non-empty (so NULL if the fragment is closed).
@@ -271,7 +276,7 @@
value));
}
const Bool& bool_true = Bool::ZoneHandle(Bool::True());
- Value* constant_true = Bind(new ConstantVal(bool_true));
+ Value* constant_true = Bind(Constant(bool_true));
BranchInstr* branch = new BranchInstr(condition_token_pos(),
owner()->try_index(),
value,
@@ -301,7 +306,7 @@
void TestGraphVisitor::MergeBranchWithNegate(BooleanNegateComp* comp) {
ASSERT(!FLAG_enable_type_checks);
const Bool& bool_true = Bool::ZoneHandle(Bool::True());
- Value* constant_true = Bind(new ConstantVal(bool_true));
+ Value* constant_true = Bind(Constant(bool_true));
BranchInstr* branch = new BranchInstr(condition_token_pos(),
owner()->try_index(),
comp->value(),
@@ -396,7 +401,7 @@
void ValueGraphVisitor::VisitLiteralNode(LiteralNode* node) {
- ReturnComputation(new ConstantVal(node->literal()));
+ ReturnComputation(Constant(node->literal()));
}
@@ -548,7 +553,7 @@
owner()->try_index(),
right_value));
}
- Value* constant_true = for_right.Bind(new ConstantVal(bool_true));
+ Value* constant_true = for_right.Bind(Constant(bool_true));
Value* compare =
for_right.Bind(new StrictCompareComp(Token::kEQ_STRICT,
right_value,
@@ -559,7 +564,7 @@
if (node->kind() == Token::kAND) {
ValueGraphVisitor for_false(owner(), temp_index());
- Value* constant_false = for_false.Bind(new ConstantVal(bool_false));
+ Value* constant_false = for_false.Bind(Constant(bool_false));
for_false.Do(BuildStoreLocal(
*owner()->parsed_function().expression_temp_var(),
constant_false));
@@ -567,7 +572,7 @@
} else {
ASSERT(node->kind() == Token::kOR);
ValueGraphVisitor for_true(owner(), temp_index());
- Value* constant_true = for_true.Bind(new ConstantVal(bool_true));
+ Value* constant_true = for_true.Bind(Constant(bool_true));
for_true.Do(BuildStoreLocal(
*owner()->parsed_function().expression_temp_var(),
constant_true));
@@ -612,7 +617,7 @@
Value* EffectGraphVisitor::BuildNullValue() {
- return Bind(new ConstantVal(Object::ZoneHandle()));
+ return Bind(Constant(Object::ZoneHandle()));
}
@@ -693,7 +698,7 @@
EffectGraphVisitor for_left_value(owner(), temp_index());
node->left()->Visit(&for_left_value);
Append(for_left_value);
- ReturnComputation(new ConstantVal(negate_result ? bool_false : bool_true));
+ ReturnComputation(Constant(negate_result ? bool_false : bool_true));
return;
}
@@ -703,18 +708,18 @@
type.IsInstantiated()) {
const Instance& literal_value = node->left()->AsLiteralNode()->literal();
const Class& cls = Class::Handle(literal_value.clazz());
- ConstantVal* result = NULL;
+ MaterializeComp* result = NULL;
if (cls.IsNullClass()) {
// A null object is only an instance of Object and Dynamic, which has
// already been checked above (if the type is instantiated). So we can
// return false here if the instance is null (and if the type is
// instantiated).
- result = new ConstantVal(negate_result ? bool_true : bool_false);
+ result = Constant(negate_result ? bool_true : bool_false);
} else {
if (literal_value.IsInstanceOf(type, TypeArguments::Handle(), NULL)) {
- result = new ConstantVal(negate_result ? bool_false : bool_true);
+ result = Constant(negate_result ? bool_false : bool_true);
} else {
- result = new ConstantVal(negate_result ? bool_true : bool_false);
+ result = Constant(negate_result ? bool_true : bool_false);
}
}
ReturnComputation(result);
@@ -1498,7 +1503,7 @@
ConstructorCallNode* node,
PushArgumentInstr* push_alloc_value) {
Value* ctor_arg = Bind(
- new ConstantVal(Smi::ZoneHandle(Smi::New(Function::kCtorPhaseAll))));
+ Constant(Smi::ZoneHandle(Smi::New(Function::kCtorPhaseAll))));
PushArgumentInstr* push_ctor_arg = PushArgument(ctor_arg);
ZoneGrowableArray<PushArgumentInstr*>* arguments =
@@ -1586,7 +1591,7 @@
ASSERT(!type.IsMalformed());
type_arguments = type.arguments();
type_arguments = type_arguments.Canonicalize();
- return Bind(new ConstantVal(type_arguments));
+ return Bind(Constant(type_arguments));
}
Function& outer_function =
Function::Handle(owner()->parsed_function().function().raw());
@@ -1624,7 +1629,7 @@
intptr_t token_pos,
const AbstractTypeArguments& type_arguments) {
if (type_arguments.IsNull() || type_arguments.IsInstantiated()) {
- return Bind(new ConstantVal(type_arguments));
+ return Bind(Constant(type_arguments));
}
// The type arguments are uninstantiated.
Value* instantiator_value =
@@ -1645,7 +1650,7 @@
ASSERT(cls.HasTypeArguments() && !node->constructor().IsFactory());
if (node->type_arguments().IsNull() ||
node->type_arguments().IsInstantiated()) {
- Value* type_arguments_val = Bind(new ConstantVal(node->type_arguments()));
+ Value* type_arguments_val = Bind(Constant(node->type_arguments()));
if (call_arguments != NULL) {
ASSERT(type_arguments == NULL);
call_arguments->Add(PushArgument(type_arguments_val));
@@ -1656,7 +1661,7 @@
// No instantiator required.
Value* instantiator_val = Bind(
- new ConstantVal(Smi::ZoneHandle(Smi::New(StubCode::kNoInstantiator))));
+ Constant(Smi::ZoneHandle(Smi::New(StubCode::kNoInstantiator))));
if (call_arguments != NULL) {
ASSERT(instantiator == NULL);
call_arguments->Add(PushArgument(instantiator_val));
@@ -2157,7 +2162,7 @@
Value* current_context = Bind(new CurrentContextComp());
Do(BuildStoreLocal(*owner()->parsed_function().saved_context_var(),
current_context));
- Value* null_context = Bind(new ConstantVal(Object::ZoneHandle()));
+ Value* null_context = Bind(Constant(Object::ZoneHandle()));
Do(new StoreContextComp(null_context));
}
@@ -2191,7 +2196,7 @@
// Write NULL to the source location to detect buggy accesses and
// allow GC of passed value if it gets overwritten by a new value in
// the function.
- Value* null_constant = Bind(new ConstantVal(Object::ZoneHandle()));
+ Value* null_constant = Bind(Constant(Object::ZoneHandle()));
Do(BuildStoreLocal(*temp_local, null_constant));
}
}
@@ -2365,7 +2370,7 @@
// so that the fragment is not closed in the middle of an expression.
void ValueGraphVisitor::VisitThrowNode(ThrowNode* node) {
BuildThrowNode(node);
- ReturnComputation(new ConstantVal(Instance::ZoneHandle()));
+ ReturnComputation(Constant(Instance::ZoneHandle()));
}

Powered by Google App Engine
This is Rietveld 408576698