| 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_X64 | 5 #if V8_TARGET_ARCH_X64 |
| 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 1102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1113 void Builtins::Generate_InstantiateAsmJs(MacroAssembler* masm) { | 1113 void Builtins::Generate_InstantiateAsmJs(MacroAssembler* masm) { |
| 1114 // ----------- S t a t e ------------- | 1114 // ----------- S t a t e ------------- |
| 1115 // -- rax : argument count (preserved for callee) | 1115 // -- rax : argument count (preserved for callee) |
| 1116 // -- rdx : new target (preserved for callee) | 1116 // -- rdx : new target (preserved for callee) |
| 1117 // -- rdi : target function (preserved for callee) | 1117 // -- rdi : target function (preserved for callee) |
| 1118 // ----------------------------------- | 1118 // ----------------------------------- |
| 1119 Label failed; | 1119 Label failed; |
| 1120 { | 1120 { |
| 1121 FrameScope scope(masm, StackFrame::INTERNAL); | 1121 FrameScope scope(masm, StackFrame::INTERNAL); |
| 1122 // Preserve argument count for later compare. | 1122 // Preserve argument count for later compare. |
| 1123 __ movp(kScratchRegister, rax); | 1123 __ movp(rcx, rax); |
| 1124 // Push the number of arguments to the callee. | 1124 // Push the number of arguments to the callee. |
| 1125 __ Integer32ToSmi(rax, rax); | 1125 __ Integer32ToSmi(rax, rax); |
| 1126 __ Push(rax); | 1126 __ Push(rax); |
| 1127 // Push a copy of the target function and the new target. | 1127 // Push a copy of the target function and the new target. |
| 1128 __ Push(rdi); | 1128 __ Push(rdi); |
| 1129 __ Push(rdx); | 1129 __ Push(rdx); |
| 1130 | 1130 |
| 1131 // The function. | 1131 // The function. |
| 1132 __ Push(rdi); | 1132 __ Push(rdi); |
| 1133 // Copy arguments from caller (stdlib, foreign, heap). | 1133 // Copy arguments from caller (stdlib, foreign, heap). |
| 1134 Label args_done; | 1134 Label args_done; |
| 1135 for (int j = 0; j < 4; ++j) { | 1135 for (int j = 0; j < 4; ++j) { |
| 1136 Label over; | 1136 Label over; |
| 1137 if (j < 3) { | 1137 if (j < 3) { |
| 1138 __ cmpp(kScratchRegister, Immediate(j)); | 1138 __ cmpp(rcx, Immediate(j)); |
| 1139 __ j(not_equal, &over, Label::kNear); | 1139 __ j(not_equal, &over, Label::kNear); |
| 1140 } | 1140 } |
| 1141 for (int i = j - 1; i >= 0; --i) { | 1141 for (int i = j - 1; i >= 0; --i) { |
| 1142 __ Push(Operand( | 1142 __ Push(Operand( |
| 1143 rbp, StandardFrameConstants::kCallerSPOffset + i * kPointerSize)); | 1143 rbp, StandardFrameConstants::kCallerSPOffset + i * kPointerSize)); |
| 1144 } | 1144 } |
| 1145 for (int i = 0; i < 3 - j; ++i) { | 1145 for (int i = 0; i < 3 - j; ++i) { |
| 1146 __ PushRoot(Heap::kUndefinedValueRootIndex); | 1146 __ PushRoot(Heap::kUndefinedValueRootIndex); |
| 1147 } | 1147 } |
| 1148 if (j < 3) { | 1148 if (j < 3) { |
| 1149 __ jmp(&args_done, Label::kNear); | 1149 __ jmp(&args_done, Label::kNear); |
| 1150 __ bind(&over); | 1150 __ bind(&over); |
| 1151 } | 1151 } |
| 1152 } | 1152 } |
| 1153 __ bind(&args_done); | 1153 __ bind(&args_done); |
| 1154 | 1154 |
| 1155 // Call runtime, on success unwind frame, and parent frame. | 1155 // Call runtime, on success unwind frame, and parent frame. |
| 1156 __ CallRuntime(Runtime::kInstantiateAsmJs, 4); | 1156 __ CallRuntime(Runtime::kInstantiateAsmJs, 4); |
| 1157 // A smi 0 is returned on failure, an object on success. | 1157 // A smi 0 is returned on failure, an object on success. |
| 1158 __ JumpIfSmi(rax, &failed, Label::kNear); | 1158 __ JumpIfSmi(rax, &failed, Label::kNear); |
| 1159 | 1159 |
| 1160 __ Drop(2); | 1160 __ Drop(2); |
| 1161 __ Pop(kScratchRegister); | 1161 __ Pop(rcx); |
| 1162 __ SmiToInteger32(kScratchRegister, kScratchRegister); | 1162 __ SmiToInteger32(rcx, rcx); |
| 1163 scope.GenerateLeaveFrame(); | 1163 scope.GenerateLeaveFrame(); |
| 1164 | 1164 |
| 1165 __ PopReturnAddressTo(rbx); | 1165 __ PopReturnAddressTo(rbx); |
| 1166 __ incp(kScratchRegister); | 1166 __ incp(rcx); |
| 1167 __ leap(rsp, Operand(rsp, kScratchRegister, times_pointer_size, 0)); | 1167 __ leap(rsp, Operand(rsp, rcx, times_pointer_size, 0)); |
| 1168 __ PushReturnAddressFrom(rbx); | 1168 __ PushReturnAddressFrom(rbx); |
| 1169 __ ret(0); | 1169 __ ret(0); |
| 1170 | 1170 |
| 1171 __ bind(&failed); | 1171 __ bind(&failed); |
| 1172 // Restore target function and new target. | 1172 // Restore target function and new target. |
| 1173 __ Pop(rdx); | 1173 __ Pop(rdx); |
| 1174 __ Pop(rdi); | 1174 __ Pop(rdi); |
| 1175 __ Pop(rax); | 1175 __ Pop(rax); |
| 1176 __ SmiToInteger32(rax, rax); | 1176 __ SmiToInteger32(rax, rax); |
| 1177 } | 1177 } |
| (...skipping 1877 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3055 void Builtins::Generate_InterpreterOnStackReplacement(MacroAssembler* masm) { | 3055 void Builtins::Generate_InterpreterOnStackReplacement(MacroAssembler* masm) { |
| 3056 Generate_OnStackReplacementHelper(masm, true); | 3056 Generate_OnStackReplacementHelper(masm, true); |
| 3057 } | 3057 } |
| 3058 | 3058 |
| 3059 #undef __ | 3059 #undef __ |
| 3060 | 3060 |
| 3061 } // namespace internal | 3061 } // namespace internal |
| 3062 } // namespace v8 | 3062 } // namespace v8 |
| 3063 | 3063 |
| 3064 #endif // V8_TARGET_ARCH_X64 | 3064 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |