12 #include <sys/resource.h>
14 #include <sys/types.h>
25 #include <sys/types.h>
30 #if defined(__ANDROID__) && !defined(__BIONIC_HAVE_UCONTEXT_T) && \
31 (defined(__arm__) || defined(__aarch64__)) && \
32 !defined(__BIONIC_HAVE_STRUCT_SIGCONTEXT)
33 #include <asm/sigcontext.h>
36 #if defined(LEAK_SANITIZER)
37 #include <sanitizer/lsan_interface.h>
48 #if !defined(MAP_NORESERVE)
50 #define MAP_NORESERVE 0
53 #include <sys/prctl.h>
54 #include <sys/syscall.h>
72 #define GCC_VERSION (__GNUC__ * 10000 \
73 + __GNUC_MINOR__ * 100 \
74 + __GNUC_PATCHLEVEL__)
75 #if GCC_VERSION >= 40600
76 #if defined(__ARM_PCS_VFP)
82 #elif GCC_VERSION < 40500
86 #if defined(__ARM_PCS_VFP)
88 #elif defined(__ARM_PCS) || defined(__SOFTFP__) || defined(__SOFTFP) || \
92 #error "Your version of GCC does not report the FP ABI compiled for." \
93 "Please report it on this issue" \
94 "http://code.google.com/p/v8/issues/detail?id=2140"
109 if (std::isnan(time))
return "";
110 time_t tv =
static_cast<time_t
>(std::floor(time/
msPerSecond));
111 struct tm* t = localtime(&tv);
112 if (
NULL == t)
return "";
123 time_t tv = time(
NULL);
124 struct tm* t = localtime(&tv);
126 return static_cast<double>(t->tm_gmtoff *
msPerSecond -
134 bool is_executable) {
136 int prot = PROT_READ | PROT_WRITE | (is_executable ? PROT_EXEC : 0);
138 void* mbase = mmap(addr, msize, prot, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
139 if (mbase == MAP_FAILED)
return NULL;
145 class PosixMemoryMappedFile :
public OS::MemoryMappedFile {
163 fseek(
file, 0, SEEK_END);
169 PROT_READ | PROT_WRITE,
181 int result = fwrite(initial,
size, 1,
file);
189 PROT_READ | PROT_WRITE,
193 return new PosixMemoryMappedFile(
file, memory,
size);
198 if (memory_)
OS::Free(memory_, size_);
204 std::vector<SharedLibraryAddress> result;
208 FILE*
fp = fopen(
"/proc/self/maps",
"r");
209 if (
fp ==
NULL)
return result;
212 const int kLibNameLen = FILENAME_MAX + 1;
213 char* lib_name =
reinterpret_cast<char*
>(malloc(kLibNameLen));
218 char attr_r, attr_w, attr_x, attr_p;
221 if (fscanf(
fp,
" %c%c%c%c", &attr_r, &attr_w, &attr_x, &attr_p) != 4)
break;
224 if (attr_r ==
'r' && attr_w !=
'w' && attr_x ==
'x') {
229 }
while ((c != EOF) && (c !=
'\n') && (c !=
'/') && (c !=
'['));
233 if ((c ==
'/') || (c ==
'[')) {
238 if (fgets(lib_name, kLibNameLen,
fp) ==
NULL)
break;
243 lib_name[strlen(lib_name) - 1] =
'\0';
246 snprintf(lib_name, kLibNameLen,
249 result.push_back(SharedLibraryAddress(lib_name, start, end));
255 }
while ((c != EOF) && (c !=
'\n'));
274 int size = sysconf(_SC_PAGESIZE);
275 FILE* f = fopen(OS::GetGCFakeMMapFile(),
"w+");
286 PROT_READ | PROT_EXEC,
288 MAP_PRIVATE, fileno(f), 0);
289 DCHECK(addr != MAP_FAILED);
303 VirtualMemory::VirtualMemory(
size_t size)
304 : address_(ReserveRegion(
size)), size_(
size) { }
307 VirtualMemory::VirtualMemory(
size_t size,
size_t alignment)
308 : address_(
NULL), size_(0) {
315 MAP_PRIVATE | MAP_ANONYMOUS | MAP_NORESERVE,
318 if (reservation == MAP_FAILED)
return;
320 uint8_t* base =
static_cast<uint8_t*
>(reservation);
321 uint8_t* aligned_base =
RoundUp(base, alignment);
325 if (aligned_base != base) {
326 size_t prefix_size =
static_cast<size_t>(aligned_base - base);
328 request_size -= prefix_size;
334 if (aligned_size != request_size) {
335 size_t suffix_size = request_size - aligned_size;
336 OS::Free(aligned_base + aligned_size, suffix_size);
337 request_size -= suffix_size;
340 DCHECK(aligned_size == request_size);
342 address_ =
static_cast<void*
>(aligned_base);
343 size_ = aligned_size;
344 #if defined(LEAK_SANITIZER)
345 __lsan_register_root_region(address_, size_);
350 VirtualMemory::~VirtualMemory() {
352 bool result = ReleaseRegion(address(),
size());
359 bool VirtualMemory::IsReserved() {
360 return address_ !=
NULL;
364 void VirtualMemory::Reset() {
370 bool VirtualMemory::Commit(
void* address,
size_t size,
bool is_executable) {
371 return CommitRegion(address,
size, is_executable);
375 bool VirtualMemory::Uncommit(
void* address,
size_t size) {
376 return UncommitRegion(address,
size);
380 bool VirtualMemory::Guard(
void* address) {
381 OS::Guard(address, OS::CommitPageSize());
386 void* VirtualMemory::ReserveRegion(
size_t size) {
387 void* result = mmap(OS::GetRandomMmapAddr(),
390 MAP_PRIVATE | MAP_ANONYMOUS | MAP_NORESERVE,
394 if (result == MAP_FAILED)
return NULL;
396 #if defined(LEAK_SANITIZER)
397 __lsan_register_root_region(result,
size);
403 bool VirtualMemory::CommitRegion(
void* base,
size_t size,
bool is_executable) {
407 int prot = PROT_READ | PROT_WRITE;
409 int prot = PROT_READ | PROT_WRITE | (is_executable ? PROT_EXEC : 0);
411 if (MAP_FAILED == mmap(base,
414 MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED,
424 bool VirtualMemory::UncommitRegion(
void* base,
size_t size) {
428 MAP_PRIVATE | MAP_ANONYMOUS | MAP_NORESERVE | MAP_FIXED,
434 bool VirtualMemory::ReleaseRegion(
void* base,
size_t size) {
435 #if defined(LEAK_SANITIZER)
436 __lsan_unregister_root_region(base,
size);
438 return munmap(base,
size) == 0;
442 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 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.