From e102347ae923f983ae5e19281ba4c93fb17dc6ca Mon Sep 17 00:00:00 2001 From: Elijah Taylor Date: Thu, 31 Jan 2013 14:00:58 -0800 Subject: [PATCH] NaCl/arm initial support (Apply part of commit 21f0df7 from 'mono_libgc' branch.) Conflicts: * include/private/gc_locks.h * include/private/gcconfig.h * pthread_stop_world.c --- include/private/gcconfig.h | 12 +++++++++--- include/private/pthread_stop_world.h | 7 ++++++- pthread_stop_world.c | 16 +++++++++++++++- 3 files changed, 30 insertions(+), 5 deletions(-) diff --git a/include/private/gcconfig.h b/include/private/gcconfig.h index 2f80b3d0..e2dcc864 100644 --- a/include/private/gcconfig.h +++ b/include/private/gcconfig.h @@ -93,7 +93,7 @@ /* Determine the machine type: */ # if defined(__native_client__) # define NACL -# if !defined(__portable_native_client__) +# if !defined(__portable_native_client__) && !defined(__arm__) # define I386 # define mach_type_known # else @@ -109,7 +109,9 @@ # endif # if defined(__arm) || defined(__arm__) || defined(__thumb__) # define ARM32 -# if !defined(LINUX) && !defined(NETBSD) && !defined(FREEBSD) \ +# if defined(NACL) +# define mach_type_known +# elif !defined(LINUX) && !defined(NETBSD) && !defined(FREEBSD) \ && !defined(OPENBSD) && !defined(DARWIN) \ && !defined(_WIN32) && !defined(__CEGCC__) && !defined(SYMBIAN) # define NOSYS @@ -2134,8 +2136,12 @@ # endif # ifdef ARM32 +# if defined(NACL) +# define MACH_TYPE "NACL" +# else +# define MACH_TYPE "ARM32" +# endif # define CPP_WORDSZ 32 -# define MACH_TYPE "ARM32" # define ALIGNMENT 4 # ifdef NETBSD # define OS_TYPE "NETBSD" diff --git a/include/private/pthread_stop_world.h b/include/private/pthread_stop_world.h index 48374286..49b87bc6 100644 --- a/include/private/pthread_stop_world.h +++ b/include/private/pthread_stop_world.h @@ -34,7 +34,12 @@ struct thread_stop_info { /* saved registers, they may be pushed to the stack much earlier. */ /* Also, on amd64 'push' puts 8 bytes on the stack even though */ /* our pointers are 4 bytes. */ -# define NACL_GC_REG_STORAGE_SIZE 20 +# ifdef ARM32 + /* Space for r4-r8, r10-r12, r14. */ +# define NACL_GC_REG_STORAGE_SIZE 9 +# else +# define NACL_GC_REG_STORAGE_SIZE 20 +# endif ptr_t reg_storage[NACL_GC_REG_STORAGE_SIZE]; # endif }; diff --git a/pthread_stop_world.c b/pthread_stop_world.c index c0bc2a5e..22393092 100644 --- a/pthread_stop_world.c +++ b/pthread_stop_world.c @@ -711,8 +711,22 @@ GC_INNER void GC_stop_world(void) NACL_GC_REG_STORAGE_SIZE * sizeof(ptr_t));\ __asm__ __volatile__ ("add $16, %esp"); \ } while (0) +# elif defined(__arm__) +# define NACL_STORE_REGS() \ + do { \ + __asm__ __volatile__ ("push {r4-r8,r10-r12,lr}"); \ + __asm__ __volatile__ ("mov r0, %0" \ + : : "r" (&GC_nacl_gc_thread_self->stop_info.stack_ptr)); \ + __asm__ __volatile__ ("bic r0, r0, #0xc0000000"); \ + __asm__ __volatile__ ("str sp, [r0]"); \ + BCOPY(GC_nacl_gc_thread_self->stop_info.stack_ptr, \ + GC_nacl_gc_thread_self->stop_info.reg_storage, \ + NACL_GC_REG_STORAGE_SIZE * sizeof(ptr_t)); \ + __asm__ __volatile__ ("add sp, sp, #40"); \ + __asm__ __volatile__ ("bic sp, sp, #0xc0000000"); \ + } while (0) # else -# error FIXME for non-amd64/x86 NaCl +# error TODO Please port NACL_STORE_REGS # endif GC_API_OSCALL void nacl_pre_syscall_hook(void) -- 2.40.0