Reviewers: ulan,

Message:
PTAL.

I've not tried running it yet, but this gets us most of the way through the
compile.

Description:
A64: Fix some compile errors when building for Android.

 - replace __arm__ define checks with __aarch64__
 - add 64 bit ucontext_t struct definition
 - fix V8_HOST_ARCH_A64 compile errors in sampler.cc
 - add aarch64 brk assembly instruction for debug break

Please review this at https://codereview.chromium.org/148913008/

SVN Base: https://v8.googlecode.com/svn/branches/experimental/a64

Affected files (+32, -17 lines):
  M src/a64/cpu-a64.cc
  M src/isolate.h
  M src/isolate.cc
  M src/platform-freebsd.cc
  M src/platform-linux.cc
  M src/sampler.cc


Index: src/a64/cpu-a64.cc
diff --git a/src/a64/cpu-a64.cc b/src/a64/cpu-a64.cc
index 7e8daf807b1e550361325ca3c33c9e44a2064586..e99184bc35c54d22ff4acc147e12c3a66d9e0450 100644
--- a/src/a64/cpu-a64.cc
+++ b/src/a64/cpu-a64.cc
@@ -26,7 +26,7 @@
 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

 // CPU specific code for arm independent of OS goes here.
-#ifdef __arm__
+#ifdef __aarch64__
 #include <sys/syscall.h>  // For cache flushing.
 #endif

Index: src/isolate.cc
diff --git a/src/isolate.cc b/src/isolate.cc
index b960d100e96e0005a58a242ba1935e6d31101af9..f3829b08efc138c88d03c1ec368820a05faa8435 100644
--- a/src/isolate.cc
+++ b/src/isolate.cc
@@ -1806,7 +1806,7 @@ Isolate::Isolate()
   thread_manager_->isolate_ = this;

 #if V8_TARGET_ARCH_ARM && !defined(__arm__) || \
-    V8_TARGET_ARCH_A64 && !defined(__arm__) || \
+    V8_TARGET_ARCH_A64 && !defined(__aarch64__) || \
     V8_TARGET_ARCH_MIPS && !defined(__mips__)
   simulator_initialized_ = false;
   simulator_i_cache_ = NULL;
Index: src/isolate.h
diff --git a/src/isolate.h b/src/isolate.h
index f5a94aa5eba0afeea570ddcd7621de36b8b48f06..f6974ce14f7e007a0d6a37c5ee01bbd347a54a84 100644
--- a/src/isolate.h
+++ b/src/isolate.h
@@ -101,8 +101,8 @@ class Debugger;
 class DebuggerAgent;
 #endif

-#if !defined(__arm__) && V8_TARGET_ARCH_A64 || \
-    !defined(__arm__) && V8_TARGET_ARCH_ARM || \
+#if !defined(__arm__) && V8_TARGET_ARCH_ARM || \
+    !defined(__aarch64__) && V8_TARGET_ARCH_A64 || \
     !defined(__mips__) && V8_TARGET_ARCH_MIPS
 class Redirection;
 class Simulator;
@@ -394,7 +394,7 @@ class Isolate {
           stack_limit_(0),
           thread_state_(NULL),
 #if !defined(__arm__) && V8_TARGET_ARCH_ARM || \
-    !defined(__arm__) && V8_TARGET_ARCH_A64 || \
+    !defined(__aarch64__) && V8_TARGET_ARCH_A64 || \
     !defined(__mips__) && V8_TARGET_ARCH_MIPS
           simulator_(NULL),
 #endif
@@ -408,7 +408,7 @@ class Isolate {
     void set_thread_state(ThreadState* value) { thread_state_ = value; }

 #if !defined(__arm__) && V8_TARGET_ARCH_ARM || \
-    !defined(__arm__) && V8_TARGET_ARCH_A64 || \
+    !defined(__aarch64__) && V8_TARGET_ARCH_A64 || \
     !defined(__mips__) && V8_TARGET_ARCH_MIPS
     Simulator* simulator() const { return simulator_; }
     void set_simulator(Simulator* simulator) {
@@ -427,7 +427,7 @@ class Isolate {
     ThreadState* thread_state_;

 #if !defined(__arm__) && V8_TARGET_ARCH_ARM || \
-    !defined(__arm__) && V8_TARGET_ARCH_A64 || \
+    !defined(__aarch64__) && V8_TARGET_ARCH_A64 || \
     !defined(__mips__) && V8_TARGET_ARCH_MIPS
     Simulator* simulator_;
 #endif
@@ -1004,7 +1004,7 @@ class Isolate {
 #endif

 #if V8_TARGET_ARCH_ARM && !defined(__arm__) || \
-    V8_TARGET_ARCH_A64 && !defined(__arm__) || \
+    V8_TARGET_ARCH_A64 && !defined(__aarch64__) || \
     V8_TARGET_ARCH_MIPS && !defined(__mips__)
   bool simulator_initialized() { return simulator_initialized_; }
   void set_simulator_initialized(bool initialized) {
@@ -1313,7 +1313,7 @@ class Isolate {
   double time_millis_at_init_;

 #if V8_TARGET_ARCH_ARM && !defined(__arm__) || \
-    V8_TARGET_ARCH_A64 && !defined(__arm__) || \
+    V8_TARGET_ARCH_A64 && !defined(__aarch64__) || \
     V8_TARGET_ARCH_MIPS && !defined(__mips__)
   bool simulator_initialized_;
   HashMap* simulator_i_cache_;
Index: src/platform-freebsd.cc
diff --git a/src/platform-freebsd.cc b/src/platform-freebsd.cc
index c771cd3be029aea168a1333a57a5481690354518..78458a78118eb0469e675eeb7c9b35d2efea6501 100644
--- a/src/platform-freebsd.cc
+++ b/src/platform-freebsd.cc
@@ -189,6 +189,8 @@ void OS::Abort() {
 void OS::DebugBreak() {
 #if (defined(__arm__) || defined(__thumb__))
   asm("bkpt 0");
+#elif defined(__aarch64__)
+  asm("brk 0");
 #else
   asm("int $3");
 #endif
Index: src/platform-linux.cc
diff --git a/src/platform-linux.cc b/src/platform-linux.cc
index a9aaf7803b8dd2e2295057146447c69d6cda764d..99a15939c2fb0fa3b389935b37de412fb7b8b4b3 100644
--- a/src/platform-linux.cc
+++ b/src/platform-linux.cc
@@ -58,7 +58,8 @@
 // GLibc on ARM defines mcontext_t has a typedef for 'struct sigcontext'.
 // Old versions of the C library <signal.h> didn't define the type.
 #if defined(__ANDROID__) && !defined(__BIONIC_HAVE_UCONTEXT_T) && \
-    defined(__arm__) && !defined(__BIONIC_HAVE_STRUCT_SIGCONTEXT)
+    (defined(__arm__) || defined(__aarch64__)) && \
+    !defined(__BIONIC_HAVE_STRUCT_SIGCONTEXT)
 #include <asm/sigcontext.h>
 #endif

@@ -442,6 +443,8 @@ void OS::DebugBreak() {
   asm("hlt 0");
 #elif defined(__arm__) || defined(__thumb__)
   asm("bkpt 0");
+#elif defined(__aarch64__)
+  asm("brk 0");
 #elif defined(__mips__)
   asm("break");
 #elif defined(__native_client__)
Index: src/sampler.cc
diff --git a/src/sampler.cc b/src/sampler.cc
index 624a96f6092d7f1771337665ecb1b494f73ff607..32c5b251f61d70f4cab6d6662f45d9a4880f1bab 100644
--- a/src/sampler.cc
+++ b/src/sampler.cc
@@ -46,7 +46,8 @@
 // GLibc on ARM defines mcontext_t has a typedef for 'struct sigcontext'.
 // Old versions of the C library <signal.h> didn't define the type.
 #if defined(__ANDROID__) && !defined(__BIONIC_HAVE_UCONTEXT_T) && \
-    defined(__arm__) && !defined(__BIONIC_HAVE_STRUCT_SIGCONTEXT)
+    (defined(__arm__) || defined(__aarch64__)) && \
+    !defined(__BIONIC_HAVE_STRUCT_SIGCONTEXT)
 #include <asm/sigcontext.h>
 #endif

@@ -80,9 +81,6 @@
 //
 // See http://code.google.com/p/android/issues/detail?id=34784

-// TODO(jbramley): This is not (and has never been) defined for A64. Does A64's
-// Android provide ucontext_t? Should we add an A64 variant?
-
 #if defined(__arm__)

 typedef struct sigcontext mcontext_t;
@@ -95,6 +93,18 @@ typedef struct ucontext {
   // Other fields are not used by V8, don't define them here.
 } ucontext_t;

+#elif defined(__aarch64__)
+
+typedef struct sigcontext mcontext_t;
+
+typedef struct ucontext {
+  uint64_t uc_flags;
+  struct ucontext *uc_link;
+  stack_t uc_stack;
+  mcontext_t uc_mcontext;
+  // Other fields are not used by V8, don't define them here.
+} ucontext_t;
+
 #elif defined(__mips__)
 // MIPS version of sigcontext, for Android bionic.
 typedef struct {
@@ -376,10 +386,10 @@ void SignalHandler::HandleProfilerSignal(int signal, siginfo_t* info,
 #endif  // defined(__GLIBC__) && !defined(__UCLIBC__) &&
         // (__GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ <= 3))
 #elif V8_HOST_ARCH_A64
-  sample->pc = reinterpret_cast<Address>(mcontext.pc);
-  sample->sp = reinterpret_cast<Address>(mcontext.sp);
+  state.pc = reinterpret_cast<Address>(mcontext.pc);
+  state.sp = reinterpret_cast<Address>(mcontext.sp);
   // FP is an alias for x29.
-  sample->fp = reinterpret_cast<Address>(mcontext.regs[29]);
+  state.fp = reinterpret_cast<Address>(mcontext.regs[29]);
 #elif V8_HOST_ARCH_MIPS
   state.pc = reinterpret_cast<Address>(mcontext.pc);
   state.sp = reinterpret_cast<Address>(mcontext.gregs[29]);


--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to