Revision: 6259
Author: [email protected]
Date: Tue Jan 11 03:44:16 2011
Log: Fix Solaris build. Patch from Ryan Dahl. See
http://codereview.chromium.org/5968004/
http://code.google.com/p/v8/source/detail?r=6259
Modified:
/branches/bleeding_edge/SConstruct
/branches/bleeding_edge/src/platform-solaris.cc
/branches/bleeding_edge/src/v8utils.h
=======================================
--- /branches/bleeding_edge/SConstruct Mon Dec 20 02:38:19 2010
+++ /branches/bleeding_edge/SConstruct Tue Jan 11 03:44:16 2011
@@ -663,6 +663,8 @@
if os == 'win32' and toolchain == 'gcc':
# MinGW can't do it.
return 'default'
+ elif os == 'solaris':
+ return 'default'
else:
return 'hidden'
=======================================
--- /branches/bleeding_edge/src/platform-solaris.cc Tue Jan 4 01:09:50 2011
+++ /branches/bleeding_edge/src/platform-solaris.cc Tue Jan 11 03:44:16 2011
@@ -45,6 +45,7 @@
#include <errno.h>
#include <ieeefp.h> // finite()
#include <signal.h> // sigemptyset(), etc
+#include <sys/kdi_regs.h>
#undef MAP_TYPE
@@ -492,6 +493,16 @@
int Lock() { return pthread_mutex_lock(&mutex_); }
int Unlock() { return pthread_mutex_unlock(&mutex_); }
+
+ virtual bool TryLock() {
+ int result = pthread_mutex_trylock(&mutex_);
+ // Return false if the lock is busy and locking failed.
+ if (result == EBUSY) {
+ return false;
+ }
+ ASSERT(result == 0); // Verify no other errors.
+ return true;
+ }
private:
pthread_mutex_t mutex_;
@@ -584,21 +595,37 @@
#ifdef ENABLE_LOGGING_AND_PROFILING
static Sampler* active_sampler_ = NULL;
+static pthread_t vm_tid_ = 0;
+
static void ProfilerSignalHandler(int signal, siginfo_t* info, void*
context) {
USE(info);
if (signal != SIGPROF) return;
- if (active_sampler_ == NULL) return;
-
- TickSample sample;
- sample.pc = 0;
- sample.sp = 0;
- sample.fp = 0;
-
- // We always sample the VM state.
- sample.state = VMState::current_state();
-
- active_sampler_->Tick(&sample);
+ if (active_sampler_ == NULL || !active_sampler_->IsActive()) return;
+ if (vm_tid_ != pthread_self()) return;
+
+ TickSample sample_obj;
+ TickSample* sample = CpuProfiler::TickSampleEvent();
+ if (sample == NULL) sample = &sample_obj;
+
+ // Extracting the sample from the context is extremely machine dependent.
+ ucontext_t* ucontext = reinterpret_cast<ucontext_t*>(context);
+ mcontext_t& mcontext = ucontext->uc_mcontext;
+ sample->state = Top::current_vm_state();
+
+#if V8_HOST_ARCH_IA32
+ sample->pc = reinterpret_cast<Address>(mcontext.gregs[KDIREG_EIP]);
+ sample->sp = reinterpret_cast<Address>(mcontext.gregs[KDIREG_ESP]);
+ sample->fp = reinterpret_cast<Address>(mcontext.gregs[KDIREG_EBP]);
+#elif V8_HOST_ARCH_X64
+ sample->pc = reinterpret_cast<Address>(mcontext.gregs[KDIREG_RIP]);
+ sample->sp = reinterpret_cast<Address>(mcontext.gregs[KDIREG_RSP]);
+ sample->fp = reinterpret_cast<Address>(mcontext.gregs[KDIREG_RBP]);
+#else
+ UNIMPLEMENTED();
+#endif
+ active_sampler_->SampleStack(sample);
+ active_sampler_->Tick(sample);
}
=======================================
--- /branches/bleeding_edge/src/v8utils.h Mon Dec 20 02:38:19 2010
+++ /branches/bleeding_edge/src/v8utils.h Tue Jan 11 03:44:16 2011
@@ -29,6 +29,7 @@
#define V8_V8UTILS_H_
#include "utils.h"
+#include "platform.h" // For va_list on Solaris.
namespace v8 {
namespace internal {
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev