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