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