30 #define V8_WIN32_HEADERS_FULL
43 int strncasecmp(
const char*
s1,
const char*
s2,
int n) {
44 return _strnicmp(s1, s2, n);
55 #ifndef __MINGW64_VERSION_MAJOR
62 __asm__ __volatile__(
"xchgl %%eax,%0 ":
"=r" (barrier));
65 #endif // __MINGW64_VERSION_MAJOR
68 #ifndef MINGW_HAS_SECURE_API
70 int localtime_s(tm* out_tm,
const time_t* time) {
71 tm* posix_local_time_struct = localtime(time);
72 if (posix_local_time_struct ==
NULL)
return 1;
73 *out_tm = *posix_local_time_struct;
78 int fopen_s(FILE** pFile,
const char* filename,
const char* mode) {
79 *pFile = fopen(filename, mode);
80 return *pFile !=
NULL ? 0 : 1;
83 int _vsnprintf_s(
char* buffer,
size_t sizeOfBuffer,
size_t count,
84 const char* format, va_list argptr) {
85 ASSERT(count == _TRUNCATE);
86 return _vsnprintf(buffer, sizeOfBuffer, format, argptr);
90 int strncpy_s(
char* dest,
size_t dest_size,
const char* source,
size_t count) {
95 if (count == _TRUNCATE) {
96 while (dest_size > 0 && *source != 0) {
97 *(dest++) = *(source++);
100 if (dest_size == 0) {
105 while (dest_size > 0 && count > 0 && *source != 0) {
106 *(dest++) = *(source++);
116 #endif // MINGW_HAS_SECURE_API
118 #endif // __MINGW32__
140 static Mutex* limit_mutex =
NULL;
142 #if defined(V8_TARGET_ARCH_IA32)
143 static OS::MemCopyFunction memcopy_function =
NULL;
145 OS::MemCopyFunction CreateMemCopyFunction();
148 void OS::MemCopy(
void* dest,
const void* src,
size_t size) {
151 (*memcopy_function)(dest, src, size);
153 CHECK_EQ(0, memcmp(dest, src, size));
156 #endif // V8_TARGET_ARCH_IA32
159 typedef double (*ModuloFunction)(double, double);
160 static ModuloFunction modulo_function =
NULL;
162 ModuloFunction CreateModuloFunction();
164 void init_modulo_function() {
165 modulo_function = CreateModuloFunction();
168 double modulo(
double x,
double y) {
171 return (*modulo_function)(x, y);
175 double modulo(
double x,
double y) {
180 !(x == 0 && (y != 0 &&
isfinite(y)))) {
189 #define UNARY_MATH_FUNCTION(name, generator) \
190 static UnaryMathFunction fast_##name##_function = NULL; \
191 void init_fast_##name##_function() { \
192 fast_##name##_function = generator; \
194 double fast_##name(double x) { \
195 return (*fast_##name##_function)(x); \
209 init_modulo_function();
211 init_fast_sin_function();
212 init_fast_cos_function();
213 init_fast_tan_function();
214 init_fast_log_function();
215 init_fast_sqrt_function();
229 explicit Time(
double jstime);
230 Time(
int year,
int mon,
int day,
int hour,
int min,
int sec);
254 static const int64_t kTimeEpoc = 116444736000000000LL;
255 static const int64_t kTimeScaler = 10000;
256 static const int64_t kMsPerMinute = 60000;
259 static const int kTzNameSize = 128;
260 static const bool kShortTzNames =
false;
265 static bool tz_initialized_;
266 static TIME_ZONE_INFORMATION tzinfo_;
267 static char std_tz_name_[kTzNameSize];
268 static char dst_tz_name_[kTzNameSize];
274 static const char* GuessTimezoneNameFromBias(
int bias);
281 int64_t Diff(
Time* other);
284 FILETIME& ft() {
return time_.ft_; }
287 int64_t& t() {
return time_.t_; }
303 bool Time::tz_initialized_ =
false;
304 TIME_ZONE_INFORMATION Time::tzinfo_;
305 char Time::std_tz_name_[kTzNameSize];
306 char Time::dst_tz_name_[kTzNameSize];
317 t() =
static_cast<int64_t
>(jstime) * kTimeScaler + kTimeEpoc;
322 Time::Time(
int year,
int mon,
int day,
int hour,
int min,
int sec) {
330 st.wMilliseconds = 0;
331 SystemTimeToFileTime(&st, &ft());
337 return static_cast<double>((t() - kTimeEpoc) / kTimeScaler);
343 const char* Time::GuessTimezoneNameFromBias(
int bias) {
344 static const int kHour = 60;
346 case -9*kHour:
return "Alaska";
347 case -8*kHour:
return "Pacific";
348 case -7*kHour:
return "Mountain";
349 case -6*kHour:
return "Central";
350 case -5*kHour:
return "Eastern";
351 case -4*kHour:
return "Atlantic";
352 case 0*kHour:
return "GMT";
353 case +1*kHour:
return "Central Europe";
354 case +2*kHour:
return "Eastern Europe";
355 case +3*kHour:
return "Russia";
356 case +5*kHour + 30:
return "India";
357 case +8*kHour:
return "China";
358 case +9*kHour:
return "Japan";
359 case +12*kHour:
return "New Zealand";
360 default:
return "Local";
370 if (tz_initialized_)
return;
375 memset(&tzinfo_, 0,
sizeof(tzinfo_));
376 if (GetTimeZoneInformation(&tzinfo_) == TIME_ZONE_ID_INVALID) {
379 tzinfo_.StandardDate.wMonth = 10;
380 tzinfo_.StandardDate.wDay = 5;
381 tzinfo_.StandardDate.wHour = 3;
382 tzinfo_.StandardBias = 0;
383 tzinfo_.DaylightDate.wMonth = 3;
384 tzinfo_.DaylightDate.wDay = 5;
385 tzinfo_.DaylightDate.wHour = 2;
386 tzinfo_.DaylightBias = -60;
390 WideCharToMultiByte(CP_UTF8, 0, tzinfo_.StandardName, -1,
391 std_tz_name_, kTzNameSize,
NULL,
NULL);
392 std_tz_name_[kTzNameSize - 1] =
'\0';
393 WideCharToMultiByte(CP_UTF8, 0, tzinfo_.DaylightName, -1,
394 dst_tz_name_, kTzNameSize,
NULL,
NULL);
395 dst_tz_name_[kTzNameSize - 1] =
'\0';
401 if (std_tz_name_[0] ==
'\0' || std_tz_name_[0] ==
'@') {
402 OS::SNPrintF(Vector<char>(std_tz_name_, kTzNameSize - 1),
404 GuessTimezoneNameFromBias(tzinfo_.Bias));
406 if (dst_tz_name_[0] ==
'\0' || dst_tz_name_[0] ==
'@') {
407 OS::SNPrintF(Vector<char>(dst_tz_name_, kTzNameSize - 1),
409 GuessTimezoneNameFromBias(tzinfo_.Bias));
413 tz_initialized_ =
true;
418 int64_t Time::Diff(Time* other) {
419 return (t() - other->t()) / kTimeScaler;
442 static bool initialized =
false;
443 static TimeStamp init_time;
444 static DWORD init_ticks;
445 static const int64_t kHundredNanosecondsPerSecond = 10000000;
446 static const int64_t kMaxClockElapsedTime =
447 60*kHundredNanosecondsPerSecond;
450 bool needs_resync = !initialized;
454 GetSystemTimeAsFileTime(&time_now.ft_);
455 DWORD ticks_now = timeGetTime();
458 needs_resync |= ticks_now < init_ticks;
461 needs_resync |= (time_now.t_ - init_time.t_) > kMaxClockElapsedTime;
464 needs_resync |= time_now.t_ < init_time.t_;
468 GetSystemTimeAsFileTime(&init_time.ft_);
469 init_ticks = ticks_now = timeGetTime();
474 DWORD elapsed = ticks_now - init_ticks;
475 this->time_.t_ = init_time.t_ + (
static_cast<int64_t
>(elapsed) * 10000);
488 Time rounded_to_second(*
this);
489 rounded_to_second.t() = rounded_to_second.t() / 1000 / kTimeScaler *
497 double unchecked_posix_time = rounded_to_second.
ToJSTime() / 1000;
498 if (unchecked_posix_time > INT_MAX || unchecked_posix_time < 0) {
502 time_t posix_time =
static_cast<time_t
>(unchecked_posix_time);
505 tm posix_local_time_struct;
506 if (localtime_s(&posix_local_time_struct, &posix_time))
return 0;
508 if (posix_local_time_struct.tm_isdst > 0) {
509 return (tzinfo_.Bias + tzinfo_.DaylightBias) * -kMsPerMinute;
510 }
else if (posix_local_time_struct.tm_isdst == 0) {
511 return (tzinfo_.Bias + tzinfo_.StandardBias) * -kMsPerMinute;
513 return tzinfo_.Bias * -kMsPerMinute;
525 if (tzinfo_.StandardDate.wMonth != 0 || tzinfo_.DaylightDate.wMonth != 0) {
531 int64_t dstofs = -(tzinfo_.Bias + tzinfo_.DaylightBias) * kMsPerMinute;
535 in_dst = offset == dstofs;
544 return InDST() ? 60 * kMsPerMinute : 0;
553 return InDST() ? dst_tz_name_ : std_tz_name_;
561 #if defined(V8_TARGET_ARCH_IA32)
562 memcopy_function = CreateMemCopyFunction();
573 if (!GetThreadTimes(GetCurrentThread(), &dummy, &dummy, &dummy,
574 reinterpret_cast<FILETIME*>(&usertime)))
return -1;
580 *secs =
static_cast<uint32_t
>(usertime / 1000000);
581 *usecs =
static_cast<uint32_t
>(usertime % 1000000);
590 t.SetToCurrentTime();
596 return timeGetTime() * 1000;
603 return Time(time).LocalTimezone();
613 return static_cast<double>(t.LocalOffset() - t.DaylightSavingsOffset());
620 int64_t offset = Time(time).DaylightSavingsOffset();
621 return static_cast<double>(offset);
626 return ::GetLastError();
652 static bool HasConsole() {
660 if (GetStdHandle(STD_OUTPUT_HANDLE) != INVALID_HANDLE_VALUE &&
661 GetFileType(GetStdHandle(STD_OUTPUT_HANDLE)) != FILE_TYPE_UNKNOWN)
670 static void VPrintHelper(FILE* stream,
const char* format, va_list args) {
672 vfprintf(stream, format, args);
677 EmbeddedVector<char, 4096> buffer;
679 OutputDebugStringA(buffer.start());
684 FILE*
OS::FOpen(
const char* path,
const char* mode) {
686 if (fopen_s(&result, path, mode) == 0) {
695 return (DeleteFileA(path) != 0);
701 char tempPathBuffer[MAX_PATH];
702 DWORD path_result = 0;
703 path_result = GetTempPathA(MAX_PATH, tempPathBuffer);
704 if (path_result > MAX_PATH || path_result == 0)
return NULL;
705 UINT name_result = 0;
706 char tempNameBuffer[MAX_PATH];
707 name_result = GetTempFileNameA(tempPathBuffer,
"", 0, tempNameBuffer);
708 if (name_result == 0)
return NULL;
709 FILE* result =
FOpen(tempNameBuffer,
"w+");
710 if (result !=
NULL) {
722 void OS::Print(
const char* format, ...) {
724 va_start(args, format);
730 void OS::VPrint(
const char* format, va_list args) {
731 VPrintHelper(stdout, format, args);
735 void OS::FPrint(FILE* out,
const char* format, ...) {
737 va_start(args, format);
743 void OS::VFPrint(FILE* out,
const char* format, va_list args) {
744 VPrintHelper(out, format, args);
751 va_start(args, format);
758 VPrintHelper(stderr, format, args);
762 int OS::SNPrintF(Vector<char> str,
const char* format, ...) {
764 va_start(args, format);
765 int result =
VSNPrintF(str, format, args);
771 int OS::VSNPrintF(Vector<char> str,
const char* format, va_list args) {
772 int n = _vsnprintf_s(str.start(), str.length(), _TRUNCATE, format, args);
775 if (n < 0 || n >= str.length()) {
776 if (str.length() > 0)
777 str[str.length() - 1] =
'\0';
786 return const_cast<char*
>(strchr(str, c));
790 void OS::StrNCpy(Vector<char> dest,
const char* src,
size_t n) {
792 size_t buffer_size =
static_cast<size_t>(dest.length());
793 if (n + 1 > buffer_size)
795 int result = strncpy_s(dest.start(), dest.length(), src, n);
797 ASSERT(result == 0 || (n == _TRUNCATE && result == STRUNCATE));
806 static void* lowest_ever_allocated =
reinterpret_cast<void*
>(-1);
807 static void* highest_ever_allocated =
reinterpret_cast<void*
>(0);
810 static void UpdateAllocatedSpaceLimits(
void* address,
int size) {
812 ScopedLock lock(limit_mutex);
814 lowest_ever_allocated =
Min(lowest_ever_allocated, address);
815 highest_ever_allocated =
816 Max(highest_ever_allocated,
817 reinterpret_cast<void*>(reinterpret_cast<char*>(address) + size));
822 if (pointer < lowest_ever_allocated || pointer >= highest_ever_allocated)
825 if (IsBadWritePtr(pointer, 1))
834 static size_t GetPageSize() {
835 static size_t page_size = 0;
836 if (page_size == 0) {
838 GetSystemInfo(&info);
848 static size_t allocate_alignment = 0;
849 if (allocate_alignment == 0) {
851 GetSystemInfo(&info);
852 allocate_alignment = info.dwAllocationGranularity;
854 return allocate_alignment;
858 static void* GetRandomAddr() {
859 Isolate* isolate = Isolate::UncheckedCurrent();
863 if (isolate !=
NULL) {
869 #ifdef V8_HOST_ARCH_64_BIT
870 static const intptr_t kAllocationRandomAddressMin = 0x0000000080000000;
871 static const intptr_t kAllocationRandomAddressMax = 0x000003FFFFFF0000;
873 static const intptr_t kAllocationRandomAddressMin = 0x04000000;
874 static const intptr_t kAllocationRandomAddressMax = 0x3FFF0000;
877 | kAllocationRandomAddressMin;
878 address &= kAllocationRandomAddressMax;
879 return reinterpret_cast<void *
>(address);
885 static void* RandomizedVirtualAlloc(
size_t size,
int action,
int protection) {
888 if (protection == PAGE_EXECUTE_READWRITE || protection == PAGE_NOACCESS) {
890 for (
size_t attempts = 0; base ==
NULL && attempts < 3; ++attempts) {
891 base = VirtualAlloc(GetRandomAddr(), size, action, protection);
896 if (base ==
NULL) base = VirtualAlloc(
NULL, size, action, protection);
904 bool is_executable) {
906 size_t msize =
RoundUp(requested, static_cast<int>(GetPageSize()));
909 int prot = is_executable ? PAGE_EXECUTE_READWRITE : PAGE_READWRITE;
911 LPVOID mbase = RandomizedVirtualAlloc(msize,
912 MEM_COMMIT | MEM_RESERVE,
916 LOG(
ISOLATE, StringEvent(
"OS::Allocate",
"VirtualAlloc failed"));
923 UpdateAllocatedSpaceLimits(mbase, static_cast<int>(msize));
928 void OS::Free(
void* address,
const size_t size) {
930 VirtualFree(address, 0, MEM_RELEASE);
942 VirtualProtect(address, size, PAGE_EXECUTE_READ, &old_protect);
946 void OS::Guard(
void* address,
const size_t size) {
948 VirtualProtect(address, size, PAGE_READONLY | PAGE_GUARD, &oldprotect);
958 if (IsDebuggerPresent() || FLAG_break_on_abort) {
983 file_mapping_(file_mapping),
987 virtual void*
memory() {
return memory_; }
988 virtual int size() {
return size_; }
999 HANDLE file = CreateFileA(name, GENERIC_READ | GENERIC_WRITE,
1000 FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL, OPEN_EXISTING, 0,
NULL);
1001 if (file == INVALID_HANDLE_VALUE)
return NULL;
1003 int size =
static_cast<int>(GetFileSize(file,
NULL));
1006 HANDLE file_mapping = CreateFileMapping(file,
NULL,
1007 PAGE_READWRITE, 0, static_cast<DWORD>(size),
NULL);
1008 if (file_mapping ==
NULL)
return NULL;
1011 void*
memory = MapViewOfFile(file_mapping, FILE_MAP_ALL_ACCESS, 0, 0, size);
1012 return new Win32MemoryMappedFile(file, file_mapping, memory, size);
1019 HANDLE file = CreateFileA(name, GENERIC_READ | GENERIC_WRITE,
1020 FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL, OPEN_ALWAYS, 0,
NULL);
1023 HANDLE file_mapping = CreateFileMapping(file,
NULL,
1024 PAGE_READWRITE, 0, static_cast<DWORD>(size),
NULL);
1025 if (file_mapping ==
NULL)
return NULL;
1027 void* memory = MapViewOfFile(file_mapping, FILE_MAP_ALL_ACCESS, 0, 0, size);
1028 if (memory) memmove(memory, initial, size);
1029 return new Win32MemoryMappedFile(file, file_mapping, memory, size);
1034 if (memory_ !=
NULL)
1035 UnmapViewOfFile(memory_);
1036 CloseHandle(file_mapping_);
1048 #define DBGHELP_FUNCTION_LIST(V) \
1052 V(SymGetSearchPath) \
1053 V(SymLoadModule64) \
1055 V(SymGetSymFromAddr64) \
1056 V(SymGetLineFromAddr64) \
1057 V(SymFunctionTableAccess64) \
1058 V(SymGetModuleBase64)
1061 #define TLHELP32_FUNCTION_LIST(V) \
1062 V(CreateToolhelp32Snapshot) \
1068 #define DLL_FUNC_TYPE(name) _##name##_
1069 #define DLL_FUNC_VAR(name) _##name
1115 OUT PIMAGEHLP_SYMBOL64
Symbol);
1120 OUT PIMAGEHLP_LINE64
Line64);
1136 LPMODULEENTRY32W
lpme);
1142 #define DEF_DLL_FUNCTION(name) DLL_FUNC_TYPE(name) DLL_FUNC_VAR(name) = NULL;
1145 #undef DEF_DLL_FUNCTION
1150 static bool LoadDbgHelpAndTlHelp32() {
1151 static bool dbghelp_loaded =
false;
1153 if (dbghelp_loaded)
return true;
1158 module = LoadLibrary(TEXT(
"dbghelp.dll"));
1159 if (module ==
NULL) {
1163 #define LOAD_DLL_FUNC(name) \
1164 DLL_FUNC_VAR(name) = \
1165 reinterpret_cast<DLL_FUNC_TYPE(name)>(GetProcAddress(module, #name));
1169 #undef LOAD_DLL_FUNC
1173 module = LoadLibrary(TEXT(
"kernel32.dll"));
1174 if (module ==
NULL) {
1178 #define LOAD_DLL_FUNC(name) \
1179 DLL_FUNC_VAR(name) = \
1180 reinterpret_cast<DLL_FUNC_TYPE(name)>(GetProcAddress(module, #name));
1184 #undef LOAD_DLL_FUNC
1188 #define DLL_FUNC_LOADED(name) (DLL_FUNC_VAR(name) != NULL) &&
1193 #undef DLL_FUNC_LOADED
1196 dbghelp_loaded = result;
1204 static bool LoadSymbols(
HANDLE process_handle) {
1205 static bool symbols_loaded =
false;
1207 if (symbols_loaded)
return true;
1212 ok = _SymInitialize(process_handle,
1215 if (!ok)
return false;
1217 DWORD options = _SymGetOptions();
1218 options |= SYMOPT_LOAD_LINES;
1219 options |= SYMOPT_FAIL_CRITICAL_ERRORS;
1220 options = _SymSetOptions(options);
1230 HANDLE snapshot = _CreateToolhelp32Snapshot(
1232 GetCurrentProcessId());
1233 if (snapshot == INVALID_HANDLE_VALUE)
return false;
1234 MODULEENTRY32W module_entry;
1235 module_entry.dwSize =
sizeof(module_entry);
1236 BOOL cont = _Module32FirstW(snapshot, &module_entry);
1241 base = _SymLoadModule64(
1244 reinterpret_cast<PSTR>(module_entry.szExePath),
1245 reinterpret_cast<PSTR>(module_entry.szModule),
1246 reinterpret_cast<DWORD64>(module_entry.modBaseAddr),
1247 module_entry.modBaseSize);
1250 if (err != ERROR_MOD_NOT_FOUND &&
1251 err != ERROR_INVALID_HANDLE)
return false;
1253 LOG(i::Isolate::Current(),
1255 module_entry.szExePath,
1256 reinterpret_cast<unsigned int>(module_entry.modBaseAddr),
1257 reinterpret_cast<unsigned int>(module_entry.modBaseAddr +
1258 module_entry.modBaseSize)));
1259 cont = _Module32NextW(snapshot, &module_entry);
1261 CloseHandle(snapshot);
1263 symbols_loaded =
true;
1273 if (!LoadDbgHelpAndTlHelp32())
return;
1274 HANDLE process_handle = GetCurrentProcess();
1275 LoadSymbols(process_handle);
1288 #pragma warning(push)
1289 #pragma warning(disable : 4748)
1297 HANDLE process_handle = GetCurrentProcess();
1298 HANDLE thread_handle = GetCurrentThread();
1305 RtlCaptureContext(&context);
1308 STACKFRAME64 stack_frame;
1309 memset(&stack_frame, 0,
sizeof(stack_frame));
1311 stack_frame.AddrPC.Offset = context.Rip;
1312 stack_frame.AddrFrame.Offset = context.Rbp;
1313 stack_frame.AddrStack.Offset = context.Rsp;
1315 stack_frame.AddrPC.Offset = context.Eip;
1316 stack_frame.AddrFrame.Offset = context.Ebp;
1317 stack_frame.AddrStack.Offset = context.Esp;
1319 stack_frame.AddrPC.Mode = AddrModeFlat;
1320 stack_frame.AddrFrame.Mode = AddrModeFlat;
1321 stack_frame.AddrStack.Mode = AddrModeFlat;
1322 int frames_count = 0;
1325 int frames_size = frames.length();
1326 while (frames_count < frames_size) {
1328 IMAGE_FILE_MACHINE_I386,
1334 _SymFunctionTableAccess64,
1335 _SymGetModuleBase64,
1340 ASSERT((stack_frame.AddrPC.Offset >> 32) == 0);
1341 frames[frames_count].address =
1342 reinterpret_cast<void*
>(stack_frame.AddrPC.Offset);
1346 SmartArrayPointer<IMAGEHLP_SYMBOL64> symbol(
1350 (*symbol)->SizeOfStruct =
sizeof(IMAGEHLP_SYMBOL64);
1352 ok = _SymGetSymFromAddr64(process_handle,
1353 stack_frame.AddrPC.Offset,
1354 &symbol_displacement,
1358 IMAGEHLP_LINE64 Line;
1359 memset(&Line, 0,
sizeof(Line));
1360 Line.SizeOfStruct =
sizeof(Line);
1361 DWORD line_displacement;
1362 ok = _SymGetLineFromAddr64(
1364 stack_frame.AddrPC.Offset,
1373 (*symbol)->Name, Line.FileName, Line.LineNumber,
1385 frames[frames_count].text[0] =
'\0';
1390 if (err != ERROR_MOD_NOT_FOUND) {
1399 return frames_count;
1403 #pragma warning(pop)
1405 #else // __MINGW32__
1408 int OS::StackWalk(Vector<OS::StackFrame> frames) {
return 0; }
1409 #endif // __MINGW32__
1422 return *
reinterpret_cast<const double*
>(&nanval);
1447 VirtualMemory::VirtualMemory(
size_t size)
1448 : address_(ReserveRegion(size)), size_(size) { }
1451 VirtualMemory::VirtualMemory(
size_t size,
size_t alignment)
1452 : address_(
NULL), size_(0) {
1453 ASSERT(
IsAligned(alignment, static_cast<intptr_t>(OS::AllocateAlignment())));
1454 size_t request_size =
RoundUp(size + alignment,
1455 static_cast<intptr_t>(OS::AllocateAlignment()));
1456 void* address = ReserveRegion(request_size);
1457 if (address ==
NULL)
return;
1458 Address base =
RoundUp(static_cast<Address>(address), alignment);
1460 bool result = ReleaseRegion(address, request_size);
1463 address = VirtualAlloc(base, size, MEM_RESERVE, PAGE_NOACCESS);
1464 if (address !=
NULL) {
1465 request_size = size;
1466 ASSERT(base == static_cast<Address>(address));
1469 address = ReserveRegion(request_size);
1470 if (address ==
NULL)
return;
1473 size_ = request_size;
1477 VirtualMemory::~VirtualMemory() {
1479 bool result = ReleaseRegion(address_, size_);
1486 bool VirtualMemory::IsReserved() {
1487 return address_ !=
NULL;
1497 bool VirtualMemory::Commit(
void* address,
size_t size,
bool is_executable) {
1498 if (CommitRegion(address, size, is_executable)) {
1499 UpdateAllocatedSpaceLimits(address, static_cast<int>(size));
1506 bool VirtualMemory::Uncommit(
void* address,
size_t size) {
1508 return UncommitRegion(address, size);
1512 void* VirtualMemory::ReserveRegion(
size_t size) {
1513 return RandomizedVirtualAlloc(size, MEM_RESERVE, PAGE_NOACCESS);
1517 bool VirtualMemory::CommitRegion(
void* base,
size_t size,
bool is_executable) {
1518 int prot = is_executable ? PAGE_EXECUTE_READWRITE : PAGE_READWRITE;
1519 if (
NULL == VirtualAlloc(base, size, MEM_COMMIT, prot)) {
1523 UpdateAllocatedSpaceLimits(base, static_cast<int>(size));
1528 bool VirtualMemory::Guard(
void* address) {
1529 if (
NULL == VirtualAlloc(address,
1530 OS::CommitPageSize(),
1532 PAGE_READONLY | PAGE_GUARD)) {
1539 bool VirtualMemory::UncommitRegion(
void* base,
size_t size) {
1540 return VirtualFree(base, size, MEM_DECOMMIT) != 0;
1544 bool VirtualMemory::ReleaseRegion(
void* base,
size_t size) {
1545 return VirtualFree(base, 0, MEM_RELEASE) != 0;
1553 static const HANDLE kNoThread = INVALID_HANDLE_VALUE;
1559 static unsigned int __stdcall ThreadEntry(
void* arg) {
1560 Thread* thread =
reinterpret_cast<Thread*
>(arg);
1566 class Thread::PlatformData :
public Malloced {
1577 Thread::Thread(
const Options& options)
1578 : stack_size_(options.stack_size()) {
1580 set_name(options.
name());
1584 void Thread::set_name(
const char* name) {
1586 name_[
sizeof(name_) - 1] =
'\0';
1602 _beginthreadex(
NULL,
1603 static_cast<unsigned>(stack_size_),
1613 if (data_->
thread_id_ != GetCurrentThreadId()) {
1614 WaitForSingleObject(data_->
thread_, INFINITE);
1620 DWORD result = TlsAlloc();
1621 ASSERT(result != TLS_OUT_OF_INDEXES);
1627 BOOL result = TlsFree(static_cast<DWORD>(key));
1634 return TlsGetValue(static_cast<DWORD>(key));
1639 BOOL result = TlsSetValue(static_cast<DWORD>(key), value);
1666 EnterCriticalSection(&cs_);
1671 LeaveCriticalSection(&cs_);
1678 return TryEnterCriticalSection(&cs_);
1682 CRITICAL_SECTION cs_;
1687 return new Win32Mutex();
1702 sem = ::CreateSemaphoreA(
NULL, count, 0x7fffffff,
NULL);
1710 WaitForSingleObject(sem, INFINITE);
1715 DWORD millis_timeout = timeout / 1000;
1716 return WaitForSingleObject(sem, millis_timeout) != WAIT_TIMEOUT;
1721 ReleaseSemaphore(sem, 1, &dummy);
1730 return new Win32Semaphore(count);
1742 socket_ = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
1748 bool Bind(
const int port);
1749 bool Listen(
int backlog)
const;
1753 bool Connect(
const char* host,
const char* port);
1759 int Send(
const char*
data,
int len)
const;
1760 int Receive(
char*
data,
int len)
const;
1762 bool SetReuseAddress(
bool reuse_address);
1764 bool IsValid()
const {
return socket_ != INVALID_SOCKET; }
1777 memset(&addr, 0,
sizeof(addr));
1778 addr.sin_family = AF_INET;
1779 addr.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
1780 addr.sin_port = htons(port);
1781 int status = bind(socket_,
1782 reinterpret_cast<struct sockaddr *>(&addr),
1793 int status = listen(socket_, backlog);
1803 SOCKET socket = accept(socket_,
NULL,
NULL);
1804 if (socket == INVALID_SOCKET) {
1818 struct addrinfo *result =
NULL;
1819 struct addrinfo hints;
1820 memset(&hints, 0,
sizeof(addrinfo));
1821 hints.ai_family = AF_INET;
1822 hints.ai_socktype = SOCK_STREAM;
1823 hints.ai_protocol = IPPROTO_TCP;
1824 int status = getaddrinfo(host, port, &hints, &result);
1830 status = connect(socket_,
1832 static_cast<int>(result->ai_addrlen));
1833 freeaddrinfo(result);
1841 int status = shutdown(socket_, SD_BOTH);
1842 closesocket(socket_);
1843 socket_ = INVALID_SOCKET;
1844 return status == SOCKET_ERROR;
1851 if (len <= 0)
return 0;
1853 while (written < len) {
1854 int status = send(socket_, data + written, len - written, 0);
1857 }
else if (status > 0) {
1868 if (len <= 0)
return 0;
1869 int status = recv(socket_, data, len, 0);
1870 return (status == SOCKET_ERROR) ? 0 : status;
1875 BOOL on = reuse_address ?
true :
false;
1876 int status = setsockopt(socket_, SOL_SOCKET, SO_REUSEADDR,
1877 reinterpret_cast<char*>(&on),
sizeof(on));
1878 return status == SOCKET_ERROR;
1885 WSADATA winsock_data;
1886 WORD version_requested = MAKEWORD(1, 0);
1887 err = WSAStartup(version_requested, &winsock_data);
1897 return WSAGetLastError();
1902 return htons(value);
1907 return ntohs(value);
1912 return htonl(value);
1917 return ntohl(value);
1922 return new Win32Socket();
1929 class Sampler::PlatformData :
public Malloced {
1937 THREAD_SUSPEND_RESUME |
1938 THREAD_QUERY_INFORMATION,
1940 GetCurrentThreadId())) {}
1943 if (profiled_thread_ !=
NULL) {
1944 CloseHandle(profiled_thread_);
1945 profiled_thread_ =
NULL;
1958 static const int kSamplerThreadStackSize = 64 *
KB;
1962 interval_(interval) {}
1970 if (instance_ ==
NULL) {
1993 bool cpu_profiling_enabled =
1998 if (!cpu_profiling_enabled) {
1999 if (rate_limiter_.SuspendIfNecessary())
continue;
2001 if (cpu_profiling_enabled) {
2006 if (runtime_profiler_enabled) {
2030 if (profiled_thread ==
NULL)
return;
2034 memset(&context, 0,
sizeof(context));
2038 if (sample ==
NULL) sample = &sample_obj;
2040 static const DWORD kSuspendFailed =
static_cast<DWORD>(-1);
2041 if (SuspendThread(profiled_thread) == kSuspendFailed)
return;
2044 context.ContextFlags = CONTEXT_FULL;
2045 if (GetThreadContext(profiled_thread, &context) != 0) {
2046 #if V8_HOST_ARCH_X64
2047 sample->
pc =
reinterpret_cast<Address>(context.Rip);
2048 sample->
sp =
reinterpret_cast<Address>(context.Rsp);
2049 sample->
fp =
reinterpret_cast<Address>(context.Rbp);
2051 sample->
pc =
reinterpret_cast<Address>(context.Eip);
2052 sample->
sp =
reinterpret_cast<Address>(context.Esp);
2053 sample->
fp =
reinterpret_cast<Address>(context.Ebp);
2056 sampler->
Tick(sample);
2058 ResumeThread(profiled_thread);
2061 const int interval_;
2062 RuntimeProfilerRateLimiter rate_limiter_;
2065 static Mutex* mutex_;
2083 uint64_t
seed =
static_cast<uint64_t
>(TimeCurrentMillis());
2084 srand(static_cast<unsigned int>(seed));
2085 limit_mutex = CreateMutex();
2097 : isolate_(isolate),
2098 interval_(interval),
2102 data_ =
new PlatformData;
HANDLE HANDLE LPSTACKFRAME64 PVOID PREAD_PROCESS_MEMORY_ROUTINE64 PFUNCTION_TABLE_ACCESS_ROUTINE64 PGET_MODULE_BASE_ROUTINE64 PTRANSLATE_ADDRESS_ROUTINE64 TranslateAddress
static void * GetThreadLocal(LocalStorageKey key)
static void RemoveActiveSampler(Sampler *sampler)
#define CHECK_EQ(expected, value)
IN DWORD64 OUT PDWORD64 pdwDisplacement
static void Free(void *address, const size_t size)
void PrintF(const char *format,...)
PlatformData * platform_data()
static int VSNPrintF(Vector< char > str, const char *format, va_list args)
StateTag current_vm_state()
IN DWORD64 OUT PDWORD OUT PIMAGEHLP_LINE64 Line64
#define LOG(isolate, Call)
typedef PVOID(__stdcall *DLL_FUNC_TYPE(SymFunctionTableAccess64))(HANDLE hProcess
static FILE * OpenTemporaryFile()
Win32Socket(SOCKET socket)
static void SignalCodeMovingGC()
value format" "after each garbage collection") DEFINE_bool(print_cumulative_gc_stat, false, "print cumulative GC statistics in name=value format on exit") DEFINE_bool(trace_gc_verbose, false, "print more details following each garbage collection") DEFINE_bool(trace_fragmentation, false, "report fragmentation for old pointer and data pages") DEFINE_bool(collect_maps, true, "garbage collect maps from which no objects can be reached") DEFINE_bool(flush_code, true, "flush code that we expect not to use again before full gc") DEFINE_bool(incremental_marking, true, "use incremental marking") DEFINE_bool(incremental_marking_steps, true, "do incremental marking steps") DEFINE_bool(trace_incremental_marking, false, "trace progress of the incremental marking") DEFINE_bool(use_idle_notification, true, "Use idle notification to reduce memory footprint.") DEFINE_bool(send_idle_notification, false, "Send idle notifcation between stress runs.") DEFINE_bool(use_ic, true, "use inline caching") DEFINE_bool(native_code_counters, false, "generate extra code for manipulating stats counters") DEFINE_bool(always_compact, false, "Perform compaction on every full GC") DEFINE_bool(lazy_sweeping, true, "Use lazy sweeping for old pointer and data spaces") DEFINE_bool(never_compact, false, "Never perform compaction on full GC-testing only") DEFINE_bool(compact_code_space, true, "Compact code space on full non-incremental collections") DEFINE_bool(cleanup_code_caches_at_gc, true, "Flush inline caches prior to mark compact collection and" "flush code caches in maps during mark compact cycle.") DEFINE_int(random_seed, 0, "Default seed for initializing random generator" "(0, the default, means to use system random).") DEFINE_bool(use_verbose_printer, true, "allows verbose printing") DEFINE_bool(allow_natives_syntax, false, "allow natives syntax") DEFINE_bool(trace_sim, false, "Trace simulator execution") DEFINE_bool(check_icache, false, "Check icache flushes in ARM and MIPS simulator") DEFINE_int(stop_sim_at, 0, "Simulator stop after x number of instructions") DEFINE_int(sim_stack_alignment, 8, "Stack alingment in bytes in simulator(4 or 8, 8 is default)") DEFINE_bool(trace_exception, false, "print stack trace when throwing exceptions") DEFINE_bool(preallocate_message_memory, false, "preallocate some memory to build stack traces.") DEFINE_bool(randomize_hashes, true, "randomize hashes to avoid predictable hash collisions" "(with snapshots this option cannot override the baked-in seed)") DEFINE_int(hash_seed, 0, "Fixed seed to use to hash property keys(0 means random)" "(with snapshots this option cannot override the baked-in seed)") DEFINE_bool(preemption, false, "activate a 100ms timer that switches between V8 threads") DEFINE_bool(regexp_optimization, true, "generate optimized regexp code") DEFINE_bool(testing_bool_flag, true, "testing_bool_flag") DEFINE_int(testing_int_flag, 13, "testing_int_flag") DEFINE_float(testing_float_flag, 2.5, "float-flag") DEFINE_string(testing_string_flag, "Hello, world!", "string-flag") DEFINE_int(testing_prng_seed, 42, "Seed used for threading test randomness") DEFINE_string(testing_serialization_file, "/tmp/serdes", "file in which to serialize heap") DEFINE_bool(help, false, "Print usage message, including flags, on console") DEFINE_bool(dump_counters, false, "Dump counters on exit") DEFINE_string(map_counters, "", "Map counters to a file") DEFINE_args(js_arguments, JSARGUMENTS_INIT, "Pass all remaining arguments to the script.Alias for\"--\".") DEFINE_bool(debug_compile_events, true,"Enable debugger compile events") DEFINE_bool(debug_script_collected_events, true,"Enable debugger script collected events") DEFINE_bool(gdbjit, false,"enable GDBJIT interface (disables compacting GC)") DEFINE_bool(gdbjit_full, false,"enable GDBJIT interface for all code objects") DEFINE_bool(gdbjit_dump, false,"dump elf objects with debug info to disk") DEFINE_string(gdbjit_dump_filter,"","dump only objects containing this substring") DEFINE_bool(force_marking_deque_overflows, false,"force overflows of marking deque by reducing it's size ""to 64 words") DEFINE_bool(stress_compaction, false,"stress the GC compactor to flush out bugs (implies ""--force_marking_deque_overflows)")#define FLAG DEFINE_bool(enable_slow_asserts, false,"enable asserts that are slow to execute") DEFINE_bool(trace_codegen, false,"print name of functions for which code is generated") DEFINE_bool(print_source, false,"pretty print source code") DEFINE_bool(print_builtin_source, false,"pretty print source code for builtins") DEFINE_bool(print_ast, false,"print source AST") DEFINE_bool(print_builtin_ast, false,"print source AST for builtins") DEFINE_string(stop_at,"","function name where to insert a breakpoint") DEFINE_bool(print_builtin_scopes, false,"print scopes for builtins") DEFINE_bool(print_scopes, false,"print scopes") DEFINE_bool(trace_contexts, false,"trace contexts operations") DEFINE_bool(gc_greedy, false,"perform GC prior to some allocations") DEFINE_bool(gc_verbose, false,"print stuff during garbage collection") DEFINE_bool(heap_stats, false,"report heap statistics before and after GC") DEFINE_bool(code_stats, false,"report code statistics after GC") DEFINE_bool(verify_heap, false,"verify heap pointers before and after GC") DEFINE_bool(print_handles, false,"report handles after GC") DEFINE_bool(print_global_handles, false,"report global handles after GC") DEFINE_bool(trace_ic, false,"trace inline cache state transitions") DEFINE_bool(print_interfaces, false,"print interfaces") DEFINE_bool(print_interface_details, false,"print interface inference details") DEFINE_int(print_interface_depth, 5,"depth for printing interfaces") DEFINE_bool(trace_normalization, false,"prints when objects are turned into dictionaries.") DEFINE_bool(trace_lazy, false,"trace lazy compilation") DEFINE_bool(collect_heap_spill_statistics, false,"report heap spill statistics along with heap_stats ""(requires heap_stats)") DEFINE_bool(trace_isolates, false,"trace isolate state changes") DEFINE_bool(log_state_changes, false,"Log state changes.") DEFINE_bool(regexp_possessive_quantifier, false,"enable possessive quantifier syntax for testing") DEFINE_bool(trace_regexp_bytecodes, false,"trace regexp bytecode execution") DEFINE_bool(trace_regexp_assembler, false,"trace regexp macro assembler calls.")#define FLAG DEFINE_bool(log, false,"Minimal logging (no API, code, GC, suspect, or handles samples).") DEFINE_bool(log_all, false,"Log all events to the log file.") DEFINE_bool(log_runtime, false,"Activate runtime system %Log call.") DEFINE_bool(log_api, false,"Log API events to the log file.") DEFINE_bool(log_code, false,"Log code events to the log file without profiling.") DEFINE_bool(log_gc, false,"Log heap samples on garbage collection for the hp2ps tool.") DEFINE_bool(log_handles, false,"Log global handle events.") DEFINE_bool(log_snapshot_positions, false,"log positions of (de)serialized objects in the snapshot.") DEFINE_bool(log_suspect, false,"Log suspect operations.") DEFINE_bool(prof, false,"Log statistical profiling information (implies --log-code).") DEFINE_bool(prof_auto, true,"Used with --prof, starts profiling automatically") DEFINE_bool(prof_lazy, false,"Used with --prof, only does sampling and logging"" when profiler is active (implies --noprof_auto).") DEFINE_bool(prof_browser_mode, true,"Used with --prof, turns on browser-compatible mode for profiling.") DEFINE_bool(log_regexp, false,"Log regular expression execution.") DEFINE_bool(sliding_state_window, false,"Update sliding state window counters.") DEFINE_string(logfile,"v8.log","Specify the name of the log file.") DEFINE_bool(ll_prof, false,"Enable low-level linux profiler.")#define FLAG DEFINE_bool(trace_elements_transitions, false,"trace elements transitions") DEFINE_bool(print_code_stubs, false,"print code stubs") DEFINE_bool(test_secondary_stub_cache, false,"test secondary stub cache by disabling the primary one") DEFINE_bool(test_primary_stub_cache, false,"test primary stub cache by disabling the secondary one") DEFINE_bool(print_code, false,"print generated code") DEFINE_bool(print_opt_code, false,"print optimized code") DEFINE_bool(print_unopt_code, false,"print unoptimized code before ""printing optimized code based on it") DEFINE_bool(print_code_verbose, false,"print more information for code") DEFINE_bool(print_builtin_code, false,"print generated code for builtins")#43"/Users/thlorenz/dev/dx/v8-perf/build/v8/src/flags.cc"2#define FLAG_MODE_DEFINE_DEFAULTS#1"/Users/thlorenz/dev/dx/v8-perf/build/v8/src/flag-definitions.h"1#define FLAG_FULL(ftype, ctype, nam, def, cmt)#define FLAG_READONLY(ftype, ctype, nam, def, cmt)#define DEFINE_implication(whenflag, thenflag)#define DEFINE_bool(nam, def, cmt)#define DEFINE_int(nam, def, cmt)#define DEFINE_float(nam, def, cmt)#define DEFINE_string(nam, def, cmt)#define DEFINE_args(nam, def, cmt)#define FLAG DEFINE_bool(use_strict, false,"enforce strict mode") DEFINE_bool(es5_readonly, false,"activate correct semantics for inheriting readonliness") DEFINE_bool(es52_globals, false,"activate new semantics for global var declarations") DEFINE_bool(harmony_typeof, false,"enable harmony semantics for typeof") DEFINE_bool(harmony_scoping, false,"enable harmony block scoping") DEFINE_bool(harmony_modules, false,"enable harmony modules (implies block scoping)") DEFINE_bool(harmony_proxies, false,"enable harmony proxies") DEFINE_bool(harmony_collections, false,"enable harmony collections (sets, maps, and weak maps)") DEFINE_bool(harmony, false,"enable all harmony features (except typeof)") DEFINE_implication(harmony, harmony_scoping) DEFINE_implication(harmony, harmony_modules) DEFINE_implication(harmony, harmony_proxies) DEFINE_implication(harmony, harmony_collections) DEFINE_implication(harmony_modules, harmony_scoping) DEFINE_bool(packed_arrays, false,"optimizes arrays that have no holes") DEFINE_bool(smi_only_arrays, true,"tracks arrays with only smi values") DEFINE_bool(clever_optimizations, true,"Optimize object size, Array shift, DOM strings and string +") DEFINE_bool(unbox_double_arrays, true,"automatically unbox arrays of doubles") DEFINE_bool(string_slices, true,"use string slices") DEFINE_bool(crankshaft, true,"use crankshaft") DEFINE_string(hydrogen_filter,"","optimization filter") DEFINE_bool(use_range, true,"use hydrogen range analysis") DEFINE_bool(eliminate_dead_phis, true,"eliminate dead phis") DEFINE_bool(use_gvn, true,"use hydrogen global value numbering") DEFINE_bool(use_canonicalizing, true,"use hydrogen instruction canonicalizing") DEFINE_bool(use_inlining, true,"use function inlining") DEFINE_int(max_inlined_source_size, 600,"maximum source size in bytes considered for a single inlining") DEFINE_int(max_inlined_nodes, 196,"maximum number of AST nodes considered for a single inlining") DEFINE_int(max_inlined_nodes_cumulative, 196,"maximum cumulative number of AST nodes considered for inlining") DEFINE_bool(loop_invariant_code_motion, true,"loop invariant code motion") DEFINE_bool(collect_megamorphic_maps_from_stub_cache, true,"crankshaft harvests type feedback from stub cache") DEFINE_bool(hydrogen_stats, false,"print statistics for hydrogen") DEFINE_bool(trace_hydrogen, false,"trace generated hydrogen to file") DEFINE_string(trace_phase,"Z","trace generated IR for specified phases") DEFINE_bool(trace_inlining, false,"trace inlining decisions") DEFINE_bool(trace_alloc, false,"trace register allocator") DEFINE_bool(trace_all_uses, false,"trace all use positions") DEFINE_bool(trace_range, false,"trace range analysis") DEFINE_bool(trace_gvn, false,"trace global value numbering") DEFINE_bool(trace_representation, false,"trace representation types") DEFINE_bool(stress_pointer_maps, false,"pointer map for every instruction") DEFINE_bool(stress_environments, false,"environment for every instruction") DEFINE_int(deopt_every_n_times, 0,"deoptimize every n times a deopt point is passed") DEFINE_bool(trap_on_deopt, false,"put a break point before deoptimizing") DEFINE_bool(deoptimize_uncommon_cases, true,"deoptimize uncommon cases") DEFINE_bool(polymorphic_inlining, true,"polymorphic inlining") DEFINE_bool(use_osr, true,"use on-stack replacement") DEFINE_bool(array_bounds_checks_elimination, false,"perform array bounds checks elimination") DEFINE_bool(array_index_dehoisting, false,"perform array index dehoisting") DEFINE_bool(trace_osr, false,"trace on-stack replacement") DEFINE_int(stress_runs, 0,"number of stress runs") DEFINE_bool(optimize_closures, true,"optimize closures") DEFINE_bool(inline_construct, true,"inline constructor calls") DEFINE_bool(inline_arguments, true,"inline functions with arguments object") DEFINE_int(loop_weight, 1,"loop weight for representation inference") DEFINE_bool(optimize_for_in, true,"optimize functions containing for-in loops") DEFINE_bool(experimental_profiler, true,"enable all profiler experiments") DEFINE_bool(watch_ic_patching, false,"profiler considers IC stability") DEFINE_int(frame_count, 1,"number of stack frames inspected by the profiler") DEFINE_bool(self_optimization, false,"primitive functions trigger their own optimization") DEFINE_bool(direct_self_opt, false,"call recompile stub directly when self-optimizing") DEFINE_bool(retry_self_opt, false,"re-try self-optimization if it failed") DEFINE_bool(count_based_interrupts, false,"trigger profiler ticks based on counting instead of timing") DEFINE_bool(interrupt_at_exit, false,"insert an interrupt check at function exit") DEFINE_bool(weighted_back_edges, false,"weight back edges by jump distance for interrupt triggering") DEFINE_int(interrupt_budget, 5900,"execution budget before interrupt is triggered") DEFINE_int(type_info_threshold, 15,"percentage of ICs that must have type info to allow optimization") DEFINE_int(self_opt_count, 130,"call count before self-optimization") DEFINE_implication(experimental_profiler, watch_ic_patching) DEFINE_implication(experimental_profiler, self_optimization) DEFINE_implication(experimental_profiler, retry_self_opt) DEFINE_implication(experimental_profiler, count_based_interrupts) DEFINE_implication(experimental_profiler, interrupt_at_exit) DEFINE_implication(experimental_profiler, weighted_back_edges) DEFINE_bool(trace_opt_verbose, false,"extra verbose compilation tracing") DEFINE_implication(trace_opt_verbose, trace_opt) DEFINE_bool(debug_code, false,"generate extra code (assertions) for debugging") DEFINE_bool(code_comments, false,"emit comments in code disassembly") DEFINE_bool(enable_sse2, true,"enable use of SSE2 instructions if available") DEFINE_bool(enable_sse3, true,"enable use of SSE3 instructions if available") DEFINE_bool(enable_sse4_1, true,"enable use of SSE4.1 instructions if available") DEFINE_bool(enable_cmov, true,"enable use of CMOV instruction if available") DEFINE_bool(enable_rdtsc, true,"enable use of RDTSC instruction if available") DEFINE_bool(enable_sahf, true,"enable use of SAHF instruction if available (X64 only)") DEFINE_bool(enable_vfp3, true,"enable use of VFP3 instructions if available - this implies ""enabling ARMv7 instructions (ARM only)") DEFINE_bool(enable_armv7, true,"enable use of ARMv7 instructions if available (ARM only)") DEFINE_bool(enable_fpu, true,"enable use of MIPS FPU instructions if available (MIPS only)") DEFINE_string(expose_natives_as, NULL,"expose natives in global object") DEFINE_string(expose_debug_as, NULL,"expose debug in global object") DEFINE_bool(expose_gc, false,"expose gc extension") DEFINE_bool(expose_externalize_string, false,"expose externalize string extension") DEFINE_int(stack_trace_limit, 10,"number of stack frames to capture") DEFINE_bool(builtins_in_stack_traces, false,"show built-in functions in stack traces") DEFINE_bool(disable_native_files, false,"disable builtin natives files") DEFINE_bool(inline_new, true,"use fast inline allocation") DEFINE_bool(stack_trace_on_abort, true,"print a stack trace if an assertion failure occurs") DEFINE_bool(trace, false,"trace function calls") DEFINE_bool(mask_constants_with_cookie, true,"use random jit cookie to mask large constants") DEFINE_bool(lazy, true,"use lazy compilation") DEFINE_bool(trace_opt, false,"trace lazy optimization") DEFINE_bool(trace_opt_stats, false,"trace lazy optimization statistics") DEFINE_bool(opt, true,"use adaptive optimizations") DEFINE_bool(always_opt, false,"always try to optimize functions") DEFINE_bool(prepare_always_opt, false,"prepare for turning on always opt") DEFINE_bool(trace_deopt, false,"trace deoptimization") DEFINE_int(min_preparse_length, 1024,"minimum length for automatic enable preparsing") DEFINE_bool(always_full_compiler, false,"try to use the dedicated run-once backend for all code") DEFINE_bool(trace_bailout, false,"print reasons for falling back to using the classic V8 backend") DEFINE_bool(compilation_cache, true,"enable compilation cache") DEFINE_bool(cache_prototype_transitions, true,"cache prototype transitions") DEFINE_bool(trace_debug_json, false,"trace debugging JSON request/response") DEFINE_bool(debugger_auto_break, true,"automatically set the debug break flag when debugger commands are ""in the queue") DEFINE_bool(enable_liveedit, true,"enable liveedit experimental feature") DEFINE_bool(break_on_abort, true,"always cause a debug break before aborting") DEFINE_int(stack_size, kPointerSize *123,"default size of stack region v8 is allowed to use (in kBytes)") DEFINE_int(max_stack_trace_source_length, 300,"maximum length of function source code printed in a stack trace.") DEFINE_bool(always_inline_smi_code, false,"always inline smi code in non-opt code") DEFINE_int(max_new_space_size, 0,"max size of the new generation (in kBytes)") DEFINE_int(max_old_space_size, 0,"max size of the old generation (in Mbytes)") DEFINE_int(max_executable_size, 0,"max size of executable memory (in Mbytes)") DEFINE_bool(gc_global, false,"always perform global GCs") DEFINE_int(gc_interval,-1,"garbage collect after <n> allocations") DEFINE_bool(trace_gc, false,"print one trace line following each garbage collection") DEFINE_bool(trace_gc_nvp, false,"print one detailed trace line in name=value format ""after each garbage collection") DEFINE_bool(print_cumulative_gc_stat, false,"print cumulative GC statistics in name=value format on exit") DEFINE_bool(trace_gc_verbose, false,"print more details following each garbage collection") DEFINE_bool(trace_fragmentation, false,"report fragmentation for old pointer and data pages") DEFINE_bool(collect_maps, true,"garbage collect maps from which no objects can be reached") DEFINE_bool(flush_code, true,"flush code that we expect not to use again before full gc") DEFINE_bool(incremental_marking, true,"use incremental marking") DEFINE_bool(incremental_marking_steps, true,"do incremental marking steps") DEFINE_bool(trace_incremental_marking, false,"trace progress of the incremental marking") DEFINE_bool(use_idle_notification, true,"Use idle notification to reduce memory footprint.") DEFINE_bool(send_idle_notification, false,"Send idle notifcation between stress runs.") DEFINE_bool(use_ic, true,"use inline caching") DEFINE_bool(native_code_counters, false,"generate extra code for manipulating stats counters") DEFINE_bool(always_compact, false,"Perform compaction on every full GC") DEFINE_bool(lazy_sweeping, true,"Use lazy sweeping for old pointer and data spaces") DEFINE_bool(never_compact, false,"Never perform compaction on full GC - testing only") DEFINE_bool(compact_code_space, true,"Compact code space on full non-incremental collections") DEFINE_bool(cleanup_code_caches_at_gc, true,"Flush inline caches prior to mark compact collection and ""flush code caches in maps during mark compact cycle.") DEFINE_int(random_seed, 0,"Default seed for initializing random generator ""(0, the default, means to use system random).") DEFINE_bool(use_verbose_printer, true,"allows verbose printing") DEFINE_bool(allow_natives_syntax, false,"allow natives syntax") DEFINE_bool(trace_sim, false,"Trace simulator execution") DEFINE_bool(check_icache, false,"Check icache flushes in ARM and MIPS simulator") DEFINE_int(stop_sim_at, 0,"Simulator stop after x number of instructions") DEFINE_int(sim_stack_alignment, 8,"Stack alingment in bytes in simulator (4 or 8, 8 is default)") DEFINE_bool(trace_exception, false,"print stack trace when throwing exceptions") DEFINE_bool(preallocate_message_memory, false,"preallocate some memory to build stack traces.") DEFINE_bool(randomize_hashes, true,"randomize hashes to avoid predictable hash collisions ""(with snapshots this option cannot override the baked-in seed)") DEFINE_int(hash_seed, 0,"Fixed seed to use to hash property keys (0 means random)""(with snapshots this option cannot override the baked-in seed)") DEFINE_bool(preemption, false,"activate a 100ms timer that switches between V8 threads") DEFINE_bool(regexp_optimization, true,"generate optimized regexp code") DEFINE_bool(testing_bool_flag, true,"testing_bool_flag") DEFINE_int(testing_int_flag, 13,"testing_int_flag") DEFINE_float(testing_float_flag, 2.5,"float-flag") DEFINE_string(testing_string_flag,"Hello, world!","string-flag") DEFINE_int(testing_prng_seed, 42,"Seed used for threading test randomness") DEFINE_string(testing_serialization_file,"/tmp/serdes","file in which to serialize heap") DEFINE_bool(help, false,"Print usage message, including flags, on console") DEFINE_bool(dump_counters, false,"Dump counters on exit") DEFINE_string(map_counters,"","Map counters to a file") DEFINE_args(js_arguments, JSARGUMENTS_INIT,"Pass all remaining arguments to the script. Alias for \"--\".") DEFINE_bool(debug_compile_events, true,"Enable debugger compile events") DEFINE_bool(debug_script_collected_events, true,"Enable debugger script collected events") DEFINE_bool(gdbjit, false,"enable GDBJIT interface (disables compacting GC)") DEFINE_bool(gdbjit_full, false,"enable GDBJIT interface for all code objects") DEFINE_bool(gdbjit_dump, false,"dump elf objects with debug info to disk") DEFINE_string(gdbjit_dump_filter,"","dump only objects containing this substring") DEFINE_bool(force_marking_deque_overflows, false,"force overflows of marking deque by reducing it's size ""to 64 words") DEFINE_bool(stress_compaction, false,"stress the GC compactor to flush out bugs (implies ""--force_marking_deque_overflows)")#define FLAG DEFINE_bool(enable_slow_asserts, false,"enable asserts that are slow to execute") DEFINE_bool(trace_codegen, false,"print name of functions for which code is generated") DEFINE_bool(print_source, false,"pretty print source code") DEFINE_bool(print_builtin_source, false,"pretty print source code for builtins") DEFINE_bool(print_ast, false,"print source AST") DEFINE_bool(print_builtin_ast, false,"print source AST for builtins") DEFINE_string(stop_at,"","function name where to insert a breakpoint") DEFINE_bool(print_builtin_scopes, false,"print scopes for builtins") DEFINE_bool(print_scopes, false,"print scopes") DEFINE_bool(trace_contexts, false,"trace contexts operations") DEFINE_bool(gc_greedy, false,"perform GC prior to some allocations") DEFINE_bool(gc_verbose, false,"print stuff during garbage collection") DEFINE_bool(heap_stats, false,"report heap statistics before and after GC") DEFINE_bool(code_stats, false,"report code statistics after GC") DEFINE_bool(verify_heap, false,"verify heap pointers before and after GC") DEFINE_bool(print_handles, false,"report handles after GC") DEFINE_bool(print_global_handles, false,"report global handles after GC") DEFINE_bool(trace_ic, false,"trace inline cache state transitions") DEFINE_bool(print_interfaces, false,"print interfaces") DEFINE_bool(print_interface_details, false,"print interface inference details") DEFINE_int(print_interface_depth, 5,"depth for printing interfaces") DEFINE_bool(trace_normalization, false,"prints when objects are turned into dictionaries.") DEFINE_bool(trace_lazy, false,"trace lazy compilation") DEFINE_bool(collect_heap_spill_statistics, false,"report heap spill statistics along with heap_stats ""(requires heap_stats)") DEFINE_bool(trace_isolates, false,"trace isolate state changes") DEFINE_bool(log_state_changes, false,"Log state changes.") DEFINE_bool(regexp_possessive_quantifier, false,"enable possessive quantifier syntax for testing") DEFINE_bool(trace_regexp_bytecodes, false,"trace regexp bytecode execution") DEFINE_bool(trace_regexp_assembler, false,"trace regexp macro assembler calls.")#define FLAG DEFINE_bool(log, false,"Minimal logging (no API, code, GC, suspect, or handles samples).") DEFINE_bool(log_all, false,"Log all events to the log file.") DEFINE_bool(log_runtime, false,"Activate runtime system %Log call.") DEFINE_bool(log_api, false,"Log API events to the log file.") DEFINE_bool(log_code, false,"Log code events to the log file without profiling.") DEFINE_bool(log_gc, false,"Log heap samples on garbage collection for the hp2ps tool.") DEFINE_bool(log_handles, false,"Log global handle events.") DEFINE_bool(log_snapshot_positions, false,"log positions of (de)serialized objects in the snapshot.") DEFINE_bool(log_suspect, false,"Log suspect operations.") DEFINE_bool(prof, false,"Log statistical profiling information (implies --log-code).") DEFINE_bool(prof_auto, true,"Used with --prof, starts profiling automatically") DEFINE_bool(prof_lazy, false,"Used with --prof, only does sampling and logging"" when profiler is active (implies --noprof_auto).") DEFINE_bool(prof_browser_mode, true,"Used with --prof, turns on browser-compatible mode for profiling.") DEFINE_bool(log_regexp, false,"Log regular expression execution.") DEFINE_bool(sliding_state_window, false,"Update sliding state window counters.") DEFINE_string(logfile,"v8.log","Specify the name of the log file.") DEFINE_bool(ll_prof, false,"Enable low-level linux profiler.")#define FLAG DEFINE_bool(trace_elements_transitions, false,"trace elements transitions") DEFINE_bool(print_code_stubs, false,"print code stubs") DEFINE_bool(test_secondary_stub_cache, false,"test secondary stub cache by disabling the primary one") DEFINE_bool(test_primary_stub_cache, false,"test primary stub cache by disabling the secondary one") DEFINE_bool(print_code, false,"print generated code") DEFINE_bool(print_opt_code, false,"print optimized code") DEFINE_bool(print_unopt_code, false,"print unoptimized code before ""printing optimized code based on it") DEFINE_bool(print_code_verbose, false,"print more information for code") DEFINE_bool(print_builtin_code, false,"print generated code for builtins")#47"/Users/thlorenz/dev/dx/v8-perf/build/v8/src/flags.cc"2 namespace{struct Flag{enum FlagType{TYPE_BOOL, TYPE_INT, TYPE_FLOAT, TYPE_STRING, TYPE_ARGS} name
IN HANDLE IN PSTR IN PSTR ModuleName
SamplerThread(int interval)
const uint64_t kQuietNaNMask
static bool IsOutsideAllocatedSpace(void *pointer)
static const char * LocalTimezone(double time)
Vector< char > MutableCStrVector(char *data)
Win32Semaphore(int count)
static const int kStackWalkError
static SamplerThread * instance_
static int GetUserTime(uint32_t *secs, uint32_t *usecs)
static const int kStackWalkMaxTextLen
bool Listen(int backlog) const
static void AddActiveSampler(Sampler *sampler)
#define ASSERT(condition)
typedef HANDLE(__stdcall *DLL_FUNC_TYPE(CreateToolhelp32Snapshot))(DWORD dwFlags
static void VFPrint(FILE *out, const char *format, va_list args)
IN HANDLE IN PSTR IN PSTR IN DWORD64 IN DWORD SizeOfDll
static MemoryMappedFile * open(const char *name)
static void RemoveActiveSampler(Sampler *sampler)
bool Bind(const int port)
typedef DWORD(__stdcall *DLL_FUNC_TYPE(SymGetOptions))(VOID)
int Send(const char *data, int len) const
IN HANDLE IN PSTR ImageName
HANDLE HANDLE LPSTACKFRAME64 StackFrame
virtual void * memory()=0
int Receive(char *data, int len) const
static void StopRuntimeProfilerThreadBeforeShutdown(Thread *thread)
typedef BOOL(__stdcall *DLL_FUNC_TYPE(SymInitialize))(IN HANDLE hProcess
typedef DWORD64(__stdcall *DLL_FUNC_TYPE(SymLoadModule64))(IN HANDLE hProcess
bool SetReuseAddress(bool reuse_address)
IN HANDLE IN PSTR IN PSTR IN DWORD64 BaseOfDll
static void ReleaseStore(volatile AtomicWord *ptr, AtomicWord value)
Win32MemoryMappedFile(HANDLE file, HANDLE file_mapping, void *memory, int size)
static void MemCopy(void *dest, const void *src, size_t size)
RuntimeProfiler * runtime_profiler()
static TickSample * TickSampleEvent(Isolate *isolate)
HANDLE HANDLE LPSTACKFRAME64 PVOID ContextRecord
static void ProtectCode(void *address, const size_t size)
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 trace on stack replacement optimize closures functions with arguments object optimize functions containing for in loops profiler considers IC stability primitive functions trigger their own optimization re try self optimization if it failed insert an interrupt check at function exit execution budget before interrupt is triggered call count before self optimization self_optimization count_based_interrupts weighted_back_edges trace_opt 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 enable use of ARMv7 instructions if enable use of MIPS FPU instructions if NULL
virtual ~Win32MemoryMappedFile()
HANDLE HANDLE LPSTACKFRAME64 PVOID PREAD_PROCESS_MEMORY_ROUTINE64 ReadMemoryRoutine
static LocalStorageKey CreateThreadLocalKey()
static FILE * FOpen(const char *path, const char *mode)
bool IsAligned(T value, U alignment)
static MemoryMappedFile * create(const char *name, int size, void *initial)
static void VPrint(const char *format, va_list args)
#define DISALLOW_COPY_AND_ASSIGN(TypeName)
UnaryMathFunction CreateSqrtFunction()
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 uint16_t NToH(uint16_t value)
T RoundUp(T x, intptr_t m)
static Mutex * CreateMutex()
static double TimeCurrentMillis()
static void DoCpuProfile(Sampler *sampler, void *raw_sampler_thread)
static uint16_t HToN(uint16_t value)
static void DeleteThreadLocalKey(LocalStorageKey key)
static void Sleep(const int milliseconds)
static void Print(const char *format,...)
HANDLE HANDLE LPSTACKFRAME64 PVOID PREAD_PROCESS_MEMORY_ROUTINE64 PFUNCTION_TABLE_ACCESS_ROUTINE64 PGET_MODULE_BASE_ROUTINE64 GetModuleBaseRoutine
static int SNPrintF(Vector< char > str, const char *format,...)
static Semaphore * CreateSemaphore(int count)
static const int kStackWalkMaxNameLen
bool Connect(const char *host, const char *port)
void SampleContext(Sampler *sampler)
static double nan_value()
static uint32_t RandomPrivate(Isolate *isolate)
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 void LogSharedLibraryAddresses()
OUT PSTR IN DWORD SearchPathLength
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 trace on stack replacement optimize closures functions with arguments object optimize functions containing for in loops profiler considers IC stability primitive functions trigger their own optimization re try self optimization if it failed insert an interrupt check at function exit execution budget before interrupt is triggered call count before self optimization self_optimization count_based_interrupts weighted_back_edges trace_opt 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 enable use of ARMv7 instructions if enable use of MIPS FPU instructions if NULL
static void StrNCpy(Vector< char > dest, const char *src, size_t n)
static int ActivationFrameAlignment()
const char * name() const
IN DWORD64 OUT PDWORD64 OUT PIMAGEHLP_SYMBOL64 Symbol
static double DaylightSavingsOffset(double time)
static size_t AllocateAlignment()
static void AddActiveSampler(Sampler *sampler)
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 bool IterateActiveSamplers(VisitSampler func, void *param)
static void FPrint(FILE *out, const char *format,...)
static double LocalTimeOffset()
IN PSTR IN BOOL fInvadeProcess
HANDLE HANDLE LPSTACKFRAME64 PVOID PREAD_PROCESS_MEMORY_ROUTINE64 PFUNCTION_TABLE_ACCESS_ROUTINE64 FunctionTableAccessRoutine
int64_t DaylightSavingsOffset()
static intptr_t CommitPageSize()
static const char *const LogFileOpenMode
UnaryMathFunction CreateTranscendentalFunction(TranscendentalCache::Type type)
uint32_t RoundUpToPowerOf2(uint32_t x)
static char * StrChr(char *str, int c)
static Socket * CreateSocket()
static void DoRuntimeProfile(Sampler *sampler, void *ignored)