| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 573 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 584 | 584 |
| 585 | 585 |
| 586 // Returns current time as the number of milliseconds since | 586 // Returns current time as the number of milliseconds since |
| 587 // 00:00:00 UTC, January 1, 1970. | 587 // 00:00:00 UTC, January 1, 1970. |
| 588 double OS::TimeCurrentMillis() { | 588 double OS::TimeCurrentMillis() { |
| 589 Time t; | 589 Time t; |
| 590 t.SetToCurrentTime(); | 590 t.SetToCurrentTime(); |
| 591 return t.ToJSTime(); | 591 return t.ToJSTime(); |
| 592 } | 592 } |
| 593 | 593 |
| 594 // Returns the tickcounter based on timeGetTime. | 594 |
| 595 static LARGE_INTEGER frequency = 0; |
| 596 |
| 597 |
| 598 // Returns the tickcounter based on QueryPerformanceCounter or timeGetTime. |
| 595 int64_t OS::Ticks() { | 599 int64_t OS::Ticks() { |
| 600 static LARGE_INTEGER tick; |
| 601 if (frequency != 0 && QueryPerformanceCounter(&tick)) { |
| 602 return static_cast<int64_t>(tick.QuadPart * 1e6 / frequency->QuadPart); |
| 603 } |
| 596 return timeGetTime() * 1000; // Convert to microseconds. | 604 return timeGetTime() * 1000; // Convert to microseconds. |
| 597 } | 605 } |
| 598 | 606 |
| 599 | 607 |
| 600 // Returns a string identifying the current timezone taking into | 608 // Returns a string identifying the current timezone taking into |
| 601 // account daylight saving. | 609 // account daylight saving. |
| 602 const char* OS::LocalTimezone(double time) { | 610 const char* OS::LocalTimezone(double time) { |
| 603 return Time(time).LocalTimezone(); | 611 return Time(time).LocalTimezone(); |
| 604 } | 612 } |
| 605 | 613 |
| (...skipping 1474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2080 | 2088 |
| 2081 | 2089 |
| 2082 void OS::SetUp() { | 2090 void OS::SetUp() { |
| 2083 // Seed the random number generator. | 2091 // Seed the random number generator. |
| 2084 // Convert the current time to a 64-bit integer first, before converting it | 2092 // Convert the current time to a 64-bit integer first, before converting it |
| 2085 // to an unsigned. Going directly can cause an overflow and the seed to be | 2093 // to an unsigned. Going directly can cause an overflow and the seed to be |
| 2086 // set to all ones. The seed will be identical for different instances that | 2094 // set to all ones. The seed will be identical for different instances that |
| 2087 // call this setup code within the same millisecond. | 2095 // call this setup code within the same millisecond. |
| 2088 uint64_t seed = static_cast<uint64_t>(TimeCurrentMillis()); | 2096 uint64_t seed = static_cast<uint64_t>(TimeCurrentMillis()); |
| 2089 srand(static_cast<unsigned int>(seed)); | 2097 srand(static_cast<unsigned int>(seed)); |
| 2098 // Get the number of ticks per second that is used in OS::Ticks() |
| 2099 QueryPerformanceFrequency(&frequency); |
| 2090 limit_mutex = CreateMutex(); | 2100 limit_mutex = CreateMutex(); |
| 2091 SamplerThread::SetUp(); | 2101 SamplerThread::SetUp(); |
| 2092 } | 2102 } |
| 2093 | 2103 |
| 2094 | 2104 |
| 2095 void OS::TearDown() { | 2105 void OS::TearDown() { |
| 2106 frequency = 0; |
| 2096 SamplerThread::TearDown(); | 2107 SamplerThread::TearDown(); |
| 2097 delete limit_mutex; | 2108 delete limit_mutex; |
| 2098 } | 2109 } |
| 2099 | 2110 |
| 2100 | 2111 |
| 2101 Sampler::Sampler(Isolate* isolate, int interval) | 2112 Sampler::Sampler(Isolate* isolate, int interval) |
| 2102 : isolate_(isolate), | 2113 : isolate_(isolate), |
| 2103 interval_(interval), | 2114 interval_(interval), |
| 2104 profiling_(false), | 2115 profiling_(false), |
| 2105 active_(false), | 2116 active_(false), |
| (...skipping 16 matching lines...) Expand all Loading... |
| 2122 | 2133 |
| 2123 | 2134 |
| 2124 void Sampler::Stop() { | 2135 void Sampler::Stop() { |
| 2125 ASSERT(IsActive()); | 2136 ASSERT(IsActive()); |
| 2126 SamplerThread::RemoveActiveSampler(this); | 2137 SamplerThread::RemoveActiveSampler(this); |
| 2127 SetActive(false); | 2138 SetActive(false); |
| 2128 } | 2139 } |
| 2129 | 2140 |
| 2130 | 2141 |
| 2131 } } // namespace v8::internal | 2142 } } // namespace v8::internal |
| OLD | NEW |