diff options
Diffstat (limited to 'deps/v8/src/platform-linux.cc')
-rw-r--r-- | deps/v8/src/platform-linux.cc | 101 |
1 files changed, 68 insertions, 33 deletions
diff --git a/deps/v8/src/platform-linux.cc b/deps/v8/src/platform-linux.cc index 08f4495b53..f6db423e42 100644 --- a/deps/v8/src/platform-linux.cc +++ b/deps/v8/src/platform-linux.cc @@ -46,9 +46,9 @@ #include <sys/stat.h> // open #include <fcntl.h> // open #include <unistd.h> // sysconf -#ifdef __GLIBC__ +#if defined(__GLIBC__) && !defined(__UCLIBC__) #include <execinfo.h> // backtrace, backtrace_symbols -#endif // def __GLIBC__ +#endif // defined(__GLIBC__) && !defined(__UCLIBC__) #include <strings.h> // index #include <errno.h> #include <stdarg.h> @@ -57,6 +57,7 @@ #include "v8.h" +#include "platform-posix.h" #include "platform.h" #include "v8threads.h" #include "vm-state-inl.h" @@ -78,30 +79,8 @@ double ceiling(double x) { static Mutex* limit_mutex = NULL; -void OS::SetUp() { - // Seed the random number generator. We preserve microsecond resolution. - uint64_t seed = Ticks() ^ (getpid() << 16); - srandom(static_cast<unsigned int>(seed)); - limit_mutex = CreateMutex(); - -#ifdef __arm__ - // When running on ARM hardware check that the EABI used by V8 and - // by the C code is the same. - bool hard_float = OS::ArmUsingHardFloat(); - if (hard_float) { -#if !USE_EABI_HARDFLOAT - PrintF("ERROR: Binary compiled with -mfloat-abi=hard but without " - "-DUSE_EABI_HARDFLOAT\n"); - exit(1); -#endif - } else { -#if USE_EABI_HARDFLOAT - PrintF("ERROR: Binary not compiled with -mfloat-abi=hard but with " - "-DUSE_EABI_HARDFLOAT\n"); - exit(1); -#endif - } -#endif +void OS::PostSetUp() { + POSIXPostSetUp(); } @@ -556,7 +535,7 @@ void OS::SignalCodeMovingGC() { int OS::StackWalk(Vector<OS::StackFrame> frames) { // backtrace is a glibc extension. -#ifdef __GLIBC__ +#if defined(__GLIBC__) && !defined(__UCLIBC__) int frames_size = frames.length(); ScopedVector<void*> addresses(frames_size); @@ -581,9 +560,9 @@ int OS::StackWalk(Vector<OS::StackFrame> frames) { free(symbols); return frames_count; -#else // ndef __GLIBC__ +#else // defined(__GLIBC__) && !defined(__UCLIBC__) return 0; -#endif // ndef __GLIBC__ +#endif // defined(__GLIBC__) && !defined(__UCLIBC__) } @@ -985,6 +964,25 @@ typedef struct ucontext { __sigset_t uc_sigmask; } ucontext_t; +#elif !defined(__GLIBC__) && defined(__i386__) +// x86 version for Android. +struct sigcontext { + uint32_t gregs[19]; + void* fpregs; + uint32_t oldmask; + uint32_t cr2; +}; + +typedef uint32_t __sigset_t; +typedef struct sigcontext mcontext_t; +typedef struct ucontext { + uint32_t uc_flags; + struct ucontext* uc_link; + stack_t uc_stack; + mcontext_t uc_mcontext; + __sigset_t uc_sigmask; +} ucontext_t; +enum { REG_EBP = 6, REG_ESP = 7, REG_EIP = 14 }; #endif @@ -1076,6 +1074,9 @@ class SignalSender : public Thread { vm_tgid_(getpid()), interval_(interval) {} + static void SetUp() { if (!mutex_) mutex_ = OS::CreateMutex(); } + static void TearDown() { delete mutex_; } + static void InstallSignalHandler() { struct sigaction sa; sa.sa_sigaction = ProfilerSignalHandler; @@ -1093,7 +1094,7 @@ class SignalSender : public Thread { } static void AddActiveSampler(Sampler* sampler) { - ScopedLock lock(mutex_.Pointer()); + ScopedLock lock(mutex_); SamplerRegistry::AddActiveSampler(sampler); if (instance_ == NULL) { // Start a thread that will send SIGPROF signal to VM threads, @@ -1106,7 +1107,7 @@ class SignalSender : public Thread { } static void RemoveActiveSampler(Sampler* sampler) { - ScopedLock lock(mutex_.Pointer()); + ScopedLock lock(mutex_); SamplerRegistry::RemoveActiveSampler(sampler); if (SamplerRegistry::GetState() == SamplerRegistry::HAS_NO_SAMPLERS) { RuntimeProfiler::StopRuntimeProfilerThreadBeforeShutdown(instance_); @@ -1209,7 +1210,7 @@ class SignalSender : public Thread { RuntimeProfilerRateLimiter rate_limiter_; // Protects the process wide state below. - static LazyMutex mutex_; + static Mutex* mutex_; static SignalSender* instance_; static bool signal_handler_installed_; static struct sigaction old_signal_handler_; @@ -1219,12 +1220,46 @@ class SignalSender : public Thread { }; -LazyMutex SignalSender::mutex_ = LAZY_MUTEX_INITIALIZER; +Mutex* SignalSender::mutex_ = NULL; SignalSender* SignalSender::instance_ = NULL; struct sigaction SignalSender::old_signal_handler_; bool SignalSender::signal_handler_installed_ = false; +void OS::SetUp() { + // Seed the random number generator. We preserve microsecond resolution. + uint64_t seed = Ticks() ^ (getpid() << 16); + srandom(static_cast<unsigned int>(seed)); + limit_mutex = CreateMutex(); + +#ifdef __arm__ + // When running on ARM hardware check that the EABI used by V8 and + // by the C code is the same. + bool hard_float = OS::ArmUsingHardFloat(); + if (hard_float) { +#if !USE_EABI_HARDFLOAT + PrintF("ERROR: Binary compiled with -mfloat-abi=hard but without " + "-DUSE_EABI_HARDFLOAT\n"); + exit(1); +#endif + } else { +#if USE_EABI_HARDFLOAT + PrintF("ERROR: Binary not compiled with -mfloat-abi=hard but with " + "-DUSE_EABI_HARDFLOAT\n"); + exit(1); +#endif + } +#endif + SignalSender::SetUp(); +} + + +void OS::TearDown() { + SignalSender::TearDown(); + delete limit_mutex; +} + + Sampler::Sampler(Isolate* isolate, int interval) : isolate_(isolate), interval_(interval), |