Chromium Code Reviews| Index: runtime/vm/kernel_binary_flowgraph.cc |
| diff --git a/runtime/vm/kernel_binary_flowgraph.cc b/runtime/vm/kernel_binary_flowgraph.cc |
| index 8e1b0e1986cb78d29e37c6e79389f57c9aa117d4..cfa7f3f0b0245a050b1d222864dd508f1e0d1e34 100644 |
| --- a/runtime/vm/kernel_binary_flowgraph.cc |
| +++ b/runtime/vm/kernel_binary_flowgraph.cc |
| @@ -1227,6 +1227,16 @@ Fragment StreamingFlowGraphBuilder::BuildExpression(TokenPosition* position) { |
| return BuildBoolLiteral(false, position); |
| case kNullLiteral: |
| return BuildNullLiteral(position); |
| + case kVectorCreation: |
| + return BuildVectorCreation(position); |
| + case kVectorGet: |
| + return BuildVectorGet(position); |
| + case kVectorSet: |
| + return BuildVectorSet(position); |
| + case kVectorCopy: |
| + return BuildVectorCopy(position); |
| + case kClosureCreation: |
| + return BuildClosureCreation(position); |
| default: |
| UNREACHABLE(); |
| } |
| @@ -1932,6 +1942,10 @@ Value* StreamingFlowGraphBuilder::stack() { |
| return flow_graph_builder_->stack_; |
| } |
| +void StreamingFlowGraphBuilder::Push(Definition* definition) { |
| + flow_graph_builder_->Push(definition); |
| +} |
| + |
| Value* StreamingFlowGraphBuilder::Pop() { |
| return flow_graph_builder_->Pop(); |
| } |
| @@ -2112,6 +2126,20 @@ Fragment StreamingFlowGraphBuilder::AllocateObject(const dart::Class& klass, |
| return flow_graph_builder_->AllocateObject(klass, argument_count); |
| } |
| +Fragment StreamingFlowGraphBuilder::AllocateObject( |
| + const dart::Class& klass, |
| + const Function& closure_function) { |
| + return flow_graph_builder_->AllocateObject(klass, closure_function); |
| +} |
| + |
| +Fragment StreamingFlowGraphBuilder::AllocateContext(int size) { |
| + return flow_graph_builder_->AllocateContext(size); |
| +} |
| + |
| +Fragment StreamingFlowGraphBuilder::LoadField(intptr_t offset) { |
| + return flow_graph_builder_->LoadField(offset); |
| +} |
| + |
| Fragment StreamingFlowGraphBuilder::InstanceCall(TokenPosition position, |
| const dart::String& name, |
| Token::Kind kind, |
| @@ -2132,6 +2160,11 @@ Fragment StreamingFlowGraphBuilder::StoreStaticField(TokenPosition position, |
| return flow_graph_builder_->StoreStaticField(position, field); |
| } |
| +Fragment StreamingFlowGraphBuilder::StoreInstanceField(TokenPosition position, |
| + intptr_t offset) { |
| + return flow_graph_builder_->StoreInstanceField(position, offset); |
| +} |
| + |
| Fragment StreamingFlowGraphBuilder::StringInterpolate(TokenPosition position) { |
| return flow_graph_builder_->StringInterpolate(position); |
| } |
| @@ -3045,9 +3078,10 @@ Fragment StreamingFlowGraphBuilder::BuildIsExpression(TokenPosition* p) { |
| if (dart::FlowGraphBuilder::SimpleInstanceOfType(type)) { |
| instructions += Constant(type); |
| instructions += PushArgument(); // Type. |
| - instructions += InstanceCall(position, dart::Library::PrivateCoreLibName( |
| - Symbols::_simpleInstanceOf()), |
| - Token::kIS, 2, 2); // 2 checked arguments. |
| + instructions += InstanceCall( |
| + position, |
| + dart::Library::PrivateCoreLibName(Symbols::_simpleInstanceOf()), |
| + Token::kIS, 2, 2); // 2 checked arguments. |
| return instructions; |
| } |
| @@ -3372,6 +3406,91 @@ Fragment StreamingFlowGraphBuilder::BuildNullLiteral(TokenPosition* position) { |
| return Constant(Instance::ZoneHandle(Z, Instance::null())); |
| } |
| +Fragment StreamingFlowGraphBuilder::BuildVectorCreation( |
| + TokenPosition* position) { |
| + if (position != NULL) *position = TokenPosition::kNoSource; |
| + |
| + intptr_t size = ReadUInt(); // read size. |
| + return AllocateContext(size); |
| +} |
| + |
| +Fragment StreamingFlowGraphBuilder::BuildVectorGet(TokenPosition* position) { |
| + if (position != NULL) *position = TokenPosition::kNoSource; |
| + |
| + Fragment instructions = BuildExpression(); // read expression. |
| + intptr_t index = ReadUInt(); // read index. |
| + instructions += LoadField(Context::variable_offset(index)); |
| + return instructions; |
| +} |
| + |
| +Fragment StreamingFlowGraphBuilder::BuildVectorSet(TokenPosition* position) { |
| + if (position != NULL) *position = TokenPosition::kNoSource; |
| + |
| + Fragment instructions = BuildExpression(); // read vector expression. |
| + intptr_t index = ReadUInt(); // read index. |
| + instructions += BuildExpressionStatement(); // read value expression. |
|
jensj
2017/05/18 11:19:05
Shouldn't this just be BuildExpression();?
Dmitry Stefantsov
2017/05/18 12:18:53
Yes, of course. Thanks! Fixed.
|
| + |
| + // The assigned value is the result of the expression. |
| + LocalVariable* result = MakeTemporary(); |
| + |
| + Value* value = Pop(); |
| + StoreInstanceFieldInstr* store = new (Z) |
| + StoreInstanceFieldInstr(Context::variable_offset(index), Pop(), value, |
| + kNoStoreBarrier, TokenPosition::kNoSource); |
| + instructions <<= store; |
| + |
| + // Load the result that is stored in the temporary variable. |
| + instructions += LoadLocal(result); |
| + |
| + return instructions; |
| +} |
| + |
| +Fragment StreamingFlowGraphBuilder::BuildVectorCopy(TokenPosition* position) { |
| + if (position != NULL) *position = TokenPosition::kNoSource; |
| + |
| + Fragment instructions = BuildExpression(); // read vector expression. |
| + CloneContextInstr* clone_instruction = |
| + new (Z) CloneContextInstr(TokenPosition::kNoSource, Pop()); |
| + instructions <<= clone_instruction; |
| + Push(clone_instruction); |
| + |
| + return instructions; |
| +} |
| + |
| +Fragment StreamingFlowGraphBuilder::BuildClosureCreation( |
| + TokenPosition* position) { |
| + if (position != NULL) *position = TokenPosition::kNoSource; |
| + |
| + NameIndex function_reference = |
| + ReadCanonicalNameReference(); // read function reference. |
| + Function& function = Function::ZoneHandle( |
| + Z, H.LookupStaticMethodByKernelProcedure(function_reference)); |
| + function = function.ConvertedClosureFunction(); |
| + ASSERT(!function.IsNull()); |
| + |
| + const dart::Class& closure_class = |
| + dart::Class::ZoneHandle(Z, I->object_store()->closure_class()); |
| + Fragment instructions = AllocateObject(closure_class, function); |
| + LocalVariable* closure = MakeTemporary(); |
| + |
| + instructions += BuildExpression(); // read vector expression. |
|
jensj
2017/05/18 11:19:06
from the kernel_binary.cc file I would guess the c
Dmitry Stefantsov
2017/05/18 12:18:52
Yep. Thanks!
|
| + LocalVariable* context = MakeTemporary(); |
| + |
| + instructions += LoadLocal(closure); |
| + instructions += Constant(function); |
| + instructions += |
| + StoreInstanceField(TokenPosition::kNoSource, Closure::function_offset()); |
| + |
| + instructions += LoadLocal(closure); |
| + instructions += LoadLocal(context); |
| + instructions += |
| + StoreInstanceField(TokenPosition::kNoSource, Closure::context_offset()); |
| + |
| + instructions += Drop(); |
| + |
| + return instructions; |
|
jensj
2017/05/18 11:19:06
Isn't there a SkipDartType or something missing?
Dmitry Stefantsov
2017/05/18 12:18:52
Yes. I should have put an invocation of SkipDartTy
|
| +} |
| + |
| Fragment StreamingFlowGraphBuilder::BuildInvalidStatement() { |
| H.ReportError("Invalid statements not implemented yet!"); |
| return Fragment(); |