Revision: 5244
Author: [email protected]
Date: Wed Aug 11 06:48:58 2010
Log: Change lazy compilation stub to a builtin.
This change changes the lazy compilation stub to a builtin and
eliminates the argc (argument count for the function for which to
create a lazy stub) parameter.
Review URL: http://codereview.chromium.org/3146008
http://code.google.com/p/v8/source/detail?r=5244
Modified:
/branches/bleeding_edge/src/arm/builtins-arm.cc
/branches/bleeding_edge/src/arm/stub-cache-arm.cc
/branches/bleeding_edge/src/builtins.h
/branches/bleeding_edge/src/compiler.cc
/branches/bleeding_edge/src/handles.cc
/branches/bleeding_edge/src/handles.h
/branches/bleeding_edge/src/heap.cc
/branches/bleeding_edge/src/ia32/builtins-ia32.cc
/branches/bleeding_edge/src/ia32/stub-cache-ia32.cc
/branches/bleeding_edge/src/objects-inl.h
/branches/bleeding_edge/src/stub-cache.cc
/branches/bleeding_edge/src/stub-cache.h
/branches/bleeding_edge/src/x64/builtins-x64.cc
/branches/bleeding_edge/src/x64/stub-cache-x64.cc
=======================================
--- /branches/bleeding_edge/src/arm/builtins-arm.cc Wed Aug 11 01:12:53 2010
+++ /branches/bleeding_edge/src/arm/builtins-arm.cc Wed Aug 11 06:48:58 2010
@@ -909,6 +909,29 @@
void Builtins::Generate_JSConstructEntryTrampoline(MacroAssembler* masm) {
Generate_JSEntryTrampolineHelper(masm, true);
}
+
+
+void Builtins::Generate_LazyCompile(MacroAssembler* masm) {
+ // Enter an internal frame.
+ __ EnterInternalFrame();
+
+ // Preserve the function.
+ __ push(r1);
+
+ // Push the function on the stack as the argument to the runtime
function.
+ __ push(r1);
+ __ CallRuntime(Runtime::kLazyCompile, 1);
+ // Calculate the entry point.
+ __ add(r2, r0, Operand(Code::kHeaderSize - kHeapObjectTag));
+ // Restore saved function.
+ __ pop(r1);
+
+ // Tear down temporary frame.
+ __ LeaveInternalFrame();
+
+ // Do a tail-call of the compiled function.
+ __ Jump(r2);
+}
void Builtins::Generate_FunctionCall(MacroAssembler* masm) {
=======================================
--- /branches/bleeding_edge/src/arm/stub-cache-arm.cc Fri Aug 6 01:49:59
2010
+++ /branches/bleeding_edge/src/arm/stub-cache-arm.cc Wed Aug 11 06:48:58
2010
@@ -1210,38 +1210,6 @@
__ TailCallExternalReference(ref, 5, 1);
}
}
-
-
-Object* StubCompiler::CompileLazyCompile(Code::Flags flags) {
- // ----------- S t a t e -------------
- // -- r1: function
- // -- lr: return address
- // -----------------------------------
-
- // Enter an internal frame.
- __ EnterInternalFrame();
-
- // Preserve the function.
- __ push(r1);
-
- // Push the function on the stack as the argument to the runtime
function.
- __ push(r1);
- __ CallRuntime(Runtime::kLazyCompile, 1);
-
- // Calculate the entry point.
- __ add(r2, r0, Operand(Code::kHeaderSize - kHeapObjectTag));
-
- // Restore saved function.
- __ pop(r1);
-
- // Tear down temporary frame.
- __ LeaveInternalFrame();
-
- // Do a tail-call of the compiled function.
- __ Jump(r2);
-
- return GetCodeWithFlags(flags, "LazyCompileStub");
-}
void CallStubCompiler::GenerateNameCheck(String* name, Label* miss) {
=======================================
--- /branches/bleeding_edge/src/builtins.h Wed Jun 30 05:27:49 2010
+++ /branches/bleeding_edge/src/builtins.h Wed Aug 11 06:48:58 2010
@@ -69,6 +69,7 @@
V(JSConstructStubApi, BUILTIN, UNINITIALIZED) \
V(JSEntryTrampoline, BUILTIN, UNINITIALIZED) \
V(JSConstructEntryTrampoline, BUILTIN, UNINITIALIZED) \
+ V(LazyCompile, BUILTIN, UNINITIALIZED) \
\
V(LoadIC_Miss, BUILTIN, UNINITIALIZED) \
V(KeyedLoadIC_Miss, BUILTIN, UNINITIALIZED) \
@@ -249,6 +250,7 @@
static void Generate_JSConstructStubApi(MacroAssembler* masm);
static void Generate_JSEntryTrampoline(MacroAssembler* masm);
static void Generate_JSConstructEntryTrampoline(MacroAssembler* masm);
+ static void Generate_LazyCompile(MacroAssembler* masm);
static void Generate_ArgumentsAdaptorTrampoline(MacroAssembler* masm);
static void Generate_FunctionCall(MacroAssembler* masm);
=======================================
--- /branches/bleeding_edge/src/compiler.cc Sun Jul 18 23:29:30 2010
+++ /branches/bleeding_edge/src/compiler.cc Wed Aug 11 06:48:58 2010
@@ -494,7 +494,7 @@
// Generate code
Handle<Code> code;
if (FLAG_lazy && allow_lazy) {
- code = ComputeLazyCompile(literal->num_parameters());
+ code = Handle<Code>(Builtins::builtin(Builtins::LazyCompile));
} else {
// The bodies of function literals have not yet been visited by
// the AST optimizer/analyzer.
=======================================
--- /branches/bleeding_edge/src/handles.cc Wed Aug 11 01:12:53 2010
+++ /branches/bleeding_edge/src/handles.cc Wed Aug 11 06:48:58 2010
@@ -817,11 +817,6 @@
has_been_transformed_ = false;
}
}
-
-
-Handle<Code> ComputeLazyCompile(int argc) {
- CALL_HEAP_FUNCTION(StubCache::ComputeLazyCompile(argc), Code);
-}
OptimizedObjectForAddingMultipleProperties::
=======================================
--- /branches/bleeding_edge/src/handles.h Wed Jun 30 00:40:40 2010
+++ /branches/bleeding_edge/src/handles.h Wed Aug 11 06:48:58 2010
@@ -353,9 +353,6 @@
Handle<Object> receiver,
ClearExceptionFlag flag);
-// Returns the lazy compilation stub for argc arguments.
-Handle<Code> ComputeLazyCompile(int argc);
-
class NoHandleAllocation BASE_EMBEDDED {
public:
#ifndef DEBUG
=======================================
--- /branches/bleeding_edge/src/heap.cc Wed Aug 11 03:52:34 2010
+++ /branches/bleeding_edge/src/heap.cc Wed Aug 11 06:48:58 2010
@@ -2504,8 +2504,7 @@
if (CodeIsActive(shared_info->code())) return;
// Compute the lazy compilable version of the code.
- HandleScope scope;
- Code* code = *ComputeLazyCompile(shared_info->length());
+ Code* code = Builtins::builtin(Builtins::LazyCompile);
shared_info->set_code(code);
function->set_code(code);
}
=======================================
--- /branches/bleeding_edge/src/ia32/builtins-ia32.cc Wed Aug 11 01:12:53
2010
+++ /branches/bleeding_edge/src/ia32/builtins-ia32.cc Wed Aug 11 06:48:58
2010
@@ -427,6 +427,26 @@
void Builtins::Generate_JSConstructEntryTrampoline(MacroAssembler* masm) {
Generate_JSEntryTrampolineHelper(masm, true);
}
+
+
+void Builtins::Generate_LazyCompile(MacroAssembler* masm) {
+ // Enter an internal frame.
+ __ EnterInternalFrame();
+
+ // Push a copy of the function onto the stack.
+ __ push(edi);
+
+ __ push(edi); // Function is also the parameter to the runtime call.
+ __ CallRuntime(Runtime::kLazyCompile, 1);
+ __ pop(edi);
+
+ // Tear down temporary frame.
+ __ LeaveInternalFrame();
+
+ // Do a tail-call of the compiled function.
+ __ lea(ecx, FieldOperand(eax, Code::kHeaderSize));
+ __ jmp(Operand(ecx));
+}
void Builtins::Generate_FunctionCall(MacroAssembler* masm) {
=======================================
--- /branches/bleeding_edge/src/ia32/stub-cache-ia32.cc Fri Aug 6 01:49:59
2010
+++ /branches/bleeding_edge/src/ia32/stub-cache-ia32.cc Wed Aug 11 06:48:58
2010
@@ -1253,30 +1253,6 @@
__ TailCallExternalReference(ref, 5, 1);
}
}
-
-
-// TODO(1241006): Avoid having lazy compile stubs specialized by the
-// number of arguments. It is not needed anymore.
-Object* StubCompiler::CompileLazyCompile(Code::Flags flags) {
- // Enter an internal frame.
- __ EnterInternalFrame();
-
- // Push a copy of the function onto the stack.
- __ push(edi);
-
- __ push(edi); // function is also the parameter to the runtime call
- __ CallRuntime(Runtime::kLazyCompile, 1);
- __ pop(edi);
-
- // Tear down temporary frame.
- __ LeaveInternalFrame();
-
- // Do a tail-call of the compiled function.
- __ lea(ecx, FieldOperand(eax, Code::kHeaderSize));
- __ jmp(Operand(ecx));
-
- return GetCodeWithFlags(flags, "LazyCompileStub");
-}
void CallStubCompiler::GenerateNameCheck(String* name, Label* miss) {
=======================================
--- /branches/bleeding_edge/src/objects-inl.h Wed Aug 11 01:12:53 2010
+++ /branches/bleeding_edge/src/objects-inl.h Wed Aug 11 06:48:58 2010
@@ -2661,8 +2661,7 @@
bool SharedFunctionInfo::is_compiled() {
- // TODO(1242782): Create a code kind for uncompiled code.
- return code()->kind() != Code::STUB;
+ return code() != Builtins::builtin(Builtins::LazyCompile);
}
@@ -2773,7 +2772,7 @@
bool JSFunction::is_compiled() {
- return code()->kind() != Code::STUB;
+ return code() != Builtins::builtin(Builtins::LazyCompile);
}
=======================================
--- /branches/bleeding_edge/src/stub-cache.cc Fri Aug 6 01:49:59 2010
+++ /branches/bleeding_edge/src/stub-cache.cc Wed Aug 11 06:48:58 2010
@@ -789,23 +789,6 @@
#endif
-Object* StubCache::ComputeLazyCompile(int argc) {
- Code::Flags flags =
- Code::ComputeFlags(Code::STUB, NOT_IN_LOOP, UNINITIALIZED, NORMAL,
argc);
- Object* probe = ProbeCache(flags);
- if (!probe->IsUndefined()) return probe;
- StubCompiler compiler;
- Object* result = FillCache(compiler.CompileLazyCompile(flags));
- if (result->IsCode()) {
- Code* code = Code::cast(result);
- USE(code);
- PROFILE(CodeCreateEvent(Logger::LAZY_COMPILE_TAG,
- code, code->arguments_count()));
- }
- return result;
-}
-
-
void StubCache::Clear() {
for (int i = 0; i < kPrimaryTableSize; i++) {
primary_[i].key = Heap::empty_string();
=======================================
--- /branches/bleeding_edge/src/stub-cache.h Fri Aug 6 01:49:59 2010
+++ /branches/bleeding_edge/src/stub-cache.h Wed Aug 11 06:48:58 2010
@@ -210,8 +210,6 @@
static Object* ComputeCallDebugPrepareStepIn(int argc, Code::Kind kind);
#endif
- static Object* ComputeLazyCompile(int argc);
-
// Update cache for entry hash(name, map).
static Code* Set(String* name, Map* map, Code* code);
@@ -357,7 +355,6 @@
Object* CompileCallDebugBreak(Code::Flags flags);
Object* CompileCallDebugPrepareStepIn(Code::Flags flags);
#endif
- Object* CompileLazyCompile(Code::Flags flags);
// Static functions for generating parts of stubs.
static void GenerateLoadGlobalFunctionPrototype(MacroAssembler* masm,
=======================================
--- /branches/bleeding_edge/src/x64/builtins-x64.cc Wed Aug 11 01:12:53 2010
+++ /branches/bleeding_edge/src/x64/builtins-x64.cc Wed Aug 11 06:48:58 2010
@@ -1290,6 +1290,26 @@
void Builtins::Generate_JSConstructEntryTrampoline(MacroAssembler* masm) {
Generate_JSEntryTrampolineHelper(masm, true);
}
+
+
+void Builtins::Generate_LazyCompile(MacroAssembler* masm) {
+ // Enter an internal frame.
+ __ EnterInternalFrame();
+
+ // Push a copy of the function onto the stack.
+ __ push(rdi);
+
+ __ push(rdi); // Function is also the parameter to the runtime call.
+ __ CallRuntime(Runtime::kLazyCompile, 1);
+ __ pop(rdi);
+
+ // Tear down temporary frame.
+ __ LeaveInternalFrame();
+
+ // Do a tail-call of the compiled function.
+ __ lea(rcx, FieldOperand(rax, Code::kHeaderSize));
+ __ jmp(rcx);
+}
} } // namespace v8::internal
=======================================
--- /branches/bleeding_edge/src/x64/stub-cache-x64.cc Fri Aug 6 01:49:59
2010
+++ /branches/bleeding_edge/src/x64/stub-cache-x64.cc Wed Aug 11 06:48:58
2010
@@ -2037,30 +2037,6 @@
// Return the generated code.
return GetCode(transition == NULL ? FIELD : MAP_TRANSITION, name);
}
-
-
-// TODO(1241006): Avoid having lazy compile stubs specialized by the
-// number of arguments. It is not needed anymore.
-Object* StubCompiler::CompileLazyCompile(Code::Flags flags) {
- // Enter an internal frame.
- __ EnterInternalFrame();
-
- // Push a copy of the function onto the stack.
- __ push(rdi);
-
- __ push(rdi); // function is also the parameter to the runtime call
- __ CallRuntime(Runtime::kLazyCompile, 1);
- __ pop(rdi);
-
- // Tear down temporary frame.
- __ LeaveInternalFrame();
-
- // Do a tail-call of the compiled function.
- __ lea(rcx, FieldOperand(rax, Code::kHeaderSize));
- __ jmp(rcx);
-
- return GetCodeWithFlags(flags, "LazyCompileStub");
-}
void StubCompiler::GenerateLoadInterceptor(JSObject* object,
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev