| 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 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 } | 145 } |
| 146 | 146 |
| 147 | 147 |
| 148 static Mutex* limit_mutex = NULL; | 148 static Mutex* limit_mutex = NULL; |
| 149 | 149 |
| 150 #if 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 275 matching lines...) Expand 10 before | Expand all | Expand 10 after 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 519 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1981 limit_mutex = CreateMutex(); | 1986 limit_mutex = CreateMutex(); |
| 1982 } | 1987 } |
| 1983 | 1988 |
| 1984 | 1989 |
| 1985 void OS::TearDown() { | 1990 void OS::TearDown() { |
| 1986 delete limit_mutex; | 1991 delete limit_mutex; |
| 1987 } | 1992 } |
| 1988 | 1993 |
| 1989 | 1994 |
| 1990 } } // namespace v8::internal | 1995 } } // namespace v8::internal |
| OLD | NEW |