Chromium Code Reviews| Index: src/simulator-arm.cc |
| =================================================================== |
| --- src/simulator-arm.cc (revision 727) |
| +++ src/simulator-arm.cc (working copy) |
| @@ -48,11 +48,7 @@ |
| // SScanF not beeing implemented in a platform independent was through |
| // ::v8::internal::OS in the same way as SNPrintF is that the Windows C Run-Time |
| // Library does not provide vsscanf. |
| -#ifdef WIN32 |
| -#define SScanF sscanf_s |
| -#else |
| #define SScanF sscanf // NOLINT |
| -#endif |
| // The Debugger class is used by the simulator while debugging simulated ARM |
| // code. |
| @@ -382,19 +378,19 @@ |
| } |
| -// This is the Simulator singleton. Currently only one thread is supported by |
| -// V8. If we had multiple threads, then we should have a Simulator instance on |
| -// a per thread basis. |
| -static Simulator* the_sim = NULL; |
| +// Create one simulator per thread and keep it in thread local storage. |
| +static v8::internal::Thread::LocalStorageKey simulator_key = |
| + v8::internal::Thread::CreateThreadLocalKey(); |
| - |
| -// Get the active Simulator for the current thread. See comment above about |
| -// using a singleton currently. |
| +// Get the active Simulator for the current thread. |
| Simulator* Simulator::current() { |
| - if (the_sim == NULL) { |
| - the_sim = new Simulator(); |
| + Simulator* sim = reinterpret_cast<Simulator*>( |
| + v8::internal::Thread::GetThreadLocal(simulator_key)); |
| + if (sim == NULL) { |
| + sim = new Simulator(); |
| + v8::internal::Thread::SetThreadLocal(simulator_key, sim); |
|
iposva
2008/11/12 20:16:42
Since there is no AttachCurrentThread/DetachCurren
|
| } |
| - return the_sim; |
| + return sim; |
| } |
| @@ -1495,7 +1491,7 @@ |
| // |
| -void Simulator::execute() { |
| +void Simulator::Execute() { |
| // Get the PC to simulate. Cannot use the accessor here as we need the |
| // raw PC value and not the one used as input to arithmetic instructions. |
| int program_counter = get_pc(); |
| @@ -1527,7 +1523,7 @@ |
| } |
| -Object* Simulator::call(int32_t entry, int32_t p0, int32_t p1, int32_t p2, |
| +Object* Simulator::Call(int32_t entry, int32_t p0, int32_t p1, int32_t p2, |
| int32_t p3, int32_t p4) { |
| // Setup parameters |
| set_register(r0, p0); |
| @@ -1570,7 +1566,7 @@ |
| set_register(r11, callee_saved_value); |
| // Start the simulation |
| - execute(); |
| + Execute(); |
| // Check that the callee-saved registers have been preserved. |
| CHECK_EQ(get_register(r4), callee_saved_value); |