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 "vm/globals.h" // Needed here to get TARGET_ARCH_DBC. | 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_DBC. |
6 #if defined(TARGET_ARCH_DBC) | 6 #if defined(TARGET_ARCH_DBC) |
7 | 7 |
8 #include "vm/flow_graph_compiler.h" | 8 #include "vm/flow_graph_compiler.h" |
9 | 9 |
10 #include "vm/ast_printer.h" | 10 #include "vm/ast_printer.h" |
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
374 if (!is_optimizing()) { | 374 if (!is_optimizing()) { |
375 ASSERT(num_locals > 0); // There is always at least context_var. | 375 ASSERT(num_locals > 0); // There is always at least context_var. |
376 __ Frame(num_locals); // Reserve space for locals. | 376 __ Frame(num_locals); // Reserve space for locals. |
377 } else if (flow_graph_.graph_entry()->spill_slot_count() > | 377 } else if (flow_graph_.graph_entry()->spill_slot_count() > |
378 flow_graph_.num_copied_params()) { | 378 flow_graph_.num_copied_params()) { |
379 __ Frame(flow_graph_.graph_entry()->spill_slot_count() - | 379 __ Frame(flow_graph_.graph_entry()->spill_slot_count() - |
380 flow_graph_.num_copied_params()); | 380 flow_graph_.num_copied_params()); |
381 } | 381 } |
382 } | 382 } |
383 | 383 |
| 384 const bool has_type_arguments = |
| 385 FLAG_reify_generic_functions && function.IsGeneric(); |
384 if (function.IsClosureFunction()) { | 386 if (function.IsClosureFunction()) { |
385 // In optimized mode the register allocator expects CurrentContext in the | 387 // In optimized mode the register allocator expects CurrentContext in the |
386 // flow_graph_.num_copied_params() register at function entry. | 388 // flow_graph_.num_copied_params() register at function entry, unless that |
| 389 // register is used for function type arguments, either as their |
| 390 // permanent location or as their temporary location when captured. |
| 391 // In that case, the next register holds CurrentContext. |
387 // (see FlowGraphAllocator::ProcessInitialDefinition) | 392 // (see FlowGraphAllocator::ProcessInitialDefinition) |
388 Register context_reg = | 393 Register context_reg = |
389 is_optimizing() ? flow_graph_.num_copied_params() : context_index; | 394 is_optimizing() |
| 395 ? (has_type_arguments ? flow_graph_.num_copied_params() + 1 |
| 396 : flow_graph_.num_copied_params()) |
| 397 : context_index; |
390 LocalScope* scope = parsed_function().node_sequence()->scope(); | 398 LocalScope* scope = parsed_function().node_sequence()->scope(); |
391 LocalVariable* local = scope->VariableAt(0); | 399 LocalVariable* local = scope->VariableAt(0); // Closure instance receiver. |
392 | 400 |
393 Register closure_reg; | 401 Register closure_reg; |
394 if (local->index() > 0) { | 402 if (local->index() > 0) { |
395 __ Move(context_reg, -local->index()); | 403 __ Move(context_reg, -local->index()); |
396 closure_reg = context_reg; | 404 closure_reg = context_reg; |
397 } else { | 405 } else { |
398 closure_reg = -local->index() - 1; | 406 closure_reg = -local->index() - 1; |
399 } | 407 } |
400 __ LoadField(context_reg, closure_reg, | 408 __ LoadField(context_reg, closure_reg, |
401 Closure::context_offset() / kWordSize); | 409 Closure::context_offset() / kWordSize); |
402 } else if (has_optional_params && !is_optimizing()) { | 410 } else if (has_optional_params && !is_optimizing()) { |
403 __ LoadConstant(context_index, Object::empty_context()); | 411 __ LoadConstant(context_index, Object::empty_context()); |
404 } | 412 } |
405 | 413 |
406 // Check for a passed type argument vector if the function is generic. | 414 // Check for a passed type argument vector if the function is generic. |
407 if (FLAG_reify_generic_functions && function.IsGeneric() && | 415 if (has_type_arguments && !flow_graph().IsCompiledForOsr()) { |
408 !flow_graph().IsCompiledForOsr()) { | 416 ASSERT(-parsed_function().first_stack_local_index() - 1 == |
409 __ Comment("Check passed-in type args"); | 417 flow_graph_.num_copied_params()); |
410 UNIMPLEMENTED(); // TODO(regis): Not yet supported. | 418 __ CheckFunctionTypeArgs(function.NumTypeParameters(), |
| 419 flow_graph_.num_copied_params()); |
411 } | 420 } |
| 421 |
| 422 // TODO(regis): Verify that no vector is passed if not generic, unless already |
| 423 // checked during resolution. |
412 } | 424 } |
413 | 425 |
414 void FlowGraphCompiler::CompileGraph() { | 426 void FlowGraphCompiler::CompileGraph() { |
415 InitCompiler(); | 427 InitCompiler(); |
416 | 428 |
417 if (TryIntrinsify()) { | 429 if (TryIntrinsify()) { |
418 // Skip regular code generation. | 430 // Skip regular code generation. |
419 return; | 431 return; |
420 } | 432 } |
421 | 433 |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
546 | 558 |
547 void ParallelMoveResolver::RestoreFpuScratch(FpuRegister reg) { | 559 void ParallelMoveResolver::RestoreFpuScratch(FpuRegister reg) { |
548 UNIMPLEMENTED(); | 560 UNIMPLEMENTED(); |
549 } | 561 } |
550 | 562 |
551 #undef __ | 563 #undef __ |
552 | 564 |
553 } // namespace dart | 565 } // namespace dart |
554 | 566 |
555 #endif // defined TARGET_ARCH_DBC | 567 #endif // defined TARGET_ARCH_DBC |
OLD | NEW |