diff -ur v8/SConstruct v8/SConstruct --- v8/SConstruct 2012-06-18 21:39:33.000000000 +0900 +++ v8/SConstruct 2012-06-19 17:38:46.000000000 +0900 @@ -130,6 +134,12 @@ 'LIBPATH' : ['/usr/local/lib'], 'CCFLAGS': ['-ansi'], }, + 'os:netbsd': { + 'CPPPATH' : ['/usr/pkg/include'], + 'LIBPATH' : ['/usr/pkg/lib'], + 'CCFLAGS': ['-ansi', '-fPIC'], + 'CXXFLAGS': ['-fPIC'], + }, 'os:solaris': { # On Solaris, to get isinf, INFINITY, fpclassify and other macros one # needs to define __C99FEATURES__. @@ -364,6 +374,9 @@ 'os:openbsd': { 'LIBS': ['execinfo', 'pthread'] }, + 'os:netbsd': { + 'LIBS': ['execinfo', 'pthread'] + }, 'os:win32': { 'LIBS': ['winmm', 'ws2_32'], }, @@ -424,6 +437,9 @@ 'os:openbsd': { 'LIBS': ['execinfo', 'pthread'] }, + 'os:netbsd': { + 'LIBS': ['execinfo', 'pthread'] + }, 'os:win32': { 'LIBS': ['winmm', 'ws2_32'] }, @@ -480,6 +496,10 @@ 'LIBPATH' : ['/usr/local/lib'], 'LIBS': ['execinfo', 'pthread'] }, + 'os:netbsd': { + 'LIBPATH' : ['/usr/pkg/lib'], + 'LIBS': ['execinfo', 'pthread'] + }, 'os:win32': { 'LIBS': ['winmm', 'ws2_32'] }, @@ -801,6 +821,9 @@ 'os:openbsd': { 'LIBS': ['pthread'], }, + 'os:netbsd': { + 'LIBS': ['pthread'], + }, 'os:win32': { 'LIBS': ['winmm', 'ws2_32'], }, @@ -880,7 +903,7 @@ 'help': 'the architecture to build for' }, 'os': { - 'values': ['freebsd', 'linux', 'macos', 'win32', 'openbsd', 'solaris', 'cygwin'], + 'values': ['freebsd', 'linux', 'macos', 'win32', 'openbsd', 'netbsd', 'solaris', 'cygwin'], 'guess': GuessOS, 'help': 'the os to build for' }, diff -ur v8/src/SConscript v8/src/SConscript --- v8/src/SConscript 2012-06-18 21:39:33.000000000 +0900 +++ v8/src/SConscript 2012-06-19 17:45:20.000000000 +0900 @@ -213,6 +213,7 @@ 'simulator:mips': ['mips/simulator-mips.cc'], 'os:freebsd': ['platform-freebsd.cc', 'platform-posix.cc'], 'os:openbsd': ['platform-openbsd.cc', 'platform-posix.cc'], + 'os:netbsd': ['platform-openbsd.cc', 'platform-posix.cc'], 'os:linux': ['platform-linux.cc', 'platform-posix.cc'], 'os:android': ['platform-linux.cc', 'platform-posix.cc'], 'os:macos': ['platform-macos.cc', 'platform-posix.cc'], diff -ur v8/src/flags.cc v8/src/flags.cc --- v8/src/flags.cc 2012-06-18 21:39:34.000000000 +0900 +++ v8/src/flags.cc 2012-06-18 22:07:44.000000000 +0900 @@ -456,13 +456,13 @@ static char* SkipWhiteSpace(char* p) { - while (*p != '\0' && isspace(*p) != 0) p++; + while (*p != '\0' && isspace(*((unsigned char *)p)) != 0) p++; return p; } static char* SkipBlackSpace(char* p) { - while (*p != '\0' && isspace(*p) == 0) p++; + while (*p != '\0' && isspace(*((unsigned char *)p)) == 0) p++; return p; } diff -ur v8/src/platform-openbsd.cc v8/src/platform-openbsd.cc --- v8/src/platform-openbsd.cc 2012-06-18 21:39:34.000000000 +0900 +++ v8/src/platform-openbsd.cc 2012-06-19 19:50:55.000000000 +0900 @@ -297,7 +297,7 @@ // There may be no filename in this line. Skip to next. if (start_of_path == NULL) continue; buffer[bytes_read] = 0; - LOG(SharedLibraryEvent(start_of_path, start, end)); + LOG(ISOLATE, SharedLibraryEvent(start_of_path, start, end)); } close(fd); #endif @@ -368,7 +368,7 @@ Thread::Thread(Isolate* isolate, const Options& options) - : data_(new PlatformData()), + :data_(new PlatformData()), isolate_(isolate), stack_size_(options.stack_size) { set_name(options.name); @@ -376,7 +376,7 @@ Thread::Thread(Isolate* isolate, const char* name) - : data_(new PlatfromData()), + :data_(new PlatformData()), isolate_(isolate), stack_size_(0) { set_name(name); @@ -483,6 +483,15 @@ int result = pthread_mutex_unlock(&mutex_); return result; } + 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_; // Pthread mutex for POSIX platforms. @@ -557,14 +566,50 @@ static void ProfilerSignalHandler(int signal, siginfo_t* info, void* context) { USE(info); if (signal != SIGPROF) return; - if (active_sampler_ == NULL) return; - - TickSample sample; - - // We always sample the VM state. - sample.state = VMState::current_state(); - - active_sampler_->Tick(&sample); + Isolate* isolate = Isolate::UncheckedCurrent(); + if (isolate == NULL || !isolate->IsInitialized() || !isolate->IsInUse()) { + // We require a fully initialized and entered isolate. + return; + } + if (v8::Locker::IsActive() && + !isolate->thread_manager()->IsLockedByCurrentThread()) { + return; + } + + Sampler* sampler = isolate->logger()->sampler(); + if (sampler == NULL || !sampler->IsActive()) return; + + TickSample sample_obj; + TickSample* sample = CpuProfiler::TickSampleEvent(isolate); + if (sample == NULL) sample = &sample_obj; + + // Extracting the sample from the context is extremely machine dependent. + sample->state = isolate->current_vm_state(); + ucontext_t* ucontext = reinterpret_cast(context); +#ifdef __NetBSD__ + mcontext_t& mcontext = ucontext->uc_mcontext; +#if V8_HOST_ARCH_IA32 + sample->pc = reinterpret_cast
(mcontext.__gregs[_REG_EIP]); + sample->sp = reinterpret_cast
(mcontext.__gregs[_REG_ESP]); + sample->fp = reinterpret_cast
(mcontext.__gregs[_REG_EBP]); +#elif V8_HOST_ARCH_X64 + sample->pc = reinterpret_cast
(mcontext.__gregs[_REG_RIP]); + sample->sp = reinterpret_cast
(mcontext.__gregs[_REG_RSP]); + sample->fp = reinterpret_cast
(mcontext.__gregs[_REG_RBP]); +#endif // V8_HOST_ARCH +#else // OpenBSD +#if V8_HOST_ARCH_IA32 + sample->pc = reinterpret_cast
(ucontext->sc_eip); + sample->sp = reinterpret_cast
(ucontext->sc_esp); + sample->fp = reinterpret_cast
(ucontext->sc_ebp); +#elif V8_HOST_ARCH_X64 + sample->pc = reinterpret_cast
(ucontext->sc_rip); + sample->sp = reinterpret_cast
(ucontext->sc_rsp); + sample->fp = reinterpret_cast
(ucontext->sc_rbp); +#endif // V8_HOST_ARCH +#endif // __NetBSD__ + sampler->SampleStack(sample); + sampler->Tick(sample); } diff -ur v8/tools/utils.py v8/tools/utils.py --- v8/tools/utils.py 2012-06-18 21:39:34.000000000 +0900 +++ v8/tools/utils.py 2012-06-18 21:54:03.000000000 +0900 @@ -59,6 +59,8 @@ return 'freebsd' elif id == 'OpenBSD': return 'openbsd' + elif id == 'NetBSD': + return 'netbsd' elif id == 'SunOS': return 'solaris' else: