| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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_PPC | 5 #if V8_TARGET_ARCH_PPC |
| 6 | 6 |
| 7 #include "src/codegen.h" | 7 #include "src/codegen.h" |
| 8 #include "src/debug/debug.h" | 8 #include "src/debug/debug.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 1144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1155 __ addi(index, index, Operand(kPointerSize)); // Bias up for LoadPU | 1155 __ addi(index, index, Operand(kPointerSize)); // Bias up for LoadPU |
| 1156 __ mtctr(count); | 1156 __ mtctr(count); |
| 1157 __ bind(&loop); | 1157 __ bind(&loop); |
| 1158 __ LoadPU(scratch, MemOperand(index, -kPointerSize)); | 1158 __ LoadPU(scratch, MemOperand(index, -kPointerSize)); |
| 1159 __ push(scratch); | 1159 __ push(scratch); |
| 1160 __ bdnz(&loop); | 1160 __ bdnz(&loop); |
| 1161 } | 1161 } |
| 1162 | 1162 |
| 1163 // static | 1163 // static |
| 1164 void Builtins::Generate_InterpreterPushArgsAndCallImpl( | 1164 void Builtins::Generate_InterpreterPushArgsAndCallImpl( |
| 1165 MacroAssembler* masm, TailCallMode tail_call_mode, | 1165 MacroAssembler* masm, TailCallMode tail_call_mode, PushArgsMode mode) { |
| 1166 CallableType function_type) { | |
| 1167 // ----------- S t a t e ------------- | 1166 // ----------- S t a t e ------------- |
| 1168 // -- r3 : the number of arguments (not including the receiver) | 1167 // -- r3 : the number of arguments (not including the receiver) |
| 1169 // -- r5 : the address of the first argument to be pushed. Subsequent | 1168 // -- r5 : the address of the first argument to be pushed. Subsequent |
| 1170 // arguments should be consecutive above this, in the same order as | 1169 // arguments should be consecutive above this, in the same order as |
| 1171 // they are to be pushed onto the stack. | 1170 // they are to be pushed onto the stack. |
| 1172 // -- r4 : the target to call (can be any Object). | 1171 // -- r4 : the target to call (can be any Object). |
| 1173 // ----------------------------------- | 1172 // ----------------------------------- |
| 1174 Label stack_overflow; | 1173 Label stack_overflow; |
| 1175 | 1174 |
| 1176 // Calculate number of arguments (add one for receiver). | 1175 // Calculate number of arguments (add one for receiver). |
| 1177 __ addi(r6, r3, Operand(1)); | 1176 __ addi(r6, r3, Operand(1)); |
| 1178 | 1177 |
| 1179 // Push the arguments. r5, r6, r7 will be modified. | 1178 // Push the arguments. r5, r6, r7 will be modified. |
| 1180 Generate_InterpreterPushArgs(masm, r6, r5, r6, r7, &stack_overflow); | 1179 Generate_InterpreterPushArgs(masm, r6, r5, r6, r7, &stack_overflow); |
| 1181 | 1180 |
| 1182 // Call the target. | 1181 // Call the target. |
| 1183 if (function_type == CallableType::kJSFunction) { | 1182 if (mode == PushArgsMode::kJSFunction) { |
| 1184 __ Jump(masm->isolate()->builtins()->CallFunction(ConvertReceiverMode::kAny, | 1183 __ Jump(masm->isolate()->builtins()->CallFunction(ConvertReceiverMode::kAny, |
| 1185 tail_call_mode), | 1184 tail_call_mode), |
| 1186 RelocInfo::CODE_TARGET); | 1185 RelocInfo::CODE_TARGET); |
| 1187 } else { | 1186 } else { |
| 1188 DCHECK_EQ(function_type, CallableType::kAny); | 1187 DCHECK_EQ(mode, PushArgsMode::kOther); |
| 1189 __ Jump(masm->isolate()->builtins()->Call(ConvertReceiverMode::kAny, | 1188 __ Jump(masm->isolate()->builtins()->Call(ConvertReceiverMode::kAny, |
| 1190 tail_call_mode), | 1189 tail_call_mode), |
| 1191 RelocInfo::CODE_TARGET); | 1190 RelocInfo::CODE_TARGET); |
| 1192 } | 1191 } |
| 1193 | 1192 |
| 1194 __ bind(&stack_overflow); | 1193 __ bind(&stack_overflow); |
| 1195 { | 1194 { |
| 1196 __ TailCallRuntime(Runtime::kThrowStackOverflow); | 1195 __ TailCallRuntime(Runtime::kThrowStackOverflow); |
| 1197 // Unreachable Code. | 1196 // Unreachable Code. |
| 1198 __ bkpt(0); | 1197 __ bkpt(0); |
| 1199 } | 1198 } |
| 1200 } | 1199 } |
| 1201 | 1200 |
| 1202 // static | 1201 // static |
| 1203 void Builtins::Generate_InterpreterPushArgsAndConstructImpl( | 1202 void Builtins::Generate_InterpreterPushArgsAndConstructImpl( |
| 1204 MacroAssembler* masm, PushArgsConstructMode mode) { | 1203 MacroAssembler* masm, PushArgsMode mode) { |
| 1205 // ----------- S t a t e ------------- | 1204 // ----------- S t a t e ------------- |
| 1206 // -- r3 : argument count (not including receiver) | 1205 // -- r3 : argument count (not including receiver) |
| 1207 // -- r6 : new target | 1206 // -- r6 : new target |
| 1208 // -- r4 : constructor to call | 1207 // -- r4 : constructor to call |
| 1209 // -- r5 : allocation site feedback if available, undefined otherwise. | 1208 // -- r5 : allocation site feedback if available, undefined otherwise. |
| 1210 // -- r7 : address of the first argument | 1209 // -- r7 : address of the first argument |
| 1211 // ----------------------------------- | 1210 // ----------------------------------- |
| 1212 Label stack_overflow; | 1211 Label stack_overflow; |
| 1213 | 1212 |
| 1214 // Push a slot for the receiver to be constructed. | 1213 // Push a slot for the receiver to be constructed. |
| 1215 __ li(r0, Operand::Zero()); | 1214 __ li(r0, Operand::Zero()); |
| 1216 __ push(r0); | 1215 __ push(r0); |
| 1217 | 1216 |
| 1218 // Push the arguments (skip if none). | 1217 // Push the arguments (skip if none). |
| 1219 Label skip; | 1218 Label skip; |
| 1220 __ cmpi(r3, Operand::Zero()); | 1219 __ cmpi(r3, Operand::Zero()); |
| 1221 __ beq(&skip); | 1220 __ beq(&skip); |
| 1222 // Push the arguments. r8, r7, r9 will be modified. | 1221 // Push the arguments. r8, r7, r9 will be modified. |
| 1223 Generate_InterpreterPushArgs(masm, r3, r7, r3, r8, &stack_overflow); | 1222 Generate_InterpreterPushArgs(masm, r3, r7, r3, r8, &stack_overflow); |
| 1224 __ bind(&skip); | 1223 __ bind(&skip); |
| 1225 | 1224 |
| 1226 __ AssertUndefinedOrAllocationSite(r5, r8); | 1225 __ AssertUndefinedOrAllocationSite(r5, r8); |
| 1227 if (mode == PushArgsConstructMode::kJSFunction) { | 1226 if (mode == PushArgsMode::kJSFunction) { |
| 1228 __ AssertFunction(r4); | 1227 __ AssertFunction(r4); |
| 1229 | 1228 |
| 1230 // Tail call to the function-specific construct stub (still in the caller | 1229 // Tail call to the function-specific construct stub (still in the caller |
| 1231 // context at this point). | 1230 // context at this point). |
| 1232 __ LoadP(r7, FieldMemOperand(r4, JSFunction::kSharedFunctionInfoOffset)); | 1231 __ LoadP(r7, FieldMemOperand(r4, JSFunction::kSharedFunctionInfoOffset)); |
| 1233 __ LoadP(r7, FieldMemOperand(r7, SharedFunctionInfo::kConstructStubOffset)); | 1232 __ LoadP(r7, FieldMemOperand(r7, SharedFunctionInfo::kConstructStubOffset)); |
| 1234 // Jump to the construct function. | 1233 // Jump to the construct function. |
| 1235 __ addi(ip, r7, Operand(Code::kHeaderSize - kHeapObjectTag)); | 1234 __ addi(ip, r7, Operand(Code::kHeaderSize - kHeapObjectTag)); |
| 1236 __ Jump(ip); | 1235 __ Jump(ip); |
| 1237 } else if (mode == PushArgsConstructMode::kWithFinalSpread) { | 1236 } else if (mode == PushArgsMode::kWithFinalSpread) { |
| 1238 // Call the constructor with r3, r4, and r6 unmodified. | 1237 // Call the constructor with r3, r4, and r6 unmodified. |
| 1239 __ Jump(masm->isolate()->builtins()->ConstructWithSpread(), | 1238 __ Jump(masm->isolate()->builtins()->ConstructWithSpread(), |
| 1240 RelocInfo::CODE_TARGET); | 1239 RelocInfo::CODE_TARGET); |
| 1241 } else { | 1240 } else { |
| 1242 DCHECK_EQ(PushArgsConstructMode::kOther, mode); | 1241 DCHECK_EQ(PushArgsMode::kOther, mode); |
| 1243 // Call the constructor with r3, r4, and r6 unmodified. | 1242 // Call the constructor with r3, r4, and r6 unmodified. |
| 1244 __ Jump(masm->isolate()->builtins()->Construct(), RelocInfo::CODE_TARGET); | 1243 __ Jump(masm->isolate()->builtins()->Construct(), RelocInfo::CODE_TARGET); |
| 1245 } | 1244 } |
| 1246 | 1245 |
| 1247 __ bind(&stack_overflow); | 1246 __ bind(&stack_overflow); |
| 1248 { | 1247 { |
| 1249 __ TailCallRuntime(Runtime::kThrowStackOverflow); | 1248 __ TailCallRuntime(Runtime::kThrowStackOverflow); |
| 1250 // Unreachable Code. | 1249 // Unreachable Code. |
| 1251 __ bkpt(0); | 1250 __ bkpt(0); |
| 1252 } | 1251 } |
| (...skipping 1858 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3111 __ CallRuntime(Runtime::kThrowStackOverflow); | 3110 __ CallRuntime(Runtime::kThrowStackOverflow); |
| 3112 __ bkpt(0); | 3111 __ bkpt(0); |
| 3113 } | 3112 } |
| 3114 } | 3113 } |
| 3115 | 3114 |
| 3116 #undef __ | 3115 #undef __ |
| 3117 } // namespace internal | 3116 } // namespace internal |
| 3118 } // namespace v8 | 3117 } // namespace v8 |
| 3119 | 3118 |
| 3120 #endif // V8_TARGET_ARCH_PPC | 3119 #endif // V8_TARGET_ARCH_PPC |
| OLD | NEW |