12 #include <sys/resource.h>
13 #include <sys/syscall.h>
15 #include <sys/types.h>
23 #include <sys/types.h>
39 if (std::isnan(time))
return "";
40 time_t tv =
static_cast<time_t
>(std::floor(time/
msPerSecond));
41 struct tm* t = localtime(&tv);
42 if (
NULL == t)
return "";
48 time_t tv = time(
NULL);
49 struct tm* t = localtime(&tv);
51 return static_cast<double>(t->tm_gmtoff *
msPerSecond -
60 int prot = PROT_READ | PROT_WRITE | (is_executable ? PROT_EXEC : 0);
62 void* mbase = mmap(addr, msize, prot, MAP_PRIVATE | MAP_ANON, -1, 0);
63 if (mbase == MAP_FAILED)
return NULL;
69 class PosixMemoryMappedFile :
public OS::MemoryMappedFile {
87 fseek(
file, 0, SEEK_END);
91 mmap(0,
size, PROT_READ | PROT_WRITE, MAP_SHARED, fileno(
file), 0);
100 int result = fwrite(initial,
size, 1,
file);
106 mmap(0,
size, PROT_READ | PROT_WRITE, MAP_SHARED, fileno(
file), 0);
107 return new PosixMemoryMappedFile(
file, memory,
size);
112 if (memory_)
OS::Free(memory_, size_);
118 std::vector<SharedLibraryAddress> result;
122 FILE*
fp = fopen(
"/proc/self/maps",
"r");
123 if (
fp ==
NULL)
return result;
126 const int kLibNameLen = FILENAME_MAX + 1;
127 char* lib_name =
reinterpret_cast<char*
>(malloc(kLibNameLen));
132 char attr_r, attr_w, attr_x, attr_p;
135 if (fscanf(
fp,
" %c%c%c%c", &attr_r, &attr_w, &attr_x, &attr_p) != 4)
break;
138 if (attr_r ==
'r' && attr_w !=
'w' && attr_x ==
'x') {
143 }
while ((c != EOF) && (c !=
'\n') && (c !=
'/'));
151 if (fgets(lib_name, kLibNameLen,
fp) ==
NULL)
break;
156 lib_name[strlen(lib_name) - 1] =
'\0';
159 snprintf(lib_name, kLibNameLen,
162 result.push_back(SharedLibraryAddress(lib_name, start, end));
168 }
while ((c != EOF) && (c !=
'\n'));
187 int size = sysconf(_SC_PAGESIZE);
188 FILE* f = fopen(OS::GetGCFakeMMapFile(),
"w+");
193 void* addr = mmap(
NULL,
size, PROT_READ | PROT_EXEC, MAP_PRIVATE,
195 DCHECK(addr != MAP_FAILED);
210 VirtualMemory::VirtualMemory(
size_t size)
211 : address_(ReserveRegion(
size)), size_(
size) { }
214 VirtualMemory::VirtualMemory(
size_t size,
size_t alignment)
215 : address_(
NULL), size_(0) {
222 MAP_PRIVATE | MAP_ANON | MAP_NORESERVE,
225 if (reservation == MAP_FAILED)
return;
227 uint8_t* base =
static_cast<uint8_t*
>(reservation);
228 uint8_t* aligned_base =
RoundUp(base, alignment);
232 if (aligned_base != base) {
233 size_t prefix_size =
static_cast<size_t>(aligned_base - base);
235 request_size -= prefix_size;
241 if (aligned_size != request_size) {
242 size_t suffix_size = request_size - aligned_size;
243 OS::Free(aligned_base + aligned_size, suffix_size);
244 request_size -= suffix_size;
247 DCHECK(aligned_size == request_size);
249 address_ =
static_cast<void*
>(aligned_base);
250 size_ = aligned_size;
254 VirtualMemory::~VirtualMemory() {
256 bool result = ReleaseRegion(address(),
size());
263 bool VirtualMemory::IsReserved() {
264 return address_ !=
NULL;
268 void VirtualMemory::Reset() {
274 bool VirtualMemory::Commit(
void* address,
size_t size,
bool is_executable) {
275 return CommitRegion(address,
size, is_executable);
279 bool VirtualMemory::Uncommit(
void* address,
size_t size) {
280 return UncommitRegion(address,
size);
284 bool VirtualMemory::Guard(
void* address) {
285 OS::Guard(address, OS::CommitPageSize());
290 void* VirtualMemory::ReserveRegion(
size_t size) {
291 void* result = mmap(OS::GetRandomMmapAddr(),
294 MAP_PRIVATE | MAP_ANON | MAP_NORESERVE,
298 if (result == MAP_FAILED)
return NULL;
304 bool VirtualMemory::CommitRegion(
void* base,
size_t size,
bool is_executable) {
305 int prot = PROT_READ | PROT_WRITE | (is_executable ? PROT_EXEC : 0);
306 if (MAP_FAILED == mmap(base,
309 MAP_PRIVATE | MAP_ANON | MAP_FIXED,
318 bool VirtualMemory::UncommitRegion(
void* base,
size_t size) {
322 MAP_PRIVATE | MAP_ANON | MAP_NORESERVE | MAP_FIXED,
328 bool VirtualMemory::ReleaseRegion(
void* base,
size_t size) {
329 return munmap(base,
size) == 0;
333 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 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 PrintError(const char *format,...)
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 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
Debugger support for the V8 JavaScript engine.