Skip to content

Commit

Permalink
Bug 1360322 - 2. Add initial AArch64 support to Gecko profiler; r=mst…
Browse files Browse the repository at this point in the history
…ange

Add enough AArch64-specific code for the Gecko profiler to build.
  • Loading branch information
Jim Chen committed May 3, 2017
1 parent 28cf921 commit 7041014
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 4 deletions.
2 changes: 1 addition & 1 deletion toolkit/moz.configure
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ imply_option('--enable-profiling', jprof)
@depends(target)
def gecko_profiler(target):
if target.os == 'Android':
return target.cpu in ('arm', 'x86')
return target.cpu in ('aarch64', 'arm', 'x86')
elif target.kernel == 'Linux':
return target.cpu in ('x86', 'x86_64')
return target.os in ('OSX', 'WINNT')
Expand Down
7 changes: 7 additions & 0 deletions tools/profiler/core/PlatformMacros.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

#undef GP_PLAT_x86_android
#undef GP_PLAT_arm_android
#undef GP_PLAT_aarch64_android
#undef GP_PLAT_x86_linux
#undef GP_PLAT_amd64_linux
#undef GP_PLAT_x86_darwin
Expand All @@ -25,6 +26,7 @@
#undef GP_ARCH_x86
#undef GP_ARCH_amd64
#undef GP_ARCH_arm
#undef GP_ARCH_aarch64

#undef GP_OS_android
#undef GP_OS_linux
Expand All @@ -44,6 +46,11 @@
# define GP_ARCH_arm 1
# define GP_OS_android 1

#elif defined(__ANDROID__) && defined(__aarch64__)
# define GP_PLAT_aarch64_android 1
# define GP_ARCH_aarch64 1
# define GP_OS_android 1

#elif defined(__linux__) && defined(__i386__)
# define GP_PLAT_x86_linux 1
# define GP_ARCH_x86 1
Expand Down
5 changes: 5 additions & 0 deletions tools/profiler/core/platform-linux-android.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,11 @@ FillInSample(TickSample& aSample, ucontext_t* aContext)
aSample.mSP = reinterpret_cast<Address>(mcontext.arm_sp);
aSample.mFP = reinterpret_cast<Address>(mcontext.arm_fp);
aSample.mLR = reinterpret_cast<Address>(mcontext.arm_lr);
#elif defined(GP_ARCH_aarch64)
aSample.mPC = reinterpret_cast<Address>(mcontext.pc);
aSample.mSP = reinterpret_cast<Address>(mcontext.sp);
aSample.mFP = reinterpret_cast<Address>(mcontext.regs[29]);
aSample.mLR = reinterpret_cast<Address>(mcontext.regs[30]);
#else
# error "bad platform"
#endif
Expand Down
2 changes: 2 additions & 0 deletions tools/profiler/moz.build
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ if CONFIG['MOZ_GECKO_PROFILER']:
]

if CONFIG['OS_TARGET'] == 'Android':
DEFINES['ANDROID_NDK_MAJOR_VERSION'] = CONFIG['ANDROID_NDK_MAJOR_VERSION']
DEFINES['ANDROID_NDK_MINOR_VERSION'] = CONFIG['ANDROID_NDK_MINOR_VERSION']
LOCAL_INCLUDES += [
# We need access to Breakpad's getcontext(3) which is suitable for Android
'/toolkit/crashreporter/google-breakpad/src/common/android/include',
Expand Down
9 changes: 6 additions & 3 deletions tools/profiler/public/StoreSequencer.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,19 @@ LinuxKernelMemoryBarrierFunc pLinuxKernelMemoryBarrier __attribute__((weak)) =

# define STORE_SEQUENCER() pLinuxKernelMemoryBarrier()

#elif defined(__aarch64__)
# define STORE_SEQUENCER() asm volatile("dmb ish" ::: "memory")

#elif defined(__i386__) || defined(__x86_64__) || \
defined(_M_IX86) || defined(_M_X64)

# if defined(_MSC_VER)
# include <intrin.h>
# define STORE_SEQUENCER() _ReadWriteBarrier();
# define STORE_SEQUENCER() _ReadWriteBarrier()
# elif defined(__INTEL_COMPILER)
# define STORE_SEQUENCER() __memory_barrier();
# define STORE_SEQUENCER() __memory_barrier()
# elif __GNUC__
# define STORE_SEQUENCER() asm volatile("" ::: "memory");
# define STORE_SEQUENCER() asm volatile("" ::: "memory")
# else
# error "STORE_SEQUENCER not supported for your compiler."
# endif
Expand Down

0 comments on commit 7041014

Please sign in to comment.