Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 199 return _vsnprintf(buffer, sizeOfBuffer, format, argptr); | 199 return _vsnprintf(buffer, sizeOfBuffer, format, argptr); |
| 200 } | 200 } |
| 201 #define _TRUNCATE 0 | 201 #define _TRUNCATE 0 |
| 202 | 202 |
| 203 | 203 |
| 204 int strncpy_s(char* strDest, size_t numberOfElements, | 204 int strncpy_s(char* strDest, size_t numberOfElements, |
| 205 const char* strSource, size_t count) { | 205 const char* strSource, size_t count) { |
| 206 strncpy(strDest, strSource, count); | 206 strncpy(strDest, strSource, count); |
| 207 return 0; | 207 return 0; |
| 208 } | 208 } |
| 209 | 209 |
|
Erik Corry
2010/12/01 22:10:18
Extra blank line needed here (2 blank lines betwee
| |
| 210 inline void MemoryBarrier() { | |
| 211 long barrier = 0; | |
| 212 __asm__ __volatile__("xchgl %%eax,%0 ":"=r" (barrier)); | |
| 213 } | |
| 214 | |
| 210 #endif // __MINGW32__ | 215 #endif // __MINGW32__ |
| 211 | 216 |
| 212 // Generate a pseudo-random number in the range 0-2^31-1. Usually | 217 // Generate a pseudo-random number in the range 0-2^31-1. Usually |
| 213 // defined in stdlib.h. Missing in both Microsoft Visual Studio C++ and MinGW. | 218 // defined in stdlib.h. Missing in both Microsoft Visual Studio C++ and MinGW. |
| 214 int random() { | 219 int random() { |
| 215 return rand(); | 220 return rand(); |
| 216 } | 221 } |
| 217 | 222 |
| 218 | 223 |
| 219 namespace v8 { | 224 namespace v8 { |
| (...skipping 631 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 851 #ifdef V8_HOST_ARCH_64_BIT | 856 #ifdef V8_HOST_ARCH_64_BIT |
| 852 static const intptr_t kAllocationRandomAddressMin = 0x0000000080000000; | 857 static const intptr_t kAllocationRandomAddressMin = 0x0000000080000000; |
| 853 static const intptr_t kAllocationRandomAddressMax = 0x000003FFFFFF0000; | 858 static const intptr_t kAllocationRandomAddressMax = 0x000003FFFFFF0000; |
| 854 #else | 859 #else |
| 855 static const intptr_t kAllocationRandomAddressMin = 0x04000000; | 860 static const intptr_t kAllocationRandomAddressMin = 0x04000000; |
| 856 static const intptr_t kAllocationRandomAddressMax = 0x3FFF0000; | 861 static const intptr_t kAllocationRandomAddressMax = 0x3FFF0000; |
| 857 #endif | 862 #endif |
| 858 | 863 |
| 859 // VirtualAlloc rounds allocated size to page size automatically. | 864 // VirtualAlloc rounds allocated size to page size automatically. |
| 860 size_t msize = RoundUp(requested, static_cast<int>(GetPageSize())); | 865 size_t msize = RoundUp(requested, static_cast<int>(GetPageSize())); |
| 861 intptr_t address = NULL; | 866 intptr_t address = (intptr_t)NULL; |
|
Erik Corry
2010/12/01 22:10:18
We don't allow C-style casts in V8. See the Googl
| |
| 862 | 867 |
| 863 // Windows XP SP2 allows Data Excution Prevention (DEP). | 868 // Windows XP SP2 allows Data Excution Prevention (DEP). |
| 864 int prot = is_executable ? PAGE_EXECUTE_READWRITE : PAGE_READWRITE; | 869 int prot = is_executable ? PAGE_EXECUTE_READWRITE : PAGE_READWRITE; |
| 865 | 870 |
| 866 // For exectutable pages try and randomize the allocation address | 871 // For exectutable pages try and randomize the allocation address |
| 867 if (prot == PAGE_EXECUTE_READWRITE && msize >= Page::kPageSize) { | 872 if (prot == PAGE_EXECUTE_READWRITE && msize >= (size_t)Page::kPageSize) { |
|
Erik Corry
2010/12/01 22:10:18
C-style cast
| |
| 868 address = (V8::RandomPrivate() << kPageSizeBits) | 873 address = (V8::RandomPrivate() << kPageSizeBits) |
| 869 | kAllocationRandomAddressMin; | 874 | kAllocationRandomAddressMin; |
| 870 address &= kAllocationRandomAddressMax; | 875 address &= kAllocationRandomAddressMax; |
| 871 } | 876 } |
| 872 | 877 |
| 873 LPVOID mbase = VirtualAlloc(reinterpret_cast<void *>(address), | 878 LPVOID mbase = VirtualAlloc(reinterpret_cast<void *>(address), |
| 874 msize, | 879 msize, |
| 875 MEM_COMMIT | MEM_RESERVE, | 880 MEM_COMMIT | MEM_RESERVE, |
| 876 prot); | 881 prot); |
| 877 if (mbase == NULL && address != NULL) | 882 if (mbase == NULL && address != (intptr_t)NULL) |
|
Erik Corry
2010/12/01 22:10:18
C-style cast
| |
| 878 mbase = VirtualAlloc(NULL, msize, MEM_COMMIT | MEM_RESERVE, prot); | 883 mbase = VirtualAlloc(NULL, msize, MEM_COMMIT | MEM_RESERVE, prot); |
| 879 | 884 |
| 880 if (mbase == NULL) { | 885 if (mbase == NULL) { |
| 881 LOG(StringEvent("OS::Allocate", "VirtualAlloc failed")); | 886 LOG(StringEvent("OS::Allocate", "VirtualAlloc failed")); |
| 882 return NULL; | 887 return NULL; |
| 883 } | 888 } |
| 884 | 889 |
| 885 ASSERT(IsAligned(reinterpret_cast<size_t>(mbase), OS::AllocateAlignment())); | 890 ASSERT(IsAligned(reinterpret_cast<size_t>(mbase), OS::AllocateAlignment())); |
| 886 | 891 |
| 887 *allocated = msize; | 892 *allocated = msize; |
| (...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1340 | 1345 |
| 1341 // Return the number of frames filled in. | 1346 // Return the number of frames filled in. |
| 1342 return frames_count; | 1347 return frames_count; |
| 1343 } | 1348 } |
| 1344 | 1349 |
| 1345 // Restore warnings to previous settings. | 1350 // Restore warnings to previous settings. |
| 1346 #pragma warning(pop) | 1351 #pragma warning(pop) |
| 1347 | 1352 |
| 1348 #else // __MINGW32__ | 1353 #else // __MINGW32__ |
| 1349 void OS::LogSharedLibraryAddresses() { } | 1354 void OS::LogSharedLibraryAddresses() { } |
| 1355 void OS::SignalCodeMovingGC() { } | |
| 1350 int OS::StackWalk(Vector<OS::StackFrame> frames) { return 0; } | 1356 int OS::StackWalk(Vector<OS::StackFrame> frames) { return 0; } |
| 1351 #endif // __MINGW32__ | 1357 #endif // __MINGW32__ |
| 1352 | 1358 |
| 1353 | 1359 |
| 1354 uint64_t OS::CpuFeaturesImpliedByPlatform() { | 1360 uint64_t OS::CpuFeaturesImpliedByPlatform() { |
| 1355 return 0; // Windows runs on anything. | 1361 return 0; // Windows runs on anything. |
| 1356 } | 1362 } |
| 1357 | 1363 |
| 1358 | 1364 |
| 1359 double OS::nan_value() { | 1365 double OS::nan_value() { |
| (...skipping 594 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1954 | 1960 |
| 1955 // Release the thread handles | 1961 // Release the thread handles |
| 1956 CloseHandle(data_->sampler_thread_); | 1962 CloseHandle(data_->sampler_thread_); |
| 1957 CloseHandle(data_->profiled_thread_); | 1963 CloseHandle(data_->profiled_thread_); |
| 1958 } | 1964 } |
| 1959 | 1965 |
| 1960 | 1966 |
| 1961 #endif // ENABLE_LOGGING_AND_PROFILING | 1967 #endif // ENABLE_LOGGING_AND_PROFILING |
| 1962 | 1968 |
| 1963 } } // namespace v8::internal | 1969 } } // namespace v8::internal |
| OLD | NEW |