Revision: 5700
Author: [email protected]
Date: Mon Oct 25 09:40:41 2010
Log: Clean up definitions in simulator.

Clean up the definition of USE_SIMULATOR and its uses.
Review URL: http://codereview.chromium.org/4044003
http://code.google.com/p/v8/source/detail?r=5700

Modified:
 /branches/bleeding_edge/SConstruct
 /branches/bleeding_edge/src/arm/cpu-arm.cc
 /branches/bleeding_edge/src/arm/simulator-arm.cc
 /branches/bleeding_edge/src/arm/simulator-arm.h
 /branches/bleeding_edge/src/globals.h
 /branches/bleeding_edge/src/ia32/simulator-ia32.h
 /branches/bleeding_edge/src/top.cc
 /branches/bleeding_edge/src/top.h
 /branches/bleeding_edge/src/v8.cc
 /branches/bleeding_edge/src/x64/simulator-x64.h

=======================================
--- /branches/bleeding_edge/SConstruct  Mon Oct 18 07:39:59 2010
+++ /branches/bleeding_edge/SConstruct  Mon Oct 25 09:40:41 2010
@@ -207,7 +207,6 @@
     'simulator:arm': {
       'CCFLAGS':      ['-m32'],
       'LINKFLAGS':    ['-m32'],
-      'CPPDEFINES':   ['USE_SIMULATOR']
     },
     'arch:mips': {
       'CPPDEFINES':   ['V8_TARGET_ARCH_MIPS'],
@@ -219,7 +218,6 @@
     'simulator:mips': {
       'CCFLAGS':      ['-m32'],
       'LINKFLAGS':    ['-m32'],
-      'CPPDEFINES':   ['USE_SIMULATOR']
     },
     'arch:x64': {
       'CPPDEFINES':   ['V8_TARGET_ARCH_X64'],
=======================================
--- /branches/bleeding_edge/src/arm/cpu-arm.cc  Mon May 17 08:41:35 2010
+++ /branches/bleeding_edge/src/arm/cpu-arm.cc  Mon Oct 25 09:40:41 2010
@@ -36,10 +36,7 @@

 #include "cpu.h"
 #include "macro-assembler.h"
-
-#ifndef __arm__
-#include "simulator-arm.h"  // for cache flushing.
-#endif
+#include "simulator.h"  // for cache flushing.

 namespace v8 {
 namespace internal {
@@ -50,7 +47,7 @@


 void CPU::FlushICache(void* start, size_t size) {
-#if !defined (__arm__)
+#if defined (USE_SIMULATOR)
   // Not generating ARM instructions for C-code. This means that we are
   // building an ARM emulator based target.  We should notify the simulator
   // that the Icache was flushed.
=======================================
--- /branches/bleeding_edge/src/arm/simulator-arm.cc Thu Oct 14 04:39:48 2010 +++ /branches/bleeding_edge/src/arm/simulator-arm.cc Mon Oct 25 09:40:41 2010
@@ -37,7 +37,7 @@
 #include "arm/constants-arm.h"
 #include "arm/simulator-arm.h"

-#if !defined(__arm__) || defined(USE_SIMULATOR)
+#if defined(USE_SIMULATOR)

 // Only build the simulator if not compiling for real ARM hardware.
 namespace assembler {
@@ -2840,6 +2840,6 @@

 } }  // namespace assembler::arm

-#endif  // !__arm__ || USE_SIMULATOR
+#endif  // USE_SIMULATOR

 #endif  // V8_TARGET_ARCH_ARM
=======================================
--- /branches/bleeding_edge/src/arm/simulator-arm.h     Thu Oct 14 04:39:48 2010
+++ /branches/bleeding_edge/src/arm/simulator-arm.h     Mon Oct 25 09:40:41 2010
@@ -38,12 +38,24 @@

 #include "allocation.h"

-#if defined(__arm__) && !defined(USE_SIMULATOR)
+#if !defined(USE_SIMULATOR)
+// Running without a simulator on a native arm platform.
+
+namespace v8 {
+namespace internal {

 // When running without a simulator we call the entry directly.
 #define CALL_GENERATED_CODE(entry, p0, p1, p2, p3, p4) \
   (entry(p0, p1, p2, p3, p4))

+// Call the generated regexp code directly. The entry function pointer should
+// expect seven int/pointer sized arguments and return an int.
+#define CALL_GENERATED_REGEXP_CODE(entry, p0, p1, p2, p3, p4, p5, p6) \
+  (entry(p0, p1, p2, p3, p4, p5, p6))
+
+#define TRY_CATCH_FROM_ADDRESS(try_catch_address) \
+  (reinterpret_cast<TryCatch*>(try_catch_address))
+
 // The stack limit beyond which we will throw stack overflow errors in
 // generated code. Because generated code on arm uses the C stack, we
 // just use the C stack limit.
@@ -60,38 +72,14 @@
   static inline void UnregisterCTryCatch() { }
 };

-
-// Call the generated regexp code directly. The entry function pointer should
-// expect eight int/pointer sized arguments and return an int.
-#define CALL_GENERATED_REGEXP_CODE(entry, p0, p1, p2, p3, p4, p5, p6) \
-  entry(p0, p1, p2, p3, p4, p5, p6)
-
-#define TRY_CATCH_FROM_ADDRESS(try_catch_address) \
-  reinterpret_cast<TryCatch*>(try_catch_address)
-
-
-#else  // !defined(__arm__) || defined(USE_SIMULATOR)
-
-// When running with the simulator transition into simulated execution at this
-// point.
-#define CALL_GENERATED_CODE(entry, p0, p1, p2, p3, p4) \
-  reinterpret_cast<Object*>( \
-      assembler::arm::Simulator::current()->Call(FUNCTION_ADDR(entry), 5, \
-                                                 p0, p1, p2, p3, p4))
-
-#define CALL_GENERATED_REGEXP_CODE(entry, p0, p1, p2, p3, p4, p5, p6) \
-  assembler::arm::Simulator::current()->Call( \
-    FUNCTION_ADDR(entry), 7, p0, p1, p2, p3, p4, p5, p6)
-
-#define TRY_CATCH_FROM_ADDRESS(try_catch_address) \
-  try_catch_address == NULL ? \
-      NULL : *(reinterpret_cast<TryCatch**>(try_catch_address))
-
+} }  // namespace v8::internal
+
+#else  // !defined(USE_SIMULATOR)
+// Running with a simulator.

 #include "constants-arm.h"
 #include "hashmap.h"

-
 namespace assembler {
 namespace arm {

@@ -334,6 +322,24 @@
 } }  // namespace assembler::arm


+namespace v8 {
+namespace internal {
+
+// When running with the simulator transition into simulated execution at this
+// point.
+#define CALL_GENERATED_CODE(entry, p0, p1, p2, p3, p4) \
+  reinterpret_cast<Object*>(assembler::arm::Simulator::current()->Call( \
+      FUNCTION_ADDR(entry), 5, p0, p1, p2, p3, p4))
+
+#define CALL_GENERATED_REGEXP_CODE(entry, p0, p1, p2, p3, p4, p5, p6) \
+  assembler::arm::Simulator::current()->Call( \
+      FUNCTION_ADDR(entry), 7, p0, p1, p2, p3, p4, p5, p6)
+
+#define TRY_CATCH_FROM_ADDRESS(try_catch_address) \
+  try_catch_address == \
+      NULL ? NULL : *(reinterpret_cast<TryCatch**>(try_catch_address))
+
+
// The simulator has its own stack. Thus it has a different stack limit from
 // the C-based native code.  Setting the c_limit to indicate a very small
// stack cause stack overflow errors, since the simulator ignores the input.
@@ -355,7 +361,7 @@
   }
 };

-
-#endif  // !defined(__arm__) || defined(USE_SIMULATOR)
-
+} }  // namespace v8::internal
+
+#endif  // !defined(USE_SIMULATOR)
 #endif  // V8_ARM_SIMULATOR_ARM_H_
=======================================
--- /branches/bleeding_edge/src/globals.h       Mon Oct 25 08:22:03 2010
+++ /branches/bleeding_edge/src/globals.h       Mon Oct 25 09:40:41 2010
@@ -93,6 +93,14 @@
 #error Target architecture mips is only supported on mips and ia32 host
 #endif

+// Determine whether we are running in a simulated environment.
+#if (defined(V8_TARGET_ARCH_ARM) && !defined(V8_HOST_ARCH_ARM))
+#define USE_SIMULATOR 1
+#endif
+#if (defined(V8_TARGET_ARCH_MIPS) && !defined(V8_HOST_ARCH_MIPS))
+#define USE_SIMULATOR 1
+#endif
+
 // Define unaligned read for the target architectures supporting it.
 #if defined(V8_TARGET_ARCH_X64) || defined(V8_TARGET_ARCH_IA32)
 #define V8_TARGET_CAN_READ_UNALIGNED 1
=======================================
--- /branches/bleeding_edge/src/ia32/simulator-ia32.h Tue Jan 26 03:08:42 2010 +++ /branches/bleeding_edge/src/ia32/simulator-ia32.h Mon Oct 25 09:40:41 2010
@@ -30,10 +30,21 @@

 #include "allocation.h"

+namespace v8 {
+namespace internal {
+
// Since there is no simulator for the ia32 architecture the only thing we can
 // do is to call the entry directly.
 #define CALL_GENERATED_CODE(entry, p0, p1, p2, p3, p4) \
-  entry(p0, p1, p2, p3, p4);
+  (entry(p0, p1, p2, p3, p4))
+
+// Call the generated regexp code directly. The entry function pointer should
+// expect seven int/pointer sized arguments and return an int.
+#define CALL_GENERATED_REGEXP_CODE(entry, p0, p1, p2, p3, p4, p5, p6) \
+  (entry(p0, p1, p2, p3, p4, p5, p6))
+
+#define TRY_CATCH_FROM_ADDRESS(try_catch_address) \
+  (reinterpret_cast<TryCatch*>(try_catch_address))

 // The stack limit beyond which we will throw stack overflow errors in
 // generated code. Because generated code on ia32 uses the C stack, we
@@ -51,12 +62,6 @@
   static inline void UnregisterCTryCatch() { }
 };

-// Call the generated regexp code directly. The entry function pointer should
-// expect eight int/pointer sized arguments and return an int.
-#define CALL_GENERATED_REGEXP_CODE(entry, p0, p1, p2, p3, p4, p5, p6) \
-  entry(p0, p1, p2, p3, p4, p5, p6)
-
-#define TRY_CATCH_FROM_ADDRESS(try_catch_address) \
-  reinterpret_cast<TryCatch*>(try_catch_address)
+} }  // namespace v8::internal

 #endif  // V8_IA32_SIMULATOR_IA32_H_
=======================================
--- /branches/bleeding_edge/src/top.cc  Mon Oct 25 08:22:03 2010
+++ /branches/bleeding_edge/src/top.cc  Mon Oct 25 09:40:41 2010
@@ -66,6 +66,9 @@
 void ThreadLocalTop::Initialize() {
   c_entry_fp_ = 0;
   handler_ = 0;
+#ifdef USE_SIMULATOR
+  simulator_ = assembler::arm::Simulator::current();
+#endif  // USE_SIMULATOR
 #ifdef ENABLE_LOGGING_AND_PROFILING
   js_entry_sp_ = 0;
 #endif
@@ -1060,6 +1063,11 @@

 char* Top::RestoreThread(char* from) {
memcpy(reinterpret_cast<char*>(&thread_local_), from, sizeof(thread_local_));
+  // This might be just paranoia, but it seems to be needed in case a
+  // thread_local_ is restored on a separate OS thread.
+#ifdef USE_SIMULATOR
+  thread_local_.simulator_ = assembler::arm::Simulator::current();
+#endif
   return from + sizeof(thread_local_);
 }

=======================================
--- /branches/bleeding_edge/src/top.h   Mon Oct 25 08:22:03 2010
+++ /branches/bleeding_edge/src/top.h   Mon Oct 25 09:40:41 2010
@@ -29,6 +29,7 @@
 #define V8_TOP_H_

 #include "frames-inl.h"
+#include "simulator.h"

 namespace v8 {
 namespace internal {
@@ -103,6 +104,10 @@
   Address c_entry_fp_;  // the frame pointer of the top c entry frame
   Address handler_;   // try-blocks are chained through the stack

+#ifdef USE_SIMULATOR
+  assembler::arm::Simulator* simulator_;
+#endif  // USE_SIMULATOR
+
 #ifdef ENABLE_LOGGING_AND_PROFILING
   Address js_entry_sp_;  // the stack pointer of the bottom js entry frame
 #endif
=======================================
--- /branches/bleeding_edge/src/v8.cc   Thu Oct 14 04:39:48 2010
+++ /branches/bleeding_edge/src/v8.cc   Mon Oct 25 09:40:41 2010
@@ -68,7 +68,7 @@
   OS::Setup();

   // Initialize other runtime facilities
-#if (defined(USE_SIMULATOR) || !V8_HOST_ARCH_ARM) && V8_TARGET_ARCH_ARM
+#if defined(USE_SIMULATOR)
   ::assembler::arm::Simulator::Initialize();
 #endif

=======================================
--- /branches/bleeding_edge/src/x64/simulator-x64.h     Tue Jan 26 03:08:42 2010
+++ /branches/bleeding_edge/src/x64/simulator-x64.h     Mon Oct 25 09:40:41 2010
@@ -30,11 +30,22 @@

 #include "allocation.h"

-// Since there is no simulator for the ia32 architecture the only thing we can
+namespace v8 {
+namespace internal {
+
+// Since there is no simulator for the x64 architecture the only thing we can
 // do is to call the entry directly.
 // TODO(X64): Don't pass p0, since it isn't used?
 #define CALL_GENERATED_CODE(entry, p0, p1, p2, p3, p4) \
-  entry(p0, p1, p2, p3, p4);
+  (entry(p0, p1, p2, p3, p4))
+
+// Call the generated regexp code directly. The entry function pointer should
+// expect seven int/pointer sized arguments and return an int.
+#define CALL_GENERATED_REGEXP_CODE(entry, p0, p1, p2, p3, p4, p5, p6) \
+  (entry(p0, p1, p2, p3, p4, p5, p6))
+
+#define TRY_CATCH_FROM_ADDRESS(try_catch_address) \
+  (reinterpret_cast<TryCatch*>(try_catch_address))

 // The stack limit beyond which we will throw stack overflow errors in
 // generated code. Because generated code on x64 uses the C stack, we
@@ -52,12 +63,6 @@
   static inline void UnregisterCTryCatch() { }
 };

-// Call the generated regexp code directly. The entry function pointer should
-// expect eight int/pointer sized arguments and return an int.
-#define CALL_GENERATED_REGEXP_CODE(entry, p0, p1, p2, p3, p4, p5, p6) \
-  entry(p0, p1, p2, p3, p4, p5, p6)
-
-#define TRY_CATCH_FROM_ADDRESS(try_catch_address) \
-  reinterpret_cast<TryCatch*>(try_catch_address)
+} }  // namespace v8::internal

 #endif  // V8_X64_SIMULATOR_X64_H_

--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to