| OLD | NEW | 
|---|
| 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 1450 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1461   ASSERT(IsReserved()); | 1461   ASSERT(IsReserved()); | 
| 1462   return VirtualFree(address, size, MEM_DECOMMIT) != false; | 1462   return VirtualFree(address, size, MEM_DECOMMIT) != false; | 
| 1463 } | 1463 } | 
| 1464 | 1464 | 
| 1465 | 1465 | 
| 1466 // ---------------------------------------------------------------------------- | 1466 // ---------------------------------------------------------------------------- | 
| 1467 // Win32 thread support. | 1467 // Win32 thread support. | 
| 1468 | 1468 | 
| 1469 // Definition of invalid thread handle and id. | 1469 // Definition of invalid thread handle and id. | 
| 1470 static const HANDLE kNoThread = INVALID_HANDLE_VALUE; | 1470 static const HANDLE kNoThread = INVALID_HANDLE_VALUE; | 
| 1471 static const DWORD kNoThreadId = 0; |  | 
| 1472 |  | 
| 1473 |  | 
| 1474 class ThreadHandle::PlatformData : public Malloced { |  | 
| 1475  public: |  | 
| 1476   explicit PlatformData(ThreadHandle::Kind kind) { |  | 
| 1477     Initialize(kind); |  | 
| 1478   } |  | 
| 1479 |  | 
| 1480   void Initialize(ThreadHandle::Kind kind) { |  | 
| 1481     switch (kind) { |  | 
| 1482       case ThreadHandle::SELF: tid_ = GetCurrentThreadId(); break; |  | 
| 1483       case ThreadHandle::INVALID: tid_ = kNoThreadId; break; |  | 
| 1484     } |  | 
| 1485   } |  | 
| 1486   DWORD tid_;  // Win32 thread identifier. |  | 
| 1487 }; |  | 
| 1488 |  | 
| 1489 | 1471 | 
| 1490 // Entry point for threads. The supplied argument is a pointer to the thread | 1472 // Entry point for threads. The supplied argument is a pointer to the thread | 
| 1491 // object. The entry function dispatches to the run method in the thread | 1473 // object. The entry function dispatches to the run method in the thread | 
| 1492 // object. It is important that this function has __stdcall calling | 1474 // object. It is important that this function has __stdcall calling | 
| 1493 // convention. | 1475 // convention. | 
| 1494 static unsigned int __stdcall ThreadEntry(void* arg) { | 1476 static unsigned int __stdcall ThreadEntry(void* arg) { | 
| 1495   Thread* thread = reinterpret_cast<Thread*>(arg); | 1477   Thread* thread = reinterpret_cast<Thread*>(arg); | 
| 1496   // This is also initialized by the last parameter to _beginthreadex() but we | 1478   // This is also initialized by the last parameter to _beginthreadex() but we | 
| 1497   // don't know which thread will run first (the original thread or the new | 1479   // don't know which thread will run first (the original thread or the new | 
| 1498   // one) so we initialize it here too. | 1480   // one) so we initialize it here too. | 
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1544 // Create a new thread. It is important to use _beginthreadex() instead of | 1526 // Create a new thread. It is important to use _beginthreadex() instead of | 
| 1545 // the Win32 function CreateThread(), because the CreateThread() does not | 1527 // the Win32 function CreateThread(), because the CreateThread() does not | 
| 1546 // initialize thread specific structures in the C runtime library. | 1528 // initialize thread specific structures in the C runtime library. | 
| 1547 void Thread::Start() { | 1529 void Thread::Start() { | 
| 1548   data_->thread_ = reinterpret_cast<HANDLE>( | 1530   data_->thread_ = reinterpret_cast<HANDLE>( | 
| 1549       _beginthreadex(NULL, | 1531       _beginthreadex(NULL, | 
| 1550                      static_cast<unsigned>(stack_size_), | 1532                      static_cast<unsigned>(stack_size_), | 
| 1551                      ThreadEntry, | 1533                      ThreadEntry, | 
| 1552                      this, | 1534                      this, | 
| 1553                      0, | 1535                      0, | 
| 1554                      reinterpret_cast<unsigned int*>( | 1536                      NULL)); | 
| 1555                          &thread_handle_data()->tid_))); |  | 
| 1556   ASSERT(IsValid()); | 1537   ASSERT(IsValid()); | 
| 1557 } | 1538 } | 
| 1558 | 1539 | 
| 1559 | 1540 | 
| 1560 // Wait for thread to terminate. | 1541 // Wait for thread to terminate. | 
| 1561 void Thread::Join() { | 1542 void Thread::Join() { | 
| 1562   WaitForSingleObject(data_->thread_, INFINITE); | 1543   WaitForSingleObject(data_->thread_, INFINITE); | 
| 1563 } | 1544 } | 
| 1564 | 1545 | 
| 1565 | 1546 | 
| (...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 2032 | 2013 | 
| 2033 void Sampler::Stop() { | 2014 void Sampler::Stop() { | 
| 2034   ASSERT(IsActive()); | 2015   ASSERT(IsActive()); | 
| 2035   SamplerThread::RemoveActiveSampler(this); | 2016   SamplerThread::RemoveActiveSampler(this); | 
| 2036   SetActive(false); | 2017   SetActive(false); | 
| 2037 } | 2018 } | 
| 2038 | 2019 | 
| 2039 #endif  // ENABLE_LOGGING_AND_PROFILING | 2020 #endif  // ENABLE_LOGGING_AND_PROFILING | 
| 2040 | 2021 | 
| 2041 } }  // namespace v8::internal | 2022 } }  // namespace v8::internal | 
| OLD | NEW | 
|---|