OLD | NEW |
1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 mips uses the C stack, we | 67 // generated code. Because generated code on mips 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(Isolate* isolate, |
| 72 uintptr_t c_limit) { |
72 return c_limit; | 73 return c_limit; |
73 } | 74 } |
74 | 75 |
75 static inline uintptr_t RegisterCTryCatch(uintptr_t try_catch_address) { | 76 static inline uintptr_t RegisterCTryCatch(uintptr_t try_catch_address) { |
76 return try_catch_address; | 77 return try_catch_address; |
77 } | 78 } |
78 | 79 |
79 static inline void UnregisterCTryCatch() { } | 80 static inline void UnregisterCTryCatch() { } |
80 }; | 81 }; |
81 | 82 |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 // Coprocessor registers. | 164 // Coprocessor registers. |
164 // Generated code will always use doubles. So we will only use even registers. | 165 // Generated code will always use doubles. So we will only use even registers. |
165 enum FPURegister { | 166 enum FPURegister { |
166 f0, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, | 167 f0, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, |
167 f12, f13, f14, f15, // f12 and f14 are arguments FPURegisters | 168 f12, f13, f14, f15, // f12 and f14 are arguments FPURegisters |
168 f16, f17, f18, f19, f20, f21, f22, f23, f24, f25, | 169 f16, f17, f18, f19, f20, f21, f22, f23, f24, f25, |
169 f26, f27, f28, f29, f30, f31, | 170 f26, f27, f28, f29, f30, f31, |
170 kNumFPURegisters | 171 kNumFPURegisters |
171 }; | 172 }; |
172 | 173 |
173 Simulator(); | 174 explicit Simulator(Isolate* isolate); |
174 ~Simulator(); | 175 ~Simulator(); |
175 | 176 |
176 // The currently executing Simulator instance. Potentially there can be one | 177 // The currently executing Simulator instance. Potentially there can be one |
177 // for each native thread. | 178 // for each native thread. |
178 static Simulator* current(v8::internal::Isolate* isolate); | 179 static Simulator* current(v8::internal::Isolate* isolate); |
179 | 180 |
180 // Accessors for register state. Reading the pc value adheres to the MIPS | 181 // Accessors for register state. Reading the pc value adheres to the MIPS |
181 // architecture specification and is off by a 8 from the currently executing | 182 // architecture specification and is off by a 8 from the currently executing |
182 // instruction. | 183 // instruction. |
183 void set_register(int reg, int32_t value); | 184 void set_register(int reg, int32_t value); |
(...skipping 14 matching lines...) Expand all Loading... |
198 void set_pc(int32_t value); | 199 void set_pc(int32_t value); |
199 int32_t get_pc() const; | 200 int32_t get_pc() const; |
200 | 201 |
201 // Accessor to the internal simulator stack area. | 202 // Accessor to the internal simulator stack area. |
202 uintptr_t StackLimit() const; | 203 uintptr_t StackLimit() const; |
203 | 204 |
204 // Executes MIPS instructions until the PC reaches end_sim_pc. | 205 // Executes MIPS instructions until the PC reaches end_sim_pc. |
205 void Execute(); | 206 void Execute(); |
206 | 207 |
207 // Call on program start. | 208 // Call on program start. |
208 static void Initialize(); | 209 static void Initialize(Isolate* isolate); |
209 | 210 |
210 // V8 generally calls into generated JS code with 5 parameters and into | 211 // V8 generally calls into generated JS code with 5 parameters and into |
211 // generated RegExp code with 7 parameters. This is a convenience function, | 212 // generated RegExp code with 7 parameters. This is a convenience function, |
212 // which sets up the simulator state and grabs the result on return. | 213 // which sets up the simulator state and grabs the result on return. |
213 int32_t Call(byte* entry, int argument_count, ...); | 214 int32_t Call(byte* entry, int argument_count, ...); |
214 | 215 |
215 // Push an address onto the JS stack. | 216 // Push an address onto the JS stack. |
216 uintptr_t PushAddress(uintptr_t address); | 217 uintptr_t PushAddress(uintptr_t address); |
217 | 218 |
218 // Pop an address from the JS stack. | 219 // Pop an address from the JS stack. |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
366 NULL : *(reinterpret_cast<TryCatch**>(try_catch_address)) | 367 NULL : *(reinterpret_cast<TryCatch**>(try_catch_address)) |
367 | 368 |
368 | 369 |
369 // The simulator has its own stack. Thus it has a different stack limit from | 370 // The simulator has its own stack. Thus it has a different stack limit from |
370 // the C-based native code. Setting the c_limit to indicate a very small | 371 // the C-based native code. Setting the c_limit to indicate a very small |
371 // stack cause stack overflow errors, since the simulator ignores the input. | 372 // stack cause stack overflow errors, since the simulator ignores the input. |
372 // This is unlikely to be an issue in practice, though it might cause testing | 373 // This is unlikely to be an issue in practice, though it might cause testing |
373 // trouble down the line. | 374 // trouble down the line. |
374 class SimulatorStack : public v8::internal::AllStatic { | 375 class SimulatorStack : public v8::internal::AllStatic { |
375 public: | 376 public: |
376 static inline uintptr_t JsLimitFromCLimit(uintptr_t c_limit) { | 377 static inline uintptr_t JsLimitFromCLimit(Isolate* isolate, |
377 return Simulator::current(Isolate::Current())->StackLimit(); | 378 uintptr_t c_limit) { |
| 379 return Simulator::current(isolate)->StackLimit(); |
378 } | 380 } |
379 | 381 |
380 static inline uintptr_t RegisterCTryCatch(uintptr_t try_catch_address) { | 382 static inline uintptr_t RegisterCTryCatch(uintptr_t try_catch_address) { |
381 Simulator* sim = Simulator::current(Isolate::Current()); | 383 Simulator* sim = Simulator::current(Isolate::Current()); |
382 return sim->PushAddress(try_catch_address); | 384 return sim->PushAddress(try_catch_address); |
383 } | 385 } |
384 | 386 |
385 static inline void UnregisterCTryCatch() { | 387 static inline void UnregisterCTryCatch() { |
386 Simulator::current(Isolate::Current())->PopAddress(); | 388 Simulator::current(Isolate::Current())->PopAddress(); |
387 } | 389 } |
388 }; | 390 }; |
389 | 391 |
390 } } // namespace v8::internal | 392 } } // namespace v8::internal |
391 | 393 |
392 #endif // !defined(USE_SIMULATOR) | 394 #endif // !defined(USE_SIMULATOR) |
393 #endif // V8_MIPS_SIMULATOR_MIPS_H_ | 395 #endif // V8_MIPS_SIMULATOR_MIPS_H_ |
394 | 396 |
OLD | NEW |