Commit 47c71e84 authored by feng@chromium.org's avatar feng@chromium.org

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@743 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 7518f92d
...@@ -106,7 +106,10 @@ V8_EXTRA_FLAGS = { ...@@ -106,7 +106,10 @@ V8_EXTRA_FLAGS = {
'CPPDEFINES': ['BUILDING_V8_SHARED'] 'CPPDEFINES': ['BUILDING_V8_SHARED']
}, },
'arch:arm': { 'arch:arm': {
'CPPDEFINES': ['ARM'] 'CPPDEFINES': ['ARM'],
# /wd4996 is to silence the warning about sscanf
# used by the arm simulator.
'WARNINGFLAGS': ['/wd4996']
}, },
'disassembler:on': { 'disassembler:on': {
'CPPDEFINES': ['ENABLE_DISASSEMBLER'] 'CPPDEFINES': ['ENABLE_DISASSEMBLER']
......
...@@ -48,11 +48,7 @@ using ::v8::internal::DeleteArray; ...@@ -48,11 +48,7 @@ using ::v8::internal::DeleteArray;
// SScanF not beeing implemented in a platform independent was through // 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 // ::v8::internal::OS in the same way as SNPrintF is that the Windows C Run-Time
// Library does not provide vsscanf. // Library does not provide vsscanf.
#ifdef WIN32
#define SScanF sscanf_s
#else
#define SScanF sscanf // NOLINT #define SScanF sscanf // NOLINT
#endif
// The Debugger class is used by the simulator while debugging simulated ARM // The Debugger class is used by the simulator while debugging simulated ARM
// code. // code.
...@@ -382,19 +378,20 @@ Simulator::Simulator() { ...@@ -382,19 +378,20 @@ Simulator::Simulator() {
} }
// This is the Simulator singleton. Currently only one thread is supported by // Create one simulator per thread and keep it in thread local storage.
// V8. If we had multiple threads, then we should have a Simulator instance on static v8::internal::Thread::LocalStorageKey simulator_key =
// a per thread basis. v8::internal::Thread::CreateThreadLocalKey();
static Simulator* the_sim = NULL;
// Get the active Simulator for the current thread.
// Get the active Simulator for the current thread. See comment above about
// using a singleton currently.
Simulator* Simulator::current() { Simulator* Simulator::current() {
if (the_sim == NULL) { Simulator* sim = reinterpret_cast<Simulator*>(
the_sim = new Simulator(); v8::internal::Thread::GetThreadLocal(simulator_key));
} if (sim == NULL) {
return the_sim; // TODO(146): delete the simulator object when a thread goes away.
sim = new Simulator();
v8::internal::Thread::SetThreadLocal(simulator_key, sim);
}
return sim;
} }
...@@ -1495,7 +1492,7 @@ void Simulator::InstructionDecode(Instr* instr) { ...@@ -1495,7 +1492,7 @@ void Simulator::InstructionDecode(Instr* instr) {
// //
void Simulator::execute() { void Simulator::Execute() {
// Get the PC to simulate. Cannot use the accessor here as we need the // 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. // raw PC value and not the one used as input to arithmetic instructions.
int program_counter = get_pc(); int program_counter = get_pc();
...@@ -1527,7 +1524,7 @@ void Simulator::execute() { ...@@ -1527,7 +1524,7 @@ void Simulator::execute() {
} }
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) { int32_t p3, int32_t p4) {
// Setup parameters // Setup parameters
set_register(r0, p0); set_register(r0, p0);
...@@ -1570,7 +1567,7 @@ Object* Simulator::call(int32_t entry, int32_t p0, int32_t p1, int32_t p2, ...@@ -1570,7 +1567,7 @@ Object* Simulator::call(int32_t entry, int32_t p0, int32_t p1, int32_t p2,
set_register(r11, callee_saved_value); set_register(r11, callee_saved_value);
// Start the simulation // Start the simulation
execute(); Execute();
// Check that the callee-saved registers have been preserved. // Check that the callee-saved registers have been preserved.
CHECK_EQ(get_register(r4), callee_saved_value); CHECK_EQ(get_register(r4), callee_saved_value);
......
...@@ -54,7 +54,7 @@ ...@@ -54,7 +54,7 @@
// When running with the simulator transition into simulated execution at this // When running with the simulator transition into simulated execution at this
// point. // point.
#define CALL_GENERATED_CODE(entry, p0, p1, p2, p3, p4) \ #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) (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 // The simulator has its own stack. Thus it has a different stack limit from
...@@ -103,12 +103,12 @@ class Simulator { ...@@ -103,12 +103,12 @@ class Simulator {
uintptr_t StackLimit() const; uintptr_t StackLimit() const;
// Executes ARM instructions until the PC reaches end_sim_pc. // 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 // V8 generally calls into generated code with 5 parameters. This is a
// convenience funtion, which sets up the simulator state and grabs the // convenience funtion, which sets up the simulator state and grabs the
// result on return. // 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); int32_t p2, int32_t p3, int32_t p4);
private: private:
......
...@@ -7,5 +7,6 @@ ...@@ -7,5 +7,6 @@
<Tool <Tool
Name="VCCLCompilerTool" Name="VCCLCompilerTool"
PreprocessorDefinitions="ARM" PreprocessorDefinitions="ARM"
DisableSpecificWarnings="4996"
/> />
</VisualStudioPropertySheet> </VisualStudioPropertySheet>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment