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 20 matching lines...) Expand all Loading... |
31 // on Windows XP. Make sure MINGW_HAS_SECURE_API is not defined to | 31 // on Windows XP. Make sure MINGW_HAS_SECURE_API is not defined to |
32 // disable definition of secure API functions in standard headers that | 32 // disable definition of secure API functions in standard headers that |
33 // would conflict with our own implementation. | 33 // would conflict with our own implementation. |
34 #ifdef __MINGW32__ | 34 #ifdef __MINGW32__ |
35 #include <_mingw.h> | 35 #include <_mingw.h> |
36 #ifdef MINGW_HAS_SECURE_API | 36 #ifdef MINGW_HAS_SECURE_API |
37 #undef MINGW_HAS_SECURE_API | 37 #undef MINGW_HAS_SECURE_API |
38 #endif // MINGW_HAS_SECURE_API | 38 #endif // MINGW_HAS_SECURE_API |
39 #endif // __MINGW32__ | 39 #endif // __MINGW32__ |
40 | 40 |
| 41 #define V8_WIN32_HEADERS_FULL |
41 #include "win32-headers.h" | 42 #include "win32-headers.h" |
42 | 43 |
43 #include "v8.h" | 44 #include "v8.h" |
44 | 45 |
45 #include "codegen.h" | 46 #include "codegen.h" |
46 #include "platform.h" | 47 #include "platform.h" |
47 #include "simulator.h" | 48 #include "simulator.h" |
48 #include "vm-state-inl.h" | 49 #include "vm-state-inl.h" |
49 | 50 |
50 #ifdef _MSC_VER | 51 #ifdef _MSC_VER |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 init_fast_sqrt_function(); | 239 init_fast_sqrt_function(); |
239 } | 240 } |
240 | 241 |
241 | 242 |
242 // ---------------------------------------------------------------------------- | 243 // ---------------------------------------------------------------------------- |
243 // The Time class represents time on win32. A timestamp is represented as | 244 // The Time class represents time on win32. A timestamp is represented as |
244 // a 64-bit integer in 100 nanoseconds since January 1, 1601 (UTC). JavaScript | 245 // a 64-bit integer in 100 nanoseconds since January 1, 1601 (UTC). JavaScript |
245 // timestamps are represented as a doubles in milliseconds since 00:00:00 UTC, | 246 // timestamps are represented as a doubles in milliseconds since 00:00:00 UTC, |
246 // January 1, 1970. | 247 // January 1, 1970. |
247 | 248 |
248 class Win32Time { | 249 class Time { |
249 public: | 250 public: |
250 // Constructors. | 251 // Constructors. |
251 explicit Win32Time(double jstime); | 252 Time(); |
252 Win32Time(int year, int mon, int day, int hour, int min, int sec); | 253 explicit Time(double jstime); |
| 254 Time(int year, int mon, int day, int hour, int min, int sec); |
253 | 255 |
254 // Convert timestamp to JavaScript representation. | 256 // Convert timestamp to JavaScript representation. |
255 double ToJSTime(); | 257 double ToJSTime(); |
256 | 258 |
| 259 // Set timestamp to current time. |
| 260 void SetToCurrentTime(); |
| 261 |
257 // Returns the local timezone offset in milliseconds east of UTC. This is | 262 // Returns the local timezone offset in milliseconds east of UTC. This is |
258 // the number of milliseconds you must add to UTC to get local time, i.e. | 263 // the number of milliseconds you must add to UTC to get local time, i.e. |
259 // LocalOffset(CET) = 3600000 and LocalOffset(PST) = -28800000. This | 264 // LocalOffset(CET) = 3600000 and LocalOffset(PST) = -28800000. This |
260 // routine also takes into account whether daylight saving is effect | 265 // routine also takes into account whether daylight saving is effect |
261 // at the time. | 266 // at the time. |
262 int64_t LocalOffset(); | 267 int64_t LocalOffset(); |
263 | 268 |
264 // Returns the daylight savings time offset for the time in milliseconds. | 269 // Returns the daylight savings time offset for the time in milliseconds. |
265 int64_t DaylightSavingsOffset(); | 270 int64_t DaylightSavingsOffset(); |
266 | 271 |
(...skipping 21 matching lines...) Expand all Loading... |
288 | 293 |
289 // Initialize the timezone information (if not already done). | 294 // Initialize the timezone information (if not already done). |
290 static void TzSet(); | 295 static void TzSet(); |
291 | 296 |
292 // Guess the name of the timezone from the bias. | 297 // Guess the name of the timezone from the bias. |
293 static const char* GuessTimezoneNameFromBias(int bias); | 298 static const char* GuessTimezoneNameFromBias(int bias); |
294 | 299 |
295 // Return whether or not daylight savings time is in effect at this time. | 300 // Return whether or not daylight savings time is in effect at this time. |
296 bool InDST(); | 301 bool InDST(); |
297 | 302 |
| 303 // Return the difference (in milliseconds) between this timestamp and |
| 304 // another timestamp. |
| 305 int64_t Diff(Time* other); |
| 306 |
298 // Accessor for FILETIME representation. | 307 // Accessor for FILETIME representation. |
299 FILETIME& ft() { return time_.ft_; } | 308 FILETIME& ft() { return time_.ft_; } |
300 | 309 |
301 // Accessor for integer representation. | 310 // Accessor for integer representation. |
302 int64_t& t() { return time_.t_; } | 311 int64_t& t() { return time_.t_; } |
303 | 312 |
304 // Although win32 uses 64-bit integers for representing timestamps, | 313 // Although win32 uses 64-bit integers for representing timestamps, |
305 // these are packed into a FILETIME structure. The FILETIME structure | 314 // these are packed into a FILETIME structure. The FILETIME structure |
306 // is just a struct representing a 64-bit integer. The TimeStamp union | 315 // is just a struct representing a 64-bit integer. The TimeStamp union |
307 // allows access to both a FILETIME and an integer representation of | 316 // allows access to both a FILETIME and an integer representation of |
308 // the timestamp. | 317 // the timestamp. |
309 union TimeStamp { | 318 union TimeStamp { |
310 FILETIME ft_; | 319 FILETIME ft_; |
311 int64_t t_; | 320 int64_t t_; |
312 }; | 321 }; |
313 | 322 |
314 TimeStamp time_; | 323 TimeStamp time_; |
315 }; | 324 }; |
316 | 325 |
317 | 326 |
318 // Static variables. | 327 // Static variables. |
319 bool Win32Time::tz_initialized_ = false; | 328 bool Time::tz_initialized_ = false; |
320 TIME_ZONE_INFORMATION Win32Time::tzinfo_; | 329 TIME_ZONE_INFORMATION Time::tzinfo_; |
321 char Win32Time::std_tz_name_[kTzNameSize]; | 330 char Time::std_tz_name_[kTzNameSize]; |
322 char Win32Time::dst_tz_name_[kTzNameSize]; | 331 char Time::dst_tz_name_[kTzNameSize]; |
| 332 |
| 333 |
| 334 // Initialize timestamp to start of epoc. |
| 335 Time::Time() { |
| 336 t() = 0; |
| 337 } |
323 | 338 |
324 | 339 |
325 // Initialize timestamp from a JavaScript timestamp. | 340 // Initialize timestamp from a JavaScript timestamp. |
326 Win32Time::Win32Time(double jstime) { | 341 Time::Time(double jstime) { |
327 t() = static_cast<int64_t>(jstime) * kTimeScaler + kTimeEpoc; | 342 t() = static_cast<int64_t>(jstime) * kTimeScaler + kTimeEpoc; |
328 } | 343 } |
329 | 344 |
330 | 345 |
331 // Initialize timestamp from date/time components. | 346 // Initialize timestamp from date/time components. |
332 Win32Time::Win32Time(int year, int mon, int day, int hour, int min, int sec) { | 347 Time::Time(int year, int mon, int day, int hour, int min, int sec) { |
333 SYSTEMTIME st; | 348 SYSTEMTIME st; |
334 st.wYear = year; | 349 st.wYear = year; |
335 st.wMonth = mon; | 350 st.wMonth = mon; |
336 st.wDay = day; | 351 st.wDay = day; |
337 st.wHour = hour; | 352 st.wHour = hour; |
338 st.wMinute = min; | 353 st.wMinute = min; |
339 st.wSecond = sec; | 354 st.wSecond = sec; |
340 st.wMilliseconds = 0; | 355 st.wMilliseconds = 0; |
341 SystemTimeToFileTime(&st, &ft()); | 356 SystemTimeToFileTime(&st, &ft()); |
342 } | 357 } |
343 | 358 |
344 | 359 |
345 // Convert timestamp to JavaScript timestamp. | 360 // Convert timestamp to JavaScript timestamp. |
346 double Win32Time::ToJSTime() { | 361 double Time::ToJSTime() { |
347 return static_cast<double>((t() - kTimeEpoc) / kTimeScaler); | 362 return static_cast<double>((t() - kTimeEpoc) / kTimeScaler); |
348 } | 363 } |
349 | 364 |
350 | 365 |
351 // Guess the name of the timezone from the bias. | 366 // Guess the name of the timezone from the bias. |
352 // The guess is very biased towards the northern hemisphere. | 367 // The guess is very biased towards the northern hemisphere. |
353 const char* Win32Time::GuessTimezoneNameFromBias(int bias) { | 368 const char* Time::GuessTimezoneNameFromBias(int bias) { |
354 static const int kHour = 60; | 369 static const int kHour = 60; |
355 switch (-bias) { | 370 switch (-bias) { |
356 case -9*kHour: return "Alaska"; | 371 case -9*kHour: return "Alaska"; |
357 case -8*kHour: return "Pacific"; | 372 case -8*kHour: return "Pacific"; |
358 case -7*kHour: return "Mountain"; | 373 case -7*kHour: return "Mountain"; |
359 case -6*kHour: return "Central"; | 374 case -6*kHour: return "Central"; |
360 case -5*kHour: return "Eastern"; | 375 case -5*kHour: return "Eastern"; |
361 case -4*kHour: return "Atlantic"; | 376 case -4*kHour: return "Atlantic"; |
362 case 0*kHour: return "GMT"; | 377 case 0*kHour: return "GMT"; |
363 case +1*kHour: return "Central Europe"; | 378 case +1*kHour: return "Central Europe"; |
364 case +2*kHour: return "Eastern Europe"; | 379 case +2*kHour: return "Eastern Europe"; |
365 case +3*kHour: return "Russia"; | 380 case +3*kHour: return "Russia"; |
366 case +5*kHour + 30: return "India"; | 381 case +5*kHour + 30: return "India"; |
367 case +8*kHour: return "China"; | 382 case +8*kHour: return "China"; |
368 case +9*kHour: return "Japan"; | 383 case +9*kHour: return "Japan"; |
369 case +12*kHour: return "New Zealand"; | 384 case +12*kHour: return "New Zealand"; |
370 default: return "Local"; | 385 default: return "Local"; |
371 } | 386 } |
372 } | 387 } |
373 | 388 |
374 | 389 |
375 // Initialize timezone information. The timezone information is obtained from | 390 // Initialize timezone information. The timezone information is obtained from |
376 // windows. If we cannot get the timezone information we fall back to CET. | 391 // windows. If we cannot get the timezone information we fall back to CET. |
377 // Please notice that this code is not thread-safe. | 392 // Please notice that this code is not thread-safe. |
378 void Win32Time::TzSet() { | 393 void Time::TzSet() { |
379 // Just return if timezone information has already been initialized. | 394 // Just return if timezone information has already been initialized. |
380 if (tz_initialized_) return; | 395 if (tz_initialized_) return; |
381 | 396 |
382 // Initialize POSIX time zone data. | 397 // Initialize POSIX time zone data. |
383 _tzset(); | 398 _tzset(); |
384 // Obtain timezone information from operating system. | 399 // Obtain timezone information from operating system. |
385 memset(&tzinfo_, 0, sizeof(tzinfo_)); | 400 memset(&tzinfo_, 0, sizeof(tzinfo_)); |
386 if (GetTimeZoneInformation(&tzinfo_) == TIME_ZONE_ID_INVALID) { | 401 if (GetTimeZoneInformation(&tzinfo_) == TIME_ZONE_ID_INVALID) { |
387 // If we cannot get timezone information we fall back to CET. | 402 // If we cannot get timezone information we fall back to CET. |
388 tzinfo_.Bias = -60; | 403 tzinfo_.Bias = -60; |
(...skipping 28 matching lines...) Expand all Loading... |
417 OS::SNPrintF(Vector<char>(dst_tz_name_, kTzNameSize - 1), | 432 OS::SNPrintF(Vector<char>(dst_tz_name_, kTzNameSize - 1), |
418 "%s Daylight Time", | 433 "%s Daylight Time", |
419 GuessTimezoneNameFromBias(tzinfo_.Bias)); | 434 GuessTimezoneNameFromBias(tzinfo_.Bias)); |
420 } | 435 } |
421 | 436 |
422 // Timezone information initialized. | 437 // Timezone information initialized. |
423 tz_initialized_ = true; | 438 tz_initialized_ = true; |
424 } | 439 } |
425 | 440 |
426 | 441 |
| 442 // Return the difference in milliseconds between this and another timestamp. |
| 443 int64_t Time::Diff(Time* other) { |
| 444 return (t() - other->t()) / kTimeScaler; |
| 445 } |
| 446 |
| 447 |
| 448 // Set timestamp to current time. |
| 449 void Time::SetToCurrentTime() { |
| 450 // The default GetSystemTimeAsFileTime has a ~15.5ms resolution. |
| 451 // Because we're fast, we like fast timers which have at least a |
| 452 // 1ms resolution. |
| 453 // |
| 454 // timeGetTime() provides 1ms granularity when combined with |
| 455 // timeBeginPeriod(). If the host application for v8 wants fast |
| 456 // timers, it can use timeBeginPeriod to increase the resolution. |
| 457 // |
| 458 // Using timeGetTime() has a drawback because it is a 32bit value |
| 459 // and hence rolls-over every ~49days. |
| 460 // |
| 461 // To use the clock, we use GetSystemTimeAsFileTime as our base; |
| 462 // and then use timeGetTime to extrapolate current time from the |
| 463 // start time. To deal with rollovers, we resync the clock |
| 464 // any time when more than kMaxClockElapsedTime has passed or |
| 465 // whenever timeGetTime creates a rollover. |
| 466 |
| 467 static bool initialized = false; |
| 468 static TimeStamp init_time; |
| 469 static DWORD init_ticks; |
| 470 static const int64_t kHundredNanosecondsPerSecond = 10000000; |
| 471 static const int64_t kMaxClockElapsedTime = |
| 472 60*kHundredNanosecondsPerSecond; // 1 minute |
| 473 |
| 474 // If we are uninitialized, we need to resync the clock. |
| 475 bool needs_resync = !initialized; |
| 476 |
| 477 // Get the current time. |
| 478 TimeStamp time_now; |
| 479 GetSystemTimeAsFileTime(&time_now.ft_); |
| 480 DWORD ticks_now = timeGetTime(); |
| 481 |
| 482 // Check if we need to resync due to clock rollover. |
| 483 needs_resync |= ticks_now < init_ticks; |
| 484 |
| 485 // Check if we need to resync due to elapsed time. |
| 486 needs_resync |= (time_now.t_ - init_time.t_) > kMaxClockElapsedTime; |
| 487 |
| 488 // Check if we need to resync due to backwards time change. |
| 489 needs_resync |= time_now.t_ < init_time.t_; |
| 490 |
| 491 // Resync the clock if necessary. |
| 492 if (needs_resync) { |
| 493 GetSystemTimeAsFileTime(&init_time.ft_); |
| 494 init_ticks = ticks_now = timeGetTime(); |
| 495 initialized = true; |
| 496 } |
| 497 |
| 498 // Finally, compute the actual time. Why is this so hard. |
| 499 DWORD elapsed = ticks_now - init_ticks; |
| 500 this->time_.t_ = init_time.t_ + (static_cast<int64_t>(elapsed) * 10000); |
| 501 } |
| 502 |
| 503 |
427 // Return the local timezone offset in milliseconds east of UTC. This | 504 // Return the local timezone offset in milliseconds east of UTC. This |
428 // takes into account whether daylight saving is in effect at the time. | 505 // takes into account whether daylight saving is in effect at the time. |
429 // Only times in the 32-bit Unix range may be passed to this function. | 506 // Only times in the 32-bit Unix range may be passed to this function. |
430 // Also, adding the time-zone offset to the input must not overflow. | 507 // Also, adding the time-zone offset to the input must not overflow. |
431 // The function EquivalentTime() in date.js guarantees this. | 508 // The function EquivalentTime() in date.js guarantees this. |
432 int64_t Win32Time::LocalOffset() { | 509 int64_t Time::LocalOffset() { |
433 // Initialize timezone information, if needed. | 510 // Initialize timezone information, if needed. |
434 TzSet(); | 511 TzSet(); |
435 | 512 |
436 Win32Time rounded_to_second(*this); | 513 Time rounded_to_second(*this); |
437 rounded_to_second.t() = rounded_to_second.t() / 1000 / kTimeScaler * | 514 rounded_to_second.t() = rounded_to_second.t() / 1000 / kTimeScaler * |
438 1000 * kTimeScaler; | 515 1000 * kTimeScaler; |
439 // Convert to local time using POSIX localtime function. | 516 // Convert to local time using POSIX localtime function. |
440 // Windows XP Service Pack 3 made SystemTimeToTzSpecificLocalTime() | 517 // Windows XP Service Pack 3 made SystemTimeToTzSpecificLocalTime() |
441 // very slow. Other browsers use localtime(). | 518 // very slow. Other browsers use localtime(). |
442 | 519 |
443 // Convert from JavaScript milliseconds past 1/1/1970 0:00:00 to | 520 // Convert from JavaScript milliseconds past 1/1/1970 0:00:00 to |
444 // POSIX seconds past 1/1/1970 0:00:00. | 521 // POSIX seconds past 1/1/1970 0:00:00. |
445 double unchecked_posix_time = rounded_to_second.ToJSTime() / 1000; | 522 double unchecked_posix_time = rounded_to_second.ToJSTime() / 1000; |
446 if (unchecked_posix_time > INT_MAX || unchecked_posix_time < 0) { | 523 if (unchecked_posix_time > INT_MAX || unchecked_posix_time < 0) { |
(...skipping 10 matching lines...) Expand all Loading... |
457 return (tzinfo_.Bias + tzinfo_.DaylightBias) * -kMsPerMinute; | 534 return (tzinfo_.Bias + tzinfo_.DaylightBias) * -kMsPerMinute; |
458 } else if (posix_local_time_struct.tm_isdst == 0) { | 535 } else if (posix_local_time_struct.tm_isdst == 0) { |
459 return (tzinfo_.Bias + tzinfo_.StandardBias) * -kMsPerMinute; | 536 return (tzinfo_.Bias + tzinfo_.StandardBias) * -kMsPerMinute; |
460 } else { | 537 } else { |
461 return tzinfo_.Bias * -kMsPerMinute; | 538 return tzinfo_.Bias * -kMsPerMinute; |
462 } | 539 } |
463 } | 540 } |
464 | 541 |
465 | 542 |
466 // Return whether or not daylight savings time is in effect at this time. | 543 // Return whether or not daylight savings time is in effect at this time. |
467 bool Win32Time::InDST() { | 544 bool Time::InDST() { |
468 // Initialize timezone information, if needed. | 545 // Initialize timezone information, if needed. |
469 TzSet(); | 546 TzSet(); |
470 | 547 |
471 // Determine if DST is in effect at the specified time. | 548 // Determine if DST is in effect at the specified time. |
472 bool in_dst = false; | 549 bool in_dst = false; |
473 if (tzinfo_.StandardDate.wMonth != 0 || tzinfo_.DaylightDate.wMonth != 0) { | 550 if (tzinfo_.StandardDate.wMonth != 0 || tzinfo_.DaylightDate.wMonth != 0) { |
474 // Get the local timezone offset for the timestamp in milliseconds. | 551 // Get the local timezone offset for the timestamp in milliseconds. |
475 int64_t offset = LocalOffset(); | 552 int64_t offset = LocalOffset(); |
476 | 553 |
477 // Compute the offset for DST. The bias parameters in the timezone info | 554 // Compute the offset for DST. The bias parameters in the timezone info |
478 // are specified in minutes. These must be converted to milliseconds. | 555 // are specified in minutes. These must be converted to milliseconds. |
479 int64_t dstofs = -(tzinfo_.Bias + tzinfo_.DaylightBias) * kMsPerMinute; | 556 int64_t dstofs = -(tzinfo_.Bias + tzinfo_.DaylightBias) * kMsPerMinute; |
480 | 557 |
481 // If the local time offset equals the timezone bias plus the daylight | 558 // If the local time offset equals the timezone bias plus the daylight |
482 // bias then DST is in effect. | 559 // bias then DST is in effect. |
483 in_dst = offset == dstofs; | 560 in_dst = offset == dstofs; |
484 } | 561 } |
485 | 562 |
486 return in_dst; | 563 return in_dst; |
487 } | 564 } |
488 | 565 |
489 | 566 |
490 // Return the daylight savings time offset for this time. | 567 // Return the daylight savings time offset for this time. |
491 int64_t Win32Time::DaylightSavingsOffset() { | 568 int64_t Time::DaylightSavingsOffset() { |
492 return InDST() ? 60 * kMsPerMinute : 0; | 569 return InDST() ? 60 * kMsPerMinute : 0; |
493 } | 570 } |
494 | 571 |
495 | 572 |
496 // Returns a string identifying the current timezone for the | 573 // Returns a string identifying the current timezone for the |
497 // timestamp taking into account daylight saving. | 574 // timestamp taking into account daylight saving. |
498 char* Win32Time::LocalTimezone() { | 575 char* Time::LocalTimezone() { |
499 // Return the standard or DST time zone name based on whether daylight | 576 // Return the standard or DST time zone name based on whether daylight |
500 // saving is in effect at the given time. | 577 // saving is in effect at the given time. |
501 return InDST() ? dst_tz_name_ : std_tz_name_; | 578 return InDST() ? dst_tz_name_ : std_tz_name_; |
502 } | 579 } |
503 | 580 |
504 | 581 |
505 void OS::PostSetUp() { | 582 void OS::PostSetUp() { |
506 // Math functions depend on CPU features therefore they are initialized after | 583 // Math functions depend on CPU features therefore they are initialized after |
507 // CPU. | 584 // CPU. |
508 MathSetup(); | 585 MathSetup(); |
(...skipping 21 matching lines...) Expand all Loading... |
530 // Convert to seconds and microseconds | 607 // Convert to seconds and microseconds |
531 *secs = static_cast<uint32_t>(usertime / 1000000); | 608 *secs = static_cast<uint32_t>(usertime / 1000000); |
532 *usecs = static_cast<uint32_t>(usertime % 1000000); | 609 *usecs = static_cast<uint32_t>(usertime % 1000000); |
533 return 0; | 610 return 0; |
534 } | 611 } |
535 | 612 |
536 | 613 |
537 // Returns current time as the number of milliseconds since | 614 // Returns current time as the number of milliseconds since |
538 // 00:00:00 UTC, January 1, 1970. | 615 // 00:00:00 UTC, January 1, 1970. |
539 double OS::TimeCurrentMillis() { | 616 double OS::TimeCurrentMillis() { |
540 return Time::Now().ToJsTime(); | 617 Time t; |
| 618 t.SetToCurrentTime(); |
| 619 return t.ToJSTime(); |
| 620 } |
| 621 |
| 622 |
| 623 // Returns the tickcounter based on timeGetTime. |
| 624 int64_t OS::Ticks() { |
| 625 return timeGetTime() * 1000; // Convert to microseconds. |
541 } | 626 } |
542 | 627 |
543 | 628 |
544 // Returns a string identifying the current timezone taking into | 629 // Returns a string identifying the current timezone taking into |
545 // account daylight saving. | 630 // account daylight saving. |
546 const char* OS::LocalTimezone(double time) { | 631 const char* OS::LocalTimezone(double time) { |
547 return Win32Time(time).LocalTimezone(); | 632 return Time(time).LocalTimezone(); |
548 } | 633 } |
549 | 634 |
550 | 635 |
551 // Returns the local time offset in milliseconds east of UTC without | 636 // Returns the local time offset in milliseconds east of UTC without |
552 // taking daylight savings time into account. | 637 // taking daylight savings time into account. |
553 double OS::LocalTimeOffset() { | 638 double OS::LocalTimeOffset() { |
554 // Use current time, rounded to the millisecond. | 639 // Use current time, rounded to the millisecond. |
555 Win32Time t(TimeCurrentMillis()); | 640 Time t(TimeCurrentMillis()); |
556 // Time::LocalOffset inlcudes any daylight savings offset, so subtract it. | 641 // Time::LocalOffset inlcudes any daylight savings offset, so subtract it. |
557 return static_cast<double>(t.LocalOffset() - t.DaylightSavingsOffset()); | 642 return static_cast<double>(t.LocalOffset() - t.DaylightSavingsOffset()); |
558 } | 643 } |
559 | 644 |
560 | 645 |
561 // Returns the daylight savings offset in milliseconds for the given | 646 // Returns the daylight savings offset in milliseconds for the given |
562 // time. | 647 // time. |
563 double OS::DaylightSavingsOffset(double time) { | 648 double OS::DaylightSavingsOffset(double time) { |
564 int64_t offset = Win32Time(time).DaylightSavingsOffset(); | 649 int64_t offset = Time(time).DaylightSavingsOffset(); |
565 return static_cast<double>(offset); | 650 return static_cast<double>(offset); |
566 } | 651 } |
567 | 652 |
568 | 653 |
569 int OS::GetLastError() { | 654 int OS::GetLastError() { |
570 return ::GetLastError(); | 655 return ::GetLastError(); |
571 } | 656 } |
572 | 657 |
573 | 658 |
574 int OS::GetCurrentProcessId() { | 659 int OS::GetCurrentProcessId() { |
(...skipping 1326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1901 limit_mutex = CreateMutex(); | 1986 limit_mutex = CreateMutex(); |
1902 } | 1987 } |
1903 | 1988 |
1904 | 1989 |
1905 void OS::TearDown() { | 1990 void OS::TearDown() { |
1906 delete limit_mutex; | 1991 delete limit_mutex; |
1907 } | 1992 } |
1908 | 1993 |
1909 | 1994 |
1910 } } // namespace v8::internal | 1995 } } // namespace v8::internal |
OLD | NEW |