Simplify dispatch in optimizing compile stubs.

This is to re-establish a single choke point for lazy compile stubs in
preparation for CallRuntimePassFunction being changed soon.

R=bmeurer@chromium.org

Review URL: https://codereview.chromium.org/1456003003

Cr-Commit-Position: refs/heads/master@{#32095}
This commit is contained in:
mstarzinger 2015-11-18 11:34:02 -08:00 committed by Commit bot
parent c91bcf7192
commit c0bf04b119
10 changed files with 46 additions and 159 deletions

View File

@ -1014,31 +1014,14 @@ void Builtins::Generate_CompileLazy(MacroAssembler* masm) {
}
static void CallCompileOptimized(MacroAssembler* masm, bool concurrent) {
FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL);
// Push a copy of the function onto the stack.
__ push(r1);
// Push function as parameter to the runtime call.
__ Push(r1);
// Whether to compile in a background thread.
__ LoadRoot(
ip, concurrent ? Heap::kTrueValueRootIndex : Heap::kFalseValueRootIndex);
__ push(ip);
__ CallRuntime(Runtime::kCompileOptimized, 2);
// Restore receiver.
__ pop(r1);
}
void Builtins::Generate_CompileOptimized(MacroAssembler* masm) {
CallCompileOptimized(masm, false);
CallRuntimePassFunction(masm, Runtime::kCompileOptimized_NotConcurrent);
GenerateTailCallToReturnedCode(masm);
}
void Builtins::Generate_CompileOptimizedConcurrent(MacroAssembler* masm) {
CallCompileOptimized(masm, true);
CallRuntimePassFunction(masm, Runtime::kCompileOptimized_Concurrent);
GenerateTailCallToReturnedCode(masm);
}

View File

@ -984,30 +984,14 @@ void Builtins::Generate_CompileLazy(MacroAssembler* masm) {
}
static void CallCompileOptimized(MacroAssembler* masm, bool concurrent) {
FrameScope scope(masm, StackFrame::INTERNAL);
Register function = x1;
// Preserve function. At the same time, push arguments for
// kCompileOptimized.
__ LoadObject(x10, masm->isolate()->factory()->ToBoolean(concurrent));
__ Push(function, function, x10);
__ CallRuntime(Runtime::kCompileOptimized, 2);
// Restore receiver.
__ Pop(function);
}
void Builtins::Generate_CompileOptimized(MacroAssembler* masm) {
CallCompileOptimized(masm, false);
CallRuntimePassFunction(masm, Runtime::kCompileOptimized_NotConcurrent);
GenerateTailCallToReturnedCode(masm);
}
void Builtins::Generate_CompileOptimizedConcurrent(MacroAssembler* masm) {
CallCompileOptimized(masm, true);
CallRuntimePassFunction(masm, Runtime::kCompileOptimized_Concurrent);
GenerateTailCallToReturnedCode(masm);
}

View File

@ -788,29 +788,14 @@ void Builtins::Generate_CompileLazy(MacroAssembler* masm) {
}
static void CallCompileOptimized(MacroAssembler* masm, bool concurrent) {
FrameScope scope(masm, StackFrame::INTERNAL);
// Push a copy of the function.
__ push(edi);
// Function is also the parameter to the runtime call.
__ push(edi);
// Whether to compile in a background thread.
__ Push(masm->isolate()->factory()->ToBoolean(concurrent));
__ CallRuntime(Runtime::kCompileOptimized, 2);
// Restore receiver.
__ pop(edi);
}
void Builtins::Generate_CompileOptimized(MacroAssembler* masm) {
CallCompileOptimized(masm, false);
CallRuntimePassFunction(masm, Runtime::kCompileOptimized_NotConcurrent);
GenerateTailCallToReturnedCode(masm);
}
void Builtins::Generate_CompileOptimizedConcurrent(MacroAssembler* masm) {
CallCompileOptimized(masm, true);
CallRuntimePassFunction(masm, Runtime::kCompileOptimized_Concurrent);
GenerateTailCallToReturnedCode(masm);
}

View File

@ -1020,35 +1020,18 @@ void Builtins::Generate_CompileLazy(MacroAssembler* masm) {
}
static void CallCompileOptimized(MacroAssembler* masm, bool concurrent) {
FrameScope scope(masm, StackFrame::INTERNAL);
// Push a copy of the function onto the stack.
// Push function as parameter to the runtime call.
__ Push(a1, a1);
// Whether to compile in a background thread.
__ LoadRoot(
at, concurrent ? Heap::kTrueValueRootIndex : Heap::kFalseValueRootIndex);
__ push(at);
__ CallRuntime(Runtime::kCompileOptimized, 2);
// Restore receiver.
__ Pop(a1);
}
void Builtins::Generate_CompileOptimized(MacroAssembler* masm) {
CallCompileOptimized(masm, false);
CallRuntimePassFunction(masm, Runtime::kCompileOptimized_NotConcurrent);
GenerateTailCallToReturnedCode(masm);
}
void Builtins::Generate_CompileOptimizedConcurrent(MacroAssembler* masm) {
CallCompileOptimized(masm, true);
CallRuntimePassFunction(masm, Runtime::kCompileOptimized_Concurrent);
GenerateTailCallToReturnedCode(masm);
}
static void GenerateMakeCodeYoungAgainCommon(MacroAssembler* masm) {
// For now, we are relying on the fact that make_code_young doesn't do any
// garbage collection which allows us to save/restore the registers without

View File

@ -1015,30 +1015,14 @@ void Builtins::Generate_CompileLazy(MacroAssembler* masm) {
}
static void CallCompileOptimized(MacroAssembler* masm, bool concurrent) {
FrameScope scope(masm, StackFrame::INTERNAL);
// Push a copy of the function onto the stack.
// Push function as parameter to the runtime call.
__ Push(a1, a1);
// Whether to compile in a background thread.
__ LoadRoot(
at, concurrent ? Heap::kTrueValueRootIndex : Heap::kFalseValueRootIndex);
__ push(at);
__ CallRuntime(Runtime::kCompileOptimized, 2);
// Restore receiver.
__ Pop(a1);
}
void Builtins::Generate_CompileOptimized(MacroAssembler* masm) {
CallCompileOptimized(masm, false);
CallRuntimePassFunction(masm, Runtime::kCompileOptimized_NotConcurrent);
GenerateTailCallToReturnedCode(masm);
}
void Builtins::Generate_CompileOptimizedConcurrent(MacroAssembler* masm) {
CallCompileOptimized(masm, true);
CallRuntimePassFunction(masm, Runtime::kCompileOptimized_Concurrent);
GenerateTailCallToReturnedCode(masm);
}

View File

@ -1015,30 +1015,14 @@ void Builtins::Generate_CompileLazy(MacroAssembler* masm) {
}
static void CallCompileOptimized(MacroAssembler* masm, bool concurrent) {
FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL);
// Push a copy of the function onto the stack.
// Push function as parameter to the runtime call.
__ Push(r4, r4);
// Whether to compile in a background thread.
__ LoadRoot(
r0, concurrent ? Heap::kTrueValueRootIndex : Heap::kFalseValueRootIndex);
__ push(r0);
__ CallRuntime(Runtime::kCompileOptimized, 2);
// Restore receiver.
__ pop(r4);
}
void Builtins::Generate_CompileOptimized(MacroAssembler* masm) {
CallCompileOptimized(masm, false);
CallRuntimePassFunction(masm, Runtime::kCompileOptimized_NotConcurrent);
GenerateTailCallToReturnedCode(masm);
}
void Builtins::Generate_CompileOptimizedConcurrent(MacroAssembler* masm) {
CallCompileOptimized(masm, true);
CallRuntimePassFunction(masm, Runtime::kCompileOptimized_Concurrent);
GenerateTailCallToReturnedCode(masm);
}

View File

@ -44,17 +44,13 @@ RUNTIME_FUNCTION(Runtime_CompileLazy) {
}
RUNTIME_FUNCTION(Runtime_CompileOptimized) {
HandleScope scope(isolate);
DCHECK(args.length() == 2);
CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0);
CONVERT_BOOLEAN_ARG_CHECKED(concurrent, 1);
namespace {
Object* CompileOptimized(Isolate* isolate, Handle<JSFunction> function,
Compiler::ConcurrencyMode mode) {
StackLimitCheck check(isolate);
if (check.JsHasOverflowed(1 * KB)) return isolate->StackOverflow();
Compiler::ConcurrencyMode mode =
concurrent ? Compiler::CONCURRENT : Compiler::NOT_CONCURRENT;
Handle<Code> code;
Handle<Code> unoptimized(function->shared()->code());
if (Compiler::GetOptimizedCode(function, unoptimized, mode).ToHandle(&code)) {
@ -80,6 +76,24 @@ RUNTIME_FUNCTION(Runtime_CompileOptimized) {
return function->code();
}
} // namespace
RUNTIME_FUNCTION(Runtime_CompileOptimized_Concurrent) {
HandleScope scope(isolate);
DCHECK(args.length() == 1);
CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0);
return CompileOptimized(isolate, function, Compiler::CONCURRENT);
}
RUNTIME_FUNCTION(Runtime_CompileOptimized_NotConcurrent) {
HandleScope scope(isolate);
DCHECK(args.length() == 1);
CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0);
return CompileOptimized(isolate, function, Compiler::NOT_CONCURRENT);
}
RUNTIME_FUNCTION(Runtime_NotifyStubFailure) {
HandleScope scope(isolate);

View File

@ -127,7 +127,8 @@ namespace internal {
#define FOR_EACH_INTRINSIC_COMPILER(F) \
F(CompileLazy, 1, 1) \
F(CompileOptimized, 2, 1) \
F(CompileOptimized_Concurrent, 1, 1) \
F(CompileOptimized_NotConcurrent, 1, 1) \
F(NotifyStubFailure, 0, 1) \
F(NotifyDeoptimized, 1, 1) \
F(CompileForOnStackReplacement, 1, 1) \

View File

@ -840,30 +840,14 @@ void Builtins::Generate_CompileLazy(MacroAssembler* masm) {
}
static void CallCompileOptimized(MacroAssembler* masm,
bool concurrent) {
FrameScope scope(masm, StackFrame::INTERNAL);
// Push a copy of the function onto the stack.
__ Push(rdi);
// Function is also the parameter to the runtime call.
__ Push(rdi);
// Whether to compile in a background thread.
__ Push(masm->isolate()->factory()->ToBoolean(concurrent));
__ CallRuntime(Runtime::kCompileOptimized, 2);
// Restore receiver.
__ Pop(rdi);
}
void Builtins::Generate_CompileOptimized(MacroAssembler* masm) {
CallCompileOptimized(masm, false);
CallRuntimePassFunction(masm, Runtime::kCompileOptimized_NotConcurrent);
GenerateTailCallToReturnedCode(masm);
}
void Builtins::Generate_CompileOptimizedConcurrent(MacroAssembler* masm) {
CallCompileOptimized(masm, true);
CallRuntimePassFunction(masm, Runtime::kCompileOptimized_Concurrent);
GenerateTailCallToReturnedCode(masm);
}

View File

@ -788,29 +788,14 @@ void Builtins::Generate_CompileLazy(MacroAssembler* masm) {
}
static void CallCompileOptimized(MacroAssembler* masm, bool concurrent) {
FrameScope scope(masm, StackFrame::INTERNAL);
// Push a copy of the function.
__ push(edi);
// Function is also the parameter to the runtime call.
__ push(edi);
// Whether to compile in a background thread.
__ Push(masm->isolate()->factory()->ToBoolean(concurrent));
__ CallRuntime(Runtime::kCompileOptimized, 2);
// Restore receiver.
__ pop(edi);
}
void Builtins::Generate_CompileOptimized(MacroAssembler* masm) {
CallCompileOptimized(masm, false);
CallRuntimePassFunction(masm, Runtime::kCompileOptimized_NotConcurrent);
GenerateTailCallToReturnedCode(masm);
}
void Builtins::Generate_CompileOptimizedConcurrent(MacroAssembler* masm) {
CallCompileOptimized(masm, true);
CallRuntimePassFunction(masm, Runtime::kCompileOptimized_Concurrent);
GenerateTailCallToReturnedCode(masm);
}