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 1001 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1012 void Builtins::Generate_CompileOptimized(MacroAssembler* masm) { | 1012 void Builtins::Generate_CompileOptimized(MacroAssembler* masm) { |
1013 GenerateTailCallToReturnedCode(masm, | 1013 GenerateTailCallToReturnedCode(masm, |
1014 Runtime::kCompileOptimized_NotConcurrent); | 1014 Runtime::kCompileOptimized_NotConcurrent); |
1015 } | 1015 } |
1016 | 1016 |
1017 | 1017 |
1018 void Builtins::Generate_CompileOptimizedConcurrent(MacroAssembler* masm) { | 1018 void Builtins::Generate_CompileOptimizedConcurrent(MacroAssembler* masm) { |
1019 GenerateTailCallToReturnedCode(masm, Runtime::kCompileOptimized_Concurrent); | 1019 GenerateTailCallToReturnedCode(masm, Runtime::kCompileOptimized_Concurrent); |
1020 } | 1020 } |
1021 | 1021 |
| 1022 void Builtins::Generate_InstantiateAsmJs(MacroAssembler* masm) { |
| 1023 // ----------- S t a t e ------------- |
| 1024 // -- eax : argument count (preserved for callee) |
| 1025 // -- edx : new target (preserved for callee) |
| 1026 // -- edi : target function (preserved for callee) |
| 1027 // ----------------------------------- |
| 1028 Label failed; |
| 1029 { |
| 1030 FrameScope scope(masm, StackFrame::INTERNAL); |
| 1031 // Push the number of arguments to the callee. |
| 1032 __ SmiTag(eax); |
| 1033 __ push(eax); |
| 1034 // Push a copy of the target function and the new target. |
| 1035 __ push(edi); |
| 1036 __ push(edx); |
| 1037 |
| 1038 // The function. |
| 1039 __ push(edi); |
| 1040 // Copy arguments from caller (stdlib, foreign, heap). |
| 1041 for (int i = 2; i >= 0; --i) { |
| 1042 __ push(Operand( |
| 1043 ebp, StandardFrameConstants::kCallerSPOffset + i * kPointerSize)); |
| 1044 } |
| 1045 // Call runtime, on success unwind frame, and parent frame. |
| 1046 __ CallRuntime(Runtime::kInstantiateAsmJs, 4); |
| 1047 // A smi 0 is returned on failure, an object on success. |
| 1048 __ JumpIfSmi(eax, &failed, Label::kNear); |
| 1049 scope.GenerateLeaveFrame(); |
| 1050 __ ret(4 * kPointerSize); |
| 1051 |
| 1052 __ bind(&failed); |
| 1053 // Restore target function and new target. |
| 1054 __ pop(edx); |
| 1055 __ pop(edi); |
| 1056 __ pop(eax); |
| 1057 __ SmiUntag(eax); |
| 1058 } |
| 1059 // On failure, tail call back to regular js. |
| 1060 GenerateTailCallToReturnedCode(masm, Runtime::kCompileLazy); |
| 1061 } |
1022 | 1062 |
1023 static void GenerateMakeCodeYoungAgainCommon(MacroAssembler* masm) { | 1063 static void GenerateMakeCodeYoungAgainCommon(MacroAssembler* masm) { |
1024 // For now, we are relying on the fact that make_code_young doesn't do any | 1064 // For now, we are relying on the fact that make_code_young doesn't do any |
1025 // garbage collection which allows us to save/restore the registers without | 1065 // garbage collection which allows us to save/restore the registers without |
1026 // worrying about which of them contain pointers. We also don't build an | 1066 // worrying about which of them contain pointers. We also don't build an |
1027 // internal frame to make the code faster, since we shouldn't have to do stack | 1067 // internal frame to make the code faster, since we shouldn't have to do stack |
1028 // crawls in MakeCodeYoung. This seems a bit fragile. | 1068 // crawls in MakeCodeYoung. This seems a bit fragile. |
1029 | 1069 |
1030 // Re-execute the code that was patched back to the young age when | 1070 // Re-execute the code that was patched back to the young age when |
1031 // the stub returns. | 1071 // the stub returns. |
(...skipping 1949 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2981 // And "return" to the OSR entry point of the function. | 3021 // And "return" to the OSR entry point of the function. |
2982 __ ret(0); | 3022 __ ret(0); |
2983 } | 3023 } |
2984 | 3024 |
2985 | 3025 |
2986 #undef __ | 3026 #undef __ |
2987 } // namespace internal | 3027 } // namespace internal |
2988 } // namespace v8 | 3028 } // namespace v8 |
2989 | 3029 |
2990 #endif // V8_TARGET_ARCH_IA32 | 3030 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |