| Index: vm/flow_graph_builder.cc
|
| ===================================================================
|
| --- vm/flow_graph_builder.cc (revision 10004)
|
| +++ vm/flow_graph_builder.cc (working copy)
|
| @@ -199,6 +199,13 @@
|
| }
|
|
|
|
|
| +PushArgumentInstr* EffectGraphVisitor::PushArgument(Value* value) {
|
| + PushArgumentInstr* result = new PushArgumentInstr(value);
|
| + AddInstruction(result);
|
| + return result;
|
| +}
|
| +
|
| +
|
| Computation* EffectGraphVisitor::BuildStoreLocal(
|
| const LocalVariable& local, Value* value) {
|
| if (local.is_captured()) {
|
| @@ -1368,11 +1375,10 @@
|
| } else {
|
| receiver = BuildNullValue();
|
| }
|
| - PushArgumentInstr* push_receiver = new PushArgumentInstr(receiver);
|
| + PushArgumentInstr* push_receiver = PushArgument(receiver);
|
| ZoneGrowableArray<PushArgumentInstr*>* arguments =
|
| new ZoneGrowableArray<PushArgumentInstr*>(2);
|
| arguments->Add(push_receiver);
|
| - AddInstruction(push_receiver);
|
| ASSERT(function.context_scope() != ContextScope::null());
|
|
|
| // The function type of a closure may have type arguments. In that case, pass
|
| @@ -1387,10 +1393,8 @@
|
| } else {
|
| type_arguments = BuildNullValue();
|
| }
|
| - PushArgumentInstr* push_type_arguments =
|
| - new PushArgumentInstr(type_arguments);
|
| + PushArgumentInstr* push_type_arguments = PushArgument(type_arguments);
|
| arguments->Add(push_type_arguments);
|
| - AddInstruction(push_type_arguments);
|
| ReturnComputation(
|
| new CreateClosureComp(node, owner()->try_index(), arguments));
|
| }
|
| @@ -1415,8 +1419,7 @@
|
| ValueGraphVisitor for_argument(owner(), temp_index());
|
| node.NodeAt(i)->Visit(&for_argument);
|
| Append(for_argument);
|
| - PushArgumentInstr* push_arg = new PushArgumentInstr(for_argument.value());
|
| - AddInstruction(push_arg);
|
| + PushArgumentInstr* push_arg = PushArgument(for_argument.value());
|
| values->Add(push_arg);
|
| }
|
| }
|
| @@ -1445,14 +1448,15 @@
|
| // arguments: <ArgumentList> }
|
| void EffectGraphVisitor::VisitStaticCallNode(StaticCallNode* node) {
|
| int length = node->arguments()->length();
|
| - ZoneGrowableArray<Value*>* values = new ZoneGrowableArray<Value*>(length);
|
| - TranslateArgumentList(*node->arguments(), values);
|
| + ZoneGrowableArray<PushArgumentInstr*>* arguments =
|
| + new ZoneGrowableArray<PushArgumentInstr*>(length);
|
| + BuildPushArguments(*node->arguments(), arguments);
|
| StaticCallComp* call =
|
| new StaticCallComp(node->token_pos(),
|
| owner()->try_index(),
|
| node->function(),
|
| node->arguments()->names(),
|
| - values);
|
| + arguments);
|
| ReturnComputation(call);
|
| }
|
|
|
| @@ -1462,8 +1466,7 @@
|
| ValueGraphVisitor for_closure(owner(), temp_index());
|
| node->closure()->Visit(&for_closure);
|
| Append(for_closure);
|
| - PushArgumentInstr* push_closure = new PushArgumentInstr(for_closure.value());
|
| - AddInstruction(push_closure);
|
| + PushArgumentInstr* push_closure = PushArgument(for_closure.value());
|
|
|
| ZoneGrowableArray<PushArgumentInstr*>* arguments =
|
| new ZoneGrowableArray<PushArgumentInstr*>(node->arguments()->length());
|
| @@ -1537,39 +1540,43 @@
|
| }
|
|
|
|
|
| -void EffectGraphVisitor::BuildConstructorCall(ConstructorCallNode* node,
|
| - Value* alloc_value) {
|
| +void EffectGraphVisitor::BuildConstructorCall(
|
| + ConstructorCallNode* node,
|
| + PushArgumentInstr* push_alloc_value) {
|
| Value* ctor_arg = Bind(
|
| new ConstantVal(Smi::ZoneHandle(Smi::New(Function::kCtorPhaseAll))));
|
| + PushArgumentInstr* push_ctor_arg = PushArgument(ctor_arg);
|
|
|
| - ZoneGrowableArray<Value*>* values = new ZoneGrowableArray<Value*>();
|
| - values->Add(alloc_value);
|
| - values->Add(ctor_arg);
|
| + ZoneGrowableArray<PushArgumentInstr*>* arguments =
|
| + new ZoneGrowableArray<PushArgumentInstr*>(2);
|
| + arguments->Add(push_alloc_value);
|
| + arguments->Add(push_ctor_arg);
|
|
|
| - TranslateArgumentList(*node->arguments(), values);
|
| + BuildPushArguments(*node->arguments(), arguments);
|
| Do(new StaticCallComp(node->token_pos(),
|
| owner()->try_index(),
|
| node->constructor(),
|
| node->arguments()->names(),
|
| - values));
|
| + arguments));
|
| }
|
|
|
|
|
| void EffectGraphVisitor::VisitConstructorCallNode(ConstructorCallNode* node) {
|
| if (node->constructor().IsFactory()) {
|
| - ZoneGrowableArray<Value*>* factory_arguments =
|
| - new ZoneGrowableArray<Value*>();
|
| - factory_arguments->Add(
|
| + ZoneGrowableArray<PushArgumentInstr*>* arguments =
|
| + new ZoneGrowableArray<PushArgumentInstr*>();
|
| + PushArgumentInstr* push_type_arguments = PushArgument(
|
| BuildInstantiatedTypeArguments(node->token_pos(),
|
| node->type_arguments()));
|
| - ASSERT(factory_arguments->length() == 1);
|
| - TranslateArgumentList(*node->arguments(), factory_arguments);
|
| + arguments->Add(push_type_arguments);
|
| + ASSERT(arguments->length() == 1);
|
| + BuildPushArguments(*node->arguments(), arguments);
|
| StaticCallComp* call =
|
| new StaticCallComp(node->token_pos(),
|
| owner()->try_index(),
|
| node->constructor(),
|
| node->arguments()->names(),
|
| - factory_arguments);
|
| + arguments);
|
| ReturnComputation(call);
|
| return;
|
| }
|
| @@ -1579,8 +1586,9 @@
|
| // t_n+2... <- constructor arguments start here
|
| // StaticCall(constructor, t_n+1, t_n+2, ...)
|
| // No need to preserve allocated value (simpler than in ValueGraphVisitor).
|
| - Value* allocate = BuildObjectAllocation(node);
|
| - BuildConstructorCall(node, allocate);
|
| + Value* allocated_value = BuildObjectAllocation(node);
|
| + PushArgumentInstr* push_allocated_value = PushArgument(allocated_value);
|
| + BuildConstructorCall(node, push_allocated_value);
|
| }
|
|
|
|
|
| @@ -1749,7 +1757,8 @@
|
| node->allocated_object_var(),
|
| allocate);
|
| Value* allocated_value = Bind(store_allocated);
|
| - BuildConstructorCall(node, allocated_value);
|
| + PushArgumentInstr* push_allocated_value = PushArgument(allocated_value);
|
| + BuildConstructorCall(node, push_allocated_value);
|
| Computation* load_allocated = BuildLoadLocal(
|
| node->allocated_object_var());
|
| allocated_value = Bind(load_allocated);
|
| @@ -1820,12 +1829,13 @@
|
| const Function& getter_function =
|
| Function::ZoneHandle(node->cls().LookupStaticFunction(getter_name));
|
| ASSERT(!getter_function.IsNull());
|
| - ZoneGrowableArray<Value*>* values = new ZoneGrowableArray<Value*>();
|
| + ZoneGrowableArray<PushArgumentInstr*>* arguments =
|
| + new ZoneGrowableArray<PushArgumentInstr*>();
|
| StaticCallComp* call = new StaticCallComp(node->token_pos(),
|
| owner()->try_index(),
|
| getter_function,
|
| Array::ZoneHandle(), // No names.
|
| - values);
|
| + arguments);
|
| ReturnComputation(call);
|
| }
|
|
|
|
|