Chromium Code Reviews| Index: src/x64/builtins-x64.cc |
| diff --git a/src/x64/builtins-x64.cc b/src/x64/builtins-x64.cc |
| index fb43324d58a0d8fca734d4f1e383b9518a7a15d2..b021f95bc39ee16e3982e1c8611f82d5116e9681 100644 |
| --- a/src/x64/builtins-x64.cc |
| +++ b/src/x64/builtins-x64.cc |
| @@ -90,6 +90,47 @@ static void GenerateTailCallToReturnedCode(MacroAssembler* masm, |
| __ jmp(rbx); |
| } |
| +void Builtins::Generate_InstantiateAsmJs(MacroAssembler* masm) { |
| + // ----------- S t a t e ------------- |
| + // -- rax : argument count (preserved for callee) |
| + // -- rdx : new target (preserved for callee) |
| + // -- rdi : target function (preserved for callee) |
| + // ----------------------------------- |
| + Label failed; |
| + { |
| + FrameScope scope(masm, StackFrame::INTERNAL); |
| + // Push the number of arguments to the callee. |
| + __ Integer32ToSmi(rax, rax); |
| + __ Push(rax); |
| + // Push a copy of the target function and the new target. |
| + __ Push(rdi); |
| + __ Push(rdx); |
| + |
| + // The function. |
| + __ Push(rdi); |
| + // Pick the 'stdlib' from the parent frame. |
| + __ Push(Operand(rsp, 10 * kPointerSize)); |
|
Michael Starzinger
2016/06/29 08:29:23
nit: Magic constant '10' is being magic. Can we ex
bradn
2016/06/30 07:59:36
Done.
|
| + // Pick the 'foreign' from the parent frame. |
| + __ Push(Operand(rsp, 10 * kPointerSize)); |
| + // Pick the 'heap' from the parent frame. |
| + __ Push(Operand(rsp, 10 * kPointerSize)); |
| + // Call runtime, on success unwind frame, and parent frame. |
| + __ CallRuntime(Runtime::kInstantiateAsmJs, 4); |
| + // A smi 0 is returned on failure, an object on success. |
| + __ JumpIfSmi(rax, &failed, Label::kNear); |
| + scope.GenerateLeaveFrame(); |
| + __ ret(4 * kPointerSize); |
| + |
| + __ bind(&failed); |
| + // Restore target function and new target. |
| + __ Pop(rdx); |
| + __ Pop(rdi); |
| + __ Pop(rax); |
| + __ SmiToInteger32(rax, rax); |
| + } |
| + // On failure, tail call into generated baseline code. |
| + GenerateTailCallToReturnedCode(masm, Runtime::kCompileBaseline); |
| +} |
| void Builtins::Generate_InOptimizationQueue(MacroAssembler* masm) { |
| // Checking whether the queued function is ready for install is optional, |