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

Unified Diff: runtime/vm/stub_code_x64.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
« runtime/vm/raw_object.cc ('K') | « runtime/vm/stub_code_mips.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/stub_code_x64.cc
===================================================================
--- runtime/vm/stub_code_x64.cc (revision 34118)
+++ runtime/vm/stub_code_x64.cc (working copy)
@@ -760,41 +760,20 @@
__ j(EQUAL, &not_closure, Assembler::kNearJump);
// RAX is just the signature function. Load the actual closure function.
- __ movq(RBX, FieldAddress(R13, Closure::function_offset()));
+ __ movq(RAX, FieldAddress(R13, Closure::function_offset()));
// Load closure context in CTX; note that CTX has already been preserved.
__ movq(CTX, FieldAddress(R13, Closure::context_offset()));
// Load closure function code in RAX.
- __ movq(RAX, FieldAddress(RBX, Function::code_offset()));
- __ cmpq(RAX, R12);
- Label function_compiled;
- __ j(NOT_EQUAL, &function_compiled, Assembler::kNearJump);
+ __ movq(RBX, FieldAddress(RAX, Function::code_offset()));
- // Create a stub frame as we are pushing some objects on the stack before
- // calling into the runtime.
- __ EnterStubFrame();
-
- __ pushq(R10); // Preserve arguments descriptor array.
- __ pushq(RBX); // Preserve read-only function object argument.
- __ CallRuntime(kCompileFunctionRuntimeEntry, 1);
- __ popq(RBX); // Restore read-only function object argument in RBX.
- __ popq(R10); // Restore arguments descriptor array.
- // Restore RAX.
- __ movq(RAX, FieldAddress(RBX, Function::code_offset()));
-
- // Remove the stub frame as we are about to jump to the closure function.
- __ LeaveStubFrame();
-
- __ Bind(&function_compiled);
- // RAX: Code.
- // RBX: Function.
+ // RAX: Function.
// R10: Arguments descriptor array.
+ __ movq(RCX, FieldAddress(RBX, Code::instructions_offset()));
+ __ addq(RCX, Immediate(Instructions::HeaderSize() - kHeapObjectTag));
+ __ jmp(RCX);
- __ movq(RBX, FieldAddress(RAX, Code::instructions_offset()));
- __ addq(RBX, Immediate(Instructions::HeaderSize() - kHeapObjectTag));
- __ jmp(RBX);
-
__ Bind(&not_closure);
// Call runtime to attempt to resolve and invoke a call method on a
// non-closure object, passing the non-closure object and its arguments array,
@@ -1497,18 +1476,7 @@
if (FLAG_collect_code) {
// If code might be GC'd, then RBX might be null. If it is, recompile.
__ CompareObject(RCX, Object::null_object(), PP);
- __ j(NOT_EQUAL, &is_compiled, Assembler::kNearJump);
- __ EnterStubFrame();
- __ pushq(R10); // Preserve arguments descriptor array.
- __ pushq(RBX); // Preserve IC data object.
- __ pushq(RAX); // Pass function.
- __ CallRuntime(kCompileFunctionRuntimeEntry, 1);
- __ popq(RAX); // Restore function.
- __ popq(RBX); // Restore IC data array.
- __ popq(R10); // Restore arguments descriptor array.
- __ LeaveStubFrame();
- __ movq(RCX, FieldAddress(RAX, Function::code_offset()));
- __ Bind(&is_compiled);
+ __ j(EQUAL, &StubCode::LazyCompileLabel());
}
__ movq(RAX, FieldAddress(RCX, Code::instructions_offset()));
__ addq(RAX, Immediate(Instructions::HeaderSize() - kHeapObjectTag));
@@ -1655,55 +1623,77 @@
Immediate(Smi::RawValue(Smi::kMaxValue)));
__ Bind(&increment_done);
- Label target_is_compiled;
+ // Load arguments descriptor into R10.
+ __ movq(R10, FieldAddress(RBX, ICData::arguments_descriptor_offset()));
+
// Get function and call it, if possible.
- __ movq(R13, Address(R12, target_offset));
- __ movq(RAX, FieldAddress(R13, Function::code_offset()));
- __ LoadObject(R12, Object::null_object(), PP);
- __ cmpq(RAX, R12);
- __ j(NOT_EQUAL, &target_is_compiled, Assembler::kNearJump);
+ __ movq(RAX, Address(R12, target_offset));
+ __ movq(RCX, FieldAddress(RAX, Function::code_offset()));
+ __ CompareObject(RCX, Object::null_object(), PP);
+ __ j(EQUAL, &StubCode::LazyCompileLabel());
+ // RCX: Target code.
+ __ movq(RAX, FieldAddress(RCX, Code::instructions_offset()));
+ __ addq(RAX, Immediate(Instructions::HeaderSize() - kHeapObjectTag));
+ __ jmp(RAX);
+}
+
+
+void StubCode::GenerateTwoArgsUnoptimizedStaticCallStub(Assembler* assembler) {
+ GenerateUsageCounterIncrement(assembler, RCX);
+ GenerateNArgsCheckInlineCacheStub(
+ assembler, 2, kStaticCallMissHandlerTwoArgsRuntimeEntry);
+}
+
+
+// Stub for compiling a function and jumping to the compiled code.
+// RCX: IC-Data.
+// R10: Arguments descriptor.
+// RAX: Function.
+void StubCode::GenerateLazyCompileStub(Assembler* assembler) {
__ EnterStubFrame();
- __ pushq(R13); // Preserve target function.
+ __ pushq(R10); // Preserve arguments descriptor array.
__ pushq(RBX); // Preserve IC data object.
- __ pushq(R13); // Pass function.
+ __ pushq(RAX); // Pass function.
__ CallRuntime(kCompileFunctionRuntimeEntry, 1);
- __ popq(RAX); // Discard argument.
- __ popq(RBX); // Restore IC data object.
- __ popq(R13); // Restore target function.
+ __ popq(RAX); // Restore function.
+ __ popq(RBX); // Restore IC data array.
+ __ popq(R10); // Restore arguments descriptor array.
__ LeaveStubFrame();
- __ movq(RAX, FieldAddress(R13, Function::code_offset()));
- __ Bind(&target_is_compiled);
- // RAX: Target code.
+ __ movq(RAX, FieldAddress(RAX, Function::code_offset()));
__ movq(RAX, FieldAddress(RAX, Code::instructions_offset()));
__ addq(RAX, Immediate(Instructions::HeaderSize() - kHeapObjectTag));
- // Load arguments descriptor into R10.
- __ movq(R10, FieldAddress(RBX, ICData::arguments_descriptor_offset()));
__ jmp(RAX);
}
-void StubCode::GenerateTwoArgsUnoptimizedStaticCallStub(Assembler* assembler) {
- GenerateUsageCounterIncrement(assembler, RCX);
- GenerateNArgsCheckInlineCacheStub(
- assembler, 2, kStaticCallMissHandlerTwoArgsRuntimeEntry);
+// Stub for compiling a closure and jumping to the compiled code.
+// R10: Arguments descriptor.
+// RAX: Function.
+void StubCode::GenerateLazyCompileClosureStub(Assembler* assembler) {
+ __ EnterStubFrame();
+ __ pushq(R10); // Preserve arguments descriptor array.
+ __ pushq(RAX); // Pass function.
+ __ CallRuntime(kCompileFunctionRuntimeEntry, 1);
+ __ popq(RAX); // Restore function.
+ __ popq(R10); // Restore arguments descriptor array.
+ __ LeaveStubFrame();
+
+ __ movq(RAX, FieldAddress(RAX, Function::code_offset()));
+ __ movq(RAX, FieldAddress(RAX, Code::instructions_offset()));
+ __ addq(RAX, Immediate(Instructions::HeaderSize() - kHeapObjectTag));
+ __ jmp(RAX);
}
// Stub for calling the CompileFunction runtime call.
-// RCX: IC-Data.
-// RDX: Arguments descriptor.
// RAX: Function.
void StubCode::GenerateCompileFunctionRuntimeCallStub(Assembler* assembler) {
__ EnterStubFrame();
- __ pushq(RDX); // Preserve arguments descriptor array.
- __ pushq(RCX); // Preserve IC data object.
__ pushq(RAX); // Pass function.
__ CallRuntime(kCompileFunctionRuntimeEntry, 1);
__ popq(RAX); // Restore function.
- __ popq(RCX); // Restore IC data array.
- __ popq(RDX); // Restore arguments descriptor array.
__ LeaveStubFrame();
__ ret();
}
« runtime/vm/raw_object.cc ('K') | « runtime/vm/stub_code_mips.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698