34 #include <sys/prctl.h>
36 #include <sys/resource.h>
37 #include <sys/syscall.h>
38 #include <sys/types.h>
44 #include <sys/types.h>
55 #if defined(__ANDROID__) && !defined(__BIONIC_HAVE_UCONTEXT_T) && \
56 (defined(__arm__) || defined(__aarch64__)) && \
57 !defined(__BIONIC_HAVE_STRUCT_SIGCONTEXT)
58 #include <asm/sigcontext.h>
61 #if defined(LEAK_SANITIZER)
62 #include <sanitizer/lsan_interface.h>
89 #define GCC_VERSION (__GNUC__ * 10000 \
90 + __GNUC_MINOR__ * 100 \
91 + __GNUC_PATCHLEVEL__)
92 #if GCC_VERSION >= 40600
93 #if defined(__ARM_PCS_VFP)
99 #elif GCC_VERSION < 40500
103 #if defined(__ARM_PCS_VFP)
105 #elif defined(__ARM_PCS) || defined(__SOFTFP__) || defined(__SOFTFP) || \
109 #error "Your version of GCC does not report the FP ABI compiled for." \
110 "Please report it on this issue" \
111 "http://code.google.com/p/v8/issues/detail?id=2140"
118 #endif // def __arm__
123 time_t tv =
static_cast<time_t
>(std::floor(time/msPerSecond));
124 struct tm* t = localtime(&tv);
125 if (
NULL == t)
return "";
131 time_t tv = time(
NULL);
132 struct tm* t = localtime(&tv);
134 return static_cast<double>(t->tm_gmtoff * msPerSecond -
135 (t->tm_isdst > 0 ? 3600 * msPerSecond : 0));
141 bool is_executable) {
143 int prot = PROT_READ | PROT_WRITE | (is_executable ? PROT_EXEC : 0);
145 void* mbase = mmap(addr, msize, prot, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
146 if (mbase == MAP_FAILED) {
147 LOG(i::Isolate::Current(),
148 StringEvent(
"OS::Allocate",
"mmap failed"));
156 class PosixMemoryMappedFile :
public OS::MemoryMappedFile {
159 : file_(file), memory_(memory), size_(size) { }
161 virtual void*
memory() {
return memory_; }
162 virtual int size() {
return size_; }
171 FILE* file = fopen(name,
"r+");
174 fseek(file, 0, SEEK_END);
175 int size = ftell(file);
180 PROT_READ | PROT_WRITE,
184 return new PosixMemoryMappedFile(file, memory, size);
190 FILE* file = fopen(name,
"w+");
192 int result = fwrite(initial, size, 1, file);
200 PROT_READ | PROT_WRITE,
204 return new PosixMemoryMappedFile(file, memory, size);
209 if (memory_)
OS::Free(memory_, size_);
218 FILE*
fp = fopen(
"/proc/self/maps",
"r");
219 if (fp ==
NULL)
return;
222 const int kLibNameLen = FILENAME_MAX + 1;
223 char* lib_name =
reinterpret_cast<char*
>(malloc(kLibNameLen));
227 uintptr_t start, end;
228 char attr_r, attr_w, attr_x, attr_p;
231 if (fscanf(fp,
" %c%c%c%c", &attr_r, &attr_w, &attr_x, &attr_p) != 4)
break;
234 if (attr_r ==
'r' && attr_w !=
'w' && attr_x ==
'x') {
239 }
while ((c != EOF) && (c !=
'\n') && (c !=
'/') && (c !=
'['));
243 if ((c ==
'/') || (c ==
'[')) {
248 if (fgets(lib_name, kLibNameLen, fp) ==
NULL)
break;
253 lib_name[strlen(lib_name) - 1] =
'\0';
256 snprintf(lib_name, kLibNameLen,
257 "%08" V8PRIxPTR
"-%08" V8PRIxPTR, start, end);
259 LOG(isolate, SharedLibraryEvent(lib_name, start, end));
265 }
while ((c != EOF) && (c !=
'\n'));
283 int size = sysconf(_SC_PAGESIZE);
284 FILE* f = fopen(FLAG_gc_fake_mmap,
"w+");
291 #
if defined(__native_client__)
296 PROT_READ | PROT_EXEC,
301 ASSERT(addr != MAP_FAILED);
308 static const int kMmapFd = -1;
309 static const int kMmapFdOffset = 0;
316 : address_(ReserveRegion(size)), size_(size) { }
320 : address_(
NULL), size_(0) {
322 size_t request_size =
RoundUp(size + alignment,
327 MAP_PRIVATE | MAP_ANONYMOUS | MAP_NORESERVE,
330 if (reservation == MAP_FAILED)
return;
337 if (aligned_base != base) {
338 size_t prefix_size =
static_cast<size_t>(aligned_base - base);
340 request_size -= prefix_size;
346 if (aligned_size != request_size) {
347 size_t suffix_size = request_size - aligned_size;
348 OS::Free(aligned_base + aligned_size, suffix_size);
349 request_size -= suffix_size;
352 ASSERT(aligned_size == request_size);
354 address_ =
static_cast<void*
>(aligned_base);
355 size_ = aligned_size;
356 #if defined(LEAK_SANITIZER)
357 __lsan_register_root_region(address_, size_);
372 return address_ !=
NULL;
402 MAP_PRIVATE | MAP_ANONYMOUS | MAP_NORESERVE,
406 if (result == MAP_FAILED)
return NULL;
408 #if defined(LEAK_SANITIZER)
409 __lsan_register_root_region(result, size);
416 #if defined(__native_client__)
419 int prot = PROT_READ | PROT_WRITE;
421 int prot = PROT_READ | PROT_WRITE | (is_executable ? PROT_EXEC : 0);
423 if (MAP_FAILED == mmap(base,
426 MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED,
440 MAP_PRIVATE | MAP_ANONYMOUS | MAP_NORESERVE | MAP_FIXED,
442 kMmapFdOffset) != MAP_FAILED;
447 #if defined(LEAK_SANITIZER)
448 __lsan_unregister_root_region(base, size);
450 return munmap(base, size) == 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 Free(void *address, const size_t size)
static void LogSharedLibraryAddresses(Isolate *isolate)
#define LOG(isolate, Call)
static bool ArmUsingHardFloat()
static void SignalCodeMovingGC()
static void * GetRandomMmapAddr()
static void * ReserveRegion(size_t size)
PosixMemoryMappedFile(FILE *file, void *memory, int size)
#define ASSERT(condition)
static MemoryMappedFile * open(const char *name)
static bool HasLazyCommits()
virtual void * memory()=0
bool Guard(void *address)
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)
static void Guard(void *address, const size_t size)
T RoundUp(T x, intptr_t m)
#define ASSERT_LE(v1, v2)
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)
static void PrintError(const char *format,...)
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)