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

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

Issue 353113003: Remove dependency from platform files on v8.h (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 5 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') | src/platform-openbsd.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 MacOS goes here. For the POSIX-compatible 5 // Platform-specific code for MacOS goes here. For the POSIX-compatible
6 // parts, the implementation is in platform-posix.cc. 6 // parts, the implementation is in platform-posix.cc.
7 7
8 #include <dlfcn.h> 8 #include <dlfcn.h>
9 #include <mach/mach_init.h> 9 #include <mach/mach_init.h>
10 #include <mach-o/dyld.h> 10 #include <mach-o/dyld.h>
(...skipping 13 matching lines...) Expand all
24 #include <semaphore.h> 24 #include <semaphore.h>
25 #include <signal.h> 25 #include <signal.h>
26 #include <stdarg.h> 26 #include <stdarg.h>
27 #include <stdlib.h> 27 #include <stdlib.h>
28 #include <string.h> 28 #include <string.h>
29 #include <sys/resource.h> 29 #include <sys/resource.h>
30 #include <sys/sysctl.h> 30 #include <sys/sysctl.h>
31 #include <sys/time.h> 31 #include <sys/time.h>
32 #include <sys/types.h> 32 #include <sys/types.h>
33 33
34 #include <cmath>
35
34 #undef MAP_TYPE 36 #undef MAP_TYPE
35 37
36 #include "src/v8.h"
37
38 #include "src/platform.h" 38 #include "src/platform.h"
39 #include "src/utils.h"
39 40
40 41
41 namespace v8 { 42 namespace v8 {
42 namespace internal { 43 namespace internal {
43 44
44 45
45 // Constants used for mmap. 46 // Constants used for mmap.
46 // kMmapFd is used to pass vm_alloc flags to tag the region with the user 47 // kMmapFd is used to pass vm_alloc flags to tag the region with the user
47 // defined tag 255 This helps identify V8-allocated regions in memory analysis 48 // defined tag 255 This helps identify V8-allocated regions in memory analysis
48 // tools like vmmap(1). 49 // tools like vmmap(1).
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 size_t request_size = RoundUp(size + alignment, 188 size_t request_size = RoundUp(size + alignment,
188 static_cast<intptr_t>(OS::AllocateAlignment())); 189 static_cast<intptr_t>(OS::AllocateAlignment()));
189 void* reservation = mmap(OS::GetRandomMmapAddr(), 190 void* reservation = mmap(OS::GetRandomMmapAddr(),
190 request_size, 191 request_size,
191 PROT_NONE, 192 PROT_NONE,
192 MAP_PRIVATE | MAP_ANON | MAP_NORESERVE, 193 MAP_PRIVATE | MAP_ANON | MAP_NORESERVE,
193 kMmapFd, 194 kMmapFd,
194 kMmapFdOffset); 195 kMmapFdOffset);
195 if (reservation == MAP_FAILED) return; 196 if (reservation == MAP_FAILED) return;
196 197
197 Address base = static_cast<Address>(reservation); 198 uint8_t* base = static_cast<uint8_t*>(reservation);
198 Address aligned_base = RoundUp(base, alignment); 199 uint8_t* aligned_base = RoundUp(base, alignment);
199 ASSERT_LE(base, aligned_base); 200 ASSERT_LE(base, aligned_base);
200 201
201 // Unmap extra memory reserved before and after the desired block. 202 // Unmap extra memory reserved before and after the desired block.
202 if (aligned_base != base) { 203 if (aligned_base != base) {
203 size_t prefix_size = static_cast<size_t>(aligned_base - base); 204 size_t prefix_size = static_cast<size_t>(aligned_base - base);
204 OS::Free(base, prefix_size); 205 OS::Free(base, prefix_size);
205 request_size -= prefix_size; 206 request_size -= prefix_size;
206 } 207 }
207 208
208 size_t aligned_size = RoundUp(size, OS::AllocateAlignment()); 209 size_t aligned_size = RoundUp(size, OS::AllocateAlignment());
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 bool VirtualMemory::ReleaseRegion(void* address, size_t size) { 301 bool VirtualMemory::ReleaseRegion(void* address, size_t size) {
301 return munmap(address, size) == 0; 302 return munmap(address, size) == 0;
302 } 303 }
303 304
304 305
305 bool VirtualMemory::HasLazyCommits() { 306 bool VirtualMemory::HasLazyCommits() {
306 return false; 307 return false;
307 } 308 }
308 309
309 } } // namespace v8::internal 310 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/platform-linux.cc ('k') | src/platform-openbsd.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698