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

Side by Side Diff: third_party/WebKit/Source/wtf/PageAllocator.cpp

Issue 1820413003: Update allocPageErrorCode only when mmap fails. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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
« 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 /* 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
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
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
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