OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 p0, p1, p2, p3, NULL, p4, p5, p6, p7)) | 61 p0, p1, p2, p3, NULL, p4, p5, p6, p7)) |
62 | 62 |
63 #define TRY_CATCH_FROM_ADDRESS(try_catch_address) \ | 63 #define TRY_CATCH_FROM_ADDRESS(try_catch_address) \ |
64 reinterpret_cast<TryCatch*>(try_catch_address) | 64 reinterpret_cast<TryCatch*>(try_catch_address) |
65 | 65 |
66 // The stack limit beyond which we will throw stack overflow errors in | 66 // The stack limit beyond which we will throw stack overflow errors in |
67 // generated code. Because generated code on arm uses the C stack, we | 67 // generated code. Because generated code on arm uses the C stack, we |
68 // just use the C stack limit. | 68 // just use the C stack limit. |
69 class SimulatorStack : public v8::internal::AllStatic { | 69 class SimulatorStack : public v8::internal::AllStatic { |
70 public: | 70 public: |
71 static inline uintptr_t JsLimitFromCLimit(uintptr_t c_limit) { | 71 static inline uintptr_t JsLimitFromCLimit(v8::internal::Isolate* isolate, |
| 72 uintptr_t c_limit) { |
| 73 USE(isolate); |
72 return c_limit; | 74 return c_limit; |
73 } | 75 } |
74 | 76 |
75 static inline uintptr_t RegisterCTryCatch(uintptr_t try_catch_address) { | 77 static inline uintptr_t RegisterCTryCatch(uintptr_t try_catch_address) { |
76 return try_catch_address; | 78 return try_catch_address; |
77 } | 79 } |
78 | 80 |
79 static inline void UnregisterCTryCatch() { } | 81 static inline void UnregisterCTryCatch() { } |
80 }; | 82 }; |
81 | 83 |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 s0 = 0, s1, s2, s3, s4, s5, s6, s7, | 138 s0 = 0, s1, s2, s3, s4, s5, s6, s7, |
137 s8, s9, s10, s11, s12, s13, s14, s15, | 139 s8, s9, s10, s11, s12, s13, s14, s15, |
138 s16, s17, s18, s19, s20, s21, s22, s23, | 140 s16, s17, s18, s19, s20, s21, s22, s23, |
139 s24, s25, s26, s27, s28, s29, s30, s31, | 141 s24, s25, s26, s27, s28, s29, s30, s31, |
140 num_s_registers = 32, | 142 num_s_registers = 32, |
141 d0 = 0, d1, d2, d3, d4, d5, d6, d7, | 143 d0 = 0, d1, d2, d3, d4, d5, d6, d7, |
142 d8, d9, d10, d11, d12, d13, d14, d15, | 144 d8, d9, d10, d11, d12, d13, d14, d15, |
143 num_d_registers = 16 | 145 num_d_registers = 16 |
144 }; | 146 }; |
145 | 147 |
146 Simulator(); | 148 explicit Simulator(Isolate* isolate); |
147 ~Simulator(); | 149 ~Simulator(); |
148 | 150 |
149 // The currently executing Simulator instance. Potentially there can be one | 151 // The currently executing Simulator instance. Potentially there can be one |
150 // for each native thread. | 152 // for each native thread. |
151 static Simulator* current(v8::internal::Isolate* isolate); | 153 static Simulator* current(v8::internal::Isolate* isolate); |
152 | 154 |
153 // Accessors for register state. Reading the pc value adheres to the ARM | 155 // Accessors for register state. Reading the pc value adheres to the ARM |
154 // architecture specification and is off by a 8 from the currently executing | 156 // architecture specification and is off by a 8 from the currently executing |
155 // instruction. | 157 // instruction. |
156 void set_register(int reg, int32_t value); | 158 void set_register(int reg, int32_t value); |
(...skipping 15 matching lines...) Expand all Loading... |
172 void set_pc(int32_t value); | 174 void set_pc(int32_t value); |
173 int32_t get_pc() const; | 175 int32_t get_pc() const; |
174 | 176 |
175 // Accessor to the internal simulator stack area. | 177 // Accessor to the internal simulator stack area. |
176 uintptr_t StackLimit() const; | 178 uintptr_t StackLimit() const; |
177 | 179 |
178 // Executes ARM instructions until the PC reaches end_sim_pc. | 180 // Executes ARM instructions until the PC reaches end_sim_pc. |
179 void Execute(); | 181 void Execute(); |
180 | 182 |
181 // Call on program start. | 183 // Call on program start. |
182 static void Initialize(); | 184 static void Initialize(Isolate* isolate); |
183 | 185 |
184 // V8 generally calls into generated JS code with 5 parameters and into | 186 // V8 generally calls into generated JS code with 5 parameters and into |
185 // generated RegExp code with 7 parameters. This is a convenience function, | 187 // generated RegExp code with 7 parameters. This is a convenience function, |
186 // which sets up the simulator state and grabs the result on return. | 188 // which sets up the simulator state and grabs the result on return. |
187 int32_t Call(byte* entry, int argument_count, ...); | 189 int32_t Call(byte* entry, int argument_count, ...); |
188 | 190 |
189 // Push an address onto the JS stack. | 191 // Push an address onto the JS stack. |
190 uintptr_t PushAddress(uintptr_t address); | 192 uintptr_t PushAddress(uintptr_t address); |
191 | 193 |
192 // Pop an address from the JS stack. | 194 // Pop an address from the JS stack. |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
401 NULL : *(reinterpret_cast<TryCatch**>(try_catch_address)) | 403 NULL : *(reinterpret_cast<TryCatch**>(try_catch_address)) |
402 | 404 |
403 | 405 |
404 // The simulator has its own stack. Thus it has a different stack limit from | 406 // The simulator has its own stack. Thus it has a different stack limit from |
405 // the C-based native code. Setting the c_limit to indicate a very small | 407 // the C-based native code. Setting the c_limit to indicate a very small |
406 // stack cause stack overflow errors, since the simulator ignores the input. | 408 // stack cause stack overflow errors, since the simulator ignores the input. |
407 // This is unlikely to be an issue in practice, though it might cause testing | 409 // This is unlikely to be an issue in practice, though it might cause testing |
408 // trouble down the line. | 410 // trouble down the line. |
409 class SimulatorStack : public v8::internal::AllStatic { | 411 class SimulatorStack : public v8::internal::AllStatic { |
410 public: | 412 public: |
411 static inline uintptr_t JsLimitFromCLimit(uintptr_t c_limit) { | 413 static inline uintptr_t JsLimitFromCLimit(v8::internal::Isolate* isolate, |
412 return Simulator::current(Isolate::Current())->StackLimit(); | 414 uintptr_t c_limit) { |
| 415 return Simulator::current(isolate)->StackLimit(); |
413 } | 416 } |
414 | 417 |
415 static inline uintptr_t RegisterCTryCatch(uintptr_t try_catch_address) { | 418 static inline uintptr_t RegisterCTryCatch(uintptr_t try_catch_address) { |
416 Simulator* sim = Simulator::current(Isolate::Current()); | 419 Simulator* sim = Simulator::current(Isolate::Current()); |
417 return sim->PushAddress(try_catch_address); | 420 return sim->PushAddress(try_catch_address); |
418 } | 421 } |
419 | 422 |
420 static inline void UnregisterCTryCatch() { | 423 static inline void UnregisterCTryCatch() { |
421 Simulator::current(Isolate::Current())->PopAddress(); | 424 Simulator::current(Isolate::Current())->PopAddress(); |
422 } | 425 } |
423 }; | 426 }; |
424 | 427 |
425 } } // namespace v8::internal | 428 } } // namespace v8::internal |
426 | 429 |
427 #endif // !defined(USE_SIMULATOR) | 430 #endif // !defined(USE_SIMULATOR) |
428 #endif // V8_ARM_SIMULATOR_ARM_H_ | 431 #endif // V8_ARM_SIMULATOR_ARM_H_ |
OLD | NEW |