Index: runtime/vm/stub_code_x64.cc |
diff --git a/runtime/vm/stub_code_x64.cc b/runtime/vm/stub_code_x64.cc |
index 53f153e2c25d4d1d337309569f7377f94a1654c1..733a7bc34d51ae471da51b2ccf409aa19ac72c9d 100644 |
--- a/runtime/vm/stub_code_x64.cc |
+++ b/runtime/vm/stub_code_x64.cc |
@@ -564,8 +564,17 @@ static void GenerateDispatcherCode(Assembler* assembler, |
__ pushq(RAX); // Receiver. |
__ pushq(RBX); // ICData/MegamorphicCache. |
__ pushq(R10); // Arguments descriptor array. |
+ |
+ // Adjust arguments count. |
+ __ cmpq(FieldAddress(R10, ArgumentsDescriptor::type_args_len_offset()), |
+ Immediate(0)); |
__ movq(R10, RDI); |
- // EDX: Smi-tagged arguments array length. |
+ Label args_count_ok; |
+ __ j(EQUAL, &args_count_ok, Assembler::kNearJump); |
+ __ addq(R10, Immediate(Smi::RawValue(1))); // Include the type arguments. |
+ __ Bind(&args_count_ok); |
+ |
+ // R10: Smi-tagged arguments array length. |
PushArgumentsArray(assembler); |
const intptr_t kNumArgs = 4; |
__ CallRuntime(kInvokeNoSuchMethodDispatcherRuntimeEntry, kNumArgs); |
@@ -1214,7 +1223,16 @@ void StubCode::GenerateCallClosureNoSuchMethodStub(Assembler* assembler) { |
__ pushq(RAX); // Receiver. |
__ pushq(R10); // Arguments descriptor array. |
- __ movq(R10, R13); // Smi-tagged arguments array length. |
+ // Adjust arguments count. |
+ __ cmpq(FieldAddress(R10, ArgumentsDescriptor::type_args_len_offset()), |
+ Immediate(0)); |
+ __ movq(R10, R13); |
+ Label args_count_ok; |
+ __ j(EQUAL, &args_count_ok, Assembler::kNearJump); |
+ __ addq(R10, Immediate(Smi::RawValue(1))); // Include the type arguments. |
+ __ Bind(&args_count_ok); |
+ |
+ // R10: Smi-tagged arguments array length. |
PushArgumentsArray(assembler); |
const intptr_t kNumArgs = 3; |