13 #include <sys/resource.h>
15 #include <sys/types.h>
25 #include <sys/procfs.h>
27 #include <sys/types.h>
57 #define GCC_VERSION (__GNUC__ * 10000 \
58 + __GNUC_MINOR__ * 100 \
59 + __GNUC_PATCHLEVEL__)
60 #if GCC_VERSION >= 40600
61 #if defined(__ARM_PCS_VFP)
67 #elif GCC_VERSION < 40500
71 #if defined(__ARM_PCS_VFP)
73 #elif defined(__ARM_PCS) || defined(__SOFTFP__) || defined(__SOFTFP) || \
77 #error "Your version of GCC does not report the FP ABI compiled for." \
78 "Please report it on this issue" \
79 "http://code.google.com/p/v8/issues/detail?id=2140"
90 if (std::isnan(time))
return "";
91 time_t tv =
static_cast<time_t
>(std::floor(time/
msPerSecond));
92 struct tm* t = localtime(&tv);
93 if (
NULL == t)
return "";
99 time_t tv = time(
NULL);
100 struct tm* t = localtime(&tv);
102 return static_cast<double>(t->tm_gmtoff *
msPerSecond -
109 bool is_executable) {
111 int prot = PROT_READ | PROT_WRITE | (is_executable ? PROT_EXEC : 0);
113 void* mbase = mmap(addr, msize, prot, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
114 if (mbase == MAP_FAILED)
return NULL;
120 class PosixMemoryMappedFile :
public OS::MemoryMappedFile {
138 fseek(
file, 0, SEEK_END);
144 PROT_READ | PROT_WRITE,
156 int result = fwrite(initial,
size, 1,
file);
164 PROT_READ | PROT_WRITE,
168 return new PosixMemoryMappedFile(
file, memory,
size);
173 if (memory_)
OS::Free(memory_, size_);
179 std::vector<SharedLibraryAddress> result;
180 procfs_mapinfo *mapinfos =
NULL, *mapinfo;
184 procfs_debuginfo info;
188 char buf[PATH_MAX + 1];
189 snprintf(buf, PATH_MAX + 1,
"/proc/%d/as", getpid());
191 if ((proc_fd = open(buf, O_RDONLY)) == -1) {
197 if (devctl(proc_fd, DCMD_PROC_MAPINFO,
NULL, 0, &num) != EOK) {
202 mapinfos =
reinterpret_cast<procfs_mapinfo *
>(
203 malloc(num *
sizeof(procfs_mapinfo)));
204 if (mapinfos ==
NULL) {
210 if (devctl(proc_fd, DCMD_PROC_PAGEDATA,
211 mapinfos, num *
sizeof(procfs_mapinfo), &num) != EOK) {
217 for (
i = 0;
i < num;
i++) {
218 mapinfo = mapinfos +
i;
219 if (mapinfo->flags & MAP_ELF) {
220 map.info.vaddr = mapinfo->vaddr;
221 if (devctl(proc_fd, DCMD_PROC_MAPDEBUG, &
map,
sizeof(
map), 0) != EOK) {
224 result.push_back(SharedLibraryAddress(
225 map.info.path, mapinfo->vaddr, mapinfo->vaddr + mapinfo->size));
246 VirtualMemory::VirtualMemory(
size_t size)
247 : address_(ReserveRegion(
size)), size_(
size) { }
250 VirtualMemory::VirtualMemory(
size_t size,
size_t alignment)
251 : address_(
NULL), size_(0) {
258 MAP_PRIVATE | MAP_ANONYMOUS | MAP_LAZY,
261 if (reservation == MAP_FAILED)
return;
263 uint8_t* base =
static_cast<uint8_t*
>(reservation);
264 uint8_t* aligned_base =
RoundUp(base, alignment);
268 if (aligned_base != base) {
269 size_t prefix_size =
static_cast<size_t>(aligned_base - base);
271 request_size -= prefix_size;
277 if (aligned_size != request_size) {
278 size_t suffix_size = request_size - aligned_size;
279 OS::Free(aligned_base + aligned_size, suffix_size);
280 request_size -= suffix_size;
283 DCHECK(aligned_size == request_size);
285 address_ =
static_cast<void*
>(aligned_base);
286 size_ = aligned_size;
290 VirtualMemory::~VirtualMemory() {
292 bool result = ReleaseRegion(address(),
size());
299 bool VirtualMemory::IsReserved() {
300 return address_ !=
NULL;
304 void VirtualMemory::Reset() {
310 bool VirtualMemory::Commit(
void* address,
size_t size,
bool is_executable) {
311 return CommitRegion(address,
size, is_executable);
315 bool VirtualMemory::Uncommit(
void* address,
size_t size) {
316 return UncommitRegion(address,
size);
320 bool VirtualMemory::Guard(
void* address) {
321 OS::Guard(address, OS::CommitPageSize());
326 void* VirtualMemory::ReserveRegion(
size_t size) {
327 void* result = mmap(OS::GetRandomMmapAddr(),
330 MAP_PRIVATE | MAP_ANONYMOUS | MAP_LAZY,
334 if (result == MAP_FAILED)
return NULL;
340 bool VirtualMemory::CommitRegion(
void* base,
size_t size,
bool is_executable) {
341 int prot = PROT_READ | PROT_WRITE | (is_executable ? PROT_EXEC : 0);
342 if (MAP_FAILED == mmap(base,
345 MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED,
355 bool VirtualMemory::UncommitRegion(
void* base,
size_t size) {
359 MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED | MAP_LAZY,
365 bool VirtualMemory::ReleaseRegion(
void* base,
size_t size) {
366 return munmap(base,
size) == 0;
370 bool VirtualMemory::HasLazyCommits() {
static MemoryMappedFile * create(const char *name, int size, void *initial)
virtual void * memory()=0
static MemoryMappedFile * open(const char *name)
static void * GetRandomMmapAddr()
static size_t AllocateAlignment()
static void SignalCodeMovingGC()
static bool ArmUsingHardFloat()
static void * Allocate(const size_t requested, size_t *allocated, bool is_executable)
static const char * LocalTimezone(double time, TimezoneCache *cache)
static std::vector< SharedLibraryAddress > GetSharedLibraryAddresses()
static double LocalTimeOffset(TimezoneCache *cache)
static void Free(void *address, const size_t size)
static const int msPerSecond
virtual ~PosixMemoryMappedFile()
PosixMemoryMappedFile(FILE *file, void *memory, int size)
virtual ~PosixMemoryMappedFile()
enable harmony numeric enable harmony object literal extensions Optimize object Array DOM strings and string trace pretenuring decisions of HAllocate instructions Enables optimizations which favor memory size over execution speed maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining trace the tracking of allocation sites deoptimize every n garbage collections perform array bounds checks elimination analyze liveness of environment slots and zap dead values flushes the cache of optimized code for closures on every GC allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms do not emit check maps for constant values that have a leaf map
enable harmony numeric enable harmony object literal extensions Optimize object size
enable harmony numeric enable harmony object literal extensions Optimize object Array DOM strings and string trace pretenuring decisions of HAllocate instructions Enables optimizations which favor memory size over execution speed maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining trace the tracking of allocation sites deoptimize every n garbage collections perform array bounds checks elimination analyze liveness of environment slots and zap dead values flushes the cache of optimized code for closures on every GC allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes enable context specialization in TurboFan execution budget before interrupt is triggered max percentage of megamorphic generic ICs to allow optimization enable use of SAHF instruction if enable use of VFP3 instructions if available enable use of NEON instructions if enable use of SDIV and UDIV instructions if enable use of MLS instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of d16 d31 registers on ARM this requires VFP3 force all emitted branches to be in long enable alignment of csp to bytes on platforms which prefer the register to always be expose gc extension under the specified name show built in functions in stack traces use random jit cookie to mask large constants minimum length for automatic enable preparsing CPU profiler sampling interval in microseconds trace out of bounds accesses to external arrays default size of stack region v8 is allowed to maximum length of function source code printed in a stack trace min size of a semi the new space consists of two semi spaces print one trace line following each garbage collection do not print trace line after scavenger collection print cumulative GC statistics in name
enable harmony numeric enable harmony object literal extensions Optimize object Array DOM strings and string trace pretenuring decisions of HAllocate instructions Enables optimizations which favor memory size over execution speed maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining trace the tracking of allocation sites deoptimize every n garbage collections perform array bounds checks elimination analyze liveness of environment slots and zap dead values flushes the cache of optimized code for closures on every GC allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes enable context specialization in TurboFan execution budget before interrupt is triggered max percentage of megamorphic generic ICs to allow optimization enable use of SAHF instruction if enable use of VFP3 instructions if available enable use of NEON instructions if enable use of SDIV and UDIV instructions if enable use of MLS instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of d16 d31 registers on ARM this requires VFP3 force all emitted branches to be in long enable alignment of csp to bytes on platforms which prefer the register to always be expose gc extension under the specified name show built in functions in stack traces use random jit cookie to mask large constants minimum length for automatic enable preparsing CPU profiler sampling interval in microseconds trace out of bounds accesses to external arrays default size of stack region v8 is allowed to maximum length of function source code printed in a stack trace min size of a semi the new space consists of two semi spaces print one trace line following each garbage collection do not print trace line after scavenger collection print cumulative GC statistics in only print modified registers Trace simulator debug messages Implied by trace sim abort randomize hashes to avoid predictable hash Fixed seed to use to hash property Print the time it takes to deserialize the snapshot A filename with extra code to be included in the A file to write the raw snapshot bytes A file to write the raw context snapshot bytes Write V8 startup blob file(mksnapshot only)") DEFINE_BOOL(profile_hydrogen_code_stub_compilation
enable harmony numeric enable harmony object literal extensions Optimize object Array DOM strings and string trace pretenuring decisions of HAllocate instructions Enables optimizations which favor memory size over execution speed maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining trace the tracking of allocation sites deoptimize every n garbage collections perform array bounds checks elimination analyze liveness of environment slots and zap dead values flushes the cache of optimized code for closures on every GC allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes enable context specialization in TurboFan execution budget before interrupt is triggered max percentage of megamorphic generic ICs to allow optimization enable use of SAHF instruction if enable use of VFP3 instructions if available enable use of NEON instructions if enable use of SDIV and UDIV instructions if enable use of MLS instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of d16 d31 registers on ARM this requires VFP3 force all emitted branches to be in long enable alignment of csp to bytes on platforms which prefer the register to always be NULL
#define DCHECK_LE(v1, v2)
#define DCHECK(condition)
T RoundUp(T x, intptr_t m)
static const int kMmapFdOffset
static const pthread_t kNoThread
Debugger support for the V8 JavaScript engine.