3 --- v8/src/platform-openbsd.cc.orig 2011-04-13 08:24:41.000000000 +0000
4 +++ v8/src/platform-openbsd.cc
5 @@ -164,6 +164,7 @@ void* OS::Allocate(const size_t requeste
8 void OS::Free(void* buf, const size_t length) {
9 + // TODO(1240712): munmap has a return value which is ignored here.
10 int result = munmap(buf, length);
13 @@ -197,13 +198,7 @@ void OS::Abort() {
16 void OS::DebugBreak() {
17 -#if (defined(__arm__) || defined(__thumb__))
18 -# if defined(CAN_USE_ARMV5_INSTRUCTIONS)
27 @@ -309,8 +304,30 @@ void OS::SignalCodeMovingGC() {
30 int OS::StackWalk(Vector<OS::StackFrame> frames) {
33 + int frames_size = frames.length();
34 + ScopedVector<void*> addresses(frames_size);
36 + int frames_count = backtrace(addresses.start(), frames_size);
38 + char** symbols = backtrace_symbols(addresses.start(), frames_count);
39 + if (symbols == NULL) {
40 + return kStackWalkError;
43 + for (int i = 0; i < frames_count; i++) {
44 + frames[i].address = addresses[i];
45 + // Format a text representation of the frame based on the information
47 + SNPrintF(MutableCStrVector(frames[i].text, kStackWalkMaxTextLen),
50 + // Make sure line termination is in place.
51 + frames[i].text[kStackWalkMaxTextLen - 1] = '\0';
56 + return frames_count;
60 @@ -502,6 +519,16 @@ class OpenBSDMutex : public Mutex {
64 + virtual bool TryLock() {
65 + int result = pthread_mutex_trylock(&mutex_);
66 + // Return false if the lock is busy and locking failed.
67 + if (result == EBUSY) {
70 + ASSERT(result == 0); // Verify no other errors.
75 pthread_mutex_t mutex_; // Pthread mutex for POSIX platforms.
77 @@ -571,18 +598,37 @@ Semaphore* OS::CreateSemaphore(int count
78 #ifdef ENABLE_LOGGING_AND_PROFILING
80 static Sampler* active_sampler_ = NULL;
81 +static pthread_t vm_tid_ = 0;
83 +typedef struct sigcontext ucontext_t;
85 static void ProfilerSignalHandler(int signal, siginfo_t* info, void* context) {
87 if (signal != SIGPROF) return;
88 - if (active_sampler_ == NULL) return;
91 + if (active_sampler_ == NULL || !active_sampler_->IsActive()) return;
92 + if (vm_tid_ != pthread_self()) return;
94 - // We always sample the VM state.
95 - sample.state = VMState::current_state();
97 - active_sampler_->Tick(&sample);
98 + TickSample sample_obj;
99 + TickSample* sample = CpuProfiler::TickSampleEvent();
100 + if (sample == NULL) sample = &sample_obj;
102 + // Extracting the sample from the context is extremely machine dependent.
103 + ucontext_t* ucontext = reinterpret_cast<ucontext_t*>(context);
104 + sample->state = Top::current_vm_state();
106 +#if V8_HOST_ARCH_IA32
107 + sample->pc = reinterpret_cast<Address>(ucontext->sc_eip);
108 + sample->sp = reinterpret_cast<Address>(ucontext->sc_esp);
109 + sample->fp = reinterpret_cast<Address>(ucontext->sc_ebp);
110 +#elif V8_HOST_ARCH_X64
111 + sample->pc = reinterpret_cast<Address>(ucontext->sc_rip);
112 + sample->sp = reinterpret_cast<Address>(ucontext->sc_rsp);
113 + sample->fp = reinterpret_cast<Address>(ucontext->sc_rbp);
117 + active_sampler_->SampleStack(sample);
118 + active_sampler_->Tick(sample);
122 @@ -616,6 +662,7 @@ void Sampler::Start() {
123 // There can only be one active sampler at the time on POSIX
125 if (active_sampler_ != NULL) return;
126 + vm_tid_ = pthread_self();
128 // Request profiling signals.