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

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

Issue 244051: Based on a patch submitted by Jens Alfke:... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 11 years, 2 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 | « 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 // 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 24 matching lines...) Expand all
35 #include <mach-o/getsect.h> 35 #include <mach-o/getsect.h>
36 36
37 #include <AvailabilityMacros.h> 37 #include <AvailabilityMacros.h>
38 38
39 #include <pthread.h> 39 #include <pthread.h>
40 #include <semaphore.h> 40 #include <semaphore.h>
41 #include <signal.h> 41 #include <signal.h>
42 #include <mach/mach.h> 42 #include <mach/mach.h>
43 #include <mach/semaphore.h> 43 #include <mach/semaphore.h>
44 #include <mach/task.h> 44 #include <mach/task.h>
45 #include <mach/vm_statistics.h>
45 #include <sys/time.h> 46 #include <sys/time.h>
46 #include <sys/resource.h> 47 #include <sys/resource.h>
47 #include <sys/types.h> 48 #include <sys/types.h>
48 #include <stdarg.h> 49 #include <stdarg.h>
49 #include <stdlib.h> 50 #include <stdlib.h>
50 51
51 #include <errno.h> 52 #include <errno.h>
52 53
53 #undef MAP_TYPE 54 #undef MAP_TYPE
54 55
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 bool OS::IsOutsideAllocatedSpace(void* address) { 117 bool OS::IsOutsideAllocatedSpace(void* address) {
117 return address < lowest_ever_allocated || address >= highest_ever_allocated; 118 return address < lowest_ever_allocated || address >= highest_ever_allocated;
118 } 119 }
119 120
120 121
121 size_t OS::AllocateAlignment() { 122 size_t OS::AllocateAlignment() {
122 return getpagesize(); 123 return getpagesize();
123 } 124 }
124 125
125 126
127 // Constants used for mmap.
128 // kMmapFd is used to pass vm_alloc flags to tag the region with the user
129 // defined tag 255 This helps identify V8-allocated regions in memory analysis
130 // tools like vmmap(1).
131 static const int kMmapFd = VM_MAKE_TAG(255);
132 static const off_t kMmapFdOffset = 0;
133
134
126 void* OS::Allocate(const size_t requested, 135 void* OS::Allocate(const size_t requested,
127 size_t* allocated, 136 size_t* allocated,
128 bool is_executable) { 137 bool is_executable) {
129 const size_t msize = RoundUp(requested, getpagesize()); 138 const size_t msize = RoundUp(requested, getpagesize());
130 int prot = PROT_READ | PROT_WRITE | (is_executable ? PROT_EXEC : 0); 139 int prot = PROT_READ | PROT_WRITE | (is_executable ? PROT_EXEC : 0);
131 void* mbase = mmap(NULL, msize, prot, MAP_PRIVATE | MAP_ANON, -1, 0); 140 void* mbase = mmap(NULL, msize, prot,
141 MAP_PRIVATE | MAP_ANON,
142 kMmapFd, kMmapFdOffset);
132 if (mbase == MAP_FAILED) { 143 if (mbase == MAP_FAILED) {
133 LOG(StringEvent("OS::Allocate", "mmap failed")); 144 LOG(StringEvent("OS::Allocate", "mmap failed"));
134 return NULL; 145 return NULL;
135 } 146 }
136 *allocated = msize; 147 *allocated = msize;
137 UpdateAllocatedSpaceLimits(mbase, msize); 148 UpdateAllocatedSpaceLimits(mbase, msize);
138 return mbase; 149 return mbase;
139 } 150 }
140 151
141 152
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 frames[i].text[kStackWalkMaxTextLen - 1] = '\0'; 284 frames[i].text[kStackWalkMaxTextLen - 1] = '\0';
274 } 285 }
275 286
276 DeleteArray(addresses); 287 DeleteArray(addresses);
277 free(symbols); 288 free(symbols);
278 289
279 return frames_count; 290 return frames_count;
280 } 291 }
281 292
282 293
283 // Constants used for mmap.
284 static const int kMmapFd = -1;
285 static const int kMmapFdOffset = 0;
286 294
287 295
288 VirtualMemory::VirtualMemory(size_t size) { 296 VirtualMemory::VirtualMemory(size_t size) {
289 address_ = mmap(NULL, size, PROT_NONE, 297 address_ = mmap(NULL, size, PROT_NONE,
290 MAP_PRIVATE | MAP_ANON | MAP_NORESERVE, 298 MAP_PRIVATE | MAP_ANON | MAP_NORESERVE,
291 kMmapFd, kMmapFdOffset); 299 kMmapFd, kMmapFdOffset);
292 size_ = size; 300 size_ = size;
293 } 301 }
294 302
295 303
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
623 631
624 // Deallocate Mach port for thread. 632 // Deallocate Mach port for thread.
625 if (IsProfiling()) { 633 if (IsProfiling()) {
626 mach_port_deallocate(data_->task_self_, data_->profiled_thread_); 634 mach_port_deallocate(data_->task_self_, data_->profiled_thread_);
627 } 635 }
628 } 636 }
629 637
630 #endif // ENABLE_LOGGING_AND_PROFILING 638 #endif // ENABLE_LOGGING_AND_PROFILING
631 639
632 } } // namespace v8::internal 640 } } // namespace v8::internal
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