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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « src/builtins/x64/builtins-x64.cc ('k') | src/compiler.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_X87 5 #if V8_TARGET_ARCH_X87
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 993 matching lines...) Expand 10 before | Expand all | Expand 10 after
1004 1004
1005 void Builtins::Generate_InstantiateAsmJs(MacroAssembler* masm) { 1005 void Builtins::Generate_InstantiateAsmJs(MacroAssembler* masm) {
1006 // ----------- S t a t e ------------- 1006 // ----------- S t a t e -------------
1007 // -- eax : argument count (preserved for callee) 1007 // -- eax : argument count (preserved for callee)
1008 // -- edx : new target (preserved for callee) 1008 // -- edx : new target (preserved for callee)
1009 // -- edi : target function (preserved for callee) 1009 // -- edi : target function (preserved for callee)
1010 // ----------------------------------- 1010 // -----------------------------------
1011 Label failed; 1011 Label failed;
1012 { 1012 {
1013 FrameScope scope(masm, StackFrame::INTERNAL); 1013 FrameScope scope(masm, StackFrame::INTERNAL);
1014 // Preserve argument count for later compare.
1015 __ mov(ecx, eax);
1014 // Push the number of arguments to the callee. 1016 // Push the number of arguments to the callee.
1015 __ SmiTag(eax); 1017 __ SmiTag(eax);
1016 __ push(eax); 1018 __ push(eax);
1017 // Push a copy of the target function and the new target. 1019 // Push a copy of the target function and the new target.
1018 __ push(edi); 1020 __ push(edi);
1019 __ push(edx); 1021 __ push(edx);
1020 1022
1021 // The function. 1023 // The function.
1022 __ push(edi); 1024 __ push(edi);
1023 // Copy arguments from caller (stdlib, foreign, heap). 1025 // Copy arguments from caller (stdlib, foreign, heap).
1024 for (int i = 2; i >= 0; --i) { 1026 Label args_done;
1025 __ push(Operand( 1027 for (int j = 0; j < 4; ++j) {
1026 ebp, StandardFrameConstants::kCallerSPOffset + i * kPointerSize)); 1028 Label over;
1029 if (j < 3) {
1030 __ cmp(ecx, Immediate(j));
1031 __ j(not_equal, &over, Label::kNear);
1032 }
1033 for (int i = j - 1; i >= 0; --i) {
1034 __ Push(Operand(
1035 ebp, StandardFrameConstants::kCallerSPOffset + i * kPointerSize));
1036 }
1037 for (int i = 0; i < 3 - j; ++i) {
1038 __ PushRoot(Heap::kUndefinedValueRootIndex);
1039 }
1040 if (j < 3) {
1041 __ jmp(&args_done, Label::kNear);
1042 __ bind(&over);
1043 }
1027 } 1044 }
1045 __ bind(&args_done);
1046
1028 // Call runtime, on success unwind frame, and parent frame. 1047 // Call runtime, on success unwind frame, and parent frame.
1029 __ CallRuntime(Runtime::kInstantiateAsmJs, 4); 1048 __ CallRuntime(Runtime::kInstantiateAsmJs, 4);
1030 // A smi 0 is returned on failure, an object on success. 1049 // A smi 0 is returned on failure, an object on success.
1031 __ JumpIfSmi(eax, &failed, Label::kNear); 1050 __ JumpIfSmi(eax, &failed, Label::kNear);
1051
1052 __ Drop(2);
1053 __ Pop(ecx);
1054 __ SmiUntag(ecx);
1032 scope.GenerateLeaveFrame(); 1055 scope.GenerateLeaveFrame();
1033 __ ret(4 * kPointerSize); 1056
1057 __ PopReturnAddressTo(ebx);
1058 __ inc(ecx);
1059 __ lea(esp, Operand(esp, ecx, times_pointer_size, 0));
1060 __ PushReturnAddressFrom(ebx);
1061 __ ret(0);
1034 1062
1035 __ bind(&failed); 1063 __ bind(&failed);
1036 // Restore target function and new target. 1064 // Restore target function and new target.
1037 __ pop(edx); 1065 __ pop(edx);
1038 __ pop(edi); 1066 __ pop(edi);
1039 __ pop(eax); 1067 __ pop(eax);
1040 __ SmiUntag(eax); 1068 __ SmiUntag(eax);
1041 } 1069 }
1042 // On failure, tail call back to regular js. 1070 // On failure, tail call back to regular js.
1043 GenerateTailCallToReturnedCode(masm, Runtime::kCompileLazy); 1071 GenerateTailCallToReturnedCode(masm, Runtime::kCompileLazy);
(...skipping 1981 matching lines...) Expand 10 before | Expand all | Expand 10 after
3025 3053
3026 void Builtins::Generate_InterpreterOnStackReplacement(MacroAssembler* masm) { 3054 void Builtins::Generate_InterpreterOnStackReplacement(MacroAssembler* masm) {
3027 Generate_OnStackReplacementHelper(masm, true); 3055 Generate_OnStackReplacementHelper(masm, true);
3028 } 3056 }
3029 3057
3030 #undef __ 3058 #undef __
3031 } // namespace internal 3059 } // namespace internal
3032 } // namespace v8 3060 } // namespace v8
3033 3061
3034 #endif // V8_TARGET_ARCH_X87 3062 #endif // V8_TARGET_ARCH_X87
OLDNEW
« 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