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 907 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
918 return NULL; | 918 return NULL; |
919 } | 919 } |
920 | 920 |
921 | 921 |
922 static void* RandomizedVirtualAlloc(size_t size, int action, int protection) { | 922 static void* RandomizedVirtualAlloc(size_t size, int action, int protection) { |
923 LPVOID base = NULL; | 923 LPVOID base = NULL; |
924 | 924 |
925 if (protection == PAGE_EXECUTE_READWRITE || protection == PAGE_NOACCESS) { | 925 if (protection == PAGE_EXECUTE_READWRITE || protection == PAGE_NOACCESS) { |
926 // For exectutable pages try and randomize the allocation address | 926 // For exectutable pages try and randomize the allocation address |
927 for (size_t attempts = 0; base == NULL && attempts < 3; ++attempts) { | 927 for (size_t attempts = 0; base == NULL && attempts < 3; ++attempts) { |
928 base = VirtualAlloc(GetRandomAddr(), size, action, protection); | 928 base = VirtualAlloc(OS::GetRandomAddr(), size, action, protection); |
929 } | 929 } |
930 } | 930 } |
931 | 931 |
932 // After three attempts give up and let the OS find an address to use. | 932 // After three attempts give up and let the OS find an address to use. |
933 if (base == NULL) base = VirtualAlloc(NULL, size, action, protection); | 933 if (base == NULL) base = VirtualAlloc(NULL, size, action, protection); |
934 | 934 |
935 return base; | 935 return base; |
936 } | 936 } |
937 | 937 |
938 | 938 |
(...skipping 1051 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1990 limit_mutex = CreateMutex(); | 1990 limit_mutex = CreateMutex(); |
1991 } | 1991 } |
1992 | 1992 |
1993 | 1993 |
1994 void OS::TearDown() { | 1994 void OS::TearDown() { |
1995 delete limit_mutex; | 1995 delete limit_mutex; |
1996 } | 1996 } |
1997 | 1997 |
1998 | 1998 |
1999 } } // namespace v8::internal | 1999 } } // namespace v8::internal |
OLD | NEW |