| 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 30 matching lines...) Expand all Loading... |
| 41 #define V8_WIN32_HEADERS_FULL | 41 #define V8_WIN32_HEADERS_FULL |
| 42 #include "win32-headers.h" | 42 #include "win32-headers.h" |
| 43 | 43 |
| 44 #include "v8.h" | 44 #include "v8.h" |
| 45 | 45 |
| 46 #include "codegen.h" | 46 #include "codegen.h" |
| 47 #include "platform.h" | 47 #include "platform.h" |
| 48 #include "simulator.h" | 48 #include "simulator.h" |
| 49 #include "vm-state-inl.h" | 49 #include "vm-state-inl.h" |
| 50 | 50 |
| 51 #if V8_CC_MSVC | 51 #ifdef _MSC_VER |
| 52 | 52 |
| 53 // Case-insensitive bounded string comparisons. Use stricmp() on Win32. Usually | 53 // Case-insensitive bounded string comparisons. Use stricmp() on Win32. Usually |
| 54 // defined in strings.h. | 54 // defined in strings.h. |
| 55 int strncasecmp(const char* s1, const char* s2, int n) { | 55 int strncasecmp(const char* s1, const char* s2, int n) { |
| 56 return _strnicmp(s1, s2, n); | 56 return _strnicmp(s1, s2, n); |
| 57 } | 57 } |
| 58 | 58 |
| 59 #endif // V8_CC_MSVC | 59 #endif // _MSC_VER |
| 60 | 60 |
| 61 | 61 |
| 62 // Extra functions for MinGW. Most of these are the _s functions which are in | 62 // Extra functions for MinGW. Most of these are the _s functions which are in |
| 63 // the Microsoft Visual Studio C++ CRT. | 63 // the Microsoft Visual Studio C++ CRT. |
| 64 #ifdef __MINGW32__ | 64 #ifdef __MINGW32__ |
| 65 | 65 |
| 66 | 66 |
| 67 #ifndef __MINGW64_VERSION_MAJOR | 67 #ifndef __MINGW64_VERSION_MAJOR |
| 68 | 68 |
| 69 #define _TRUNCATE 0 | 69 #define _TRUNCATE 0 |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 // Copy memory area to disjoint memory area. | 162 // Copy memory area to disjoint memory area. |
| 163 void OS::MemMove(void* dest, const void* src, size_t size) { | 163 void OS::MemMove(void* dest, const void* src, size_t size) { |
| 164 if (size == 0) return; | 164 if (size == 0) return; |
| 165 // 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 |
| 166 // on all architectures we currently support. | 166 // on all architectures we currently support. |
| 167 (*memmove_function)(dest, src, size); | 167 (*memmove_function)(dest, src, size); |
| 168 } | 168 } |
| 169 | 169 |
| 170 #endif // V8_TARGET_ARCH_IA32 | 170 #endif // V8_TARGET_ARCH_IA32 |
| 171 | 171 |
| 172 #if V8_OS_WIN64 | 172 #ifdef _WIN64 |
| 173 typedef double (*ModuloFunction)(double, double); | 173 typedef double (*ModuloFunction)(double, double); |
| 174 static ModuloFunction modulo_function = NULL; | 174 static ModuloFunction modulo_function = NULL; |
| 175 // Defined in codegen-x64.cc. | 175 // Defined in codegen-x64.cc. |
| 176 ModuloFunction CreateModuloFunction(); | 176 ModuloFunction CreateModuloFunction(); |
| 177 | 177 |
| 178 void init_modulo_function() { | 178 void init_modulo_function() { |
| 179 modulo_function = CreateModuloFunction(); | 179 modulo_function = CreateModuloFunction(); |
| 180 } | 180 } |
| 181 | 181 |
| 182 | 182 |
| 183 double modulo(double x, double y) { | 183 double modulo(double x, double y) { |
| 184 // 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 |
| 185 // on all architectures we currently support. | 185 // on all architectures we currently support. |
| 186 return (*modulo_function)(x, y); | 186 return (*modulo_function)(x, y); |
| 187 } | 187 } |
| 188 #else | 188 #else // Win32 |
| 189 |
| 189 double modulo(double x, double y) { | 190 double modulo(double x, double y) { |
| 190 // Workaround MS fmod bugs. ECMA-262 says: | 191 // Workaround MS fmod bugs. ECMA-262 says: |
| 191 // dividend is finite and divisor is an infinity => result equals dividend | 192 // dividend is finite and divisor is an infinity => result equals dividend |
| 192 // dividend is a zero and divisor is nonzero finite => result equals dividend | 193 // dividend is a zero and divisor is nonzero finite => result equals dividend |
| 193 if (!(std::isfinite(x) && (!std::isfinite(y) && !std::isnan(y))) && | 194 if (!(std::isfinite(x) && (!std::isfinite(y) && !std::isnan(y))) && |
| 194 !(x == 0 && (y != 0 && std::isfinite(y)))) { | 195 !(x == 0 && (y != 0 && std::isfinite(y)))) { |
| 195 x = fmod(x, y); | 196 x = fmod(x, y); |
| 196 } | 197 } |
| 197 return x; | 198 return x; |
| 198 } | 199 } |
| 199 #endif // V8_OS_WIN64 | 200 |
| 201 #endif // _WIN64 |
| 200 | 202 |
| 201 | 203 |
| 202 #define UNARY_MATH_FUNCTION(name, generator) \ | 204 #define UNARY_MATH_FUNCTION(name, generator) \ |
| 203 static UnaryMathFunction fast_##name##_function = NULL; \ | 205 static UnaryMathFunction fast_##name##_function = NULL; \ |
| 204 void init_fast_##name##_function() { \ | 206 void init_fast_##name##_function() { \ |
| 205 fast_##name##_function = generator; \ | 207 fast_##name##_function = generator; \ |
| 206 } \ | 208 } \ |
| 207 double fast_##name(double x) { \ | 209 double fast_##name(double x) { \ |
| 208 return (*fast_##name##_function)(x); \ | 210 return (*fast_##name##_function)(x); \ |
| 209 } | 211 } |
| 210 | 212 |
| 211 UNARY_MATH_FUNCTION(sin, CreateTranscendentalFunction(TranscendentalCache::SIN)) | 213 UNARY_MATH_FUNCTION(sin, CreateTranscendentalFunction(TranscendentalCache::SIN)) |
| 212 UNARY_MATH_FUNCTION(cos, CreateTranscendentalFunction(TranscendentalCache::COS)) | 214 UNARY_MATH_FUNCTION(cos, CreateTranscendentalFunction(TranscendentalCache::COS)) |
| 213 UNARY_MATH_FUNCTION(tan, CreateTranscendentalFunction(TranscendentalCache::TAN)) | 215 UNARY_MATH_FUNCTION(tan, CreateTranscendentalFunction(TranscendentalCache::TAN)) |
| 214 UNARY_MATH_FUNCTION(log, CreateTranscendentalFunction(TranscendentalCache::LOG)) | 216 UNARY_MATH_FUNCTION(log, CreateTranscendentalFunction(TranscendentalCache::LOG)) |
| 215 UNARY_MATH_FUNCTION(exp, CreateExpFunction()) | 217 UNARY_MATH_FUNCTION(exp, CreateExpFunction()) |
| 216 UNARY_MATH_FUNCTION(sqrt, CreateSqrtFunction()) | 218 UNARY_MATH_FUNCTION(sqrt, CreateSqrtFunction()) |
| 217 | 219 |
| 218 #undef UNARY_MATH_FUNCTION | 220 #undef UNARY_MATH_FUNCTION |
| 219 | 221 |
| 220 | 222 |
| 221 void lazily_initialize_fast_exp() { | 223 void lazily_initialize_fast_exp() { |
| 222 if (fast_exp_function == NULL) { | 224 if (fast_exp_function == NULL) { |
| 223 init_fast_exp_function(); | 225 init_fast_exp_function(); |
| 224 } | 226 } |
| 225 } | 227 } |
| 226 | 228 |
| 227 | 229 |
| 228 void MathSetup() { | 230 void MathSetup() { |
| 229 #if V8_OS_WIN64 | 231 #ifdef _WIN64 |
| 230 init_modulo_function(); | 232 init_modulo_function(); |
| 231 #endif | 233 #endif |
| 232 init_fast_sin_function(); | 234 init_fast_sin_function(); |
| 233 init_fast_cos_function(); | 235 init_fast_cos_function(); |
| 234 init_fast_tan_function(); | 236 init_fast_tan_function(); |
| 235 init_fast_log_function(); | 237 init_fast_log_function(); |
| 236 // fast_exp is initialized lazily. | 238 // fast_exp is initialized lazily. |
| 237 init_fast_sqrt_function(); | 239 init_fast_sqrt_function(); |
| 238 } | 240 } |
| 239 | 241 |
| (...skipping 760 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1000 if (IsDebuggerPresent() || FLAG_break_on_abort) { | 1002 if (IsDebuggerPresent() || FLAG_break_on_abort) { |
| 1001 DebugBreak(); | 1003 DebugBreak(); |
| 1002 } else { | 1004 } else { |
| 1003 // Make the MSVCRT do a silent abort. | 1005 // Make the MSVCRT do a silent abort. |
| 1004 raise(SIGABRT); | 1006 raise(SIGABRT); |
| 1005 } | 1007 } |
| 1006 } | 1008 } |
| 1007 | 1009 |
| 1008 | 1010 |
| 1009 void OS::DebugBreak() { | 1011 void OS::DebugBreak() { |
| 1010 #if V8_CC_MSVC | 1012 #ifdef _MSC_VER |
| 1011 __debugbreak(); | 1013 __debugbreak(); |
| 1012 #else | 1014 #else |
| 1013 ::DebugBreak(); | 1015 ::DebugBreak(); |
| 1014 #endif // V8_CC_MSVC | 1016 #endif |
| 1015 } | 1017 } |
| 1016 | 1018 |
| 1017 | 1019 |
| 1018 void OS::DumpBacktrace() { | 1020 void OS::DumpBacktrace() { |
| 1019 // Currently unsupported. | 1021 // Currently unsupported. |
| 1020 } | 1022 } |
| 1021 | 1023 |
| 1022 | 1024 |
| 1023 class Win32MemoryMappedFile : public OS::MemoryMappedFile { | 1025 class Win32MemoryMappedFile : public OS::MemoryMappedFile { |
| 1024 public: | 1026 public: |
| (...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1352 // Read the symbols. | 1354 // Read the symbols. |
| 1353 if (!LoadSymbols(process_handle)) return kStackWalkError; | 1355 if (!LoadSymbols(process_handle)) return kStackWalkError; |
| 1354 | 1356 |
| 1355 // Capture current context. | 1357 // Capture current context. |
| 1356 CONTEXT context; | 1358 CONTEXT context; |
| 1357 RtlCaptureContext(&context); | 1359 RtlCaptureContext(&context); |
| 1358 | 1360 |
| 1359 // Initialize the stack walking | 1361 // Initialize the stack walking |
| 1360 STACKFRAME64 stack_frame; | 1362 STACKFRAME64 stack_frame; |
| 1361 memset(&stack_frame, 0, sizeof(stack_frame)); | 1363 memset(&stack_frame, 0, sizeof(stack_frame)); |
| 1362 #if V8_OS_WIN64 | 1364 #ifdef _WIN64 |
| 1363 stack_frame.AddrPC.Offset = context.Rip; | 1365 stack_frame.AddrPC.Offset = context.Rip; |
| 1364 stack_frame.AddrFrame.Offset = context.Rbp; | 1366 stack_frame.AddrFrame.Offset = context.Rbp; |
| 1365 stack_frame.AddrStack.Offset = context.Rsp; | 1367 stack_frame.AddrStack.Offset = context.Rsp; |
| 1366 #else | 1368 #else |
| 1367 stack_frame.AddrPC.Offset = context.Eip; | 1369 stack_frame.AddrPC.Offset = context.Eip; |
| 1368 stack_frame.AddrFrame.Offset = context.Ebp; | 1370 stack_frame.AddrFrame.Offset = context.Ebp; |
| 1369 stack_frame.AddrStack.Offset = context.Esp; | 1371 stack_frame.AddrStack.Offset = context.Esp; |
| 1370 #endif | 1372 #endif |
| 1371 stack_frame.AddrPC.Mode = AddrModeFlat; | 1373 stack_frame.AddrPC.Mode = AddrModeFlat; |
| 1372 stack_frame.AddrFrame.Mode = AddrModeFlat; | 1374 stack_frame.AddrFrame.Mode = AddrModeFlat; |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1461 int OS::StackWalk(Vector<OS::StackFrame> frames) { return 0; } | 1463 int OS::StackWalk(Vector<OS::StackFrame> frames) { return 0; } |
| 1462 #endif // __MINGW32__ | 1464 #endif // __MINGW32__ |
| 1463 | 1465 |
| 1464 | 1466 |
| 1465 uint64_t OS::CpuFeaturesImpliedByPlatform() { | 1467 uint64_t OS::CpuFeaturesImpliedByPlatform() { |
| 1466 return 0; // Windows runs on anything. | 1468 return 0; // Windows runs on anything. |
| 1467 } | 1469 } |
| 1468 | 1470 |
| 1469 | 1471 |
| 1470 double OS::nan_value() { | 1472 double OS::nan_value() { |
| 1471 #if V8_CC_MSVC | 1473 #ifdef _MSC_VER |
| 1472 // Positive Quiet NaN with no payload (aka. Indeterminate) has all bits | 1474 // Positive Quiet NaN with no payload (aka. Indeterminate) has all bits |
| 1473 // in mask set, so value equals mask. | 1475 // in mask set, so value equals mask. |
| 1474 static const __int64 nanval = kQuietNaNMask; | 1476 static const __int64 nanval = kQuietNaNMask; |
| 1475 return *reinterpret_cast<const double*>(&nanval); | 1477 return *reinterpret_cast<const double*>(&nanval); |
| 1476 #else // V8_CC_MSVC | 1478 #else // _MSC_VER |
| 1477 return NAN; | 1479 return NAN; |
| 1478 #endif // V8_CC_MSVC | 1480 #endif // _MSC_VER |
| 1479 } | 1481 } |
| 1480 | 1482 |
| 1481 | 1483 |
| 1482 int OS::ActivationFrameAlignment() { | 1484 int OS::ActivationFrameAlignment() { |
| 1483 #if V8_OS__WIN64 | 1485 #ifdef _WIN64 |
| 1484 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. |
| 1485 #elif V8_CC_MINGW | 1487 #elif defined(__MINGW32__) |
| 1486 // With gcc 4.4 the tree vectorization optimizer can generate code | 1488 // With gcc 4.4 the tree vectorization optimizer can generate code |
| 1487 // that requires 16 byte alignment such as movdqa on x86. | 1489 // that requires 16 byte alignment such as movdqa on x86. |
| 1488 return 16; | 1490 return 16; |
| 1489 #else | 1491 #else |
| 1490 return 8; // Floating-point math runs faster with 8-byte alignment. | 1492 return 8; // Floating-point math runs faster with 8-byte alignment. |
| 1491 #endif | 1493 #endif |
| 1492 } | 1494 } |
| 1493 | 1495 |
| 1494 | 1496 |
| 1495 VirtualMemory::VirtualMemory() : address_(NULL), size_(0) { } | 1497 VirtualMemory::VirtualMemory() : address_(NULL), size_(0) { } |
| (...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1988 limit_mutex = CreateMutex(); | 1990 limit_mutex = CreateMutex(); |
| 1989 } | 1991 } |
| 1990 | 1992 |
| 1991 | 1993 |
| 1992 void OS::TearDown() { | 1994 void OS::TearDown() { |
| 1993 delete limit_mutex; | 1995 delete limit_mutex; |
| 1994 } | 1996 } |
| 1995 | 1997 |
| 1996 | 1998 |
| 1997 } } // namespace v8::internal | 1999 } } // namespace v8::internal |
| OLD | NEW |