| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 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 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 !(x == 0 && (y != 0 && isfinite(y)))) { | 191 !(x == 0 && (y != 0 && isfinite(y)))) { |
| 192 x = fmod(x, y); | 192 x = fmod(x, y); |
| 193 } | 193 } |
| 194 return x; | 194 return x; |
| 195 } | 195 } |
| 196 | 196 |
| 197 #endif // _WIN64 | 197 #endif // _WIN64 |
| 198 | 198 |
| 199 // ---------------------------------------------------------------------------- | 199 // ---------------------------------------------------------------------------- |
| 200 // The Time class represents time on win32. A timestamp is represented as | 200 // The Time class represents time on win32. A timestamp is represented as |
| 201 // a 64-bit integer in 100 nano-seconds since January 1, 1601 (UTC). JavaScript | 201 // a 64-bit integer in 100 nanoseconds since January 1, 1601 (UTC). JavaScript |
| 202 // timestamps are represented as a doubles in milliseconds since 00:00:00 UTC, | 202 // timestamps are represented as a doubles in milliseconds since 00:00:00 UTC, |
| 203 // January 1, 1970. | 203 // January 1, 1970. |
| 204 | 204 |
| 205 class Time { | 205 class Time { |
| 206 public: | 206 public: |
| 207 // Constructors. | 207 // Constructors. |
| 208 Time(); | 208 Time(); |
| 209 explicit Time(double jstime); | 209 explicit Time(double jstime); |
| 210 Time(int year, int mon, int day, int hour, int min, int sec); | 210 Time(int year, int mon, int day, int hour, int min, int sec); |
| 211 | 211 |
| (...skipping 557 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 769 if (n + 1 > buffer_size) // count for trailing '\0' | 769 if (n + 1 > buffer_size) // count for trailing '\0' |
| 770 n = _TRUNCATE; | 770 n = _TRUNCATE; |
| 771 int result = strncpy_s(dest.start(), dest.length(), src, n); | 771 int result = strncpy_s(dest.start(), dest.length(), src, n); |
| 772 USE(result); | 772 USE(result); |
| 773 ASSERT(result == 0 || (n == _TRUNCATE && result == STRUNCATE)); | 773 ASSERT(result == 0 || (n == _TRUNCATE && result == STRUNCATE)); |
| 774 } | 774 } |
| 775 | 775 |
| 776 | 776 |
| 777 // We keep the lowest and highest addresses mapped as a quick way of | 777 // We keep the lowest and highest addresses mapped as a quick way of |
| 778 // determining that pointers are outside the heap (used mostly in assertions | 778 // determining that pointers are outside the heap (used mostly in assertions |
| 779 // and verification). The estimate is conservative, ie, not all addresses in | 779 // and verification). The estimate is conservative, i.e., not all addresses in |
| 780 // 'allocated' space are actually allocated to our heap. The range is | 780 // 'allocated' space are actually allocated to our heap. The range is |
| 781 // [lowest, highest), inclusive on the low and and exclusive on the high end. | 781 // [lowest, highest), inclusive on the low and and exclusive on the high end. |
| 782 static void* lowest_ever_allocated = reinterpret_cast<void*>(-1); | 782 static void* lowest_ever_allocated = reinterpret_cast<void*>(-1); |
| 783 static void* highest_ever_allocated = reinterpret_cast<void*>(0); | 783 static void* highest_ever_allocated = reinterpret_cast<void*>(0); |
| 784 | 784 |
| 785 | 785 |
| 786 static void UpdateAllocatedSpaceLimits(void* address, int size) { | 786 static void UpdateAllocatedSpaceLimits(void* address, int size) { |
| 787 ASSERT(limit_mutex != NULL); | 787 ASSERT(limit_mutex != NULL); |
| 788 ScopedLock lock(limit_mutex); | 788 ScopedLock lock(limit_mutex); |
| 789 | 789 |
| (...skipping 729 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1519 explicit PlatformData(HANDLE thread) : thread_(thread) {} | 1519 explicit PlatformData(HANDLE thread) : thread_(thread) {} |
| 1520 HANDLE thread_; | 1520 HANDLE thread_; |
| 1521 unsigned thread_id_; | 1521 unsigned thread_id_; |
| 1522 }; | 1522 }; |
| 1523 | 1523 |
| 1524 | 1524 |
| 1525 // Initialize a Win32 thread object. The thread has an invalid thread | 1525 // Initialize a Win32 thread object. The thread has an invalid thread |
| 1526 // handle until it is started. | 1526 // handle until it is started. |
| 1527 | 1527 |
| 1528 Thread::Thread(const Options& options) | 1528 Thread::Thread(const Options& options) |
| 1529 : stack_size_(options.stack_size) { | 1529 : stack_size_(options.stack_size()) { |
| 1530 data_ = new PlatformData(kNoThread); | 1530 data_ = new PlatformData(kNoThread); |
| 1531 set_name(options.name); | 1531 set_name(options.name()); |
| 1532 } | |
| 1533 | |
| 1534 | |
| 1535 Thread::Thread(const char* name) | |
| 1536 : stack_size_(0) { | |
| 1537 data_ = new PlatformData(kNoThread); | |
| 1538 set_name(name); | |
| 1539 } | 1532 } |
| 1540 | 1533 |
| 1541 | 1534 |
| 1542 void Thread::set_name(const char* name) { | 1535 void Thread::set_name(const char* name) { |
| 1543 OS::StrNCpy(Vector<char>(name_, sizeof(name_)), name, strlen(name)); | 1536 OS::StrNCpy(Vector<char>(name_, sizeof(name_)), name, strlen(name)); |
| 1544 name_[sizeof(name_) - 1] = '\0'; | 1537 name_[sizeof(name_) - 1] = '\0'; |
| 1545 } | 1538 } |
| 1546 | 1539 |
| 1547 | 1540 |
| 1548 // Close our own handle for the thread. | 1541 // Close our own handle for the thread. |
| (...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1894 | 1887 |
| 1895 HANDLE profiled_thread() { return profiled_thread_; } | 1888 HANDLE profiled_thread() { return profiled_thread_; } |
| 1896 | 1889 |
| 1897 private: | 1890 private: |
| 1898 HANDLE profiled_thread_; | 1891 HANDLE profiled_thread_; |
| 1899 }; | 1892 }; |
| 1900 | 1893 |
| 1901 | 1894 |
| 1902 class SamplerThread : public Thread { | 1895 class SamplerThread : public Thread { |
| 1903 public: | 1896 public: |
| 1897 static const int kSamplerThreadStackSize = 32 * KB; |
| 1898 |
| 1904 explicit SamplerThread(int interval) | 1899 explicit SamplerThread(int interval) |
| 1905 : Thread("SamplerThread"), | 1900 : Thread(Thread::Options("SamplerThread", kSamplerThreadStackSize)), |
| 1906 interval_(interval) {} | 1901 interval_(interval) {} |
| 1907 | 1902 |
| 1908 static void AddActiveSampler(Sampler* sampler) { | 1903 static void AddActiveSampler(Sampler* sampler) { |
| 1909 ScopedLock lock(mutex_); | 1904 ScopedLock lock(mutex_); |
| 1910 SamplerRegistry::AddActiveSampler(sampler); | 1905 SamplerRegistry::AddActiveSampler(sampler); |
| 1911 if (instance_ == NULL) { | 1906 if (instance_ == NULL) { |
| 1912 instance_ = new SamplerThread(sampler->interval()); | 1907 instance_ = new SamplerThread(sampler->interval()); |
| 1913 instance_->Start(); | 1908 instance_->Start(); |
| 1914 } else { | 1909 } else { |
| 1915 ASSERT(instance_->interval_ == sampler->interval()); | 1910 ASSERT(instance_->interval_ == sampler->interval()); |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2038 | 2033 |
| 2039 | 2034 |
| 2040 void Sampler::Stop() { | 2035 void Sampler::Stop() { |
| 2041 ASSERT(IsActive()); | 2036 ASSERT(IsActive()); |
| 2042 SamplerThread::RemoveActiveSampler(this); | 2037 SamplerThread::RemoveActiveSampler(this); |
| 2043 SetActive(false); | 2038 SetActive(false); |
| 2044 } | 2039 } |
| 2045 | 2040 |
| 2046 | 2041 |
| 2047 } } // namespace v8::internal | 2042 } } // namespace v8::internal |
| OLD | NEW |