Author: [EMAIL PROTECTED]
Date: Wed Nov 12 14:57:04 2008
New Revision: 743
Modified:
branches/bleeding_edge/SConstruct
branches/bleeding_edge/src/simulator-arm.cc
branches/bleeding_edge/src/simulator-arm.h
branches/bleeding_edge/tools/visual_studio/arm.vsprops
Log:
Some fixes in ARM simulator:
1) create a simulator per thread and using thread storage;
2) capitalize two function names;
3) use sscanf instead of sscanf_s in arm simulator;
4) disable warning of sscanf when building with arm simulator;
Review URL: http://codereview.chromium.org/10634
Modified: branches/bleeding_edge/SConstruct
==============================================================================
--- branches/bleeding_edge/SConstruct (original)
+++ branches/bleeding_edge/SConstruct Wed Nov 12 14:57:04 2008
@@ -106,7 +106,10 @@
'CPPDEFINES': ['BUILDING_V8_SHARED']
},
'arch:arm': {
- 'CPPDEFINES': ['ARM']
+ 'CPPDEFINES': ['ARM'],
+ # /wd4996 is to silence the warning about sscanf
+ # used by the arm simulator.
+ 'WARNINGFLAGS': ['/wd4996']
},
'disassembler:on': {
'CPPDEFINES': ['ENABLE_DISASSEMBLER']
Modified: branches/bleeding_edge/src/simulator-arm.cc
==============================================================================
--- branches/bleeding_edge/src/simulator-arm.cc (original)
+++ branches/bleeding_edge/src/simulator-arm.cc Wed Nov 12 14:57:04 2008
@@ -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,20 @@
}
-// 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) {
+ // TODO(146): delete the simulator object when a thread goes away.
+ sim = new Simulator();
+ v8::internal::Thread::SetThreadLocal(simulator_key, sim);
}
- return the_sim;
+ return sim;
}
@@ -1495,7 +1492,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 +1524,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 +1567,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);
Modified: branches/bleeding_edge/src/simulator-arm.h
==============================================================================
--- branches/bleeding_edge/src/simulator-arm.h (original)
+++ branches/bleeding_edge/src/simulator-arm.h Wed Nov 12 14:57:04 2008
@@ -54,7 +54,7 @@
// When running with the simulator transition into simulated execution at
this
// point.
#define CALL_GENERATED_CODE(entry, p0, p1, p2, p3, p4) \
- assembler::arm::Simulator::current()->call((int32_t)entry, (int32_t)p0, \
+ assembler::arm::Simulator::current()->Call((int32_t)entry, (int32_t)p0, \
(int32_t)p1, (int32_t)p2, (int32_t)p3, (int32_t)p4)
// The simulator has its own stack. Thus it has a different stack limit
from
@@ -103,12 +103,12 @@
uintptr_t StackLimit() const;
// Executes ARM instructions until the PC reaches end_sim_pc.
- void execute();
+ void Execute();
// V8 generally calls into generated code with 5 parameters. This is a
// convenience funtion, which sets up the simulator state and grabs the
// result on return.
- v8::internal::Object* call(int32_t entry, int32_t p0, int32_t p1,
+ v8::internal::Object* Call(int32_t entry, int32_t p0, int32_t p1,
int32_t p2, int32_t p3, int32_t p4);
private:
Modified: branches/bleeding_edge/tools/visual_studio/arm.vsprops
==============================================================================
--- branches/bleeding_edge/tools/visual_studio/arm.vsprops (original)
+++ branches/bleeding_edge/tools/visual_studio/arm.vsprops Wed Nov 12
14:57:04 2008
@@ -7,5 +7,6 @@
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions="ARM"
+ DisableSpecificWarnings="4996"
/>
</VisualStudioPropertySheet>
--~--~---------~--~----~------------~-------~--~----~
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
-~----------~----~----~----~------~----~------~--~---