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