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, void*, Isolate*); | 28 int, Address, int, 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. | |
34 #define CALL_GENERATED_REGEXP_CODE(isolate, entry, p0, p1, p2, p3, p4, p5, p6, \ | 32 #define CALL_GENERATED_REGEXP_CODE(isolate, entry, p0, p1, p2, p3, p4, p5, p6, \ |
35 p7, p8) \ | 33 p7, p8) \ |
36 (FUNCTION_CAST<s390_regexp_matcher>(entry)(p0, p1, p2, p3, p4, p5, p6, p7, \ | 34 (FUNCTION_CAST<s390_regexp_matcher>(entry)(p0, p1, p2, p3, p4, p5, p6, p7, \ |
37 NULL, p8)) | 35 p8)) |
38 | 36 |
39 // The stack limit beyond which we will throw stack overflow errors in | 37 // The stack limit beyond which we will throw stack overflow errors in |
40 // generated code. Because generated code on s390 uses the C stack, we | 38 // generated code. Because generated code on s390 uses the C stack, we |
41 // just use the C stack limit. | 39 // just use the C stack limit. |
42 class SimulatorStack : public v8::internal::AllStatic { | 40 class SimulatorStack : public v8::internal::AllStatic { |
43 public: | 41 public: |
44 static inline uintptr_t JsLimitFromCLimit(v8::internal::Isolate* isolate, | 42 static inline uintptr_t JsLimitFromCLimit(v8::internal::Isolate* isolate, |
45 uintptr_t c_limit) { | 43 uintptr_t c_limit) { |
46 USE(isolate); | 44 USE(isolate); |
47 return c_limit; | 45 return c_limit; |
(...skipping 1204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1252 | 1250 |
1253 // When running with the simulator transition into simulated execution at this | 1251 // When running with the simulator transition into simulated execution at this |
1254 // point. | 1252 // point. |
1255 #define CALL_GENERATED_CODE(isolate, entry, p0, p1, p2, p3, p4) \ | 1253 #define CALL_GENERATED_CODE(isolate, entry, p0, p1, p2, p3, p4) \ |
1256 reinterpret_cast<Object*>(Simulator::current(isolate)->Call( \ | 1254 reinterpret_cast<Object*>(Simulator::current(isolate)->Call( \ |
1257 FUNCTION_ADDR(entry), 5, (intptr_t)p0, (intptr_t)p1, (intptr_t)p2, \ | 1255 FUNCTION_ADDR(entry), 5, (intptr_t)p0, (intptr_t)p1, (intptr_t)p2, \ |
1258 (intptr_t)p3, (intptr_t)p4)) | 1256 (intptr_t)p3, (intptr_t)p4)) |
1259 | 1257 |
1260 #define CALL_GENERATED_REGEXP_CODE(isolate, entry, p0, p1, p2, p3, p4, p5, p6, \ | 1258 #define CALL_GENERATED_REGEXP_CODE(isolate, entry, p0, p1, p2, p3, p4, p5, p6, \ |
1261 p7, p8) \ | 1259 p7, p8) \ |
1262 Simulator::current(isolate)->Call(entry, 10, (intptr_t)p0, (intptr_t)p1, \ | 1260 Simulator::current(isolate)->Call( \ |
1263 (intptr_t)p2, (intptr_t)p3, (intptr_t)p4, \ | 1261 entry, 9, (intptr_t)p0, (intptr_t)p1, (intptr_t)p2, (intptr_t)p3, \ |
1264 (intptr_t)p5, (intptr_t)p6, (intptr_t)p7, \ | 1262 (intptr_t)p4, (intptr_t)p5, (intptr_t)p6, (intptr_t)p7, (intptr_t)p8) |
1265 (intptr_t)NULL, (intptr_t)p8) | |
1266 | 1263 |
1267 // The simulator has its own stack. Thus it has a different stack limit from | 1264 // The simulator has its own stack. Thus it has a different stack limit from |
1268 // the C-based native code. The JS-based limit normally points near the end of | 1265 // the C-based native code. The JS-based limit normally points near the end of |
1269 // the simulator stack. When the C-based limit is exhausted we reflect that by | 1266 // the simulator stack. When the C-based limit is exhausted we reflect that by |
1270 // lowering the JS-based limit as well, to make stack checks trigger. | 1267 // lowering the JS-based limit as well, to make stack checks trigger. |
1271 class SimulatorStack : public v8::internal::AllStatic { | 1268 class SimulatorStack : public v8::internal::AllStatic { |
1272 public: | 1269 public: |
1273 static inline uintptr_t JsLimitFromCLimit(v8::internal::Isolate* isolate, | 1270 static inline uintptr_t JsLimitFromCLimit(v8::internal::Isolate* isolate, |
1274 uintptr_t c_limit) { | 1271 uintptr_t c_limit) { |
1275 return Simulator::current(isolate)->StackLimit(c_limit); | 1272 return Simulator::current(isolate)->StackLimit(c_limit); |
1276 } | 1273 } |
1277 | 1274 |
1278 static inline uintptr_t RegisterCTryCatch(v8::internal::Isolate* isolate, | 1275 static inline uintptr_t RegisterCTryCatch(v8::internal::Isolate* isolate, |
1279 uintptr_t try_catch_address) { | 1276 uintptr_t try_catch_address) { |
1280 Simulator* sim = Simulator::current(isolate); | 1277 Simulator* sim = Simulator::current(isolate); |
1281 return sim->PushAddress(try_catch_address); | 1278 return sim->PushAddress(try_catch_address); |
1282 } | 1279 } |
1283 | 1280 |
1284 static inline void UnregisterCTryCatch(v8::internal::Isolate* isolate) { | 1281 static inline void UnregisterCTryCatch(v8::internal::Isolate* isolate) { |
1285 Simulator::current(isolate)->PopAddress(); | 1282 Simulator::current(isolate)->PopAddress(); |
1286 } | 1283 } |
1287 }; | 1284 }; |
1288 | 1285 |
1289 } // namespace internal | 1286 } // namespace internal |
1290 } // namespace v8 | 1287 } // namespace v8 |
1291 | 1288 |
1292 #endif // !defined(USE_SIMULATOR) | 1289 #endif // !defined(USE_SIMULATOR) |
1293 #endif // V8_S390_SIMULATOR_S390_H_ | 1290 #endif // V8_S390_SIMULATOR_S390_H_ |
OLD | NEW |