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

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

Issue 3044013: [Isolates] Patch to land http://codereview.chromium.org/3043007 by Maxim.Moss... (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/isolates/
Patch Set: Created 10 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-solaris.cc ('k') | src/v8threads.h » ('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-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 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 1405 matching lines...) Expand 10 before | Expand all | Expand 10 after
1416 // Entry point for threads. The supplied argument is a pointer to the thread 1416 // Entry point for threads. The supplied argument is a pointer to the thread
1417 // object. The entry function dispatches to the run method in the thread 1417 // object. The entry function dispatches to the run method in the thread
1418 // object. It is important that this function has __stdcall calling 1418 // object. It is important that this function has __stdcall calling
1419 // convention. 1419 // convention.
1420 static unsigned int __stdcall ThreadEntry(void* arg) { 1420 static unsigned int __stdcall ThreadEntry(void* arg) {
1421 Thread* thread = reinterpret_cast<Thread*>(arg); 1421 Thread* thread = reinterpret_cast<Thread*>(arg);
1422 // This is also initialized by the last parameter to _beginthreadex() but we 1422 // This is also initialized by the last parameter to _beginthreadex() but we
1423 // don't know which thread will run first (the original thread or the new 1423 // don't know which thread will run first (the original thread or the new
1424 // one) so we initialize it here too. 1424 // one) so we initialize it here too.
1425 thread->thread_handle_data()->tid_ = GetCurrentThreadId(); 1425 thread->thread_handle_data()->tid_ = GetCurrentThreadId();
1426 Thread::SetThreadLocal(Isolate::isolate_key(), thread->isolate());
1426 thread->Run(); 1427 thread->Run();
1427 return 0; 1428 return 0;
1428 } 1429 }
1429 1430
1430 1431
1431 // Initialize thread handle to invalid handle. 1432 // Initialize thread handle to invalid handle.
1432 ThreadHandle::ThreadHandle(ThreadHandle::Kind kind) { 1433 ThreadHandle::ThreadHandle(ThreadHandle::Kind kind) {
1433 data_ = new PlatformData(kind); 1434 data_ = new PlatformData(kind);
1434 } 1435 }
1435 1436
(...skipping 23 matching lines...) Expand all
1459 class Thread::PlatformData : public Malloced { 1460 class Thread::PlatformData : public Malloced {
1460 public: 1461 public:
1461 explicit PlatformData(HANDLE thread) : thread_(thread) {} 1462 explicit PlatformData(HANDLE thread) : thread_(thread) {}
1462 HANDLE thread_; 1463 HANDLE thread_;
1463 }; 1464 };
1464 1465
1465 1466
1466 // Initialize a Win32 thread object. The thread has an invalid thread 1467 // Initialize a Win32 thread object. The thread has an invalid thread
1467 // handle until it is started. 1468 // handle until it is started.
1468 1469
1469 Thread::Thread() : ThreadHandle(ThreadHandle::INVALID) { 1470 Thread::Thread(Isolate* isolate)
1471 : ThreadHandle(ThreadHandle::INVALID),
1472 isolate_(isolate) {
1470 data_ = new PlatformData(kNoThread); 1473 data_ = new PlatformData(kNoThread);
1471 } 1474 }
1472 1475
1473 1476
1474 // Close our own handle for the thread. 1477 // Close our own handle for the thread.
1475 Thread::~Thread() { 1478 Thread::~Thread() {
1476 if (data_->thread_ != kNoThread) CloseHandle(data_->thread_); 1479 if (data_->thread_ != kNoThread) CloseHandle(data_->thread_);
1477 delete data_; 1480 delete data_;
1478 } 1481 }
1479 1482
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after
1846 sampler_->Tick(sample); 1849 sampler_->Tick(sample);
1847 } 1850 }
1848 } 1851 }
1849 }; 1852 };
1850 1853
1851 1854
1852 // Entry point for sampler thread. 1855 // Entry point for sampler thread.
1853 static unsigned int __stdcall SamplerEntry(void* arg) { 1856 static unsigned int __stdcall SamplerEntry(void* arg) {
1854 Sampler::PlatformData* data = 1857 Sampler::PlatformData* data =
1855 reinterpret_cast<Sampler::PlatformData*>(arg); 1858 reinterpret_cast<Sampler::PlatformData*>(arg);
1859 Thread::SetThreadLocal(Isolate::isolate_key(), data->sampler_->isolate());
1856 data->Runner(); 1860 data->Runner();
1857 return 0; 1861 return 0;
1858 } 1862 }
1859 1863
1860 1864
1861 // Initialize a profile sampler. 1865 // Initialize a profile sampler.
1862 Sampler::Sampler(int interval, bool profiling) 1866 Sampler::Sampler(Isolate* isolate, int interval, bool profiling)
1863 : interval_(interval), profiling_(profiling), active_(false) { 1867 : isolate_(isolate),
1868 interval_(interval),
1869 profiling_(profiling),
1870 active_(false) {
1864 data_ = new PlatformData(this); 1871 data_ = new PlatformData(this);
1865 } 1872 }
1866 1873
1867 1874
1868 Sampler::~Sampler() { 1875 Sampler::~Sampler() {
1869 delete data_; 1876 delete data_;
1870 } 1877 }
1871 1878
1872 1879
1873 // Start profiling. 1880 // Start profiling.
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1910 1917
1911 // Release the thread handles 1918 // Release the thread handles
1912 CloseHandle(data_->sampler_thread_); 1919 CloseHandle(data_->sampler_thread_);
1913 CloseHandle(data_->profiled_thread_); 1920 CloseHandle(data_->profiled_thread_);
1914 } 1921 }
1915 1922
1916 1923
1917 #endif // ENABLE_LOGGING_AND_PROFILING 1924 #endif // ENABLE_LOGGING_AND_PROFILING
1918 1925
1919 } } // namespace v8::internal 1926 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/platform-solaris.cc ('k') | src/v8threads.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698