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