Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(55)

Side by Side Diff: src/platform-cygwin.cc

Issue 7348008: Merge up to 8597 to experimental/gc from the bleeding edge. (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/gc/
Patch Set: '' Created 9 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/platform.h ('k') | src/platform-freebsd.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2006-2011 the V8 project authors. All rights reserved. 1 // Copyright 2006-2011 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 364
365 class Thread::PlatformData : public Malloced { 365 class Thread::PlatformData : public Malloced {
366 public: 366 public:
367 PlatformData() : thread_(kNoThread) {} 367 PlatformData() : thread_(kNoThread) {}
368 pthread_t thread_; // Thread handle for pthread. 368 pthread_t thread_; // Thread handle for pthread.
369 }; 369 };
370 370
371 371
372 372
373 373
374 Thread::Thread(Isolate* isolate, const Options& options) 374 Thread::Thread(const Options& options)
375 : data_(new PlatformData), 375 : data_(new PlatformData),
376 isolate_(isolate),
377 stack_size_(options.stack_size) { 376 stack_size_(options.stack_size) {
378 set_name(options.name); 377 set_name(options.name);
379 } 378 }
380 379
381 380
382 Thread::Thread(Isolate* isolate, const char* name) 381 Thread::Thread(const char* name)
383 : data_(new PlatformData), 382 : data_(new PlatformData),
384 isolate_(isolate),
385 stack_size_(0) { 383 stack_size_(0) {
386 set_name(name); 384 set_name(name);
387 } 385 }
388 386
389 387
390 Thread::~Thread() { 388 Thread::~Thread() {
391 delete data_; 389 delete data_;
392 } 390 }
393 391
394 392
395 static void* ThreadEntry(void* arg) { 393 static void* ThreadEntry(void* arg) {
396 Thread* thread = reinterpret_cast<Thread*>(arg); 394 Thread* thread = reinterpret_cast<Thread*>(arg);
397 // This is also initialized by the first argument to pthread_create() but we 395 // This is also initialized by the first argument to pthread_create() but we
398 // don't know which thread will run first (the original thread or the new 396 // don't know which thread will run first (the original thread or the new
399 // one) so we initialize it here too. 397 // one) so we initialize it here too.
400 thread->data()->thread_ = pthread_self(); 398 thread->data()->thread_ = pthread_self();
401 ASSERT(thread->data()->thread_ != kNoThread); 399 ASSERT(thread->data()->thread_ != kNoThread);
402 Thread::SetThreadLocal(Isolate::isolate_key(), thread->isolate());
403 thread->Run(); 400 thread->Run();
404 return NULL; 401 return NULL;
405 } 402 }
406 403
407 404
408 void Thread::set_name(const char* name) { 405 void Thread::set_name(const char* name) {
409 strncpy(name_, name, sizeof(name_)); 406 strncpy(name_, name, sizeof(name_));
410 name_[sizeof(name_) - 1] = '\0'; 407 name_[sizeof(name_) - 1] = '\0';
411 } 408 }
412 409
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
624 HANDLE profiled_thread() { return profiled_thread_; } 621 HANDLE profiled_thread() { return profiled_thread_; }
625 622
626 private: 623 private:
627 HANDLE profiled_thread_; 624 HANDLE profiled_thread_;
628 }; 625 };
629 626
630 627
631 class SamplerThread : public Thread { 628 class SamplerThread : public Thread {
632 public: 629 public:
633 explicit SamplerThread(int interval) 630 explicit SamplerThread(int interval)
634 : Thread(NULL, "SamplerThread"), 631 : Thread("SamplerThread"),
635 interval_(interval) {} 632 interval_(interval) {}
636 633
637 static void AddActiveSampler(Sampler* sampler) { 634 static void AddActiveSampler(Sampler* sampler) {
638 ScopedLock lock(mutex_); 635 ScopedLock lock(mutex_);
639 SamplerRegistry::AddActiveSampler(sampler); 636 SamplerRegistry::AddActiveSampler(sampler);
640 if (instance_ == NULL) { 637 if (instance_ == NULL) {
641 instance_ = new SamplerThread(sampler->interval()); 638 instance_ = new SamplerThread(sampler->interval());
642 instance_->Start(); 639 instance_->Start();
643 } else { 640 } else {
644 ASSERT(instance_->interval_ == sampler->interval()); 641 ASSERT(instance_->interval_ == sampler->interval());
645 } 642 }
646 } 643 }
647 644
648 static void RemoveActiveSampler(Sampler* sampler) { 645 static void RemoveActiveSampler(Sampler* sampler) {
649 ScopedLock lock(mutex_); 646 ScopedLock lock(mutex_);
650 SamplerRegistry::RemoveActiveSampler(sampler); 647 SamplerRegistry::RemoveActiveSampler(sampler);
651 if (SamplerRegistry::GetState() == SamplerRegistry::HAS_NO_SAMPLERS) { 648 if (SamplerRegistry::GetState() == SamplerRegistry::HAS_NO_SAMPLERS) {
652 RuntimeProfiler::WakeUpRuntimeProfilerThreadBeforeShutdown(); 649 RuntimeProfiler::StopRuntimeProfilerThreadBeforeShutdown(instance_);
653 instance_->Join();
654 delete instance_; 650 delete instance_;
655 instance_ = NULL; 651 instance_ = NULL;
656 } 652 }
657 } 653 }
658 654
659 // Implement Thread::Run(). 655 // Implement Thread::Run().
660 virtual void Run() { 656 virtual void Run() {
661 SamplerRegistry::State state; 657 SamplerRegistry::State state;
662 while ((state = SamplerRegistry::GetState()) != 658 while ((state = SamplerRegistry::GetState()) !=
663 SamplerRegistry::HAS_NO_SAMPLERS) { 659 SamplerRegistry::HAS_NO_SAMPLERS) {
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
770 void Sampler::Stop() { 766 void Sampler::Stop() {
771 ASSERT(IsActive()); 767 ASSERT(IsActive());
772 SamplerThread::RemoveActiveSampler(this); 768 SamplerThread::RemoveActiveSampler(this);
773 SetActive(false); 769 SetActive(false);
774 } 770 }
775 771
776 #endif // ENABLE_LOGGING_AND_PROFILING 772 #endif // ENABLE_LOGGING_AND_PROFILING
777 773
778 } } // namespace v8::internal 774 } } // namespace v8::internal
779 775
OLDNEW
« no previous file with comments | « src/platform.h ('k') | src/platform-freebsd.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698