Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(399)

Side by Side Diff: src/platform-win32.cc

Issue 3849004: Make randomized allocations along 64k granularity boundaries to avoid comitti... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 10 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 827 matching lines...) Expand 10 before | Expand all | Expand 10 after
838 } 838 }
839 return allocate_alignment; 839 return allocate_alignment;
840 } 840 }
841 841
842 842
843 void* OS::Allocate(const size_t requested, 843 void* OS::Allocate(const size_t requested,
844 size_t* allocated, 844 size_t* allocated,
845 bool is_executable) { 845 bool is_executable) {
846 // The address range used to randomize RWX allocations in OS::Allocate 846 // The address range used to randomize RWX allocations in OS::Allocate
847 // Try not to map pages into the default range that windows loads DLLs 847 // Try not to map pages into the default range that windows loads DLLs
848 // Use a multiple of 64k to prevent committing unused memory.
848 // Note: This does not guarantee RWX regions will be within the 849 // Note: This does not guarantee RWX regions will be within the
849 // range kAllocationRandomAddressMin to kAllocationRandomAddressMax 850 // range kAllocationRandomAddressMin to kAllocationRandomAddressMax
850 #ifdef V8_HOST_ARCH_64_BIT 851 #ifdef V8_HOST_ARCH_64_BIT
851 static const intptr_t kAllocationRandomAddressMin = 0x0000000080000000; 852 static const intptr_t kAllocationRandomAddressMin = 0x0000000080000000;
852 static const intptr_t kAllocationRandomAddressMax = 0x000004FFFFFFFFFF; 853 static const intptr_t kAllocationRandomAddressMax = 0x000003FFFFFF0000;
853 #else 854 #else
854 static const intptr_t kAllocationRandomAddressMin = 0x04000000; 855 static const intptr_t kAllocationRandomAddressMin = 0x04000000;
855 static const intptr_t kAllocationRandomAddressMax = 0x4FFFFFFF; 856 static const intptr_t kAllocationRandomAddressMax = 0x3FFF0000;
856 #endif 857 #endif
857 858
858 // VirtualAlloc rounds allocated size to page size automatically. 859 // VirtualAlloc rounds allocated size to page size automatically.
859 size_t msize = RoundUp(requested, static_cast<int>(GetPageSize())); 860 size_t msize = RoundUp(requested, static_cast<int>(GetPageSize()));
860 intptr_t address = NULL; 861 intptr_t address = NULL;
861 862
862 // Windows XP SP2 allows Data Excution Prevention (DEP). 863 // Windows XP SP2 allows Data Excution Prevention (DEP).
863 int prot = is_executable ? PAGE_EXECUTE_READWRITE : PAGE_READWRITE; 864 int prot = is_executable ? PAGE_EXECUTE_READWRITE : PAGE_READWRITE;
864 865
865 // For exectutable pages try and randomize the allocation address 866 // For exectutable pages try and randomize the allocation address
(...skipping 1081 matching lines...) Expand 10 before | Expand all | Expand 10 after
1947 1948
1948 // Release the thread handles 1949 // Release the thread handles
1949 CloseHandle(data_->sampler_thread_); 1950 CloseHandle(data_->sampler_thread_);
1950 CloseHandle(data_->profiled_thread_); 1951 CloseHandle(data_->profiled_thread_);
1951 } 1952 }
1952 1953
1953 1954
1954 #endif // ENABLE_LOGGING_AND_PROFILING 1955 #endif // ENABLE_LOGGING_AND_PROFILING
1955 1956
1956 } } // namespace v8::internal 1957 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698