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

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: mips and more 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
« no previous file with comments | « src/builtins/x64/builtins-x64.cc ('k') | src/compiler.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/builtins/x87/builtins-x87.cc
diff --git a/src/builtins/x87/builtins-x87.cc b/src/builtins/x87/builtins-x87.cc
index 4135c2859624a57b7d75602a09fce74fba366d6d..bb7dc8380b5a3f762e253b2a27eebf1207d7b0fe 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,42 @@ 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);
+
+ __ Drop(2);
+ __ Pop(ecx);
+ __ SmiUntag(ecx);
scope.GenerateLeaveFrame();
- __ ret(4 * kPointerSize);
+
+ __ PopReturnAddressTo(ebx);
+ __ inc(ecx);
+ __ lea(esp, Operand(esp, ecx, times_pointer_size, 0));
+ __ PushReturnAddressFrom(ebx);
+ __ ret(0);
__ bind(&failed);
// Restore target function and new target.
« no previous file with comments | « src/builtins/x64/builtins-x64.cc ('k') | src/compiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698