blob: 1dcfe9b8d7e57bb8808c3ad62300e6b7ce900f02 [file] [log] [blame]
2017-04-24 Andy VanWagoner <thetalecrafter@gmail.com>
Clean up ICU headers
https://bugs.webkit.org/show_bug.cgi?id=170997
Reviewed by JF Bastien.
Update all icu headers to 55.1
* icu/LICENSE: Update copyright
* icu/README: Explain ICU headers for OS X better
* icu/unicode/localpointer.h:
(LocalPointer::LocalPointer):
(LocalPointer::adoptInsteadAndCheckErrorCode):
* icu/unicode/platform.h:
* icu/unicode/putil.h:
* icu/unicode/std_string.h:
* icu/unicode/ubrk.h:
* icu/unicode/uchar.h:
* icu/unicode/ucnv.h:
* icu/unicode/ucol.h:
* icu/unicode/uconfig.h:
* icu/unicode/ucurr.h:
* icu/unicode/uloc.h:
* icu/unicode/umachine.h:
* icu/unicode/unistr.h:
(UnicodeString::getArrayStart):
(UnicodeString::UnicodeString):
(UnicodeString::hasShortLength):
(UnicodeString::getShortLength):
(UnicodeString::length):
(UnicodeString::getCapacity):
(UnicodeString::isBogus):
(UnicodeString::isWritable):
(UnicodeString::isBufferWritable):
(UnicodeString::getBuffer):
(UnicodeString::isEmpty):
(UnicodeString::setZeroLength):
(UnicodeString::setShortLength):
(UnicodeString::setLength):
(UnicodeString::setToEmpty):
(UnicodeString::remove):
* icu/unicode/urename.h:
* icu/unicode/uscript.h:
* icu/unicode/uset.h:
* icu/unicode/ustring.h:
* icu/unicode/utf8.h:
* icu/unicode/utypes.h:
* icu/unicode/uvernum.h:
2017-04-24 Yusuke Suzuki <utatane.tea@gmail.com>
Unreviewed, fix Windows build after r215715
https://bugs.webkit.org/show_bug.cgi?id=171199
* wtf/StackTrace.h:
2017-04-24 Yusuke Suzuki <utatane.tea@gmail.com>
[WTF] Move JSC tools/StackTrace to WTF and unify stack trace dump code
https://bugs.webkit.org/show_bug.cgi?id=171199
Reviewed by Mark Lam.
JSC tools/StackTrace's dump code is almost identical to WTF Assertions'
stack trace dump code. This patch moves tools/StackTrace to WTF and use
it in Assertions. It unifies the two duplicate implementations into one.
* WTF.xcodeproj/project.pbxproj:
* wtf/Assertions.cpp:
* wtf/CMakeLists.txt:
* wtf/Platform.h:
* wtf/StackTrace.cpp: Renamed from Source/JavaScriptCore/tools/StackTrace.cpp.
(WTF::StackTrace::captureStackTrace):
(WTF::StackTrace::dump):
* wtf/StackTrace.h: Copied from Source/JavaScriptCore/tools/StackTrace.h.
(WTF::StackTrace::StackTrace):
(WTF::StackTrace::stack):
(WTF::StackTrace::DemangleEntry::mangledName):
(WTF::StackTrace::DemangleEntry::demangledName):
(WTF::StackTrace::DemangleEntry::DemangleEntry):
* wtf/SystemFree.h: Renamed from Source/JavaScriptCore/tools/StackTrace.h.
(WTF::SystemFree::operator()):
2017-04-24 Yusuke Suzuki <utatane.tea@gmail.com>
[AppleWin] The procedure entry point ?waitForThreadCompletion@WTF@@YAHI@Z could not be located in the dynamic link library WebKitQuartzCoreAdditions.dll
https://bugs.webkit.org/show_bug.cgi?id=171029
Reviewed by Brent Fulgham.
While WTF Threading APIs are updated, WebKitQuartzCoreAdditions.dll in Windows uses some of the old APIs,
waitForThreadCompletion and createThread. This patch implements both on top of the new APIs.
These APIs are only exposed in Windows for this compatibility problem and new code should not use it.
* wtf/ThreadHolder.cpp:
(WTF::ThreadHolder::initialize):
* wtf/ThreadHolder.h:
* wtf/ThreadHolderWin.cpp:
(WTF::ThreadHolder::get):
(WTF::ThreadHolder::platformInitialize):
(WTF::ThreadHolder::destruct):
* wtf/Threading.h:
* wtf/ThreadingWin.cpp:
(WTF::createThread):
(WTF::waitForThreadCompletion):
2017-04-24 Carlos Garcia Campos <cgarcia@igalia.com>
[GTK] Switch to use ENABLE_REMOTE_INSPECTOR instead of ENABLE_INSPECTOR_SERVER for the remote inspector
https://bugs.webkit.org/show_bug.cgi?id=166680
Reviewed by Michael Catanzaro.
Add GRefPtr hash traits to allow using GRefPtr as a key of HashMaps.
* wtf/glib/GRefPtr.h:
(WTF::HashTraits<GRefPtr<P>>::emptyValue):
(WTF::HashTraits<GRefPtr<P>>::peek):
(WTF::HashTraits<GRefPtr<P>>::customDeleteBucket):
2017-04-22 Yusuke Suzuki <utatane.tea@gmail.com>
[JSC] Get stack pointer without pthread attr
https://bugs.webkit.org/show_bug.cgi?id=171162
Reviewed by Mark Lam.
If HAVE(MACHINE_CONTEXT) is not enabled, we get stack base and boundary by using
pthread_attr functions. However, it is wrong since this function can be called
after the thread is suspended. In that case, we should not call any functions
that is not async signal safe. For example, pthread_getattr_np calls malloc.
Instead we use getApproximateStackPointer(), which returns approximate stack pointer.
* wtf/Threading.h:
* wtf/ThreadingPthreads.cpp:
(WTF::getApproximateStackPointer):
(WTF::isOnAlternativeSignalStack):
When gathering conservative roots, we should keep stack pointer pointing stack.
And if concurrent GC is enabled, we always need to keep the above invariant.
So, we do not support alternative signal stack.
(WTF::Thread::signalHandlerSuspendResume):
(WTF::Thread::getRegisters):
2017-04-22 Yusuke Suzuki <utatane.tea@gmail.com>
REGRESSION(r215638): [Linux] Several worker tests are crashing in Thread::signalHandlerSuspendResume after r215638
https://bugs.webkit.org/show_bug.cgi?id=171159
Reviewed by Michael Catanzaro.
Now, SIGUSR2 is used by ThreadMessage. Instead SIGUSR1 becomes empty.
We should use some signal, that is not managed by WTF Signal mechanism
because the behaivor of this suspend and resume is a bit tricky.
For example, we set a bit tricky signal mask to sigaction to temporary
block SIGUSR2 in the handler to avoid nested SIGUSR2. And we cannot
use ThreadMessage to implement this mechanism because this suspend
and resume handler will stop in the middle of the handler by sigsuspend.
It is not the expected semantics by ThreadMessage.
So now, we use SIGUSR1 instead. And we note that SIGUSR1 is used for
pthread ports.
* wtf/ThreadingPthreads.cpp:
* wtf/threads/Signals.h:
2017-04-20 Sam Weinig <sam@webkit.org>
Split cryptographic digest computation and parsing out of CSP code so it can be reused
https://bugs.webkit.org/show_bug.cgi?id=171076
Reviewed by Chris Dumez.
* wtf/text/Base64.cpp:
(WTF::base64Decode):
(WTF::base64URLDecode):
Add overloads for base64Decode and base64URLDecode that take a StringView, to avoid allocations
of Strings.
* wtf/text/Base64.h:
(WTF::isBase64OrBase64URLCharacter):
Move helper predicate used for parsing either type of Base64 encoded string from WebCore.
2017-04-21 Keith Miller <keith_miller@apple.com>
Unreviewed, rolling out r215634.
underlying build issues should have been fixed
Reverted changeset:
"Unreviewed, rolling out r215620 and r215623."
https://bugs.webkit.org/show_bug.cgi?id=171139
http://trac.webkit.org/changeset/215634
2017-04-21 Keith Miller <keith_miller@apple.com>
Remove LL/SC from Atomics
https://bugs.webkit.org/show_bug.cgi?id=171141
Reviewed by Saam Barati.
Adding load link and store conditionally was not an actual progression
and the existing code is causing problems for users of Atomics. So let's
get rid of it.
* wtf/Atomics.h:
(WTF::hasFence):
(WTF::Atomic::exchange):
(WTF::Atomic::transaction):
(WTF::Atomic::transactionRelaxed):
(WTF::Atomic::prepare): Deleted.
(WTF::Atomic::attempt): Deleted.
* wtf/Bitmap.h:
(WTF::WordType>::concurrentTestAndSet):
(WTF::WordType>::concurrentTestAndClear):
* wtf/LockAlgorithm.h:
(WTF::LockAlgorithm::lockFast):
(WTF::LockAlgorithm::unlockFast):
2017-04-21 Commit Queue <commit-queue@webkit.org>
Unreviewed, rolling out r215620 and r215623.
https://bugs.webkit.org/show_bug.cgi?id=171139
broke arm64 build (Requested by keith_miller on #webkit).
Reverted changesets:
"Add signaling API"
https://bugs.webkit.org/show_bug.cgi?id=170976
http://trac.webkit.org/changeset/215620
"Unreviewed, fix Cloop build."
http://trac.webkit.org/changeset/215623
2017-04-20 Keith Miller <keith_miller@apple.com>
Add signaling API
https://bugs.webkit.org/show_bug.cgi?id=170976
Reviewed by Filip Pizlo.
This patch adds a bunch of new functionality to WTF. First, it add
a new data structure of a lockless bag. The LocklessBag class can
be used as either a multi-writer multi-reader lockless bag or a
multi-writer single consumer lockless bag.
Next, this patch adds an abstraction around sigaction in WTF.
Basically, you can add a handler, which can be an arbitrary
lambda. Although it should still be safe for the signal you are
handling. the signal handler manager will then do all the
appropriate handling of chaining:
In the SIGUSR case we always forward the signal to any other
non-default handler installed before us. We need to do this,
otherwise, since it's not possible to tell if a SIGUSR was
intended exlusively for our handlers. Signal handlers don't record
how many times they were sent only that there is at least one
unhandled signal.
In the faulting cases we require that every handle be able to
recognise a fault they installed, vs crashes. If none of our
handlers claim to have handled the fault we will forward the
fault. If a handler was installed before the first fault handler
we simply call that handler and rely on them to take the
appropriate action. If no handler was installed before our first
handler we restore the default handler and allow the fault to
happen again.
Finally, this patch adds a signal based messaging system. This
system allows the user to run an arbitrary lambda from the SIGUSR2
signal handler of any target WTF::Thread. This is already in use
for the VMTraps API which allows us to kill rogue VMs by sending
the VM's running WTF::Thread a SIGUSR and requesting it jetison
all optimized code and throw an uncatchable exception from all
function entries/loop backedges. In the future, we will also use
this API for Wasm to reset the instruction caches in currently
executing Wasm threads.
* WTF.xcodeproj/project.pbxproj:
* wtf/Atomics.h:
(WTF::Atomic::Atomic):
* wtf/LocklessBag.h: Added.
(WTF::LocklessBag::LocklessBag):
(WTF::LocklessBag::add):
(WTF::LocklessBag::iterate):
(WTF::LocklessBag::consumeAll):
* wtf/ThreadMessage.cpp: Added.
(WTF::ThreadMessageData::ThreadMessageData):
(WTF::initializeThreadMessages):
(WTF::sendMessageScoped):
* wtf/ThreadMessage.h: Added.
(WTF::sendMessage):
* wtf/Threading.cpp:
(WTF::initializeThreading):
* wtf/Threading.h:
(WTF::Thread::threadMessages):
* wtf/ThreadingPthreads.cpp:
(WTF::Thread::currentMayBeNull):
(WTF::Thread::current):
(WTF::Thread::signal):
* wtf/threads/Signals.cpp: Added.
(WTF::jscSignalHandler):
(WTF::installSignalHandler):
* wtf/threads/Signals.h: Added.
(WTF::toSystemSignal):
(WTF::fromSystemSignal):
2017-04-21 Konstantin Tokarev <annulen@yandex.ru>
[cmake] WTF target should not have wtf and subdirectries in public interface
https://bugs.webkit.org/show_bug.cgi?id=171115
Reviewed by Michael Catanzaro.
In r209665 WEBCORE_FRAMEWORK macro started to export INCLUDE_DIRECTORIES of
targets as their public interface, so that linked targets can use them
implicitly without copying directory lists around. This matches existing
practice for all targets except WTF, headers from which are always included
with full path starting from "<wtf/...".
Since r209665 it became possible to include headers from wtf or its
subdirectories in CMake builds without using "<wtf/..." path. It should
not be allowed.
* wtf/CMakeLists.txt: WTF/wtf and its sudirectories should not be in
public include paths of WTF target.
2017-04-20 Sam Weinig <sam@webkit.org>
Move notFound into its own file
https://bugs.webkit.org/show_bug.cgi?id=170972
Reviewed by Zalan Bujtas.
It is odd to require including <wtf/Vector.h> just to use WTF::notFound.
This is not causing any current problems, but does in few changes I have
queued up.
* WTF.xcodeproj/project.pbxproj:
* wtf/NotFound.h: Added.
* wtf/Vector.h:
* wtf/text/StringCommon.h:
2017-04-20 Filip Pizlo <fpizlo@apple.com>
Optimize SharedArrayBuffer in the DFG+FTL
https://bugs.webkit.org/show_bug.cgi?id=164108
Reviewed by Saam Barati.
Made small changes as part of benchmarking the JS versions of these locks.
* benchmarks/LockSpeedTest.cpp:
* benchmarks/ToyLocks.h:
* wtf/Range.h:
(WTF::Range::dump):
2017-04-19 Youenn Fablet <youenn@apple.com>
[Win] Activate streams API by default
https://bugs.webkit.org/show_bug.cgi?id=171000
Reviewed by Brent Fulgham.
* wtf/FeatureDefines.h:
2017-04-19 David Kilzer <ddkilzer@apple.com>
Vector.h: error: 'auto' not allowed in lambda parameter
<https://webkit.org/b/171010>
<rdar://problem/31716076>
Reviewed by Saam Barati.
* wtf/Vector.h:
(WTF::removeRepeatedElements): Replace 'auto' with a specific
type, 'T', based on a Vector<> template type.
2017-04-19 Ryan Haddad <ryanhaddad@apple.com>
Unreviewed, rolling out r215518.
This change appears to have broken the Windows build.
Reverted changeset:
"Move notFound into its own file"
https://bugs.webkit.org/show_bug.cgi?id=170972
http://trac.webkit.org/changeset/215518
2017-04-19 Sam Weinig <sam@webkit.org>
Move notFound into its own file
https://bugs.webkit.org/show_bug.cgi?id=170972
Reviewed by Zalan Bujtas.
It is odd to require including <wtf/Vector.h> just to use WTF::notFound.
This is not causing any current problems, but does in few changes I have
queued up.
* WTF.xcodeproj/project.pbxproj:
* wtf/NotFound.h: Added.
* wtf/Vector.h:
* wtf/text/StringCommon.h:
2017-04-18 Carlos Garcia Campos <cgarcia@igalia.com>
[GLIB] Define priorities also for async network IO tasks
https://bugs.webkit.org/show_bug.cgi?id=170905
Reviewed by Žan Doberšek.
Add AsyncIONetwork, DiskCacheRead and DiskCacheWrite priorities.
* wtf/glib/RunLoopSourcePriority.h:
2017-04-18 Yusuke Suzuki <utatane.tea@gmail.com>
[JSC][GTK] glib RunLoop does not accept negative start interval
https://bugs.webkit.org/show_bug.cgi?id=170775
Reviewed by Saam Barati.
RunLoop::Timer for glib does not accept negative start interval.
We use 0_s if the given value is negative.
* wtf/glib/RunLoopGLib.cpp:
(WTF::RunLoop::TimerBase::secondsUntilFire):
2017-04-17 Alex Christensen <achristensen@webkit.org>
Allow Variants of RetainPtrs
https://bugs.webkit.org/show_bug.cgi?id=170923
Reviewed by Tim Horton and Sam Weinig.
* wtf/RetainPtr.h:
(WTF::RetainPtr::operator&): Deleted.
Operator& was causing a compile error when making Variant<RetainPtr<T>, ...>
and because it is strange and only used once, let's just remove it.
* wtf/Variant.h:
(WTF::get):
(WTF::get_if):
Use std::addressof instead of operator& which could be overloaded to return any type with any meaning.
2017-04-17 Youenn Fablet <youenn@apple.com>
Disable outdated WritableStream API
https://bugs.webkit.org/show_bug.cgi?id=170749
<rdar://problem/31446233>
Reviewed by Alex Christensen.
Replacing READABLE_STREAM_API, READABLE_BYTE_STREAM_API and WRITABLE_STREAM_API compilation flag by:
- A STREAMS_API compilation flag.
- A ReadableByteStreamAPI and WritableStreamAPI runtime flags, turned off except for RWT and DRT.
* wtf/FeatureDefines.h:
2017-04-17 Dan Bernstein <mitz@apple.com>
[Cocoa] Move isNullFunctionPointer down into WTF
https://bugs.webkit.org/show_bug.cgi?id=170892
Reviewed by Sam Weinig.
Test: TestWebKitAPI/Tests/WTF/darwin/WeakLinking.cpp
* WTF.xcodeproj/project.pbxproj: Added reference to new file.
* wtf/darwin: Added.
* wtf/darwin/WeakLinking.h: Added.
(WTF::isNullFunctionPointer): Copied from ResourceLoadStatisticsClassifierCocoa.cpp in
WebKit2 and changed into a function template that works with any function pointer.
2017-04-17 Ryan Haddad <ryanhaddad@apple.com>
Unreviewed, rolling out r215366.
This test is failing on performance bots.
Reverted changeset:
"Add performance test for asking the platform for a font for
U+2060 WORD JOINER"
https://bugs.webkit.org/show_bug.cgi?id=170842
http://trac.webkit.org/changeset/215366
2017-04-17 Yusuke Suzuki <utatane.tea@gmail.com>
[JSCOnly] Fix build failures in macOS
https://bugs.webkit.org/show_bug.cgi?id=170887
Reviewed by Alex Christensen.
JSCOnly port does not use mac/MainThread.cpp.
We change the ifdef gurard to use generic implementaion in JSCOnly on macOS.
* wtf/MainThread.cpp:
* wtf/PlatformJSCOnly.cmake:
2017-04-17 JF Bastien <jfbastien@apple.com>
B3: don't allow unsigned offsets in Value
https://bugs.webkit.org/show_bug.cgi?id=170692
Reviewed by Filip Pizlo.
Add C++17's std::conjunction type trait, except for Microsoft VS
2015 update 2 and later because it adds the logical operator type
traits, event when C++ is pre-2017:
https://blogs.msdn.microsoft.com/vcblog/2016/01/22/vs-2015-update-2s-stl-is-c17-so-far-feature-complete/
* wtf/StdLibExtras.h:
2017-04-14 Mark Lam <mark.lam@apple.com>
Update architectures in xcconfig files.
https://bugs.webkit.org/show_bug.cgi?id=170867
<rdar://problem/31628104>
Reviewed by Joseph Pecoraro.
* Configurations/Base.xcconfig:
2017-04-14 Myles C. Maxfield <mmaxfield@apple.com>
Add performance test for asking the platform for a font for U+2060 WORD JOINER
https://bugs.webkit.org/show_bug.cgi?id=170842
Reviewed by Tim Horton.
* wtf/unicode/CharacterNames.h:
2017-04-13 Yusuke Suzuki <utatane.tea@gmail.com>
[JSC] Date.parse should accept wider range of representation
https://bugs.webkit.org/show_bug.cgi?id=170720
Reviewed by Darin Adler.
We would like to relax Date.parse to accept the representation "May 8".
At that time, we choose `2000` as a default year. This is because of
the following reason.
1. According to the V8, this default value is compatible to the old KJS. While current V8 uses 2001,
SpiderMonkey does not have such a fallback path. So this reason is not big deal.
2. It is a leap year. When using `new Date("Feb 29")`, we assume that people want to save month and day.
Leap year can save user inputs if they is valid. If we use the current year instead, the current year
may not be a leap year. In that case, `new Date("Feb 29").getMonth()` becomes 2 (March).
* wtf/DateMath.cpp:
(WTF::parseDateFromNullTerminatedCharacters):
2017-04-13 Dan Bernstein <mitz@apple.com>
WTF installs an extra copy of a header outside /usr/local/include/wtf
* WTF.xcodeproj/project.pbxproj: Demoted PriorityQueue.h from Private to Project.
2017-04-13 Oliver Hunt <oliver@apple.com>
allocationSize should use safe arithmetic by default
https://bugs.webkit.org/show_bug.cgi?id=170804
Reviewed by JF Bastien.
Make all allocationSize() functions work in terms
of Checked<size_t>
* wtf/text/StringImpl.h:
(WTF::StringImpl::allocationSize):
(WTF::StringImpl::tailOffset):
2017-04-13 JF Bastien <jfbastien@apple.com>
WebAssembly: manage memory better
https://bugs.webkit.org/show_bug.cgi?id=170628
Reviewed by Keith Miller, Michael Saboff.
Re-use a VM tag which was intended for JavaScript core, was then
used by our GC, and is now unused. If I don't do this then
WebAssembly fast memories will make vmmap look super weird because
it'll look like multi-gigabyte of virtual memory are allocated as
part of our process' regular memory!
Separately I need to update vmmap and other tools to print the
right name. Right now this tag gets identified as "JS garbage
collector".
* wtf/OSAllocator.h:
* wtf/VMTags.h:
2017-04-13 Yusuke Suzuki <utatane.tea@gmail.com>
[JSC] Use proper ifdef guard for code using MachineContext
https://bugs.webkit.org/show_bug.cgi?id=170800
Reviewed by Carlos Alberto Lopez Perez.
SamplingProfiler and FastMemory rely on MachineContext feature.
* wtf/Platform.h:
2017-04-12 Dan Bernstein <mitz@apple.com>
[Mac] Future-proof .xcconfig files
https://bugs.webkit.org/show_bug.cgi?id=170802
Reviewed by Tim Horton.
* Configurations/Base.xcconfig:
* Configurations/DebugRelease.xcconfig:
2017-04-12 Yusuke Suzuki <utatane.tea@gmail.com>
Use HAVE(MACHINE_CONTEXT) instead of USE(MACHINE_CONTEXT)
https://bugs.webkit.org/show_bug.cgi?id=170770
Rubber stamped by Mark Lam.
* wtf/Platform.h:
* wtf/PlatformRegisters.h:
* wtf/ThreadingPthreads.cpp:
(WTF::Thread::getRegisters):
2017-04-12 Yusuke Suzuki <utatane.tea@gmail.com>
[JSC] Clean up heap/MachineStackMarker by introducing USE(MACHINE_CONTEXT)
https://bugs.webkit.org/show_bug.cgi?id=170770
Reviewed by Mark Lam.
We add a new define USE_MACHINE_CONTEXT, which becomes true if mcontext_t exists
and we know the way to retrieve values from mcontext_t.
* wtf/Platform.h:
* wtf/PlatformRegisters.h:
* wtf/ThreadingPthreads.cpp:
(WTF::Thread::getRegisters):
2017-04-12 Yusuke Suzuki <utatane.tea@gmail.com>
[WTF] Introduce Thread class and use RefPtr<Thread> and align Windows Threading implementation semantics to Pthread one
https://bugs.webkit.org/show_bug.cgi?id=170502
Reviewed by Mark Lam.
This patch is refactoring of WTF Threading mechanism to merge JavaScriptCore's threading extension to WTF Threading.
Previously, JavaScriptCore requires richer threading features (such as suspending and resuming threads), and they
are implemented for PlatformThread in JavaScriptCore. But these features should be implemented in WTF Threading side
instead of maintaining JSC's own threading features too. This patch removes these features from JSC and move it to
WTF Threading.
However, current WTF Threading has one problem: Windows version of WTF Threading has different semantics from Pthreads
one. In Windows WTF Threading, we cannot perform any operation after the target thread is detached: WTF Threading stop
tracking the state of the thread once the thread is detached. But this is not the same to Pthreads one. In Pthreads,
pthread_detach just means that the resource of the thread will be destroyed automatically. While some operations like
pthread_join will be rejected, some operations like pthread_kill will be accepted.
The problem is that detached thread can be suspended and resumed in JSC. For example, in jsc.cpp, we start the worker
thread and detach it immediately. In worker thread, we will create VM and thus concurrent GC will suspend and resume
the detached thread. However, in Windows WTF Threading, we have no reference to the detached thread. Thus we cannot
perform suspend and resume operations onto the detached thread.
To solve the problem, we change Windows Threading mechanism drastically to align it to the Pthread semantics. In the
new Threading, we have RefPtr<Thread> class. It holds a handle to a platform thread. We can perform threading operations
with this class. For example, Thread::suspend is offered. And we use destructor of the thread local variable to release
the resources held by RefPtr<Thread>. In Windows, Thread::detach does nothing because the resource will be destroyed
automatically by RefPtr<Thread>.
To do so, we introduce ThreadHolder for Windows. This is similar to the previous ThreadIdentifierData for Pthreads.
It holds RefPtr<Thread> in the thread local storage (technically, it is Fiber Local Storage in Windows). Thread::current()
will return this reference.
The problematic situation is that the order of the deallocation of the thread local storage is not defined. So we should
not touch thread local storage in the destructor of the thread local storage. To avoid such edge cases, we have
currentThread() / Thread::currentID() APIs. They are safe to be called even in the destructor of the other thread local
storage. And in Windows, in the FLS destructor, we will create the thread_local variable to defer the destruction of
the ThreadHolder. We ensure that this destructor is called after the other FLS destructors are called in Windows 10.
This patch is performance neutral.
* WTF.xcodeproj/project.pbxproj:
* benchmarks/ConditionSpeedTest.cpp:
* benchmarks/LockFairnessTest.cpp:
* benchmarks/LockSpeedTest.cpp:
* wtf/AutomaticThread.cpp:
(WTF::AutomaticThread::start):
* wtf/CMakeLists.txt:
* wtf/MainThread.h:
* wtf/MemoryPressureHandler.h:
* wtf/ParallelJobsGeneric.cpp:
(WTF::ParallelEnvironment::ThreadPrivate::tryLockFor):
(WTF::ParallelEnvironment::ThreadPrivate::workerThread):
* wtf/ParallelJobsGeneric.h:
(WTF::ParallelEnvironment::ThreadPrivate::ThreadPrivate): Deleted.
* wtf/ParkingLot.cpp:
(WTF::ParkingLot::forEachImpl):
* wtf/ParkingLot.h:
(WTF::ParkingLot::forEach):
* wtf/PlatformRegisters.h: Renamed from Source/JavaScriptCore/runtime/PlatformThread.h.
* wtf/RefPtr.h:
(WTF::RefPtr::RefPtr):
* wtf/ThreadFunctionInvocation.h:
(WTF::ThreadFunctionInvocation::ThreadFunctionInvocation):
* wtf/ThreadHolder.cpp: Added.
(WTF::ThreadHolder::~ThreadHolder):
(WTF::ThreadHolder::initialize):
* wtf/ThreadHolder.h: Renamed from Source/WTF/wtf/ThreadIdentifierDataPthreads.h.
(WTF::ThreadHolder::thread):
(WTF::ThreadHolder::ThreadHolder):
* wtf/ThreadHolderPthreads.cpp: Renamed from Source/WTF/wtf/ThreadIdentifierDataPthreads.cpp.
(WTF::ThreadHolder::initializeOnce):
(WTF::ThreadHolder::current):
(WTF::ThreadHolder::destruct):
* wtf/ThreadHolderWin.cpp: Added.
(WTF::threadMapMutex):
(WTF::threadMap):
(WTF::ThreadHolder::initializeOnce):
(WTF::ThreadHolder::current):
(WTF::ThreadHolder::destruct):
* wtf/ThreadSpecific.h:
* wtf/Threading.cpp:
(WTF::Thread::normalizeThreadName):
(WTF::threadEntryPoint):
(WTF::Thread::create):
(WTF::Thread::setCurrentThreadIsUserInteractive):
(WTF::Thread::setCurrentThreadIsUserInitiated):
(WTF::Thread::setGlobalMaxQOSClass):
(WTF::Thread::adjustedQOSClass):
(WTF::Thread::dump):
(WTF::initializeThreading):
(WTF::normalizeThreadName): Deleted.
(WTF::createThread): Deleted.
(WTF::setCurrentThreadIsUserInteractive): Deleted.
(WTF::setCurrentThreadIsUserInitiated): Deleted.
(WTF::setGlobalMaxQOSClass): Deleted.
(WTF::adjustedQOSClass): Deleted.
* wtf/Threading.h:
(WTF::Thread::id):
(WTF::Thread::operator==):
(WTF::Thread::operator!=):
(WTF::Thread::joinableState):
(WTF::Thread::didBecomeDetached):
(WTF::Thread::didJoin):
(WTF::Thread::hasExited):
(WTF::currentThread):
* wtf/ThreadingPthreads.cpp:
(WTF::Thread::Thread):
(WTF::Thread::~Thread):
(WTF::Thread::signalHandlerSuspendResume):
(WTF::Thread::initializePlatformThreading):
(WTF::initializeCurrentThreadEvenIfNonWTFCreated):
(WTF::wtfThreadEntryPoint):
(WTF::Thread::createInternal):
(WTF::Thread::initializeCurrentThreadInternal):
(WTF::Thread::changePriority):
(WTF::Thread::waitForCompletion):
(WTF::Thread::detach):
(WTF::Thread::current):
(WTF::Thread::currentID):
(WTF::Thread::signal):
(WTF::Thread::resume):
(WTF::Thread::getRegisters):
(WTF::Thread::didExit):
(WTF::Thread::establish):
(WTF::PthreadState::PthreadState): Deleted.
(WTF::PthreadState::joinableState): Deleted.
(WTF::PthreadState::pthreadHandle): Deleted.
(WTF::PthreadState::didBecomeDetached): Deleted.
(WTF::PthreadState::didExit): Deleted.
(WTF::PthreadState::didJoin): Deleted.
(WTF::PthreadState::hasExited): Deleted.
(WTF::threadMapMutex): Deleted.
(WTF::initializeThreading): Deleted.
(WTF::threadMap): Deleted.
(WTF::identifierByPthreadHandle): Deleted.
(WTF::establishIdentifierForPthreadHandle): Deleted.
(WTF::pthreadHandleForIdentifierWithLockAlreadyHeld): Deleted.
(WTF::createThreadInternal): Deleted.
(WTF::initializeCurrentThreadInternal): Deleted.
(WTF::changeThreadPriority): Deleted.
(WTF::waitForThreadCompletion): Deleted.
(WTF::detachThread): Deleted.
(WTF::threadDidExit): Deleted.
(WTF::currentThread): Deleted.
(WTF::signalThread): Deleted.
* wtf/ThreadingWin.cpp:
(WTF::Thread::Thread):
(WTF::Thread::~Thread):
(WTF::Thread::initializeCurrentThreadInternal):
(WTF::Thread::initializePlatformThreading):
(WTF::wtfThreadEntryPoint):
(WTF::Thread::createInternal):
(WTF::Thread::changePriority):
(WTF::Thread::waitForCompletion):
(WTF::Thread::detach):
(WTF::Thread::resume):
(WTF::Thread::getRegisters):
(WTF::Thread::current):
(WTF::Thread::currentID):
(WTF::Thread::didExit):
(WTF::Thread::establish):
(WTF::initializeCurrentThreadInternal): Deleted.
(WTF::threadMapMutex): Deleted.
(WTF::initializeThreading): Deleted.
(WTF::threadMap): Deleted.
(WTF::storeThreadHandleByIdentifier): Deleted.
(WTF::threadHandleForIdentifier): Deleted.
(WTF::clearThreadHandleForIdentifier): Deleted.
(WTF::createThreadInternal): Deleted.
(WTF::changeThreadPriority): Deleted.
(WTF::waitForThreadCompletion): Deleted.
(WTF::detachThread): Deleted.
(WTF::currentThread): Deleted.
* wtf/WorkQueue.cpp:
(WTF::WorkQueue::concurrentApply):
* wtf/WorkQueue.h:
* wtf/cocoa/WorkQueueCocoa.cpp:
(WTF::dispatchQOSClass):
* wtf/generic/WorkQueueGeneric.cpp:
(WorkQueue::platformInitialize):
(WorkQueue::platformInvalidate):
* wtf/linux/MemoryPressureHandlerLinux.cpp:
(WTF::MemoryPressureHandler::EventFDPoller::EventFDPoller):
(WTF::MemoryPressureHandler::EventFDPoller::~EventFDPoller):
* wtf/win/MainThreadWin.cpp:
(WTF::initializeMainThreadPlatform):
2017-04-11 Zan Dobersek <zdobersek@igalia.com>
[GTK] Use the DisplayRefreshMonitor facilities
https://bugs.webkit.org/show_bug.cgi?id=170599
Reviewed by Carlos Garcia Campos.
* wtf/Platform.h: Enable USE_REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR for the GTK+ port.
* wtf/glib/RunLoopSourcePriority.h: Add the DisplayRefreshMonitorTimer entry that
matches the value of LayerFlushTimer.
2017-04-11 Yusuke Suzuki <utatane.tea@gmail.com>
[WebCore][JSC] ResourceUsageData.{timeOfNextEdenCollection,timeOfNextFullCollection} should be MonotonicTime
https://bugs.webkit.org/show_bug.cgi?id=170725
Reviewed by Sam Weinig.
Make MonotonicTime more constexpr friendly mainly to annotate MonotonicTime::nan() as constexpr.
* wtf/MonotonicTime.h:
(WTF::MonotonicTime::MonotonicTime):
(WTF::MonotonicTime::fromRawSeconds):
(WTF::MonotonicTime::infinity):
(WTF::MonotonicTime::nan):
(WTF::MonotonicTime::secondsSinceEpoch):
(WTF::MonotonicTime::operator bool):
(WTF::MonotonicTime::operator+):
(WTF::MonotonicTime::operator-):
(WTF::MonotonicTime::operator==):
(WTF::MonotonicTime::operator!=):
(WTF::MonotonicTime::operator<):
(WTF::MonotonicTime::operator>):
(WTF::MonotonicTime::operator<=):
(WTF::MonotonicTime::operator>=):
2017-04-11 Yusuke Suzuki <utatane.tea@gmail.com>
Unreviewed, build fix for Windows port after r215228
https://bugs.webkit.org/show_bug.cgi?id=170723
* wtf/win/RunLoopWin.cpp:
(WTF::RunLoop::TimerBase::timerFired):
2017-04-11 Yusuke Suzuki <utatane.tea@gmail.com>
[JSC][GTK] Use RunLoop::Timer in GTK port
https://bugs.webkit.org/show_bug.cgi?id=170723
Reviewed by Carlos Garcia Campos.
Add secondsUntilFire method. And add setName and setPriority
for GTK RunLoop::Timer.
* wtf/RunLoop.h:
* wtf/cf/RunLoopCF.cpp:
(WTF::RunLoop::TimerBase::secondsUntilFire):
* wtf/generic/RunLoopGeneric.cpp:
(WTF::RunLoop::TimerBase::secondsUntilFire):
* wtf/glib/RunLoopGLib.cpp:
(WTF::RunLoop::TimerBase::setName):
(WTF::RunLoop::TimerBase::secondsUntilFire):
* wtf/win/RunLoopWin.cpp:
(WTF::RunLoop::TimerBase::timerFired):
(WTF::RunLoop::TimerBase::start):
(WTF::RunLoop::TimerBase::isActive):
(WTF::RunLoop::TimerBase::secondsUntilFire):
2017-04-11 Yusuke Suzuki <utatane.tea@gmail.com>
[JSC] Enable JSRunLoopTimer for JSCOnly and Windows
https://bugs.webkit.org/show_bug.cgi?id=170655
Reviewed by Carlos Garcia Campos.
This patch makes RunLoop::Timer in Generic and Windows thread-safe to use it
in JSC's JSRunLoopTimer. Eventually, we would like to replace JSRunLoopTimer's
platform-dependent implementation to WTF::RunLoop::Timer.
* wtf/RunLoop.h:
* wtf/cf/RunLoopCF.cpp:
(WTF::RunLoop::TimerBase::start):
* wtf/generic/RunLoopGeneric.cpp:
(WTF::RunLoop::TimerBase::ScheduledTask::EarliestSchedule::operator()):
(WTF::RunLoop::populateTasks):
(WTF::RunLoop::runImpl):
(WTF::RunLoop::schedule):
(WTF::RunLoop::scheduleAndWakeUp):
(WTF::RunLoop::TimerBase::~TimerBase):
(WTF::RunLoop::TimerBase::start):
(WTF::RunLoop::TimerBase::stop):
(WTF::RunLoop::TimerBase::isActive):
* wtf/glib/RunLoopGLib.cpp:
(WTF::RunLoop::TimerBase::TimerBase):
* wtf/win/RunLoopWin.cpp:
(WTF::RunLoop::TimerBase::timerFired):
(WTF::RunLoop::TimerBase::start):
(WTF::RunLoop::TimerBase::stop):
(WTF::RunLoop::TimerBase::isActive):
2017-04-11 Zan Dobersek <zdobersek@igalia.com>
REGRESSION(r213645): It made JSC tests super slow and timeout on AArch64 Linux
https://bugs.webkit.org/show_bug.cgi?id=169510
Reviewed by Saam Barati.
Add the `volatile` qualifiers for ASM statements that set up ldxr and stxr
instruction calls when HAVE(LL_SC) is enabled for aarch64 platforms.
This avoids indefinite execution when running GCC-compiled JSC on Linux.
Specific bug or expected behavior that differs from Clang wasn't determined.
HAVE(LL_SC) is re-enabled on non-Darwin aarch64 platforms.
* wtf/Atomics.h:
* wtf/Platform.h:
2017-04-10 Thorsten Glaser <tg@mirbsd.de>
[GTK] Fix x32 build
https://bugs.webkit.org/show_bug.cgi?id=170673
Reviewed by Carlos Alberto Lopez Perez.
* wtf/Platform.h:
2017-04-09 Yusuke Suzuki <utatane.tea@gmail.com>
[WTF] Annotate Seconds' member functions and operators with constexpr
https://bugs.webkit.org/show_bug.cgi?id=170662
Reviewed by Daniel Bates.
Annotate Seconds' member functions and operators with constexpr.
It allows us to use Seconds calculation in compile time and use these
calculation for static const global variables.
operator% is an exception: it uses fmod and it is not offered as constexpr.
* wtf/MathExtras.h:
(defaultMinimumForClamp):
(defaultMaximumForClamp):
(clampToAccepting64):
Super unfortunate ugly code. This is because GCC 4.9 does not support C++14 relaxed constexpr.
* wtf/Seconds.h:
(WTF::Seconds::Seconds):
(WTF::Seconds::value):
(WTF::Seconds::minutes):
(WTF::Seconds::seconds):
(WTF::Seconds::milliseconds):
(WTF::Seconds::microseconds):
(WTF::Seconds::nanoseconds):
(WTF::Seconds::operator bool):
(WTF::Seconds::operator+):
(WTF::Seconds::operator-):
(WTF::Seconds::operator*):
(WTF::Seconds::operator/):
(WTF::Seconds::operator==):
(WTF::Seconds::operator!=):
(WTF::Seconds::operator<):
(WTF::Seconds::operator>):
(WTF::Seconds::operator<=):
(WTF::Seconds::operator>=):
2017-04-09 Chris Dumez <cdumez@apple.com>
Start dropping Timer API dealing with double
https://bugs.webkit.org/show_bug.cgi?id=170649
Reviewed by Yusuke Suzuki.
Start dropping Timer API dealing with double as people should use Seconds now.
* wtf/RunLoopTimer.h:
* wtf/glib/MainThreadGLib.cpp:
(WTF::MainThreadDispatcher::schedule):
2017-04-07 Keith Miller <keith_miller@apple.com>
Unreviewed, remove constexpr function since GTK didn't like it.
* wtf/PriorityQueue.h:
(WTF::PriorityQueue::parentOf):
2017-04-07 Chris Dumez <cdumez@apple.com>
Start using MonotonicTime / Seconds in Timer class
https://bugs.webkit.org/show_bug.cgi?id=170625
Reviewed by Simon Fraser.
Add modulo operator to MonotonicTime.
* wtf/MonotonicTime.h:
(WTF::MonotonicTime::operator%):
2017-04-07 Keith Miller <keith_miller@apple.com>
Add a PriorityQueue class
https://bugs.webkit.org/show_bug.cgi?id=170579
Reviewed by Saam Barati.
This patch adds a new PriorityQueue class that is backed by
WTF::Vector. It also has a number of other niceties such as being
able to iterate the queue and increase or decrease keys.
One note is that increaseKey and decreaseKey are O(n) rather than
O(log(n)). Traditionally, the lookup of the key is done with a
hash map but that's not feasible here. This is because unless the
queue's element type is a pointer there is no good way maintain a
persistent reference to every entry in the queue while we sift.
The only way to update the location of an entry is to do a hash
table lookup with the entry's hash but this is probably more
expensive than just doing a linear search.
Also, add comparison operator functions, which can be passed to PriorityQueue.
* WTF.xcodeproj/project.pbxproj:
* wtf/MathExtras.h:
(isLessThan):
(isLessThanEqual):
(isGreaterThan):
(isGreaterThanEqual):
* wtf/PriorityQueue.h: Added.
(WTF::PriorityQueue::size):
(WTF::PriorityQueue::isEmpty):
(WTF::PriorityQueue::enqueue):
(WTF::PriorityQueue::peek):
(WTF::PriorityQueue::dequeue):
(WTF::PriorityQueue::decreaseKey):
(WTF::PriorityQueue::increaseKey):
(WTF::PriorityQueue::begin):
(WTF::PriorityQueue::end):
(WTF::PriorityQueue::isValidHeap):
(WTF::PriorityQueue::parentOf):
(WTF::PriorityQueue::leftChildOf):
(WTF::PriorityQueue::rightChildOf):
(WTF::PriorityQueue::siftUp):
(WTF::PriorityQueue::siftDown):
2017-04-07 Alex Christensen <achristensen@webkit.org>
Use audit_token_t instead of pid_t for checking sandbox of other processes
https://bugs.webkit.org/show_bug.cgi?id=170616
<rdar://problem/31158189>
Reviewed by Daniel Bates.
* wtf/spi/darwin/SandboxSPI.h:
Declare more SPI.
2017-04-07 Ting-Wei Lan <lantw44@gmail.com>
Include cstdio before using sscanf and stderr
https://bugs.webkit.org/show_bug.cgi?id=170098
Reviewed by Michael Catanzaro.
* wtf/NumberOfCores.cpp:
2017-04-07 Saam Barati <sbarati@apple.com>
WebAssembly: Make to a compilation API that allows for multi-VM concurrent compilations of Wasm Modules
https://bugs.webkit.org/show_bug.cgi?id=170488
Reviewed by JF Bastien.
* wtf/SharedTask.h: Make SharedTaskFunctor forward its arguments.
2017-04-07 Carlos Garcia Campos <cgarcia@igalia.com>
[GTK] Update the priorities used in glib main loop sources
https://bugs.webkit.org/show_bug.cgi?id=170457
Reviewed by Žan Doberšek.
Add an enum to define prirorities used in different GLib main sources. It allows to give them a better name
than high, low, medium, etc., but also to document them and other GLib based ports can define their own
values without changing all the places where they are used. The default values are based on the priorities
pre-defined by GLib.
* wtf/glib/MainThreadGLib.cpp:
(WTF::MainThreadDispatcher::MainThreadDispatcher):
* wtf/glib/RunLoopGLib.cpp:
(WTF::RunLoop::RunLoop):
(WTF::RunLoop::dispatchAfter):
(WTF::RunLoop::TimerBase::TimerBase):
* wtf/glib/RunLoopSourcePriority.h: Added.
* wtf/linux/MemoryPressureHandlerLinux.cpp:
(WTF::MemoryPressureHandler::EventFDPoller::EventFDPoller):
2017-04-06 Filip Pizlo <fpizlo@apple.com>
Linear scan should run liveness only once
https://bugs.webkit.org/show_bug.cgi?id=170569
Reviewed by Keith Miller.
Have Liveness<> call Adapter::prepareToCompute(), since this makes it a lot easier to implement
constraint generation, since the constraint generator now gets to run after the Adapter is fully
constructed.
* wtf/IndexMap.h:
(WTF::IndexMap::append): Also make this a bit more versatile.
* wtf/Liveness.h:
(WTF::Liveness::LocalCalc::Iterable::contains):
(WTF::Liveness::Iterable::contains):
(WTF::Liveness::compute):
2017-04-06 Andreas Kling <akling@apple.com>
Kill any WebContent process using over 16 GB of memory.
https://bugs.webkit.org/show_bug.cgi?id=170515
<rdar://problem/29930931>
Reviewed by Antti Koivisto.
Restructure the code since it was getting out of sync with the intended behavior.
Now there's a thresholdForMemoryKill() which returns the current memory limit based
on the process status.
The memory usage policy is separated from the killing, and now only drives the
asynchronous invocations of pressure relief that occur when we pass over one of
the policy edges (now 1GB for Conservative, 2GB for Strict.)
Removed the "Panic" policy and moved the memory kill logic to shrinkOrDie().
Behavior as of this patch:
- Everyone gets killed over 16 GB.
- Inactive processes get killed over 4 GB.
- Strict memory usage policy kicks in at 2 GB.
- Conservative memory usage policy at 1 GB.
Like before, we make a best-effort attempt to free up memory before killing the process.
* wtf/MemoryPressureHandler.cpp:
(WTF::toString):
(WTF::MemoryPressureHandler::thresholdForMemoryKill):
(WTF::thresholdForPolicy):
(WTF::policyForFootprint):
(WTF::MemoryPressureHandler::shrinkOrDie):
(WTF::MemoryPressureHandler::setMemoryUsagePolicyBasedOnFootprint):
(WTF::MemoryPressureHandler::measurementTimerFired):
* wtf/MemoryPressureHandler.h:
2017-04-05 Andreas Kling <akling@apple.com>
Make inactive web processes behave as though under memory pressure.
https://bugs.webkit.org/show_bug.cgi?id=170042
<rdar://problem/31038445>
Reviewed by Antti Koivisto.
Once a web process becomes inactive, let's try to reduce its impact
on memory usage by treating it as if it's under memory pressure until
it becomes active.
* wtf/MemoryPressureHandler.cpp:
(WTF::MemoryPressureHandler::setProcessState):
(WTF::MemoryPressureHandler::isUnderMemoryPressure):
* wtf/MemoryPressureHandler.h:
(WTF::MemoryPressureHandler::isUnderMemoryPressure): Deleted.
2017-04-05 Yusuke Suzuki <utatane.tea@gmail.com>
[JSC] Suppress warnings in GCC
https://bugs.webkit.org/show_bug.cgi?id=170501
Reviewed by Keith Miller.
Add a new macro UNUSED_FUNCTION to annotate unused static functions.
#pragma GCC diagnostic ignored "-Wunused-function" does not work.
* wtf/Compiler.h:
2017-04-04 Filip Pizlo <fpizlo@apple.com>
Air::eliminateDeadCode() should not use a HashSet
https://bugs.webkit.org/show_bug.cgi?id=170487
Reviewed by Saam Barati.
BitVector::iterator knows when it's at the end. Expose this functionality.
* wtf/BitVector.h:
(WTF::BitVector::iterator::isAtEnd):
2017-04-04 Keith Miller <keith_miller@apple.com>
WebAssembly: ModuleInformation should be a ref counted thing that can be shared across threads.
https://bugs.webkit.org/show_bug.cgi?id=170478
Reviewed by Saam Barati.
This adds a new String::fromUTF8 that converts a vector of characters to
a string.
Also, it cleans up some style.
* wtf/text/WTFString.h:
(WTF::String::fromUTF8):
* wtf/unicode/UTF8.cpp:
(WTF::Unicode::convertLatin1ToUTF8):
2017-04-04 Filip Pizlo <fpizlo@apple.com>
B3::fixSSA() needs a tune-up
https://bugs.webkit.org/show_bug.cgi?id=170485
Reviewed by Saam Barati.
This makes IndexSparseSet capable of being used as a map if you instantiate it with
KeyValuePair<unsigned, ValueType>.
* wtf/HashTraits.h:
* wtf/IndexSparseSet.h:
(WTF::DefaultIndexSparseSetTraits::create):
(WTF::DefaultIndexSparseSetTraits::key):
(WTF::OverflowHandler>::IndexSparseSet):
(WTF::OverflowHandler>::add):
(WTF::OverflowHandler>::set):
(WTF::OverflowHandler>::remove):
(WTF::OverflowHandler>::clear):
(WTF::OverflowHandler>::size):
(WTF::OverflowHandler>::isEmpty):
(WTF::OverflowHandler>::contains):
(WTF::OverflowHandler>::sort):
(WTF::IndexSparseSet<OverflowHandler>::IndexSparseSet): Deleted.
(WTF::IndexSparseSet<OverflowHandler>::add): Deleted.
(WTF::IndexSparseSet<OverflowHandler>::remove): Deleted.
(WTF::IndexSparseSet<OverflowHandler>::clear): Deleted.
(WTF::IndexSparseSet<OverflowHandler>::size): Deleted.
(WTF::IndexSparseSet<OverflowHandler>::isEmpty): Deleted.
(WTF::IndexSparseSet<OverflowHandler>::contains): Deleted.
(WTF::IndexSparseSet<OverflowHandler>::sort): Deleted.
* wtf/Liveness.h:
(WTF::Liveness::LocalCalc::Iterable::iterator::iterator):
(WTF::Liveness::workset):
2017-04-04 Filip Pizlo <fpizlo@apple.com>
Don't need to Air::reportUsedRegisters for wasm at -O1
https://bugs.webkit.org/show_bug.cgi?id=170459
Reviewed by Saam Barati.
Just moved the liveness computation into a method, which enabled me to do the profiling
that I used to write this patch.
* wtf/Liveness.h:
(WTF::Liveness::Liveness):
(WTF::Liveness::compute):
2017-04-03 Filip Pizlo <fpizlo@apple.com>
Air liveness should build constraints and solve them rather than repeatedly parsing IR
https://bugs.webkit.org/show_bug.cgi?id=170421
Reviewed by Saam Barati.
* wtf/Vector.h:
(WTF::minCapacity>::appendIfNotContains): Because sometimes Vector<> is the best kind of set.
2017-04-03 Yusuke Suzuki <utatane.tea@gmail.com>
[WTF] Introduce WTF::RandomDevice which keeps /dev/urandom opened
https://bugs.webkit.org/show_bug.cgi?id=170095
Reviewed by Michael Catanzaro.
In this patch, we introduce RandomDevice, which keeps /dev/urandom opened
to avoid repeatedly open and close urandom file descriptor in Linux.
The purpose is similar to std::random_device, but WTF::RandomDevice explicitly
avoids using ARC4, which is recently attempted to be removed from the WebKit
tree[1].
[1]: https://trac.webkit.org/r214329
* WTF.xcodeproj/project.pbxproj:
* wtf/CMakeLists.txt:
* wtf/OSRandomSource.cpp:
(WTF::cryptographicallyRandomValuesFromOS):
(WTF::crashUnableToOpenURandom): Deleted.
(WTF::crashUnableToReadFromURandom): Deleted.
* wtf/RandomDevice.cpp: Copied from Source/WTF/wtf/OSRandomSource.cpp.
(WTF::crashUnableToOpenURandom):
(WTF::crashUnableToReadFromURandom):
(WTF::RandomDevice::RandomDevice):
(WTF::RandomDevice::~RandomDevice):
(WTF::RandomDevice::cryptographicallyRandomValues):
* wtf/RandomDevice.h: Added.
2017-04-03 Filip Pizlo <fpizlo@apple.com>
WTF::Liveness should have an API that focuses on actions at instruction boundaries
https://bugs.webkit.org/show_bug.cgi?id=170407
Reviewed by Keith Miller.
Change the Liveness<> API to handle early and late things in one lump inside forEachUse
and forEachDef functions. This reduces the amount of different functions that Liveness<>
expects from its adaptor. This makes it easier to implement optimizations that cache the
use/def behavior of each instruction boundary.
* wtf/Liveness.h:
(WTF::Liveness::Liveness):
(WTF::Liveness::LocalCalc::execute):
2017-04-01 Csaba Osztrogonác <ossy@webkit.org>
Mac cmake buildfix after 214586.
https://bugs.webkit.org/show_bug.cgi?id=170381
Unreviewed.
* wtf/BlockPtr.h:
2017-03-30 Filip Pizlo <fpizlo@apple.com>
Air should support linear scan for optLevel<2
https://bugs.webkit.org/show_bug.cgi?id=170161
Reviewed by Saam Barati.
This change introduces a new low-latency register allocator. It can allocate registers very
quickly by doing a relatively poor job. Implementing this algorithm required beefing up some of
our core algorithms.
* WTF.xcodeproj/project.pbxproj:
* wtf/CMakeLists.txt:
* wtf/Deque.h: Make it possible to do some basic priority queueing with this data structure.
(WTF::inlineCapacity>::removeAllMatching):
(WTF::inlineCapacity>::appendAndBubble):
(WTF::inlineCapacity>::takeLast):
* wtf/IndexKeyType.h: Added. This makes it possible to use IndexMap and IndexSet with value or pointer types. Previously they just worked with pointer types.
(WTF::IndexKeyType::index):
* wtf/IndexMap.h: Adopt IndexKeyType.
(WTF::IndexMap::operator[]):
(WTF::IndexMap::append):
* wtf/IndexSet.h: Adopt IndexKeyType.
(WTF::IndexSet::add):
(WTF::IndexSet::addAll):
(WTF::IndexSet::remove):
(WTF::IndexSet::contains):
(WTF::IndexSet::Iterable::iterator::operator*):
* wtf/Range.h: Added. This used to be B3::HeapRange. This generalizes that data structure to any kind of range stuff.
(WTF::Range::Range):
(WTF::Range::top):
(WTF::Range::operator==):
(WTF::Range::operator!=):
(WTF::Range::operator bool):
(WTF::Range::operator|):
(WTF::Range::operator|=):
(WTF::Range::begin):
(WTF::Range::end):
(WTF::Range::overlaps):
(WTF::Range::dump):
* wtf/RangeSet.h:
(WTF::RangeSet::add):
2017-03-25 Yusuke Suzuki <utatane.tea@gmail.com>
[JSC] Move platformThreadSignal to WTF
https://bugs.webkit.org/show_bug.cgi?id=170097
Reviewed by Mark Lam.
* wtf/Threading.h:
* wtf/ThreadingPthreads.cpp:
(WTF::signalThread):
2017-03-26 Filip Pizlo <fpizlo@apple.com>
B3::fixSSA should do liveness pruning
https://bugs.webkit.org/show_bug.cgi?id=170111
Reviewed by Saam Barati.
Move Air::Liveness<> to WTF::Liveness<>. This is pretty easy since Air::Liveness<> was
already fairly generic. It leverages the CFG concept so that it can understand many
different kinds of basic blocks. It doesn't try to understand the contents of basic
blocks; it just asks the adaptor for the block size and asks for the early/late
uses/defs of each thing in the block.
This makes it easy to create a B3::VariableLiveness, which fixSSA then uses for
pruning. One of the new features is the Liveness::LiveAtHead nested class, which you
instantiate if you want to perform liveAtHead queries, which SSA construction wants to
do.
This also fixes https://bugs.webkit.org/show_bug.cgi?id=170102#c12
* WTF.xcodeproj/project.pbxproj:
* wtf/CMakeLists.txt:
* wtf/Liveness.h: Added.
(WTF::Liveness::Liveness):
(WTF::Liveness::LocalCalc::LocalCalc):
(WTF::Liveness::LocalCalc::Iterable::Iterable):
(WTF::Liveness::LocalCalc::Iterable::iterator::iterator):
(WTF::Liveness::LocalCalc::Iterable::iterator::operator++):
(WTF::Liveness::LocalCalc::Iterable::iterator::operator*):
(WTF::Liveness::LocalCalc::Iterable::iterator::operator==):
(WTF::Liveness::LocalCalc::Iterable::iterator::operator!=):
(WTF::Liveness::LocalCalc::Iterable::begin):
(WTF::Liveness::LocalCalc::Iterable::end):
(WTF::Liveness::LocalCalc::Iterable::contains):
(WTF::Liveness::LocalCalc::live):
(WTF::Liveness::LocalCalc::isLive):
(WTF::Liveness::LocalCalc::execute):
(WTF::Liveness::rawLiveAtHead):
(WTF::Liveness::Iterable::Iterable):
(WTF::Liveness::Iterable::iterator::iterator):
(WTF::Liveness::Iterable::iterator::operator*):
(WTF::Liveness::Iterable::iterator::operator++):
(WTF::Liveness::Iterable::iterator::operator==):
(WTF::Liveness::Iterable::iterator::operator!=):
(WTF::Liveness::Iterable::begin):
(WTF::Liveness::Iterable::end):
(WTF::Liveness::Iterable::contains):
(WTF::Liveness::liveAtHead):
(WTF::Liveness::liveAtTail):
(WTF::Liveness::workset):
(WTF::Liveness::LiveAtHead::LiveAtHead):
(WTF::Liveness::LiveAtHead::isLiveAtHead):
2017-03-25 Filip Pizlo <fpizlo@apple.com>
Air::Liveness shouldn't need HashSets
https://bugs.webkit.org/show_bug.cgi?id=170102
Reviewed by Yusuke Suzuki.
* wtf/IndexSparseSet.h: Add some helpers for a HashSet-free liveness analysis.
(WTF::IndexSparseSet::values):
(WTF::IndexSparseSet<OverflowHandler>::sort):
* wtf/StdLibExtras.h:
(WTF::mergeDeduplicatedSorted): Rapidly merge two sorted lists that don't have duplicates to produce a new sorted list that doesn't have duplicates.
* wtf/Vector.h:
(WTF::minCapacity>::uncheckedAppend): Inline this!
(WTF::removeRepeatedElements): This is a version of std::unique() that works naturally for Vectors.
2017-03-26 Filip Pizlo <fpizlo@apple.com>
Air should use RegisterSet for RegLiveness
https://bugs.webkit.org/show_bug.cgi?id=170108
Reviewed by Yusuke Suzuki.
* wtf/Atomics.h:
(WTF::ensurePointer): This is a useful replacement for std::once, which requires less fencing.
* wtf/Bitmap.h: Add more utilities.
(WTF::Bitmap::iterator::iterator): An iterator for set bits.
(WTF::Bitmap::iterator::operator*):
(WTF::Bitmap::iterator::operator++):
(WTF::Bitmap::iterator::operator==):
(WTF::Bitmap::iterator::operator!=):
(WTF::Bitmap::begin):
(WTF::Bitmap::end):
(WTF::WordType>::subsumes): a.subsumes(b) if all of b's set bits are set in a.
(WTF::WordType>::findBit): find next set or clear bit.
2017-03-24 JF Bastien <jfbastien@apple.com>
WebAssembly: store state in TLS instead of on VM
https://bugs.webkit.org/show_bug.cgi?id=169611
Reviewed by Filip Pizlo.
* wtf/FastTLS.h: reserve one key for WebAssembly, delete a bunch
of dead code which clang couldn't compile (it's valid GCC assembly
which LLVM dislikes).
2017-03-24 Ryan Haddad <ryanhaddad@apple.com>
Unreviewed, rolling out r214351.
This change caused API test
WebKit1.DidCreateJavaScriptContextBackForwardCacheTest to
fail.
Reverted changeset:
"Make inactive web processes behave as though under memory
pressure."
https://bugs.webkit.org/show_bug.cgi?id=170042
http://trac.webkit.org/changeset/214351
2017-03-24 Chris Dumez <cdumez@apple.com>
Unreviewed, rolling out r214329.
Significantly regressed Speedometer
Reverted changeset:
"window.crypto.getRandomValues() uses the insecure RC4 RNG"
https://bugs.webkit.org/show_bug.cgi?id=169623
http://trac.webkit.org/changeset/214329
2017-03-24 Andreas Kling <akling@apple.com>
Make inactive web processes behave as though under memory pressure.
<https://webkit.org/b/170042>
Reviewed by Antti Koivisto.
Once a web process becomes inactive, let's try to reduce its impact
on memory usage by treating it as if it's under memory pressure until
it becomes active.
* wtf/MemoryPressureHandler.cpp:
(WTF::MemoryPressureHandler::setProcessState):
(WTF::MemoryPressureHandler::isUnderMemoryPressure):
* wtf/MemoryPressureHandler.h:
(WTF::MemoryPressureHandler::isUnderMemoryPressure): Deleted.
2017-03-23 Michael Catanzaro <mcatanzaro@igalia.com>
window.crypto.getRandomValues() uses the insecure RC4 RNG
https://bugs.webkit.org/show_bug.cgi?id=169623
Reviewed by Alex Christensen.
Remove the RC4 random generator in favor of using OS randomness for now. This is basically
a merge of https://codereview.chromium.org/1431233002 from Blink, original author "eroman".
* wtf/CryptographicallyRandomNumber.cpp:
(WTF::cryptographicallyRandomNumber):
(WTF::cryptographicallyRandomValues):
(): Deleted.
2017-03-23 Tomas Popela <tpopela@redhat.com>
Fix uninitialized public members in WTF
https://bugs.webkit.org/show_bug.cgi?id=169676
Reviewed by Michael Catanzaro.
Found by Coverity scan.
* wtf/Bag.h:
* wtf/HashTable.h:
* wtf/HashTraits.h:
* wtf/Insertion.h:
* wtf/OrderMaker.h:
* wtf/ParallelJobsGeneric.h:
2017-03-22 Andreas Kling <akling@apple.com>
Let MemoryPressureHandler track whether the process is active or inactive.
<https://webkit.org/b/169990>
Reviewed by Antti Koivisto.
An active process is a process that meets any of these criteria:
- Has had a visible Page in an active window in the last hour
- Is playing audio
This replaces the old mechanism where MemoryPressureHandler would invoke
a callback to know whether the process was eligible for a memory kill.
Instead we now plumb the relevant information down from WebCore and kill
based on this activity state.
* wtf/MemoryPressureHandler.cpp:
(WTF::MemoryPressureHandler::measurementTimerFired):
(WTF::MemoryPressureHandler::setProcessState):
* wtf/MemoryPressureHandler.h:
(WTF::MemoryPressureHandler::setMemoryKillCallback):
(WTF::MemoryPressureHandler::processState):
(WTF::MemoryPressureHandler::setProcessIsEligibleForMemoryKillCallback): Deleted.
2017-03-20 Simon Fraser <simon.fraser@apple.com>
Add a system trace point for memory warning handling
https://bugs.webkit.org/show_bug.cgi?id=169893
Reviewed by Zalan Bujtas.
Make it possible to pass data to the Begin trace point.
* wtf/SystemTracing.h:
(WTF::TraceScope::TraceScope):
2017-03-17 Said Abou-Hallawa <sabouhallawa@apple.com>
Time channel attack on SVG Filters
https://bugs.webkit.org/show_bug.cgi?id=118689
Reviewed by Simon Fraser.
Performing arithmetic operations on subnormal floating-point numbers is
very expensive. Normalizing the floating-point number to the minimum normal
value should accelerate the calculations and there won't be a noticeable
difference in the result since all the subnormal values and the minimum
normal value are all very close to zero.
* wtf/MathExtras.h:
(normalizedFloat):
2017-03-11 Filip Pizlo <fpizlo@apple.com>
Air should be powerful enough to support Tmp-splitting
https://bugs.webkit.org/show_bug.cgi?id=169515
Reviewed by Saam Barati.
Teach IndexMap how to handle types that don't have a default constructor. This makes it
easy to create a IndexMap<BasicBlock, InsertionSet>, which is a super powerful
construct.
* wtf/IndexMap.h:
(WTF::IndexMap::IndexMap):
(WTF::IndexMap::resize):
(WTF::IndexMap::clear):
2017-03-16 Simon Fraser <simon.fraser@apple.com>
Improve the system tracing points
https://bugs.webkit.org/show_bug.cgi?id=169790
Reviewed by Zalan Bujtas.
Use a more cohesive set of system trace points that give a good overview of what
WebKit is doing. Added points for resource loading, render tree building, sync messages
to the web process, async image decode, WASM and fetching cookies.
* wtf/SystemTracing.h:
2017-03-16 Carlos Garcia Campos <cgarcia@igalia.com>
[UNIX] Implement currentSearchLocaleID() and currentTextBreakLocaleID()
https://bugs.webkit.org/show_bug.cgi?id=169745
Reviewed by Yusuke Suzuki.
Add a common implementation for Unix based ports using setlocale.
* wtf/PlatformGTK.cmake:
* wtf/PlatformJSCOnly.cmake:
* wtf/text/gtk/TextBreakIteratorInternalICUGtk.cpp: Removed.
* wtf/text/unix/TextBreakIteratorInternalICUUnix.cpp: Renamed from Source/WTF/wtf/text/jsconly/TextBreakIteratorInternalICUJSCOnly.cpp.
(WTF::currentSearchLocaleID):
(WTF::currentTextBreakLocaleID):
2017-03-16 Carlos Garcia Campos <cgarcia@igalia.com>
[GLIB] MainThread implementation is not GTK+ specific
https://bugs.webkit.org/show_bug.cgi?id=169736
Reviewed by Yusuke Suzuki.
It's implemented in MainThreadGLib.cpp for glib based ports, so ifdefs in MainThread should not be
PLATFORM(GTK) but USE(GLIB).
* wtf/MainThread.cpp:
* wtf/MainThread.h:
2017-03-15 Carlos Alberto Lopez Perez <clopez@igalia.com>
[CMake][JSCOnly] Fix build with GLib event loop
https://bugs.webkit.org/show_bug.cgi?id=169730
Reviewed by Michael Catanzaro.
* wtf/MainThread.cpp:
* wtf/PlatformJSCOnly.cmake: WorkQueueGLib was removed in r199713.
2017-03-15 Dean Jackson <dino@apple.com>
Sort Xcode project files
https://bugs.webkit.org/show_bug.cgi?id=169669
Reviewed by Antoine Quint.
* WTF.xcodeproj/project.pbxproj:
2017-03-14 Filip Pizlo <fpizlo@apple.com>
Fix some typos in this benchmark.
Rubber stamped by Saam Barati.
* benchmarks/HashSetDFGReplay.cpp:
(main):
2017-03-14 Filip Pizlo <fpizlo@apple.com>
Record the HashSet/HashMap operations in DFG/FTL/B3 and replay them in a benchmark
https://bugs.webkit.org/show_bug.cgi?id=169590
Reviewed by Saam Barati.
This adds LoggingHashSet and LoggingHashMap, which are drop-in replacements for HashSet and
HashMap that log everything that they do, so that you can replay it later.
This also adds a benchmark (HashSetDFGReplay) based on doing a recording of some of the HashSets
in the DFG compiler.
* WTF.xcodeproj/project.pbxproj:
* benchmarks/HashSetDFGReplay.cpp: Added.
(benchmark):
(main):
* wtf/CMakeLists.txt:
* wtf/GlobalVersion.cpp: Added.
(WTF::newGlobalVersion):
* wtf/GlobalVersion.h: Added.
* wtf/HashMap.h:
(WTF::X>::swap):
* wtf/HashSet.h:
(WTF::V>::addVoid):
* wtf/LoggingHashID.h: Added.
(WTF::LoggingHashID::LoggingHashID):
(WTF::LoggingHashID::dump):
* wtf/LoggingHashMap.h: Added.
* wtf/LoggingHashSet.h: Added.
* wtf/LoggingHashTraits.h: Added.
(WTF::LoggingHashKeyTraits::print):
(WTF::LoggingHashValueTraits::print):
2017-03-13 Jer Noble <jer.noble@apple.com>
Make classes used by Media Stream encode/decode friendly
https://bugs.webkit.org/show_bug.cgi?id=169567
Reviewed by Eric Carlson.
* wtf/MediaTime.h:
(WTF::MediaTime::encode):
(WTF::MediaTime::decode):
2017-03-14 Yusuke Suzuki <utatane.tea@gmail.com>
Add secondsAs<T> methods to Seconds to convert it to integers with clamp
https://bugs.webkit.org/show_bug.cgi?id=169537
Reviewed by Carlos Garcia Campos.
When using the usual static_cast, infinity becomes 0 accidentally.
It is not intended value when using Seconds for timeout value.
Instead, we use clampToAccepting64 to convert Seconds to
integer values to pass them to the system functions.
* wtf/MathExtras.h:
(clampToAccepting64):
* wtf/Seconds.h:
(WTF::Seconds::minutesAs):
(WTF::Seconds::secondsAs):
(WTF::Seconds::millisecondsAs):
(WTF::Seconds::microsecondsAs):
(WTF::Seconds::nanosecondsAs):
* wtf/cocoa/WorkQueueCocoa.cpp:
(WTF::WorkQueue::dispatchAfter):
* wtf/glib/RunLoopGLib.cpp:
(WTF::RunLoop::dispatchAfter):
(WTF::RunLoop::TimerBase::updateReadyTime):
2017-03-13 Yusuke Suzuki <utatane.tea@gmail.com>
[JSC][Linux] Implement VMTrap in Linux ports
https://bugs.webkit.org/show_bug.cgi?id=169436
Reviewed by Mark Lam.
Enable VMTrap mechanism for Linux and FreeBSD.
* wtf/Platform.h:
2017-03-13 Yusuke Suzuki <utatane.tea@gmail.com>
[WTF] Clean up RunLoop and WorkQueue with Seconds and Function
https://bugs.webkit.org/show_bug.cgi?id=169537
Reviewed by Sam Weinig.
This patch modernizes RunLoop and WorkQueue.
1. Use Ref<> aggressively
2. Use Seconds instead of chrono times
3. Use Function<> instead of std::function
* wtf/MainThread.cpp:
(WTF::dispatchFunctionsFromMainThread):
* wtf/RunLoop.h:
* wtf/WorkQueue.h:
* wtf/cocoa/WorkQueueCocoa.cpp:
(WTF::WorkQueue::dispatch):
(WTF::WorkQueue::dispatchAfter):
(WTF::WorkQueue::concurrentApply):
* wtf/generic/MainThreadGeneric.cpp:
(WTF::scheduleDispatchFunctionsOnMainThread):
* wtf/generic/RunLoopGeneric.cpp:
(WTF::RunLoop::TimerBase::ScheduledTask::create):
(WTF::RunLoop::TimerBase::ScheduledTask::EarliestSchedule::operator()):
(WTF::RunLoop::populateTasks):
(WTF::RunLoop::runImpl):
(WTF::RunLoop::schedule):
(WTF::RunLoop::scheduleAndWakeUp):
(WTF::RunLoop::dispatchAfter):
(WTF::RunLoop::TimerBase::start):
* wtf/generic/WorkQueueGeneric.cpp:
(WorkQueue::dispatch):
(WorkQueue::dispatchAfter):
* wtf/glib/RunLoopGLib.cpp:
(WTF::DispatchAfterContext::DispatchAfterContext):
(WTF::RunLoop::dispatchAfter):
(WTF::RunLoop::TimerBase::updateReadyTime):
(WTF::RunLoop::TimerBase::start):
* wtf/win/WorkQueueWin.cpp:
(WTF::WorkQueue::performWorkOnRegisteredWorkThread):
(WTF::WorkQueue::dispatch):
(WTF::WorkQueue::dispatchAfter):
2017-03-13 Chris Dumez <cdumez@apple.com>
[WK2] Only report background WebProcesses as unresponsive in the background after 90 seconds
https://bugs.webkit.org/show_bug.cgi?id=169425
<rdar://problem/30954003>
Reviewed by Andreas Kling.
* wtf/RunLoop.h:
(WTF::RunLoop::TimerBase::startRepeating):
(WTF::RunLoop::TimerBase::startOneShot):
Add overloads to RunLoop::Timer that take Seconds in parameter,
for convenience.
* wtf/Seconds.h:
(WTF::Seconds::fromHours):
(WTF::seconds_literals::operator _h):
Allow _h suffix for initializing Seconds type to hours.
2017-03-11 Csaba Osztrogonác <ossy@webkit.org>
REGRESSION(r213645): It made JSC tests super slow and timeout on AArch64 Linux
https://bugs.webkit.org/show_bug.cgi?id=169510
Unreviewed, disable LL_SC on Linux to unbreak this platform.
* wtf/Atomics.h:
* wtf/Platform.h:
2017-03-10 Filip Pizlo <fpizlo@apple.com>
The JITs should be able to emit fast TLS loads
https://bugs.webkit.org/show_bug.cgi?id=169483
Reviewed by Keith Miller.
Consolidated what we know about fast TLS in FastTLS.h.
* WTF.xcodeproj/project.pbxproj:
* wtf/CMakeLists.txt:
* wtf/FastTLS.h: Added.
(WTF::loadFastTLS):
(WTF::fastTLSOffsetForKey):
* wtf/Platform.h:
* wtf/WTFThreadData.cpp:
(WTF::WTFThreadData::createAndRegisterForGetspecificDirect):
* wtf/WTFThreadData.h:
(WTF::wtfThreadData):
2017-03-10 Mark Lam <mark.lam@apple.com>
Turn ENABLE(MASM_PROBE) on by default for OS(DARWIN) release builds.
https://bugs.webkit.org/show_bug.cgi?id=169493
Reviewed by Saam Barati.
MASM_PROBE was already enabled for debug builds. This change makes it so that we
don't have to rebuild the world every time we need to use it on a release build.
* wtf/Platform.h:
2017-03-10 Csaba Osztrogonác <ossy@webkit.org>
Unreviewed AArch64 Linux buildfix after r213645.
https://bugs.webkit.org/show_bug.cgi?id=169300
* wtf/Atomics.h: intptr_t and int64_t are typedefs for long int on Linux.
They are different types only on Darwin platforms.
2017-03-09 Caio Lima <ticaiolima@gmail.com>
[ESnext] Implement Object Rest - Implementing Object Rest Destructuring
https://bugs.webkit.org/show_bug.cgi?id=167962
Reviewed by Keith Miller.
* wtf/HashSet.h:
(WTF::=):
2017-03-09 Youenn Fablet <youenn@apple.com>
Activate VideoToolbox when WebRTC is enabled on iOS
https://bugs.webkit.org/show_bug.cgi?id=169423
Reviewed by Jon Lee.
* wtf/Platform.h: Activate VIDEOTOOLBOX if WEBRTC is enabled.
2017-03-09 Filip Pizlo <fpizlo@apple.com>
std::isnan/isinf/isfinite should work with WTF time classes
https://bugs.webkit.org/show_bug.cgi?id=164991
Reviewed by Darin Adler.
The consensus view (see comments in https://bugs.webkit.org/show_bug.cgi?id=152045) of how
to check if something is NaN is to use std::isnan(). To be able to do that for time
classes, they need to provide their own isnan() overhload. This also provides isinf()
overloads.
* wtf/MonotonicTime.h:
(std::isnan):
(std::isinf):
* wtf/Seconds.h:
(std::isnan):
(std::isinf):
* wtf/TimeWithDynamicClockType.h:
(std::isnan):
(std::isinf):
* wtf/WallTime.h:
(std::isnan):
(std::isinf):
2017-03-09 Mark Lam <mark.lam@apple.com>
Use const AbstractLocker& (instead of const LockHolder&) in more places.
https://bugs.webkit.org/show_bug.cgi?id=169424
Reviewed by Filip Pizlo.
* wtf/RunLoop.h:
* wtf/generic/RunLoopGeneric.cpp:
(WTF::RunLoop::wakeUp):
(WTF::RunLoop::schedule):
2017-03-09 Mark Lam <mark.lam@apple.com>
Make the VM Traps mechanism non-polling for the DFG and FTL.
https://bugs.webkit.org/show_bug.cgi?id=168920
<rdar://problem/30738588>
Reviewed by Filip Pizlo.
Make StackBounds more useful for checking if a pointer is within stack bounds.
* wtf/MetaAllocator.cpp:
(WTF::MetaAllocator::isInAllocatedMemory):
* wtf/MetaAllocator.h:
* wtf/Platform.h:
* wtf/StackBounds.h:
(WTF::StackBounds::emptyBounds):
(WTF::StackBounds::StackBounds):
(WTF::StackBounds::isEmpty):
(WTF::StackBounds::contains):
2017-03-07 Filip Pizlo <fpizlo@apple.com>
WTF should make it super easy to do ARM concurrency tricks
https://bugs.webkit.org/show_bug.cgi?id=169300
Reviewed by Mark Lam.
This adds Atomic<>::loadLink and Atomic<>::storeCond, available only when HAVE(LL_SC).
It abstracts loadLink/storeCond behind prepare/attempt. You can write prepare/attempt
loops whenever your loop fits into the least common denominator of LL/SC and CAS.
This modifies Atomic<>::transaction to use prepare/attempt. So, if you write your loop
using Atomic<>::transaction, then you get LL/SC for free.
Depending on the kind of transaction you are doing, you may not want to perform an LL
until you have a chance to just load the current value. Atomic<>::transaction() assumes
that you do not care to have any ordering guarantees in that case. If you think that
the transaction has a good chance of aborting this way, you want
Atomic<>::transaction() to first do a plain load. But if you don't think that such an
abort is likely, then you want to go straight to the LL. The API supports this concept
via TransactionAbortLikelihood.
Additionally, this redoes the depend/consume API to be dead simple. Dependency is
unsigned. You get a dependency on a loaded value by just saying
dependency(loadedValue). You consume the dependency by using it as a bonus index to
some pointer dereference. This is made easy with the consume<T*>(ptr, dependency)
helper. In those cases where you want to pass around both a computed value and a
dependency, there's DependencyWith<T>. But you won't need it in most cases. The loaded
value or any value computed from the loaded value is a fine input to dependency()!
This change updates a bunch of hot paths to use the new APIs. Using transaction() gives
us optimal LL/SC loops for object marking and lock acquisition.
This change also updates a bunch of hot paths to use dependency()/consume().
This is a significant Octane/splay speed-up on ARM.
* wtf/Atomics.h:
(WTF::hasFence):
(WTF::Atomic::prepare):
(WTF::Atomic::attempt):
(WTF::Atomic::transaction):
(WTF::Atomic::transactionRelaxed):
(WTF::nullDependency):
(WTF::dependency):
(WTF::DependencyWith::DependencyWith):
(WTF::dependencyWith):
(WTF::consume):
(WTF::Atomic::tryTransactionRelaxed): Deleted.
(WTF::Atomic::tryTransaction): Deleted.
(WTF::zeroWithConsumeDependency): Deleted.
(WTF::consumeLoad): Deleted.
* wtf/Bitmap.h:
(WTF::WordType>::get):
(WTF::WordType>::concurrentTestAndSet):
(WTF::WordType>::concurrentTestAndClear):
* wtf/LockAlgorithm.h:
(WTF::LockAlgorithm::lockFast):
(WTF::LockAlgorithm::unlockFast):
(WTF::LockAlgorithm::unlockSlow):
* wtf/Platform.h:
2017-03-08 Anders Carlsson <andersca@apple.com>
Simplify the PaymentCoordinator interface
https://bugs.webkit.org/show_bug.cgi?id=169382
Part of rdar://problem/28880714.
Reviewed by Tim Horton.
* wtf/EnumTraits.h:
Fix a build warning.
2017-03-06 Andreas Kling <akling@apple.com>
[iOS] Report domains crashing under memory pressure via enhanced privacy logging.
<https://webkit.org/b/169133>
<rdar://problem/29964017>
Reviewed by Antti Koivisto.
Add a mechanism for getting a callback when the memory pressure status changes.
* wtf/MemoryPressureHandler.cpp:
(WTF::MemoryPressureHandler::measurementTimerFired):
(WTF::MemoryPressureHandler::beginSimulatedMemoryPressure):
(WTF::MemoryPressureHandler::endSimulatedMemoryPressure):
(WTF::MemoryPressureHandler::setUnderMemoryPressure):
(WTF::MemoryPressureHandler::memoryPressureStatusChanged):
* wtf/MemoryPressureHandler.h:
(WTF::MemoryPressureHandler::setMemoryPressureStatusChangedCallback):
(WTF::MemoryPressureHandler::setUnderMemoryPressure): Deleted.
2017-03-03 Jer Noble <jer.noble@apple.com>
[Win64] '__int128_t': undeclared identifier in MediaTime.cpp
https://bugs.webkit.org/show_bug.cgi?id=169123
Reviewed by Alex Christensen.
Don't perform the 128-bit optimized path on Windows, where the __int128_t intrinsic isn't available.
* wtf/MediaTime.cpp:
(WTF::MediaTime::setTimeScale):
2017-03-03 Keith Miller <keith_miller@apple.com>
WASM should support faster loads.
https://bugs.webkit.org/show_bug.cgi?id=162693
Reviewed by Saam Barati.
Add new forms of dataLog that take a boolean which describes if the log should happen. This makes cases where we have a static const bool for printing nicer since you can do:
dataLogIf(verbose, things, to, print);
instead of:
if (verbose)
dataLog(things, to, print);
Also, add a operator! to Ref that has the same semantics as C++ refs.
* wtf/DataLog.h:
(WTF::dataLogLn):
(WTF::dataLogIf):
(WTF::dataLogLnIf):
* wtf/Ref.h:
(WTF::Ref::operator!):
2017-03-02 Jer Noble <jer.noble@apple.com>
Sufficently large timeValue and timeScale arguments to MediaTime will cause wrapping in toTimeScale().
https://bugs.webkit.org/show_bug.cgi?id=169098
Reviewed by Keith Miller.
Use a non-standard but Clang & GCC supported __int128_t type extension to do the 128-bit math rather than
rolling our own. Since this is only available in 64-bit builds, for 32-bit, just fix the underlying 128-bit
math.
* wtf/MediaTime.cpp:
(WTF::MediaTime::setTimeScale):
2017-03-01 Konstantin Tokarev <annulen@yandex.ru>
Removed unused WTF_COMPILER_SUPPORTS_CXX_USER_LITERALS macro
https://bugs.webkit.org/show_bug.cgi?id=168969
Reviewed by Darin Adler.
* wtf/Compiler.h:
2017-03-01 Tomas Popela <tpopela@redhat.com>
[WTF] va_list is not ended in StringPrintStream
https://bugs.webkit.org/show_bug.cgi?id=169035
Reviewed by Michael Saboff.
Also fix whitespace errors while touching this file.
* wtf/StringPrintStream.cpp:
(WTF::StringPrintStream::vprintf):
(WTF::StringPrintStream::increaseSize):
2017-03-01 Andreas Kling <akling@apple.com>
Move MemoryPressureHandler to WTF
<https://webkit.org/b/168908>
Reviewed by Sam Weinig.
Move MemoryPressureHandler down to WTF so it can be used from JavaScriptCore.
I had to do a blind rewrite of the Windows memory checking timer since it can
no longer use WebCore::Timer. I also moved the Win32Handle helper class to WTF.
* WTF.xcodeproj/project.pbxproj:
* wtf/CMakeLists.txt:
* wtf/MemoryPressureHandler.cpp: Renamed from Source/WebCore/platform/MemoryPressureHandler.cpp.
(WTF::MemoryPressureHandler::singleton):
(WTF::MemoryPressureHandler::MemoryPressureHandler):
(WTF::MemoryPressureHandler::setShouldUsePeriodicMemoryMonitor):
(WTF::toString):
(WTF::thresholdForPolicy):
(WTF::policyForFootprint):
(WTF::MemoryPressureHandler::measurementTimerFired):
(WTF::MemoryPressureHandler::beginSimulatedMemoryPressure):
(WTF::MemoryPressureHandler::endSimulatedMemoryPressure):
(WTF::MemoryPressureHandler::releaseMemory):
(WTF::MemoryPressureHandler::ReliefLogger::logMemoryUsageChange):
(WTF::MemoryPressureHandler::install):
(WTF::MemoryPressureHandler::uninstall):
(WTF::MemoryPressureHandler::holdOff):
(WTF::MemoryPressureHandler::respondToMemoryPressure):
(WTF::MemoryPressureHandler::platformReleaseMemory):
(WTF::MemoryPressureHandler::ReliefLogger::platformMemoryUsage):
(WTF::MemoryPressureHandler::platformInitialize):
* wtf/MemoryPressureHandler.h: Renamed from Source/WebCore/platform/MemoryPressureHandler.h.
(WTF::MemoryPressureHandler::setMemoryKillCallback):
(WTF::MemoryPressureHandler::setProcessIsEligibleForMemoryKillCallback):
(WTF::MemoryPressureHandler::setLowMemoryHandler):
(WTF::MemoryPressureHandler::isUnderMemoryPressure):
(WTF::MemoryPressureHandler::setUnderMemoryPressure):
(WTF::MemoryPressureHandler::ReliefLogger::ReliefLogger):
(WTF::MemoryPressureHandler::ReliefLogger::~ReliefLogger):
(WTF::MemoryPressureHandler::ReliefLogger::logString):
(WTF::MemoryPressureHandler::ReliefLogger::setLoggingEnabled):
(WTF::MemoryPressureHandler::ReliefLogger::loggingEnabled):
(WTF::MemoryPressureHandler::ReliefLogger::MemoryUsage::MemoryUsage):
* wtf/PlatformEfl.cmake:
* wtf/PlatformGTK.cmake:
* wtf/PlatformMac.cmake:
* wtf/PlatformWin.cmake:
* wtf/cocoa/MemoryPressureHandlerCocoa.mm: Renamed from Source/WebCore/platform/cocoa/MemoryPressureHandlerCocoa.mm.
(WTF::MemoryPressureHandler::platformReleaseMemory):
(WTF::MemoryPressureHandler::install):
(WTF::MemoryPressureHandler::uninstall):
(WTF::MemoryPressureHandler::holdOff):
(WTF::MemoryPressureHandler::respondToMemoryPressure):
(WTF::MemoryPressureHandler::ReliefLogger::platformMemoryUsage):
* wtf/linux/CurrentProcessMemoryStatus.cpp: Renamed from Source/WebCore/platform/linux/CurrentProcessMemoryStatus.cpp.
(WTF::systemPageSize):
(WTF::currentProcessMemoryStatus):
* wtf/linux/CurrentProcessMemoryStatus.h: Renamed from Source/WebCore/platform/linux/CurrentProcessMemoryStatus.h.
* wtf/linux/MemoryPressureHandlerLinux.cpp: Renamed from Source/WebCore/platform/linux/MemoryPressureHandlerLinux.cpp.
(WTF::MemoryPressureHandler::EventFDPoller::EventFDPoller):
* wtf/win/MemoryPressureHandlerWin.cpp: Renamed from Source/WebCore/platform/win/MemoryPressureHandlerWin.cpp.
(WTF::MemoryPressureHandler::platformInitialize):
(WTF::MemoryPressureHandler::windowsMeasurementTimerFired):
(WTF::MemoryPressureHandler::platformReleaseMemory):
(WTF::MemoryPressureHandler::install):
(WTF::MemoryPressureHandler::uninstall):
(WTF::MemoryPressureHandler::holdOff):
(WTF::MemoryPressureHandler::respondToMemoryPressure):
(WTF::MemoryPressureHandler::ReliefLogger::platformMemoryUsage):
* wtf/win/Win32Handle.h: Renamed from Source/WebCore/platform/win/Win32Handle.h.
(WTF::Win32Handle::Win32Handle):
(WTF::Win32Handle::~Win32Handle):
(WTF::Win32Handle::clear):
(WTF::Win32Handle::isValid):
(WTF::Win32Handle::get):
(WTF::Win32Handle::release):
(WTF::Win32Handle::operator=):
2017-02-28 Chris Dumez <cdumez@apple.com>
[iOS] Throttle requestAnimationFrame to 30fps in low power mode
https://bugs.webkit.org/show_bug.cgi?id=168837
<rdar://problem/30700929>
Reviewed by Simon Fraser.
Add support for operator -= on WTF::OptionSet for convenience:
set -= Enum::A;
looks much better than:
set = set - Enum::A;
* wtf/OptionSet.h:
(WTF::OptionSet::operator-=):
2017-02-28 Michael Saboff <msaboff@apple.com>
Add ability to configure JSC options from a file
https://bugs.webkit.org/show_bug.cgi?id=168914
Reviewed by Filip Pizlo.
Added the ability to set options and DataLog file location via a configuration file.
The pathname can include the printf style "%pid", which will be replaced with the
current process id.
* wtf/DataLog.cpp:
(WTF::initializeLogFileOnce):
(WTF::setDataFile):
* wtf/DataLog.h:
2017-02-27 Andy Estes <aestes@apple.com>
[iOS] Enable file replacement
https://bugs.webkit.org/show_bug.cgi?id=168907
<rdar://problem/22258242>
Reviewed by David Kilzer.
* wtf/FeatureDefines.h: Set ENABLE_FILE_REPLACEMENT to 1 on all Cocoa platforms.
2017-02-27 Myles C. Maxfield <mmaxfield@apple.com>
Rename ICU cursor iterator to caret iterator
https://bugs.webkit.org/show_bug.cgi?id=168206
Reviewed by Simon Fraser.
* wtf/text/TextBreakIterator.cpp:
(WTF::mapModeToBackingIterator):
* wtf/text/TextBreakIterator.h:
* wtf/text/cf/TextBreakIteratorCF.h:
(WTF::TextBreakIteratorCF::TextBreakIteratorCF):
* wtf/text/icu/TextBreakIteratorICU.h:
(WTF::caretRules):
(WTF::TextBreakIteratorICU::TextBreakIteratorICU):
(WTF::cursorRules): Deleted.
* wtf/text/mac/TextBreakIteratorInternalICUMac.mm:
(WTF::mapModeToBackingIterator):
2017-02-27 Myles C. Maxfield <mmaxfield@apple.com>
Use RAII for ICU breaking iterators
https://bugs.webkit.org/show_bug.cgi?id=168203
Reviewed by Simon Fraser.
* wtf/text/TextBreakIterator.h:
(WTF::CachedTextBreakIterator::CachedTextBreakIterator):
(WTF::CachedTextBreakIterator::~CachedTextBreakIterator):
(WTF::CachedTextBreakIterator::preceding):
(WTF::CachedTextBreakIterator::following):
(WTF::CachedTextBreakIterator::isBoundary):
2017-02-24 Jer Noble <jer.noble@apple.com>
Add public method to MediaTime for doing timeScale conversion.
https://bugs.webkit.org/show_bug.cgi?id=168860
Reviewed by Eric Carlson.
The newly public method, modeled on CMTimeConvertScale, allows callers to specify what rounding technique
will be used when converting to a new time scale.
* wtf/MediaTime.cpp:
(WTF::MediaTime::toTimeScale):
(WTF::MediaTime::setTimeScale):
* wtf/MediaTime.h:
2017-02-26 Myles C. Maxfield <mmaxfield@apple.com>
Stop compiling our own cursorMovementIterator()
https://bugs.webkit.org/show_bug.cgi?id=168211
Reviewed by David Hyatt.
This patch creates a unified Text Breaking API, which can be backed by either ICU
or CoreFoundation (for ports which can use it). Rather than using inheritance and
virtual functions to implement this, because there are only two subclasses, the
simpler option of just using a Variant is used instead. There is also a cache which
allows you to reuse iterators without reconstructing them. This cache is better
than the previous method of having a single static iterator because the cache
lets you use two iterators simultaneously.
In the future, I will hook up all iterators to use this shared class. However, for
this patch, I've only hooked up the caret position iterator (backed by CoreFoundation
on Cocoa ports and UBRK_CHARACTER on other ports).
* WTF.xcodeproj/project.pbxproj:
* wtf/spi/cf/CFStringSPI.h: Added.
* wtf/text/TextBreakIterator.cpp:
(WTF::initializeIteratorWithRules): Deleted.
(WTF::cursorMovementIterator): Deleted.
* wtf/text/TextBreakIterator.h:
(WTF::TextBreakIterator::preceding):
(WTF::TextBreakIterator::following):
(WTF::TextBreakIterator::isBoundary):
(WTF::TextBreakIterator::setText):
(WTF::TextBreakIterator::mode):
(WTF::TextBreakIterator::locale):
(WTF::TextBreakIteratorCache::singleton):
(WTF::TextBreakIteratorCache::take):
(WTF::TextBreakIteratorCache::put):
(WTF::TextBreakIteratorCache::TextBreakIteratorCache):
* wtf/text/cf/TextBreakIteratorCF.h: Added.
(WTF::TextBreakIteratorCF::TextBreakIteratorCF):
(WTF::TextBreakIteratorCF::setText):
(WTF::TextBreakIteratorCF::preceding):
(WTF::TextBreakIteratorCF::following):
(WTF::TextBreakIteratorCF::isBoundary):
* wtf/text/icu/TextBreakIteratorICU.h: Added.
(WTF::TextBreakIteratorICU::set8BitText):
(WTF::TextBreakIteratorICU::TextBreakIteratorICU):
(WTF::TextBreakIteratorICU::operator=):
(WTF::TextBreakIteratorICU::~TextBreakIteratorICU):
(WTF::TextBreakIteratorICU::setText):
(WTF::TextBreakIteratorICU::preceding):
(WTF::TextBreakIteratorICU::following):
(WTF::TextBreakIteratorICU::isBoundary):
* wtf/text/icu/UTextProviderLatin1.h:
* wtf/text/mac/TextBreakIteratorInternalICUMac.mm:
(WTF::mapModeToBackingIterator):
(WTF::TextBreakIterator::TextBreakIterator):
2017-02-24 Joseph Pecoraro <pecoraro@apple.com>
[Resource Timing] Gather timing information with reliable responseEnd time
https://bugs.webkit.org/show_bug.cgi?id=168351
Reviewed by Alex Christensen.
* wtf/persistence/Coders.h:
(WTF::Persistence::Coder<Seconds>::encode):
(WTF::Persistence::Coder<Seconds>::decode):
2017-02-24 Keith Miller <keith_miller@apple.com>
Rubber-stamped by Chris Dumez.
Replace typename Bool with typename BoolType because X11 has
#define Bool int for some unknown reason...
* wtf/HashFunctions.h:
(WTF::TupleHash::allTrue):
* wtf/HashTraits.h:
(WTF::TupleHashTraits::allTrue):
2017-02-24 Chris Dumez <cdumez@apple.com>
Unreviewed, rolling out r212944.
Caused a lot of failures on the debug bots
Reverted changeset:
"[Resource Timing] Gather timing information with reliable
responseEnd time"
https://bugs.webkit.org/show_bug.cgi?id=168351
http://trac.webkit.org/changeset/212944
2017-02-24 Keith Miller <keith_miller@apple.com>
We should be able to use std::tuples as keys in HashMap
https://bugs.webkit.org/show_bug.cgi?id=168805
Reviewed by Filip Pizlo.
This patch adds support for using std::tupeles as the key
type in HashMap. It is equivalent to doing a sequence of
std::pairs but has a nicer syntax.
* wtf/HashFunctions.h:
(WTF::TupleHash::hash):
(WTF::TupleHash::equal):
(WTF::TupleHash::allTrue):
* wtf/HashTraits.h:
(WTF::TupleHashTraits::allTrue):
(WTF::TupleHashTraits::emptyValue):
(WTF::TupleHashTraits::constructDeletedValue):
(WTF::TupleHashTraits::isDeletedValue):
2017-02-24 Alex Christensen <achristensen@webkit.org>
Prepare to enable WebRTC on iOS
https://bugs.webkit.org/show_bug.cgi?id=168811
Reviewed by Youenn Fablet.
* wtf/Platform.h:
2017-02-23 Joseph Pecoraro <pecoraro@apple.com>
[Resource Timing] Gather timing information with reliable responseEnd time
https://bugs.webkit.org/show_bug.cgi?id=168351
Reviewed by Alex Christensen.
* wtf/persistence/Coders.h:
(WTF::Persistence::Coder<Seconds>::encode):
(WTF::Persistence::Coder<Seconds>::decode):
2017-02-22 Carlos Garcia Campos <cgarcia@igalia.com>
Better handle Thread and RunLoop initialization
https://bugs.webkit.org/show_bug.cgi?id=167828
Reviewed by Yusuke Suzuki.
Make initialization functions more independent so that they can run in different
order. WTF::initializeMainThread initializes WTF threading, so that neither WTF nor JSC theading need to be
initialized before. RunLoop::initializeMainRunLoop() requires main thread to be initialized in some
ports, so it initializes main thread too. WebKit1 always calls WTF::initializeMainThreadToProcessMainThread()
before RunLoop::initializeMainRunLoop() so there's no problem there. GC threads are initialized alwayas by the
main thread. The rules should be simpler now:
- JSC::initializeThreading: should always be called when JSC is used.
- WTF::initializeThreading: only needs to be explicitly called when JSC is not used and process doesn't
initialize a main thread or main run loop.
- WTF::initializeMainThread: only needs to be explicitly called if process initializes a main thread but not a
main run loop.
- WTF::initializeMainThreadToProcessMainThread(): should always be called in WebKit1 before
RunLoop::initializeMainRunLoop().
- RunLoop::initializeMainRunLoop(): to initialize the main run loop. The only requirement is JSC::initializeThreading()
to be called before if JSC is used.
* wtf/MainThread.cpp:
(WTF::initializeMainThreadOnce): Use pthread_once to initialize the main thread also in GTK+ port.
(WTF::initializeMainThreadToProcessMainThreadOnce): Call initializeThreading() before the platform
initialization and initializeGCThreads() after it.
(WTF::initializeMainThread): Ditto.
* wtf/RunLoop.cpp:
(WTF::RunLoop::initializeMainRunLoop): Call initializeMainThread().
* wtf/glib/MainThreadGLib.cpp:
(WTF::initializeMainThreadPlatform):
(WTF::isMainThread):
* wtf/mac/MainThreadMac.mm:
(WTF::initializeMainThreadPlatform): Remove call to initializeGCThreads().
(WTF::initializeMainThreadToProcessMainThreadPlatform): Ditto.
2017-02-22 Myles C. Maxfield <mmaxfield@apple.com>
[Cocoa] Remove Yosemite-specific font lookup code
https://bugs.webkit.org/show_bug.cgi?id=168682
Reviewed by Zalan Bujtas.
* wtf/Platform.h:
2017-02-22 Keith Miller <keith_miller@apple.com>
Remove the demand executable allocator
https://bugs.webkit.org/show_bug.cgi?id=168754
Reviewed by Saam Barati.
* wtf/Platform.h:
2017-02-22 Alex Christensen <achristensen@webkit.org>
Re-commit part of r212812 accidentally rolled out with r212841.
https://bugs.webkit.org/show_bug.cgi?id=167293
* wtf/Platform.h:
Use libwebrtc on Mac if webrtc is enabled.
2017-02-22 Alex Christensen <achristensen@webkit.org>
Fix ASAN build after activating libwebrtc.
* wtf/Ref.h:
__asan_address_is_poisoned returns an int, not a bool.
This didn't cause a problem before because we didn't include the real definition anywhere,
but libwebrtc includes <sanitizer/asan_interface.h> directly now so the return types need to be correct.
2017-02-22 Carlos Garcia Campos <cgarcia@igalia.com>
[GTK] Test fast/events/message-port-postMessage-recursive.html times out
https://bugs.webkit.org/show_bug.cgi?id=168570
Reviewed by Michael Catanzaro.
This has recently been added and the patch is good. It's just revealing a problem with our timers. The test is
posting a message recursively, and also starts a timeout timer to finish the test. The timeout timer is never
fired for us, because WebCore timers have lower priority than the one used by postMessage. ScriptExecutionContext
uses Document::postTask, that uses scheduleOnMainThread, that uses RunLoop::dispatch(). We are not setting any
priority for the timer used by RunLoop::dispatch, so it's using the default.
Use a RunLoop::Timer to schedule tasks to the main thread instead of using RunLoop::dispatch(). This allows us
to use a different priority, that is now set to G_PRIORITY_HIGH_IDLE + 20 to match WebCore timers. But it also
avoids the double queue we had with RunLoop::dispatch(), because scheduleOnMainThread() also queues the tasks.
* wtf/glib/MainThreadGLib.cpp:
(WTF::MainThreadDispatcher::MainThreadDispatcher):
(WTF::MainThreadDispatcher::schedule):
(WTF::MainThreadDispatcher::fired):
(WTF::scheduleDispatchFunctionsOnMainThread):
2017-02-21 Youenn Fablet <youenn@apple.com>
[WebRTC][Mac] Activate libwebrtc
https://bugs.webkit.org/show_bug.cgi?id=167293
Reviewed by Alex Christensen.
* wtf/Platform.h:
2017-02-20 Filip Pizlo <fpizlo@apple.com>
The collector thread should only start when the mutator doesn't have heap access
https://bugs.webkit.org/show_bug.cgi?id=167737
Reviewed by Keith Miller.
Extend the use of AbstractLocker so that we can use more locking idioms.
* wtf/AutomaticThread.cpp:
(WTF::AutomaticThreadCondition::notifyOne):
(WTF::AutomaticThreadCondition::notifyAll):
(WTF::AutomaticThreadCondition::add):
(WTF::AutomaticThreadCondition::remove):
(WTF::AutomaticThreadCondition::contains):
(WTF::AutomaticThread::AutomaticThread):
(WTF::AutomaticThread::tryStop):
(WTF::AutomaticThread::isWaiting):
(WTF::AutomaticThread::notify):
(WTF::AutomaticThread::start):
(WTF::AutomaticThread::threadIsStopping):
* wtf/AutomaticThread.h:
* wtf/NumberOfCores.cpp:
(WTF::numberOfProcessorCores):
* wtf/ParallelHelperPool.cpp:
(WTF::ParallelHelperClient::finish):
(WTF::ParallelHelperClient::claimTask):
(WTF::ParallelHelperPool::Thread::Thread):
(WTF::ParallelHelperPool::didMakeWorkAvailable):
(WTF::ParallelHelperPool::hasClientWithTask):
(WTF::ParallelHelperPool::getClientWithTask):
* wtf/ParallelHelperPool.h:
2017-02-21 Alex Christensen <achristensen@webkit.org>
Unreviewed, rolling out r212699.
Internal build not ready
Reverted changeset:
"[WebRTC][Mac] Activate libwebrtc"
https://bugs.webkit.org/show_bug.cgi?id=167293
http://trac.webkit.org/changeset/212699
2017-02-20 Youenn Fablet <youenn@apple.com>
[WebRTC][Mac] Activate libwebrtc
https://bugs.webkit.org/show_bug.cgi?id=167293
Reviewed by Alex Christensen.
* wtf/Platform.h:
2017-02-20 Mark Lam <mark.lam@apple.com>
[Re-landing] CachedCall should let GC know to keep its arguments alive.
https://bugs.webkit.org/show_bug.cgi?id=168567
<rdar://problem/30475767>
Reviewed by Saam Barati.
Added a WTF_FORBID_HEAP_ALLOCATION that will cause a compilation failure if
a class declared with it is malloced.
While this doesn't prevent that class declared WTF_FORBID_HEAP_ALLOCATION from
being embedded in another class that is heap allocated, it does at minimum
document the intent and gives the users of this class a chance to do the
right thing.
* WTF.xcodeproj/project.pbxproj:
* wtf/ForbidHeapAllocation.h: Added.
2017-02-20 Ryan Haddad <ryanhaddad@apple.com>
Unreviewed, rolling out r212685.
This change broke the 32-bit Sierra build.
Reverted changeset:
"Resource Load Statistics: Add alternate classification
method"
https://bugs.webkit.org/show_bug.cgi?id=168347
http://trac.webkit.org/changeset/212685
2017-02-20 John Wilander <wilander@apple.com>
Resource Load Statistics: Add alternate classification method
https://bugs.webkit.org/show_bug.cgi?id=168347
<rdar://problem/30352793>
Reviewed by Alex Christensen.
* wtf/Platform.h:
Added support for HAVE(CORE_PREDICTION).
2017-02-20 Commit Queue <commit-queue@webkit.org>
Unreviewed, rolling out r212618.
https://bugs.webkit.org/show_bug.cgi?id=168609
"Appears to cause PLT regression" (Requested by mlam on
#webkit).
Reverted changeset:
"CachedCall should let GC know to keep its arguments alive."
https://bugs.webkit.org/show_bug.cgi?id=168567
http://trac.webkit.org/changeset/212618
2017-02-20 Carlos Garcia Campos <cgarcia@igalia.com>
Unreviewed, rolling out r212622.
Caused several test failures
Reverted changeset:
"[GTK] Test fast/events/message-port-postMessage-
recursive.html times out"
https://bugs.webkit.org/show_bug.cgi?id=168570
http://trac.webkit.org/changeset/212622
2017-02-19 Carlos Garcia Campos <cgarcia@igalia.com>
[GTK] Test fast/events/message-port-postMessage-recursive.html times out
https://bugs.webkit.org/show_bug.cgi?id=168570
Reviewed by Michael Catanzaro.
This has recently been added and the patch is good. It's just revealing a problem with our timers. The test is
posting a message recursively, and also starts a timeout timer to finish the test. The timeout timer is never
fired for us, because WebCore timers have lower priority than the one used by
postMessage. ScriptExecutionContext uses Document::postTask, that uses scheduleOnMainThread, that uses
RunLoop::dispatch(). We are not setting any priority for the timer used by RunLoop::dispatch, so it's using the
default. RunLoop::dispatch is normally used to schedule tasks between threads, or just to ensure something is
run in a different run loop iteration, but in general nothing urgent as a graphics redraw or something like
that. It's quite common to use g_idle_add to schedule tasks between threads, so I think it makes sense to use
G_PRIORITY_DEFAULT_IDLE for the RunLoop timer.
* wtf/glib/RunLoopGLib.cpp:
(WTF::RunLoop::RunLoop):
2017-02-19 Mark Lam <mark.lam@apple.com>
CachedCall should let GC know to keep its arguments alive.
https://bugs.webkit.org/show_bug.cgi?id=168567
<rdar://problem/30475767>
Reviewed by Saam Barati.
Added a WTF_FORBID_HEAP_ALLOCATION that will cause a compilation failure if
a class declared with it is malloced.
While this doesn't prevent that class declared WTF_FORBID_HEAP_ALLOCATION from
being embedded in another class that is heap allocated, it does at minimum
document the intent and gives the users of this class a chance to do the
right thing.
* WTF.xcodeproj/project.pbxproj:
* wtf/ForbidHeapAllocation.h: Added.
2017-02-19 Commit Queue <commit-queue@webkit.org>
Unreviewed, rolling out r212466.
https://bugs.webkit.org/show_bug.cgi?id=168577
causes crashes on AArch64 on linux, maybe it's causing crashes
on iOS too (Requested by pizlo on #webkit).
Reverted changeset:
"The collector thread should only start when the mutator
doesn't have heap access"
https://bugs.webkit.org/show_bug.cgi?id=167737
http://trac.webkit.org/changeset/212466
2017-02-18 Chris Dumez <cdumez@apple.com>
Recursive MessagePort.postMessage() calls causes tab to become unresponsive
https://bugs.webkit.org/show_bug.cgi?id=168548
<rdar://problem/29808005>
Reviewed by Darin Adler.
Add API to retrieve all messages in the queue at once.
* wtf/MessageQueue.h:
2017-02-16 Alex Christensen <achristensen@webkit.org>
Remove EFL-specific files in Source.
Rubber-stamped by Anders Carlsson.
* wtf/text/efl: Removed.
* wtf/text/efl/TextBreakIteratorInternalICUEfl.cpp: Removed.
2017-02-10 Filip Pizlo <fpizlo@apple.com>
The collector thread should only start when the mutator doesn't have heap access
https://bugs.webkit.org/show_bug.cgi?id=167737
Reviewed by Keith Miller.
Extend the use of AbstractLocker so that we can use more locking idioms.
* wtf/AutomaticThread.cpp:
(WTF::AutomaticThreadCondition::notifyOne):
(WTF::AutomaticThreadCondition::notifyAll):
(WTF::AutomaticThreadCondition::add):
(WTF::AutomaticThreadCondition::remove):
(WTF::AutomaticThreadCondition::contains):
(WTF::AutomaticThread::AutomaticThread):
(WTF::AutomaticThread::tryStop):
(WTF::AutomaticThread::isWaiting):
(WTF::AutomaticThread::notify):
(WTF::AutomaticThread::start):
(WTF::AutomaticThread::threadIsStopping):
* wtf/AutomaticThread.h:
* wtf/NumberOfCores.cpp:
(WTF::numberOfProcessorCores): Allow this to be overridden for testing.
* wtf/ParallelHelperPool.cpp:
(WTF::ParallelHelperClient::finish):
(WTF::ParallelHelperClient::claimTask):
(WTF::ParallelHelperPool::Thread::Thread):
(WTF::ParallelHelperPool::didMakeWorkAvailable):
(WTF::ParallelHelperPool::hasClientWithTask):
(WTF::ParallelHelperPool::getClientWithTask):
* wtf/ParallelHelperPool.h:
2017-02-16 Anders Carlsson <andersca@apple.com>
Remove EFL from WTF
https://bugs.webkit.org/show_bug.cgi?id=168452
Reviewed by Alex Christensen.
* wtf/CurrentTime.cpp:
* wtf/DisallowCType.h:
* wtf/FeatureDefines.h:
* wtf/MainThread.cpp:
* wtf/MainThread.h:
* wtf/Platform.h:
* wtf/RunLoop.h:
* wtf/WorkQueue.h:
* wtf/efl/DispatchQueueEfl.cpp: Removed.
* wtf/efl/DispatchQueueEfl.h: Removed.
* wtf/efl/DispatchQueueWorkItemEfl.h: Removed.
* wtf/efl/EflTypedefs.h: Removed.
* wtf/efl/MainThreadEfl.cpp: Removed.
* wtf/efl/RunLoopEfl.cpp: Removed.
* wtf/efl/UniquePtrEfl.h: Removed.
* wtf/efl/WorkQueueEfl.cpp: Removed.
2017-02-13 Alex Christensen <achristensen@webkit.org>
URLs with an invalid IPv4 address should be invalid
https://bugs.webkit.org/show_bug.cgi?id=168260
Reviewed by Tim Horton.
* wtf/Expected.h:
(WTF::Expected::value):
Added missing WTFMove for rvalue Expected::value().
2017-02-13 Said Abou-Hallawa <sabouhallawa@apple.com>
The current frame of an image should not deleted if another frame is asynchronously being decoded
https://bugs.webkit.org/show_bug.cgi?id=167618
Reviewed by Simon Fraser.
Add ASSERT_IMPLIES() which should fire when a condition is true but the
assertion is false.
* wtf/Assertions.h:
2017-02-13 Brady Eidson <beidson@apple.com>
Followup to: Replace all WebKit Library Version checks in WK2 with SDK version checks.
https://bugs.webkit.org/show_bug.cgi?id=168124
Reviewed by Geoffrey Garen.
* wtf/spi/darwin/dyldSPI.h:
2017-02-13 Myles C. Maxfield <mmaxfield@apple.com>
Update custom line breaking iterators to the latest version of Unicode
https://bugs.webkit.org/show_bug.cgi?id=168182
Reviewed by Zalan Bujtas.
ICU 55.1 supports loose / normal / strict line breaking rules. The oldest platform we ship
on has a version of ICU >= that one. Therefore, we don't need to compile our own rules;
we can just use ICU's rules.
* wtf/text/LineBreakIteratorPoolICU.h:
(WTF::LineBreakIteratorPool::makeLocaleWithBreakKeyword):
(WTF::LineBreakIteratorPool::take):
* wtf/text/TextBreakIterator.cpp:
(WTF::acquireLineBreakIterator):
(WTF::openLineBreakIterator):
(WTF::mapLineIteratorModeToRules): Deleted.
(WTF::isCJKLocale): Deleted.
* wtf/text/TextBreakIterator.h:
(WTF::LazyLineBreakIterator::LazyLineBreakIterator):
(WTF::LazyLineBreakIterator::mode):
(WTF::LazyLineBreakIterator::get):
(WTF::LazyLineBreakIterator::resetStringAndReleaseIterator):
(WTF::LazyLineBreakIterator::isLooseCJKMode): Deleted.
2017-02-10 Dan Bernstein <mitz@apple.com>
[Xcode] WTF installs extra copies of two headers outside /usr/local/include/wtf
https://bugs.webkit.org/show_bug.cgi?id=168160
Reviewed by Sam Weinig.
* WTF.xcodeproj/project.pbxproj: Demoted OrdinalNumber.h MemoryFootprint.h from Private to
Project.
2017-02-10 Commit Queue <commit-queue@webkit.org>
Unreviewed, rolling out r212139.
https://bugs.webkit.org/show_bug.cgi?id=168152
Caused some assertions (Requested by JoePeck on #webkit).
Reverted changeset:
"Fix misleading comment in RunLoop.h"
https://bugs.webkit.org/show_bug.cgi?id=167832
http://trac.webkit.org/changeset/212139
2017-02-10 Joseph Pecoraro <pecoraro@apple.com>
Fix misleading comment in RunLoop.h
https://bugs.webkit.org/show_bug.cgi?id=167832
Reviewed by Sam Weinig.
* wtf/RunLoop.h:
Mac initialization used to force using CFRunLoopGetMain(). Now however it just
uses RunLoop::current which uses CFRunLoopGetCurrent(). So this comment that
it can be done on any thread is misleading and can lead to incorrect behavior
if it is actually done on a non-main thread on Mac.
2017-02-09 Alex Christensen <achristensen@webkit.org>
Unreviewed, rolling out r212040.
Broke build. I'm not surprised
Reverted changeset:
"[WebRTC][Mac] Activate libwebrtc"
https://bugs.webkit.org/show_bug.cgi?id=167293
http://trac.webkit.org/changeset/212040
2017-02-09 Youenn Fablet <youenn@apple.com>
[WebRTC][Mac] Activate libwebrtc
https://bugs.webkit.org/show_bug.cgi?id=167293
Reviewed by Alex Christensen.
* wtf/Platform.h:
2017-02-09 Brady Eidson <beidson@apple.com>
Transition "WebKit Library Version" checks to SDK version checks.
<rdar://problem/30313696> and https://bugs.webkit.org/show_bug.cgi?id=168056
Reviewed by Geoffrey Garen.
* wtf/spi/darwin/dyldSPI.h: Add entries for the iOS 10.3, macOS 10.11, and macOS 10.12.4 SDKs.
2017-02-09 Commit Queue <commit-queue@webkit.org>
Unreviewed, rolling out r211980 and r211987.
https://bugs.webkit.org/show_bug.cgi?id=168072
Caused API test WebKit2.DuplicateCompletionHandlerCalls to
fail (Requested by ryanhaddad on #webkit).
Reverted changesets:
"Transition "WebKit Library Version" checks to SDK version
checks."
https://bugs.webkit.org/show_bug.cgi?id=168056
http://trac.webkit.org/changeset/211980
"Build fix for APPLE_INTERNAL_SDK builds after r211980."
http://trac.webkit.org/changeset/211987
2017-02-09 Alexey Proskuryakov <ap@apple.com>
Remove unused WebThreadRunSync
https://bugs.webkit.org/show_bug.cgi?id=168024
Reviewed by Tim Horton.
* wtf/ios/WebCoreThread.cpp:
* wtf/ios/WebCoreThread.h:
2017-02-09 Brady Eidson <beidson@apple.com>
Build fix for APPLE_INTERNAL_SDK builds after r211980.
Unreviewed.
* wtf/spi/darwin/dyldSPI.h:
2017-02-09 Brady Eidson <beidson@apple.com>
Transition "WebKit Library Version" checks to SDK version checks.
<rdar://problem/30313696> and https://bugs.webkit.org/show_bug.cgi?id=168056
Reviewed by Geoffrey Garen.
* wtf/spi/darwin/dyldSPI.h: Add entries for the iOS 10.3, macOS 10.11, and macOS 10.12.4 SDKs.
2017-02-06 Jer Noble <jer.noble@apple.com>
Playback stalls when a SourceBuffer append causes frame eviction
https://bugs.webkit.org/show_bug.cgi?id=167834
Reviewed by Eric Carlson.
Optimize the MediaTime class; specifically the compare() method. The class only
needs 6 bits to store the TimeFlags, so make that a uint8_t rather than uint32_t.
The implementation is slightly simpler if the TimeScale is unsigned, so make that
a uint32_t rather than int32_t. Inline the comparison operators. Optimize the equality
comparison by bitwise-and'ing the flags together and masking the result. Optimize for
common comparison scenarios (equal timeScales, equal timeValues(), etc.). Attempt the
mathematically simpler simpler method for comparing ratios, and only fall back to the
complex method if the results of multiplying the timeScale by the timeValue overflows.
* wtf/MediaTime.cpp:
(WTF::greatestCommonDivisor):
(WTF::leastCommonMultiple):
(WTF::signum):
(WTF::MediaTime::MediaTime):
(WTF::MediaTime::createWithFloat):
(WTF::MediaTime::createWithDouble):
(WTF::MediaTime::operator+):
(WTF::MediaTime::operator-):
(WTF::MediaTime::operator!):
(WTF::MediaTime::operator bool):
(WTF::MediaTime::compare):
(WTF::MediaTime::setTimeScale):
(WTF::abs):
(WTF::MediaTime::operator<): Deleted.
(WTF::MediaTime::operator>): Deleted.
(WTF::MediaTime::operator!=): Deleted.
(WTF::MediaTime::operator==): Deleted.
(WTF::MediaTime::operator>=): Deleted.
(WTF::MediaTime::operator<=): Deleted.
* wtf/MediaTime.h:
2017-02-04 Michael Catanzaro <mcatanzaro@igalia.com>
[GTK] Fix huge ENABLE_RESOURCE_USAGE warning spam
Unreviewed. We shouldn't redefine ENABLE_RESOURCE_USAGE in Platform.h as
it's already defined in cmakeconfig.h.
* wtf/Platform.h:
2017-02-03 Joseph Pecoraro <pecoraro@apple.com>
Performance Timing: Convert WTF::MonotonicTime and WTF::Seconds
https://bugs.webkit.org/show_bug.cgi?id=167768
Reviewed by Geoffrey Garen.
* wtf/Stopwatch.h:
(WTF::Stopwatch::elapsedTimeSince):
(WTF::Stopwatch::elapsedTimeSinceMonotonicTime): Deleted.
2017-02-03 Carlos Garcia Campos <cgarcia@igalia.com>
[GTK] Add initial implementation of resource usage overlay
https://bugs.webkit.org/show_bug.cgi?id=167731
Reviewed by Michael Catanzaro.
Enable RESOURCE_USAGE for GTK+ port too.
* wtf/Platform.h:
2017-02-02 Andreas Kling <akling@apple.com>
[Mac] In-process memory pressure monitor for WebContent processes AKA websam
<https://webkit.org/b/167491>
<rdar://problem/30116072>
Reviewed by Antti Koivisto.
Add a WTF helper function for getting the current process's memory footprint.
* WTF.xcodeproj/project.pbxproj:
* wtf/CMakeLists.txt:
* wtf/MemoryFootprint.cpp:
(WTF::memoryFootprint):
* wtf/MemoryFootprint.h:
2017-02-02 Mark Lam <mark.lam@apple.com>
Add a SIGILL crash analyzer to make debugging SIGILLs easier.
https://bugs.webkit.org/show_bug.cgi?id=167714
<rdar://problem/30318237>
Reviewed by Filip Pizlo.
* wtf/StdLibExtras.h:
2017-02-02 Commit Queue <commit-queue@webkit.org>
Unreviewed, rolling out r211571 and r211582.
https://bugs.webkit.org/show_bug.cgi?id=167751
This change caused API test WebKit1.MemoryPressureHandler to
fail with an assertion. (Requested by ryanhaddad on #webkit).
Reverted changesets:
"[Mac] In-process memory pressure monitor for WebContent
processes."
https://bugs.webkit.org/show_bug.cgi?id=167491
http://trac.webkit.org/changeset/211571
"Unreviewed attempt to fix the Windows build after r211571."
http://trac.webkit.org/changeset/211582
2017-02-02 Andreas Kling <akling@apple.com>
[Mac] In-process memory pressure monitor for WebContent processes.
<https://webkit.org/b/167491>
<rdar://problem/30116072>
Reviewed by Antti Koivisto.
Add a WTF helper function for getting the current process's memory footprint.
* WTF.xcodeproj/project.pbxproj:
* wtf/CMakeLists.txt:
* wtf/MemoryFootprint.cpp:
(WTF::memoryFootprint):
* wtf/MemoryFootprint.h:
2017-02-01 Wenson Hsieh <wenson_hsieh@apple.com>
Unreviewed, fix the WebKit nightly open source build
<rdar://problem/30308635>
We cannot assume all internal SDKs have the latest WebKitAdditions, so we need an explicit header check here.
* wtf/Platform.h:
2017-02-01 Andreas Kling <akling@apple.com>
Implement the alwaysRunsAtBackgroundPriority WK2 setting using thread QoS.
<https://webkit.org/b/167387>
<rdar://problem/29711409>
Reviewed by Antti Koivisto.
Add a new mechanism for overriding the max thread QoS level globally:
void setGlobalMaxQOSClass(qos_class_t)
qos_class_t adjustedQOSClass(qos_class_t)
The QoS cap applies to all newly created threads, threads that try to override
their QoS class manually, and also passed down to bmalloc.
* wtf/Threading.cpp:
(WTF::setCurrentThreadIsUserInteractive):
(WTF::setCurrentThreadIsUserInitiated):
(WTF::setGlobalMaxQOSClass):
(WTF::adjustedQOSClass):
* wtf/Threading.h:
* wtf/ThreadingPthreads.cpp:
(WTF::createThreadInternal):
* wtf/cocoa/WorkQueueCocoa.cpp:
(WTF::dispatchQOSClass):
2017-01-31 Antti Koivisto <antti@apple.com>
Teach cache coders to encode time_points
https://bugs.webkit.org/show_bug.cgi?id=167670
Reviewed by Andreas Kling.
* wtf/persistence/Coders.h:
(WTF::Persistence::Coder<std::chrono::system_clock::time_point>::encode):
(WTF::Persistence::Coder<std::chrono::system_clock::time_point>::decode):
2017-01-31 Joseph Pecoraro <pecoraro@apple.com>
Removed unused m_nestedCount from RunLoop
https://bugs.webkit.org/show_bug.cgi?id=167674
Reviewed by Sam Weinig.
* wtf/RunLoop.h:
* wtf/cf/RunLoopCF.cpp:
(WTF::RunLoop::RunLoop):
(WTF::RunLoop::run):
2017-01-31 Filip Pizlo <fpizlo@apple.com>
The mutator should be able to perform increments of GC work
https://bugs.webkit.org/show_bug.cgi?id=167528
Reviewed by Keith Miller and Geoffrey Garen.
We want dataLog to be locked even if you're not logging to a file!
* wtf/DataLog.cpp:
(WTF::initializeLogFileOnce):
2017-01-28 Wenson Hsieh <wenson_hsieh@apple.com>
Check USE(APPLE_INTERNAL_SDK) instead of specific headers when importing from WebKitAdditions
https://bugs.webkit.org/show_bug.cgi?id=167555
Reviewed by Dan Bernstein.
Instead of guarding #import <WebKitAdditions/*> on the existence of the imported file, consult
USE(APPLE_INTERNAL_SDK) instead.
* wtf/Platform.h:
2017-01-26 Saam Barati <sbarati@apple.com>
Harden how the compiler references GC objects
https://bugs.webkit.org/show_bug.cgi?id=167277
<rdar://problem/30179506>
Reviewed by Filip Pizlo.
I made TinyPtrSet use bitwise_cast instead of static_cast
for its singleEntry() function so that it can work on pointer-like
types just as it can on actual pointer types.
An example of where this matters is when you have TinyPtrSet<T>
where T is defined to be a struct which wraps a pointer, e.g:
struct T {
void* m_pointer;
}
* wtf/TinyPtrSet.h:
(WTF::TinyPtrSet::singleEntry):
2017-01-25 Wenson Hsieh <wenson_hsieh@apple.com>
Introduce an item-provider-based pasteboard wrapper
https://bugs.webkit.org/show_bug.cgi?id=167410
Reviewed by Enrica Casucci.
Adds an additional feature flag.
* wtf/FeatureDefines.h:
2017-01-25 Konstantin Tokarev <annulen@yandex.ru>
Removed leftovers of pre-2015 VisualStudio support
https://bugs.webkit.org/show_bug.cgi?id=167434
Reviewed by Alex Christensen.
* wtf/Compiler.h:
* wtf/Platform.h:
* wtf/StringExtras.h:
2017-01-25 Chris Dumez <cdumez@apple.com>
Disable Download attribute support on iOS
https://bugs.webkit.org/show_bug.cgi?id=167337
<rdar://problem/30154148>
Reviewed by Alexey Proskuryakov.
Disable Download attribute support on iOS as it currently does not work.
* wtf/FeatureDefines.h:
2017-01-25 Wenson Hsieh <wenson_hsieh@apple.com>
Add a hook to include additional feature defines
https://bugs.webkit.org/show_bug.cgi?id=167403
Reviewed by Enrica Casucci.
* wtf/Platform.h: Include AdditionalFeatureDefines.h, if it exists.
2017-01-24 Joseph Pecoraro <pecoraro@apple.com>
Fold USER_TIMING into WEB_TIMING and make it a RuntimeEnabledFeature
https://bugs.webkit.org/show_bug.cgi?id=167394
Reviewed by Ryosuke Niwa.
* wtf/FeatureDefines.h:
2017-01-24 Konstantin Tokarev <annulen@yandex.ru>
VS2015 supports ref qualifiers
https://bugs.webkit.org/show_bug.cgi?id=167368
Reviewed by Sam Weinig.
* wtf/Compiler.h: Enable
WTF_COMPILER_SUPPORTS_CXX_REFERENCE_QUALIFIED_FUNCTIONS for VS2015
2017-01-24 Daniel Bates <dabates@apple.com>
StringView.split() should use an iterator design pattern instead of allocating a Vector
https://bugs.webkit.org/show_bug.cgi?id=163225
Reviewed by Darin Adler.
Implement StringView.split() using an iterator design.
Using an iterator design avoids the need to allocate a Vector of StringView objects,
which is space-inefficient and error prone as the returned Vector may outlive the
lifetime of the underlying string associated with the split (as StringView is a non-
owning reference to a string).
StringView.split() now returns a StringView::SplitResult object that implements begin()/end()
to support iterating over StringView substrings delimited by the specified separator
character. For example, to iterate over the 'c'-separated substrings of a StringView v,
you can write:
for (StringView substring : v.split('c'))
// Do something with substring.
* wtf/text/StringView.cpp:
(WTF::StringView::SplitResult::Iterator::findNextSubstring): Advances the iterator to point to the
next substring.
(WTF::StringView::split): Modified to return a SplitResult::Iterator object instead of a Vector<StringView>.
* wtf/text/StringView.h:
(WTF::StringView::SplitResult::SplitResult):
(WTF::StringView::SplitResult::Iterator::Iterator):
(WTF::StringView::SplitResult::Iterator::operator*):
(WTF::StringView::SplitResult::Iterator::operator==):
(WTF::StringView::SplitResult::Iterator::operator!=):
Implements the iterator interface.
2017-01-20 Joseph Pecoraro <pecoraro@apple.com>
Remove outdated ENABLE(CSP_NEXT) build flag
https://bugs.webkit.org/show_bug.cgi?id=167252
Reviewed by Brent Fulgham.
* wtf/FeatureDefines.h:
2017-01-17 Andreas Kling <akling@apple.com>
Annotate FastMalloc functions with returns_nonnull attribute.
<https://webkit.org/b/167144>
Reviewed by Antti Koivisto.
Decorate fastMalloc() and friends with __attribute__((returns_nonnull)) for supporting
compilers that can do useful things with that information.
* wtf/Compiler.h:
* wtf/FastMalloc.h:
2017-01-17 Joseph Pecoraro <pecoraro@apple.com>
ENABLE(USER_TIMING) Not Defined for Apple Windows or OS X Ports
https://bugs.webkit.org/show_bug.cgi?id=116551
<rdar://problem/13949830>
Reviewed by Alex Christensen.
* wtf/FeatureDefines.h:
2017-01-16 Joseph Pecoraro <pecoraro@apple.com>
Remove the REQUEST_ANIMATION_FRAME flag
https://bugs.webkit.org/show_bug.cgi?id=156980
<rdar://problem/25906849>
Reviewed by Simon Fraser.
* wtf/FeatureDefines.h:
2017-01-15 Sam Weinig <sam@webkit.org>
Add the ability to use numbers in makeString()
https://bugs.webkit.org/show_bug.cgi?id=167087
Reviewed by Darin Adler.
Allow numbers to be easily used in makeString() and tryMakeString().
For instance, you can now write:
int amount = 7;
auto foo = makeString("There are ", amount, " apples in the cart");
* WTF.xcodeproj/project.pbxproj:
Add new file.
* wtf/text/IntegerToStringConversion.h:
(WTF::writeNumberToBufferImpl):
(WTF::writeNumberToBufferSigned):
(WTF::writeNumberToBufferUnsigned):
(WTF::lengthOfNumberAsStringImpl):
(WTF::lengthOfNumberAsStringSigned):
(WTF::lengthOfNumberAsStringUnsigned):
Add variants of integer writing code that compute the length of the string
that would be produced and writes the string to an existing buffer.
(WTF::IntegerToStringConversionTrait<AtomicString>::flush): Deleted.
(WTF::IntegerToStringConversionTrait<String>::flush): Deleted.
(WTF::IntegerToStringConversionTrait<StringBuilder>::flush): Deleted.
Move these traits to their respective classes.
* wtf/text/AtomicString.h:
(WTF::IntegerToStringConversionTrait<AtomicString>::flush):
* wtf/text/StringBuilder.h:
(WTF::IntegerToStringConversionTrait<StringBuilder>::flush):
* wtf/text/WTFString.h:
(WTF::IntegerToStringConversionTrait<String>::flush):
Traits moved here from IntegerToStringConversion.h
* wtf/text/StringConcatenateNumbers.h: Added.
(WTF::StringTypeAdapter<int>::StringTypeAdapter<int>):
(WTF::StringTypeAdapter<int>::length):
(WTF::StringTypeAdapter<int>::is8Bit):
(WTF::StringTypeAdapter<int>::writeTo):
(WTF::StringTypeAdapter<int>::toString):
(WTF::StringTypeAdapter<unsigned>::StringTypeAdapter<unsigned>):
(WTF::StringTypeAdapter<unsigned>::length):
(WTF::StringTypeAdapter<unsigned>::is8Bit):
(WTF::StringTypeAdapter<unsigned>::writeTo):
(WTF::StringTypeAdapter<unsigned>::toString):
(WTF::StringTypeAdapter<float>::StringTypeAdapter<float>):
(WTF::StringTypeAdapter<float>::length):
(WTF::StringTypeAdapter<float>::is8Bit):
(WTF::StringTypeAdapter<float>::writeTo):
(WTF::StringTypeAdapter<float>::toString):
(WTF::StringTypeAdapter<double>::StringTypeAdapter<double>):
(WTF::StringTypeAdapter<double>::length):
(WTF::StringTypeAdapter<double>::is8Bit):
(WTF::StringTypeAdapter<double>::writeTo):
(WTF::StringTypeAdapter<double>::toString):
Add basic adaptors for int, unsigned, float, and double.
(WTF::FormattedNumber::fixedPrecision):
(WTF::FormattedNumber::fixedWidth):
(WTF::FormattedNumber::length):
(WTF::FormattedNumber::buffer):
(WTF::FormattedNumber::stringView):
(WTF::StringTypeAdapter<FormattedNumber>::StringTypeAdapter<FormattedNumber>):
(WTF::StringTypeAdapter<FormattedNumber>::length):
(WTF::StringTypeAdapter<FormattedNumber>::is8Bit):
(WTF::StringTypeAdapter<FormattedNumber>::writeTo):
(WTF::StringTypeAdapter<FormattedNumber>::toString):
Add a special class, FormattedNumber, and an adaptor for it, allowing for
fixedPrecision and fixedWidth representation of doubles.
2017-01-14 Yusuke Suzuki <utatane.tea@gmail.com>
WebAssembly: Suppress warnings & errors in GCC
https://bugs.webkit.org/show_bug.cgi?id=167049
Reviewed by Sam Weinig.
* wtf/LEBDecoder.h:
(WTF::LEBDecoder::decodeInt):
If T = int, it performs `-1 << shift`. It causes
warning in GCC. Instead, we first cast it to the
UnsignedT, perform operation and re-cast to the
T.
2017-01-13 Joseph Pecoraro <pecoraro@apple.com>
Remove ENABLE(DETAILS_ELEMENT) guards
https://bugs.webkit.org/show_bug.cgi?id=167042
Reviewed by Alex Christensen.
* wtf/FeatureDefines.h:
2017-01-11 Darin Adler <darin@apple.com>
Remove PassRefPtr from more of "platform"
https://bugs.webkit.org/show_bug.cgi?id=166809
Reviewed by Sam Weinig.
* wtf/Ref.h: Changed the template so that a const Ref<T> does not prohibit non-const
use of T. We can still use const Ref<const T> to express that. The earlier design
was intentional, but was not consistent with either actual references or with
other smart pointer classes like RefPtr. One way to see how much better this is,
is to see all the many, many cases where we have const_cast just to work around
this. I searched for those and included fixes for many in this patch.
2017-01-12 Chris Dumez <cdumez@apple.com>
[iOS] Implement support for KeyboardEvent.code
https://bugs.webkit.org/show_bug.cgi?id=166932
<rdar://problem/29972518>
Reviewed by Darin Adler.
Enable KEYBOARD_CODE_ATTRIBUTE feature on iOS.
* wtf/FeatureDefines.h:
2017-01-11 Andreas Kling <akling@apple.com>
Crash when WebCore's GC heap grows way too large.
<https://webkit.org/b/166875>
<rdar://problem/27896585>
Reviewed by Mark Lam.
Publish the WTF::GB constant.
* wtf/StdLibExtras.h:
2017-01-11 Anders Carlsson <andersca@apple.com>
navigator.plugins.refresh and WKContextRefreshPlugIns doesn't pick up changes to already-present plug-ins
https://bugs.webkit.org/show_bug.cgi?id=166942
rdar://problem/29839194
Reviewed by Sam Weinig.
* wtf/spi/cf/CFBundleSPI.h:
Add SPI declaration.
2017-01-06 Gustavo Noronha Silva <gustavo.noronha@collabora.co.uk>
[GTK] Should support key and code properties on keyboard events
https://bugs.webkit.org/show_bug.cgi?id=166759
Reviewed by Carlos Garcia Campos.
* wtf/FeatureDefines.h: enable key and code properties support for GTK.
2017-01-08 Antti Koivisto <antti@apple.com>
Move cache coders to WTF
https://bugs.webkit.org/show_bug.cgi?id=166825
Rubber-stamped by Sam Weinig.
Make it possible to use robust serialization of WTF types on the lower levels of the stack.
* WTF.xcodeproj/project.pbxproj:
* wtf/persistence: Added.
* wtf/persistence/Coder.h: Copied from Source/WebKit2/NetworkProcess/cache/NetworkCacheCoder.h.
(WebKit::NetworkCache::Coder::encode): Deleted.
(WebKit::NetworkCache::Coder::decode): Deleted.
* wtf/persistence/Coders.cpp: Copied from Source/WebKit2/NetworkProcess/cache/NetworkCacheCoders.cpp.
(WebKit::NetworkCache::Coder<AtomicString>::encode): Deleted.
(WebKit::NetworkCache::Coder<AtomicString>::decode): Deleted.
(WebKit::NetworkCache::Coder<CString>::encode): Deleted.
(WebKit::NetworkCache::Coder<CString>::decode): Deleted.
(WebKit::NetworkCache::Coder<String>::encode): Deleted.
(WebKit::NetworkCache::decodeStringText): Deleted.
(WebKit::NetworkCache::Coder<String>::decode): Deleted.
(WebKit::NetworkCache::Coder<SHA1::Digest>::encode): Deleted.
(WebKit::NetworkCache::Coder<SHA1::Digest>::decode): Deleted.
(WebKit::NetworkCache::Coder<WebCore::HTTPHeaderMap>::encode): Deleted.
(WebKit::NetworkCache::Coder<WebCore::HTTPHeaderMap>::decode): Deleted.
* wtf/persistence/Coders.h: Copied from Source/WebKit2/NetworkProcess/cache/NetworkCacheCoders.h.
(WebKit::NetworkCache::Coder<std::optional<T>>::encode): Deleted.
(WebKit::NetworkCache::Coder<std::optional<T>>::decode): Deleted.
* wtf/persistence/Decoder.cpp: Copied from Source/WebKit2/NetworkProcess/cache/NetworkCacheDecoder.cpp.
(WebKit::NetworkCache::Decoder::Decoder): Deleted.
(WebKit::NetworkCache::Decoder::~Decoder): Deleted.
(WebKit::NetworkCache::Decoder::bufferIsLargeEnoughToContain): Deleted.
(WebKit::NetworkCache::Decoder::decodeFixedLengthData): Deleted.
(WebKit::NetworkCache::Decoder::decodeNumber): Deleted.
(WebKit::NetworkCache::Decoder::decode): Deleted.
(WebKit::NetworkCache::Decoder::verifyChecksum): Deleted.
* wtf/persistence/Decoder.h: Copied from Source/WebKit2/NetworkProcess/cache/NetworkCacheDecoder.h.
(WebKit::NetworkCache::Decoder::length): Deleted.
(WebKit::NetworkCache::Decoder::currentOffset): Deleted.
(WebKit::NetworkCache::Decoder::decodeEnum): Deleted.
(WebKit::NetworkCache::Decoder::decode): Deleted.
(WebKit::NetworkCache::Decoder::bufferIsLargeEnoughToContain): Deleted.
* wtf/persistence/Encoder.cpp: Copied from Source/WebKit2/NetworkProcess/cache/NetworkCacheEncoder.cpp.
(WebKit::NetworkCache::Encoder::Encoder): Deleted.
(WebKit::NetworkCache::Encoder::~Encoder): Deleted.
(WebKit::NetworkCache::Encoder::grow): Deleted.
(WebKit::NetworkCache::Encoder::updateChecksumForData): Deleted.
(WebKit::NetworkCache::Encoder::encodeFixedLengthData): Deleted.
(WebKit::NetworkCache::Encoder::encodeNumber): Deleted.
(WebKit::NetworkCache::Encoder::encode): Deleted.
(WebKit::NetworkCache::Encoder::encodeChecksum): Deleted.
* wtf/persistence/Encoder.h: Copied from Source/WebKit2/NetworkProcess/cache/NetworkCacheEncoder.h.
(WebKit::NetworkCache::Encoder::encodeEnum): Deleted.
(WebKit::NetworkCache::Encoder::encode): Deleted.
(WebKit::NetworkCache::Encoder::operator<<): Deleted.
(WebKit::NetworkCache::Encoder::buffer): Deleted.
(WebKit::NetworkCache::Encoder::bufferSize): Deleted.
(WebKit::NetworkCache::Encoder::updateChecksumForNumber): Deleted.
2017-01-08 Konstantin Tokarev <annulen@yandex.ru>
Introduce CPU(X86_SSE2) instead of various SSE2 checks
https://bugs.webkit.org/show_bug.cgi?id=166808
Reviewed by Michael Catanzaro.
Now copyLCharsFromUCharSource can use SSE2 implementation on non-Darwin
OSes, and all SSE2 code paths are available for MSVC on x86 if /arch:SSE2
or higher is enabled, and for MSVC on x86_64.
* wtf/Platform.h:
* wtf/text/ASCIIFastPath.h:
(WTF::copyLCharsFromUCharSource):
2017-01-05 Myles C. Maxfield <mmaxfield@apple.com>
Carets can split up marriages and families
https://bugs.webkit.org/show_bug.cgi?id=166711
<rdar://problem/29019333>
Reviewed by Alex Christensen.
There are four code points which should be allowed to accept emoji modifiers:
- U+1F46A FAMILY
- U+1F46B MAN AND WOMAN HOLDING HANDS
- U+1F46C TWO MEN HOLDING HANDS
- U+1F46D TWO WOMEN HOLDING HANDS
Even though macOS's and iOS's emoji keyboard don't allow users to actually type
these combinations, we may still receive them from other platforms. We should
therefore treat these as joining sequences. Rendering isn't a problem because
the fonts accept the emoji modifiers, but our caret placement code isn't educated
about it. Currently, we treat these emoji groups as ligatures, allowing the caret
to be placed between the two code points, which visually shows as being horizontally
centered in the glyph. Instead, we should treat these code points as accepting
emoji modifiers.
Tests: editing/caret/emoji.html
editing/caret/ios/emoji.html
* wtf/text/TextBreakIterator.cpp:
(WTF::cursorMovementIterator):
2017-01-05 Filip Pizlo <fpizlo@apple.com>
AutomaticThread timeout shutdown leaves a small window where notify() would think that the thread is still running
https://bugs.webkit.org/show_bug.cgi?id=166742
Reviewed by Geoffrey Garen.
Remove the use of the RAII ThreadScope, since the use of RAII helped make this bug possible:
we'd do ~ThreadScope after we had done ~LockHolder, so in between when we decided to shut
down a thread and when it reported itself as being shut down, there was a window where a
notify() call would get confused.
Now, we run all thread shutdown stuff while the lock is held. We release the lock last. One
API implication is that threadWillStop becomes threadIsStopping and it's called while the
lock is held. This seems benign.
* wtf/AutomaticThread.cpp:
(WTF::AutomaticThread::start):
(WTF::AutomaticThread::threadIsStopping):
(WTF::AutomaticThread::ThreadScope::ThreadScope): Deleted.
(WTF::AutomaticThread::ThreadScope::~ThreadScope): Deleted.
(WTF::AutomaticThread::threadWillStop): Deleted.
* wtf/AutomaticThread.h:
2017-01-04 Darin Adler <darin@apple.com>
Remove PassRefPtr use from the "html" directory, other improvements
https://bugs.webkit.org/show_bug.cgi?id=166635
Reviewed by Alex Christensen.
* wtf/RefPtr.h:
(WTF::makeRefPtr): Added.
2017-01-04 Yusuke Suzuki <utatane.tea@gmail.com>
Unreviewed build fix after r210313
https://bugs.webkit.org/show_bug.cgi?id=166676
Revert `#pragma once` to ifdefs due to build failure.
* wtf/text/StringView.h:
2017-01-04 Yusuke Suzuki <utatane.tea@gmail.com>
Limit thread name appropriately
https://bugs.webkit.org/show_bug.cgi?id=166676
Reviewed by Sam Weinig.
In some platform, the max length of thread names are limited.
For example, the number of the max length is 32 in Windows and
16 in Linux. But the specified thread name is typically long
in WebKit like "com.apple.CoreIPC.ReceiveQueue"
We port the logic substring the thread name in
generic/WorkQueueGeneric.cpp to Threading. It retrieves the name
"ReceiveQueue" from "com.apple.CoreIPC.ReceiveQueue". And apply
the appropriate the thread name limit and use it on Linux and
Windows environment.
* wtf/Threading.cpp:
(WTF::normalizeThreadName):
(WTF::createThread):
* wtf/Threading.h:
* wtf/ThreadingPthreads.cpp:
(WTF::initializeCurrentThreadInternal):
* wtf/ThreadingWin.cpp:
(WTF::initializeCurrentThreadInternal):
* wtf/generic/WorkQueueGeneric.cpp:
(WorkQueue::platformInitialize):
* wtf/text/StringView.h:
(WTF::StringView::left):
(WTF::StringView::right):
(WTF::StringView::reverseFind):
2017-01-04 Sam Weinig <sam@webkit.org>
REGRESSION (r210257): com.apple.WebKit.WebContent.Development crashed in com.apple.WebCore: WebCore::ExceptionOr<WTF::Ref<WebCore::Database> >::operator= + 14
<rdar://problem/29866398>
* wtf/Expected.h:
(WTF::Expected::swap):
Add missing calls to destroy() when moving things over each other in a union.
2017-01-03 Yusuke Suzuki <utatane.tea@gmail.com>
Use prctl to name thread on Linux
https://bugs.webkit.org/show_bug.cgi?id=166663
Reviewed by Michael Catanzaro.
It is quite useful if we can name threads. This name will be shown in GDB.
While macOS uses pthread_setname_np, we can use prctl on Linux.
* wtf/ThreadingPthreads.cpp:
(WTF::initializeCurrentThreadInternal):
2017-01-03 Yusuke Suzuki <utatane.tea@gmail.com>
WorkQueueGeneric's platformInvalidate() can deadlock when called on the RunLoop's thread
https://bugs.webkit.org/show_bug.cgi?id=166645
Reviewed by Carlos Garcia Campos.
WorkQueue can be destroyed on its invoking thread itself.
The scenario is the following.
1. Create WorkQueue (in thread A).
2. Dispatch a task (in thread A, dispatching a task to thread B).
3. Deref in thread A.
4. The task is executed in thread B.
5. Deref in thread B.
6. The WorkQueue is destroyed, calling platformInvalidate in thread B.
In that case, if platformInvalidate waits thread B's termination, it causes deadlock.
We do not need to wait the thread termination.
* wtf/WorkQueue.h:
* wtf/generic/WorkQueueGeneric.cpp:
(WorkQueue::platformInitialize):
(WorkQueue::platformInvalidate):
2017-01-03 Sam Weinig <sam@webkit.org>
Make WTF::Expected support Ref template parameters
https://bugs.webkit.org/show_bug.cgi?id=166662
Reviewed by Alex Christensen.
Tests: Added to TestWebKitAPI/Expected.cpp
* wtf/Expected.h:
(WTF::UnexpectedType::value):
Add overloads based on this value type to allow getting at the value
as an rvalue for moving the error into the Expected.
(WTF::Expected::Expected):
Add overload that takes an ErrorType/UnexpectedType<ErrorType> as an rvalue.
(WTF::Expected::swap):
Move the temporary value/error rather than copying.
2017-01-02 Julien Brianceau <jbriance@cisco.com>
Remove sh4 specific code from JavaScriptCore
https://bugs.webkit.org/show_bug.cgi?id=166640
Reviewed by Filip Pizlo.
* wtf/Platform.h:
2017-01-02 Yusuke Suzuki <utatane.tea@gmail.com>
Leverage Substring to create new AtomicStringImpl for StaticStringImpl and SymbolImpl
https://bugs.webkit.org/show_bug.cgi?id=166636
Reviewed by Darin Adler.
Previously we always create the full atomic string if we need to create the same string
based on the given value. For example, when generating AtomicStringImpl from the SymbolImpl,
we need to create a new AtomicStringImpl since SymbolImpl never becomes `isAtomic() == true`.
But it is costly.
This patch leverages the substring system of StringImpl. Instead of allocating the completely
duplicate string, we create a substring StringImpl that shares the same content with the
base string.
* wtf/text/AtomicStringImpl.cpp:
(WTF::stringTable):
(WTF::addToStringTable):
(WTF::addSubstring):
(WTF::AtomicStringImpl::addSlowCase):
(WTF::AtomicStringImpl::remove):
(WTF::AtomicStringImpl::lookUpSlowCase):
* wtf/text/StringImpl.h:
(WTF::StringImpl::StaticStringImpl::operator StringImpl&):
2017-01-02 Yusuke Suzuki <utatane.tea@gmail.com>
Use StaticStringImpl instead of StaticASCIILiteral
https://bugs.webkit.org/show_bug.cgi?id=166586
Reviewed by Darin Adler.
It is more handy way to define static StringImpl. It calculates the length
and hash value by using the constexpr constructor and function. So we do
not need to calculate these things in Perl script.
And it allows us to use StaticStringImpl in the hand written C++ code.
Previously, we need to calculate the length and hash value by hand if we
would like to use StaticASCIILiteral in the hand written C++ code, and it
meant that we cannot use it at all in the hand written C++ code.
* wtf/text/AtomicStringImpl.cpp:
(WTF::AtomicStringImpl::addSlowCase):
(WTF::AtomicStringImpl::lookUpSlowCase):
* wtf/text/AtomicStringImpl.h:
* wtf/text/StringImpl.h:
* wtf/text/SymbolImpl.h:
* wtf/text/UniquedStringImpl.h:
2017-01-02 Andreas Kling <akling@apple.com>
Discard media controls JS/CSS caches under memory pressure.
<https://webkit.org/b/166639>
Reviewed by Antti Koivisto.
* wtf/text/WTFString.h:
(WTF::String::clearImplIfNotShared): Add a helper for clearing a String if the underlying
StringImpl is not referenced by anyone else.
2016-12-22 Mark Lam <mark.lam@apple.com>
De-duplicate finally blocks.
https://bugs.webkit.org/show_bug.cgi?id=160168
Reviewed by Saam Barati.
Added some methods to bring SegmentedVector closer to parity with Vector.
* wtf/SegmentedVector.h:
(WTF::SegmentedVector::first):
(WTF::SegmentedVector::last):
(WTF::SegmentedVector::takeLast):
2016-12-19 Mark Lam <mark.lam@apple.com>
Rolling out r209974 and r209952. They break some websites in mysterious ways. Step 2: Rollout r209952.
https://bugs.webkit.org/show_bug.cgi?id=166049
Not reviewed.
* wtf/SegmentedVector.h:
(WTF::SegmentedVector::last):
(WTF::SegmentedVector::first): Deleted.
(WTF::SegmentedVector::takeLast): Deleted.
2016-12-16 Mark Lam <mark.lam@apple.com>
Add predecessor info to dumps from JSC_dumpBytecodeLivenessResults=true.
https://bugs.webkit.org/show_bug.cgi?id=165958
Reviewed by Keith Miller.
Added some methods to bring SegmentedVector closer to parity with Vector.
* wtf/SegmentedVector.h:
(WTF::SegmentedVector::first):
(WTF::SegmentedVector::last):
(WTF::SegmentedVector::takeLast):
2016-12-16 Michael Saboff <msaboff@apple.com>
REGRESSION: HipChat and Mail sometimes hang beneath JSC::Heap::lastChanceToFinalize()
https://bugs.webkit.org/show_bug.cgi?id=165962
Reviewed by Filip Pizlo.
There is an inherent race in Condition::waitFor() where the timeout can happen just before
a notify from another thread.
Fixed this by adding a condition variable and flag to each AutomaticThread. The flag
is used to signify to a notifying thread that the thread is waiting. That flag is set
in the waiting thread before calling waitFor() and cleared by another thread when it
notifies the thread. The access to that flag happens when the lock is held.
Now the waiting thread checks if the flag after a timeout to see that it in fact should
proceed like a normal notification.
The added condition variable allows us to target a specific thread. We used to keep a list
of waiting threads, now we keep a list of all threads. To notify one thread, we look for
a waiting thread and notify it directly. If we can't find a waiting thread, we start a
sleeping thread.
We notify all threads by waking all waiting threads and starting all sleeping threads.
* wtf/AutomaticThread.cpp:
(WTF::AutomaticThreadCondition::notifyOne):
(WTF::AutomaticThreadCondition::notifyAll):
(WTF::AutomaticThread::isWaiting):
(WTF::AutomaticThread::notify):
(WTF::AutomaticThread::start):
* wtf/AutomaticThread.h:
2016-12-15 Myles C. Maxfield <mmaxfield@apple.com>
Unreviewed build fix after r209910
Unreviewed.
* wtf/Platform.h:
2016-12-15 Myles C. Maxfield <mmaxfield@apple.com>
Stop reinterpret_casting UBreakIterators to the undefined type TextBreakIterator
https://bugs.webkit.org/show_bug.cgi?id=165931
We have a class declaration for TextBreakIterator but no definition for it. When we
create an ICU UBreakIterator, we immediately reinterpret_cast it to this undefined
type, and pass it around our code inside WebCore. Then, whenever we want to actually
use this iterator, we reinterpret_cast it back to UBreakIterator. This is likely due
to some ports historically implementing breaking interators on top of other libraries
other than ICU; however, now, all ports use ICU. Because this internal type is not
helpful and just adds confusion, we should just call our breaking iterators what
they are: UBreakIterators.
This patch is a mechanical replacement of TextBreakIterator to UBreakIterator and
removes the functions we were calling which pass through directly to ubrk_*().
Reviewed by Alex Christensen.
* wtf/text/LineBreakIteratorPoolICU.h:
(WTF::LineBreakIteratorPool::take):
(WTF::LineBreakIteratorPool::put):
* wtf/text/StringView.cpp:
(WTF::StringView::GraphemeClusters::Iterator::Impl::computeIndexEnd):
* wtf/text/TextBreakIterator.cpp:
(WTF::initializeIterator):
(WTF::initializeIteratorWithRules):
(WTF::setTextForIterator):
(WTF::setContextAwareTextForIterator):
(WTF::wordBreakIterator):
(WTF::sentenceBreakIterator):
(WTF::cursorMovementIterator):
(WTF::acquireLineBreakIterator):
(WTF::releaseLineBreakIterator):
(WTF::openLineBreakIterator):
(WTF::closeLineBreakIterator):
(WTF::getNonSharedCharacterBreakIterator):
(WTF::cacheNonSharedCharacterBreakIterator):
(WTF::isWordTextBreak):
(WTF::numGraphemeClusters):
(WTF::numCharactersInGraphemeClusters):
(WTF::textBreakFirst): Deleted.
(WTF::textBreakLast): Deleted.
(WTF::textBreakNext): Deleted.
(WTF::textBreakPrevious): Deleted.
(WTF::textBreakPreceding): Deleted.
(WTF::textBreakFollowing): Deleted.
(WTF::textBreakCurrent): Deleted.
(WTF::isTextBreak): Deleted.
* wtf/text/TextBreakIterator.h:
(WTF::LazyLineBreakIterator::lastCharacter):
(WTF::LazyLineBreakIterator::secondToLastCharacter):
(WTF::LazyLineBreakIterator::setPriorContext):
(WTF::LazyLineBreakIterator::updatePriorContext):
(WTF::LazyLineBreakIterator::resetPriorContext):
(WTF::LazyLineBreakIterator::priorContextLength):
(WTF::LazyLineBreakIterator::get):
(WTF::NonSharedCharacterBreakIterator::operator UBreakIterator*):
(WTF::NonSharedCharacterBreakIterator::operator TextBreakIterator*): Deleted.
2016-12-15 Myles C. Maxfield <mmaxfield@apple.com>
Sort Xcode project files
https://bugs.webkit.org/show_bug.cgi?id=165937
Reviewed by Simon Fraser.
* WTF.xcodeproj/project.pbxproj:
2016-12-15 Konstantin Tokarev <annulen@yandex.ru>
Added missing override and final specifiers
https://bugs.webkit.org/show_bug.cgi?id=165903
Reviewed by Darin Adler.
* wtf/RunLoop.h:
2016-12-15 Yusuke Suzuki <utatane.tea@gmail.com>
[JSC] Optimize Kraken stringify
https://bugs.webkit.org/show_bug.cgi?id=165857
Reviewed by Darin Adler.
Kraken json-stringify-tinderbox performance heavily relies on StringBuilder::appendQuotedJSONString.
According to the result produced by Linux `perf`, it occupies 28% of execution time.
We tighten the hottest loop in the above function. We create the super fast path for non escaping case.
And add " and \ cases (since including " in the string is common). Then we fallback to the slow case.
It improves the performance 5.5% in Kraken json-stringify-tinderbox in MBP.
Performance result in my MBP (dandelion).
Collected 100 samples per benchmark/VM, with 100 VM invocations per benchmark. Emitted a call to gc()
between sample measurements. Used 1 benchmark iteration per VM invocation for warm-up. Used the
jsc-specific preciseTime() function to get microsecond-level timing. Reporting benchmark execution times
with 95% confidence intervals in milliseconds.
baseline patched
json-stringify-tinderbox 29.243+-0.241 ^ 27.701+-0.235 ^ definitely 1.0557x faster
<arithmetic> 29.243+-0.241 ^ 27.701+-0.235 ^ definitely 1.0557x faster
Performance result in my Linux laptop (hanayamata).
Collected 100 samples per benchmark/VM, with 100 VM invocations per benchmark. Emitted a call to gc()
between sample measurements. Used 1 benchmark iteration per VM invocation for warm-up. Used the
jsc-specific preciseTime() function to get microsecond-level timing. Reporting benchmark execution times
with 95% confidence intervals in milliseconds.
baseline patched
json-stringify-tinderbox 26.711+-0.475 ^ 25.255+-0.034 ^ definitely 1.0577x faster
<arithmetic> 26.711+-0.475 ^ 25.255+-0.034 ^ definitely 1.0577x faster
* wtf/text/StringBuilder.cpp:
(WTF::appendQuotedJSONStringInternalSlow):
(WTF::appendQuotedJSONStringInternal):
2016-12-14 Commit Queue <commit-queue@webkit.org>
Unreviewed, rolling out r209795.
https://bugs.webkit.org/show_bug.cgi?id=165853
rolled out the wrong revision (Requested by pizlo on #webkit).
Reverted changeset:
"MarkedBlock::marksConveyLivenessDuringMarking should take
into account collection scope"
https://bugs.webkit.org/show_bug.cgi?id=165741
http://trac.webkit.org/changeset/209795
2016-12-14 Enrique Ocaña González <eocanha@igalia.com>
REGRESSION(r207879-207891): [GStreamer] Introduced many layout test failures and crashes, bots exiting early
https://bugs.webkit.org/show_bug.cgi?id=164022
Reviewed by Xabier Rodriguez-Calvar.
* wtf/glib/GLibUtilities.h:
Added new macros to convert gulong to/from gpointer.
2016-12-14 Gavin Barraclough <barraclough@apple.com>
MarkedBlock::marksConveyLivenessDuringMarking should take into account collection scope
https://bugs.webkit.org/show_bug.cgi?id=165741
Unreviewed, re-landing this with fix (revert erroneous change to Options).
* WTF.xcodeproj/project.pbxproj:
* wtf/CMakeLists.txt:
* wtf/DataLog.cpp:
(WTF::initializeLogFileOnce):
(WTF::initializeLogFile):
(WTF::dataFile):
* wtf/DataLog.h:
* wtf/LockedPrintStream.cpp: Added.
(WTF::LockedPrintStream::LockedPrintStream):
(WTF::LockedPrintStream::~LockedPrintStream):
(WTF::LockedPrintStream::vprintf):
(WTF::LockedPrintStream::flush):
(WTF::LockedPrintStream::begin):
(WTF::LockedPrintStream::end):
* wtf/LockedPrintStream.h: Added.
* wtf/PrintStream.cpp:
(WTF::PrintStream::printfVariableFormat):
(WTF::PrintStream::begin):
(WTF::PrintStream::end):
* wtf/PrintStream.h:
(WTF::PrintStream::atomically):
(WTF::PrintStream::print):
(WTF::PrintStream::println):
(WTF::PrintStream::printImpl):
(WTF::>::unpack):
(WTF::FormatImpl::FormatImpl):
(WTF::FormatImpl::dump):
(WTF::format):
(WTF::printInternal):
* wtf/RecursiveLockAdapter.h: Added.
(WTF::RecursiveLockAdapter::RecursiveLockAdapter):
(WTF::RecursiveLockAdapter::lock):
(WTF::RecursiveLockAdapter::unlock):
(WTF::RecursiveLockAdapter::tryLock):
(WTF::RecursiveLockAdapter::isLocked):
* wtf/WordLock.cpp:
* wtf/WordLock.h:
2016-12-14 Gavin Barraclough <barraclough@apple.com>
MarkedBlock::marksConveyLivenessDuringMarking should take into account collection scope
https://bugs.webkit.org/show_bug.cgi?id=165741
Unreviewed rollout due to performance regression.
* WTF.xcodeproj/project.pbxproj:
* wtf/CMakeLists.txt:
* wtf/DataLog.cpp:
(WTF::initializeLogFileOnce):
(WTF::initializeLogFile):
(WTF::dataFile):
* wtf/DataLog.h:
* wtf/LockedPrintStream.cpp: Removed.
* wtf/LockedPrintStream.h: Removed.
* wtf/PrintStream.cpp:
(WTF::PrintStream::printfVariableFormat): Deleted.
(WTF::PrintStream::begin): Deleted.
(WTF::PrintStream::end): Deleted.
* wtf/PrintStream.h:
(WTF::PrintStream::print):
(WTF::PrintStream::println):
(WTF::PrintStream::atomically): Deleted.
(WTF::PrintStream::printImpl): Deleted.
(): Deleted.
(WTF::>::unpack): Deleted.
(WTF::FormatImpl::FormatImpl): Deleted.
(WTF::FormatImpl::dump): Deleted.
(WTF::format): Deleted.
* wtf/RecursiveLockAdapter.h: Removed.
* wtf/WordLock.cpp:
* wtf/WordLock.h:
2016-12-13 JF Bastien <jfbastien@apple.com>
std::expected: fix rvalue forwarding issues
https://bugs.webkit.org/show_bug.cgi?id=165812
Reviewed by Mark Lam.
* wtf/Expected.h:
(WTF::UnexpectedType::UnexpectedType):
(WTF::ExpectedDetail::Base::Base):
(WTF::Expected::Expected):
2016-12-13 Chris Dumez <cdumez@apple.com>
Unreviewed, rolling out r209544.
Looks like r209489 did not cause the performance regression
after all
Reverted changeset:
"Unreviewed, rolling out r209489."
https://bugs.webkit.org/show_bug.cgi?id=165550
http://trac.webkit.org/changeset/209544
2016-12-13 Commit Queue <commit-queue@webkit.org>
Unreviewed, rolling out r209725.
https://bugs.webkit.org/show_bug.cgi?id=165811
"Broke ARMv7 builds" (Requested by msaboff on #webkit).
Reverted changeset:
"REGRESSION(r209653): speedometer crashes making virtual slow
path tailcalls"
https://bugs.webkit.org/show_bug.cgi?id=165748
http://trac.webkit.org/changeset/209725
2016-12-13 JF Bastien <jfbastien@apple.com>
[WTF] Turn tryMakeString(), makeString() into variadic templates
https://bugs.webkit.org/show_bug.cgi?id=147142
Reviewed by Mark Lam.
I wrote this patch while improving WebAssembly's error messages,
and only found this bug afterwards. My implementation does the
bare minimum to make this code variadic without changing
behavior. I think it's better to go with this baby step first, and
improve the code later.
Notable, for my WebAssembly patch I also taught the code to handle
integers and other types (including WebAssembly types). A
follow-up could rely on ADL magic to pretty-format these other
types.
* wtf/text/StringConcatenate.h:
(WTF::sumWithOverflow): This unconditionally does the sum for all
inputs, which the compiler is more likely to appreciate (because
it's the common case) compared to testing for overflow and bailing
on each addition
(WTF::are8Bit): are: the plural of is!
(WTF::makeStringAccumulator): accumulate strings
(WTF::tryMakeStringFromAdapters): a small helper which creates the string adapters
(WTF::tryMakeString): expose out of WTF, since it's part of this file's used API
(WTF::makeString): make it variadic
2016-12-13 Konstantin Tokarev <annulen@yandex.ru>
Unreviewed, silence -Wsuggest-attribute for GCC with pragmas
* wtf/PrintStream.cpp:
(WTF::PrintStream::printfVariableFormat):
2016-12-12 Michael Saboff <msaboff@apple.com>
REGRESSION(r209653): speedometer crashes making virtual slow path tailcalls
https://bugs.webkit.org/show_bug.cgi?id=165748
Reviewed by Filip Pizlo.
Rolling back in r209653, r209654, r209663, and r209673.
* wtf/Platform.h:
2016-12-12 Commit Queue <commit-queue@webkit.org>
Unreviewed, rolling out r209703.
https://bugs.webkit.org/show_bug.cgi?id=165749
Broke Apple builds (Requested by annulen|home on #webkit).
Reverted changeset:
"Unreviewed, use WTF_ATTRIBUTE_PRINTF instead of clang pragma"
http://trac.webkit.org/changeset/209703
2016-12-12 Konstantin Tokarev <annulen@yandex.ru>
Unreviewed, use WTF_ATTRIBUTE_PRINTF instead of clang pragma
* wtf/PrintStream.cpp:
(WTF::PrintStream::printfVariableFormat):
* wtf/PrintStream.h:
2016-12-11 Konstantin Tokarev <annulen@yandex.ru>
Unreviewed, guarded clang pragma with COMPILER(CLANG) to fix -Werror
* wtf/PrintStream.cpp:
(WTF::PrintStream::printfVariableFormat):
2016-12-11 Filip Pizlo <fpizlo@apple.com>
Change to use #pragma once (requested by Darin Adler).
* wtf/RecursiveLockAdapter.h:
2016-12-11 Filip Pizlo <fpizlo@apple.com>
Change to use #pragma once (requested by Darin Adler).
* wtf/LockedPrintStream.h:
2016-12-10 Filip Pizlo <fpizlo@apple.com>
MarkedBlock::marksConveyLivenessDuringMarking should take into account collection scope
https://bugs.webkit.org/show_bug.cgi?id=165741
Reviewed by Saam Barati.
To find this bug, I needed to seriously beef up our logging infrastructure.
It's now the case that:
dataLog(...);
will print its output atomically. This happens with some careful magic:
- dataFile() is now a LockedPrintStream that locks around print().
- The lock is a recursive lock via RecursiveLockAdapter<>, so if the dump methods end
up calling back into dataLog() then it just works. This is important: say the dump()
calls a getter that itself does logging, maybe because it's encountering badness and
wants to report it before crashing).
- The lock is a WordLock so that ParkingLot and Lock can keep using dataLog() for
debugging. We probably won't need to debug WordLock anytime soon - the algorithm is
so simple.
- LockedPrintStream::print(...) causes the print callbacks of its arguments to run on
the underlying PrintStream, so that you don't need to do recursive lock acquisition
on each individual argument and whatever printing it does recursively.
* WTF.xcodeproj/project.pbxproj:
* wtf/CMakeLists.txt:
* wtf/DataLog.cpp:
(WTF::initializeLogFileOnce):
(WTF::initializeLogFile):
(WTF::dataFile):
* wtf/DataLog.h:
* wtf/LockedPrintStream.cpp: Added.
(WTF::LockedPrintStream::LockedPrintStream):
(WTF::LockedPrintStream::~LockedPrintStream):
(WTF::LockedPrintStream::vprintf):
(WTF::LockedPrintStream::flush):
(WTF::LockedPrintStream::begin):
(WTF::LockedPrintStream::end):
* wtf/LockedPrintStream.h: Added.
* wtf/PrintStream.cpp:
(WTF::PrintStream::printfVariableFormat):
(WTF::PrintStream::begin):
(WTF::PrintStream::end):
* wtf/PrintStream.h:
(WTF::PrintStream::atomically):
(WTF::PrintStream::print):
(WTF::PrintStream::println):
(WTF::PrintStream::printImpl):
(WTF::>::unpack):
(WTF::FormatImpl::FormatImpl):
(WTF::FormatImpl::dump):
(WTF::format):
(WTF::printInternal):
* wtf/RecursiveLockAdapter.h: Added.
(WTF::RecursiveLockAdapter::RecursiveLockAdapter):
(WTF::RecursiveLockAdapter::lock):
(WTF::RecursiveLockAdapter::unlock):
(WTF::RecursiveLockAdapter::tryLock):
(WTF::RecursiveLockAdapter::isLocked):
* wtf/WordLock.cpp:
* wtf/WordLock.h:
2016-12-11 Darin Adler <darin@apple.com>
Use std::vsnprintf instead of vasprintf
https://bugs.webkit.org/show_bug.cgi?id=165740
Reviewed by Sam Weinig.
* wtf/Platform.h: Remove HAVE_VASPRINTF.
* wtf/StringExtras.h: Change the vsnprintf workaround to be used only
in older versions of Visual Studio, since the problem it works around
was resolved in Visual Studio 2015.
2016-12-10 Commit Queue <commit-queue@webkit.org>
Unreviewed, rolling out r209653, r209654, r209663, and
r209673.
https://bugs.webkit.org/show_bug.cgi?id=165739
speedometer crashes (Requested by pizlo on #webkit).
Reverted changesets:
"JSVALUE64: Pass arguments in platform argument registers when
making JavaScript calls"
https://bugs.webkit.org/show_bug.cgi?id=160355
http://trac.webkit.org/changeset/209653
"Unreviewed build fix for 32 bit builds."
http://trac.webkit.org/changeset/209654
"Unreviewed build fix for the CLOOP after r209653"
http://trac.webkit.org/changeset/209663
"REGRESSION(r209653) Crash in CallFrameShuffler::snapshot()"
https://bugs.webkit.org/show_bug.cgi?id=165728
http://trac.webkit.org/changeset/209673
2016-12-10 Chris Dumez <cdumez@apple.com>
Avoid calling shrink() in the Vector destructor
https://bugs.webkit.org/show_bug.cgi?id=165675
Reviewed by Daniel Bates.
Avoid calling shrink() in the Vector destructor to avoid function call
overhead and unnecessarily reseting m_size to 0.
* wtf/Vector.h:
(WTF::Vector::~Vector):
(WTF::Vector::asanSetBufferSizeToFullCapacity):
(WTF::minCapacity>::asanSetBufferSizeToFullCapacity):
2016-12-09 Michael Saboff <msaboff@apple.com>
JSVALUE64: Pass arguments in platform argument registers when making JavaScript calls
https://bugs.webkit.org/show_bug.cgi?id=160355
Reviewed by Filip Pizlo.
Added a new build option ENABLE_VM_COUNTERS to enable JIT'able counters.
The default is for the option to be off.
* wtf/Platform.h:
Added ENABLE_VM_COUNTERS
2016-12-09 Geoffrey Garen <ggaren@apple.com>
Deploy OrdinalNumber in JSC::SourceCode
https://bugs.webkit.org/show_bug.cgi?id=165687
Reviewed by Michael Saboff.
* wtf/text/OrdinalNumber.h:
(WTF::OrdinalNumber::operator>): Added a >.
2016-12-09 Geoffrey Garen <ggaren@apple.com>
TextPosition and OrdinalNumber should be more like idiomatic numbers
https://bugs.webkit.org/show_bug.cgi?id=165678
Reviewed by Filip Pizlo.
* wtf/text/TextPosition.h:
(WTF::TextPosition::minimumPosition): Deleted. Just use the default
constructor. Other numbers use their default constructors to mean zero.
Any time you need a comment that says "used as a default value", that's
a pretty good indicator that it should be the default constructor.
2016-12-09 Geoffrey Garen <ggaren@apple.com>
Moved OrdinalNumber into its own file
https://bugs.webkit.org/show_bug.cgi?id=165663
Reviewed by Saam Barati.
* WTF.xcodeproj/project.pbxproj:
* wtf/text/OrdinalNumber.h: Copied from Source/WTF/wtf/text/TextPosition.h.
(WTF::TextPosition::TextPosition): Deleted.
(WTF::TextPosition::operator==): Deleted.
(WTF::TextPosition::operator!=): Deleted.
(WTF::TextPosition::minimumPosition): Deleted.
(WTF::TextPosition::belowRangePosition): Deleted.
* wtf/text/TextPosition.h:
(WTF::OrdinalNumber::fromZeroBasedInt): Deleted.
(WTF::OrdinalNumber::fromOneBasedInt): Deleted.
(WTF::OrdinalNumber::OrdinalNumber): Deleted.
(WTF::OrdinalNumber::zeroBasedInt): Deleted.
(WTF::OrdinalNumber::oneBasedInt): Deleted.
(WTF::OrdinalNumber::operator==): Deleted.
(WTF::OrdinalNumber::operator!=): Deleted.
(WTF::OrdinalNumber::first): Deleted.
(WTF::OrdinalNumber::beforeFirst): Deleted.
2016-12-08 David Kilzer <ddkilzer@apple.com>
Always check the return value of pthread_key_create()
<https://webkit.org/b/165274>
Reviewed by Darin Adler.
* wtf/ThreadIdentifierDataPthreads.cpp:
(WTF::ThreadIdentifierData::initializeOnce): Make the code more
readable by assigning a variable to the result of
pthread_key_create(). This matches the idiom used elsewhere.
2016-12-08 Keith Miller <keith_miller@apple.com>
Add 64-bit signed LEB decode method
https://bugs.webkit.org/show_bug.cgi?id=165630
Reviewed by Ryosuke Niwa.
Add int64 LEB decode and fix some 64-bit specific issues
with the decoder. There is also a fix where we would allow
LEBs with canonical length + 1 size that is fixed by this
patch.
* wtf/LEBDecoder.h:
(WTF::LEBDecoder::decodeUInt):
(WTF::LEBDecoder::decodeInt):
(WTF::LEBDecoder::decodeUInt32):
(WTF::LEBDecoder::decodeUInt64):
(WTF::LEBDecoder::decodeInt32):
(WTF::LEBDecoder::decodeInt64):
2016-12-08 Anders Carlsson <andersca@apple.com>
Defer sending Mach messages if the queue is full
https://bugs.webkit.org/show_bug.cgi?id=165622
rdar://problem/29518036
Reviewed by Brady Eidson.
Add new SPI.
* wtf/spi/darwin/XPCSPI.h:
2016-12-06 Filip Pizlo <fpizlo@apple.com>
Concurrent GC should be stable enough to land enabled on X86_64
https://bugs.webkit.org/show_bug.cgi?id=164990
Reviewed by Geoffrey Garen.
Adds the ability to say:
auto locker = holdLock(any type of lock)
Instead of having to say:
Locker<LockType> locker(locks of type LockType)
I think that we should use "auto locker = holdLock(lock)" as the default way that we acquire
locks unless we need to use a special locker type.
This also adds the ability to safepoint a lock. Safepointing a lock is basically a super fast
way of unlocking it fairly and then immediately relocking it - i.e. letting anyone who is
waiting to run without losing steam of there is noone waiting.
* wtf/Lock.cpp:
(WTF::LockBase::safepointSlow):
* wtf/Lock.h:
(WTF::LockBase::safepoint):
* wtf/LockAlgorithm.h:
(WTF::LockAlgorithm::safepointFast):
(WTF::LockAlgorithm::safepoint):
(WTF::LockAlgorithm::safepointSlow):
* wtf/Locker.h:
(WTF::AbstractLocker::AbstractLocker):
(WTF::Locker::tryLock):
(WTF::Locker::operator bool):
(WTF::Locker::Locker):
(WTF::Locker::operator=):
(WTF::holdLock):
(WTF::tryHoldLock):
2016-12-08 Chris Dumez <cdumez@apple.com>
Unreviewed, rolling out r209489.
Likely caused large regressions on JetStream, Sunspider and
Speedometer
Reverted changeset:
"Add system trace points for JavaScript VM entry/exit"
https://bugs.webkit.org/show_bug.cgi?id=165550
http://trac.webkit.org/changeset/209489
2016-12-07 Simon Fraser <simon.fraser@apple.com>
Add system trace points for JavaScript VM entry/exit
https://bugs.webkit.org/show_bug.cgi?id=165550
Reviewed by Tim Horton.
Add trace points for entry/exit into/out of the JS VM.
* wtf/SystemTracing.h:
2016-12-06 Alexey Proskuryakov <ap@apple.com>
Correct SDKROOT values in xcconfig files
https://bugs.webkit.org/show_bug.cgi?id=165487
rdar://problem/29539209
Reviewed by Dan Bernstein.
Fix suggested by Dan Bernstein.
* Configurations/DebugRelease.xcconfig:
2016-12-06 Michael Saboff <msaboff@apple.com>
REGRESSION(r209399): Causes crashes when dumping JIT disassembly
https://bugs.webkit.org/show_bug.cgi?id=165483
Reviewed by Geoffrey Garen.
Fixed the RELEASE_ASSERT() to check that the 6 character string is terminated by a null
character.
* wtf/SixCharacterHash.cpp:
(WTF::sixCharacterHashStringToInteger):
2016-12-04 Darin Adler <darin@apple.com>
Use ASCIICType more, and improve it a little bit
https://bugs.webkit.org/show_bug.cgi?id=165360
Reviewed by Sam Weinig.
* wtf/ASCIICType.h: Added declarations of all the functions to the top of the file,
so we have a list of what's available, not just a mix of that and the implementation.
* wtf/HexNumber.h:
(WTF::Internal::hexDigitsForMode): Moved lowerHexDigits and upperHexDigits
inside this function.
(WTF::appendByteAsHex): Use auto.
(WTF::placeByteAsHexCompressIfPossible): Ditto.
(WTF::placeByteAsHex): Ditto.
(WTF::appendUnsignedAsHex): Ditto.
(WTF::appendUnsigned64AsHex): Ditto.
(WTF::appendUnsignedAsHexFixedSize): Ditto.
(WTF::isHexDigit): Deleted.
(WTF::uncheckedHexDigit): Deleted.
(WTF::hexDigitValue): Deleted.
(WTF::uncheckedHexDigitValue): Deleted.
* wtf/SixCharacterHash.cpp:
(WTF::sixCharacterHashStringToInteger): Use isASCIIUpper, isASCIILower, and
isASCIIDigit. Also added some FIXMEs; for some reason this function uses
RELEASE_ASSERT to abort if the passed-in string is not six characters long,
and it's not clear to me why this is so critical to assert.
(WTF::integerToSixCharacterHashString): Moved the table inside this function,
obviating the need for a macro named TABLE.
* wtf/dtoa/bignum.cc:
(WTF::double_conversion::HexCharValue): Deleted.
(WTF::double_conversion::Bignum::AssignHexString): Use toASCIIHexValue.
* wtf/dtoa/double-conversion.cc:
(WTF::double_conversion::StringToDoubleConverter::StringToDouble): Use isASCIIDigit.
* wtf/text/StringBuilder.cpp:
(WTF::appendQuotedJSONStringInternal): Use upperNibbleToASCIIHexDigit and
lowerNibbleToASCIIHexDigit.
* wtf/text/StringImpl.cpp:
(WTF::StringImpl::convertToUppercaseWithoutLocale): Use toASCIIUpper.
Removed the workaround for a bug that was fixed in Visual Studio 2013.
2016-12-05 Joseph Pecoraro <pecoraro@apple.com>
REGRESSION(r208985): SafariForWebKitDevelopment Symbol Not Found looking for method with WTF::Optional
https://bugs.webkit.org/show_bug.cgi?id=165351
Reviewed by Yusuke Suzuki.
Include a slimmed down version of WTF::Optional which older versions
of Safari still depend on for a JavaScriptCore exported symbol.
To prevent misuse name it WTF::DeprecatedOptional and use it only in
the one instance it is needed.
* WTF.xcodeproj/project.pbxproj:
* wtf/DeprecatedOptional.h: Added.
(WTF::Optional::operator bool):
(WTF::Optional::value):
(WTF::Optional::asPtr):
2016-12-05 Konstantin Tokarev <annulen@yandex.ru>
Add __STDC_FORMAT_MACROS before inttypes.h is included
https://bugs.webkit.org/show_bug.cgi?id=165374
We need formatting macros like PRIu64 to be available in all places where
inttypes.h header is used. All these usages get inttypes.h definitions
via wtf/Assertions.h header, except SQLiteFileSystem.cpp where formatting
macros are not used anymore since r185129.
This patch fixes multiple build errors with MinGW and reduces number of
independent __STDC_FORMAT_MACROS uses in the code base.
Reviewed by Darin Adler.
* wtf/Assertions.h: Define __STDC_FORMAT_MACROS.
* wtf/StdLibExtras.h: Remove definition of PRId64 for Windows, as we
have __STDC_FORMAT_MACROS defined now.
2016-12-03 Yusuke Suzuki <utatane.tea@gmail.com>
Refactor SymbolImpl layout
https://bugs.webkit.org/show_bug.cgi?id=165247
Reviewed by Darin Adler.
This patch moves SymbolImpl initialization from StringImpl to SymbolImpl.
In SymbolImpl, we create the appropriate fields. At that time, these fields
should be aligned to the BufferSubstring StringImpl.
And we newly create the `m_flags` in SymbolImpl. Instead of using special
StringImpl::null(), we store s_flagIsNullSymbol flag here. In WTF, we have
the invariant that StringImpl::empty() is the only atomic empty string.
But StringImpl::null() breaks this invariant. Using a special flag is safer
way to represent the null Symbol `Symbol()`.
* WTF.xcodeproj/project.pbxproj:
* wtf/CMakeLists.txt:
* wtf/StdLibExtras.h:
(WTF::roundUpToMultipleOfImpl0):
(WTF::roundUpToMultipleOfImpl):
(WTF::roundUpToMultipleOf):
* wtf/text/StringImpl.cpp:
(WTF::StringImpl::~StringImpl):
(WTF::StringImpl::createSymbol): Deleted.
(WTF::StringImpl::createNullSymbol): Deleted.
* wtf/text/StringImpl.h:
(WTF::StringImpl::isAtomic):
(WTF::StringImpl::StringImpl):
(WTF::StringImpl::requiresCopy):
(WTF::StringImpl::isNullSymbol): Deleted.
(WTF::StringImpl::symbolAwareHash): Deleted.
(WTF::StringImpl::existingSymbolAwareHash): Deleted.
(WTF::StringImpl::null): Deleted.
(WTF::StringImpl::extractFoldedStringInSymbol): Deleted.
(WTF::StringImpl::symbolRegistry): Deleted.
(WTF::StringImpl::hashForSymbol): Deleted.
* wtf/text/StringStatics.cpp:
(WTF::StringImpl::nextHashForSymbol): Deleted.
* wtf/text/SymbolImpl.cpp: Copied from Source/WTF/wtf/text/SymbolRegistry.cpp.
(WTF::SymbolImpl::nextHashForSymbol):
(WTF::SymbolImpl::create):
(WTF::SymbolImpl::createNullSymbol):
* wtf/text/SymbolImpl.h:
(WTF::SymbolImpl::hashForSymbol):
(WTF::SymbolImpl::symbolRegistry):
(WTF::SymbolImpl::isNullSymbol):
(WTF::SymbolImpl::extractFoldedString):
(WTF::SymbolImpl::SymbolImpl):
(WTF::StringImpl::symbolAwareHash):
(WTF::StringImpl::existingSymbolAwareHash):
* wtf/text/SymbolRegistry.cpp:
(WTF::SymbolRegistry::~SymbolRegistry):
(WTF::SymbolRegistry::symbolForKey):
(WTF::SymbolRegistry::keyForSymbol):
* wtf/text/UniquedStringImpl.h:
(WTF::UniquedStringImpl::UniquedStringImpl):
2016-12-01 Yusuke Suzuki <utatane.tea@gmail.com>
Introduce StringImpl::StaticStringImpl with constexpr constructor
https://bugs.webkit.org/show_bug.cgi?id=165093
Reviewed by Darin Adler.
This patch adds new class, StringImpl::StaticStringImpl.
By using this class, we can easily create static StringImpls.
This class has constexpr constructor. You can initialize instances
of this class as global static variables without invoking global
constructors.
We already have similar system, StaticASCIILiteral. But using it
requires some special perl script since we need to calculate
hash value. On the other hand, we can use StaticStringImpl without
any script supports since we implement constexpr hash function.
In the future, we will replace all the use of StaticASCIILiteral
with this StaticStringImpl.
We define empty / null strings as StaticStringImpl. And we make
StringImpl::empty() & StringImpl::null() inline functions.
* wtf/Hasher.h:
(WTF::StringHasher::hashWithTop8BitsMasked):
(WTF::StringHasher::hash):
(WTF::StringHasher::finalize):
(WTF::StringHasher::finalizeAndMaskTop8Bits):
(WTF::StringHasher::computeLiteralHash):
(WTF::StringHasher::computeLiteralHashAndMaskTop8Bits):
(WTF::StringHasher::avalancheBits3):
(WTF::StringHasher::avalancheBits2):
(WTF::StringHasher::avalancheBits1):
(WTF::StringHasher::avalancheBits0):
(WTF::StringHasher::avalancheBits):
(WTF::StringHasher::avoidZero):
(WTF::StringHasher::processPendingCharacter):
(WTF::StringHasher::calculateWithRemainingLastCharacter1):
(WTF::StringHasher::calculateWithRemainingLastCharacter0):
(WTF::StringHasher::calculateWithRemainingLastCharacter):
(WTF::StringHasher::calculate1):
(WTF::StringHasher::calculate0):
(WTF::StringHasher::calculate):
(WTF::StringHasher::computeLiteralHashImpl):
* wtf/text/StringImpl.cpp:
* wtf/text/StringImpl.h:
(WTF::StringImpl::StaticStringImpl::StaticStringImpl):
(WTF::StringImpl::null):
(WTF::StringImpl::empty):
* wtf/text/StringStatics.cpp:
(WTF::StringImpl::null): Deleted.
(WTF::StringImpl::empty): Deleted.
2016-11-30 Darin Adler <darin@apple.com>
Roll out StringBuilder changes from the previous patch.
They were a slowdown on a Kraken JSON test.
* wtf/text/StringBuilder.cpp:
* wtf/text/StringBuilder.h:
Roll out changes from below.
2016-11-30 Darin Adler <darin@apple.com>
Streamline and speed up tokenizer and segmented string classes
https://bugs.webkit.org/show_bug.cgi?id=165003
And do it without re-introducing:
REGRESSION (r209058): API test StringBuilderTest.Equal crashing
https://bugs.webkit.org/show_bug.cgi?id=165142
Reviewed by Sam Weinig.
* wtf/text/StringBuilder.cpp:
(WTF::StringBuilder::bufferCharacters<LChar>): Moved this here from
the header since it is only used inside the class. Also renamed from
getBufferCharacters.
(WTF::StringBuilder::bufferCharacters<UChar>): Ditto.
(WTF::StringBuilder::appendUninitializedUpconvert): Added. Helper
for the upconvert case in the 16-bit overload of StrinBuilder::append.
(WTF::StringBuilder::append): Changed to use appendUninitializedUpconvert.
(WTF::quotedJSONStringLength): Added. Used in new appendQuotedJSONString
implementation below that now correctly determines the size of what will
be appended by walking thorugh the string twice.
(WTF::appendQuotedJSONStringInternal): Moved the code that writes the
quote marks in here. Also made a few coding style tweaks.
(WTF::StringBuilder::appendQuotedJSONString): Rewrote to use a much
simpler algorithm that grows the string the same way the append function
does. The old code would use reserveCapacity in a way that was costly when
doing a lot of appends on the same string, and also allocated far too much
memory for normal use cases where characters did not need to be turned
into escape sequences.
* wtf/text/StringBuilder.h:
(WTF::StringBuilder::append): Tweaked style a bit, fixed a bug where the
m_is8Bit field wasn't set correctly in one case, optimized the function that
adds substrings for the case where this is the first append and the substring
happens to cover the entire string. Also clarified the assertions and removed
an unneeded check from that substring overload.
(WTF::equal): Reimplemented, using equalCommon. Added an overload of the equal
function just for the case where the arguments are StringBuilder, String.
This is needed because of the peculiar behavior of is8Bit in String, different
from any of our other string classes. I think we should consider changing
String::is8Bit to return true for null strings. We could then remove this
overload and probably remove other checks for null and zero length elsewhere
that are also needed only to avoid calling is8Bit on a null String.
2016-11-29 JF Bastien <jfbastien@apple.com>
WebAssembly JS API: improve Instance
https://bugs.webkit.org/show_bug.cgi?id=164757
Reviewed by Keith Miller.
* wtf/Expected.h:
(WTF::ExpectedDetail::destroy): silence a warning
2016-11-29 Commit Queue <commit-queue@webkit.org>
Unreviewed, rolling out r209058 and r209074.
https://bugs.webkit.org/show_bug.cgi?id=165188
These changes caused API test StringBuilderTest.Equal to crash
and/or fail. (Requested by ryanhaddad on #webkit).
Reverted changesets:
"Streamline and speed up tokenizer and segmented string
classes"
https://bugs.webkit.org/show_bug.cgi?id=165003
http://trac.webkit.org/changeset/209058
"REGRESSION (r209058): API test StringBuilderTest.Equal
crashing"
https://bugs.webkit.org/show_bug.cgi?id=165142
http://trac.webkit.org/changeset/209074
2016-11-29 Simon Fraser <simon.fraser@apple.com>
Allow TracePoint to take arbitrary data
https://bugs.webkit.org/show_bug.cgi?id=165182
Reviewed by Tim Horton.
Allow TracePoint() to take four numeric arguments, for arbitrary data.
#pragma once
* wtf/SystemTracing.h:
(WTF::TracePoint):
2016-11-29 Andy Estes <aestes@apple.com>
[Cocoa] Enable two clang warnings recommended by Xcode
https://bugs.webkit.org/show_bug.cgi?id=164498
Reviewed by Mark Lam.
* Configurations/Base.xcconfig: Enabled CLANG_WARN_INFINITE_RECURSION and CLANG_WARN_SUSPICIOUS_MOVE.
2016-11-29 Darin Adler <darin@apple.com>
REGRESSION (r209058): API test StringBuilderTest.Equal crashing
https://bugs.webkit.org/show_bug.cgi?id=165142
* wtf/text/StringBuilder.h: Added an overload of the equal function just
for the case where the arguments are StringBuilder, String. This is needed
because of the peculiar behavior of is8Bit in String, different from any of
our other string classes. I think we should consider changing String::is8Bit
to return true for null strings. We could then remove this overload and
probably remove other checks for null and zero length elsewhere that are
also needed only to avoid calling is8Bit on a null String.
2016-11-29 Wenson Hsieh <wenson_hsieh@apple.com>
Scroll snapping on Mac should use AppKit animations
https://bugs.webkit.org/show_bug.cgi?id=147261
<rdar://problem/29395293>
Reviewed by Brent Fulgham.
Introduce HAVE(NSSCROLLING_FILTERS), which is on for macOS El Capitan and later.
* wtf/Platform.h:
2016-11-28 Darin Adler <darin@apple.com>
Streamline and speed up tokenizer and segmented string classes
https://bugs.webkit.org/show_bug.cgi?id=165003
Reviewed by Sam Weinig.
* wtf/text/StringBuilder.cpp:
(WTF::StringBuilder::bufferCharacters<LChar>): Moved this here from
the header since it is only used inside the class. Also renamed from
getBufferCharacters.
(WTF::StringBuilder::bufferCharacters<UChar>): Ditto.
(WTF::StringBuilder::appendUninitializedUpconvert): Added. Helper
for the upconvert case in the 16-bit overload of StrinBuilder::append.
(WTF::StringBuilder::append): Changed to use appendUninitializedUpconvert.
(WTF::quotedJSONStringLength): Added. Used in new appendQuotedJSONString
implementation below that now correctly determines the size of what will
be appended by walking thorugh the string twice.
(WTF::appendQuotedJSONStringInternal): Moved the code that writes the
quote marks in here. Also made a few coding style tweaks.
(WTF::StringBuilder::appendQuotedJSONString): Rewrote to use a much
simpler algorithm that grows the string the same way the append function
does. The old code would use reserveCapacity in a way that was costly when
doing a lot of appends on the same string, and also allocated far too much
memory for normal use cases where characters did not need to be turned
into escape sequences.
* wtf/text/StringBuilder.h:
(WTF::StringBuilder::append): Tweaked style a bit, fixed a bug where the
m_is8Bit field wasn't set correctly in one case, optimized the function that
adds substrings for the case where this is the first append and the substring
happens to cover the entire string. Also clarified the assertions and removed
an unneeded check from that substring overload.
(WTF::equal): Reimplemented, using equalCommon.
2016-11-26 Yusuke Suzuki <utatane.tea@gmail.com>
[WTF] Import std::optional reference implementation as WTF::Optional
https://bugs.webkit.org/show_bug.cgi?id=164199
Reviewed by Saam Barati and Sam Weinig.
Import std::optional reference implementation offered by the C++17
original proposal paper. It has the same interface and functionality
to the C++17's one. Previous WTF::Optional lacks several functionalities.
The largest one is the correct constexpr constructors. This fact prevents
us from using Optional<literal type> in constexpr context in WebKit.
In WebKit, we do not allow global constructors. So only the constexpr
constructor is the way to use WTF::Optional in the static const
global variables. WTF::Optional is used in DOMJIT::Effect and
we would like to emit static const global variables that includes
this DOMJIT::Effect. That is the main motivation of this work.
This functionality allows the IDL code generator to emit DOMJIT
signatures as static const global variables.
We import the reference implementation one instead of LLVM libc++'s one.
This is because LLVM libc++'s one depends on many macro and type_traits
offered by libc++ implementation. And adopting it to WebKit requires
large modification compared to this reference implementation one.
Furthermore, it is difficult to compile libc++'s optional in old GCC and VC++.
It also requires some more modifications. To keep the thing simple,
we import the reference implementation one now. Once C++17 is released
and we update the compiler baseline, we can smoothly switch to the standard
library's std::optional.
We also add support for the environment that does not use exceptions to this
reference implementation.
And we also add valueOrCompute helper function. That keeps the extended
functionality that previous WTF::Optional has.
* wtf/CrossThreadQueue.h:
(WTF::CrossThreadQueue<DataType>::tryGetMessage):
* wtf/Expected.h:
(WTF::makeExpected):
* wtf/Forward.h:
* wtf/HashTraits.h:
(WTF::HashTraits<Ref<P>>::take):
* wtf/MainThread.cpp:
(WTF::initializeGCThreads):
(WTF::mayBeGCThread):
* wtf/MainThread.h:
* wtf/Optional.h:
(std::detail_::is_assignable::has_assign):
(std::detail_::has_overloaded_addressof::has_overload):
(std::detail_::static_addressof):
(std::detail_::convert):
(std::nullopt_t::nullopt_t):
(std::bad_optional_access::bad_optional_access):
(std::optional_base::optional_base):
(std::optional_base::~optional_base):
(std::constexpr_optional_base::constexpr_optional_base):
(std::optional::dataptr):
(std::optional::contained_val):
(std::optional::__NOEXCEPT_):
(std::optional::optional):
(std::optional::operator=):
(std::optional::emplace):
(std::optional::operator ->):
(std::optional::operator *):
(std::optional::value):
(std::optional::value_or):
(std::operator==):
(std::operator!=):
(std::operator<):
(std::operator>):
(std::operator<=):
(std::operator>=):
(std::__NOEXCEPT_):
(std::make_optional):
(std::hash<std::optional<T>>::operator()):
(WTF::NulloptTag::NulloptTag): Deleted.
(WTF::Optional::Optional): Deleted.
(WTF::Optional::~Optional): Deleted.
(WTF::Optional::operator=): Deleted.
(WTF::Optional::operator bool): Deleted.
(WTF::Optional::operator->): Deleted.
(WTF::Optional::operator*): Deleted.
(WTF::Optional::value): Deleted.
(WTF::Optional::valueOr): Deleted.
(WTF::Optional::valueOrCompute): Deleted.
(WTF::Optional::asPtr): Deleted.
(WTF::Optional::destroy): Deleted.
(WTF::operator==): Deleted.
(WTF::operator!=): Deleted.
(WTF::makeOptional): Deleted.
(WTF::printInternal): Deleted.
* wtf/text/StringView.cpp:
(WTF::StringView::GraphemeClusters::Iterator::Impl::Impl):
(WTF::StringView::GraphemeClusters::Iterator::Iterator):
* wtf/text/StringView.h:
2016-11-26 Simon Fraser <simon.fraser@apple.com>
Migrate some layout timer-related code from std::chrono to Seconds and MonotonicTime
https://bugs.webkit.org/show_bug.cgi?id=164992
Reviewed by Darin Adler.
Add Seconds::zero() as a nicer way to express Seconds(0).
* wtf/Seconds.h:
(WTF::Seconds::zero):
2016-11-26 Simon Fraser <simon.fraser@apple.com>
Add literals for various time units
https://bugs.webkit.org/show_bug.cgi?id=165074
Reviewed by Filip Pizlo.
Add _min, _s, _ms, _us and _ns literals for easy creation of Seconds from long double
and unsigned long long types (those allowed for custom literals).
Add minutes-related functions (there are one or two use cases in WebCore).
* wtf/Seconds.h:
(WTF::Seconds::minutes):
(WTF::Seconds::fromMinutes):
(WTF::Seconds::fromMilliseconds):
(WTF::Seconds::fromMicroseconds):
(WTF::Seconds::fromNanoseconds):
(WTF::operator _min):
(WTF::operator _s):
(WTF::operator _ms):
(WTF::operator _us):
(WTF::operator _ns):
2016-11-22 Darin Adler <darin@apple.com>
One more tiny bit of follow-up.
* wtf/text/TextBreakIterator.cpp:
(WTF::numCharactersInGraphemeClusters): Removed unneeded always-true check.
2016-11-22 Darin Adler <darin@apple.com>
Quick follow-up to previous patch.
* wtf/text/TextBreakIterator.cpp:
(WTF::numCharactersInGraphemeClusters): Removed incorrect assertion.
2016-11-22 Darin Adler <darin@apple.com>
Make normal case fast in the input element limitString function
https://bugs.webkit.org/show_bug.cgi?id=165023
Reviewed by Dan Bernstein.
* wtf/text/LineBreakIteratorPoolICU.h: Removed many unneeded includes.
Simplified the class a bit, removing some extra definitions.
(WTF::LineBreakIteratorPool::sharedPool): Use NeverDestroyed instead of new.
(WTF::LineBreakIteratorPool::makeLocaleWithBreakKeyword): Reimplemented in
a simpler way without using StringBuilder. Also updated for change to
LineBreakIteratorMode.
(WTF::LineBreakIteratorPool::put): Use uncheckedAppend since the code is
careful to only use the inline capacity in the vector.
* wtf/text/TextBreakIterator.cpp: Moved some includes in here from the header.
(WTF::mapLineIteratorModeToRules): Updated for change to LineBreakIteratorMode.
(WTF::openLineBreakIterator): Ditto.
(WTF::numGraphemeClusters): Added a fast path for all 8-bit strings; don't
use ICU for that case, even if there is a CR character in it.
(WTF::numCharactersInGraphemeClusters): Added a fast path for strings that are
short enough to entirely fit without even looking at the characters; that's a
case we likely hit all the time. Also added a fast path for all 8-bit strings.
* wtf/text/TextBreakIterator.h: Changed LineBreakIteratorMode to be an enum
class and not repeat UAX14 in the names of the modes. Initialize data members
in the class definition rather than the constructors.
2016-11-21 Mark Lam <mark.lam@apple.com>
Hasher::addCharacters() should be able to handle zero length strings.
https://bugs.webkit.org/show_bug.cgi?id=165024
Reviewed by Yusuke Suzuki.
Currently, it will fail to handle zero length strings if it has a pending
character. The fix is simply to return early if length is 0.
* wtf/Hasher.h:
(WTF::StringHasher::addCharacters):
2016-11-18 Jeremy Jones <jeremyj@apple.com>
Add runtime flag to enable pointer lock. Enable pointer lock feature for mac.
https://bugs.webkit.org/show_bug.cgi?id=163801
Reviewed by Simon Fraser.
* wtf/FeatureDefines.h: ENABLE_POINTER_LOCK true for Mac.
2016-11-17 Saam Barati <sbarati@apple.com>
Remove async/await compile time flag and enable tests
https://bugs.webkit.org/show_bug.cgi?id=164828
<rdar://problem/28639334>
Reviewed by Yusuke Suzuki.
* wtf/FeatureDefines.h:
2016-11-17 Yusuke Suzuki <utatane.tea@gmail.com>
[JSC] WTF::TemporaryChange with WTF::SetForScope
https://bugs.webkit.org/show_bug.cgi?id=164761
Reviewed by Saam Barati.
JavaScriptCore's bytecompiler/SetForScope.h is completely the same
to WTF::TemporaryChange. SetForScope sounds better name since it
says that this object works as Scope.
We rename WTF::TemporaryChange to WTF::SetForScope. And replace
all the use to this WTF::SetForScope.
* WTF.xcodeproj/project.pbxproj:
* wtf/SetForScope.h: Renamed from Source/WTF/wtf/TemporaryChange.h.
(WTF::SetForScope::SetForScope):
(WTF::SetForScope::~SetForScope):
2016-11-16 Yusuke Suzuki <utatane.tea@gmail.com>
[ES6][WebCore] Change ES6_MODULES compile time flag to runtime flag
https://bugs.webkit.org/show_bug.cgi?id=164827
Reviewed by Ryosuke Niwa.
* wtf/FeatureDefines.h:
2016-11-16 Carlos Alberto Lopez Perez <clopez@igalia.com>
[JSC] Build broken for 32-bit x86 after r208306 with GCC 4.9
https://bugs.webkit.org/show_bug.cgi?id=164588
Reviewed by Mark Lam.
Provide assembly for executing the cpuid instruction when compiling
in PIC mode with the GCC 4.9 EBX on 32-bit x86.
Note that the values returned by cpuid here are not used. The purpose
of calling this instruction is to force the CPU to complete and sync
any buffered modifications on registers, memory or flags before
fetching and executing the next instruction.
* wtf/Atomics.h:
(WTF::x86_cpuid):
2016-11-15 Filip Pizlo <fpizlo@apple.com>
Rename CONCURRENT_JIT/ConcurrentJIT to CONCURRENT_JS/ConcurrentJS
https://bugs.webkit.org/show_bug.cgi?id=164791
Reviewed by Geoffrey Garen.
Both the concurrent GC and the concurrent JIT rely on concurrency support in fundamental
JSC runtime components like JSValue. So, the thing that guards it should be a "feature"
called CONCURRENT_JS not CONCURRENT_JIT.
* wtf/Platform.h:
2016-11-15 Filip Pizlo <fpizlo@apple.com>
The concurrent GC should have a timeslicing controller
https://bugs.webkit.org/show_bug.cgi?id=164783
Reviewed by Geoffrey Garen.
* wtf/LockAlgorithm.h: Added some comments.
* wtf/Seconds.h: Added support for modulo. It's necessary for timeslicing.
(WTF::Seconds::operator%):
(WTF::Seconds::operator%=):
2016-11-11 Filip Pizlo <fpizlo@apple.com>
The GC should be optionally concurrent and disabled by default
https://bugs.webkit.org/show_bug.cgi?id=164454
Reviewed by Geoffrey Garen.
The reason why I went to such great pains to make WTF::Lock fit in two bits is that I
knew that I would eventually need to stuff one into some miscellaneous bits of the
JSCell header. That time has come, because the concurrent GC has numerous race
conditions in visitChildren that can be trivially fixed if each object just has an
internal lock. Some cell types might use it to simply protect their entire visitChildren
function and anything that mutates the fields it touches, while other cell types might
use it as a "lock of last resort" to handle corner cases of an otherwise wait-free or
lock-free algorithm. Right now, it's used to protect certain transformations involving
indexing storage.
To make this happen, I factored the WTF::Lock algorithm into a LockAlgorithm struct that
is templatized on lock type (uint8_t for WTF::Lock), the isHeldBit value (1 for
WTF::Lock), and the hasParkedBit value (2 for WTF::Lock). This could have been done as
a templatized Lock class that basically contains Atomic<LockType>. You could then make
any field into a lock by bitwise_casting it to TemplateLock<field type, bit1, bit2>. But
this felt too dirty, so instead, LockAlgorithm has static methods that take
Atomic<LockType>& as their first argument. I think that this makes it more natural to
project a LockAlgorithm onto an existing Atomic<> field. Sadly, some places have to cast
their non-Atomic<> field to Atomic<> in order for this to work. Like so many other things
we do, this just shows that the C++ style of labeling fields that are subject to atomic
ops as atomic is counterproductive. Maybe some day I'll change LockAlgorithm to use our
other Atomics API, which does not require Atomic<>.
WTF::Lock now uses LockAlgorithm. The slow paths are still outlined. I don't feel too
bad about the LockAlgorithm.h header being included in so many places because we change
that algorithm so infrequently.
Also, I added a hasElapsed(time) function. This function makes it so much more natural
to write timeslicing code, which the concurrent GC has to do a lot of.
* WTF.xcodeproj/project.pbxproj:
* wtf/CMakeLists.txt:
* wtf/ListDump.h:
* wtf/Lock.cpp:
(WTF::LockBase::lockSlow):
(WTF::LockBase::unlockSlow):
(WTF::LockBase::unlockFairlySlow):
(WTF::LockBase::unlockSlowImpl): Deleted.
* wtf/Lock.h:
(WTF::LockBase::lock):
(WTF::LockBase::tryLock):
(WTF::LockBase::unlock):
(WTF::LockBase::unlockFairly):
(WTF::LockBase::isHeld):
(): Deleted.
* wtf/LockAlgorithm.h: Added.
(WTF::LockAlgorithm::lockFastAssumingZero):
(WTF::LockAlgorithm::lockFast):
(WTF::LockAlgorithm::lock):
(WTF::LockAlgorithm::tryLock):
(WTF::LockAlgorithm::unlockFastAssumingZero):
(WTF::LockAlgorithm::unlockFast):
(WTF::LockAlgorithm::unlock):
(WTF::LockAlgorithm::unlockFairly):
(WTF::LockAlgorithm::isLocked):
(WTF::LockAlgorithm::lockSlow):
(WTF::LockAlgorithm::unlockSlow):
* wtf/TimeWithDynamicClockType.cpp:
(WTF::hasElapsed):
* wtf/TimeWithDynamicClockType.h:
2016-11-14 JF Bastien <jfbastien@apple.com>
Expected: add missing `inline`
https://bugs.webkit.org/show_bug.cgi?id=164735
Reviewed by Yusuke Suzuki.
Free functions and full template specializations need to be
`inline`, or in a .cpp file, otherwise each .o creates a duplicate
symbol which makes the linker very sad.
* wtf/Expected.h:
(WTF::ExpectedDetail::Throw):
(WTF::makeExpected):
2016-11-14 Mark Lam <mark.lam@apple.com>
Build fix after r208690.
https://bugs.webkit.org/show_bug.cgi?id=164681
Not reviewed.
* wtf/FastMalloc.h:
2016-11-13 Mark Lam <mark.lam@apple.com>
Add debugging facility to limit the max single allocation size.
https://bugs.webkit.org/show_bug.cgi?id=164681
Reviewed by Keith Miller.
This is useful for simulating memory allocation failures on resource constraint
devices for testing purposes.
This facility is only conditionally compiled in on debug builds. It does not
have any burden on release builds at all. When in use, the max single allocation
size limit applies to individual allocations. For malloc (and similar), the
allocation will crash in FastMalloc if the requested size exceeds the set max
single allocation size. For tryMalloc (and similar), the allocation returns
nullptr if the requested size exceeds the set max single allocation size. The
max single allocation size is set to std::numeric_limit<size_t>::max() by default
(i.e. when not set and no limit is in effect).
Also fixed non-bmalloc versions of fastAlignedMalloc() to crash when allocation
fails.
* wtf/FastMalloc.cpp:
(WTF::fastSetMaxSingleAllocationSize):
(WTF::fastAlignedMalloc):
(WTF::tryFastAlignedMalloc):
(WTF::tryFastMalloc):
(WTF::fastMalloc):
(WTF::tryFastCalloc):
(WTF::fastCalloc):
(WTF::fastRealloc):
* wtf/FastMalloc.h:
2016-11-13 JF Bastien <jfbastien@apple.com>
Implement WTF::Expected
https://bugs.webkit.org/show_bug.cgi?id=164526
Reviewed by Yusuke Suzuki.
std::expected isn't in C++17, and may be in C++20. It's a nice
complement to std::any / std::optional because it's a type-tagged
union which has a single expected result but could also contain an
error.
This would be useful in the WebAssembly parser, for example.
Using this implementation will allow us to provide feedback to the
standards committee and guide std::expected's design before it
gets standardized. I've already sent a bunch of feedback to the
author based on my experience implementing this.
This could supplement WTF::Either and WTF::ExceptionOr.
* WTF.xcodeproj/project.pbxproj:
* wtf/Compiler.h: Add RELAXED_CONSTEXPR
* wtf/Expected.h: Added.
(WTF::UnexpectedType::UnexpectedType):
(WTF::UnexpectedType::value):
(WTF::operator==):
(WTF::operator!=):
(WTF::operator<):
(WTF::operator>):
(WTF::operator<=):
(WTF::operator>=):
(WTF::makeUnexpected):
(WTF::ExpectedDetail::Throw):
(WTF::ExpectedDetail::ConstexprBase::ConstexprBase):
(WTF::ExpectedDetail::Base::Base):
(WTF::ExpectedDetail::Base::~Base):
(WTF::Expected::Expected):
(WTF::Expected::operator=):
(WTF::Expected::swap):
(WTF::Expected::operator->):
(WTF::Expected::operator*):
(WTF::Expected::operator bool):
(WTF::Expected::hasValue):
(WTF::Expected::value):
(WTF::Expected::error):
(WTF::Expected::getUnexpected):
(WTF::Expected::valueOr):
(WTF::swap):
(WTF::makeExpected):
(WTF::makeExpectedFromError):
2016-11-11 Alex Christensen <achristensen@webkit.org>
Allow mutable lambdas in HashMap::ensure
https://bugs.webkit.org/show_bug.cgi?id=164642
Reviewed by Sam Weinig.
* wtf/HashMap.h:
(WTF::HashMapEnsureTranslator::translate):
(WTF::X>::removeIf):
2016-11-11 Beth Dakin <bdakin@apple.com>
Get touch bar code building for open source builds
https://bugs.webkit.org/show_bug.cgi?id=164610
Reviewed by Wenson Hsieh.
* wtf/Platform.h:
2016-11-10 JF Bastien <jfbastien@apple.com>
ASSERTION FAILED: length > offset encountered with wasm.yaml/wasm/js-api/test_Module.js.default-wasm
https://bugs.webkit.org/show_bug.cgi?id=164597
Reviewed by Keith Miller.
Decoding at end of file should fail, not assert.
* wtf/LEBDecoder.h:
(WTF::LEBDecoder::decodeUInt):
(WTF::LEBDecoder::decodeInt32):
2016-11-10 Alex Christensen <achristensen@webkit.org>
Remove unused CFURLCACHE code
https://bugs.webkit.org/show_bug.cgi?id=164551
Reviewed by Antti Koivisto.
* wtf/Platform.h:
2016-11-09 Alex Christensen <achristensen@webkit.org>
Allow RefPtrs of const ThreadSafeRefCounted types
https://bugs.webkit.org/show_bug.cgi?id=164548
Reviewed by Tim Horton.
* wtf/ThreadSafeRefCounted.h:
Make m_refCount mutable like we did with RefCounted in r203257.
2016-11-09 Chris Dumez <cdumez@apple.com>
[Mac] Stop using deprecated AppKit enumeration values
https://bugs.webkit.org/show_bug.cgi?id=164494
Reviewed by Darin Adler.
Stop using deprecated AppKit enumeration values.
* wtf/mac/AppKitCompatibilityDeclarations.h:
2016-11-05 Konstantin Tokarev <annulen@yandex.ru>
Fixed compilation of LLInt with MinGW
https://bugs.webkit.org/show_bug.cgi?id=164449
Reviewed by Michael Catanzaro.
MinGW uses LLIntAssembly.h with GNU assembler syntax, just like GCC on
other platforms.
* wtf/InlineASM.h: Define LOCAL_LABEL_STRING as .L#name for MinGW.
2016-11-05 Konstantin Tokarev <annulen@yandex.ru>
[MinGW] Fixed C99/C++11 format attributes in printf-like functions
https://bugs.webkit.org/show_bug.cgi?id=164448
Reviewed by Michael Catanzaro.
By default MinGW uses printf-like function provided in msvcrt.dll,
however they miss support for C99/C++11 format attributes. Use MinGW
implementations instead.
* wtf/Assertions.h: Use gnu_printf format in WTF_ATTRIBUTE_PRINTF
2016-11-05 Yusuke Suzuki <utatane.tea@gmail.com>
[JSCOnly] RunLoopGeneric should adopt MonotonicTime / WallTime change
https://bugs.webkit.org/show_bug.cgi?id=164447
Reviewed by Csaba Osztrogonác.
Build fix for JSCOnly.
* wtf/generic/RunLoopGeneric.cpp:
(WTF::RunLoop::TimerBase::ScheduledTask::create):
(WTF::RunLoop::TimerBase::ScheduledTask::ScheduledTask):
(WTF::RunLoop::TimerBase::ScheduledTask::scheduledTimePoint):
(WTF::RunLoop::TimerBase::ScheduledTask::updateReadyTime):
(WTF::RunLoop::populateTasks):
(WTF::RunLoop::dispatchAfter):
(WTF::RunLoop::TimerBase::start):
2016-11-04 Filip Pizlo <fpizlo@apple.com>
WTF::ParkingLot should stop using std::chrono because std::chrono::duration casts are prone to overflows
https://bugs.webkit.org/show_bug.cgi?id=152045
Reviewed by Andy Estes.
We used to use 'double' for all time measurements. Sometimes it was milliseconds,
sometimes it was seconds. Sometimes we measured a span of time, sometimes we spoke of time
since some epoch. When we spoke of time since epoch, we either used a monotonic clock or
a wall clock. The type - always 'double' - never told us what kind of time we had, even
though there were roughly six of them (sec interval, ms interval, sec since epoch on wall,
ms since epoch on wall, sec since epoch monotonic, ms since epoch monotonic).
At some point, we thought that it would be a good idea to replace these doubles with
std::chrono. But since replacing some things with std::chrono, we found it to be terribly
inconvenient:
- Outrageous API. I never want to say std::chrono::milliseconds(blah). I never want to say
std::chrono::steady_clock::timepoint. The syntax for duration_cast is ugly, and ideally
duration_cast would not even be a thing.
- No overflow protection. std::chrono uses integers by default and using anything else is
clumsy. But the integer math is done without regard for the rough edges of integer math,
so any cast between std::chrono types risks overflow. Any comparison risks overflow
because it may do conversions silently. We have even found bugs where some C++
implementations had more overflows than others, which ends up being a special kind of
hell. In many cases, the overflow also has nasal demons.
It's an error to represent time using integers. It would have been excusable back when
floating point math was not guaranteed to be supported on all platforms, but that would
have been a long time ago. Time is a continuous, infinite concept and it's a perfect fit
for floating point:
- Floating point preserves precision under multiplication in all but extreme cases, so
using floating point for time means that unit conversions are almost completely
lossless. This means that we don't have to think very hard about what units to use. In
this patch, we use seconds almost everywhere. We only convert at boundaries, like an API
boundary that wants something other than seconds.
- Floating point makes it easy to reason about infinity, which is something that time code
wants to do a lot. Example: when would you like to timeout? Infinity please! This is the
most elegant way of having an API support both a timeout variant and a no-timeout
variant.
- Floating point does well-understood things when math goes wrong, and these things are
pretty well optimized to match what a mathematician would do when computing with real
numbers represented using scientific notation with a finite number of significant
digits. This means that time math under floating point looks like normal math. On the
other hand, std::chrono time math looks like garbage because you have to always check
for multiple possible UB corners whenever you touch large integers. Integers that
represent time are very likely to be large and you don't have to do much to overflow
them. At this time, based on the number of bugs we have already seen due to chrono
overflows, I am not certain that we even understand what are all of the corner cases
that we should even check for.
This patch introduces a new set of timekeeping classes that are all based on double, and
all internally use seconds. These classes support algebraic typing. The classes are:
- Seconds: this is for measuring a duration.
- WallTime: time since epoch according to a wall clock (aka real time clock).
- MonotonicTime: time since epoch according to a monotonic clock.
- ClockType: enum that says either Wall or Monotonic.
- TimeWithDynamicClockType: a tuple of double and ClockType, which represents either a
wall time or a monotonic time.
All of these classes behave like C++ values and are cheap to copy around since they are
very nearly POD. This supports comprehensive conversions between the various time types.
Most of this is by way of algebra. Here are just some of the rules we recognize:
WallTime = WallTime + Seconds
Seconds = WallTime - WallTime
MonotonicTime = MonotonicTime + Seconds
etc...
We support negative, infinite, and NaN times because math.
We support conversions between MonotonicTime and WallTime, like:
WallTime wt = mt.approximateWallTime()
This is called this "approximate" because the only way to do it is to get the current time
on both clocks and convert relative to that.
Many of our APIs would be happy using whatever notion of time the user wanted to use. For
those APIs, which includes Condition and ParkingLot, we have TimeWithDynamicClockType. You
can automatically convert WallTime or MonotonicTime to TimeWithDynamicClockType. This
means that if you use a WallTime with Condition::waitUntil, then Condition's internal
logic for when it should wake up makes its decision based on the current WallTime - but if
you use MonotonicTime then waitUntil will make its decision based on current
MonotonicTime. This is a greater level of flexibility than chrono allowed, since chrono
did not have the concept of a dynamic clock type.
This patch does not include conversions between std::chrono and these new time classes,
because past experience shows that we're quite bad at getting conversions between
std::chrono and anything else right. Also, I didn't need such conversion code because this
patch only converts code that transitively touches ParkingLot and Condition. It was easy
to get all of that code onto the new time classes.
* WTF.xcodeproj/project.pbxproj:
* wtf/AutomaticThread.cpp:
(WTF::AutomaticThread::start):
* wtf/CMakeLists.txt:
* wtf/ClockType.cpp: Added.
(WTF::printInternal):
* wtf/ClockType.h: Added.
* wtf/Condition.h:
(WTF::ConditionBase::waitUntil):
(WTF::ConditionBase::waitFor):
(WTF::ConditionBase::wait):
(WTF::ConditionBase::waitUntilWallClockSeconds): Deleted.
(WTF::ConditionBase::waitUntilMonotonicClockSeconds): Deleted.
(WTF::ConditionBase::waitForSeconds): Deleted.
(WTF::ConditionBase::waitForSecondsImpl): Deleted.
(WTF::ConditionBase::waitForImpl): Deleted.
(WTF::ConditionBase::absoluteFromRelative): Deleted.
* wtf/CrossThreadQueue.h:
(WTF::CrossThreadQueue<DataType>::waitForMessage):
* wtf/CurrentTime.cpp:
(WTF::sleep):
* wtf/MessageQueue.h:
(WTF::MessageQueue::infiniteTime): Deleted.
* wtf/MonotonicTime.cpp: Added.
(WTF::MonotonicTime::now):
(WTF::MonotonicTime::approximateWallTime):
(WTF::MonotonicTime::dump):
(WTF::MonotonicTime::sleep):
* wtf/MonotonicTime.h: Added.
(WTF::MonotonicTime::MonotonicTime):
(WTF::MonotonicTime::fromRawDouble):
(WTF::MonotonicTime::infinity):
(WTF::MonotonicTime::secondsSinceEpoch):
(WTF::MonotonicTime::approximateMonotonicTime):
(WTF::MonotonicTime::operator bool):
(WTF::MonotonicTime::operator+):
(WTF::MonotonicTime::operator-):
(WTF::MonotonicTime::operator+=):
(WTF::MonotonicTime::operator-=):
(WTF::MonotonicTime::operator==):
(WTF::MonotonicTime::operator!=):
(WTF::MonotonicTime::operator<):
(WTF::MonotonicTime::operator>):
(WTF::MonotonicTime::operator<=):
(WTF::MonotonicTime::operator>=):
* wtf/ParkingLot.cpp:
(WTF::ParkingLot::parkConditionallyImpl):
(WTF::ParkingLot::unparkOne):
(WTF::ParkingLot::unparkOneImpl):
(WTF::ParkingLot::unparkCount):
* wtf/ParkingLot.h:
(WTF::ParkingLot::parkConditionally):
(WTF::ParkingLot::compareAndPark):
* wtf/Seconds.cpp: Added.
(WTF::Seconds::operator+):
(WTF::Seconds::operator-):
(WTF::Seconds::dump):
(WTF::Seconds::sleep):
* wtf/Seconds.h: Added.
(WTF::Seconds::Seconds):
(WTF::Seconds::value):
(WTF::Seconds::seconds):
(WTF::Seconds::milliseconds):
(WTF::Seconds::microseconds):
(WTF::Seconds::nanoseconds):
(WTF::Seconds::fromMilliseconds):
(WTF::Seconds::fromMicroseconds):
(WTF::Seconds::fromNanoseconds):
(WTF::Seconds::infinity):
(WTF::Seconds::operator bool):
(WTF::Seconds::operator+):
(WTF::Seconds::operator-):
(WTF::Seconds::operator*):
(WTF::Seconds::operator/):
(WTF::Seconds::operator+=):
(WTF::Seconds::operator-=):
(WTF::Seconds::operator*=):
(WTF::Seconds::operator/=):
(WTF::Seconds::operator==):
(WTF::Seconds::operator!=):
(WTF::Seconds::operator<):
(WTF::Seconds::operator>):
(WTF::Seconds::operator<=):
(WTF::Seconds::operator>=):
* wtf/TimeWithDynamicClockType.cpp: Added.
(WTF::TimeWithDynamicClockType::now):
(WTF::TimeWithDynamicClockType::nowWithSameClock):
(WTF::TimeWithDynamicClockType::wallTime):
(WTF::TimeWithDynamicClockType::monotonicTime):
(WTF::TimeWithDynamicClockType::approximateWallTime):
(WTF::TimeWithDynamicClockType::approximateMonotonicTime):
(WTF::TimeWithDynamicClockType::operator-):
(WTF::TimeWithDynamicClockType::operator<):
(WTF::TimeWithDynamicClockType::operator>):
(WTF::TimeWithDynamicClockType::operator<=):
(WTF::TimeWithDynamicClockType::operator>=):
(WTF::TimeWithDynamicClockType::dump):
(WTF::TimeWithDynamicClockType::sleep):
* wtf/TimeWithDynamicClockType.h: Added.
(WTF::TimeWithDynamicClockType::TimeWithDynamicClockType):
(WTF::TimeWithDynamicClockType::fromRawDouble):
(WTF::TimeWithDynamicClockType::secondsSinceEpoch):
(WTF::TimeWithDynamicClockType::clockType):
(WTF::TimeWithDynamicClockType::withSameClockAndRawDouble):
(WTF::TimeWithDynamicClockType::operator bool):
(WTF::TimeWithDynamicClockType::operator+):
(WTF::TimeWithDynamicClockType::operator-):
(WTF::TimeWithDynamicClockType::operator+=):
(WTF::TimeWithDynamicClockType::operator-=):
(WTF::TimeWithDynamicClockType::operator==):
(WTF::TimeWithDynamicClockType::operator!=):
* wtf/WallTime.cpp: Added.
(WTF::WallTime::now):
(WTF::WallTime::approximateMonotonicTime):
(WTF::WallTime::dump):
(WTF::WallTime::sleep):
* wtf/WallTime.h: Added.
(WTF::WallTime::WallTime):
(WTF::WallTime::fromRawDouble):
(WTF::WallTime::infinity):
(WTF::WallTime::secondsSinceEpoch):
(WTF::WallTime::approximateWallTime):
(WTF::WallTime::operator bool):
(WTF::WallTime::operator+):
(WTF::WallTime::operator-):
(WTF::WallTime::operator+=):
(WTF::WallTime::operator-=):
(WTF::WallTime::operator==):
(WTF::WallTime::operator!=):
(WTF::WallTime::operator<):
(WTF::WallTime::operator>):
(WTF::WallTime::operator<=):
(WTF::WallTime::operator>=):
* wtf/threads/BinarySemaphore.cpp:
(WTF::BinarySemaphore::wait):
* wtf/threads/BinarySemaphore.h:
2016-11-03 Filip Pizlo <fpizlo@apple.com>
DFG plays fast and loose with the shadow values of a Phi
https://bugs.webkit.org/show_bug.cgi?id=164309
Reviewed by Saam Barati.
Made this API use size rather than maxIndex as its initialization parameter, because that's
less confusing.
* wtf/IndexSparseSet.h:
(WTF::IndexSparseSet<OverflowHandler>::IndexSparseSet):
2016-11-03 Commit Queue <commit-queue@webkit.org>
Unreviewed, rolling out r208364.
https://bugs.webkit.org/show_bug.cgi?id=164402
broke the build (Requested by smfr on #webkit).
Reverted changeset:
"DFG plays fast and loose with the shadow values of a Phi"
https://bugs.webkit.org/show_bug.cgi?id=164309
http://trac.webkit.org/changeset/208364
2016-11-03 Filip Pizlo <fpizlo@apple.com>
DFG plays fast and loose with the shadow values of a Phi
https://bugs.webkit.org/show_bug.cgi?id=164309
Reviewed by Saam Barati.
Made this API use size rather than maxIndex as its initialization parameter, because that's
less confusing.
* wtf/IndexSparseSet.h:
(WTF::IndexSparseSet<OverflowHandler>::IndexSparseSet):
2016-11-03 Konstantin Tokarev <annulen@yandex.ru>
Fixes to build JSCOnly on macOS
https://bugs.webkit.org/show_bug.cgi?id=164379
Reviewed by Michael Catanzaro.
* wtf/Platform.h: JSCOnly port should not provide any PLATFORM() macro
2016-11-03 Brady Eidson <beidson@apple.com>
IndexedDB 2.0: Support binary keys.
<rdar://problem/28806927> and https://bugs.webkit.org/show_bug.cgi?id=164359
Reviewed by Alex Christensen.
* wtf/Hasher.h:
(WTF::StringHasher::hashMemory): Teach hashMemory() to handle buffers with odd lengths.
2016-11-02 Filip Pizlo <fpizlo@apple.com>
The GC should be in a thread
https://bugs.webkit.org/show_bug.cgi?id=163562
Reviewed by Geoffrey Garen and Andreas Kling.
This fixes some bugs and adds a few features.
* wtf/Atomics.h: The GC may do work on behalf of the JIT. If it does, the main thread needs to execute a cross-modifying code fence. This is cpuid on x86 and I believe it's isb on ARM. It would have been an isync on PPC and I think that isb is the ARM equivalent.
(WTF::arm_isb):
(WTF::crossModifyingCodeFence):
(WTF::x86_ortop):
(WTF::x86_cpuid):
* wtf/AutomaticThread.cpp: I accidentally had AutomaticThreadCondition inherit from ThreadSafeRefCounted<AutomaticThread> [sic]. This never crashed before because all of our prior AutomaticThreadConditions were immortal.
(WTF::AutomaticThread::AutomaticThread):
(WTF::AutomaticThread::~AutomaticThread):
(WTF::AutomaticThread::start):
* wtf/AutomaticThread.h:
* wtf/MainThread.cpp: Need to allow initializeGCThreads() to be called separately because it's now more than just a debugging thing.
(WTF::initializeGCThreads):
2016-11-02 Carlos Alberto Lopez Perez <clopez@igalia.com>
Clean wrong comment about compositing on the UI process.
https://bugs.webkit.org/show_bug.cgi?id=164339
Reviewed by Michael Catanzaro.
* wtf/Platform.h: The comment about compositing on the UI process
was added on r109302 but was not removed properly when the Qt port
was removed from trunk.
USE_PROTECTION_SPACE_AUTH_CALLBACK has nothing to do with it.
2016-11-02 Alex Christensen <achristensen@webkit.org>
Remove Battery Status API from the tree
https://bugs.webkit.org/show_bug.cgi?id=164213
Reviewed by Sam Weinig.
* wtf/FeatureDefines.h:
2016-11-02 Romain Bellessort <romain.bellessort@crf.canon.fr>
[Readable Streams API] Enable creation of ReadableByteStreamController
https://bugs.webkit.org/show_bug.cgi?id=164014
Reviewed by Youenn Fablet.
Added flag for the byte stream part of Readable Streams API.
* wtf/FeatureDefines.h:
2016-11-02 Per Arne Vollan <pvollan@apple.com>
[Win] Copy build results to AAS 'Program Files' folder.
https://bugs.webkit.org/show_bug.cgi?id=164273
Reviewed by Brent Fulgham.
The preferred location for the binaries is the AAS 'Program Files' folder.
* WTF.vcxproj/WTF.proj:
2016-10-29 Filip Pizlo <fpizlo@apple.com>
JSC should support SharedArrayBuffer
https://bugs.webkit.org/show_bug.cgi?id=163986
Reviewed by Keith Miller.
Adds some small things we need for SharedArrayBuffer.
* wtf/Atomics.h:
(WTF::Atomic::compareExchangeWeakRelaxed):
(WTF::Atomic::exchangeAdd):
(WTF::Atomic::exchangeAnd):
(WTF::Atomic::exchangeOr):
(WTF::Atomic::exchangeSub):
(WTF::Atomic::exchangeXor):
(WTF::atomicLoad):
(WTF::atomicStore):
(WTF::atomicCompareExchangeWeak):
(WTF::atomicCompareExchangeWeakRelaxed):
(WTF::atomicCompareExchangeStrong):
(WTF::atomicExchangeAdd):
(WTF::atomicExchangeAnd):
(WTF::atomicExchangeOr):
(WTF::atomicExchangeSub):
(WTF::atomicExchangeXor):
(WTF::atomicExchange):
(WTF::Atomic::exchangeAndAdd): Deleted.
(WTF::weakCompareAndSwap): Deleted.
We need to be able to do atomics operations on naked pointers. We also need to be able to do
all of the things that std::atomic does. This adds those things and renames
weakCompareAndSwap to atomicCompareExchangeWeakRelaxed so that we're using consistent
terminology.
* wtf/Bitmap.h:
(WTF::WordType>::concurrentTestAndSet): Renamed weakCompareAndSwap.
(WTF::WordType>::concurrentTestAndClear): Renamed weakCompareAndSwap.
* wtf/FastBitVector.h:
(WTF::FastBitVector::atomicSetAndCheck): Renamed weakCompareAndSwap.
* wtf/ParkingLot.cpp:
(WTF::ParkingLot::unparkOne):
(WTF::ParkingLot::unparkCount):
* wtf/ParkingLot.h:
Added unparkCount(), which lets you unpark some bounded number of threads and returns the
number of threads unparked. This is just a modest extension of unparkAll(). unparkAll() now
just calls unparkCount(ptr, UINT_MAX).
2016-10-30 Frederic Wang <fwang@igalia.com>
Use HarfBuzz ot-math API to parse the OpenType MATH table
https://bugs.webkit.org/show_bug.cgi?id=162671
Reviewed by Michael Catanzaro.
* wtf/Platform.h: By default, do not enable internal OpenType MATH parsing on GTK.
2016-10-25 Mark Lam <mark.lam@apple.com>
String.prototype.replace() should throw an OutOfMemoryError when using too much memory.
https://bugs.webkit.org/show_bug.cgi?id=163996
<rdar://problem/28263117>
Reviewed by Geoffrey Garen.
* wtf/Vector.h:
(WTF::minCapacity>::tryConstructAndAppend):
(WTF::minCapacity>::tryConstructAndAppendSlowCase):
- Added try versions of constructAndAppend() so that we can handle the failure
to allocate more gracefully.
2016-10-25 Konstantin Tokarev <annulen@yandex.ru>
Non-specialized version of deleteObject should not have template argument
https://bugs.webkit.org/show_bug.cgi?id=163943
Reviewed by Anders Carlsson.
Fixes compilation of GDIObject.h with MinGW
* wtf/win/GDIObject.h:
(WTF::deleteObject):
2016-10-24 Per Arne Vollan <pvollan@apple.com>
[Win] CMake build type is not set.
https://bugs.webkit.org/show_bug.cgi?id=163917
Reviewed by Alex Christensen.
The CMAKE_BUILD_TYPE variable should be set to Debug or Release.
* WTF.vcxproj/WTF.proj:
2016-10-23 Yusuke Suzuki <utatane.tea@gmail.com>
[DOMJIT] Add a way for DOMJIT::Patchpoint to express effects
https://bugs.webkit.org/show_bug.cgi?id=163657
Reviewed by Saam Barati.
Simplify nonEmptyRangesOverlap.
* wtf/MathExtras.h:
(WTF::nonEmptyRangesOverlap):
2016-10-23 Chris Dumez <cdumez@apple.com>
Another unreviewed attempt to fix the WatchOS / TvOS build after r207585.
<rdar://problem/28902292>
Disable USE_CFURLCONNECTION on newer WatchOS / TvOS.
* wtf/Platform.h:
2016-10-20 Keith Miller <keith_miller@apple.com>
Add support for WASM calls
https://bugs.webkit.org/show_bug.cgi?id=161727
Reviewed by Filip Pizlo and Michael Saboff.
Added a new decodeUInt64. Also, added WTF::LEBDecoder namespace.
* wtf/LEBDecoder.h:
(WTF::LEBDecoder::decodeUInt):
(WTF::LEBDecoder::decodeUInt32):
(WTF::LEBDecoder::decodeUInt64):
(WTF::LEBDecoder::decodeInt32):
(decodeUInt32): Deleted.
(decodeInt32): Deleted.
2016-10-20 Filip Pizlo <fpizlo@apple.com>
The tracking of the coarse-grain Heap state (allocating or not, collector or not, eden vs full) should respect the orthogonality between allocating and collecting
https://bugs.webkit.org/show_bug.cgi?id=163738
Reviewed by Geoffrey Garen.
There will soon be different kinds of GC threads, and WTF's "are you a GC thread" thing
should know about this.
* wtf/MainThread.cpp:
(WTF::initializeGCThreads):
(WTF::registerGCThread):
(WTF::mayBeGCThread):
* wtf/MainThread.h:
2016-10-19 Sam Weinig <sam@webkit.org>
Add convenience function that combines WTF::visit(...) with WTF::makeVisitor(...)
https://bugs.webkit.org/show_bug.cgi?id=163713
Reviewed by Dan Bernstein.
- Add WTF::switchOn which merges WTF::visit with WTF::makeVisitor in the following
way:
WTF::visit(WTF::makeVisitor(...), variant)
* wtf/Variant.h:
(WTF::switchOn):
2016-10-19 Alex Christensen <achristensen@webkit.org>
Revert r207151
https://bugs.webkit.org/show_bug.cgi?id=163675
Reviewed by Brent Fulgham.
* wtf/Platform.h:
* wtf/SchedulePair.h:
* wtf/SchedulePairMac.mm:
2016-10-19 Filip Pizlo <fpizlo@apple.com>
REGRESSION (r207480): 3 Dromaeo tests failing
https://bugs.webkit.org/show_bug.cgi?id=163633
Reviewed by Mark Lam.
It's a ParkingLot bug: if we timeout and get unparked at the same time, then the unparking
thread will clear our address eventually - but not immediately. This causes a nasty
assertion failure. The tricky thing is that when we detect this, we need to wait until that
unparking thread does the deed. Otherwise, they will still do it at some later time.
Alternatively, we could use some kind of versioning to detect this - increment the version
when you park, so that unparking threads will know if they are time travelers. That seems
more yucky.
I don't think it matters too much what we do here, so long as it's simple and correct, since
this requires a race that is rare enough that it didn't happen once in my testing, and I was
pretty thorough. For example, it didn't happen once in 15 runs of JetStream. The race is
rare because it requires the timeout to happen right as someone else is unparking. Since
it's so rare, its probably OK that the unparked thread waits just a tiny moment until the
unparking thread is done.
* wtf/ParkingLot.cpp:
(WTF::ParkingLot::parkConditionallyImpl):
(WTF::ParkingLot::unparkOneImpl):
2016-10-19 Filip Pizlo <fpizlo@apple.com>
Baseline JIT should use AutomaticThread
https://bugs.webkit.org/show_bug.cgi?id=163686
Reviewed by Geoffrey Garen.
Added a AutomaticThreadCondition::wait() method, so that if you really want to use one
common condition for your thread and something else, you can do it. This trivially works
if you only use notifyAll(), and behaves as you'd expect for notifyOne() (i.e. it's
dangerous, since you don't know who will wake up).
The Baseline JIT used the one-true-Condition idiom because it used notifyAll() in an
optimal way: there are just two threads talking to each other, so it wakes up at most one
thread and that thread is exactly the one you want woken up. Adding wait() means that I did
not have to change that code.
* wtf/AutomaticThread.cpp:
(WTF::AutomaticThreadCondition::wait):
* wtf/AutomaticThread.h:
2016-10-18 Filip Pizlo <fpizlo@apple.com>
DFG worklist should use AutomaticThread
https://bugs.webkit.org/show_bug.cgi?id=163615
Reviewed by Mark Lam.
This adds new functionality to AutomaticThread to support DFG::Worklist:
- AutomaticThread::threadDidStart/threadWillStop virtual methods called at the start and end
of a thread's lifetime. This allows Worklist to tie some resources to the life of the
thread, and also means that now those resources will naturally free up when the Worklist is
not in use.
- AutomaticThreadCondition::notifyOne(). This required changes to Condition::notifyOne(). We
need to know if the Condition woke up anyone. If it didn't, then we need to launch one of
our threads.
* wtf/AutomaticThread.cpp:
(WTF::AutomaticThreadCondition::notifyOne):
(WTF::AutomaticThread::ThreadScope::ThreadScope):
(WTF::AutomaticThread::ThreadScope::~ThreadScope):
(WTF::AutomaticThread::start):
(WTF::AutomaticThread::threadDidStart):
(WTF::AutomaticThread::threadWillStop):
* wtf/AutomaticThread.h:
* wtf/Condition.h:
(WTF::ConditionBase::notifyOne):
2016-10-18 Sam Weinig <sam@webkit.org>
Replace std::experimental::variant with WTF::Variant (or similar)
https://bugs.webkit.org/show_bug.cgi?id=163626
Reviewed by Chris Dumez.
Rename std::experimental::variant, Variant. Move helpers get/holds_alternative/etc.
into the WTF namespace.
* wtf/Forward.h:
* wtf/Variant.h:
2016-10-18 Filip Pizlo <fpizlo@apple.com>
WTF should make it easier to create threads that die automatically after inactivity
https://bugs.webkit.org/show_bug.cgi?id=163576
Reviewed by Andreas Kling.
For a long time now, I've been adding threads to WTF/JSC and each time I do this, I feel
guilty because those threads don't shut down when they are inactive. For example, in bug
163562, I need to add a new GC thread. There will be one of them per VM. This means that a
JSC API client that starts a lot of VMs will have a lot of threads. I don't think that's
good.
A common pattern for all of these threads is that they have some well-defined trigger that
causes them to run. This trigger has a lock, a condition variable, some logic that determines
if there is work to do, and then of course the logic for the thread's actual work. The thread
bodies usually look like this:
void Thingy::runThread()
{
for (;;) {
Work work;
{
LockHolder locker(m_lock);
while (!hasWork())
m_cond.wait(m_lock);
work = takeWork();
}
doWork(work);
}
}
If you look at ParallelHelperPool (the GC's threads) and DFG::Worklist (some of the JIT's
threads), you will see this pattern.
This change adds a new kind of thread, called AutomaticThread, that lets you write threads to
this pattern while getting automatic thread shutdown for free: instead of just waiting on a
condition variable, AutomaticThread will have a timeout that causes the thread to die. The
condition variable associated with AutomaticThread, called AutomaticThreadCondition, is smart
enough to restart any threads that have decided to stop due to inactivity. The inactivity
threshold is current just 1 second.
In this patch I only adopt AutomaticThread for ParallelHelperPool. I plan to adopt it in more
places soon.
* WTF.xcodeproj/project.pbxproj:
* wtf/AutomaticThread.cpp: Added.
(WTF::AutomaticThreadCondition::create):
(WTF::AutomaticThreadCondition::AutomaticThreadCondition):
(WTF::AutomaticThreadCondition::~AutomaticThreadCondition):
(WTF::AutomaticThreadCondition::notifyAll):
(WTF::AutomaticThreadCondition::add):
(WTF::AutomaticThreadCondition::remove):
(WTF::AutomaticThreadCondition::contains):
(WTF::AutomaticThread::AutomaticThread):
(WTF::AutomaticThread::~AutomaticThread):
(WTF::AutomaticThread::join):
(WTF::AutomaticThread::start):
* wtf/AutomaticThread.h: Added.
* wtf/CMakeLists.txt:
* wtf/ParallelHelperPool.cpp:
(WTF::ParallelHelperClient::ParallelHelperClient):
(WTF::ParallelHelperClient::~ParallelHelperClient):
(WTF::ParallelHelperClient::setTask):
(WTF::ParallelHelperClient::finish):
(WTF::ParallelHelperClient::doSomeHelping):
(WTF::ParallelHelperClient::runTask):
(WTF::ParallelHelperPool::ParallelHelperPool):
(WTF::ParallelHelperPool::~ParallelHelperPool):
(WTF::ParallelHelperPool::ensureThreads):
(WTF::ParallelHelperPool::doSomeHelping):
(WTF::ParallelHelperPool::Thread::Thread):
(WTF::ParallelHelperPool::didMakeWorkAvailable):
(WTF::ParallelHelperPool::helperThreadBody): Deleted.
(WTF::ParallelHelperPool::waitForClientWithTask): Deleted.
* wtf/ParallelHelperPool.h:
2016-10-18 Said Abou-Hallawa <sabouhallawa@apple.com>
SVGCSSParser: m_implicitShorthand value is not reset after adding the shorthand property
https://bugs.webkit.org/show_bug.cgi?id=116470
Reviewed by Simon Fraser.
* wtf/TemporaryChange.h:
(WTF::TemporaryChange::TemporaryChange):
Add a new constructor to make TemporaryChange work as a restorer. The
temporary change will happen after we construct the object.
2016-10-17 Simon Fraser <simon.fraser@apple.com>
Implement DOMRect/DOMRectReadOnly
https://bugs.webkit.org/show_bug.cgi?id=163464
Reviewed by Darin Adler.
Implement min()/max() in a way that follows Math.min/Math.max, which return
NaN if either argument is NaN.
* wtf/MathExtras.h:
(WTF::nanPropagatingMin):
(WTF::nanPropagatingMax):
2016-10-15 Sam Weinig <sam@webkit.org>
MessageEvent's source property should be a (DOMWindow or MessagePort)? rather than a EventTarget?
https://bugs.webkit.org/show_bug.cgi?id=163475
Reviewed by Simon Fraser.
* wtf/Variant.h:
Add missing return statement that was tripping up some compilers.
2016-10-12 Ryan Haddad <ryanhaddad@apple.com>
Unreviewed, rolling out r207225.
This change causes debug tests to exit early with crashes.
Reverted changeset:
"Optional's move-constructor and move-assignment operator
don't disengage the value being moved from"
https://bugs.webkit.org/show_bug.cgi?id=163309
http://trac.webkit.org/changeset/207225
2016-10-11 Sam Weinig <sam@webkit.org>
Optional's move-constructor and move-assignment operator don't disengage the value being moved from
https://bugs.webkit.org/show_bug.cgi?id=163309
Reviewed by Anders Carlsson.
* wtf/Optional.h:
(WTF::Optional::Optional):
(WTF::Optional::operator=):
Disengage 'other' on move-construction and move-assignment.
2016-10-08 Filip Pizlo <fpizlo@apple.com>
MarkedBlock should know what objects are live during marking
https://bugs.webkit.org/show_bug.cgi?id=162309
Reviewed by Geoffrey Garen.
This removes the atomicity mode, because it's not really used: it only affects the
concurrentBlah methods, but their only users turn on atomicity. This was useful because
previously, some binary Bitmap methods (like merge(const Bitmap&)) couldn't be used
effectively in the GC because some of the GC's bitmaps set the atomic mode and some didn't.
Removing this useless mode is the best solution.
Also added some new binary Bitmap methods: mergeAndClear(Bitmap& other) and
setAndClear(Bitmap& other). They perform their action on 'this' (either merge or set,
respectively) while also clearing the contents of 'other'. This is great for one of the GC
hot paths.
* wtf/Bitmap.h:
(WTF::WordType>::Bitmap):
(WTF::WordType>::get):
(WTF::WordType>::set):
(WTF::WordType>::testAndSet):
(WTF::WordType>::testAndClear):
(WTF::WordType>::concurrentTestAndSet):
(WTF::WordType>::concurrentTestAndClear):
(WTF::WordType>::clear):
(WTF::WordType>::clearAll):
(WTF::WordType>::nextPossiblyUnset):
(WTF::WordType>::findRunOfZeros):
(WTF::WordType>::count):
(WTF::WordType>::isEmpty):
(WTF::WordType>::isFull):
(WTF::WordType>::merge):
(WTF::WordType>::filter):
(WTF::WordType>::exclude):
(WTF::WordType>::forEachSetBit):
(WTF::WordType>::mergeAndClear):
(WTF::WordType>::setAndClear):
(WTF::=):
(WTF::WordType>::hash):
2016-10-11 Said Abou-Hallawa <sabouhallawa@apple.com>
Add SynchronizedFixedQueue class
https://bugs.webkit.org/show_bug.cgi?id=162478
Reviewed by Geoffrey Garen.
This class represents a simple producer/consumer worker. It facilitates
synchronizing enqueuing to and dequeuing from a fixed size-queue. It uses
a single lock and a single condition to synchronize all its members among
the working threads. This means a single thread is active at any time and
and the other threads are blocked waiting for the lock to be released. Or
they are sleeping waiting for the condition to be satisfied.
* WTF.xcodeproj/project.pbxproj:
* wtf/SynchronizedFixedQueue.h: Added.
(WTF::SynchronizedFixedQueue::SynchronizedFixedQueue):
(WTF::SynchronizedFixedQueue::open): Restore the queue to its original state.
(WTF::SynchronizedFixedQueue::close): Wake all the sleeping threads with a closing state.
(WTF::SynchronizedFixedQueue::isOpen): Does the queue accept new items?
(WTF::SynchronizedFixedQueue::enqueue): Enqueue an item into the queue.
(WTF::SynchronizedFixedQueue::dequeue): Dequeue an item form the queue.
2016-10-11 Alex Christensen <achristensen@webkit.org>
Remove dead networking code
https://bugs.webkit.org/show_bug.cgi?id=163263
Reviewed by Daniel Bates.
* wtf/Platform.h:
* wtf/SchedulePair.h:
* wtf/SchedulePairMac.mm:
2016-10-10 Zan Dobersek <zdobersek@igalia.com>
Add ENABLE_ENCRYPTED_MEDIA configuration option
https://bugs.webkit.org/show_bug.cgi?id=163219
Reviewed by Darin Adler.
* wtf/FeatureDefines.h:
If undefined, define the ENABLE_ENCRYPTED_MEDIA option to 0.
2016-10-10 Yusuke Suzuki <utatane.tea@gmail.com>
[DOMJIT] Implement Node accessors in DOMJIT
https://bugs.webkit.org/show_bug.cgi?id=163005
Reviewed by Filip Pizlo.
Add CAST_OFFSET. It is not necessary for JSCell thingy
since we don't use virtual member functions. However, it
is not true for WebCore DOM wrapped objects.
* wtf/StdLibExtras.h:
2016-10-07 Chris Dumez <cdumez@apple.com>
window.navigator.language incorrectly returns all lowercase string
https://bugs.webkit.org/show_bug.cgi?id=163096
Reviewed by Darin Adler.
Update platformUserPreferredLanguages() so that it no longer lowercases
the string it returns. On Mac, we rely on CFLocale which returns
BCP-47 language tags as per:
- https://developer.apple.com/reference/corefoundation/1666963-cflocale?language=objc
* wtf/PlatformUserPreferredLanguagesMac.mm:
(WTF::httpStyleLanguageCode):
* wtf/PlatformUserPreferredLanguagesUnix.cpp:
(WTF::platformLanguage):
2016-10-06 Brent Fulgham <bfulgham@apple.com>
[Win][Direct2D] Add Direct2D CMake rules
https://bugs.webkit.org/show_bug.cgi?id=162925
Reviewed by Brent Fulgham.
* wtf/Platform.h: Don't USE(CA) or USE(CG) if building
with Direct2D.
2016-10-05 Yusuke Suzuki <utatane.tea@gmail.com>
[DOMJIT] Add initial CheckDOM and CallDOM implementations
https://bugs.webkit.org/show_bug.cgi?id=162941
Reviewed by Filip Pizlo.
* wtf/Box.h:
(WTF::Box::Box):
2016-10-05 Zan Dobersek <zdobersek@igalia.com>
Rename ENABLE_ENCRYPTED_MEDIA_V2 to ENABLE_LEGACY_ENCRYPTED_MEDIA
https://bugs.webkit.org/show_bug.cgi?id=162903
Reviewed by Alex Christensen.
Rename build guards for the remaining implementation of the legacy EME API
to ENABLE_LEGACY_ENCRYPTED_MEDIA. This will allow for the future implementation
of the near-finished API to be guarded with the simple ENABLE_ENCRYPTED_MEDIA guards.
* wtf/FeatureDefines.h:
2016-10-04 Saam Barati <sbarati@apple.com>
String.prototype.toLowerCase should be a DFG/FTL intrinsic
https://bugs.webkit.org/show_bug.cgi?id=162887
Reviewed by Filip Pizlo and Yusuke Suzuki.
This patch exposes a new StringImpl function called convertToLowercaseWithoutLocaleStartingAtFailingIndex8Bit
which extracts slow path for the 8-bit part of convertToLowercaseWithoutLocale
into a helper function. I decided to extract this into its own function because
it may be the case that JSCs JITs will want to continue the operation
after it has already ensured that part of an 8-bit string is lower case.
* wtf/text/StringImpl.cpp:
(WTF::StringImpl::convertToLowercaseWithoutLocale):
(WTF::StringImpl::convertToLowercaseWithoutLocaleStartingAtFailingIndex8Bit):
* wtf/text/StringImpl.h:
* wtf/text/WTFString.cpp:
(WTF::String::convertToLowercaseWithoutLocaleStartingAtFailingIndex8Bit):
* wtf/text/WTFString.h:
2016-10-04 Chris Dumez <cdumez@apple.com>
Implement KeyboardEvent.code from the UI Event spec
https://bugs.webkit.org/show_bug.cgi?id=149584
Reviewed by Darin Adler.
Add build time flag to toggle support for the code attribute on
KeyboardEvent and only enable it on Mac for now, given that the
implementation is missing on other platforms.
* wtf/FeatureDefines.h:
2016-10-03 Chris Dumez <cdumez@apple.com>
Add support for KeyboardEvent.key attribute
https://bugs.webkit.org/show_bug.cgi?id=36267
Reviewed by Darin Adler.
Add compile time flag for the key attribute on KeyboardEvent and enable
it on Cocoa only.
* wtf/FeatureDefines.h:
2016-09-29 Sam Weinig <sam@webkit.org>
Add initial support for IDL union conversion
https://bugs.webkit.org/show_bug.cgi?id=161576
Reviewed by Chris Dumez.
* WTF.xcodeproj/project.pbxproj:
* wtf/CMakeLists.txt:
Add Brigand.h
* wtf/Brigand.h: Added.
Import a standalone copy of Edouard Alligand and Joel Falcou's
Brigand library for help with for help with list based meta programming
* wtf/StdLibExtras.h:
Add a new three new type traits, IsTemplate, IsBaseOfTemplate and RemoveCVAndReference.
- IsTemplate acts like std::is_class, but works with a generic base.
- IsBaseOfTemplate acts like std::is_base_of, but works with a generic base.
- RemoveCVAndReference combines std::remove_cv and std::remove_reference.
2016-09-30 Filip Pizlo <fpizlo@apple.com>
B3::moveConstants should be able to edit code to minimize the number of constants
https://bugs.webkit.org/show_bug.cgi?id=162764
Reviewed by Saam Barati.
I thought it would be a good idea to document the fact that dominator traversal happens in a
particular order for a reason.
* wtf/Dominators.h:
2016-09-29 Filip Pizlo <fpizlo@apple.com>
Air should have a way of expressing additional instruction flags
https://bugs.webkit.org/show_bug.cgi?id=162699
Reviewed by Mark Lam.
* wtf/CommaPrinter.h:
(WTF::CommaPrinter::CommaPrinter):
(WTF::CommaPrinter::dump):
(WTF::CommaPrinter::didPrint):
2016-09-30 Youenn Fablet <youenn@apple.com>
Add a way to go from a RefPtr<T> to Ref<const T>
https://bugs.webkit.org/show_bug.cgi?id=162683
Reviewed by Alex Christensen.
* wtf/RefPtr.h:
(WTF::RefPtr::releaseConstNonNull): Added.
2016-09-29 Mark Lam <mark.lam@apple.com>
Re-enable StringView life-cycle checking.
https://bugs.webkit.org/show_bug.cgi?id=160384
<rdar://problem/28479434>
Reviewed by Saam Barati.
Re-landing after slow running tests have been resolved.
* wtf/text/StringView.h:
2016-09-29 Commit Queue <commit-queue@webkit.org>
Unreviewed, rolling out r206563.
https://bugs.webkit.org/show_bug.cgi?id=162732
Caused stress/op_*.js.ftl-no-cjit tests to time out (Requested
by ryanhaddad on #webkit).
Reverted changeset:
"Re-enable StringView life-cycle checking."
https://bugs.webkit.org/show_bug.cgi?id=160384
http://trac.webkit.org/changeset/206563
2016-09-29 Fujii Hironori <Hironori.Fujii@sony.com>
Clang 3.9 reports a compilation warning about ENABLE_EXCEPTION_SCOPE_VERIFICATION
https://bugs.webkit.org/show_bug.cgi?id=162718
Reviewed by Alex Christensen.
Clang 3.9 reports a following compilation warning:
Source/JavaScriptCore/runtime/VM.h:656:5: warning: macro expansion producing 'defined' has undefined behavior [-Wexpansion-to-defined]
* wtf/Platform.h: Changed the definition of ENABLE_EXCEPTION_SCOPE_VERIFICATION not to use 'defined'.
2016-09-28 Mark Lam <mark.lam@apple.com>
Re-enable StringView life-cycle checking.
https://bugs.webkit.org/show_bug.cgi?id=160384
<rdar://problem/28479434>
Reviewed by Saam Barati.
* wtf/text/StringView.h:
2016-09-28 Filip Pizlo <fpizlo@apple.com>
The write barrier should be down with TSO
https://bugs.webkit.org/show_bug.cgi?id=162316
Reviewed by Geoffrey Garen.
Added clearRange(), which quickly clears a range of bits. This turned out to be useful for
a DFG optimization pass.
* wtf/FastBitVector.cpp:
(WTF::FastBitVector::clearRange):
* wtf/FastBitVector.h:
2016-09-28 Mark Lam <mark.lam@apple.com>
Fix race condition in StringView's UnderlyingString lifecycle management.
https://bugs.webkit.org/show_bug.cgi?id=162702
Reviewed by Geoffrey Garen.
There 2 relevant functions at play:
void StringView::setUnderlyingString(const StringImpl* string)
{
UnderlyingString* underlyingString;
if (!string)
underlyingString = nullptr;
else {
std::lock_guard<StaticLock> lock(underlyingStringsMutex);
auto result = underlyingStrings().add(string, nullptr);
if (result.isNewEntry)
result.iterator->value = new UnderlyingString(*string);
else
++result.iterator->value->refCount;
underlyingString = result.iterator->value; // Point P2.
}
adoptUnderlyingString(underlyingString); // Point P5.
}
... and ...
void StringView::adoptUnderlyingString(UnderlyingString* underlyingString)
{
if (m_underlyingString) {
// Point P0.
if (!--m_underlyingString->refCount) {
if (m_underlyingString->isValid) { // Point P1.
std::lock_guard<StaticLock> lock(underlyingStringsMutex);
underlyingStrings().remove(&m_underlyingString->string); // Point P3.
}
delete m_underlyingString; // Point P4.
}
}
m_underlyingString = underlyingString;
}
Imagine the following scenario:
1. Thread T1 has been using an UnderlyingString U1, and is now done with it.
T1 runs up to point P1 in adoptUnderlyingString(), and is blocked waiting for
the underlyingStringsMutex (which is currently being held by Thread T2).
2. Context switch to Thread T2.
T2 wants to use UnderlyingString U1, and runs up to point P2 in setUnderlyingString()
and releases the underlyingStringsMutex.
Note: T2 thinks it has successfully refCounted U1, and therefore U1 is safe to use.
3. Context switch to Thread T1.
T1 acquires the underlyingStringsMutex, and proceeds to remove it from the
underlyingStrings() map (see Point P3). It thinks it has successfully done so
and proceeds to delete U1 (see Point P4).
4. Context switch to Thread T2.
T2 proceeds to use U1 (see Point P5 in setUnderlyingString()).
Note: U1 has already been freed. This is a use after free.
The fix is to acquire the underlyingStringsMutex at Point P0 in adoptUnderlyingString()
instead of after P1. This ensures that the decrementing of the UnderlyingString
refCount and its removal from the underlyingStrings() map is done as an atomic unit.
Note: If you look in StringView.cpp, you see another setUnderlyingString() which
takes a StringView otherString. This version of setUnderlyingString() can only
be called from within the same thread that created the other StringView. As a
result, here, we are guaranteed that the UnderlyingString refCount is never zero,
and there's no other threat of another thread trying to delete the UnderlyingString
while we adopt it. Hence, we don't need to acquire the underlyingStringsMutex
here.
This race condition was found when running layout tests fetch/fetch-worker-crash.html
and storage/indexeddb/modern/opendatabase-versions.html when CHECK_STRINGVIEW_LIFETIME
is enabled. This issue resulted in those tests crashing due to a use-after-free.
* wtf/text/StringView.cpp:
(WTF::StringView::adoptUnderlyingString):
(WTF::StringView::setUnderlyingString):
2016-09-28 Brent Fulgham <bfulgham@apple.com>
Correct 'safeCast' implementation
https://bugs.webkit.org/show_bug.cgi?id=162679
<rdar://problem/28518189>
Reviewed by Zalan Bujtas.
* wtf/StdLibExtras.h:
(WTF::safeCast): Use a RELEASE_ASSERT.
2016-09-27 Don Olmstead <don.olmstead@am.sony.com>
[CMake] Add HAVE_LOCALTIME_R definition
https://bugs.webkit.org/show_bug.cgi?id=162636
Reviewed by Alex Christensen.
* wtf/DateMath.cpp:
(WTF::getLocalTime):
* wtf/GregorianDateTime.cpp:
(WTF::GregorianDateTime::setToCurrentLocalTime):
* wtf/Platform.h:
2016-09-27 JF Bastien <jfbastien@apple.com>
Speed up Heap::isMarkedConcurrently
https://bugs.webkit.org/show_bug.cgi?id=162095
Reviewed by Filip Pizlo.
Heap::isMarkedConcurrently had a load-load fence which is expensive on weak memory ISAs such as ARM.
This patch is fairly perf-neutral overall, but the GC's instrumentation reports:
GC:Eden is 93% average runtime after change
GC:Full is 76% average runtime after change
The fence was there because:
1. If the read of m_markingVersion in MarkedBlock::areMarksStale isn't what's expected then;
2. The read of m_marks in MarkedBlock::isMarked needs to observe the value that was stored *before* m_markingVersion was stored.
This ordering isn't guaranteed on ARM, which has a weak memory model.
There are 3 ways to guarantee this ordering:
A. Use a barrier instruction.
B. Use a load-acquire (new in ARMv8).
C. use ARM's address dependency rule, which C++ calls memory_order_consume.
In general:
A. is slow but orders all of memory in an intuitive manner.
B. is faster-ish and has the same property-ish.
C. should be faster still, but *only orders dependent loads*. This last part is critical! Consume isn't an all-out replacement for acquire (acquire is rather a superset of consume).
ARM explains the address dependency rule in their document "barrier litmus tests and cookbook":
> *Resolving by the use of barriers and address dependency*
>
> There is a rule within the ARM architecture that:
> Where the value returned by a read is used to compute the virtual address of a subsequent read or write (this is known as an address dependency), then these two memory accesses will be observed in program order. An address dependency exists even if the value read by the first read has no effect in changing the virtual address (as might be the case if the value returned is masked off before it is used, or if it had no effect on changing a predicted address value).
> This restriction applies only when the data value returned from one read is used as a data value to calculate the address of a subsequent read or write. This does not apply if the data value returned from one read is used to determine the condition code flags, and the values of the flags are used for condition code evaluation to determine the address of a subsequent reads, either through conditional execution or the evaluation of a branch. This is known as a control dependency.
> Where both a control and address dependency exist, the ordering behaviour is consistent with the address dependency.
C++'s memory_order_consume is unfortunately unimplemented by C++ compilers, and maybe unimplementable as spec'd. I'm working with interested folks in the committee to fix this situation: http://wg21.link/p0190r2
* wtf/Atomics.h:
(WTF::zeroWithConsumeDependency): a 0 which carries a dependency
(WTF::consumeLoad): pixie magic
2016-09-27 JF Bastien <jfbastien@apple.com>
Atomics.h on Windows: remove seq_cst hack
https://bugs.webkit.org/show_bug.cgi?id=162022
Reviewed by Mark Lam.
No need to force access to seq_cst, always inlining fixes the MSVC warning.
* wtf/Atomics.h:
(WTF::Atomic::compareExchangeWeak): remove seq_cst hack
(WTF::Atomic::compareExchangeStrong): remove seq_cst hack
(WTF::Atomic::exchangeAndAdd): remove seq_cst hack
(WTF::Atomic::exchange): remove seq_cst hack
2016-09-27 Don Olmstead <don.olmstead@am.sony.com>
[CMake] Use CMake to determine HAVE_* defines
https://bugs.webkit.org/show_bug.cgi?id=162368
Reviewed by Alex Christensen.
* wtf/Platform.h:
2016-09-20 Anders Carlsson <andersca@apple.com>
PlatformEvent::m_modifiers should be an OptionSet
https://bugs.webkit.org/show_bug.cgi?id=162326
Reviewed by Daniel Bates.
* wtf/OptionSet.h:
(WTF::OptionSet::operator!=):
(WTF::OptionSet::operator-):
2016-09-27 Jer Noble <jer.noble@apple.com>
Remove deprecated ENCRYPTED_MEDIA implementation.
https://bugs.webkit.org/show_bug.cgi?id=161010
Reviewed by Eric Carlson.
Remove ENABLE_ENCRYPTED_MEDIA.
* wtf/FeatureDefines.h:
2016-09-27 Youenn Fablet <youenn@apple.com>
[Fetch API] Use Ref<const T> in FetchBody::m_data variant
https://bugs.webkit.org/show_bug.cgi?id=162599
Reviewed by Alex Christensen.
Enabling to use DeferrableRefCounted<const T> by making m_refCount mutable.
* wtf/DeferrableRefCounted.h:
(WTF::DeferrableRefCountedBase::ref):
(WTF::DeferrableRefCountedBase::derefBase):
(WTF::DeferrableRefCounted::deref):
2016-09-26 Daniel Bates <dabates@apple.com>
Rename IOS_TEXT_AUTOSIZING to TEXT_AUTOSIZING
https://bugs.webkit.org/show_bug.cgi?id=162365
Reviewed by Simon Fraser.
* wtf/FeatureDefines.h:
2016-09-26 Benjamin Poulain <benjamin@webkit.org>
[JSC] Shrink the Math inline caches some more
https://bugs.webkit.org/show_bug.cgi?id=162485
Reviewed by Saam Barati.
* wtf/Bag.h:
Don't copy the arguments before initializing the nodes.
2016-09-26 Michael Catanzaro <mcatanzaro@igalia.com>
std::unique_ptr deleter functions should not check if pointer is null
https://bugs.webkit.org/show_bug.cgi?id=162558
Reviewed by Alex Christensen.
std::unique_ptr already does this before calling the deleter.
* wtf/efl/UniquePtrEfl.h:
* wtf/glib/GUniquePtr.h:
== Rolled over to ChangeLog-2016-09-26 ==