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

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: 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 unified diff | Download patch
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 __ cmp(ecx, Immediate(0));
1026 ebp, StandardFrameConstants::kCallerSPOffset + i * kPointerSize)); 1028 __ j(equal, &args_done, Label::kNear);
1027 } 1029
1030 Label args2;
1031 __ cmp(ecx, Immediate(1));
1032 __ j(not_equal, &args2, Label::kNear);
1033 __ Push(Operand(
1034 ebp, StandardFrameConstants::kCallerSPOffset + 0 * kPointerSize));
1035 __ jmp(&args_done, Label::kNear);
1036
1037 __ bind(&args2);
1038 Label args3;
1039 __ cmp(ecx, Immediate(2));
1040 __ j(not_equal, &args3, Label::kNear);
1041 __ Push(Operand(
1042 ebp, StandardFrameConstants::kCallerSPOffset + 1 * kPointerSize));
1043 __ Push(Operand(
1044 ebp, StandardFrameConstants::kCallerSPOffset + 0 * kPointerSize));
1045 __ jmp(&args_done, Label::kNear);
1046
1047 __ bind(&args3);
1048 __ Push(Operand(
1049 ebp, StandardFrameConstants::kCallerSPOffset + 2 * kPointerSize));
1050 __ Push(Operand(
1051 ebp, StandardFrameConstants::kCallerSPOffset + 1 * kPointerSize));
1052 __ Push(Operand(
1053 ebp, StandardFrameConstants::kCallerSPOffset + 0 * kPointerSize));
1054 __ bind(&args_done);
1055
1056 // Increment and restore argument count to call runtime method
1057 // with function as extra argument.
1058 __ inc(ecx);
1059 __ mov(eax, ecx);
1028 // Call runtime, on success unwind frame, and parent frame. 1060 // Call runtime, on success unwind frame, and parent frame.
1029 __ CallRuntime(Runtime::kInstantiateAsmJs, 4); 1061 __ CallRuntime(Runtime::kInstantiateAsmJs, -1);
1030 // A smi 0 is returned on failure, an object on success. 1062 // A smi 0 is returned on failure, an object on success.
1031 __ JumpIfSmi(eax, &failed, Label::kNear); 1063 __ JumpIfSmi(eax, &failed, Label::kNear);
1064
1065 __ Pop(ecx);
1066 __ Pop(ecx);
1067 __ Pop(ecx);
1068 __ SmiUntag(ecx);
1032 scope.GenerateLeaveFrame(); 1069 scope.GenerateLeaveFrame();
1033 __ ret(4 * kPointerSize); 1070
1071 __ Pop(ebx);
1072 __ inc(ecx);
1073 __ lea(esp, Operand(esp, ecx, times_pointer_size, 0));
1074 __ Push(ebx);
1075 __ ret(0);
1034 1076
1035 __ bind(&failed); 1077 __ bind(&failed);
1036 // Restore target function and new target. 1078 // Restore target function and new target.
1037 __ pop(edx); 1079 __ pop(edx);
1038 __ pop(edi); 1080 __ pop(edi);
1039 __ pop(eax); 1081 __ pop(eax);
1040 __ SmiUntag(eax); 1082 __ SmiUntag(eax);
1041 } 1083 }
1042 // On failure, tail call back to regular js. 1084 // On failure, tail call back to regular js.
1043 GenerateTailCallToReturnedCode(masm, Runtime::kCompileLazy); 1085 GenerateTailCallToReturnedCode(masm, Runtime::kCompileBaseline);
1044 } 1086 }
1045 1087
1046 static void GenerateMakeCodeYoungAgainCommon(MacroAssembler* masm) { 1088 static void GenerateMakeCodeYoungAgainCommon(MacroAssembler* masm) {
1047 // For now, we are relying on the fact that make_code_young doesn't do any 1089 // For now, we are relying on the fact that make_code_young doesn't do any
1048 // garbage collection which allows us to save/restore the registers without 1090 // garbage collection which allows us to save/restore the registers without
1049 // worrying about which of them contain pointers. We also don't build an 1091 // worrying about which of them contain pointers. We also don't build an
1050 // internal frame to make the code faster, since we shouldn't have to do stack 1092 // internal frame to make the code faster, since we shouldn't have to do stack
1051 // crawls in MakeCodeYoung. This seems a bit fragile. 1093 // crawls in MakeCodeYoung. This seems a bit fragile.
1052 1094
1053 // Re-execute the code that was patched back to the young age when 1095 // Re-execute the code that was patched back to the young age when
(...skipping 1995 matching lines...) Expand 10 before | Expand all | Expand 10 after
3049 3091
3050 void Builtins::Generate_InterpreterOnStackReplacement(MacroAssembler* masm) { 3092 void Builtins::Generate_InterpreterOnStackReplacement(MacroAssembler* masm) {
3051 Generate_OnStackReplacementHelper(masm, true); 3093 Generate_OnStackReplacementHelper(masm, true);
3052 } 3094 }
3053 3095
3054 #undef __ 3096 #undef __
3055 } // namespace internal 3097 } // namespace internal
3056 } // namespace v8 3098 } // namespace v8
3057 3099
3058 #endif // V8_TARGET_ARCH_X87 3100 #endif // V8_TARGET_ARCH_X87
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698