OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
331 // With recent updates on HAL and newer BIOS, QPC is getting more reliable but | 331 // With recent updates on HAL and newer BIOS, QPC is getting more reliable but |
332 // it should be used with caution. | 332 // it should be used with caution. |
333 // | 333 // |
334 // (3) System time. The system time provides a low-resolution (typically 10ms | 334 // (3) System time. The system time provides a low-resolution (typically 10ms |
335 // to 55 milliseconds) time stamp but is comparatively less expensive to | 335 // to 55 milliseconds) time stamp but is comparatively less expensive to |
336 // retrieve and more reliable. | 336 // retrieve and more reliable. |
337 class HighResolutionTickClock V8_FINAL : public TickClock { | 337 class HighResolutionTickClock V8_FINAL : public TickClock { |
338 public: | 338 public: |
339 explicit HighResolutionTickClock(int64_t ticks_per_second) | 339 explicit HighResolutionTickClock(int64_t ticks_per_second) |
340 : ticks_per_second_(ticks_per_second) { | 340 : ticks_per_second_(ticks_per_second) { |
341 ASSERT_NE(0, ticks_per_second); | 341 ASSERT_LT(0, ticks_per_second); |
342 } | 342 } |
343 virtual ~HighResolutionTickClock() {} | 343 virtual ~HighResolutionTickClock() {} |
344 | 344 |
345 virtual int64_t Now() V8_OVERRIDE { | 345 virtual int64_t Now() V8_OVERRIDE { |
346 LARGE_INTEGER now; | 346 LARGE_INTEGER now; |
347 BOOL result = QueryPerformanceCounter(&now); | 347 BOOL result = QueryPerformanceCounter(&now); |
348 ASSERT(result); | 348 ASSERT(result); |
349 USE(result); | 349 USE(result); |
350 | 350 |
351 // Intentionally calculate microseconds in a round about manner to avoid | 351 // Intentionally calculate microseconds in a round about manner to avoid |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
473 ticks = (ts.tv_sec * Time::kMicrosecondsPerSecond + | 473 ticks = (ts.tv_sec * Time::kMicrosecondsPerSecond + |
474 ts.tv_nsec / Time::kNanosecondsPerMicrosecond); | 474 ts.tv_nsec / Time::kNanosecondsPerMicrosecond); |
475 #endif // V8_OS_MACOSX | 475 #endif // V8_OS_MACOSX |
476 // Make sure we never return 0 here. | 476 // Make sure we never return 0 here. |
477 return TimeTicks(ticks + 1); | 477 return TimeTicks(ticks + 1); |
478 } | 478 } |
479 | 479 |
480 #endif // V8_OS_WIN | 480 #endif // V8_OS_WIN |
481 | 481 |
482 } } // namespace v8::internal | 482 } } // namespace v8::internal |
OLD | NEW |