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

Side by Side Diff: runtime/vm/kernel_binary_flowgraph.cc

Issue 2891053003: Add support for converted closures with explicit contexts to VM (Closed)
Patch Set: Temporarily disable Run step in closures test suite Created 3 years, 5 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 unified diff | Download patch
« no previous file with comments | « runtime/vm/kernel_binary_flowgraph.h ('k') | runtime/vm/kernel_to_il.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/kernel_binary_flowgraph.h" 5 #include "vm/kernel_binary_flowgraph.h"
6 6
7 #include "vm/compiler.h" 7 #include "vm/compiler.h"
8 #include "vm/longjump.h" 8 #include "vm/longjump.h"
9 #include "vm/object_store.h" 9 #include "vm/object_store.h"
10 10
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 parsed_function->SetNodeSequence( 124 parsed_function->SetNodeSequence(
125 new SequenceNode(TokenPosition::kNoSource, scope_)); 125 new SequenceNode(TokenPosition::kNoSource, scope_));
126 126
127 intptr_t parent_offset = -1; 127 intptr_t parent_offset = -1;
128 builder_->SetOffset(kernel_offset_); 128 builder_->SetOffset(kernel_offset_);
129 129
130 FunctionNodeHelper function_node_helper(builder_); 130 FunctionNodeHelper function_node_helper(builder_);
131 131
132 switch (function.kind()) { 132 switch (function.kind()) {
133 case RawFunction::kClosureFunction: 133 case RawFunction::kClosureFunction:
134 case RawFunction::kConvertedClosureFunction:
134 case RawFunction::kRegularFunction: 135 case RawFunction::kRegularFunction:
135 case RawFunction::kGetterFunction: 136 case RawFunction::kGetterFunction:
136 case RawFunction::kSetterFunction: 137 case RawFunction::kSetterFunction:
137 case RawFunction::kConstructor: { 138 case RawFunction::kConstructor: {
138 const Tag tag = builder_->PeekTag(); 139 const Tag tag = builder_->PeekTag();
139 parent_offset = builder_->ReadUntilFunctionNode(); 140 parent_offset = builder_->ReadUntilFunctionNode();
140 function_node_helper.ReadUntilExcluding( 141 function_node_helper.ReadUntilExcluding(
141 FunctionNodeHelper::kPositionalParameters); 142 FunctionNodeHelper::kPositionalParameters);
142 current_function_async_marker_ = function_node_helper.async_marker_; 143 current_function_async_marker_ = function_node_helper.async_marker_;
143 // NOTE: FunctionNode is read further below the if. 144 // NOTE: FunctionNode is read further below the if.
(...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after
668 return; 669 return;
669 case kDoubleLiteral: 670 case kDoubleLiteral:
670 builder_->SkipStringReference(); // read index into string table. 671 builder_->SkipStringReference(); // read index into string table.
671 return; 672 return;
672 case kTrueLiteral: 673 case kTrueLiteral:
673 return; 674 return;
674 case kFalseLiteral: 675 case kFalseLiteral:
675 return; 676 return;
676 case kNullLiteral: 677 case kNullLiteral:
677 return; 678 return;
679 case kVectorCreation:
680 builder_->ReadUInt(); // read size.
681 return;
682 case kVectorGet:
683 VisitExpression(); // read expression.
684 builder_->ReadUInt(); // read index.
685 return;
686 case kVectorSet:
687 VisitExpression(); // read vector expression.
688 builder_->ReadUInt(); // read index.
689 VisitExpression(); // read value.
690 return;
691 case kVectorCopy:
692 VisitExpression(); // read vector expression.
693 return;
694 case kClosureCreation:
695 builder_->SkipCanonicalNameReference(); // read function reference.
696 VisitExpression(); // read context vector.
697 VisitDartType(); // read function type of the closure.
698 return;
678 default: 699 default:
679 UNREACHABLE(); 700 UNREACHABLE();
680 } 701 }
681 } 702 }
682 703
683 void StreamingScopeBuilder::VisitStatement() { 704 void StreamingScopeBuilder::VisitStatement() {
684 Tag tag = builder_->ReadTag(); // read tag. 705 Tag tag = builder_->ReadTag(); // read tag.
685 switch (tag) { 706 switch (tag) {
686 case kInvalidStatement: 707 case kInvalidStatement:
687 return; 708 return;
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
1004 result_->locals.Insert(kernel_offset_no_tag, variable); 1025 result_->locals.Insert(kernel_offset_no_tag, variable);
1005 } 1026 }
1006 1027
1007 void StreamingScopeBuilder::VisitDartType() { 1028 void StreamingScopeBuilder::VisitDartType() {
1008 Tag tag = builder_->ReadTag(); 1029 Tag tag = builder_->ReadTag();
1009 switch (tag) { 1030 switch (tag) {
1010 case kInvalidType: 1031 case kInvalidType:
1011 case kDynamicType: 1032 case kDynamicType:
1012 case kVoidType: 1033 case kVoidType:
1013 case kBottomType: 1034 case kBottomType:
1035 case kVectorType:
1014 // those contain nothing. 1036 // those contain nothing.
1015 return; 1037 return;
1016 case kInterfaceType: 1038 case kInterfaceType:
1017 VisitInterfaceType(false); 1039 VisitInterfaceType(false);
1018 return; 1040 return;
1019 case kSimpleInterfaceType: 1041 case kSimpleInterfaceType:
1020 VisitInterfaceType(true); 1042 VisitInterfaceType(true);
1021 return; 1043 return;
1022 case kFunctionType: 1044 case kFunctionType:
1023 VisitFunctionType(false); 1045 VisitFunctionType(false);
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after
1404 Error::Handle(Z), // No previous error. 1426 Error::Handle(Z), // No previous error.
1405 dart::Script::Handle(Z, dart::Script::null()), 1427 dart::Script::Handle(Z, dart::Script::null()),
1406 TokenPosition::kNoSource, "[InvalidType] in Kernel IR."); 1428 TokenPosition::kNoSource, "[InvalidType] in Kernel IR.");
1407 break; 1429 break;
1408 case kDynamicType: 1430 case kDynamicType:
1409 result_ = Object::dynamic_type().raw(); 1431 result_ = Object::dynamic_type().raw();
1410 break; 1432 break;
1411 case kVoidType: 1433 case kVoidType:
1412 result_ = Object::void_type().raw(); 1434 result_ = Object::void_type().raw();
1413 break; 1435 break;
1436 case kVectorType:
1437 result_ = Object::vector_type().raw();
1438 break;
1414 case kBottomType: 1439 case kBottomType:
1415 result_ = dart::Class::Handle(Z, I->object_store()->null_class()) 1440 result_ = dart::Class::Handle(Z, I->object_store()->null_class())
1416 .CanonicalType(); 1441 .CanonicalType();
1417 break; 1442 break;
1418 case kInterfaceType: 1443 case kInterfaceType:
1419 BuildInterfaceType(false); 1444 BuildInterfaceType(false);
1420 break; 1445 break;
1421 case kSimpleInterfaceType: 1446 case kSimpleInterfaceType:
1422 BuildInterfaceType(true); 1447 BuildInterfaceType(true);
1423 break; 1448 break;
(...skipping 1554 matching lines...) Expand 10 before | Expand all | Expand 10 after
2978 argument_names); 3003 argument_names);
2979 3004
2980 // Return the result. 3005 // Return the result.
2981 body += Return(function_node_helper.end_position_); 3006 body += Return(function_node_helper.end_position_);
2982 3007
2983 return new (Z) 3008 return new (Z)
2984 FlowGraph(*parsed_function(), flow_graph_builder_->graph_entry_, 3009 FlowGraph(*parsed_function(), flow_graph_builder_->graph_entry_,
2985 flow_graph_builder_->next_block_id_ - 1); 3010 flow_graph_builder_->next_block_id_ - 1);
2986 } 3011 }
2987 3012
3013 // This method follows the logic of
3014 // StreamingFlowGraphBuilder::BuildGraphOfImplicitClosureFunction. For
3015 // additional details on converted closure functions, please, see the comment on
3016 // the method Function::ConvertedClosureFunction.
3017 FlowGraph* StreamingFlowGraphBuilder::BuildGraphOfConvertedClosureFunction(
3018 const Function& function) {
3019 const Function& target = Function::ZoneHandle(Z, function.parent_function());
3020
3021 TargetEntryInstr* normal_entry = flow_graph_builder_->BuildTargetEntry();
3022 flow_graph_builder_->graph_entry_ = new (Z) GraphEntryInstr(
3023 *parsed_function(), normal_entry, Compiler::kNoOSRDeoptId);
3024 SetupDefaultParameterValues();
3025
3026 Fragment body(normal_entry);
3027 body += flow_graph_builder_->CheckStackOverflowInPrologue();
3028
3029 // Load all the arguments.
3030 ASSERT(target.is_static());
3031
3032 FunctionNodeHelper function_node_helper(this);
3033 function_node_helper.ReadUntilExcluding(
3034 FunctionNodeHelper::kPositionalParameters);
3035
3036 // Positional.
3037 const intptr_t positional_argument_count = ReadListLength();
3038
3039 // The first argument is the instance of the closure class. For converted
3040 // closures its context field contains the context vector that is used by the
3041 // converted top-level function (target) explicitly and that should be passed
3042 // to that function as the first parameter.
3043 body += LoadLocal(LookupVariable(ReaderOffset())); // 0th variable offset.
3044 body += flow_graph_builder_->LoadField(Closure::context_offset());
3045 body += PushArgument();
3046 SkipVariableDeclaration(); // read 0th variable.
3047
3048 // The rest of the parameters are the same for the method of the Closure class
3049 // being invoked and the top-level function (target).
3050 for (intptr_t i = 1; i < positional_argument_count; i++) {
3051 body += LoadLocal(LookupVariable(ReaderOffset())); // ith variable offset.
3052 body += PushArgument();
3053 SkipVariableDeclaration(); // read ith variable.
3054 }
3055
3056 // Named.
3057 const intptr_t named_argument_count = ReadListLength();
3058 Array& argument_names = Array::ZoneHandle(Z);
3059 if (named_argument_count > 0) {
3060 argument_names = Array::New(named_argument_count);
3061 for (intptr_t i = 0; i < named_argument_count; i++) {
3062 body +=
3063 LoadLocal(LookupVariable(ReaderOffset())); // ith variable offset.
3064 body += PushArgument();
3065 argument_names.SetAt(
3066 i, H.DartSymbol(GetNameFromVariableDeclaration(ReaderOffset())));
3067 SkipVariableDeclaration(); // read ith variable.
3068 }
3069 }
3070
3071 // Forward them to the target.
3072 const intptr_t argument_count =
3073 positional_argument_count + named_argument_count;
3074 body += StaticCall(TokenPosition::kNoSource, target, argument_count,
3075 argument_names);
3076
3077 // Return the result.
3078 body += Return(function_node_helper.end_position_);
3079
3080 return new (Z)
3081 FlowGraph(*parsed_function(), flow_graph_builder_->graph_entry_,
3082 flow_graph_builder_->next_block_id_ - 1);
3083 }
3084
2988 FlowGraph* StreamingFlowGraphBuilder::BuildGraphOfFunction( 3085 FlowGraph* StreamingFlowGraphBuilder::BuildGraphOfFunction(
2989 intptr_t constructor_class_parent_offset) { 3086 intptr_t constructor_class_parent_offset) {
2990 const Function& dart_function = parsed_function()->function(); 3087 const Function& dart_function = parsed_function()->function();
2991 TargetEntryInstr* normal_entry = flow_graph_builder_->BuildTargetEntry(); 3088 TargetEntryInstr* normal_entry = flow_graph_builder_->BuildTargetEntry();
2992 flow_graph_builder_->graph_entry_ = new (Z) GraphEntryInstr( 3089 flow_graph_builder_->graph_entry_ = new (Z) GraphEntryInstr(
2993 *parsed_function(), normal_entry, flow_graph_builder_->osr_id_); 3090 *parsed_function(), normal_entry, flow_graph_builder_->osr_id_);
2994 3091
2995 SetupDefaultParameterValues(); 3092 SetupDefaultParameterValues();
2996 3093
2997 Fragment body; 3094 Fragment body;
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after
3318 // will not need an AST. The code generator will assume that there is a 3415 // will not need an AST. The code generator will assume that there is a
3319 // local variable stack slot allocated for the current context and (I 3416 // local variable stack slot allocated for the current context and (I
3320 // think) that the runtime will expect it to be at a fixed offset which 3417 // think) that the runtime will expect it to be at a fixed offset which
3321 // requires allocating an unused expression temporary variable. 3418 // requires allocating an unused expression temporary variable.
3322 set_scopes(parsed_function()->EnsureKernelScopes()); 3419 set_scopes(parsed_function()->EnsureKernelScopes());
3323 3420
3324 SetOffset(kernel_offset); 3421 SetOffset(kernel_offset);
3325 3422
3326 switch (function.kind()) { 3423 switch (function.kind()) {
3327 case RawFunction::kClosureFunction: 3424 case RawFunction::kClosureFunction:
3425 case RawFunction::kConvertedClosureFunction:
3328 case RawFunction::kRegularFunction: 3426 case RawFunction::kRegularFunction:
3329 case RawFunction::kGetterFunction: 3427 case RawFunction::kGetterFunction:
3330 case RawFunction::kSetterFunction: { 3428 case RawFunction::kSetterFunction: {
3331 ReadUntilFunctionNode(); // read until function node. 3429 ReadUntilFunctionNode(); // read until function node.
3332 return function.IsImplicitClosureFunction() 3430 if (function.IsImplicitClosureFunction()) {
3333 ? BuildGraphOfImplicitClosureFunction(function) 3431 return BuildGraphOfImplicitClosureFunction(function);
3334 : BuildGraphOfFunction(); 3432 } else if (function.IsConvertedClosureFunction()) {
3433 return BuildGraphOfConvertedClosureFunction(function);
3434 }
3435 return BuildGraphOfFunction();
3335 } 3436 }
3336 case RawFunction::kConstructor: { 3437 case RawFunction::kConstructor: {
3337 bool is_factory = function.IsFactory(); 3438 bool is_factory = function.IsFactory();
3338 if (is_factory) { 3439 if (is_factory) {
3339 ReadUntilFunctionNode(); // read until function node. 3440 ReadUntilFunctionNode(); // read until function node.
3340 return BuildGraphOfFunction(); 3441 return BuildGraphOfFunction();
3341 } else { 3442 } else {
3342 // Constructor: Pass offset to parent class. 3443 // Constructor: Pass offset to parent class.
3343 return BuildGraphOfFunction( 3444 return BuildGraphOfFunction(
3344 ReadUntilFunctionNode()); // read until function node. 3445 ReadUntilFunctionNode()); // read until function node.
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
3453 case kPositiveIntLiteral: 3554 case kPositiveIntLiteral:
3454 return BuildIntLiteral(false, position); 3555 return BuildIntLiteral(false, position);
3455 case kDoubleLiteral: 3556 case kDoubleLiteral:
3456 return BuildDoubleLiteral(position); 3557 return BuildDoubleLiteral(position);
3457 case kTrueLiteral: 3558 case kTrueLiteral:
3458 return BuildBoolLiteral(true, position); 3559 return BuildBoolLiteral(true, position);
3459 case kFalseLiteral: 3560 case kFalseLiteral:
3460 return BuildBoolLiteral(false, position); 3561 return BuildBoolLiteral(false, position);
3461 case kNullLiteral: 3562 case kNullLiteral:
3462 return BuildNullLiteral(position); 3563 return BuildNullLiteral(position);
3564 case kVectorCreation:
3565 return BuildVectorCreation(position);
3566 case kVectorGet:
3567 return BuildVectorGet(position);
3568 case kVectorSet:
3569 return BuildVectorSet(position);
3570 case kVectorCopy:
3571 return BuildVectorCopy(position);
3572 case kClosureCreation:
3573 return BuildClosureCreation(position);
3463 default: 3574 default:
3464 UNREACHABLE(); 3575 UNREACHABLE();
3465 } 3576 }
3466 3577
3467 return Fragment(); 3578 return Fragment();
3468 } 3579 }
3469 3580
3470 Fragment StreamingFlowGraphBuilder::BuildStatement() { 3581 Fragment StreamingFlowGraphBuilder::BuildStatement() {
3471 Tag tag = ReadTag(); // read tag. 3582 Tag tag = ReadTag(); // read tag.
3472 switch (tag) { 3583 switch (tag) {
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
3619 ReadUInt(); 3730 ReadUInt();
3620 } 3731 }
3621 3732
3622 void StreamingFlowGraphBuilder::SkipDartType() { 3733 void StreamingFlowGraphBuilder::SkipDartType() {
3623 Tag tag = ReadTag(); 3734 Tag tag = ReadTag();
3624 switch (tag) { 3735 switch (tag) {
3625 case kInvalidType: 3736 case kInvalidType:
3626 case kDynamicType: 3737 case kDynamicType:
3627 case kVoidType: 3738 case kVoidType:
3628 case kBottomType: 3739 case kBottomType:
3740 case kVectorType:
3629 // those contain nothing. 3741 // those contain nothing.
3630 return; 3742 return;
3631 case kInterfaceType: 3743 case kInterfaceType:
3632 SkipInterfaceType(false); 3744 SkipInterfaceType(false);
3633 return; 3745 return;
3634 case kSimpleInterfaceType: 3746 case kSimpleInterfaceType:
3635 SkipInterfaceType(true); 3747 SkipInterfaceType(true);
3636 return; 3748 return;
3637 case kFunctionType: 3749 case kFunctionType:
3638 SkipFunctionType(false); 3750 SkipFunctionType(false);
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
3867 } 3979 }
3868 return; 3980 return;
3869 } 3981 }
3870 case kFunctionExpression: 3982 case kFunctionExpression:
3871 SkipFunctionNode(); // read function node. 3983 SkipFunctionNode(); // read function node.
3872 return; 3984 return;
3873 case kLet: 3985 case kLet:
3874 SkipVariableDeclaration(); // read variable declaration. 3986 SkipVariableDeclaration(); // read variable declaration.
3875 SkipExpression(); // read expression. 3987 SkipExpression(); // read expression.
3876 return; 3988 return;
3989 case kVectorCreation:
3990 ReadUInt(); // read value.
3991 return;
3992 case kVectorGet:
3993 SkipExpression(); // read vector expression.
3994 ReadUInt(); // read index.
3995 return;
3996 case kVectorSet:
3997 SkipExpression(); // read vector expression.
3998 ReadUInt(); // read index.
3999 SkipExpression(); // read value.
4000 return;
4001 case kVectorCopy:
4002 SkipExpression(); // read vector expression.
4003 return;
4004 case kClosureCreation:
4005 SkipCanonicalNameReference(); // read top-level function reference.
4006 SkipExpression(); // read context vector.
4007 SkipDartType(); // read function type.
4008 return;
3877 case kBigIntLiteral: 4009 case kBigIntLiteral:
3878 SkipStringReference(); // read string reference. 4010 SkipStringReference(); // read string reference.
3879 return; 4011 return;
3880 case kStringLiteral: 4012 case kStringLiteral:
3881 SkipStringReference(); // read string reference. 4013 SkipStringReference(); // read string reference.
3882 return; 4014 return;
3883 case kSpecialIntLiteral: 4015 case kSpecialIntLiteral:
3884 return; 4016 return;
3885 case kNegativeIntLiteral: 4017 case kNegativeIntLiteral:
3886 ReadUInt(); // read value. 4018 ReadUInt(); // read value.
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after
4212 4344
4213 GrowableArray<YieldContinuation>& 4345 GrowableArray<YieldContinuation>&
4214 StreamingFlowGraphBuilder::yield_continuations() { 4346 StreamingFlowGraphBuilder::yield_continuations() {
4215 return flow_graph_builder_->yield_continuations_; 4347 return flow_graph_builder_->yield_continuations_;
4216 } 4348 }
4217 4349
4218 Value* StreamingFlowGraphBuilder::stack() { 4350 Value* StreamingFlowGraphBuilder::stack() {
4219 return flow_graph_builder_->stack_; 4351 return flow_graph_builder_->stack_;
4220 } 4352 }
4221 4353
4354 void StreamingFlowGraphBuilder::Push(Definition* definition) {
4355 flow_graph_builder_->Push(definition);
4356 }
4357
4222 Value* StreamingFlowGraphBuilder::Pop() { 4358 Value* StreamingFlowGraphBuilder::Pop() {
4223 return flow_graph_builder_->Pop(); 4359 return flow_graph_builder_->Pop();
4224 } 4360 }
4225 4361
4226 Tag StreamingFlowGraphBuilder::PeekArgumentsFirstPositionalTag() { 4362 Tag StreamingFlowGraphBuilder::PeekArgumentsFirstPositionalTag() {
4227 // read parts of arguments, then go back to before doing so. 4363 // read parts of arguments, then go back to before doing so.
4228 AlternativeReadingScope alt(reader_); 4364 AlternativeReadingScope alt(reader_);
4229 ReadUInt(); // read number of arguments. 4365 ReadUInt(); // read number of arguments.
4230 4366
4231 SkipListOfDartTypes(); // Read list of types. 4367 SkipListOfDartTypes(); // Read list of types.
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
4380 bool number_check) { 4516 bool number_check) {
4381 return flow_graph_builder_->StrictCompare(kind, number_check); 4517 return flow_graph_builder_->StrictCompare(kind, number_check);
4382 } 4518 }
4383 4519
4384 Fragment StreamingFlowGraphBuilder::AllocateObject(TokenPosition position, 4520 Fragment StreamingFlowGraphBuilder::AllocateObject(TokenPosition position,
4385 const dart::Class& klass, 4521 const dart::Class& klass,
4386 intptr_t argument_count) { 4522 intptr_t argument_count) {
4387 return flow_graph_builder_->AllocateObject(position, klass, argument_count); 4523 return flow_graph_builder_->AllocateObject(position, klass, argument_count);
4388 } 4524 }
4389 4525
4526 Fragment StreamingFlowGraphBuilder::AllocateObject(
4527 const dart::Class& klass,
4528 const Function& closure_function) {
4529 return flow_graph_builder_->AllocateObject(klass, closure_function);
4530 }
4531
4532 Fragment StreamingFlowGraphBuilder::AllocateContext(intptr_t size) {
4533 return flow_graph_builder_->AllocateContext(size);
4534 }
4535
4536 Fragment StreamingFlowGraphBuilder::LoadField(intptr_t offset) {
4537 return flow_graph_builder_->LoadField(offset);
4538 }
4539
4390 Fragment StreamingFlowGraphBuilder::InstanceCall( 4540 Fragment StreamingFlowGraphBuilder::InstanceCall(
4391 TokenPosition position, 4541 TokenPosition position,
4392 const dart::String& name, 4542 const dart::String& name,
4393 Token::Kind kind, 4543 Token::Kind kind,
4394 intptr_t type_args_len, 4544 intptr_t type_args_len,
4395 intptr_t argument_count, 4545 intptr_t argument_count,
4396 const Array& argument_names, 4546 const Array& argument_names,
4397 intptr_t checked_argument_count) { 4547 intptr_t checked_argument_count) {
4398 return flow_graph_builder_->InstanceCall(position, name, kind, type_args_len, 4548 return flow_graph_builder_->InstanceCall(position, name, kind, type_args_len,
4399 argument_count, argument_names, 4549 argument_count, argument_names,
4400 checked_argument_count); 4550 checked_argument_count);
4401 } 4551 }
4402 4552
4403 Fragment StreamingFlowGraphBuilder::StoreLocal(TokenPosition position, 4553 Fragment StreamingFlowGraphBuilder::StoreLocal(TokenPosition position,
4404 LocalVariable* variable) { 4554 LocalVariable* variable) {
4405 return flow_graph_builder_->StoreLocal(position, variable); 4555 return flow_graph_builder_->StoreLocal(position, variable);
4406 } 4556 }
4407 4557
4408 Fragment StreamingFlowGraphBuilder::StoreStaticField(TokenPosition position, 4558 Fragment StreamingFlowGraphBuilder::StoreStaticField(TokenPosition position,
4409 const dart::Field& field) { 4559 const dart::Field& field) {
4410 return flow_graph_builder_->StoreStaticField(position, field); 4560 return flow_graph_builder_->StoreStaticField(position, field);
4411 } 4561 }
4412 4562
4563 Fragment StreamingFlowGraphBuilder::StoreInstanceField(TokenPosition position,
4564 intptr_t offset) {
4565 return flow_graph_builder_->StoreInstanceField(position, offset);
4566 }
4567
4413 Fragment StreamingFlowGraphBuilder::StringInterpolate(TokenPosition position) { 4568 Fragment StreamingFlowGraphBuilder::StringInterpolate(TokenPosition position) {
4414 return flow_graph_builder_->StringInterpolate(position); 4569 return flow_graph_builder_->StringInterpolate(position);
4415 } 4570 }
4416 4571
4417 Fragment StreamingFlowGraphBuilder::StringInterpolateSingle( 4572 Fragment StreamingFlowGraphBuilder::StringInterpolateSingle(
4418 TokenPosition position) { 4573 TokenPosition position) {
4419 return flow_graph_builder_->StringInterpolateSingle(position); 4574 return flow_graph_builder_->StringInterpolateSingle(position);
4420 } 4575 }
4421 4576
4422 Fragment StreamingFlowGraphBuilder::ThrowTypeError() { 4577 Fragment StreamingFlowGraphBuilder::ThrowTypeError() {
(...skipping 1235 matching lines...) Expand 10 before | Expand all | Expand 10 after
5658 5813
5659 return Constant(Bool::Get(value)); 5814 return Constant(Bool::Get(value));
5660 } 5815 }
5661 5816
5662 Fragment StreamingFlowGraphBuilder::BuildNullLiteral(TokenPosition* position) { 5817 Fragment StreamingFlowGraphBuilder::BuildNullLiteral(TokenPosition* position) {
5663 if (position != NULL) *position = TokenPosition::kNoSource; 5818 if (position != NULL) *position = TokenPosition::kNoSource;
5664 5819
5665 return Constant(Instance::ZoneHandle(Z, Instance::null())); 5820 return Constant(Instance::ZoneHandle(Z, Instance::null()));
5666 } 5821 }
5667 5822
5823 Fragment StreamingFlowGraphBuilder::BuildVectorCreation(
5824 TokenPosition* position) {
5825 if (position != NULL) *position = TokenPosition::kNoSource;
5826
5827 intptr_t size = ReadUInt(); // read size.
5828 return AllocateContext(size);
5829 }
5830
5831 Fragment StreamingFlowGraphBuilder::BuildVectorGet(TokenPosition* position) {
5832 if (position != NULL) *position = TokenPosition::kNoSource;
5833
5834 Fragment instructions = BuildExpression(); // read expression.
5835 intptr_t index = ReadUInt(); // read index.
5836 instructions += LoadField(Context::variable_offset(index));
5837 return instructions;
5838 }
5839
5840 Fragment StreamingFlowGraphBuilder::BuildVectorSet(TokenPosition* position) {
5841 if (position != NULL) *position = TokenPosition::kNoSource;
5842
5843 Fragment instructions = NullConstant();
5844 LocalVariable* result = MakeTemporary();
5845
5846 instructions += BuildExpression(); // read vector expression.
5847 intptr_t index = ReadUInt(); // read index.
5848 instructions += BuildExpression(); // read value expression.
5849 instructions += StoreLocal(TokenPosition::kNoSource, result);
5850
5851 instructions += StoreInstanceField(TokenPosition::kNoSource,
5852 Context::variable_offset(index));
5853
5854 return instructions;
5855 }
5856
5857 Fragment StreamingFlowGraphBuilder::BuildVectorCopy(TokenPosition* position) {
5858 if (position != NULL) *position = TokenPosition::kNoSource;
5859
5860 Fragment instructions = BuildExpression(); // read vector expression.
5861 Value* context_to_copy = Pop();
5862 CloneContextInstr* clone_instruction =
5863 new (Z) CloneContextInstr(TokenPosition::kNoSource, context_to_copy,
5864 Thread::Current()->GetNextDeoptId());
5865 instructions <<= clone_instruction;
5866 Push(clone_instruction);
5867
5868 return instructions;
5869 }
5870
5871 Fragment StreamingFlowGraphBuilder::BuildClosureCreation(
5872 TokenPosition* position) {
5873 if (position != NULL) *position = TokenPosition::kNoSource;
5874
5875 NameIndex function_reference =
5876 ReadCanonicalNameReference(); // read function reference.
5877 Function& function = Function::ZoneHandle(
5878 Z, H.LookupStaticMethodByKernelProcedure(function_reference));
5879 function = function.ConvertedClosureFunction();
5880 ASSERT(!function.IsNull());
5881
5882 const dart::Class& closure_class =
5883 dart::Class::ZoneHandle(Z, I->object_store()->closure_class());
5884 Fragment instructions = AllocateObject(closure_class, function);
5885 LocalVariable* closure = MakeTemporary();
5886
5887 instructions += BuildExpression(); // read context vector.
5888 LocalVariable* context = MakeTemporary();
5889
5890 instructions += LoadLocal(closure);
5891 instructions += Constant(function);
5892 instructions +=
5893 StoreInstanceField(TokenPosition::kNoSource, Closure::function_offset());
5894
5895 instructions += LoadLocal(closure);
5896 instructions += LoadLocal(context);
5897 instructions +=
5898 StoreInstanceField(TokenPosition::kNoSource, Closure::context_offset());
5899
5900 instructions += Drop();
5901
5902 SkipDartType(); // skip function type of the closure.
5903
5904 return instructions;
5905 }
5906
5668 Fragment StreamingFlowGraphBuilder::BuildInvalidStatement() { 5907 Fragment StreamingFlowGraphBuilder::BuildInvalidStatement() {
5669 H.ReportError("Invalid statements not implemented yet!"); 5908 H.ReportError("Invalid statements not implemented yet!");
5670 return Fragment(); 5909 return Fragment();
5671 } 5910 }
5672 5911
5673 Fragment StreamingFlowGraphBuilder::BuildExpressionStatement() { 5912 Fragment StreamingFlowGraphBuilder::BuildExpressionStatement() {
5674 Fragment instructions = BuildExpression(); // read expression. 5913 Fragment instructions = BuildExpression(); // read expression.
5675 instructions += Drop(); 5914 instructions += Drop();
5676 return instructions; 5915 return instructions;
5677 } 5916 }
(...skipping 1350 matching lines...) Expand 10 before | Expand all | Expand 10 after
7028 } 7267 }
7029 } 7268 }
7030 7269
7031 return Array::Handle(Array::null()); 7270 return Array::Handle(Array::null());
7032 } 7271 }
7033 7272
7034 } // namespace kernel 7273 } // namespace kernel
7035 } // namespace dart 7274 } // namespace dart
7036 7275
7037 #endif // !defined(DART_PRECOMPILED_RUNTIME) 7276 #endif // !defined(DART_PRECOMPILED_RUNTIME)
OLDNEW
« no previous file with comments | « runtime/vm/kernel_binary_flowgraph.h ('k') | runtime/vm/kernel_to_il.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698