Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 46 #include <mach/task.h> | 46 #include <mach/task.h> |
| 47 #include <mach/vm_statistics.h> | 47 #include <mach/vm_statistics.h> |
| 48 #include <sys/time.h> | 48 #include <sys/time.h> |
| 49 #include <sys/resource.h> | 49 #include <sys/resource.h> |
| 50 #include <sys/types.h> | 50 #include <sys/types.h> |
| 51 #include <sys/sysctl.h> | 51 #include <sys/sysctl.h> |
| 52 #include <stdarg.h> | 52 #include <stdarg.h> |
| 53 #include <stdlib.h> | 53 #include <stdlib.h> |
| 54 #include <string.h> | 54 #include <string.h> |
| 55 #include <errno.h> | 55 #include <errno.h> |
| 56 #include <cxxabi.h> | |
| 57 | 56 |
| 58 #undef MAP_TYPE | 57 #undef MAP_TYPE |
| 59 | 58 |
| 60 #include "v8.h" | 59 #include "v8.h" |
| 61 | 60 |
| 62 #include "platform-posix.h" | |
| 63 #include "platform.h" | 61 #include "platform.h" |
| 64 #include "simulator.h" | 62 #include "simulator.h" |
| 65 #include "vm-state-inl.h" | 63 #include "vm-state-inl.h" |
| 66 | 64 |
| 67 // Manually define these here as weak imports, rather than including execinfo.h. | |
| 68 // This lets us launch on 10.4 which does not have these calls. | |
|
Michael Achenbach
2013/09/23 11:12:50
In the new code, execinfo.h will be included. Will
Benedikt Meurer
2013/09/23 11:26:40
Nope. We've moved to 10.6 as announced publicly la
| |
| 69 extern "C" { | |
| 70 extern int backtrace(void**, int) __attribute__((weak_import)); | |
| 71 extern char** backtrace_symbols(void* const*, int) | |
| 72 __attribute__((weak_import)); | |
| 73 extern void backtrace_symbols_fd(void* const*, int, int) | |
| 74 __attribute__((weak_import)); | |
| 75 } | |
| 76 | |
| 77 | 65 |
| 78 namespace v8 { | 66 namespace v8 { |
| 79 namespace internal { | 67 namespace internal { |
| 80 | 68 |
| 81 | 69 |
| 82 // Constants used for mmap. | 70 // Constants used for mmap. |
| 83 // kMmapFd is used to pass vm_alloc flags to tag the region with the user | 71 // kMmapFd is used to pass vm_alloc flags to tag the region with the user |
| 84 // defined tag 255 This helps identify V8-allocated regions in memory analysis | 72 // defined tag 255 This helps identify V8-allocated regions in memory analysis |
| 85 // tools like vmmap(1). | 73 // tools like vmmap(1). |
| 86 static const int kMmapFd = VM_MAKE_TAG(255); | 74 static const int kMmapFd = VM_MAKE_TAG(255); |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 100 kMmapFdOffset); | 88 kMmapFdOffset); |
| 101 if (mbase == MAP_FAILED) { | 89 if (mbase == MAP_FAILED) { |
| 102 LOG(Isolate::Current(), StringEvent("OS::Allocate", "mmap failed")); | 90 LOG(Isolate::Current(), StringEvent("OS::Allocate", "mmap failed")); |
| 103 return NULL; | 91 return NULL; |
| 104 } | 92 } |
| 105 *allocated = msize; | 93 *allocated = msize; |
| 106 return mbase; | 94 return mbase; |
| 107 } | 95 } |
| 108 | 96 |
| 109 | 97 |
| 110 void OS::DumpBacktrace() { | |
| 111 // If weak link to execinfo lib has failed, ie because we are on 10.4, abort. | |
| 112 if (backtrace == NULL) return; | |
| 113 | |
| 114 POSIXBacktraceHelper<backtrace, backtrace_symbols>::DumpBacktrace(); | |
| 115 } | |
| 116 | |
| 117 | |
| 118 class PosixMemoryMappedFile : public OS::MemoryMappedFile { | 98 class PosixMemoryMappedFile : public OS::MemoryMappedFile { |
| 119 public: | 99 public: |
| 120 PosixMemoryMappedFile(FILE* file, void* memory, int size) | 100 PosixMemoryMappedFile(FILE* file, void* memory, int size) |
| 121 : file_(file), memory_(memory), size_(size) { } | 101 : file_(file), memory_(memory), size_(size) { } |
| 122 virtual ~PosixMemoryMappedFile(); | 102 virtual ~PosixMemoryMappedFile(); |
| 123 virtual void* memory() { return memory_; } | 103 virtual void* memory() { return memory_; } |
| 124 virtual int size() { return size_; } | 104 virtual int size() { return size_; } |
| 125 private: | 105 private: |
| 126 FILE* file_; | 106 FILE* file_; |
| 127 void* memory_; | 107 void* memory_; |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 346 bool VirtualMemory::ReleaseRegion(void* address, size_t size) { | 326 bool VirtualMemory::ReleaseRegion(void* address, size_t size) { |
| 347 return munmap(address, size) == 0; | 327 return munmap(address, size) == 0; |
| 348 } | 328 } |
| 349 | 329 |
| 350 | 330 |
| 351 bool VirtualMemory::HasLazyCommits() { | 331 bool VirtualMemory::HasLazyCommits() { |
| 352 return false; | 332 return false; |
| 353 } | 333 } |
| 354 | 334 |
| 355 } } // namespace v8::internal | 335 } } // namespace v8::internal |
| OLD | NEW |