| OLD | NEW |
| 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 <set> | 5 #include <set> |
| 6 | 6 |
| 7 #include "vm/kernel_to_il.h" | 7 #include "vm/kernel_to_il.h" |
| 8 | 8 |
| 9 #include "vm/compiler.h" | 9 #include "vm/compiler.h" |
| 10 #include "vm/intermediate_language.h" | 10 #include "vm/intermediate_language.h" |
| (...skipping 1159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1170 ArgumentArray arguments = GetArguments(argument_count); | 1170 ArgumentArray arguments = GetArguments(argument_count); |
| 1171 const intptr_t kTypeArgsLen = 0; // Generic instance calls not yet supported. | 1171 const intptr_t kTypeArgsLen = 0; // Generic instance calls not yet supported. |
| 1172 InstanceCallInstr* call = new (Z) InstanceCallInstr( | 1172 InstanceCallInstr* call = new (Z) InstanceCallInstr( |
| 1173 position, name, kind, arguments, kTypeArgsLen, argument_names, | 1173 position, name, kind, arguments, kTypeArgsLen, argument_names, |
| 1174 num_args_checked, ic_data_array_, GetNextDeoptId()); | 1174 num_args_checked, ic_data_array_, GetNextDeoptId()); |
| 1175 Push(call); | 1175 Push(call); |
| 1176 return Fragment(call); | 1176 return Fragment(call); |
| 1177 } | 1177 } |
| 1178 | 1178 |
| 1179 | 1179 |
| 1180 Fragment FlowGraphBuilder::ClosureCall(int argument_count, | 1180 Fragment FlowGraphBuilder::ClosureCall(intptr_t type_args_len, |
| 1181 intptr_t argument_count, |
| 1181 const Array& argument_names) { | 1182 const Array& argument_names) { |
| 1182 Value* function = Pop(); | 1183 Value* function = Pop(); |
| 1183 ArgumentArray arguments = GetArguments(argument_count); | 1184 const intptr_t total_count = argument_count + (type_args_len > 0 ? 1 : 0); |
| 1184 const intptr_t kTypeArgsLen = 0; // Generic closures not yet supported. | 1185 ArgumentArray arguments = GetArguments(total_count); |
| 1185 ClosureCallInstr* call = new (Z) | 1186 ClosureCallInstr* call = new (Z) |
| 1186 ClosureCallInstr(function, arguments, kTypeArgsLen, argument_names, | 1187 ClosureCallInstr(function, arguments, type_args_len, argument_names, |
| 1187 TokenPosition::kNoSource, GetNextDeoptId()); | 1188 TokenPosition::kNoSource, GetNextDeoptId()); |
| 1188 Push(call); | 1189 Push(call); |
| 1189 return Fragment(call); | 1190 return Fragment(call); |
| 1190 } | 1191 } |
| 1191 | 1192 |
| 1192 | 1193 |
| 1193 Fragment FlowGraphBuilder::ThrowException(TokenPosition position) { | 1194 Fragment FlowGraphBuilder::ThrowException(TokenPosition position) { |
| 1194 Fragment instructions; | 1195 Fragment instructions; |
| 1195 instructions += Drop(); | 1196 instructions += Drop(); |
| 1196 instructions += | 1197 instructions += |
| (...skipping 1105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2302 | 2303 |
| 2303 TargetEntryInstr* normal_entry = BuildTargetEntry(); | 2304 TargetEntryInstr* normal_entry = BuildTargetEntry(); |
| 2304 graph_entry_ = new (Z) | 2305 graph_entry_ = new (Z) |
| 2305 GraphEntryInstr(*parsed_function_, normal_entry, Compiler::kNoOSRDeoptId); | 2306 GraphEntryInstr(*parsed_function_, normal_entry, Compiler::kNoOSRDeoptId); |
| 2306 | 2307 |
| 2307 Fragment body(normal_entry); | 2308 Fragment body(normal_entry); |
| 2308 body += CheckStackOverflowInPrologue(); | 2309 body += CheckStackOverflowInPrologue(); |
| 2309 | 2310 |
| 2310 LocalScope* scope = parsed_function_->node_sequence()->scope(); | 2311 LocalScope* scope = parsed_function_->node_sequence()->scope(); |
| 2311 | 2312 |
| 2313 if (descriptor.TypeArgsLen() > 0) { |
| 2314 LocalVariable* type_args = parsed_function_->function_type_arguments(); |
| 2315 ASSERT(type_args != NULL); |
| 2316 body += LoadLocal(type_args); |
| 2317 body += PushArgument(); |
| 2318 } |
| 2319 |
| 2312 LocalVariable* closure = NULL; | 2320 LocalVariable* closure = NULL; |
| 2313 if (is_closure_call) { | 2321 if (is_closure_call) { |
| 2314 closure = scope->VariableAt(0); | 2322 closure = scope->VariableAt(0); |
| 2315 | 2323 |
| 2316 // The closure itself is the first argument. | 2324 // The closure itself is the first argument. |
| 2317 body += LoadLocal(closure); | 2325 body += LoadLocal(closure); |
| 2318 } else { | 2326 } else { |
| 2319 // Invoke the getter to get the field value. | 2327 // Invoke the getter to get the field value. |
| 2320 body += LoadLocal(scope->VariableAt(0)); | 2328 body += LoadLocal(scope->VariableAt(0)); |
| 2321 body += PushArgument(); | 2329 body += PushArgument(); |
| 2322 body += | 2330 body += |
| 2323 InstanceCall(TokenPosition::kMinSource, getter_name, Token::kGET, 1); | 2331 InstanceCall(TokenPosition::kMinSource, getter_name, Token::kGET, 1); |
| 2324 } | 2332 } |
| 2325 | 2333 |
| 2326 body += PushArgument(); | 2334 body += PushArgument(); |
| 2327 | 2335 |
| 2328 // Push all arguments onto the stack. | 2336 // Push all arguments onto the stack. |
| 2329 intptr_t pos = 1; | 2337 intptr_t pos = 1; |
| 2330 for (; pos < descriptor.Count(); pos++) { | 2338 for (; pos < descriptor.Count(); pos++) { |
| 2331 body += LoadLocal(scope->VariableAt(pos)); | 2339 body += LoadLocal(scope->VariableAt(pos)); |
| 2332 body += PushArgument(); | 2340 body += PushArgument(); |
| 2333 } | 2341 } |
| 2334 | 2342 |
| 2335 if (is_closure_call) { | 2343 if (is_closure_call) { |
| 2336 // Lookup the function in the closure. | 2344 // Lookup the function in the closure. |
| 2337 body += LoadLocal(closure); | 2345 body += LoadLocal(closure); |
| 2338 body += LoadField(Closure::function_offset()); | 2346 body += LoadField(Closure::function_offset()); |
| 2339 | 2347 |
| 2340 body += ClosureCall(descriptor.Count(), argument_names); | 2348 body += ClosureCall(descriptor.TypeArgsLen(), descriptor.Count(), |
| 2349 argument_names); |
| 2341 } else { | 2350 } else { |
| 2351 if (descriptor.TypeArgsLen() > 0) { |
| 2352 UNIMPLEMENTED(); |
| 2353 } |
| 2342 body += InstanceCall(TokenPosition::kMinSource, Symbols::Call(), | 2354 body += InstanceCall(TokenPosition::kMinSource, Symbols::Call(), |
| 2343 Token::kILLEGAL, descriptor.Count(), argument_names); | 2355 Token::kILLEGAL, descriptor.Count(), argument_names); |
| 2344 } | 2356 } |
| 2345 | 2357 |
| 2346 body += Return(TokenPosition::kNoSource); | 2358 body += Return(TokenPosition::kNoSource); |
| 2347 | 2359 |
| 2348 return new (Z) FlowGraph(*parsed_function_, graph_entry_, next_block_id_ - 1); | 2360 return new (Z) FlowGraph(*parsed_function_, graph_entry_, next_block_id_ - 1); |
| 2349 } | 2361 } |
| 2350 | 2362 |
| 2351 | 2363 |
| (...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2739 thread->clear_sticky_error(); | 2751 thread->clear_sticky_error(); |
| 2740 return error.raw(); | 2752 return error.raw(); |
| 2741 } | 2753 } |
| 2742 } | 2754 } |
| 2743 | 2755 |
| 2744 | 2756 |
| 2745 } // namespace kernel | 2757 } // namespace kernel |
| 2746 } // namespace dart | 2758 } // namespace dart |
| 2747 | 2759 |
| 2748 #endif // !defined(DART_PRECOMPILED_RUNTIME) | 2760 #endif // !defined(DART_PRECOMPILED_RUNTIME) |
| OLD | NEW |