| Index: runtime/vm/flow_graph_builder.cc
|
| ===================================================================
|
| --- runtime/vm/flow_graph_builder.cc (revision 5536)
|
| +++ runtime/vm/flow_graph_builder.cc (working copy)
|
| @@ -435,7 +435,7 @@
|
|
|
|
|
| int EffectGraphVisitor::BuildIncrOpFieldLoad(IncrOpInstanceFieldNode* node,
|
| - int start_index) {
|
| + intptr_t start_index) {
|
| // Evaluate the receiver and duplicate it (it has two uses).
|
| // t_n <- ... receiver ...
|
| // t_n+1 <- Pick(t_n)
|
| @@ -464,7 +464,7 @@
|
| void EffectGraphVisitor::BuildIncrOpIncrement(Token::Kind kind,
|
| intptr_t node_id,
|
| intptr_t token_index,
|
| - int start_index) {
|
| + intptr_t start_index) {
|
| ASSERT((kind == Token::kINCR) || (kind == Token::kDECR));
|
| // Assumed that t_n-1 (where n is start_index) is the field value.
|
| // t_n <- #1
|
| @@ -540,7 +540,7 @@
|
|
|
|
|
| int EffectGraphVisitor::BuildIncrOpIndexedLoad(IncrOpIndexedNode* node,
|
| - int start_index) {
|
| + intptr_t start_index) {
|
| // Evaluate the receiver and index.
|
| // t_n <- ... receiver ...
|
| // t_n+1 <- ... index ...
|
| @@ -918,7 +918,7 @@
|
| if (node->constructor().IsFactory()) {
|
| ZoneGrowableArray<Value*>* factory_arguments =
|
| new ZoneGrowableArray<Value*>();
|
| - BuildTypeArguments(node, factory_arguments);
|
| + factory_arguments->Add(BuildFactoryTypeArguments(node, temp_index()));
|
| ASSERT(factory_arguments->length() == 1);
|
| TranslateArgumentList(*node->arguments(),
|
| temp_index() + 1,
|
| @@ -935,8 +935,8 @@
|
| }
|
|
|
|
|
| -Value* EffectGraphVisitor::GenerateInstantiatorTypeArguments(
|
| - intptr_t token_index, intptr_t value_index) {
|
| +Value* EffectGraphVisitor::BuildInstantiatorTypeArguments(
|
| + intptr_t token_index, intptr_t start_index) {
|
| const Class& instantiator_class = Class::Handle(
|
| owner()->parsed_function().function().owner());
|
| if (instantiator_class.NumTypeParameters() == 0) {
|
| @@ -948,11 +948,11 @@
|
| type ^= ClassFinalizer::FinalizeType(
|
| instantiator_class, type, ClassFinalizer::kFinalizeWellFormed);
|
| type_arguments = type.arguments();
|
| - AddInstruction(new BindInstr(value_index, new ConstantVal(type_arguments)));
|
| - return new TempVal(value_index);
|
| + AddInstruction(new BindInstr(start_index, new ConstantVal(type_arguments)));
|
| + return new TempVal(start_index);
|
| }
|
| ASSERT(owner()->parsed_function().instantiator() != NULL);
|
| - ValueGraphVisitor for_instantiator(owner(), value_index);
|
| + ValueGraphVisitor for_instantiator(owner(), start_index);
|
| owner()->parsed_function().instantiator()->Visit(&for_instantiator);
|
| Append(for_instantiator);
|
| Function& outer_function =
|
| @@ -975,46 +975,69 @@
|
|
|
| NativeLoadFieldComp* load = new NativeLoadFieldComp(
|
| for_instantiator.value(), type_arguments_instance_field_offset);
|
| - AddInstruction(new BindInstr(value_index, load));
|
| - return new TempVal(value_index);
|
| + AddInstruction(new BindInstr(start_index, load));
|
| + return new TempVal(start_index);
|
| }
|
|
|
|
|
| +Value* EffectGraphVisitor::BuildFactoryTypeArguments(
|
| + ConstructorCallNode* node, intptr_t start_index) {
|
| + ASSERT(node->constructor().IsFactory());
|
| + if (node->type_arguments().IsNull() ||
|
| + node->type_arguments().IsInstantiated()) {
|
| + AddInstruction(
|
| + new BindInstr(start_index, new ConstantVal(node->type_arguments())));
|
| + return new TempVal(start_index);
|
| + }
|
| + // The type arguments are uninstantiated.
|
| + Value* instantiator_value =
|
| + BuildInstantiatorTypeArguments(node->token_index(), start_index);
|
| + ExtractFactoryTypeArgumentsComp* extract =
|
| + new ExtractFactoryTypeArgumentsComp(node, instantiator_value);
|
| + AddInstruction(new BindInstr(start_index, extract));
|
| + return new TempVal(start_index);
|
| +}
|
|
|
| -void EffectGraphVisitor::BuildTypeArguments(ConstructorCallNode* node,
|
| - ZoneGrowableArray<Value*>* args) {
|
| +
|
| +void EffectGraphVisitor::BuildConstructorTypeArguments(
|
| + ConstructorCallNode* node,
|
| + intptr_t start_index,
|
| + ZoneGrowableArray<Value*>* args) {
|
| const Class& cls = Class::ZoneHandle(node->constructor().owner());
|
| - ASSERT(cls.HasTypeArguments() || node->constructor().IsFactory());
|
| + ASSERT(cls.HasTypeArguments() && !node->constructor().IsFactory());
|
| if (node->type_arguments().IsNull() ||
|
| node->type_arguments().IsInstantiated()) {
|
| AddInstruction(
|
| - new BindInstr(temp_index(), new ConstantVal(node->type_arguments())));
|
| - args->Add(new TempVal(temp_index()));
|
| - if (!node->constructor().IsFactory()) {
|
| - // Null instantiator.
|
| - AddInstruction(new BindInstr(
|
| - temp_index() + 1, new ConstantVal(Object::ZoneHandle())));
|
| - args->Add(new TempVal(temp_index() + 1));
|
| - }
|
| + new BindInstr(start_index, new ConstantVal(node->type_arguments())));
|
| + args->Add(new TempVal(start_index));
|
| + // Null instantiator.
|
| + AddInstruction(new BindInstr(
|
| + start_index + 1, new ConstantVal(Object::ZoneHandle())));
|
| + args->Add(new TempVal(start_index + 1));
|
| return;
|
| }
|
| - if (!node->constructor().IsFactory()) {
|
| - // Place holder instruction as ExtractTypeArgumentsComp returns two values.
|
| - AddInstruction(new BindInstr(temp_index(),
|
| - new ConstantVal(Object::ZoneHandle())));
|
| - }
|
| // The type arguments are uninstantiated.
|
| + // Place holder to hold uninstantiated constructor type arguments.
|
| + AddInstruction(new BindInstr(start_index,
|
| + new ConstantVal(Object::ZoneHandle())));
|
| Value* instantiator_value =
|
| - GenerateInstantiatorTypeArguments(node->token_index(), temp_index() + 1);
|
| - ExtractTypeArgumentsComp* extract = new ExtractTypeArgumentsComp(
|
| - node, instantiator_value);
|
| - AddInstruction(new BindInstr(temp_index() + 1, extract));
|
| - if (node->constructor().IsFactory()) {
|
| - args->Add(new TempVal(temp_index()));
|
| - } else {
|
| - args->Add(new TempVal(temp_index()));
|
| - args->Add(new TempVal(temp_index() + 1));
|
| - }
|
| + BuildInstantiatorTypeArguments(node->token_index(), start_index + 1);
|
| + AddInstruction(new PickTempInstr(start_index + 2, start_index + 1));
|
| + Value* dup_instantiator_value = new TempVal(start_index + 2);
|
| + ExtractConstructorTypeArgumentsComp* extract_type_arguments =
|
| + new ExtractConstructorTypeArgumentsComp(node, dup_instantiator_value);
|
| + AddInstruction(new BindInstr(start_index + 2, extract_type_arguments));
|
| + AddInstruction(new TuckTempInstr(start_index, start_index + 2));
|
| + Value* constructor_type_arguments_value = new TempVal(start_index);
|
| + args->Add(constructor_type_arguments_value);
|
| + Value* discard_value = new TempVal(start_index + 2);
|
| + ExtractConstructorInstantiatorComp* extract_instantiator =
|
| + new ExtractConstructorInstantiatorComp(node,
|
| + instantiator_value,
|
| + discard_value);
|
| + AddInstruction(new BindInstr(start_index + 1, extract_instantiator));
|
| + Value* constructor_instantiator_value = new TempVal(start_index + 1);
|
| + args->Add(constructor_instantiator_value);
|
| }
|
|
|
|
|
| @@ -1030,7 +1053,7 @@
|
| ZoneGrowableArray<Value*>* allocate_arguments =
|
| new ZoneGrowableArray<Value*>();
|
| if (requires_type_arguments) {
|
| - BuildTypeArguments(node, allocate_arguments);
|
| + BuildConstructorTypeArguments(node, temp_index(), allocate_arguments);
|
| }
|
| // t_n contains the allocated and initialized object.
|
| // t_n <- AllocateObject(class)
|
| @@ -1553,14 +1576,32 @@
|
| }
|
|
|
|
|
| -void FlowGraphPrinter::VisitExtractTypeArguments(
|
| - ExtractTypeArgumentsComp* comp) {
|
| - OS::Print("ExtractTypeArguments(");
|
| +void FlowGraphPrinter::VisitExtractFactoryTypeArguments(
|
| + ExtractFactoryTypeArgumentsComp* comp) {
|
| + OS::Print("ExtractFactoryTypeArguments(");
|
| comp->instantiator()->Accept(this);
|
| OS::Print(")");
|
| }
|
|
|
|
|
| +void FlowGraphPrinter::VisitExtractConstructorTypeArguments(
|
| + ExtractConstructorTypeArgumentsComp* comp) {
|
| + OS::Print("ExtractConstructorTypeArguments(");
|
| + comp->instantiator()->Accept(this);
|
| + OS::Print(")");
|
| +}
|
| +
|
| +
|
| +void FlowGraphPrinter::VisitExtractConstructorInstantiator(
|
| + ExtractConstructorInstantiatorComp* comp) {
|
| + OS::Print("ExtractConstructorInstantiator(");
|
| + comp->instantiator()->Accept(this);
|
| + OS::Print(", ");
|
| + comp->discard_value()->Accept(this);
|
| + OS::Print(")");
|
| +}
|
| +
|
| +
|
| void FlowGraphPrinter::VisitJoinEntry(JoinEntryInstr* instr) {
|
| OS::Print("%2d: [join]", instr->block_number());
|
| }
|
|
|