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

Unified Diff: runtime/vm/stub_code_mips.cc

Issue 203523011: Introduce a lazy-compile stub for functions. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: rebased & added MIPS code Created 6 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: runtime/vm/stub_code_mips.cc
===================================================================
--- runtime/vm/stub_code_mips.cc (revision 34118)
+++ runtime/vm/stub_code_mips.cc (working copy)
@@ -908,42 +908,21 @@
__ beq(T0, T7, &not_closure);
// T0 is just the signature function. Load the actual closure function.
- __ lw(T2, FieldAddress(T1, Closure::function_offset()));
+ __ lw(T0, FieldAddress(T1, Closure::function_offset()));
// Load closure context in CTX; note that CTX has already been preserved.
__ lw(CTX, FieldAddress(T1, Closure::context_offset()));
+ // Load closure function code in T2.
Label function_compiled;
- // Load closure function code in T0.
- __ lw(T0, FieldAddress(T2, Function::code_offset()));
- __ bne(T0, T7, &function_compiled);
+ __ lw(T2, FieldAddress(T0, Function::code_offset()));
+ __ beq(T2, T7, &function_compiled);
+ __ Branch(&StubCode::LazyCompileClosureLabel());
- // Create a stub frame as we are pushing some objects on the stack before
- // calling into the runtime.
- __ EnterStubFrame();
-
- // Preserve arguments descriptor array and read-only function object argument.
- __ addiu(SP, SP, Immediate(-2 * kWordSize));
- __ sw(S4, Address(SP, 1 * kWordSize));
- __ sw(T2, Address(SP, 0 * kWordSize));
- __ CallRuntime(kCompileFunctionRuntimeEntry, 1);
- __ TraceSimMsg("GenerateCallClosureFunctionStub return");
- // Restore arguments descriptor array and read-only function object argument.
- __ lw(T2, Address(SP, 0 * kWordSize));
- __ lw(S4, Address(SP, 1 * kWordSize));
- __ addiu(SP, SP, Immediate(2 * kWordSize));
- // Restore T0.
- __ lw(T0, FieldAddress(T2, Function::code_offset()));
-
- // Remove the stub frame as we are about to jump to the closure function.
- __ LeaveStubFrame();
-
__ Bind(&function_compiled);
- // T0: Code.
- // S4: Arguments descriptor array.
- __ lw(T0, FieldAddress(T0, Code::instructions_offset()));
- __ AddImmediate(T0, Instructions::HeaderSize() - kHeapObjectTag);
- __ jr(T0);
+ __ lw(T2, FieldAddress(T2, Code::instructions_offset()));
+ __ AddImmediate(T2, Instructions::HeaderSize() - kHeapObjectTag);
+ __ jr(T2);
__ Bind(&not_closure);
// Call runtime to attempt to resolve and invoke a call method on a
@@ -1738,24 +1717,14 @@
__ sw(T1, Address(T0, count_offset));
__ Bind(&call_target_function);
- // T3: Target function.
+ // T0 <- T3: Target function.
+ __ mov(T0, T3);
Label is_compiled;
__ lw(T4, FieldAddress(T3, Function::code_offset()));
if (FLAG_collect_code) {
__ BranchNotEqual(T4, reinterpret_cast<int32_t>(Object::null()),
&is_compiled);
- __ EnterStubFrame();
- __ addiu(SP, SP, Immediate(-3 * kWordSize));
- __ sw(S5, Address(SP, 2 * kWordSize)); // Preserve IC data.
- __ sw(S4, Address(SP, 1 * kWordSize)); // Preserve arg desc.
- __ sw(T3, Address(SP, 0 * kWordSize)); // Function argument.
- __ CallRuntime(kCompileFunctionRuntimeEntry, 1);
- __ lw(T3, Address(SP, 0 * kWordSize)); // Restore Function.
- __ lw(S4, Address(SP, 1 * kWordSize)); // Restore arg desc.
- __ lw(S5, Address(SP, 2 * kWordSize)); // Restore IC data.
- __ addiu(SP, SP, Immediate(3 * kWordSize));
- __ LeaveStubFrame();
- __ lw(T4, FieldAddress(T3, Function::code_offset()));
+ __ Branch(&StubCode::LazyCompileLabel());
__ Bind(&is_compiled);
}
__ lw(T3, FieldAddress(T4, Code::instructions_offset()));
@@ -1900,36 +1869,22 @@
__ Bind(&increment_done);
+ // Load arguments descriptor into S4.
+ __ lw(S4, FieldAddress(S5, ICData::arguments_descriptor_offset()));
+
Label target_is_compiled;
// Get function and call it, if possible.
- __ lw(T3, Address(T0, target_offset));
- __ lw(T4, FieldAddress(T3, Function::code_offset()));
+ __ lw(T0, Address(T0, target_offset));
+ __ lw(T4, FieldAddress(T0, Function::code_offset()));
__ LoadImmediate(CMPRES1, reinterpret_cast<intptr_t>(Object::null()));
__ bne(T4, CMPRES1, &target_is_compiled);
+ __ Branch(&StubCode::LazyCompileLabel());
- __ 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, 1);
- __ 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()));
}
@@ -1940,11 +1895,11 @@
}
-// Stub for calling the CompileFunction runtime call.
+// Stub for compiling a function and jumping to the compiled code.
// S5: IC-Data.
// S4: Arguments descriptor.
// T0: Function.
-void StubCode::GenerateCompileFunctionRuntimeCallStub(Assembler* assembler) {
+void StubCode::GenerateLazyCompileStub(Assembler* assembler) {
__ EnterStubFrame();
__ addiu(SP, SP, Immediate(-3 * kWordSize));
__ sw(S5, Address(SP, 2 * kWordSize)); // Preserve IC data object.
@@ -1954,6 +1909,44 @@
__ lw(T0, Address(SP, 0 * kWordSize)); // Restore function.
__ lw(S4, Address(SP, 1 * kWordSize)); // Restore args descriptor array.
__ lw(S5, Address(SP, 2 * kWordSize)); // Restore IC data array.
+ __ LeaveStubFrame();
+
+ __ lw(T2, FieldAddress(T0, Function::code_offset()));
+ __ lw(T2, FieldAddress(T2, Code::instructions_offset()));
+ __ AddImmediate(T2, Instructions::HeaderSize() - kHeapObjectTag);
+ __ jr(T2);
+}
+
+
+// Stub for compiling a closure and jumping to the compiled code.
+// S5: IC-Data.
+// S4: Arguments descriptor.
+// T0: Function.
+void StubCode::GenerateLazyCompileClosureStub(Assembler* assembler) {
+ __ EnterStubFrame();
+ __ addiu(SP, SP, Immediate(-3 * kWordSize));
+ __ sw(S4, Address(SP, 1 * kWordSize)); // Preserve args descriptor array.
+ __ sw(T0, Address(SP, 0 * kWordSize)); // Pass function.
+ __ CallRuntime(kCompileFunctionRuntimeEntry, 1);
+ __ lw(T0, Address(SP, 0 * kWordSize)); // Restore function.
+ __ lw(S4, Address(SP, 1 * kWordSize)); // Restore args descriptor array.
+ __ LeaveStubFrame();
+
+ __ lw(T2, FieldAddress(T0, Function::code_offset()));
+ __ lw(T2, FieldAddress(T2, Code::instructions_offset()));
+ __ AddImmediate(T2, Instructions::HeaderSize() - kHeapObjectTag);
+ __ jr(T2);
+}
+
+
+// Stub for calling the CompileFunction runtime call.
+// T0: Function.
+void StubCode::GenerateCompileFunctionRuntimeCallStub(Assembler* assembler) {
+ __ EnterStubFrame();
+ __ addiu(SP, SP, Immediate(-2 * kWordSize));
+ __ sw(T0, Address(SP, 0 * kWordSize)); // Pass function.
+ __ CallRuntime(kCompileFunctionRuntimeEntry, 1);
+ __ lw(T0, Address(SP, 0 * kWordSize)); // Restore function.
__ LeaveStubFrameAndReturn();
}

Powered by Google App Engine
This is Rietveld 408576698