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

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

Issue 2941643002: Check for a passed-in type argument vector in the prolog of generic functions. (Closed)
Patch Set: Created 3 years, 6 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
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 <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 1779 matching lines...) Expand 10 before | Expand all | Expand 10 after
1790 ArgumentArray arguments = GetArguments(argument_count); 1790 ArgumentArray arguments = GetArguments(argument_count);
1791 const intptr_t kTypeArgsLen = 0; // Generic instance calls not yet supported. 1791 const intptr_t kTypeArgsLen = 0; // Generic instance calls not yet supported.
1792 InstanceCallInstr* call = new (Z) InstanceCallInstr( 1792 InstanceCallInstr* call = new (Z) InstanceCallInstr(
1793 position, name, kind, arguments, kTypeArgsLen, argument_names, 1793 position, name, kind, arguments, kTypeArgsLen, argument_names,
1794 num_args_checked, ic_data_array_, GetNextDeoptId()); 1794 num_args_checked, ic_data_array_, GetNextDeoptId());
1795 Push(call); 1795 Push(call);
1796 return Fragment(call); 1796 return Fragment(call);
1797 } 1797 }
1798 1798
1799 1799
1800 Fragment FlowGraphBuilder::ClosureCall(int argument_count, 1800 Fragment FlowGraphBuilder::ClosureCall(intptr_t type_args_len,
1801 intptr_t argument_count,
1801 const Array& argument_names) { 1802 const Array& argument_names) {
1802 Value* function = Pop(); 1803 Value* function = Pop();
1803 ArgumentArray arguments = GetArguments(argument_count); 1804 const intptr_t total_count = argument_count + (type_args_len > 0 ? 1 : 0);
1804 const intptr_t kTypeArgsLen = 0; // Generic closures not yet supported. 1805 ArgumentArray arguments = GetArguments(total_count);
1805 ClosureCallInstr* call = new (Z) 1806 ClosureCallInstr* call = new (Z)
1806 ClosureCallInstr(function, arguments, kTypeArgsLen, argument_names, 1807 ClosureCallInstr(function, arguments, type_args_len, argument_names,
1807 TokenPosition::kNoSource, GetNextDeoptId()); 1808 TokenPosition::kNoSource, GetNextDeoptId());
1808 Push(call); 1809 Push(call);
1809 return Fragment(call); 1810 return Fragment(call);
1810 } 1811 }
1811 1812
1812 1813
1813 Fragment FlowGraphBuilder::ThrowException(TokenPosition position) { 1814 Fragment FlowGraphBuilder::ThrowException(TokenPosition position) {
1814 Fragment instructions; 1815 Fragment instructions;
1815 instructions += Drop(); 1816 instructions += Drop();
1816 instructions += 1817 instructions +=
(...skipping 1636 matching lines...) Expand 10 before | Expand all | Expand 10 after
3453 3454
3454 TargetEntryInstr* normal_entry = BuildTargetEntry(); 3455 TargetEntryInstr* normal_entry = BuildTargetEntry();
3455 graph_entry_ = new (Z) 3456 graph_entry_ = new (Z)
3456 GraphEntryInstr(*parsed_function_, normal_entry, Compiler::kNoOSRDeoptId); 3457 GraphEntryInstr(*parsed_function_, normal_entry, Compiler::kNoOSRDeoptId);
3457 3458
3458 Fragment body(normal_entry); 3459 Fragment body(normal_entry);
3459 body += CheckStackOverflowInPrologue(); 3460 body += CheckStackOverflowInPrologue();
3460 3461
3461 LocalScope* scope = parsed_function_->node_sequence()->scope(); 3462 LocalScope* scope = parsed_function_->node_sequence()->scope();
3462 3463
3464 if (descriptor.TypeArgsLen() > 0) {
3465 LocalVariable* type_args = parsed_function_->function_type_arguments();
3466 ASSERT(type_args != NULL);
3467 body += LoadLocal(type_args);
3468 body += PushArgument();
3469 }
3470
3463 LocalVariable* closure = NULL; 3471 LocalVariable* closure = NULL;
3464 if (is_closure_call) { 3472 if (is_closure_call) {
3465 closure = scope->VariableAt(0); 3473 closure = scope->VariableAt(0);
3466 3474
3467 // The closure itself is the first argument. 3475 // The closure itself is the first argument.
3468 body += LoadLocal(closure); 3476 body += LoadLocal(closure);
3469 } else { 3477 } else {
3470 // Invoke the getter to get the field value. 3478 // Invoke the getter to get the field value.
3471 body += LoadLocal(scope->VariableAt(0)); 3479 body += LoadLocal(scope->VariableAt(0));
3472 body += PushArgument(); 3480 body += PushArgument();
3473 body += 3481 body +=
3474 InstanceCall(TokenPosition::kMinSource, getter_name, Token::kGET, 1); 3482 InstanceCall(TokenPosition::kMinSource, getter_name, Token::kGET, 1);
3475 } 3483 }
3476 3484
3477 body += PushArgument(); 3485 body += PushArgument();
3478 3486
3479 // Push all arguments onto the stack. 3487 // Push all arguments onto the stack.
3480 intptr_t pos = 1; 3488 intptr_t pos = 1;
3481 for (; pos < descriptor.Count(); pos++) { 3489 for (; pos < descriptor.Count(); pos++) {
3482 body += LoadLocal(scope->VariableAt(pos)); 3490 body += LoadLocal(scope->VariableAt(pos));
3483 body += PushArgument(); 3491 body += PushArgument();
3484 } 3492 }
3485 3493
3486 if (is_closure_call) { 3494 if (is_closure_call) {
3487 // Lookup the function in the closure. 3495 // Lookup the function in the closure.
3488 body += LoadLocal(closure); 3496 body += LoadLocal(closure);
3489 body += LoadField(Closure::function_offset()); 3497 body += LoadField(Closure::function_offset());
3490 3498
3491 body += ClosureCall(descriptor.Count(), argument_names); 3499 body += ClosureCall(descriptor.TypeArgsLen(), descriptor.Count(),
3500 argument_names);
3492 } else { 3501 } else {
3502 if (descriptor.TypeArgsLen() > 0) {
3503 UNIMPLEMENTED();
3504 }
3493 body += InstanceCall(TokenPosition::kMinSource, Symbols::Call(), 3505 body += InstanceCall(TokenPosition::kMinSource, Symbols::Call(),
3494 Token::kILLEGAL, descriptor.Count(), argument_names); 3506 Token::kILLEGAL, descriptor.Count(), argument_names);
3495 } 3507 }
3496 3508
3497 body += Return(TokenPosition::kNoSource); 3509 body += Return(TokenPosition::kNoSource);
3498 3510
3499 return new (Z) FlowGraph(*parsed_function_, graph_entry_, next_block_id_ - 1); 3511 return new (Z) FlowGraph(*parsed_function_, graph_entry_, next_block_id_ - 1);
3500 } 3512 }
3501 3513
3502 3514
(...skipping 2610 matching lines...) Expand 10 before | Expand all | Expand 10 after
6113 thread->clear_sticky_error(); 6125 thread->clear_sticky_error();
6114 return error.raw(); 6126 return error.raw();
6115 } 6127 }
6116 } 6128 }
6117 6129
6118 6130
6119 } // namespace kernel 6131 } // namespace kernel
6120 } // namespace dart 6132 } // namespace dart
6121 6133
6122 #endif // !defined(DART_PRECOMPILED_RUNTIME) 6134 #endif // !defined(DART_PRECOMPILED_RUNTIME)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698