Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: src/platform/time.cc

Issue 23548007: Import ConditionVariable class. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Rename OperandSize enum names. Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/platform/time.h ('k') | src/x64/disasm-x64.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 119
120 120
121 int64_t TimeDelta::InNanoseconds() const { 121 int64_t TimeDelta::InNanoseconds() const {
122 return delta_ * Time::kNanosecondsPerMicrosecond; 122 return delta_ * Time::kNanosecondsPerMicrosecond;
123 } 123 }
124 124
125 125
126 #if V8_OS_MACOSX 126 #if V8_OS_MACOSX
127 127
128 TimeDelta TimeDelta::FromMachTimespec(struct mach_timespec ts) { 128 TimeDelta TimeDelta::FromMachTimespec(struct mach_timespec ts) {
129 ASSERT(ts.tv_nsec >= 0); 129 ASSERT_GE(ts.tv_nsec, 0);
130 ASSERT_LT(ts.tv_nsec,
131 static_cast<long>(Time::kNanosecondsPerSecond)); // NOLINT
130 return TimeDelta(ts.tv_sec * Time::kMicrosecondsPerSecond + 132 return TimeDelta(ts.tv_sec * Time::kMicrosecondsPerSecond +
131 ts.tv_nsec / Time::kNanosecondsPerMicrosecond); 133 ts.tv_nsec / Time::kNanosecondsPerMicrosecond);
132 } 134 }
133 135
134 136
135 struct mach_timespec TimeDelta::ToMachTimespec() const { 137 struct mach_timespec TimeDelta::ToMachTimespec() const {
136 struct mach_timespec ts; 138 struct mach_timespec ts;
137 ASSERT(delta_ >= 0); 139 ASSERT(delta_ >= 0);
138 ts.tv_sec = delta_ / Time::kMicrosecondsPerSecond; 140 ts.tv_sec = delta_ / Time::kMicrosecondsPerSecond;
139 ts.tv_nsec = (delta_ % Time::kMicrosecondsPerSecond) * 141 ts.tv_nsec = (delta_ % Time::kMicrosecondsPerSecond) *
140 Time::kNanosecondsPerMicrosecond; 142 Time::kNanosecondsPerMicrosecond;
141 return ts; 143 return ts;
142 } 144 }
143 145
144 #endif // V8_OS_MACOSX 146 #endif // V8_OS_MACOSX
145 147
146 148
149 #if V8_OS_POSIX
150
151 TimeDelta TimeDelta::FromTimespec(struct timespec ts) {
152 ASSERT_GE(ts.tv_nsec, 0);
153 ASSERT_LT(ts.tv_nsec,
154 static_cast<long>(Time::kNanosecondsPerSecond)); // NOLINT
155 return TimeDelta(ts.tv_sec * Time::kMicrosecondsPerSecond +
156 ts.tv_nsec / Time::kNanosecondsPerMicrosecond);
157 }
158
159
160 struct timespec TimeDelta::ToTimespec() const {
161 struct timespec ts;
162 ts.tv_sec = delta_ / Time::kMicrosecondsPerSecond;
163 ts.tv_nsec = (delta_ % Time::kMicrosecondsPerSecond) *
164 Time::kNanosecondsPerMicrosecond;
165 return ts;
166 }
167
168 #endif // V8_OS_POSIX
169
170
147 #if V8_OS_WIN 171 #if V8_OS_WIN
148 172
149 // We implement time using the high-resolution timers so that we can get 173 // We implement time using the high-resolution timers so that we can get
150 // timeouts which are smaller than 10-15ms. To avoid any drift, we 174 // timeouts which are smaller than 10-15ms. To avoid any drift, we
151 // periodically resync the internal clock to the system clock. 175 // periodically resync the internal clock to the system clock.
152 class Clock V8_FINAL { 176 class Clock V8_FINAL {
153 public: 177 public:
154 Clock() : initial_time_(CurrentWallclockTime()), 178 Clock() : initial_time_(CurrentWallclockTime()),
155 initial_ticks_(TimeTicks::Now()) {} 179 initial_ticks_(TimeTicks::Now()) {}
156 180
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after
580 ticks = (ts.tv_sec * Time::kMicrosecondsPerSecond + 604 ticks = (ts.tv_sec * Time::kMicrosecondsPerSecond +
581 ts.tv_nsec / Time::kNanosecondsPerMicrosecond); 605 ts.tv_nsec / Time::kNanosecondsPerMicrosecond);
582 #endif // V8_OS_MACOSX 606 #endif // V8_OS_MACOSX
583 // Make sure we never return 0 here. 607 // Make sure we never return 0 here.
584 return TimeTicks(ticks + 1); 608 return TimeTicks(ticks + 1);
585 } 609 }
586 610
587 #endif // V8_OS_WIN 611 #endif // V8_OS_WIN
588 612
589 } } // namespace v8::internal 613 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/platform/time.h ('k') | src/x64/disasm-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698