2020-05-20 Alan Coon Cherry-pick r261877. rdar://problem/63461428 Put PtrTagLookup data structures in Configs for freezing. https://bugs.webkit.org/show_bug.cgi?id=212089 Reviewed by Robin Morisset. Source/JavaScriptCore: PtrTagLookup data structures were always meant to only be initialized once at initialization time and never modified thereafter. This patch puts them in the Configs for freezing to document and enforce this invariant. * runtime/JSCConfig.h: * runtime/JSCPtrTag.cpp: (JSC::initializePtrTagLookup): Source/WTF: * wtf/PtrTag.cpp: (WTF::tagForPtr): (WTF::ptrTagName): (WTF::registerPtrTagLookup): * wtf/PtrTag.h: (WTF::PtrTagLookup::initialize): * wtf/WTFConfig.h: git-svn-id: https://svn.webkit.org/repository/webkit/trunk@261877 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-05-19 Mark Lam Put PtrTagLookup data structures in Configs for freezing. https://bugs.webkit.org/show_bug.cgi?id=212089 Reviewed by Robin Morisset. PtrTagLookup data structures were always meant to only be initialized once at initialization time and never modified thereafter. This patch puts them in the Configs for freezing to document and enforce this invariant. * runtime/JSCConfig.h: * runtime/JSCPtrTag.cpp: (JSC::initializePtrTagLookup): 2020-05-20 Alan Coon Cherry-pick r261747. rdar://problem/63461445 Remove debugging dataLogs in LinkBuffer::copyCompactAndLinkCode() for release builds. https://bugs.webkit.org/show_bug.cgi?id=211961 Reviewed by Keith Miller. * assembler/LinkBuffer.cpp: (JSC::LinkBuffer::copyCompactAndLinkCode): git-svn-id: https://svn.webkit.org/repository/webkit/trunk@261747 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-05-15 Mark Lam Remove debugging dataLogs in LinkBuffer::copyCompactAndLinkCode() for release builds. https://bugs.webkit.org/show_bug.cgi?id=211961 Reviewed by Keith Miller. * assembler/LinkBuffer.cpp: (JSC::LinkBuffer::copyCompactAndLinkCode): 2020-05-12 Mark Lam Cherry-pick r261549. rdar://problem/63156073 2020-05-12 Mark Lam Wasm::enableFastMemory() was called too late. https://bugs.webkit.org/show_bug.cgi?id=211773 Reviewed by Yusuke Suzuki. If Wasm fast memory is to be enabled, we should just do it in initializeThreading() just like for all the other signal handlers that need to be initialized for JSC. This simplifies its initialization and ensures that it is done in a timely manner before Configs are frozen. * jsc.cpp: (jscmain): * runtime/InitializeThreading.cpp: (JSC::initializeThreading): 2020-05-12 Mark Lam Cherry-pick r260165, r261538. rdar://problem/63156083 2020-04-15 Robin Morisset Flaky Test: fetch/fetch-worker-crash.html https://bugs.webkit.org/show_bug.cgi?id=187257 Reviewed by Yusuke Suzuki. The crash is coming from setExceptionPorts which is inlined in WTF::registerThreadForMachExceptionHandling. From the error message we know that the problem is an "invalid port right". http://web.mit.edu/darwin/src/modules/xnu/osfmk/man/thread_set_exception_ports.html tells us that the "port right" is the third parameter to thread_set_exception_ports, which is exceptionPort in our case. exceptionPort is a global variable defined at the top of Signals.cpp: static mach_port_t exceptionPort; It is set in exactly one place: kern_return_t kr = mach_port_allocate(mach_task_self(), MACH_PORT_RIGHT_RECEIVE, &exceptionPort); in a std::call_once, in startMachExceptionHandlerThread(). Note that startMachExceptionHandlerThread() is called from the main thread just before the point where we are stuck.. and there is no synchronization to make sure it completed and its effect is visible to the worker thread before it uses exceptionPort. So I think the crash is due to this race between allocating exceptionPort and using it, resulting in an invalid exceptionPort being sometimes passed to the kernel. So this patch is a simple speculative fix, by running startMachExceptionHandlerThread() in initializeThreading(), before JSLock()::lock() can be run. * runtime/InitializeThreading.cpp: (JSC::initializeThreading): 2020-05-11 Mark Lam Introduce WTF::Config and put Signal.cpp's init-once globals in it. https://bugs.webkit.org/show_bug.cgi?id=211729 Reviewed by Keith Miller and Saam Barati. 1. Initialize VMTraps' signals early now that we'll be freezing signals at the end of the first VM initialization. 2. Move the !initializeThreadingHasBeenCalled RELEASE_ASSERT in initializeThreading() to the bottom of the function. This way, we'll also catch bugs which may cause us to jump into the middle of the function. Added a compilerFence there to ensure that the RELEASE_ASSERT is only executed after all initialization is done. This guarantees that it will only be executed at the end. 3. Call WTF::Config::permanentlyFreeze() from JSC::Config::permanentlyFreeze() for obvious reasons: freezing one should freeze the other. * runtime/InitializeThreading.cpp: (JSC::initializeThreading): * runtime/JSCConfig.cpp: (JSC::Config::permanentlyFreeze): * runtime/VMTraps.cpp: (JSC::VMTraps::initializeSignals): * runtime/VMTraps.h: 2020-04-18 Alex Christensen Branch build fix after r260286 https://bugs.webkit.org/show_bug.cgi?id=210583 The branch used ensureStillAliveHere but did not have the rename of that function in r258825, so this effectively merges that revision, too, to make the branch and trunk more similar. No change in behavior, just rename to successfully compile. * ftl/FTLLowerDFGToB3.cpp: (JSC::FTL::DFG::LowerDFGToB3::compileGetByVal): (JSC::FTL::DFG::LowerDFGToB3::compileArrayIndexOf): (JSC::FTL::DFG::LowerDFGToB3::compileArrayPop): (JSC::FTL::DFG::LowerDFGToB3::compileStringCharAt): (JSC::FTL::DFG::LowerDFGToB3::compileStringCharCodeAt): (JSC::FTL::DFG::LowerDFGToB3::compileStringCodePointAt): (JSC::FTL::DFG::LowerDFGToB3::compileGetByOffset): (JSC::FTL::DFG::LowerDFGToB3::compileMultiGetByOffset): 2020-04-17 Alan Coon Cherry-pick r260246. rdar://problem/61943700 offlineasm is generating the wrong load/store for the "orh" instruction. https://bugs.webkit.org/show_bug.cgi?id=210639 Reviewed by Robin Morisset. For example, on ARM64E, the "orh" instruction was generating the following: "\tldr w17, [x1, #0]\n" // JavaScriptCore/llint/LowLevelInterpreter64.asm:919 "\torr w17, w17, #64\n" // JavaScriptCore/llint/LowLevelInterpreter64.asm:919 "\tstr w17, [x1, #0]\n" // JavaScriptCore/llint/LowLevelInterpreter64.asm:919 i.e. a 32-bit load, followed by a 32-bit OR, followed by a 32-bit store. Instead, it should be generating the following: "\tldrh w17, [x1, #0]\n" // JavaScriptCore/llint/LowLevelInterpreter64.asm:919 "\torr w17, w17, #64\n" // JavaScriptCore/llint/LowLevelInterpreter64.asm:919 "\tstrh w17, [x1, #0]\n" // JavaScriptCore/llint/LowLevelInterpreter64.asm:919 i.e. a 16-bit load, followed by a 32-bit OR, followed by a 16-bit store. This bug also affects ARM64, ARMv7, and MIPS (basically any backend that uses riscLowerMisplacedAddresses() from rise.rb). It does not affect x86, x86_64, and C_LOOP (which was written based on x86). * offlineasm/risc.rb: git-svn-id: https://svn.webkit.org/repository/webkit/trunk@260246 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-04-17 Mark Lam offlineasm is generating the wrong load/store for the "orh" instruction. https://bugs.webkit.org/show_bug.cgi?id=210639 Reviewed by Robin Morisset. For example, on ARM64E, the "orh" instruction was generating the following: "\tldr w17, [x1, #0]\n" // JavaScriptCore/llint/LowLevelInterpreter64.asm:919 "\torr w17, w17, #64\n" // JavaScriptCore/llint/LowLevelInterpreter64.asm:919 "\tstr w17, [x1, #0]\n" // JavaScriptCore/llint/LowLevelInterpreter64.asm:919 i.e. a 32-bit load, followed by a 32-bit OR, followed by a 32-bit store. Instead, it should be generating the following: "\tldrh w17, [x1, #0]\n" // JavaScriptCore/llint/LowLevelInterpreter64.asm:919 "\torr w17, w17, #64\n" // JavaScriptCore/llint/LowLevelInterpreter64.asm:919 "\tstrh w17, [x1, #0]\n" // JavaScriptCore/llint/LowLevelInterpreter64.asm:919 i.e. a 16-bit load, followed by a 32-bit OR, followed by a 16-bit store. This bug also affects ARM64, ARMv7, and MIPS (basically any backend that uses riscLowerMisplacedAddresses() from rise.rb). It does not affect x86, x86_64, and C_LOOP (which was written based on x86). * offlineasm/risc.rb: 2020-04-17 Alan Coon Cherry-pick r260180. rdar://problem/61943707 [JSC] Use ensureStillAliveHere in FTL when content of storage should be kept alive https://bugs.webkit.org/show_bug.cgi?id=210583 Reviewed by Mark Lam. The content of Butterfly / ArrayStorage is kept alive only when the owner JSCell is alive. This means that we should keep the owner JSCell alive if we are loading content of storage which includes JSCells. This patch inserts ensureStillAliveHere in FTL to ensure this invariant. * ftl/FTLJITCode.cpp: (JSC::FTL::JITCode::~JITCode): Found that we get crash with `dumpDisassembly` if FTL::JITCode is destroyed while it fails to generate code while testing this. * ftl/FTLLowerDFGToB3.cpp: (JSC::FTL::DFG::LowerDFGToB3::compileGetByVal): (JSC::FTL::DFG::LowerDFGToB3::compileArrayIndexOf): (JSC::FTL::DFG::LowerDFGToB3::compileArrayPop): (JSC::FTL::DFG::LowerDFGToB3::compileStringCharAt): (JSC::FTL::DFG::LowerDFGToB3::compileStringCharCodeAt): (JSC::FTL::DFG::LowerDFGToB3::compileStringCodePointAt): (JSC::FTL::DFG::LowerDFGToB3::compileGetByOffset): (JSC::FTL::DFG::LowerDFGToB3::compileMultiGetByOffset): git-svn-id: https://svn.webkit.org/repository/webkit/trunk@260180 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-04-15 Yusuke Suzuki [JSC] Use ensureStillAliveHere in FTL when content of storage should be kept alive https://bugs.webkit.org/show_bug.cgi?id=210583 Reviewed by Mark Lam. The content of Butterfly / ArrayStorage is kept alive only when the owner JSCell is alive. This means that we should keep the owner JSCell alive if we are loading content of storage which includes JSCells. This patch inserts ensureStillAliveHere in FTL to ensure this invariant. * ftl/FTLJITCode.cpp: (JSC::FTL::JITCode::~JITCode): Found that we get crash with `dumpDisassembly` if FTL::JITCode is destroyed while it fails to generate code while testing this. * ftl/FTLLowerDFGToB3.cpp: (JSC::FTL::DFG::LowerDFGToB3::compileGetByVal): (JSC::FTL::DFG::LowerDFGToB3::compileArrayIndexOf): (JSC::FTL::DFG::LowerDFGToB3::compileArrayPop): (JSC::FTL::DFG::LowerDFGToB3::compileStringCharAt): (JSC::FTL::DFG::LowerDFGToB3::compileStringCharCodeAt): (JSC::FTL::DFG::LowerDFGToB3::compileStringCodePointAt): (JSC::FTL::DFG::LowerDFGToB3::compileGetByOffset): (JSC::FTL::DFG::LowerDFGToB3::compileMultiGetByOffset): 2020-04-17 Alan Coon Cherry-pick r259572. rdar://problem/61943713 [JSC] Put ensureStillAliveHere for Integer TypedArrays in GetByVal https://bugs.webkit.org/show_bug.cgi?id=210047 Reviewed by Mark Lam. While r258381 puts ensureStillAliveHere in FTL to keep base alive for float/double TypedArrays, we need to do the same thing for integer TypedArrays too. This patch places it. * ftl/FTLLowerDFGToB3.cpp: (JSC::FTL::DFG::LowerDFGToB3::compileGetByVal): git-svn-id: https://svn.webkit.org/repository/webkit/trunk@259572 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-04-06 Yusuke Suzuki [JSC] Put ensureStillAliveHere for Integer TypedArrays in GetByVal https://bugs.webkit.org/show_bug.cgi?id=210047 Reviewed by Mark Lam. While r258381 puts ensureStillAliveHere in FTL to keep base alive for float/double TypedArrays, we need to do the same thing for integer TypedArrays too. This patch places it. * ftl/FTLLowerDFGToB3.cpp: (JSC::FTL::DFG::LowerDFGToB3::compileGetByVal): 2020-04-06 Alan Coon Cherry-pick r259424. rdar://problem/61352472 [JSC] RecordedStatuses's assignment should be guarded by CodeBlock's lock https://bugs.webkit.org/show_bug.cgi?id=209935 Reviewed by Mark Lam. Previously RecordedStatuses are not touched by GC. But now, GC visits RecordedStatuses. This means that modifying RecordedStatuses should be guarded by CodeBlock's lock if it is reachable from CodeBlock. In DFG::Plan::reallyAdd, we already installed DFG::JITCode into the CodeBlock so that RecordedStatuses is reachable from CodeBlock. We should lock CodeBlock's lock while performing `WTFMove(RecordedStatuses)`. We do not need to emit write-barrier here because (1) DFG::Plan::reallyAdd is executed while GC is deferred and (2) we emit write-barrier to CodeBlock before deferred GC is executed. * dfg/DFGPlan.cpp: (JSC::DFG::Plan::reallyAdd): git-svn-id: https://svn.webkit.org/repository/webkit/trunk@259424 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-04-02 Yusuke Suzuki [JSC] RecordedStatuses's assignment should be guarded by CodeBlock's lock https://bugs.webkit.org/show_bug.cgi?id=209935 Reviewed by Mark Lam. Previously RecordedStatuses are not touched by GC. But now, GC visits RecordedStatuses. This means that modifying RecordedStatuses should be guarded by CodeBlock's lock if it is reachable from CodeBlock. In DFG::Plan::reallyAdd, we already installed DFG::JITCode into the CodeBlock so that RecordedStatuses is reachable from CodeBlock. We should lock CodeBlock's lock while performing `WTFMove(RecordedStatuses)`. We do not need to emit write-barrier here because (1) DFG::Plan::reallyAdd is executed while GC is deferred and (2) we emit write-barrier to CodeBlock before deferred GC is executed. * dfg/DFGPlan.cpp: (JSC::DFG::Plan::reallyAdd): 2020-04-06 Alan Coon Cherry-pick r259264. rdar://problem/61352442 [JSC] DFGArrayMode::alreadyChecked should have NonArray check when ArrayMode is NonArray+SlowPutArrayStorage https://bugs.webkit.org/show_bug.cgi?id=209791 Reviewed by Saam Barati. DFGArrayMode::alreadyChecked with NonArray+SlowPutArrayStorage should check NonArray condition. * dfg/DFGArrayMode.cpp: (JSC::DFG::ArrayMode::alreadyChecked const): * dfg/DFGArrayMode.h: (JSC::DFG::ArrayMode::arrayModesWithIndexingShapes const): git-svn-id: https://svn.webkit.org/repository/webkit/trunk@259264 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-03-30 Yusuke Suzuki [JSC] DFGArrayMode::alreadyChecked should have NonArray check when ArrayMode is NonArray+SlowPutArrayStorage https://bugs.webkit.org/show_bug.cgi?id=209791 Reviewed by Saam Barati. DFGArrayMode::alreadyChecked with NonArray+SlowPutArrayStorage should check NonArray condition. * dfg/DFGArrayMode.cpp: (JSC::DFG::ArrayMode::alreadyChecked const): * dfg/DFGArrayMode.h: (JSC::DFG::ArrayMode::arrayModesWithIndexingShapes const): 2020-04-03 Alan Coon Cherry-pick r259355. rdar://problem/61269744 Bindings that override getOwnPropertySlotByIndex need to say they MayHaveIndexedAccessors https://bugs.webkit.org/show_bug.cgi?id=209762 Reviewed by Darin Adler. Source/JavaScriptCore: Change indexingType to indexingModeIncludingHistory to more clearly indicate the expected range of possible valid values. * runtime/StructureInlines.h: (JSC::Structure::create): Source/WebCore: There may be places where we rely on this for semantic correctness. I couldn't find any right now but we might as well be conservative since this isn't a performance regression. * bindings/js/JSDOMWindowProperties.h: * bindings/scripts/CodeGeneratorJS.pm: (GenerateHeader): * bindings/scripts/test/JS/JSInterfaceName.h: (WebCore::JSInterfaceName::createStructure): * bindings/scripts/test/JS/JSMapLike.h: (WebCore::JSMapLike::createStructure): * bindings/scripts/test/JS/JSReadOnlyMapLike.h: (WebCore::JSReadOnlyMapLike::createStructure): * bindings/scripts/test/JS/JSReadOnlySetLike.h: (WebCore::JSReadOnlySetLike::createStructure): * bindings/scripts/test/JS/JSSetLike.h: (WebCore::JSSetLike::createStructure): * bindings/scripts/test/JS/JSTestActiveDOMObject.h: (WebCore::JSTestActiveDOMObject::createStructure): * bindings/scripts/test/JS/JSTestCEReactions.h: (WebCore::JSTestCEReactions::createStructure): * bindings/scripts/test/JS/JSTestCEReactionsStringifier.h: (WebCore::JSTestCEReactionsStringifier::createStructure): * bindings/scripts/test/JS/JSTestCallTracer.h: (WebCore::JSTestCallTracer::createStructure): * bindings/scripts/test/JS/JSTestClassWithJSBuiltinConstructor.h: (WebCore::JSTestClassWithJSBuiltinConstructor::createStructure): * bindings/scripts/test/JS/JSTestDOMJIT.h: (WebCore::JSTestDOMJIT::createStructure): * bindings/scripts/test/JS/JSTestEnabledBySetting.h: (WebCore::JSTestEnabledBySetting::createStructure): * bindings/scripts/test/JS/JSTestEnabledForContext.h: (WebCore::JSTestEnabledForContext::createStructure): * bindings/scripts/test/JS/JSTestEventConstructor.h: (WebCore::JSTestEventConstructor::createStructure): * bindings/scripts/test/JS/JSTestEventTarget.h: (WebCore::JSTestEventTarget::createStructure): * bindings/scripts/test/JS/JSTestException.h: (WebCore::JSTestException::createStructure): * bindings/scripts/test/JS/JSTestGenerateIsReachable.h: (WebCore::JSTestGenerateIsReachable::createStructure): * bindings/scripts/test/JS/JSTestGlobalObject.h: (WebCore::JSTestGlobalObject::createStructure): * bindings/scripts/test/JS/JSTestIndexedSetterNoIdentifier.h: (WebCore::JSTestIndexedSetterNoIdentifier::createStructure): * bindings/scripts/test/JS/JSTestIndexedSetterThrowingException.h: (WebCore::JSTestIndexedSetterThrowingException::createStructure): * bindings/scripts/test/JS/JSTestIndexedSetterWithIdentifier.h: (WebCore::JSTestIndexedSetterWithIdentifier::createStructure): * bindings/scripts/test/JS/JSTestInterface.h: * bindings/scripts/test/JS/JSTestInterfaceLeadingUnderscore.h: (WebCore::JSTestInterfaceLeadingUnderscore::createStructure): * bindings/scripts/test/JS/JSTestIterable.h: (WebCore::JSTestIterable::createStructure): * bindings/scripts/test/JS/JSTestJSBuiltinConstructor.h: (WebCore::JSTestJSBuiltinConstructor::createStructure): * bindings/scripts/test/JS/JSTestMediaQueryListListener.h: (WebCore::JSTestMediaQueryListListener::createStructure): * bindings/scripts/test/JS/JSTestNamedAndIndexedSetterNoIdentifier.h: (WebCore::JSTestNamedAndIndexedSetterNoIdentifier::createStructure): * bindings/scripts/test/JS/JSTestNamedAndIndexedSetterThrowingException.h: (WebCore::JSTestNamedAndIndexedSetterThrowingException::createStructure): * bindings/scripts/test/JS/JSTestNamedAndIndexedSetterWithIdentifier.h: (WebCore::JSTestNamedAndIndexedSetterWithIdentifier::createStructure): * bindings/scripts/test/JS/JSTestNamedConstructor.h: (WebCore::JSTestNamedConstructor::createStructure): * bindings/scripts/test/JS/JSTestNamedDeleterNoIdentifier.h: (WebCore::JSTestNamedDeleterNoIdentifier::createStructure): * bindings/scripts/test/JS/JSTestNamedDeleterThrowingException.h: (WebCore::JSTestNamedDeleterThrowingException::createStructure): * bindings/scripts/test/JS/JSTestNamedDeleterWithIdentifier.h: (WebCore::JSTestNamedDeleterWithIdentifier::createStructure): * bindings/scripts/test/JS/JSTestNamedDeleterWithIndexedGetter.h: (WebCore::JSTestNamedDeleterWithIndexedGetter::createStructure): * bindings/scripts/test/JS/JSTestNamedGetterCallWith.h: (WebCore::JSTestNamedGetterCallWith::createStructure): * bindings/scripts/test/JS/JSTestNamedGetterNoIdentifier.h: (WebCore::JSTestNamedGetterNoIdentifier::createStructure): * bindings/scripts/test/JS/JSTestNamedGetterWithIdentifier.h: (WebCore::JSTestNamedGetterWithIdentifier::createStructure): * bindings/scripts/test/JS/JSTestNamedSetterNoIdentifier.h: (WebCore::JSTestNamedSetterNoIdentifier::createStructure): * bindings/scripts/test/JS/JSTestNamedSetterThrowingException.h: (WebCore::JSTestNamedSetterThrowingException::createStructure): * bindings/scripts/test/JS/JSTestNamedSetterWithIdentifier.h: (WebCore::JSTestNamedSetterWithIdentifier::createStructure): * bindings/scripts/test/JS/JSTestNamedSetterWithIndexedGetter.h: (WebCore::JSTestNamedSetterWithIndexedGetter::createStructure): * bindings/scripts/test/JS/JSTestNamedSetterWithIndexedGetterAndSetter.h: (WebCore::JSTestNamedSetterWithIndexedGetterAndSetter::createStructure): * bindings/scripts/test/JS/JSTestNamedSetterWithOverrideBuiltins.h: (WebCore::JSTestNamedSetterWithOverrideBuiltins::createStructure): * bindings/scripts/test/JS/JSTestNamedSetterWithUnforgableProperties.h: (WebCore::JSTestNamedSetterWithUnforgableProperties::createStructure): * bindings/scripts/test/JS/JSTestNamedSetterWithUnforgablePropertiesAndOverrideBuiltins.h: (WebCore::JSTestNamedSetterWithUnforgablePropertiesAndOverrideBuiltins::createStructure): * bindings/scripts/test/JS/JSTestNode.h: * bindings/scripts/test/JS/JSTestObj.h: (WebCore::JSTestObj::createStructure): * bindings/scripts/test/JS/JSTestOverloadedConstructors.h: (WebCore::JSTestOverloadedConstructors::createStructure): * bindings/scripts/test/JS/JSTestOverloadedConstructorsWithSequence.h: (WebCore::JSTestOverloadedConstructorsWithSequence::createStructure): * bindings/scripts/test/JS/JSTestOverrideBuiltins.h: (WebCore::JSTestOverrideBuiltins::createStructure): * bindings/scripts/test/JS/JSTestPluginInterface.h: (WebCore::JSTestPluginInterface::createStructure): * bindings/scripts/test/JS/JSTestPromiseRejectionEvent.h: (WebCore::JSTestPromiseRejectionEvent::createStructure): * bindings/scripts/test/JS/JSTestSerialization.h: (WebCore::JSTestSerialization::createStructure): * bindings/scripts/test/JS/JSTestSerializationIndirectInheritance.h: (WebCore::JSTestSerializationIndirectInheritance::createStructure): * bindings/scripts/test/JS/JSTestSerializationInherit.h: (WebCore::JSTestSerializationInherit::createStructure): * bindings/scripts/test/JS/JSTestSerializationInheritFinal.h: (WebCore::JSTestSerializationInheritFinal::createStructure): * bindings/scripts/test/JS/JSTestSerializedScriptValueInterface.h: (WebCore::JSTestSerializedScriptValueInterface::createStructure): * bindings/scripts/test/JS/JSTestStringifier.h: (WebCore::JSTestStringifier::createStructure): * bindings/scripts/test/JS/JSTestStringifierAnonymousOperation.h: (WebCore::JSTestStringifierAnonymousOperation::createStructure): * bindings/scripts/test/JS/JSTestStringifierNamedOperation.h: (WebCore::JSTestStringifierNamedOperation::createStructure): * bindings/scripts/test/JS/JSTestStringifierOperationImplementedAs.h: (WebCore::JSTestStringifierOperationImplementedAs::createStructure): * bindings/scripts/test/JS/JSTestStringifierOperationNamedToString.h: (WebCore::JSTestStringifierOperationNamedToString::createStructure): * bindings/scripts/test/JS/JSTestStringifierReadOnlyAttribute.h: (WebCore::JSTestStringifierReadOnlyAttribute::createStructure): * bindings/scripts/test/JS/JSTestStringifierReadWriteAttribute.h: (WebCore::JSTestStringifierReadWriteAttribute::createStructure): * bindings/scripts/test/JS/JSTestTypedefs.h: (WebCore::JSTestTypedefs::createStructure): git-svn-id: https://svn.webkit.org/repository/webkit/trunk@259355 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-04-01 Keith Miller Bindings that override getOwnPropertySlotByIndex need to say they MayHaveIndexedAccessors https://bugs.webkit.org/show_bug.cgi?id=209762 Reviewed by Darin Adler. Change indexingType to indexingModeIncludingHistory to more clearly indicate the expected range of possible valid values. * runtime/StructureInlines.h: (JSC::Structure::create): 2020-03-30 Alan Coon Cherry-pick r258540. rdar://problem/61064830 [JSC] JSMapIterator and JSSetIterator are CellType https://bugs.webkit.org/show_bug.cgi?id=209168 Reviewed by Saam Barati. They are JSCell, not JSObject since they are not used as a user-observable set/map iterators in JSC. However, their JSType is ObjectType. They should use CellType instead. * runtime/JSMapIterator.h: * runtime/JSSetIterator.h: git-svn-id: https://svn.webkit.org/repository/webkit/trunk@258540 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-03-16 Yusuke Suzuki [JSC] JSMapIterator and JSSetIterator are CellType https://bugs.webkit.org/show_bug.cgi?id=209168 Reviewed by Saam Barati. They are JSCell, not JSObject since they are not used as a user-observable set/map iterators in JSC. However, their JSType is ObjectType. They should use CellType instead. * runtime/JSMapIterator.h: * runtime/JSSetIterator.h: 2020-03-30 Alan Coon Cherry-pick r258452. rdar://problem/61064799 Missing arithMode for ArithAbs and ArithNegate in DFGClobberize https://bugs.webkit.org/show_bug.cgi?id=208685 Reviewed by Saam Barati. In the pure case of ArithNegate and ArithAbs in DFGClobberize, their PureValues did not include their respective ArithMode. That means that e.g. a CheckOverflow ArithNegate/Abs could be considered equivalent to an Unchecked version of the same node. Thanks to Samuel Groß of Google Project Zero for identifying this bug. * dfg/DFGClobberize.h: (JSC::DFG::clobberize): git-svn-id: https://svn.webkit.org/repository/webkit/trunk@258452 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-03-13 Tadeu Zagallo Missing arithMode for ArithAbs and ArithNegate in DFGClobberize https://bugs.webkit.org/show_bug.cgi?id=208685 Reviewed by Saam Barati. In the pure case of ArithNegate and ArithAbs in DFGClobberize, their PureValues did not include their respective ArithMode. That means that e.g. a CheckOverflow ArithNegate/Abs could be considered equivalent to an Unchecked version of the same node. Thanks to Samuel Groß of Google Project Zero for identifying this bug. * dfg/DFGClobberize.h: (JSC::DFG::clobberize): b"2020-03-24 Russell Epstein \n\n Cherry-pick r258901. rdar://problem/60827028\n\n HasIndexedProperty should know about sane chain\n https://bugs.webkit.org/show_bug.cgi?id=209457\n \n Reviewed by Saam Barati.\n \n This patch makes it so HasIndexedProperty is aware of\n sane chain. This is useful because, most of the time we do an\n indexed in it is on an array. If the array has a sane chain (i.e.\n no indexed properties on it's prototypes and has the default\n prototype chain) then we can just test for the index being a hole.\n \n Note, we could also just convert OOB indices into false but that\n should happen in another patch.\n https://bugs.webkit.org/show_bug.cgi?id=209456\n \n I didn't add any tests because it turns out we already have a ton.\n I know this because I broke most of them repeatedly... >.>\n \n * dfg/DFGAbstractInterpreterInlines.h:\n (JSC::DFG::AbstractInterpreter::executeEffects):\n * dfg/DFGClobberize.h:\n (JSC::DFG::clobberize):\n * dfg/DFGFixupPhase.cpp:\n (JSC::DFG::FixupPhase::fixupNode):\n (JSC::DFG::FixupPhase::setSaneChainIfPossible):\n (JSC::DFG::FixupPhase::convertToHasIndexedProperty):\n * dfg/DFGNodeType.h:\n * dfg/DFGSpeculativeJIT.cpp:\n (JSC::DFG::SpeculativeJIT::compileHasIndexedProperty):\n * ftl/FTLLowerDFGToB3.cpp:\n (JSC::FTL::DFG::LowerDFGToB3::compileHasIndexedProperty):\n (JSC::FTL::DFG::LowerDFGToB3::speculateAndJump):\n * jit/AssemblyHelpers.h:\n (JSC::AssemblyHelpers::isEmpty):\n \n \n git-svn-id: https://svn.webkit.org/repository/webkit/trunk@258901 268f45cc-cd09-0410-ab3c-d52691b4dbfc\n\n 2020-03-23 Keith Miller \n\n HasIndexedProperty should know about sane chain\n https://bugs.webkit.org/show_bug.cgi?id=209457\n\n Reviewed by Saam Barati.\n\n This patch makes it so HasIndexedProperty is aware of\n sane chain. This is useful because, most of the time we do an\n indexed in it is on an array. If the array has a sane chain (i.e.\n no indexed properties on it's prototypes and has the default\n prototype chain) then we can just test for the index being a hole.\n\n Note, we could also just convert OOB indices into false but that\n should happen in another patch.\n https://bugs.webkit.org/show_bug.cgi?id=209456\n\n I didn't add any tests because it turns out we already have a ton.\n I know this because I broke most of them repeatedly... >.>\n\n * dfg/DFGAbstractInterpreterInlines.h:\n (JSC::DFG::AbstractInterpreter::executeEffects):\n * dfg/DFGClobberize.h:\n (JSC::DFG::clobberize):\n * dfg/DFGFixupPhase.cpp:\n (JSC::DFG::FixupPhase::fixupNode):\n (JSC::DFG::FixupPhase::setSaneChainIfPossible):\n (JSC::DFG::FixupPhase::convertToHasIndexedProperty):\n * dfg/DFGNodeType.h:\n * dfg/DFGSpeculativeJIT.cpp:\n (JSC::DFG::SpeculativeJIT::compileHasIndexedProperty):\n * ftl/FTLLowerDFGToB3.cpp:\n (JSC::FTL::DFG::LowerDFGToB3::compileHasIndexedProperty):\n (JSC::FTL::DFG::LowerDFGToB3::speculateAndJump):\n * jit/AssemblyHelpers.h:\n (JSC::AssemblyHelpers::isEmpty):\n\n"2020-03-17 Alan Coon Apply patch. rdar://problem/60396286 Cherry-pick r258062. rdar://problem/60396286 2020-03-06 David Kilzer REGRESSION (r258038): Build failure on Windows 10 bots * assembler/testmasm.cpp: (JSC::testCompareDouble): (JSC::testCompareDoubleSameArg): (JSC::testMoveConditionallyFloatingPoint): (JSC::testMoveConditionallyFloatingPointSameArg): - Add RELEASE_ASSERT_NOT_REACHED() statements to try to fix the bots. 2020-03-13 David Kilzer Cherry-pick r258062. rdar://problem/60396286 2020-03-06 David Kilzer REGRESSION (r258038): Build failure on Windows 10 bots * assembler/testmasm.cpp: (JSC::testCompareDouble): (JSC::testCompareDoubleSameArg): (JSC::testMoveConditionallyFloatingPoint): (JSC::testMoveConditionallyFloatingPointSameArg): - Add RELEASE_ASSERT_NOT_REACHED() statements to try to fix the bots. 2020-03-17 Alan Coon Apply patch. rdar://problem/60396286 Cherry-pick r258038. rdar://problem/60396286 2020-03-06 Mark Lam Fix some issues in the ARM64 moveConditionallyAfterFloatingPointCompare() and moveDoubleConditionallyAfterFloatingPointCompare(). https://bugs.webkit.org/show_bug.cgi?id=208731 Patch by Mark Lam on 2020-03-06 Reviewed by Saam Barati. Both the ARM64 moveConditionallyAfterFloatingPointCompare() and moveDoubleConditionallyAfterFloatingPointCompare() had the following issues: 1. For the DoubleNotEqual condition, they fail to set the result register if one or both of the comparison operands is a NaN. 2. For the DoubleEqualOrUnordered condition, they can clobber the else case input register if one of the comparison operands is a NaN. This patch fixes both of these, and exhaustive testmasm test cases for affected MacroAssembler instruction emitters using these functions. * assembler/MacroAssemblerARM64.h: (JSC::MacroAssemblerARM64::moveConditionallyAfterFloatingPointCompare): (JSC::MacroAssemblerARM64::moveDoubleConditionallyAfterFloatingPointCompare): * assembler/testmasm.cpp: (JSC::testCompareDouble): (JSC::testCompareDoubleSameArg): (JSC::testMoveConditionallyFloatingPoint): (JSC::testMoveConditionallyDouble2): (JSC::testMoveConditionallyDouble3): (JSC::testMoveConditionallyDouble3DestSameAsThenCase): (JSC::testMoveConditionallyDouble3DestSameAsElseCase): (JSC::testMoveConditionallyFloat2): (JSC::testMoveConditionallyFloat3): (JSC::testMoveConditionallyFloat3DestSameAsThenCase): (JSC::testMoveConditionallyFloat3DestSameAsElseCase): (JSC::testMoveDoubleConditionallyDouble): (JSC::testMoveDoubleConditionallyDoubleDestSameAsThenCase): (JSC::testMoveDoubleConditionallyDoubleDestSameAsElseCase): (JSC::testMoveDoubleConditionallyFloat): (JSC::testMoveDoubleConditionallyFloatDestSameAsThenCase): (JSC::testMoveDoubleConditionallyFloatDestSameAsElseCase): (JSC::testMoveConditionallyFloatingPointSameArg): (JSC::testMoveConditionallyDouble2SameArg): (JSC::testMoveConditionallyDouble3SameArg): (JSC::testMoveConditionallyFloat2SameArg): (JSC::testMoveConditionallyFloat3SameArg): (JSC::testMoveDoubleConditionallyDoubleSameArg): (JSC::testMoveDoubleConditionallyFloatSameArg): (JSC::run): 2020-03-13 David Kilzer Cherry-pick r258038. rdar://problem/60396286 2020-03-06 Mark Lam Fix some issues in the ARM64 moveConditionallyAfterFloatingPointCompare() and moveDoubleConditionallyAfterFloatingPointCompare(). https://bugs.webkit.org/show_bug.cgi?id=208731 Reviewed by Saam Barati. Both the ARM64 moveConditionallyAfterFloatingPointCompare() and moveDoubleConditionallyAfterFloatingPointCompare() had the following issues: 1. For the DoubleNotEqual condition, they fail to set the result register if one or both of the comparison operands is a NaN. 2. For the DoubleEqualOrUnordered condition, they can clobber the else case input register if one of the comparison operands is a NaN. This patch fixes both of these, and exhaustive testmasm test cases for affected MacroAssembler instruction emitters using these functions. * assembler/MacroAssemblerARM64.h: (JSC::MacroAssemblerARM64::moveConditionallyAfterFloatingPointCompare): (JSC::MacroAssemblerARM64::moveDoubleConditionallyAfterFloatingPointCompare): * assembler/testmasm.cpp: (JSC::testCompareDouble): (JSC::testCompareDoubleSameArg): (JSC::testMoveConditionallyFloatingPoint): (JSC::testMoveConditionallyDouble2): (JSC::testMoveConditionallyDouble3): (JSC::testMoveConditionallyDouble3DestSameAsThenCase): (JSC::testMoveConditionallyDouble3DestSameAsElseCase): (JSC::testMoveConditionallyFloat2): (JSC::testMoveConditionallyFloat3): (JSC::testMoveConditionallyFloat3DestSameAsThenCase): (JSC::testMoveConditionallyFloat3DestSameAsElseCase): (JSC::testMoveDoubleConditionallyDouble): (JSC::testMoveDoubleConditionallyDoubleDestSameAsThenCase): (JSC::testMoveDoubleConditionallyDoubleDestSameAsElseCase): (JSC::testMoveDoubleConditionallyFloat): (JSC::testMoveDoubleConditionallyFloatDestSameAsThenCase): (JSC::testMoveDoubleConditionallyFloatDestSameAsElseCase): (JSC::testMoveConditionallyFloatingPointSameArg): (JSC::testMoveConditionallyDouble2SameArg): (JSC::testMoveConditionallyDouble3SameArg): (JSC::testMoveConditionallyFloat2SameArg): (JSC::testMoveConditionallyFloat3SameArg): (JSC::testMoveDoubleConditionallyDoubleSameArg): (JSC::testMoveDoubleConditionallyFloatSameArg): (JSC::run): 2020-03-17 Alan Coon Cherry-pick r258381. rdar://problem/60539195 DFG nodes that take a TypedArray's storage need to keepAlive the TypedArray https://bugs.webkit.org/show_bug.cgi?id=209035 Reviewed by Saam Barati. It might be possible to produce a graph where the last reference to a TypedArray is via a GetByVal or PutByVal. Since those nodes don't create any reference to the TypedArray in B3 we may end up not keeping the TypedArray alive until after the storage access. * ftl/FTLLowerDFGToB3.cpp: (JSC::FTL::DFG::LowerDFGToB3::compileAtomicsReadModifyWrite): (JSC::FTL::DFG::LowerDFGToB3::compileGetByVal): (JSC::FTL::DFG::LowerDFGToB3::compilePutByVal): git-svn-id: https://svn.webkit.org/repository/webkit/trunk@258381 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-03-12 Keith Miller DFG nodes that take a TypedArray's storage need to keepAlive the TypedArray https://bugs.webkit.org/show_bug.cgi?id=209035 Reviewed by Saam Barati. It might be possible to produce a graph where the last reference to a TypedArray is via a GetByVal or PutByVal. Since those nodes don't create any reference to the TypedArray in B3 we may end up not keeping the TypedArray alive until after the storage access. * ftl/FTLLowerDFGToB3.cpp: (JSC::FTL::DFG::LowerDFGToB3::compileAtomicsReadModifyWrite): (JSC::FTL::DFG::LowerDFGToB3::compileGetByVal): (JSC::FTL::DFG::LowerDFGToB3::compilePutByVal): 2020-03-09 Alan Coon Apply patch. rdar://problem/60183769 2020-03-09 Yusuke Suzuki [JSC] @hasOwnLengthProperty returns wrong value if "length" is attempted to be modified https://bugs.webkit.org/show_bug.cgi?id=208497 Reviewed by Mark Lam. When "length" of JSFunction is attempted to be modified, we put a flag. And @hasOwnLengthProperty does not correctly use this flag to return a value for the fast path. This affects on "length" property of bound functions. For example, function userFunction(a) { } userFunction.length = 20; // This field is read-only. So, it is not changed. userFunction.bind().length; // Should be 1, but it returns 0. 1. We rename m_hasModifiedLength to m_hasModifiedLengthForNonHostFunction and m_hasModifiedName to m_hasModifiedNameForNonHostFunction since we are not tracking these states for host-functions which can eagerly initialize them. 2. We rename areNameAndLengthOriginal to canAssumeNameAndLengthAreOriginal to allow it to return "false" for host functions. If it returns true, we go to the fast path. 3. Correctly use canAssumeNameAndLengthAreOriginal information in @hasOwnLengthProperty. * runtime/FunctionRareData.cpp: (JSC::FunctionRareData::FunctionRareData): * runtime/FunctionRareData.h: * runtime/JSFunction.cpp: (JSC::JSFunction::put): (JSC::JSFunction::deleteProperty): (JSC::JSFunction::defineOwnProperty): * runtime/JSFunction.h: * runtime/JSFunctionInlines.h: (JSC::JSFunction::canAssumeNameAndLengthAreOriginal): (JSC::JSFunction::areNameAndLengthOriginal): Deleted. * runtime/JSGlobalObject.cpp: (JSC::hasOwnLengthProperty): * tools/JSDollarVM.cpp: (JSC::functionHasOwnLengthProperty): 2020-03-09 Alan Coon Cherry-pick r257605. rdar://problem/59870340 Poly proto should work with property delete transitions https://bugs.webkit.org/show_bug.cgi?id=208261 Reviewed by Saam Barati. JSTests: * stress/delete-property-poly-proto.js: Added. (A.prototype.set x): (A): (B): Source/JavaScriptCore: This patch fixes a bug where the combination of inline caching and poly proto cause us to cache a setter call along a prototype chain that is no longer the correct setter to call. This is exposed as a result of https://bugs.webkit.org/show_bug.cgi?id=206430 since DefineOwnProperty used to transition to uncacheable dictionary. The case looks like this: A - setter for x redefines x | B | C We set (new C).x Right now, we first call A's setter, then we try to figure out what the state of things were before it was called in order to cache it. We just assume that A's setter still exists, and we cache it without ever checking, In this patch, we ensure that the property exists and the attributes match in order to prevent crashing. In the code, A = target, C = base. Get is correct because it collects caching information before any calls. The bug https://bugs.webkit.org/show_bug.cgi?id=208337 tracks the remaining semantic bugs around this code. * jit/Repatch.cpp: (JSC::tryCachePutByID): git-svn-id: https://svn.webkit.org/repository/webkit/trunk@257605 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-02-27 Justin Michaud Poly proto should work with property delete transitions https://bugs.webkit.org/show_bug.cgi?id=208261 Reviewed by Saam Barati. This patch fixes a bug where the combination of inline caching and poly proto cause us to cache a setter call along a prototype chain that is no longer the correct setter to call. This is exposed as a result of https://bugs.webkit.org/show_bug.cgi?id=206430 since DefineOwnProperty used to transition to uncacheable dictionary. The case looks like this: A - setter for x redefines x | B | C We set (new C).x Right now, we first call A's setter, then we try to figure out what the state of things were before it was called in order to cache it. We just assume that A's setter still exists, and we cache it without ever checking, In this patch, we ensure that the property exists and the attributes match in order to prevent crashing. In the code, A = target, C = base. Get is correct because it collects caching information before any calls. The bug https://bugs.webkit.org/show_bug.cgi?id=208337 tracks the remaining semantic bugs around this code. * jit/Repatch.cpp: (JSC::tryCachePutByID): 2020-03-09 Alan Coon Cherry-pick r255542. rdar://problem/59870340 [JSC] Hold StructureID instead of Structure* in PolyProtoAccessChain and DFG::CommonData https://bugs.webkit.org/show_bug.cgi?id=207086 Reviewed by Mark Lam. PolyProtoAccessChain and DFG::CommonData are kept alive so long as associated AccessCase / DFG/FTL CodeBlock is alive. They hold Vector / Vector>, but access frequency is low. And We should hold Vector instead to cut 50% of the size. * bytecode/AccessCase.cpp: (JSC::AccessCase::commit): (JSC::AccessCase::forEachDependentCell const): (JSC::AccessCase::doesCalls const): (JSC::AccessCase::visitWeak const): (JSC::AccessCase::propagateTransitions const): (JSC::AccessCase::generateWithGuard): * bytecode/AccessCase.h: * bytecode/CodeBlock.cpp: (JSC::CodeBlock::propagateTransitions): (JSC::CodeBlock::determineLiveness): (JSC::CodeBlock::stronglyVisitWeakReferences): * bytecode/GetByStatus.cpp: (JSC::GetByStatus::computeForStubInfoWithoutExitSiteFeedback): * bytecode/InByIdStatus.cpp: (JSC::InByIdStatus::computeFor): (JSC::InByIdStatus::computeForStubInfo): (JSC::InByIdStatus::computeForStubInfoWithoutExitSiteFeedback): * bytecode/InByIdStatus.h: * bytecode/InstanceOfStatus.cpp: (JSC::InstanceOfStatus::computeFor): (JSC::InstanceOfStatus::computeForStubInfo): * bytecode/InstanceOfStatus.h: * bytecode/PolyProtoAccessChain.cpp: (JSC::PolyProtoAccessChain::create): (JSC::PolyProtoAccessChain::needImpurePropertyWatchpoint const): (JSC::PolyProtoAccessChain::dump const): * bytecode/PolyProtoAccessChain.h: (JSC::PolyProtoAccessChain::chain const): (JSC::PolyProtoAccessChain::forEach const): (JSC::PolyProtoAccessChain::slotBaseStructure const): (JSC::PolyProtoAccessChain:: const): Deleted. * bytecode/PolymorphicAccess.cpp: (JSC::PolymorphicAccess::regenerate): * bytecode/PutByIdStatus.cpp: (JSC::PutByIdStatus::computeForStubInfo): * bytecode/StructureStubInfo.cpp: (JSC::StructureStubInfo::summary const): (JSC::StructureStubInfo::summary): * bytecode/StructureStubInfo.h: * dfg/DFGCommonData.h: * dfg/DFGDesiredWeakReferences.cpp: (JSC::DFG::DesiredWeakReferences::reallyAdd): * dfg/DFGPlan.cpp: (JSC::DFG::Plan::finalizeWithoutNotifyingCallback): * jit/Repatch.cpp: (JSC::tryCacheGetBy): (JSC::tryCachePutByID): (JSC::tryCacheInByID): git-svn-id: https://svn.webkit.org/repository/webkit/trunk@255542 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-01-31 Yusuke Suzuki [JSC] Hold StructureID instead of Structure* in PolyProtoAccessChain and DFG::CommonData https://bugs.webkit.org/show_bug.cgi?id=207086 Reviewed by Mark Lam. PolyProtoAccessChain and DFG::CommonData are kept alive so long as associated AccessCase / DFG/FTL CodeBlock is alive. They hold Vector / Vector>, but access frequency is low. And We should hold Vector instead to cut 50% of the size. * bytecode/AccessCase.cpp: (JSC::AccessCase::commit): (JSC::AccessCase::forEachDependentCell const): (JSC::AccessCase::doesCalls const): (JSC::AccessCase::visitWeak const): (JSC::AccessCase::propagateTransitions const): (JSC::AccessCase::generateWithGuard): * bytecode/AccessCase.h: * bytecode/CodeBlock.cpp: (JSC::CodeBlock::propagateTransitions): (JSC::CodeBlock::determineLiveness): (JSC::CodeBlock::stronglyVisitWeakReferences): * bytecode/GetByStatus.cpp: (JSC::GetByStatus::computeForStubInfoWithoutExitSiteFeedback): * bytecode/InByIdStatus.cpp: (JSC::InByIdStatus::computeFor): (JSC::InByIdStatus::computeForStubInfo): (JSC::InByIdStatus::computeForStubInfoWithoutExitSiteFeedback): * bytecode/InByIdStatus.h: * bytecode/InstanceOfStatus.cpp: (JSC::InstanceOfStatus::computeFor): (JSC::InstanceOfStatus::computeForStubInfo): * bytecode/InstanceOfStatus.h: * bytecode/PolyProtoAccessChain.cpp: (JSC::PolyProtoAccessChain::create): (JSC::PolyProtoAccessChain::needImpurePropertyWatchpoint const): (JSC::PolyProtoAccessChain::dump const): * bytecode/PolyProtoAccessChain.h: (JSC::PolyProtoAccessChain::chain const): (JSC::PolyProtoAccessChain::forEach const): (JSC::PolyProtoAccessChain::slotBaseStructure const): (JSC::PolyProtoAccessChain:: const): Deleted. * bytecode/PolymorphicAccess.cpp: (JSC::PolymorphicAccess::regenerate): * bytecode/PutByIdStatus.cpp: (JSC::PutByIdStatus::computeForStubInfo): * bytecode/StructureStubInfo.cpp: (JSC::StructureStubInfo::summary const): (JSC::StructureStubInfo::summary): * bytecode/StructureStubInfo.h: * dfg/DFGCommonData.h: * dfg/DFGDesiredWeakReferences.cpp: (JSC::DFG::DesiredWeakReferences::reallyAdd): * dfg/DFGPlan.cpp: (JSC::DFG::Plan::finalizeWithoutNotifyingCallback): * jit/Repatch.cpp: (JSC::tryCacheGetBy): (JSC::tryCachePutByID): (JSC::tryCacheInByID): 2020-02-21 Russell Epstein Apply patch. rdar://problem/59654268 2020-02-21 Justin Michaud Deleting a property should not turn structures into uncacheable dictionaries https://bugs.webkit.org/show_bug.cgi?id=206430 Reviewed by Yusuke Suzuki. Right now, deleteProperty/removePropertyTransition causes a structure transition to uncacheable dictionary. Instead, we should allow it to transition to a new regular structure like adding a property does. This means that we have to: 1) Break the assumption that structure transition offsets increase monotonically We add a new flag to tell that a structure has deleted its property, and update materializePropertyTable to use it. 2) Add a new transition map and transition kind for deletes We cache the delete transition. We will not transition back to a previous structure if you add then immediately remove a property. 3) Find some heuristic for when we should actually transition to uncacheable dictionary. Since deleting properties is expected to be rare, we just walk the structure list and count its size on removal. This patch also fixes a related bug in addProperty, where we did not use a GCSafeConcurrentJSLocker, and adds an option to trigger the bug. Finally, we add some helper methods to dollarVM to test. This gives a 24x speedup on delete-property-keeps-cacheable-structure.js, and is neutral on delete-property-from-prototype-chain.js (which was already generating code using the inline cache). * heap/HeapInlines.h: (JSC::Heap::decrementDeferralDepthAndGCIfNeeded): * runtime/JSObject.cpp: (JSC::JSObject::deleteProperty): * runtime/OptionsList.h: * runtime/PropertyMapHashTable.h: (JSC::PropertyTable::get): (JSC::PropertyTable::add): (JSC::PropertyTable::addDeletedOffset): (JSC::PropertyTable::reinsert): * runtime/Structure.cpp: (JSC::StructureTransitionTable::contains const): (JSC::StructureTransitionTable::get const): (JSC::StructureTransitionTable::add): (JSC::Structure::Structure): (JSC::Structure::materializePropertyTable): (JSC::Structure::addNewPropertyTransition): (JSC::Structure::removePropertyTransition): (JSC::Structure::removePropertyTransitionFromExistingStructure): (JSC::Structure::removeNewPropertyTransition): (JSC::Structure::toUncacheableDictionaryTransition): (JSC::Structure::remove): (JSC::Structure::visitChildren): * runtime/Structure.h: * runtime/StructureInlines.h: (JSC::Structure::forEachPropertyConcurrently): (JSC::Structure::add): (JSC::Structure::remove): (JSC::Structure::removePropertyWithoutTransition): * runtime/StructureTransitionTable.h: (JSC::StructureTransitionTable::Hash::hash): * tools/JSDollarVM.cpp: (JSC::JSDollarVMHelper::functionGetStructureTransitionList): (JSC::functionGetConcurrently): (JSC::JSDollarVM::finishCreation): 2020-02-04 Yusuke Suzuki [JSC] Structure::setMaxOffset and setTransitionOffset are racy https://bugs.webkit.org/show_bug.cgi?id=207249 Reviewed by Mark Lam. We hit crash in JSTests/stress/array-slice-osr-exit-2.js. The situation is following. 1. The mutator thread (A) is working. 2. The concurrent collector (B) is working. 3. A attempts to set m_maxOffset in StructureRareData by allocating it. First, A sets Structure::m_maxOffset to useRareDataFlag. 3. B is in JSObject::visitButterflyImpl, and executing Structure::maxOffset(). 4. B detects that m_maxOffset is useRareDataFlag. 5. B attempts to load rareData, but this is not a StructureRareData since A is just now setting up StructureRareData. 6. B crashes. Set useRareDataFlag after StructureRareData is set. Ensuring this store-order by using storeStoreFence. * runtime/Structure.h: 2020-01-29 Justin Michaud Fix small memory regression caused by r206365 https://bugs.webkit.org/show_bug.cgi?id=206557 Reviewed by Yusuke Suzuki. Put StructureRareData::m_giveUpOnObjectToStringValueCache into m_objectToStringValue to prevent increasing StructureRareData's size. We make a special value for the pointer objectToStringCacheGiveUpMarker() to signal that we should not cache the string value. As a result, adding m_transitionOffset does not increase the size of the class. * runtime/Structure.h: * runtime/StructureRareData.cpp: (JSC::StructureRareData::StructureRareData): (JSC::StructureRareData::visitChildren): (JSC::StructureRareData::setObjectToStringValue): (JSC::StructureRareData::clearObjectToStringValue): * runtime/StructureRareData.h: * runtime/StructureRareDataInlines.h: (JSC::StructureRareData::objectToStringValue const): 2020-01-17 Justin Michaud Separate storage of Structure::m_offset into transition and max offset https://bugs.webkit.org/show_bug.cgi?id=206365 Reviewed by Saam Barati. Right now, deleteProperty/removePropertyTransition causes a structure transition to uncacheable dictionary. Other transitions assume that the transition offset (m_offset) is monotonically increasing. In order to support structure transitions for deletion that do not involve turning into a dictionary (), we first need to separate the transition offset (the offset of the property that was added/deleted) from the maximum offset. For example, suppose we have the following operations: Structure 1 (pinned property table, transitionOffset = _, maxOffset = 2): x y z (delete y, assuming that deletion transitions have been added) Structure 2 (transitionOffset = 1, maxOffset = 2): x _ z (add w) Structure 3 (transitionOffset = 1, maxOffset = 2): x w z Note that without splitting the two, Structures 2/3 would be impossible to represent. This change: We split the existing Structure::m_offset into two 16-bit fields, transitionOffset and maxOffset, and put them in 32-bit rare data fields if they overflow. We also rename _inPrevious fields to transition_ and lastOffset to maxOffset to make the code more clear. * runtime/ClonedArguments.cpp: (JSC::ClonedArguments::createStructure): * runtime/JSObject.cpp: (JSC::JSObject::markAuxiliaryAndVisitOutOfLineProperties): (JSC::JSObject::visitButterflyImpl): * runtime/JSObject.h: * runtime/JSObjectInlines.h: (JSC::JSObject::prepareToPutDirectWithoutTransition): * runtime/ObjectInitializationScope.cpp: (JSC::ObjectInitializationScope::verifyPropertiesAreInitialized): * runtime/PropertyOffset.h: (JSC::numberOfOutOfLineSlotsForMaxOffset): (JSC::numberOfSlotsForMaxOffset): (JSC::numberOfOutOfLineSlotsForLastOffset): Deleted. (JSC::numberOfSlotsForLastOffset): Deleted. * runtime/Structure.cpp: (JSC::StructureTransitionTable::contains const): (JSC::StructureTransitionTable::get const): (JSC::StructureTransitionTable::add): (JSC::Structure::Structure): (JSC::Structure::create): (JSC::Structure::materializePropertyTable): (JSC::Structure::addPropertyTransitionToExistingStructureImpl): (JSC::Structure::addNewPropertyTransition): (JSC::Structure::changePrototypeTransition): (JSC::Structure::attributeChangeTransition): (JSC::Structure::toDictionaryTransition): (JSC::Structure::nonPropertyTransitionSlow): (JSC::Structure::flattenDictionaryStructure): (JSC::Structure::pin): (JSC::Structure::pinForCaching): (JSC::Structure::add): * runtime/Structure.h: * runtime/StructureInlines.h: (JSC::Structure::forEachPropertyConcurrently): (JSC::Structure::checkOffsetConsistency const): (JSC::Structure::add): * runtime/StructureRareData.cpp: (JSC::StructureRareData::StructureRareData): * runtime/StructureRareData.h: 2020-02-21 Russell Epstein Cherry-pick r257134. rdar://problem/59676907 Make support for bytecode caching more robust against file corruption. https://bugs.webkit.org/show_bug.cgi?id=207972 Reviewed by Yusuke Suzuki. If a bytecode cache file is corrupted, we currently will always crash every time we try to read it (in perpetuity as long as the corrupted cache file continues to exist on disk). To guard against this, we'll harden the bytecode caching mechanism as follows: 1. Modify the writeCache operation to always write the cache file in a transactional manner i.e. we'll first write to a .tmp file, and then rename the .tmp file to the cache file only if the entire file has been written in completeness. This ensures that we won't get corrupted cache files due to interrupted writes. 2. Modify the writeCache operation to also compute a SHA1 hash of the cache file and append the hash at end of the file. Modify the readCache operation to first authenticate the SHA1 hash before allowing the cache file to be used. If the hash does not match, the file is bad, and we'll just delete it. This ensures that we won't be crashing while decoding a corrupted cache file. Manually tested with the following scenarios and ensuring that the client recovers with no crashes: 1. no cache file on disk. 2. a 0-sized cache file on a disk. 3. a truncated cache file on disk. 4. a corrupted cache file on disk. 5. an uncorrupted cache file on disk. Also added some static_asserts in CachedTypes.cpp to document some invariants that the pre-existing code is dependent on. * API/JSScript.mm: (-[JSScript readCache]): (-[JSScript writeCache:]): * runtime/CachedTypes.cpp: git-svn-id: https://svn.webkit.org/repository/webkit/trunk@257134 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-02-20 Mark Lam Make support for bytecode caching more robust against file corruption. https://bugs.webkit.org/show_bug.cgi?id=207972 Reviewed by Yusuke Suzuki. If a bytecode cache file is corrupted, we currently will always crash every time we try to read it (in perpetuity as long as the corrupted cache file continues to exist on disk). To guard against this, we'll harden the bytecode caching mechanism as follows: 1. Modify the writeCache operation to always write the cache file in a transactional manner i.e. we'll first write to a .tmp file, and then rename the .tmp file to the cache file only if the entire file has been written in completeness. This ensures that we won't get corrupted cache files due to interrupted writes. 2. Modify the writeCache operation to also compute a SHA1 hash of the cache file and append the hash at end of the file. Modify the readCache operation to first authenticate the SHA1 hash before allowing the cache file to be used. If the hash does not match, the file is bad, and we'll just delete it. This ensures that we won't be crashing while decoding a corrupted cache file. Manually tested with the following scenarios and ensuring that the client recovers with no crashes: 1. no cache file on disk. 2. a 0-sized cache file on a disk. 3. a truncated cache file on disk. 4. a corrupted cache file on disk. 5. an uncorrupted cache file on disk. Also added some static_asserts in CachedTypes.cpp to document some invariants that the pre-existing code is dependent on. * API/JSScript.mm: (-[JSScript readCache]): (-[JSScript writeCache:]): * runtime/CachedTypes.cpp: 2020-02-19 Alan Coon Apply patch. rdar://problem/59611919 2020-02-19 Yusuke Suzuki [JSC] Compact StructureTransitionTable https://bugs.webkit.org/show_bug.cgi?id=207616 Reviewed by Mark Lam. Some of StructureTransitionTable are shown as very large HashMap and we can compact it by encoding key. We leverage 48bit pointers and 8byte alignment of UniquedStringImpl* to encode other parameters into it. * runtime/Structure.cpp: (JSC::StructureTransitionTable::contains const): (JSC::StructureTransitionTable::get const): (JSC::StructureTransitionTable::add): * runtime/Structure.h: * runtime/StructureTransitionTable.h: (JSC::StructureTransitionTable::Hash::Key::Key): (JSC::StructureTransitionTable::Hash::Key::isHashTableDeletedValue const): (JSC::StructureTransitionTable::Hash::Key::impl const): (JSC::StructureTransitionTable::Hash::Key::isAddition const): (JSC::StructureTransitionTable::Hash::Key::attributes const): (JSC::StructureTransitionTable::Hash::Key::operator==): (JSC::StructureTransitionTable::Hash::Key::operator!=): (JSC::StructureTransitionTable::Hash::hash): (JSC::StructureTransitionTable::Hash::equal): 2020-02-18 Simon Fraser Unreviewed build fix. * jit/JITThunks.cpp: (JSC::JITThunks::hostFunctionStub): 2020-02-18 Alan Coon Cherry-pick r256779. rdar://problem/59551695 [JSC] JITThunk should be HashSet> with appropriate GC weakness handling https://bugs.webkit.org/show_bug.cgi?id=207715 Reviewed by Darin Adler. JSTests: * stress/stress-jitthunks.js: Added. (let.set newGlobal): (set catch): Source/JavaScriptCore: This patch refines JITThunks GC-aware Weak hash map for NativeExecutable. Previously, we have HashMap, Weak> table. But this is not good because the first tuple's information is already in NativeExecutable. But we were using this design since Weak can be nullified because of Weak<>. If this happens, we could have invalid Entry in HashMap which does not have corresponding values. This will cause crash when rehasing requires hash code for this entry. But this HashMap is very bad in terms of memory usage. Each entry has 32 bytes, and this table gets enough large. We identified that this table is consuming much memory in Membuster. So it is worth designing carefully crafted data structure which only holds Weak by leveraging the deep interaction with our GC implementation. This patch implements new design of JITThunks, which uses HashSet> and carefully crafted HashTraits / KeyTraits to handle Weak<> well. 1. Each Weak should have finalizer, and this finalizer should remove dead Weak from HashSet. This is ensuring that all the keys in HashSet is, even if Weak<> is saying it is Dead, it still has an way to access content of NativeExecutable if the content is not a JS objects. For example, we can get function pointer from dead Weak if it is not yet finalized. Since we remove all finalized Weak<> from the table, this finalizer mechanism allows us to access function pointers etc. from Weak so long as it is held in this table. 2. Getting NativeExecutable* from JITThunks should have special protocol. When getting NativeExecutable* from JITThunks, we do the following, 1. First, we check we have an Entry in JITThunks. If it does not exist, we should insert it anyway. 1.1. If it exists, we should check whether this Weak is dead or not. It is possible that dead one is still in the table because "dead" does not mean that it is "finalized". Until finalizing happens (and it can be delayed by incremental-sweeper), Weak can be dead but still accessible. So the table is still holding dead one. If we get dead one, we should insert a new one. 1.2. If it is not dead, we return it. 2. Second, we create a new NativeExecutable and insert it. In that case, it is possible that the table already has Weak, but it is dead. In that case, we need to explicitly replace it with newly created one since old one is holding old content. If we replaced, finalizer of Weak<> will not be invoked since it immediately deallocates Weak<>. So, it does not happen that this newly inserted NativeExecutable* is removed by the finalizer registered by the old Weak<>. This change makes memory usage of JITThunks table 1/4. * heap/Weak.cpp: (JSC::weakClearSlowCase): * heap/Weak.h: (JSC::Weak::Weak): (JSC::Weak::isHashTableEmptyValue const): (JSC::Weak::unsafeImpl const): (WTF::HashTraits>::isEmptyValue): * heap/WeakInlines.h: (JSC::Weak::Weak): * jit/JITThunks.cpp: (JSC::JITThunks::JITThunks): (JSC::JITThunks::WeakNativeExecutableHash::hash): (JSC::JITThunks::WeakNativeExecutableHash::equal): (JSC::JITThunks::HostKeySearcher::hash): (JSC::JITThunks::HostKeySearcher::equal): (JSC::JITThunks::NativeExecutableTranslator::hash): (JSC::JITThunks::NativeExecutableTranslator::equal): (JSC::JITThunks::NativeExecutableTranslator::translate): (JSC::JITThunks::finalize): (JSC::JITThunks::hostFunctionStub): (JSC::JITThunks::clearHostFunctionStubs): Deleted. * jit/JITThunks.h: * runtime/NativeExecutable.h: * tools/JSDollarVM.cpp: (JSC::functionGCSweepAsynchronously): (JSC::functionCreateEmptyFunctionWithName): (JSC::JSDollarVM::finishCreation): git-svn-id: https://svn.webkit.org/repository/webkit/trunk@256779 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-02-17 Yusuke Suzuki [JSC] JITThunk should be HashSet> with appropriate GC weakness handling https://bugs.webkit.org/show_bug.cgi?id=207715 Reviewed by Darin Adler. This patch refines JITThunks GC-aware Weak hash map for NativeExecutable. Previously, we have HashMap, Weak> table. But this is not good because the first tuple's information is already in NativeExecutable. But we were using this design since Weak can be nullified because of Weak<>. If this happens, we could have invalid Entry in HashMap which does not have corresponding values. This will cause crash when rehasing requires hash code for this entry. But this HashMap is very bad in terms of memory usage. Each entry has 32 bytes, and this table gets enough large. We identified that this table is consuming much memory in Membuster. So it is worth designing carefully crafted data structure which only holds Weak by leveraging the deep interaction with our GC implementation. This patch implements new design of JITThunks, which uses HashSet> and carefully crafted HashTraits / KeyTraits to handle Weak<> well. 1. Each Weak should have finalizer, and this finalizer should remove dead Weak from HashSet. This is ensuring that all the keys in HashSet is, even if Weak<> is saying it is Dead, it still has an way to access content of NativeExecutable if the content is not a JS objects. For example, we can get function pointer from dead Weak if it is not yet finalized. Since we remove all finalized Weak<> from the table, this finalizer mechanism allows us to access function pointers etc. from Weak so long as it is held in this table. 2. Getting NativeExecutable* from JITThunks should have special protocol. When getting NativeExecutable* from JITThunks, we do the following, 1. First, we check we have an Entry in JITThunks. If it does not exist, we should insert it anyway. 1.1. If it exists, we should check whether this Weak is dead or not. It is possible that dead one is still in the table because "dead" does not mean that it is "finalized". Until finalizing happens (and it can be delayed by incremental-sweeper), Weak can be dead but still accessible. So the table is still holding dead one. If we get dead one, we should insert a new one. 1.2. If it is not dead, we return it. 2. Second, we create a new NativeExecutable and insert it. In that case, it is possible that the table already has Weak, but it is dead. In that case, we need to explicitly replace it with newly created one since old one is holding old content. If we replaced, finalizer of Weak<> will not be invoked since it immediately deallocates Weak<>. So, it does not happen that this newly inserted NativeExecutable* is removed by the finalizer registered by the old Weak<>. This change makes memory usage of JITThunks table 1/4. * heap/Weak.cpp: (JSC::weakClearSlowCase): * heap/Weak.h: (JSC::Weak::Weak): (JSC::Weak::isHashTableEmptyValue const): (JSC::Weak::unsafeImpl const): (WTF::HashTraits>::isEmptyValue): * heap/WeakInlines.h: (JSC::Weak::Weak): * jit/JITThunks.cpp: (JSC::JITThunks::JITThunks): (JSC::JITThunks::WeakNativeExecutableHash::hash): (JSC::JITThunks::WeakNativeExecutableHash::equal): (JSC::JITThunks::HostKeySearcher::hash): (JSC::JITThunks::HostKeySearcher::equal): (JSC::JITThunks::NativeExecutableTranslator::hash): (JSC::JITThunks::NativeExecutableTranslator::equal): (JSC::JITThunks::NativeExecutableTranslator::translate): (JSC::JITThunks::finalize): (JSC::JITThunks::hostFunctionStub): (JSC::JITThunks::clearHostFunctionStubs): Deleted. * jit/JITThunks.h: * runtime/NativeExecutable.h: * tools/JSDollarVM.cpp: (JSC::functionGCSweepAsynchronously): (JSC::functionCreateEmptyFunctionWithName): (JSC::JSDollarVM::finishCreation): 2020-02-18 Alan Coon Cherry-pick r256766. rdar://problem/59551706 [Wasm] REGRESSION(r256665): Wasm->JS call IC needs to save memory size register https://bugs.webkit.org/show_bug.cgi?id=207849 Reviewed by Mark Lam. JSTests: * wasm/regress/regress-256665.js: Added. (f): Source/JavaScriptCore: When generating the call IC, we should select the callee saves using BoundsChecking mode in order to obey to the calling conventions described in r256665. Currently, we won't restore the memory size register when calling the Wasm LLInt through the call IC. * wasm/js/WebAssemblyFunction.cpp: (JSC::WebAssemblyFunction::calleeSaves const): git-svn-id: https://svn.webkit.org/repository/webkit/trunk@256766 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-02-17 Tadeu Zagallo [Wasm] REGRESSION(r256665): Wasm->JS call IC needs to save memory size register https://bugs.webkit.org/show_bug.cgi?id=207849 Reviewed by Mark Lam. When generating the call IC, we should select the callee saves using BoundsChecking mode in order to obey to the calling conventions described in r256665. Currently, we won't restore the memory size register when calling the Wasm LLInt through the call IC. * wasm/js/WebAssemblyFunction.cpp: (JSC::WebAssemblyFunction::calleeSaves const): 2020-02-18 Alan Coon Cherry-pick r256665. rdar://problem/59551715 [WASM] Wasm interpreter's calling convention doesn't match Wasm JIT's convention. https://bugs.webkit.org/show_bug.cgi?id=207727 JSTests: Reviewed by Mark Lam. * wasm/regress/llint-callee-saves-with-fast-memory.js: Added. * wasm/regress/llint-callee-saves-without-fast-memory.js: Added. Source/JavaScriptCore: Reviewed by Mark Lam. The Wasm JIT has unusual calling conventions, which were further complicated by the addition of the interpreter, and the interpreter did not correctly follow these conventions (by incorrectly saving and restoring the callee save registers used for the memory base and size). Here's a summary of the calling convention: - When entering Wasm from JS, the wrapper must: - Preserve the base and size when entering LLInt regardless of the mode. (Prior to this patch we only preserved the base in Signaling mode) - Preserve the memory base in either mode, and the size for BoundsChecking. - Both tiers must preserve every *other* register they use. e.g. the LLInt must preserve PB and wasmInstance, but must *not* preserve memoryBase and memorySize. - Changes to memoryBase and memorySize are visible to the caller. This means that: - Intra-module calls can assume these registers are up-to-date even if the memory was resized. The only exception here is if the LLInt calls a signaling JIT, in which case the JIT will not update the size register, since it won't be using it. - Inter-module and JS calls require the caller to reload these registers. These calls may result in memory changes (e.g. the callee may call memory.grow). - A Signaling JIT caller must be aware that the LLInt may trash the size register, since it always bounds checks. * llint/WebAssembly.asm: * wasm/WasmAirIRGenerator.cpp: (JSC::Wasm::AirIRGenerator::addCall): * wasm/WasmB3IRGenerator.cpp: (JSC::Wasm::B3IRGenerator::addCall): * wasm/WasmCallee.cpp: (JSC::Wasm::LLIntCallee::calleeSaveRegisters): * wasm/WasmCallingConvention.h: * wasm/WasmLLIntPlan.cpp: (JSC::Wasm::LLIntPlan::didCompleteCompilation): * wasm/WasmMemoryInformation.cpp: (JSC::Wasm::PinnedRegisterInfo::get): (JSC::Wasm::getPinnedRegisters): Deleted. git-svn-id: https://svn.webkit.org/repository/webkit/trunk@256665 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-02-14 Tadeu Zagallo and Michael Saboff [WASM] Wasm interpreter's calling convention doesn't match Wasm JIT's convention. https://bugs.webkit.org/show_bug.cgi?id=207727 Reviewed by Mark Lam. The Wasm JIT has unusual calling conventions, which were further complicated by the addition of the interpreter, and the interpreter did not correctly follow these conventions (by incorrectly saving and restoring the callee save registers used for the memory base and size). Here's a summary of the calling convention: - When entering Wasm from JS, the wrapper must: - Preserve the base and size when entering LLInt regardless of the mode. (Prior to this patch we only preserved the base in Signaling mode) - Preserve the memory base in either mode, and the size for BoundsChecking. - Both tiers must preserve every *other* register they use. e.g. the LLInt must preserve PB and wasmInstance, but must *not* preserve memoryBase and memorySize. - Changes to memoryBase and memorySize are visible to the caller. This means that: - Intra-module calls can assume these registers are up-to-date even if the memory was resized. The only exception here is if the LLInt calls a signaling JIT, in which case the JIT will not update the size register, since it won't be using it. - Inter-module and JS calls require the caller to reload these registers. These calls may result in memory changes (e.g. the callee may call memory.grow). - A Signaling JIT caller must be aware that the LLInt may trash the size register, since it always bounds checks. * llint/WebAssembly.asm: * wasm/WasmAirIRGenerator.cpp: (JSC::Wasm::AirIRGenerator::addCall): * wasm/WasmB3IRGenerator.cpp: (JSC::Wasm::B3IRGenerator::addCall): * wasm/WasmCallee.cpp: (JSC::Wasm::LLIntCallee::calleeSaveRegisters): * wasm/WasmCallingConvention.h: * wasm/WasmLLIntPlan.cpp: (JSC::Wasm::LLIntPlan::didCompleteCompilation): * wasm/WasmMemoryInformation.cpp: (JSC::Wasm::PinnedRegisterInfo::get): (JSC::Wasm::getPinnedRegisters): Deleted. 2020-02-17 Alan Coon Apply patch. rdar://problem/59446991 2020-02-17 Yusuke Suzuki [JSC] CodeBlock::shrinkToFit should shrink m_constantRegisters and m_constantsSourceCodeRepresentation in 64bit architectures https://bugs.webkit.org/show_bug.cgi?id=207356 Reviewed by Mark Lam. Only 32bit architectures are using m_constantRegisters's address. 64bit architectures are not relying on m_constantRegisters's address. This patches fixes the thing so that CodeBlock::shrinkToFit will shrink m_constantRegisters and m_constantsSourceCodeRepresentation regardless of whether this is EarlyShrink or not. We also move DFG/FTL's LateShrink call to the place after calling DFGCommon reallyAdd since they can add more constant registers. Relanding it by fixing dead-lock. * bytecode/CodeBlock.cpp: (JSC::CodeBlock::shrinkToFit): * bytecode/CodeBlock.h: * dfg/DFGJITCompiler.cpp: (JSC::DFG::JITCompiler::compile): (JSC::DFG::JITCompiler::compileFunction): * dfg/DFGJITFinalizer.cpp: (JSC::DFG::JITFinalizer::finalizeCommon): * dfg/DFGPlan.cpp: (JSC::DFG::Plan::compileInThreadImpl): (JSC::DFG::Plan::finalizeWithoutNotifyingCallback): * jit/JIT.cpp: (JSC::JIT::link): * jit/JIT.h: * jit/JITInlines.h: (JSC::JIT::emitLoadDouble): (JSC::JIT::emitLoadInt32ToDouble): Deleted. 2020-01-31 Yusuke Suzuki [JSC] DFG::CommonData::shrinkToFit called before DFG::Plan::reallyAdd is called https://bugs.webkit.org/show_bug.cgi?id=207083 Reviewed by Mark Lam. We are calling DFG::CommonData::shrinkToFit, but calling this too early: we execute DFG::Plan::reallyAdd(DFG::CommonData*) after that, and this adds many entries to DFG::CommonData*. We should call DFG::CommonData::shrinkToFit after calling DFG::Plan::reallyAdd. To implement it, we make DFG::JITCode::shrinkToFit virtual function in JSC::JITCode. Then, we can also implement FTL::JITCode::shrinkToFit which was previously not implemented. * dfg/DFGJITCode.cpp: (JSC::DFG::JITCode::shrinkToFit): * dfg/DFGJITCode.h: * dfg/DFGJITCompiler.cpp: (JSC::DFG::JITCompiler::compile): (JSC::DFG::JITCompiler::compileFunction): * dfg/DFGPlan.cpp: (JSC::DFG::Plan::finalizeWithoutNotifyingCallback): * ftl/FTLJITCode.cpp: (JSC::FTL::JITCode::shrinkToFit): * ftl/FTLJITCode.h: * jit/JITCode.cpp: (JSC::JITCode::shrinkToFit): * jit/JITCode.h: 2020-02-17 Alan Coon Apply patch. rdar://problem/59447004 Apply content from rdar://problem/59447004 2020-02-04 Yusuke Suzuki [JSC] Introduce UnlinkedCodeBlockGenerator and reduce sizeof(UnlinkedCodeBlock) https://bugs.webkit.org/show_bug.cgi?id=207087 Reviewed by Tadeu Zagallo. While UnlinkedCodeBlock is immutable once it is created from BytecodeGenerator, it has many mutable Vectors. This is because we are using UnlinkedCodeBlock as a builder of UnlinkedCodeBlock itself too in BytecodeGenerator. Since Vector takes 16 bytes to allow efficient expansions, it is nice if we can use RefCountedArray instead when we know this Vector is immutable. In this patch, we introduce UnlinkedCodeBlockGenerator wrapper. BytecodeGenerator, BytecodeRewriter, BytecodeDumper, and BytecodeGeneratorification interact with UnlinkedCodeBlockGenerator instead of UnlinkedCodeBlock. And UnlinkedCodeBlockGenerator will generate the finalized UnlinkedCodeBlock. This design allows us to use RefCountedArray for data in UnlinkedCodeBlock, which is (1) smaller and (2) doing shrinkToFit operation when creating it from Vector. This patch reduces sizeof(UnlinkedCodeBlock) from 256 to 168, 88 bytes reduction. * JavaScriptCore.xcodeproj/project.pbxproj: * Sources.txt: * bytecode/BytecodeBasicBlock.cpp: (JSC::BytecodeBasicBlock::compute): * bytecode/BytecodeBasicBlock.h: * bytecode/BytecodeDumper.cpp: * bytecode/BytecodeGeneratorification.cpp: (JSC::BytecodeGeneratorification::BytecodeGeneratorification): (JSC::GeneratorLivenessAnalysis::run): (JSC::BytecodeGeneratorification::run): (JSC::performGeneratorification): * bytecode/BytecodeGeneratorification.h: * bytecode/BytecodeRewriter.h: (JSC::BytecodeRewriter::BytecodeRewriter): * bytecode/CodeBlock.cpp: (JSC::CodeBlock::finishCreation): (JSC::CodeBlock::setConstantIdentifierSetRegisters): (JSC::CodeBlock::setConstantRegisters): (JSC::CodeBlock::handlerForIndex): (JSC::CodeBlock::insertBasicBlockBoundariesForControlFlowProfiler): * bytecode/CodeBlock.h: (JSC::CodeBlock::numberOfSwitchJumpTables const): (JSC::CodeBlock::numberOfStringSwitchJumpTables const): (JSC::CodeBlock::addSwitchJumpTable): Deleted. (JSC::CodeBlock::addStringSwitchJumpTable): Deleted. * bytecode/HandlerInfo.h: (JSC::HandlerInfoBase::handlerForIndex): * bytecode/JumpTable.h: (JSC::SimpleJumpTable::add): Deleted. * bytecode/PreciseJumpTargets.cpp: (JSC::computePreciseJumpTargets): (JSC::recomputePreciseJumpTargets): (JSC::findJumpTargetsForInstruction): * bytecode/PreciseJumpTargets.h: * bytecode/UnlinkedCodeBlock.cpp: (JSC::UnlinkedCodeBlock::UnlinkedCodeBlock): (JSC::UnlinkedCodeBlock::visitChildren): (JSC::UnlinkedCodeBlock::dumpExpressionRangeInfo): (JSC::UnlinkedCodeBlock::expressionRangeForBytecodeIndex const): (JSC::UnlinkedCodeBlock::handlerForIndex): (JSC::UnlinkedCodeBlock::addExpressionInfo): Deleted. (JSC::UnlinkedCodeBlock::addTypeProfilerExpressionInfo): Deleted. (JSC::UnlinkedCodeBlock::setInstructions): Deleted. (JSC::UnlinkedCodeBlock::applyModification): Deleted. (JSC::UnlinkedCodeBlock::shrinkToFit): Deleted. (JSC::UnlinkedCodeBlock::addOutOfLineJumpTarget): Deleted. * bytecode/UnlinkedCodeBlock.h: (JSC::UnlinkedCodeBlock::expressionInfo): (JSC::UnlinkedCodeBlock::setNumParameters): (JSC::UnlinkedCodeBlock::numberOfIdentifiers const): (JSC::UnlinkedCodeBlock::identifiers const): (JSC::UnlinkedCodeBlock::bitVector): (JSC::UnlinkedCodeBlock::constantRegisters): (JSC::UnlinkedCodeBlock::constantsSourceCodeRepresentation): (JSC::UnlinkedCodeBlock::constantIdentifierSets): (JSC::UnlinkedCodeBlock::numberOfJumpTargets const): (JSC::UnlinkedCodeBlock::numberOfSwitchJumpTables const): (JSC::UnlinkedCodeBlock::numberOfStringSwitchJumpTables const): (JSC::UnlinkedCodeBlock::numberOfFunctionDecls): (JSC::UnlinkedCodeBlock::numberOfExceptionHandlers const): (JSC::UnlinkedCodeBlock::opProfileControlFlowBytecodeOffsets const): (JSC::UnlinkedCodeBlock::createRareDataIfNecessary): (JSC::UnlinkedCodeBlock::addParameter): Deleted. (JSC::UnlinkedCodeBlock::addIdentifier): Deleted. (JSC::UnlinkedCodeBlock::addBitVector): Deleted. (JSC::UnlinkedCodeBlock::addSetConstant): Deleted. (JSC::UnlinkedCodeBlock::addConstant): Deleted. (JSC::UnlinkedCodeBlock::addJumpTarget): Deleted. (JSC::UnlinkedCodeBlock::addSwitchJumpTable): Deleted. (JSC::UnlinkedCodeBlock::addStringSwitchJumpTable): Deleted. (JSC::UnlinkedCodeBlock::addFunctionDecl): Deleted. (JSC::UnlinkedCodeBlock::addFunctionExpr): Deleted. (JSC::UnlinkedCodeBlock::addExceptionHandler): Deleted. (JSC::UnlinkedCodeBlock::addOpProfileControlFlowBytecodeOffset): Deleted. (JSC::UnlinkedCodeBlock::replaceOutOfLineJumpTargets): Deleted. * bytecode/UnlinkedCodeBlockGenerator.cpp: Added. (JSC::UnlinkedCodeBlockGenerator::getLineAndColumn const): (JSC::UnlinkedCodeBlockGenerator::addExpressionInfo): (JSC::UnlinkedCodeBlockGenerator::addTypeProfilerExpressionInfo): (JSC::UnlinkedCodeBlockGenerator::finalize): (JSC::UnlinkedCodeBlockGenerator::handlerForBytecodeIndex): (JSC::UnlinkedCodeBlockGenerator::handlerForIndex): (JSC::UnlinkedCodeBlockGenerator::applyModification): (JSC::UnlinkedCodeBlockGenerator::addOutOfLineJumpTarget): (JSC::UnlinkedCodeBlockGenerator::outOfLineJumpOffset): (JSC::UnlinkedCodeBlockGenerator::dump const): * bytecode/UnlinkedCodeBlockGenerator.h: Added. (JSC::UnlinkedCodeBlockGenerator::UnlinkedCodeBlockGenerator): (JSC::UnlinkedCodeBlockGenerator::vm): (JSC::UnlinkedCodeBlockGenerator::isConstructor const): (JSC::UnlinkedCodeBlockGenerator::constructorKind const): (JSC::UnlinkedCodeBlockGenerator::superBinding const): (JSC::UnlinkedCodeBlockGenerator::scriptMode const): (JSC::UnlinkedCodeBlockGenerator::needsClassFieldInitializer const): (JSC::UnlinkedCodeBlockGenerator::isStrictMode const): (JSC::UnlinkedCodeBlockGenerator::usesEval const): (JSC::UnlinkedCodeBlockGenerator::parseMode const): (JSC::UnlinkedCodeBlockGenerator::isArrowFunction): (JSC::UnlinkedCodeBlockGenerator::derivedContextType const): (JSC::UnlinkedCodeBlockGenerator::evalContextType const): (JSC::UnlinkedCodeBlockGenerator::isArrowFunctionContext const): (JSC::UnlinkedCodeBlockGenerator::isClassContext const): (JSC::UnlinkedCodeBlockGenerator::numCalleeLocals const): (JSC::UnlinkedCodeBlockGenerator::numVars const): (JSC::UnlinkedCodeBlockGenerator::numParameters const): (JSC::UnlinkedCodeBlockGenerator::thisRegister const): (JSC::UnlinkedCodeBlockGenerator::scopeRegister const): (JSC::UnlinkedCodeBlockGenerator::wasCompiledWithDebuggingOpcodes const): (JSC::UnlinkedCodeBlockGenerator::hasCheckpoints const): (JSC::UnlinkedCodeBlockGenerator::hasTailCalls const): (JSC::UnlinkedCodeBlockGenerator::setHasCheckpoints): (JSC::UnlinkedCodeBlockGenerator::setHasTailCalls): (JSC::UnlinkedCodeBlockGenerator::setNumCalleeLocals): (JSC::UnlinkedCodeBlockGenerator::setNumVars): (JSC::UnlinkedCodeBlockGenerator::setThisRegister): (JSC::UnlinkedCodeBlockGenerator::setScopeRegister): (JSC::UnlinkedCodeBlockGenerator::setNumParameters): (JSC::UnlinkedCodeBlockGenerator::metadata): (JSC::UnlinkedCodeBlockGenerator::addOpProfileControlFlowBytecodeOffset): (JSC::UnlinkedCodeBlockGenerator::numberOfJumpTargets const): (JSC::UnlinkedCodeBlockGenerator::addJumpTarget): (JSC::UnlinkedCodeBlockGenerator::jumpTarget const): (JSC::UnlinkedCodeBlockGenerator::lastJumpTarget const): (JSC::UnlinkedCodeBlockGenerator::numberOfSwitchJumpTables const): (JSC::UnlinkedCodeBlockGenerator::addSwitchJumpTable): (JSC::UnlinkedCodeBlockGenerator::switchJumpTable): (JSC::UnlinkedCodeBlockGenerator::numberOfStringSwitchJumpTables const): (JSC::UnlinkedCodeBlockGenerator::addStringSwitchJumpTable): (JSC::UnlinkedCodeBlockGenerator::stringSwitchJumpTable): (JSC::UnlinkedCodeBlockGenerator::numberOfExceptionHandlers const): (JSC::UnlinkedCodeBlockGenerator::exceptionHandler): (JSC::UnlinkedCodeBlockGenerator::addExceptionHandler): (JSC::UnlinkedCodeBlockGenerator::bitVector): (JSC::UnlinkedCodeBlockGenerator::addBitVector): (JSC::UnlinkedCodeBlockGenerator::numberOfConstantIdentifierSets const): (JSC::UnlinkedCodeBlockGenerator::constantIdentifierSets): (JSC::UnlinkedCodeBlockGenerator::addSetConstant): (JSC::UnlinkedCodeBlockGenerator::constantRegister const): (JSC::UnlinkedCodeBlockGenerator::constantRegisters): (JSC::UnlinkedCodeBlockGenerator::getConstant const): (JSC::UnlinkedCodeBlockGenerator::constantsSourceCodeRepresentation): (JSC::UnlinkedCodeBlockGenerator::addConstant): (JSC::UnlinkedCodeBlockGenerator::addFunctionDecl): (JSC::UnlinkedCodeBlockGenerator::addFunctionExpr): (JSC::UnlinkedCodeBlockGenerator::numberOfIdentifiers const): (JSC::UnlinkedCodeBlockGenerator::identifier const): (JSC::UnlinkedCodeBlockGenerator::addIdentifier): (JSC::UnlinkedCodeBlockGenerator::outOfLineJumpOffset): (JSC::UnlinkedCodeBlockGenerator::replaceOutOfLineJumpTargets): (JSC::UnlinkedCodeBlockGenerator::metadataSizeInBytes): * bytecompiler/BytecodeGenerator.cpp: (JSC::BytecodeGenerator::generate): (JSC::BytecodeGenerator::BytecodeGenerator): (JSC::BytecodeGenerator::initializeNextParameter): (JSC::BytecodeGenerator::emitPushFunctionNameScope): (JSC::prepareJumpTableForSwitch): (JSC::ForInContext::finalize): (JSC::StructureForInContext::finalize): (JSC::IndexedForInContext::finalize): * bytecompiler/BytecodeGenerator.h: * bytecompiler/BytecodeGeneratorBaseInlines.h: (JSC::BytecodeGeneratorBase::newRegister): (JSC::BytecodeGeneratorBase::addVar): * runtime/CachedTypes.cpp: (JSC::CachedVector::encode): (JSC::CachedVector::decode const): * wasm/WasmFunctionCodeBlock.h: (JSC::Wasm::FunctionCodeBlock::setNumVars): (JSC::Wasm::FunctionCodeBlock::setNumCalleeLocals): 2020-01-30 Yusuke Suzuki [JSC] Remove unnecessary allocations in BytecodeBasicBlock https://bugs.webkit.org/show_bug.cgi?id=206986 Reviewed by Mark Lam. We know that BytecodeBasicBlock itself takes 2MB in Gmail. And each BytecodeBasicBlock has Vector and Vector. BytecodeBasicBlock holds all the offset per bytecode as unsigned in m_offsets. But this offset is only used when reverse iterating a bytecode in a BytecodeBasicBlock. We can hold a length of each bytecode instead, which is much smaller (unsigned v.s. uint8_t). Since each BytecodeBasicBlock has index, we should hold successors in Vector instead of Vector. We are also allocating BytecodeBasicBlock in makeUnique<> and having them in Vector>. But this is not necessary since only BytecodeBasicBlock::compute can modify this vector. We should generate Vector from BytecodeBasicBlock::compute. We are also planning purging BytecodeBasicBlock in UnlinkedCodeBlock if it is not used so much. But this will be done in a separate patch. * bytecode/BytecodeBasicBlock.cpp: (JSC::BytecodeBasicBlock::BytecodeBasicBlock): (JSC::BytecodeBasicBlock::addLength): (JSC::BytecodeBasicBlock::shrinkToFit): (JSC::BytecodeBasicBlock::computeImpl): (JSC::BytecodeBasicBlock::compute): * bytecode/BytecodeBasicBlock.h: (JSC::BytecodeBasicBlock::delta const): (JSC::BytecodeBasicBlock::successors const): (JSC::BytecodeBasicBlock::operator bool const): (JSC::BytecodeBasicBlock::addSuccessor): (JSC::BytecodeBasicBlock::offsets const): Deleted. (JSC::BytecodeBasicBlock:: const): Deleted. (JSC::BytecodeBasicBlock::BytecodeBasicBlock): Deleted. (JSC::BytecodeBasicBlock::addLength): Deleted. * bytecode/BytecodeGeneratorification.cpp: (JSC::BytecodeGeneratorification::BytecodeGeneratorification): * bytecode/BytecodeGraph.h: (JSC::BytecodeGraph::blockContainsBytecodeOffset): (JSC::BytecodeGraph::findBasicBlockForBytecodeOffset): (JSC::BytecodeGraph::findBasicBlockWithLeaderOffset): (JSC::BytecodeGraph::at const): (JSC::BytecodeGraph::operator[] const): (JSC::BytecodeGraph::begin): (JSC::BytecodeGraph::end): (JSC::BytecodeGraph::first): (JSC::BytecodeGraph::last): (JSC::BytecodeGraph::BytecodeGraph): (JSC::BytecodeGraph::begin const): Deleted. (JSC::BytecodeGraph::end const): Deleted. * bytecode/BytecodeLivenessAnalysis.cpp: (JSC::BytecodeLivenessAnalysis::getLivenessInfoAtBytecodeIndex): (JSC::BytecodeLivenessAnalysis::computeFullLiveness): (JSC::BytecodeLivenessAnalysis::computeKills): (JSC::BytecodeLivenessAnalysis::dumpResults): * bytecode/BytecodeLivenessAnalysis.h: * bytecode/BytecodeLivenessAnalysisInlines.h: (JSC::BytecodeLivenessPropagation::computeLocalLivenessForBytecodeIndex): (JSC::BytecodeLivenessPropagation::computeLocalLivenessForBlock): (JSC::BytecodeLivenessPropagation::getLivenessInfoAtBytecodeIndex): (JSC::BytecodeLivenessPropagation::runLivenessFixpoint): * bytecode/InstructionStream.h: (JSC::InstructionStream::MutableRef::operator-> const): (JSC::InstructionStream::MutableRef::ptr const): (JSC::InstructionStream::MutableRef::unwrap const): * bytecode/Opcode.h: * generator/Section.rb: * jit/JIT.cpp: (JSC::JIT::privateCompileMainPass): * llint/LLIntData.cpp: (JSC::LLInt::initialize): * llint/LowLevelInterpreter.cpp: (JSC::CLoop::execute): 2020-02-14 Russell Epstein Cherry-pick r256498. rdar://problem/59478929 [JSC] Compact JITCodeMap by storing BytecodeIndex and CodeLocation separately https://bugs.webkit.org/show_bug.cgi?id=207673 Reviewed by Mark Lam. Source/JavaScriptCore: While BytecodeIndex is 4 bytes, CodeLocation is 8 bytes. So the tuple of them "JITCodeMap::Entry" becomes 16 bytes because it adds 4 bytes padding. We should store BytecodeIndex and CodeLocation separately to avoid this padding. This patch introduces JITCodeMapBuilder. We use this to build JITCodeMap data structure as a immutable final result. * jit/JIT.cpp: (JSC::JIT::link): * jit/JITCodeMap.h: (JSC::JITCodeMap::JITCodeMap): (JSC::JITCodeMap::find const): (JSC::JITCodeMap::operator bool const): (JSC::JITCodeMap::codeLocations const): (JSC::JITCodeMap::indexes const): (JSC::JITCodeMapBuilder::append): (JSC::JITCodeMapBuilder::finalize): (JSC::JITCodeMap::Entry::Entry): Deleted. (JSC::JITCodeMap::Entry::bytecodeIndex const): Deleted. (JSC::JITCodeMap::Entry::codeLocation): Deleted. (JSC::JITCodeMap::append): Deleted. (JSC::JITCodeMap::finish): Deleted. Source/WTF: * wtf/MallocPtr.h: git-svn-id: https://svn.webkit.org/repository/webkit/trunk@256498 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-02-12 Yusuke Suzuki [JSC] Compact JITCodeMap by storing BytecodeIndex and CodeLocation separately https://bugs.webkit.org/show_bug.cgi?id=207673 Reviewed by Mark Lam. While BytecodeIndex is 4 bytes, CodeLocation is 8 bytes. So the tuple of them "JITCodeMap::Entry" becomes 16 bytes because it adds 4 bytes padding. We should store BytecodeIndex and CodeLocation separately to avoid this padding. This patch introduces JITCodeMapBuilder. We use this to build JITCodeMap data structure as a immutable final result. * jit/JIT.cpp: (JSC::JIT::link): * jit/JITCodeMap.h: (JSC::JITCodeMap::JITCodeMap): (JSC::JITCodeMap::find const): (JSC::JITCodeMap::operator bool const): (JSC::JITCodeMap::codeLocations const): (JSC::JITCodeMap::indexes const): (JSC::JITCodeMapBuilder::append): (JSC::JITCodeMapBuilder::finalize): (JSC::JITCodeMap::Entry::Entry): Deleted. (JSC::JITCodeMap::Entry::bytecodeIndex const): Deleted. (JSC::JITCodeMap::Entry::codeLocation): Deleted. (JSC::JITCodeMap::append): Deleted. (JSC::JITCodeMap::finish): Deleted. 2020-02-14 Russell Epstein Cherry-pick r256467. rdar://problem/59478994 [JSC] Make RegExpCache small https://bugs.webkit.org/show_bug.cgi?id=207619 Reviewed by Mark Lam. We can compact RegExpKey by using PackedRefPtr, so that we can shrink memory consumption of RegExpCache. * runtime/RegExpKey.h: git-svn-id: https://svn.webkit.org/repository/webkit/trunk@256467 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-02-12 Yusuke Suzuki [JSC] Make RegExpCache small https://bugs.webkit.org/show_bug.cgi?id=207619 Reviewed by Mark Lam. We can compact RegExpKey by using PackedRefPtr, so that we can shrink memory consumption of RegExpCache. * runtime/RegExpKey.h: 2020-02-14 Russell Epstein Cherry-pick r254681. rdar://problem/59474790 [Win] Fix AppleWin build https://bugs.webkit.org/show_bug.cgi?id=206299 Reviewed by Brent Fulgham. .: This patch has been created by don.olmstead@sony.com and pvollan@apple.com. Add target files for WTF and JavaScriptCore. Also, to make sure headers are copied to the forwarding headers directory, add the CMake keywork ALL when adding custom target for copying files. * Source/cmake/TargetJavaScriptCore.cmake: Added. * Source/cmake/TargetWTF.cmake: Added. * Source/cmake/WebKitMacros.cmake: Source/JavaScriptCore: Include required target. Build internal builds with VS2019. * CMakeLists.txt: * JavaScriptCore.vcxproj/JavaScriptCore.proj: Source/WebCore: Include required targets. Build internal builds with VS2019. * CMakeLists.txt: * WebCore.vcxproj/WebCore.proj: Source/WebKitLegacy: Include required targets. Build internal builds with VS2019. * CMakeLists.txt: * WebKitLegacy.vcxproj/WebKitLegacy.proj: Source/WTF: Build internal builds with VS2019. * WTF.vcxproj/WTF.proj: git-svn-id: https://svn.webkit.org/repository/webkit/trunk@254681 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-01-16 Per Arne Vollan [Win] Fix AppleWin build https://bugs.webkit.org/show_bug.cgi?id=206299 Reviewed by Brent Fulgham. Include required target. Build internal builds with VS2019. * CMakeLists.txt: * JavaScriptCore.vcxproj/JavaScriptCore.proj: 2020-02-11 Alan Coon Apply patch. rdar://problem/59299139 2020-02-11 Saam Barati safe to execute should return false when we know code won't be moved https://bugs.webkit.org/show_bug.cgi?id=207074 Reviewed by Yusuke Suzuki. We use safeToExecute to determine inside LICM whether it's safe to execute a node somewhere else in the program. We were returning true for nodes we knew would never be moved, because they were effectful. Things like Call and GetById. This patch makes those nodes return false now, since we want to make it easier to audit the nodes that return true. This makes that audit easier, since it gets rid of the obvious things that will never be hoisted. * dfg/DFGSafeToExecute.h: (JSC::DFG::safeToExecute): 2020-02-10 Kocsen Chung Cherry-pick r255539. rdar://problem/59299142 GetButterfly should check if the input value is an object in safe to execute https://bugs.webkit.org/show_bug.cgi?id=207082 Reviewed by Mark Lam. We can only hoist GetButterfly when we know the incoming value is an object. We might want to reconsider making GetButterfly use ObjectUse as its edge kind, but that's out of the scope of this patch. Currently, we use CellUse for GetButterfly node's child1. * dfg/DFGSafeToExecute.h: (JSC::DFG::safeToExecute): git-svn-id: https://svn.webkit.org/repository/webkit/trunk@255539 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-01-31 Saam Barati GetButterfly should check if the input value is an object in safe to execute https://bugs.webkit.org/show_bug.cgi?id=207082 Reviewed by Mark Lam. We can only hoist GetButterfly when we know the incoming value is an object. We might want to reconsider making GetButterfly use ObjectUse as its edge kind, but that's out of the scope of this patch. Currently, we use CellUse for GetButterfly node's child1. * dfg/DFGSafeToExecute.h: (JSC::DFG::safeToExecute): 2020-02-05 Russell Epstein Cherry-pick r255396. rdar://problem/59097789 Web Inspector: add instrumentation for showing existing Web Animations https://bugs.webkit.org/show_bug.cgi?id=205434 Reviewed by Brian Burg. Source/JavaScriptCore: * inspector/protocol/Animation.json: Add types/commands/events for instrumenting the lifecycle of `Animation` objects, as well as commands for getting the JavaScript wrapper object and the target DOM node. Source/WebCore: Add types/commands/events for instrumenting the lifecycle of `Animation` objects, as well as commands for getting the JavaScript wrapper object and the target DOM node. Tests: inspector/animation/effectChanged.html inspector/animation/lifecycle-css-animation.html inspector/animation/lifecycle-css-transition.html inspector/animation/lifecycle-web-animation.html inspector/animation/requestEffectTarget.html inspector/animation/resolveAnimation.html inspector/animation/targetChanged.html * animation/WebAnimation.h: * animation/WebAnimation.cpp: (WebCore::WebAnimation::instances): Added. (WebCore::WebAnimation::instancesMutex): Added. (WebCore::WebAnimation::create): (WebCore::WebAnimation::WebAnimation): (WebCore::WebAnimation::~WebAnimation): (WebCore::WebAnimation::effectTimingDidChange): (WebCore::WebAnimation::setEffectInternal): (WebCore::WebAnimation::effectTargetDidChange): * animation/CSSAnimation.cpp: (WebCore::CSSAnimation::create): * animation/CSSTransition.cpp: (WebCore::CSSTransition::create): * animation/KeyframeEffect.h: (WebCore::KeyframeEffect::parsedKeyframes const): Added. (WebCore::KeyframeEffect::blendingKeyframes const): Added. (WebCore::KeyframeEffect::hasBlendingKeyframes const): Deleted. Provide a way to access the list of keyframes. * inspector/InspectorInstrumentation.h: (WebCore::InspectorInstrumentation::didSetWebAnimationEffect): Added. (WebCore::InspectorInstrumentation::didChangeWebAnimationEffectTiming): Added. (WebCore::InspectorInstrumentation::didChangeWebAnimationEffectTarget): Added. (WebCore::InspectorInstrumentation::didCreateWebAnimation): Added. (WebCore::InspectorInstrumentation::didChangeWebAnimationEffect): Deleted. * inspector/InspectorInstrumentation.cpp: (WebCore::InspectorInstrumentation::didCommitLoadImpl): (WebCore::InspectorInstrumentation::didSetWebAnimationEffectImpl): Added. (WebCore::InspectorInstrumentation::didChangeWebAnimationEffectTimingImpl): Added. (WebCore::InspectorInstrumentation::didChangeWebAnimationEffectTargetImpl): Added. (WebCore::InspectorInstrumentation::didCreateWebAnimationImpl): Added. (WebCore::InspectorInstrumentation::willDestroyWebAnimationImpl): (WebCore::InspectorInstrumentation::didChangeWebAnimationEffectImpl): Deleted. * inspector/InstrumentingAgents.h: (WebCore::InstrumentingAgents::enabledInspectorAnimationAgent const): Added. (WebCore::InstrumentingAgents::setEnabledInspectorAnimationAgent): Added. * inspector/InstrumentingAgents.cpp: (WebCore::InstrumentingAgents::reset): * inspector/agents/InspectorAnimationAgent.h: * inspector/agents/InspectorAnimationAgent.cpp: (WebCore::protocolValueForSeconds): Added. (WebCore::protocolValueForPlaybackDirection): Added. (WebCore::protocolValueForFillMode): Added. (WebCore::buildObjectForKeyframes): Added. (WebCore::buildObjectForEffect): Added. (WebCore::InspectorAnimationAgent::InspectorAnimationAgent): (WebCore::InspectorAnimationAgent::willDestroyFrontendAndBackend): (WebCore::InspectorAnimationAgent::enable): Added. (WebCore::InspectorAnimationAgent::disable): Added. (WebCore::InspectorAnimationAgent::requestEffectTarget): Added. (WebCore::InspectorAnimationAgent::resolveAnimation): Added. (WebCore::InspectorAnimationAgent::didSetWebAnimationEffect): Added. (WebCore::InspectorAnimationAgent::didChangeWebAnimationEffectTiming): Added. (WebCore::InspectorAnimationAgent::didChangeWebAnimationEffectTarget): Added. (WebCore::InspectorAnimationAgent::didCreateWebAnimation): Added. (WebCore::InspectorAnimationAgent::willDestroyWebAnimation): (WebCore::InspectorAnimationAgent::frameNavigated): (WebCore::InspectorAnimationAgent::findAnimationId): Added. (WebCore::InspectorAnimationAgent::assertAnimation): Added. (WebCore::InspectorAnimationAgent::bindAnimation): Added. (WebCore::InspectorAnimationAgent::unbindAnimation): Added. (WebCore::InspectorAnimationAgent::animationDestroyedTimerFired): Added. (WebCore::InspectorAnimationAgent::reset): Added. (WebCore::InspectorAnimationAgent::didChangeWebAnimationEffect): Deleted. * inspector/agents/InspectorDOMAgent.h: * inspector/agents/InspectorDOMAgent.cpp: (WebCore::InspectorDOMAgent::pushNodeToFrontend): (WebCore::InspectorDOMAgent::querySelector): (WebCore::InspectorDOMAgent::pushNodePathToFrontend): (WebCore::InspectorDOMAgent::setNodeName): (WebCore::InspectorDOMAgent::setOuterHTML): (WebCore::InspectorDOMAgent::moveTo): (WebCore::InspectorDOMAgent::requestNode): (WebCore::InspectorDOMAgent::pushNodeByPathToFrontend): Add an overload for `pushNodePathToFrontend` that exposes an `ErrorString`. Source/WebInspectorUI: * UserInterface/Controllers/AnimationManager.js: Added. (WI.AnimationManager): (WI.AnimationManager.prototype.get domains): (WI.AnimationManager.prototype.activateExtraDomain): (WI.AnimationManager.prototype.initializeTarget): (WI.AnimationManager.prototype.get animationCollection): (WI.AnimationManager.prototype.get supported): (WI.AnimationManager.prototype.enable): (WI.AnimationManager.prototype.disable): (WI.AnimationManager.prototype.animationCreated): (WI.AnimationManager.prototype.effectChanged): (WI.AnimationManager.prototype.targetChanged): (WI.AnimationManager.prototype.animationDestroyed): (WI.AnimationManager.prototype._handleMainResourceDidChange): * UserInterface/Protocol/AnimationObserver.js: (WI.AnimationObserver.prototype.animationCreated): Added. (WI.AnimationObserver.prototype.effectChanged): Added. (WI.AnimationObserver.prototype.targetChanged): Added. (WI.AnimationObserver.prototype.animationDestroyed): Added. * UserInterface/Models/AnimationCollection.js: Added. (WI.AnimationCollection): (WI.AnimationCollection.prototype.get animationType): (WI.AnimationCollection.prototype.get displayName): (WI.AnimationCollection.prototype.objectIsRequiredType): (WI.AnimationCollection.prototype.animationCollectionForType): (WI.AnimationCollection.prototype.itemAdded): (WI.AnimationCollection.prototype.itemRemoved): (WI.AnimationCollection.prototype.itemsCleared): Similar to `WI.ResourceCollection`, create a subclass of `WI.Collection` that maintains it's own sub-`WI.AnimationCollection`s for each type of `WI.Animation.Type`. * UserInterface/Models/Animation.js: Added. (WI.Animation): (WI.Animation.fromPayload): (WI.Animation.displayNameForAnimationType): (WI.Animation.displayNameForPlaybackDirection): (WI.Animation.displayNameForFillMode): (WI.Animation.resetUniqueDisplayNameNumbers): (WI.Animation.prototype.get animationId): (WI.Animation.prototype.get backtrace): (WI.Animation.prototype.get animationType): (WI.Animation.prototype.get startDelay): (WI.Animation.prototype.get endDelay): (WI.Animation.prototype.get iterationCount): (WI.Animation.prototype.get iterationStart): (WI.Animation.prototype.get iterationDuration): (WI.Animation.prototype.get timingFunction): (WI.Animation.prototype.get playbackDirection): (WI.Animation.prototype.get fillMode): (WI.Animation.prototype.get keyframes): (WI.Animation.prototype.get displayName): (WI.Animation.prototype.requestEffectTarget): (WI.Animation.prototype.effectChanged): (WI.Animation.prototype.targetChanged): (WI.Animation.prototype._updateEffect): * UserInterface/Protocol/RemoteObject.js: (WI.RemoteObject.resolveAnimation): Added. * UserInterface/Views/GraphicsTabContentView.js: Renamed from Source/WebInspectorUI/UserInterface/Views/CanvasTabContentView.js. (WI.GraphicsTabContentView): (WI.GraphicsTabContentView.tabInfo): (WI.GraphicsTabContentView.isTabAllowed): (WI.GraphicsTabContentView.prototype.get type): (WI.GraphicsTabContentView.prototype.showRepresentedObject): Added. (WI.GraphicsTabContentView.prototype.canShowRepresentedObject): (WI.GraphicsTabContentView.prototype.closed): (WI.GraphicsTabContentView.prototype.attached): (WI.GraphicsTabContentView.prototype.detached): (WI.GraphicsTabContentView.prototype.initialLayout): Added. (WI.GraphicsTabContentView.prototype._handleOverviewTreeOutlineSelectionDidChange): Added. * UserInterface/Views/GraphicsTabContentView.css: Renamed from Source/WebInspectorUI/UserInterface/Views/CanvasTabContentView.css. Rename the Canvas Tab to Graphics Tab and display four sections: - Canvases - Web Animations - CSS Animations - CSS Transitions * UserInterface/Views/CanvasSidebarPanel.js: (WI.CanvasSidebarPanel.prototype.canShowRepresentedObject): Only appear if a `WI.Canvas` or `WI.Recording` is selected. * UserInterface/Views/GraphicsOverviewContentView.js: Added. (WI.GraphicsOverviewContentView): (WI.GraphicsOverviewContentView.prototype.get supplementalRepresentedObjects): (WI.GraphicsOverviewContentView.prototype.get navigationItems): (WI.GraphicsOverviewContentView.prototype.attached): (WI.GraphicsOverviewContentView.prototype.detached): (WI.GraphicsOverviewContentView.prototype.initialLayout): (WI.GraphicsOverviewContentView.prototype.dropZoneShouldAppearForDragEvent): (WI.GraphicsOverviewContentView.prototype.dropZoneHandleDrop): (WI.GraphicsOverviewContentView.prototype._handleRefreshButtonClicked): (WI.GraphicsOverviewContentView.prototype._handleShowGridButtonClicked): (WI.GraphicsOverviewContentView.prototype._handleShowImageGridSettingChanged): (WI.GraphicsOverviewContentView.prototype._handleImportButtonNavigationItemClicked): (WI.GraphicsOverviewContentView.prototype._handleOverviewViewSelectedItemChanged): (WI.GraphicsOverviewContentView.prototype._handleOverviewViewSupplementalRepresentedObjectsDidChange): (WI.GraphicsOverviewContentView.prototype._handleClick): * UserInterface/Views/GraphicsOverviewContentView.css: Added. (.content-view.graphics-overview): (.content-view.graphics-overview > section): (.content-view.graphics-overview > section:not(:first-child)): (.content-view.graphics-overview > section > .header): (.content-view.graphics-overview > section:not(:first-of-type) > .header): (.content-view.graphics-overview > section > .header > h1): (.content-view.graphics-overview > section > .header > .navigation-bar): (.content-view.graphics-overview > .content-view.canvas-overview): (@media (prefers-color-scheme: light) .content-view.graphics-overview): (@media (prefers-color-scheme: light) .content-view.graphics-overview > section > .header): Add sticky headers for each of the sections described above. * UserInterface/Views/AnimationCollectionContentView.js: Added. (WI.AnimationCollectionContentView): (WI.AnimationCollectionContentView.prototype.handleRefreshButtonClicked): (WI.AnimationCollectionContentView.prototype.contentViewAdded): (WI.AnimationCollectionContentView.prototype.contentViewRemoved): (WI.AnimationCollectionContentView.prototype.detached): (WI.AnimationCollectionContentView.prototype._handleContentViewMouseEnter): (WI.AnimationCollectionContentView.prototype._handleContentViewMouseLeave): * UserInterface/Views/AnimationCollectionContentView.css: Added. (.content-view.animation-collection): * UserInterface/Views/AnimationContentView.js: Added. (WI.AnimationContentView): (WI.AnimationContentView.get previewHeight): (WI.AnimationContentView.prototype.handleRefreshButtonClicked): (WI.AnimationContentView.prototype.initialLayout): (WI.AnimationContentView.prototype.layout): (WI.AnimationContentView.prototype.sizeDidChange): (WI.AnimationContentView.prototype.attached): (WI.AnimationContentView.prototype.detached): (WI.AnimationContentView.prototype._refreshSubtitle): (WI.AnimationContentView.prototype._refreshPreview.addTitle): (WI.AnimationContentView.prototype._refreshPreview): (WI.AnimationContentView.prototype._handleEffectChanged): (WI.AnimationContentView.prototype._handleTargetChanged): (WI.AnimationContentView.prototype._populateAnimationTargetButtonContextMenu): * UserInterface/Views/AnimationContentView.css: Added. (.content-view.animation): (.content-view.animation.selected): (.content-view.animation > header): (.content-view.animation > header > .titles): (.content-view.animation > header > .titles > .title): (.content-view.animation > header > .titles > .subtitle): (.content-view.animation > header > .titles > .subtitle:not(:empty)::before): (.content-view.animation > header > .navigation-bar): (.content-view.animation:hover > header > .navigation-bar): (.content-view.animation > .preview): (.content-view.animation > .preview > svg): (body[dir=rtl] .content-view.animation > .preview > svg): (.content-view.animation > .preview > svg rect): (.content-view.animation > .preview > svg > .delay line): (.content-view.animation > .preview > svg > .active path): (.content-view.animation > .preview > svg > .active circle): (.content-view.animation > .preview > svg > .active line): (.content-view.animation > .preview > span): (@media (prefers-color-scheme: dark) .content-view.animation > header > .titles > .title): (@media (prefers-color-scheme: dark) .content-view.animation > header > .titles > .subtitle): (@media (prefers-color-scheme: dark) .content-view.animation > .preview): Visualize the start/end delay and keyframes of the given animation as a series of bezier curves separated by markers. * UserInterface/Views/AnimationDetailsSidebarPanel.js: Added. (WI.AnimationDetailsSidebarPanel): (WI.AnimationDetailsSidebarPanel.prototype.inspect): (WI.AnimationDetailsSidebarPanel.prototype.get animation): (WI.AnimationDetailsSidebarPanel.prototype.set animation): (WI.AnimationDetailsSidebarPanel.prototype.initialLayout): (WI.AnimationDetailsSidebarPanel.prototype.layout): (WI.AnimationDetailsSidebarPanel.prototype._refreshIdentitySection): (WI.AnimationDetailsSidebarPanel.prototype._refreshEffectSection): (WI.AnimationDetailsSidebarPanel.prototype._refreshBacktraceSection): (WI.AnimationDetailsSidebarPanel.prototype._handleAnimationEffectChanged): (WI.AnimationDetailsSidebarPanel.prototype._handleAnimationTargetChanged): (WI.AnimationDetailsSidebarPanel.prototype._handleDetailsSectionCollapsedStateChanged): * UserInterface/Views/AnimationDetailsSidebarPanel.css: Added. (.sidebar > .panel.details.animation > .content > .details-section.animation-keyframes .header > .subtitle): (.sidebar > .panel.details.animation > .content > .details-section.animation-keyframes .details-section): (.sidebar > .panel.details.animation > .content > .details-section.animation-keyframes .details-section .row.styles): (.sidebar > .panel.details.animation > .content > .details-section.animation-keyframes .details-section .row.styles .CodeMirror): (.sidebar > .panel.details.animation > .content > .details-section.animation-keyframes .details-section): Show collected information about the selected animation, its effect, and its target. * UserInterface/Controllers/CanvasManager.js: (WI.CanvasManager): (WI.CanvasManager.prototype.get canvasCollection): Added. (WI.CanvasManager.prototype.disable): (WI.CanvasManager.prototype.canvasAdded): (WI.CanvasManager.prototype.canvasRemoved): (WI.CanvasManager.prototype._saveRecordings): Added. (WI.CanvasManager.prototype._mainResourceDidChange): (WI.CanvasManager.prototype.get canvases): Deleted. (WI.CanvasManager.prototype._removeCanvas): Deleted. Rather than have the `WI.CanvasTabContentView` mainain the `WI.CanvasCollection` and have to listen for events from the `WI.CanvasManager`, just have the `WI.CanvasManager` hold on to it instead and provide a getter for it. * UserInterface/Views/CanvasOverviewContentView.js: (WI.CanvasOverviewContentView): (WI.CanvasOverviewContentView.prototype.get navigationItems): (WI.CanvasOverviewContentView.prototype.handleRefreshButtonClicked): (WI.CanvasOverviewContentView.prototype.contentViewAdded): (WI.CanvasOverviewContentView.prototype.contentViewRemoved): (WI.CanvasOverviewContentView.prototype.attached): (WI.CanvasOverviewContentView.prototype.detached): (WI.CanvasOverviewContentView.prototype._addSavedRecording): (WI.CanvasOverviewContentView.prototype.hidden): Deleted. (WI.CanvasOverviewContentView.prototype.get _itemMargin): Deleted. (WI.CanvasOverviewContentView.prototype._refreshPreviews): Deleted. (WI.CanvasOverviewContentView.prototype._updateNavigationItems): Deleted. (WI.CanvasOverviewContentView.prototype._showGridButtonClicked): Deleted. (WI.CanvasOverviewContentView.prototype._updateShowImageGrid): Deleted. * UserInterface/Views/CanvasOverviewContentView.css: (.content-view.canvas-overview): (.content-view.canvas-overview > .content-view.canvas): (@media (prefers-color-scheme: dark) .content-view.canvas-overview): Deleted. * UserInterface/Views/CanvasContentView.js: (WI.CanvasContentView): (WI.CanvasContentView.prototype.handleRefreshButtonClicked): Added. (WI.CanvasContentView.prototype.dropZoneShouldAppearForDragEvent): Added. (WI.CanvasContentView.prototype.dropZoneHandleDrop): Added. (WI.CanvasContentView.prototype.initialLayout): (WI.CanvasContentView.prototype.attached): (WI.CanvasContentView.prototype._populateCanvasElementButtonContextMenu): (WI.CanvasContentView.prototype.shown): Deleted. Move the "Log Canvas Context" to be the first item in the canvas element button context menu. Drive-by: add a `WI.DropZoneView` for when recording JSON files are dragged on top. * UserInterface/Views/CanvasContentView.css: Drive-by: drop `:not(.tab)` from all selectors since the Canvas Tab doesn't exist anymore. * UserInterface/Views/CollectionContentView.js: (WI.CollectionContentView): (WI.CollectionContentView.prototype.get selectedItem): Added. (WI.CollectionContentView.prototype.set selectedItem): Added. (WI.CollectionContentView.prototype.addContentViewForItem): (WI.CollectionContentView.prototype.removeContentViewForItem): (WI.CollectionContentView.prototype.showContentPlaceholder): (WI.CollectionContentView.prototype.initialLayout): (WI.CollectionContentView.prototype._selectItem): (WI.CollectionContentView.prototype._handleClick): Added. (WI.CollectionContentView.prototype.setSelectedItem): Deleted. * UserInterface/Views/CollectionContentView.css: (.content-view.collection > .placeholder:not(.message-text-view)): Added. (.content-view.collection .resource.image img): Deleted. (.content-view.collection .resource.image img:hover): Deleted. When selection is enabled, clicking outside of any of the content views should dismiss the current selection. Clients should also be able to get the currently selected item. * UserInterface/Views/DetailsSectionSimpleRow.js: (WI.DetailsSectionSimpleRow.prototype.set value): Ensure that `0` is considered as a valid value. * UserInterface/Base/Main.js: (WI.loaded): (WI.contentLoaded): (WI.tabContentViewClassForRepresentedObject): * UserInterface/Views/ContentView.js: (WI.ContentView.createFromRepresentedObject): (WI.ContentView.isViewable): Allow `WI.Animation` to be viewable. * UserInterface/Views/Main.css: (.navigation-item-help): Added. (.navigation-item-help > .navigation-bar): Added. (.navigation-item-help > .navigation-bar > .item): Added. (.message-text-view .navigation-item-help): Deleted. (.message-text-view .navigation-item-help .navigation-bar): Deleted. (.message-text-view .navigation-item-help .navigation-bar > .item): Deleted. Allow `WI.createNavigationItemHelp` to be used independently of `WI.createMessageTextView`. * UserInterface/Controllers/DOMManager.js: (WI.DOMManager.prototype.nodeForId): * UserInterface/Controllers/TimelineManager.js: (WI.TimelineManager.prototype.animationTrackingUpdated): * UserInterface/Models/AuditTestCaseResult.js: (WI.AuditTestCaseResult.async fromPayload): Add a fallback so callers don't need to. * UserInterface/Views/ResourceCollectionContentView.js: (WI.ResourceCollectionContentView): * UserInterface/Views/ResourceCollectionContentView.css: (.content-view.resource-collection > .resource.image img): Added. (.content-view.resource-collection > .resource.image img:hover): Added. Drive-by: move these styles to the right file and make them more specific. * UserInterface/Models/Canvas.js: (WI.Canvas.displayNameForContextType): * UserInterface/Models/Recording.js: (WI.Recording.displayNameForRecordingType): Added. Drive-by: fix localized strings. * UserInterface/Views/RecordingContentView.css: Drive-by: drop `:not(.tab)` from all selectors since the Recording Tab doesn't exist anymore. * UserInterface/Main.html: * UserInterface/Images/Graphics.svg: Renamed from Source/WebInspectorUI/UserInterface/Images/Canvas.svg. * Localizations/en.lproj/localizedStrings.js: * UserInterface/Test.html: * UserInterface/Test/Test.js: (WI.loaded): * UserInterface/Test/TestHarness.js: (TestHarness.prototype.expectEmpty): Added. (TestHarness.prototype.expectNotEmpty): Added. (TestHarness.prototype._expectationMessageFormat): (TestHarness.prototype._expectedValueFormat): Add utility function for checking whether the given value is empty: - Array `length === 0` - String `length === 0` - Set `size === 0` - Map `size === 0` - Object `isEmptyObject` Any other type will automatically fail, as non-objects can't be "empty" (e.g. `42`). LayoutTests: * inspector/animation/effectChanged.html: Added. * inspector/animation/effectChanged-expected.txt: Added. * inspector/animation/lifecycle-css-animation.html: Added. * inspector/animation/lifecycle-css-animation-expected.txt: Added. * inspector/animation/lifecycle-css-transition.html: Added. * inspector/animation/lifecycle-css-transition-expected.txt: Added. * inspector/animation/lifecycle-web-animation.html: Added. * inspector/animation/lifecycle-web-animation-expected.txt: Added. * inspector/animation/requestEffectTarget.html: Added. * inspector/animation/requestEffectTarget-expected.txt: Added. * inspector/animation/resolveAnimation.html: Added. * inspector/animation/resolveAnimation-expected.txt: Added. * inspector/animation/targetChanged.html: Added. * inspector/animation/targetChanged-expected.txt: Added. * inspector/animation/resources/lifecycle-utilities.js: Added. (createAnimation): (destroyAnimations): (InspectorTest.AnimationLifecycleUtilities.async awaitAnimationCreated): (InspectorTest.AnimationLifecycleUtilities.async awaitAnimationDestroyed): (InspectorTest.AnimationLifecycleUtilities.async createAnimation): (InspectorTest.AnimationLifecycleUtilities.async destroyAnimations): * inspector/canvas/create-context-webgpu.html: * inspector/canvas/resources/create-context-utilities.js: (destroyCanvases): (awaitCanvasAdded): (InspectorTest.CreateContextUtilities.initializeTestSuite): * inspector/canvas/context-attributes.html: * inspector/canvas/extensions.html: * inspector/canvas/memory.html: * inspector/canvas/requestClientNodes.html: * inspector/canvas/requestContent-2d.html: * inspector/canvas/requestContent-bitmaprenderer.html: * inspector/canvas/requestContent-webgl.html: * inspector/canvas/requestContent-webgl2.html: * inspector/canvas/requestNode.html: * inspector/canvas/resolveContext-2d.html: * inspector/canvas/resolveContext-bitmaprenderer.html: * inspector/canvas/resolveContext-webgl.html: * inspector/canvas/resolveContext-webgl2.html: * inspector/canvas/resolveContext-webgpu.html: * inspector/canvas/recording.html: * inspector/canvas/setRecordingAutoCaptureFrameCount.html: * inspector/canvas/resources/recording-utilities.js: (window.getCanvas): * inspector/canvas/shaderProgram-add-remove-webgpu.html: * inspector/canvas/updateShader-webgpu-sharedVertexFragment.html: * inspector/canvas/resources/shaderProgram-utilities-webgpu.js: * inspector/canvas/resources/shaderProgram-utilities-webgl.js: (deleteContext): (whenProgramAdded): (window.initializeTestSuite): (window.addParentCanvasRemovedTestCase): * inspector/unit-tests/test-harness-expect-functions.html: * inspector/unit-tests/test-harness-expect-functions-expected.txt: git-svn-id: https://svn.webkit.org/repository/webkit/trunk@255396 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-01-29 Devin Rousso Web Inspector: add instrumentation for showing existing Web Animations https://bugs.webkit.org/show_bug.cgi?id=205434 Reviewed by Brian Burg. * inspector/protocol/Animation.json: Add types/commands/events for instrumenting the lifecycle of `Animation` objects, as well as commands for getting the JavaScript wrapper object and the target DOM node. 2020-02-03 Russell Epstein Cherry-pick r255528. rdar://problem/59098310 GetGetterSetterByOffset and GetGetter/GetSetter are not always safe to execute https://bugs.webkit.org/show_bug.cgi?id=206805 Reviewed by Yusuke Suzuki. JSTests: * stress/get-getter-setter-by-offset-not-always-safe-to-execute.js: Added. Source/JavaScriptCore: This patch fixes two bugs. The first is GetGetterSetterByOffset. Previously, we were just checking that we could load the value safely. However, because GetGetterSetterByOffset returns a GetterSetter object, we can only safely move this node into a context where it's guaranteed that the offset loaded will return a GetterSetter. The second fix is GetGetter/GetSetter were both always marked as safe to execute. However, they're only safe to execute when the incoming value to load from is a GetterSetter object. * dfg/DFGSafeToExecute.h: (JSC::DFG::safeToExecute): git-svn-id: https://svn.webkit.org/repository/webkit/trunk@255528 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-01-31 Saam Barati GetGetterSetterByOffset and GetGetter/GetSetter are not always safe to execute https://bugs.webkit.org/show_bug.cgi?id=206805 Reviewed by Yusuke Suzuki. This patch fixes two bugs. The first is GetGetterSetterByOffset. Previously, we were just checking that we could load the value safely. However, because GetGetterSetterByOffset returns a GetterSetter object, we can only safely move this node into a context where it's guaranteed that the offset loaded will return a GetterSetter. The second fix is GetGetter/GetSetter were both always marked as safe to execute. However, they're only safe to execute when the incoming value to load from is a GetterSetter object. * dfg/DFGSafeToExecute.h: (JSC::DFG::safeToExecute): 2020-02-03 Russell Epstein Cherry-pick r255365. rdar://problem/59097795 [JSC] Give up IC when unknown structure transition happens https://bugs.webkit.org/show_bug.cgi?id=206846 Reviewed by Mark Lam. JSTests: * stress/ensure-crash.js: Added. * stress/incorrect-put-could-generate-invalid-ic-but-still-not-causing-bad-behavior-bad-transition-debug.js: Added. (shouldBe): (putter): (not_string.toString): * stress/incorrect-put-could-generate-invalid-ic-but-still-not-causing-bad-behavior-bad-transition.js: Added. (shouldBe): (putter): (not_string.toString): * stress/incorrect-put-could-generate-invalid-ic-but-still-not-causing-bad-behavior.js: Added. (shouldBe): (putter): (not_string.toString): * stress/incorrect-put-could-generate-invalid-ic-involving-dictionary-flatten.js: Added. (shouldBe): (dictionary): (putter): (not_string.toString): Source/JavaScriptCore: When we are creating Put IC for a new property, we grab the old Structure before performing the put. For a custom ::put, our convention is that the implemented ::put should mark the PutPropertySlot as non-cachable. The IC code relies on this in order to work correctly. If we didn't mark it as non-cacheable, a semantic failure can happen. This patch hardens the code against this semantic failure case by giving up trying to cache the IC when the newStructure calculated from oldStructure does not match against the actual structure after the put operation. * jit/Repatch.cpp: (JSC::tryCachePutByID): (JSC::repatchPutByID): * llint/LLIntSlowPaths.cpp: (JSC::LLInt::LLINT_SLOW_PATH_DECL): * runtime/Structure.cpp: (JSC::Structure::flattenDictionaryStructure): * tools/JSDollarVM.cpp: (JSC::functionCreateObjectDoingSideEffectPutWithoutCorrectSlotStatus): (JSC::JSDollarVM::finishCreation): (JSC::JSDollarVM::visitChildren): * tools/JSDollarVM.h: Source/WebCore: IDL Code Generator should taint PutPropertySlot or taint implemented object to avoid Put IC caching when it implements custom ::put operation which has side-effect regardless of Structure. Otherwise, IC can be setup and IC can do fast path without consulting the custom ::put operation. Test: js/dom/put-override-should-not-use-ic.html * bindings/scripts/CodeGeneratorJS.pm: (GenerateHeader): * bindings/scripts/test/JS/JSTestNamedAndIndexedSetterNoIdentifier.h: * bindings/scripts/test/JS/JSTestNamedAndIndexedSetterThrowingException.h: * bindings/scripts/test/JS/JSTestNamedAndIndexedSetterWithIdentifier.h: * bindings/scripts/test/JS/JSTestNamedSetterNoIdentifier.h: * bindings/scripts/test/JS/JSTestNamedSetterThrowingException.h: * bindings/scripts/test/JS/JSTestNamedSetterWithIdentifier.h: * bindings/scripts/test/JS/JSTestNamedSetterWithIndexedGetter.h: * bindings/scripts/test/JS/JSTestNamedSetterWithIndexedGetterAndSetter.h: * bindings/scripts/test/JS/JSTestNamedSetterWithOverrideBuiltins.h: * bindings/scripts/test/JS/JSTestNamedSetterWithUnforgableProperties.h: * bindings/scripts/test/JS/JSTestNamedSetterWithUnforgablePropertiesAndOverrideBuiltins.h: * bindings/scripts/test/JS/JSTestPluginInterface.h: Tools: Add `crash!` annotation, which allows us to write a crashing JS test. * Scripts/run-jsc-stress-tests: * Scripts/webkitruby/jsc-stress-test-writer-default.rb: * Scripts/webkitruby/jsc-stress-test-writer-playstation.rb: * Scripts/webkitruby/jsc-stress-test-writer-ruby.rb: LayoutTests: * js/dom/put-override-should-not-use-ic-expected.txt: Added. * js/dom/put-override-should-not-use-ic.html: Added. git-svn-id: https://svn.webkit.org/repository/webkit/trunk@255365 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-01-28 Yusuke Suzuki [JSC] Give up IC when unknown structure transition happens https://bugs.webkit.org/show_bug.cgi?id=206846 Reviewed by Mark Lam. When we are creating Put IC for a new property, we grab the old Structure before performing the put. For a custom ::put, our convention is that the implemented ::put should mark the PutPropertySlot as non-cachable. The IC code relies on this in order to work correctly. If we didn't mark it as non-cacheable, a semantic failure can happen. This patch hardens the code against this semantic failure case by giving up trying to cache the IC when the newStructure calculated from oldStructure does not match against the actual structure after the put operation. * jit/Repatch.cpp: (JSC::tryCachePutByID): (JSC::repatchPutByID): * llint/LLIntSlowPaths.cpp: (JSC::LLInt::LLINT_SLOW_PATH_DECL): * runtime/Structure.cpp: (JSC::Structure::flattenDictionaryStructure): * tools/JSDollarVM.cpp: (JSC::functionCreateObjectDoingSideEffectPutWithoutCorrectSlotStatus): (JSC::JSDollarVM::finishCreation): (JSC::JSDollarVM::visitChildren): * tools/JSDollarVM.h: 2020-02-03 Russell Epstein Cherry-pick r255171. rdar://problem/59098090 REGRESSION (r250009): testair crashes in (anonymous namespace)::matchAll Reviewed by Yusuke Suzuki. * b3/air/testair.cpp: ((anonymous namespace)::matchAll): Don't replace `str` in the body of the for loop since `match` references it. git-svn-id: https://svn.webkit.org/repository/webkit/trunk@255171 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-01-27 David Kilzer REGRESSION (r250009): testair crashes in (anonymous namespace)::matchAll Reviewed by Yusuke Suzuki. * b3/air/testair.cpp: ((anonymous namespace)::matchAll): Don't replace `str` in the body of the for loop since `match` references it. 2020-02-03 Russell Epstein Cherry-pick r255120. rdar://problem/58942705 Move singleton Intl string locales out of JSGlobalObject. https://bugs.webkit.org/show_bug.cgi?id=206791 Source/JavaScriptCore: Reviewed by Yusuke Suzuki and Andy Wagoner. We were creating an instance of these for each JSGlobalObject when they can be a global singleton since they are always initialized with the same intl data (barring a mid-flight change in intl settings, which we don't support even in the existing code). It turns out that intlPluralRulesAvailableLocales() wasn't called anywhere. IntlPluralRules code currently just uses intlNumberFormatAvailableLocales(). To document that this is intentional, we do the following: 1. have IntlPluralRules code call intlPluralRulesAvailableLocales(), and 2. have intlPluralRulesAvailableLocales() call intlNumberFormatAvailableLocales() for its implementation. See https://bugs.webkit.org/show_bug.cgi?id=206791#c7 and https://bugs.webkit.org/show_bug.cgi?id=206791#c8. In addMissingScriptLocales(), I'm deliberately naming the string with underscores because it's much easier to read pa_PK_String and see that it refers to "pa-PK" as opposed to paPKString. Ditto for zh_CN_String, zh_HK_String, zh_SG_String, and zh_TW_String. * runtime/IntlCollator.cpp: (JSC::IntlCollator::initializeCollator): * runtime/IntlCollatorConstructor.cpp: (JSC::IntlCollatorConstructorFuncSupportedLocalesOf): * runtime/IntlDateTimeFormat.cpp: (JSC::IntlDateTimeFormat::initializeDateTimeFormat): * runtime/IntlDateTimeFormatConstructor.cpp: (JSC::IntlDateTimeFormatConstructorFuncSupportedLocalesOf): * runtime/IntlNumberFormat.cpp: (JSC::IntlNumberFormat::initializeNumberFormat): * runtime/IntlNumberFormatConstructor.cpp: (JSC::IntlNumberFormatConstructorFuncSupportedLocalesOf): * runtime/IntlObject.cpp: (JSC::convertICULocaleToBCP47LanguageTag): (JSC::addMissingScriptLocales): (JSC::intlCollatorAvailableLocales): (JSC::intlDateTimeFormatAvailableLocales): (JSC::intlNumberFormatAvailableLocales): (JSC::defaultLocale): * runtime/IntlObject.h: * runtime/IntlPluralRules.cpp: (JSC::IntlPluralRules::initializePluralRules): * runtime/IntlPluralRulesConstructor.cpp: (JSC::IntlPluralRulesConstructorFuncSupportedLocalesOf): * runtime/JSGlobalObject.cpp: (JSC::addMissingScriptLocales): Deleted. (JSC::JSGlobalObject::intlCollatorAvailableLocales): Deleted. (JSC::JSGlobalObject::intlDateTimeFormatAvailableLocales): Deleted. (JSC::JSGlobalObject::intlNumberFormatAvailableLocales): Deleted. (JSC::JSGlobalObject::intlPluralRulesAvailableLocales): Deleted. * runtime/JSGlobalObject.h: Source/WTF: Reviewed by Yusuke Suzuki. Fix a bug in StringImpl::createStaticStringImpl(): I forgot to set its hash value when I introduced it. StaticStringImpls require that its hash code be set ahead of time, and cannot be mutated at runtime. See the comment in the definition of StaticStringImpl in StringImpl.h. * wtf/text/StringImpl.cpp: (WTF::StringImpl::createStaticStringImpl): git-svn-id: https://svn.webkit.org/repository/webkit/trunk@255120 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-01-24 Mark Lam Move singleton Intl string locales out of JSGlobalObject. https://bugs.webkit.org/show_bug.cgi?id=206791 Reviewed by Yusuke Suzuki and Andy Wagoner. We were creating an instance of these for each JSGlobalObject when they can be a global singleton since they are always initialized with the same intl data (barring a mid-flight change in intl settings, which we don't support even in the existing code). It turns out that intlPluralRulesAvailableLocales() wasn't called anywhere. IntlPluralRules code currently just uses intlNumberFormatAvailableLocales(). To document that this is intentional, we do the following: 1. have IntlPluralRules code call intlPluralRulesAvailableLocales(), and 2. have intlPluralRulesAvailableLocales() call intlNumberFormatAvailableLocales() for its implementation. See https://bugs.webkit.org/show_bug.cgi?id=206791#c7 and https://bugs.webkit.org/show_bug.cgi?id=206791#c8. In addMissingScriptLocales(), I'm deliberately naming the string with underscores because it's much easier to read pa_PK_String and see that it refers to "pa-PK" as opposed to paPKString. Ditto for zh_CN_String, zh_HK_String, zh_SG_String, and zh_TW_String. * runtime/IntlCollator.cpp: (JSC::IntlCollator::initializeCollator): * runtime/IntlCollatorConstructor.cpp: (JSC::IntlCollatorConstructorFuncSupportedLocalesOf): * runtime/IntlDateTimeFormat.cpp: (JSC::IntlDateTimeFormat::initializeDateTimeFormat): * runtime/IntlDateTimeFormatConstructor.cpp: (JSC::IntlDateTimeFormatConstructorFuncSupportedLocalesOf): * runtime/IntlNumberFormat.cpp: (JSC::IntlNumberFormat::initializeNumberFormat): * runtime/IntlNumberFormatConstructor.cpp: (JSC::IntlNumberFormatConstructorFuncSupportedLocalesOf): * runtime/IntlObject.cpp: (JSC::convertICULocaleToBCP47LanguageTag): (JSC::addMissingScriptLocales): (JSC::intlCollatorAvailableLocales): (JSC::intlDateTimeFormatAvailableLocales): (JSC::intlNumberFormatAvailableLocales): (JSC::defaultLocale): * runtime/IntlObject.h: * runtime/IntlPluralRules.cpp: (JSC::IntlPluralRules::initializePluralRules): * runtime/IntlPluralRulesConstructor.cpp: (JSC::IntlPluralRulesConstructorFuncSupportedLocalesOf): * runtime/JSGlobalObject.cpp: (JSC::addMissingScriptLocales): Deleted. (JSC::JSGlobalObject::intlCollatorAvailableLocales): Deleted. (JSC::JSGlobalObject::intlDateTimeFormatAvailableLocales): Deleted. (JSC::JSGlobalObject::intlNumberFormatAvailableLocales): Deleted. (JSC::JSGlobalObject::intlPluralRulesAvailableLocales): Deleted. * runtime/JSGlobalObject.h: 2020-02-03 Russell Epstein Cherry-pick r255112. rdar://problem/58942707 IntlObject's cached strings should be immortal and safe for concurrent access. https://bugs.webkit.org/show_bug.cgi?id=206779 Reviewed by Yusuke Suzuki. JSTests: * stress/numberingSystemsForLocale-cached-strings-should-be-immortal-and-safe-for-concurrent-access.js: Added. Source/JavaScriptCore: In IntlObject's numberingSystemsForLocale(), we have a never destroyed cachedNumberingSystems which is a singleton vector of Strings which are shared multiple VMs. Hence, the strings in this vector should be a StaticStringImpl so that it will be immortal, and can be access concurrently from multiple VMs on different threads without any ref/deref'ing race issues. * runtime/IntlObject.cpp: (JSC::numberingSystemsForLocale): Source/WTF: Add a factory for creating a dynamically allocated StaticStringImpl. Note: StaticStringImpl is guaranteed to have the same shape as StringImpl. The only difference is that s_refCountFlagIsStaticString is set on the refCount for StaticStringImpl. Since the client will use the StaticStringImpl as a StringImpl, we implement the factory by using StringImpl::createInternal() for simplicity, and set the s_refCountFlagIsStaticString flag thereafter. * wtf/text/StringImpl.cpp: (WTF::StringImpl::createStaticStringImpl): * wtf/text/StringImpl.h: git-svn-id: https://svn.webkit.org/repository/webkit/trunk@255112 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-01-24 Mark Lam IntlObject's cached strings should be immortal and safe for concurrent access. https://bugs.webkit.org/show_bug.cgi?id=206779 Reviewed by Yusuke Suzuki. In IntlObject's numberingSystemsForLocale(), we have a never destroyed cachedNumberingSystems which is a singleton vector of Strings which are shared multiple VMs. Hence, the strings in this vector should be a StaticStringImpl so that it will be immortal, and can be access concurrently from multiple VMs on different threads without any ref/deref'ing race issues. * runtime/IntlObject.cpp: (JSC::numberingSystemsForLocale): 2020-01-28 Russell Epstein Apply patch. rdar://problem/58856012 2020-01-27 Mark Lam Cherry-pick r254959. rdar://problem/58856012 Omitted parts concerning CheckNeutered because those are not applicable since r254252 will not being merged to this branch. 2020-01-22 Keith Miller InternalField and CheckNeutered DFG nodes are not always safe to execute https://bugs.webkit.org/show_bug.cgi?id=206632 Reviewed by Saam Barati. We currently mark (Get/Set)InternalField/CheckNeutered nodes as safe to execute everywhere. However, GetInternalField, etc. rely on a proof that the cell passed to it is a subclass of InteralFieldObject. This combination means we may hoist the nodes past the check guarding them. Also, remove a bogus assertion that we will have proven the value passed to CheckNeutered is a TypedArray. It's not valid to require that AI preserve a precise model of all invariants since phases can make changes that AI doesn't understand. * dfg/DFGAbstractInterpreterInlines.h: (JSC::DFG::AbstractInterpreter::executeEffects): * dfg/DFGClobberize.h: (JSC::DFG::clobberize): * dfg/DFGSafeToExecute.h: (JSC::DFG::safeToExecute): * dfg/DFGSpeculativeJIT.cpp: (JSC::DFG::SpeculativeJIT::compileCheckNeutered): * ftl/FTLLowerDFGToB3.cpp: (JSC::FTL::DFG::LowerDFGToB3::compileCheckNeutered): 2020-01-27 Russell Epstein Cherry-pick r254788. rdar://problem/58856018 Air O0 should have better stack allocation https://bugs.webkit.org/show_bug.cgi?id=206436 Reviewed by Tadeu Zagallo. JSTests: * wasm/stress/dont-stack-overflow-in-air.js: Added. Source/JavaScriptCore: This patch adds a simple stack slot allocator to Air O0 to make code use smaller stack frames. The huge stack frames from the old stack allocator were leading to stack overflows in some programs. Before, each Tmp got its own stack slot. The new allocator works similar to O0's register allocator. This stack allocator linearizes the program and uses live range end as an opportunity to place the stack slot on a free list of available stack slots. This patch also fixes an issue in our linearization code where the head of a block and the tail of another block would share the same linearization index. This didn't matter for register allocation, but does matter for the stack allocator. So "live at head", and "live at tail" now get their own linearization index. * b3/air/AirAllocateRegistersAndStackAndGenerateCode.cpp: (JSC::B3::Air::GenerateAndAllocateRegisters::buildLiveRanges): (JSC::B3::Air::GenerateAndAllocateRegisters::prepareForGeneration): (JSC::B3::Air::GenerateAndAllocateRegisters::generate): * b3/air/AirAllocateRegistersAndStackAndGenerateCode.h: * b3/air/AirLiveness.h: git-svn-id: https://svn.webkit.org/repository/webkit/trunk@254788 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-01-17 Saam Barati Air O0 should have better stack allocation https://bugs.webkit.org/show_bug.cgi?id=206436 Reviewed by Tadeu Zagallo. This patch adds a simple stack slot allocator to Air O0 to make code use smaller stack frames. The huge stack frames from the old stack allocator were leading to stack overflows in some programs. Before, each Tmp got its own stack slot. The new allocator works similar to O0's register allocator. This stack allocator linearizes the program and uses live range end as an opportunity to place the stack slot on a free list of available stack slots. This patch also fixes an issue in our linearization code where the head of a block and the tail of another block would share the same linearization index. This didn't matter for register allocation, but does matter for the stack allocator. So "live at head", and "live at tail" now get their own linearization index. * b3/air/AirAllocateRegistersAndStackAndGenerateCode.cpp: (JSC::B3::Air::GenerateAndAllocateRegisters::buildLiveRanges): (JSC::B3::Air::GenerateAndAllocateRegisters::prepareForGeneration): (JSC::B3::Air::GenerateAndAllocateRegisters::generate): * b3/air/AirAllocateRegistersAndStackAndGenerateCode.h: * b3/air/AirLiveness.h: 2020-01-24 Russell Epstein Cherry-pick r254996. rdar://problem/58856010 OptimizeAssociativeExpressionTrees should reset value owners before running https://bugs.webkit.org/show_bug.cgi?id=206670 Reviewed by Robin Morisset. We have a crash inside OptimizeAssociativeExpressionTrees and we don't know how to reproduce it. Also, based on Mark's auditing of the crash site's assembly, Mark thinks we're crashing on a "currupt" basic block. After I audited the code, I saw that we rely on value owners in this phase. However, we don't actually reset them before running the phase. This patch adds that as a speculative fix for the crash we're seeing. * b3/B3OptimizeAssociativeExpressionTrees.cpp: (JSC::B3::OptimizeAssociativeExpressionTrees::run): git-svn-id: https://svn.webkit.org/repository/webkit/trunk@254996 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-01-23 Saam Barati OptimizeAssociativeExpressionTrees should reset value owners before running https://bugs.webkit.org/show_bug.cgi?id=206670 Reviewed by Robin Morisset. We have a crash inside OptimizeAssociativeExpressionTrees and we don't know how to reproduce it. Also, based on Mark's auditing of the crash site's assembly, Mark thinks we're crashing on a "currupt" basic block. After I audited the code, I saw that we rely on value owners in this phase. However, we don't actually reset them before running the phase. This patch adds that as a speculative fix for the crash we're seeing. * b3/B3OptimizeAssociativeExpressionTrees.cpp: (JSC::B3::OptimizeAssociativeExpressionTrees::run): 2020-01-24 Russell Epstein Cherry-pick r254962. rdar://problem/58856037 Restore nullification of DFG::Plan::m_vm when the plan is cancelled. https://bugs.webkit.org/show_bug.cgi?id=206633 Reviewed by Robin Morisset. In r253243, I replaced the nullification of Plan::m_vm in Plan::cancel() with code to decorate the m_vm pointer with a nuke bit. The thinking is that keeping the VM pointer in nuked form allows us to do certain assertions, as well as implementing code in support of keeping Boxs alive. It is only correct to use the nuked VM pointer if and only if the VM is guaranteed to outlive the Plan. r253243 guarantees this condition. In r254464, I replaced the use of Box with CacheableIdentifier. This obviated all the support code added above, and rolled out most of it. However, I opted to keep the nuked VM pointer in the DFG::Plan to as a debugging aid (it's nice to be able to know which VM the Plan came from). However, r254464 also undid the guarantee that the VM will outlive the Plan. As a result, a nuked VM pointer is no longer guaranteed to point to a valid VM. Some worker layout tests, run on an ASAN build, detected that the pointer is pointing to an already freed VM and failed with a crash. This patch fixes this issue by completely reverting the nuked VM pointer code, and restores nullification of the m_vm pointer in Plan::cancel(). * dfg/DFGPlan.cpp: (JSC::DFG::Plan::computeCompileTimes const): (JSC::DFG::Plan::cancel): * dfg/DFGPlan.h: (JSC::DFG::Plan::vm const): (JSC::DFG::Plan::unnukedVM const): Deleted. (JSC::DFG::Plan::nuke): Deleted. (JSC::DFG::Plan::unnuke): Deleted. git-svn-id: https://svn.webkit.org/repository/webkit/trunk@254962 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-01-22 Mark Lam Restore nullification of DFG::Plan::m_vm when the plan is cancelled. https://bugs.webkit.org/show_bug.cgi?id=206633 Reviewed by Robin Morisset. In r253243, I replaced the nullification of Plan::m_vm in Plan::cancel() with code to decorate the m_vm pointer with a nuke bit. The thinking is that keeping the VM pointer in nuked form allows us to do certain assertions, as well as implementing code in support of keeping Boxs alive. It is only correct to use the nuked VM pointer if and only if the VM is guaranteed to outlive the Plan. r253243 guarantees this condition. In r254464, I replaced the use of Box with CacheableIdentifier. This obviated all the support code added above, and rolled out most of it. However, I opted to keep the nuked VM pointer in the DFG::Plan to as a debugging aid (it's nice to be able to know which VM the Plan came from). However, r254464 also undid the guarantee that the VM will outlive the Plan. As a result, a nuked VM pointer is no longer guaranteed to point to a valid VM. Some worker layout tests, run on an ASAN build, detected that the pointer is pointing to an already freed VM and failed with a crash. This patch fixes this issue by completely reverting the nuked VM pointer code, and restores nullification of the m_vm pointer in Plan::cancel(). * dfg/DFGPlan.cpp: (JSC::DFG::Plan::computeCompileTimes const): (JSC::DFG::Plan::cancel): * dfg/DFGPlan.h: (JSC::DFG::Plan::vm const): (JSC::DFG::Plan::unnukedVM const): Deleted. (JSC::DFG::Plan::nuke): Deleted. (JSC::DFG::Plan::unnuke): Deleted. 2020-01-23 Russell Epstein Cherry-pick r254866. rdar://problem/58807986 JSTests: Object allocation sinking is missing PutHint for allocations unreachable in the graph https://bugs.webkit.org/show_bug.cgi?id=203799 Reviewed by Saam Barati. * stress/allocation-sinking-puthint-control-flow-2.js: Added. (f.handler.construct): (f): Source/JavaScriptCore: Object allocation sinking is missing PutHint for sunken allocations https://bugs.webkit.org/show_bug.cgi?id=203799 Reviewed by Saam Barati. Consider the following graph: Block #0: 1: PhantomCreateActivation() 2: PhantomNewFunction() PutHint(@2, @1, FunctionActivationPLoc) Branch(#1, #2) Block #1: 3: MaterializeCreateActivation() PutHint(@2, @3, FunctionActivationPLoc) Upsilon(@3, ^5) Jump(#3) Block #2: 4: MaterializeCreateActivation() PutHint(@2, @4, FunctionActivationPLoc) Upsilon(@4, ^5) Jump(#3) Block #3: 5: Phi() ExitOK() On Block #3, we need to emit a PutHint after the Phi, since we might exit after it. However, object allocation sinking skipped this Phi because it was checking whether the base of the location that caused us to create this Phi (@2) was live, but it's dead in the graph (there are no pointers to it). The issue is that, even though there are no pointers to the base, the location `PromotedHeapLocation(@2, FunctionActivationPLoc)` is still live, so we should PutHint to it. We fix it by checking for liveness of the location rather than its base. * dfg/DFGObjectAllocationSinkingPhase.cpp: git-svn-id: https://svn.webkit.org/repository/webkit/trunk@254866 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-01-21 Tadeu Zagallo Object allocation sinking is missing PutHint for sunken allocations https://bugs.webkit.org/show_bug.cgi?id=203799 Reviewed by Saam Barati. Consider the following graph: Block #0: 1: PhantomCreateActivation() 2: PhantomNewFunction() PutHint(@2, @1, FunctionActivationPLoc) Branch(#1, #2) Block #1: 3: MaterializeCreateActivation() PutHint(@2, @3, FunctionActivationPLoc) Upsilon(@3, ^5) Jump(#3) Block #2: 4: MaterializeCreateActivation() PutHint(@2, @4, FunctionActivationPLoc) Upsilon(@4, ^5) Jump(#3) Block #3: 5: Phi() ExitOK() On Block #3, we need to emit a PutHint after the Phi, since we might exit after it. However, object allocation sinking skipped this Phi because it was checking whether the base of the location that caused us to create this Phi (@2) was live, but it's dead in the graph (there are no pointers to it). The issue is that, even though there are no pointers to the base, the location `PromotedHeapLocation(@2, FunctionActivationPLoc)` is still live, so we should PutHint to it. We fix it by checking for liveness of the location rather than its base. * dfg/DFGObjectAllocationSinkingPhase.cpp: 2020-01-23 Russell Epstein Cherry-pick r254687. rdar://problem/58811365 operationToObject() should check for a null errorMessage. https://bugs.webkit.org/show_bug.cgi?id=206339 Reviewed by Yusuke Suzuki. JSTests: * stress/operationToObject-should-check-for-null-errorMessage.js: Added. Source/JavaScriptCore: r224280 introduced operationToObject() with an option to specify a custom error message. r254252 added a scenario where the passed in error message is null but did not update operationToObject() to allow for this. This patch adds the missing null check. * dfg/DFGOperations.cpp: git-svn-id: https://svn.webkit.org/repository/webkit/trunk@254687 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-01-16 Mark Lam operationToObject() should check for a null errorMessage. https://bugs.webkit.org/show_bug.cgi?id=206339 Reviewed by Yusuke Suzuki. r224280 introduced operationToObject() with an option to specify a custom error message. r254252 added a scenario where the passed in error message is null but did not update operationToObject() to allow for this. This patch adds the missing null check. * dfg/DFGOperations.cpp: 2020-01-23 Russell Epstein Cherry-pick r254523. rdar://problem/58606225 Web Inspector: crash in DumpRenderTree at com.apple.JavaScriptCore: WTF::RefCountedBase::hasOneRef const https://bugs.webkit.org/show_bug.cgi?id=206191 Reviewed by Joseph Pecoraro. * debugger/Debugger.cpp: (JSC::Debugger::attach): (GatherSourceProviders::GatherSourceProviders): Deleted. (GatherSourceProviders::operator()): Deleted. Use `RefPtr` instead of `SourceProvider*` in case the `FunctionExecutable` is destroyed after the `SourceProvider*` is saved, which would destroy the `SourceProvider` as well. git-svn-id: https://svn.webkit.org/repository/webkit/trunk@254523 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-01-14 Devin Rousso Web Inspector: crash in DumpRenderTree at com.apple.JavaScriptCore: WTF::RefCountedBase::hasOneRef const https://bugs.webkit.org/show_bug.cgi?id=206191 Reviewed by Joseph Pecoraro. * debugger/Debugger.cpp: (JSC::Debugger::attach): (GatherSourceProviders::GatherSourceProviders): Deleted. (GatherSourceProviders::operator()): Deleted. Use `RefPtr` instead of `SourceProvider*` in case the `FunctionExecutable` is destroyed after the `SourceProvider*` is saved, which would destroy the `SourceProvider` as well. 2020-01-21 Alan Coon Cherry-pick r254632. rdar://problem/58764714 Revert bytecode checkpoints since it breaks watch https://bugs.webkit.org/show_bug.cgi?id=206301 Unreviewed, revert. git-svn-id: https://svn.webkit.org/repository/webkit/trunk@254632 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-01-15 Keith Miller Revert bytecode checkpoints since it breaks watch https://bugs.webkit.org/show_bug.cgi?id=206301 Unreviewed, revert. 2020-01-15 Alan Coon Cherry-pick r254187. rdar://problem/58605950 Implement css3-images image-orientation https://bugs.webkit.org/show_bug.cgi?id=89052 Patch by Said Abou-Hallawa on 2020-01-07 Reviewed by Simon Fraser. LayoutTests/imported/w3c: * web-platform-tests/css/css-images/inheritance-expected.txt: * web-platform-tests/css/css-images/inheritance.html: This test is re-synced from upstream * web-platform-tests/css/css-images/parsing/image-orientation-computed-expected.txt: * web-platform-tests/css/css-images/parsing/image-orientation-valid-expected.txt: Source/JavaScriptCore: Remove the ENABLE_CSS_IMAGE_ORIENTATION feature flag. * Configurations/FeatureDefines.xcconfig: Source/WebCore: Implement the CSS image-orientation property for content images. The valid values are "from-image" or "none". The default value is "from-image". Specification: https://drafts.csswg.org/css-images-3/#the-image-orientation GitHub issue: https://github.com/w3c/csswg-drafts/issues/4164 Tests: fast/images/image-orientation-dynamic-from-image.html fast/images/image-orientation-dynamic-none.html fast/images/image-orientation-none.html * Configurations/FeatureDefines.xcconfig: * css/CSSComputedStyleDeclaration.cpp: (WebCore::ComputedStyleExtractor::valueForPropertyInStyle): * css/CSSPrimitiveValueMappings.h: (WebCore::CSSPrimitiveValue::operator ImageOrientation const): Deleted. * css/CSSProperties.json: * css/CSSValueKeywords.in: * css/parser/CSSPropertyParser.cpp: (WebCore::consumeImageOrientation): (WebCore::CSSPropertyParser::parseSingleValue): * rendering/RenderElement.cpp: (WebCore::RenderElement::imageOrientation const): * rendering/RenderImage.cpp: (WebCore::RenderImage::styleDidChange): * rendering/style/RenderStyle.cpp: (WebCore::rareInheritedDataChangeRequiresLayout): * rendering/style/RenderStyle.h: (WebCore::RenderStyle::setImageOrientation): (WebCore::RenderStyle::initialImageOrientation): (WebCore::RenderStyle::imageOrientation const): * rendering/style/StyleRareInheritedData.cpp: (WebCore::StyleRareInheritedData::StyleRareInheritedData): (WebCore::StyleRareInheritedData::operator== const): * rendering/style/StyleRareInheritedData.h: * style/StyleBuilderConverter.h: (WebCore::Style::BuilderConverter::convertImageOrientation): Source/WebCore/PAL: Remove the ENABLE_CSS_IMAGE_ORIENTATION feature flag. * Configurations/FeatureDefines.xcconfig: Source/WebKit: Remove the ENABLE_CSS_IMAGE_ORIENTATION feature flag. * Configurations/FeatureDefines.xcconfig: Source/WebKitLegacy/mac: Remove the ENABLE_CSS_IMAGE_ORIENTATION feature flag. * Configurations/FeatureDefines.xcconfig: Source/WTF: Remove the ENABLE_CSS_IMAGE_ORIENTATION feature flag. * wtf/FeatureDefines.h: Tools: Remove the ENABLE_CSS_IMAGE_ORIENTATION feature flag. * TestWebKitAPI/Configurations/FeatureDefines.xcconfig: LayoutTests: Test the css image-orientation property. * fast/images/image-orientation-dynamic-from-image-expected.html: Added. * fast/images/image-orientation-dynamic-from-image.html: Added. * fast/images/image-orientation-dynamic-none-expected.html: Added. * fast/images/image-orientation-dynamic-none.html: Added. * fast/images/image-orientation-none-expected.html: Added. * fast/images/image-orientation-none.html: Added. git-svn-id: https://svn.webkit.org/repository/webkit/trunk@254187 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-01-07 Said Abou-Hallawa Implement css3-images image-orientation https://bugs.webkit.org/show_bug.cgi?id=89052 Reviewed by Simon Fraser. Remove the ENABLE_CSS_IMAGE_ORIENTATION feature flag. * Configurations/FeatureDefines.xcconfig: 2020-01-15 Alan Coon Cherry-pick r254464. rdar://problem/58553161 Replace uses of Box with a new CacheableIdentifier class. https://bugs.webkit.org/show_bug.cgi?id=205544 Reviewed by Saam Barati. JSTests: * stress/racy-gc-cleanup-of-identifier-after-mutator-stops-running.js: Added. Source/JavaScriptCore: The introduction of the use of Box was to get around having to ref/deref the underlying UniqedStringImpl in Identifiers from the compiler and GC threads. However, it proves to be difficult to control when these Boxs get destructed, and requires that we find all the places in the compier and GC threads where this can happen, and apply keep alive tactics there to defer destruction of the Box to the mutator thread. This patch fixes this by replacing uses of Box with CacheableIdentifier, which is effectively a tagged union of a JSCell* or a UniquedStringImpl*. The JSCell*, in this case, can be either a Symbol* or a JSString* that is backed by an atom string. The VM runtime ensures that we'll never try to cache an identifier from a JSCell that is not one of these. This CacheableIdentifier can be destructed from the compiler or GC thread. Since it doesn't hold a ref of the underlying UniquedStringImpl, it won't try to deref it on destruction. Instead, we'll need to visit CacheableIdentifiers during GC scans to keep the JSCell in it alive, and that JSCell will, in turn, keep the underlying UniquedStringImpl alive. This patch also does the following: 1. Add a visitAggregate() method to StructureStubInfo, PolymorphicAccess, and AccessCase to visit the CacheableIdentifier's JSCell identifier. This visitAggregate() is called from CodeBlock::stronglyVisitStrongReferences(). When we write barrier a CodeBlock, it guarantees that its visitAggregate() methods is called. However, it does not guarantee that its propagateTransitions() method will be called. Since the CacheableIdentifier's reference to a cell should be a strong reference, visiting it via a StructureStubInfo::visitAggregate() method is the right thing to do. See https://bugs.webkit.org/show_bug.cgi?id=205544#c7 for an example of why propagateTransitions() doesn't always do the job. StructureStubInfo::visitWeakReferences() is also inappropriate for this because it is only called after all marking is done. It is also not meant to keep cells alive but merely for clearing weak references to dead cells. 2. Also add to visitAggregate() for ModuleNamespaceData's m_identifier in GetByStatus::markIfCheap(). 3. Remove previously applied keep alive tactics to work around Box destruction. This also retores the allowance to destruct DFG::Plans on a compiler thread. 4. Added a JSString:getValueImpl() helper. 5. Added a write barrier in DFG and FTL JITFinalizer's finalizeCommon() to ensure that frozen values are scanned by the GC. During compilation, the frozen values were previously protected by the Plan. After finalization, they should be protected by the CodeBlock. Hence, we should barrier the CodeBlock since the last GC scan of the CodeBlock may have happened before the frozen values were registered with the CodeBlock. GC considerations: ================== The following also addresses Yusuke's concerns in https://bugs.webkit.org/show_bug.cgi?id=205544#c10. CacheableIdentifier is only stored as fields in 4 classes/structs: 1. AccessCase::m_identifier 2. GetByIdVariant::m_identifier 3. ModuleNamespaceData::m_identifier 4. StructureStubInfo::m_getByIdSelfIdentifier AccessCase::m_identifier ======================== While the access case is being created and added in tryCacheGetBy(), the CacheableIdentifier is still on the stack and protected from the GC. At the bottom of tryCacheGetBy(), StructureStubInfo::addAccessCase() is called to add the access case. StructureStubInfo::addAccessCase() will barrier the owner CodeBlock at its end, and CodeBlock::stronglyVisitStrongReferences() will visit the StructureStubInfo, which in turn visits the AccessCase. StructureStubInfo::visitAggregate() has been added for this purpose. GetByIdVariant::m_identifier ============================ GetByIdVariant is only stored in GetByStatus. Both GetByIdVariant and GetByStatus are only created and handled in the DFG/FTL compiler threads. While the compiler thread is working with them, they are safe from the GC because the GC won't collect objects until the compiler thread is at a SafePoint. At compiler SafePoints, any GetByStatus that needs to be persisted is stored in DFG::Plan::m_recordedStatuses. The Plan will visit the m_recordedStatuses in Plan::checkLivenessAndVisitChildren(). At the end of compilation, Plan::m_recordedStatuses is transferred over to the owner CodeBlock's DFG::CommonData in Plan::finalizeWithoutNotifyingCallback(). Plan::finalizeWithoutNotifyingCallback() will also barrier the owner CodeBlock at its end. Thereafter, CodeBlock::stronglyVisitStrongReferences() will visit the recordedStatuses. ModuleNamespaceData::m_identifier ================================= ModuleNamespaceData is only stored in a GetByStatus, and is therefore protected similarly as the GetByIdVariant::m_identifier case above. StructureStubInfo::m_getByIdSelfIdentifier ========================================== StructureStubInfo::initGetByIdSelf() is called from inside tryCacheGetBy(). StructureStubInfo::initGetByIdSelf() will barrier the owner CodeBlock. The CacheableIdentifier here is protected in the same way as the AccessCase::m_identifier case above. DesiredIdentifiers ================== The compiler thread may also stash a CacheableIdentifier's uid in its DesiredIdentifiers. Normally, the identifiers stashed in DesiredIdentifiers are from identifiers that the CodeBlock already knows abut and manages (e.g. from GetByIds). For uids from a cell-based CacheableIdentifier variable is passed to a GetByVal, we need kep the cell alive in order to keep the uid alive. This is achieved by freezing the cell with freezeStrong() in the op_get_by_val case in the DFG BytecodeParser. Reseting a StructureStubInfo while its IC code is still executing on the stack ============================================================================== The concern is that IC code may call slow path / getter functions that may in turn: 1. reset the IC, and 2. run the GC. This can be a problem if: 1. there is a scenario where we return from the slow path / getter function and run IC code that uses the cell / uid from the CacheableIdentifier. This is because the StructureStubInfo is what visits the that cell, which in turn its uid alive. Once the StructureStubInfo is reset, it will no longer be associated with any AccessCase or the m_getByIdSelfIdentifier. As such they will not be visited, and the CacheableIdentifier may be collected by the GC. In practice, the generated IC code never uses the cell / uid after it calls any slow path / getter function. I've verified this by auditing the code generation in InlineAccess::generateSelfInAccess() and PolymorphicAccess::regenerate(). Hence, there's no issue with using a collected cell / uid. 2. there is a scenario where a slow path / getter function makes use of the cell / uid from the CacheableIdentifier but does not protect it. The only 2 slow path functions: operationGetByValGeneric() operationGetByValOptimize() operationGetByValGeneric() does not use any CacheableIdentifier from the StructureStubInfo. operationGetByValOptimize() modifies the StructureStubInfo in tryCacheGetBy() under the protection of a GCSafeConcurrentJSLocker, and can reset the StructureStubInfo. However, it does not use any CacheableIdentifier after that. Hence, there's also no GC issue here. * CMakeLists.txt: * JavaScriptCore.xcodeproj/project.pbxproj: * Sources.txt: * bytecode/AccessCase.cpp: (JSC::AccessCase::AccessCase): (JSC::AccessCase::create): (JSC::AccessCase::fromStructureStubInfo): (JSC::AccessCase::commit): (JSC::AccessCase::canReplace const): (JSC::AccessCase::dump const): (JSC::AccessCase::visitAggregate const): (JSC::AccessCase::generateWithGuard): (JSC::AccessCase::generateImpl): * bytecode/AccessCase.h: (JSC::AccessCase::uid const): (JSC::AccessCase::identifier const): * bytecode/CodeBlock.cpp: (JSC::CodeBlock::propagateTransitions): (JSC::CodeBlock::stronglyVisitStrongReferences): * bytecode/GetByIdVariant.cpp: (JSC::GetByIdVariant::GetByIdVariant): (JSC::GetByIdVariant::attemptToMerge): (JSC::GetByIdVariant::visitAggregate): (JSC::GetByIdVariant::dumpInContext const): * bytecode/GetByIdVariant.h: (JSC::GetByIdVariant::identifier const): (JSC::GetByIdVariant::overlaps): * bytecode/GetByStatus.cpp: (JSC::GetByStatus::computeFromLLInt): (JSC::GetByStatus::computeFor): (JSC::GetByStatus::computeForStubInfoWithoutExitSiteFeedback): (JSC::GetByStatus::visitAggregate): (JSC::GetByStatus::singleIdentifier const): * bytecode/GetByStatus.h: * bytecode/GetterSetterAccessCase.cpp: (JSC::GetterSetterAccessCase::GetterSetterAccessCase): (JSC::GetterSetterAccessCase::create): * bytecode/GetterSetterAccessCase.h: * bytecode/InstanceOfAccessCase.cpp: (JSC::InstanceOfAccessCase::InstanceOfAccessCase): * bytecode/IntrinsicGetterAccessCase.cpp: (JSC::IntrinsicGetterAccessCase::IntrinsicGetterAccessCase): (JSC::IntrinsicGetterAccessCase::create): * bytecode/IntrinsicGetterAccessCase.h: * bytecode/ModuleNamespaceAccessCase.cpp: (JSC::ModuleNamespaceAccessCase::ModuleNamespaceAccessCase): (JSC::ModuleNamespaceAccessCase::create): * bytecode/ModuleNamespaceAccessCase.h: * bytecode/PolymorphicAccess.cpp: (JSC::PolymorphicAccess::visitAggregate): (JSC::PolymorphicAccess::regenerate): * bytecode/PolymorphicAccess.h: * bytecode/ProxyableAccessCase.cpp: (JSC::ProxyableAccessCase::ProxyableAccessCase): (JSC::ProxyableAccessCase::create): * bytecode/ProxyableAccessCase.h: * bytecode/RecordedStatuses.cpp: (JSC::RecordedStatuses::visitAggregate): * bytecode/RecordedStatuses.h: * bytecode/StructureStubInfo.cpp: (JSC::StructureStubInfo::initGetByIdSelf): (JSC::StructureStubInfo::addAccessCase): (JSC::StructureStubInfo::visitAggregate): * bytecode/StructureStubInfo.h: (JSC::StructureStubInfo::getByIdSelfIdentifier): * dfg/DFGByteCodeParser.cpp: (JSC::DFG::ByteCodeParser::parseGetById): (JSC::DFG::ByteCodeParser::parseBlock): * dfg/DFGDesiredIdentifiers.cpp: (JSC::DFG::DesiredIdentifiers::ensure): (JSC::DFG::DesiredIdentifiers::at const): (JSC::DFG::DesiredIdentifiers::reallyAdd): (JSC::DFG::DesiredIdentifiers::processCodeBlockIdentifiersIfNeeded): Deleted. * dfg/DFGDesiredIdentifiers.h: * dfg/DFGJITFinalizer.cpp: (JSC::DFG::JITFinalizer::finalizeCommon): * dfg/DFGPlan.cpp: (JSC::DFG::Plan::~Plan): (JSC::DFG::Plan::checkLivenessAndVisitChildren): (JSC::DFG::Plan::cancel): * dfg/DFGPlan.h: (JSC::DFG::Plan::keepAliveIdentifier): Deleted. * dfg/DFGWorklist.cpp: (JSC::DFG::Worklist::removeAllReadyPlansForVM): (JSC::DFG::Worklist::removeDeadPlans): (JSC::DFG::Worklist::removeNonCompilingPlansForVM): (JSC::DFG::Worklist::deleteCancelledPlansForVM): Deleted. * dfg/DFGWorklist.h: * ftl/FTLJITFinalizer.cpp: (JSC::FTL::JITFinalizer::finalizeCommon): * jit/JITOperations.cpp: * jit/Repatch.cpp: (JSC::tryCacheGetBy): (JSC::repatchGetBy): (JSC::tryCacheArrayGetByVal): (JSC::tryCacheInstanceOf): * jit/Repatch.h: * runtime/CacheableIdentifier.cpp: Added. (JSC::CacheableIdentifier::dump const): * runtime/CacheableIdentifier.h: Added. (JSC::CacheableIdentifier::CacheableIdentifier): (JSC::CacheableIdentifier::isUid const): (JSC::CacheableIdentifier::isCell const): (JSC::CacheableIdentifier::isSymbol const): (JSC::CacheableIdentifier::operator bool const): * runtime/CacheableIdentifierInlines.h: Added. (JSC::CacheableIdentifier::CacheableIdentifier): (JSC::CacheableIdentifier::cell const): (JSC::CacheableIdentifier::uid const): (JSC::CacheableIdentifier::isCacheableIdentifierCell): (JSC::CacheableIdentifier::isSymbolCell const): (JSC::CacheableIdentifier::isStringCell const): (JSC::CacheableIdentifier::setCellBits): (JSC::CacheableIdentifier::setUidBits): (JSC::CacheableIdentifier::visitAggregate const): (JSC::CacheableIdentifier::operator== const): (JSC::CacheableIdentifier::operator!= const): * runtime/ExceptionHelpers.cpp: (JSC::functionCallBase): * runtime/JSString.h: (JSC::JSString::getValueImpl const): * runtime/VM.cpp: (JSC::VM::ensureWatchpointSetForImpureProperty): (JSC::VM::addImpureProperty): (JSC::VM::registerWatchpointForImpureProperty): Deleted. * runtime/VM.h: Source/WebCore: * bindings/js/CommonVM.cpp: (WebCore::addImpureProperty): git-svn-id: https://svn.webkit.org/repository/webkit/trunk@254464 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-01-13 Mark Lam Replace uses of Box with a new CacheableIdentifier class. https://bugs.webkit.org/show_bug.cgi?id=205544 Reviewed by Saam Barati. The introduction of the use of Box was to get around having to ref/deref the underlying UniqedStringImpl in Identifiers from the compiler and GC threads. However, it proves to be difficult to control when these Boxs get destructed, and requires that we find all the places in the compier and GC threads where this can happen, and apply keep alive tactics there to defer destruction of the Box to the mutator thread. This patch fixes this by replacing uses of Box with CacheableIdentifier, which is effectively a tagged union of a JSCell* or a UniquedStringImpl*. The JSCell*, in this case, can be either a Symbol* or a JSString* that is backed by an atom string. The VM runtime ensures that we'll never try to cache an identifier from a JSCell that is not one of these. This CacheableIdentifier can be destructed from the compiler or GC thread. Since it doesn't hold a ref of the underlying UniquedStringImpl, it won't try to deref it on destruction. Instead, we'll need to visit CacheableIdentifiers during GC scans to keep the JSCell in it alive, and that JSCell will, in turn, keep the underlying UniquedStringImpl alive. This patch also does the following: 1. Add a visitAggregate() method to StructureStubInfo, PolymorphicAccess, and AccessCase to visit the CacheableIdentifier's JSCell identifier. This visitAggregate() is called from CodeBlock::stronglyVisitStrongReferences(). When we write barrier a CodeBlock, it guarantees that its visitAggregate() methods is called. However, it does not guarantee that its propagateTransitions() method will be called. Since the CacheableIdentifier's reference to a cell should be a strong reference, visiting it via a StructureStubInfo::visitAggregate() method is the right thing to do. See https://bugs.webkit.org/show_bug.cgi?id=205544#c7 for an example of why propagateTransitions() doesn't always do the job. StructureStubInfo::visitWeakReferences() is also inappropriate for this because it is only called after all marking is done. It is also not meant to keep cells alive but merely for clearing weak references to dead cells. 2. Also add to visitAggregate() for ModuleNamespaceData's m_identifier in GetByStatus::markIfCheap(). 3. Remove previously applied keep alive tactics to work around Box destruction. This also retores the allowance to destruct DFG::Plans on a compiler thread. 4. Added a JSString:getValueImpl() helper. 5. Added a write barrier in DFG and FTL JITFinalizer's finalizeCommon() to ensure that frozen values are scanned by the GC. During compilation, the frozen values were previously protected by the Plan. After finalization, they should be protected by the CodeBlock. Hence, we should barrier the CodeBlock since the last GC scan of the CodeBlock may have happened before the frozen values were registered with the CodeBlock. GC considerations: ================== The following also addresses Yusuke's concerns in https://bugs.webkit.org/show_bug.cgi?id=205544#c10. CacheableIdentifier is only stored as fields in 4 classes/structs: 1. AccessCase::m_identifier 2. GetByIdVariant::m_identifier 3. ModuleNamespaceData::m_identifier 4. StructureStubInfo::m_getByIdSelfIdentifier AccessCase::m_identifier ======================== While the access case is being created and added in tryCacheGetBy(), the CacheableIdentifier is still on the stack and protected from the GC. At the bottom of tryCacheGetBy(), StructureStubInfo::addAccessCase() is called to add the access case. StructureStubInfo::addAccessCase() will barrier the owner CodeBlock at its end, and CodeBlock::stronglyVisitStrongReferences() will visit the StructureStubInfo, which in turn visits the AccessCase. StructureStubInfo::visitAggregate() has been added for this purpose. GetByIdVariant::m_identifier ============================ GetByIdVariant is only stored in GetByStatus. Both GetByIdVariant and GetByStatus are only created and handled in the DFG/FTL compiler threads. While the compiler thread is working with them, they are safe from the GC because the GC won't collect objects until the compiler thread is at a SafePoint. At compiler SafePoints, any GetByStatus that needs to be persisted is stored in DFG::Plan::m_recordedStatuses. The Plan will visit the m_recordedStatuses in Plan::checkLivenessAndVisitChildren(). At the end of compilation, Plan::m_recordedStatuses is transferred over to the owner CodeBlock's DFG::CommonData in Plan::finalizeWithoutNotifyingCallback(). Plan::finalizeWithoutNotifyingCallback() will also barrier the owner CodeBlock at its end. Thereafter, CodeBlock::stronglyVisitStrongReferences() will visit the recordedStatuses. ModuleNamespaceData::m_identifier ================================= ModuleNamespaceData is only stored in a GetByStatus, and is therefore protected similarly as the GetByIdVariant::m_identifier case above. StructureStubInfo::m_getByIdSelfIdentifier ========================================== StructureStubInfo::initGetByIdSelf() is called from inside tryCacheGetBy(). StructureStubInfo::initGetByIdSelf() will barrier the owner CodeBlock. The CacheableIdentifier here is protected in the same way as the AccessCase::m_identifier case above. DesiredIdentifiers ================== The compiler thread may also stash a CacheableIdentifier's uid in its DesiredIdentifiers. Normally, the identifiers stashed in DesiredIdentifiers are from identifiers that the CodeBlock already knows abut and manages (e.g. from GetByIds). For uids from a cell-based CacheableIdentifier variable is passed to a GetByVal, we need kep the cell alive in order to keep the uid alive. This is achieved by freezing the cell with freezeStrong() in the op_get_by_val case in the DFG BytecodeParser. Reseting a StructureStubInfo while its IC code is still executing on the stack ============================================================================== The concern is that IC code may call slow path / getter functions that may in turn: 1. reset the IC, and 2. run the GC. This can be a problem if: 1. there is a scenario where we return from the slow path / getter function and run IC code that uses the cell / uid from the CacheableIdentifier. This is because the StructureStubInfo is what visits the that cell, which in turn its uid alive. Once the StructureStubInfo is reset, it will no longer be associated with any AccessCase or the m_getByIdSelfIdentifier. As such they will not be visited, and the CacheableIdentifier may be collected by the GC. In practice, the generated IC code never uses the cell / uid after it calls any slow path / getter function. I've verified this by auditing the code generation in InlineAccess::generateSelfInAccess() and PolymorphicAccess::regenerate(). Hence, there's no issue with using a collected cell / uid. 2. there is a scenario where a slow path / getter function makes use of the cell / uid from the CacheableIdentifier but does not protect it. The only 2 slow path functions: operationGetByValGeneric() operationGetByValOptimize() operationGetByValGeneric() does not use any CacheableIdentifier from the StructureStubInfo. operationGetByValOptimize() modifies the StructureStubInfo in tryCacheGetBy() under the protection of a GCSafeConcurrentJSLocker, and can reset the StructureStubInfo. However, it does not use any CacheableIdentifier after that. Hence, there's also no GC issue here. * CMakeLists.txt: * JavaScriptCore.xcodeproj/project.pbxproj: * Sources.txt: * bytecode/AccessCase.cpp: (JSC::AccessCase::AccessCase): (JSC::AccessCase::create): (JSC::AccessCase::fromStructureStubInfo): (JSC::AccessCase::commit): (JSC::AccessCase::canReplace const): (JSC::AccessCase::dump const): (JSC::AccessCase::visitAggregate const): (JSC::AccessCase::generateWithGuard): (JSC::AccessCase::generateImpl): * bytecode/AccessCase.h: (JSC::AccessCase::uid const): (JSC::AccessCase::identifier const): * bytecode/CodeBlock.cpp: (JSC::CodeBlock::propagateTransitions): (JSC::CodeBlock::stronglyVisitStrongReferences): * bytecode/GetByIdVariant.cpp: (JSC::GetByIdVariant::GetByIdVariant): (JSC::GetByIdVariant::attemptToMerge): (JSC::GetByIdVariant::visitAggregate): (JSC::GetByIdVariant::dumpInContext const): * bytecode/GetByIdVariant.h: (JSC::GetByIdVariant::identifier const): (JSC::GetByIdVariant::overlaps): * bytecode/GetByStatus.cpp: (JSC::GetByStatus::computeFromLLInt): (JSC::GetByStatus::computeFor): (JSC::GetByStatus::computeForStubInfoWithoutExitSiteFeedback): (JSC::GetByStatus::visitAggregate): (JSC::GetByStatus::singleIdentifier const): * bytecode/GetByStatus.h: * bytecode/GetterSetterAccessCase.cpp: (JSC::GetterSetterAccessCase::GetterSetterAccessCase): (JSC::GetterSetterAccessCase::create): * bytecode/GetterSetterAccessCase.h: * bytecode/InstanceOfAccessCase.cpp: (JSC::InstanceOfAccessCase::InstanceOfAccessCase): * bytecode/IntrinsicGetterAccessCase.cpp: (JSC::IntrinsicGetterAccessCase::IntrinsicGetterAccessCase): (JSC::IntrinsicGetterAccessCase::create): * bytecode/IntrinsicGetterAccessCase.h: * bytecode/ModuleNamespaceAccessCase.cpp: (JSC::ModuleNamespaceAccessCase::ModuleNamespaceAccessCase): (JSC::ModuleNamespaceAccessCase::create): * bytecode/ModuleNamespaceAccessCase.h: * bytecode/PolymorphicAccess.cpp: (JSC::PolymorphicAccess::visitAggregate): (JSC::PolymorphicAccess::regenerate): * bytecode/PolymorphicAccess.h: * bytecode/ProxyableAccessCase.cpp: (JSC::ProxyableAccessCase::ProxyableAccessCase): (JSC::ProxyableAccessCase::create): * bytecode/ProxyableAccessCase.h: * bytecode/RecordedStatuses.cpp: (JSC::RecordedStatuses::visitAggregate): * bytecode/RecordedStatuses.h: * bytecode/StructureStubInfo.cpp: (JSC::StructureStubInfo::initGetByIdSelf): (JSC::StructureStubInfo::addAccessCase): (JSC::StructureStubInfo::visitAggregate): * bytecode/StructureStubInfo.h: (JSC::StructureStubInfo::getByIdSelfIdentifier): * dfg/DFGByteCodeParser.cpp: (JSC::DFG::ByteCodeParser::parseGetById): (JSC::DFG::ByteCodeParser::parseBlock): * dfg/DFGDesiredIdentifiers.cpp: (JSC::DFG::DesiredIdentifiers::ensure): (JSC::DFG::DesiredIdentifiers::at const): (JSC::DFG::DesiredIdentifiers::reallyAdd): (JSC::DFG::DesiredIdentifiers::processCodeBlockIdentifiersIfNeeded): Deleted. * dfg/DFGDesiredIdentifiers.h: * dfg/DFGJITFinalizer.cpp: (JSC::DFG::JITFinalizer::finalizeCommon): * dfg/DFGPlan.cpp: (JSC::DFG::Plan::~Plan): (JSC::DFG::Plan::checkLivenessAndVisitChildren): (JSC::DFG::Plan::cancel): * dfg/DFGPlan.h: (JSC::DFG::Plan::keepAliveIdentifier): Deleted. * dfg/DFGWorklist.cpp: (JSC::DFG::Worklist::removeAllReadyPlansForVM): (JSC::DFG::Worklist::removeDeadPlans): (JSC::DFG::Worklist::removeNonCompilingPlansForVM): (JSC::DFG::Worklist::deleteCancelledPlansForVM): Deleted. * dfg/DFGWorklist.h: * ftl/FTLJITFinalizer.cpp: (JSC::FTL::JITFinalizer::finalizeCommon): * jit/JITOperations.cpp: * jit/Repatch.cpp: (JSC::tryCacheGetBy): (JSC::repatchGetBy): (JSC::tryCacheArrayGetByVal): (JSC::tryCacheInstanceOf): * jit/Repatch.h: * runtime/CacheableIdentifier.cpp: Added. (JSC::CacheableIdentifier::dump const): * runtime/CacheableIdentifier.h: Added. (JSC::CacheableIdentifier::CacheableIdentifier): (JSC::CacheableIdentifier::isUid const): (JSC::CacheableIdentifier::isCell const): (JSC::CacheableIdentifier::isSymbol const): (JSC::CacheableIdentifier::operator bool const): * runtime/CacheableIdentifierInlines.h: Added. (JSC::CacheableIdentifier::CacheableIdentifier): (JSC::CacheableIdentifier::cell const): (JSC::CacheableIdentifier::uid const): (JSC::CacheableIdentifier::isCacheableIdentifierCell): (JSC::CacheableIdentifier::isSymbolCell const): (JSC::CacheableIdentifier::isStringCell const): (JSC::CacheableIdentifier::setCellBits): (JSC::CacheableIdentifier::setUidBits): (JSC::CacheableIdentifier::visitAggregate const): (JSC::CacheableIdentifier::operator== const): (JSC::CacheableIdentifier::operator!= const): * runtime/ExceptionHelpers.cpp: (JSC::functionCallBase): * runtime/JSString.h: (JSC::JSString::getValueImpl const): * runtime/VM.cpp: (JSC::VM::ensureWatchpointSetForImpureProperty): (JSC::VM::addImpureProperty): (JSC::VM::registerWatchpointForImpureProperty): Deleted. * runtime/VM.h: 2020-01-15 Alan Coon Cherry-pick r254393. rdar://problem/58553158 [JSC] Flush old tables in End phase https://bugs.webkit.org/show_bug.cgi?id=206120 Reviewed by Mark Lam. JSTests: * stress/create-many-realms.js: Added. (foo): Source/JavaScriptCore: stopThePeriphery is stopping compiler threads and main thread (mutator), which means making m_worldIsStopped = true. It is not for stopping all heap threads including a concurrent marker. The concurrent collector can work while executing stopThePeriphery. This means that concurrent collectors can access to the old StructureIDTable while it is destroyed in stopThePeriphery. Destroying old StructureIDTable in GC End phase, this is appropriate phase that we can ensure no other threads (accessing to heap) are working including concurrent markers, mutator, and compiler threads. * heap/Heap.cpp: (JSC::Heap::runEndPhase): (JSC::Heap::stopThePeriphery): git-svn-id: https://svn.webkit.org/repository/webkit/trunk@254393 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-01-10 Yusuke Suzuki [JSC] Flush old tables in End phase https://bugs.webkit.org/show_bug.cgi?id=206120 Reviewed by Mark Lam. stopThePeriphery is stopping compiler threads and main thread (mutator), which means making m_worldIsStopped = true. It is not for stopping all heap threads including a concurrent marker. The concurrent collector can work while executing stopThePeriphery. This means that concurrent collectors can access to the old StructureIDTable while it is destroyed in stopThePeriphery. Destroying old StructureIDTable in GC End phase, this is appropriate phase that we can ensure no other threads (accessing to heap) are working including concurrent markers, mutator, and compiler threads. * heap/Heap.cpp: (JSC::Heap::runEndPhase): (JSC::Heap::stopThePeriphery): 2020-01-14 Alan Coon Cherry-pick r254244. rdar://problem/58553148 Instruction.h: Multiplication result converted to larger type https://bugs.webkit.org/show_bug.cgi?id=205945 Reviewed by Mark Lam. * bytecode/Instruction.h: (JSC::BaseInstruction::size const): Changed the types to size_t so that the computation is computed accordingly. git-svn-id: https://svn.webkit.org/repository/webkit/trunk@254244 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-01-08 Michael Saboff Instruction.h: Multiplication result converted to larger type https://bugs.webkit.org/show_bug.cgi?id=205945 Reviewed by Mark Lam. * bytecode/Instruction.h: (JSC::BaseInstruction::size const): Changed the types to size_t so that the computation is computed accordingly. 2020-01-14 Alan Coon Cherry-pick r254218. rdar://problem/58553153 JSArrayBufferView.h: Multiplication result converted to larger type https://bugs.webkit.org/show_bug.cgi?id=205943 Reviewed by Saam Barati. Added cast to size_t to make the whole calculation size_t. * runtime/JSArrayBufferView.h: (JSC::JSArrayBufferView::sizeOf): git-svn-id: https://svn.webkit.org/repository/webkit/trunk@254218 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-01-08 Michael Saboff JSArrayBufferView.h: Multiplication result converted to larger type https://bugs.webkit.org/show_bug.cgi?id=205943 Reviewed by Saam Barati. Added cast to size_t to make the whole calculation size_t. * runtime/JSArrayBufferView.h: (JSC::JSArrayBufferView::sizeOf): 2020-01-14 Alan Coon Cherry-pick r254188. rdar://problem/58553146 AI rule for ValueMod/ValueDiv produce constants with the wrong format when the result can be an int32 https://bugs.webkit.org/show_bug.cgi?id=205906 Reviewed by Yusuke Suzuki. JSTests: * stress/ai-value-div-should-result-in-constant-int-where-possible.js: Added. (foo.bar.f): (foo.): (foo): * stress/ai-value-mod-should-result-in-constant-int-where-possible.js: Added. (foo.bar.f): (foo.): (foo): Source/JavaScriptCore: The runtime code for ValueMod and ValueDiv produces an int32 when the result is of int32 value. However, the AI was saying the result is in double format. This patch fixes AI to produce a JSValue in the right format. * dfg/DFGAbstractInterpreterInlines.h: (JSC::DFG::AbstractInterpreter::handleConstantDivOp): git-svn-id: https://svn.webkit.org/repository/webkit/trunk@254188 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-01-07 Saam Barati AI rule for ValueMod/ValueDiv produce constants with the wrong format when the result can be an int32 https://bugs.webkit.org/show_bug.cgi?id=205906 Reviewed by Yusuke Suzuki. The runtime code for ValueMod and ValueDiv produces an int32 when the result is of int32 value. However, the AI was saying the result is in double format. This patch fixes AI to produce a JSValue in the right format. * dfg/DFGAbstractInterpreterInlines.h: (JSC::DFG::AbstractInterpreter::handleConstantDivOp): 2020-01-14 Alan Coon Cherry-pick r254152. rdar://problem/58552854 [JSC] Remove vm accessor in JSVirtualMachine to reduce binary size https://bugs.webkit.org/show_bug.cgi?id=205880 Reviewed by Mark Lam. Objective-C has reflection mechanism. This means that fields, methods, and their types need to hold its string representations in binary even if we are using release build. While typical Objective-C class does not have large size of type names, C++ struct / class has very large one, and putting them in Objective-C method names, parameter types, or fields makes binary size very large. By analyzing JavaScriptCore binary, I found that Objective-C method type symbols are taking 200~KB binary size. (Section __objc_methtype: 235081 (addr 0x105e9a3 offset 17164707)). And it is due to JSC::VM type included in `[JSVirtualMachine vm]` accessor. This patch removes this accessor and gets 200KB binary size reduction. * API/JSScript.mm: (-[JSScript readCache]): (-[JSScript sourceCode]): (-[JSScript jsSourceCode]): (-[JSScript writeCache:]): * API/JSVirtualMachine.mm: (-[JSVirtualMachine JSContextGroupRef]): (-[JSVirtualMachine isWebThreadAware]): (-[JSVirtualMachine vm]): Deleted. * API/JSVirtualMachineInternal.h: git-svn-id: https://svn.webkit.org/repository/webkit/trunk@254152 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-01-07 Yusuke Suzuki [JSC] Remove vm accessor in JSVirtualMachine to reduce binary size https://bugs.webkit.org/show_bug.cgi?id=205880 Reviewed by Mark Lam. Objective-C has reflection mechanism. This means that fields, methods, and their types need to hold its string representations in binary even if we are using release build. While typical Objective-C class does not have large size of type names, C++ struct / class has very large one, and putting them in Objective-C method names, parameter types, or fields makes binary size very large. By analyzing JavaScriptCore binary, I found that Objective-C method type symbols are taking 200~KB binary size. (Section __objc_methtype: 235081 (addr 0x105e9a3 offset 17164707)). And it is due to JSC::VM type included in `[JSVirtualMachine vm]` accessor. This patch removes this accessor and gets 200KB binary size reduction. * API/JSScript.mm: (-[JSScript readCache]): (-[JSScript sourceCode]): (-[JSScript jsSourceCode]): (-[JSScript writeCache:]): * API/JSVirtualMachine.mm: (-[JSVirtualMachine JSContextGroupRef]): (-[JSVirtualMachine isWebThreadAware]): (-[JSVirtualMachine vm]): Deleted. * API/JSVirtualMachineInternal.h: 2020-01-13 Alan Coon Cherry-pick r254349. rdar://problem/58529720 ObjectAllocationSinkingPhase doesn't model pointers to allocations in control flow properly https://bugs.webkit.org/show_bug.cgi?id=204738 Reviewed by Yusuke Suzuki. JSTests: * stress/allocation-sinking-must-model-allocation-pointers-properly-2.js: Added. (assert): (v9): * stress/allocation-sinking-must-model-allocation-pointers-properly-3.js: Added. (assert): (v9): * stress/allocation-sinking-must-model-allocation-pointers-properly-4.js: Added. (bool): (effects): (escape): (bar): * stress/allocation-sinking-must-model-allocation-pointers-properly.js: Added. (alwaysFalse): (sometimesZero): (assert): (v9): Source/JavaScriptCore: Allocation sinking phase conducts a points to analysis. It uses this information for programs like: ``` 1: NewObject 2: NewObject 3: PutByOffset(@2, @1, "x") 4: GetByOffset(@2, "x") ``` It solves the points to problem knowing @4 points to @1. It tracks this data in the LocalHeap data structure. This is used to track the heap across blocks, and it includes a merge function to handle control flow merges. However, this merge function would not always merge the pointer sets together. It sometimes would merge them together, since it had a fast path check inside merge, which would just copy the contents of the block to be merged with itself if it were this block's first time merging. This fast path happened to hide the bug in general case merge code. If we didn't take this fast path, we would just never transfer pointer sets from predecessor to successor. This could lead to all kinds of issues, including using the incorrect phantom node in IR instead of its materialized version. It could also lead to the phase not sinking objects it is capable of sinking. This patch makes it so that we merge together the pointer sets. We always add new pointers to the set. So in pointer A->B, if the set has yet to see A, we add it. If the set already contains pointer A->B, and we encounter a new pointer A->C, or if we encounter a merge without any A->* pointer, we mark the A pointer as top, marking it A->TOP. We do this to ensure that we fixpoint. We're guaranteed that m_pointers is monotonically increasing (module liveness pruning, which is a constant). And once something is TOP, it never becomes anything else. (Instead of marking a pointer top, we used to just remove it from the set, but this has issues, as it could lead to us ping-ponging in our fixpoint analysis, add, remove, add, remove, etc.) So the merge rules are: {A->B} merge {A->B} => {A->B} {A->B} merge {A->C} => {A->TOP} {A->B} merge {A->TOP} => {A->TOP} {A->B} merge {} => {A->TOP} Thanks to Samuel Groß of Google Project Zero for identifying this bug. * dfg/DFGObjectAllocationSinkingPhase.cpp: git-svn-id: https://svn.webkit.org/repository/webkit/trunk@254349 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-01-10 Saam Barati ObjectAllocationSinkingPhase doesn't model pointers to allocations in control flow properly https://bugs.webkit.org/show_bug.cgi?id=204738 Reviewed by Yusuke Suzuki. Allocation sinking phase conducts a points to analysis. It uses this information for programs like: ``` 1: NewObject 2: NewObject 3: PutByOffset(@2, @1, "x") 4: GetByOffset(@2, "x") ``` It solves the points to problem knowing @4 points to @1. It tracks this data in the LocalHeap data structure. This is used to track the heap across blocks, and it includes a merge function to handle control flow merges. However, this merge function would not always merge the pointer sets together. It sometimes would merge them together, since it had a fast path check inside merge, which would just copy the contents of the block to be merged with itself if it were this block's first time merging. This fast path happened to hide the bug in general case merge code. If we didn't take this fast path, we would just never transfer pointer sets from predecessor to successor. This could lead to all kinds of issues, including using the incorrect phantom node in IR instead of its materialized version. It could also lead to the phase not sinking objects it is capable of sinking. This patch makes it so that we merge together the pointer sets. We always add new pointers to the set. So in pointer A->B, if the set has yet to see A, we add it. If the set already contains pointer A->B, and we encounter a new pointer A->C, or if we encounter a merge without any A->* pointer, we mark the A pointer as top, marking it A->TOP. We do this to ensure that we fixpoint. We're guaranteed that m_pointers is monotonically increasing (module liveness pruning, which is a constant). And once something is TOP, it never becomes anything else. (Instead of marking a pointer top, we used to just remove it from the set, but this has issues, as it could lead to us ping-ponging in our fixpoint analysis, add, remove, add, remove, etc.) So the merge rules are: {A->B} merge {A->B} => {A->B} {A->B} merge {A->C} => {A->TOP} {A->B} merge {A->TOP} => {A->TOP} {A->B} merge {} => {A->TOP} Thanks to Samuel Groß of Google Project Zero for identifying this bug. * dfg/DFGObjectAllocationSinkingPhase.cpp: 2020-01-07 Alan Coon Cherry-pick r254143. rdar://problem/58310178 Unreviewed non-arm64e build fix. * dfg/DFGOSRExitCompilerCommon.cpp: (JSC::DFG::reifyInlinedCallFrames): git-svn-id: https://svn.webkit.org/repository/webkit/trunk@254143 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-01-07 Keith Miller Unreviewed non-arm64e build fix. * dfg/DFGOSRExitCompilerCommon.cpp: (JSC::DFG::reifyInlinedCallFrames): 2020-01-07 Alan Coon Cherry-pick r254142. rdar://problem/58310178 Bytecode checkpoint fixes for arm64(e) https://bugs.webkit.org/show_bug.cgi?id=205871 Reviewed by Michael Saboff. The original bytecode checkpoint patch had a couple of bugs on arm64(e). For arm64 generally, when osr exiting to an inline varargs frame we didn't set the return value of callee before moving the call frame register into a0 for the slow path call. This meant we clobber the return value on arm64 as a0 == r0. On arm64e the osr exit compiler set the tag for the return pc for an inline frame to JSEntryTag but the code expected NoTag. Additionally, in the stack unwinder, we were using the JSEntryTag but we should have been stripping the tag from the stack value. * dfg/DFGOSRExitCompilerCommon.cpp: (JSC::DFG::callerReturnPC): (JSC::DFG::reifyInlinedCallFrames): * dfg/DFGOSRExitCompilerCommon.h: * interpreter/Interpreter.cpp: (JSC::UnwindFunctor::operator() const): * llint/LowLevelInterpreter.asm: git-svn-id: https://svn.webkit.org/repository/webkit/trunk@254142 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-01-07 Keith Miller Bytecode checkpoint fixes for arm64(e) https://bugs.webkit.org/show_bug.cgi?id=205871 Reviewed by Michael Saboff. The original bytecode checkpoint patch had a couple of bugs on arm64(e). For arm64 generally, when osr exiting to an inline varargs frame we didn't set the return value of callee before moving the call frame register into a0 for the slow path call. This meant we clobber the return value on arm64 as a0 == r0. On arm64e the osr exit compiler set the tag for the return pc for an inline frame to JSEntryTag but the code expected NoTag. Additionally, in the stack unwinder, we were using the JSEntryTag but we should have been stripping the tag from the stack value. * dfg/DFGOSRExitCompilerCommon.cpp: (JSC::DFG::callerReturnPC): (JSC::DFG::reifyInlinedCallFrames): * dfg/DFGOSRExitCompilerCommon.h: * interpreter/Interpreter.cpp: (JSC::UnwindFunctor::operator() const): * llint/LowLevelInterpreter.asm: 2020-01-02 Yusuke Suzuki [JSC] MarkedBlock::Handle and BlockDirectory should be shrunk https://bugs.webkit.org/show_bug.cgi?id=205712 Reviewed by Mark Lam. This patch shrinks MarkedBlock::Handle and BlockDirectory by leveraging the fact that Vector's size and capacity is unsigned. In these data structures, we use `size_t` to hold a index, but this can be converted to unsigned since we guarantee that this never exceeds unsigned since these numbers are derived from Vector's size / capacity, or index inside MarkedBlock (which is up to 64KB in some architectures). MarkedBlock::Handle is allocated per MarkedBlock, and in Gmail, it takes 1MB. We can save some bytes just using `unsigned`. In addition, this patch removes `m_prev` and `m_next` fields in MarkedBlock::Handle since it is never used. * heap/AtomIndices.h: * heap/BlockDirectory.cpp: (JSC::BlockDirectory::findBlockForAllocation): (JSC::BlockDirectory::addBlock): * heap/IsoCellSet.cpp: (JSC::IsoCellSet::addSlow): (JSC::IsoCellSet::didResizeBits): (JSC::IsoCellSet::didRemoveBlock): * heap/IsoCellSet.h: * heap/IsoCellSetInlines.h: (JSC::IsoCellSet::forEachMarkedCell): (JSC::IsoCellSet::forEachMarkedCellInParallel): (JSC::IsoCellSet::forEachLiveCell): * heap/IsoSubspace.cpp: (JSC::IsoSubspace::didResizeBits): (JSC::IsoSubspace::didRemoveBlock): * heap/IsoSubspace.h: * heap/LocalAllocator.h: * heap/MarkedBlock.cpp: (JSC::MarkedBlock::Handle::didAddToDirectory): (JSC::MarkedBlock::Handle::didRemoveFromDirectory): * heap/MarkedBlock.h: (JSC::MarkedBlock::Handle::index const): * heap/Subspace.cpp: (JSC::Subspace::didResizeBits): (JSC::Subspace::didRemoveBlock): * heap/Subspace.h: 2020-01-03 Simon Fraser Add some shared schemes to the WebKit.xcworkspace https://bugs.webkit.org/show_bug.cgi?id=205698 Reviewed by Tim Horton. Make WebKit.xcworkspace show the following schemes by default: All Source All Tools WTF JavaScriptCore WebCore WebKit WebKitLegacy DumpRenderTree WebKitTestRunner TestWebKitAPI MiniBrowser MobileMiniBrowser. Also remove the MobileMiniBrowserUITests scheme. * JavaScriptCore.xcodeproj/xcshareddata/xcschemes/JavaScriptCore.xcscheme: Copied from Tools/MobileMiniBrowser/MobileMiniBrowser.xcodeproj/xcshareddata/xcschemes/MobileMiniBrowserUITests.xcscheme. 2020-01-03 Saam Barati B3::ReduceLoopStrength should not do range based iteration on a vector it's mutating https://bugs.webkit.org/show_bug.cgi?id=205703 Reviewed by Mark Lam. B3::ReduceLoopStrength had code that did: ``` for (BasicBlock* pred : loopPostfooter->predecessors()) loopPostfooter->removePredecessor(pred); ``` This is wrong, since it's doing a range based iteration over the vector it is mutating. The fix is to just do: ``` while (loopPostfooter->predecessors().size()) loopPostfooter->removePredecessor(loopPostfooter->predecessors()[0]); ``` * b3/B3ReduceLoopStrength.cpp: (JSC::B3::ReduceLoopStrength::reduceByteCopyLoopsToMemcpy): 2020-01-03 Saam Barati AI rule for PutById can only observe transitions when it watches the condition https://bugs.webkit.org/show_bug.cgi?id=205697 Reviewed by Yusuke Suzuki. There was a bug in AI where we were capturing a PutByIdStatus and emitting a structure transition in AI state based on the variants inside this PutByIdStatus. This, in principal, is a valid static analysis to perform. However, we can only do this if we ensure that the snapshot we have in the PutByIdStatus holds at runtime. We can do this by watching the property conditions for the various variants. AI forgot to watch these conditions. This patch fixes that. In practice, this also means we need to be slightly more strict about stating to AI when we transition since some object property conditions aren't watchable, and need to be verified at runtime via structure checks. This is ok in practice, since we'll emit the code to do that inside constant folding (constant folding was already doing this), which will continue to report the precise transition in the abstract state. * dfg/DFGAbstractInterpreter.h: * dfg/DFGAbstractInterpreterInlines.h: (JSC::DFG::AbstractInterpreter::executeEffects): * dfg/DFGConstantFoldingPhase.cpp: (JSC::DFG::ConstantFoldingPhase::foldConstants): 2020-01-02 Yusuke Suzuki and Simon Fraser Experiment: create lots of different malloc zones for easier accounting of memory use https://bugs.webkit.org/show_bug.cgi?id=186422 Reviewed by Saam Barati. * JavaScriptCore.xcodeproj/project.pbxproj: * Sources.txt: * assembler/AssemblerBuffer.cpp: Copied from Source/JavaScriptCore/bytecode/InstructionStream.cpp. * assembler/AssemblerBuffer.h: (JSC::AssemblerData::AssemblerData): (JSC::AssemblerData::operator=): (JSC::AssemblerData::~AssemblerData): (JSC::AssemblerData::grow): * bytecode/AccessCase.cpp: * bytecode/AccessCase.h: * bytecode/BytecodeBasicBlock.cpp: * bytecode/BytecodeBasicBlock.h: * bytecode/CodeBlock.cpp: * bytecode/CodeBlock.h: * bytecode/InstructionStream.cpp: * bytecode/InstructionStream.h: * bytecode/PolymorphicAccess.cpp: * bytecode/PolymorphicAccess.h: * bytecode/UnlinkedMetadataTable.cpp: (JSC::UnlinkedMetadataTable::finalize): * bytecode/UnlinkedMetadataTable.h: * bytecode/UnlinkedMetadataTableInlines.h: (JSC::UnlinkedMetadataTable::UnlinkedMetadataTable): (JSC::UnlinkedMetadataTable::~UnlinkedMetadataTable): (JSC::UnlinkedMetadataTable::link): (JSC::UnlinkedMetadataTable::unlink): * bytecode/ValueProfile.h: (JSC::ValueProfileAndVirtualRegisterBuffer::ValueProfileAndVirtualRegisterBuffer): * bytecode/Watchpoint.cpp: * bytecode/Watchpoint.h: * dfg/DFGBasicBlock.cpp: * dfg/DFGBasicBlock.h: * dfg/DFGNode.cpp: * dfg/DFGNode.h: * dfg/DFGSpeculativeJIT.cpp: * dfg/DFGSpeculativeJIT.h: * heap/BlockDirectory.cpp: * heap/BlockDirectory.h: * heap/FastMallocAlignedMemoryAllocator.cpp: (JSC::FastMallocAlignedMemoryAllocator::FastMallocAlignedMemoryAllocator): (JSC::FastMallocAlignedMemoryAllocator::tryAllocateAlignedMemory): (JSC::FastMallocAlignedMemoryAllocator::freeAlignedMemory): (JSC::FastMallocAlignedMemoryAllocator::tryAllocateMemory): (JSC::FastMallocAlignedMemoryAllocator::freeMemory): (JSC::FastMallocAlignedMemoryAllocator::tryReallocateMemory): * heap/FastMallocAlignedMemoryAllocator.h: * heap/GCSegmentedArray.cpp: Copied from Source/JavaScriptCore/parser/SourceProviderCache.cpp. * heap/GCSegmentedArray.h: * heap/GCSegmentedArrayInlines.h: (JSC::GCArraySegment::create): (JSC::GCArraySegment::destroy): * heap/GigacageAlignedMemoryAllocator.cpp: (JSC::GigacageAlignedMemoryAllocator::GigacageAlignedMemoryAllocator): (JSC::GigacageAlignedMemoryAllocator::tryAllocateAlignedMemory): (JSC::GigacageAlignedMemoryAllocator::freeAlignedMemory): (JSC::GigacageAlignedMemoryAllocator::tryAllocateMemory): (JSC::GigacageAlignedMemoryAllocator::freeMemory): (JSC::GigacageAlignedMemoryAllocator::tryReallocateMemory): * heap/GigacageAlignedMemoryAllocator.h: * heap/IsoAlignedMemoryAllocator.cpp: (JSC::IsoAlignedMemoryAllocator::IsoAlignedMemoryAllocator): (JSC::IsoAlignedMemoryAllocator::~IsoAlignedMemoryAllocator): (JSC::IsoAlignedMemoryAllocator::tryAllocateAlignedMemory): (JSC::IsoAlignedMemoryAllocator::freeAlignedMemory): (JSC::IsoAlignedMemoryAllocator::tryAllocateMemory): (JSC::IsoAlignedMemoryAllocator::freeMemory): * heap/IsoAlignedMemoryAllocator.h: * heap/IsoSubspace.cpp: (JSC::IsoSubspace::IsoSubspace): * heap/MarkedBlock.cpp: * heap/MarkedBlock.h: * heap/WeakBlock.cpp: (JSC::WeakBlock::create): (JSC::WeakBlock::destroy): * heap/WeakBlock.h: * jit/JITCode.cpp: * jit/JITCode.h: * jit/RegisterAtOffsetList.cpp: * jit/RegisterAtOffsetList.h: * parser/Nodes.cpp: * parser/Nodes.h: * parser/ParserArena.cpp: (JSC::ParserArena::deallocateObjects): (JSC::ParserArena::allocateFreeablePool): * parser/ParserArena.h: * parser/SourceProvider.cpp: * parser/SourceProvider.h: * parser/SourceProviderCache.cpp: * parser/SourceProviderCache.h: * parser/SourceProviderCacheItem.h: (JSC::SourceProviderCacheItem::create): * runtime/CachePayload.cpp: (JSC::CachePayload::makeMallocPayload): * runtime/CachePayload.h: * runtime/CachedBytecode.h: (JSC::CachedBytecode::create): * runtime/CachedTypes.cpp: (JSC::Encoder::release): (JSC::Encoder::Page::Page): (JSC::CachedVector::encode): (JSC::CachedVector::decode const): (JSC::CachedInstructionStream::decode const): * runtime/PropertyMapHashTable.h: (JSC::PropertyTable::rehash): * runtime/PropertyTable.cpp: (JSC::PropertyTable::PropertyTable): (JSC::PropertyTable::~PropertyTable): * runtime/SymbolTable.cpp: * runtime/SymbolTable.h: * runtime/VM.cpp: (JSC::VM::~VM): * runtime/VM.h: (JSC::ScratchBuffer::create): (JSC::VM::exceptionFuzzingBuffer): * wasm/WasmInstance.cpp: (JSC::Wasm::Instance::Instance): * wasm/WasmInstance.h: * wasm/WasmTable.cpp: (JSC::Wasm::Table::Table): (JSC::Wasm::FuncRefTable::FuncRefTable): * wasm/WasmTable.h: 2020-01-02 Yusuke Suzuki REGRESSION (r253867): Six test262 tests broken https://bugs.webkit.org/show_bug.cgi?id=205583 Reviewed by Mark Lam. If a function has empty name, a bound function should have "bound " name. But Intl prototypes' bound functions are exceptions: these JSBoundFunctions have empty name. In this patch, we pass `nullptr` for the JSBoundFunction::create's nameMayBeNull parameter of Intl prototypes' bound functions, to generate empty string name for these bound functions instead of "bound "[1]. This fixes test262 failures. [1]: https://tc39.es/ecma402/#sec-collator-compare-functions * runtime/IntlCollatorPrototype.cpp: (JSC::IntlCollatorPrototypeGetterCompare): * runtime/IntlDateTimeFormatPrototype.cpp: (JSC::IntlDateTimeFormatPrototypeGetterFormat): * runtime/IntlNumberFormatPrototype.cpp: (JSC::IntlNumberFormatPrototypeGetterFormat): * runtime/JSBoundFunction.cpp: (JSC::JSBoundFunction::create): (JSC::JSBoundFunction::JSBoundFunction): (JSC::JSBoundFunction::visitChildren): * runtime/JSBoundFunction.h: * runtime/JSFunction.cpp: (JSC::JSFunction::reifyLazyBoundNameIfNeeded): * runtime/SmallStrings.cpp: (JSC::SmallStrings::initializeCommonStrings): * runtime/SmallStrings.h: (JSC::SmallStrings::boundPrefixString const): 2020-01-02 Sam Weinig Simplify StringBuilder API/align with makeString by removing appendFixed* functions and using FormatNumber struct instead https://bugs.webkit.org/show_bug.cgi?id=205671 Reviewed by Alex Christensen. * API/tests/ExecutionTimeLimitTest.cpp: (testExecutionTimeLimit): * runtime/Options.cpp: (JSC::OptionReader::Option::dump const): Replace all uses of builder.appendFixedPrecisionNumber(...) with builder.append(FormattedNumber::fixedPrecision(...)). 2020-01-01 Mark Lam Declare some classes as final. https://bugs.webkit.org/show_bug.cgi?id=205670 Reviewed by Sam Weinig. There are a few "Status" classes, all of whom have static computeFor() methods. All of these classes do not have derived classes, and are independent of each others in terms of inheritance relationships. By explicitly declaring them as final, we can make it clear that a call to any unqualified computeFor() methods within one of these classes must be from the self class, and that external calls to any given computeFor() method qualified with a class name is defined in that class (and is not inherited from another class). This detail may already be known to folks who are familiar with these classes. Declaring them as final helps surface this independence for readers of the code who is not already in the know. * bytecode/CallLinkStatus.h: * bytecode/ComplexGetStatus.h: * bytecode/GetByStatus.h: * bytecode/InByIdStatus.h: * bytecode/InstanceOfStatus.h: * bytecode/PutByIdStatus.h: 2019-12-22 Jeff Miller Update user-visible copyright strings to include 2020 https://bugs.webkit.org/show_bug.cgi?id=205552 Reviewed by Darin Adler. * Info.plist: 2019-12-20 Darin Adler Tidy a bit of StringBuilder usage https://bugs.webkit.org/show_bug.cgi?id=205509 Reviewed by Sam Weinig. * dfg/DFGStrengthReductionPhase.cpp: (JSC::DFG::StrengthReductionPhase::handleNode): Remove unneeded check that duplicates range checking that StringBuilder::appendSubstring does. 2019-12-30 Yusuke Suzuki Unreviewed, build fix after r253904 https://bugs.webkit.org/show_bug.cgi?id=205553 * bytecompiler/BytecodeGeneratorBaseInlines.h: (JSC::BytecodeGeneratorBase::alignWideOpcode16): (JSC::BytecodeGeneratorBase::alignWideOpcode32): 2019-12-30 Carlos Alberto Lopez Perez REGRESSION(r253896): [GTK][WPE] Broke the build with GCC-7 https://bugs.webkit.org/show_bug.cgi?id=205649 Reviewed by Mark Lam. Add WTF_INTERNAL macro to explicitly adjust the symbol visibility. * llint/LLIntSlowPaths.h: 2019-12-29 Yusuke Suzuki [JSC] Remove WTF::loadLoadFence from JSFunction::rareData() https://bugs.webkit.org/show_bug.cgi?id=205625 Reviewed by Mark Lam. WTF::loadLoadFence() is not necessary when loading FunctionRareData from JSFunction since we ensured that stored FunctionRareData is already baked by emitting WTF::storeStoreFence(). * runtime/JSFunction.h: (JSC::JSFunction::rareData const): (JSC::JSFunction::rareData): Deleted. * runtime/JSFunctionInlines.h: (JSC::JSFunction::hasReifiedLength const): (JSC::JSFunction::hasReifiedName const): (JSC::JSFunction::areNameAndLengthOriginal): (JSC::JSFunction::ensureRareDataAndAllocationProfile): 2019-12-28 Yusuke Suzuki Unreviewed, rename `.executable` to `.isExecutable` https://bugs.webkit.org/show_bug.cgi?id=205554 * llint/LowLevelInterpreter.asm: * llint/LowLevelInterpreter32_64.asm: * llint/LowLevelInterpreter64.asm: 2019-12-28 Yusuke Suzuki [JSC] JSFunction's m_executable / m_rareData should be merged https://bugs.webkit.org/show_bug.cgi?id=205554 Reviewed by Mark Lam. This patch merges JSFunction::m_executable and JSFunction::m_rareData fields into one JSFunction::m_executableOrRareData field. JSFunction is one of the most frequently allocated objects (e.g. it is common that anonymous JSFunction expression is used as a scope). If we can save sizeof(JSFunction), we can get great savings in memory usage. JSFunction::m_scope field is touched every time we execute this function. (op_get_scope, or obtaining JSGlobalObject for host functions). On the other hand, m_executable field can be skipped if JSFunction call is cached by CallLinkInfo. So compared to JSFunction::m_scope, this field is less frequently touched. So, we merge m_executable and m_rareData fields into one, m_executableOrRareData. When it holds ExecutableBase*, we do nothing. But when we create FunctionRareData, we put ExecutableBase in FunctionRareData and store FunctionRareData to JSFunction::m_executableOrRareData field with `0x1` flag. This patch reduces sizeof(JSFunction) from 48 to 32. * dfg/DFGSpeculativeJIT.cpp: (JSC::DFG::SpeculativeJIT::compileNewFunctionCommon): (JSC::DFG::SpeculativeJIT::compileGetExecutable): (JSC::DFG::SpeculativeJIT::compileCreateThis): (JSC::DFG::SpeculativeJIT::compileCreatePromise): (JSC::DFG::SpeculativeJIT::compileCreateInternalFieldObject): * ftl/FTLAbstractHeapRepository.h: * ftl/FTLLowerDFGToB3.cpp: (JSC::FTL::DFG::LowerDFGToB3::compileGetExecutable): (JSC::FTL::DFG::LowerDFGToB3::compileNewFunction): (JSC::FTL::DFG::LowerDFGToB3::compileCreateThis): (JSC::FTL::DFG::LowerDFGToB3::compileCreatePromise): (JSC::FTL::DFG::LowerDFGToB3::compileCreateInternalFieldObject): * jit/JITOpcodes.cpp: (JSC::JIT::emit_op_create_this): * jit/JITOpcodes32_64.cpp: (JSC::JIT::emit_op_create_this): * jit/Repatch.cpp: (JSC::linkPolymorphicCall): * jit/ThunkGenerators.cpp: (JSC::virtualThunkFor): (JSC::nativeForGenerator): (JSC::boundFunctionCallGenerator): * llint/LowLevelInterpreter.asm: * llint/LowLevelInterpreter32_64.asm: * llint/LowLevelInterpreter64.asm: * runtime/FunctionRareData.cpp: (JSC::FunctionRareData::create): (JSC::FunctionRareData::visitChildren): (JSC::FunctionRareData::FunctionRareData): * runtime/FunctionRareData.h: * runtime/JSBoundFunction.cpp: (JSC::JSBoundFunction::create): (JSC::JSBoundFunction::JSBoundFunction): * runtime/JSBoundFunction.h: * runtime/JSCustomGetterSetterFunction.cpp: (JSC::JSCustomGetterSetterFunction::JSCustomGetterSetterFunction): (JSC::JSCustomGetterSetterFunction::create): * runtime/JSCustomGetterSetterFunction.h: * runtime/JSFunction.cpp: (JSC::JSFunction::create): (JSC::JSFunction::createFunctionThatMasqueradesAsUndefined): (JSC::JSFunction::JSFunction): (JSC::JSFunction::finishCreation): (JSC::JSFunction::allocateRareData): (JSC::JSFunction::allocateAndInitializeRareData): (JSC::JSFunction::initializeRareData): (JSC::JSFunction::visitChildren): (JSC::JSFunction::put): (JSC::JSFunction::defineOwnProperty): * runtime/JSFunction.h: (JSC::JSFunction::executable const): (JSC::JSFunction::offsetOfExecutableOrRareData): (JSC::JSFunction::rareData): (JSC::JSFunction::offsetOfExecutable): Deleted. (JSC::JSFunction::offsetOfRareData): Deleted. * runtime/JSFunctionInlines.h: (JSC::JSFunction::JSFunction): (JSC::JSFunction::jsExecutable const): (JSC::JSFunction::isHostFunction const): (JSC::JSFunction::nativeFunction): (JSC::JSFunction::nativeConstructor): (JSC::JSFunction::hasReifiedLength const): (JSC::JSFunction::hasReifiedName const): (JSC::JSFunction::areNameAndLengthOriginal): (JSC::JSFunction::ensureRareDataAndAllocationProfile): * runtime/JSNativeStdFunction.cpp: (JSC::JSNativeStdFunction::JSNativeStdFunction): (JSC::JSNativeStdFunction::create): * runtime/JSNativeStdFunction.h: * wasm/js/WebAssemblyFunction.cpp: (JSC::WebAssemblyFunction::create): (JSC::WebAssemblyFunction::WebAssemblyFunction): * wasm/js/WebAssemblyFunction.h: * wasm/js/WebAssemblyFunctionBase.cpp: (JSC::WebAssemblyFunctionBase::WebAssemblyFunctionBase): * wasm/js/WebAssemblyFunctionBase.h: * wasm/js/WebAssemblyWrapperFunction.cpp: (JSC::WebAssemblyWrapperFunction::WebAssemblyWrapperFunction): (JSC::WebAssemblyWrapperFunction::create): * wasm/js/WebAssemblyWrapperFunction.h: 2019-12-28 Yusuke Suzuki [JSC] StructureChain should hold vector of StructureID https://bugs.webkit.org/show_bug.cgi?id=205592 Reviewed by Mark Lam. StructureChain should keep vector of StructureID instead of Structure* to minimize the size of vector. * llint/LowLevelInterpreter64.asm: * runtime/JSPropertyNameEnumerator.h: (JSC::propertyNameEnumerator): * runtime/ProxyObject.h: * runtime/Structure.cpp: (JSC::Structure::canCachePropertyNameEnumerator const): * runtime/Structure.h: * runtime/StructureChain.cpp: (JSC::StructureChain::StructureChain): (JSC::StructureChain::create): (JSC::StructureChain::finishCreation): (JSC::StructureChain::visitChildren): * runtime/StructureChain.h: * runtime/StructureInlines.h: (JSC::Structure::isValid const): 2019-12-25 Yusuke Suzuki [JSC] Compact Bytecodes more by emitting 1-byte Opcode https://bugs.webkit.org/show_bug.cgi?id=205553 Reviewed by Keith Miller. When emitting 16bit / 32bit bytecodes, we also emit 16bit / 32bit Opcode. So the layout is the following. 8bit 16bit 16bit 16bit - [op_wide16][ Opcode ][ Operand0 ][ Operand1 ] But this is unnecessary since Opcode must fit in 8bit. We should emit Opcode in 8bit in all cases. 8bit 8bit 16bit 16bit - [op_wide16][Opcode][ Operand0 ][ Operand1 ] * bytecode/Instruction.h: (JSC::BaseInstruction::size const): * bytecompiler/BytecodeGeneratorBaseInlines.h: (JSC::BytecodeGeneratorBase::alignWideOpcode16): (JSC::BytecodeGeneratorBase::alignWideOpcode32): * generator/Argument.rb: * generator/Opcode.rb: * llint/LowLevelInterpreter.asm: * llint/LowLevelInterpreter32_64.asm: * llint/LowLevelInterpreter64.asm: * llint/WebAssembly.asm: 2019-12-24 Keith Miller Fix ARM64E by adding missing pointer tag. * llint/LowLevelInterpreter.asm: 2019-12-23 Keith Miller DFG/FTL should be able to exit to the middle of a bytecode https://bugs.webkit.org/show_bug.cgi?id=205232 Reviewed by Saam Barati. It can be valuable to exit to the middle of a bytecode for a couple of reasons. 1) It can be used to combine bytecodes that share a majority of their operands, reducing bytecode steam size. 2) It enables creating bytecodes that are easier to reconstruct useful optimization information from. To make exiting to the middle of a bytecode possible this patch introduces the concept of a temporary operand. A temporary operand is one that contains the result of effectful operations during the process of executing a bytecode. tmp operands have no meaning when executing in the LLInt or Baseline and are only used in the DFG to preserve information for OSR exit. We use the term checkpoint to refer to any point where an effectful component of a bytecode executes. For example, in op_call_varargs there are two checkpoints the first is before we have determined the number of variable arguments and the second is the actual call. When the DFG OSR exits if there are any active checkpoints inline call stack we will emit a jit probe that allocates a side state object keyed off the frame pointer of the bytecode whose checkpoint needs to be finished. We need side state because we may recursively inline several copies of the same function. Alternatively, we could call back into ourselves after OSR and exit again from optimized code before finishing the checkpoint of our caller. Another thing we need to be careful of is making sure we remove side state as we unwind for an exception. To make sure we do this correctly I've added an assertion to JSLock that there are no pending checkpoint side states on the vm when releasing the lock. A large amount of this patch is trying to remove as much code that refers to virtual registers as an int as possible. Instead, this patch replaces them with the VirtualRegister class. There are also a couple of new classes/enums added to JSC: 1) There is now a class, Operand, that represents the combination of a VirtualRegister and a temporary. This is handy in the DFG to model OSR exit values all together. Additionally, Operands has been updated to work with respect to Operand values. 2) CallFrameSlot is now an enum class instead of a struct of constexpr values. This lets us implicitly convert CallFrameSlots to VirtualRegisters without allowing all ints to implicity convert. 3) FTL::SelectPredictability is a new enum that describes to the FTL whether or not we think a select is going to be predictable. SelectPredictability has four options: Unpredictable, Predictable, LeftLikely, and RightLikely. Unpredictable means we think a branch predictor won't do a good job guessing this value so we should compile the select to a cmov. The other options mean we either think we are going to pick the same value every time or there's a reasonable chance the branch predictor will be able to guess the value. In order to validate the correctness of this patch the various varargs call opcodes have been reworked to use checkpoints. This also fixed a long-standing issue where we could call length getters twice if we OSR exit during LoadVarargs but before the actually call. Lastly, we have not enabled the probe-based OSR exit for a long time in production, thus this patch removes that code since it would be a non-trivial amount of work to get checkpoints working with probe OSR. * CMakeLists.txt: * DerivedSources-input.xcfilelist: * JavaScriptCore.xcodeproj/project.pbxproj: * assembler/MacroAssemblerCodeRef.h: * assembler/ProbeFrame.h: (JSC::Probe::Frame::operand): (JSC::Probe::Frame::setOperand): * b3/testb3.h: (populateWithInterestingValues): (floatingPointOperands): * bytecode/AccessCase.cpp: (JSC::AccessCase::generateImpl): * bytecode/AccessCaseSnippetParams.cpp: (JSC::SlowPathCallGeneratorWithArguments::generateImpl): * bytecode/BytecodeDumper.cpp: (JSC::BytecodeDumperBase::dumpValue): (JSC::BytecodeDumper::registerName const): (JSC::BytecodeDumper::constantName const): (JSC::Wasm::BytecodeDumper::constantName const): * bytecode/BytecodeDumper.h: * bytecode/BytecodeIndex.cpp: (JSC::BytecodeIndex::dump const): * bytecode/BytecodeIndex.h: (JSC::BytecodeIndex::BytecodeIndex): (JSC::BytecodeIndex::offset const): (JSC::BytecodeIndex::checkpoint const): (JSC::BytecodeIndex::asBits const): (JSC::BytecodeIndex::hash const): (JSC::BytecodeIndex::operator bool const): (JSC::BytecodeIndex::pack): (JSC::BytecodeIndex::fromBits): * bytecode/BytecodeList.rb: * bytecode/BytecodeLivenessAnalysis.cpp: (JSC::enumValuesEqualAsIntegral): (JSC::tmpLivenessForCheckpoint): * bytecode/BytecodeLivenessAnalysis.h: * bytecode/BytecodeLivenessAnalysisInlines.h: (JSC::virtualRegisterIsAlwaysLive): (JSC::virtualRegisterThatIsNotAlwaysLiveIsLive): (JSC::virtualRegisterIsLive): (JSC::operandIsAlwaysLive): Deleted. (JSC::operandThatIsNotAlwaysLiveIsLive): Deleted. (JSC::operandIsLive): Deleted. * bytecode/CodeBlock.cpp: (JSC::CodeBlock::finishCreation): (JSC::CodeBlock::bytecodeIndexForExit const): (JSC::CodeBlock::ensureCatchLivenessIsComputedForBytecodeIndexSlow): (JSC::CodeBlock::updateAllValueProfilePredictionsAndCountLiveness): * bytecode/CodeBlock.h: (JSC::CodeBlock::numTmps const): (JSC::CodeBlock::isKnownNotImmediate): (JSC::CodeBlock::isTemporaryRegister): (JSC::CodeBlock::constantRegister): (JSC::CodeBlock::getConstant const): (JSC::CodeBlock::constantSourceCodeRepresentation const): (JSC::CodeBlock::replaceConstant): (JSC::CodeBlock::isTemporaryRegisterIndex): Deleted. (JSC::CodeBlock::isConstantRegisterIndex): Deleted. * bytecode/CodeOrigin.h: * bytecode/FullBytecodeLiveness.h: (JSC::FullBytecodeLiveness::virtualRegisterIsLive const): (JSC::FullBytecodeLiveness::operandIsLive const): Deleted. * bytecode/InlineCallFrame.h: (JSC::InlineCallFrame::InlineCallFrame): (JSC::InlineCallFrame::setTmpOffset): (JSC::CodeOrigin::walkUpInlineStack const): (JSC::CodeOrigin::inlineStackContainsActiveCheckpoint const): (JSC::remapOperand): (JSC::unmapOperand): (JSC::CodeOrigin::walkUpInlineStack): Deleted. * bytecode/LazyOperandValueProfile.h: (JSC::LazyOperandValueProfileKey::LazyOperandValueProfileKey): (JSC::LazyOperandValueProfileKey::hash const): (JSC::LazyOperandValueProfileKey::operand const): * bytecode/MethodOfGettingAValueProfile.cpp: (JSC::MethodOfGettingAValueProfile::fromLazyOperand): (JSC::MethodOfGettingAValueProfile::emitReportValue const): (JSC::MethodOfGettingAValueProfile::reportValue): * bytecode/MethodOfGettingAValueProfile.h: * bytecode/Operands.h: (JSC::Operand::Operand): (JSC::Operand::tmp): (JSC::Operand::kind const): (JSC::Operand::value const): (JSC::Operand::virtualRegister const): (JSC::Operand::asBits const): (JSC::Operand::isTmp const): (JSC::Operand::isArgument const): (JSC::Operand::isLocal const): (JSC::Operand::isHeader const): (JSC::Operand::isConstant const): (JSC::Operand::toArgument const): (JSC::Operand::toLocal const): (JSC::Operand::operator== const): (JSC::Operand::isValid const): (JSC::Operand::fromBits): (JSC::Operands::Operands): (JSC::Operands::numberOfLocals const): (JSC::Operands::numberOfTmps const): (JSC::Operands::tmpIndex const): (JSC::Operands::argumentIndex const): (JSC::Operands::localIndex const): (JSC::Operands::tmp): (JSC::Operands::tmp const): (JSC::Operands::argument): (JSC::Operands::argument const): (JSC::Operands::local): (JSC::Operands::local const): (JSC::Operands::sizeFor const): (JSC::Operands::atFor): (JSC::Operands::atFor const): (JSC::Operands::ensureLocals): (JSC::Operands::ensureTmps): (JSC::Operands::getForOperandIndex): (JSC::Operands::getForOperandIndex const): (JSC::Operands::operandIndex const): (JSC::Operands::operand): (JSC::Operands::operand const): (JSC::Operands::hasOperand const): (JSC::Operands::setOperand): (JSC::Operands::at const): (JSC::Operands::at): (JSC::Operands::operator[] const): (JSC::Operands::operator[]): (JSC::Operands::operandForIndex const): (JSC::Operands::operator== const): (JSC::Operands::isArgument const): Deleted. (JSC::Operands::isLocal const): Deleted. (JSC::Operands::virtualRegisterForIndex const): Deleted. (JSC::Operands::setOperandFirstTime): Deleted. * bytecode/OperandsInlines.h: (JSC::Operand::dump const): (JSC::Operands::dumpInContext const): (JSC::Operands::dump const): * bytecode/UnlinkedCodeBlock.cpp: (JSC::UnlinkedCodeBlock::UnlinkedCodeBlock): * bytecode/UnlinkedCodeBlock.h: (JSC::UnlinkedCodeBlock::hasCheckpoints const): (JSC::UnlinkedCodeBlock::setHasCheckpoints): (JSC::UnlinkedCodeBlock::constantRegister const): (JSC::UnlinkedCodeBlock::getConstant const): (JSC::UnlinkedCodeBlock::isConstantRegisterIndex const): Deleted. * bytecode/ValueProfile.h: (JSC::ValueProfileAndVirtualRegisterBuffer::ValueProfileAndVirtualRegisterBuffer): (JSC::ValueProfileAndVirtualRegisterBuffer::~ValueProfileAndVirtualRegisterBuffer): (JSC::ValueProfileAndOperandBuffer::ValueProfileAndOperandBuffer): Deleted. (JSC::ValueProfileAndOperandBuffer::~ValueProfileAndOperandBuffer): Deleted. (JSC::ValueProfileAndOperandBuffer::forEach): Deleted. * bytecode/ValueRecovery.cpp: (JSC::ValueRecovery::recover const): * bytecode/ValueRecovery.h: * bytecode/VirtualRegister.h: (JSC::virtualRegisterIsLocal): (JSC::virtualRegisterIsArgument): (JSC::VirtualRegister::VirtualRegister): (JSC::VirtualRegister::isValid const): (JSC::VirtualRegister::isLocal const): (JSC::VirtualRegister::isArgument const): (JSC::VirtualRegister::isConstant const): (JSC::VirtualRegister::toConstantIndex const): (JSC::operandIsLocal): Deleted. (JSC::operandIsArgument): Deleted. * bytecompiler/BytecodeGenerator.cpp: (JSC::BytecodeGenerator::initializeNextParameter): (JSC::BytecodeGenerator::initializeParameters): (JSC::BytecodeGenerator::emitEqualityOpImpl): (JSC::BytecodeGenerator::emitCallVarargs): * bytecompiler/BytecodeGenerator.h: (JSC::BytecodeGenerator::setUsesCheckpoints): * bytecompiler/RegisterID.h: (JSC::RegisterID::setIndex): * dfg/DFGAbstractHeap.cpp: (JSC::DFG::AbstractHeap::Payload::dumpAsOperand const): (JSC::DFG::AbstractHeap::dump const): * dfg/DFGAbstractHeap.h: (JSC::DFG::AbstractHeap::Payload::Payload): (JSC::DFG::AbstractHeap::AbstractHeap): (JSC::DFG::AbstractHeap::operand const): * dfg/DFGAbstractInterpreterInlines.h: (JSC::DFG::AbstractInterpreter::executeEffects): * dfg/DFGArgumentPosition.h: (JSC::DFG::ArgumentPosition::dump): * dfg/DFGArgumentsEliminationPhase.cpp: * dfg/DFGArgumentsUtilities.cpp: (JSC::DFG::argumentsInvolveStackSlot): (JSC::DFG::emitCodeToGetArgumentsArrayLength): * dfg/DFGArgumentsUtilities.h: * dfg/DFGAtTailAbstractState.h: (JSC::DFG::AtTailAbstractState::operand): * dfg/DFGAvailabilityMap.cpp: (JSC::DFG::AvailabilityMap::pruneByLiveness): * dfg/DFGAvailabilityMap.h: (JSC::DFG::AvailabilityMap::closeStartingWithLocal): * dfg/DFGBasicBlock.cpp: (JSC::DFG::BasicBlock::BasicBlock): (JSC::DFG::BasicBlock::ensureTmps): * dfg/DFGBasicBlock.h: * dfg/DFGBlockInsertionSet.cpp: (JSC::DFG::BlockInsertionSet::insert): * dfg/DFGByteCodeParser.cpp: (JSC::DFG::ByteCodeParser::ByteCodeParser): (JSC::DFG::ByteCodeParser::ensureTmps): (JSC::DFG::ByteCodeParser::progressToNextCheckpoint): (JSC::DFG::ByteCodeParser::newVariableAccessData): (JSC::DFG::ByteCodeParser::getDirect): (JSC::DFG::ByteCodeParser::get): (JSC::DFG::ByteCodeParser::setDirect): (JSC::DFG::ByteCodeParser::injectLazyOperandSpeculation): (JSC::DFG::ByteCodeParser::getLocalOrTmp): (JSC::DFG::ByteCodeParser::setLocalOrTmp): (JSC::DFG::ByteCodeParser::setArgument): (JSC::DFG::ByteCodeParser::findArgumentPositionForLocal): (JSC::DFG::ByteCodeParser::findArgumentPosition): (JSC::DFG::ByteCodeParser::flushImpl): (JSC::DFG::ByteCodeParser::flushForTerminalImpl): (JSC::DFG::ByteCodeParser::flush): (JSC::DFG::ByteCodeParser::flushDirect): (JSC::DFG::ByteCodeParser::addFlushOrPhantomLocal): (JSC::DFG::ByteCodeParser::phantomLocalDirect): (JSC::DFG::ByteCodeParser::flushForTerminal): (JSC::DFG::ByteCodeParser::addToGraph): (JSC::DFG::ByteCodeParser::InlineStackEntry::remapOperand const): (JSC::DFG::ByteCodeParser::DelayedSetLocal::DelayedSetLocal): (JSC::DFG::ByteCodeParser::DelayedSetLocal::execute): (JSC::DFG::ByteCodeParser::allocateTargetableBlock): (JSC::DFG::ByteCodeParser::allocateUntargetableBlock): (JSC::DFG::ByteCodeParser::handleRecursiveTailCall): (JSC::DFG::ByteCodeParser::inlineCall): (JSC::DFG::ByteCodeParser::handleVarargsInlining): (JSC::DFG::ByteCodeParser::handleInlining): (JSC::DFG::ByteCodeParser::parseBlock): (JSC::DFG::ByteCodeParser::InlineStackEntry::InlineStackEntry): (JSC::DFG::ByteCodeParser::parse): (JSC::DFG::ByteCodeParser::getLocal): Deleted. (JSC::DFG::ByteCodeParser::setLocal): Deleted. * dfg/DFGCFAPhase.cpp: (JSC::DFG::CFAPhase::injectOSR): * dfg/DFGCPSRethreadingPhase.cpp: (JSC::DFG::CPSRethreadingPhase::run): (JSC::DFG::CPSRethreadingPhase::canonicalizeGetLocal): (JSC::DFG::CPSRethreadingPhase::canonicalizeFlushOrPhantomLocalFor): (JSC::DFG::CPSRethreadingPhase::canonicalizeFlushOrPhantomLocal): (JSC::DFG::CPSRethreadingPhase::canonicalizeSet): (JSC::DFG::CPSRethreadingPhase::canonicalizeLocalsInBlock): (JSC::DFG::CPSRethreadingPhase::propagatePhis): (JSC::DFG::CPSRethreadingPhase::phiStackFor): * dfg/DFGCSEPhase.cpp: * dfg/DFGCapabilities.cpp: (JSC::DFG::capabilityLevel): * dfg/DFGClobberize.h: (JSC::DFG::clobberize): * dfg/DFGCombinedLiveness.cpp: (JSC::DFG::addBytecodeLiveness): * dfg/DFGCommonData.cpp: (JSC::DFG::CommonData::addCodeOrigin): (JSC::DFG::CommonData::addUniqueCallSiteIndex): (JSC::DFG::CommonData::lastCallSite const): * dfg/DFGConstantFoldingPhase.cpp: (JSC::DFG::ConstantFoldingPhase::foldConstants): * dfg/DFGDoesGC.cpp: (JSC::DFG::doesGC): * dfg/DFGDriver.cpp: (JSC::DFG::compileImpl): * dfg/DFGFixupPhase.cpp: (JSC::DFG::FixupPhase::fixupNode): * dfg/DFGForAllKills.h: (JSC::DFG::forAllKilledOperands): (JSC::DFG::forAllKilledNodesAtNodeIndex): (JSC::DFG::forAllKillsInBlock): * dfg/DFGGraph.cpp: (JSC::DFG::Graph::dump): (JSC::DFG::Graph::dumpBlockHeader): (JSC::DFG::Graph::substituteGetLocal): (JSC::DFG::Graph::isLiveInBytecode): (JSC::DFG::Graph::localsAndTmpsLiveInBytecode): (JSC::DFG::Graph::methodOfGettingAValueProfileFor): (JSC::DFG::Graph::localsLiveInBytecode): Deleted. * dfg/DFGGraph.h: (JSC::DFG::Graph::forAllLocalsAndTmpsLiveInBytecode): (JSC::DFG::Graph::forAllLiveInBytecode): (JSC::DFG::Graph::forAllLocalsLiveInBytecode): Deleted. * dfg/DFGInPlaceAbstractState.cpp: (JSC::DFG::InPlaceAbstractState::InPlaceAbstractState): * dfg/DFGInPlaceAbstractState.h: (JSC::DFG::InPlaceAbstractState::operand): * dfg/DFGJITCompiler.cpp: (JSC::DFG::JITCompiler::linkOSRExits): (JSC::DFG::JITCompiler::noticeOSREntry): * dfg/DFGJITCompiler.h: (JSC::DFG::JITCompiler::emitStoreCallSiteIndex): * dfg/DFGLiveCatchVariablePreservationPhase.cpp: (JSC::DFG::LiveCatchVariablePreservationPhase::isValidFlushLocation): (JSC::DFG::LiveCatchVariablePreservationPhase::handleBlockForTryCatch): (JSC::DFG::LiveCatchVariablePreservationPhase::newVariableAccessData): * dfg/DFGMovHintRemovalPhase.cpp: * dfg/DFGNode.h: (JSC::DFG::StackAccessData::StackAccessData): (JSC::DFG::Node::hasArgumentsChild): (JSC::DFG::Node::argumentsChild): (JSC::DFG::Node::operand): (JSC::DFG::Node::hasUnlinkedOperand): (JSC::DFG::Node::unlinkedOperand): (JSC::DFG::Node::hasLoadVarargsData): (JSC::DFG::Node::local): Deleted. (JSC::DFG::Node::hasUnlinkedLocal): Deleted. (JSC::DFG::Node::unlinkedLocal): Deleted. * dfg/DFGNodeType.h: * dfg/DFGOSRAvailabilityAnalysisPhase.cpp: (JSC::DFG::OSRAvailabilityAnalysisPhase::run): (JSC::DFG::LocalOSRAvailabilityCalculator::executeNode): * dfg/DFGOSREntry.cpp: (JSC::DFG::prepareOSREntry): (JSC::DFG::prepareCatchOSREntry): * dfg/DFGOSREntrypointCreationPhase.cpp: (JSC::DFG::OSREntrypointCreationPhase::run): * dfg/DFGOSRExit.cpp: (JSC::DFG::OSRExit::emitRestoreArguments): (JSC::DFG::OSRExit::compileExit): (JSC::DFG::jsValueFor): Deleted. (JSC::DFG::restoreCalleeSavesFor): Deleted. (JSC::DFG::saveCalleeSavesFor): Deleted. (JSC::DFG::restoreCalleeSavesFromVMEntryFrameCalleeSavesBuffer): Deleted. (JSC::DFG::copyCalleeSavesToVMEntryFrameCalleeSavesBuffer): Deleted. (JSC::DFG::saveOrCopyCalleeSavesFor): Deleted. (JSC::DFG::createDirectArgumentsDuringExit): Deleted. (JSC::DFG::createClonedArgumentsDuringExit): Deleted. (JSC::DFG::emitRestoreArguments): Deleted. (JSC::DFG::OSRExit::executeOSRExit): Deleted. (JSC::DFG::reifyInlinedCallFrames): Deleted. (JSC::DFG::adjustAndJumpToTarget): Deleted. (JSC::DFG::printOSRExit): Deleted. * dfg/DFGOSRExit.h: * dfg/DFGOSRExitBase.h: (JSC::DFG::OSRExitBase::isExitingToCheckpointHandler const): * dfg/DFGOSRExitCompilerCommon.cpp: (JSC::DFG::callerReturnPC): (JSC::DFG::reifyInlinedCallFrames): (JSC::DFG::adjustAndJumpToTarget): * dfg/DFGObjectAllocationSinkingPhase.cpp: * dfg/DFGOpInfo.h: (JSC::DFG::OpInfo::OpInfo): * dfg/DFGOperations.cpp: * dfg/DFGPhantomInsertionPhase.cpp: * dfg/DFGPreciseLocalClobberize.h: (JSC::DFG::PreciseLocalClobberizeAdaptor::read): (JSC::DFG::PreciseLocalClobberizeAdaptor::write): (JSC::DFG::PreciseLocalClobberizeAdaptor::def): (JSC::DFG::PreciseLocalClobberizeAdaptor::callIfAppropriate): * dfg/DFGPredictionInjectionPhase.cpp: (JSC::DFG::PredictionInjectionPhase::run): * dfg/DFGPredictionPropagationPhase.cpp: * dfg/DFGPutStackSinkingPhase.cpp: * dfg/DFGSSAConversionPhase.cpp: (JSC::DFG::SSAConversionPhase::run): * dfg/DFGSafeToExecute.h: (JSC::DFG::safeToExecute): * dfg/DFGSpeculativeJIT.cpp: (JSC::DFG::SpeculativeJIT::compileMovHint): (JSC::DFG::SpeculativeJIT::compileCurrentBlock): (JSC::DFG::SpeculativeJIT::checkArgumentTypes): (JSC::DFG::SpeculativeJIT::compileVarargsLength): (JSC::DFG::SpeculativeJIT::compileLoadVarargs): (JSC::DFG::SpeculativeJIT::compileForwardVarargs): (JSC::DFG::SpeculativeJIT::compileCreateDirectArguments): (JSC::DFG::SpeculativeJIT::compileGetArgumentCountIncludingThis): * dfg/DFGSpeculativeJIT.h: (JSC::DFG::SpeculativeJIT::recordSetLocal): * dfg/DFGSpeculativeJIT32_64.cpp: (JSC::DFG::SpeculativeJIT::compile): * dfg/DFGSpeculativeJIT64.cpp: (JSC::DFG::SpeculativeJIT::compile): * dfg/DFGStackLayoutPhase.cpp: (JSC::DFG::StackLayoutPhase::run): (JSC::DFG::StackLayoutPhase::assign): * dfg/DFGStrengthReductionPhase.cpp: (JSC::DFG::StrengthReductionPhase::handleNode): * dfg/DFGThunks.cpp: (JSC::DFG::osrExitThunkGenerator): Deleted. * dfg/DFGThunks.h: * dfg/DFGTypeCheckHoistingPhase.cpp: (JSC::DFG::TypeCheckHoistingPhase::run): (JSC::DFG::TypeCheckHoistingPhase::disableHoistingAcrossOSREntries): * dfg/DFGValidate.cpp: * dfg/DFGVarargsForwardingPhase.cpp: * dfg/DFGVariableAccessData.cpp: (JSC::DFG::VariableAccessData::VariableAccessData): (JSC::DFG::VariableAccessData::shouldUseDoubleFormatAccordingToVote): (JSC::DFG::VariableAccessData::tallyVotesForShouldUseDoubleFormat): (JSC::DFG::VariableAccessData::couldRepresentInt52Impl): * dfg/DFGVariableAccessData.h: (JSC::DFG::VariableAccessData::operand): (JSC::DFG::VariableAccessData::local): Deleted. * dfg/DFGVariableEvent.cpp: (JSC::DFG::VariableEvent::dump const): * dfg/DFGVariableEvent.h: (JSC::DFG::VariableEvent::spill): (JSC::DFG::VariableEvent::setLocal): (JSC::DFG::VariableEvent::movHint): (JSC::DFG::VariableEvent::spillRegister const): (JSC::DFG::VariableEvent::operand const): (JSC::DFG::VariableEvent::bytecodeRegister const): Deleted. * dfg/DFGVariableEventStream.cpp: (JSC::DFG::VariableEventStream::logEvent): (JSC::DFG::VariableEventStream::reconstruct const): * dfg/DFGVariableEventStream.h: (JSC::DFG::VariableEventStream::appendAndLog): * ftl/FTLCapabilities.cpp: (JSC::FTL::canCompile): * ftl/FTLForOSREntryJITCode.cpp: (JSC::FTL::ForOSREntryJITCode::ForOSREntryJITCode): * ftl/FTLLowerDFGToB3.cpp: (JSC::FTL::DFG::LowerDFGToB3::lower): (JSC::FTL::DFG::LowerDFGToB3::compileNode): (JSC::FTL::DFG::LowerDFGToB3::compileExtractOSREntryLocal): (JSC::FTL::DFG::LowerDFGToB3::compileGetStack): (JSC::FTL::DFG::LowerDFGToB3::compileGetCallee): (JSC::FTL::DFG::LowerDFGToB3::compileSetCallee): (JSC::FTL::DFG::LowerDFGToB3::compileSetArgumentCountIncludingThis): (JSC::FTL::DFG::LowerDFGToB3::compileVarargsLength): (JSC::FTL::DFG::LowerDFGToB3::compileLoadVarargs): (JSC::FTL::DFG::LowerDFGToB3::compileForwardVarargs): (JSC::FTL::DFG::LowerDFGToB3::getSpreadLengthFromInlineCallFrame): (JSC::FTL::DFG::LowerDFGToB3::compileForwardVarargsWithSpread): (JSC::FTL::DFG::LowerDFGToB3::compileLogShadowChickenPrologue): (JSC::FTL::DFG::LowerDFGToB3::getArgumentsLength): (JSC::FTL::DFG::LowerDFGToB3::getCurrentCallee): (JSC::FTL::DFG::LowerDFGToB3::callPreflight): (JSC::FTL::DFG::LowerDFGToB3::appendOSRExitDescriptor): (JSC::FTL::DFG::LowerDFGToB3::buildExitArguments): (JSC::FTL::DFG::LowerDFGToB3::addressFor): (JSC::FTL::DFG::LowerDFGToB3::payloadFor): (JSC::FTL::DFG::LowerDFGToB3::tagFor): * ftl/FTLOSREntry.cpp: (JSC::FTL::prepareOSREntry): * ftl/FTLOSRExit.cpp: (JSC::FTL::OSRExitDescriptor::OSRExitDescriptor): * ftl/FTLOSRExit.h: * ftl/FTLOSRExitCompiler.cpp: (JSC::FTL::compileStub): * ftl/FTLOperations.cpp: (JSC::FTL::operationMaterializeObjectInOSR): * ftl/FTLOutput.cpp: (JSC::FTL::Output::select): * ftl/FTLOutput.h: * ftl/FTLSelectPredictability.h: Copied from Source/JavaScriptCore/ftl/FTLForOSREntryJITCode.cpp. * ftl/FTLSlowPathCall.h: (JSC::FTL::callOperation): * generator/Checkpoints.rb: Added. * generator/Opcode.rb: * generator/Section.rb: * heap/Heap.cpp: (JSC::Heap::gatherStackRoots): * interpreter/CallFrame.cpp: (JSC::CallFrame::callSiteAsRawBits const): (JSC::CallFrame::unsafeCallSiteAsRawBits const): (JSC::CallFrame::callSiteIndex const): (JSC::CallFrame::unsafeCallSiteIndex const): (JSC::CallFrame::setCurrentVPC): (JSC::CallFrame::bytecodeIndex): (JSC::CallFrame::codeOrigin): * interpreter/CallFrame.h: (JSC::CallSiteIndex::CallSiteIndex): (JSC::CallSiteIndex::operator bool const): (JSC::CallSiteIndex::operator== const): (JSC::CallSiteIndex::bits const): (JSC::CallSiteIndex::fromBits): (JSC::CallSiteIndex::bytecodeIndex const): (JSC::DisposableCallSiteIndex::DisposableCallSiteIndex): (JSC::CallFrame::callee const): (JSC::CallFrame::unsafeCallee const): (JSC::CallFrame::addressOfCodeBlock const): (JSC::CallFrame::argumentCountIncludingThis const): (JSC::CallFrame::offsetFor): (JSC::CallFrame::setArgumentCountIncludingThis): (JSC::CallFrame::setReturnPC): * interpreter/CallFrameInlines.h: (JSC::CallFrame::r): (JSC::CallFrame::uncheckedR): (JSC::CallFrame::guaranteedJSValueCallee const): (JSC::CallFrame::jsCallee const): (JSC::CallFrame::codeBlock const): (JSC::CallFrame::unsafeCodeBlock const): (JSC::CallFrame::setCallee): (JSC::CallFrame::setCodeBlock): * interpreter/CheckpointOSRExitSideState.h: Copied from Source/JavaScriptCore/dfg/DFGThunks.h. * interpreter/Interpreter.cpp: (JSC::eval): (JSC::sizeOfVarargs): (JSC::loadVarargs): (JSC::setupVarargsFrame): (JSC::UnwindFunctor::operator() const): (JSC::Interpreter::executeCall): (JSC::Interpreter::executeConstruct): * interpreter/Interpreter.h: * interpreter/StackVisitor.cpp: (JSC::StackVisitor::readInlinedFrame): * jit/AssemblyHelpers.h: (JSC::AssemblyHelpers::emitGetFromCallFrameHeaderPtr): (JSC::AssemblyHelpers::emitGetFromCallFrameHeader32): (JSC::AssemblyHelpers::emitGetFromCallFrameHeader64): (JSC::AssemblyHelpers::emitPutToCallFrameHeader): (JSC::AssemblyHelpers::emitPutToCallFrameHeaderBeforePrologue): (JSC::AssemblyHelpers::emitPutPayloadToCallFrameHeaderBeforePrologue): (JSC::AssemblyHelpers::emitPutTagToCallFrameHeaderBeforePrologue): (JSC::AssemblyHelpers::addressFor): (JSC::AssemblyHelpers::tagFor): (JSC::AssemblyHelpers::payloadFor): (JSC::AssemblyHelpers::calleeFrameSlot): (JSC::AssemblyHelpers::calleeArgumentSlot): (JSC::AssemblyHelpers::calleeFrameTagSlot): (JSC::AssemblyHelpers::calleeFramePayloadSlot): (JSC::AssemblyHelpers::calleeFrameCallerFrame): (JSC::AssemblyHelpers::argumentCount): * jit/CallFrameShuffler.cpp: (JSC::CallFrameShuffler::CallFrameShuffler): * jit/CallFrameShuffler.h: (JSC::CallFrameShuffler::setCalleeJSValueRegs): (JSC::CallFrameShuffler::assumeCalleeIsCell): * jit/JIT.h: * jit/JITArithmetic.cpp: (JSC::JIT::emit_op_unsigned): (JSC::JIT::emit_compareAndJump): (JSC::JIT::emit_compareAndJumpImpl): (JSC::JIT::emit_compareUnsignedAndJump): (JSC::JIT::emit_compareUnsignedAndJumpImpl): (JSC::JIT::emit_compareUnsigned): (JSC::JIT::emit_compareUnsignedImpl): (JSC::JIT::emit_compareAndJumpSlow): (JSC::JIT::emit_compareAndJumpSlowImpl): (JSC::JIT::emit_op_inc): (JSC::JIT::emit_op_dec): (JSC::JIT::emit_op_mod): (JSC::JIT::emitBitBinaryOpFastPath): (JSC::JIT::emit_op_bitnot): (JSC::JIT::emitRightShiftFastPath): (JSC::JIT::emitMathICFast): (JSC::JIT::emitMathICSlow): (JSC::JIT::emit_op_div): * jit/JITCall.cpp: (JSC::JIT::emitPutCallResult): (JSC::JIT::compileSetupFrame): (JSC::JIT::compileOpCall): * jit/JITExceptions.cpp: (JSC::genericUnwind): * jit/JITInlines.h: (JSC::JIT::isOperandConstantDouble): (JSC::JIT::getConstantOperand): (JSC::JIT::emitPutIntToCallFrameHeader): (JSC::JIT::appendCallWithExceptionCheckSetJSValueResult): (JSC::JIT::appendCallWithExceptionCheckSetJSValueResultWithProfile): (JSC::JIT::linkSlowCaseIfNotJSCell): (JSC::JIT::isOperandConstantChar): (JSC::JIT::getOperandConstantInt): (JSC::JIT::getOperandConstantDouble): (JSC::JIT::emitInitRegister): (JSC::JIT::emitLoadTag): (JSC::JIT::emitLoadPayload): (JSC::JIT::emitGet): (JSC::JIT::emitPutVirtualRegister): (JSC::JIT::emitLoad): (JSC::JIT::emitLoad2): (JSC::JIT::emitLoadDouble): (JSC::JIT::emitLoadInt32ToDouble): (JSC::JIT::emitStore): (JSC::JIT::emitStoreInt32): (JSC::JIT::emitStoreCell): (JSC::JIT::emitStoreBool): (JSC::JIT::emitStoreDouble): (JSC::JIT::emitJumpSlowCaseIfNotJSCell): (JSC::JIT::isOperandConstantInt): (JSC::JIT::emitGetVirtualRegister): (JSC::JIT::emitGetVirtualRegisters): * jit/JITOpcodes.cpp: (JSC::JIT::emit_op_mov): (JSC::JIT::emit_op_end): (JSC::JIT::emit_op_new_object): (JSC::JIT::emitSlow_op_new_object): (JSC::JIT::emit_op_overrides_has_instance): (JSC::JIT::emit_op_instanceof): (JSC::JIT::emitSlow_op_instanceof): (JSC::JIT::emit_op_is_empty): (JSC::JIT::emit_op_is_undefined): (JSC::JIT::emit_op_is_undefined_or_null): (JSC::JIT::emit_op_is_boolean): (JSC::JIT::emit_op_is_number): (JSC::JIT::emit_op_is_cell_with_type): (JSC::JIT::emit_op_is_object): (JSC::JIT::emit_op_ret): (JSC::JIT::emit_op_to_primitive): (JSC::JIT::emit_op_set_function_name): (JSC::JIT::emit_op_not): (JSC::JIT::emit_op_jfalse): (JSC::JIT::emit_op_jeq_null): (JSC::JIT::emit_op_jneq_null): (JSC::JIT::emit_op_jundefined_or_null): (JSC::JIT::emit_op_jnundefined_or_null): (JSC::JIT::emit_op_jneq_ptr): (JSC::JIT::emit_op_eq): (JSC::JIT::emit_op_jeq): (JSC::JIT::emit_op_jtrue): (JSC::JIT::emit_op_neq): (JSC::JIT::emit_op_jneq): (JSC::JIT::emit_op_throw): (JSC::JIT::compileOpStrictEq): (JSC::JIT::compileOpStrictEqJump): (JSC::JIT::emit_op_to_number): (JSC::JIT::emit_op_to_numeric): (JSC::JIT::emit_op_to_string): (JSC::JIT::emit_op_to_object): (JSC::JIT::emit_op_catch): (JSC::JIT::emit_op_get_parent_scope): (JSC::JIT::emit_op_switch_imm): (JSC::JIT::emit_op_switch_char): (JSC::JIT::emit_op_switch_string): (JSC::JIT::emit_op_eq_null): (JSC::JIT::emit_op_neq_null): (JSC::JIT::emit_op_enter): (JSC::JIT::emit_op_get_scope): (JSC::JIT::emit_op_to_this): (JSC::JIT::emit_op_create_this): (JSC::JIT::emit_op_check_tdz): (JSC::JIT::emitSlow_op_eq): (JSC::JIT::emitSlow_op_neq): (JSC::JIT::emitSlow_op_instanceof_custom): (JSC::JIT::emit_op_new_regexp): (JSC::JIT::emitNewFuncCommon): (JSC::JIT::emitNewFuncExprCommon): (JSC::JIT::emit_op_new_array): (JSC::JIT::emit_op_new_array_with_size): (JSC::JIT::emit_op_has_structure_property): (JSC::JIT::emit_op_has_indexed_property): (JSC::JIT::emitSlow_op_has_indexed_property): (JSC::JIT::emit_op_get_direct_pname): (JSC::JIT::emit_op_enumerator_structure_pname): (JSC::JIT::emit_op_enumerator_generic_pname): (JSC::JIT::emit_op_profile_type): (JSC::JIT::emit_op_log_shadow_chicken_prologue): (JSC::JIT::emit_op_log_shadow_chicken_tail): (JSC::JIT::emit_op_argument_count): (JSC::JIT::emit_op_get_rest_length): (JSC::JIT::emit_op_get_argument): * jit/JITOpcodes32_64.cpp: (JSC::JIT::emit_op_catch): * jit/JITOperations.cpp: * jit/JITPropertyAccess.cpp: (JSC::JIT::emit_op_get_by_val): (JSC::JIT::emitSlow_op_get_by_val): (JSC::JIT::emit_op_put_by_val): (JSC::JIT::emitGenericContiguousPutByVal): (JSC::JIT::emitArrayStoragePutByVal): (JSC::JIT::emitPutByValWithCachedId): (JSC::JIT::emitSlow_op_put_by_val): (JSC::JIT::emit_op_put_getter_by_id): (JSC::JIT::emit_op_put_setter_by_id): (JSC::JIT::emit_op_put_getter_setter_by_id): (JSC::JIT::emit_op_put_getter_by_val): (JSC::JIT::emit_op_put_setter_by_val): (JSC::JIT::emit_op_del_by_id): (JSC::JIT::emit_op_del_by_val): (JSC::JIT::emit_op_try_get_by_id): (JSC::JIT::emitSlow_op_try_get_by_id): (JSC::JIT::emit_op_get_by_id_direct): (JSC::JIT::emitSlow_op_get_by_id_direct): (JSC::JIT::emit_op_get_by_id): (JSC::JIT::emit_op_get_by_id_with_this): (JSC::JIT::emitSlow_op_get_by_id): (JSC::JIT::emitSlow_op_get_by_id_with_this): (JSC::JIT::emit_op_put_by_id): (JSC::JIT::emit_op_in_by_id): (JSC::JIT::emitSlow_op_in_by_id): (JSC::JIT::emitResolveClosure): (JSC::JIT::emit_op_resolve_scope): (JSC::JIT::emitLoadWithStructureCheck): (JSC::JIT::emitGetClosureVar): (JSC::JIT::emit_op_get_from_scope): (JSC::JIT::emitSlow_op_get_from_scope): (JSC::JIT::emitPutGlobalVariable): (JSC::JIT::emitPutGlobalVariableIndirect): (JSC::JIT::emitPutClosureVar): (JSC::JIT::emit_op_put_to_scope): (JSC::JIT::emit_op_get_from_arguments): (JSC::JIT::emit_op_put_to_arguments): (JSC::JIT::emitWriteBarrier): (JSC::JIT::emit_op_get_internal_field): (JSC::JIT::emit_op_put_internal_field): (JSC::JIT::emitIntTypedArrayPutByVal): (JSC::JIT::emitFloatTypedArrayPutByVal): * jit/JSInterfaceJIT.h: (JSC::JSInterfaceJIT::emitLoadJSCell): (JSC::JSInterfaceJIT::emitJumpIfNotJSCell): (JSC::JSInterfaceJIT::emitLoadInt32): (JSC::JSInterfaceJIT::emitLoadDouble): (JSC::JSInterfaceJIT::emitGetFromCallFrameHeaderPtr): (JSC::JSInterfaceJIT::emitPutToCallFrameHeader): (JSC::JSInterfaceJIT::emitPutCellToCallFrameHeader): * jit/SetupVarargsFrame.cpp: (JSC::emitSetupVarargsFrameFastCase): * jit/SpecializedThunkJIT.h: (JSC::SpecializedThunkJIT::loadDoubleArgument): (JSC::SpecializedThunkJIT::loadCellArgument): (JSC::SpecializedThunkJIT::loadInt32Argument): * jit/ThunkGenerators.cpp: (JSC::absThunkGenerator): * llint/LLIntSlowPaths.cpp: (JSC::LLInt::getNonConstantOperand): (JSC::LLInt::getOperand): (JSC::LLInt::genericCall): (JSC::LLInt::varargsSetup): (JSC::LLInt::commonCallEval): (JSC::LLInt::LLINT_SLOW_PATH_DECL): (JSC::LLInt::handleVarargsCheckpoint): (JSC::LLInt::dispatchToNextInstruction): (JSC::LLInt::slow_path_checkpoint_osr_exit_from_inlined_call): (JSC::LLInt::slow_path_checkpoint_osr_exit): (JSC::LLInt::llint_throw_stack_overflow_error): * llint/LLIntSlowPaths.h: * llint/LowLevelInterpreter.asm: * llint/LowLevelInterpreter32_64.asm: * llint/LowLevelInterpreter64.asm: * runtime/ArgList.h: (JSC::MarkedArgumentBuffer::fill): * runtime/CachedTypes.cpp: (JSC::CachedCodeBlock::hasCheckpoints const): (JSC::UnlinkedCodeBlock::UnlinkedCodeBlock): (JSC::CachedCodeBlock::encode): * runtime/CommonSlowPaths.cpp: (JSC::SLOW_PATH_DECL): * runtime/ConstructData.cpp: (JSC::construct): * runtime/ConstructData.h: * runtime/DirectArguments.cpp: (JSC::DirectArguments::copyToArguments): * runtime/DirectArguments.h: * runtime/GenericArguments.h: * runtime/GenericArgumentsInlines.h: (JSC::GenericArguments::copyToArguments): * runtime/JSArray.cpp: (JSC::JSArray::copyToArguments): * runtime/JSArray.h: * runtime/JSImmutableButterfly.cpp: (JSC::JSImmutableButterfly::copyToArguments): * runtime/JSImmutableButterfly.h: * runtime/JSLock.cpp: (JSC::JSLock::willReleaseLock): * runtime/ModuleProgramExecutable.cpp: (JSC::ModuleProgramExecutable::create): * runtime/Options.cpp: (JSC::recomputeDependentOptions): * runtime/ScopedArguments.cpp: (JSC::ScopedArguments::copyToArguments): * runtime/ScopedArguments.h: * runtime/VM.cpp: (JSC::VM::addCheckpointOSRSideState): (JSC::VM::findCheckpointOSRSideState): (JSC::VM::scanSideState const): * runtime/VM.h: (JSC::VM::hasCheckpointOSRSideState const): * tools/VMInspector.cpp: (JSC::VMInspector::dumpRegisters): * wasm/WasmFunctionCodeBlock.h: (JSC::Wasm::FunctionCodeBlock::getConstant const): (JSC::Wasm::FunctionCodeBlock::getConstantType const): * wasm/WasmLLIntGenerator.cpp: (JSC::Wasm::LLIntGenerator::setUsesCheckpoints const): * wasm/WasmOperations.cpp: (JSC::Wasm::operationWasmToJSException): * wasm/WasmSlowPaths.cpp: 2019-12-23 Yusuke Suzuki [JSC] Wasm OSR entry should capture top-most enclosing-stack https://bugs.webkit.org/show_bug.cgi?id=205571 Reviewed by Keith Miller. OSR entry should capture the top-most enclosing-stack too. Otherwise the def-node can be unreachable (since it is defined in BB which is unreachable from OSR entry point), and eliminated. * wasm/WasmAirIRGenerator.cpp: (JSC::Wasm::AirIRGenerator::emitLoopTierUpCheck): (JSC::Wasm::AirIRGenerator::addLoop): * wasm/WasmB3IRGenerator.cpp: (JSC::Wasm::B3IRGenerator::emitLoopTierUpCheck): (JSC::Wasm::B3IRGenerator::addLoop): * wasm/WasmLLIntGenerator.cpp: (JSC::Wasm::LLIntGenerator::addLoop): 2019-12-23 Carlos Garcia Campos WebDriver: fix handling of session timeouts for values higher than MAX_INT https://bugs.webkit.org/show_bug.cgi?id=204114 Reviewed by Brian Burg. Fix generation of code with optional number in stack variable. * inspector/scripts/codegen/cpp_generator.py: (CppGenerator.cpp_type_for_stack_in_parameter): Do not use Optional for numbers either. * inspector/scripts/tests/generic/expected/commands-with-optional-call-return-parameters.json-result: 2019-12-22 Yusuke Suzuki Unreviewed, fix incorrect merging https://bugs.webkit.org/show_bug.cgi?id=205327 r253862 and r253867 cause incorrect merging. This patch fixes it. * jit/ThunkGenerators.cpp: (JSC::boundFunctionCallGenerator): 2019-12-22 Yusuke Suzuki Unreviewed, fix debug failures due to missing exception checks https://bugs.webkit.org/show_bug.cgi?id=205327 * runtime/JSFunction.cpp: (JSC::JSFunction::getOwnNonIndexPropertyNames): (JSC::JSFunction::put): (JSC::JSFunction::defineOwnProperty): * runtime/JSObject.cpp: (JSC::JSObject::defineOwnNonIndexProperty): 2019-12-21 Yusuke Suzuki [JSC] Improve our bound function implementation https://bugs.webkit.org/show_bug.cgi?id=205327 Reviewed by Keith Miller. This patch improves Function#bind, and calling bound function with bound arguments. 1. Rename CallFrameSlot::argumentCount to CallFrameSlot::argumentCountIncludingThis. 2. Do not include name in NativeExecutable for JSBoundFunction. Putting name in NativeExecutable is assuming that function + name pair is almost identical. This is true in host functions except for JSBoundFunction. JSBoundFunction should hold its name in JSBoundFunction. 3. Cache NativeExecutable for JSBoundFunction in the VM. We use a hash-map in JITThunk for NativeExecutables because we assume that host-function creation cannot be done by the user program: each executable is pre-defined to exactly one object by the environment, and there is no way to create host-functions repeatedly from the user-program. The only exception to this is JSBoundFunction so caching it on the VM avoids the hash-map lookup. This is not true for JSBoundFunction. 4. ThunkGenerator should support JSBoundFunction call with bound arguments. It turns out that Speedometer2/React-Redux-TodoMVC is using bound function with bound arguments. Additionally, it is used. This is really bad: when dispatching an event, we first call this function from C++, entering JS world, going back to C++ world again, and entering JS world to call bound function again. By using ThunkGenerator, we can eliminate this back and forth by directly calling the bound JS Executable from the thunk. Previously, bound arguments are stored in JSArray. But it is difficult to access them from thunk since we need to consider have-a-bad-time case. Instead, we use JSImmutableButterfly to save bound arguments so that JIT thunk can quickly access arguments. To capture arguments as JSImmutableButterfly in JS world, we introduce op_create_arguments_butterfly, and handle it in all tiers. 5. It turns out that eager materialization of "length" in JSBoundFunction takes long time while it is rarely used. This patch makes length lazily reified for JSBoundFunction. 6. To make Function.prototype.bind faster, we track whether "name" and "length" properties of JSFunction is modified or not. This skips has-own-length-property check, which makes Function.prototype.bind 11~% faster. Combining things above, creation of JSBoundFunction is 80~% faster. And calling bound function with bound arguments is 3~x faster. This improves Speedometer2/React-TodoMVC by ~3%. * builtins/FunctionPrototype.js: (bind): * bytecode/AccessCase.cpp: (JSC::AccessCase::generateImpl): * bytecode/AccessCaseSnippetParams.cpp: (JSC::SlowPathCallGeneratorWithArguments::generateImpl): * bytecode/BytecodeIntrinsicRegistry.h: * bytecode/BytecodeList.rb: * bytecode/BytecodeUseDef.cpp: (JSC::computeUsesForBytecodeIndexImpl): (JSC::computeDefsForBytecodeIndexImpl): * bytecode/VirtualRegister.cpp: (JSC::VirtualRegister::dump const): * bytecompiler/BytecodeGenerator.cpp: (JSC::BytecodeGenerator::emitCreateArgumentsButterfly): * bytecompiler/BytecodeGenerator.h: * bytecompiler/NodesCodegen.cpp: (JSC::BytecodeIntrinsicNode::emit_intrinsic_createArgumentsButterfly): * dfg/DFGAbstractInterpreterInlines.h: (JSC::DFG::AbstractInterpreter::executeEffects): * dfg/DFGArgumentsEliminationPhase.cpp: * dfg/DFGArgumentsUtilities.cpp: (JSC::DFG::argumentsInvolveStackSlot): * dfg/DFGByteCodeParser.cpp: (JSC::DFG::ByteCodeParser::flushImpl): (JSC::DFG::ByteCodeParser::handleVarargsInlining): (JSC::DFG::ByteCodeParser::parseBlock): * dfg/DFGCapabilities.cpp: (JSC::DFG::capabilityLevel): * dfg/DFGClobberize.h: (JSC::DFG::clobberize): * dfg/DFGDoesGC.cpp: (JSC::DFG::doesGC): * dfg/DFGFixupPhase.cpp: (JSC::DFG::FixupPhase::fixupNode): * dfg/DFGGraph.cpp: (JSC::DFG::Graph::isLiveInBytecode): * dfg/DFGGraph.h: (JSC::DFG::Graph::forAllLocalsLiveInBytecode): * dfg/DFGJITCompiler.cpp: (JSC::DFG::JITCompiler::compileFunction): * dfg/DFGJITCompiler.h: (JSC::DFG::JITCompiler::emitStoreCallSiteIndex): * dfg/DFGNodeType.h: * dfg/DFGOSRAvailabilityAnalysisPhase.cpp: (JSC::DFG::LocalOSRAvailabilityCalculator::executeNode): * dfg/DFGOSRExit.cpp: (JSC::DFG::emitRestoreArguments): (JSC::DFG::reifyInlinedCallFrames): (JSC::DFG::OSRExit::emitRestoreArguments): * dfg/DFGOSRExitCompilerCommon.cpp: (JSC::DFG::reifyInlinedCallFrames): * dfg/DFGOperations.cpp: * dfg/DFGOperations.h: * dfg/DFGPreciseLocalClobberize.h: (JSC::DFG::PreciseLocalClobberizeAdaptor::readTop): * dfg/DFGPredictionPropagationPhase.cpp: * dfg/DFGSafeToExecute.h: (JSC::DFG::safeToExecute): * dfg/DFGSpeculativeJIT.cpp: (JSC::DFG::SpeculativeJIT::compileCreateArgumentsButterfly): (JSC::DFG::SpeculativeJIT::compileGetArgumentCountIncludingThis): (JSC::DFG::SpeculativeJIT::compileSetArgumentCountIncludingThis): * dfg/DFGSpeculativeJIT.h: * dfg/DFGSpeculativeJIT32_64.cpp: (JSC::DFG::SpeculativeJIT::emitCall): (JSC::DFG::SpeculativeJIT::compile): * dfg/DFGSpeculativeJIT64.cpp: (JSC::DFG::SpeculativeJIT::emitCall): (JSC::DFG::SpeculativeJIT::compile): * dfg/DFGStackLayoutPhase.cpp: (JSC::DFG::StackLayoutPhase::run): * dfg/DFGStoreBarrierInsertionPhase.cpp: * ftl/FTLAbstractHeapRepository.h: * ftl/FTLCapabilities.cpp: (JSC::FTL::canCompile): * ftl/FTLLink.cpp: (JSC::FTL::link): * ftl/FTLLowerDFGToB3.cpp: (JSC::FTL::DFG::LowerDFGToB3::lower): (JSC::FTL::DFG::LowerDFGToB3::compileNode): (JSC::FTL::DFG::LowerDFGToB3::compileCreateArgumentsButterfly): (JSC::FTL::DFG::LowerDFGToB3::compileGetArgumentCountIncludingThis): (JSC::FTL::DFG::LowerDFGToB3::compileSetArgumentCountIncludingThis): (JSC::FTL::DFG::LowerDFGToB3::compileCallOrConstruct): (JSC::FTL::DFG::LowerDFGToB3::compileDirectCallOrConstruct): (JSC::FTL::DFG::LowerDFGToB3::compileTailCall): (JSC::FTL::DFG::LowerDFGToB3::compileCallOrConstructVarargsSpread): (JSC::FTL::DFG::LowerDFGToB3::compileCallOrConstructVarargs): (JSC::FTL::DFG::LowerDFGToB3::compileCallEval): (JSC::FTL::DFG::LowerDFGToB3::getArgumentsLength): (JSC::FTL::DFG::LowerDFGToB3::callPreflight): * ftl/FTLSlowPathCall.h: (JSC::FTL::callOperation): * interpreter/CallFrame.cpp: (JSC::CallFrame::callSiteAsRawBits const): (JSC::CallFrame::unsafeCallSiteAsRawBits const): (JSC::CallFrame::setCurrentVPC): * interpreter/CallFrame.h: (JSC::CallFrame::argumentCountIncludingThis const): (JSC::CallFrame::setArgumentCountIncludingThis): * jit/AssemblyHelpers.cpp: (JSC::AssemblyHelpers::jitAssertArgumentCountSane): * jit/AssemblyHelpers.h: (JSC::AssemblyHelpers::argumentCount): * jit/CCallHelpers.h: (JSC::CCallHelpers::prepareForTailCallSlow): * jit/CallFrameShuffler.cpp: (JSC::CallFrameShuffler::dump const): (JSC::CallFrameShuffler::prepareForTailCall): (JSC::CallFrameShuffler::prepareAny): * jit/JIT.cpp: (JSC::JIT::privateCompileMainPass): (JSC::JIT::compileWithoutLinking): * jit/JITCall.cpp: (JSC::JIT::compileSetupFrame): (JSC::JIT::compileOpCall): * jit/JITCall32_64.cpp: (JSC::JIT::compileSetupFrame): (JSC::JIT::compileOpCall): * jit/JITInlines.h: (JSC::JIT::updateTopCallFrame): * jit/JITOpcodes.cpp: (JSC::JIT::emit_op_argument_count): (JSC::JIT::emit_op_get_rest_length): (JSC::JIT::emit_op_get_argument): * jit/SetupVarargsFrame.cpp: (JSC::emitSetupVarargsFrameFastCase): * jit/SpecializedThunkJIT.h: (JSC::SpecializedThunkJIT::SpecializedThunkJIT): * jit/ThunkGenerators.cpp: (JSC::arityFixupGenerator): (JSC::boundFunctionCallGenerator): (JSC::boundThisNoArgsFunctionCallGenerator): Deleted. * jit/ThunkGenerators.h: * jsc.cpp: * llint/LLIntData.cpp: (JSC::LLInt::Data::performAssertions): * llint/LowLevelInterpreter.asm: * llint/LowLevelInterpreter32_64.asm: * llint/LowLevelInterpreter64.asm: * llint/WebAssembly.asm: * runtime/CommonSlowPaths.cpp: (JSC::SLOW_PATH_DECL): * runtime/CommonSlowPaths.h: * runtime/ExecutableBase.h: * runtime/FunctionRareData.cpp: (JSC::FunctionRareData::FunctionRareData): * runtime/FunctionRareData.h: * runtime/IntlCollatorPrototype.cpp: (JSC::IntlCollatorPrototypeGetterCompare): * runtime/IntlDateTimeFormatPrototype.cpp: (JSC::IntlDateTimeFormatPrototypeGetterFormat): * runtime/IntlNumberFormatPrototype.cpp: (JSC::IntlNumberFormatPrototypeGetterFormat): * runtime/Intrinsic.cpp: (JSC::intrinsicName): * runtime/Intrinsic.h: * runtime/JSBoundFunction.cpp: (JSC::boundThisNoArgsFunctionCall): (JSC::boundFunctionCall): (JSC::boundThisNoArgsFunctionConstruct): (JSC::boundFunctionConstruct): (JSC::JSBoundFunction::create): (JSC::JSBoundFunction::JSBoundFunction): (JSC::JSBoundFunction::boundArgsCopy): (JSC::JSBoundFunction::visitChildren): * runtime/JSBoundFunction.h: * runtime/JSFunction.cpp: (JSC::JSFunction::finishCreation): (JSC::JSFunction::name): (JSC::JSFunction::getOwnPropertySlot): (JSC::JSFunction::getOwnNonIndexPropertyNames): (JSC::JSFunction::put): (JSC::JSFunction::deleteProperty): (JSC::JSFunction::defineOwnProperty): (JSC::JSFunction::reifyLength): (JSC::JSFunction::reifyLazyPropertyIfNeeded): (JSC::JSFunction::reifyLazyPropertyForHostOrBuiltinIfNeeded): (JSC::JSFunction::reifyLazyBoundNameIfNeeded): * runtime/JSFunction.h: * runtime/JSFunctionInlines.h: (JSC::JSFunction::areNameAndLengthOriginal): * runtime/JSGlobalObject.cpp: (JSC::makeBoundFunction): (JSC::hasOwnLengthProperty): * runtime/JSObject.h: (JSC::getJSFunction): (JSC::getCallData): Deleted. (JSC::getConstructData): Deleted. * runtime/JSObjectInlines.h: (JSC::getCallData): (JSC::getConstructData): * runtime/VM.cpp: (JSC::thunkGeneratorForIntrinsic): (JSC::VM::getBoundFunction): * runtime/VM.h: * wasm/js/WasmToJS.cpp: (JSC::Wasm::wasmToJS): * wasm/js/WebAssemblyFunction.cpp: (JSC::WebAssemblyFunction::jsCallEntrypointSlow): 2019-12-20 Darin Adler Make JSString values from literals in a single consistent style https://bugs.webkit.org/show_bug.cgi?id=205517 Reviewed by Saam Barati. Some call sites did it like this: jsNontrivialString(vm, "literal"_s) Others did it one of these: jsString(vm, "literal") jsNontrivialString(vm, "literal") Changed all the call sites to do it the first, *slightly* more efficient, way. * runtime/ArrayIteratorPrototype.cpp: (JSC::ArrayIteratorPrototype::finishCreation): * runtime/AsyncFunctionPrototype.cpp: (JSC::AsyncFunctionPrototype::finishCreation): * runtime/AsyncGeneratorFunctionPrototype.cpp: (JSC::AsyncGeneratorFunctionPrototype::finishCreation): * runtime/AsyncGeneratorPrototype.cpp: (JSC::AsyncGeneratorPrototype::finishCreation): * runtime/BigIntPrototype.cpp: (JSC::BigIntPrototype::finishCreation): * runtime/GeneratorFunctionPrototype.cpp: (JSC::GeneratorFunctionPrototype::finishCreation): * runtime/GeneratorPrototype.cpp: (JSC::GeneratorPrototype::finishCreation): * runtime/IntlCollatorPrototype.cpp: (JSC::IntlCollatorPrototype::finishCreation): * runtime/IntlDateTimeFormat.cpp: (JSC::IntlDateTimeFormat::formatToParts): * runtime/IntlDateTimeFormatPrototype.cpp: (JSC::IntlDateTimeFormatPrototype::finishCreation): * runtime/IntlNumberFormat.cpp: (JSC::IntlNumberFormat::formatToParts): * runtime/IntlNumberFormatPrototype.cpp: (JSC::IntlNumberFormatPrototype::finishCreation): * runtime/IntlPluralRulesPrototype.cpp: (JSC::IntlPluralRulesPrototype::finishCreation): * runtime/JSDataViewPrototype.cpp: (JSC::JSDataViewPrototype::finishCreation): * runtime/JSModuleNamespaceObject.cpp: (JSC::JSModuleNamespaceObject::finishCreation): * runtime/JSONObject.cpp: (JSC::JSONObject::finishCreation): * runtime/JSPromisePrototype.cpp: (JSC::JSPromisePrototype::finishCreation): * runtime/JSTypedArrayViewPrototype.cpp: (JSC::typedArrayViewProtoGetterFuncToStringTag): * runtime/MapIteratorPrototype.cpp: (JSC::MapIteratorPrototype::finishCreation): * runtime/MapPrototype.cpp: (JSC::MapPrototype::finishCreation): * runtime/MathObject.cpp: (JSC::MathObject::finishCreation): * runtime/RegExpPrototype.cpp: (JSC::regExpProtoGetterSource): * runtime/RegExpStringIteratorPrototype.cpp: (JSC::RegExpStringIteratorPrototype::finishCreation): * runtime/SetIteratorPrototype.cpp: (JSC::SetIteratorPrototype::finishCreation): * runtime/SetPrototype.cpp: (JSC::SetPrototype::finishCreation): * runtime/StringIteratorPrototype.cpp: (JSC::StringIteratorPrototype::finishCreation): * runtime/SymbolPrototype.cpp: (JSC::SymbolPrototype::finishCreation): * runtime/WeakMapPrototype.cpp: (JSC::WeakMapPrototype::finishCreation): * runtime/WeakObjectRefPrototype.cpp: (JSC::WeakObjectRefPrototype::finishCreation): * runtime/WeakSetPrototype.cpp: (JSC::WeakSetPrototype::finishCreation): Call jsNontrivialString instead of jsString and use the _s suffix. 2019-12-21 Yusuke Suzuki [JSC] Remove m_globalObject field from JSFunction https://bugs.webkit.org/show_bug.cgi?id=205533 Reviewed by Mark Lam. JSFunction::m_globalObject is used only when it is using NativeExecutable. And when using NativeExecutable, JSCallee::m_scope is always pointing JSGlobalObject. This patch removes JSFunction::m_globalObject field. * dfg/DFGSpeculativeJIT.cpp: (JSC::DFG::SpeculativeJIT::compileNewFunctionCommon): * ftl/FTLAbstractHeapRepository.h: * ftl/FTLLowerDFGToB3.cpp: (JSC::FTL::DFG::LowerDFGToB3::compileNewFunction): * jit/ThunkGenerators.cpp: (JSC::nativeForGenerator): (JSC::boundThisNoArgsFunctionCallGenerator): * llint/LowLevelInterpreter32_64.asm: * llint/LowLevelInterpreter64.asm: * runtime/JSFunction.cpp: (JSC::JSFunction::JSFunction): * runtime/JSFunction.h: (JSC::JSFunction::offsetOfGlobalObject): Deleted. (JSC::JSFunction::globalObject const): Deleted. * runtime/JSFunctionInlines.h: (JSC::JSFunction::JSFunction): 2019-12-20 Ross Kirsling [JSC] Memory usage statistics should be attainable without WebCore https://bugs.webkit.org/show_bug.cgi?id=205366 Reviewed by Keith Miller. * API/JSBase.cpp: (JSGetMemoryUsageStatistics): * API/JSBasePrivate.h: Add a private JSC API exposing the same Heap stats as WebCore's PerformanceLogging::memoryUsageStatistics. 2019-12-19 Saam Barati Don't cache self customs on dictionaries https://bugs.webkit.org/show_bug.cgi?id=205466 Reviewed by Mark Lam. We had a bug where we would cache a custom value/accessor on a self property of a cacheable dictionary object. This turns out to be wrong because the inline cache won't fail (because we won't transition structures) if that property is replaced with something else. We would do the right thing when the custom was on the prototype chain, but when it was a self property, we didn't. The reason customs are different from values/normal accessors is that we dynamically load values/getters/setters from the object itself. For customs, we cache the actual pointer value of the C function. This patch makes it so we don't cache customs on dictionaries. * bytecode/ObjectPropertyConditionSet.cpp: (JSC::prepareChainForCaching): (JSC::preparePrototypeChainForCaching): Deleted. * bytecode/ObjectPropertyConditionSet.h: * jit/Repatch.cpp: (JSC::tryCacheGetBy): (JSC::tryCachePutByID): (JSC::tryCacheInByID): (JSC::tryCacheInstanceOf): * llint/LLIntSlowPaths.cpp: (JSC::LLInt::setupGetByIdPrototypeCache): * runtime/StructureRareData.cpp: (JSC::StructureRareData::setObjectToStringValue): 2019-12-19 Devin Rousso Web Inspector: TypeError: InjectedScriptHost.isPromiseRejectedWithNativeGetterTypeError first argument must be a Promise https://bugs.webkit.org/show_bug.cgi?id=205439 Reviewed by Brian Burg. Before r244312, we noticed that when Web Inspector would preview native getters that return a `Promise`, Web Inspector would prevent `rejectionhandled` events from being fired since it would always add a `.catch(() => {}` to any `Promise` that it was about to instrument in the Console to avoid errors being added to the Console while expanding/collapsing value previews. In order to prevent this, logic was added so that the `.catch(() => {})` was only added if the `Promise` was returned from a native getter, such as from a `PromiseRejectionEvent`. In r244312, we made it such that this logic _required_ the `Promise` to already be rejected, which is unnecessarily restrictive and not always the case nowadays. Instead, just check to see if the result of the `Promise` is a native getter type error. * inspector/JSInjectedScriptHost.cpp: (Inspector::JSInjectedScriptHost::isPromiseRejectedWithNativeGetterTypeError): 2019-12-18 Devin Rousso Web Inspector: Elements: restrict showing paint flashing and compositing borders to the Web Inspector session https://bugs.webkit.org/show_bug.cgi?id=205201 Reviewed by Timothy Hatcher. We often get bugs from users who turn on paint flashing or compositing borders, close Web Inspector, reopen Web Inspector, and are then surprised when the page flashes red or these borders exist all over the page. Given that the dark mode and print styles toggles are limited to the Web Inspector session, we should make these have the same behavior. * inspector/protocol/Page.json: Allow Web Inspector to override the `showDebugBorders` and `showRepaintCounter` settings via the `inspectorOverride` key, rather than setting them manually via a special `Page` command. 2019-12-17 Yusuke Suzuki [JSC] 8Bit JSRopeString can contain 16Bit string in its rope https://bugs.webkit.org/show_bug.cgi?id=205323 Reviewed by Mark Lam. When resolving JSRopeString, it is possible that 8Bit JSRopeString becomes 16Bit resolved JSString. This happens when we attempt to resolve it to produce AtomicStringImpl, and 16Bit version of the resolved content is already in AtomicStringTable. This means that 16Bit flag never changes after resolving JSString, but that of JSRopeString is some sort of hint, which can be changed. This means that 8Bit JSRopeString can include 16Bit JSString, since some of children can be changed from 8Bit JSRopeString to resolved 16Bit JSString. Even in that case, we can still ensure that resolved string can be represented as 8Bit. Let's see the example. A => B + C, 8Bit Rope B => D + E, 8Bit Rope C => 8Bit String And when we convert B to 16Bit String since content of `D + E` is already registered as 16Bit String in AtomicStringTable. A => B + C, 8Bit Rope B => 16Bit String C => 8Bit String When resolving A, creating 8Bit string buffer is totally OK since we know that whole A string can be represented in 8Bit. When copying the content of B into 8Bit buffer, we should ignore upper 8Bit since they must be zero. In this patch, we completely share the implementation of resolveRopeInternalNoSubstring and resolveRopeSlowCase in 8Bit and 16Bit case: we take result buffer CharacterType, but the underlying code must check `is8Bit()` for each fiber. * runtime/JSCJSValue.cpp: (JSC::JSValue::dumpInContextAssumingStructure const): * runtime/JSString.cpp: (JSC::JSRopeString::resolveRopeInternal8 const): (JSC::JSRopeString::resolveRopeInternal16 const): (JSC::JSRopeString::resolveRopeInternalNoSubstring const): (JSC::JSRopeString::resolveRopeWithFunction const): (JSC::JSRopeString::resolveRopeSlowCase const): (JSC::JSRopeString::resolveRopeInternal8NoSubstring const): Deleted. (JSC::JSRopeString::resolveRopeInternal16NoSubstring const): Deleted. (JSC::JSRopeString::resolveRopeSlowCase8 const): Deleted. * runtime/JSString.h: 2019-12-17 Carlos Garcia Campos [GLIB] jsc_context_evaluate_in_object should take the API lock before calling setGlobalScopeExtension https://bugs.webkit.org/show_bug.cgi?id=205331 Reviewed by Žan Doberšek. We are now getting a crash due to an assert because the api lock is not held. * API/glib/JSCContext.cpp: (jsc_context_evaluate_in_object): 2019-12-16 Mark Lam Relanding r253581: Changed jsc shell timeout mechanism to leverage the VMTraps and use CPUTime. https://bugs.webkit.org/show_bug.cgi?id=205279 Reviewed by Saam Barati. This fixes all the timeouts that occur due to CPU time starvation when running JSC tests on a debug build. What this means is that the timeout mechanism may trigger asynchronous OSR exits. If a test requires no OSR exits, that test should requireOption("--usePollingTraps=true") so that the VMTraps will use its polling implementation instead. I've tested this with a full run of the JSC stress tests with a debug build and saw 0 timeouts. I've also tested it with a contrived tests that loops forever, and saw the expected timeout crash. Will look into re-tuning needed timeout value (and other JSC tests timeout cleanup) in https://bugs.webkit.org/show_bug.cgi?id=205298. Update: in the previously landed patch, I did a last minute sort of the cases Int the switch statement in VMTraps::handleTraps() before posting my patch. This is incorrect to do since one of the cases need to fall through to another case. This patch undoes the sorting to the order I originally had the cases in during development and testing. * interpreter/Interpreter.cpp: (JSC::Interpreter::executeProgram): (JSC::Interpreter::executeCall): (JSC::Interpreter::executeConstruct): (JSC::Interpreter::execute): (JSC::Interpreter::executeModuleProgram): * interpreter/InterpreterInlines.h: (JSC::Interpreter::execute): * jsc.cpp: (startTimeoutTimer): (timeoutCheckCallback): (initializeTimeoutIfNeeded): (startTimeoutThreadIfNeeded): (runJSC): (jscmain): * runtime/JSCConfig.h: * runtime/VM.h: (JSC::VM::notifyNeedShellTimeoutCheck): * runtime/VMTraps.cpp: (JSC::VMTraps::handleTraps): * runtime/VMTraps.h: (JSC::VMTraps::Mask::Mask): (JSC::VMTraps::Mask::allEventTypes): (JSC::VMTraps::Mask::init): (JSC::VMTraps::interruptingTraps): * tools/VMInspector.cpp: (JSC::VMInspector::forEachVM): * tools/VMInspector.h: 2019-12-16 Mark Lam Rolling out: r253581 is failing tests on a release build. https://bugs.webkit.org/show_bug.cgi?id=205279 Not reviewed. * interpreter/Interpreter.cpp: (JSC::Interpreter::executeProgram): (JSC::Interpreter::executeCall): (JSC::Interpreter::executeConstruct): (JSC::Interpreter::execute): (JSC::Interpreter::executeModuleProgram): * interpreter/InterpreterInlines.h: (JSC::Interpreter::execute): * jsc.cpp: (startTimeoutThreadIfNeeded): (runJSC): (jscmain): (startTimeoutTimer): Deleted. (timeoutCheckCallback): Deleted. (initializeTimeoutIfNeeded): Deleted. * runtime/JSCConfig.h: * runtime/VM.h: (JSC::VM::notifyNeedDebuggerBreak): (JSC::VM::notifyNeedShellTimeoutCheck): Deleted. * runtime/VMTraps.cpp: (JSC::VMTraps::handleTraps): * runtime/VMTraps.h: (JSC::VMTraps::Mask::Mask): (JSC::VMTraps::Mask::allEventTypes): (JSC::VMTraps::Mask::init): (JSC::VMTraps::interruptingTraps): Deleted. * tools/VMInspector.cpp: (JSC::VMInspector::forEachVM): Deleted. * tools/VMInspector.h: 2019-12-16 Yusuke Suzuki ASSERTION FAILED: length <= maximumLength in js-fixed-array-out-of-memory.js https://bugs.webkit.org/show_bug.cgi?id=205259 Reviewed by Mark Lam. JSImmutableButterfly has moderate size limit on its length, while JSFixedArray does not. We should check this maximumLength when creating it in Spread. And if it exceeds, we should throw OOM error. * dfg/DFGSpeculativeJIT.cpp: (JSC::DFG::SpeculativeJIT::compileSpread): * ftl/FTLLowerDFGToB3.cpp: (JSC::FTL::DFG::LowerDFGToB3::compileSpread): * runtime/ArrayConventions.h: * runtime/IndexingHeader.h: * runtime/JSImmutableButterfly.h: (JSC::JSImmutableButterfly::tryCreate): (JSC::JSImmutableButterfly::allocationSize): 2019-12-16 Yusuke Suzuki [JSC] Put non-dynamic scope cells in IsoSubspace https://bugs.webkit.org/show_bug.cgi?id=205311 Reviewed by Mark Lam. Put non-dynamic scope cells in IsoSubspace. - JSWithScope - StrictEvalActivation * runtime/JSScope.h: (JSC::JSScope::subspaceFor): * runtime/JSSymbolTableObject.h: * runtime/JSWithScope.h: * runtime/StrictEvalActivation.h: * runtime/VM.cpp: * runtime/VM.h: 2019-12-16 Yusuke Suzuki [JSC] Put DebuggerScope in IsoSubspace https://bugs.webkit.org/show_bug.cgi?id=205303 Reviewed by Mark Lam. Put DebuggerScope in IsoSubspace, and refine empty `subspaceFor` implementations. * bytecode/CodeBlock.h: (JSC::CodeBlock::subspaceFor): * bytecode/UnlinkedCodeBlock.h: (JSC::UnlinkedCodeBlock::subspaceFor): * debugger/DebuggerScope.h: * runtime/AbstractModuleRecord.h: (JSC::AbstractModuleRecord::subspaceFor): * runtime/JSArrayBufferView.h: (JSC::JSArrayBufferView::subspaceFor): * runtime/JSInternalFieldObjectImpl.h: (JSC::JSInternalFieldObjectImpl::subspaceFor): * runtime/JSWrapperObject.h: (JSC::JSWrapperObject::subspaceFor): * runtime/VM.cpp: * runtime/VM.h: 2019-12-16 Yusuke Suzuki [JSC] Move JSCell::subspaceFor to JSObject::subspaceFor, removing destructibleCellSpace https://bugs.webkit.org/show_bug.cgi?id=205300 Reviewed by Mark Lam. All non-JSObject JSCells have their own IsoSubspace / CompleteSubspace. We remove JSCell::subspaceFor function, and move it to JSObject::subspaceFor. And we remove destructibleCellSpace since nobody uses it. * runtime/JSCell.h: * runtime/JSCellInlines.h: (JSC::JSCell::subspaceFor): Deleted. * runtime/JSObject.h: * runtime/JSObjectInlines.h: (JSC::JSObject::subspaceFor): * runtime/VM.cpp: (JSC::VM::VM): * runtime/VM.h: 2019-12-16 Mark Lam Changed jsc shell timeout mechanism to leverage the VMTraps and use CPUTime. https://bugs.webkit.org/show_bug.cgi?id=205279 Reviewed by Saam Barati. This fixes all the timeouts that occur due to CPU time starvation when running JSC tests on a debug build. What this means is that the timeout mechanism may trigger asynchronous OSR exits. If a test requires no OSR exits, that test should requireOption("--usePollingTraps=true") so that the VMTraps will use its polling implementation instead. I've tested this with a full run of the JSC stress tests with a debug build and saw 0 timeouts. I've also tested it with a contrived tests that loops forever, and saw the expected timeout crash. Will look into re-tuning needed timeout value (and other JSC tests timeout cleanup) in https://bugs.webkit.org/show_bug.cgi?id=205298. * interpreter/Interpreter.cpp: (JSC::Interpreter::executeProgram): (JSC::Interpreter::executeCall): (JSC::Interpreter::executeConstruct): (JSC::Interpreter::execute): (JSC::Interpreter::executeModuleProgram): * interpreter/InterpreterInlines.h: (JSC::Interpreter::execute): * jsc.cpp: (timeoutCheckCallback): (initializeTimeoutIfNeeded): (startTimeoutThreadIfNeeded): (runJSC): (jscmain): * runtime/JSCConfig.h: * runtime/VM.h: (JSC::VM::notifyNeedShellTimeoutCheck): * runtime/VMTraps.cpp: (JSC::VMTraps::handleTraps): * runtime/VMTraps.h: (JSC::VMTraps::Mask::Mask): (JSC::VMTraps::Mask::allEventTypes): (JSC::VMTraps::Mask::init): (JSC::VMTraps::interruptingTraps): * tools/VMInspector.cpp: (JSC::VMInspector::forEachVM): * tools/VMInspector.h: 2019-12-16 Yusuke Suzuki [JSC] Remove ArrayBufferNeuteringWatchpointSet https://bugs.webkit.org/show_bug.cgi?id=205194 Reviewed by Saam Barati. This patch removes ArrayBufferNeuteringWatchpointSet, and instead putting InlineWatchpointSet directly into ArrayBuffer, since this is much simpler. The main reason why we are using ArrayBufferNeuteringWatchpointSet is not to increase sizeof(ArrayBuffer). But this complicates the implementation. So, not to increase sizeof(ArrayBuffer), we use PackedRefPtr in ArrayBuffer, which is RefPtr while the pointer is packed. This gives us 8 bytes which is suitable for placing InlineWatchpointSet without increasing sizeof(ArrayBuffer). We also convert Function<> in ArrayBuffer to PackedRefPtr>, and share Gigacage::free destructor by multiple ArrayBuffer. This is memory efficient since this is the common case, and we can pack this field easily. * API/JSTypedArray.cpp: (JSObjectMakeTypedArrayWithBytesNoCopy): (JSObjectMakeArrayBufferWithBytesNoCopy): * JavaScriptCore.xcodeproj/project.pbxproj: * Sources.txt: * dfg/DFGDesiredWatchpoints.cpp: (JSC::DFG::ArrayBufferViewWatchpointAdaptor::add): * dfg/DFGGraph.cpp: (JSC::DFG::Graph::tryGetFoldableView): * runtime/ArrayBuffer.cpp: (JSC::ArrayBuffer::primitiveGigacageDestructor): (JSC::SharedArrayBufferContents::~SharedArrayBufferContents): (JSC::ArrayBufferContents::destroy): (JSC::ArrayBufferContents::reset): (JSC::ArrayBufferContents::tryAllocate): (JSC::ArrayBufferContents::makeShared): (JSC::ArrayBufferContents::shareWith): (JSC::ArrayBuffer::createAdopted): (JSC::ArrayBuffer::transferTo): (JSC::ArrayBuffer::neuter): (JSC::ArrayBuffer::notifyIncommingReferencesOfTransfer): * runtime/ArrayBuffer.h: (JSC::ArrayBuffer::neuteringWatchpointSet): * runtime/ArrayBufferNeuteringWatchpointSet.cpp: Removed. * runtime/FileBasedFuzzerAgent.cpp: (JSC::FileBasedFuzzerAgent::getPredictionInternal): * runtime/FileBasedFuzzerAgentBase.cpp: (JSC::FileBasedFuzzerAgentBase::createLookupKey): * runtime/PredictionFileCreatingFuzzerAgent.cpp: (JSC::PredictionFileCreatingFuzzerAgent::getPredictionInternal): * runtime/VM.cpp: (JSC::VM::VM): * runtime/VM.h: * wasm/js/JSWebAssemblyMemory.cpp: (JSC::JSWebAssemblyMemory::buffer): 2019-12-14 Adrian Perez de Castro [GTK][WPE] Fix various non-unified build issues introduced since r251698 https://bugs.webkit.org/show_bug.cgi?id=204891 Reviewed by Alex Christensen. * API/JSCallbackConstructor.h: Add missing inclusion of JSObject.h * bytecompiler/BytecodeGeneratorBaseInlines.h: Add missing "#pragma once", which caused build breakage when the same unified source would result in multiple inclusions of the header. * bytecompiler/NodesCodegen.cpp: Add missing inclusion of BytecodeGeneratorBaseInlines.h * dfg/DFGDesiredIdentifiers.h: Add missing inclusion of Identifier.h * heap/IsoSubspacePerVM.cpp: Add missing inclusion of MarkedSpaceInlines.h * jit/GCAwareJITStubRoutine.h: Add missing forward declaration for CallLinkInfo. * runtime/PredictionFileCreatingFuzzerAgent.cpp: Add missing inclusion of wtf/DataLog.h * runtime/ScopedArgumentsTable.h: Add missing inclusion of VM.h * wasm/WasmCallee.cpp: Add missing inclusion of WasmCallingConvention.h * wasm/WasmLLIntTierUpCounter.h: Add missing inclusion of InstructionStream.h * wasm/WasmSlowPaths.cpp: Add missing inclusion of WasmSignatureInlines.h 2019-12-13 Yusuke Suzuki [JSC] Remove JSFixedArray, and use JSImmutableButterfly instead https://bugs.webkit.org/show_bug.cgi?id=204402 Reviewed by Mark Lam. This patch removes JSFixedArray, and use JSImmutableButterfly instead. JSFixedArray can be replaced by JSImmutableButterfly with Contiguous shape. And further, we can create an array from JSImmutableButterfly generated by Spread node in NewArrayBufferWithSpread. Currently, we are always creating contiguous JSImmutableButterfly from Spread. If it takes contiguous CoW array, we can reuse JSImmutableButterfly of the input. But if it is CoW and not contiguous shape (like, CopyOnWriteArrayWithInt32), we create a JSImmutableButterfly and copy it to this new butterfly. We can extend it to accept non-contiguous JSImmutableButterfly in the future. * JavaScriptCore.xcodeproj/project.pbxproj: * Sources.txt: * bytecompiler/BytecodeGenerator.cpp: * dfg/DFGAbstractInterpreterInlines.h: (JSC::DFG::AbstractInterpreter::executeEffects): * dfg/DFGByteCodeParser.cpp: * dfg/DFGClobberize.h: (JSC::DFG::clobberize): * dfg/DFGConstantFoldingPhase.cpp: (JSC::DFG::ConstantFoldingPhase::foldConstants): * dfg/DFGOperations.cpp: * dfg/DFGOperations.h: * dfg/DFGSpeculativeJIT.cpp: (JSC::DFG::SpeculativeJIT::compileSpread): (JSC::DFG::SpeculativeJIT::compileNewArrayWithSpread): (JSC::DFG::SpeculativeJIT::compileObjectKeys): * ftl/FTLAbstractHeapRepository.h: * ftl/FTLLowerDFGToB3.cpp: (JSC::FTL::DFG::LowerDFGToB3::compileNewArrayWithSpread): (JSC::FTL::DFG::LowerDFGToB3::compileSpread): (JSC::FTL::DFG::LowerDFGToB3::toButterfly): * ftl/FTLOperations.cpp: (JSC::FTL::operationMaterializeObjectInOSR): * interpreter/Interpreter.cpp: (JSC::sizeOfVarargs): (JSC::loadVarargs): * runtime/CommonSlowPaths.cpp: (JSC::SLOW_PATH_DECL): * runtime/JSCast.h: * runtime/JSFixedArray.cpp: Removed. * runtime/JSFixedArray.h: Removed. * runtime/JSImmutableButterfly.h: (JSC::JSImmutableButterfly::createFromArray): (JSC::JSImmutableButterfly::offsetOfPublicLength): (JSC::JSImmutableButterfly::offsetOfVectorLength): * runtime/JSType.cpp: (WTF::printInternal): * runtime/JSType.h: * runtime/VM.cpp: (JSC::VM::VM): * runtime/VM.h: 2019-12-13 Saam Barati Structure should have a bloom filter of seen identifiers https://bugs.webkit.org/show_bug.cgi?id=205182 Reviewed by Yusuke Suzuki and Tadeu Zagallo. This patch adds a bloom filter of seen identifiers to Structure. This usually allows us to quickly determine if a Structure *has not* seen a particular property. Based on some logging I added in JetStream2 and Speedometer2, 70% of calls to Structure::get result in us returning invalidOffset (e.g, the property does not exist). This patch allows that path to be even faster. This bloom filter is just modeling what goes inside Structure's property table. For that reason, we don't need to consider things inside the static property table. We reason about the static property table inside JSObject's property lookup. This patch appears to be a 0.5% progression on Speedometer2. * runtime/Structure.cpp: (JSC::Structure::Structure): * runtime/Structure.h: * runtime/StructureInlines.h: (JSC::Structure::get): (JSC::Structure::add): 2019-12-13 Mark Lam Fix bad exception assertion in ExceptionHelpers.cpp's createError(). https://bugs.webkit.org/show_bug.cgi?id=205230 Reviewed by Yusuke Suzuki. The code in createError() was doing the following: String valueDescription = errorDescriptionForValue(globalObject, value); EXCEPTION_ASSERT(scope.exception() || !!valueDescription); if (!valueDescription) { scope.clearException(); return createOutOfMemoryError(globalObject); } If errorDescriptionForValue() throws an exception, then we expect the valueDescription string to be null so that we can throw an OutOfMemoryError. However, errorDescriptionForValue() can detect an imminent overflow in String length and just return a null string without throwing an exception which fails the above assertion. The fix is to simply do an explicit exception check in addition to the null string check and remove the assertion. * runtime/ExceptionHelpers.cpp: (JSC::createError): 2019-12-13 Saam Barati Add a Heap::finalize function that takes WTF::Function https://bugs.webkit.org/show_bug.cgi?id=205211 Reviewed by Geoffrey Garen. * heap/Heap.cpp: (JSC::Heap::addFinalizer): (JSC::Heap::FinalizerOwner::finalize): * heap/Heap.h: 2019-12-13 Jim Mason [GTK] WebKitGTK build hangs on g-ir-scanner https://bugs.webkit.org/show_bug.cgi?id=204715 This patch fixes the static initialization order problem introduced by Bug 204503. The patch replaces the static data members with statics that are constructed only upon first access (i.e., the 'construct on first use' idiom). Reviewed by Carlos Garcia Campos. * inspector/remote/RemoteInspector.h: * inspector/remote/glib/RemoteInspectorGlib.cpp: (Inspector::RemoteInspector::start): (Inspector::RemoteInspector::messageHandlers): * inspector/remote/glib/RemoteInspectorServer.cpp: (Inspector::RemoteInspectorServer::messageHandlers): (Inspector::RemoteInspectorServer::incomingConnectionCallback): * inspector/remote/glib/RemoteInspectorServer.h: 2019-12-12 Yusuke Suzuki [JSC] Puts fixed-sized cells into IsoSubspace more https://bugs.webkit.org/show_bug.cgi?id=205183 Reviewed by Saam Barati. This patch puts many of fixed-sized cells into IsoSubspace. - Exception - JSPropertyNameEnumerator - RegExp - StructureChain - MapBucket - JSMapIterator - ScopedArgumentsTable - SetBucket - JSSetIterator - JSScriptFetchParameters - JSScriptFetcher - JSSourceCode - JSTemplateObjectDescriptor * runtime/Exception.h: * runtime/HashMapImpl.h: (JSC::HashMapBucket::selectStructure): Deleted. (JSC::HashMapBucket::info): Deleted. (JSC::HashMapBucket::createStructure): Deleted. (JSC::HashMapBucket::create): Deleted. (JSC::HashMapBucket::createSentinel): Deleted. (JSC::HashMapBucket::HashMapBucket): Deleted. (JSC::HashMapBucket::setNext): Deleted. (JSC::HashMapBucket::setPrev): Deleted. (JSC::HashMapBucket::setKey): Deleted. (JSC::HashMapBucket::setValue): Deleted. (JSC::HashMapBucket::key const): Deleted. (JSC::HashMapBucket::value const): Deleted. (JSC::HashMapBucket::next const): Deleted. (JSC::HashMapBucket::prev const): Deleted. (JSC::HashMapBucket::deleted const): Deleted. (JSC::HashMapBucket::makeDeleted): Deleted. (JSC::HashMapBucket::offsetOfKey): Deleted. (JSC::HashMapBucket::offsetOfValue): Deleted. (JSC::HashMapBucket::offsetOfNext): Deleted. (JSC::HashMapBucket::extractValue): Deleted. * runtime/JSMapIterator.h: * runtime/JSPropertyNameEnumerator.h: * runtime/JSScriptFetchParameters.h: * runtime/JSScriptFetcher.h: * runtime/JSSetIterator.h: * runtime/JSSourceCode.h: * runtime/JSTemplateObjectDescriptor.h: * runtime/RegExp.h: * runtime/ScopedArgumentsTable.h: * runtime/StructureChain.h: * runtime/VM.cpp: (JSC::VM::VM): * runtime/VM.h: 2019-12-12 Yusuke Suzuki [JSC] Wasm init-expr should reject mutable globals https://bugs.webkit.org/show_bug.cgi?id=205191 Reviewed by Mark Lam. For init-expr, expr must be a constant[1]. Constant expr, which is defined in Wasm spec, requires that, if the expr is GetGlobal, global's mutability is immutable. Previously our imported globals are always immutable, so we are using ASSERT instead of checking mutability in WasmSectionParser. But now, we have ability to import mutable globals. We should check mutability when parsing init-expr. We do not have this check previously, which leads to spec-correctness issue that we can initialize globals/elements/data-segments with snapshot values of mutable globals (this is safe, but this is not spec-compliant, and it is not reasonable semantics), while such an attempt should be rejected when compiling Wasm modules. This patch adds necessary checks. [1]: https://webassembly.github.io/spec/core/valid/instructions.html#valid-constant * wasm/WasmSectionParser.cpp: (JSC::Wasm::SectionParser::parseInitExpr): 2019-12-12 Mark Lam Fix missing exception in JSValue::toWTFStringSlowCase(). https://bugs.webkit.org/show_bug.cgi?id=205176 Reviewed by Yusuke Suzuki. Also fix all the new exception check failures that fall out of change. Also replaced some ASSERTs with EXCEPTION_ASSERT so that we can run the exception check validation on a release build. * dfg/DFGOperations.cpp: * jsc.cpp: (dumpException): * runtime/ArrayPrototype.cpp: (JSC::arrayProtoFuncPush): * runtime/ExceptionHelpers.cpp: (JSC::createError): * runtime/JSCJSValue.cpp: (JSC::JSValue::toWTFStringSlowCase const): 2019-12-12 Yusuke Suzuki [JSC] Lock-down JSGlobalObject and derived classes in IsoSubspace https://bugs.webkit.org/show_bug.cgi?id=205108 Reviewed by Mark Lam. This patch puts JSGlobalLexicalEnvironment and JSGlobalObject (and its derived classes including JSDOMWindow etc.) in IsoSubspace. We were using `addFinalizer` feature to call destructors for these objects since they do not inherit JSDestructibleObject. But now each derived classes has its IsoSubspace. So we do not need to use finalizer feature: just setting specialized HeapCellType works. * API/JSAPIGlobalObject.h: * API/JSCallbackObject.cpp: * API/glib/JSAPIWrapperGlobalObject.cpp: * JavaScriptCore.xcodeproj/project.pbxproj: * bytecode/SuperSampler.h: * heap/CellAttributes.h: * heap/FreeList.h: * heap/IsoHeapCellType.cpp: (JSC::IsoHeapCellType::IsoHeapCellType): * heap/IsoHeapCellType.h: * heap/MarkedBlock.cpp: (JSC::MarkedBlock::Handle::setIsFreeListed): Deleted. * heap/MarkedBlockInlines.h: (JSC::MarkedBlock::Handle::setIsFreeListed): * jsc.cpp: (GlobalObject::create): Deleted. (GlobalObject::createStructure): Deleted. (GlobalObject::javaScriptRuntimeFlags): Deleted. (GlobalObject::finishCreation): Deleted. (GlobalObject::addFunction): Deleted. * runtime/JSGlobalLexicalEnvironment.h: * runtime/JSGlobalObject.h: (JSC::JSGlobalObject::subspaceFor): * runtime/JSSegmentedVariableObject.cpp: (JSC::JSSegmentedVariableObject::JSSegmentedVariableObject): (JSC::JSSegmentedVariableObject::finishCreation): (JSC::JSSegmentedVariableObject::destroy): Deleted. * runtime/JSSegmentedVariableObject.h: (JSC::JSSegmentedVariableObject::subspaceFor): (JSC::JSSegmentedVariableObject::classInfo const): Deleted. * runtime/VM.cpp: (JSC::VM::VM): * runtime/VM.h: * testRegExp.cpp: (GlobalObject::create): Deleted. (GlobalObject::createStructure): Deleted. (GlobalObject::finishCreation): Deleted. 2019-12-12 Mark Lam Fix missing exception check in JSON Stringifier's gap function. https://bugs.webkit.org/show_bug.cgi?id=205171 Reviewed by Yusuke Suzuki. * runtime/JSONObject.cpp: (JSC::gap): 2019-12-12 Mark Lam DFG and FTL expects String.prototype to not qualify for StringObjectUse. https://bugs.webkit.org/show_bug.cgi?id=205147 Reviewed by Saam Barati. Currently, String.prototype's JSType is StringObjectType. However, in the compiler, there are a few places that expect that the String.prototype value to not qualify as StringObjectUse. These places are: 1. SpeculatedType.cpp's speculationFromClassInfo() will speculate SpecObjectOther for the StringPrototype object. 2. DFGFixupPhase.cpp's addCheckStructureForOriginalStringObjectUse() only emits a CheckStructure against globalObject->stringObjectStructure(). It does not check against String.prototype's structure. To resolve this discrepancy, we can either do: a. change String.prototype's JSType to something else. b. fix the places in the compiler to accept String.prototype as StringObjectUse. (a) is trivial and cheap to do. (b) is doable but will result in less optimal compiled code. Since passing String.prototype as a StringObject is expected to be a rare thing in JS code, it's not worth incurring the cost for (b). In this patch, we apply (a) to fix the discrepancy. Also added a specialization case to FOR_EACH_JS_DYNAMIC_CAST_JS_TYPE_OVERLOAD for jsDynamicCast for completeness. * runtime/JSCast.h: * runtime/JSType.cpp: (WTF::printInternal): * runtime/JSType.h: * runtime/StringPrototype.h: 2019-12-12 Yusuke Suzuki [JSC] IsoHeapCellType should have destroy function member instead of specializing template function https://bugs.webkit.org/show_bug.cgi?id=205152 Reviewed by Saam Barati. We were specializing MarkedBlock::Handle::specializedSweep in 5 different ways for each IsoSubspace-ed cell. This bloats binary. Instead of specializing it with CellType, we specialize it with one functor, which invokes function pointer held by IsoHeapCellType. This requires one indirect function call per cell. But this is OK since, 1. We were using JSDestructibleObject's cell->classInfo->methodTable.destroy function call to dispatch destruction, before IsoSubspace replaces them with IsoHeapCellType-based destruction. Compared to that, the new one is still saving one pointer chasing basically (classInfo dereference, we assume cell deference is no cost since it will be done anyway). 2. We still keep JSString's destroy function inlining by using IsoInlinedHeapCellType. This is important since it is critical to performance and we had JSStringHeapCellType before we replaced it with IsoHeapCellType. But IsoInlinedHeapCellType specialization is for only one class so generated binary size is the same to the old code using JSStringHeapCellType. This saves 480KB binary-size in JavaScriptCore. And more importantly, after this patch, adding IsoSubspace will not bloat code, so we can simply put things into IsoSubspace. This patch also removes `using namespace JSC;` in global code in JavaScriptCore except for API codes, since it starts causing build failure due to unified builds: API defines JSType enum in a global scope, which is different from our JSC::JSType. If we do `using namespace JSC;` in a global scope, it can lead to ambiguity of looking up. * API/JSHeapFinalizerPrivate.cpp: (JSContextGroupAddHeapFinalizer): (JSContextGroupRemoveHeapFinalizer): * API/JSHeapFinalizerPrivate.h: * JavaScriptCore.xcodeproj/project.pbxproj: * Sources.txt: * assembler/AbstractMacroAssembler.cpp: * bindings/ScriptFunctionCall.cpp: * bindings/ScriptObject.cpp: * bindings/ScriptValue.cpp: * heap/IsoHeapCellType.cpp: Copied from Source/JavaScriptCore/assembler/AbstractMacroAssembler.cpp. (JSC::IsoHeapCellType::finishSweep): (JSC::IsoHeapCellType::destroy): * heap/IsoHeapCellType.h: * heap/IsoInlinedHeapCellType.h: Copied from Source/JavaScriptCore/heap/IsoHeapCellType.h. * heap/MutatorState.cpp: * heap/Synchronousness.cpp: * inspector/InjectedScriptHost.cpp: * inspector/InjectedScriptManager.cpp: * inspector/JSGlobalObjectConsoleClient.cpp: * inspector/JSGlobalObjectInspectorController.cpp: * inspector/JSGlobalObjectScriptDebugServer.cpp: * inspector/JSInjectedScriptHost.cpp: * inspector/JSInjectedScriptHostPrototype.cpp: * inspector/JSJavaScriptCallFrame.cpp: * inspector/JSJavaScriptCallFramePrototype.cpp: * inspector/JavaScriptCallFrame.cpp: * inspector/PerGlobalObjectWrapperWorld.cpp: * inspector/ScriptCallStackFactory.cpp: * inspector/ScriptDebugServer.cpp: * inspector/agents/InspectorHeapAgent.cpp: * inspector/agents/InspectorScriptProfilerAgent.cpp: * inspector/agents/JSGlobalObjectAuditAgent.cpp: * inspector/agents/JSGlobalObjectDebuggerAgent.cpp: * inspector/agents/JSGlobalObjectRuntimeAgent.cpp: * runtime/VM.cpp: (JSC::VM::VM): * runtime/VM.h: 2019-12-11 Yusuke Suzuki [JSC] Put all API related JS cells into IsoSubspace https://bugs.webkit.org/show_bug.cgi?id=205097 Reviewed by Mark Lam. This patch puts API related JS cells into IsoSubspace. * API/JSAPIGlobalObject.h: (JSC::JSAPIGlobalObject::create): Deleted. (JSC::JSAPIGlobalObject::createStructure): Deleted. (JSC::JSAPIGlobalObject::JSAPIGlobalObject): Deleted. * API/JSAPIValueWrapper.h: * API/JSAPIWrapperObject.h: (JSC::JSAPIWrapperObject::subspaceFor): * API/JSAPIWrapperObject.mm: (JSC::JSCallbackObject::subspaceForImpl): * API/JSCallbackConstructor.cpp: (JSC::JSCallbackConstructor::JSCallbackConstructor): * API/JSCallbackConstructor.h: * API/JSCallbackObject.cpp: (JSC::JSCallbackObject::createStructure): (JSC::JSCallbackObject::subspaceForImpl): (JSC::JSCallbackObject::subspaceForImpl): (JSC::JSCallbackObject::createStructure): Deleted. * API/JSCallbackObject.h: * API/JSCallbackObjectFunctions.h: (JSC::JSCallbackObject::init): * API/JSClassRef.cpp: (OpaqueJSClass::prototype): * API/JSObjectRef.cpp: (JSObjectMake): (JSObjectGetPrivate): (JSObjectSetPrivate): (JSObjectGetPrivateProperty): (JSObjectSetPrivateProperty): (JSObjectDeletePrivateProperty): * API/JSValueRef.cpp: (JSValueIsObjectOfClass): * API/JSWeakObjectMapRefPrivate.cpp: * API/glib/JSAPIWrapperGlobalObject.cpp: (JSC::JSCallbackObject::subspaceForImpl): * API/glib/JSAPIWrapperGlobalObject.h: (JSC::JSAPIWrapperGlobalObject::subspaceFor): * API/glib/JSAPIWrapperObjectGLib.cpp: (JSC::JSCallbackObject::subspaceForImpl): * runtime/JSGlobalObject.cpp: (JSC::JSGlobalObject::init): * runtime/JSSegmentedVariableObject.cpp: (JSC::JSSegmentedVariableObject::finishCreation): * runtime/JSSegmentedVariableObject.h: (JSC::JSSegmentedVariableObject::classInfo const): * runtime/VM.cpp: (JSC::VM::VM): * runtime/VM.h: 2019-12-10 Saam Barati BytecodeDumper should print out of line jump targets https://bugs.webkit.org/show_bug.cgi?id=205091 Reviewed by Tadeu Zagallo and Yusuke Suzuki. * bytecode/BytecodeDumper.cpp: (JSC::BytecodeDumperBase::dumpValue): * bytecode/CodeBlock.h: (JSC::CodeBlock::outOfLineJumpOffset): 2019-12-10 Yusuke Suzuki [JSC] Adhocly created CallLinkInfo in GetterSetterAccess should be owned by GCAwareJITStubRoutine https://bugs.webkit.org/show_bug.cgi?id=204876 Reviewed by Saam Barati. When emitting GetterSetterAccessCase code in IC, we dynamically create CallLinkInfo which is owned by GetterSetterAccessCase, and we use this pointer for GetterSetter calls (like, operationLinkCall etc.). The problem is that IC code is not destroyed so long as it is live in the stack. For example, GetterSetterAccessCase might be destroyed when the StructureStubInfo is reset, while executing the emitted code. So, the code is still pointing already-destroyed CallLinkInfo. In this patch, CallLinkInfo used for GetterSetterAccessCase code is owned by emitted code, which means, owned by MarkingGCAwareJITStubRoutine. So it is kept so long as the code is live. We use Bag to create a CallLinkInfo, and MarkingGCAwareJITStubRoutine owns it. The important question is whether we should call CallLinkInfo::visitWeak when the associated GetterSetterAccessCase is already destroyed. We do not need to call it since (1) it is just clearing CallLinkInfo, and (2) this information will not be used by anyone since associated GetterSetterAccessCase is already destroyed. * bytecode/AccessCase.cpp: (JSC::AccessCase::generateImpl): * bytecode/GetterSetterAccessCase.h: (JSC::GetterSetterAccessCase::callLinkInfo const): * bytecode/PolymorphicAccess.cpp: (JSC::PolymorphicAccess::regenerate): * bytecode/PolymorphicAccess.h: * jit/AssemblyHelpers.cpp: (JSC::AssemblyHelpers::emitDumbVirtualCall): * jit/GCAwareJITStubRoutine.cpp: (JSC::MarkingGCAwareJITStubRoutine::MarkingGCAwareJITStubRoutine): (JSC::GCAwareJITStubRoutineWithExceptionHandler::GCAwareJITStubRoutineWithExceptionHandler): (JSC::createJITStubRoutine): * jit/GCAwareJITStubRoutine.h: (JSC::GCAwareJITStubRoutine::create): (JSC::createJITStubRoutine): Deleted. * jit/Repatch.cpp: (JSC::linkSlowFor): (JSC::linkVirtualFor): 2019-12-10 Mark Lam Worklist::deleteCancelledPlansForVM() should not assume that a cancelled plan is ready for deletion. https://bugs.webkit.org/show_bug.cgi?id=205086 Reviewed by Saam Barati. Consider this race scenario: 1. The DFG thread finds a plan and started compiling, and it's holding a ref to the plan while it's compiling. 2. The GC thread discovers that we no longer need the plan and cancels it. 3. After the plan is cancelled but while the DFG thread is still compiling, the mutator thread calls Worklist::deleteCancelledPlansForVM(). Worklist::deleteCancelledPlansForVM() was assuming that by the time it is called, Worklist::m_cancelledPlansPendingDestruction will contain the last ref to the cancelled plan. However, this is an incorrect assumption, and the assertion there that asserts refCount == 1 will fail. This patch fixes Worklist::deleteCancelledPlansForVM() to append the cancelled plan back into m_cancelledPlansPendingDestruction if its refCount is not 1 (implying that the compiler thread still has a ref to it), and defer deletion of the plan to a subsequent call to deleteCancelledPlansForVM(). This patch also adds a WTFMove to Worklist::removeDeadPlans() when we append the cancelled plan to m_cancelledPlansPendingDestruction there. This saves us one unnecessary ref and deref of the plan. * dfg/DFGWorklist.cpp: (JSC::DFG::Worklist::deleteCancelledPlansForVM): (JSC::DFG::Worklist::removeDeadPlans): 2019-12-10 Saam Barati methodOfGettingAValueProfileFor should return argument value profiles even when node and operandNode are the same origin https://bugs.webkit.org/show_bug.cgi?id=205083 Reviewed by Yusuke Suzuki. Inside methodOfGettingAValueProfileFor, we only grab profiles when the child node and the parent node were from different code origins. This policy doesn't make sense when the child node is the load of an argument value. In that case, we can always just grab the argument profile. We might want to reconsider this policy in general, since it's common for a node to emit a GetLocal to grab its incoming arguments (this is frequently done in the DFG when reloading locals across basic blocks). This fixes an OSR exit compile loop inside Speedometer 2's React-Redux-TodoMVC benchmark. That benchmark would repeatedly exit inside CompareStrictEq by repeatedly speculating Object. That node would run with 95% incoming Objects, and 5% incoming strings, and because we didn't grab the argument value profile during exit, we never updated the profile with the String type information. * dfg/DFGGraph.cpp: (JSC::DFG::Graph::methodOfGettingAValueProfileFor): 2019-12-10 Commit Queue Unreviewed, rolling out r253321. https://bugs.webkit.org/show_bug.cgi?id=205084 1% regression in RAMification (Requested by yusukesuzuki on #webkit). Reverted changeset: "[JSC] Put JSArray in IsoSubspace" https://bugs.webkit.org/show_bug.cgi?id=205049 https://trac.webkit.org/changeset/253321 2019-12-10 Tadeu Zagallo Reduce JSC's binary size https://bugs.webkit.org/show_bug.cgi?id=204549 Reviewed by Saam Barati. The Wasm interpreter landed in r251886 and significantly increased JSC's binary size. To try and offset that, here and some easy fixes that get us ~200kb back: - We were generating 2 instances of dumpBytecode, at 30kb each. I changed the generator to emit a cpp file instead, avoiding the duplication. - We had 3 instances of computeUsesForBytecodeIndex at 11kb each. I kept the work that depended on the template type in the template function and moved the massive switch into computeUsesForBytecodeIndexImpl. I also did the same for computeDefsForBytecodeIndex. - We had 8 instances of emit_compareAndJump(Slow) at 8kb (7kb for Slow) each. I kept the code that extracts the data from the bytecode in the template, but moved the bulk of the function into emit_compareAndJump(Slow)Impl. * CMakeLists.txt: * DerivedSources-output.xcfilelist: * DerivedSources.make: * Sources.txt: * bytecode/BytecodeDumper.cpp: (JSC::BytecodeDumperBase::printLocationAndOp): (JSC::BytecodeDumperBase::dumpValue): * bytecode/BytecodeDumper.h: (JSC::BytecodeDumperBase::~BytecodeDumperBase): (JSC::BytecodeDumperBase::dumpValue): (JSC::BytecodeDumperBase::BytecodeDumperBase): (JSC::BytecodeDumper::BytecodeDumper): * bytecode/BytecodeUseDef.cpp: Copied from Source/JavaScriptCore/bytecode/BytecodeUseDef.h. (JSC::computeUsesForBytecodeIndexImpl): (JSC::computeDefsForBytecodeIndexImpl): * bytecode/BytecodeUseDef.h: (JSC::computeUsesForBytecodeIndex): (JSC::computeDefsForBytecodeIndex): * generator/DSL.rb: * generator/Opcode.rb: * generator/Options.rb: * jit/JIT.h: * jit/JITArithmetic.cpp: (JSC::JIT::emit_compareAndJump): (JSC::JIT::emit_compareAndJumpImpl): (JSC::JIT::emit_compareUnsignedAndJump): (JSC::JIT::emit_compareUnsignedAndJumpImpl): (JSC::JIT::emit_compareUnsigned): (JSC::JIT::emit_compareUnsignedImpl): (JSC::JIT::emit_compareAndJumpSlow): (JSC::JIT::emit_compareAndJumpSlowImpl): 2019-12-10 Yusuke Suzuki [JSC] Put JSArray in IsoSubspace https://bugs.webkit.org/show_bug.cgi?id=205049 Reviewed by Mark Lam. Put JSArray in IsoSubspace. * runtime/ArrayPrototype.h: * runtime/JSArray.h: (JSC::JSArray::subspaceFor): * runtime/VM.cpp: (JSC::VM::VM): * runtime/VM.h: * tools/JSDollarVM.cpp: 2019-12-09 Mark Lam Fix the x86_64 probe so that we can get a full stack trace with libunwind and lldb. https://bugs.webkit.org/show_bug.cgi?id=205050 Reviewed by Michael Saboff. Before this patch, the stack trace from inside a probe function is cut off at ctiMasmProbeTrampoline: (lldb) bt * thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0xbbadbeef) ... frame #4: 0x0000000100824607 JavaScriptCore`WTF::Function::operator(this=0x000000010b88bd00, in=0x00007ffeefbfd400)(JSC::Probe::Context&) const at Function.h:79:35 frame #5: 0x0000000100823996 JavaScriptCore`JSC::stdFunctionCallback(context=0x00007ffeefbfd400) at MacroAssembler.cpp:53:5 frame #6: 0x000000010082701e JavaScriptCore`JSC::Probe::executeProbe(state=0x00007ffeefbfd480) at ProbeContext.cpp:51:5 frame #7: 0x000000010082614b JavaScriptCore`ctiMasmProbeTrampoline + 299 (lldb) After this patch, we'll now get the full stack trace from inside the probe function: (lldb) bt * thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0xbbadbeef) ... frame #4: 0x0000000100826d17 JavaScriptCore`WTF::Function::operator(this=0x0000000106b878f8, in=0x00007ffeefbfd400)(JSC::Probe::Context&) const at Function.h:79:35 frame #5: 0x0000000100826106 JavaScriptCore`JSC::stdFunctionCallback(context=0x00007ffeefbfd400) at MacroAssembler.cpp:53:5 frame #6: 0x000000010082986e JavaScriptCore`JSC::Probe::executeProbe(state=0x00007ffeefbfd480) at ProbeContext.cpp:51:5 frame #7: 0x00000001008289a2 JavaScriptCore`ctiMasmProbeTrampoline + 338 frame #8: 0x0000466db28025be frame #9: 0x0000000100754ffc JavaScriptCore`llint_entry at LowLevelInterpreter.asm:994 frame #10: 0x0000000100738173 JavaScriptCore`vmEntryToJavaScript at LowLevelInterpreter64.asm:307 frame #11: 0x0000000101489307 JavaScriptCore`JSC::JITCode::execute(this=0x0000000106ba1520, vm=0x0000000106d00000, protoCallFrame=0x00007ffeefbfd9b8) at JITCodeInlines.h:38:38 frame #12: 0x0000000101488982 JavaScriptCore`JSC::Interpreter::executeProgram(this=0x0000000106bfd1f8, source=0x00007ffeefbff090, (null)=0x000000010d0e0000, thisObj=0x000000010d0e8020) at Interpreter.cpp:847:51 frame #13: 0x00000001017d1f9c JavaScriptCore`JSC::evaluate(globalObject=0x000000010d0e0000, source=0x00007ffeefbff090, thisValue=JSValue @ 0x00007ffeefbfef60, returnedException=0x00007ffeefbff0b0) at Completion.cpp:146:38 frame #14: 0x000000010005838f jsc`runWithOptions(globalObject=0x000000010d0e0000, options=0x00007ffeefbff620, success=0x00007ffeefbff48b) at jsc.cpp:2670:35 frame #15: 0x000000010002a0da jsc`jscmain(this=0x00007ffeefbff5a0, vm=0x0000000106d00000, globalObject=0x000000010d0e0000, success=0x00007ffeefbff48b)::$_6::operator()(JSC::VM&, GlobalObject*, bool&) const at jsc.cpp:3157:13 frame #16: 0x0000000100006eff jsc`int runJSC(options=0x00007ffeefbff620, isWorker=false, func=0x00007ffeefbff5a0)::$_6 const&) at jsc.cpp:3003:9 frame #17: 0x0000000100005988 jsc`jscmain(argc=10, argv=0x00007ffeefbff6c8) at jsc.cpp:3150:18 frame #18: 0x000000010000575e jsc`main(argc=10, argv=0x00007ffeefbff6c8) at jsc.cpp:2498:15 frame #19: 0x00007fff6cfc4da9 libdyld.dylib`start + 1 frame #20: 0x00007fff6cfc4da9 libdyld.dylib`start + 1 (lldb) The difference is that the x86_64 ctiMasmProbeTrampoline now uses the standard function prologue, and keeps %rbp pointing to trampoline function's semblance of a frame that libunwind can understand while it calls the probe function. * assembler/MacroAssemblerX86Common.cpp: 2019-12-09 Yusuke Suzuki [JSC] Put CustomGetterSetter and DOMAttributeGetterSetter in IsoSubspace https://bugs.webkit.org/show_bug.cgi?id=205044 Reviewed by Sam Weinig. Put CustomGetterSetter and DOMAttributeGetterSetter in IsoSubspace. * runtime/CustomGetterSetter.h: (JSC::CustomGetterSetter::subspaceFor): * runtime/DOMAttributeGetterSetter.h: * runtime/VM.cpp: (JSC::VM::VM): * runtime/VM.h: 2019-12-09 Yusuke Suzuki [JSC] Remove NativeStdFunctionCell https://bugs.webkit.org/show_bug.cgi?id=205045 Reviewed by Sam Weinig. NativeStdFunctionCell is introduced because we were not able to make derived classes of JSFunction destructible. But now we can do that by using IsoSubspace. And we already have IsoSubspace for JSNativeStdFunction. So we do not need to have NativeStdFunctionCell cell. This patch removes it. And making JSNativeStdFunction destructible. * JavaScriptCore.xcodeproj/project.pbxproj: * Sources.txt: * inspector/InjectedScriptBase.cpp: (Inspector::InjectedScriptBase::makeAsyncCall): * runtime/JSNativeStdFunction.cpp: (JSC::JSNativeStdFunction::JSNativeStdFunction): (JSC::JSNativeStdFunction::visitChildren): (JSC::JSNativeStdFunction::finishCreation): (JSC::runStdFunction): (JSC::JSNativeStdFunction::create): * runtime/JSNativeStdFunction.h: * runtime/NativeStdFunctionCell.cpp: Removed. * runtime/NativeStdFunctionCell.h: Removed. * runtime/VM.cpp: (JSC::VM::VM): * runtime/VM.h: 2019-12-09 Tadeu Zagallo [WebAssembly] Remove WasmValidate https://bugs.webkit.org/show_bug.cgi?id=205037 Reviewed by Saam Barati. It's currently only used when JSC_useWasmLLInt is false and it creates an additional instantiation of Wasm::FunctionParser, which adds about 100kb to the binary size. This does not introduce any behavior changes with the default options, but it means that we'll generate bytecode when calling WebAssembly.validate/new WebAssembly.Module even when the WasmLLInt is disabled. * JavaScriptCore.xcodeproj/project.pbxproj: * Sources.txt: * wasm/WasmBBQPlan.cpp: (JSC::Wasm::BBQPlan::didReceiveFunctionData): * wasm/WasmEntryPlan.cpp: * wasm/WasmLLIntPlan.cpp: * wasm/WasmModule.cpp: (JSC::Wasm::makeValidationResult): (JSC::Wasm::makeValidationCallback): (JSC::Wasm::Module::validateSync): (JSC::Wasm::Module::validateAsync): * wasm/WasmModule.h: * wasm/WasmOMGForOSREntryPlan.cpp: (JSC::Wasm::OMGForOSREntryPlan::work): * wasm/WasmOMGPlan.cpp: (JSC::Wasm::OMGPlan::work): * wasm/WasmPlan.cpp: * wasm/WasmValidate.cpp: Removed. * wasm/WasmValidate.h: Removed. 2019-12-09 Tadeu Zagallo REGRESSION(r253140): WebAssembly validation should check for unmatched else before calling addElse/addElseToUnreachable https://bugs.webkit.org/show_bug.cgi?id=205022 Reviewed by Saam Barati. When moving the validation code into the parser in r253140, I missed the validation check of whether an if block was at the top of the control stack before calling addElse/addElseToUnreachable. * wasm/WasmFunctionParser.h: (JSC::Wasm::FunctionParser::parseExpression): (JSC::Wasm::FunctionParser::parseUnreachableExpression): 2019-12-09 Mark Lam GetByIdVariant::dumpInContext() should not ref UniqueStringImpls. https://bugs.webkit.org/show_bug.cgi?id=205023 Reviewed by Saam Barati. This is because GetByIdVariant::dumpInContext() may be called from the compiler thread. GetByIdVariant::dumpInContext() inadvertently invoking the String copy constructor on an Identifier, which in turn, refs the underlying UniqueStringImpl. This results in a race against the mutator to adjust the refCount. The fix is to have GetByIdVariant::dumpInContext() print the underlying StringImpl instead of the Identifier itself. * bytecode/GetByIdVariant.cpp: (JSC::GetByIdVariant::dumpInContext const): 2019-12-08 Yousuke Kimoto [WinCairo] Refine initialization and error handling in RemoteInspectorSocket https://bugs.webkit.org/show_bug.cgi?id=204338 Reviewed by Fujii Hironori. RemoteInspectorSocket socket error handling is not enough, which should be refined to avoid error cases. * inspector/remote/socket/RemoteInspectorSocket.h: Modifed return value checks to hanlde error cases. * inspector/remote/socket/RemoteInspectorSocketEndpoint.cpp: Refined check error handling. (Inspector::RemoteInspectorSocketEndpoint::createListener): * inspector/remote/socket/posix/RemoteInspectorSocketPOSIX.cpp: Ditto (Inspector::Socket::connect): (Inspector::Socket::listen): (Inspector::Socket::setup): (Inspector::Socket::isListening): (Inspector::Socket::getPort): (Inspector::Socket::preparePolling): * inspector/remote/socket/win/RemoteInspectorSocketWin.cpp: Ditto (Inspector::Socket::Socket::create): (Inspector::Socket::setOpt): (Inspector::Socket::bindAndListen): (Inspector::Socket::connect): (Inspector::Socket::accept): (Inspector::Socket::createPair): (Inspector::Socket::setup): (Inspector::Socket::isListening): (Inspector::Socket::getPort): (Inspector::Socket::read): (Inspector::Socket::write): (Inspector::Socket::preparePolling): Initialized 'poll' with zero 2019-12-08 Tadeu Zagallo [WebAssembly] Fix LLIntGenerator's checkConsistency contract https://bugs.webkit.org/show_bug.cgi?id=204998 Reviewed by Mark Lam. We check the consistency of the WebAssembly parser's expression stack every time the LLIntGenerator calls push to allocate a new stack value. However, if we call push more than once (e.g. in a loop), the stack is no longer consistent, since those values have not yet been placed in the parser's expression stack, so the generator and parser's stacks are out of sync. Instead, whenever we need to push multiple values, we should first manually call checkConsistency before any pushes, and all pushes after that should be replaced with push(NoConsistencyCheck). * wasm/WasmLLIntGenerator.cpp: (JSC::Wasm::LLIntGenerator::callInformationForCaller): (JSC::Wasm::LLIntGenerator::addArguments): (JSC::Wasm::LLIntGenerator::addLocal): 2019-12-07 Mark Lam Object.prototype.isPrototypeOf() should check if the passed in value is a non-object first. https://bugs.webkit.org/show_bug.cgi?id=204971 Reviewed by Saam Barati. The spec says Object.prototype.isPrototypeOf() should do checks in the following order: 1. If Type(V) is not Object, return false. 2. Let O be ? ToObject(this value). ... We were previously checking (2) before (1). This patch fixes this order. Ref: http://www.ecma-international.org/ecma-262/10.0/index.html#sec-object.prototype.isprototypeof * runtime/ObjectPrototype.cpp: (JSC::objectProtoFuncIsPrototypeOf): 2019-12-07 Saam Barati Unreviewed. Roll out r253201. It was not a progression on any benchmarks, and was 8% slower on JetStream 2 ML. * JavaScriptCore.xcodeproj/project.pbxproj: * bytecode/BytecodeList.rb: * bytecode/GetByValHistory.h: Added. (JSC::GetByValHistory::observeNonUID): (JSC::GetByValHistory::observe): (JSC::GetByValHistory::count const): (JSC::GetByValHistory::filter const): (JSC::GetByValHistory::update): * bytecode/PointerHistory.h: Removed. * dfg/DFGByteCodeParser.cpp: (JSC::DFG::ByteCodeParser::parseGetById): (JSC::DFG::ByteCodeParser::parseBlock): * dfg/DFGGraph.h: * dfg/DFGSpeculativeJIT.cpp: (JSC::DFG::SpeculativeJIT::compileGetById): * dfg/DFGSpeculativeJIT32_64.cpp: (JSC::DFG::SpeculativeJIT::compile): * dfg/DFGSpeculativeJIT64.cpp: (JSC::DFG::SpeculativeJIT::compile): * ftl/FTLLowerDFGToB3.cpp: (JSC::FTL::DFG::LowerDFGToB3::compileGetById): (JSC::FTL::DFG::LowerDFGToB3::compileGetByVal): * generator/DSL.rb: * jit/JITPropertyAccess.cpp: (JSC::JIT::emit_op_try_get_by_id): (JSC::JIT::emitSlow_op_try_get_by_id): (JSC::JIT::emit_op_get_by_id_direct): (JSC::JIT::emitSlow_op_get_by_id_direct): (JSC::JIT::emit_op_get_by_id): (JSC::JIT::emitSlow_op_get_by_id): * llint/LLIntSlowPaths.cpp: (JSC::LLInt::LLINT_SLOW_PATH_DECL): * runtime/OptionsList.h: 2019-12-07 Mark Lam Remove invalid assertion in FTL's allocateJSArray(). https://bugs.webkit.org/show_bug.cgi?id=204987 Reviewed by Saam Barati. The assertion (in the compiler thread) does not take into account that the mutator may be in the process of transiting to HavingABadTime. As a result, the assertion may fail intermittently. This patch fixes this issue by removing this bad assertion. * ftl/FTLLowerDFGToB3.cpp: (JSC::FTL::DFG::LowerDFGToB3::allocateJSArray): 2019-12-07 Mark Lam Build fix for: The compiler thread should not adjust Identifier refCounts. https://bugs.webkit.org/show_bug.cgi?id=204919 Not reviewed. * bytecode/GetByStatus.cpp: (JSC::GetByStatus::computeFor): 2019-12-07 Joonghun Park Unreviewed. Remove the build warning below since r250009. warning: comparison between signed and unsigned integer expressions [-Wsign-compare] This patch typecasts the "maybe signed" one as unsigned, which is the same what the compilers would do, but making the typecast explicit so that the warning go away. * b3/air/testair.cpp: 2019-12-07 Yusuke Suzuki [JSC] Put JSWrapperObject derived classes in IsoSubspace https://bugs.webkit.org/show_bug.cgi?id=204976 Reviewed by Mark Lam. Put JSWrapperObject derived classes in IsoSubspace. 1. StringObject 2. NumberObject 3. SymbolObject 4. BigIntObject 5. BooleanObject * runtime/BigIntObject.h: * runtime/BooleanObject.h: (JSC::BooleanObject::subspaceFor): * runtime/BooleanPrototype.h: * runtime/JSWrapperObject.h: (JSC::JSWrapperObject::subspaceFor): * runtime/NumberObject.h: (JSC::NumberObject::subspaceFor): * runtime/NumberPrototype.h: * runtime/StringObject.h: (JSC::StringObject::subspaceFor): * runtime/StringPrototype.h: * runtime/SymbolObject.h: * runtime/VM.cpp: (JSC::VM::VM): * runtime/VM.h: 2019-12-07 Devin Rousso Web Inspector: non-regex Local Overrides and Script Blackboxing shouldn't apply to scripts that just contain the URL https://bugs.webkit.org/show_bug.cgi?id=204954 Reviewed by Joseph Pecoraro. If `isRegex` is false, add `^` and `$` to the beginning and end of the search string to ensure that the search string is exactly matched, not just contained within the potentially intercepted URL. This doesn't actually change functionality because the Web Inspector frontend wouldn't replace the network response for these containing matches, as the frontend JavaScript already correctly performed this logic, and would therefore `Network.interceptContinue`. * inspector/ContentSearchUtilities.h: * inspector/ContentSearchUtilities.cpp: (Inspector::ContentSearchUtilities::escapeStringForRegularExpressionSource): Added. (Inspector::ContentSearchUtilities::createRegularExpressionForSearchString): Added. (Inspector::ContentSearchUtilities::searchInTextByLines): (Inspector::ContentSearchUtilities::createSearchRegexSource): Deleted. (Inspector::ContentSearchUtilities::createSearchRegex): Deleted. Rename functions for clarity. * inspector/agents/InspectorDebuggerAgent.cpp: (Inspector::InspectorDebuggerAgent::shouldBlackboxURL const): 2019-12-06 Zan Dobersek [GTK][WPE] Use bmalloc's memory footprint API for JSC heap growth management https://bugs.webkit.org/show_bug.cgi?id=204576 Reviewed by Saam Barati. Use the new USE(BMALLOC_MEMORY_FOOTPRINT_API) build guard to enable bmalloc-based JSC heap growth management on iOS family ports as well as additionally the Linux-based ports, if the configuration allows it (i.e. system malloc enforcement kept disabled). * heap/Heap.cpp: (JSC::Heap::overCriticalMemoryThreshold): (JSC::Heap::updateAllocationLimits): (JSC::Heap::collectIfNecessaryOrDefer): * heap/Heap.h: Initialize the two member variables and fix a typo in one of them. * runtime/Options.cpp: (JSC::overrideDefaults): Also guard two default overrides with the new flag. 2019-12-06 Mark Lam The compiler thread should not adjust Identifier refCounts. https://bugs.webkit.org/show_bug.cgi?id=204919 Reviewed by Saam Barati. 1. Previously, in the compiler thread, we would get a Symbol uid via Symbol::privateName().uid(). Symbol::privateName() returns a copy of its PrivateName, which in turn results in ref'ing the underlying SymbolImpl. This results in a race between the mutator and compiler threads to adjust the SymbolImpl's refCount, which may result in corruption. This patch fixes this by adding Symbol::uid() which return the underlying SymbolImpl without ref'ing it. 2. Previously, in the compiler thread, we also create Box via its copy constructor. The original Box is instantiated in the mutator. The Box refs its internal Data, which is ThreadSafeRefCounted and shared by all Box for the same underlying Identifier. This ensures that the compiler thread does not ref the underlying Identifier. However, when the Box is destructed, it will also check if it holds the last ref to its internal Data. If so, it will destruct its Data, and the Identifier that it embeds. This results in the compiler thread trying to deref the StringImpl referenced by the Identifier in a race against the mutator. This patch fixes this by ensuring that for any Box instance used by the compiler thread, we will register another instance in the DFG::Plan m_identifiersKeptAliveForCleanUp list, and let the mutator destruct that Box later in the mutator. This ensures that the compiler thread will never see the last reference to a Box's internal Data and avoid the race. 3. This patch also fixes the DFG::Worklist code to ensure that a DFG::Plan is always destructed in the mutator, even if the Plan was cancelled. This, in turn, enables us to assert that the Plan is never destructed in the compiler thread. * bytecode/GetByStatus.cpp: (JSC::GetByStatus::computeFor): (JSC::GetByStatus::computeForStubInfoWithoutExitSiteFeedback): * bytecode/GetByStatus.h: * debugger/Debugger.cpp: (JSC::Debugger::detach): * dfg/DFGAbstractInterpreterInlines.h: (JSC::DFG::AbstractInterpreter::executeEffects): * dfg/DFGByteCodeParser.cpp: (JSC::DFG::ByteCodeParser::parseGetById): (JSC::DFG::ByteCodeParser::parseBlock): * dfg/DFGConstantFoldingPhase.cpp: (JSC::DFG::ConstantFoldingPhase::foldConstants): * dfg/DFGPlan.cpp: (JSC::DFG::Plan::~Plan): (JSC::DFG::Plan::computeCompileTimes const): (JSC::DFG::Plan::cancel): * dfg/DFGPlan.h: (JSC::DFG::Plan::unnukedVM const): (JSC::DFG::Plan::keepAliveIdentifier): (JSC::DFG::Plan::nuke): (JSC::DFG::Plan::unnuke): * dfg/DFGSafepoint.cpp: (JSC::DFG::Safepoint::cancel): * dfg/DFGWorklist.cpp: (JSC::DFG::Worklist::deleteCancelledPlansForVM): (JSC::DFG::Worklist::removeAllReadyPlansForVM): (JSC::DFG::Worklist::removeDeadPlans): (JSC::DFG::Worklist::removeNonCompilingPlansForVM): * dfg/DFGWorklist.h: * runtime/Symbol.h: 2019-12-06 Yusuke Suzuki [JSC] Put JSModuleNamespaceObject in IsoSubspace https://bugs.webkit.org/show_bug.cgi?id=204973 Reviewed by Mark Lam. We found that we do not need to embed AbstractModuleRecord vector inside JSModuleNamespaceObject: we can just put it in ExportEntry. So we can make it non-variable-sized cell. Further, this patch puts it in IsoSubspace. * runtime/CellSize.h: (JSC::isDynamicallySizedType): (JSC::cellSize): * runtime/JSModuleNamespaceObject.cpp: (JSC::JSModuleNamespaceObject::finishCreation): (JSC::JSModuleNamespaceObject::visitChildren): (JSC::JSModuleNamespaceObject::getOwnPropertySlotCommon): * runtime/JSModuleNamespaceObject.h: * runtime/VM.cpp: (JSC::VM::VM): * runtime/VM.h: 2019-12-06 Yusuke Suzuki [JSC] Put ModuleRecords in IsoSubspace https://bugs.webkit.org/show_bug.cgi?id=204972 Reviewed by Mark Lam. This patch is putting JSModuleRecord and WebAssemblyModuleRecord in IsoSubspace. * runtime/AbstractModuleRecord.cpp: (JSC::AbstractModuleRecord::destroy): Deleted. * runtime/AbstractModuleRecord.h: (JSC::AbstractModuleRecord::subspaceFor): * runtime/JSModuleRecord.h: * runtime/VM.cpp: (JSC::VM::VM): * runtime/VM.h: * wasm/js/WebAssemblyModuleRecord.h: 2019-12-06 Per Arne Vollan Unreviewed build fix. Initialize local variable. * API/tests/testapi.cpp: (TestAPI::promiseUnhandledRejection): 2019-12-06 Joonghun Park Unreviewed. Change the format string portable by using "%" PRIx64 instead of "%llx" for uint64_t argument. This patch removes the build warning below since r252978. warning: format ‘%llx’ expects argument of type ‘long long unsigned int’, but argument 3 has type ‘JSC::SpeculatedType {aka long unsigned int}’ [-Wformat=] * runtime/PredictionFileCreatingFuzzerAgent.cpp: (JSC::PredictionFileCreatingFuzzerAgent::getPredictionInternal): 2019-12-06 Commit Queue Unreviewed, rolling out r253218. https://bugs.webkit.org/show_bug.cgi?id=204968 Broke the build (Requested by ap on #webkit). Reverted changeset: "Remove various .order files." https://bugs.webkit.org/show_bug.cgi?id=204959 https://trac.webkit.org/changeset/253218 2019-12-06 Yusuke Suzuki [JSC] JSCallee should be in IsoSubspace https://bugs.webkit.org/show_bug.cgi?id=204961 Reviewed by Mark Lam. We should put JSCallee in IsoSubspace. Currently, we are also putting JSToWasmICCallee in IsoSusbapce since it is a derived class of JSCallee, but I think we can remove this class completely. We are tracking it in [1]. [1]: https://bugs.webkit.org/show_bug.cgi?id=204960 * debugger/DebuggerScope.h: * interpreter/Interpreter.cpp: (JSC::Interpreter::executeProgram): (JSC::Interpreter::execute): * runtime/JSCallee.h: (JSC::JSCallee::subspaceFor): * runtime/JSGlobalObject.h: (JSC::JSGlobalObject::globalCallee): * runtime/VM.cpp: (JSC::VM::VM): * runtime/VM.h: * wasm/js/JSToWasmICCallee.h: (JSC::JSToWasmICCallee::function): Deleted. (JSC::JSToWasmICCallee::JSToWasmICCallee): Deleted. 2019-12-06 Devin Rousso Web Inspector: add compiler UNLIKELY hints when checking if developer extras are enabled https://bugs.webkit.org/show_bug.cgi?id=204875 Reviewed by Joseph Pecoraro. Move the check for whether developer extras are enabled from the agent to the client so that when inspecting a webpage, we don't check for it twice, since `InspectorInstrumentation` already checks for it too. * inspector/agents/InspectorConsoleAgent.h: * inspector/agents/InspectorConsoleAgent.cpp: (Inspector::InspectorConsoleAgent::developerExtrasEnabled const): Added. (Inspector::InspectorConsoleAgent::addMessageToConsole): (Inspector::InspectorConsoleAgent::startTiming): (Inspector::InspectorConsoleAgent::logTiming): (Inspector::InspectorConsoleAgent::stopTiming): (Inspector::InspectorConsoleAgent::takeHeapSnapshot): (Inspector::InspectorConsoleAgent::count): (Inspector::InspectorConsoleAgent::countReset): (Inspector::InspectorConsoleAgent::addConsoleMessage): * inspector/JSGlobalObjectConsoleClient.cpp: (Inspector::JSGlobalObjectConsoleClient::messageWithTypeAndLevel): (Inspector::JSGlobalObjectConsoleClient::count): (Inspector::JSGlobalObjectConsoleClient::countReset): (Inspector::JSGlobalObjectConsoleClient::profile): (Inspector::JSGlobalObjectConsoleClient::profileEnd): (Inspector::JSGlobalObjectConsoleClient::takeHeapSnapshot): (Inspector::JSGlobalObjectConsoleClient::time): (Inspector::JSGlobalObjectConsoleClient::timeLog): (Inspector::JSGlobalObjectConsoleClient::timeEnd): (Inspector::JSGlobalObjectConsoleClient::timeStamp): (Inspector::JSGlobalObjectConsoleClient::record): (Inspector::JSGlobalObjectConsoleClient::recordEnd): (Inspector::JSGlobalObjectConsoleClient::screenshot): 2019-12-06 Keith Miller Remove various .order files. https://bugs.webkit.org/show_bug.cgi?id=204959 Reviewed by Yusuke Suzuki. These files are all super out of date and likely don't do anything anymore. The signatures of the functions have changed thus the mangled name has changed. * JavaScriptCore.order: Removed. 2019-12-06 Joonghun Park Unreviewed. Revert r253207 because it causes compile error in Mac and ios build. * runtime/PredictionFileCreatingFuzzerAgent.cpp: (JSC::PredictionFileCreatingFuzzerAgent::getPredictionInternal): 2019-12-06 Joonghun Park Unreviewed. Remove build warning below since r252978. warning: format ‘%llx’ expects argument of type ‘long long unsigned int’, but argument 3 has type ‘JSC::SpeculatedType {aka long unsigned int}’ [-Wformat=] * runtime/PredictionFileCreatingFuzzerAgent.cpp: (JSC::PredictionFileCreatingFuzzerAgent::getPredictionInternal): 2019-12-05 Saam Barati get_by_id ICs should have a structure history used to indicate when we should skip generating an IC https://bugs.webkit.org/show_bug.cgi?id=204904 Reviewed by Yusuke Suzuki and Tadeu Zagallo. I implemented a similar policy for get_by_val for the number of unique seen identifiers. This allows us to create a heuristic to directly call the slow path when profiling information tells us if inline caching might not be profitable. This patch implements a similar policy for get_by_id where we profile the seen base value structures. If the LLInt observes enough unique structures, we omit emitting the inline cache in the upper tiers. The goal here was to try to speed up Speedometer2. Local testing showed this patch to repeatedly be 0.5% faster, but all the P values I got were insignificant. So it appears it's either neutral or slightly faster. This patch also adjusts the policy of seeing a non-identifier inside the PointerHistory data structure. Instead of increasing it to reach the limit when we see a non-identifier, we just treat each execution with a non-identifier to increment the count by 1. * JavaScriptCore.xcodeproj/project.pbxproj: * bytecode/BytecodeList.rb: * bytecode/GetByValHistory.h: Removed. * bytecode/PointerHistory.h: Copied from Source/JavaScriptCore/bytecode/GetByValHistory.h. (JSC::PointerHistory::observe): (JSC::PointerHistory::observeNull): (JSC::GetByValHistory::observeNonUID): Deleted. (JSC::GetByValHistory::observe): Deleted. (JSC::GetByValHistory::count const): Deleted. (JSC::GetByValHistory::filter const): Deleted. (JSC::GetByValHistory::update): Deleted. * dfg/DFGByteCodeParser.cpp: (JSC::DFG::ByteCodeParser::parseGetById): (JSC::DFG::ByteCodeParser::parseBlock): * dfg/DFGGraph.h: * dfg/DFGSpeculativeJIT.cpp: (JSC::DFG::SpeculativeJIT::compileGetById): * dfg/DFGSpeculativeJIT32_64.cpp: (JSC::DFG::SpeculativeJIT::compile): * dfg/DFGSpeculativeJIT64.cpp: (JSC::DFG::SpeculativeJIT::compile): * ftl/FTLLowerDFGToB3.cpp: (JSC::FTL::DFG::LowerDFGToB3::compileGetById): (JSC::FTL::DFG::LowerDFGToB3::compileGetByVal): * generator/DSL.rb: * jit/JITPropertyAccess.cpp: (JSC::JIT::emit_op_try_get_by_id): (JSC::JIT::emitSlow_op_try_get_by_id): (JSC::JIT::emit_op_get_by_id_direct): (JSC::JIT::emitSlow_op_get_by_id_direct): (JSC::JIT::emit_op_get_by_id): (JSC::JIT::emitSlow_op_get_by_id): * llint/LLIntSlowPaths.cpp: (JSC::LLInt::LLINT_SLOW_PATH_DECL): * runtime/OptionsList.h: 2019-12-05 Tadeu Zagallo [WebAssembly] Fix LLIntCallee's ownership https://bugs.webkit.org/show_bug.cgi?id=204929 Reviewed by Saam Barati. Currently, after the LLIntPlan finished generating bytecode, the Module takes ownership of the Vector of LLIntCallee's and passes a pointer to the Vector's storage to the CodeBlock. However, while we're tiering up, the module might be destroyed and we'll try to access the LLIntCallee after we finish compiling through the pointer held by the CodeBlock, which is now stale, since the Vector was owned by the Module. In order to fix this, we move the Vector into a reference counted wrapper class, LLIntCallees, and both the Module and the CodeBlock hold references to the wrapper. * wasm/WasmBBQPlan.cpp: (JSC::Wasm::BBQPlan::work): * wasm/WasmCallee.h: (JSC::Wasm::LLIntCallees::create): (JSC::Wasm::LLIntCallees::at const): (JSC::Wasm::LLIntCallees::data const): (JSC::Wasm::LLIntCallees::LLIntCallees): * wasm/WasmCodeBlock.cpp: (JSC::Wasm::CodeBlock::create): (JSC::Wasm::CodeBlock::CodeBlock): * wasm/WasmCodeBlock.h: (JSC::Wasm::CodeBlock::wasmEntrypointCalleeFromFunctionIndexSpace): * wasm/WasmModule.cpp: (JSC::Wasm::Module::Module): (JSC::Wasm::Module::getOrCreateCodeBlock): * wasm/WasmModule.h: * wasm/WasmOMGPlan.cpp: (JSC::Wasm::OMGPlan::work): 2019-12-05 Tadeu Zagallo REGRESSION(r253140): Wasm::FunctionParser needs to bounds check in SetLocal/TeeLocal https://bugs.webkit.org/show_bug.cgi?id=204909 Reviewed by Keith Miller. When moving the code from WasmValidate.cpp to WasmFunctionParser.h, I missed that SetLocal and TeeLocal used to call Wasm::Validate::getLocal, which would perform the bounds check. I just added back the checks to the parser before accessing the local's type from m_locals. * wasm/WasmFunctionParser.h: (JSC::Wasm::FunctionParser::parseExpression): 2019-12-05 Tadeu Zagallo [WebAssembly] Fix bad assertion in LLIntPlan https://bugs.webkit.org/show_bug.cgi?id=204893 Reviewed by Mark Lam. Before landing r253140 I introduced an assertion in Wasm::LLIntPlan that the pointer to previously compiled callees must be non-null. However, it's perfectly valid for the pointer to be null when the module has no functions. * wasm/WasmLLIntPlan.cpp: (JSC::Wasm::LLIntPlan::LLIntPlan): 2019-12-05 Mark Lam computeIfUsingFuzzerAgent() is called before parsing command line arguments. https://bugs.webkit.org/show_bug.cgi?id=204886 Reviewed by Saam Barati. Rolling out r253015 which introduced computeIfUsingFuzzerAgent(). * runtime/Options.cpp: (JSC::Options::initialize): (JSC::computeIfUsingFuzzerAgent): Deleted. * runtime/Options.h: (JSC::Options::isUsingFuzzerAgent): Deleted. * runtime/OptionsList.h: (JSC::OptionRange::operator bool const): Deleted. * runtime/VM.cpp: (JSC::VM::VM): 2019-12-05 Simon Fraser Fix inspector/css test assertions after r253158 https://bugs.webkit.org/show_bug.cgi?id=204924 Reviewed by Devin Rousso. Teach the inspector protocol about the ::highlight pseudoelement. * inspector/protocol/CSS.json: 2019-12-04 Yusuke Suzuki [JSC] AI should convert IsCellWithType to constant when Structure set is finite https://bugs.webkit.org/show_bug.cgi?id=204141 Reviewed by Mark Lam. We should fold IsCellWithType if Structure set is finite since we have a chance to know what JSType is. The difference from the last patch is that we have `if (!(child.m_type & ~SpecCell))` check. Even if structures meet the requirement, this structures do not guarantee that non cell types never come. We should ensure it by using proven type. * dfg/DFGAbstractInterpreterInlines.h: (JSC::DFG::AbstractInterpreter::executeEffects): 2019-12-04 Yusuke Suzuki [JSC] Put TypedArrays in IsoSubspace https://bugs.webkit.org/show_bug.cgi?id=204867 Reviewed by Mark Lam. This patch puts TypedArrays in IsoSubspace. - JSArrayBuffer - JSDataView - JSInt8Array - JSInt16Array - JSInt32Array - JSUint8Array - JSUint8ClampedArray - JSUint16Array - JSUint32Array - JSFloat32Array - JSFloat64Array * dfg/DFGSpeculativeJIT.cpp: (JSC::DFG::SpeculativeJIT::compileNewTypedArrayWithSize): * ftl/FTLLowerDFGToB3.cpp: (JSC::FTL::DFG::LowerDFGToB3::compileNewTypedArray): * runtime/JSArrayBuffer.h: * runtime/JSArrayBufferView.h: (JSC::JSArrayBufferView::subspaceFor): * runtime/JSDataView.h: * runtime/JSGenericTypedArrayView.h: * runtime/JSTypedArrays.h: * runtime/TypedArrayAdaptors.h: * runtime/VM.cpp: * runtime/VM.h: 2019-12-04 Tadeu Zagallo [WebAssembly] Validate and generate bytecode in one pass https://bugs.webkit.org/show_bug.cgi?id=204474 Reviewed by Saam Barati. Currently, we traverse the WebAssembly code twice: - a first serial pass that validates all functions - a second concurrent pass that compiles all functions. In this patch, we move the validation into the parser and update the LLIntPlan so that we no longer have the first pass. Instead, we now validate concurrently at the same time we generate bytecode. As a result, when we call WebAssembly.validate, we'll still generate bytecode for the module, but it will be thrown away. If the module is constructed with new WebAssembly.Module, we'll also eagerly generate bytecode, but in this case the bytecode is kept and shared across all instantiations of this module. This is a 1.5x speedup when compiling the ZenGarden demo. * DerivedSources.make: * wasm/WasmAirIRGenerator.cpp: (JSC::Wasm::AirIRGenerator::ControlData::ControlData): (JSC::Wasm::AirIRGenerator::ControlData::isIf): (JSC::Wasm::AirIRGenerator::ControlData::isTopLevel): (JSC::Wasm::AirIRGenerator::ControlData::branchTargetArity const): (JSC::Wasm::AirIRGenerator::ControlData::branchTargetType const): (JSC::Wasm::AirIRGenerator::emptyExpression): (JSC::Wasm::AirIRGenerator::emitCallPatchpoint): (JSC::Wasm::AirIRGenerator::tmpsForSignature): (JSC::Wasm::AirIRGenerator::emitPatchpoint): (JSC::Wasm::AirIRGenerator::AirIRGenerator): (JSC::Wasm::AirIRGenerator::addRefIsNull): (JSC::Wasm::AirIRGenerator::addTableGet): (JSC::Wasm::AirIRGenerator::addTableSet): (JSC::Wasm::AirIRGenerator::addTableGrow): (JSC::Wasm::AirIRGenerator::addTableFill): (JSC::Wasm::AirIRGenerator::emitLoopTierUpCheck): (JSC::Wasm::AirIRGenerator::addLoop): (JSC::Wasm::AirIRGenerator::addBlock): (JSC::Wasm::AirIRGenerator::addIf): (JSC::Wasm::AirIRGenerator::addReturn): (JSC::Wasm::AirIRGenerator::addEndToUnreachable): (JSC::Wasm::AirIRGenerator::addCall): (JSC::Wasm::AirIRGenerator::addCallIndirect): (JSC::Wasm::AirIRGenerator::unify): (JSC::Wasm::dumpExpressionStack): (JSC::Wasm::AirIRGenerator::dump): (JSC::Wasm::parseAndCompileAir): (JSC::Wasm::AirIRGenerator::addOp): (JSC::Wasm::AirIRGenerator::addOp): * wasm/WasmAirIRGenerator.h: * wasm/WasmB3IRGenerator.cpp: (JSC::Wasm::B3IRGenerator::ControlData::ControlData): (JSC::Wasm::B3IRGenerator::ControlData::isIf): (JSC::Wasm::B3IRGenerator::ControlData::isTopLevel): (JSC::Wasm::B3IRGenerator::ControlData::signature const): (JSC::Wasm::B3IRGenerator::ControlData::hasNonVoidresult const): (JSC::Wasm::B3IRGenerator::ControlData::branchTargetArity const): (JSC::Wasm::B3IRGenerator::ControlData::branchTargetType const): (JSC::Wasm::B3IRGenerator::emptyExpression): (JSC::Wasm::B3IRGenerator::B3IRGenerator): (JSC::Wasm::B3IRGenerator::addRefIsNull): (JSC::Wasm::B3IRGenerator::addTableGet): (JSC::Wasm::B3IRGenerator::addTableSet): (JSC::Wasm::B3IRGenerator::addTableGrow): (JSC::Wasm::B3IRGenerator::addTableFill): (JSC::Wasm::B3IRGenerator::emitLoopTierUpCheck): (JSC::Wasm::B3IRGenerator::addLoop): (JSC::Wasm::B3IRGenerator::addBlock): (JSC::Wasm::B3IRGenerator::addIf): (JSC::Wasm::B3IRGenerator::addReturn): (JSC::Wasm::B3IRGenerator::endBlock): (JSC::Wasm::B3IRGenerator::addEndToUnreachable): (JSC::Wasm::dumpExpressionStack): (JSC::Wasm::B3IRGenerator::dump): (JSC::Wasm::parseAndCompile): * wasm/WasmB3IRGenerator.h: * wasm/WasmBBQPlan.cpp: (JSC::Wasm::BBQPlan::BBQPlan): (JSC::Wasm::BBQPlan::work): (JSC::Wasm::BBQPlan::compileFunction): (JSC::Wasm::BBQPlan::initializeCallees): (JSC::Wasm::BBQPlan::didReceiveFunctionData): * wasm/WasmBBQPlan.h: * wasm/WasmCodeBlock.cpp: (JSC::Wasm::CodeBlock::create): (JSC::Wasm::CodeBlock::CodeBlock): * wasm/WasmCodeBlock.h: (JSC::Wasm::CodeBlock::wasmEntrypointCalleeFromFunctionIndexSpace): * wasm/WasmEntryPlan.cpp: (JSC::Wasm::EntryPlan::EntryPlan): (JSC::Wasm::EntryPlan::parseAndValidateModule): (JSC::Wasm::EntryPlan::prepare): (JSC::Wasm::EntryPlan::compileFunctions): (JSC::Wasm::EntryPlan::complete): * wasm/WasmEntryPlan.h: * wasm/WasmFunctionParser.h: (JSC::Wasm::splitStack): (JSC::Wasm::FunctionParser::TypedExpression::TypedExpression): (JSC::Wasm::FunctionParser::TypedExpression::type const): (JSC::Wasm::FunctionParser::TypedExpression::value const): (JSC::Wasm::FunctionParser::TypedExpression::operator ExpressionType const): (JSC::Wasm::FunctionParser::TypedExpression::operator-> const): (JSC::Wasm::FunctionParser::controlStack): (JSC::Wasm::FunctionParser::validationFail const): (JSC::Wasm::FunctionParser::parse): (JSC::Wasm::FunctionParser::binaryCase): (JSC::Wasm::FunctionParser::unaryCase): (JSC::Wasm::FunctionParser::load): (JSC::Wasm::FunctionParser::store): (JSC::Wasm::FunctionParser::checkBranchTarget): (JSC::Wasm::FunctionParser::unify): (JSC::Wasm::FunctionParser::parseExpression): (JSC::Wasm::FunctionParser::parseUnreachableExpression): * wasm/WasmLLIntGenerator.cpp: (JSC::Wasm::LLIntGenerator::ControlType::topLevel): (JSC::Wasm::LLIntGenerator::ControlType::loop): (JSC::Wasm::LLIntGenerator::ControlType::isIf): (JSC::Wasm::LLIntGenerator::ControlType::isTopLevel): (JSC::Wasm::LLIntGenerator::ControlType::stackSize const): (JSC::Wasm::LLIntGenerator::ControlType::signature const): (JSC::Wasm::LLIntGenerator::ControlType::branchTargetArity const): (JSC::Wasm::LLIntGenerator::ControlType::branchTargetType const): (JSC::Wasm::LLIntGenerator::emptyExpression): (JSC::Wasm::LLIntGenerator::dump): (JSC::Wasm::LLIntGenerator::getDropKeepCount): (JSC::Wasm::LLIntGenerator::materializeConstantsAndLocals): (JSC::Wasm::LLIntGenerator::splitStack): (JSC::Wasm::parseAndCompileBytecode): (JSC::Wasm::LLIntGenerator::LLIntGenerator): (JSC::Wasm::LLIntGenerator::callInformationForCaller): (JSC::Wasm::LLIntGenerator::addLocal): (JSC::Wasm::LLIntGenerator::setLocal): (JSC::Wasm::LLIntGenerator::addLoop): (JSC::Wasm::LLIntGenerator::addBlock): (JSC::Wasm::LLIntGenerator::addIf): (JSC::Wasm::LLIntGenerator::addEndToUnreachable): (JSC::Wasm::LLIntGenerator::addCall): (JSC::Wasm::LLIntGenerator::addCallIndirect): * wasm/WasmLLIntGenerator.h: * wasm/WasmLLIntPlan.cpp: (JSC::Wasm::LLIntPlan::LLIntPlan): (JSC::Wasm::LLIntPlan::compileFunction): (JSC::Wasm::LLIntPlan::didCompleteCompilation): (JSC::Wasm::LLIntPlan::work): (JSC::Wasm::LLIntPlan::didReceiveFunctionData): * wasm/WasmLLIntPlan.h: * wasm/WasmModule.cpp: (JSC::Wasm::Module::Module): (JSC::Wasm::makeValidationResult): (JSC::Wasm::makeValidationCallback): (JSC::Wasm::Module::validateSync): (JSC::Wasm::Module::validateAsync): (JSC::Wasm::Module::getOrCreateCodeBlock): (JSC::Wasm::Module::compileSync): (JSC::Wasm::Module::compileAsync): * wasm/WasmModule.h: (JSC::Wasm::Module::create): * wasm/WasmOMGPlan.cpp: (JSC::Wasm::OMGPlan::work): * wasm/WasmPlan.cpp: (JSC::Wasm::Plan::Plan): * wasm/WasmPlan.h: (JSC::Wasm::Plan::dontFinalize): * wasm/WasmSlowPaths.cpp: (JSC::LLInt::slow_path_wasm_throw_exception): * wasm/WasmThunks.cpp: (JSC::Wasm::throwExceptionFromWasmThunkGenerator): * wasm/WasmThunks.h: * wasm/WasmValidate.cpp: (JSC::Wasm::Validate::ControlData::isIf): (JSC::Wasm::Validate::ControlData::isTopLevel): (JSC::Wasm::Validate::ControlData::blockType const): (JSC::Wasm::Validate::ControlData::signature const): (JSC::Wasm::Validate::ControlData::branchTargetArity const): (JSC::Wasm::Validate::ControlData::branchTargetType const): (JSC::Wasm::Validate::emptyExpression): (JSC::Wasm::Validate::addConstant): (JSC::Wasm::Validate::Validate): (JSC::Wasm::Validate::addArguments): (JSC::Wasm::Validate::addTableGet): (JSC::Wasm::Validate::addTableSet): (JSC::Wasm::Validate::addTableSize): (JSC::Wasm::Validate::addTableGrow): (JSC::Wasm::Validate::addTableFill): (JSC::Wasm::Validate::addRefIsNull): (JSC::Wasm::Validate::addRefFunc): (JSC::Wasm::Validate::addLocal): (JSC::Wasm::Validate::getLocal): (JSC::Wasm::Validate::setLocal): (JSC::Wasm::Validate::getGlobal): (JSC::Wasm::Validate::setGlobal): (JSC::Wasm::Validate::addBlock): (JSC::Wasm::Validate::addLoop): (JSC::Wasm::Validate::addSelect): (JSC::Wasm::Validate::addIf): (JSC::Wasm::Validate::addElse): (JSC::Wasm::Validate::addElseToUnreachable): (JSC::Wasm::Validate::addReturn): (JSC::Wasm::Validate::addBranch): (JSC::Wasm::Validate::addSwitch): (JSC::Wasm::Validate::addGrowMemory): (JSC::Wasm::Validate::addCurrentMemory): (JSC::Wasm::Validate::endBlock): (JSC::Wasm::Validate::addEndToUnreachable): (JSC::Wasm::Validate::addCall): (JSC::Wasm::Validate::addCallIndirect): (JSC::Wasm::Validate::load): (JSC::Wasm::Validate::store): (JSC::Wasm::Validate::addOp): (JSC::Wasm::dumpExpressionStack): (JSC::Wasm::Validate::dump): (JSC::Wasm::validateFunction): * wasm/WasmWorklist.cpp: (JSC::Wasm::Worklist::enqueue): * wasm/generateWasmOpsHeader.py: (cppType): (cppMacro): (opcodeMacroizer): (opcodeWithTypesMacroizer): (opcodeWithTypesMacroizer.modifier): (memoryLoadMacroizer): (memoryLoadMacroizer.modifier): (memoryStoreMacroizer): (memoryStoreMacroizer.modifier): * wasm/generateWasmValidateInlinesHeader.py: Removed. * wasm/js/JSWebAssembly.cpp: (JSC::instantiate): (JSC::webAssemblyValidateFunc): * wasm/js/WebAssemblyInstanceConstructor.cpp: (JSC::constructJSWebAssemblyInstance): 2019-12-04 Mark Lam Fix missing exception check in ArrayPrototype's fastJoin(). https://bugs.webkit.org/show_bug.cgi?id=204868 Reviewed by Saam Barati. * runtime/ArrayPrototype.cpp: (JSC::fastJoin): 2019-12-04 Mark Lam Fix a broken assertion in GetByStatus::computeForStubInfoWithoutExitSiteFeedback(). https://bugs.webkit.org/show_bug.cgi?id=204866 Reviewed by Saam Barati. The assertion wrong assumes that access.offset() cannot be invalid unless the access.type() is a Miss. However, if the AccessCase is a Custom value or accessor, the offset is always invalid. This patch fixes this assertion. * bytecode/AccessCase.h: (JSC::AccessCase::isCustom const): * bytecode/GetByStatus.cpp: (JSC::GetByStatus::computeForStubInfoWithoutExitSiteFeedback): 2019-12-04 Yusuke Suzuki Unreviewed, rolling out r252416, vimeo does not work https://bugs.webkit.org/show_bug.cgi?id=204141 * dfg/DFGAbstractInterpreterInlines.h: (JSC::DFG::AbstractInterpreter::executeEffects): 2019-12-04 Yusuke Suzuki [JSC] JSWebAssemblyGlobal creation should have exception check https://bugs.webkit.org/show_bug.cgi?id=204857 Reviewed by Mark Lam. Each WebAssembly cells have a path throwing an exception if WebAssembly is disabled. We lack exception checking after calling JSWebAssemblyGlobal::create in WebAssemblyModuleRecord linking phase. While exception is never thrown in this place since this happens only when WebAssembly is enabled, we should put `scope.assertNoException()` to satisfy exception verifier requirement. We also rename factory function of Wasm cells from "create" to "tryCreate" since it can fail potentially. * wasm/js/JSWebAssembly.cpp: (JSC::instantiate): * wasm/js/JSWebAssemblyGlobal.cpp: (JSC::JSWebAssemblyGlobal::tryCreate): (JSC::JSWebAssemblyGlobal::create): Deleted. * wasm/js/JSWebAssemblyGlobal.h: * wasm/js/JSWebAssemblyInstance.cpp: (JSC::JSWebAssemblyInstance::tryCreate): (JSC::JSWebAssemblyInstance::create): Deleted. * wasm/js/JSWebAssemblyInstance.h: * wasm/js/JSWebAssemblyMemory.cpp: (JSC::JSWebAssemblyMemory::tryCreate): (JSC::JSWebAssemblyMemory::create): Deleted. * wasm/js/JSWebAssemblyMemory.h: * wasm/js/JSWebAssemblyTable.cpp: (JSC::JSWebAssemblyTable::tryCreate): (JSC::JSWebAssemblyTable::create): Deleted. * wasm/js/JSWebAssemblyTable.h: * wasm/js/WebAssemblyGlobalConstructor.cpp: (JSC::constructJSWebAssemblyGlobal): * wasm/js/WebAssemblyInstanceConstructor.cpp: (JSC::constructJSWebAssemblyInstance): * wasm/js/WebAssemblyMemoryConstructor.cpp: (JSC::constructJSWebAssemblyMemory): * wasm/js/WebAssemblyModuleRecord.cpp: (JSC::WebAssemblyModuleRecord::link): * wasm/js/WebAssemblyTableConstructor.cpp: (JSC::constructJSWebAssemblyTable): 2019-12-04 Yusuke Suzuki [JSC] Put more cells into IsoSubspace https://bugs.webkit.org/show_bug.cgi?id=204845 Reviewed by Saam Barati. This patch puts following cells in IsoSubspace. - ClonedArguments - JSMap - JSSet - RegExpObject * runtime/ClonedArguments.h: * runtime/JSMap.h: * runtime/JSSet.h: * runtime/RegExpObject.h: * runtime/VM.cpp: (JSC::VM::VM): * runtime/VM.h: * runtime/WeakMapImpl.h: (JSC::WeakMapImpl::subspaceFor): 2019-12-04 Yusuke Suzuki [JSC] Remove m_sharingMode field from JSArrayBufferPrototype and make it plain object https://bugs.webkit.org/show_bug.cgi?id=204832 Reviewed by Saam Barati. m_sharingMode field is not necessary. Just remove it and make JSArrayBufferPrototype a plain object. * runtime/JSArrayBufferPrototype.cpp: (JSC::JSArrayBufferPrototype::JSArrayBufferPrototype): (JSC::JSArrayBufferPrototype::finishCreation): (JSC::JSArrayBufferPrototype::create): * runtime/JSArrayBufferPrototype.h: 2019-12-04 Yusuke Suzuki [JSC] Place Wasm cells in IsoSubspace https://bugs.webkit.org/show_bug.cgi?id=204829 Reviewed by Saam Barati. This patch places Wasm cells in IsoSubspace. We remove JSDestructibleObject inheritance in wasm cells since we can call destructor through HeapCellType's specialization. We do not need to rely on m_classInfo->methodTable->destroy. This patch does not include JSToWasmICCallee since now I'm exploring the way to remove it completely. * runtime/VM.cpp: (JSC::VM::VM): * runtime/VM.h: * wasm/js/JSWebAssemblyInstance.h: * wasm/js/JSWebAssemblyMemory.cpp: (JSC::JSWebAssemblyMemory::destroy): * wasm/js/JSWebAssemblyMemory.h: * wasm/js/JSWebAssemblyModule.h: * wasm/js/JSWebAssemblyTable.h: * wasm/js/WebAssemblyGlobalConstructor.h: 2019-12-04 Tim Horton Introduce a GPU process https://bugs.webkit.org/show_bug.cgi?id=204343 Reviewed by Simon Fraser. * Configurations/FeatureDefines.xcconfig: Add ENABLE(GPU_PROCESS). 2019-12-04 Yury Semikhatsky Web Inspector: allow inspector to pause provisional page load and restore its state https://bugs.webkit.org/show_bug.cgi?id=204170 Reviewed by Devin Rousso. Added an option to Target domain to pause all new targets on start waiting for explicit 'resume' command from the inspector front-end. This allows to configure inspector backend (including user agent overrides, breakpoints and instrumentation) before navigation starts. * JavaScriptCore.xcodeproj/project.pbxproj: * Sources.txt: * inspector/InspectorTarget.cpp: Added. (Inspector::InspectorTarget::pause): (Inspector::InspectorTarget::resume): (Inspector::InspectorTarget::setResumeCallback): * inspector/InspectorTarget.h: * inspector/agents/InspectorTargetAgent.cpp: (Inspector::InspectorTargetAgent::willDestroyFrontendAndBackend): (Inspector::InspectorTargetAgent::setPauseOnStart): (Inspector::InspectorTargetAgent::resume): (Inspector::buildTargetInfoObject): (Inspector::InspectorTargetAgent::targetCreated): (Inspector::InspectorTargetAgent::targetDestroyed): * inspector/agents/InspectorTargetAgent.h: * inspector/protocol/Target.json: 2019-12-03 Saam Barati Remove "patch" struct from StructureStubInfo because it adds unnecessary padding https://bugs.webkit.org/show_bug.cgi?id=204392 Reviewed by Tadeu Zagallo. By doing this, we reduce the size of StructureStubInfo from 120 bytes to 112 bytes. * bytecode/AccessCase.cpp: (JSC::AccessCase::generateWithGuard): (JSC::AccessCase::generateImpl): * bytecode/GetterSetterAccessCase.cpp: (JSC::GetterSetterAccessCase::emitDOMJITGetter): * bytecode/InlineAccess.cpp: (JSC::linkCodeInline): (JSC::InlineAccess::generateSelfPropertyAccess): (JSC::getScratchRegister): (JSC::InlineAccess::generateSelfPropertyReplace): (JSC::InlineAccess::generateArrayLength): (JSC::InlineAccess::generateStringLength): (JSC::InlineAccess::generateSelfInAccess): (JSC::InlineAccess::rewireStubAsJump): * bytecode/PolymorphicAccess.cpp: (JSC::PolymorphicAccess::regenerate): * bytecode/StructureStubInfo.h: (JSC::StructureStubInfo::inlineSize const): (JSC::StructureStubInfo::patchableJump): (JSC::StructureStubInfo::valueRegs const): (JSC::StructureStubInfo::propertyRegs const): (JSC::StructureStubInfo::baseRegs const): (JSC::StructureStubInfo::baseGPR const): Deleted. (JSC::StructureStubInfo::slowPathCallLocation): Deleted. (JSC::StructureStubInfo::doneLocation): Deleted. (JSC::StructureStubInfo::slowPathStartLocation): Deleted. * dfg/DFGOSRExitCompilerCommon.cpp: (JSC::DFG::callerReturnPC): * jit/JITInlineCacheGenerator.cpp: (JSC::JITInlineCacheGenerator::JITInlineCacheGenerator): (JSC::JITInlineCacheGenerator::finalize): (JSC::JITByIdGenerator::JITByIdGenerator): (JSC::JITGetByIdWithThisGenerator::JITGetByIdWithThisGenerator): (JSC::JITPutByIdGenerator::JITPutByIdGenerator): (JSC::JITInstanceOfGenerator::JITInstanceOfGenerator): (JSC::JITGetByValGenerator::JITGetByValGenerator): * jit/Repatch.cpp: (JSC::tryCacheGetBy): (JSC::repatchGetBy): (JSC::repatchArrayGetByVal): (JSC::tryCachePutByID): (JSC::repatchPutByID): (JSC::tryCacheInByID): (JSC::repatchInByID): (JSC::repatchInstanceOf): (JSC::resetGetBy): (JSC::resetPutByID): (JSC::resetPatchableJump): (JSC::resetInByID): 2019-12-03 Yusuke Suzuki Unreviewed, fix build failure https://bugs.webkit.org/show_bug.cgi?id=186552 * wasm/WasmAirIRGenerator.cpp: (JSC::Wasm::AirIRGenerator::getGlobal): * wasm/WasmB3IRGenerator.cpp: (JSC::Wasm::B3IRGenerator::setGlobal): 2019-12-03 Yusuke Suzuki [JSC] Remove WebAssemblyToJSCallee https://bugs.webkit.org/show_bug.cgi?id=204808 Reviewed by Tadeu Zagallo. This patch drops WebAssemblyToJSCallee. It was originally required to put small cell to retrieve VM from callee. But now this limitation is removed. We can just put JSWebAssemblyModule in callee place instead. * JavaScriptCore.xcodeproj/project.pbxproj: * Sources.txt: * interpreter/CallFrame.cpp: (JSC::CallFrame::isAnyWasmCallee): * interpreter/StackVisitor.cpp: (JSC::StackVisitor::Frame::calleeSaveRegistersForUnwinding): * jit/Repatch.cpp: (JSC::webAssemblyOwner): (JSC::linkFor): (JSC::linkPolymorphicCall): * runtime/JSCast.h: * runtime/JSCell.cpp: * runtime/JSCellInlines.h: (JSC::isWebAssemblyModule): (JSC::isWebAssemblyToJSCallee): Deleted. * runtime/JSGlobalObject.cpp: (JSC::JSGlobalObject::init): (JSC::JSGlobalObject::visitChildren): * runtime/JSGlobalObject.h: (JSC::JSGlobalObject::webAssemblyWrapperFunctionStructure const): (JSC::JSGlobalObject::webAssemblyToJSCalleeStructure const): Deleted. * runtime/JSType.cpp: (WTF::printInternal): * runtime/JSType.h: * wasm/WasmOperations.cpp: (JSC::Wasm::operationWasmToJSException): * wasm/js/JSWebAssemblyInstance.cpp: (JSC::JSWebAssemblyInstance::finishCreation): (JSC::JSWebAssemblyInstance::visitChildren): * wasm/js/JSWebAssemblyInstance.h: * wasm/js/JSWebAssemblyModule.cpp: (JSC::JSWebAssemblyModule::createStructure): (JSC::JSWebAssemblyModule::finishCreation): (JSC::JSWebAssemblyModule::visitChildren): (JSC::JSWebAssemblyModule::callee const): Deleted. * wasm/js/JSWebAssemblyModule.h: * wasm/js/WasmToJS.cpp: (JSC::Wasm::handleBadI64Use): (JSC::Wasm::wasmToJS): * wasm/js/WebAssemblyToJSCallee.cpp: Removed. * wasm/js/WebAssemblyToJSCallee.h: Removed. 2019-12-03 Yusuke Suzuki Adopt the new WebAssembly.Global system https://bugs.webkit.org/show_bug.cgi?id=186552 Reviewed by Keith Miller. This patch adds WebAssembly.Global implementation. It is already included in the Wasm spec (this means, it is not in staging right now: it was stage-4, and included in the spec). WebAssembly.Global is a wrapper object around "global" binding. This object can hold "immutable" and "mutable" global binding, and we can access Wasm globals through this object. Furthermore, we can share mutable global binding through this object across WebAssembly modules. To implement it efficiently, this patch introduces BindingMode to Wasm globals. If the mode is EmbeddedInInstance, we continue using the current existing mechanism. If the mode is Portable, we store a pointer to actual value in Wasm globals array in Wasm::Instance, so that we can access it through one additional dereference. And we mark all immutable globals as EmbeddedInInstance. If the binding is immutable, internally we do not need to have one binding. We can just continue using the current mechanism since users cannot observe whether immutable bindings' storage is shared or not. If the global is mutable, and it is exported outside of the module, we use Portable mode. So, all the previously used wasm global bindings are EmbeddedInInstance. Only newly added "mutable" "exported" bindings are Portable and requires one additional dereference. To access portable bindings efficiently, we add new Wasm bytecodes, `get_global_portable_binding`, `set_global_portable_binding`, and `set_global_ref_portable_binding`. This patch improves WPT wasm coverage significantly. * CMakeLists.txt: * DerivedSources-input.xcfilelist: * DerivedSources-output.xcfilelist: * DerivedSources.make: * JavaScriptCore.xcodeproj/project.pbxproj: * Sources.txt: * bytecode/BytecodeList.rb: * heap/HeapCell.cpp: (JSC::keepAlive): (JSC::HeapCell::use const): Deleted. * heap/HeapCell.h: (JSC::keepAlive): (JSC::HeapCell::use const): * llint/WebAssembly.asm: * runtime/JSGlobalObject.cpp: * runtime/JSGlobalObject.h: * runtime/VM.cpp: (JSC::VM::VM): * runtime/VM.h: * wasm/WasmAirIRGenerator.cpp: (JSC::Wasm::AirIRGenerator::getGlobal): (JSC::Wasm::AirIRGenerator::setGlobal): * wasm/WasmB3IRGenerator.cpp: (JSC::Wasm::B3IRGenerator::getGlobal): (JSC::Wasm::B3IRGenerator::setGlobal): * wasm/WasmFormat.h: * wasm/WasmGlobal.cpp: Added. (JSC::Wasm::Global::get const): (JSC::Wasm::Global::set): (JSC::Wasm::Global::visitAggregate): * wasm/WasmGlobal.h: Added. * wasm/WasmInstance.cpp: (JSC::Wasm::Instance::Instance): (JSC::Wasm::Instance::setGlobal): (JSC::Wasm::Instance::linkGlobal): * wasm/WasmInstance.h: (JSC::Wasm::Instance::loadI32Global const): (JSC::Wasm::Instance::loadI64Global const): (JSC::Wasm::Instance::setGlobal): (JSC::Wasm::Instance::globalsToBinding): (JSC::Wasm::Instance::getGlobalBinding): * wasm/WasmLLIntGenerator.cpp: (JSC::Wasm::LLIntGenerator::getGlobal): (JSC::Wasm::LLIntGenerator::setGlobal): * wasm/WasmModuleInformation.h: * wasm/WasmOperations.cpp: (JSC::Wasm::operationWasmWriteBarrierSlowPath): * wasm/WasmOperations.h: * wasm/WasmSectionParser.cpp: (JSC::Wasm::SectionParser::parseImport): (JSC::Wasm::SectionParser::parseGlobal): (JSC::Wasm::SectionParser::parseExport): (JSC::Wasm::SectionParser::parseInitExpr): (JSC::Wasm::SectionParser::parseGlobalType): * wasm/WasmSectionParser.h: * wasm/WasmSlowPaths.cpp: (JSC::LLInt::WASM_SLOW_PATH_DECL): * wasm/WasmSlowPaths.h: * wasm/WasmValidate.cpp: (JSC::Wasm::Validate::setGlobal): * wasm/js/JSWebAssembly.cpp: * wasm/js/JSWebAssemblyGlobal.cpp: Added. (JSC::JSWebAssemblyGlobal::create): (JSC::JSWebAssemblyGlobal::createStructure): (JSC::JSWebAssemblyGlobal::JSWebAssemblyGlobal): (JSC::JSWebAssemblyGlobal::finishCreation): (JSC::JSWebAssemblyGlobal::destroy): (JSC::JSWebAssemblyGlobal::visitChildren): * wasm/js/JSWebAssemblyGlobal.h: Copied from Source/JavaScriptCore/wasm/js/JSWebAssemblyMemory.h. * wasm/js/JSWebAssemblyInstance.cpp: (JSC::JSWebAssemblyInstance::visitChildren): * wasm/js/JSWebAssemblyInstance.h: * wasm/js/JSWebAssemblyMemory.cpp: (JSC::JSWebAssemblyMemory::destroy): * wasm/js/JSWebAssemblyMemory.h: * wasm/js/JSWebAssemblyModule.h: * wasm/js/JSWebAssemblyTable.h: * wasm/js/WebAssemblyGlobalConstructor.cpp: Added. (JSC::constructJSWebAssemblyGlobal): (JSC::callJSWebAssemblyGlobal): (JSC::WebAssemblyGlobalConstructor::create): (JSC::WebAssemblyGlobalConstructor::createStructure): (JSC::WebAssemblyGlobalConstructor::finishCreation): (JSC::WebAssemblyGlobalConstructor::WebAssemblyGlobalConstructor): * wasm/js/WebAssemblyGlobalConstructor.h: Copied from Source/JavaScriptCore/wasm/js/JSWebAssemblyMemory.h. * wasm/js/WebAssemblyGlobalPrototype.cpp: Added. (JSC::getGlobal): (JSC::webAssemblyGlobalProtoFuncValueOf): (JSC::webAssemblyGlobalProtoGetterFuncValue): (JSC::webAssemblyGlobalProtoSetterFuncValue): (JSC::WebAssemblyGlobalPrototype::create): (JSC::WebAssemblyGlobalPrototype::createStructure): (JSC::WebAssemblyGlobalPrototype::finishCreation): (JSC::WebAssemblyGlobalPrototype::WebAssemblyGlobalPrototype): * wasm/js/WebAssemblyGlobalPrototype.h: Copied from Source/JavaScriptCore/wasm/js/JSWebAssemblyMemory.h. * wasm/js/WebAssemblyModuleRecord.cpp: (JSC::WebAssemblyModuleRecord::link): 2019-12-02 Saam Barati PropertySlot should not have Customs have a PropertyOffset of zero https://bugs.webkit.org/show_bug.cgi?id=204566 Reviewed by Keith Miller. We used to say that PropertyOffset of a cacheable custom was always zero. We did this because we were using "invalidOffset" to indicate things aren't cacheable. This patch refactors PropertySlot to not look at PropertyOffset for cacheability, but instead just uses the cacheability bit. With that change, we now say that customs always have the invalid PropertyOffset. This fixes a bug where we used to watch for property changes at the offset inside an AccessCase. We were doing this for the zero property offset for all customs. This could trigger a crash inside startWatchingPropertyForReplacements because the prototype Structure was a dictionary. We allow dictionaries to be property holders of customs as long as the property is a custom and has DontDelete property attribute, since DontDelete proves the custom will never change. * llint/LLIntSlowPaths.cpp: (JSC::LLInt::LLINT_SLOW_PATH_DECL): * runtime/PropertySlot.h: (JSC::PropertySlot::PropertySlot): (JSC::PropertySlot::isCacheable const): (JSC::PropertySlot::setValue): (JSC::PropertySlot::setCustom): (JSC::PropertySlot::setCacheableCustom): (JSC::PropertySlot::setCustomGetterSetter): (JSC::PropertySlot::setGetterSlot): (JSC::PropertySlot::setCacheableGetterSlot): (JSC::PropertySlot::setUndefined): 2019-12-02 Yusuke Suzuki [JSC] Put some destructible objects to IsoSubspace https://bugs.webkit.org/show_bug.cgi?id=204771 Reviewed by Mark Lam. This patch puts DateInstance, ErrorInstance, and Intl objects in IsoSubspace. By using specific IsoHeapCellType, we can use JSNonFinalObject as base-classes of them instead of using JSDestructibleObject. We also introduce STATIC_ASSERT_ISO_SUBSPACE_SHARABLE to ensure that derived class of some IsoSubspace'ed one is intentional and safe. * runtime/ArrayConstructor.h: * runtime/AsyncFunctionConstructor.h: * runtime/AsyncGeneratorFunctionConstructor.h: * runtime/BigIntConstructor.h: * runtime/BooleanConstructor.h: * runtime/DateConstructor.h: * runtime/DateInstance.cpp: (JSC::DateInstance::destroy): Deleted. * runtime/DateInstance.h: * runtime/ErrorConstructor.h: * runtime/ErrorInstance.cpp: (JSC::ErrorInstance::destroy): Deleted. * runtime/ErrorInstance.h: (JSC::ErrorInstance::destroy): (JSC::ErrorInstance::subspaceFor): * runtime/FunctionConstructor.h: * runtime/FunctionPrototype.h: * runtime/GeneratorFunctionConstructor.h: * runtime/IntlCollator.cpp: (JSC::IntlCollator::IntlCollator): (JSC::IntlCollator::destroy): Deleted. * runtime/IntlCollator.h: * runtime/IntlCollatorConstructor.h: * runtime/IntlDateTimeFormat.cpp: (JSC::IntlDateTimeFormat::IntlDateTimeFormat): (JSC::IntlDateTimeFormat::destroy): Deleted. * runtime/IntlDateTimeFormat.h: * runtime/IntlDateTimeFormatConstructor.h: * runtime/IntlNumberFormat.cpp: (JSC::IntlNumberFormat::IntlNumberFormat): (JSC::IntlNumberFormat::destroy): Deleted. * runtime/IntlNumberFormat.h: * runtime/IntlNumberFormatConstructor.h: * runtime/IntlPluralRules.cpp: (JSC::IntlPluralRules::IntlPluralRules): (JSC::IntlPluralRules::destroy): Deleted. * runtime/IntlPluralRules.h: * runtime/IntlPluralRulesConstructor.h: * runtime/JSArrayBufferConstructor.h: * runtime/JSCell.h: * runtime/JSObject.h: * runtime/JSTypedArrayConstructors.h: * runtime/JSTypedArrayViewConstructor.h: * runtime/MapConstructor.h: * runtime/NativeErrorConstructor.h: * runtime/NullGetterFunction.h: * runtime/NullSetterFunction.h: * runtime/NumberConstructor.h: * runtime/ObjectConstructor.h: * runtime/ProxyConstructor.h: * runtime/RegExpConstructor.h: * runtime/SetConstructor.h: * runtime/StringConstructor.h: * runtime/SymbolConstructor.h: * runtime/VM.cpp: (JSC::VM::VM): * runtime/VM.h: * runtime/WeakMapConstructor.h: * runtime/WeakObjectRefConstructor.h: * runtime/WeakSetConstructor.h: * tools/JSDollarVM.cpp: * wasm/js/JSWebAssemblyCompileError.h: * wasm/js/JSWebAssemblyLinkError.h: * wasm/js/JSWebAssemblyRuntimeError.h: * wasm/js/WebAssemblyCompileErrorConstructor.h: * wasm/js/WebAssemblyInstanceConstructor.h: * wasm/js/WebAssemblyLinkErrorConstructor.h: * wasm/js/WebAssemblyMemoryConstructor.h: * wasm/js/WebAssemblyModuleConstructor.h: * wasm/js/WebAssemblyRuntimeErrorConstructor.h: * wasm/js/WebAssemblyTableConstructor.h: 2019-12-02 Mark Lam Only check each use...FuzzerAgent() option in VM constructor if any of the options are enabled. https://bugs.webkit.org/show_bug.cgi?id=204763 Reviewed by Keith Miller. We know that we'll never use fuzzer agents in deployment. Hence, we shouldn't spend time checking for them in the normal use case. This probably doesn't matter much for Web processes, but for clients of JSC that repeatedly spawn and kill VMs, it might matter more. We might want to eventually widen this idiom to include other debugging / development options, but for now, I'm only covering the fuzzer agent options. * runtime/Options.cpp: (JSC::computeIfUsingFuzzerAgent): (JSC::Options::initialize): * runtime/Options.h: (JSC::Options::isUsingFuzzerAgent): * runtime/OptionsList.h: (JSC::OptionRange::operator bool const): * runtime/VM.cpp: (JSC::VM::VM): 2019-12-02 Tadeu Zagallo [JSC] Remove BytecodeCacheVersion.h https://bugs.webkit.org/show_bug.cgi?id=204760 Reviewed by Mark Lam. Having that as a phony make target causes a lot of unnecessary rebuilds. That was a workaround the fact that we only need a new cache version when we rebuild CachedTypes.cpp, but there was no straightforward way to get the current timestamp as an integer at that point. Instead, we now just use a constexpr function that hashes __TIMESTAMP__. * CMakeLists.txt: * DerivedSources-output.xcfilelist: * DerivedSources.make: * runtime/CachedTypes.cpp: (JSC::jscBytecodeCacheVersion): (JSC::GenericCacheEntry::isUpToDate const): 2019-12-02 Mark Lam mozilla-tests.yaml/js1_5/Array/regress-101964.js is frequently failing on JSC EWS bots. https://bugs.webkit.org/show_bug.cgi?id=200789 Reviewed by Keith Miller. * tools/JSDollarVM.cpp: (JSC::functionCurrentCPUTime): (JSC::JSDollarVM::finishCreation): 2019-12-02 Yusuke Suzuki [JSC] Put JSGenerator, JSAsyncGenerator, and JSPromise in IsoSubspace https://bugs.webkit.org/show_bug.cgi?id=204764 Reviewed by Mark Lam. Put more things in IsoSubspace. They are defined by using JSInternalObjectImpl mechanism. - JSGenerator - JSAsyncGenerator - JSPromise * runtime/JSAsyncGenerator.h: * runtime/JSGenerator.h: * runtime/JSPromise.h: (JSC::JSPromise::subspaceFor): * runtime/VM.cpp: (JSC::VM::VM): * runtime/VM.h: 2019-12-01 Tuomas Karkkainen Add FuzzerAgent that reads predictions from a file https://bugs.webkit.org/show_bug.cgi?id=203898 Reviewed by Mark Lam. This patch adds a FuzzerAgent that reads predictions from a file. The predictions in the file are correlated with the prediction sites using the name of the JavaScript source file, the opcode, and start and end offsets in the source. There is also a separate FuzzerAgent that can be used to create the prediction files. * JavaScriptCore.xcodeproj/project.pbxproj: * Sources.txt: * runtime/FileBasedFuzzerAgent.cpp: Added. * runtime/FileBasedFuzzerAgent.h: Copied from Source/JavaScriptCore/runtime/RandomizingFuzzerAgent.cpp. * runtime/FileBasedFuzzerAgentBase.cpp: Added. * runtime/FileBasedFuzzerAgentBase.h: Copied from Source/JavaScriptCore/runtime/RandomizingFuzzerAgent.cpp. * runtime/FuzzerPredictions.cpp: Added. * runtime/FuzzerPredictions.h: Copied from Source/JavaScriptCore/runtime/RandomizingFuzzerAgent.cpp. * runtime/Options.cpp: * runtime/OptionsList.h: * runtime/PredictionFileCreatingFuzzerAgent.cpp: Copied from Source/JavaScriptCore/runtime/RandomizingFuzzerAgent.cpp. * runtime/PredictionFileCreatingFuzzerAgent.h: Copied from Source/JavaScriptCore/runtime/RandomizingFuzzerAgent.cpp. * runtime/RandomizingFuzzerAgent.cpp: * runtime/VM.cpp: 2019-12-01 Caio Lima [JSC][MIPS] CallFrame is being clobbered on InternalFunction execution https://bugs.webkit.org/show_bug.cgi?id=203739 Reviewed by Saam Barati. MIPS calling conventions requires that we have stack space reserved for 4 (16-bytes) arguments ($a0-$a3). The caller doesn't use this space, but callee can still use it in case where they need to save arguments or even reuse to another allocation. Since we were not allocationg it during `makeHostFunctionCall`, the caller frame slot was being clobberred by `callGenericTypedArrayView` execution, resulting in a corrupted call frame stack. This patch is adjusting this convention into ThunkGenerator and on `makeHostFunctionCall`. * jit/ThunkGenerators.cpp: (JSC::nativeForGenerator): * llint/LowLevelInterpreter32_64.asm: 2019-12-01 Caio Lima Implement GetByVal inline caching for 32-bit JITs https://bugs.webkit.org/show_bug.cgi?id=204082 Reviewed by Saam Barati. We are adding 32-bit support for GetByVal cases added on r252684. This requires changes on some of the IC code generated to properly support JSVALUE32_64. The major difference from JSVALUE64 is the usage of tagGPR to inspect value types and store results. * bytecode/AccessCase.cpp: (JSC::AccessCase::generateWithGuard): (JSC::AccessCase::generateImpl): * bytecode/GetterSetterAccessCase.cpp: (JSC::GetterSetterAccessCase::emitDOMJITGetter): * bytecode/PolymorphicAccess.cpp: (JSC::PolymorphicAccess::regenerate): * bytecode/StructureStubInfo.h: Since a generator can't have `thisGPR` and `propertyGPR` at se same time, we created a new `union` to share `thisTagGPR` and `propertyTagGPR`, matching the approach we have for `JITInlineCacheGenerator::patch.u`. (JSC::StructureStubInfo::propertyRegs const): (JSC::StructureStubInfo::baseRegs const): To simplify scratch register allocation, we added `baseRegs()` and `propertyRegs()` to `StructureStubInfo`, so we can easily retrive payload and tag GPRs for those operands, keeping them locked. * dfg/DFGSpeculativeJIT32_64.cpp: (JSC::DFG::SpeculativeJIT::compile): * jit/JITInlineCacheGenerator.cpp: (JSC::JITByIdGenerator::JITByIdGenerator): (JSC::JITGetByIdWithThisGenerator::JITGetByIdWithThisGenerator): (JSC::JITInstanceOfGenerator::JITInstanceOfGenerator): (JSC::JITGetByValGenerator::JITGetByValGenerator): * jit/JITPropertyAccess32_64.cpp: (JSC::JIT::emit_op_get_by_val): (JSC::JIT::emitSlow_op_get_by_val): 2019-11-29 Eike Rathke Use default implementation for JSVALUE64 with GCC on unknown platform. https://bugs.webkit.org/show_bug.cgi?id=204701 Building on ppc64le and s390x failed with #error "Unknown architecture." Use the default implementation as fallback in these cases. Reviewed by Saam Barati. * heap/GCMemoryOperations.h: (JSC::gcSafeMemcpy): (JSC::gcSafeMemmove): (JSC::gcSafeZeroMemory): 2019-11-28 Fujii Hironori Remove ENABLE_KEYBOARD_CODE_ATTRIBUTE and ENABLE_KEYBOARD_KEY_ATTRIBUTE macros https://bugs.webkit.org/show_bug.cgi?id=204666 Reviewed by Ross Kirsling and Don Olmstead. * Configurations/FeatureDefines.xcconfig: 2019-11-26 Tuomas Karkkainen Attempting to enable more than one FuzzerAgent should result in an error https://bugs.webkit.org/show_bug.cgi?id=204607 Reviewed by Antti Koivisto. * runtime/VM.cpp: * runtime/VM.h: 2019-11-26 Carlos Garcia Campos [GLIB] The API lock should be held before calling JSC::createTypeError https://bugs.webkit.org/show_bug.cgi?id=204573 Reviewed by Mark Lam. We are missing it in several places. This is causing a crash in test /jsc/object after r252298. * API/glib/JSCContext.cpp: (jscContextGArrayToJSArray): (jscContextJSArrayToGArray): (jscContextGValueToJSValue): (jscContextJSValueToGValue): * API/glib/JSCValue.cpp: (jsc_value_new_array): (jscValueCallFunction): 2019-11-25 Yusuke Suzuki [JSC] InternalFunction should be non-destructible https://bugs.webkit.org/show_bug.cgi?id=204556 Reviewed by Mark Lam. InternalFunction and most of its subclasses should be non-destructible since they can be trivially destructed and don't use a destroy function. For the few subclasses that do need a destroy function, these should have different IsoSubspaces of their own. For each of these subclasses, we annotate needsDestruction = true, define a specific HeapCellType for them, and pass the HeapCellType to their IsoSubspace so that their destructors can be invoked. * API/ObjCCallbackFunction.h: * API/glib/JSCCallbackFunction.cpp: (JSC::JSCCallbackFunction::subspaceForImpl): Deleted. * API/glib/JSCCallbackFunction.h: (JSC::JSCCallbackFunction::subspaceFor): Deleted. (JSC::JSCCallbackFunction::createStructure): Deleted. (JSC::JSCCallbackFunction::functionCallback): Deleted. (JSC::JSCCallbackFunction::constructCallback): Deleted. * dfg/DFGByteCodeParser.cpp: (JSC::DFG::ByteCodeParser::handleTypedArrayConstructor): (JSC::DFG::ByteCodeParser::handleConstantInternalFunction): * runtime/InternalFunction.cpp: (JSC::InternalFunction::InternalFunction): * runtime/InternalFunction.h: * runtime/VM.cpp: (JSC::VM::VM): * runtime/VM.h: 2019-11-25 Saam Barati Unreviewed. Fix 32-bit build. * bytecode/GetByValHistory.h: (JSC::GetByValHistory::observeNonUID): (JSC::GetByValHistory::observe): (JSC::GetByValHistory::count const): (JSC::GetByValHistory::filter const): 2019-11-24 Yusuke Suzuki [JSC] Introduce IsoHeapCellType https://bugs.webkit.org/show_bug.cgi?id=204555 Reviewed by Mark Lam. We introduce IsoHeapCellType, which destroys cell based on CellType information, which should be in IsoSubspace. By using this, we can avoid inheriting JSDestructibleObject. For each IsoSubspace, we know how to destroy cells if we use IsoHeapCellType without using methodTable. We start using it for, JSString, JSWeakMap, JSWeakSet, WebAssemblyFunction, and JSWebAssemblyCodeBlock. And we use JSNonFinalObject for the base of JSWeakMap and JSWeakSet, which shrinks size of them from 48 to 32. * CMakeLists.txt: * JavaScriptCore.xcodeproj/project.pbxproj: * Sources.txt: * heap/IsoHeapCellType.h: Renamed from Source/JavaScriptCore/wasm/js/WebAssemblyFunctionHeapCellType.h. * runtime/JSString.cpp: (JSC::JSString::destroy): Deleted. * runtime/JSString.h: (JSC::JSString::destroy): * runtime/JSStringHeapCellType.cpp: Removed. * runtime/JSStringHeapCellType.h: Removed. * runtime/VM.cpp: (JSC::VM::VM): * runtime/VM.h: * runtime/WeakMapImpl.h: * wasm/js/JSWebAssemblyCodeBlockHeapCellType.cpp: Removed. * wasm/js/JSWebAssemblyCodeBlockHeapCellType.h: Removed. * wasm/js/WebAssemblyFunctionHeapCellType.cpp: Removed. 2019-11-23 Ross Kirsling [JSC] GetSubstitution is performed incorrectly via RegExp.prototype[@@replace] https://bugs.webkit.org/show_bug.cgi?id=204490 Reviewed by Mark Lam. String.prototype.replace and RegExp.prototype[Symbol.replace] are meant to perform the same substitution of $-backreferences (called GetSubstitution in the spec: https://tc39.es/ecma262/#sec-getsubstitution). The implementation of this in StringPrototype.cpp is correct but the one in RegExpPrototype.js is not. In particular, the latter *removes* backreferences with out-of-range indices, instead of leaving them as-is. One thing that is *not* broken in either implementation and thus maintained here is the fact $10 is interpreted as $1 followed by a 0 when we have 1 <= n < 10 captures (and analogously for other invalid $nn backreferences). This behavior is consistent across all engines but currently described incorrectly in the spec; this patch thus aligns with the spec PR currently open to correct this (https://github.com/tc39/ecma262/pull/1732). * builtins/RegExpPrototype.js: (getSubstitution): Ensure that invalid backreferences remain untouched in the output string. (replace): Fix off-by-one error when populating captures list. We shouldn't be reserving a slot for the full match. 2019-11-22 Saam Barati Use LLInt profiling to rule out generating an IC for get_by_val https://bugs.webkit.org/show_bug.cgi?id=204536 Reviewed by Yusuke Suzuki. When I landed the get_by_val polymorphic inline caching patch, the prepack benchmark in JetStream2 slowed down by 10%. Through some analysis, I found out that we were slowing down because of the time we spent in the JITs actually generating inline caches. This patch skips generating an inline cache when it seems like it won't be profitable. The heuristic for doing this is simple: - If we see more than 4 identifiers in the LLInt, we won't generate an IC in the upper tiers. - If we see a non-identifier JSString in the LLInt, we won't generate an IC in the upper tiers. This patch recovers the regression on prepack. * bytecode/BytecodeList.rb: * dfg/DFGByteCodeParser.cpp: (JSC::DFG::ByteCodeParser::parseBlock): * dfg/DFGOperations.cpp: * dfg/DFGOperations.h: * generator/main.rb: * heap/TinyBloomFilter.h: (JSC::TinyBloomFilter::bits const): (JSC::TinyBloomFilter::TinyBloomFilter): * jit/JIT.h: * jit/JITOperations.cpp: * jit/JITOperations.h: * jit/JITPropertyAccess.cpp: (JSC::JIT::emit_op_get_by_val): (JSC::JIT::emitSlow_op_get_by_val): * llint/LLIntSlowPaths.cpp: (JSC::LLInt::LLINT_SLOW_PATH_DECL): * runtime/Operations.h: (JSC::getByValWithIndex): * runtime/OptionsList.h: 2019-11-22 Per Arne Vollan Fix compile error in release mode https://bugs.webkit.org/show_bug.cgi?id=204534 Reviewed by Mark Lam. A compiler error is thrown in release mode when compiling FullBytecodeLiveness::getLiveness, since not all paths are returning a value. * bytecode/FullBytecodeLiveness.h: (JSC::FullBytecodeLiveness::getLiveness const): 2019-11-22 Tadeu Zagallo [WebAssembly] Improve Wasm::LLIntGenerator https://bugs.webkit.org/show_bug.cgi?id=204092 Reviewed by Saam Barati. This improves the Wasm::LLIntGenerator by: - Changing LLIntGenerator::ExpressionType from RefPtr to VirtualRegister: Instead of allocating and retaining RegisterIDs we use VirtualRegisters directly and ensure that they match the WebAssembly stack, i.e. the parser's expression stack should match the virtual registers. - Removing redundant moves when materializing constants and performing local.get: instead of creating a new temporary for each constant and local.get, we return the VirtualRegister for the constant/local slot directly. In order for this to work, we still allocate the stack slot for the temporaries, since we have to materialize them before loops and branches. - Adding a constructor to ControlType that takes the results ExpressionList as an rvalue instead of copying it - Optimizing callInformationFor, which is now split into two functions. The callee does not care about arguments, and should never allocate temporaries, and the caller case was optimized by avoiding unnecessary calls to newTemporary - Delay holding the lock in LLintPlan::compileFunction, since we do not need to hold it while compiling the js-to-wasm entrypoint * bytecode/BytecodeList.rb: * bytecompiler/Label.h: (JSC::GenericLabel::location const): (JSC::GenericLabel::unresolvedJumps const): * generator/Wasm.rb: * llint/WebAssembly.asm: * wasm/WasmAirIRGenerator.cpp: (JSC::Wasm::AirIRGenerator::endTopLevel): (JSC::Wasm::AirIRGenerator::didPopValueFromStack): * wasm/WasmB3IRGenerator.cpp: (JSC::Wasm::B3IRGenerator::endTopLevel): (JSC::Wasm::B3IRGenerator::didPopValueFromStack): * wasm/WasmFunctionCodeBlock.cpp: (JSC::Wasm::FunctionCodeBlock::addJumpTable): * wasm/WasmFunctionCodeBlock.h: * wasm/WasmFunctionParser.h: (JSC::Wasm::FunctionParser::expressionStack): (JSC::Wasm::FunctionParser::parseBody): (JSC::Wasm::FunctionParser::parseExpression): * wasm/WasmLLIntGenerator.cpp: (JSC::Wasm::LLIntGenerator::ControlType::loop): (JSC::Wasm::LLIntGenerator::ControlType::topLevel): (JSC::Wasm::LLIntGenerator::ControlType::block): (JSC::Wasm::LLIntGenerator::ControlType::if_): (JSC::Wasm::LLIntGenerator::ControlType::targetArity const): (JSC::Wasm::LLIntGenerator::ControlType::stackSize const): (JSC::Wasm::LLIntGenerator::ControlType::ControlType): (JSC::Wasm::LLIntGenerator::unifyValuesWithBlock): (JSC::Wasm::LLIntGenerator::push): (JSC::Wasm::LLIntGenerator::didPopValueFromStack): (JSC::Wasm::LLIntGenerator::emptyExpression): (JSC::Wasm::LLIntGenerator::addEndToUnreachable): (JSC::Wasm::LLIntGenerator::dump): (JSC::Wasm::LLIntGenerator::virtualRegisterForWasmLocal): (JSC::Wasm::LLIntGenerator::jsNullConstant): (JSC::Wasm::LLIntGenerator::zeroConstant): (JSC::Wasm::LLIntGenerator::getDropKeepCount): (JSC::Wasm::LLIntGenerator::dropKeep): (JSC::Wasm::LLIntGenerator::walkExpressionStack): (JSC::Wasm::LLIntGenerator::checkConsistency): (JSC::Wasm::LLIntGenerator::materializeConstantsAndLocals): (JSC::Wasm::LLIntGenerator::materializeLocals): (JSC::Wasm::LLIntGenerator::ConstantMapHashTraits::constructDeletedValue): (JSC::Wasm::LLIntGenerator::ConstantMapHashTraits::isDeletedValue): (JSC::Wasm::LLIntGenerator::LLIntGenerator): (JSC::Wasm::LLIntGenerator::finalize): (JSC::Wasm::LLIntGenerator::callInformationForCaller): (JSC::Wasm::LLIntGenerator::callInformationForCallee): (JSC::Wasm::LLIntGenerator::addArguments): (JSC::Wasm::LLIntGenerator::addLocal): (JSC::Wasm::LLIntGenerator::didFinishParsingLocals): (JSC::Wasm::LLIntGenerator::addConstant): (JSC::Wasm::LLIntGenerator::getLocal): (JSC::Wasm::LLIntGenerator::setLocal): (JSC::Wasm::LLIntGenerator::getGlobal): (JSC::Wasm::LLIntGenerator::addLoop): (JSC::Wasm::LLIntGenerator::addTopLevel): (JSC::Wasm::LLIntGenerator::addBlock): (JSC::Wasm::LLIntGenerator::addIf): (JSC::Wasm::LLIntGenerator::addElse): (JSC::Wasm::LLIntGenerator::addElseToUnreachable): (JSC::Wasm::LLIntGenerator::addReturn): (JSC::Wasm::LLIntGenerator::addBranch): (JSC::Wasm::LLIntGenerator::addSwitch): (JSC::Wasm::LLIntGenerator::endBlock): (JSC::Wasm::LLIntGenerator::endTopLevel): (JSC::Wasm::LLIntGenerator::addCall): (JSC::Wasm::LLIntGenerator::addCallIndirect): (JSC::Wasm::LLIntGenerator::addRefIsNull): (JSC::Wasm::LLIntGenerator::addRefFunc): (JSC::Wasm::LLIntGenerator::addTableGet): (JSC::Wasm::LLIntGenerator::addTableSize): (JSC::Wasm::LLIntGenerator::addTableGrow): (JSC::Wasm::LLIntGenerator::addCurrentMemory): (JSC::Wasm::LLIntGenerator::addGrowMemory): (JSC::Wasm::LLIntGenerator::addSelect): (JSC::Wasm::LLIntGenerator::load): (JSC::GenericLabel::setLocation): * wasm/WasmLLIntPlan.cpp: (JSC::Wasm::LLIntPlan::compileFunction): * wasm/WasmValidate.cpp: (JSC::Wasm::Validate::endTopLevel): (JSC::Wasm::Validate::didPopValueFromStack): 2019-11-22 Yusuke Suzuki [JSC] DFG terminal's liveness should respect caller's opcodeID https://bugs.webkit.org/show_bug.cgi?id=204317 Reviewed by Saam Barati. Let's consider the following example, which is freqneutly seen in Speedometer2/EmberJS-Debug. "use strict"; function assertImpl(cond) { if (!cond) throw new Error(); } function assert() { assertImpl.apply(undefined, arguments); } noInline(assert); When compiling `throw`, we emit a terminal node and put Phantom/PhantomLocal based on the bytecode liveness. When collecting liveness for each frame, we use the liveness information of the bytecode `op_call_varargs` in assert function. This means that op_call_varargs's uses are considered as live (like, `arguments` in this example). But it is not necessary to mark it "live": if we are in assertImpl, `arguments` is already loaded into the stack, and we no longer use `arguments` when exiting, and the execution after the exit. Marking this `arguments` live makes this `arguments` allocated in DFG, but this is wasteful. In this patch, we introduce BeforeUse and AfterUse concept into bytecode liveness information. And use AfterUse information when collecting liveness in the caller's frame in DFG. We only enable this for varargs for now since (1) applying this to the other ones is not profitable, and (2) we need to be careful to make stack arguments live to allow materialization of arguments objects. In op_call_varargs / op_tail_call_varargs / op_construct_varargs cases, uses are happen only for |callee|, |this|, and |arguments|. And these are no longer necessary after calling. We don't use liveness information in the next bytecode since it misses uses marked by exception handlers. * bytecode/BytecodeLivenessAnalysis.cpp: (JSC::BytecodeLivenessAnalysis::computeFullLiveness): * bytecode/BytecodeLivenessAnalysis.h: (JSC::BytecodeLivenessAnalysis::graph): * bytecode/BytecodeLivenessAnalysisInlines.h: (JSC::BytecodeLivenessPropagation::stepOverInstructionDef): (JSC::BytecodeLivenessPropagation::stepOverInstructionUse): (JSC::BytecodeLivenessPropagation::stepOverInstructionUseInExceptionHandler): (JSC::BytecodeLivenessPropagation::stepOverInstruction): * bytecode/BytecodeUseDef.h: (JSC::computeUsesForBytecodeIndex): (JSC::computeDefsForBytecodeIndex): * bytecode/FullBytecodeLiveness.h: (JSC::FullBytecodeLiveness::getLiveness const): (JSC::FullBytecodeLiveness::operandIsLive const): * bytecompiler/BytecodeGenerator.cpp: (JSC::ForInContext::finalize): * dfg/DFGByteCodeParser.cpp: (JSC::DFG::ByteCodeParser::flushForTerminalImpl): * dfg/DFGForAllKills.h: (JSC::DFG::forAllKilledOperands): * dfg/DFGGraph.cpp: (JSC::DFG::Graph::isLiveInBytecode): * dfg/DFGGraph.h: (JSC::DFG::Graph::forAllLocalsLiveInBytecode): (JSC::DFG::Graph::appropriateLivenessCalculationPoint): * llint/LowLevelInterpreter32_64.asm: * llint/LowLevelInterpreter64.asm: 2019-11-22 Carlos Garcia Campos Unreviewed. Fix GTK/WPE debug build after r252770 Just remove the ASSERT instead, since it now always receive a newly created Ref. * inspector/remote/glib/RemoteInspectorGlib.cpp: (Inspector::RemoteInspector::setupConnection): 2019-11-22 Carlos Garcia Campos Unreviewed. Fix GTK/WPE debug build after r252770 * inspector/remote/glib/RemoteInspectorGlib.cpp: (Inspector::RemoteInspector::setupConnection): 2019-11-22 Carlos Garcia Campos [GTK][WPE] RemoteInspector: use sockets instead of DBus https://bugs.webkit.org/show_bug.cgi?id=204503 Reviewed by Žan Doberšek. It turns out DBus is event slower than expected. Using GSockets API we can simplify the code and make it a lot more efficient. This will drastically reduce the time to run WebDriver tests in the bots. * inspector/remote/RemoteInspector.h: * inspector/remote/glib/RemoteInspectorGlib.cpp: (Inspector::RemoteInspector::start): (Inspector::RemoteInspector::stopInternal): (Inspector::RemoteInspector::setupConnection): (Inspector::RemoteInspector::pushListingsNow): (Inspector::RemoteInspector::pushListingsSoon): (Inspector::RemoteInspector::sendAutomaticInspectionCandidateMessage): (Inspector::RemoteInspector::sendMessageToRemote): * inspector/remote/glib/RemoteInspectorServer.cpp: (Inspector::RemoteInspectorServer::~RemoteInspectorServer): (Inspector::RemoteInspectorServer::start): (Inspector::RemoteInspectorServer::incomingConnectionCallback): (Inspector::RemoteInspectorServer::incomingConnection): (Inspector::RemoteInspectorServer::setTargetList): (Inspector::RemoteInspectorServer::setupInspectorClient): (Inspector::RemoteInspectorServer::setup): (Inspector::RemoteInspectorServer::close): (Inspector::RemoteInspectorServer::connectionDidClose): (Inspector::RemoteInspectorServer::sendMessageToBackend): (Inspector::RemoteInspectorServer::sendMessageToFrontend): (Inspector::RemoteInspectorServer::startAutomationSession): * inspector/remote/glib/RemoteInspectorServer.h: (Inspector::RemoteInspectorServer::isRunning const): 2019-11-22 Mark Lam Fix missing exception check in replaceUsingStringSearch(). https://bugs.webkit.org/show_bug.cgi?id=204496 Reviewed by Yusuke Suzuki. The CachedCall constructor can throw OutOfMemory or StackOverflow errors. This was caught by existing JSC stress tests when we run with a debug build. Also placate the exception check validator in $vm's functionCallWithStackSize(). * runtime/StringPrototype.cpp: (JSC::replaceUsingStringSearch): * tools/JSDollarVM.cpp: (JSC::functionCallWithStackSize): 2019-11-21 Mark Lam replaceUsingStringSearch() should not use CachedCall with host functions. https://bugs.webkit.org/show_bug.cgi?id=204494 Reviewed by Ross Kirsling. The CachedCall mechanism does not support calling hist functions. * runtime/StringPrototype.cpp: (JSC::replaceUsingStringSearch): 2019-11-21 Saam Barati GetByStatus should not say it took the slow path for multiple identifiers and should have a way to indicate if the StructureStubInfo it saw took the slow path https://bugs.webkit.org/show_bug.cgi?id=204435 Reviewed by Tadeu Zagallo. I discovered some issues with get by val ICs when re-running the microbenchmarks I wrote. I noticed that we were faster when not running with the DFG. The reason for this is that we were only emitting a get by val IC in the DFG/FTL when we observe the GetByStatus says it didn't "go to the slow path". The logic in GetByStatus for building up a variant list was wrong for ICs with multiple identifiers. We have a consistency check when building up the list to ensure that no two variants have structure sets which overlap, because we wouldn't know which one to choose. However, we were accidentally saying two GetByIdVariants overlap when they had different identifiers. This patch fixes that bug by also doing an identifier comparison check. Two GetByIdVariants with different identifiers do not overlap. We also used to say a GetByStatus "goes to the slow path" if any of the cases were an array-like load. I wrote that code thinking that ArrayProfile would just handle it. However, sometimes we have a get by val IC that both has string properties and int32 properties. In these kinds of scenarios, an IC is super profitable. This patch now distinguishes between a GetByStatus saying "we're a slow path" and if we actually observed the StructureStubInfo go to the slow path. In the DFG/FTL, we only forgo emitting a get by val IC when observing a prior StructureStubInfo that went to the slow path. I also realized are call to StructureStubInfo::considerCaching was wrong for get by val ICs. We were only considering the Structure in isolation, not the { Structure, Identifier } pair. For get by val, we need to consider the pair together, since {s1, "a"} and {s1, "b"} will be two different access cases. This patch demonstrates that on these microbenchmarks, get by val ICs can be between 50-200% faster. * bytecode/GetByIdVariant.cpp: (JSC::GetByIdVariant::dumpInContext const): * bytecode/GetByIdVariant.h: (JSC::GetByIdVariant::overlaps): * bytecode/GetByStatus.cpp: (JSC::GetByStatus::GetByStatus): (JSC::GetByStatus::computeForStubInfoWithoutExitSiteFeedback): (JSC::GetByStatus::makesCalls const): (JSC::GetByStatus::slowVersion const): (JSC::GetByStatus::merge): (JSC::GetByStatus::dump const): * bytecode/GetByStatus.h: (JSC::GetByStatus::GetByStatus): (JSC::GetByStatus::takesSlowPath const): (JSC::GetByStatus::observedStructureStubInfoSlowPath const): * bytecode/ICStatusUtils.h: (JSC::appendICStatusVariant): * bytecode/InByIdVariant.h: (JSC::InByIdVariant::overlaps): * bytecode/InstanceOfVariant.h: (JSC::InstanceOfVariant::overlaps): * bytecode/PutByIdVariant.h: (JSC::PutByIdVariant::overlaps): * bytecode/StructureStubInfo.cpp: (JSC::StructureStubInfo::visitWeakReferences): * bytecode/StructureStubInfo.h: (JSC::StructureStubInfo::considerCaching): * dfg/DFGByteCodeParser.cpp: (JSC::DFG::ByteCodeParser::parseBlock): * jit/JITOperations.cpp: 2019-11-21 Mark Lam Fix broken String.prototype.replace() and replaceAll(). https://bugs.webkit.org/show_bug.cgi?id=204479 Reviewed by Ross Kirsling and Yusuke Suzuki. String.prototype.replace() regressed due to r252683: for webkit.org/b/202471. The patch failed to handle InternalFunctions. This patch also fixed a spec compliance bug for String.prototype.replace() i.e. the replaceValue needs to be evaluated before we check if there's a match in the source string. Ref: 21.1.3.16-6 at https://www.ecma-international.org/ecma-262/10.0/#sec-string.prototype.replace For String.prototype.replaceAll(), make sure it "behaves just like String.prototype.replace if searchValue is a global regular expression". Ref: https://github.com/tc39/proposal-string-replaceall r252683 also made replaceUsingStringSearch() work the same way as replaceUsingRegExpSearch(). I think this is the wrong trade off to make. replaceUsingRegExpSearch() expects each search leg to do a RegExp search, which is inherently expensive. We shouldn't make string searches slower just because the RegExp search does it that way. However, at https://bugs.webkit.org/show_bug.cgi?id=202471#c22, Ross pointed out that JetStream 2 results appeared to be neutral. I think we should double check with a micro-benchmark as well. I'll leave this for a later patch. For now, the goal of this patch is simply to achieve correctness. Ref: https://bugs.webkit.org/show_bug.cgi?id=204481 * runtime/StringPrototype.cpp: (JSC::replaceUsingRegExpSearch): (JSC::replaceUsingStringSearch): 2019-11-21 Per Arne Vollan Fix Win64 compile errors https://bugs.webkit.org/show_bug.cgi?id=204471 Reviewed by Brent Fulgham. Fix warnings being treated as errors. * bytecode/AccessCase.cpp: (JSC::AccessCase::requiresIdentifierNameMatch const): (JSC::AccessCase::requiresInt32PropertyCheck const): (JSC::AccessCase::needsScratchFPR const): (JSC::AccessCase::doesCalls const): (JSC::AccessCase::canReplace const): * dfg/DFGOSRExit.cpp: (JSC::DFG::OSRExit::executeOSRExit): * jit/JITOperations.cpp: (JSC::profiledAdd): * jit/Repatch.cpp: (JSC::appropriateOptimizingGetByFunction): (JSC::appropriateGetByFunction): * tools/JSDollarVM.cpp: (JSC::functionCallWithStackSize): 2019-11-21 Yusuke Suzuki Unreviewed, rolling in again, regression is not caused by it https://bugs.webkit.org/show_bug.cgi?id=202471 * builtins/BuiltinNames.h: * builtins/StringPrototype.js: (replaceAll): * runtime/StringPrototype.cpp: (JSC::StringPrototype::finishCreation): (JSC::jsSpliceSubstringsWithSeparators): (JSC::replaceUsingStringSearch): (JSC::replace): (JSC::stringProtoFuncReplaceUsingStringSearch): (JSC::stringProtoFuncReplaceAllUsingStringSearch): 2019-11-21 Commit Queue Unreviewed, rolling out r252683 and r252721. https://bugs.webkit.org/show_bug.cgi?id=204475 13% regression in JetStream2/prepack-wtb (Requested by yusukesuzuki on #webkit). Reverted changesets: "Implement String.prototype.replaceAll" https://bugs.webkit.org/show_bug.cgi?id=202471 https://trac.webkit.org/changeset/252683 "Unreviewed, address Darin's feedback on r252683." https://trac.webkit.org/changeset/252721 2019-11-21 Devin Rousso Web Inspector: removing the blackbox for a specific script doesn't actually remove the blackbox https://bugs.webkit.org/show_bug.cgi?id=204428 Reviewed by Timothy Hatcher. Previously, when updating the blackbox state of each existing script, we would only tell the `Debugger` about when scripts should be blackboxed, not when they shouldn't. This means that when a given script is un-blackboxed, the `Debugger` would never get told about it and would therefore still defer pauses as if it was blackboxed. The solution to this is simple; update the blackboxed state of every script, not just those that should be blackboxed, and tell the `Debugger` about each. * inspector/agents/InspectorDebuggerAgent.cpp: (Inspector::InspectorDebuggerAgent::setShouldBlackboxURL): 2019-11-20 Yusuke Suzuki [JSC] Extend MacroAssemblerARM64::load/store for datasize = 16 https://bugs.webkit.org/show_bug.cgi?id=204442 Reviewed by Mark Lam. Our `void load16(const void* address, RegisterID dest)` and `void store16(RegisterID src, const void* address)` are not aware of the condition that passed register can be memoryTempRegister, while `MacroAssemblerARM64::{load,store}` handles it correctly, e.g. `load` invalidates `cachedMemoryTempRegister` if destination register is memoryTempRegister. As a result, when we are emitting `or16(TrustedImm32 imm, AbsoluteAddress address)` with address where the address's value does not fit in imm, the generated code is reusing memoryTempRegister incorrectly. 0xedf8d4fb4: mov x17, #0x7af0 0xedf8d4fb8: movk x17, #0xd5a, lsl #16 0xedf8d4fbc: movk x17, #0x1, lsl #32 // Construct imm register on x17. 0xedf8d4fc0: ldrh w17, [x17] // Load half word from x17 to w17 (we should invalidate x17 memoryTempRegister here). 0xedf8d4fc4: mov w16, #0x1b 0xedf8d4fc8: orr w16, w17, w16 0xedf8d4fcc: strh w16, [x17] // x17 memoryTempRegister is reused while its content is invalid. The problem is that `load` and `store` functions are not supporting datasize = 16 case. This patch extends `MacroAssemblerARM64::{load,store}` to support 16 so that `or16` implementation looks is similar to `or32` etc. * assembler/MacroAssemblerARM64.h: (JSC::MacroAssemblerARM64::load16): (JSC::MacroAssemblerARM64::store16): (JSC::MacroAssemblerARM64::load): (JSC::MacroAssemblerARM64::store): * assembler/testmasm.cpp: (JSC::testOrImmMem): 2019-11-20 Saam Barati Baseline JIT should fill in StructureStubInfo's propertyIsInt32 and the slow path should update the array profile more frequently https://bugs.webkit.org/show_bug.cgi?id=204432 Reviewed by Tadeu Zagallo. When I added inline caching for get by val, I removed code which updated the ArrayProfile with some frequency. This patch adds code that does that back, which recovers some of the JetStream2 regressions we are seeing. * jit/JITOperations.cpp: * jit/JITPropertyAccess.cpp: (JSC::JIT::emit_op_get_by_val): 2019-11-20 Ross Kirsling Unreviewed, address Darin's feedback on r252683. * runtime/StringPrototype.cpp: (JSC::replaceUsingStringSearch): (JSC::replace): (JSC::stringProtoFuncReplaceUsingStringSearch): (JSC::stringProtoFuncReplaceAllUsingStringSearch): 2019-11-20 Caio Lima [JSC] OSR exit to LLInt is broken on MIPS https://bugs.webkit.org/show_bug.cgi?id=203737 Reviewed by Yusuke Suzuki. This patch is adjusting the OSR to LLInt mechanism to MIPS. When we use PIC on this architecture, we need to properly configure `$gp` at some places to be able to access global variables. This is required on LLInt to access Global Offset Table (got). According to MIPS ABI, the `$gp` can be recalculated during function prologue using caller register `$t9`. We also emit such instructions (we can see this as `OFFLINE_ASM_CPLOAD` macro) immediately after a non-local label on LLInt. With the introduction of OSR to LLInt mechanism, we now have return location labels that are reached from `ret` LLInt instructions. Such return locations are used to properly return to LLInt execution whenever an OSR exits from inlined call on DFG or FTL to LLInt. When OSR is materializing LLInt stack frames for inlined functions (or accessors), it sets return address to its return location label. This means that for such labels, we need to adjust `$gp` using `$ra` instead of `$t9`, given that LLInt `ret` operation uses `jr $ra` to jump the execution to there. To implement this, we changed `mipsAddPICCode` to emit code using the correct register required to recalculate `$gp`. We also changed `callTargetFunction` to use the stubs as return location points, since the declaration of global labels will emmit `OFFLINE_ASM_CPLOAD($ra)` and we don't want to execute it during normal LLInt execution. * llint/LowLevelInterpreter.asm: * offlineasm/mips.rb: 2019-11-20 Robin Morisset Fix load<16> on ARM64 https://bugs.webkit.org/show_bug.cgi?id=204326 Reviewed by Mark Lam. On ARM64 I used load<16> in https://bugs.webkit.org/show_bug.cgi?id=202832. Unfortunately it turns out to call ldr<16>, and ldr asserts that n is either 32 or 64. This fix simply calls ldrh/strh directly. * assembler/MacroAssemblerARM64.h: (JSC::MacroAssemblerARM64::load16): (JSC::MacroAssemblerARM64::store16): 2019-11-20 Mark Lam Flaky JSC test: stress/stack-overflow-in-yarr-byteCompile.js.dfg-eager. https://bugs.webkit.org/show_bug.cgi?id=204405 Reviewed by Alexey Proskuryakov. $vm.allWithStackSize() manipulates the stack in ways that will freak out ASan. So, add SUPPRESS_ASAN to functionCallWithStackSize() to tell ASan to ignore it. * tools/JSDollarVM.cpp: 2019-11-20 Caio Lima Regression (r252680): JSCOnly build broken: no matching function for call to JSC::DFG::SpeculativeJIT::jsValueResult https://bugs.webkit.org/show_bug.cgi?id=204404 Reviewed by Saam Barati. Adjusting build after changes from r252684 and r252680. * bytecode/AccessCase.cpp: (JSC::AccessCase::generateWithGuard): * dfg/DFGSpeculativeJIT.cpp: (JSC::DFG::SpeculativeJIT::compileIncOrDec): * dfg/DFGSpeculativeJIT32_64.cpp: (JSC::DFG::SpeculativeJIT::compile): * jit/JITOpcodes32_64.cpp: (JSC::JIT::emit_op_to_numeric): * jit/JITPropertyAccess32_64.cpp: (JSC::JIT::emit_op_get_by_val): (JSC::JIT::emitSlow_op_get_by_val): 2019-11-19 Saam Barati GetByVal should use polymorphic access and hook into a status object https://bugs.webkit.org/show_bug.cgi?id=202767 Reviewed by Keith Miller. This patch puts get_by_val in our normal IC caching infrastructure. This means building it on top of StructureStubInfo and PolymorphicAccess. For this to work, AccessCase now supports all the array load variants that we used to have fast paths for. For identifier based variants, it we just fall back to the code we've already implemented, but only after doing a runtime check that the identifier matches the expected identifier. This allows us to reuse all the IC infrastructure we have for get_by_id. Our compilation strategy is that the baseline JIT always emits a get_by_val IC. If that IC goes to the slow path, the DFG/FTL won't also emit the same IC, since it's probable that we're seeing a megamorphic switch over strings. This was needed to keep this patch neutral on Speedometer 2. It's likely there is room to improve this heuristic: https://bugs.webkit.org/show_bug.cgi?id=204336 This now allows us to have inline caches which contain array loads, and uses of different identifiers. They just show up as different access cases inside polymorphic access. This patch is a progression on various microbenchmarks, especially those with uses of a fixed set of multiple identifiers. It's neutral on JetStream 2 and Speedometer 2. This patch also hooks in get_by_val ICs to our ICStatus infrastructure. This is going to pave the way to allow us to eagerly throw away baseline code, since when we go for an FTL compile, we will be able to use the IC status from the prior compile without relying on baseline specific data structures. There are a few interesting tidbits in this patch that are worth highlighting. - Unlike get_by_id, when we take an IC snapshot for a get_by_val IC, we're not guaranteed the various identifiers in question will outlive the compile (get_by_id ensures this since they're in the constant pool of CodeBlock). For get_by_val, the Identifiers in question are dynamic fields of AccessCase, and AccessCase may get destroyed as we're compiling concurrently. Also, String's reference counting isn't thread safe, so we can't just ref it. Instead, we use a Box inside AccessCase. This allows us to safely ref the Box without refing the underlying String. We're not worried about the Box being destroyed while we're doing this, since we're holding a lock while taking an IC snapshot inside GetByStatus. - We no longer hold onto the actual JS symbol object in the inline cache. This is what we used to do for inlining by val infos. Instead, this patch extends the CheckStringIdent node to be able to handle symbols as well. This patch also renames CheckStringIdent to CheckIdent. This patch also renames various IC related helpers from GetById* to GetBy*, since they can both be used by get_by_val and get_by_id. * JavaScriptCore.xcodeproj/project.pbxproj: * Sources.txt: * bytecode/AccessCase.cpp: (JSC::AccessCase::AccessCase): (JSC::AccessCase::create): (JSC::AccessCase::fromStructureStubInfo): (JSC::AccessCase::commit): (JSC::AccessCase::guardedByStructureCheck const): (JSC::AccessCase::guardedByStructureCheckSkippingConstantIdentifierCheck const): (JSC::AccessCase::requiresIdentifierNameMatch const): (JSC::AccessCase::requiresInt32PropertyCheck const): (JSC::AccessCase::needsScratchFPR const): (JSC::AccessCase::forEachDependentCell const): (JSC::AccessCase::doesCalls const): (JSC::AccessCase::canReplace const): (JSC::AccessCase::dump const): (JSC::AccessCase::generateWithGuard): (JSC::AccessCase::generate): (JSC::AccessCase::generateImpl): (JSC::AccessCase::toTypedArrayType): (JSC::AccessCase::checkConsistency): * bytecode/AccessCase.h: (JSC::AccessCase::uid const): (JSC::AccessCase::identifier const): (JSC::AccessCase::checkConsistency): (JSC::AccessCase::AccessCase): * bytecode/GetByIdStatus.cpp: Removed. * bytecode/GetByIdStatus.h: Removed. * bytecode/GetByIdVariant.cpp: (JSC::GetByIdVariant::GetByIdVariant): (JSC::GetByIdVariant::operator=): (JSC::GetByIdVariant::attemptToMerge): * bytecode/GetByIdVariant.h: (JSC::GetByIdVariant::domAttribute const): (JSC::GetByIdVariant::identifier const): * bytecode/GetByStatus.cpp: Copied from Source/JavaScriptCore/bytecode/GetByIdStatus.cpp. (JSC::GetByStatus::appendVariant): (JSC::GetByStatus::computeFromLLInt): (JSC::GetByStatus::computeFor): (JSC::GetByStatus::GetByStatus): (JSC::GetByStatus::computeForStubInfoWithoutExitSiteFeedback): (JSC::GetByStatus::makesCalls const): (JSC::GetByStatus::slowVersion const): (JSC::GetByStatus::merge): (JSC::GetByStatus::filter): (JSC::GetByStatus::markIfCheap): (JSC::GetByStatus::finalize): (JSC::GetByStatus::singleIdentifier const): (JSC::GetByStatus::dump const): (JSC::GetByIdStatus::appendVariant): Deleted. (JSC::GetByIdStatus::computeFromLLInt): Deleted. (JSC::GetByIdStatus::computeFor): Deleted. (JSC::GetByIdStatus::computeForStubInfo): Deleted. (JSC::GetByIdStatus::GetByIdStatus): Deleted. (JSC::GetByIdStatus::computeForStubInfoWithoutExitSiteFeedback): Deleted. (JSC::GetByIdStatus::makesCalls const): Deleted. (JSC::GetByIdStatus::slowVersion const): Deleted. (JSC::GetByIdStatus::merge): Deleted. (JSC::GetByIdStatus::filter): Deleted. (JSC::GetByIdStatus::markIfCheap): Deleted. (JSC::GetByIdStatus::finalize): Deleted. (JSC::GetByIdStatus::dump const): Deleted. * bytecode/GetByStatus.h: Copied from Source/JavaScriptCore/bytecode/GetByIdStatus.h. (JSC::GetByStatus::GetByStatus): (JSC::GetByStatus::moduleNamespaceObject const): (JSC::GetByStatus::moduleEnvironment const): (JSC::GetByStatus::scopeOffset const): (JSC::GetByIdStatus::GetByIdStatus): Deleted. (JSC::GetByIdStatus::state const): Deleted. (JSC::GetByIdStatus::isSet const): Deleted. (JSC::GetByIdStatus::operator bool const): Deleted. (JSC::GetByIdStatus::isSimple const): Deleted. (JSC::GetByIdStatus::isCustom const): Deleted. (JSC::GetByIdStatus::isModuleNamespace const): Deleted. (JSC::GetByIdStatus::numVariants const): Deleted. (JSC::GetByIdStatus::variants const): Deleted. (JSC::GetByIdStatus::at const): Deleted. (JSC::GetByIdStatus::operator[] const): Deleted. (JSC::GetByIdStatus::takesSlowPath const): Deleted. (JSC::GetByIdStatus::wasSeenInJIT const): Deleted. (JSC::GetByIdStatus::moduleNamespaceObject const): Deleted. (JSC::GetByIdStatus::moduleEnvironment const): Deleted. (JSC::GetByIdStatus::scopeOffset const): Deleted. * bytecode/GetterSetterAccessCase.cpp: (JSC::GetterSetterAccessCase::GetterSetterAccessCase): (JSC::GetterSetterAccessCase::create): * bytecode/GetterSetterAccessCase.h: * bytecode/ICStatusMap.h: * bytecode/InByIdStatus.cpp: (JSC::InByIdStatus::computeForStubInfoWithoutExitSiteFeedback): * bytecode/InlineAccess.cpp: (JSC::InlineAccess::generateSelfPropertyAccess): (JSC::InlineAccess::canGenerateSelfPropertyReplace): (JSC::InlineAccess::generateSelfPropertyReplace): (JSC::InlineAccess::isCacheableArrayLength): (JSC::InlineAccess::generateArrayLength): (JSC::InlineAccess::isCacheableStringLength): (JSC::InlineAccess::generateStringLength): (JSC::InlineAccess::generateSelfInAccess): * bytecode/InstanceOfAccessCase.cpp: (JSC::InstanceOfAccessCase::InstanceOfAccessCase): * bytecode/InstanceOfStatus.cpp: (JSC::InstanceOfStatus::computeForStubInfo): * bytecode/IntrinsicGetterAccessCase.cpp: (JSC::IntrinsicGetterAccessCase::IntrinsicGetterAccessCase): (JSC::IntrinsicGetterAccessCase::create): * bytecode/IntrinsicGetterAccessCase.h: * bytecode/ModuleNamespaceAccessCase.cpp: (JSC::ModuleNamespaceAccessCase::ModuleNamespaceAccessCase): (JSC::ModuleNamespaceAccessCase::create): * bytecode/ModuleNamespaceAccessCase.h: * bytecode/PolymorphicAccess.cpp: (JSC::AccessGenerationState::preserveLiveRegistersToStackForCall): (JSC::PolymorphicAccess::addCases): (JSC::PolymorphicAccess::addCase): (JSC::PolymorphicAccess::commit): (JSC::PolymorphicAccess::regenerate): (WTF::printInternal): * bytecode/PolymorphicAccess.h: * bytecode/ProxyableAccessCase.cpp: (JSC::ProxyableAccessCase::ProxyableAccessCase): (JSC::ProxyableAccessCase::create): * bytecode/ProxyableAccessCase.h: * bytecode/PutByIdStatus.cpp: (JSC::PutByIdStatus::computeForStubInfo): * bytecode/RecordedStatuses.cpp: (JSC::RecordedStatuses::addGetByStatus): (JSC::RecordedStatuses::addGetByIdStatus): Deleted. * bytecode/RecordedStatuses.h: * bytecode/StructureStubInfo.cpp: (JSC::StructureStubInfo::StructureStubInfo): (JSC::StructureStubInfo::initGetByIdSelf): (JSC::StructureStubInfo::initArrayLength): (JSC::StructureStubInfo::initStringLength): (JSC::StructureStubInfo::initPutByIdReplace): (JSC::StructureStubInfo::initInByIdSelf): (JSC::StructureStubInfo::deref): (JSC::StructureStubInfo::aboutToDie): (JSC::StructureStubInfo::addAccessCase): (JSC::StructureStubInfo::reset): (JSC::StructureStubInfo::visitWeakReferences): (JSC::StructureStubInfo::propagateTransitions): (JSC::StructureStubInfo::summary const): (JSC::StructureStubInfo::containsPC const): (JSC::StructureStubInfo::setCacheType): (JSC::StructureStubInfo::checkConsistency): * bytecode/StructureStubInfo.h: (JSC::StructureStubInfo::getByIdSelfIdentifier): (JSC::StructureStubInfo::thisValueIsInThisGPR const): (JSC::StructureStubInfo::checkConsistency): (JSC::StructureStubInfo::cacheType const): (JSC::appropriateOptimizingGetByIdFunction): (JSC::appropriateGenericGetByIdFunction): * dfg/DFGAbstractInterpreterInlines.h: (JSC::DFG::AbstractInterpreter::executeEffects): (JSC::DFG::AbstractInterpreter::filterICStatus): * dfg/DFGArgumentsEliminationPhase.cpp: * dfg/DFGByteCodeParser.cpp: (JSC::DFG::ByteCodeParser::handleDOMJITGetter): (JSC::DFG::ByteCodeParser::handleModuleNamespaceLoad): (JSC::DFG::ByteCodeParser::load): (JSC::DFG::ByteCodeParser::handleGetById): (JSC::DFG::ByteCodeParser::parseGetById): (JSC::DFG::ByteCodeParser::parseBlock): (JSC::DFG::ByteCodeParser::handlePutByVal): * dfg/DFGClobberize.h: (JSC::DFG::clobberize): * dfg/DFGClobbersExitState.cpp: (JSC::DFG::clobbersExitState): * dfg/DFGConstantFoldingPhase.cpp: (JSC::DFG::ConstantFoldingPhase::foldConstants): * dfg/DFGDesiredIdentifiers.cpp: (JSC::DFG::DesiredIdentifiers::processCodeBlockIdentifiersIfNeeded): (JSC::DFG::DesiredIdentifiers::ensure): (JSC::DFG::DesiredIdentifiers::at const): (JSC::DFG::DesiredIdentifiers::reallyAdd): * dfg/DFGDesiredIdentifiers.h: * dfg/DFGDoesGC.cpp: (JSC::DFG::doesGC): * dfg/DFGFixupPhase.cpp: (JSC::DFG::FixupPhase::fixupNode): * dfg/DFGGraph.cpp: (JSC::DFG::Graph::dump): * dfg/DFGGraph.h: * dfg/DFGInPlaceAbstractState.cpp: * dfg/DFGJITCompiler.cpp: (JSC::DFG::JITCompiler::link): * dfg/DFGJITCompiler.h: (JSC::DFG::JITCompiler::addGetByVal): * dfg/DFGMayExit.cpp: * dfg/DFGNode.h: (JSC::DFG::Node::hasUidOperand): (JSC::DFG::Node::hasGetByStatus): (JSC::DFG::Node::getByStatus): (JSC::DFG::Node::hasGetByIdStatus): Deleted. (JSC::DFG::Node::getByIdStatus): Deleted. * dfg/DFGNodeType.h: * dfg/DFGObjectAllocationSinkingPhase.cpp: * dfg/DFGPredictionPropagationPhase.cpp: * dfg/DFGSafeToExecute.h: (JSC::DFG::safeToExecute): * dfg/DFGSpeculativeJIT.cpp: (JSC::DFG::SpeculativeJIT::compileGetById): (JSC::DFG::SpeculativeJIT::compileCheckIdent): (JSC::DFG::SpeculativeJIT::compileCheckStringIdent): Deleted. * dfg/DFGSpeculativeJIT.h: * dfg/DFGSpeculativeJIT32_64.cpp: (JSC::DFG::SpeculativeJIT::cachedGetByIdWithThis): (JSC::DFG::SpeculativeJIT::compile): * dfg/DFGSpeculativeJIT64.cpp: (JSC::DFG::SpeculativeJIT::cachedGetByIdWithThis): (JSC::DFG::SpeculativeJIT::compile): * dfg/DFGVarargsForwardingPhase.cpp: * ftl/FTLCapabilities.cpp: (JSC::FTL::canCompile): * ftl/FTLLowerDFGToB3.cpp: (JSC::FTL::DFG::LowerDFGToB3::compileNode): (JSC::FTL::DFG::LowerDFGToB3::compileCheckIdent): (JSC::FTL::DFG::LowerDFGToB3::compileGetById): (JSC::FTL::DFG::LowerDFGToB3::compileGetByVal): (JSC::FTL::DFG::LowerDFGToB3::getByIdWithThis): (JSC::FTL::DFG::LowerDFGToB3::compileCheckStringIdent): Deleted. * jit/ICStats.h: * jit/JIT.cpp: (JSC::JIT::privateCompileSlowCases): (JSC::JIT::link): * jit/JIT.h: * jit/JITInlineCacheGenerator.cpp: (JSC::garbageStubInfo): (JSC::JITGetByIdWithThisGenerator::JITGetByIdWithThisGenerator): (JSC::JITInstanceOfGenerator::JITInstanceOfGenerator): (JSC::JITGetByValGenerator::JITGetByValGenerator): (JSC::JITGetByValGenerator::generateFastPath): (JSC::JITGetByValGenerator::finalize): * jit/JITInlineCacheGenerator.h: (JSC::JITGetByValGenerator::JITGetByValGenerator): (JSC::JITGetByValGenerator::slowPathJump const): * jit/JITInlines.h: (JSC::JIT::emitDoubleGetByVal): Deleted. (JSC::JIT::emitContiguousGetByVal): Deleted. (JSC::JIT::emitArrayStorageGetByVal): Deleted. * jit/JITOperations.cpp: (JSC::getByVal): (JSC::tryGetByValOptimize): Deleted. * jit/JITOperations.h: * jit/JITPropertyAccess.cpp: (JSC::JIT::emit_op_get_by_val): (JSC::JIT::emitSlow_op_get_by_val): (JSC::JIT::emit_op_try_get_by_id): (JSC::JIT::emit_op_get_by_id_direct): (JSC::JIT::emit_op_get_by_id): (JSC::JIT::emit_op_get_by_id_with_this): (JSC::JIT::emitGetByValWithCachedId): Deleted. (JSC::JIT::privateCompileGetByVal): Deleted. (JSC::JIT::privateCompileGetByValWithCachedId): Deleted. (JSC::JIT::emitDirectArgumentsGetByVal): Deleted. (JSC::JIT::emitScopedArgumentsGetByVal): Deleted. (JSC::JIT::emitIntTypedArrayGetByVal): Deleted. (JSC::JIT::emitFloatTypedArrayGetByVal): Deleted. * jit/JITPropertyAccess32_64.cpp: (JSC::JIT::emit_op_get_by_val): (JSC::JIT::emit_op_try_get_by_id): (JSC::JIT::emit_op_get_by_id_direct): (JSC::JIT::emit_op_get_by_id): (JSC::JIT::emit_op_get_by_id_with_this): (JSC::JIT::emitGetByValWithCachedId): Deleted. * jit/Repatch.cpp: (JSC::appropriateOptimizingGetByFunction): (JSC::appropriateGetByFunction): (JSC::tryCacheGetBy): (JSC::repatchGetBy): (JSC::tryCacheArrayGetByVal): (JSC::repatchArrayGetByVal): (JSC::tryCachePutByID): (JSC::tryCacheInByID): (JSC::tryCacheInstanceOf): (JSC::resetGetBy): (JSC::appropriateOptimizingGetByIdFunction): Deleted. (JSC::appropriateGetByIdFunction): Deleted. (JSC::tryCacheGetByID): Deleted. (JSC::repatchGetByID): Deleted. (JSC::resetGetByID): Deleted. * jit/Repatch.h: * llint/LowLevelInterpreter.h: * runtime/DOMAnnotation.h: * runtime/JSCJSValue.cpp: (JSC::JSValue::dumpInContextAssumingStructure const): * runtime/Structure.h: 2019-11-19 Ross Kirsling Implement String.prototype.replaceAll https://bugs.webkit.org/show_bug.cgi?id=202471 Reviewed by Yusuke Suzuki. Implement the stage 3 proposal here: https://github.com/tc39/proposal-string-replaceall String.prototype.replaceAll is the same as String.prototype.replace, except: 1. When the first argument is a string, all instances of the search string are replaced. 2. When the first argument is a non-global regular expression, a TypeError is thrown. * builtins/BuiltinNames.h: * builtins/StringPrototype.js: (replaceAll): Added. * runtime/StringPrototype.cpp: (JSC::StringPrototype::finishCreation): (JSC::jsSpliceSubstringsWithSeparators): Add early out for single-replacement case. (JSC::replaceUsingStringSearch): Add global replacement logic, following replaceUsingRegExpSearch. (JSC::replace): (JSC::stringProtoFuncReplaceUsingStringSearch): (JSC::stringProtoFuncReplaceAllUsingStringSearch): Added. 2019-11-19 Robin Morisset [ESNext][BigInt] Add support for op_inc https://bugs.webkit.org/show_bug.cgi?id=193240 Reviewed by Yusuke Suzuki. This patch adds support for both ++ and -- on BigInts. It required the following secondary changes: - teaching FixupPhase how to replace it by ArithAdd/ArithSub/ValueAdd/ValueSub when the type is Int32/Double/BigInt - pulling ObservedResults out of UnaryArithProfile/BinaryArithProfile, so that it can be used by ArithAdd regardless of whether it comes from an Inc or from an Add - adding the constant 1n to the VM object so that it can be used by FixupPhase since it cannot allocate a new JSValue. - adding an UnaryArithProfile to op_inc and op_dec, and teaching the llint to update them. - adding ToNumeric (identity on bigints, same as toNumber on everything else) to all tiers * bytecode/ArithProfile.cpp: (JSC::ArithProfile::shouldEmitSetDouble const): (JSC::ArithProfile::emitSetDouble const): (JSC::ArithProfile::shouldEmitSetNonNumeric const): (JSC::ArithProfile::shouldEmitSetBigInt const): (JSC::ArithProfile::emitSetNonNumeric const): (JSC::ArithProfile::emitSetBigInt const): * bytecode/ArithProfile.h: (JSC::ObservedResults::ObservedResults): (JSC::ObservedResults::didObserveNonInt32): (JSC::ObservedResults::didObserveDouble): (JSC::ObservedResults::didObserveNonNegZeroDouble): (JSC::ObservedResults::didObserveNegZeroDouble): (JSC::ObservedResults::didObserveNonNumeric): (JSC::ObservedResults::didObserveBigInt): (JSC::ObservedResults::didObserveInt32Overflow): (JSC::ObservedResults::didObserveInt52Overflow): (JSC::ArithProfile::observedResults const): (JSC::ArithProfile::didObserveNonInt32 const): (JSC::ArithProfile::didObserveDouble const): (JSC::ArithProfile::didObserveNonNegZeroDouble const): (JSC::ArithProfile::didObserveNegZeroDouble const): (JSC::ArithProfile::didObserveNonNumeric const): (JSC::ArithProfile::didObserveBigInt const): (JSC::ArithProfile::didObserveInt32Overflow const): (JSC::ArithProfile::didObserveInt52Overflow const): (JSC::ArithProfile::setObservedNonNegZeroDouble): (JSC::ArithProfile::setObservedNegZeroDouble): (JSC::ArithProfile::setObservedNonNumeric): (JSC::ArithProfile::setObservedBigInt): (JSC::ArithProfile::setObservedInt32Overflow): (JSC::ArithProfile::setObservedInt52Overflow): (JSC::ArithProfile::observeResult): * bytecode/BytecodeList.rb: * bytecode/BytecodeUseDef.h: (JSC::computeUsesForBytecodeIndex): (JSC::computeDefsForBytecodeIndex): * bytecode/CodeBlock.cpp: (JSC::CodeBlock::unaryArithProfileForPC): * bytecode/ExitKind.h: * bytecode/SpeculatedType.h: (JSC::isInt32SpeculationForArithmetic): (JSC::isInt32OrBooleanSpeculationForArithmetic): * bytecompiler/BytecodeGenerator.cpp: (JSC::BytecodeGenerator::emitUnaryOp): (JSC::BytecodeGenerator::emitToNumeric): * bytecompiler/BytecodeGenerator.h: * bytecompiler/NodesCodegen.cpp: (JSC::emitPostIncOrDec): * dfg/DFGAbstractInterpreterInlines.h: (JSC::DFG::AbstractInterpreter::executeEffects): * dfg/DFGBackwardsPropagationPhase.cpp: (JSC::DFG::BackwardsPropagationPhase::propagate): * dfg/DFGByteCodeParser.cpp: (JSC::DFG::ByteCodeParser::makeSafe): (JSC::DFG::ByteCodeParser::parseBlock): * dfg/DFGCapabilities.cpp: (JSC::DFG::capabilityLevel): * dfg/DFGClobberize.h: (JSC::DFG::clobberize): * dfg/DFGConstantFoldingPhase.cpp: (JSC::DFG::ConstantFoldingPhase::foldConstants): * dfg/DFGDoesGC.cpp: (JSC::DFG::doesGC): * dfg/DFGFixupPhase.cpp: (JSC::DFG::FixupPhase::fixupNode): (JSC::DFG::FixupPhase::fixupToNumeric): * dfg/DFGMayExit.cpp: * dfg/DFGNode.h: (JSC::DFG::Node::hasHeapPrediction): * dfg/DFGNodeType.h: * dfg/DFGOperations.cpp: * dfg/DFGOperations.h: * dfg/DFGPredictionPropagationPhase.cpp: * dfg/DFGSafeToExecute.h: (JSC::DFG::safeToExecute): * dfg/DFGSpeculativeJIT.cpp: (JSC::DFG::SpeculativeJIT::compileIncOrDec): (JSC::DFG::SpeculativeJIT::compileToPrimitive): (JSC::DFG::SpeculativeJIT::compileToNumeric): * dfg/DFGSpeculativeJIT.h: * dfg/DFGSpeculativeJIT32_64.cpp: (JSC::DFG::SpeculativeJIT::compile): * dfg/DFGSpeculativeJIT64.cpp: (JSC::DFG::SpeculativeJIT::compile): * ftl/FTLCapabilities.cpp: (JSC::FTL::canCompile): * ftl/FTLLowerDFGToB3.cpp: (JSC::FTL::DFG::LowerDFGToB3::compileNode): (JSC::FTL::DFG::LowerDFGToB3::compileIncOrDec): * jit/JIT.cpp: (JSC::JIT::privateCompileMainPass): (JSC::JIT::privateCompileSlowCases): * jit/JIT.h: * jit/JITMathIC.h: (JSC::JITMathIC::generateInline): * jit/JITMulGenerator.cpp: (JSC::JITMulGenerator::generateFastPath): * jit/JITOpcodes.cpp: (JSC::JIT::emit_op_to_numeric): * jit/JITOpcodes32_64.cpp: (JSC::JIT::emit_op_to_numeric): * llint/LowLevelInterpreter.asm: * llint/LowLevelInterpreter32_64.asm: * llint/LowLevelInterpreter64.asm: * runtime/CommonSlowPaths.cpp: (JSC::SLOW_PATH_DECL): * runtime/CommonSlowPaths.h: * runtime/JSBigInt.cpp: (JSC::JSBigInt::inc): (JSC::JSBigInt::dec): * runtime/JSBigInt.h: * runtime/VM.cpp: (JSC::VM::VM): * runtime/VM.h: 2019-11-19 Yusuke Suzuki [JSC] MetadataTable::sizeInBytes should not touch m_rawBuffer in UnlinkedMetadataTable unless MetadataTable is linked to that UnlinkedMetadataTable https://bugs.webkit.org/show_bug.cgi?id=204390 Reviewed by Mark Lam. We have a race issue here. When calling MetadataTable::sizeInBytes, we call UnlinkedMetadataTable::sizeInBytes since we change the result based on whether this MetadataTable is linked to this UnlinkedMetadataTable or not. The problem is that we are calling `UnlinkedMetadataTable::totalSize` unconditionally in UnlinkedMetadataTable::sizeInBytes, and this is touching m_rawBuffer unconditionally. This is not correct since it is possible that this m_rawBuffer is realloced while we are calling MetadataTable::sizeInBytes in GC thread. 1. The GC thread is calling MetadataTable::sizeInBytes for MetadataTable "A". 2. The main thread is destroying MetadataTable "B". 3. MetadataTable "B" is linked to UnlinkedMetadataTable "C". 4. MetadataTable "A" is pointing to UnlinkedMetadataTable "C". 5. "A" is touching UnlinkedMetadataTable::m_rawBuffer in "C", called from MetadataTable::sizeInBytes. 6. (2) destroys MetadataTable "B", and realloc UnlinkedMetadataTable::m_rawBuffer in "C". 7. (5) can touch already freed buffer. This patch fixes UnlinkedMetadataTable::sizeInBytes: not touching m_rawBuffer unless it is owned by the caller's MetadataTable. We need to call UnlinkedMetadataTable::sizeInBytes anyway since we need to adjust the result based on whether the caller MetadataTable is linked to this UnlinkedMetadataTable. * bytecode/UnlinkedMetadataTableInlines.h: (JSC::UnlinkedMetadataTable::sizeInBytes): 2019-11-19 Fujii Hironori [JSC] DisallowVMReentry and DeferGC should use WTF::ThreadSpecific instead of using WTF::threadSpecificKeyCreate directly https://bugs.webkit.org/show_bug.cgi?id=204350 Reviewed by Yusuke Suzuki. WTF provides two thread specific storages, ThreadSpecific and threadSpecificKeyCreate. Only DisallowVMReentry and DeferGC were using the latter. They should use WTF::ThreadSpecific because it is a useful type-safe wrapper class. * heap/DeferGC.cpp: * heap/DeferGC.h: (JSC::DisallowGC::initialize): (JSC::DisallowGC::scopeReentryCount): (JSC::DisallowGC::setScopeReentryCount): * runtime/DisallowVMReentry.cpp: * runtime/DisallowVMReentry.h: (JSC::DisallowVMReentry::initialize): (JSC::DisallowVMReentry::scopeReentryCount): (JSC::DisallowVMReentry::setScopeReentryCount): 2019-11-19 Yusuke Suzuki [JSC] Work-around Leaks' false-positive report about memory leaking https://bugs.webkit.org/show_bug.cgi?id=204384 Reviewed by Mark Lam. According to the radar, Leaks start reporting false-positive memory leaks about ExecutableAllocator and FixedVMPoolExecutableAllocator, while they are per-process singleton and reachable through g_jscConfig. I'm guessing this is because Leaks start skipping scan for readonly memory region. (g_jscConfig is now mprotected to readonly). To work-around this, we anchor these heap allocated things to global variables to help Leaks scan. Once it is fixed, we should remove it. * jit/ExecutableAllocator.cpp: (JSC::ExecutableAllocator::initializeUnderlyingAllocator): (JSC::ExecutableAllocator::initialize): 2019-11-18 Mark Lam Always enable Optional parse(const char* string) for OS(DARWIN). https://bugs.webkit.org/show_bug.cgi?id=204333 Reviewed by Yusuke Suzuki. On OS(DARWIN), the compiler does not consider size_t and unsigned to be the same type, even for 32-bit targets. Hence, we need the size_t version of the function in addition to the unsigned version. * runtime/Options.cpp: (JSC::parse): 2019-11-18 Devin Rousso Web Inspector: Local Resource Overrides: allow substitution based on a url pattern https://bugs.webkit.org/show_bug.cgi?id=202375 Reviewed by Brian Burg. Often, websites will load content with a timestamp-based URL query parameter for cache-busting or logging purposes. If a developer is trying to override these resources (or is trying to have an existing override also match these resources), they'd need to edit the local override's URL to match in addition to editing the resource that loads it (e.g. change the