44 #ifndef V8_PLATFORM_H_
45 #define V8_PLATFORM_H_
72 int strncasecmp(
const char*
s1,
const char*
s2,
int n);
76 inline int lrint(
double flt) {
78 #if V8_TARGET_ARCH_IA32
84 intgr =
static_cast<int>(flt + 0.5);
85 if ((intgr & 1) != 0 && intgr - flt == 0.5) {
92 #endif // _MSC_VER < 1800
94 #endif // V8_LIBC_MSVCRT
99 double modulo(
double x,
double y);
111 #ifndef V8_NO_FAST_TLS
113 #if defined(_MSC_VER) && V8_HOST_ARCH_IA32
115 #define V8_FAST_TLS_SUPPORTED 1
117 INLINE(intptr_t InternalGetExistingThreadLocal(intptr_t index));
119 inline intptr_t InternalGetExistingThreadLocal(intptr_t index) {
120 const intptr_t kTibInlineTlsOffset = 0xE10;
121 const intptr_t kTibExtraTlsOffset = 0xF94;
122 const intptr_t kMaxInlineSlots = 64;
123 const intptr_t kMaxSlots = kMaxInlineSlots + 1024;
124 ASSERT(0 <= index && index < kMaxSlots);
125 if (index < kMaxInlineSlots) {
126 return static_cast<intptr_t
>(__readfsdword(kTibInlineTlsOffset +
129 intptr_t extra =
static_cast<intptr_t
>(__readfsdword(kTibExtraTlsOffset));
131 return *
reinterpret_cast<intptr_t*
>(extra +
135 #elif defined(__APPLE__) && (V8_HOST_ARCH_IA32 || V8_HOST_ARCH_X64)
137 #define V8_FAST_TLS_SUPPORTED 1
139 extern intptr_t kMacTlsBaseOffset;
141 INLINE(intptr_t InternalGetExistingThreadLocal(intptr_t index));
143 inline intptr_t InternalGetExistingThreadLocal(intptr_t index) {
145 #if V8_HOST_ARCH_IA32
146 asm(
"movl %%gs:(%1,%2,4), %0;"
148 :
"r"(kMacTlsBaseOffset),
"r"(index));
150 asm(
"movq %%gs:(%1,%2,8), %0;"
152 :
"r"(kMacTlsBaseOffset),
"r"(index));
159 #endif // V8_NO_FAST_TLS
182 static int GetUserTime(uint32_t* secs, uint32_t* usecs);
206 static FILE*
FOpen(
const char* path,
const char*
mode);
207 static bool Remove(
const char* path);
218 static void Print(
const char* format, ...);
219 static void VPrint(
const char* format, va_list args);
222 static void FPrint(FILE* out,
const char* format, ...);
223 static void VFPrint(FILE* out,
const char* format, va_list args);
228 static void PrintError(
const char* format, ...);
229 static void VPrintError(
const char* format, va_list args);
234 static void*
Allocate(
const size_t requested,
237 static void Free(
void* address,
const size_t size);
247 static void Guard(
void* address,
const size_t size);
256 static void Sleep(
const int milliseconds);
278 virtual void*
memory() = 0;
279 virtual int size() = 0;
289 static char*
StrChr(
char* str,
int c);
328 #if defined(V8_TARGET_ARCH_IA32)
334 static void MemMove(
void* dest,
const void* src,
size_t size);
335 typedef void (*MemMoveFunction)(
void* dest,
const void* src,
size_t size);
339 static void MemCopy(
void* dest,
const void* src,
size_t size) {
342 #elif defined(V8_HOST_ARCH_ARM)
343 typedef void (*MemCopyUint8Function)(uint8_t* dest,
346 static MemCopyUint8Function memcopy_uint8_function;
347 static void MemCopyUint8Wrapper(uint8_t* dest,
350 memcpy(dest, src, chars);
354 static void MemCopy(
void* dest,
const void* src,
size_t size) {
355 (*memcopy_uint8_function)(
reinterpret_cast<uint8_t*
>(dest),
356 reinterpret_cast<const uint8_t*>(src),
359 static void MemMove(
void* dest,
const void* src,
size_t size) {
360 memmove(dest, src, size);
363 typedef void (*MemCopyUint16Uint8Function)(
uint16_t* dest,
366 static MemCopyUint16Uint8Function memcopy_uint16_uint8_function;
367 static void MemCopyUint16Uint8Wrapper(
uint16_t* dest,
371 static const int kMinComplexConvertMemCopy = 12;
372 static void MemCopyUint16Uint8(
uint16_t* dest,
375 (*memcopy_uint16_uint8_function)(dest, src,
size);
377 #elif defined(V8_HOST_ARCH_MIPS)
378 typedef void (*MemCopyUint8Function)(uint8_t* dest,
381 static MemCopyUint8Function memcopy_uint8_function;
382 static void MemCopyUint8Wrapper(uint8_t* dest,
385 memcpy(dest, src, chars);
389 static void MemCopy(
void* dest,
const void* src,
size_t size) {
390 (*memcopy_uint8_function)(
reinterpret_cast<uint8_t*
>(dest),
391 reinterpret_cast<const uint8_t*>(src),
394 static void MemMove(
void* dest,
const void* src,
size_t size) {
395 memmove(dest, src, size);
400 memcpy(dest, src, size);
403 memmove(dest, src, size);
406 #endif // V8_TARGET_ARCH_IA32
411 static const int msPerSecond = 1000;
413 DISALLOW_IMPLICIT_CONSTRUCTORS(
OS);
456 size_t size() {
return size_; }
483 address_ = from->address_;
490 static bool CommitRegion(
void* base,
size_t size,
bool is_executable);
530 Options() : name_(
"v8:<unknown>"), stack_size_(0) {}
534 const char*
name()
const {
return name_; }
543 explicit Thread(
const Options& options);
551 start_semaphore_ =
new Semaphore(0);
553 start_semaphore_->Wait();
554 delete start_semaphore_;
555 start_semaphore_ =
NULL;
561 inline const char*
name()
const {
566 virtual void Run() = 0;
573 return static_cast<int>(
reinterpret_cast<intptr_t
>(
GetThreadLocal(key)));
577 SetThreadLocal(key, reinterpret_cast<void*>(static_cast<intptr_t>(value)));
583 #ifdef V8_FAST_TLS_SUPPORTED
585 void* result =
reinterpret_cast<void*
>(
586 InternalGetExistingThreadLocal(static_cast<intptr_t>(key)));
608 if (start_semaphore_) start_semaphore_->Signal();
613 void set_name(
const char*
name);
619 Semaphore* start_semaphore_;
626 #endif // V8_PLATFORM_H_
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 * GetThreadLocal(LocalStorageKey key)
static bool HasThreadLocal(LocalStorageKey key)
static void Free(void *address, const size_t size)
Thread(const Options &options)
static int VSNPrintF(Vector< char > str, const char *format, va_list args)
static void LogSharedLibraryAddresses(Isolate *isolate)
static FILE * OpenTemporaryFile()
static bool ArmUsingHardFloat()
static void SignalCodeMovingGC()
static void * GetRandomMmapAddr()
static double DaylightSavingsOffset(double time, TimezoneCache *cache)
static void * ReserveRegion(size_t size)
double fast_sqrt(double input)
void TakeControl(VirtualMemory *from)
static const int kStackWalkError
static int GetUserTime(uint32_t *secs, uint32_t *usecs)
static void ClearTimezoneCache(TimezoneCache *cache)
static const int kStackWalkMaxTextLen
#define ASSERT(condition)
static void VFPrint(FILE *out, const char *format, va_list args)
static int GetThreadLocalInt(LocalStorageKey key)
static MemoryMappedFile * open(const char *name)
static const int kMinComplexMemCopy
static bool HasLazyCommits()
double fast_exp(double input)
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 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 mode(MIPS only)") DEFINE_string(expose_natives_as
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
static void MemCopy(void *dest, const void *src, size_t size)
static void ProtectCode(void *address, const size_t size)
void lazily_initialize_fast_exp()
static LocalStorageKey CreateThreadLocalKey()
static FILE * FOpen(const char *path, const char *mode)
static MemoryMappedFile * create(const char *name, int size, void *initial)
bool Commit(void *address, size_t size, bool is_executable)
static void * GetExistingThreadLocal(LocalStorageKey key)
static void VPrint(const char *format, va_list args)
#define DISALLOW_COPY_AND_ASSIGN(TypeName)
static void MemMove(void *dest, const void *src, size_t size)
static void Guard(void *address, const size_t size)
static void VPrintError(const char *format, va_list args)
double modulo(double x, double y)
static int GetCurrentProcessId()
static double TimeCurrentMillis()
void NotifyStartedAndRun()
static void DeleteThreadLocalKey(LocalStorageKey key)
static void Sleep(const int milliseconds)
void StartSynchronously()
static const char * LocalTimezone(double time, TimezoneCache *cache)
static void Print(const char *format,...)
static int SNPrintF(Vector< char > str, const char *format,...)
static const int kMaxThreadNameLength
static const int kStackWalkMaxNameLen
static void DisposeTimezoneCache(TimezoneCache *cache)
static bool ReleaseRegion(void *base, size_t size)
static bool CommitRegion(void *base, size_t size, bool is_executable)
static double nan_value()
INLINE(static HeapObject *EnsureDoubleAligned(Heap *heap, HeapObject *object, int size))
static void SetThreadLocal(LocalStorageKey key, void *value)
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)
Options(const char *name, int stack_size=0)
char text[kStackWalkMaxTextLen]
virtual ~MemoryMappedFile()
static void StrNCpy(Vector< char > dest, const char *src, size_t n)
static int ActivationFrameAlignment()
const char * name() const
static size_t AllocateAlignment()
static TimezoneCache * CreateTimezoneCache()
static uint64_t CpuFeaturesImpliedByPlatform()
static bool Remove(const char *path)
static int GetLastError()
static intptr_t MaxVirtualMemory()
static void FPrint(FILE *out, const char *format,...)
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 const char *const LogFileOpenMode
static void SetThreadLocalInt(LocalStorageKey key, int value)
static double LocalTimeOffset(TimezoneCache *cache)
static char * StrChr(char *str, int c)
bool Uncommit(void *address, size_t size)
const char * name() const
static uint64_t TotalPhysicalMemory()