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

Unified Diff: src/builtins/x87/builtins-x87.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: file change 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/x87/builtins-x87.cc
diff --git a/src/builtins/x87/builtins-x87.cc b/src/builtins/x87/builtins-x87.cc
index c2544715bf9c858fc65af204bc9d183ccf824c3e..816f59391a7782e465b9aafce2c6d7ac4ff4c7eb 100644
--- a/src/builtins/x87/builtins-x87.cc
+++ b/src/builtins/x87/builtins-x87.cc
@@ -1011,6 +1011,8 @@ void Builtins::Generate_InstantiateAsmJs(MacroAssembler* masm) {
Label failed;
{
FrameScope scope(masm, StackFrame::INTERNAL);
+ // Preserve argument count for later compare.
+ __ mov(ecx, eax);
// Push the number of arguments to the callee.
__ SmiTag(eax);
__ push(eax);
@@ -1021,16 +1023,43 @@ void Builtins::Generate_InstantiateAsmJs(MacroAssembler* masm) {
// The function.
__ push(edi);
// Copy arguments from caller (stdlib, foreign, heap).
- for (int i = 2; i >= 0; --i) {
- __ push(Operand(
- ebp, StandardFrameConstants::kCallerSPOffset + i * kPointerSize));
+ Label args_done;
+ for (int j = 0; j < 4; ++j) {
+ Label over;
+ if (j < 3) {
+ __ cmp(ecx, Immediate(j));
+ __ j(not_equal, &over, Label::kNear);
+ }
+ for (int i = j - 1; i >= 0; --i) {
+ __ Push(Operand(
+ ebp, StandardFrameConstants::kCallerSPOffset + i * kPointerSize));
+ }
+ for (int i = 0; i < 3 - j; ++i) {
+ __ PushRoot(Heap::kUndefinedValueRootIndex);
+ }
+ if (j < 3) {
+ __ jmp(&args_done, Label::kNear);
+ __ bind(&over);
+ }
}
+ __ bind(&args_done);
+
// 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(eax, &failed, Label::kNear);
+
+ __ Pop(ecx);
+ __ Pop(ecx);
+ __ Pop(ecx);
+ __ SmiUntag(ecx);
scope.GenerateLeaveFrame();
- __ ret(4 * kPointerSize);
+
+ __ Pop(ebx);
+ __ inc(ecx);
+ __ lea(esp, Operand(esp, ecx, times_pointer_size, 0));
+ __ Push(ebx);
+ __ ret(0);
__ bind(&failed);
// Restore target function and new target.

Powered by Google App Engine
This is Rietveld 408576698