V8 Project
v8::base::OS Class Reference

#include <platform.h>

+ Collaboration diagram for v8::base::OS:

Classes

class  MemoryMappedFile
 
struct  SharedLibraryAddress
 
struct  StackFrame
 

Static Public Member Functions

static void Initialize (int64_t random_seed, bool hard_abort, const char *const gc_fake_mmap)
 
static int GetUserTime (uint32_t *secs, uint32_t *usecs)
 
static double TimeCurrentMillis ()
 
static TimezoneCacheCreateTimezoneCache ()
 
static void DisposeTimezoneCache (TimezoneCache *cache)
 
static void ClearTimezoneCache (TimezoneCache *cache)
 
static const char * LocalTimezone (double time, TimezoneCache *cache)
 
static double LocalTimeOffset (TimezoneCache *cache)
 
static double DaylightSavingsOffset (double time, TimezoneCache *cache)
 
static int GetLastError ()
 
static FILE * FOpen (const char *path, const char *mode)
 
static bool Remove (const char *path)
 
static FILE * OpenTemporaryFile ()
 
static void Print (const char *format,...)
 
static void VPrint (const char *format, va_list args)
 
static void FPrint (FILE *out, const char *format,...)
 
static void VFPrint (FILE *out, const char *format, va_list args)
 
static void PrintError (const char *format,...)
 
static void VPrintError (const char *format, va_list args)
 
static void * Allocate (const size_t requested, size_t *allocated, bool is_executable)
 
static void Free (void *address, const size_t size)
 
static intptr_t CommitPageSize ()
 
static void ProtectCode (void *address, const size_t size)
 
static void Guard (void *address, const size_t size)
 
static void * GetRandomMmapAddr ()
 
static size_t AllocateAlignment ()
 
static void Sleep (const int milliseconds)
 
static void Abort ()
 
static void DebugBreak ()
 
static int SNPrintF (char *str, int length, const char *format,...)
 
static int VSNPrintF (char *str, int length, const char *format, va_list args)
 
static char * StrChr (char *str, int c)
 
static void StrNCpy (char *dest, int length, const char *src, size_t n)
 
static std::vector< SharedLibraryAddressGetSharedLibraryAddresses ()
 
static void SignalCodeMovingGC ()
 
static double nan_value ()
 
static bool ArmUsingHardFloat ()
 
static int ActivationFrameAlignment ()
 
static int GetCurrentProcessId ()
 
static int GetCurrentThreadId ()
 

Static Public Attributes

static const char *const LogFileOpenMode = "w"
 
static const int kStackWalkError = -1
 
static const int kStackWalkMaxNameLen = 256
 
static const int kStackWalkMaxTextLen = 256
 

Private Member Functions

 DISALLOW_IMPLICIT_CONSTRUCTORS (OS)
 

Static Private Attributes

static const int msPerSecond = 1000
 

Detailed Description

Definition at line 142 of file platform.h.

Member Function Documentation

◆ Abort()

void v8::base::OS::Abort ( )
static

Definition at line 209 of file platform-posix.cc.

209  {
210  if (g_hard_abort) {
212  }
213  // Redirect to std abort to signal abnormal program termination.
214  abort();
215 }
#define V8_IMMEDIATE_CRASH()
Definition: macros.h:287

References v8::base::anonymous_namespace{platform-posix.cc}::g_hard_abort, and V8_IMMEDIATE_CRASH.

Referenced by v8::internal::Isolate::DoThrow(), v8::Utils::ReportApiFailure(), v8::internal::RUNTIME_FUNCTION(), v8::internal::Isolate::StackTraceString(), and V8_Fatal().

+ Here is the caller graph for this function:

◆ ActivationFrameAlignment()

int v8::base::OS::ActivationFrameAlignment ( )
static

Definition at line 76 of file platform-posix.cc.

76  {
77 #if V8_TARGET_ARCH_ARM
78  // On EABI ARM targets this is required for fp correctness in the
79  // runtime system.
80  return 8;
81 #elif V8_TARGET_ARCH_MIPS
82  return 8;
83 #else
84  // Otherwise we just assume 16 byte alignment, i.e.:
85  // - With gcc 4.4 the tree vectorization optimizer can generate code
86  // that requires 16 byte alignment such as movdqa on x86.
87  // - Mac OS X and Solaris (64-bit) activation frames must be 16 byte-aligned;
88  // see "Mac OS X ABI Function Call Guide"
89  return 16;
90 #endif
91 }

◆ Allocate()

void * v8::base::OS::Allocate ( const size_t  requested,
size_t *  allocated,
bool  is_executable 
)
static

Definition at line 50 of file platform-cygwin.cc.

52  {
53  const size_t msize = RoundUp(requested, sysconf(_SC_PAGESIZE));
54  int prot = PROT_READ | PROT_WRITE | (is_executable ? PROT_EXEC : 0);
55  void* mbase = mmap(NULL, msize, prot, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
56  if (mbase == MAP_FAILED) return NULL;
57  *allocated = msize;
58  return mbase;
59 }
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
T RoundUp(T x, intptr_t m)
Definition: macros.h:407

References NULL, and RoundUp().

+ Here is the call graph for this function:

◆ AllocateAlignment()

size_t v8::base::OS::AllocateAlignment ( )
static

Definition at line 198 of file platform-posix.cc.

198  {
199  return static_cast<size_t>(sysconf(_SC_PAGESIZE));
200 }

Referenced by v8::internal::SemiSpace::GrowTo(), v8::internal::SemiSpace::ShrinkTo(), and v8::base::VirtualMemory::VirtualMemory().

+ Here is the caller graph for this function:

◆ ArmUsingHardFloat()

static bool v8::base::OS::ArmUsingHardFloat ( )
static

Referenced by v8::internal::MacroAssembler::use_eabi_hardfloat().

+ Here is the caller graph for this function:

◆ ClearTimezoneCache()

void v8::base::OS::ClearTimezoneCache ( TimezoneCache cache)
static

Definition at line 305 of file platform-posix.cc.

305  {
306  DCHECK(cache == NULL);
307 }
#define DCHECK(condition)
Definition: logging.h:205

References DCHECK, and NULL.

Referenced by v8::internal::DateCache::ResetDateCache().

+ Here is the caller graph for this function:

◆ CommitPageSize()

intptr_t v8::base::OS::CommitPageSize ( )
static

Definition at line 94 of file platform-posix.cc.

94  {
95  static intptr_t page_size = getpagesize();
96  return page_size;
97 }

Referenced by v8::internal::MemoryAllocator::AllocateChunk(), v8::internal::AllocateCodeChunk(), v8::internal::MemoryAllocator::CodePageAreaEndOffset(), v8::internal::MemoryAllocator::CodePageGuardSize(), v8::internal::MemoryAllocator::CodePageGuardStartOffset(), v8::internal::MemoryChunk::CommitArea(), v8::internal::Deoptimizer::GetMaxDeoptTableSize(), v8::base::VirtualMemory::Guard(), and v8::internal::StoreBuffer::SetUp().

+ Here is the caller graph for this function:

◆ CreateTimezoneCache()

TimezoneCache * v8::base::OS::CreateTimezoneCache ( )
static

Definition at line 295 of file platform-posix.cc.

295  {
296  return NULL;
297 }

References NULL.

◆ DaylightSavingsOffset()

double v8::base::OS::DaylightSavingsOffset ( double  time,
TimezoneCache cache 
)
static

Definition at line 310 of file platform-posix.cc.

310  {
311  if (std::isnan(time)) return nan_value();
312  time_t tv = static_cast<time_t>(std::floor(time/msPerSecond));
313  struct tm* t = localtime(&tv);
314  if (NULL == t) return nan_value();
315  return t->tm_isdst > 0 ? 3600 * msPerSecond : 0;
316 }
static double nan_value()
static const int msPerSecond
Definition: platform.h:303

References msPerSecond, nan_value(), and NULL.

Referenced by v8::internal::DateCache::GetDaylightSavingsOffsetFromOS().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ DebugBreak()

void v8::base::OS::DebugBreak ( )
static

Definition at line 218 of file platform-posix.cc.

218  {
219 #if V8_HOST_ARCH_ARM
220  asm("bkpt 0");
221 #elif V8_HOST_ARCH_ARM64
222  asm("brk 0");
223 #elif V8_HOST_ARCH_MIPS
224  asm("break");
225 #elif V8_HOST_ARCH_MIPS64
226  asm("break");
227 #elif V8_HOST_ARCH_IA32
228 #if V8_OS_NACL
229  asm("hlt");
230 #else
231  asm("int $3");
232 #endif // V8_OS_NACL
233 #elif V8_HOST_ARCH_X64
234  asm("int $3");
235 #else
236 #error Unsupported host architecture.
237 #endif
238 }

Referenced by v8::internal::RUNTIME_FUNCTION().

+ Here is the caller graph for this function:

◆ DISALLOW_IMPLICIT_CONSTRUCTORS()

v8::base::OS::DISALLOW_IMPLICIT_CONSTRUCTORS ( OS  )
private

◆ DisposeTimezoneCache()

void v8::base::OS::DisposeTimezoneCache ( TimezoneCache cache)
static

Definition at line 300 of file platform-posix.cc.

300  {
301  DCHECK(cache == NULL);
302 }

References DCHECK, and NULL.

Referenced by v8::internal::DateCache::~DateCache().

+ Here is the caller graph for this function:

◆ FOpen()

FILE * v8::base::OS::FOpen ( const char *  path,
const char *  mode 
)
static

Definition at line 328 of file platform-posix.cc.

328  {
329  FILE* file = fopen(path, mode);
330  if (file == NULL) return NULL;
331  struct stat file_stat;
332  if (fstat(fileno(file), &file_stat) != 0) return NULL;
333  bool is_regular_file = ((file_stat.st_mode & S_IFREG) != 0);
334  if (is_regular_file) return file;
335  fclose(file);
336  return NULL;
337 }
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 mode(MIPS only)") DEFINE_BOOL(enable_always_align_csp
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

References file(), mode(), and NULL.

Referenced by v8::internal::AppendChars(), SnapshotWriter::GetFileDescriptorOrDie(), v8::internal::LowLevelLogger::LowLevelLogger(), main(), v8::internal::FINAL< kOperandKind, kNumCachedOperands >::OpenFile(), v8::internal::Log::OpenFile(), v8::internal::PerfBasicLogger::PerfBasicLogger(), v8::internal::ReadCharsFromFile(), v8::internal::compiler::Pipeline::VerifyAndPrintGraph(), and v8::internal::WriteChars().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ FPrint()

void v8::base::OS::FPrint ( FILE *  out,
const char *  format,
  ... 
)
static

Definition at line 370 of file platform-posix.cc.

370  {
371  va_list args;
372  va_start(args, format);
373  VFPrint(out, format, args);
374  va_end(args);
375 }
static void VFPrint(FILE *out, const char *format, va_list args)

References VFPrint().

Referenced by v8::internal::PerfBasicLogger::LogRecordedBuffer().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Free()

void v8::base::OS::Free ( void *  address,
const size_t  size 
)
static

Definition at line 100 of file platform-posix.cc.

100  {
101  // TODO(1240712): munmap has a return value which is ignored here.
102  int result = munmap(address, size);
103  USE(result);
104  DCHECK(result == 0);
105 }
enable harmony numeric enable harmony object literal extensions Optimize object size
void USE(T)
Definition: macros.h:322

References DCHECK, size, and USE().

+ Here is the call graph for this function:

◆ GetCurrentProcessId()

int v8::base::OS::GetCurrentProcessId ( )
static

Definition at line 250 of file platform-posix.cc.

250  {
251  return static_cast<int>(getpid());
252 }

Referenced by v8::internal::FINAL< kOperandKind, kNumCachedOperands >::CodeTracer(), v8::internal::FINAL< kOperandKind, kNumCachedOperands >::HTracer(), v8::base::LoadSymbols(), v8::internal::PerfBasicLogger::PerfBasicLogger(), v8::internal::PrepareLogFileName(), v8::internal::PrintPID(), and v8::base::TEST().

+ Here is the caller graph for this function:

◆ GetCurrentThreadId()

int v8::base::OS::GetCurrentThreadId ( )
static

Definition at line 255 of file platform-posix.cc.

255  {
256 #if defined(ANDROID)
257  return static_cast<int>(syscall(__NR_gettid));
258 #elif defined(SYS_gettid)
259  return static_cast<int>(syscall(SYS_gettid));
260 #else
261  // PNaCL doesn't have a way to get an integral thread ID, but it doesn't
262  // really matter, because we only need it in PerfJitLogger::LogRecordedBuffer.
263  return 0;
264 #endif
265 }

◆ GetLastError()

int v8::base::OS::GetLastError ( )
static

Definition at line 319 of file platform-posix.cc.

319  {
320  return errno;
321 }

Referenced by v8::base::LoadSymbols(), and v8::internal::Heap::RecordStats().

+ Here is the caller graph for this function:

◆ GetRandomMmapAddr()

void * v8::base::OS::GetRandomMmapAddr ( )
static

Definition at line 153 of file platform-posix.cc.

153  {
154 #if V8_OS_NACL
155  // TODO(bradchen): restore randomization once Native Client gets
156  // smarter about using mmap address hints.
157  // See http://code.google.com/p/nativeclient/issues/3341
158  return NULL;
159 #endif
160 #if defined(ADDRESS_SANITIZER) || defined(MEMORY_SANITIZER) || \
161  defined(THREAD_SANITIZER)
162  // Dynamic tools do not support custom mmap addresses.
163  return NULL;
164 #endif
165  uintptr_t raw_addr;
166  platform_random_number_generator.Pointer()->NextBytes(&raw_addr,
167  sizeof(raw_addr));
168 #if V8_TARGET_ARCH_X64
169  // Currently available CPUs have 48 bits of virtual addressing. Truncate
170  // the hint address to 46 bits to give the kernel a fighting chance of
171  // fulfilling our placement request.
172  raw_addr &= V8_UINT64_C(0x3ffffffff000);
173 #else
174  raw_addr &= 0x3ffff000;
175 
176 # ifdef __sun
177  // For our Solaris/illumos mmap hint, we pick a random address in the bottom
178  // half of the top half of the address space (that is, the third quarter).
179  // Because we do not MAP_FIXED, this will be treated only as a hint -- the
180  // system will not fail to mmap() because something else happens to already
181  // be mapped at our random address. We deliberately set the hint high enough
182  // to get well above the system's break (that is, the heap); Solaris and
183  // illumos will try the hint and if that fails allocate as if there were
184  // no hint at all. The high hint prevents the break from getting hemmed in
185  // at low values, ceding half of the address space to the system heap.
186  raw_addr += 0x80000000;
187 # else
188  // The range 0x20000000 - 0x60000000 is relatively unpopulated across a
189  // variety of ASLR modes (PAE kernel, NX compat mode, etc) and on macos
190  // 10.6 and 10.7.
191  raw_addr += 0x20000000;
192 # endif
193 #endif
194  return reinterpret_cast<void*>(raw_addr);
195 }
#define V8_UINT64_C(x)
Definition: macros.h:357
static LazyInstance< RandomNumberGenerator >::type platform_random_number_generator

References NULL, v8::base::platform_random_number_generator, and V8_UINT64_C.

Referenced by v8::base::RandomizedVirtualAlloc().

+ Here is the caller graph for this function:

◆ GetSharedLibraryAddresses()

std::vector< OS::SharedLibraryAddress > v8::base::OS::GetSharedLibraryAddresses ( )
static

Definition at line 110 of file platform-cygwin.cc.

110  {
111  std::vector<SharedLibraryAddresses> result;
112  // This function assumes that the layout of the file is as follows:
113  // hex_start_addr-hex_end_addr rwxp <unused data> [binary_file_name]
114  // If we encounter an unexpected situation we abort scanning further entries.
115  FILE* fp = fopen("/proc/self/maps", "r");
116  if (fp == NULL) return result;
117 
118  // Allocate enough room to be able to store a full file name.
119  const int kLibNameLen = FILENAME_MAX + 1;
120  char* lib_name = reinterpret_cast<char*>(malloc(kLibNameLen));
121 
122  // This loop will terminate once the scanning hits an EOF.
123  while (true) {
124  uintptr_t start, end;
125  char attr_r, attr_w, attr_x, attr_p;
126  // Parse the addresses and permission bits at the beginning of the line.
127  if (fscanf(fp, "%" V8PRIxPTR "-%" V8PRIxPTR, &start, &end) != 2) break;
128  if (fscanf(fp, " %c%c%c%c", &attr_r, &attr_w, &attr_x, &attr_p) != 4) break;
129 
130  int c;
131  if (attr_r == 'r' && attr_w != 'w' && attr_x == 'x') {
132  // Found a read-only executable entry. Skip characters until we reach
133  // the beginning of the filename or the end of the line.
134  do {
135  c = getc(fp);
136  } while ((c != EOF) && (c != '\n') && (c != '/'));
137  if (c == EOF) break; // EOF: Was unexpected, just exit.
138 
139  // Process the filename if found.
140  if (c == '/') {
141  ungetc(c, fp); // Push the '/' back into the stream to be read below.
142 
143  // Read to the end of the line. Exit if the read fails.
144  if (fgets(lib_name, kLibNameLen, fp) == NULL) break;
145 
146  // Drop the newline character read by fgets. We do not need to check
147  // for a zero-length string because we know that we at least read the
148  // '/' character.
149  lib_name[strlen(lib_name) - 1] = '\0';
150  } else {
151  // No library name found, just record the raw address range.
152  snprintf(lib_name, kLibNameLen,
153  "%08" V8PRIxPTR "-%08" V8PRIxPTR, start, end);
154  }
155  result.push_back(SharedLibraryAddress(lib_name, start, end));
156  } else {
157  // Entry not describing executable data. Skip to end of line to set up
158  // reading the next entry.
159  do {
160  c = getc(fp);
161  } while ((c != EOF) && (c != '\n'));
162  if (c == EOF) break;
163  }
164  }
165  free(lib_name);
166  fclose(fp);
167  return result;
168 }
#define V8PRIxPTR
Definition: macros.h:363
const Register fp

References v8::internal::fp, NULL, and V8PRIxPTR.

Referenced by v8::internal::Profiler::Engage().

+ Here is the caller graph for this function:

◆ GetUserTime()

int v8::base::OS::GetUserTime ( uint32_t secs,
uint32_t usecs 
)
static

Definition at line 272 of file platform-posix.cc.

272  {
273 #if V8_OS_NACL
274  // Optionally used in Logger::ResourceEvent.
275  return -1;
276 #else
277  struct rusage usage;
278 
279  if (getrusage(RUSAGE_SELF, &usage) < 0) return -1;
280  *secs = usage.ru_utime.tv_sec;
281  *usecs = usage.ru_utime.tv_usec;
282  return 0;
283 #endif
284 }

Referenced by v8::internal::Logger::ResourceEvent().

+ Here is the caller graph for this function:

◆ Guard()

void v8::base::OS::Guard ( void *  address,
const size_t  size 
)
static

Definition at line 124 of file platform-posix.cc.

124  {
125 #if V8_OS_CYGWIN
126  DWORD oldprotect;
127  VirtualProtect(address, size, PAGE_NOACCESS, &oldprotect);
128 #else
129  mprotect(address, size, PROT_NONE);
130 #endif
131 }
typedef DWORD(__stdcall *DLL_FUNC_TYPE(SymGetOptions))(VOID)

References v8::base::DWORD(), and size.

+ Here is the call graph for this function:

◆ Initialize()

void v8::base::OS::Initialize ( int64_t  random_seed,
bool  hard_abort,
const char *const  gc_fake_mmap 
)
static

Definition at line 138 of file platform-posix.cc.

139  {
140  if (random_seed) {
141  platform_random_number_generator.Pointer()->SetSeed(random_seed);
142  }
143  g_hard_abort = hard_abort;
144  g_gc_fake_mmap = gc_fake_mmap;
145 }

References v8::base::anonymous_namespace{platform-posix.cc}::g_gc_fake_mmap, v8::base::anonymous_namespace{platform-posix.cc}::g_hard_abort, and v8::base::platform_random_number_generator.

Referenced by v8::internal::V8::InitializeOncePerProcessImpl().

+ Here is the caller graph for this function:

◆ LocalTimeOffset()

double v8::base::OS::LocalTimeOffset ( TimezoneCache cache)
static

Definition at line 38 of file platform-cygwin.cc.

38  {
39  // On Cygwin, struct tm does not contain a tm_gmtoff field.
40  time_t utc = time(NULL);
41  DCHECK(utc != -1);
42  struct tm* loc = localtime(&utc);
43  DCHECK(loc != NULL);
44  // time - localtime includes any daylight savings offset, so subtract it.
45  return static_cast<double>((mktime(loc) - utc) * msPerSecond -
46  (loc->tm_isdst > 0 ? 3600 * msPerSecond : 0));
47 }

References DCHECK, msPerSecond, and NULL.

Referenced by v8::internal::DateCache::GetLocalOffsetFromOS().

+ Here is the caller graph for this function:

◆ LocalTimezone()

const char * v8::base::OS::LocalTimezone ( double  time,
TimezoneCache cache 
)
static

Definition at line 29 of file platform-cygwin.cc.

29  {
30  if (std::isnan(time)) return "";
31  time_t tv = static_cast<time_t>(std::floor(time/msPerSecond));
32  struct tm* t = localtime(&tv);
33  if (NULL == t) return "";
34  return tzname[0]; // The location of the timezone string on Cygwin.
35 }

References msPerSecond, and NULL.

Referenced by v8::internal::DateCache::LocalTimezone().

+ Here is the caller graph for this function:

◆ nan_value()

◆ OpenTemporaryFile()

FILE * v8::base::OS::OpenTemporaryFile ( )
static

Definition at line 345 of file platform-posix.cc.

345  {
346  return tmpfile();
347 }

Referenced by v8::internal::Log::OpenTemporaryFile().

+ Here is the caller graph for this function:

◆ Print()

void v8::base::OS::Print ( const char *  format,
  ... 
)
static

Definition at line 353 of file platform-posix.cc.

353  {
354  va_list args;
355  va_start(args, format);
356  VPrint(format, args);
357  va_end(args);
358 }
static void VPrint(const char *format, va_list args)

References VPrint().

Referenced by v8::internal::CodeMap::CodeTreePrinter::Call(), v8::internal::BoundsCheckBbData::CoverCheck(), v8::base::LoadSymbols(), v8::internal::HBoundsCheckEliminationPhase::PreProcessBlock(), v8::internal::CpuProfile::Print(), v8::internal::AllocationTraceTree::Print(), v8::internal::ProfileNode::Print(), v8::internal::AllocationTraceNode::Print(), v8::internal::PrintPID(), and v8::internal::BoundsCheckBbData::TightenCheck().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ PrintError()

void v8::base::OS::PrintError ( const char *  format,
  ... 
)
static

Definition at line 387 of file platform-posix.cc.

387  {
388  va_list args;
389  va_start(args, format);
390  VPrintError(format, args);
391  va_end(args);
392 }
static void VPrintError(const char *format, va_list args)

References VPrintError().

Referenced by v8::internal::AppendChars(), v8::internal::Isolate::DoThrow(), v8::base::DumpBacktrace(), v8::internal::Isolate::PrintStack(), v8::internal::ReadCharsFromFile(), v8::Utils::ReportApiFailure(), v8::internal::RUNTIME_FUNCTION(), v8::internal::Isolate::StackTraceString(), V8_Fatal(), and v8::internal::WriteChars().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ProtectCode()

void v8::base::OS::ProtectCode ( void *  address,
const size_t  size 
)
static

Definition at line 109 of file platform-posix.cc.

109  {
110 #if V8_OS_CYGWIN
111  DWORD old_protect;
112  VirtualProtect(address, size, PAGE_EXECUTE_READ, &old_protect);
113 #elif V8_OS_NACL
114  // The Native Client port of V8 uses an interpreter, so
115  // code pages don't need PROT_EXEC.
116  mprotect(address, size, PROT_READ);
117 #else
118  mprotect(address, size, PROT_READ | PROT_EXEC);
119 #endif
120 }

References v8::base::DWORD(), and size.

+ Here is the call graph for this function:

◆ Remove()

bool v8::base::OS::Remove ( const char *  path)
static

Definition at line 340 of file platform-posix.cc.

340  {
341  return (remove(path) == 0);
342 }

◆ SignalCodeMovingGC()

void v8::base::OS::SignalCodeMovingGC ( )
static

Definition at line 171 of file platform-cygwin.cc.

171  {
172  // Nothing to do on Cygwin.
173 }

Referenced by v8::internal::Logger::CodeMovingGCEvent().

+ Here is the caller graph for this function:

◆ Sleep()

void v8::base::OS::Sleep ( const int  milliseconds)
static

Definition at line 203 of file platform-posix.cc.

203  {
204  useconds_t ms = static_cast<useconds_t>(milliseconds);
205  usleep(1000 * ms);
206 }

Referenced by v8::internal::OptimizingCompilerThread::Run(), v8::internal::SamplerThread::Run(), and v8::internal::RUNTIME_FUNCTION().

+ Here is the caller graph for this function:

◆ SNPrintF()

int v8::base::OS::SNPrintF ( char *  str,
int  length,
const char *  format,
  ... 
)
static

Definition at line 404 of file platform-posix.cc.

404  {
405  va_list args;
406  va_start(args, format);
407  int result = VSNPrintF(str, length, format, args);
408  va_end(args);
409  return result;
410 }
static int VSNPrintF(char *str, int length, const char *format, va_list args)

References VSNPrintF().

Referenced by v8::base::TimezoneCache::InitializeIfNeeded().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ StrChr()

char * v8::base::OS::StrChr ( char *  str,
int  c 
)
static

Definition at line 433 of file platform-posix.cc.

433  {
434  return strchr(str, c);
435 }

◆ StrNCpy()

void v8::base::OS::StrNCpy ( char *  dest,
int  length,
const char *  src,
size_t  n 
)
static

Definition at line 438 of file platform-posix.cc.

438  {
439  strncpy(dest, src, n);
440 }

Referenced by v8::internal::StrNCpy().

+ Here is the caller graph for this function:

◆ TimeCurrentMillis()

◆ VFPrint()

void v8::base::OS::VFPrint ( FILE *  out,
const char *  format,
va_list  args 
)
static

Definition at line 378 of file platform-posix.cc.

378  {
379 #if defined(ANDROID) && !defined(V8_ANDROID_LOG_STDOUT)
380  __android_log_vprint(ANDROID_LOG_INFO, LOG_TAG, format, args);
381 #else
382  vfprintf(out, format, args);
383 #endif
384 }

Referenced by FPrint(), and v8::internal::PrintF().

+ Here is the caller graph for this function:

◆ VPrint()

void v8::base::OS::VPrint ( const char *  format,
va_list  args 
)
static

Definition at line 361 of file platform-posix.cc.

361  {
362 #if defined(ANDROID) && !defined(V8_ANDROID_LOG_STDOUT)
363  __android_log_vprint(ANDROID_LOG_INFO, LOG_TAG, format, args);
364 #else
365  vprintf(format, args);
366 #endif
367 }

Referenced by Print(), v8::internal::PrintF(), v8::internal::PrintPID(), v8::internal::compiler::Trace(), v8::internal::TraceGVN(), and v8::internal::HRangeAnalysisPhase::TraceRange().

+ Here is the caller graph for this function:

◆ VPrintError()

void v8::base::OS::VPrintError ( const char *  format,
va_list  args 
)
static

Definition at line 395 of file platform-posix.cc.

395  {
396 #if defined(ANDROID) && !defined(V8_ANDROID_LOG_STDOUT)
397  __android_log_vprint(ANDROID_LOG_ERROR, LOG_TAG, format, args);
398 #else
399  vfprintf(stderr, format, args);
400 #endif
401 }

Referenced by PrintError(), and V8_Fatal().

+ Here is the caller graph for this function:

◆ VSNPrintF()

int v8::base::OS::VSNPrintF ( char *  str,
int  length,
const char *  format,
va_list  args 
)
static

Definition at line 413 of file platform-posix.cc.

416  {
417  int n = vsnprintf(str, length, format, args);
418  if (n < 0 || n >= length) {
419  // If the length is zero, the assignment fails.
420  if (length > 0)
421  str[length - 1] = '\0';
422  return -1;
423  } else {
424  return n;
425  }
426 }

Referenced by SNPrintF(), v8::base::VPrintHelper(), and v8::internal::VSNPrintF().

+ Here is the caller graph for this function:

Member Data Documentation

◆ kStackWalkError

const int v8::base::OS::kStackWalkError = -1
static

Definition at line 239 of file platform.h.

◆ kStackWalkMaxNameLen

const int v8::base::OS::kStackWalkMaxNameLen = 256
static

Definition at line 240 of file platform.h.

Referenced by v8::base::LoadSymbols().

◆ kStackWalkMaxTextLen

const int v8::base::OS::kStackWalkMaxTextLen = 256
static

Definition at line 241 of file platform.h.

◆ LogFileOpenMode

const char *const v8::base::OS::LogFileOpenMode = "w"
static

◆ msPerSecond

const int v8::base::OS::msPerSecond = 1000
staticprivate

Definition at line 303 of file platform.h.

Referenced by DaylightSavingsOffset(), LocalTimeOffset(), and LocalTimezone().


The documentation for this class was generated from the following files: