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

Unified Diff: src/builtins/mips/builtins-mips.cc

Issue 2229723002: [wasm] Support validation of asm.js modules with != 3 args. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: fix Created 4 years, 4 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
Index: src/builtins/mips/builtins-mips.cc
diff --git a/src/builtins/mips/builtins-mips.cc b/src/builtins/mips/builtins-mips.cc
index 94d0ef643d7b72a4a30bee738f67fc988405696b..4910f4b575f7f5b6af76f2b8a706aabf147e00de 100644
--- a/src/builtins/mips/builtins-mips.cc
+++ b/src/builtins/mips/builtins-mips.cc
@@ -1444,23 +1444,66 @@ void Builtins::Generate_InstantiateAsmJs(MacroAssembler* masm) {
Label failed;
{
FrameScope scope(masm, StackFrame::INTERNAL);
+ // Preserve argument count for later compare.
+ __ Move(s4, a0);
// Push a copy of the target function and the new target.
// Push function as parameter to the runtime call.
__ SmiTag(a0);
__ Push(a0, a1, a3, a1);
// Copy arguments from caller (stdlib, foreign, heap).
- for (int i = 2; i >= 0; --i) {
- __ lw(a3, MemOperand(fp, StandardFrameConstants::kCallerSPOffset +
- i * kPointerSize));
- __ push(a3);
- }
+ Label args_done;
+ __ Branch(&args_done, eq, s4, Operand(0));
+
+ Label args2;
+ __ Branch(&args2, ne, s4, Operand(1));
+ __ lw(a3, MemOperand(fp, StandardFrameConstants::kCallerSPOffset +
+ 0 * kPointerSize));
+ __ push(a3);
+ __ jmp(&args_done);
+
+ __ bind(&args2);
+ Label args3;
+ __ Branch(&args3, ne, s4, Operand(2));
+ __ lw(a3, MemOperand(fp, StandardFrameConstants::kCallerSPOffset +
+ 1 * kPointerSize));
+ __ push(a3);
+ __ lw(a3, Operand(fp, StandardFrameConstants::kCallerSPOffset +
+ 0 * kPointerSize));
+ __ push(a3);
+ __ jmp(&args_done);
+
+ __ bind(&args3);
+ __ lw(a3, Operand(fp, StandardFrameConstants::kCallerSPOffset +
+ 2 * kPointerSize));
+ __ push(a3);
+ __ lw(a3, Operand(fp, StandardFrameConstants::kCallerSPOffset +
+ 1 * kPointerSize));
+ __ push(a3);
+ __ lw(a3, Operand(fp, StandardFrameConstants::kCallerSPOffset +
+ 0 * kPointerSize));
+ __ push(a3);
+ __ bind(&args_done);
+ // Increment and restore argument count to call runtime method
+ // with function as extra argument.
+ __ Addu(s4, s4, Operand(1));
+ __ Move(a0, s4);
// 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(a0, &failed);
+
+ __ pop(s4);
+ __ pop(s4);
+ __ pop(s4);
+ __ SmiUntag(s4);
+
scope.GenerateLeaveFrame();
- __ Drop(4);
+
+ __ pop(s3);
+ __ Addu(s4, s4, Operand(1));
+ __ Lsa(sp, sp, s4, kPointerSizeLog2);
+ __ push(s3);
__ Ret();
__ bind(&failed);
@@ -1469,7 +1512,7 @@ void Builtins::Generate_InstantiateAsmJs(MacroAssembler* masm) {
__ SmiUntag(a0);
}
// On failure, tail call back to regular js.
- GenerateTailCallToReturnedCode(masm, Runtime::kCompileLazy);
+ GenerateTailCallToReturnedCode(masm, Runtime::kCompileBaseline);
}
static void GenerateMakeCodeYoungAgainCommon(MacroAssembler* masm) {

Powered by Google App Engine
This is Rietveld 408576698