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

Side by Side Diff: src/base/platform/platform-openbsd.cc

Issue 430503007: Rename ASSERT* to DCHECK*. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: REBASE and fixes Created 6 years, 4 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 | « src/base/platform/platform-macos.cc ('k') | src/base/platform/platform-posix.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Platform-specific code for OpenBSD and NetBSD goes here. For the 5 // Platform-specific code for OpenBSD and NetBSD goes here. For the
6 // POSIX-compatible parts, the implementation is in platform-posix.cc. 6 // POSIX-compatible parts, the implementation is in platform-posix.cc.
7 7
8 #include <pthread.h> 8 #include <pthread.h>
9 #include <semaphore.h> 9 #include <semaphore.h>
10 #include <signal.h> 10 #include <signal.h>
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 // by the kernel and allows us to synchronize V8 code log and the 185 // by the kernel and allows us to synchronize V8 code log and the
186 // kernel log. 186 // kernel log.
187 int size = sysconf(_SC_PAGESIZE); 187 int size = sysconf(_SC_PAGESIZE);
188 FILE* f = fopen(OS::GetGCFakeMMapFile(), "w+"); 188 FILE* f = fopen(OS::GetGCFakeMMapFile(), "w+");
189 if (f == NULL) { 189 if (f == NULL) {
190 OS::PrintError("Failed to open %s\n", OS::GetGCFakeMMapFile()); 190 OS::PrintError("Failed to open %s\n", OS::GetGCFakeMMapFile());
191 OS::Abort(); 191 OS::Abort();
192 } 192 }
193 void* addr = mmap(NULL, size, PROT_READ | PROT_EXEC, MAP_PRIVATE, 193 void* addr = mmap(NULL, size, PROT_READ | PROT_EXEC, MAP_PRIVATE,
194 fileno(f), 0); 194 fileno(f), 0);
195 ASSERT(addr != MAP_FAILED); 195 DCHECK(addr != MAP_FAILED);
196 OS::Free(addr, size); 196 OS::Free(addr, size);
197 fclose(f); 197 fclose(f);
198 } 198 }
199 199
200 200
201 201
202 // Constants used for mmap. 202 // Constants used for mmap.
203 static const int kMmapFd = -1; 203 static const int kMmapFd = -1;
204 static const int kMmapFdOffset = 0; 204 static const int kMmapFdOffset = 0;
205 205
206 206
207 VirtualMemory::VirtualMemory() : address_(NULL), size_(0) { } 207 VirtualMemory::VirtualMemory() : address_(NULL), size_(0) { }
208 208
209 209
210 VirtualMemory::VirtualMemory(size_t size) 210 VirtualMemory::VirtualMemory(size_t size)
211 : address_(ReserveRegion(size)), size_(size) { } 211 : address_(ReserveRegion(size)), size_(size) { }
212 212
213 213
214 VirtualMemory::VirtualMemory(size_t size, size_t alignment) 214 VirtualMemory::VirtualMemory(size_t size, size_t alignment)
215 : address_(NULL), size_(0) { 215 : address_(NULL), size_(0) {
216 ASSERT(IsAligned(alignment, static_cast<intptr_t>(OS::AllocateAlignment()))); 216 DCHECK(IsAligned(alignment, static_cast<intptr_t>(OS::AllocateAlignment())));
217 size_t request_size = RoundUp(size + alignment, 217 size_t request_size = RoundUp(size + alignment,
218 static_cast<intptr_t>(OS::AllocateAlignment())); 218 static_cast<intptr_t>(OS::AllocateAlignment()));
219 void* reservation = mmap(OS::GetRandomMmapAddr(), 219 void* reservation = mmap(OS::GetRandomMmapAddr(),
220 request_size, 220 request_size,
221 PROT_NONE, 221 PROT_NONE,
222 MAP_PRIVATE | MAP_ANON | MAP_NORESERVE, 222 MAP_PRIVATE | MAP_ANON | MAP_NORESERVE,
223 kMmapFd, 223 kMmapFd,
224 kMmapFdOffset); 224 kMmapFdOffset);
225 if (reservation == MAP_FAILED) return; 225 if (reservation == MAP_FAILED) return;
226 226
227 uint8_t* base = static_cast<uint8_t*>(reservation); 227 uint8_t* base = static_cast<uint8_t*>(reservation);
228 uint8_t* aligned_base = RoundUp(base, alignment); 228 uint8_t* aligned_base = RoundUp(base, alignment);
229 ASSERT_LE(base, aligned_base); 229 DCHECK_LE(base, aligned_base);
230 230
231 // Unmap extra memory reserved before and after the desired block. 231 // Unmap extra memory reserved before and after the desired block.
232 if (aligned_base != base) { 232 if (aligned_base != base) {
233 size_t prefix_size = static_cast<size_t>(aligned_base - base); 233 size_t prefix_size = static_cast<size_t>(aligned_base - base);
234 OS::Free(base, prefix_size); 234 OS::Free(base, prefix_size);
235 request_size -= prefix_size; 235 request_size -= prefix_size;
236 } 236 }
237 237
238 size_t aligned_size = RoundUp(size, OS::AllocateAlignment()); 238 size_t aligned_size = RoundUp(size, OS::AllocateAlignment());
239 ASSERT_LE(aligned_size, request_size); 239 DCHECK_LE(aligned_size, request_size);
240 240
241 if (aligned_size != request_size) { 241 if (aligned_size != request_size) {
242 size_t suffix_size = request_size - aligned_size; 242 size_t suffix_size = request_size - aligned_size;
243 OS::Free(aligned_base + aligned_size, suffix_size); 243 OS::Free(aligned_base + aligned_size, suffix_size);
244 request_size -= suffix_size; 244 request_size -= suffix_size;
245 } 245 }
246 246
247 ASSERT(aligned_size == request_size); 247 DCHECK(aligned_size == request_size);
248 248
249 address_ = static_cast<void*>(aligned_base); 249 address_ = static_cast<void*>(aligned_base);
250 size_ = aligned_size; 250 size_ = aligned_size;
251 } 251 }
252 252
253 253
254 VirtualMemory::~VirtualMemory() { 254 VirtualMemory::~VirtualMemory() {
255 if (IsReserved()) { 255 if (IsReserved()) {
256 bool result = ReleaseRegion(address(), size()); 256 bool result = ReleaseRegion(address(), size());
257 ASSERT(result); 257 DCHECK(result);
258 USE(result); 258 USE(result);
259 } 259 }
260 } 260 }
261 261
262 262
263 bool VirtualMemory::IsReserved() { 263 bool VirtualMemory::IsReserved() {
264 return address_ != NULL; 264 return address_ != NULL;
265 } 265 }
266 266
267 267
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 return munmap(base, size) == 0; 329 return munmap(base, size) == 0;
330 } 330 }
331 331
332 332
333 bool VirtualMemory::HasLazyCommits() { 333 bool VirtualMemory::HasLazyCommits() {
334 // TODO(alph): implement for the platform. 334 // TODO(alph): implement for the platform.
335 return false; 335 return false;
336 } 336 }
337 337
338 } } // namespace v8::base 338 } } // namespace v8::base
OLDNEW
« no previous file with comments | « src/base/platform/platform-macos.cc ('k') | src/base/platform/platform-posix.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698