| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 // the hint. If false, the hint is mandatory and a successful allocation will | 72 // the hint. If false, the hint is mandatory and a successful allocation will |
| 73 // not differ from the hint. | 73 // not differ from the hint. |
| 74 static void* systemAllocPages(void* hint, size_t len, PageAccessibilityConfigura
tion pageAccessibility) | 74 static void* systemAllocPages(void* hint, size_t len, PageAccessibilityConfigura
tion pageAccessibility) |
| 75 { | 75 { |
| 76 ASSERT(!(len & kPageAllocationGranularityOffsetMask)); | 76 ASSERT(!(len & kPageAllocationGranularityOffsetMask)); |
| 77 ASSERT(!(reinterpret_cast<uintptr_t>(hint) & kPageAllocationGranularityOffse
tMask)); | 77 ASSERT(!(reinterpret_cast<uintptr_t>(hint) & kPageAllocationGranularityOffse
tMask)); |
| 78 void* ret; | 78 void* ret; |
| 79 #if OS(WIN) | 79 #if OS(WIN) |
| 80 DWORD accessFlag = pageAccessibility == PageAccessible ? PAGE_READWRITE : PA
GE_NOACCESS; | 80 DWORD accessFlag = pageAccessibility == PageAccessible ? PAGE_READWRITE : PA
GE_NOACCESS; |
| 81 ret = VirtualAlloc(hint, len, MEM_RESERVE | MEM_COMMIT, accessFlag); | 81 ret = VirtualAlloc(hint, len, MEM_RESERVE | MEM_COMMIT, accessFlag); |
| 82 allocPageErrorCode = !ret ? GetLastError() : ERROR_SUCCESS; | 82 if (!ret) |
| 83 allocPageErrorCode = GetLastError(); |
| 83 #else | 84 #else |
| 84 int accessFlag = pageAccessibility == PageAccessible ? (PROT_READ | PROT_WRI
TE) : PROT_NONE; | 85 int accessFlag = pageAccessibility == PageAccessible ? (PROT_READ | PROT_WRI
TE) : PROT_NONE; |
| 85 ret = mmap(hint, len, accessFlag, MAP_ANONYMOUS | MAP_PRIVATE, -1, 0); | 86 ret = mmap(hint, len, accessFlag, MAP_ANONYMOUS | MAP_PRIVATE, -1, 0); |
| 86 if (ret == MAP_FAILED) { | 87 if (ret == MAP_FAILED) { |
| 87 allocPageErrorCode = errno; | 88 allocPageErrorCode = errno; |
| 88 ret = 0; | 89 ret = 0; |
| 89 } else { | |
| 90 allocPageErrorCode = 0; | |
| 91 } | 90 } |
| 92 #endif | 91 #endif |
| 93 return ret; | 92 return ret; |
| 94 } | 93 } |
| 95 | 94 |
| 96 // Trims base to given length and alignment. Windows returns null on failure and
frees base. | 95 // Trims base to given length and alignment. Windows returns null on failure and
frees base. |
| 97 static void* trimMapping(void *base, size_t baseLen, size_t trimLen, uintptr_t a
lign, PageAccessibilityConfiguration pageAccessibility) | 96 static void* trimMapping(void *base, size_t baseLen, size_t trimLen, uintptr_t a
lign, PageAccessibilityConfiguration pageAccessibility) |
| 98 { | 97 { |
| 99 size_t preSlack = reinterpret_cast<uintptr_t>(base) & (align - 1); | 98 size_t preSlack = reinterpret_cast<uintptr_t>(base) & (align - 1); |
| 100 if (preSlack) | 99 if (preSlack) |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 #endif | 268 #endif |
| 270 } | 269 } |
| 271 | 270 |
| 272 uint32_t getAllocPageErrorCode() | 271 uint32_t getAllocPageErrorCode() |
| 273 { | 272 { |
| 274 return allocPageErrorCode; | 273 return allocPageErrorCode; |
| 275 } | 274 } |
| 276 | 275 |
| 277 } // namespace WTF | 276 } // namespace WTF |
| 278 | 277 |
| OLD | NEW |