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 1079 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1090 // here which will cause scratch to become negative. | 1090 // here which will cause scratch to become negative. |
1091 __ sub(scratch, sp, scratch); | 1091 __ sub(scratch, sp, scratch); |
1092 // Check if the arguments will overflow the stack. | 1092 // Check if the arguments will overflow the stack. |
1093 __ ShiftLeftImm(r0, num_args, Operand(kPointerSizeLog2)); | 1093 __ ShiftLeftImm(r0, num_args, Operand(kPointerSizeLog2)); |
1094 __ cmp(scratch, r0); | 1094 __ cmp(scratch, r0); |
1095 __ ble(stack_overflow); // Signed comparison. | 1095 __ ble(stack_overflow); // Signed comparison. |
1096 } | 1096 } |
1097 | 1097 |
1098 static void Generate_InterpreterPushArgs(MacroAssembler* masm, | 1098 static void Generate_InterpreterPushArgs(MacroAssembler* masm, |
1099 Register num_args, Register index, | 1099 Register num_args, Register index, |
1100 Register count, Register scratch) { | 1100 Register count, Register scratch, |
| 1101 Label* stack_overflow) { |
| 1102 // A stack check before pushing arguments. |
| 1103 Generate_StackOverflowCheck(masm, num_args, scratch, stack_overflow); |
| 1104 |
1101 Label loop; | 1105 Label loop; |
1102 __ addi(index, index, Operand(kPointerSize)); // Bias up for LoadPU | 1106 __ addi(index, index, Operand(kPointerSize)); // Bias up for LoadPU |
1103 __ mtctr(count); | 1107 __ mtctr(count); |
1104 __ bind(&loop); | 1108 __ bind(&loop); |
1105 __ LoadPU(scratch, MemOperand(index, -kPointerSize)); | 1109 __ LoadPU(scratch, MemOperand(index, -kPointerSize)); |
1106 __ push(scratch); | 1110 __ push(scratch); |
1107 __ bdnz(&loop); | 1111 __ bdnz(&loop); |
1108 } | 1112 } |
1109 | 1113 |
1110 // static | 1114 // static |
1111 void Builtins::Generate_InterpreterPushArgsThenCallImpl( | 1115 void Builtins::Generate_InterpreterPushArgsThenCallImpl( |
1112 MacroAssembler* masm, ConvertReceiverMode receiver_mode, | 1116 MacroAssembler* masm, TailCallMode tail_call_mode, |
1113 TailCallMode tail_call_mode, InterpreterPushArgsMode mode) { | 1117 InterpreterPushArgsMode mode) { |
1114 // ----------- S t a t e ------------- | 1118 // ----------- S t a t e ------------- |
1115 // -- r3 : the number of arguments (not including the receiver) | 1119 // -- r3 : the number of arguments (not including the receiver) |
1116 // -- r5 : the address of the first argument to be pushed. Subsequent | 1120 // -- r5 : the address of the first argument to be pushed. Subsequent |
1117 // arguments should be consecutive above this, in the same order as | 1121 // arguments should be consecutive above this, in the same order as |
1118 // they are to be pushed onto the stack. | 1122 // they are to be pushed onto the stack. |
1119 // -- r4 : the target to call (can be any Object). | 1123 // -- r4 : the target to call (can be any Object). |
1120 // ----------------------------------- | 1124 // ----------------------------------- |
1121 Label stack_overflow; | 1125 Label stack_overflow; |
1122 | 1126 |
1123 // Calculate number of arguments (add one for receiver). | 1127 // Calculate number of arguments (add one for receiver). |
1124 __ addi(r6, r3, Operand(1)); | 1128 __ addi(r6, r3, Operand(1)); |
1125 | 1129 |
1126 Generate_StackOverflowCheck(masm, r6, ip, &stack_overflow); | |
1127 | |
1128 // Push "undefined" as the receiver arg if we need to. | |
1129 if (receiver_mode == ConvertReceiverMode::kNullOrUndefined) { | |
1130 __ PushRoot(Heap::kUndefinedValueRootIndex); | |
1131 __ mr(r6, r3); // Argument count is correct. | |
1132 } | |
1133 | |
1134 // Push the arguments. r5, r6, r7 will be modified. | 1130 // Push the arguments. r5, r6, r7 will be modified. |
1135 Generate_InterpreterPushArgs(masm, r6, r5, r6, r7); | 1131 Generate_InterpreterPushArgs(masm, r6, r5, r6, r7, &stack_overflow); |
1136 | 1132 |
1137 // Call the target. | 1133 // Call the target. |
1138 if (mode == InterpreterPushArgsMode::kJSFunction) { | 1134 if (mode == InterpreterPushArgsMode::kJSFunction) { |
1139 __ Jump(masm->isolate()->builtins()->CallFunction(ConvertReceiverMode::kAny, | 1135 __ Jump(masm->isolate()->builtins()->CallFunction(ConvertReceiverMode::kAny, |
1140 tail_call_mode), | 1136 tail_call_mode), |
1141 RelocInfo::CODE_TARGET); | 1137 RelocInfo::CODE_TARGET); |
1142 } else if (mode == InterpreterPushArgsMode::kWithFinalSpread) { | 1138 } else if (mode == InterpreterPushArgsMode::kWithFinalSpread) { |
1143 __ Jump(masm->isolate()->builtins()->CallWithSpread(), | 1139 __ Jump(masm->isolate()->builtins()->CallWithSpread(), |
1144 RelocInfo::CODE_TARGET); | 1140 RelocInfo::CODE_TARGET); |
1145 } else { | 1141 } else { |
(...skipping 23 matching lines...) Expand all Loading... |
1169 Label stack_overflow; | 1165 Label stack_overflow; |
1170 | 1166 |
1171 // Push a slot for the receiver to be constructed. | 1167 // Push a slot for the receiver to be constructed. |
1172 __ li(r0, Operand::Zero()); | 1168 __ li(r0, Operand::Zero()); |
1173 __ push(r0); | 1169 __ push(r0); |
1174 | 1170 |
1175 // Push the arguments (skip if none). | 1171 // Push the arguments (skip if none). |
1176 Label skip; | 1172 Label skip; |
1177 __ cmpi(r3, Operand::Zero()); | 1173 __ cmpi(r3, Operand::Zero()); |
1178 __ beq(&skip); | 1174 __ beq(&skip); |
1179 Generate_StackOverflowCheck(masm, r3, ip, &stack_overflow); | |
1180 // Push the arguments. r8, r7, r9 will be modified. | 1175 // Push the arguments. r8, r7, r9 will be modified. |
1181 Generate_InterpreterPushArgs(masm, r3, r7, r3, r9); | 1176 Generate_InterpreterPushArgs(masm, r3, r7, r3, r8, &stack_overflow); |
1182 __ bind(&skip); | 1177 __ bind(&skip); |
1183 | 1178 |
1184 __ AssertUndefinedOrAllocationSite(r5, r8); | 1179 __ AssertUndefinedOrAllocationSite(r5, r8); |
1185 if (mode == InterpreterPushArgsMode::kJSFunction) { | 1180 if (mode == InterpreterPushArgsMode::kJSFunction) { |
1186 __ AssertFunction(r4); | 1181 __ AssertFunction(r4); |
1187 | 1182 |
1188 // Tail call to the function-specific construct stub (still in the caller | 1183 // Tail call to the function-specific construct stub (still in the caller |
1189 // context at this point). | 1184 // context at this point). |
1190 __ LoadP(r7, FieldMemOperand(r4, JSFunction::kSharedFunctionInfoOffset)); | 1185 __ LoadP(r7, FieldMemOperand(r4, JSFunction::kSharedFunctionInfoOffset)); |
1191 __ LoadP(r7, FieldMemOperand(r7, SharedFunctionInfo::kConstructStubOffset)); | 1186 __ LoadP(r7, FieldMemOperand(r7, SharedFunctionInfo::kConstructStubOffset)); |
(...skipping 22 matching lines...) Expand all Loading... |
1214 void Builtins::Generate_InterpreterPushArgsThenConstructArray( | 1209 void Builtins::Generate_InterpreterPushArgsThenConstructArray( |
1215 MacroAssembler* masm) { | 1210 MacroAssembler* masm) { |
1216 // ----------- S t a t e ------------- | 1211 // ----------- S t a t e ------------- |
1217 // -- r3 : argument count (not including receiver) | 1212 // -- r3 : argument count (not including receiver) |
1218 // -- r4 : target to call verified to be Array function | 1213 // -- r4 : target to call verified to be Array function |
1219 // -- r5 : allocation site feedback if available, undefined otherwise. | 1214 // -- r5 : allocation site feedback if available, undefined otherwise. |
1220 // -- r6 : address of the first argument | 1215 // -- r6 : address of the first argument |
1221 // ----------------------------------- | 1216 // ----------------------------------- |
1222 Label stack_overflow; | 1217 Label stack_overflow; |
1223 | 1218 |
1224 // Push a slot for the receiver to be constructed. | 1219 __ addi(r7, r3, Operand(1)); // Add one for receiver. |
1225 __ li(r0, Operand::Zero()); | |
1226 __ push(r0); | |
1227 | |
1228 Generate_StackOverflowCheck(masm, r3, ip, &stack_overflow); | |
1229 | 1220 |
1230 // Push the arguments. r6, r8, r3 will be modified. | 1221 // Push the arguments. r6, r8, r3 will be modified. |
1231 Generate_InterpreterPushArgs(masm, r3, r6, r3, r8); | 1222 Generate_InterpreterPushArgs(masm, r7, r6, r7, r8, &stack_overflow); |
1232 | 1223 |
1233 // Array constructor expects constructor in r6. It is same as r4 here. | 1224 // Array constructor expects constructor in r6. It is same as r4 here. |
1234 __ mr(r6, r4); | 1225 __ mr(r6, r4); |
1235 | 1226 |
1236 ArrayConstructorStub stub(masm->isolate()); | 1227 ArrayConstructorStub stub(masm->isolate()); |
1237 __ TailCallStub(&stub); | 1228 __ TailCallStub(&stub); |
1238 | 1229 |
1239 __ bind(&stack_overflow); | 1230 __ bind(&stack_overflow); |
1240 { | 1231 { |
1241 __ TailCallRuntime(Runtime::kThrowStackOverflow); | 1232 __ TailCallRuntime(Runtime::kThrowStackOverflow); |
(...skipping 1844 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3086 } | 3077 } |
3087 // Now jump to the instructions of the returned code object. | 3078 // Now jump to the instructions of the returned code object. |
3088 __ Jump(r11); | 3079 __ Jump(r11); |
3089 } | 3080 } |
3090 | 3081 |
3091 #undef __ | 3082 #undef __ |
3092 } // namespace internal | 3083 } // namespace internal |
3093 } // namespace v8 | 3084 } // namespace v8 |
3094 | 3085 |
3095 #endif // V8_TARGET_ARCH_PPC | 3086 #endif // V8_TARGET_ARCH_PPC |
OLD | NEW |