44 #ifndef V8_PLATFORM_H_
45 #define V8_PLATFORM_H_
59 #define __GNUC_VERSION__ (__GNUC__ * 10000 + __GNUC_MINOR__ * 100)
72 int strncasecmp(
const char*
s1,
const char*
s2,
int n);
74 inline int lrint(
double flt) {
76 #if defined(V8_TARGET_ARCH_IA32)
82 intgr =
static_cast<int>(flt + 0.5);
83 if ((intgr & 1) != 0 && intgr - flt == 0.5) {
110 #if defined(__OpenBSD__) && defined(__i386__)
120 double modulo(
double x,
double y);
155 static int GetUserTime(uint32_t* secs, uint32_t* usecs);
159 static int64_t
Ticks();
179 static FILE*
FOpen(
const char* path,
const char* mode);
180 static bool Remove(
const char* path);
191 static void Print(
const char* format, ...);
192 static void VPrint(
const char* format, va_list args);
195 static void FPrint(FILE* out,
const char* format, ...);
196 static void VFPrint(FILE* out,
const char* format, va_list args);
201 static void PrintError(
const char* format, ...);
202 static void VPrintError(
const char* format, va_list args);
207 static void*
Allocate(
const size_t requested,
210 static void Free(
void* address,
const size_t size);
217 static void ProtectCode(
void* address,
const size_t size);
220 static void Guard(
void* address,
const size_t size);
236 static void Sleep(
const int milliseconds);
272 virtual void*
memory() = 0;
273 virtual int size() = 0;
283 static char*
StrChr(
char* str,
int c);
330 #if defined(V8_TARGET_ARCH_IA32)
332 static void MemCopy(
void* dest,
const void* src,
size_t size);
336 typedef void (*MemCopyFunction)(
void* dest,
const void* src,
size_t size);
338 #else // V8_TARGET_ARCH_IA32
339 static void MemCopy(
void* dest,
const void* src,
size_t size) {
340 memcpy(dest, src, size);
343 #endif // V8_TARGET_ARCH_IA32
348 static const int msPerSecond = 1000;
350 DISALLOW_IMPLICIT_CONSTRUCTORS(
OS);
393 size_t size() {
return size_; }
420 address_ = from->address_;
427 static bool CommitRegion(
void* base,
size_t size,
bool is_executable);
462 Options() : name_(
"v8:<unknown>"), stack_size_(0) {}
466 const char*
name()
const {
return name_; }
475 explicit Thread(
const Options& options);
484 inline const char*
name()
const {
489 virtual void Run() = 0;
496 return static_cast<int>(
reinterpret_cast<intptr_t
>(
GetThreadLocal(key)));
500 SetThreadLocal(key, reinterpret_cast<void*>(static_cast<intptr_t>(value)));
506 #ifdef V8_FAST_TLS_SUPPORTED
508 void* result =
reinterpret_cast<void*
>(
509 InternalGetExistingThreadLocal(static_cast<intptr_t>(key)));
531 void set_name(
const char*
name);
556 virtual int Lock() = 0;
582 typedef LazyDynamicInstance<
585 #define LAZY_MUTEX_INITIALIZER LAZY_DYNAMIC_INSTANCE_INITIALIZER
623 virtual void Wait() = 0;
629 virtual bool Wait(
int timeout) = 0;
632 virtual void Signal() = 0;
635 template <
int InitialValue>
651 template <
int InitialValue>
658 #define LAZY_SEMAPHORE_INITIALIZER LAZY_DYNAMIC_INSTANCE_INITIALIZER
670 virtual bool Bind(
const int port) = 0;
671 virtual bool Listen(
int backlog)
const = 0;
675 virtual bool Connect(
const char* host,
const char* port) = 0;
684 virtual int Send(
const char* data,
int len)
const = 0;
685 virtual int Receive(
char* data,
int len)
const = 0;
690 virtual bool IsValid()
const = 0;
696 static uint32_t
HToN(uint32_t value);
697 static uint32_t
NToH(uint32_t value);
779 void IncSamplesTaken() {
if (++samples_taken_ < 0) samples_taken_ = 0; }
793 #endif // V8_PLATFORM_H_
double fast_tan(double x)
Address external_callback
static void * GetThreadLocal(LocalStorageKey key)
static Semaphore * Create()
static bool HasThreadLocal(LocalStorageKey key)
static void Free(void *address, const size_t size)
Thread(const Options &options)
PlatformData * platform_data()
static int VSNPrintF(Vector< char > str, const char *format, va_list args)
virtual void DoSampleStack(TickSample *sample)=0
static FILE * OpenTemporaryFile()
static void SignalCodeMovingGC()
static void * GetRandomMmapAddr()
virtual bool SetReuseAddress(bool reuse_address)=0
virtual bool Listen(int backlog) const =0
static void * ReserveRegion(size_t size)
virtual bool Shutdown()=0
static bool IsOutsideAllocatedSpace(void *pointer)
static const char * LocalTimezone(double time)
double fast_sqrt(double input)
void TakeControl(VirtualMemory *from)
void DecreaseProfilingDepth()
static const int kStackWalkError
static int GetUserTime(uint32_t *secs, uint32_t *usecs)
static const int kStackWalkMaxTextLen
virtual int Receive(char *data, int len) const =0
#define ASSERT(condition)
static void VFPrint(FILE *out, const char *format, va_list args)
double fast_sin(double x)
Address stack[kMaxFramesCount]
static int GetThreadLocalInt(LocalStorageKey key)
static MemoryMappedFile * open(const char *name)
virtual int Send(const char *data, int len) const =0
void NoBarrier_Store(volatile Atomic32 *ptr, Atomic32 value)
static const int kMinComplexMemCopy
virtual void * memory()=0
bool Guard(void *address)
void IncreaseProfilingDepth()
static void ReleaseStore(volatile AtomicWord *ptr, AtomicWord value)
static void MemCopy(void *dest, const void *src, size_t size)
static void ProtectCode(void *address, const size_t size)
static LocalStorageKey CreateThreadLocalKey()
static FILE * FOpen(const char *path, const char *mode)
static MemoryMappedFile * create(const char *name, int size, void *initial)
#define DISALLOW_IMPLICIT_CONSTRUCTORS(TypeName)
double fast_log(double x)
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 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 bool ArmCpuHasFeature(CpuFeature feature)
static uint16_t NToH(uint16_t value)
static Mutex * CreateMutex()
static double TimeCurrentMillis()
int samples_taken() const
Atomic32 NoBarrier_AtomicIncrement(volatile Atomic32 *ptr, Atomic32 increment)
virtual Socket * Accept() const =0
static CpuImplementer GetCpuImplementer()
LazyDynamicInstance< Semaphore, CreateSemaphoreTrait< InitialValue >, ThreadSafeInitOnceTrait >::type type
virtual bool Connect(const char *host, const char *port)=0
static uint16_t HToN(uint16_t value)
static bool MipsCpuHasFeature(CpuFeature feature)
activate correct semantics for inheriting readonliness false
static void DeleteThreadLocalKey(LocalStorageKey key)
static void Sleep(const int milliseconds)
LazyDynamicInstance< Mutex, CreateMutexTrait, ThreadSafeInitOnceTrait >::type LazyMutex
static void Print(const char *format,...)
virtual bool IsValid() const =0
Atomic32 NoBarrier_Load(volatile const Atomic32 *ptr)
static int SNPrintF(Vector< char > str, const char *format,...)
static Semaphore * CreateSemaphore(int count)
static const int kMaxThreadNameLength
static const int kStackWalkMaxNameLen
static bool ReleaseRegion(void *base, size_t size)
static bool CommitRegion(void *base, size_t size, bool is_executable)
static double nan_value()
static const int kMaxFramesCount
static void SetThreadLocal(LocalStorageKey key, void *value)
static void * Allocate(const size_t requested, size_t *allocated, bool is_executable)
static int StackWalk(Vector< StackFrame > frames)
static void PrintError(const char *format,...)
void SampleStack(TickSample *sample)
static bool UncommitRegion(void *base, size_t size)
static void LogSharedLibraryAddresses()
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()
virtual bool Bind(const int port)=0
const char * name() const
static double DaylightSavingsOffset(double time)
static size_t AllocateAlignment()
activate correct semantics for inheriting readonliness enable harmony semantics for typeof enable harmony enable harmony proxies enable all harmony harmony_scoping harmony_proxies harmony_scoping tracks arrays with only smi values automatically unbox arrays of doubles use crankshaft use hydrogen range analysis use hydrogen global value numbering use function inlining maximum number of AST nodes considered for a single inlining loop invariant code motion print statistics for hydrogen trace generated IR for specified phases trace register allocator trace range analysis trace representation types environment for every instruction put a break point before deoptimizing polymorphic inlining perform array bounds checks elimination use dead code elimination trace on stack replacement optimize closures cache optimized code for closures functions with arguments object loop weight for representation inference allow uint32 values on optimize frames if they are used only in safe operations track parallel recompilation enable all profiler experiments number of stack frames inspected by the profiler call recompile stub directly when self optimizing trigger profiler ticks based on counting instead of timing weight back edges by jump distance for interrupt triggering percentage of ICs that must have type info to allow optimization watch_ic_patching retry_self_opt interrupt_at_exit 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 SAHF instruction if enable use of VFP3 instructions if available this implies enabling ARMv7 and VFP2 enable use of VFP2 instructions if available 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 MIPS FPU instructions if NULL
Sampler(Isolate *isolate, int interval)
static uint64_t CpuFeaturesImpliedByPlatform()
virtual void Tick(TickSample *sample)=0
static bool Remove(const char *path)
static int GetLastError()
static intptr_t MaxVirtualMemory()
static void FPrint(FILE *out, const char *format,...)
double fast_cos(double x)
static double LocalTimeOffset()
static bool ArmUsingHardFloat()
static intptr_t CommitPageSize()
static const char *const LogFileOpenMode
static void SetThreadLocalInt(LocalStorageKey key, int value)
bool has_external_callback
static char * StrChr(char *str, int c)
static Socket * CreateSocket()
bool Uncommit(void *address, size_t size)
const char * name() const