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

Side by Side Diff: src/builtins/ia32/builtins-ia32.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 unified diff | Download patch
« no previous file with comments | « src/builtins/arm64/builtins-arm64.cc ('k') | src/builtins/mips/builtins-mips.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #if V8_TARGET_ARCH_IA32 5 #if V8_TARGET_ARCH_IA32
6 6
7 #include "src/code-factory.h" 7 #include "src/code-factory.h"
8 #include "src/codegen.h" 8 #include "src/codegen.h"
9 #include "src/deoptimizer.h" 9 #include "src/deoptimizer.h"
10 #include "src/full-codegen/full-codegen.h" 10 #include "src/full-codegen/full-codegen.h"
(...skipping 992 matching lines...) Expand 10 before | Expand all | Expand 10 after
1003 1003
1004 void Builtins::Generate_InstantiateAsmJs(MacroAssembler* masm) { 1004 void Builtins::Generate_InstantiateAsmJs(MacroAssembler* masm) {
1005 // ----------- S t a t e ------------- 1005 // ----------- S t a t e -------------
1006 // -- eax : argument count (preserved for callee) 1006 // -- eax : argument count (preserved for callee)
1007 // -- edx : new target (preserved for callee) 1007 // -- edx : new target (preserved for callee)
1008 // -- edi : target function (preserved for callee) 1008 // -- edi : target function (preserved for callee)
1009 // ----------------------------------- 1009 // -----------------------------------
1010 Label failed; 1010 Label failed;
1011 { 1011 {
1012 FrameScope scope(masm, StackFrame::INTERNAL); 1012 FrameScope scope(masm, StackFrame::INTERNAL);
1013 // Preserve argument count for later compare.
1014 __ mov(ecx, eax);
1013 // Push the number of arguments to the callee. 1015 // Push the number of arguments to the callee.
1014 __ SmiTag(eax); 1016 __ SmiTag(eax);
1015 __ push(eax); 1017 __ push(eax);
1016 // Push a copy of the target function and the new target. 1018 // Push a copy of the target function and the new target.
1017 __ push(edi); 1019 __ push(edi);
1018 __ push(edx); 1020 __ push(edx);
1019 1021
1020 // The function. 1022 // The function.
1021 __ push(edi); 1023 __ push(edi);
1022 // Copy arguments from caller (stdlib, foreign, heap). 1024 // Copy arguments from caller (stdlib, foreign, heap).
1023 for (int i = 2; i >= 0; --i) { 1025 Label args_done;
1024 __ push(Operand( 1026 for (int j = 0; j < 4; ++j) {
1025 ebp, StandardFrameConstants::kCallerSPOffset + i * kPointerSize)); 1027 Label over;
1028 if (j < 3) {
1029 __ cmp(ecx, Immediate(j));
1030 __ j(not_equal, &over, Label::kNear);
1031 }
1032 for (int i = j - 1; i >= 0; --i) {
1033 __ Push(Operand(
1034 ebp, StandardFrameConstants::kCallerSPOffset + i * kPointerSize));
1035 }
1036 for (int i = 0; i < 3 - j; ++i) {
1037 __ PushRoot(Heap::kUndefinedValueRootIndex);
1038 }
1039 if (j < 3) {
1040 __ jmp(&args_done, Label::kNear);
1041 __ bind(&over);
1042 }
1026 } 1043 }
1044 __ bind(&args_done);
1045
1027 // Call runtime, on success unwind frame, and parent frame. 1046 // Call runtime, on success unwind frame, and parent frame.
1028 __ CallRuntime(Runtime::kInstantiateAsmJs, 4); 1047 __ CallRuntime(Runtime::kInstantiateAsmJs, 4);
1029 // A smi 0 is returned on failure, an object on success. 1048 // A smi 0 is returned on failure, an object on success.
1030 __ JumpIfSmi(eax, &failed, Label::kNear); 1049 __ JumpIfSmi(eax, &failed, Label::kNear);
1050
1051 __ Drop(2);
1052 __ Pop(ecx);
1053 __ SmiUntag(ecx);
1031 scope.GenerateLeaveFrame(); 1054 scope.GenerateLeaveFrame();
1032 __ ret(4 * kPointerSize); 1055
1056 __ PopReturnAddressTo(ebx);
1057 __ inc(ecx);
1058 __ lea(esp, Operand(esp, ecx, times_pointer_size, 0));
1059 __ PushReturnAddressFrom(ebx);
1060 __ ret(0);
1033 1061
1034 __ bind(&failed); 1062 __ bind(&failed);
1035 // Restore target function and new target. 1063 // Restore target function and new target.
1036 __ pop(edx); 1064 __ pop(edx);
1037 __ pop(edi); 1065 __ pop(edi);
1038 __ pop(eax); 1066 __ pop(eax);
1039 __ SmiUntag(eax); 1067 __ SmiUntag(eax);
1040 } 1068 }
1041 // On failure, tail call back to regular js. 1069 // On failure, tail call back to regular js.
1042 GenerateTailCallToReturnedCode(masm, Runtime::kCompileLazy); 1070 GenerateTailCallToReturnedCode(masm, Runtime::kCompileLazy);
(...skipping 1957 matching lines...) Expand 10 before | Expand all | Expand 10 after
3000 3028
3001 void Builtins::Generate_InterpreterOnStackReplacement(MacroAssembler* masm) { 3029 void Builtins::Generate_InterpreterOnStackReplacement(MacroAssembler* masm) {
3002 Generate_OnStackReplacementHelper(masm, true); 3030 Generate_OnStackReplacementHelper(masm, true);
3003 } 3031 }
3004 3032
3005 #undef __ 3033 #undef __
3006 } // namespace internal 3034 } // namespace internal
3007 } // namespace v8 3035 } // namespace v8
3008 3036
3009 #endif // V8_TARGET_ARCH_IA32 3037 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/builtins/arm64/builtins-arm64.cc ('k') | src/builtins/mips/builtins-mips.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698