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

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

Issue 54883002: Fix more warnings. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years, 1 month 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
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 13 matching lines...) Expand all
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #include "config.h" 31 #include "config.h"
32 #include "wtf/PageAllocator.h" 32 #include "wtf/PageAllocator.h"
33 33
34 #include "wtf/Assertions.h"
34 #include "wtf/ProcessID.h" 35 #include "wtf/ProcessID.h"
35 #include "wtf/SpinLock.h" 36 #include "wtf/SpinLock.h"
36 37
37 #if OS(POSIX) 38 #if OS(POSIX)
38 39
39 #include <sys/mman.h> 40 #include <sys/mman.h>
40 41
41 #ifndef MADV_FREE 42 #ifndef MADV_FREE
42 #define MADV_FREE MADV_DONTNEED 43 #define MADV_FREE MADV_DONTNEED
43 #endif 44 #endif
(...skipping 18 matching lines...) Expand all
62 ASSERT(!(reinterpret_cast<uintptr_t>(addr) & kSuperPageOffsetMask)); 63 ASSERT(!(reinterpret_cast<uintptr_t>(addr) & kSuperPageOffsetMask));
63 #if OS(POSIX) 64 #if OS(POSIX)
64 char* ptr = reinterpret_cast<char*>(mmap(addr, len, PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_PRIVATE, -1, 0)); 65 char* ptr = reinterpret_cast<char*>(mmap(addr, len, PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_PRIVATE, -1, 0));
65 RELEASE_ASSERT(ptr != MAP_FAILED); 66 RELEASE_ASSERT(ptr != MAP_FAILED);
66 // If our requested address collided with another mapping, there's a 67 // If our requested address collided with another mapping, there's a
67 // chance we'll get back an unaligned address. We fix this by attempting 68 // chance we'll get back an unaligned address. We fix this by attempting
68 // the allocation again, but with enough slack pages that we can find 69 // the allocation again, but with enough slack pages that we can find
69 // correct alignment within the allocation. 70 // correct alignment within the allocation.
70 if (UNLIKELY(reinterpret_cast<uintptr_t>(ptr) & kSuperPageOffsetMask)) { 71 if (UNLIKELY(reinterpret_cast<uintptr_t>(ptr) & kSuperPageOffsetMask)) {
71 int ret = munmap(ptr, len); 72 int ret = munmap(ptr, len);
72 ASSERT(!ret); 73 ASSERT_UNUSED(ret, !ret);
73 ptr = reinterpret_cast<char*>(mmap(0, len + kSuperPageSize - kSystemPage Size, PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_PRIVATE, -1, 0)); 74 ptr = reinterpret_cast<char*>(mmap(0, len + kSuperPageSize - kSystemPage Size, PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_PRIVATE, -1, 0));
74 RELEASE_ASSERT(ptr != MAP_FAILED); 75 RELEASE_ASSERT(ptr != MAP_FAILED);
75 int numSystemPagesToUnmap = kNumSystemPagesPerSuperPage - 1; 76 int numSystemPagesToUnmap = kNumSystemPagesPerSuperPage - 1;
76 int numSystemPagesBefore = (kNumSystemPagesPerSuperPage - ((reinterpret_ cast<uintptr_t>(ptr) & kSuperPageOffsetMask) / kSystemPageSize)) % kNumSystemPag esPerSuperPage; 77 int numSystemPagesBefore = (kNumSystemPagesPerSuperPage - ((reinterpret_ cast<uintptr_t>(ptr) & kSuperPageOffsetMask) / kSystemPageSize)) % kNumSystemPag esPerSuperPage;
77 ASSERT(numSystemPagesBefore <= numSystemPagesToUnmap); 78 ASSERT(numSystemPagesBefore <= numSystemPagesToUnmap);
78 int numSystemPagesAfter = numSystemPagesToUnmap - numSystemPagesBefore; 79 int numSystemPagesAfter = numSystemPagesToUnmap - numSystemPagesBefore;
79 if (numSystemPagesBefore) { 80 if (numSystemPagesBefore) {
80 size_t beforeSize = kSystemPageSize * numSystemPagesBefore; 81 size_t beforeSize = kSystemPageSize * numSystemPagesBefore;
81 ret = munmap(ptr, beforeSize); 82 ret = munmap(ptr, beforeSize);
82 ASSERT(!ret); 83 ASSERT(!ret);
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 ASSERT(byteIndex < sizeof(s_bitmap)); 242 ASSERT(byteIndex < sizeof(s_bitmap));
242 // The read/modify/write is not guaranteed atomic, so take a lock. 243 // The read/modify/write is not guaranteed atomic, so take a lock.
243 spinLockLock(&bitmapLock); 244 spinLockLock(&bitmapLock);
244 s_bitmap[byteIndex] &= ~(1 << bit); 245 s_bitmap[byteIndex] &= ~(1 << bit);
245 spinLockUnlock(&bitmapLock); 246 spinLockUnlock(&bitmapLock);
246 } 247 }
247 #endif 248 #endif
248 249
249 } // namespace WTF 250 } // namespace WTF
250 251
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698