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_S390 | 5 #if V8_TARGET_ARCH_S390 |
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 1184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1195 // Push function as argument and compile for baseline. | 1195 // Push function as argument and compile for baseline. |
1196 __ push(r3); | 1196 __ push(r3); |
1197 __ CallRuntime(Runtime::kCompileBaseline); | 1197 __ CallRuntime(Runtime::kCompileBaseline); |
1198 | 1198 |
1199 // Restore return value. | 1199 // Restore return value. |
1200 __ pop(r2); | 1200 __ pop(r2); |
1201 } | 1201 } |
1202 __ Ret(); | 1202 __ Ret(); |
1203 } | 1203 } |
1204 | 1204 |
| 1205 static void Generate_StackOverflowCheck(MacroAssembler* masm, Register num_args, |
| 1206 Register scratch, |
| 1207 Label* stack_overflow) { |
| 1208 // Check the stack for overflow. We are not trying to catch |
| 1209 // interruptions (e.g. debug break and preemption) here, so the "real stack |
| 1210 // limit" is checked. |
| 1211 __ LoadRoot(scratch, Heap::kRealStackLimitRootIndex); |
| 1212 // Make scratch the space we have left. The stack might already be overflowed |
| 1213 // here which will cause scratch to become negative. |
| 1214 __ SubP(scratch, sp, scratch); |
| 1215 // Check if the arguments will overflow the stack. |
| 1216 __ ShiftLeftP(r0, num_args, Operand(kPointerSizeLog2)); |
| 1217 __ CmpP(scratch, r0); |
| 1218 __ ble(stack_overflow); // Signed comparison. |
| 1219 } |
| 1220 |
1205 static void Generate_InterpreterPushArgs(MacroAssembler* masm, | 1221 static void Generate_InterpreterPushArgs(MacroAssembler* masm, |
1206 Register num_args, Register index, | 1222 Register num_args, Register index, |
1207 Register count, Register scratch) { | 1223 Register count, Register scratch, |
1208 // TODO(mythria): Add a stack check before pushing arguments. | 1224 Label* stack_overflow) { |
| 1225 // Add a stack check before pushing arguments. |
| 1226 Generate_StackOverflowCheck(masm, num_args, scratch, stack_overflow); |
| 1227 |
1209 Label loop; | 1228 Label loop; |
1210 __ AddP(index, index, Operand(kPointerSize)); // Bias up for LoadPU | 1229 __ AddP(index, index, Operand(kPointerSize)); // Bias up for LoadPU |
1211 __ LoadRR(r0, count); | 1230 __ LoadRR(r0, count); |
1212 __ bind(&loop); | 1231 __ bind(&loop); |
1213 __ LoadP(scratch, MemOperand(index, -kPointerSize)); | 1232 __ LoadP(scratch, MemOperand(index, -kPointerSize)); |
1214 __ lay(index, MemOperand(index, -kPointerSize)); | 1233 __ lay(index, MemOperand(index, -kPointerSize)); |
1215 __ push(scratch); | 1234 __ push(scratch); |
1216 __ SubP(r0, Operand(1)); | 1235 __ SubP(r0, Operand(1)); |
1217 __ bne(&loop); | 1236 __ bne(&loop); |
1218 } | 1237 } |
1219 | 1238 |
1220 // static | 1239 // static |
1221 void Builtins::Generate_InterpreterPushArgsAndCallImpl( | 1240 void Builtins::Generate_InterpreterPushArgsAndCallImpl( |
1222 MacroAssembler* masm, TailCallMode tail_call_mode, | 1241 MacroAssembler* masm, TailCallMode tail_call_mode, |
1223 CallableType function_type) { | 1242 CallableType function_type) { |
1224 // ----------- S t a t e ------------- | 1243 // ----------- S t a t e ------------- |
1225 // -- r2 : the number of arguments (not including the receiver) | 1244 // -- r2 : the number of arguments (not including the receiver) |
1226 // -- r4 : the address of the first argument to be pushed. Subsequent | 1245 // -- r4 : the address of the first argument to be pushed. Subsequent |
1227 // arguments should be consecutive above this, in the same order as | 1246 // arguments should be consecutive above this, in the same order as |
1228 // they are to be pushed onto the stack. | 1247 // they are to be pushed onto the stack. |
1229 // -- r3 : the target to call (can be any Object). | 1248 // -- r3 : the target to call (can be any Object). |
1230 // ----------------------------------- | 1249 // ----------------------------------- |
| 1250 Label stack_overflow; |
1231 | 1251 |
1232 // Calculate number of arguments (AddP one for receiver). | 1252 // Calculate number of arguments (AddP one for receiver). |
1233 __ AddP(r5, r2, Operand(1)); | 1253 __ AddP(r5, r2, Operand(1)); |
1234 | 1254 |
1235 // Push the arguments. | 1255 // Push the arguments. |
1236 Generate_InterpreterPushArgs(masm, r5, r4, r5, r6); | 1256 Generate_InterpreterPushArgs(masm, r5, r4, r5, r6, &stack_overflow); |
1237 | 1257 |
1238 // Call the target. | 1258 // Call the target. |
1239 if (function_type == CallableType::kJSFunction) { | 1259 if (function_type == CallableType::kJSFunction) { |
1240 __ Jump(masm->isolate()->builtins()->CallFunction(ConvertReceiverMode::kAny, | 1260 __ Jump(masm->isolate()->builtins()->CallFunction(ConvertReceiverMode::kAny, |
1241 tail_call_mode), | 1261 tail_call_mode), |
1242 RelocInfo::CODE_TARGET); | 1262 RelocInfo::CODE_TARGET); |
1243 } else { | 1263 } else { |
1244 DCHECK_EQ(function_type, CallableType::kAny); | 1264 DCHECK_EQ(function_type, CallableType::kAny); |
1245 __ Jump(masm->isolate()->builtins()->Call(ConvertReceiverMode::kAny, | 1265 __ Jump(masm->isolate()->builtins()->Call(ConvertReceiverMode::kAny, |
1246 tail_call_mode), | 1266 tail_call_mode), |
1247 RelocInfo::CODE_TARGET); | 1267 RelocInfo::CODE_TARGET); |
1248 } | 1268 } |
| 1269 |
| 1270 __ bind(&stack_overflow); |
| 1271 { |
| 1272 __ TailCallRuntime(Runtime::kThrowStackOverflow); |
| 1273 // Unreachable Code. |
| 1274 __ bkpt(0); |
| 1275 } |
1249 } | 1276 } |
1250 | 1277 |
1251 // static | 1278 // static |
1252 void Builtins::Generate_InterpreterPushArgsAndConstructImpl( | 1279 void Builtins::Generate_InterpreterPushArgsAndConstructImpl( |
1253 MacroAssembler* masm, CallableType construct_type) { | 1280 MacroAssembler* masm, CallableType construct_type) { |
1254 // ----------- S t a t e ------------- | 1281 // ----------- S t a t e ------------- |
1255 // -- r2 : argument count (not including receiver) | 1282 // -- r2 : argument count (not including receiver) |
1256 // -- r5 : new target | 1283 // -- r5 : new target |
1257 // -- r3 : constructor to call | 1284 // -- r3 : constructor to call |
1258 // -- r4 : allocation site feedback if available, undefined otherwise. | 1285 // -- r4 : allocation site feedback if available, undefined otherwise. |
1259 // -- r6 : address of the first argument | 1286 // -- r6 : address of the first argument |
1260 // ----------------------------------- | 1287 // ----------------------------------- |
| 1288 Label stack_overflow; |
1261 | 1289 |
1262 // Push a slot for the receiver to be constructed. | 1290 // Push a slot for the receiver to be constructed. |
1263 __ LoadImmP(r0, Operand::Zero()); | 1291 __ LoadImmP(r0, Operand::Zero()); |
1264 __ push(r0); | 1292 __ push(r0); |
1265 | 1293 |
1266 // Push the arguments (skip if none). | 1294 // Push the arguments (skip if none). |
1267 Label skip; | 1295 Label skip; |
1268 __ CmpP(r2, Operand::Zero()); | 1296 __ CmpP(r2, Operand::Zero()); |
1269 __ beq(&skip); | 1297 __ beq(&skip); |
1270 Generate_InterpreterPushArgs(masm, r2, r6, r2, r7); | 1298 Generate_InterpreterPushArgs(masm, r2, r6, r2, r7, &stack_overflow); |
1271 __ bind(&skip); | 1299 __ bind(&skip); |
1272 | 1300 |
1273 __ AssertUndefinedOrAllocationSite(r4, r7); | 1301 __ AssertUndefinedOrAllocationSite(r4, r7); |
1274 if (construct_type == CallableType::kJSFunction) { | 1302 if (construct_type == CallableType::kJSFunction) { |
1275 __ AssertFunction(r3); | 1303 __ AssertFunction(r3); |
1276 | 1304 |
1277 // Tail call to the function-specific construct stub (still in the caller | 1305 // Tail call to the function-specific construct stub (still in the caller |
1278 // context at this point). | 1306 // context at this point). |
1279 __ LoadP(r6, FieldMemOperand(r3, JSFunction::kSharedFunctionInfoOffset)); | 1307 __ LoadP(r6, FieldMemOperand(r3, JSFunction::kSharedFunctionInfoOffset)); |
1280 __ LoadP(r6, FieldMemOperand(r6, SharedFunctionInfo::kConstructStubOffset)); | 1308 __ LoadP(r6, FieldMemOperand(r6, SharedFunctionInfo::kConstructStubOffset)); |
1281 // Jump to the construct function. | 1309 // Jump to the construct function. |
1282 __ AddP(ip, r6, Operand(Code::kHeaderSize - kHeapObjectTag)); | 1310 __ AddP(ip, r6, Operand(Code::kHeaderSize - kHeapObjectTag)); |
1283 __ Jump(ip); | 1311 __ Jump(ip); |
1284 | 1312 |
1285 } else { | 1313 } else { |
1286 DCHECK_EQ(construct_type, CallableType::kAny); | 1314 DCHECK_EQ(construct_type, CallableType::kAny); |
1287 // Call the constructor with r2, r3, and r5 unmodified. | 1315 // Call the constructor with r2, r3, and r5 unmodified. |
1288 __ Jump(masm->isolate()->builtins()->Construct(), RelocInfo::CODE_TARGET); | 1316 __ Jump(masm->isolate()->builtins()->Construct(), RelocInfo::CODE_TARGET); |
1289 } | 1317 } |
| 1318 |
| 1319 __ bind(&stack_overflow); |
| 1320 { |
| 1321 __ TailCallRuntime(Runtime::kThrowStackOverflow); |
| 1322 // Unreachable Code. |
| 1323 __ bkpt(0); |
| 1324 } |
1290 } | 1325 } |
1291 | 1326 |
1292 // static | 1327 // static |
1293 void Builtins::Generate_InterpreterPushArgsAndConstructArray( | 1328 void Builtins::Generate_InterpreterPushArgsAndConstructArray( |
1294 MacroAssembler* masm) { | 1329 MacroAssembler* masm) { |
1295 // ----------- S t a t e ------------- | 1330 // ----------- S t a t e ------------- |
1296 // -- r2 : argument count (not including receiver) | 1331 // -- r2 : argument count (not including receiver) |
1297 // -- r3 : target to call verified to be Array function | 1332 // -- r3 : target to call verified to be Array function |
1298 // -- r4 : allocation site feedback if available, undefined otherwise. | 1333 // -- r4 : allocation site feedback if available, undefined otherwise. |
1299 // -- r5 : address of the first argument | 1334 // -- r5 : address of the first argument |
1300 // ----------------------------------- | 1335 // ----------------------------------- |
| 1336 Label stack_overflow; |
1301 | 1337 |
1302 __ AddP(r6, r2, Operand(1)); // Add one for receiver. | 1338 __ AddP(r6, r2, Operand(1)); // Add one for receiver. |
1303 | 1339 |
1304 // TODO(mythria): Add a stack check before pushing arguments. | |
1305 // Push the arguments. r6, r8, r3 will be modified. | 1340 // Push the arguments. r6, r8, r3 will be modified. |
1306 Generate_InterpreterPushArgs(masm, r6, r5, r6, r7); | 1341 Generate_InterpreterPushArgs(masm, r6, r5, r6, r7, &stack_overflow); |
1307 | 1342 |
1308 // Array constructor expects constructor in r5. It is same as r3 here. | 1343 // Array constructor expects constructor in r5. It is same as r3 here. |
1309 __ LoadRR(r5, r3); | 1344 __ LoadRR(r5, r3); |
1310 | 1345 |
1311 ArrayConstructorStub stub(masm->isolate()); | 1346 ArrayConstructorStub stub(masm->isolate()); |
1312 __ TailCallStub(&stub); | 1347 __ TailCallStub(&stub); |
| 1348 |
| 1349 __ bind(&stack_overflow); |
| 1350 { |
| 1351 __ TailCallRuntime(Runtime::kThrowStackOverflow); |
| 1352 // Unreachable Code. |
| 1353 __ bkpt(0); |
| 1354 } |
1313 } | 1355 } |
1314 | 1356 |
1315 void Builtins::Generate_InterpreterEnterBytecodeDispatch(MacroAssembler* masm) { | 1357 void Builtins::Generate_InterpreterEnterBytecodeDispatch(MacroAssembler* masm) { |
1316 // Set the return address to the correct point in the interpreter entry | 1358 // Set the return address to the correct point in the interpreter entry |
1317 // trampoline. | 1359 // trampoline. |
1318 Smi* interpreter_entry_return_pc_offset( | 1360 Smi* interpreter_entry_return_pc_offset( |
1319 masm->isolate()->heap()->interpreter_entry_return_pc_offset()); | 1361 masm->isolate()->heap()->interpreter_entry_return_pc_offset()); |
1320 DCHECK_NE(interpreter_entry_return_pc_offset, Smi::FromInt(0)); | 1362 DCHECK_NE(interpreter_entry_return_pc_offset, Smi::FromInt(0)); |
1321 __ Move(r4, masm->isolate()->builtins()->InterpreterEntryTrampoline()); | 1363 __ Move(r4, masm->isolate()->builtins()->InterpreterEntryTrampoline()); |
1322 __ AddP(r14, r4, Operand(interpreter_entry_return_pc_offset->value() + | 1364 __ AddP(r14, r4, Operand(interpreter_entry_return_pc_offset->value() + |
(...skipping 821 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2144 } | 2186 } |
2145 | 2187 |
2146 // 4c. The new.target is not a constructor, throw an appropriate TypeError. | 2188 // 4c. The new.target is not a constructor, throw an appropriate TypeError. |
2147 __ bind(&new_target_not_constructor); | 2189 __ bind(&new_target_not_constructor); |
2148 { | 2190 { |
2149 __ StoreP(r5, MemOperand(sp, 0)); | 2191 __ StoreP(r5, MemOperand(sp, 0)); |
2150 __ TailCallRuntime(Runtime::kThrowCalledNonCallable); | 2192 __ TailCallRuntime(Runtime::kThrowCalledNonCallable); |
2151 } | 2193 } |
2152 } | 2194 } |
2153 | 2195 |
2154 static void ArgumentAdaptorStackCheck(MacroAssembler* masm, | |
2155 Label* stack_overflow) { | |
2156 // ----------- S t a t e ------------- | |
2157 // -- r2 : actual number of arguments | |
2158 // -- r3 : function (passed through to callee) | |
2159 // -- r4 : expected number of arguments | |
2160 // -- r5 : new target (passed through to callee) | |
2161 // ----------------------------------- | |
2162 // Check the stack for overflow. We are not trying to catch | |
2163 // interruptions (e.g. debug break and preemption) here, so the "real stack | |
2164 // limit" is checked. | |
2165 __ LoadRoot(r7, Heap::kRealStackLimitRootIndex); | |
2166 // Make r7 the space we have left. The stack might already be overflowed | |
2167 // here which will cause r7 to become negative. | |
2168 __ SubP(r7, sp, r7); | |
2169 // Check if the arguments will overflow the stack. | |
2170 __ ShiftLeftP(r0, r4, Operand(kPointerSizeLog2)); | |
2171 __ CmpP(r7, r0); | |
2172 __ ble(stack_overflow); // Signed comparison. | |
2173 } | |
2174 | |
2175 static void EnterArgumentsAdaptorFrame(MacroAssembler* masm) { | 2196 static void EnterArgumentsAdaptorFrame(MacroAssembler* masm) { |
2176 __ SmiTag(r2); | 2197 __ SmiTag(r2); |
2177 __ LoadSmiLiteral(r6, Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR)); | 2198 __ LoadSmiLiteral(r6, Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR)); |
2178 // Stack updated as such: | 2199 // Stack updated as such: |
2179 // old SP ---> | 2200 // old SP ---> |
2180 // R14 Return Addr | 2201 // R14 Return Addr |
2181 // Old FP <--- New FP | 2202 // Old FP <--- New FP |
2182 // Argument Adapter SMI | 2203 // Argument Adapter SMI |
2183 // Function | 2204 // Function |
2184 // ArgC as SMI <--- New SP | 2205 // ArgC as SMI <--- New SP |
(...skipping 700 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2885 Label enough, too_few; | 2906 Label enough, too_few; |
2886 __ LoadP(ip, FieldMemOperand(r3, JSFunction::kCodeEntryOffset)); | 2907 __ LoadP(ip, FieldMemOperand(r3, JSFunction::kCodeEntryOffset)); |
2887 __ CmpP(r2, r4); | 2908 __ CmpP(r2, r4); |
2888 __ blt(&too_few); | 2909 __ blt(&too_few); |
2889 __ CmpP(r4, Operand(SharedFunctionInfo::kDontAdaptArgumentsSentinel)); | 2910 __ CmpP(r4, Operand(SharedFunctionInfo::kDontAdaptArgumentsSentinel)); |
2890 __ beq(&dont_adapt_arguments); | 2911 __ beq(&dont_adapt_arguments); |
2891 | 2912 |
2892 { // Enough parameters: actual >= expected | 2913 { // Enough parameters: actual >= expected |
2893 __ bind(&enough); | 2914 __ bind(&enough); |
2894 EnterArgumentsAdaptorFrame(masm); | 2915 EnterArgumentsAdaptorFrame(masm); |
2895 ArgumentAdaptorStackCheck(masm, &stack_overflow); | 2916 Generate_StackOverflowCheck(masm, r4, r7, &stack_overflow); |
2896 | 2917 |
2897 // Calculate copy start address into r2 and copy end address into r6. | 2918 // Calculate copy start address into r2 and copy end address into r6. |
2898 // r2: actual number of arguments as a smi | 2919 // r2: actual number of arguments as a smi |
2899 // r3: function | 2920 // r3: function |
2900 // r4: expected number of arguments | 2921 // r4: expected number of arguments |
2901 // r5: new target (passed through to callee) | 2922 // r5: new target (passed through to callee) |
2902 // ip: code entry to call | 2923 // ip: code entry to call |
2903 __ SmiToPtrArrayOffset(r2, r2); | 2924 __ SmiToPtrArrayOffset(r2, r2); |
2904 __ AddP(r2, fp); | 2925 __ AddP(r2, fp); |
2905 // adjust for return address and receiver | 2926 // adjust for return address and receiver |
(...skipping 17 matching lines...) Expand all Loading... |
2923 __ lay(r2, MemOperand(r2, -kPointerSize)); | 2944 __ lay(r2, MemOperand(r2, -kPointerSize)); |
2924 __ bne(©); | 2945 __ bne(©); |
2925 | 2946 |
2926 __ b(&invoke); | 2947 __ b(&invoke); |
2927 } | 2948 } |
2928 | 2949 |
2929 { // Too few parameters: Actual < expected | 2950 { // Too few parameters: Actual < expected |
2930 __ bind(&too_few); | 2951 __ bind(&too_few); |
2931 | 2952 |
2932 EnterArgumentsAdaptorFrame(masm); | 2953 EnterArgumentsAdaptorFrame(masm); |
2933 ArgumentAdaptorStackCheck(masm, &stack_overflow); | 2954 Generate_StackOverflowCheck(masm, r4, r7, &stack_overflow); |
2934 | 2955 |
2935 // Calculate copy start address into r0 and copy end address is fp. | 2956 // Calculate copy start address into r0 and copy end address is fp. |
2936 // r2: actual number of arguments as a smi | 2957 // r2: actual number of arguments as a smi |
2937 // r3: function | 2958 // r3: function |
2938 // r4: expected number of arguments | 2959 // r4: expected number of arguments |
2939 // r5: new target (passed through to callee) | 2960 // r5: new target (passed through to callee) |
2940 // ip: code entry to call | 2961 // ip: code entry to call |
2941 __ SmiToPtrArrayOffset(r2, r2); | 2962 __ SmiToPtrArrayOffset(r2, r2); |
2942 __ lay(r2, MemOperand(r2, fp)); | 2963 __ lay(r2, MemOperand(r2, fp)); |
2943 | 2964 |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3002 __ bkpt(0); | 3023 __ bkpt(0); |
3003 } | 3024 } |
3004 } | 3025 } |
3005 | 3026 |
3006 #undef __ | 3027 #undef __ |
3007 | 3028 |
3008 } // namespace internal | 3029 } // namespace internal |
3009 } // namespace v8 | 3030 } // namespace v8 |
3010 | 3031 |
3011 #endif // V8_TARGET_ARCH_S390 | 3032 #endif // V8_TARGET_ARCH_S390 |
OLD | NEW |