56 time_t tv =
static_cast<time_t
>(std::floor(time/msPerSecond));
57 struct tm* t = localtime(&tv);
58 if (
NULL == t)
return "";
65 time_t utc = time(
NULL);
67 struct tm* loc = localtime(&utc);
70 return static_cast<double>((mktime(loc) - utc) * msPerSecond -
71 (loc->tm_isdst > 0 ? 3600 * msPerSecond : 0));
78 const size_t msize =
RoundUp(requested, sysconf(_SC_PAGESIZE));
79 int prot = PROT_READ | PROT_WRITE | (is_executable ? PROT_EXEC : 0);
80 void* mbase = mmap(
NULL, msize, prot, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
81 if (mbase == MAP_FAILED) {
82 LOG(Isolate::Current(), StringEvent(
"OS::Allocate",
"mmap failed"));
93 : file_(file), memory_(memory), size_(size) { }
95 virtual void*
memory() {
return memory_; }
96 virtual int size() {
return size_; }
105 FILE* file = fopen(name,
"r+");
108 fseek(file, 0, SEEK_END);
109 int size = ftell(file);
112 mmap(0, size, PROT_READ | PROT_WRITE, MAP_SHARED, fileno(file), 0);
119 FILE* file = fopen(name,
"w+");
121 int result = fwrite(initial, size, 1, file);
127 mmap(0, size, PROT_READ | PROT_WRITE, MAP_SHARED, fileno(file), 0);
133 if (memory_) munmap(memory_, size_);
142 FILE*
fp = fopen(
"/proc/self/maps",
"r");
143 if (fp ==
NULL)
return;
146 const int kLibNameLen = FILENAME_MAX + 1;
147 char* lib_name =
reinterpret_cast<char*
>(malloc(kLibNameLen));
151 uintptr_t start, end;
152 char attr_r, attr_w, attr_x, attr_p;
155 if (fscanf(fp,
" %c%c%c%c", &attr_r, &attr_w, &attr_x, &attr_p) != 4)
break;
158 if (attr_r ==
'r' && attr_w !=
'w' && attr_x ==
'x') {
163 }
while ((c != EOF) && (c !=
'\n') && (c !=
'/'));
171 if (fgets(lib_name, kLibNameLen, fp) ==
NULL)
break;
176 lib_name[strlen(lib_name) - 1] =
'\0';
179 snprintf(lib_name, kLibNameLen,
180 "%08" V8PRIxPTR
"-%08" V8PRIxPTR, start, end);
182 LOG(isolate, SharedLibraryEvent(lib_name, start, end));
188 }
while ((c != EOF) && (c !=
'\n'));
208 static void* GetRandomAddr() {
209 Isolate* isolate = Isolate::UncheckedCurrent();
213 if (isolate !=
NULL) {
219 #ifdef V8_HOST_ARCH_64_BIT
220 static const intptr_t kAllocationRandomAddressMin = 0x0000000080000000;
221 static const intptr_t kAllocationRandomAddressMax = 0x000003FFFFFF0000;
223 static const intptr_t kAllocationRandomAddressMin = 0x04000000;
224 static const intptr_t kAllocationRandomAddressMax = 0x3FFF0000;
228 kAllocationRandomAddressMin;
229 address &= kAllocationRandomAddressMax;
230 return reinterpret_cast<void *
>(address);
236 static void* RandomizedVirtualAlloc(
size_t size,
int action,
int protection) {
239 if (protection == PAGE_EXECUTE_READWRITE || protection == PAGE_NOACCESS) {
241 for (
size_t attempts = 0; base ==
NULL && attempts < 3; ++attempts) {
242 base = VirtualAlloc(GetRandomAddr(), size, action, protection);
247 if (base ==
NULL) base = VirtualAlloc(
NULL, size, action, protection);
257 : address_(ReserveRegion(size)), size_(size) { }
261 : address_(
NULL), size_(0) {
263 size_t request_size =
RoundUp(size + alignment,
266 if (address ==
NULL)
return;
272 address = VirtualAlloc(base, size, MEM_RESERVE, PAGE_NOACCESS);
273 if (address !=
NULL) {
275 ASSERT(base == static_cast<Address>(address));
279 if (address ==
NULL)
return;
282 size_ = request_size;
296 return address_ !=
NULL;
318 return RandomizedVirtualAlloc(size, MEM_RESERVE, PAGE_NOACCESS);
323 int prot = is_executable ? PAGE_EXECUTE_READWRITE : PAGE_READWRITE;
324 if (
NULL == VirtualAlloc(base, size, MEM_COMMIT, prot)) {
332 if (
NULL == VirtualAlloc(address,
343 return VirtualFree(base, size, MEM_DECOMMIT) != 0;
348 return VirtualFree(base, 0, MEM_RELEASE) != 0;
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric enable harmony string enable harmony math functions harmony_scoping harmony_symbols harmony_collections harmony_iteration harmony_strings harmony_scoping harmony_maths tracks arrays with only smi values Optimize object Array DOM strings and string pretenure call new trace pretenuring decisions of HAllocate instructions track fields with only smi values track fields with heap values track_fields track_fields Enables optimizations which favor memory size over execution speed use string slices optimization filter maximum number of GVN fix point iterations use function inlining use allocation folding eliminate write barriers targeting allocations in optimized code maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining crankshaft harvests type feedback from stub cache trace check elimination phase hydrogen tracing filter NULL
static void LogSharedLibraryAddresses(Isolate *isolate)
#define LOG(isolate, Call)
static void SignalCodeMovingGC()
static void * ReserveRegion(size_t size)
PosixMemoryMappedFile(FILE *file, void *memory, int size)
RandomNumberGenerator * random_number_generator()
#define ASSERT(condition)
static MemoryMappedFile * open(const char *name)
static bool HasLazyCommits()
virtual void * memory()=0
bool Guard(void *address)
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric enable harmony string enable harmony math functions harmony_scoping harmony_symbols harmony_collections harmony_iteration harmony_strings harmony_scoping harmony_maths tracks arrays with only smi values Optimize object size
bool IsAligned(T value, U alignment)
static MemoryMappedFile * create(const char *name, int size, void *initial)
bool Commit(void *address, size_t size, bool is_executable)
T RoundUp(T x, intptr_t m)
static const char * LocalTimezone(double time, TimezoneCache *cache)
static bool ReleaseRegion(void *base, size_t size)
static bool CommitRegion(void *base, size_t size, bool is_executable)
static void * Allocate(const size_t requested, size_t *allocated, bool is_executable)
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric enable harmony string enable harmony math functions harmony_scoping harmony_symbols harmony_collections harmony_iteration harmony_strings harmony_scoping harmony_maths tracks arrays with only smi values Optimize object Array DOM strings and string pretenure call new trace pretenuring decisions of HAllocate instructions track fields with only smi values track fields with heap values track_fields track_fields Enables optimizations which favor memory size over execution speed use string slices optimization filter maximum number of GVN fix point iterations use function inlining use allocation folding eliminate write barriers targeting allocations in optimized code maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining crankshaft harvests type feedback from stub cache trace check elimination phase hydrogen tracing filter trace hydrogen to given file name trace inlining decisions trace store elimination trace all use positions trace global value numbering trace hydrogen escape analysis trace the tracking of allocation sites trace map generalization environment for every instruction deoptimize every n garbage collections put a break point before deoptimizing deoptimize uncommon cases use on stack replacement trace array bounds check elimination perform array index dehoisting use load elimination use store elimination use constant folding eliminate unreachable code number of stress runs when picking a function to watch for shared function not JSFunction itself flushes the cache of optimized code for closures on every GC functions with arguments object maximum number of escape analysis fix point iterations allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms concurrent on stack replacement do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes number of stack frames inspected by the profiler percentage of ICs that must have type info to allow optimization extra verbose compilation tracing generate extra emit comments in code disassembly enable use of SSE3 instructions if available enable use of CMOV instruction if available enable use of VFP3 instructions if available enable use of NEON instructions if enable use of SDIV and UDIV 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 expose natives in global object expose freeBuffer extension expose gc extension under the specified name expose externalize string extension number of stack frames to capture disable builtin natives files print name of functions for which code is generated use random jit cookie to mask large constants trace lazy optimization use adaptive optimizations always try to OSR functions trace optimize function deoptimization minimum length for automatic enable preparsing maximum number of optimization attempts before giving up cache prototype transitions trace debugging JSON request response trace out of bounds accesses to external arrays trace_js_array_abuse automatically set the debug break flag when debugger commands are in the queue abort by crashing maximum length of function source code printed in a stack trace max size of the new max size of the old max size of executable memory(in Mbytes)") DEFINE_bool(gc_global
static bool UncommitRegion(void *base, size_t size)
virtual ~PosixMemoryMappedFile()
static size_t AllocateAlignment()
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric enable harmony string enable harmony math functions harmony_scoping harmony_symbols harmony_collections harmony_iteration harmony_strings harmony_scoping harmony_maths tracks arrays with only smi values Optimize object Array DOM strings and string pretenure call new trace pretenuring decisions of HAllocate instructions track fields with only smi values track fields with heap values track_fields track_fields Enables optimizations which favor memory size over execution speed use string slices optimization filter maximum number of GVN fix point iterations use function inlining use allocation folding eliminate write barriers targeting allocations in optimized code maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining crankshaft harvests type feedback from stub cache trace check elimination phase hydrogen tracing filter trace hydrogen to given file name trace inlining decisions trace store elimination trace all use positions trace global value numbering trace hydrogen escape analysis trace the tracking of allocation sites trace map generalization environment for every instruction deoptimize every n garbage collections put a break point before deoptimizing deoptimize uncommon cases use on stack replacement trace array bounds check elimination perform array index dehoisting use load elimination use store elimination use constant folding eliminate unreachable code number of stress runs when picking a function to watch for shared function not JSFunction itself flushes the cache of optimized code for closures on every GC functions with arguments object maximum number of escape analysis fix point iterations allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms concurrent on stack replacement do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes number of stack frames inspected by the profiler percentage of ICs that must have type info to allow optimization extra verbose compilation tracing generate extra emit comments in code disassembly enable use of SSE3 instructions if available enable use of CMOV instruction if available enable use of VFP3 instructions if available enable use of NEON instructions if enable use of SDIV and UDIV 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 expose natives in global object expose freeBuffer extension expose gc extension under the specified name expose externalize string extension number of stack frames to capture disable builtin natives files print name of functions for which code is generated use random jit cookie to mask large constants trace lazy optimization use adaptive optimizations always try to OSR functions trace optimize function deoptimization minimum length for automatic enable preparsing maximum number of optimization attempts before giving up cache prototype transitions trace debugging JSON request response trace out of bounds accesses to external arrays trace_js_array_abuse automatically set the debug break flag when debugger commands are in the queue abort by crashing maximum length of function source code printed in a stack trace max size of the new max size of the old max size of executable always perform global GCs print one trace line following each garbage collection do not print trace line after scavenger collection print statistics of the maximum memory committed for the heap in name
static intptr_t CommitPageSize()
static double LocalTimeOffset(TimezoneCache *cache)
bool Uncommit(void *address, size_t size)