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

Side by Side Diff: src/platform-macos.cc

Issue 7491089: Make experimental/gc compilable on Mac OS. (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/gc/
Patch Set: Created 9 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/platform-linux.cc ('k') | 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 // Copyright 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 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 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 // Make sure line termination is in place. 327 // Make sure line termination is in place.
328 frames[i].text[kStackWalkMaxTextLen - 1] = '\0'; 328 frames[i].text[kStackWalkMaxTextLen - 1] = '\0';
329 } 329 }
330 330
331 free(symbols); 331 free(symbols);
332 332
333 return frames_count; 333 return frames_count;
334 } 334 }
335 335
336 336
337 VirtualMemory::VirtualMemory(size_t size) {
338 address_ = ReserveRegion(size);
339 size_ = size;
340 }
337 341
338 342
339 VirtualMemory::VirtualMemory(size_t size) { 343 void* VirtualMemory::ReserveRegion(size_t size) {
340 address_ = mmap(NULL, size, PROT_NONE, 344 void* result = mmap(NULL,
341 MAP_PRIVATE | MAP_ANON | MAP_NORESERVE, 345 size,
342 kMmapFd, kMmapFdOffset); 346 PROT_NONE,
343 size_ = size; 347 MAP_PRIVATE | MAP_ANON | MAP_NORESERVE,
348 kMmapFd,
349 kMmapFdOffset);
350
351 if (result == MAP_FAILED) return NULL;
352
Lasse Reichstein 2011/08/08 09:29:39 Not setting size_?
Vyacheslav Egorov (Chromium) 2011/08/08 10:00:53 This is a static method.
353 return result;
344 } 354 }
345 355
346 356
347 VirtualMemory::~VirtualMemory() { 357 VirtualMemory::~VirtualMemory() {
348 if (IsReserved()) { 358 if (IsReserved()) {
349 if (0 == munmap(address(), size())) address_ = MAP_FAILED; 359 if (ReleaseRegion(address_, size_)) address_ = MAP_FAILED;
350 } 360 }
351 } 361 }
352 362
353 363
354 bool VirtualMemory::IsReserved() { 364 bool VirtualMemory::IsReserved() {
355 return address_ != MAP_FAILED; 365 return address_ != MAP_FAILED;
356 } 366 }
357 367
358 368
359 bool VirtualMemory::Commit(void* address, size_t size, bool is_executable) { 369 bool VirtualMemory::Commit(void* address, size_t size, bool is_executable) {
370 return CommitRegion(address, size, is_executable);
371 }
372
373
374 bool VirtualMemory::CommitRegion(void* address,
375 size_t size,
376 bool is_executable) {
360 int prot = PROT_READ | PROT_WRITE | (is_executable ? PROT_EXEC : 0); 377 int prot = PROT_READ | PROT_WRITE | (is_executable ? PROT_EXEC : 0);
361 if (MAP_FAILED == mmap(address, size, prot, 378 if (MAP_FAILED == mmap(address,
379 size,
380 prot,
362 MAP_PRIVATE | MAP_ANON | MAP_FIXED, 381 MAP_PRIVATE | MAP_ANON | MAP_FIXED,
363 kMmapFd, kMmapFdOffset)) { 382 kMmapFd,
383 kMmapFdOffset)) {
364 return false; 384 return false;
365 } 385 }
366 386
367 UpdateAllocatedSpaceLimits(address, size); 387 UpdateAllocatedSpaceLimits(address, size);
368 return true; 388 return true;
369 } 389 }
370 390
371 391
372 bool VirtualMemory::Uncommit(void* address, size_t size) { 392 bool VirtualMemory::Uncommit(void* address, size_t size) {
373 return mmap(address, size, PROT_NONE, 393 return UncommitRegion(address, size);
394 }
395
396
397 bool VirtualMemory::UncommitRegion(void* address, size_t size) {
398 return mmap(address,
399 size,
400 PROT_NONE,
374 MAP_PRIVATE | MAP_ANON | MAP_NORESERVE | MAP_FIXED, 401 MAP_PRIVATE | MAP_ANON | MAP_NORESERVE | MAP_FIXED,
375 kMmapFd, kMmapFdOffset) != MAP_FAILED; 402 kMmapFd,
403 kMmapFdOffset) != MAP_FAILED;
404 }
405
406
407 bool VirtualMemory::ReleaseRegion(void* address, size_t size) {
408 return munmap(address, size) == 0;
376 } 409 }
377 410
378 411
379 class Thread::PlatformData : public Malloced { 412 class Thread::PlatformData : public Malloced {
380 public: 413 public:
381 PlatformData() : thread_(kNoThread) {} 414 PlatformData() : thread_(kNoThread) {}
382 pthread_t thread_; // Thread handle for pthread. 415 pthread_t thread_; // Thread handle for pthread.
383 }; 416 };
384 417
385 Thread::Thread(const Options& options) 418 Thread::Thread(const Options& options)
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after
798 831
799 832
800 void Sampler::Stop() { 833 void Sampler::Stop() {
801 ASSERT(IsActive()); 834 ASSERT(IsActive());
802 SamplerThread::RemoveActiveSampler(this); 835 SamplerThread::RemoveActiveSampler(this);
803 SetActive(false); 836 SetActive(false);
804 } 837 }
805 838
806 839
807 } } // namespace v8::internal 840 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/platform-linux.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698