| Index: runtime/vm/kernel_to_il.cc
|
| diff --git a/runtime/vm/kernel_to_il.cc b/runtime/vm/kernel_to_il.cc
|
| index c344d6d0b8605e07aad12593718c900f77580b17..9ebcfc1a87cdb923dba3c9319005cbcce3edbd55 100644
|
| --- a/runtime/vm/kernel_to_il.cc
|
| +++ b/runtime/vm/kernel_to_il.cc
|
| @@ -2287,24 +2287,26 @@ Fragment FlowGraphBuilder::IntConstant(int64_t value) {
|
| }
|
|
|
|
|
| -Fragment FlowGraphBuilder::InstanceCall(const dart::String& name,
|
| +Fragment FlowGraphBuilder::InstanceCall(TokenPosition position,
|
| + const dart::String& name,
|
| Token::Kind kind,
|
| intptr_t argument_count,
|
| intptr_t num_args_checked) {
|
| - return InstanceCall(name, kind, argument_count, Array::null_array(),
|
| + return InstanceCall(position, name, kind, argument_count, Array::null_array(),
|
| num_args_checked);
|
| }
|
|
|
|
|
| -Fragment FlowGraphBuilder::InstanceCall(const dart::String& name,
|
| +Fragment FlowGraphBuilder::InstanceCall(TokenPosition position,
|
| + const dart::String& name,
|
| Token::Kind kind,
|
| intptr_t argument_count,
|
| const Array& argument_names,
|
| intptr_t num_args_checked) {
|
| ArgumentArray arguments = GetArguments(argument_count);
|
| - InstanceCallInstr* call = new (Z)
|
| - InstanceCallInstr(TokenPosition::kNoSource, name, kind, arguments,
|
| - argument_names, num_args_checked, ic_data_array_);
|
| + InstanceCallInstr* call =
|
| + new (Z) InstanceCallInstr(position, name, kind, arguments, argument_names,
|
| + num_args_checked, ic_data_array_);
|
| Push(call);
|
| return Fragment(call);
|
| }
|
| @@ -2321,11 +2323,10 @@ Fragment FlowGraphBuilder::ClosureCall(int argument_count,
|
| }
|
|
|
|
|
| -Fragment FlowGraphBuilder::ThrowException() {
|
| +Fragment FlowGraphBuilder::ThrowException(TokenPosition position) {
|
| Fragment instructions;
|
| instructions += Drop();
|
| - instructions +=
|
| - Fragment(new (Z) ThrowInstr(TokenPosition::kNoSource)).closed();
|
| + instructions += Fragment(new (Z) ThrowInstr(position)).closed();
|
| // Use it's side effect of leaving a constant on the stack (does not change
|
| // the graph).
|
| NullConstant();
|
| @@ -2471,9 +2472,10 @@ Fragment FlowGraphBuilder::Return() {
|
| }
|
|
|
|
|
| -Fragment FlowGraphBuilder::StaticCall(const Function& target,
|
| +Fragment FlowGraphBuilder::StaticCall(TokenPosition position,
|
| + const Function& target,
|
| intptr_t argument_count) {
|
| - return StaticCall(target, argument_count, Array::null_array());
|
| + return StaticCall(position, target, argument_count, Array::null_array());
|
| }
|
|
|
|
|
| @@ -2499,13 +2501,13 @@ static intptr_t GetResultCidOfListFactory(Zone* zone,
|
| }
|
|
|
|
|
| -Fragment FlowGraphBuilder::StaticCall(const Function& target,
|
| +Fragment FlowGraphBuilder::StaticCall(TokenPosition position,
|
| + const Function& target,
|
| intptr_t argument_count,
|
| const Array& argument_names) {
|
| ArgumentArray arguments = GetArguments(argument_count);
|
| - StaticCallInstr* call =
|
| - new (Z) StaticCallInstr(TokenPosition::kNoSource, target, argument_names,
|
| - arguments, ic_data_array_);
|
| + StaticCallInstr* call = new (Z) StaticCallInstr(
|
| + position, target, argument_names, arguments, ic_data_array_);
|
| const intptr_t list_cid =
|
| GetResultCidOfListFactory(Z, target, argument_count);
|
| if (list_cid != kDynamicCid) {
|
| @@ -2645,12 +2647,12 @@ Fragment FlowGraphBuilder::ThrowTypeError() {
|
| instructions += Constant(H.DartSymbol("Malformed type."));
|
| instructions += PushArgument(); // message
|
|
|
| - instructions += StaticCall(constructor, 5);
|
| + instructions += StaticCall(TokenPosition::kNoSource, constructor, 5);
|
| instructions += Drop();
|
|
|
| // Throw the exception
|
| instructions += PushArgument();
|
| - instructions += ThrowException();
|
| + instructions += ThrowException(TokenPosition::kNoSource);
|
|
|
| return instructions;
|
| }
|
| @@ -2685,7 +2687,7 @@ Fragment FlowGraphBuilder::ThrowNoSuchMethodError() {
|
| instructions += NullConstant();
|
| instructions += PushArgument(); // existingArgumentNames
|
|
|
| - instructions += StaticCall(throw_function, 6);
|
| + instructions += StaticCall(TokenPosition::kNoSource, throw_function, 6);
|
| // Leave "result" on the stack since callers expect it to be there (even
|
| // though the function will result in an exception).
|
|
|
| @@ -3447,7 +3449,8 @@ FlowGraph* FlowGraphBuilder::BuildGraphOfImplicitClosureFunction(
|
| // Forward them to the target.
|
| intptr_t argument_count = positional_argument_count + named_argument_count;
|
| if (!target.is_static()) ++argument_count;
|
| - body += StaticCall(target, argument_count, argument_names);
|
| + body += StaticCall(TokenPosition::kNoSource, target, argument_count,
|
| + argument_names);
|
|
|
| // Return the result.
|
| body += Return();
|
| @@ -3534,7 +3537,7 @@ FlowGraph* FlowGraphBuilder::BuildGraphOfNoSuchMethodDispatcher(
|
| Z, mirror_class.LookupStaticFunction(dart::Library::PrivateCoreLibName(
|
| Symbols::AllocateInvocationMirror())));
|
| ASSERT(!allocation_function.IsNull());
|
| - body += StaticCall(allocation_function, 4);
|
| + body += StaticCall(TokenPosition::kMinSource, allocation_function, 4);
|
| body += PushArgument(); // For the call to noSuchMethod.
|
|
|
| ArgumentsDescriptor two_arguments(
|
| @@ -3550,7 +3553,7 @@ FlowGraph* FlowGraphBuilder::BuildGraphOfNoSuchMethodDispatcher(
|
| dart::Class::Handle(Z, I->object_store()->object_class()),
|
| Symbols::NoSuchMethod(), two_arguments);
|
| }
|
| - body += StaticCall(no_such_method, 2);
|
| + body += StaticCall(TokenPosition::kMinSource, no_such_method, 2);
|
| body += Return();
|
|
|
| return new (Z) FlowGraph(*parsed_function_, graph_entry_, next_block_id_ - 1);
|
| @@ -3614,7 +3617,8 @@ FlowGraph* FlowGraphBuilder::BuildGraphOfInvokeFieldDispatcher(
|
| // Invoke the getter to get the field value.
|
| body += LoadLocal(scope->VariableAt(0));
|
| body += PushArgument();
|
| - body += InstanceCall(getter_name, Token::kGET, 1);
|
| + body +=
|
| + InstanceCall(TokenPosition::kMinSource, getter_name, Token::kGET, 1);
|
| }
|
|
|
| body += PushArgument();
|
| @@ -3633,8 +3637,8 @@ FlowGraph* FlowGraphBuilder::BuildGraphOfInvokeFieldDispatcher(
|
|
|
| body += ClosureCall(descriptor.Count(), argument_names);
|
| } else {
|
| - body += InstanceCall(Symbols::Call(), Token::kILLEGAL, descriptor.Count(),
|
| - argument_names);
|
| + body += InstanceCall(TokenPosition::kMinSource, Symbols::Call(),
|
| + Token::kILLEGAL, descriptor.Count(), argument_names);
|
| }
|
|
|
| body += Return();
|
| @@ -3747,7 +3751,8 @@ Fragment FlowGraphBuilder::TranslateInitializers(
|
| const Function& target = Function::ZoneHandle(
|
| Z, H.LookupConstructorByKernelConstructor(init->target()));
|
| intptr_t argument_count = init->arguments()->count() + 1;
|
| - instructions += StaticCall(target, argument_count, argument_names);
|
| + instructions += StaticCall(TokenPosition::kNoSource, target,
|
| + argument_count, argument_names);
|
| instructions += Drop();
|
| } else if (initializer->IsRedirectingInitializer()) {
|
| RedirectingInitializer* init = RedirectingInitializer::Cast(initializer);
|
| @@ -3762,7 +3767,8 @@ Fragment FlowGraphBuilder::TranslateInitializers(
|
| const Function& target = Function::ZoneHandle(
|
| Z, H.LookupConstructorByKernelConstructor(init->target()));
|
| intptr_t argument_count = init->arguments()->count() + 1;
|
| - instructions += StaticCall(target, argument_count, argument_names);
|
| + instructions += StaticCall(TokenPosition::kNoSource, target,
|
| + argument_count, argument_names);
|
| instructions += Drop();
|
| } else if (initializer->IsLocalInitializer()) {
|
| // The other initializers following this one might read the variable. This
|
| @@ -4189,7 +4195,7 @@ void FlowGraphBuilder::VisitStaticGet(StaticGet* node) {
|
| Fragment instructions = Constant(field);
|
| fragment_ = instructions + LoadStaticField();
|
| } else {
|
| - fragment_ = StaticCall(getter, 0);
|
| + fragment_ = StaticCall(node->position(), getter, 0);
|
| }
|
| }
|
| } else {
|
| @@ -4198,7 +4204,7 @@ void FlowGraphBuilder::VisitStaticGet(StaticGet* node) {
|
| Z, H.LookupStaticMethodByKernelProcedure(procedure));
|
|
|
| if (procedure->kind() == Procedure::kGetter) {
|
| - fragment_ = StaticCall(target, 0);
|
| + fragment_ = StaticCall(node->position(), target, 0);
|
| } else if (procedure->kind() == Procedure::kMethod) {
|
| ASSERT(procedure->IsStatic());
|
| Function& closure_function =
|
| @@ -4239,7 +4245,7 @@ void FlowGraphBuilder::VisitStaticSet(StaticSet* node) {
|
| Procedure* procedure = Procedure::Cast(target);
|
| const Function& target = Function::ZoneHandle(
|
| Z, H.LookupStaticMethodByKernelProcedure(procedure));
|
| - instructions += StaticCall(target, 1);
|
| + instructions += StaticCall(node->position(), target, 1);
|
|
|
| // Drop the unused result & leave the stored value on the stack.
|
| fragment_ = instructions + Drop();
|
| @@ -4251,7 +4257,8 @@ void FlowGraphBuilder::VisitPropertyGet(PropertyGet* node) {
|
| Fragment instructions = TranslateExpression(node->receiver());
|
| instructions += PushArgument();
|
| const dart::String& getter_name = H.DartGetterName(node->name());
|
| - fragment_ = instructions + InstanceCall(getter_name, Token::kGET, 1);
|
| + fragment_ = instructions +
|
| + InstanceCall(node->position(), getter_name, Token::kGET, 1);
|
| }
|
|
|
|
|
| @@ -4265,7 +4272,7 @@ void FlowGraphBuilder::VisitPropertySet(PropertySet* node) {
|
| instructions += PushArgument();
|
|
|
| const dart::String& setter_name = H.DartSetterName(node->name());
|
| - instructions += InstanceCall(setter_name, Token::kSET, 2);
|
| + instructions += InstanceCall(node->position(), setter_name, Token::kSET, 2);
|
| fragment_ = instructions + Drop();
|
| }
|
|
|
| @@ -4295,7 +4302,7 @@ void FlowGraphBuilder::VisitDirectPropertyGet(DirectPropertyGet* node) {
|
|
|
| Fragment instructions = TranslateExpression(node->receiver());
|
| instructions += PushArgument();
|
| - fragment_ = instructions + StaticCall(target, 1);
|
| + fragment_ = instructions + StaticCall(node->position(), target, 1);
|
| }
|
|
|
|
|
| @@ -4312,7 +4319,7 @@ void FlowGraphBuilder::VisitDirectPropertySet(DirectPropertySet* node) {
|
| instructions += TranslateExpression(node->value());
|
| instructions += StoreLocal(value);
|
| instructions += PushArgument();
|
| - instructions += StaticCall(target, 2);
|
| + instructions += StaticCall(node->position(), target, 2);
|
|
|
| fragment_ = instructions + Drop();
|
| }
|
| @@ -4397,7 +4404,8 @@ void FlowGraphBuilder::VisitStaticInvocation(StaticInvocation* node) {
|
| instructions += StrictCompare(Token::kEQ_STRICT, /*number_check=*/true);
|
| } else {
|
| instructions += TranslateArguments(node->arguments(), NULL);
|
| - instructions += StaticCall(target, argument_count, argument_names);
|
| + instructions +=
|
| + StaticCall(node->position(), target, argument_count, argument_names);
|
|
|
| if (target.IsGenerativeConstructor()) {
|
| // Drop the result of the constructor call and leave [instance_variable]
|
| @@ -4454,8 +4462,9 @@ void FlowGraphBuilder::VisitMethodInvocation(MethodInvocation* node) {
|
| num_args_checked = argument_count;
|
| }
|
|
|
| - fragment_ = instructions + InstanceCall(name, token_kind, argument_count,
|
| - argument_names, num_args_checked);
|
| + fragment_ = instructions + InstanceCall(node->position(), name, token_kind,
|
| + argument_count, argument_names,
|
| + num_args_checked);
|
| }
|
|
|
|
|
| @@ -4472,7 +4481,8 @@ void FlowGraphBuilder::VisitDirectMethodInvocation(
|
| Fragment instructions = TranslateExpression(node->receiver());
|
| instructions += PushArgument();
|
| instructions += TranslateArguments(node->arguments(), &argument_names);
|
| - fragment_ = instructions + StaticCall(target, argument_count, argument_names);
|
| + fragment_ = instructions + StaticCall(node->position(), target,
|
| + argument_count, argument_names);
|
| }
|
|
|
|
|
| @@ -4532,7 +4542,8 @@ void FlowGraphBuilder::VisitConstructorInvocation(ConstructorInvocation* node) {
|
| const Function& target = Function::ZoneHandle(
|
| Z, H.LookupConstructorByKernelConstructor(klass, node->target()));
|
| intptr_t argument_count = node->arguments()->count() + 1;
|
| - instructions += StaticCall(target, argument_count, argument_names);
|
| + instructions +=
|
| + StaticCall(node->position(), target, argument_count, argument_names);
|
| fragment_ = instructions + Drop();
|
| }
|
|
|
| @@ -4575,7 +4586,8 @@ void FlowGraphBuilder::VisitIsExpression(IsExpression* node) {
|
| instructions += PushArgument(); // Negate?.
|
|
|
| instructions +=
|
| - InstanceCall(dart::Library::PrivateCoreLibName(Symbols::_instanceOf()),
|
| + InstanceCall(TokenPosition::kNoSource,
|
| + dart::Library::PrivateCoreLibName(Symbols::_instanceOf()),
|
| Token::kIS, 4);
|
| }
|
|
|
| @@ -4615,6 +4627,7 @@ void FlowGraphBuilder::VisitAsExpression(AsExpression* node) {
|
| instructions += PushArgument(); // Type.
|
|
|
| instructions += InstanceCall(
|
| + TokenPosition::kNoSource,
|
| dart::Library::PrivateCoreLibName(Symbols::_as()), Token::kAS, 3);
|
| }
|
|
|
| @@ -4761,7 +4774,7 @@ void FlowGraphBuilder::VisitListLiteral(ListLiteral* node) {
|
| const Function& factory_method = Function::ZoneHandle(
|
| Z, factory_class.LookupFactory(
|
| dart::Library::PrivateCoreLibName(Symbols::ListLiteralFactory())));
|
| - fragment_ = instructions + StaticCall(factory_method, 2);
|
| + fragment_ = instructions + StaticCall(node->position(), factory_method, 2);
|
| }
|
|
|
|
|
| @@ -4812,7 +4825,7 @@ void FlowGraphBuilder::VisitMapLiteral(MapLiteral* node) {
|
| }
|
| instructions += PushArgument(); // The array.
|
|
|
| - fragment_ = instructions + StaticCall(factory_method, 2);
|
| + fragment_ = instructions + StaticCall(node->position(), factory_method, 2);
|
| }
|
|
|
|
|
| @@ -4833,7 +4846,7 @@ void FlowGraphBuilder::VisitThrow(Throw* node) {
|
|
|
| instructions += TranslateExpression(node->expression());
|
| instructions += PushArgument();
|
| - instructions += ThrowException();
|
| + instructions += ThrowException(node->position());
|
| ASSERT(instructions.is_closed());
|
|
|
| fragment_ = instructions;
|
| @@ -5117,7 +5130,8 @@ void FlowGraphBuilder::VisitForInStatement(ForInStatement* node) {
|
|
|
| const dart::String& iterator_getter = dart::String::ZoneHandle(
|
| Z, dart::Field::GetterSymbol(Symbols::Iterator()));
|
| - instructions += InstanceCall(iterator_getter, Token::kGET, 1);
|
| + instructions +=
|
| + InstanceCall(TokenPosition::kNoSource, iterator_getter, Token::kGET, 1);
|
| LocalVariable* iterator = scopes_->iterator_variables[for_in_depth_];
|
| instructions += StoreLocal(iterator);
|
| instructions += Drop();
|
| @@ -5126,7 +5140,8 @@ void FlowGraphBuilder::VisitForInStatement(ForInStatement* node) {
|
| ++loop_depth_;
|
| Fragment condition = LoadLocal(iterator);
|
| condition += PushArgument();
|
| - condition += InstanceCall(Symbols::MoveNext(), Token::kILLEGAL, 1);
|
| + condition += InstanceCall(TokenPosition::kNoSource, Symbols::MoveNext(),
|
| + Token::kILLEGAL, 1);
|
| TargetEntryInstr* body_entry;
|
| TargetEntryInstr* loop_exit;
|
| condition += BranchIfTrue(&body_entry, &loop_exit);
|
| @@ -5137,7 +5152,8 @@ void FlowGraphBuilder::VisitForInStatement(ForInStatement* node) {
|
| body += PushArgument();
|
| const dart::String& current_getter = dart::String::ZoneHandle(
|
| Z, dart::Field::GetterSymbol(Symbols::Current()));
|
| - body += InstanceCall(current_getter, Token::kGET, 1);
|
| + body +=
|
| + InstanceCall(TokenPosition::kNoSource, current_getter, Token::kGET, 1);
|
| body += StoreLocal(LookupVariable(node->variable()));
|
| body += Drop();
|
| body += TranslateStatement(node->body());
|
| @@ -5258,12 +5274,12 @@ void FlowGraphBuilder::VisitSwitchStatement(SwitchStatement* node) {
|
| body_fragment += NullConstant();
|
| body_fragment += PushArgument(); // line
|
|
|
| - body_fragment += StaticCall(constructor, 3);
|
| + body_fragment += StaticCall(TokenPosition::kNoSource, constructor, 3);
|
| body_fragment += Drop();
|
|
|
| // Throw the exception
|
| body_fragment += PushArgument();
|
| - body_fragment += ThrowException();
|
| + body_fragment += ThrowException(TokenPosition::kNoSource);
|
| body_fragment += Drop();
|
| }
|
|
|
| @@ -5327,10 +5343,10 @@ void FlowGraphBuilder::VisitSwitchStatement(SwitchStatement* node) {
|
| current_instructions += PushArgument();
|
| current_instructions += LoadLocal(scopes_->switch_variable);
|
| current_instructions += PushArgument();
|
| - current_instructions +=
|
| - InstanceCall(Symbols::EqualOperator(), Token::kEQ,
|
| - /*argument_count=*/2,
|
| - /*num_args_checked=*/2);
|
| + current_instructions += InstanceCall(
|
| + TokenPosition::kNoSource, Symbols::EqualOperator(), Token::kEQ,
|
| + /*argument_count=*/2,
|
| + /*num_args_checked=*/2);
|
| current_instructions += BranchIfTrue(&then, &otherwise);
|
|
|
| Fragment then_fragment(then);
|
| @@ -5450,12 +5466,12 @@ void FlowGraphBuilder::VisitAssertStatement(AssertStatement* node) {
|
| otherwise_fragment += IntConstant(0);
|
| otherwise_fragment += PushArgument(); // column
|
|
|
| - otherwise_fragment += StaticCall(constructor, 5);
|
| + otherwise_fragment += StaticCall(TokenPosition::kNoSource, constructor, 5);
|
| otherwise_fragment += Drop();
|
|
|
| // Throw _AssertionError exception.
|
| otherwise_fragment += PushArgument();
|
| - otherwise_fragment += ThrowException();
|
| + otherwise_fragment += ThrowException(TokenPosition::kNoSource);
|
| otherwise_fragment += Drop();
|
|
|
| fragment_ = Fragment(instructions.entry, then);
|
| @@ -5610,6 +5626,7 @@ void FlowGraphBuilder::VisitTryCatch(class TryCatch* node) {
|
| catch_body += Constant(Object::bool_false());
|
| catch_body += PushArgument(); // negate
|
| catch_body += InstanceCall(
|
| + TokenPosition::kNoSource,
|
| dart::Library::PrivateCoreLibName(Symbols::_instanceOf()),
|
| Token::kIS, 4);
|
|
|
| @@ -5727,6 +5744,7 @@ Fragment FlowGraphBuilder::TranslateFunctionNode(FunctionNode* node,
|
| for (intptr_t i = 0; i < scopes_->function_scopes.length(); ++i) {
|
| if (scopes_->function_scopes[i].function != node) continue;
|
|
|
| + // NOTE: This is not TokenPosition in the general sense!
|
| function = I->LookupClosureFunction(parsed_function_->function(),
|
| TokenPosition(i));
|
| if (function.IsNull()) {
|
| @@ -5738,6 +5756,7 @@ Fragment FlowGraphBuilder::TranslateFunctionNode(FunctionNode* node,
|
| name = &H.DartSymbol(
|
| FunctionDeclaration::Cast(parent)->variable()->name());
|
| }
|
| + // NOTE: This is not TokenPosition in the general sense!
|
| function = Function::NewClosureFunction(
|
| *name, parsed_function_->function(), TokenPosition(i));
|
| function.set_is_debuggable(false);
|
|
|