Commit f3f940f4 authored by mbrandy's avatar mbrandy Committed by Commit bot

PPC: [Interpreter] Add CallRuntime support to the interpreter.

Port 75f6ad74

Original commit message:
    Adds support for calling runtime functions from the interpreter. Adds the
    CallRuntime bytecode which takes a Runtime::FunctionId of the function to call
    and the arguments in sequential registers. Adds a InterpreterCEntry builtin
    to enable the interpreter to enter C++ code based on the functionId.

    Also renames Builtin::PushArgsAndCall to Builtin::InterpreterPushArgsAndCall
    and groups all the interpreter builtins together.

R=rmcilroy@chromium.org, joransiu@ca.ibm.com, jyan@ca.ibm.com, michael_dawson@ca.ibm.com, dstence@us.ibm.com
BUG=v8:4280
LOG=N

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

Cr-Commit-Position: refs/heads/master@{#31098}
parent 871529b4
......@@ -956,6 +956,32 @@ void Builtins::Generate_InterpreterExitTrampoline(MacroAssembler* masm) {
}
// static
void Builtins::Generate_InterpreterPushArgsAndCall(MacroAssembler* masm) {
// ----------- S t a t e -------------
// -- r3 : the number of arguments (not including the receiver)
// -- r5 : the address of the first argument to be pushed. Subsequent
// arguments should be consecutive above this, in the same order as
// they are to be pushed onto the stack.
// -- r4 : the target to call (can be any Object).
// Calculate number of arguments (add one for receiver).
__ addi(r6, r3, Operand(1));
// Push the arguments.
Label loop;
__ addi(r5, r5, Operand(kPointerSize)); // Bias up for LoadPU
__ mtctr(r6);
__ bind(&loop);
__ LoadPU(r6, MemOperand(r5, -kPointerSize));
__ push(r6);
__ bdnz(&loop);
// Call the target.
__ Jump(masm->isolate()->builtins()->Call(), RelocInfo::CODE_TARGET);
}
void Builtins::Generate_CompileLazy(MacroAssembler* masm) {
CallRuntimePassFunction(masm, Runtime::kCompileLazy);
GenerateTailCallToReturnedCode(masm);
......@@ -1719,32 +1745,6 @@ void Builtins::Generate_Construct(MacroAssembler* masm) {
}
// static
void Builtins::Generate_PushArgsAndCall(MacroAssembler* masm) {
// ----------- S t a t e -------------
// -- r3 : the number of arguments (not including the receiver)
// -- r5 : the address of the first argument to be pushed. Subsequent
// arguments should be consecutive above this, in the same order as
// they are to be pushed onto the stack.
// -- r4 : the target to call (can be any Object).
// Calculate number of arguments (add one for receiver).
__ addi(r6, r3, Operand(1));
// Push the arguments.
Label loop;
__ addi(r5, r5, Operand(kPointerSize)); // Bias up for LoadPU
__ mtctr(r6);
__ bind(&loop);
__ LoadPU(r6, MemOperand(r5, -kPointerSize));
__ push(r6);
__ bdnz(&loop);
// Call the target.
__ Jump(masm->isolate()->builtins()->Call(), RelocInfo::CODE_TARGET);
}
void Builtins::Generate_ArgumentsAdaptorTrampoline(MacroAssembler* masm) {
// ----------- S t a t e -------------
// -- r3 : actual number of arguments
......
......@@ -1034,15 +1034,22 @@ void CEntryStub::Generate(MacroAssembler* masm) {
// fp: frame pointer (restored after C call)
// sp: stack pointer (restored as callee's sp after C call)
// cp: current context (C callee-saved)
//
// If argv_in_register():
// r5: pointer to the first argument
ProfileEntryHookStub::MaybeCallEntryHook(masm);
__ mr(r15, r4);
// Compute the argv pointer.
__ ShiftLeftImm(r4, r3, Operand(kPointerSizeLog2));
__ add(r4, r4, sp);
__ subi(r4, r4, Operand(kPointerSize));
if (argv_in_register()) {
// Move argv into the correct register.
__ mr(r4, r5);
} else {
// Compute the argv pointer.
__ ShiftLeftImm(r4, r3, Operand(kPointerSizeLog2));
__ add(r4, r4, sp);
__ subi(r4, r4, Operand(kPointerSize));
}
// Enter the exit frame that transitions from JavaScript to C++.
FrameScope scope(masm, StackFrame::MANUAL);
......@@ -1141,8 +1148,15 @@ void CEntryStub::Generate(MacroAssembler* masm) {
// r3:r4: result
// sp: stack pointer
// fp: frame pointer
// r14: still holds argc (callee-saved).
__ LeaveExitFrame(save_doubles(), r14, true);
Register argc;
if (argv_in_register()) {
// We don't want to pop arguments so set argc to no_reg.
argc = no_reg;
} else {
// r14: still holds argc (callee-saved).
argc = r14;
}
__ LeaveExitFrame(save_doubles(), argc, true);
__ blr();
// Handling of exception.
......
......@@ -391,15 +391,26 @@ void MathRoundVariantCallFromOptimizedCodeDescriptor::
}
void PushArgsAndCallDescriptor::InitializePlatformSpecific(
void InterpreterPushArgsAndCallDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {
r3, // argument count (including receiver)
r3, // argument count (not including receiver)
r5, // address of first argument
r4 // the target callable to be call
};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void InterpreterCEntryDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {
r3, // argument count (argc)
r5, // address of first argument (argv)
r4 // the runtime function to call
};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
} // namespace internal
} // namespace v8
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment