| 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 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 } | 140 } |
| 141 | 141 |
| 142 | 142 |
| 143 double ceiling(double x) { | 143 double ceiling(double x) { |
| 144 return ceil(x); | 144 return ceil(x); |
| 145 } | 145 } |
| 146 | 146 |
| 147 | 147 |
| 148 static Mutex* limit_mutex = NULL; | 148 static Mutex* limit_mutex = NULL; |
| 149 | 149 |
| 150 #if defined(V8_TARGET_ARCH_IA32) | 150 #if V8_TARGET_ARCH_IA32 |
| 151 static void MemMoveWrapper(void* dest, const void* src, size_t size) { | 151 static void MemMoveWrapper(void* dest, const void* src, size_t size) { |
| 152 memmove(dest, src, size); | 152 memmove(dest, src, size); |
| 153 } | 153 } |
| 154 | 154 |
| 155 |
| 155 // Initialize to library version so we can call this at any time during startup. | 156 // Initialize to library version so we can call this at any time during startup. |
| 156 static OS::MemMoveFunction memmove_function = &MemMoveWrapper; | 157 static OS::MemMoveFunction memmove_function = &MemMoveWrapper; |
| 157 | 158 |
| 158 // Defined in codegen-ia32.cc. | 159 // Defined in codegen-ia32.cc. |
| 159 OS::MemMoveFunction CreateMemMoveFunction(); | 160 OS::MemMoveFunction CreateMemMoveFunction(); |
| 160 | 161 |
| 161 // Copy memory area to disjoint memory area. | 162 // Copy memory area to disjoint memory area. |
| 162 void OS::MemMove(void* dest, const void* src, size_t size) { | 163 void OS::MemMove(void* dest, const void* src, size_t size) { |
| 163 if (size == 0) return; | 164 if (size == 0) return; |
| 164 // Note: here we rely on dependent reads being ordered. This is true | 165 // Note: here we rely on dependent reads being ordered. This is true |
| 165 // on all architectures we currently support. | 166 // on all architectures we currently support. |
| 166 (*memmove_function)(dest, src, size); | 167 (*memmove_function)(dest, src, size); |
| 167 } | 168 } |
| 168 | 169 |
| 169 #endif // V8_TARGET_ARCH_IA32 | 170 #endif // V8_TARGET_ARCH_IA32 |
| 170 | 171 |
| 171 #ifdef _WIN64 | 172 #ifdef _WIN64 |
| 172 typedef double (*ModuloFunction)(double, double); | 173 typedef double (*ModuloFunction)(double, double); |
| 173 static ModuloFunction modulo_function = NULL; | 174 static ModuloFunction modulo_function = NULL; |
| 174 // Defined in codegen-x64.cc. | 175 // Defined in codegen-x64.cc. |
| 175 ModuloFunction CreateModuloFunction(); | 176 ModuloFunction CreateModuloFunction(); |
| 176 | 177 |
| 177 void init_modulo_function() { | 178 void init_modulo_function() { |
| 178 modulo_function = CreateModuloFunction(); | 179 modulo_function = CreateModuloFunction(); |
| 179 } | 180 } |
| 180 | 181 |
| 182 |
| 181 double modulo(double x, double y) { | 183 double modulo(double x, double y) { |
| 182 // Note: here we rely on dependent reads being ordered. This is true | 184 // Note: here we rely on dependent reads being ordered. This is true |
| 183 // on all architectures we currently support. | 185 // on all architectures we currently support. |
| 184 return (*modulo_function)(x, y); | 186 return (*modulo_function)(x, y); |
| 185 } | 187 } |
| 186 #else // Win32 | 188 #else // Win32 |
| 187 | 189 |
| 188 double modulo(double x, double y) { | 190 double modulo(double x, double y) { |
| 189 // Workaround MS fmod bugs. ECMA-262 says: | 191 // Workaround MS fmod bugs. ECMA-262 says: |
| 190 // dividend is finite and divisor is an infinity => result equals dividend | 192 // dividend is finite and divisor is an infinity => result equals dividend |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 314 // allows access to both a FILETIME and an integer representation of | 316 // allows access to both a FILETIME and an integer representation of |
| 315 // the timestamp. | 317 // the timestamp. |
| 316 union TimeStamp { | 318 union TimeStamp { |
| 317 FILETIME ft_; | 319 FILETIME ft_; |
| 318 int64_t t_; | 320 int64_t t_; |
| 319 }; | 321 }; |
| 320 | 322 |
| 321 TimeStamp time_; | 323 TimeStamp time_; |
| 322 }; | 324 }; |
| 323 | 325 |
| 326 |
| 324 // Static variables. | 327 // Static variables. |
| 325 bool Time::tz_initialized_ = false; | 328 bool Time::tz_initialized_ = false; |
| 326 TIME_ZONE_INFORMATION Time::tzinfo_; | 329 TIME_ZONE_INFORMATION Time::tzinfo_; |
| 327 char Time::std_tz_name_[kTzNameSize]; | 330 char Time::std_tz_name_[kTzNameSize]; |
| 328 char Time::dst_tz_name_[kTzNameSize]; | 331 char Time::dst_tz_name_[kTzNameSize]; |
| 329 | 332 |
| 330 | 333 |
| 331 // Initialize timestamp to start of epoc. | 334 // Initialize timestamp to start of epoc. |
| 332 Time::Time() { | 335 Time::Time() { |
| 333 t() = 0; | 336 t() = 0; |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 573 // 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 |
| 574 // saving is in effect at the given time. | 577 // saving is in effect at the given time. |
| 575 return InDST() ? dst_tz_name_ : std_tz_name_; | 578 return InDST() ? dst_tz_name_ : std_tz_name_; |
| 576 } | 579 } |
| 577 | 580 |
| 578 | 581 |
| 579 void OS::PostSetUp() { | 582 void OS::PostSetUp() { |
| 580 // Math functions depend on CPU features therefore they are initialized after | 583 // Math functions depend on CPU features therefore they are initialized after |
| 581 // CPU. | 584 // CPU. |
| 582 MathSetup(); | 585 MathSetup(); |
| 583 #if defined(V8_TARGET_ARCH_IA32) | 586 #if V8_TARGET_ARCH_IA32 |
| 584 OS::MemMoveFunction generated_memmove = CreateMemMoveFunction(); | 587 OS::MemMoveFunction generated_memmove = CreateMemMoveFunction(); |
| 585 if (generated_memmove != NULL) { | 588 if (generated_memmove != NULL) { |
| 586 memmove_function = generated_memmove; | 589 memmove_function = generated_memmove; |
| 587 } | 590 } |
| 588 #endif | 591 #endif |
| 589 } | 592 } |
| 590 | 593 |
| 591 | 594 |
| 592 // Returns the accumulated user time for thread. | 595 // Returns the accumulated user time for thread. |
| 593 int OS::GetUserTime(uint32_t* secs, uint32_t* usecs) { | 596 int OS::GetUserTime(uint32_t* secs, uint32_t* usecs) { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 609 | 612 |
| 610 | 613 |
| 611 // Returns current time as the number of milliseconds since | 614 // Returns current time as the number of milliseconds since |
| 612 // 00:00:00 UTC, January 1, 1970. | 615 // 00:00:00 UTC, January 1, 1970. |
| 613 double OS::TimeCurrentMillis() { | 616 double OS::TimeCurrentMillis() { |
| 614 Time t; | 617 Time t; |
| 615 t.SetToCurrentTime(); | 618 t.SetToCurrentTime(); |
| 616 return t.ToJSTime(); | 619 return t.ToJSTime(); |
| 617 } | 620 } |
| 618 | 621 |
| 622 |
| 619 // Returns the tickcounter based on timeGetTime. | 623 // Returns the tickcounter based on timeGetTime. |
| 620 int64_t OS::Ticks() { | 624 int64_t OS::Ticks() { |
| 621 return timeGetTime() * 1000; // Convert to microseconds. | 625 return timeGetTime() * 1000; // Convert to microseconds. |
| 622 } | 626 } |
| 623 | 627 |
| 624 | 628 |
| 625 // Returns a string identifying the current timezone taking into | 629 // Returns a string identifying the current timezone taking into |
| 626 // account daylight saving. | 630 // account daylight saving. |
| 627 const char* OS::LocalTimezone(double time) { | 631 const char* OS::LocalTimezone(double time) { |
| 628 return Time(time).LocalTimezone(); | 632 return Time(time).LocalTimezone(); |
| (...skipping 813 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1442 } | 1446 } |
| 1443 } | 1447 } |
| 1444 | 1448 |
| 1445 frames_count++; | 1449 frames_count++; |
| 1446 } | 1450 } |
| 1447 | 1451 |
| 1448 // Return the number of frames filled in. | 1452 // Return the number of frames filled in. |
| 1449 return frames_count; | 1453 return frames_count; |
| 1450 } | 1454 } |
| 1451 | 1455 |
| 1456 |
| 1452 // Restore warnings to previous settings. | 1457 // Restore warnings to previous settings. |
| 1453 #pragma warning(pop) | 1458 #pragma warning(pop) |
| 1454 | 1459 |
| 1455 #else // __MINGW32__ | 1460 #else // __MINGW32__ |
| 1456 void OS::LogSharedLibraryAddresses() { } | 1461 void OS::LogSharedLibraryAddresses() { } |
| 1457 void OS::SignalCodeMovingGC() { } | 1462 void OS::SignalCodeMovingGC() { } |
| 1458 int OS::StackWalk(Vector<OS::StackFrame> frames) { return 0; } | 1463 int OS::StackWalk(Vector<OS::StackFrame> frames) { return 0; } |
| 1459 #endif // __MINGW32__ | 1464 #endif // __MINGW32__ |
| 1460 | 1465 |
| 1461 | 1466 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1472 return *reinterpret_cast<const double*>(&nanval); | 1477 return *reinterpret_cast<const double*>(&nanval); |
| 1473 #else // _MSC_VER | 1478 #else // _MSC_VER |
| 1474 return NAN; | 1479 return NAN; |
| 1475 #endif // _MSC_VER | 1480 #endif // _MSC_VER |
| 1476 } | 1481 } |
| 1477 | 1482 |
| 1478 | 1483 |
| 1479 int OS::ActivationFrameAlignment() { | 1484 int OS::ActivationFrameAlignment() { |
| 1480 #ifdef _WIN64 | 1485 #ifdef _WIN64 |
| 1481 return 16; // Windows 64-bit ABI requires the stack to be 16-byte aligned. | 1486 return 16; // Windows 64-bit ABI requires the stack to be 16-byte aligned. |
| 1487 #elif defined(__MINGW32__) |
| 1488 // With gcc 4.4 the tree vectorization optimizer can generate code |
| 1489 // that requires 16 byte alignment such as movdqa on x86. |
| 1490 return 16; |
| 1482 #else | 1491 #else |
| 1483 return 8; // Floating-point math runs faster with 8-byte alignment. | 1492 return 8; // Floating-point math runs faster with 8-byte alignment. |
| 1484 #endif | 1493 #endif |
| 1485 } | 1494 } |
| 1486 | 1495 |
| 1487 | 1496 |
| 1488 VirtualMemory::VirtualMemory() : address_(NULL), size_(0) { } | 1497 VirtualMemory::VirtualMemory() : address_(NULL), size_(0) { } |
| 1489 | 1498 |
| 1490 | 1499 |
| 1491 VirtualMemory::VirtualMemory(size_t size) | 1500 VirtualMemory::VirtualMemory(size_t size) |
| (...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1981 limit_mutex = CreateMutex(); | 1990 limit_mutex = CreateMutex(); |
| 1982 } | 1991 } |
| 1983 | 1992 |
| 1984 | 1993 |
| 1985 void OS::TearDown() { | 1994 void OS::TearDown() { |
| 1986 delete limit_mutex; | 1995 delete limit_mutex; |
| 1987 } | 1996 } |
| 1988 | 1997 |
| 1989 | 1998 |
| 1990 } } // namespace v8::internal | 1999 } } // namespace v8::internal |
| OLD | NEW |