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 // Declares a Simulator for S390 instructions if we are not generating a native | 5 // Declares a Simulator for S390 instructions if we are not generating a native |
6 // S390 binary. This Simulator allows us to run and debug S390 code generation | 6 // S390 binary. This Simulator allows us to run and debug S390 code generation |
7 // on regular desktop machines. | 7 // on regular desktop machines. |
8 // V8 calls into generated code by "calling" the CALL_GENERATED_CODE macro, | 8 // V8 calls into generated code by "calling" the CALL_GENERATED_CODE macro, |
9 // which will start execution in the Simulator or forwards to the real entry | 9 // which will start execution in the Simulator or forwards to the real entry |
10 // on a S390 hardware platform. | 10 // on a S390 hardware platform. |
11 | 11 |
12 #ifndef V8_S390_SIMULATOR_S390_H_ | 12 #ifndef V8_S390_SIMULATOR_S390_H_ |
13 #define V8_S390_SIMULATOR_S390_H_ | 13 #define V8_S390_SIMULATOR_S390_H_ |
14 | 14 |
15 #include "src/allocation.h" | 15 #include "src/allocation.h" |
16 | 16 |
17 #if !defined(USE_SIMULATOR) | 17 #if !defined(USE_SIMULATOR) |
18 // Running without a simulator on a native s390 platform. | 18 // Running without a simulator on a native s390 platform. |
19 | 19 |
20 namespace v8 { | 20 namespace v8 { |
21 namespace internal { | 21 namespace internal { |
22 | 22 |
23 // When running without a simulator we call the entry directly. | 23 // When running without a simulator we call the entry directly. |
24 #define CALL_GENERATED_CODE(isolate, entry, p0, p1, p2, p3, p4) \ | 24 #define CALL_GENERATED_CODE(isolate, entry, p0, p1, p2, p3, p4) \ |
25 (entry(p0, p1, p2, p3, p4)) | 25 (entry(p0, p1, p2, p3, p4)) |
26 | 26 |
27 typedef int (*s390_regexp_matcher)(String*, int, const byte*, const byte*, int*, | 27 typedef int (*s390_regexp_matcher)(String*, int, const byte*, const byte*, int*, |
28 int, Address, int, Isolate*); | 28 int, Address, int, void*, Isolate*); |
29 | 29 |
30 // Call the generated regexp code directly. The code at the entry address | 30 // Call the generated regexp code directly. The code at the entry address |
31 // should act as a function matching the type ppc_regexp_matcher. | 31 // should act as a function matching the type ppc_regexp_matcher. |
| 32 // The ninth argument is a dummy that reserves the space used for |
| 33 // the return address added by the ExitFrame in native calls. |
32 #define CALL_GENERATED_REGEXP_CODE(isolate, entry, p0, p1, p2, p3, p4, p5, p6, \ | 34 #define CALL_GENERATED_REGEXP_CODE(isolate, entry, p0, p1, p2, p3, p4, p5, p6, \ |
33 p7, p8) \ | 35 p7, p8) \ |
34 (FUNCTION_CAST<s390_regexp_matcher>(entry)(p0, p1, p2, p3, p4, p5, p6, p7, \ | 36 (FUNCTION_CAST<s390_regexp_matcher>(entry)(p0, p1, p2, p3, p4, p5, p6, p7, \ |
35 p8)) | 37 NULL, p8)) |
36 | 38 |
37 // The stack limit beyond which we will throw stack overflow errors in | 39 // The stack limit beyond which we will throw stack overflow errors in |
38 // generated code. Because generated code on s390 uses the C stack, we | 40 // generated code. Because generated code on s390 uses the C stack, we |
39 // just use the C stack limit. | 41 // just use the C stack limit. |
40 class SimulatorStack : public v8::internal::AllStatic { | 42 class SimulatorStack : public v8::internal::AllStatic { |
41 public: | 43 public: |
42 static inline uintptr_t JsLimitFromCLimit(v8::internal::Isolate* isolate, | 44 static inline uintptr_t JsLimitFromCLimit(v8::internal::Isolate* isolate, |
43 uintptr_t c_limit) { | 45 uintptr_t c_limit) { |
44 USE(isolate); | 46 USE(isolate); |
45 return c_limit; | 47 return c_limit; |
(...skipping 1204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1250 | 1252 |
1251 // When running with the simulator transition into simulated execution at this | 1253 // When running with the simulator transition into simulated execution at this |
1252 // point. | 1254 // point. |
1253 #define CALL_GENERATED_CODE(isolate, entry, p0, p1, p2, p3, p4) \ | 1255 #define CALL_GENERATED_CODE(isolate, entry, p0, p1, p2, p3, p4) \ |
1254 reinterpret_cast<Object*>(Simulator::current(isolate)->Call( \ | 1256 reinterpret_cast<Object*>(Simulator::current(isolate)->Call( \ |
1255 FUNCTION_ADDR(entry), 5, (intptr_t)p0, (intptr_t)p1, (intptr_t)p2, \ | 1257 FUNCTION_ADDR(entry), 5, (intptr_t)p0, (intptr_t)p1, (intptr_t)p2, \ |
1256 (intptr_t)p3, (intptr_t)p4)) | 1258 (intptr_t)p3, (intptr_t)p4)) |
1257 | 1259 |
1258 #define CALL_GENERATED_REGEXP_CODE(isolate, entry, p0, p1, p2, p3, p4, p5, p6, \ | 1260 #define CALL_GENERATED_REGEXP_CODE(isolate, entry, p0, p1, p2, p3, p4, p5, p6, \ |
1259 p7, p8) \ | 1261 p7, p8) \ |
1260 Simulator::current(isolate)->Call( \ | 1262 Simulator::current(isolate)->Call(entry, 10, (intptr_t)p0, (intptr_t)p1, \ |
1261 entry, 9, (intptr_t)p0, (intptr_t)p1, (intptr_t)p2, (intptr_t)p3, \ | 1263 (intptr_t)p2, (intptr_t)p3, (intptr_t)p4, \ |
1262 (intptr_t)p4, (intptr_t)p5, (intptr_t)p6, (intptr_t)p7, (intptr_t)p8) | 1264 (intptr_t)p5, (intptr_t)p6, (intptr_t)p7, \ |
| 1265 (intptr_t)NULL, (intptr_t)p8) |
1263 | 1266 |
1264 // The simulator has its own stack. Thus it has a different stack limit from | 1267 // The simulator has its own stack. Thus it has a different stack limit from |
1265 // the C-based native code. The JS-based limit normally points near the end of | 1268 // the C-based native code. The JS-based limit normally points near the end of |
1266 // the simulator stack. When the C-based limit is exhausted we reflect that by | 1269 // the simulator stack. When the C-based limit is exhausted we reflect that by |
1267 // lowering the JS-based limit as well, to make stack checks trigger. | 1270 // lowering the JS-based limit as well, to make stack checks trigger. |
1268 class SimulatorStack : public v8::internal::AllStatic { | 1271 class SimulatorStack : public v8::internal::AllStatic { |
1269 public: | 1272 public: |
1270 static inline uintptr_t JsLimitFromCLimit(v8::internal::Isolate* isolate, | 1273 static inline uintptr_t JsLimitFromCLimit(v8::internal::Isolate* isolate, |
1271 uintptr_t c_limit) { | 1274 uintptr_t c_limit) { |
1272 return Simulator::current(isolate)->StackLimit(c_limit); | 1275 return Simulator::current(isolate)->StackLimit(c_limit); |
1273 } | 1276 } |
1274 | 1277 |
1275 static inline uintptr_t RegisterCTryCatch(v8::internal::Isolate* isolate, | 1278 static inline uintptr_t RegisterCTryCatch(v8::internal::Isolate* isolate, |
1276 uintptr_t try_catch_address) { | 1279 uintptr_t try_catch_address) { |
1277 Simulator* sim = Simulator::current(isolate); | 1280 Simulator* sim = Simulator::current(isolate); |
1278 return sim->PushAddress(try_catch_address); | 1281 return sim->PushAddress(try_catch_address); |
1279 } | 1282 } |
1280 | 1283 |
1281 static inline void UnregisterCTryCatch(v8::internal::Isolate* isolate) { | 1284 static inline void UnregisterCTryCatch(v8::internal::Isolate* isolate) { |
1282 Simulator::current(isolate)->PopAddress(); | 1285 Simulator::current(isolate)->PopAddress(); |
1283 } | 1286 } |
1284 }; | 1287 }; |
1285 | 1288 |
1286 } // namespace internal | 1289 } // namespace internal |
1287 } // namespace v8 | 1290 } // namespace v8 |
1288 | 1291 |
1289 #endif // !defined(USE_SIMULATOR) | 1292 #endif // !defined(USE_SIMULATOR) |
1290 #endif // V8_S390_SIMULATOR_S390_H_ | 1293 #endif // V8_S390_SIMULATOR_S390_H_ |
OLD | NEW |