| Index: runtime/vm/stub_code_mips.cc
|
| ===================================================================
|
| --- runtime/vm/stub_code_mips.cc (revision 24306)
|
| +++ runtime/vm/stub_code_mips.cc (working copy)
|
| @@ -1798,13 +1798,83 @@
|
| }
|
|
|
|
|
| +// Intermediary stub between a static call and its target. ICData contains
|
| +// the target function and the call count.
|
| +// S5: ICData
|
| +void StubCode::GenerateUnoptimizedStaticCallStub(Assembler* assembler) {
|
| + GenerateUsageCounterIncrement(assembler, T0);
|
| + __ TraceSimMsg("UnoptimizedStaticCallStub");
|
| +#if defined(DEBUG)
|
| + { Label ok;
|
| + // Check that the IC data array has NumberOfArgumentsChecked() == 0.
|
| + // 'num_args_tested' is stored as an untagged int.
|
| + __ lw(T0, FieldAddress(S5, ICData::num_args_tested_offset()));
|
| + __ beq(T0, ZR, &ok);
|
| + __ Stop("Incorrect IC data for unoptimized static call");
|
| + __ Bind(&ok);
|
| + }
|
| +#endif // DEBUG
|
| +
|
| + // S5: IC data object (preserved).
|
| + __ lw(T0, FieldAddress(S5, ICData::ic_data_offset()));
|
| + // T0: ic_data_array with entries: target functions and count.
|
| + __ AddImmediate(T0, Array::data_offset() - kHeapObjectTag);
|
| + // T0: points directly to the first ic data array element.
|
| + const intptr_t target_offset = ICData::TargetIndexFor(0) * kWordSize;
|
| + const intptr_t count_offset = ICData::CountIndexFor(0) * kWordSize;
|
| +
|
| + // Increment count for this call.
|
| + Label increment_done;
|
| + __ lw(T4, Address(T0, count_offset));
|
| + __ AddImmediateDetectOverflow(T4, T4, Smi::RawValue(1), T5, T6);
|
| + __ bgez(T5, &increment_done); // No overflow.
|
| + __ delay_slot()->sw(T4, Address(T0, count_offset));
|
| +
|
| + __ LoadImmediate(T1, Smi::RawValue(Smi::kMaxValue));
|
| + __ sw(T1, Address(T0, count_offset));
|
| +
|
| + __ Bind(&increment_done);
|
| +
|
| + Label target_is_compiled;
|
| + // Get function and call it, if possible.
|
| + __ lw(T3, Address(T0, target_offset));
|
| + __ lw(T4, FieldAddress(T3, Function::code_offset()));
|
| + __ LoadImmediate(TMP, reinterpret_cast<intptr_t>(Object::null()));
|
| + __ bne(T4, TMP, &target_is_compiled);
|
| +
|
| + __ EnterStubFrame();
|
| + // Preserve target function and IC data object.
|
| + // Two preserved registers, one argument (function) => 3 slots.
|
| + __ addiu(SP, SP, Immediate(-3 * kWordSize));
|
| + __ sw(S5, Address(SP, 2 * kWordSize)); // Preserve IC data.
|
| + __ sw(T3, Address(SP, 1 * kWordSize)); // Preserve function.
|
| + __ sw(T3, Address(SP, 0 * kWordSize)); // Function argument.
|
| + __ CallRuntime(kCompileFunctionRuntimeEntry);
|
| + __ lw(T3, Address(SP, 1 * kWordSize)); // Restore function.
|
| + __ lw(S5, Address(SP, 2 * kWordSize)); // Restore IC data.
|
| + __ addiu(SP, SP, Immediate(3 * kWordSize));
|
| + // T3: target function.
|
| + __ lw(T4, FieldAddress(T3, Function::code_offset()));
|
| + __ LeaveStubFrame();
|
| +
|
| + __ Bind(&target_is_compiled);
|
| + // T4: target code.
|
| + __ lw(T3, FieldAddress(T4, Code::instructions_offset()));
|
| + __ AddImmediate(T3, Instructions::HeaderSize() - kHeapObjectTag);
|
| + __ jr(T3);
|
| + // Load arguments descriptor into S4.
|
| + __ delay_slot()->
|
| + lw(S4, FieldAddress(S5, ICData::arguments_descriptor_offset()));
|
| +}
|
| +
|
| +
|
| void StubCode::GenerateBreakpointRuntimeStub(Assembler* assembler) {
|
| __ Unimplemented("BreakpointRuntime stub");
|
| }
|
|
|
|
|
| // RA: return address (Dart code).
|
| -// S4: Arguments descriptor array.
|
| +// S5: IC data (unoptimized static call).
|
| void StubCode::GenerateBreakpointStaticStub(Assembler* assembler) {
|
| __ TraceSimMsg("BreakpointStaticStub");
|
| // Create a stub frame as we are pushing some objects on the stack before
|
| @@ -1812,13 +1882,13 @@
|
| __ EnterStubFrame();
|
| // Preserve arguments descriptor and make room for result.
|
| __ addiu(SP, SP, Immediate(-2 * kWordSize));
|
| - __ sw(S4, Address(SP, 1 * kWordSize));
|
| + __ sw(S5, Address(SP, 1 * kWordSize));
|
| __ LoadImmediate(TMP, reinterpret_cast<intptr_t>(Object::null()));
|
| __ sw(TMP, Address(SP, 0 * kWordSize));
|
| __ CallRuntime(kBreakpointStaticHandlerRuntimeEntry);
|
| // Pop code object result and restore arguments descriptor.
|
| __ lw(T0, Address(SP, 0 * kWordSize));
|
| - __ lw(S4, Address(SP, 1 * kWordSize));
|
| + __ lw(S5, Address(SP, 1 * kWordSize));
|
| __ addiu(SP, SP, Immediate(2 * kWordSize));
|
| __ LeaveStubFrame();
|
|
|
| @@ -1826,6 +1896,8 @@
|
| // ensures that the call target is compiled.
|
| __ lw(T0, FieldAddress(T0, Code::instructions_offset()));
|
| __ AddImmediate(T0, Instructions::HeaderSize() - kHeapObjectTag);
|
| + // Load arguments descriptor into S4.
|
| + __ lw(S4, FieldAddress(S5, ICData::arguments_descriptor_offset()));
|
| __ jr(T0);
|
| }
|
|
|
|
|