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 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
386 case +2*kHour: return "Eastern Europe"; | 386 case +2*kHour: return "Eastern Europe"; |
387 case +3*kHour: return "Russia"; | 387 case +3*kHour: return "Russia"; |
388 case +5*kHour + 30: return "India"; | 388 case +5*kHour + 30: return "India"; |
389 case +8*kHour: return "China"; | 389 case +8*kHour: return "China"; |
390 case +9*kHour: return "Japan"; | 390 case +9*kHour: return "Japan"; |
391 case +12*kHour: return "New Zealand"; | 391 case +12*kHour: return "New Zealand"; |
392 default: return "Local"; | 392 default: return "Local"; |
393 } | 393 } |
394 } | 394 } |
395 | 395 |
| 396 static MutexLockAdapter time_lock(OS::CreateMutex()); |
396 | 397 |
397 // Initialize timezone information. The timezone information is obtained from | 398 // Initialize timezone information. The timezone information is obtained from |
398 // windows. If we cannot get the timezone information we fall back to CET. | 399 // windows. If we cannot get the timezone information we fall back to CET. |
399 // Please notice that this code is not thread-safe. | 400 // Please notice that this code is not thread-safe. |
400 void Time::TzSet() { | 401 void Time::TzSet() { |
| 402 V8SharedStateLocker time_locker(&time_lock); |
401 // Just return if timezone information has already been initialized. | 403 // Just return if timezone information has already been initialized. |
402 if (tz_initialized_) return; | 404 if (tz_initialized_) return; |
403 | 405 |
404 // Initialize POSIX time zone data. | 406 // Initialize POSIX time zone data. |
405 _tzset(); | 407 _tzset(); |
406 // Obtain timezone information from operating system. | 408 // Obtain timezone information from operating system. |
407 memset(&tzinfo_, 0, sizeof(tzinfo_)); | 409 memset(&tzinfo_, 0, sizeof(tzinfo_)); |
408 if (GetTimeZoneInformation(&tzinfo_) == TIME_ZONE_ID_INVALID) { | 410 if (GetTimeZoneInformation(&tzinfo_) == TIME_ZONE_ID_INVALID) { |
409 // If we cannot get timezone information we fall back to CET. | 411 // If we cannot get timezone information we fall back to CET. |
410 tzinfo_.Bias = -60; | 412 tzinfo_.Bias = -60; |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
499 GetSystemTimeAsFileTime(&init_time.ft_); | 501 GetSystemTimeAsFileTime(&init_time.ft_); |
500 init_ticks = ticks_now = timeGetTime(); | 502 init_ticks = ticks_now = timeGetTime(); |
501 initialized = true; | 503 initialized = true; |
502 } | 504 } |
503 | 505 |
504 // Finally, compute the actual time. Why is this so hard. | 506 // Finally, compute the actual time. Why is this so hard. |
505 DWORD elapsed = ticks_now - init_ticks; | 507 DWORD elapsed = ticks_now - init_ticks; |
506 this->time_.t_ = init_time.t_ + (static_cast<int64_t>(elapsed) * 10000); | 508 this->time_.t_ = init_time.t_ + (static_cast<int64_t>(elapsed) * 10000); |
507 } | 509 } |
508 | 510 |
509 | |
510 // Return the local timezone offset in milliseconds east of UTC. This | 511 // Return the local timezone offset in milliseconds east of UTC. This |
511 // takes into account whether daylight saving is in effect at the time. | 512 // takes into account whether daylight saving is in effect at the time. |
512 // Only times in the 32-bit Unix range may be passed to this function. | 513 // Only times in the 32-bit Unix range may be passed to this function. |
513 // Also, adding the time-zone offset to the input must not overflow. | 514 // Also, adding the time-zone offset to the input must not overflow. |
514 // The function EquivalentTime() in date-delay.js guarantees this. | 515 // The function EquivalentTime() in date-delay.js guarantees this. |
515 int64_t Time::LocalOffset() { | 516 int64_t Time::LocalOffset() { |
516 // Initialize timezone information, if needed. | 517 // Initialize timezone information, if needed. |
517 TzSet(); | 518 TzSet(); |
518 | 519 |
519 Time rounded_to_second(*this); | 520 Time rounded_to_second(*this); |
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
782 | 783 |
783 | 784 |
784 // We keep the lowest and highest addresses mapped as a quick way of | 785 // We keep the lowest and highest addresses mapped as a quick way of |
785 // determining that pointers are outside the heap (used mostly in assertions | 786 // determining that pointers are outside the heap (used mostly in assertions |
786 // and verification). The estimate is conservative, ie, not all addresses in | 787 // and verification). The estimate is conservative, ie, not all addresses in |
787 // 'allocated' space are actually allocated to our heap. The range is | 788 // 'allocated' space are actually allocated to our heap. The range is |
788 // [lowest, highest), inclusive on the low and and exclusive on the high end. | 789 // [lowest, highest), inclusive on the low and and exclusive on the high end. |
789 static void* lowest_ever_allocated = reinterpret_cast<void*>(-1); | 790 static void* lowest_ever_allocated = reinterpret_cast<void*>(-1); |
790 static void* highest_ever_allocated = reinterpret_cast<void*>(0); | 791 static void* highest_ever_allocated = reinterpret_cast<void*>(0); |
791 | 792 |
| 793 static MutexLockAdapter heap_limits_lock(OS::CreateMutex()); |
792 | 794 |
793 static void UpdateAllocatedSpaceLimits(void* address, int size) { | 795 static void UpdateAllocatedSpaceLimits(void* address, int size) { |
794 lowest_ever_allocated = Min(lowest_ever_allocated, address); | 796 V8SharedStateLocker heap_limits_locker(&heap_limits_lock); |
795 highest_ever_allocated = | 797 lowest_ever_allocated = Min( |
796 Max(highest_ever_allocated, | 798 lowest_ever_allocated, reinterpret_cast<void*>(address)); |
797 reinterpret_cast<void*>(reinterpret_cast<char*>(address) + size)); | 799 highest_ever_allocated = Max(highest_ever_allocated, |
| 800 reinterpret_cast<void*>(reinterpret_cast<char*>(address) + size)); |
798 } | 801 } |
799 | 802 |
800 | 803 |
801 bool OS::IsOutsideAllocatedSpace(void* pointer) { | 804 bool OS::IsOutsideAllocatedSpace(void* pointer) { |
| 805 V8SharedStateLocker heap_limits_locker(&heap_limits_lock); |
802 if (pointer < lowest_ever_allocated || pointer >= highest_ever_allocated) | 806 if (pointer < lowest_ever_allocated || pointer >= highest_ever_allocated) |
803 return true; | 807 return true; |
804 // Ask the Windows API | 808 // Ask the Windows API |
805 if (IsBadWritePtr(pointer, 1)) | 809 if (IsBadWritePtr(pointer, 1)) |
806 return true; | 810 return true; |
807 return false; | 811 return false; |
808 } | 812 } |
809 | 813 |
810 | 814 |
811 // Get the system's page size used by VirtualAlloc() or the next power | 815 // Get the system's page size used by VirtualAlloc() or the next power |
812 // of two. The reason for always returning a power of two is that the | 816 // of two. The reason for always returning a power of two is that the |
813 // rounding up in OS::Allocate expects that. | 817 // rounding up in OS::Allocate expects that. |
814 static size_t GetPageSize() { | 818 static size_t GetPageSize() { |
815 static size_t page_size = 0; | 819 static volatile size_t page_size = 0; |
816 if (page_size == 0) { | 820 if (page_size == 0) { |
817 SYSTEM_INFO info; | 821 SYSTEM_INFO info; |
818 GetSystemInfo(&info); | 822 GetSystemInfo(&info); |
819 page_size = RoundUpToPowerOf2(info.dwPageSize); | 823 page_size = RoundUpToPowerOf2(info.dwPageSize); |
820 } | 824 } |
821 return page_size; | 825 return page_size; |
822 } | 826 } |
823 | 827 |
824 | 828 |
825 // The allocation alignment is the guaranteed alignment for | 829 // The allocation alignment is the guaranteed alignment for |
(...skipping 1073 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1899 | 1903 |
1900 // Release the thread handles | 1904 // Release the thread handles |
1901 CloseHandle(data_->sampler_thread_); | 1905 CloseHandle(data_->sampler_thread_); |
1902 CloseHandle(data_->profiled_thread_); | 1906 CloseHandle(data_->profiled_thread_); |
1903 } | 1907 } |
1904 | 1908 |
1905 | 1909 |
1906 #endif // ENABLE_LOGGING_AND_PROFILING | 1910 #endif // ENABLE_LOGGING_AND_PROFILING |
1907 | 1911 |
1908 } } // namespace v8::internal | 1912 } } // namespace v8::internal |
OLD | NEW |