OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 #ifndef V8_ARM64_SIMULATOR_ARM64_H_ | 5 #ifndef V8_ARM64_SIMULATOR_ARM64_H_ |
6 #define V8_ARM64_SIMULATOR_ARM64_H_ | 6 #define V8_ARM64_SIMULATOR_ARM64_H_ |
7 | 7 |
8 #include <stdarg.h> | 8 #include <stdarg.h> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "src/allocation.h" | 11 #include "src/allocation.h" |
12 #include "src/arm64/assembler-arm64.h" | 12 #include "src/arm64/assembler-arm64.h" |
13 #include "src/arm64/decoder-arm64.h" | 13 #include "src/arm64/decoder-arm64.h" |
14 #include "src/arm64/disasm-arm64.h" | 14 #include "src/arm64/disasm-arm64.h" |
15 #include "src/arm64/instrument-arm64.h" | 15 #include "src/arm64/instrument-arm64.h" |
16 #include "src/assembler.h" | 16 #include "src/assembler.h" |
17 #include "src/globals.h" | 17 #include "src/globals.h" |
18 #include "src/utils.h" | 18 #include "src/utils.h" |
19 | 19 |
20 namespace v8 { | 20 namespace v8 { |
21 namespace internal { | 21 namespace internal { |
22 | 22 |
23 #if !defined(USE_SIMULATOR) | 23 #if !defined(USE_SIMULATOR) |
24 | 24 |
25 // Running without a simulator on a native ARM64 platform. | 25 // Running without a simulator on a native ARM64 platform. |
26 // When running without a simulator we call the entry directly. | 26 // When running without a simulator we call the entry directly. |
27 #define CALL_GENERATED_CODE(entry, p0, p1, p2, p3, p4) \ | 27 #define CALL_GENERATED_CODE(isolate, entry, p0, p1, p2, p3, p4) \ |
28 (entry(p0, p1, p2, p3, p4)) | 28 (entry(p0, p1, p2, p3, p4)) |
29 | 29 |
30 typedef int (*arm64_regexp_matcher)(String* input, | 30 typedef int (*arm64_regexp_matcher)(String* input, |
31 int64_t start_offset, | 31 int64_t start_offset, |
32 const byte* input_start, | 32 const byte* input_start, |
33 const byte* input_end, | 33 const byte* input_end, |
34 int* output, | 34 int* output, |
35 int64_t output_size, | 35 int64_t output_size, |
36 Address stack_base, | 36 Address stack_base, |
37 int64_t direct_call, | 37 int64_t direct_call, |
38 void* return_address, | 38 void* return_address, |
39 Isolate* isolate); | 39 Isolate* isolate); |
40 | 40 |
41 // Call the generated regexp code directly. The code at the entry address | 41 // Call the generated regexp code directly. The code at the entry address |
42 // should act as a function matching the type arm64_regexp_matcher. | 42 // should act as a function matching the type arm64_regexp_matcher. |
43 // The ninth argument is a dummy that reserves the space used for | 43 // The ninth argument is a dummy that reserves the space used for |
44 // the return address added by the ExitFrame in native calls. | 44 // the return address added by the ExitFrame in native calls. |
45 #define CALL_GENERATED_REGEXP_CODE(entry, p0, p1, p2, p3, p4, p5, p6, p7, p8) \ | 45 #define CALL_GENERATED_REGEXP_CODE(isolate, entry, p0, p1, p2, p3, p4, p5, p6, \ |
46 (FUNCTION_CAST<arm64_regexp_matcher>(entry)( \ | 46 p7, p8) \ |
47 p0, p1, p2, p3, p4, p5, p6, p7, NULL, p8)) | 47 (FUNCTION_CAST<arm64_regexp_matcher>(entry)(p0, p1, p2, p3, p4, p5, p6, p7, \ |
| 48 NULL, p8)) |
48 | 49 |
49 // Running without a simulator there is nothing to do. | 50 // Running without a simulator there is nothing to do. |
50 class SimulatorStack : public v8::internal::AllStatic { | 51 class SimulatorStack : public v8::internal::AllStatic { |
51 public: | 52 public: |
52 static uintptr_t JsLimitFromCLimit(v8::internal::Isolate* isolate, | 53 static uintptr_t JsLimitFromCLimit(v8::internal::Isolate* isolate, |
53 uintptr_t c_limit) { | 54 uintptr_t c_limit) { |
54 USE(isolate); | 55 USE(isolate); |
55 return c_limit; | 56 return c_limit; |
56 } | 57 } |
57 | 58 |
58 static uintptr_t RegisterCTryCatch(uintptr_t try_catch_address) { | 59 static uintptr_t RegisterCTryCatch(v8::internal::Isolate* isolate, |
| 60 uintptr_t try_catch_address) { |
| 61 USE(isolate); |
59 return try_catch_address; | 62 return try_catch_address; |
60 } | 63 } |
61 | 64 |
62 static void UnregisterCTryCatch() { } | 65 static void UnregisterCTryCatch(v8::internal::Isolate* isolate) { |
| 66 USE(isolate); |
| 67 } |
63 }; | 68 }; |
64 | 69 |
65 #else // !defined(USE_SIMULATOR) | 70 #else // !defined(USE_SIMULATOR) |
66 | 71 |
67 | 72 |
68 // The proper way to initialize a simulated system register (such as NZCV) is as | 73 // The proper way to initialize a simulated system register (such as NZCV) is as |
69 // follows: | 74 // follows: |
70 // SimSystemRegister nzcv = SimSystemRegister::DefaultValueFor(NZCV); | 75 // SimSystemRegister nzcv = SimSystemRegister::DefaultValueFor(NZCV); |
71 class SimSystemRegister { | 76 class SimSystemRegister { |
72 public: | 77 public: |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
265 | 270 |
266 // Pop an address from the JS stack. | 271 // Pop an address from the JS stack. |
267 uintptr_t PopAddress(); | 272 uintptr_t PopAddress(); |
268 | 273 |
269 // Accessor to the internal simulator stack area. | 274 // Accessor to the internal simulator stack area. |
270 uintptr_t StackLimit(uintptr_t c_limit) const; | 275 uintptr_t StackLimit(uintptr_t c_limit) const; |
271 | 276 |
272 void ResetState(); | 277 void ResetState(); |
273 | 278 |
274 // Runtime call support. | 279 // Runtime call support. |
275 static void* RedirectExternalReference(void* external_function, | 280 static void* RedirectExternalReference(Isolate* isolate, |
| 281 void* external_function, |
276 ExternalReference::Type type); | 282 ExternalReference::Type type); |
277 void DoRuntimeCall(Instruction* instr); | 283 void DoRuntimeCall(Instruction* instr); |
278 | 284 |
279 // Run the simulator. | 285 // Run the simulator. |
280 static const Instruction* kEndOfSimAddress; | 286 static const Instruction* kEndOfSimAddress; |
281 void DecodeInstruction(); | 287 void DecodeInstruction(); |
282 void Run(); | 288 void Run(); |
283 void RunFrom(Instruction* start); | 289 void RunFrom(Instruction* start); |
284 | 290 |
285 // Simulation helpers. | 291 // Simulation helpers. |
(...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
864 private: | 870 private: |
865 void Init(FILE* stream); | 871 void Init(FILE* stream); |
866 | 872 |
867 int log_parameters_; | 873 int log_parameters_; |
868 Isolate* isolate_; | 874 Isolate* isolate_; |
869 }; | 875 }; |
870 | 876 |
871 | 877 |
872 // When running with the simulator transition into simulated execution at this | 878 // When running with the simulator transition into simulated execution at this |
873 // point. | 879 // point. |
874 #define CALL_GENERATED_CODE(entry, p0, p1, p2, p3, p4) \ | 880 #define CALL_GENERATED_CODE(isolate, entry, p0, p1, p2, p3, p4) \ |
875 reinterpret_cast<Object*>(Simulator::current(Isolate::Current())->CallJS( \ | 881 reinterpret_cast<Object*>(Simulator::current(isolate)->CallJS( \ |
876 FUNCTION_ADDR(entry), \ | 882 FUNCTION_ADDR(entry), p0, p1, p2, p3, p4)) |
877 p0, p1, p2, p3, p4)) | |
878 | 883 |
879 #define CALL_GENERATED_REGEXP_CODE(entry, p0, p1, p2, p3, p4, p5, p6, p7, p8) \ | 884 #define CALL_GENERATED_REGEXP_CODE(isolate, entry, p0, p1, p2, p3, p4, p5, p6, \ |
880 static_cast<int>( \ | 885 p7, p8) \ |
881 Simulator::current(Isolate::Current()) \ | 886 static_cast<int>(Simulator::current(isolate)->CallRegExp( \ |
882 ->CallRegExp(entry, p0, p1, p2, p3, p4, p5, p6, p7, NULL, p8)) | 887 entry, p0, p1, p2, p3, p4, p5, p6, p7, NULL, p8)) |
883 | 888 |
884 | 889 |
885 // The simulator has its own stack. Thus it has a different stack limit from | 890 // The simulator has its own stack. Thus it has a different stack limit from |
886 // the C-based native code. The JS-based limit normally points near the end of | 891 // the C-based native code. The JS-based limit normally points near the end of |
887 // the simulator stack. When the C-based limit is exhausted we reflect that by | 892 // the simulator stack. When the C-based limit is exhausted we reflect that by |
888 // lowering the JS-based limit as well, to make stack checks trigger. | 893 // lowering the JS-based limit as well, to make stack checks trigger. |
889 class SimulatorStack : public v8::internal::AllStatic { | 894 class SimulatorStack : public v8::internal::AllStatic { |
890 public: | 895 public: |
891 static uintptr_t JsLimitFromCLimit(v8::internal::Isolate* isolate, | 896 static uintptr_t JsLimitFromCLimit(v8::internal::Isolate* isolate, |
892 uintptr_t c_limit) { | 897 uintptr_t c_limit) { |
893 return Simulator::current(isolate)->StackLimit(c_limit); | 898 return Simulator::current(isolate)->StackLimit(c_limit); |
894 } | 899 } |
895 | 900 |
896 static uintptr_t RegisterCTryCatch(uintptr_t try_catch_address) { | 901 static uintptr_t RegisterCTryCatch(v8::internal::Isolate* isolate, |
897 Simulator* sim = Simulator::current(Isolate::Current()); | 902 uintptr_t try_catch_address) { |
| 903 Simulator* sim = Simulator::current(isolate); |
898 return sim->PushAddress(try_catch_address); | 904 return sim->PushAddress(try_catch_address); |
899 } | 905 } |
900 | 906 |
901 static void UnregisterCTryCatch() { | 907 static void UnregisterCTryCatch(v8::internal::Isolate* isolate) { |
902 Simulator::current(Isolate::Current())->PopAddress(); | 908 Simulator::current(isolate)->PopAddress(); |
903 } | 909 } |
904 }; | 910 }; |
905 | 911 |
906 #endif // !defined(USE_SIMULATOR) | 912 #endif // !defined(USE_SIMULATOR) |
907 | 913 |
908 } // namespace internal | 914 } // namespace internal |
909 } // namespace v8 | 915 } // namespace v8 |
910 | 916 |
911 #endif // V8_ARM64_SIMULATOR_ARM64_H_ | 917 #endif // V8_ARM64_SIMULATOR_ARM64_H_ |
OLD | NEW |