From a4f5ce9b4def3317c06b96d2329c6e72ab3153f9 Mon Sep 17 00:00:00 2001 From: Ivailo Monev Date: Wed, 26 Apr 2017 06:28:54 +0000 Subject: [PATCH] JavaScriptCore cleanups Signed-off-by: Ivailo Monev --- .../javascriptcore/bytecode/SamplingTool.cpp | 12 +- .../javascriptcore/interpreter/RegisterFile.cpp | 20 +- .../javascriptcore/interpreter/RegisterFile.h | 34 +-- src/3rdparty/javascriptcore/runtime/Collector.cpp | 87 +------ src/3rdparty/javascriptcore/runtime/Collector.h | 4 - src/3rdparty/javascriptcore/runtime/MarkStack.h | 7 - .../javascriptcore/runtime/TimeoutChecker.cpp | 35 --- src/3rdparty/javascriptcore/runtime/UString.cpp | 4 - .../javascriptcore/wtf/CONTRIBUTORS.pthreads-win32 | 137 ----------- src/3rdparty/javascriptcore/wtf/CurrentTime.cpp | 253 --------------------- src/3rdparty/javascriptcore/wtf/CurrentTime.h | 16 +- src/3rdparty/javascriptcore/wtf/DateMath.cpp | 14 +- src/3rdparty/javascriptcore/wtf/Platform.h | 9 - src/3rdparty/javascriptcore/wtf/StringExtras.h | 2 +- src/3rdparty/javascriptcore/wtf/Threading.h | 14 -- src/script/CMakeLists.txt | 1 - 16 files changed, 17 insertions(+), 632 deletions(-) delete mode 100644 src/3rdparty/javascriptcore/wtf/CONTRIBUTORS.pthreads-win32 delete mode 100644 src/3rdparty/javascriptcore/wtf/CurrentTime.cpp diff --git a/src/3rdparty/javascriptcore/bytecode/SamplingTool.cpp b/src/3rdparty/javascriptcore/bytecode/SamplingTool.cpp index b3e83e1c0..4c0718cf9 100644 --- a/src/3rdparty/javascriptcore/bytecode/SamplingTool.cpp +++ b/src/3rdparty/javascriptcore/bytecode/SamplingTool.cpp @@ -33,9 +33,7 @@ #include "Interpreter.h" #include "Opcode.h" -#if !OS(WINDOWS) #include -#endif namespace JSC { @@ -100,15 +98,7 @@ ThreadIdentifier SamplingThread::s_samplingThread; void* SamplingThread::threadStartFunc(void*) { while (s_running) { - unsigned us = 1000000 / s_hertz; -#if OS(WINDOWS) - unsigned ms = us / 1000; - if (us && !ms) - ms = 1; - Sleep(ms); -#else - usleep(us); -#endif // OS(WINDOWS) + usleep(1000000 / s_hertz); #if ENABLE(SAMPLING_FLAGS) SamplingFlags::sample(); diff --git a/src/3rdparty/javascriptcore/interpreter/RegisterFile.cpp b/src/3rdparty/javascriptcore/interpreter/RegisterFile.cpp index ed98a413d..eb6d8563f 100644 --- a/src/3rdparty/javascriptcore/interpreter/RegisterFile.cpp +++ b/src/3rdparty/javascriptcore/interpreter/RegisterFile.cpp @@ -35,11 +35,6 @@ RegisterFile::~RegisterFile() { #if HAVE(MMAP) munmap(reinterpret_cast(m_buffer), ((m_max - m_start) + m_maxGlobals) * sizeof(Register)); -#elif HAVE(VIRTUALALLOC) -#if OS(WINCE) - VirtualFree(m_buffer, DWORD(m_commitEnd) - DWORD(m_buffer), MEM_DECOMMIT); -#endif - VirtualFree(m_buffer, 0, MEM_RELEASE); #else fastFree(m_buffer); #endif @@ -47,21 +42,8 @@ RegisterFile::~RegisterFile() void RegisterFile::releaseExcessCapacity() { -#if OS(QNX) - size_t sizeForGlobals = roundUpAllocationSize(m_maxGlobals * sizeof(Register), commitSize); - Register *endOfGlobals = reinterpret_cast(reinterpret_cast(m_buffer) + sizeForGlobals); - size_t decommitSize = (m_max - endOfGlobals) * sizeof(Register); - if (decommitSize > 0) { - if (mmap(endOfGlobals, decommitSize, PROT_NONE, MAP_FIXED|MAP_LAZY|MAP_PRIVATE|MAP_ANON, -1, 0) == MAP_FAILED) - fprintf(stderr, "Could not decommit register file memory: %d\n", errno); - } - m_commitEnd = endOfGlobals; - -#elif HAVE(MMAP) && HAVE(MADV_FREE) && !HAVE(VIRTUALALLOC) +#if HAVE(MMAP) && HAVE(MADV_FREE) while (madvise(m_start, (m_max - m_start) * sizeof(Register), MADV_FREE) == -1 && errno == EAGAIN) { } -#elif HAVE(VIRTUALALLOC) - VirtualFree(m_start, (m_max - m_start) * sizeof(Register), MEM_DECOMMIT); - m_commitEnd = m_start; #endif m_maxUsed = m_start; } diff --git a/src/3rdparty/javascriptcore/interpreter/RegisterFile.h b/src/3rdparty/javascriptcore/interpreter/RegisterFile.h index 4ba83e48a..b84d907e7 100644 --- a/src/3rdparty/javascriptcore/interpreter/RegisterFile.h +++ b/src/3rdparty/javascriptcore/interpreter/RegisterFile.h @@ -147,10 +147,6 @@ namespace JSC { Register* m_buffer; Register* m_maxUsed; -#if HAVE(VIRTUALALLOC) - Register* m_commitEnd; -#endif - JSGlobalObject* m_globalObject; // The global object whose vars are currently stored in the register file. }; @@ -167,7 +163,7 @@ namespace JSC { , m_buffer(0) , m_globalObject(0) { - // Verify that our values will play nice with mmap and VirtualAlloc. + // Verify that our values will play nice with mmap. Q_ASSERT(isPageAligned(maxGlobals)); Q_ASSERT(isPageAligned(capacity)); @@ -178,27 +174,14 @@ namespace JSC { fprintf(stderr, "Could not allocate register file: %d\n", errno); CRASH(); } - #elif HAVE(VIRTUALALLOC) - m_buffer = static_cast(VirtualAlloc(0, roundUpAllocationSize(bufferLength, commitSize), MEM_RESERVE, PAGE_READWRITE)); - if (!m_buffer) { - fprintf(stderr, "Could not allocate register file: %d\n", errno); - CRASH(); - } - size_t committedSize = roundUpAllocationSize(maxGlobals * sizeof(Register), commitSize); - void* commitCheck = VirtualAlloc(m_buffer, committedSize, MEM_COMMIT, PAGE_READWRITE); - if (commitCheck != m_buffer) { - fprintf(stderr, "Could not allocate register file: %d\n", errno); - CRASH(); - } - m_commitEnd = reinterpret_cast(reinterpret_cast(m_buffer) + committedSize); #else /* - * If neither MMAP nor VIRTUALALLOC are available - use fastMalloc instead. + * If MMAP is not available - use fastMalloc instead. * * Please note that this is the fallback case, which is non-optimal. * If any possible, the platform should provide for a better memory * allocation mechanism that allows for "lazy commit" or dynamic - * pre-allocation, similar to mmap or VirtualAlloc, to avoid waste of memory. + * pre-allocation, similar to mmap, to avoid waste of memory. */ m_buffer = static_cast(fastMalloc(bufferLength)); #endif @@ -226,17 +209,6 @@ namespace JSC { if (newEnd > m_max) return false; -#if !HAVE(MMAP) && HAVE(VIRTUALALLOC) - if (newEnd > m_commitEnd) { - size_t size = roundUpAllocationSize(reinterpret_cast(newEnd) - reinterpret_cast(m_commitEnd), commitSize); - if (!VirtualAlloc(m_commitEnd, size, MEM_COMMIT, PAGE_READWRITE)) { - fprintf(stderr, "Could not allocate register file: %d\n", errno); - CRASH(); - } - m_commitEnd = reinterpret_cast(reinterpret_cast(m_commitEnd) + size); - } -#endif - if (newEnd > m_maxUsed) m_maxUsed = newEnd; diff --git a/src/3rdparty/javascriptcore/runtime/Collector.cpp b/src/3rdparty/javascriptcore/runtime/Collector.cpp index 55c620197..6e5875657 100644 --- a/src/3rdparty/javascriptcore/runtime/Collector.cpp +++ b/src/3rdparty/javascriptcore/runtime/Collector.cpp @@ -42,22 +42,7 @@ #include #include -#if OS(DARWIN) - -#include -#include -#include -#include -#include -// clang's libc++ headers does not pull in pthread.h (but libstdc++ does) -#include - -#elif OS(WINDOWS) - -#include -#include - -#elif OS(HAIKU) +#if OS(HAIKU) #include @@ -79,10 +64,6 @@ #include #endif -#if OS(QNX) -#include -#endif - #endif #define COLLECT_ON_EVERY_ALLOCATION 0 @@ -362,63 +343,6 @@ void Heap::shrinkBlocks(size_t neededBlocks) m_heap.blocks[i]->marked.set(HeapConstants::cellsPerBlock - 1); } -#if OS(WINCE) -void* g_stackBase = 0; - -inline bool isPageWritable(void* page) -{ - MEMORY_BASIC_INFORMATION memoryInformation; - DWORD result = VirtualQuery(page, &memoryInformation, sizeof(memoryInformation)); - - // return false on error, including ptr outside memory - if (result != sizeof(memoryInformation)) - return false; - - DWORD protect = memoryInformation.Protect & ~(PAGE_GUARD | PAGE_NOCACHE); - return protect == PAGE_READWRITE - || protect == PAGE_WRITECOPY - || protect == PAGE_EXECUTE_READWRITE - || protect == PAGE_EXECUTE_WRITECOPY; -} - -static void* getStackBase(void* previousFrame) -{ - // find the address of this stack frame by taking the address of a local variable - bool isGrowingDownward; - void* thisFrame = (void*)(&isGrowingDownward); - - isGrowingDownward = previousFrame < &thisFrame; - static DWORD pageSize = 0; - if (!pageSize) { - SYSTEM_INFO systemInfo; - GetSystemInfo(&systemInfo); - pageSize = systemInfo.dwPageSize; - } - - // scan all of memory starting from this frame, and return the last writeable page found - register char* currentPage = (char*)((DWORD)thisFrame & ~(pageSize - 1)); - if (isGrowingDownward) { - while (currentPage > 0) { - // check for underflow - if (currentPage >= (char*)pageSize) - currentPage -= pageSize; - else - currentPage = 0; - if (!isPageWritable(currentPage)) - return currentPage + pageSize; - } - return 0; - } else { - while (true) { - // guaranteed to complete because isPageWritable returns false at end of memory - currentPage += pageSize; - if (!isPageWritable(currentPage)) - return currentPage; - } - } -} -#endif - #if OS(HPUX) struct hpux_get_stack_base_data { @@ -467,8 +391,6 @@ static inline void* currentThreadStackBase() { #if OS(HPUX) return hpux_get_stack_base(); -#elif OS(QNX) - return (void *) (((uintptr_t)__tls() + __PAGESIZE - 1) & ~(__PAGESIZE - 1)); #elif OS(SOLARIS) stack_t s; thr_stksegment(&s); @@ -613,14 +535,7 @@ void Heap::markCurrentThreadConservatively(MarkStack& markStack) { // setjmp forces volatile registers onto the stack jmp_buf registers REGISTER_BUFFER_ALIGNMENT; -#if COMPILER(MSVC) -#pragma warning(push) -#pragma warning(disable: 4611) -#endif setjmp(registers); -#if COMPILER(MSVC) -#pragma warning(pop) -#endif markCurrentThreadConservativelyInternal(markStack); } diff --git a/src/3rdparty/javascriptcore/runtime/Collector.h b/src/3rdparty/javascriptcore/runtime/Collector.h index 3690c5f75..447159ce0 100644 --- a/src/3rdparty/javascriptcore/runtime/Collector.h +++ b/src/3rdparty/javascriptcore/runtime/Collector.h @@ -152,11 +152,7 @@ namespace JSC { JSGlobalData* m_globalData; }; -#if OS(WINCE) - const size_t BLOCK_SIZE = 64 * 1024; // 64k -#else const size_t BLOCK_SIZE = 64 * 4096; // 256k -#endif // derived constants const size_t BLOCK_OFFSET_MASK = BLOCK_SIZE - 1; diff --git a/src/3rdparty/javascriptcore/runtime/MarkStack.h b/src/3rdparty/javascriptcore/runtime/MarkStack.h index 2dcb52256..dfa385073 100644 --- a/src/3rdparty/javascriptcore/runtime/MarkStack.h +++ b/src/3rdparty/javascriptcore/runtime/MarkStack.h @@ -153,14 +153,7 @@ namespace JSC { Q_ASSERT(0 == (size % MarkStack::pageSize())); if (size == m_allocated) return; -#if OS(WINDOWS) || PLATFORM(BREWMP) - // We cannot release a part of a region with VirtualFree. To get around this, - // we'll release the entire region and reallocate the size that we want. - releaseStack(m_data, m_allocated); - m_data = reinterpret_cast(allocateStack(size)); -#else releaseStack(reinterpret_cast(m_data) + size, m_allocated - size); -#endif m_allocated = size; m_capacity = m_allocated / sizeof(T); } diff --git a/src/3rdparty/javascriptcore/runtime/TimeoutChecker.cpp b/src/3rdparty/javascriptcore/runtime/TimeoutChecker.cpp index 0ee8b784e..25e9ad018 100644 --- a/src/3rdparty/javascriptcore/runtime/TimeoutChecker.cpp +++ b/src/3rdparty/javascriptcore/runtime/TimeoutChecker.cpp @@ -32,14 +32,7 @@ #include "CallFrame.h" #include "JSGlobalObject.h" - -#if OS(DARWIN) -#include -#elif OS(WINDOWS) -#include -#else #include "CurrentTime.h" -#endif using namespace std; @@ -54,36 +47,8 @@ static const int defaultIntervalBetweenChecks = 1000; // Returns the time the current thread has spent executing, in milliseconds. static inline unsigned getCPUTime() { -#if OS(DARWIN) - mach_msg_type_number_t infoCount = THREAD_BASIC_INFO_COUNT; - thread_basic_info_data_t info; - - // Get thread information - mach_port_t threadPort = mach_thread_self(); - thread_info(threadPort, THREAD_BASIC_INFO, reinterpret_cast(&info), &infoCount); - mach_port_deallocate(mach_task_self(), threadPort); - - unsigned time = info.user_time.seconds * 1000 + info.user_time.microseconds / 1000; - time += info.system_time.seconds * 1000 + info.system_time.microseconds / 1000; - - return time; -#elif OS(WINDOWS) - union { - FILETIME fileTime; - unsigned long long fileTimeAsLong; - } userTime, kernelTime; - - // GetThreadTimes won't accept NULL arguments so we pass these even though - // they're not used. - FILETIME creationTime, exitTime; - - GetThreadTimes(GetCurrentThread(), &creationTime, &exitTime, &kernelTime.fileTime, &userTime.fileTime); - - return userTime.fileTimeAsLong / 10000 + kernelTime.fileTimeAsLong / 10000; -#else // FIXME: We should return the time the current thread has spent executing. return currentTime() * 1000; -#endif } TimeoutChecker::TimeoutChecker() diff --git a/src/3rdparty/javascriptcore/runtime/UString.cpp b/src/3rdparty/javascriptcore/runtime/UString.cpp index a840b08c9..c0446520d 100644 --- a/src/3rdparty/javascriptcore/runtime/UString.cpp +++ b/src/3rdparty/javascriptcore/runtime/UString.cpp @@ -179,11 +179,7 @@ UString UString::from(long long i) *--p = '0'; else if (i == std::numeric_limits::min()) { char minBuf[1 + sizeof(i) * 3]; -#if OS(WINDOWS) - snprintf(minBuf, sizeof(minBuf) - 1, "%I64d", std::numeric_limits::min()); -#else snprintf(minBuf, sizeof(minBuf) - 1, "%lld", std::numeric_limits::min()); -#endif return UString(minBuf); } else { bool negative = false; diff --git a/src/3rdparty/javascriptcore/wtf/CONTRIBUTORS.pthreads-win32 b/src/3rdparty/javascriptcore/wtf/CONTRIBUTORS.pthreads-win32 deleted file mode 100644 index 7de0f2606..000000000 --- a/src/3rdparty/javascriptcore/wtf/CONTRIBUTORS.pthreads-win32 +++ /dev/null @@ -1,137 +0,0 @@ -This is a copy of CONTRIBUTORS file for the Pthreads-win32 library, downloaded -from http://sourceware.org/cgi-bin/cvsweb.cgi/~checkout~/pthreads/CONTRIBUTORS?rev=1.32&cvsroot=pthreads-win32 - -Included here to compliment the Pthreads-win32 license header in wtf/ThreadingWin.cpp file. -WebKit is using derived sources of ThreadCondition code from Pthreads-win32. - -------------------------------------------------------------------------------- - -Contributors (in approximate order of appearance) - -[See also the ChangeLog file where individuals are -attributed in log entries. Likewise in the FAQ file.] - -Ben Elliston bje at cygnus dot com - Initiated the project; - setup the project infrastructure (CVS, web page, etc.); - early prototype routines. -Ross Johnson rpj at callisto dot canberra dot edu dot au - early prototype routines; - ongoing project coordination/maintenance; - implementation of spin locks and barriers; - various enhancements; - bug fixes; - documentation; - testsuite. -Robert Colquhoun rjc at trump dot net dot au - Early bug fixes. -John E. Bossom John dot Bossom at cognos dot com - Contributed substantial original working implementation; - bug fixes; - ongoing guidance and standards interpretation. -Anders Norlander anorland at hem2 dot passagen dot se - Early enhancements and runtime checking for supported - Win32 routines. -Tor Lillqvist tml at iki dot fi - General enhancements; - early bug fixes to condition variables. -Scott Lightner scott at curriculum dot com - Bug fix. -Kevin Ruland Kevin dot Ruland at anheuser-busch dot com - Various bug fixes. -Mike Russo miker at eai dot com - Bug fix. -Mark E. Armstrong avail at pacbell dot net - Bug fixes. -Lorin Hochstein lmh at xiphos dot ca - general bug fixes; bug fixes to condition variables. -Peter Slacik Peter dot Slacik at tatramed dot sk - Bug fixes. -Mumit Khan khan at xraylith dot wisc dot edu - Fixes to work with Mingw32. -Milan Gardian mg at tatramed dot sk - Bug fixes and reports/analyses of obscure problems. -Aurelio Medina aureliom at crt dot com - First implementation of read-write locks. -Graham Dumpleton Graham dot Dumpleton at ra dot pad dot otc dot telstra dot com dot au - Bug fix in condition variables. -Tristan Savatier tristan at mpegtv dot com - WinCE port. -Erik Hensema erik at hensema dot xs4all dot nl - Bug fixes. -Rich Peters rpeters at micro-magic dot com -Todd Owen towen at lucidcalm dot dropbear dot id dot au - Bug fixes to dll loading. -Jason Nye jnye at nbnet dot nb dot ca - Implementation of async cancelation. -Fred Forester fforest at eticomm dot net -Kevin D. Clark kclark at cabletron dot com -David Baggett dmb at itasoftware dot com - Bug fixes. -Paul Redondo paul at matchvision dot com -Scott McCaskill scott at 3dfx dot com - Bug fixes. -Jef Gearhart jgearhart at tpssys dot com - Bug fix. -Arthur Kantor akantor at bexusa dot com - Mutex enhancements. -Steven Reddie smr at essemer dot com dot au - Bug fix. -Alexander Terekhov TEREKHOV at de dot ibm dot com - Re-implemented and improved read-write locks; - (with Louis Thomas) re-implemented and improved - condition variables; - enhancements to semaphores; - enhancements to mutexes; - new mutex implementation in 'futex' style; - suggested a robust implementation of pthread_once - similar to that implemented by V.Kliathcko; - system clock change handling re CV timeouts; - bug fixes. -Thomas Pfaff tpfaff at gmx dot net - Changes to make C version usable with C++ applications; - re-implemented mutex routines to avoid Win32 mutexes - and TryEnterCriticalSection; - procedure to fix Mingw32 thread-safety issues. -Franco Bez franco dot bez at gmx dot de - procedure to fix Mingw32 thread-safety issues. -Louis Thomas lthomas at arbitrade dot com - (with Alexander Terekhov) re-implemented and improved - condition variables. -David Korn dgk at research dot att dot com - Ported to UWIN. -Phil Frisbie, Jr. phil at hawksoft dot com - Bug fix. -Ralf Brese Ralf dot Brese at pdb4 dot siemens dot de - Bug fix. -prionx at juno dot com prionx at juno dot com - Bug fixes. -Max Woodbury mtew at cds dot duke dot edu - POSIX versioning conditionals; - reduced namespace pollution; - idea to separate routines to reduce statically - linked image sizes. -Rob Fanner rfanner at stonethree dot com - Bug fix. -Michael Johnson michaelj at maine dot rr dot com - Bug fix. -Nicolas Barry boozai at yahoo dot com - Bug fixes. -Piet van Bruggen pietvb at newbridges dot nl - Bug fix. -Makoto Kato raven at oldskool dot jp - AMD64 port. -Panagiotis E. Hadjidoukas peh at hpclab dot ceid dot upatras dot gr - Contributed the QueueUserAPCEx package which - makes preemptive async cancelation possible. -Will Bryant will dot bryant at ecosm dot com - Borland compiler patch and makefile. -Anuj Goyal anuj dot goyal at gmail dot com - Port to Digital Mars compiler. -Gottlob Frege gottlobfrege at gmail dot com - re-implemented pthread_once (version 2) - (pthread_once cancellation added by rpj). -Vladimir Kliatchko vladimir at kliatchko dot com - reimplemented pthread_once with the same form - as described by A.Terekhov (later version 2); - implementation of MCS (Mellor-Crummey/Scott) locks. \ No newline at end of file diff --git a/src/3rdparty/javascriptcore/wtf/CurrentTime.cpp b/src/3rdparty/javascriptcore/wtf/CurrentTime.cpp deleted file mode 100644 index 699bc4bbb..000000000 --- a/src/3rdparty/javascriptcore/wtf/CurrentTime.cpp +++ /dev/null @@ -1,253 +0,0 @@ -/* - * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. - * Copyright (C) 2008 Google Inc. All rights reserved. - * Copyright (C) 2007-2009 Torch Mobile, Inc. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "Platform.h" -#include "CurrentTime.h" -#include "DateMath.h" - -#if OS(WINDOWS) - -// Windows is first since we want to use hires timers, despite PLATFORM(CF) -// being defined. -// If defined, WIN32_LEAN_AND_MEAN disables timeBeginPeriod/timeEndPeriod. -#undef WIN32_LEAN_AND_MEAN -#include -#include -#include -#include - -#if USE(QUERY_PERFORMANCE_COUNTER) -#if OS(WINCE) -extern "C" time_t mktime(struct tm *t); -#else -#include -#include -#endif -#endif - -#else // Posix systems relying on the gettimeofday() -#include -#endif -namespace WTF { - -#if OS(WINDOWS) - -#if USE(QUERY_PERFORMANCE_COUNTER) - -static LARGE_INTEGER qpcFrequency; -static bool syncedTime; - -static double highResUpTime() -{ - // We use QPC, but only after sanity checking its result, due to bugs: - // http://support.microsoft.com/kb/274323 - // http://support.microsoft.com/kb/895980 - // http://msdn.microsoft.com/en-us/library/ms644904.aspx ("...you can get different results on different processors due to bugs in the basic input/output system (BIOS) or the hardware abstraction layer (HAL)." - - static LARGE_INTEGER qpcLast; - static DWORD tickCountLast; - static bool inited; - - LARGE_INTEGER qpc; - QueryPerformanceCounter(&qpc); - DWORD tickCount = GetTickCount(); - - if (inited) { - __int64 qpcElapsed = ((qpc.QuadPart - qpcLast.QuadPart) * 1000) / qpcFrequency.QuadPart; - __int64 tickCountElapsed; - if (tickCount >= tickCountLast) - tickCountElapsed = (tickCount - tickCountLast); - else { -#if COMPILER(MINGW) - __int64 tickCountLarge = tickCount + 0x100000000ULL; -#else - __int64 tickCountLarge = tickCount + 0x100000000I64; -#endif - tickCountElapsed = tickCountLarge - tickCountLast; - } - - // force a re-sync if QueryPerformanceCounter differs from GetTickCount by more than 500ms. - // (500ms value is from http://support.microsoft.com/kb/274323) - __int64 diff = tickCountElapsed - qpcElapsed; - if (diff > 500 || diff < -500) - syncedTime = false; - } else - inited = true; - - qpcLast = qpc; - tickCountLast = tickCount; - - return (1000.0 * qpc.QuadPart) / static_cast(qpcFrequency.QuadPart); -} - -static double lowResUTCTime() -{ -#if OS(WINCE) - SYSTEMTIME systemTime; - GetSystemTime(&systemTime); - struct tm tmtime; - tmtime.tm_year = systemTime.wYear - 1900; - tmtime.tm_mon = systemTime.wMonth - 1; - tmtime.tm_mday = systemTime.wDay; - tmtime.tm_wday = systemTime.wDayOfWeek; - tmtime.tm_hour = systemTime.wHour; - tmtime.tm_min = systemTime.wMinute; - tmtime.tm_sec = systemTime.wSecond; - time_t timet = mktime(&tmtime); - return timet * msPerSecond + systemTime.wMilliseconds; -#else - struct _timeb timebuffer; - _ftime(&timebuffer); - return timebuffer.time * msPerSecond + timebuffer.millitm; -#endif -} - -static bool qpcAvailable() -{ - static bool available; - static bool checked; - - if (checked) - return available; - - available = QueryPerformanceFrequency(&qpcFrequency); - checked = true; - return available; -} - -double currentTime() -{ - // Use a combination of ftime and QueryPerformanceCounter. - // ftime returns the information we want, but doesn't have sufficient resolution. - // QueryPerformanceCounter has high resolution, but is only usable to measure time intervals. - // To combine them, we call ftime and QueryPerformanceCounter initially. Later calls will use QueryPerformanceCounter - // by itself, adding the delta to the saved ftime. We periodically re-sync to correct for drift. - static bool started; - static double syncLowResUTCTime; - static double syncHighResUpTime; - static double lastUTCTime; - - double lowResTime = lowResUTCTime(); - - if (!qpcAvailable()) - return lowResTime / 1000.0; - - double highResTime = highResUpTime(); - - if (!syncedTime) { - timeBeginPeriod(1); // increase time resolution around low-res time getter - syncLowResUTCTime = lowResTime = lowResUTCTime(); - timeEndPeriod(1); // restore time resolution - syncHighResUpTime = highResTime; - syncedTime = true; - } - - double highResElapsed = highResTime - syncHighResUpTime; - double utc = syncLowResUTCTime + highResElapsed; - - // force a clock re-sync if we've drifted - double lowResElapsed = lowResTime - syncLowResUTCTime; - const double maximumAllowedDriftMsec = 15.625 * 2.0; // 2x the typical low-res accuracy - if (fabs(highResElapsed - lowResElapsed) > maximumAllowedDriftMsec) - syncedTime = false; - - // make sure time doesn't run backwards (only correct if difference is < 2 seconds, since DST or clock changes could occur) - const double backwardTimeLimit = 2000.0; - if (utc < lastUTCTime && (lastUTCTime - utc) < backwardTimeLimit) - return lastUTCTime / 1000.0; - lastUTCTime = utc; - return utc / 1000.0; -} - -#else - -static double currentSystemTime() -{ - FILETIME ft; - GetCurrentFT(&ft); - - // As per Windows documentation for FILETIME, copy the resulting FILETIME structure to a - // ULARGE_INTEGER structure using memcpy (using memcpy instead of direct assignment can - // prevent alignment faults on 64-bit Windows). - - ULARGE_INTEGER t; - memcpy(&t, &ft, sizeof(t)); - - // Windows file times are in 100s of nanoseconds. - // To convert to seconds, we have to divide by 10,000,000, which is more quickly - // done by multiplying by 0.0000001. - - // Between January 1, 1601 and January 1, 1970, there were 369 complete years, - // of which 89 were leap years (1700, 1800, and 1900 were not leap years). - // That is a total of 134774 days, which is 11644473600 seconds. - - return t.QuadPart * 0.0000001 - 11644473600.0; -} - -double currentTime() -{ - static bool init = false; - static double lastTime; - static DWORD lastTickCount; - if (!init) { - lastTime = currentSystemTime(); - lastTickCount = GetTickCount(); - init = true; - return lastTime; - } - - DWORD tickCountNow = GetTickCount(); - DWORD elapsed = tickCountNow - lastTickCount; - double timeNow = lastTime + (double)elapsed / 1000.; - if (elapsed >= 0x7FFFFFFF) { - lastTime = timeNow; - lastTickCount = tickCountNow; - } - return timeNow; -} - -#endif // USE(QUERY_PERFORMANCE_COUNTER) - -#else // Other Posix systems rely on the gettimeofday(). - -double currentTime() -{ - struct timeval now; - struct timezone zone; - - gettimeofday(&now, &zone); - return static_cast(now.tv_sec) + (double)(now.tv_usec / 1000000.0); -} - -#endif - -} // namespace WTF diff --git a/src/3rdparty/javascriptcore/wtf/CurrentTime.h b/src/3rdparty/javascriptcore/wtf/CurrentTime.h index 334a6e98a..5114164c0 100644 --- a/src/3rdparty/javascriptcore/wtf/CurrentTime.h +++ b/src/3rdparty/javascriptcore/wtf/CurrentTime.h @@ -33,13 +33,21 @@ #define CurrentTime_h #include +#include namespace WTF { // Returns the current UTC time in seconds, counted from January 1, 1970. // Precision varies depending on platform but is usually as good or better // than a millisecond. - double currentTime(); + inline double currentTime() + { + struct timeval now; + struct timezone zone; + + gettimeofday(&now, &zone); + return static_cast(now.tv_sec) + (double)(now.tv_usec / 1000000.0); + } // Same thing, in milliseconds. inline double currentTimeMS() @@ -49,13 +57,7 @@ namespace WTF { inline void getLocalTime(const time_t* localTime, struct tm* localTM) { - #if COMPILER(MSVC7) || COMPILER(MINGW) || OS(WINCE) - *localTM = *localtime(localTime); - #elif COMPILER(MSVC) - localtime_s(localTM, localTime); - #else localtime_r(localTime, localTM); - #endif } } // namespace WTF diff --git a/src/3rdparty/javascriptcore/wtf/DateMath.cpp b/src/3rdparty/javascriptcore/wtf/DateMath.cpp index 58268ba12..57c373075 100644 --- a/src/3rdparty/javascriptcore/wtf/DateMath.cpp +++ b/src/3rdparty/javascriptcore/wtf/DateMath.cpp @@ -89,11 +89,6 @@ #include #endif -#if OS(WINCE) -extern "C" size_t strftime(char * const s, const size_t maxsize, const char * const format, const struct tm * const t); -extern "C" struct tm * localtime(const time_t *timer); -#endif - #if HAVE(SYS_TIME_H) #include #endif @@ -371,11 +366,7 @@ int equivalentYearForDST(int year) static int32_t calculateUTCOffset() { -#if PLATFORM(BREWMP) - time_t localTime = static_cast(currentTime()); -#else time_t localTime = time(0); -#endif tm localt; getLocalTime(&localTime, &localt); @@ -494,10 +485,7 @@ static inline double ymdhmsToSeconds(long year, int mon, int day, int hour, int // We follow the recommendation of RFC 2822 to consider all // obsolete time zones not listed here equivalent to "-0000". static const struct KnownZone { -#if !OS(WINDOWS) - const -#endif - char tzName[4]; + const char tzName[4]; int tzOffset; } known_zones[] = { { "UT", 0 }, diff --git a/src/3rdparty/javascriptcore/wtf/Platform.h b/src/3rdparty/javascriptcore/wtf/Platform.h index 15f4be10d..2c9acdee0 100644 --- a/src/3rdparty/javascriptcore/wtf/Platform.h +++ b/src/3rdparty/javascriptcore/wtf/Platform.h @@ -462,11 +462,6 @@ QT_USE_NAMESPACE #define HAVE_PTHREAD_NP_H 1 #endif -/* On Windows, use QueryPerformanceCounter by default */ -#if OS(WINDOWS) -#define WTF_USE_QUERY_PERFORMANCE_COUNTER 1 -#endif - #if OS(UNIX) #define HAVE_SIGNAL_H 1 #endif @@ -526,10 +521,6 @@ QT_USE_NAMESPACE #define WTF_USE_JSVALUE64 1 #elif CPU(ARM) || CPU(PPC64) #define WTF_USE_JSVALUE32 1 -#elif OS(WINDOWS) && COMPILER(MINGW) -/* Using JSVALUE32_64 causes padding/alignement issues for JITStubArg -on MinGW. See https://bugs.webkit.org/show_bug.cgi?id=29268 */ -#define WTF_USE_JSVALUE32 1 #else #define WTF_USE_JSVALUE32_64 1 #endif diff --git a/src/3rdparty/javascriptcore/wtf/StringExtras.h b/src/3rdparty/javascriptcore/wtf/StringExtras.h index 6bde6dca9..a22923bb4 100644 --- a/src/3rdparty/javascriptcore/wtf/StringExtras.h +++ b/src/3rdparty/javascriptcore/wtf/StringExtras.h @@ -33,7 +33,7 @@ #include #endif -#if OS(WINDOWS) || OS(LINUX) || OS(SOLARIS) +#if OS(LINUX) || OS(SOLARIS) // FIXME: should check HAVE_STRNSTR inline char* strnstr(const char* buffer, const char* target, size_t bufferLength) diff --git a/src/3rdparty/javascriptcore/wtf/Threading.h b/src/3rdparty/javascriptcore/wtf/Threading.h index e0d8240e3..f208222d6 100644 --- a/src/3rdparty/javascriptcore/wtf/Threading.h +++ b/src/3rdparty/javascriptcore/wtf/Threading.h @@ -61,23 +61,9 @@ #include "Platform.h" -#if OS(WINCE) -#include -#endif - #include #include -#if OS(WINDOWS) && !OS(WINCE) -#include -#elif OS(DARWIN) -#include -#elif OS(ANDROID) -#include -#elif OS(QNX) -#include -#endif - #include #include #include diff --git a/src/script/CMakeLists.txt b/src/script/CMakeLists.txt index 39d7c7495..29a80b4be 100644 --- a/src/script/CMakeLists.txt +++ b/src/script/CMakeLists.txt @@ -147,7 +147,6 @@ set(SCRIPT_SOURCES ${CMAKE_SOURCE_DIR}/src/3rdparty/javascriptcore/runtime/UString.cpp ${CMAKE_SOURCE_DIR}/src/3rdparty/javascriptcore/runtime/UStringImpl.cpp ${CMAKE_SOURCE_DIR}/src/3rdparty/javascriptcore/wtf/ByteArray.cpp - ${CMAKE_SOURCE_DIR}/src/3rdparty/javascriptcore/wtf/CurrentTime.cpp ${CMAKE_SOURCE_DIR}/src/3rdparty/javascriptcore/wtf/DateMath.cpp ${CMAKE_SOURCE_DIR}/src/3rdparty/javascriptcore/wtf/dtoa.cpp ${CMAKE_SOURCE_DIR}/src/3rdparty/javascriptcore/wtf/FastMalloc.cpp -- 2.11.0