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 847 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
858 | 858 |
859 // VirtualAlloc rounds allocated size to page size automatically. | 859 // VirtualAlloc rounds allocated size to page size automatically. |
860 size_t msize = RoundUp(requested, static_cast<int>(GetPageSize())); | 860 size_t msize = RoundUp(requested, static_cast<int>(GetPageSize())); |
861 intptr_t address = NULL; | 861 intptr_t address = NULL; |
862 | 862 |
863 // Windows XP SP2 allows Data Excution Prevention (DEP). | 863 // Windows XP SP2 allows Data Excution Prevention (DEP). |
864 int prot = is_executable ? PAGE_EXECUTE_READWRITE : PAGE_READWRITE; | 864 int prot = is_executable ? PAGE_EXECUTE_READWRITE : PAGE_READWRITE; |
865 | 865 |
866 // For exectutable pages try and randomize the allocation address | 866 // For exectutable pages try and randomize the allocation address |
867 if (prot == PAGE_EXECUTE_READWRITE && msize >= Page::kPageSize) { | 867 if (prot == PAGE_EXECUTE_READWRITE && msize >= Page::kPageSize) { |
868 address = (V8::Random() << kPageSizeBits) | kAllocationRandomAddressMin; | 868 address = (V8::RandomPrivate() << kPageSizeBits) |
869 address &= kAllocationRandomAddressMax; | 869 | kAllocationRandomAddressMin; |
| 870 address &= kAllocationRandomAddressMax; |
870 } | 871 } |
871 | 872 |
872 LPVOID mbase = VirtualAlloc(reinterpret_cast<void *>(address), | 873 LPVOID mbase = VirtualAlloc(reinterpret_cast<void *>(address), |
873 msize, | 874 msize, |
874 MEM_COMMIT | MEM_RESERVE, | 875 MEM_COMMIT | MEM_RESERVE, |
875 prot); | 876 prot); |
876 if (mbase == NULL && address != NULL) | 877 if (mbase == NULL && address != NULL) |
877 mbase = VirtualAlloc(NULL, msize, MEM_COMMIT | MEM_RESERVE, prot); | 878 mbase = VirtualAlloc(NULL, msize, MEM_COMMIT | MEM_RESERVE, prot); |
878 | 879 |
879 if (mbase == NULL) { | 880 if (mbase == NULL) { |
(...skipping 1072 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1952 | 1953 |
1953 // Release the thread handles | 1954 // Release the thread handles |
1954 CloseHandle(data_->sampler_thread_); | 1955 CloseHandle(data_->sampler_thread_); |
1955 CloseHandle(data_->profiled_thread_); | 1956 CloseHandle(data_->profiled_thread_); |
1956 } | 1957 } |
1957 | 1958 |
1958 | 1959 |
1959 #endif // ENABLE_LOGGING_AND_PROFILING | 1960 #endif // ENABLE_LOGGING_AND_PROFILING |
1960 | 1961 |
1961 } } // namespace v8::internal | 1962 } } // namespace v8::internal |
OLD | NEW |