2018-05-30 Keith Miller LLInt get_by_id prototype caching doesn't properly handle changes https://bugs.webkit.org/show_bug.cgi?id=186112 Reviewed by Filip Pizlo. The caching would sometimes fail to track that a prototype had changed and wouldn't update its set of watchpoints. * bytecode/CodeBlock.cpp: (JSC::CodeBlock::finalizeLLIntInlineCaches): * bytecode/CodeBlock.h: * bytecode/LLIntPrototypeLoadAdaptiveStructureWatchpoint.h: (JSC::LLIntPrototypeLoadAdaptiveStructureWatchpoint::key const): * bytecode/ObjectPropertyConditionSet.h: (JSC::ObjectPropertyConditionSet::size const): * bytecode/Watchpoint.h: (JSC::Watchpoint::Watchpoint): Deleted. * llint/LLIntSlowPaths.cpp: (JSC::LLInt::setupGetByIdPrototypeCache): 2018-05-25 Mark Lam for-in loops should preserve and restore the TDZ stack for each of its internal loops. https://bugs.webkit.org/show_bug.cgi?id=185995 Reviewed by Saam Barati. This is because there's no guarantee that any of the loop bodies will be executed. Hence, there's no guarantee that the TDZ variables will have been initialized after each loop body. * bytecompiler/BytecodeGenerator.cpp: (JSC::BytecodeGenerator::preserveTDZStack): (JSC::BytecodeGenerator::restoreTDZStack): * bytecompiler/BytecodeGenerator.h: * bytecompiler/NodesCodegen.cpp: (JSC::ForInNode::emitBytecode): 2018-05-08 Michael Saboff Deferred firing of structure transition watchpoints is racy https://bugs.webkit.org/show_bug.cgi?id=185438 Reviewed by Saam Barati. Changed DeferredStructureTransitionWatchpointFire to take the watchpoints to fire and fire them in the destructor. When the watchpoints are taken from the original WatchpointSet, that WatchpointSet if marked invalid. * bytecode/Watchpoint.cpp: (JSC::WatchpointSet::fireAllSlow): (JSC::WatchpointSet::take): (JSC::DeferredWatchpointFire::DeferredWatchpointFire): (JSC::DeferredWatchpointFire::~DeferredWatchpointFire): (JSC::DeferredWatchpointFire::fireAll): (JSC::DeferredWatchpointFire::takeWatchpointsToFire): * bytecode/Watchpoint.h: (JSC::WatchpointSet::fireAll): (JSC::InlineWatchpointSet::fireAll): * runtime/JSObject.cpp: (JSC::JSObject::setPrototypeDirect): (JSC::JSObject::convertToDictionary): * runtime/JSObjectInlines.h: (JSC::JSObject::putDirectInternal): * runtime/Structure.cpp: (JSC::Structure::Structure): (JSC::DeferredStructureTransitionWatchpointFire::DeferredStructureTransitionWatchpointFire): (JSC::DeferredStructureTransitionWatchpointFire::~DeferredStructureTransitionWatchpointFire): (JSC::DeferredStructureTransitionWatchpointFire::dump const): (JSC::Structure::didTransitionFromThisStructure const): (JSC::DeferredStructureTransitionWatchpointFire::add): Deleted. * runtime/Structure.h: (JSC::DeferredStructureTransitionWatchpointFire::structure const): 2018-04-28 Saam Barati We don't model regexp effects properly https://bugs.webkit.org/show_bug.cgi?id=185059 Reviewed by Filip Pizlo. RegExp exec/test can do arbitrary effects when toNumbering the lastIndex if the regexp is global. * dfg/DFGAbstractInterpreterInlines.h: (JSC::DFG::AbstractInterpreter::executeEffects): * dfg/DFGClobberize.h: (JSC::DFG::clobberize): 2018-04-25 Robin Morisset In FTLLowerDFGToB3.cpp::compileCreateRest, always use a contiguous array as the indexing type when under isWatchingHavingABadTimeWatchpoint https://bugs.webkit.org/show_bug.cgi?id=184773 Reviewed by Filip Pizlo. We were calling restParameterStructure(), which returns arrayStructureForIndexingTypeDuringAllocation(ArrayWithContiguous). arrayStructureForIndexingTypeDuringAllocation uses m_arrayStructureForIndexingShapeDuringAllocation, which is set to SlowPutArrayStorage when we are 'having a bad time'. This is problematic, because the structure is then passed to allocateUninitializedContiguousJSArray, which ASSERTs that the indexing type is contiguous (or int32). We solve the problem by using originalArrayStructureForIndexingType which always returns a structure with the right indexing type (contiguous), even if we are having a bad time. This is safe, as we are under isWatchingHavingABadTimeWatchpoint, so if we have a bad time, the code we generate will never be installed. * ftl/FTLLowerDFGToB3.cpp: (JSC::FTL::DFG::LowerDFGToB3::compileCreateRest): 2018-04-17 JF Bastien A put is not an ExistingProperty put when we transition a structure because of an attributes change https://bugs.webkit.org/show_bug.cgi?id=184706 Reviewed by Saam Barati. When putting a property on a structure and the slot is a different type, the slot can't be said to have already been existing. * runtime/JSObjectInlines.h: (JSC::JSObject::putDirectInternal): 2018-04-30 Keith Miller Remove unneeded exception check from String.fromCharCode https://bugs.webkit.org/show_bug.cgi?id=185083 Reviewed by Mark Lam. * runtime/StringConstructor.cpp: (JSC::stringFromCharCode): 2018-06-15 Michael Catanzaro Unreviewed, rolling out r232816. Suggested by Caitlin: "this patch clearly does get some things wrong, and it's not easy to find what those things are" Reverted changeset: "[LLInt] use loadp consistently for get_from_scope/put_to_scope" https://bugs.webkit.org/show_bug.cgi?id=132333 https://trac.webkit.org/changeset/232816 2018-07-25 Michael Catanzaro [GTK][STABLE] Non-deterministic build failure (missing JavaScriptCore/JSContextRef.h) https://bugs.webkit.org/show_bug.cgi?id=183788 Unreviewed build fix. LLIntOffsetsExtractor target should depend on JavaScriptCoreForwardingHeaders. Thanks to Fujii for debugging this, Don for fixing it months ago on trunk, and Mart from Gentoo for testing it. * CMakeLists.txt: 2018-06-13 Adrian Perez de Castro [WPE] Trying to access the remote inspector hits an assertion in the UIProcess https://bugs.webkit.org/show_bug.cgi?id=186588 Reviewed by Carlos Garcia Campos. Make both the WPE and GTK+ ports use /org/webkit/inspector as base prefix for resource paths, which avoids needing a switcheroo depending on the port. * inspector/remote/glib/RemoteInspectorUtils.cpp: 2018-06-13 Caitlin Potter [LLInt] use loadp consistently for get_from_scope/put_to_scope https://bugs.webkit.org/show_bug.cgi?id=132333 Reviewed by Mark Lam. Using `loadis` for register indexes and `loadp` for constant scopes / symboltables makes sense, but is problematic for big-endian architectures. Consistently treating the operand as a pointer simplifies determining how to access the operand, and helps avoid bad accesses and crashes on big-endian ports. * bytecode/CodeBlock.cpp: (JSC::CodeBlock::finishCreation): * bytecode/Instruction.h: * jit/JITOperations.cpp: * llint/LLIntSlowPaths.cpp: (JSC::LLInt::LLINT_SLOW_PATH_DECL): * llint/LowLevelInterpreter32_64.asm: * llint/LowLevelInterpreter64.asm: * runtime/CommonSlowPaths.h: (JSC::CommonSlowPaths::tryCachePutToScopeGlobal): (JSC::CommonSlowPaths::tryCacheGetFromScopeGlobal): 2018-04-14 Filip Pizlo Function.prototype.caller shouldn't return generator bodies https://bugs.webkit.org/show_bug.cgi?id=184630 Reviewed by Yusuke Suzuki. Function.prototype.caller no longer returns generator bodies. Those are meant to be private. Also added some builtin debugging tools so that it's easier to do the investigation that I did. * builtins/BuiltinNames.h: * runtime/JSFunction.cpp: (JSC::JSFunction::callerGetter): * runtime/JSGlobalObject.cpp: (JSC::JSGlobalObject::init): * runtime/JSGlobalObjectFunctions.cpp: (JSC::globalFuncBuiltinDescribe): * runtime/JSGlobalObjectFunctions.h: 2018-04-08 Yusuke Suzuki Unreviewed, follow-up patch for DFG 32bit https://bugs.webkit.org/show_bug.cgi?id=183970 * dfg/DFGSpeculativeJIT32_64.cpp: (JSC::DFG::SpeculativeJIT::cachedGetById): 2018-04-08 Yusuke Suzuki [JSC] Introduce op_get_by_id_direct https://bugs.webkit.org/show_bug.cgi?id=183970 Reviewed by Filip Pizlo. This patch introduces op_get_by_id_direct bytecode. This is super similar to op_get_by_id. But it just performs [[GetOwnProperty]] operation instead of [[Get]]. We support this in all the tiers, so using this opcode does not lead to inefficiency. Main purpose of this op_get_by_id_direct is using it for private properties. We are using properties indexed with private symbols to implement ECMAScript internal fields. Before this patch, we just use get and put operations. However, it is not the correct semantics: accessing to the internal fields should not traverse prototype chain, which is specified in the spec. We use op_get_by_id_direct to access to properties which are used internal fields, so that prototype chains are not traversed. To emit op_get_by_id_direct, we introduce a new bytecode intrinsic @getByIdDirectPrivate(). When you write `@getByIdDirectPrivate(object, "name")`, the bytecode generator emits the bytecode `op_get_by_id_direct, object, @name`. * builtins/ArrayIteratorPrototype.js: (next): (globalPrivate.arrayIteratorValueNext): (globalPrivate.arrayIteratorKeyNext): (globalPrivate.arrayIteratorKeyValueNext): * builtins/AsyncFromSyncIteratorPrototype.js: * builtins/AsyncFunctionPrototype.js: (globalPrivate.asyncFunctionResume): * builtins/AsyncGeneratorPrototype.js: (globalPrivate.asyncGeneratorQueueIsEmpty): (globalPrivate.asyncGeneratorQueueEnqueue): (globalPrivate.asyncGeneratorQueueDequeue): (globalPrivate.asyncGeneratorDequeue): (globalPrivate.isExecutionState): (globalPrivate.isSuspendYieldState): (globalPrivate.asyncGeneratorReject): (globalPrivate.asyncGeneratorResolve): (globalPrivate.doAsyncGeneratorBodyCall): (globalPrivate.asyncGeneratorEnqueue): * builtins/GeneratorPrototype.js: (globalPrivate.generatorResume): (next): (return): (throw): * builtins/MapIteratorPrototype.js: (next): * builtins/PromiseOperations.js: (globalPrivate.isPromise): (globalPrivate.rejectPromise): (globalPrivate.fulfillPromise): * builtins/PromisePrototype.js: (then): * builtins/SetIteratorPrototype.js: (next): * builtins/StringIteratorPrototype.js: (next): * builtins/TypedArrayConstructor.js: (of): (from): * bytecode/BytecodeDumper.cpp: (JSC::BytecodeDumper::dumpBytecode): * bytecode/BytecodeIntrinsicRegistry.h: * bytecode/BytecodeList.json: * bytecode/BytecodeUseDef.h: (JSC::computeUsesForBytecodeOffset): (JSC::computeDefsForBytecodeOffset): * bytecode/CodeBlock.cpp: (JSC::CodeBlock::finishCreation): (JSC::CodeBlock::finalizeLLIntInlineCaches): * bytecode/GetByIdStatus.cpp: (JSC::GetByIdStatus::computeFromLLInt): (JSC::GetByIdStatus::computeFor): * bytecode/StructureStubInfo.cpp: (JSC::StructureStubInfo::reset): * bytecode/StructureStubInfo.h: (JSC::appropriateOptimizingGetByIdFunction): (JSC::appropriateGenericGetByIdFunction): * bytecompiler/BytecodeGenerator.cpp: (JSC::BytecodeGenerator::emitDirectGetById): * bytecompiler/BytecodeGenerator.h: * bytecompiler/NodesCodegen.cpp: (JSC::BytecodeIntrinsicNode::emit_intrinsic_getByIdDirect): (JSC::BytecodeIntrinsicNode::emit_intrinsic_getByIdDirectPrivate): * dfg/DFGAbstractInterpreterInlines.h: (JSC::DFG::AbstractInterpreter::executeEffects): * dfg/DFGByteCodeParser.cpp: (JSC::DFG::ByteCodeParser::handleGetById): (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): * dfg/DFGNode.h: (JSC::DFG::Node::convertToGetByOffset): (JSC::DFG::Node::convertToMultiGetByOffset): (JSC::DFG::Node::hasIdentifier): (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::compileGetById): (JSC::DFG::SpeculativeJIT::compileGetByIdFlush): (JSC::DFG::SpeculativeJIT::compileTryGetById): Deleted. * dfg/DFGSpeculativeJIT.h: * dfg/DFGSpeculativeJIT32_64.cpp: (JSC::DFG::SpeculativeJIT::cachedGetById): (JSC::DFG::SpeculativeJIT::compile): * dfg/DFGSpeculativeJIT64.cpp: (JSC::DFG::SpeculativeJIT::cachedGetById): (JSC::DFG::SpeculativeJIT::compile): * ftl/FTLCapabilities.cpp: (JSC::FTL::canCompile): * ftl/FTLLowerDFGToB3.cpp: (JSC::FTL::DFG::LowerDFGToB3::compileNode): (JSC::FTL::DFG::LowerDFGToB3::compileGetById): (JSC::FTL::DFG::LowerDFGToB3::compileGetByIdWithThis): (JSC::FTL::DFG::LowerDFGToB3::getById): * jit/JIT.cpp: (JSC::JIT::privateCompileMainPass): (JSC::JIT::privateCompileSlowCases): * jit/JIT.h: * jit/JITOperations.cpp: * jit/JITOperations.h: * jit/JITPropertyAccess.cpp: (JSC::JIT::emit_op_get_by_id_direct): (JSC::JIT::emitSlow_op_get_by_id_direct): * jit/JITPropertyAccess32_64.cpp: (JSC::JIT::emit_op_get_by_id_direct): (JSC::JIT::emitSlow_op_get_by_id_direct): * jit/Repatch.cpp: (JSC::appropriateOptimizingGetByIdFunction): (JSC::appropriateGetByIdFunction): (JSC::tryCacheGetByID): (JSC::repatchGetByID): (JSC::appropriateGenericGetByIdFunction): Deleted. * jit/Repatch.h: * llint/LLIntSlowPaths.cpp: (JSC::LLInt::LLINT_SLOW_PATH_DECL): * llint/LLIntSlowPaths.h: * llint/LowLevelInterpreter32_64.asm: * llint/LowLevelInterpreter64.asm: * runtime/JSCJSValue.h: * runtime/JSCJSValueInlines.h: (JSC::JSValue::getOwnPropertySlot const): * runtime/JSObject.h: * runtime/JSObjectInlines.h: (JSC::JSObject::getOwnPropertySlotInline): 2018-03-26 Filip Pizlo DFG should know that CreateThis can be effectful https://bugs.webkit.org/show_bug.cgi?id=184013 Reviewed by Saam Barati. As shown in the tests added in JSTests, CreateThis can be effectful if the constructor this is a proxy. * dfg/DFGAbstractInterpreterInlines.h: (JSC::DFG::AbstractInterpreter::executeEffects): * dfg/DFGClobberize.h: (JSC::DFG::clobberize): 2018-03-30 JF Bastien WebAssembly: support DataView compilation https://bugs.webkit.org/show_bug.cgi?id=183342 Reviewed by Mark Lam. Compiling a module from a DataView was incorrectly dealing with DataView's offset. * wasm/WasmModuleParser.cpp: (JSC::Wasm::ModuleParser::parse): * wasm/js/JSWebAssemblyHelpers.h: (JSC::getWasmBufferFromValue): (JSC::createSourceBufferFromValue): * wasm/js/WebAssemblyPrototype.cpp: (JSC::webAssemblyValidateFunc): 2018-05-22 Alberto Garcia [CMake] Properly detect compiler flags, needed libs, and fallbacks for usage of 64-bit atomic operations https://bugs.webkit.org/show_bug.cgi?id=182622 Reviewed by Michael Catanzaro. We were linking JavaScriptCore against libatomic in MIPS because in that architecture __atomic_fetch_add_8() is not a compiler intrinsic and is provided by that library instead. However other architectures (e.g armel) are in the same situation, so we need a generic test. That test already exists in WebKit/CMakeLists.txt, so we just have to move it to a common file (WebKitCompilerFlags.cmake) and use its result (ATOMIC_INT64_REQUIRES_LIBATOMIC) here. * CMakeLists.txt: 2018-05-22 Michael Catanzaro Unreviewed, rolling out r231843. Broke cross build Reverted changeset: "[CMake] Properly detect compiler flags, needed libs, and fallbacks for usage of 64-bit atomic operations" https://bugs.webkit.org/show_bug.cgi?id=182622 https://trac.webkit.org/changeset/231843 2018-05-16 Alberto Garcia [CMake] Properly detect compiler flags, needed libs, and fallbacks for usage of 64-bit atomic operations https://bugs.webkit.org/show_bug.cgi?id=182622 Reviewed by Michael Catanzaro. We were linking JavaScriptCore against libatomic in MIPS because in that architecture __atomic_fetch_add_8() is not a compiler intrinsic and is provided by that library instead. However other architectures (e.g armel) are in the same situation, so we need a generic test. That test already exists in WebKit/CMakeLists.txt, so we just have to move it to a common file (WebKitCompilerFlags.cmake) and use its result (ATOMIC_INT64_REQUIRES_LIBATOMIC) here. * CMakeLists.txt: 2018-05-10 Michael Catanzaro Unreviewed, silence a couple more build warnings on the stable branch * heap/MarkedBlock.cpp: (JSC::MarkedBlock::Handle::didAddToDirectory): 2018-05-09 Michael Catanzaro [WPE] Build cleanly with GCC 8 and ICU 60 https://bugs.webkit.org/show_bug.cgi?id=185462 Reviewed by Carlos Alberto Lopez Perez. * API/glib/JSCClass.cpp: Silence many -Wcast-function-type warnings. (jsc_class_add_constructor): (jsc_class_add_method): * API/glib/JSCValue.cpp: Silence many -Wcast-function-type warnings. (jsc_value_object_define_property_accessor): (jsc_value_new_function): * CMakeLists.txt: Build BuiltinNames.cpp with -fno-var-tracking-assignments. This was a problem with GCC 7 too, but might as well fix it now. * assembler/ProbeContext.h: (JSC::Probe::CPUState::gpr const): Silence a -Wclass-memaccess warning. (JSC::Probe::CPUState::spr const): Ditto. Assume std::remove_const is safe to clobber. * b3/air/AirArg.h: (JSC::B3::Air::Arg::isRepresentableAs): Silence -Wfallthrough warning. * builtins/BuiltinNames.cpp: (JSC::BuiltinNames::BuiltinNames): Moved from BuiltinNames.h so we can use a special flag. * builtins/BuiltinNames.h: (JSC::BuiltinNames::BuiltinNames): Moved to BuiltinNames.cpp. * dfg/DFGDoubleFormatState.h: (JSC::DFG::mergeDoubleFormatStates): Silence -Wfallthrough warnings. * heap/MarkedBlockInlines.h: (JSC::MarkedBlock::Handle::finishSweepKnowingHeapCellType): Silence -Wfallthrough warnings. * runtime/ConfigFile.cpp: (JSC::ConfigFile::canonicalizePaths): Here GCC found a genuine mistake, strncat is called with the wrong length parameter and the result is not null-terminated. Also, silence a -Wstringop-truncation warning as we intentionally truncate filenames that exceed PATH_MAX. * runtime/IntlDateTimeFormat.cpp: (JSC::IntlDateTimeFormat::partTypeString): Avoid an ICU deprecation warning. * runtime/JSGlobalObject.cpp: (JSC::JSGlobalObject::init): We were unconditionally running some BigInt code by accident. (JSC::JSGlobalObject::visitChildren): Probably a serious bug? Fixed. 2018-04-12 Michael Catanzaro [WPE] Move libWPEWebInspectorResources.so to pkglibdir https://bugs.webkit.org/show_bug.cgi?id=184379 Reviewed by Žan Doberšek. Load the module from the new location. * PlatformWPE.cmake: * inspector/remote/glib/RemoteInspectorUtils.cpp: (Inspector::backendCommands): 2018-04-12 Michael Catanzaro [WPE] Improve include hierarchy https://bugs.webkit.org/show_bug.cgi?id=184376 Reviewed by Žan Doberšek. Install JSC headers under /usr/include/wpe-webkit-0.1/jsc instead of /usr/include/wpe-0.1/WPE/jsc. * PlatformWPE.cmake: 2018-04-09 Michael Catanzaro [WPE] Don't install JSC C API headers https://bugs.webkit.org/show_bug.cgi?id=184375 Reviewed by Žan Doberšek. None of the functions declared in these headers are exported in WPE. Use the new jsc API instead. * PlatformWPE.cmake: 2018-05-01 Dominik Infuehr Add SetCallee as DFG-Operation https://bugs.webkit.org/show_bug.cgi?id=184582 Reviewed by Filip Pizlo. For recursive tail calls not only the argument count can change but also the callee. Add SetCallee to DFG that sets the callee slot in the current call frame. Also update the callee when optimizing a recursive tail call. Enable recursive tail call optimization also for closures. * dfg/DFGAbstractInterpreterInlines.h: (JSC::DFG::AbstractInterpreter::executeEffects): * dfg/DFGByteCodeParser.cpp: (JSC::DFG::ByteCodeParser::handleRecursiveTailCall): (JSC::DFG::ByteCodeParser::handleCallVariant): * dfg/DFGClobberize.h: (JSC::DFG::clobberize): * dfg/DFGDoesGC.cpp: (JSC::DFG::doesGC): * dfg/DFGFixupPhase.cpp: (JSC::DFG::FixupPhase::fixupNode): * dfg/DFGMayExit.cpp: * dfg/DFGNodeType.h: * dfg/DFGPredictionPropagationPhase.cpp: * dfg/DFGSafeToExecute.h: (JSC::DFG::safeToExecute): * dfg/DFGSpeculativeJIT.cpp: (JSC::DFG::SpeculativeJIT::compileSetCallee): * 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::compileSetCallee): 2018-04-24 Keith Miller fromCharCode is missing some exception checks https://bugs.webkit.org/show_bug.cgi?id=184952 Reviewed by Saam Barati. I also removed the pointless slow path function and moved it into the main function. * runtime/StringConstructor.cpp: (JSC::stringFromCharCode): (JSC::stringFromCharCodeSlowCase): Deleted. 2018-04-23 Filip Pizlo Unreviewed, revert accidental change to verbose flag. * dfg/DFGByteCodeParser.cpp: 2018-04-23 Filip Pizlo Roll out r226655 because it broke OSR entry when the pre-header is inadequately profiled. Rubber stamped by Saam Barati. This is a >2x speed-up in SunSpider/bitops-bitwise-and. We don't really care about SunSpider anymore, but r226655 didn't result in any benchmark wins and just regressed this test by a lot. Seems sensible to just roll it out. * dfg/DFGByteCodeParser.cpp: (JSC::DFG::ByteCodeParser::addToGraph): (JSC::DFG::ByteCodeParser::parse): 2018-04-08 Yusuke Suzuki Use alignas instead of compiler-specific attributes https://bugs.webkit.org/show_bug.cgi?id=183508 Reviewed by Mark Lam. Use C++11 alignas specifier. It is portable compared to compiler-specific aligned attributes. * heap/RegisterState.h: * jit/JIT.h: (JSC::JIT::compile): Deleted. (JSC::JIT::compileGetByVal): Deleted. (JSC::JIT::compileGetByValWithCachedId): Deleted. (JSC::JIT::compilePutByVal): Deleted. (JSC::JIT::compileDirectPutByVal): Deleted. (JSC::JIT::compilePutByValWithCachedId): Deleted. (JSC::JIT::compileHasIndexedProperty): Deleted. (JSC::JIT::appendCall): Deleted. (JSC::JIT::appendCallWithSlowPathReturnType): Deleted. (JSC::JIT::exceptionCheck): Deleted. (JSC::JIT::exceptionCheckWithCallFrameRollback): Deleted. (JSC::JIT::emitInt32Load): Deleted. (JSC::JIT::emitInt32GetByVal): Deleted. (JSC::JIT::emitInt32PutByVal): Deleted. (JSC::JIT::emitDoublePutByVal): Deleted. (JSC::JIT::emitContiguousPutByVal): Deleted. (JSC::JIT::emitStoreCell): Deleted. (JSC::JIT::getSlowCase): Deleted. (JSC::JIT::linkSlowCase): Deleted. (JSC::JIT::linkDummySlowCase): Deleted. (JSC::JIT::linkAllSlowCases): Deleted. (JSC::JIT::callOperation): Deleted. (JSC::JIT::callOperationWithProfile): Deleted. (JSC::JIT::callOperationWithResult): Deleted. (JSC::JIT::callOperationNoExceptionCheck): Deleted. (JSC::JIT::callOperationWithCallFrameRollbackOnException): Deleted. (JSC::JIT::emitEnterOptimizationCheck): Deleted. (JSC::JIT::sampleCodeBlock): Deleted. (JSC::JIT::canBeOptimized): Deleted. (JSC::JIT::canBeOptimizedOrInlined): Deleted. (JSC::JIT::shouldEmitProfiling): Deleted. * runtime/VM.h: 2018-04-10 Filip Pizlo REGRESSION(r227341 and r227742): AI and clobberize should be precise and consistent about the effectfulness of CompareEq https://bugs.webkit.org/show_bug.cgi?id=184455 Reviewed by Michael Saboff. LICM is sort of an assertion that AI is as precise as clobberize about effects. If clobberize says that something is not effectful, then LICM will try to hoist it. But LICM's AI hack (AtTailAbstractState) cannot handle hoisting of things that have effects. So, if AI thinks that the thing being hoisted does have effects, then we get a crash. In r227341, we incorrectly told AI that CompareEq(Untyped:, _) is effectful. In fact, only ComapreEq(Untyped:, Untyped:) is effectful, and clobberize knew this already. As a result, LICM would blow up if we hoisted CompareEq(Untyped:, Other:), which clobberize knew wasn't effectful. Instead of fixing this by making AI precise, in r227742 we made matters worse by then breaking clobberize to also think that CompareEq(Untyped:, _) is effectful. This fixes the whole situation by teaching both clobberize and AI that the only effectful form of CompareEq is ComapreEq(Untyped:, Untyped:). * dfg/DFGAbstractInterpreterInlines.h: (JSC::DFG::AbstractInterpreter::executeEffects): * dfg/DFGClobberize.h: (JSC::DFG::clobberize): 2018-04-04 Filip Pizlo REGRESSION(r222563): removed DoubleReal type check causes tons of crashes because CSE has never known how to handle SaneChain https://bugs.webkit.org/show_bug.cgi?id=184319 Reviewed by Saam Barati. In r222581, we replaced type checks about DoubleReal in ArrayPush in the DFG/FTL backends with assertions. That's correct because FixupPhase was emitting those checks as Check(DoubleRealRep:) before the ArrayPush. But this revealed a longstanding CSE bug: CSE will happily match a SaneChain GetByVal with a InBounds GetByVal. SaneChain can return NaN while InBounds cannot. This means that if we first use AI to eliminate the Check(DoubleRealRep:) based on the input being a GetByVal(InBounds) but then replace that with a GetByVal(SaneChain), then we will hit the assertion. This teaches CSE to not replace GetByVal(InBounds) with GetByVal(SaneChain) and vice versa. That gets tricky because PutByVal can match either. So, we use the fact that it's legal for a store to def() more than once: PutByVal now defs() a HeapLocation for InBounds and a HeapLocation for SaneChain. * dfg/DFGCSEPhase.cpp: * dfg/DFGClobberize.h: (JSC::DFG::clobberize): * dfg/DFGHeapLocation.cpp: (WTF::printInternal): * dfg/DFGHeapLocation.h: * dfg/DFGSpeculativeJIT.cpp: (JSC::DFG::SpeculativeJIT::compileArrayPush): 2018-04-03 Filip Pizlo JSArray::appendMemcpy seems to be missing a barrier https://bugs.webkit.org/show_bug.cgi?id=184290 Reviewed by Mark Lam. If you write to an array that may contain pointers and you didn't just allocate it, then you need to barrier right after. I don't know if this is really a bug - it's possible that all callers of appendMemcpy do things that obviate the need for this barrier. But these barriers are cheap, so we should do them if in doubt. * runtime/JSArray.cpp: (JSC::JSArray::appendMemcpy): 2018-03-31 Filip Pizlo JSC crash in JIT code with for-of loop and Array/Set iterators https://bugs.webkit.org/show_bug.cgi?id=183174 Reviewed by Saam Barati. * dfg/DFGSafeToExecute.h: (JSC::DFG::safeToExecute): Fix the bug by making GetByOffset and friends verify that they are getting the type proof they want at the desired hoisting site. 2018-03-30 Robin Morisset Out-of-bounds accesses due to a missing check for MAX_STORAGE_VECTOR_LENGTH in unshiftCountForAnyIndexingType https://bugs.webkit.org/show_bug.cgi?id=183657 Reviewed by Keith Miller. There was just a missing check in unshiftCountForIndexingType. I've also replaced 'return false' by 'return true' in the case of an 'out-of-memory' exception, because 'return false' means 'please continue to the slow path', and the slow path has an assert that there is no unhandled exception (line 360 of ArrayPrototype.cpp). Finally, I made the assert in ensureLength a release assert as it would have caught this bug and prevented it from being a security risk. * runtime/ArrayPrototype.cpp: (JSC::unshift): * runtime/JSArray.cpp: (JSC::JSArray::unshiftCountWithAnyIndexingType): * runtime/JSObject.h: (JSC::JSObject::ensureLength): 2018-03-28 Robin Morisset appendQuotedJSONString stops on arithmetic overflow instead of propagating it upwards https://bugs.webkit.org/show_bug.cgi?id=183894 Reviewed by Saam Barati. Use the return value of appendQuotedJSONString to fail more gracefully when given a string that is too large to handle. * runtime/JSONObject.cpp: (JSC::Stringifier::appendStringifiedValue): 2018-03-25 Saam Barati r228149 accidentally removed code that resets m_emptyCursor at the end of a GC https://bugs.webkit.org/show_bug.cgi?id=183995 Reviewed by Filip Pizlo. The removal of this line of code was unintended and happened during some refactoring Fil was doing. The consequence of removing this line of code is that the m_emptyCursor became a monotonically increasing integer, leading the cursor to usually being out of bounds of the block range (depending on what the program is doing). This made the functionality of finding an empty block to steal almost always fail. * heap/BlockDirectory.cpp: (JSC::BlockDirectory::prepareForAllocation): 2018-03-22 Michael Saboff Race Condition in arrayProtoFuncReverse() causes wrong results or crash https://bugs.webkit.org/show_bug.cgi?id=183901 Reviewed by Keith Miller. Added write barriers to ensure the reversed contents are properly marked. * runtime/ArrayPrototype.cpp: (JSC::arrayProtoFuncReverse): 2018-03-05 Mark Lam JITThunk functions should only be called when the JIT is enabled. https://bugs.webkit.org/show_bug.cgi?id=183351 Reviewed by Keith Miller. * jit/JITThunks.cpp: (JSC::JITThunks::ctiNativeCall): (JSC::JITThunks::ctiNativeConstruct): (JSC::JITThunks::ctiInternalFunctionCall): (JSC::JITThunks::ctiInternalFunctionConstruct): * runtime/VM.cpp: (JSC::VM::VM): (JSC::VM::getCTIInternalFunctionTrampolineFor): 2018-03-01 Yusuke Suzuki ASSERTION FAILED: matchContextualKeyword(m_vm->propertyNames->async) https://bugs.webkit.org/show_bug.cgi?id=183173 Reviewed by Saam Barati. Classifier could propagate an error which does not occur at the first token of the given expression. We should check whether the given token is "async" instead of assertion. * parser/Parser.cpp: (JSC::Parser::parseAssignmentExpression): 2018-03-01 Saam Barati We need to clear cached structures when having a bad time https://bugs.webkit.org/show_bug.cgi?id=183256 Reviewed by Mark Lam. This patch makes both InternalFunctionAllocationProfile and the VM's structure cache having-a-bad-time aware. For InternalFunctionAllocationProfile, we clear them when they'd produce an object with a bad indexing type. For the VM's Structure cache, we conservatively clear the entire cache since it may be housing Structures with bad indexing types. * runtime/FunctionRareData.h: (JSC::FunctionRareData::clearInternalFunctionAllocationProfile): * runtime/JSGlobalObject.cpp: (JSC::JSGlobalObject::haveABadTime): * runtime/StructureCache.h: (JSC::StructureCache::clear): 2018-03-01 Yusuke Suzuki Unreviewed, fix exception check for ExceptionScope https://bugs.webkit.org/show_bug.cgi?id=183175 * jsc.cpp: (GlobalObject::moduleLoaderFetch): 2018-02-28 Dominik Infuehr [ARM] Fix compile error in debug builds by invoking unpoisoned(). Reviewed by Mark Lam. * assembler/MacroAssemblerCodeRef.h: (JSC::MacroAssemblerCodePtr::MacroAssemblerCodePtr): Fix compile error. (JSC::MacroAssemblerCodePtr::createFromExecutableAddress()): Ditto. (JSC::MacroAssemblerCodePtr::dataLocation()): Ditto. * yarr/YarrInterpreter.cpp: (JSC::Yarr::ByteCompiler::dumpDisjunction): use %zu for printf'ing size_t. 2018-02-28 JF Bastien GC should sweep code block before deleting https://bugs.webkit.org/show_bug.cgi?id=183229 Reviewed by Saam Barati, Fil Pizlo. Stub routines shouldn't get deleted before codeblocks have been swept, otherwise there's a small race window where the codeblock thinks it's still reachable. * heap/Heap.cpp: (JSC::Heap::deleteUnmarkedCompiledCode): (JSC::Heap::sweepInFinalize): 2018-02-28 Yusuke Suzuki JSC crash with `import("")` https://bugs.webkit.org/show_bug.cgi?id=183175 Reviewed by Saam Barati. Add file existence and file type check for module loader implementation in jsc.cpp. This is not safe for TOCTOU, but it is OK since this functionality is used for the JSC shell (jsc.cpp): testing purpose. * jsc.cpp: (fillBufferWithContentsOfFile): (fetchModuleFromLocalFileSystem): 2018-02-27 Keith Miller Replace TrustedImmPtr(0) with TrustedImmPtr(nullptr) https://bugs.webkit.org/show_bug.cgi?id=183195 Reviewed by Mark Lam. * assembler/AbstractMacroAssembler.h: (JSC::AbstractMacroAssembler::TrustedImmPtr::TrustedImmPtr): * assembler/MacroAssembler.h: (JSC::MacroAssembler::patchableBranchPtr): (JSC::MacroAssembler::patchableBranchPtrWithPatch): * assembler/MacroAssemblerARM.h: (JSC::MacroAssemblerARM::branchPtrWithPatch): (JSC::MacroAssemblerARM::storePtrWithPatch): * assembler/MacroAssemblerARM64.h: (JSC::MacroAssemblerARM64::call): (JSC::MacroAssemblerARM64::tailRecursiveCall): (JSC::MacroAssemblerARM64::branchPtrWithPatch): (JSC::MacroAssemblerARM64::patchableBranchPtrWithPatch): (JSC::MacroAssemblerARM64::storePtrWithPatch): * assembler/MacroAssemblerARMv7.h: (JSC::MacroAssemblerARMv7::branchPtrWithPatch): (JSC::MacroAssemblerARMv7::patchableBranchPtr): (JSC::MacroAssemblerARMv7::patchableBranchPtrWithPatch): (JSC::MacroAssemblerARMv7::storePtrWithPatch): * assembler/MacroAssemblerMIPS.h: (JSC::MacroAssemblerMIPS::branchPtrWithPatch): (JSC::MacroAssemblerMIPS::storePtrWithPatch): * assembler/MacroAssemblerX86.h: (JSC::MacroAssemblerX86::branchPtrWithPatch): * assembler/MacroAssemblerX86_64.h: (JSC::MacroAssemblerX86_64::callWithSlowPathReturnType): (JSC::MacroAssemblerX86_64::call): (JSC::MacroAssemblerX86_64::tailRecursiveCall): (JSC::MacroAssemblerX86_64::makeTailRecursiveCall): (JSC::MacroAssemblerX86_64::branchPtrWithPatch): * bytecode/AccessCase.cpp: (JSC::AccessCase::generateImpl): * dfg/DFGSpeculativeJIT.cpp: (JSC::DFG::SpeculativeJIT::emitAllocateRawObject): (JSC::DFG::SpeculativeJIT::compileToLowerCase): (JSC::DFG::SpeculativeJIT::compileMakeRope): (JSC::DFG::SpeculativeJIT::compileGetTypedArrayByteOffset): (JSC::DFG::SpeculativeJIT::compileNewFunctionCommon): (JSC::DFG::SpeculativeJIT::compileCreateDirectArguments): (JSC::DFG::SpeculativeJIT::compileNewArrayWithSpread): (JSC::DFG::SpeculativeJIT::compileArraySlice): (JSC::DFG::SpeculativeJIT::compileAllocatePropertyStorage): (JSC::DFG::SpeculativeJIT::compileReallocatePropertyStorage): (JSC::DFG::SpeculativeJIT::compileNewTypedArrayWithSize): * dfg/DFGSpeculativeJIT.h: (JSC::DFG::SpeculativeJIT::TrustedImmPtr::TrustedImmPtr): * dfg/DFGSpeculativeJIT32_64.cpp: (JSC::DFG::SpeculativeJIT::compile): (JSC::DFG::SpeculativeJIT::compileAllocateNewArrayWithSize): * dfg/DFGSpeculativeJIT64.cpp: (JSC::DFG::SpeculativeJIT::emitCall): (JSC::DFG::SpeculativeJIT::compile): (JSC::DFG::SpeculativeJIT::compileAllocateNewArrayWithSize): * dfg/DFGThunks.cpp: (JSC::DFG::osrExitGenerationThunkGenerator): * ftl/FTLLowerDFGToB3.cpp: (JSC::FTL::DFG::LowerDFGToB3::compileCallOrConstruct): (JSC::FTL::DFG::LowerDFGToB3::compileTailCall): (JSC::FTL::DFG::LowerDFGToB3::compileCallOrConstructVarargs): * ftl/FTLThunks.cpp: (JSC::FTL::genericGenerationThunkGenerator): * jit/AssemblyHelpers.cpp: (JSC::AssemblyHelpers::debugCall): (JSC::AssemblyHelpers::sanitizeStackInline): * jit/IntrinsicEmitter.cpp: (JSC::IntrinsicGetterAccessCase::emitIntrinsicGetter): * jit/JITCall.cpp: (JSC::JIT::compileOpCall): * jit/JITCall32_64.cpp: (JSC::JIT::compileOpCall): * jit/ScratchRegisterAllocator.cpp: (JSC::ScratchRegisterAllocator::restoreUsedRegistersFromScratchBufferForCall): * wasm/js/WasmToJS.cpp: (JSC::Wasm::wasmToJS): * yarr/YarrJIT.cpp: (JSC::Yarr::YarrGenerator::initParenContextFreeList): (JSC::Yarr::YarrGenerator::storeToFrameWithPatch): (JSC::Yarr::YarrGenerator::generate): 2018-02-26 Mark Lam Modernize FINALIZE_CODE and peer macros to use __VA_ARGS__ arguments. https://bugs.webkit.org/show_bug.cgi?id=183159 Reviewed by Keith Miller. * assembler/LinkBuffer.h: * assembler/testmasm.cpp: (JSC::compile): * b3/B3Compile.cpp: (JSC::B3::compile): * b3/air/testair.cpp: * b3/testb3.cpp: (JSC::B3::testEntrySwitchSimple): (JSC::B3::testEntrySwitchNoEntrySwitch): (JSC::B3::testEntrySwitchWithCommonPaths): (JSC::B3::testEntrySwitchWithCommonPathsAndNonTrivialEntrypoint): (JSC::B3::testEntrySwitchLoop): * bytecode/InlineAccess.cpp: (JSC::linkCodeInline): (JSC::InlineAccess::rewireStubAsJump): * bytecode/PolymorphicAccess.cpp: (JSC::PolymorphicAccess::regenerate): * dfg/DFGJITFinalizer.cpp: (JSC::DFG::JITFinalizer::finalize): (JSC::DFG::JITFinalizer::finalizeFunction): * dfg/DFGOSRExit.cpp: (JSC::DFG::OSRExit::compileOSRExit): * dfg/DFGThunks.cpp: (JSC::DFG::osrExitThunkGenerator): (JSC::DFG::osrExitGenerationThunkGenerator): (JSC::DFG::osrEntryThunkGenerator): * ftl/FTLJITFinalizer.cpp: (JSC::FTL::JITFinalizer::finalizeCommon): * ftl/FTLLazySlowPath.cpp: (JSC::FTL::LazySlowPath::generate): * ftl/FTLOSRExitCompiler.cpp: (JSC::FTL::compileStub): * ftl/FTLThunks.cpp: (JSC::FTL::genericGenerationThunkGenerator): (JSC::FTL::slowPathCallThunkGenerator): * jit/ExecutableAllocator.cpp: * jit/JIT.cpp: (JSC::JIT::link): * jit/JITMathIC.h: (JSC::isProfileEmpty): * jit/JITOpcodes.cpp: (JSC::JIT::privateCompileHasIndexedProperty): * jit/JITOpcodes32_64.cpp: (JSC::JIT::privateCompileHasIndexedProperty): * jit/JITPropertyAccess.cpp: (JSC::JIT::stringGetByValStubGenerator): (JSC::JIT::privateCompileGetByVal): (JSC::JIT::privateCompileGetByValWithCachedId): (JSC::JIT::privateCompilePutByVal): (JSC::JIT::privateCompilePutByValWithCachedId): * jit/JITPropertyAccess32_64.cpp: (JSC::JIT::stringGetByValStubGenerator): * jit/JITStubRoutine.h: * jit/Repatch.cpp: (JSC::linkPolymorphicCall): * jit/SpecializedThunkJIT.h: (JSC::SpecializedThunkJIT::finalize): * jit/ThunkGenerators.cpp: (JSC::throwExceptionFromCallSlowPathGenerator): (JSC::linkCallThunkGenerator): (JSC::linkPolymorphicCallThunkGenerator): (JSC::virtualThunkFor): (JSC::nativeForGenerator): (JSC::arityFixupGenerator): (JSC::unreachableGenerator): (JSC::boundThisNoArgsFunctionCallGenerator): * llint/LLIntThunks.cpp: (JSC::LLInt::generateThunkWithJumpTo): * wasm/WasmBBQPlan.cpp: (JSC::Wasm::BBQPlan::complete): * wasm/WasmBinding.cpp: (JSC::Wasm::wasmToWasm): * wasm/WasmOMGPlan.cpp: (JSC::Wasm::OMGPlan::work): * wasm/WasmThunks.cpp: (JSC::Wasm::throwExceptionFromWasmThunkGenerator): (JSC::Wasm::throwStackOverflowFromWasmThunkGenerator): (JSC::Wasm::triggerOMGTierUpThunkGenerator): * wasm/js/WasmToJS.cpp: (JSC::Wasm::handleBadI64Use): (JSC::Wasm::wasmToJS): * yarr/YarrJIT.cpp: (JSC::Yarr::YarrGenerator::compile): 2018-02-25 Yusuke Suzuki [FTL] Support PutByVal(ArrayStorage/SlowPutArrayStorage) https://bugs.webkit.org/show_bug.cgi?id=182965 Reviewed by Saam Barati. This patch extends FTL coverage for PutByVal by adding ArrayStorage and SlwoPutArrayStorage support. Basically large part of the patch is porting from DFG code. Since PutByVal already emits CheckInBounds for InBounds case, we do not have OutOfBounds check for that case. This is the last change for FTL to support all the types of DFG nodes except for CreateThis. * dfg/DFGOperations.cpp: * dfg/DFGOperations.h: * dfg/DFGSpeculativeJIT.cpp: (JSC::DFG::SpeculativeJIT::compileDoublePutByVal): * dfg/DFGSpeculativeJIT64.cpp: (JSC::DFG::SpeculativeJIT::compile): * ftl/FTLCapabilities.cpp: (JSC::FTL::canCompile): * ftl/FTLLowerDFGToB3.cpp: (JSC::FTL::DFG::LowerDFGToB3::compilePutByVal): (JSC::FTL::DFG::LowerDFGToB3::contiguousPutByValOutOfBounds): For consistency, we use operationPutByValXXX and operationPutByValDirectXXX. But except for SlowPutArrayStorage case, basically it is meaningless since we do not have indexed accessors. 2018-02-26 Saam Barati validateStackAccess should not validate if the offset is within the stack bounds https://bugs.webkit.org/show_bug.cgi?id=183067 Reviewed by Mark Lam. The validation rule was saying that any load from the stack must be within the stack bounds of the frame. However, it's natural for a user of B3 to emit code that may be outside of B3's stack bounds, but guard such a load with a branch. The FTL does exactly this with GetMyArgumentByVal. B3 is wrong to assert that this is a static property about all stack loads. * b3/B3Validate.cpp: 2018-02-23 Saam Barati Make Number.isInteger an intrinsic https://bugs.webkit.org/show_bug.cgi?id=183088 Reviewed by JF Bastien. When profiling the ML subtest in ARES, I noticed it was spending some time in Number.isInteger. This patch makes that operation an intrinsic in the DFG/FTL. It might be a speedup by 1% or so on that subtest, but it's likely not an aggregate speedup on ARES. However, it is definitely faster than calling into a builtin function, so we might as well have it as an intrinsic. * dfg/DFGAbstractInterpreterInlines.h: (JSC::DFG::AbstractInterpreter::executeEffects): * dfg/DFGByteCodeParser.cpp: (JSC::DFG::ByteCodeParser::handleIntrinsicCall): * dfg/DFGClobberize.h: (JSC::DFG::clobberize): * dfg/DFGDoesGC.cpp: (JSC::DFG::doesGC): * dfg/DFGFixupPhase.cpp: (JSC::DFG::FixupPhase::fixupNode): * dfg/DFGNodeType.h: * dfg/DFGOperations.cpp: * dfg/DFGOperations.h: * dfg/DFGPredictionPropagationPhase.cpp: * dfg/DFGSafeToExecute.h: (JSC::DFG::safeToExecute): * 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::compileNumberIsInteger): (JSC::FTL::DFG::LowerDFGToB3::unboxDouble): * runtime/Intrinsic.cpp: (JSC::intrinsicName): * runtime/Intrinsic.h: * runtime/NumberConstructor.cpp: (JSC::NumberConstructor::finishCreation): (JSC::numberConstructorFuncIsInteger): * runtime/NumberConstructor.h: (JSC::NumberConstructor::isIntegerImpl): 2018-02-23 Oleksandr Skachkov WebAssembly: cache memory address / size on instance https://bugs.webkit.org/show_bug.cgi?id=177305 Reviewed by JF Bastien. Cache memory address/size in wasm:Instance to avoid load wasm:Memory object during access to memory and memory size property in JiT * wasm/WasmB3IRGenerator.cpp: (JSC::Wasm::B3IRGenerator::restoreWebAssemblyGlobalState): (JSC::Wasm::B3IRGenerator::addCurrentMemory): (JSC::Wasm::B3IRGenerator::addCallIndirect): * wasm/WasmBinding.cpp: (JSC::Wasm::wasmToWasm): * wasm/WasmInstance.h: (JSC::Wasm::Instance::cachedMemory const): (JSC::Wasm::Instance::cachedMemorySize const): (JSC::Wasm::Instance::createWeakPtr): (JSC::Wasm::Instance::setMemory): (JSC::Wasm::Instance::updateCachedMemory): (JSC::Wasm::Instance::offsetOfCachedMemory): (JSC::Wasm::Instance::offsetOfCachedMemorySize): (JSC::Wasm::Instance::offsetOfCachedIndexingMask): (JSC::Wasm::Instance::allocationSize): * wasm/WasmMemory.cpp: (JSC::Wasm::Memory::grow): (JSC::Wasm::Memory::registerInstance): * wasm/WasmMemory.h: (JSC::Wasm::Memory::indexingMask): * wasm/js/JSToWasm.cpp: (JSC::Wasm::createJSToWasmWrapper): * wasm/js/WebAssemblyModuleRecord.cpp: (JSC::WebAssemblyModuleRecord::evaluate): 2018-02-23 Saam Barati ArgumentsEliminationPhase has a branch on GetByOffset that should be an assert https://bugs.webkit.org/show_bug.cgi?id=182982 Reviewed by Yusuke Suzuki. I don't know why this check was not always an assert. When we see a GetByOffset on an eliminated allocation, that allocation *must* be a PhantomClonedArguments. If it weren't, the GetByOffset would have escaped it. Because this transformation happens by visiting blocks in pre-order, and by visiting nodes in a block starting from index zero to index block->size() - 1, we're guaranteed that eliminated allocations get transformed before users of it, since we visit nodes in dominator order. * dfg/DFGArgumentsEliminationPhase.cpp: 2018-02-23 Yusuke Suzuki [JSC] Implement $vm.ftlTrue function for FTL testing https://bugs.webkit.org/show_bug.cgi?id=183071 Reviewed by Mark Lam. Add $vm.ftlTrue, which becomes true if the caller is compiled in FTL. This is useful for testing whether the caller function is compiled in FTL. We also remove duplicate DFGTrue function in jsc.cpp. We have $vm.dfgTrue. * dfg/DFGByteCodeParser.cpp: (JSC::DFG::ByteCodeParser::handleIntrinsicCall): * jsc.cpp: (GlobalObject::finishCreation): (functionFalse1): (functionFalse2): Deleted. * runtime/Intrinsic.cpp: (JSC::intrinsicName): * runtime/Intrinsic.h: * tools/JSDollarVM.cpp: (JSC::functionFTLTrue): (JSC::JSDollarVM::finishCreation): 2018-02-22 Yusuke Suzuki [FTL] Support HasIndexedProperty for ArrayStorage and SlowPutArrayStorage https://bugs.webkit.org/show_bug.cgi?id=182792 Reviewed by Mark Lam. This patch adds HasIndexedProperty for ArrayStorage and SlowPutArrayStorage in FTL. HasIndexedProperty with ArrayStorage frequently causes FTL compilation failures in web-tooling-benchmarks. * ftl/FTLCapabilities.cpp: (JSC::FTL::canCompile): * ftl/FTLLowerDFGToB3.cpp: (JSC::FTL::DFG::LowerDFGToB3::compileHasIndexedProperty): 2018-02-22 Mark Lam Refactor MacroAssembler code to improve reuse and extensibility. https://bugs.webkit.org/show_bug.cgi?id=183054 Reviewed by Saam Barati. * assembler/ARM64Assembler.h: * assembler/MacroAssembler.cpp: * assembler/MacroAssembler.h: * assembler/MacroAssemblerARM.h: * assembler/MacroAssemblerARM64.h: (JSC::MacroAssemblerARM64::canCompact): (JSC::MacroAssemblerARM64::computeJumpType): (JSC::MacroAssemblerARM64::jumpSizeDelta): (JSC::MacroAssemblerARM64::link): (JSC::MacroAssemblerARM64::load64): (JSC::MacroAssemblerARM64::load64WithAddressOffsetPatch): (JSC::MacroAssemblerARM64::load32): (JSC::MacroAssemblerARM64::load32WithAddressOffsetPatch): (JSC::MacroAssemblerARM64::load16): (JSC::MacroAssemblerARM64::load16SignedExtendTo32): (JSC::MacroAssemblerARM64::load8): (JSC::MacroAssemblerARM64::load8SignedExtendTo32): (JSC::MacroAssemblerARM64::store64): (JSC::MacroAssemblerARM64::store64WithAddressOffsetPatch): (JSC::MacroAssemblerARM64::store32): (JSC::MacroAssemblerARM64::store32WithAddressOffsetPatch): (JSC::MacroAssemblerARM64::store16): (JSC::MacroAssemblerARM64::store8): (JSC::MacroAssemblerARM64::getEffectiveAddress): (JSC::MacroAssemblerARM64::branchDoubleNonZero): (JSC::MacroAssemblerARM64::branchDoubleZeroOrNaN): (JSC::MacroAssemblerARM64::branchTruncateDoubleToInt32): (JSC::MacroAssemblerARM64::loadDouble): (JSC::MacroAssemblerARM64::loadFloat): (JSC::MacroAssemblerARM64::moveConditionallyAfterFloatingPointCompare): (JSC::MacroAssemblerARM64::moveDoubleConditionallyAfterFloatingPointCompare): (JSC::MacroAssemblerARM64::storeDouble): (JSC::MacroAssemblerARM64::storeFloat): (JSC::MacroAssemblerARM64::call): (JSC::MacroAssemblerARM64::jump): (JSC::MacroAssemblerARM64::tailRecursiveCall): (JSC::MacroAssemblerARM64::setCarry): (JSC::MacroAssemblerARM64::reemitInitialMoveWithPatch): (JSC::MacroAssemblerARM64::isBreakpoint): (JSC::MacroAssemblerARM64::invert): (JSC::MacroAssemblerARM64::readCallTarget): (JSC::MacroAssemblerARM64::replaceWithVMHalt): (JSC::MacroAssemblerARM64::replaceWithJump): (JSC::MacroAssemblerARM64::maxJumpReplacementSize): (JSC::MacroAssemblerARM64::patchableJumpSize): (JSC::MacroAssemblerARM64::repatchCall): (JSC::MacroAssemblerARM64::makeBranch): (JSC::MacroAssemblerARM64::makeCompareAndBranch): (JSC::MacroAssemblerARM64::makeTestBitAndBranch): (JSC::MacroAssemblerARM64::ARM64Condition): (JSC::MacroAssemblerARM64::moveWithFixedWidth): (JSC::MacroAssemblerARM64::load): (JSC::MacroAssemblerARM64::store): (JSC::MacroAssemblerARM64::tryLoadWithOffset): (JSC::MacroAssemblerARM64::tryLoadSignedWithOffset): (JSC::MacroAssemblerARM64::tryStoreWithOffset): (JSC::MacroAssemblerARM64::jumpAfterFloatingPointCompare): (JSC::MacroAssemblerARM64::linkCall): * assembler/MacroAssemblerARMv7.h: * assembler/MacroAssemblerMIPS.h: * assembler/MacroAssemblerX86Common.h: * assembler/ProbeStack.h: - Removed a forward declaration of an obsolete class. 2018-02-22 Yusuke Suzuki Remove sleep(double) and sleepMS(double) interfaces https://bugs.webkit.org/show_bug.cgi?id=183038 Reviewed by Mark Lam. * bytecode/SuperSampler.cpp: (JSC::initializeSuperSampler): 2018-02-20 Saam Barati DFG::VarargsForwardingPhase should eliminate getting argument length https://bugs.webkit.org/show_bug.cgi?id=182959 Reviewed by Keith Miller. This patch teaches the DFG VarargsForwardingPhase to not treat length accesses on Cloned/Direct Arguments objects as escapes. It teaches this phase to materialize the length in the same way the ArgumentsEliminationPhase does. This is around a 0.5-1% speedup on ARES6 on my iMac. It speeds up the ML subtest by 2-4%. This patch also extends compileGetArgumentCountIncludingThis to take a parameter that is the inline call frame to load from (in the case where the inline call frame is a varargs frame). This allows the the emitCodeToGetArgumentsArrayLength helper function to just emit a GetArgumentCountIncludingThis node instead of a GetLocal. If we emitted a GetLocal, we'd need to rerun CPS rethreading. * dfg/DFGArgumentsEliminationPhase.cpp: * dfg/DFGArgumentsUtilities.cpp: (JSC::DFG::emitCodeToGetArgumentsArrayLength): * dfg/DFGByteCodeParser.cpp: (JSC::DFG::ByteCodeParser::getArgumentCount): * dfg/DFGClobberize.h: (JSC::DFG::clobberize): * dfg/DFGNode.h: (JSC::DFG::Node::argumentsInlineCallFrame): * dfg/DFGSpeculativeJIT.cpp: (JSC::DFG::SpeculativeJIT::compileGetArgumentCountIncludingThis): * dfg/DFGVarargsForwardingPhase.cpp: * ftl/FTLLowerDFGToB3.cpp: (JSC::FTL::DFG::LowerDFGToB3::compileGetArgumentCountIncludingThis): 2018-02-14 Yusuke Suzuki [FTL] Support ArrayPush for ArrayStorage https://bugs.webkit.org/show_bug.cgi?id=182782 Reviewed by Saam Barati. This patch adds support for ArrayPush(ArrayStorage). We just port ArrayPush(ArrayStorage) in DFG to FTL. * ftl/FTLAbstractHeapRepository.h: * ftl/FTLCapabilities.cpp: (JSC::FTL::canCompile): * ftl/FTLLowerDFGToB3.cpp: (JSC::FTL::DFG::LowerDFGToB3::compileArrayPush): 2018-02-14 Yusuke Suzuki [FTL] Support ArrayPop for ArrayStorage https://bugs.webkit.org/show_bug.cgi?id=182783 Reviewed by Saam Barati. This patch adds ArrayPop(ArrayStorage) support to FTL. We port the implementation in DFG to FTL. * ftl/FTLAbstractHeapRepository.h: * ftl/FTLCapabilities.cpp: (JSC::FTL::canCompile): * ftl/FTLLowerDFGToB3.cpp: (JSC::FTL::DFG::LowerDFGToB3::compileArrayPop): 2018-02-14 Yusuke Suzuki [FTL] Add Arrayify for ArrayStorage and SlowPutArrayStorage https://bugs.webkit.org/show_bug.cgi?id=182731 Reviewed by Saam Barati. This patch adds support for Arrayify(ArrayStorage/SlowPutArrayStorage) to FTL. Due to ArrayifyToStructure and CheckArray changes, necessary changes for supporting Arrayify in FTL are already done. Just allowing it in FTLCapabilities.cpp is enough. We fix FTL's CheckArray logic. Previously, CheckArray(SlowPutArrayStorage) does not pass ArrayStorage in FTL. But now it passes this as DFG does. Moreover, we fix DFG's CheckArray where CheckArray(ArrayStorage+NonArray) can pass ArrayStorage+Array. * dfg/DFGSpeculativeJIT.cpp: (JSC::DFG::SpeculativeJIT::silentFill): (JSC::DFG::SpeculativeJIT::jumpSlowForUnwantedArrayMode): * dfg/DFGSpeculativeJIT.h: * ftl/FTLCapabilities.cpp: (JSC::FTL::canCompile): * ftl/FTLLowerDFGToB3.cpp: (JSC::FTL::DFG::LowerDFGToB3::isArrayTypeForArrayify): 2018-02-19 Saam Barati Don't use JSFunction's allocation profile when getting the prototype can be effectful https://bugs.webkit.org/show_bug.cgi?id=182942 Reviewed by Mark Lam. Prior to this patch, the create_this implementation assumed that anything that is a JSFunction can use the object allocation profile and go down the fast path to allocate the |this| object. Implied by this approach is that accessing the 'prototype' property of the incoming function is not an effectful operation. This is inherent to the ObjectAllocationProfile data structure: it caches the prototype field. However, getting the 'prototype' property might be an effectful operation, e.g, it could be a getter. Many variants of functions in JS have the 'prototype' property as non-configurable. However, some functions, like bound functions, do not have the 'prototype' field with these attributes. This patch adds the notion of 'canUseAllocationProfile' to JSFunction and threads it through so that we only go down the fast path and use the allocation profile when the prototype property is non-configurable. * bytecompiler/NodesCodegen.cpp: (JSC::ClassExprNode::emitBytecode): * dfg/DFGOperations.cpp: * runtime/CommonSlowPaths.cpp: (JSC::SLOW_PATH_DECL): * runtime/JSFunction.cpp: (JSC::JSFunction::prototypeForConstruction): (JSC::JSFunction::allocateAndInitializeRareData): (JSC::JSFunction::initializeRareData): (JSC::JSFunction::getOwnPropertySlot): (JSC::JSFunction::canUseAllocationProfileNonInline): * runtime/JSFunction.h: (JSC::JSFunction::ensureRareDataAndAllocationProfile): * runtime/JSFunctionInlines.h: (JSC::JSFunction::canUseAllocationProfile): 2018-02-19 Saam Barati Don't mark an array profile out of bounds for the cases where the DFG will convert the access to SaneChain https://bugs.webkit.org/show_bug.cgi?id=182912 Reviewed by Keith Miller. In the baseline JIT and LLInt, when we loading a hole from an original array, with the array prototype chain being normal, we end up marking the ArrayProfile for that GetByVal as out of bounds. However, the DFG knows exactly how to optimize this case by returning undefined when loading from a hole. Currently, it only does this for Contiguous arrays (and sometimes Double arrays). This patch just makes sure to not mark the ArrayProfile as out of bounds in this scenario for Contiguous arrays, since the DFG will always optimize this case. However, we should extend this by profiling when a GetByVal loads a hole. By doing so, we can optimize this for Int32, ArrayStorage, and maybe even Double arrays. That work will happen in: https://bugs.webkit.org/show_bug.cgi?id=182940 This patch is a 30-50% speedup on JetStream's hash-map test. This patch speeds up JetStream by 1% when testing on my iMac. * dfg/DFGArrayMode.cpp: (JSC::DFG::ArrayMode::refine const): * dfg/DFGFixupPhase.cpp: (JSC::DFG::FixupPhase::fixupNode): * jit/JITOperations.cpp: (JSC::getByVal): (JSC::canAccessArgumentIndexQuickly): Deleted. * llint/LLIntSlowPaths.cpp: (JSC::LLInt::getByVal): (JSC::LLInt::LLINT_SLOW_PATH_DECL): * llint/LowLevelInterpreter32_64.asm: * llint/LowLevelInterpreter64.asm: * runtime/CommonSlowPaths.h: (JSC::CommonSlowPaths::canAccessArgumentIndexQuickly): 2018-02-17 Filip Pizlo GetArrayMask should support constant folding https://bugs.webkit.org/show_bug.cgi?id=182907 Reviewed by Saam Barati. Implement constant folding for GetArrayMask. This revealed a bug in tryGetFoldableView, where it was ignoring the result of a jsDynamicCast<>(). This wasn't a bug before because it would have been impossible for that function to get called with a non-null value if the value was not an array view, due to type filtering in CheckArray, the fact that CheckArray had to dominate GetArrayLength, and the fact that the other tryGetFoldableView overload made sure that the array mode was some typed array. This isn't a measurable progression, but it does save a register in the codegen for typed array accesses. Hopefully these improvements add up. * assembler/AssemblerBuffer.h: * dfg/DFGAbstractInterpreterInlines.h: (JSC::DFG::AbstractInterpreter::executeEffects): * dfg/DFGGraph.cpp: (JSC::DFG::Graph::tryGetFoldableView): 2018-02-16 Fujii Hironori fast/frames/sandboxed-iframe-navigation-top-denied.html is crashing in Inspector::createScriptCallStackForConsole::Exec for GTK https://bugs.webkit.org/show_bug.cgi?id=172952 Reviewed by Michael Catanzaro. Null dereference of VM::topCallFrame happens in Inspector::createScriptCallStackForConsole if the ExecState has no call frames. * inspector/ScriptCallStackFactory.cpp: (Inspector::createScriptCallStack): Do null check of topCallFrame. (Inspector::createScriptCallStackForConsole): Ditto. 2018-02-18 Dominik Inführ Offlineasm/MIPS: immediates need to be within 16-bit signed values https://bugs.webkit.org/show_bug.cgi?id=182890 Reviewed by Michael Catanzaro. In Sequence.getModifiedListMIPS(), we allow immediate values within the range -0xffff..0xffff for immediates (addresses and other immediates), but then in Immediate.mipsOperand() and Address.mipsOperand() we raise if immediate values are not within -0x7fff..0x7fff. This is inconsistent, and broke compilation on mips since r228552 made the VM structure bigger meaning we address values with bigger offsets in llint. This change restricts the allowed range, so that a separate load of the value is done for values outside of that range. * offlineasm/mips.rb: 2018-02-15 Filip Pizlo Objects that contain dangerous things should be allocated far away from objects that can do OOB https://bugs.webkit.org/show_bug.cgi?id=182843 Reviewed by Saam Barati. To complete our object distancing plan, we need to put objects that can contain unpoisoned data far away from objects that cannot. Objects referenceable from JSValues cannot contain unpoisoned data, but auxiliary data can. This further divides auxiliary data that is meant for storing mostly JSValues from data that is meant for storing anything. This is achieved by having three SecurityKinds that are used for MarkedBlock selection and zeroing sort of the same way SecurityOriginToken already was. This change shouldn't make anything slower. If anything, it will be a small speed-up because it removes some cases of MarkedBlock zeroing since we don't need to zero blocks used for two of the SecurityKinds. * Sources.txt: * bytecode/ObjectAllocationProfileInlines.h: (JSC::ObjectAllocationProfile::initializeProfile): * heap/BlockDirectory.cpp: (JSC::BlockDirectory::addBlock): * heap/BlockDirectory.h: * heap/CellAttributes.cpp: (JSC::CellAttributes::dump const): * heap/CellAttributes.h: (JSC::CellAttributes::CellAttributes): * heap/LocalAllocator.cpp: (JSC::LocalAllocator::allocateSlowCase): (JSC::LocalAllocator::tryAllocateWithoutCollecting): * heap/MarkedBlock.cpp: (JSC::MarkedBlock::Handle::didAddToDirectory): (JSC::MarkedBlock::Handle::associateWithOrigin): Deleted. * heap/MarkedBlock.h: * heap/SecurityKind.cpp: Added. (WTF::printInternal): * heap/SecurityKind.h: Added. * runtime/JSCellInlines.h: (JSC::JSCell::subspaceFor): * runtime/JSDestructibleObjectHeapCellType.cpp: (JSC::JSDestructibleObjectHeapCellType::JSDestructibleObjectHeapCellType): * runtime/JSObject.h: (JSC::JSObject::subspaceFor): * runtime/JSSegmentedVariableObjectHeapCellType.cpp: (JSC::JSSegmentedVariableObjectHeapCellType::JSSegmentedVariableObjectHeapCellType): * runtime/JSStringHeapCellType.cpp: (JSC::JSStringHeapCellType::JSStringHeapCellType): * runtime/Symbol.h: (JSC::Symbol::subspaceFor): * runtime/VM.cpp: (JSC::VM::VM): * runtime/VM.h: * wasm/js/JSWebAssemblyCodeBlockHeapCellType.cpp: (JSC::JSWebAssemblyCodeBlockHeapCellType::JSWebAssemblyCodeBlockHeapCellType): 2018-02-15 Yusuke Suzuki [JSC] Remove monotonicallyIncreasingTime and currentTime https://bugs.webkit.org/show_bug.cgi?id=182793 Reviewed by Saam Barati. We would like to drop monotonicallyIncreasingTime and currentTime from our tree by replacing them with MonotonicTime and WallTime, which are well-typed alternatives, compared to double. This patch removes monotonicallyIncreasingTime and currentTime in JSC. * b3/testb3.cpp: (JSC::B3::testComplex): * dfg/DFGPhase.h: (JSC::DFG::runAndLog): * dfg/DFGPlan.cpp: (JSC::DFG::Plan::compileInThread): (JSC::DFG::Plan::compileInThreadImpl): * dfg/DFGPlan.h: * dynbench.cpp: (JSC::benchmarkImpl): * heap/BlockDirectory.cpp: (JSC::BlockDirectory::isPagedOut): * heap/BlockDirectory.h: * heap/FullGCActivityCallback.cpp: (JSC::FullGCActivityCallback::doCollection): * heap/Heap.cpp: (JSC::Heap::isPagedOut): (JSC::Heap::sweepSynchronously): * heap/Heap.h: * heap/MarkedSpace.cpp: (JSC::MarkedSpace::isPagedOut): * heap/MarkedSpace.h: * inspector/agents/InspectorConsoleAgent.cpp: (Inspector::InspectorConsoleAgent::startTiming): (Inspector::InspectorConsoleAgent::stopTiming): * inspector/agents/InspectorConsoleAgent.h: * inspector/agents/InspectorRuntimeAgent.cpp: (Inspector::InspectorRuntimeAgent::getRuntimeTypesForVariablesAtOffsets): * jit/JIT.cpp: (JSC::JIT::compileWithoutLinking): (JSC::JIT::compileTimeStats): * jit/JIT.h: * jsc.cpp: (StopWatch::start): (StopWatch::stop): (StopWatch::getElapsedMS): (functionPreciseTime): (runJSC): * profiler/ProfilerDatabase.cpp: (JSC::Profiler::Database::logEvent): * profiler/ProfilerEvent.cpp: (JSC::Profiler::Event::toJS const): * profiler/ProfilerEvent.h: (JSC::Profiler::Event::Event): (JSC::Profiler::Event::time const): * runtime/CodeCache.cpp: (JSC::CodeCacheMap::pruneSlowCase): * runtime/CodeCache.h: (JSC::CodeCacheMap::CodeCacheMap): (JSC::CodeCacheMap::prune): * runtime/DateConstructor.cpp: (JSC::callDate): * runtime/TypeProfilerLog.cpp: (JSC::TypeProfilerLog::processLogEntries): * testRegExp.cpp: (StopWatch::start): (StopWatch::stop): (StopWatch::getElapsedMS): 2018-02-14 Keith Miller We should be able to jsDynamicCast from JSType when possible https://bugs.webkit.org/show_bug.cgi?id=182804 Reviewed by Filip Pizlo and Mark Lam. This patch beefs up jsDynamicCast in some of the cases where we can use the JSType to quickly determine if a cell is a subclass of the desired type. Since all JSCells have a range of JSTypes they support, if there is a range exclusive to a class and all subclasses we can use that range to quickly determine if the cast should be successful. Additionally, the JSValue versions of jsCast and jsDynamicCast now call the JSCell version after checking the value is a cell. Finally, the casting functions have been moved to a new header, JSCast.h * JavaScriptCore.xcodeproj/project.pbxproj: * bytecode/CallVariant.h: * bytecode/CodeBlock.h: * bytecode/ExecutableToCodeBlockEdge.h: * bytecode/TrackedReferences.h: * bytecode/UnlinkedCodeBlock.h: * bytecode/UnlinkedFunctionExecutable.h: * dfg/DFGAbstractValue.h: * dfg/DFGCommonData.h: * dfg/DFGFrozenValue.h: * dfg/DFGStructureAbstractValue.h: * heap/CellContainerInlines.h: * heap/ConservativeRoots.cpp: * heap/GCLogging.cpp: * heap/HeapInlines.h: * heap/HeapSnapshotBuilder.cpp: * heap/MarkedBlock.cpp: * heap/MarkedBlockInlines.h: * heap/SubspaceInlines.h: * heap/WeakInlines.h: * jit/JITOpcodes.cpp: * jit/JITOpcodes32_64.cpp: * llint/LLIntOffsetsExtractor.cpp: * runtime/ArrayBufferNeuteringWatchpoint.h: * runtime/BigIntPrototype.cpp: * runtime/ClassInfo.h: * runtime/CustomGetterSetter.h: * runtime/FunctionRareData.h: * runtime/GetterSetter.h: * runtime/InferredType.h: * runtime/InferredTypeTable.h: * runtime/InferredValue.h: * runtime/InternalFunction.cpp: (JSC::InternalFunction::finishCreation): * runtime/JSAPIValueWrapper.h: * runtime/JSArray.h: (JSC::JSArray::finishCreation): * runtime/JSArrayBufferView.cpp: (JSC::JSArrayBufferView::finishCreation): * runtime/JSCast.h: Added. (JSC::jsCast): (JSC::JSCastingHelpers::jsDynamicCastGenericImpl): (JSC::JSCastingHelpers::jsDynamicCastJSTypeImpl): (JSC::JSCastingHelpers::JSDynamicCastTraits::cast): (JSC::jsDynamicCast): * runtime/JSCell.cpp: * runtime/JSCell.h: (JSC::jsCast): Deleted. (JSC::jsDynamicCast): Deleted. * runtime/JSCellInlines.h: * runtime/JSFunction.cpp: (JSC::JSFunction::finishCreation): * runtime/JSJob.h: * runtime/JSObject.h: (JSC::JSObject::finishCreation): * runtime/JSPromiseDeferred.h: * runtime/JSPropertyNameEnumerator.h: * runtime/NativeStdFunctionCell.h: * runtime/ScopedArgumentsTable.h: * runtime/SparseArrayValueMap.h: * runtime/Structure.h: * runtime/StructureChain.h: * runtime/StructureRareData.h: * tools/CellProfile.h: * wasm/js/JSWebAssemblyCodeBlock.h: 2018-02-14 Michael Saboff Crash: triggerOMGTierUpThunkGenerator() doesn't align the stack pointer before calling C++ code https://bugs.webkit.org/show_bug.cgi?id=182808 Reviewed by Keith Miller. Set up a proper frame with a prologue and epilogue to align the stack pointer for the rest of the thunk. * wasm/WasmThunks.cpp: (JSC::Wasm::triggerOMGTierUpThunkGenerator): 2018-02-14 Saam Barati Setting a VMTrap shouldn't look at topCallFrame since that may imply we're in C code and holding the malloc lock https://bugs.webkit.org/show_bug.cgi?id=182801 Reviewed by Keith Miller. VMTraps would sometimes install traps when it paused the JS thread when it was in C code. This is wrong, as installing traps mallocs, and the JS thread may have been holding the malloc lock while in C code. This could lead to a deadlock when C code was holding the malloc lock. This patch makes it so that we only install traps when we've proven the PC is in JIT or LLInt code. If we're in JIT/LLInt code, we are guaranteed that we're not holding the malloc lock. * jsc.cpp: (GlobalObject::finishCreation): (functionMallocInALoop): * runtime/VMTraps.cpp: (JSC::VMTraps::tryInstallTrapBreakpoints): 2018-02-14 Michael Saboff REGRESSION(225695) : com.apple.WebKit.WebContent at com.apple.JavaScriptCore: JSC::RegExp::match + 630 :: stack overflow https://bugs.webkit.org/show_bug.cgi?id=182705 Reviewed by Mark Lam. Moved the pattern context buffer used by YARR JIT'ed code from a stack local to a lazily allocated buffer on the VM. Exposed when the buffer is needed to reduce likelihood that we'd allocated it. Guarded use of the buffer with a lock since the DFG compiler may call into YARR JIT'ed code on a compilation thread. * runtime/RegExpInlines.h: (JSC::RegExp::matchInline): * runtime/VM.cpp: (JSC::VM::~VM): (JSC::VM::acquireRegExpPatternContexBuffer): (JSC::VM::releaseRegExpPatternContexBuffer): * runtime/VM.h: * yarr/YarrJIT.cpp: (JSC::Yarr::YarrGenerator::generate): (JSC::Yarr::YarrGenerator::backtrack): (JSC::Yarr::YarrGenerator::opCompileParenthesesSubpattern): (JSC::Yarr::YarrGenerator::generateEnter): (JSC::Yarr::YarrGenerator::generateReturn): (JSC::Yarr::YarrGenerator::YarrGenerator): (JSC::Yarr::YarrGenerator::compile): * yarr/YarrJIT.h: (JSC::Yarr::YarrCodeBlock::usesPatternContextBuffer): (JSC::Yarr::YarrCodeBlock::setUsesPaternContextBuffer): 2018-02-13 Saam Barati putDirectIndexSlowOrBeyondVectorLength needs to convert to dictionary indexing mode always if attributes are present https://bugs.webkit.org/show_bug.cgi?id=182755 Reviewed by Keith Miller. putDirectIndexSlowOrBeyondVectorLength with non-zero attributes only converted the object in question to a dictionary indexing mode when the index is less than the vector length. This makes no sense. If we're defining a getter, setter, or read only property, we must always enter the dictionary indexing mode irrespective of the index in relation to the vector length. * runtime/JSObject.cpp: (JSC::JSObject::putDirectIndexSlowOrBeyondVectorLength): 2018-02-13 Guillaume Emont [YarrJIT][ARM] We need to save r8 as it is the initial start register https://bugs.webkit.org/show_bug.cgi?id=182157 Reviewed by Saam Barati. Register r8 is the initial start register since r224172, so we need to save it. We still need to save r6 as well even though it is not the initial start register any more, since it is used by the MacroAssembler which we use (we get crashes in some situations if we don't save r6). This issue was discovered because stress/regress-174044.js crashes on a raspberry pi 2 when compiled in -O2. * yarr/YarrJIT.cpp: (JSC::Yarr::YarrGenerator::generateEnter): (JSC::Yarr::YarrGenerator::generateReturn): 2018-02-13 Caitlin Potter [JSC] cache TaggedTemplate arrays by callsite rather than by contents https://bugs.webkit.org/show_bug.cgi?id=182717 Reviewed by Yusuke Suzuki. https://github.com/tc39/ecma262/pull/890 imposes a change to template literals, to allow template callsite arrays to be collected when the code containing the tagged template call is collected. This spec change has received concensus and been ratified. This change eliminates the eternal map associating template contents with arrays. * CMakeLists.txt: * JavaScriptCore.xcodeproj/project.pbxproj: * Sources.txt: * bytecode/CodeBlock.cpp: (JSC::CodeBlock::setConstantRegisters): * bytecode/DirectEvalCodeCache.cpp: (JSC::DirectEvalCodeCache::setSlow): * bytecode/UnlinkedCodeBlock.cpp: (JSC::UnlinkedCodeBlock::UnlinkedCodeBlock): * bytecode/UnlinkedCodeBlock.h: (JSC::UnlinkedCodeBlock::allowDirectEvalCache const): * bytecompiler/BytecodeGenerator.cpp: (JSC::BytecodeGenerator::addTemplateObjectConstant): (JSC::BytecodeGenerator::emitGetTemplateObject): (JSC::BytecodeGenerator::addTemplateRegistryKeyConstant): Deleted. * bytecompiler/BytecodeGenerator.h: * parser/Parser.cpp: (JSC::Parser::parseInner): (JSC::Parser::parseMemberExpression): * parser/Parser.h: * parser/ParserModes.h: * runtime/EvalExecutable.h: (JSC::EvalExecutable::allowDirectEvalCache const): * runtime/JSGlobalObject.cpp: (JSC::JSGlobalObject::JSGlobalObject): * runtime/JSGlobalObject.h: (JSC::JSGlobalObject::templateRegistry): Deleted. * runtime/JSTemplateObjectDescriptor.cpp: Renamed from Source/JavaScriptCore/runtime/TemplateRegistry.cpp. (JSC::JSTemplateObjectDescriptor::JSTemplateObjectDescriptor): (JSC::JSTemplateObjectDescriptor::create): (JSC::JSTemplateObjectDescriptor::destroy): (JSC::JSTemplateObjectDescriptor::createTemplateObject): * runtime/JSTemplateObjectDescriptor.h: Renamed from Source/JavaScriptCore/runtime/JSTemplateRegistryKey.h. (JSC::isTemplateObjectDescriptor): * runtime/JSTemplateRegistryKey.cpp: Removed. * runtime/TemplateObjectDescriptor.cpp: Renamed from Source/JavaScriptCore/runtime/TemplateRegistryKey.cpp. (JSC::TemplateObjectDescriptor::~TemplateObjectDescriptor): * runtime/TemplateObjectDescriptor.h: Renamed from Source/JavaScriptCore/runtime/TemplateRegistryKey.h. (JSC::TemplateObjectDescriptor::operator== const): (JSC::TemplateObjectDescriptor::operator!= const): (JSC::TemplateObjectDescriptor::Hasher::hash): (JSC::TemplateObjectDescriptor::Hasher::equal): (JSC::TemplateObjectDescriptor::create): (JSC::TemplateObjectDescriptor::TemplateObjectDescriptor): (JSC::TemplateObjectDescriptor::calculateHash): * runtime/TemplateRegistry.h: Removed. * runtime/TemplateRegistryKeyTable.cpp: Removed. * runtime/TemplateRegistryKeyTable.h: Removed. * runtime/VM.cpp: (JSC::VM::VM): * runtime/VM.h: (JSC::VM::templateRegistryKeyTable): Deleted. * runtime/VMEntryScope.cpp: * CMakeLists.txt: * JavaScriptCore.xcodeproj/project.pbxproj: * Sources.txt: * bytecode/CodeBlock.cpp: (JSC::CodeBlock::setConstantRegisters): * bytecode/DirectEvalCodeCache.cpp: (JSC::DirectEvalCodeCache::setSlow): * bytecode/UnlinkedCodeBlock.h: (JSC::UnlinkedCodeBlock::allowDirectEvalCache const): * bytecompiler/BytecodeGenerator.cpp: (JSC::BytecodeGenerator::addTemplateObjectConstant): (JSC::BytecodeGenerator::emitGetTemplateObject): (JSC::BytecodeGenerator::addTemplateRegistryKeyConstant): Deleted. * bytecompiler/BytecodeGenerator.h: * parser/Parser.cpp: (JSC::Parser::parseInner): (JSC::Parser::parseMemberExpression): * parser/Parser.h: * parser/ParserModes.h: * runtime/EvalExecutable.h: (JSC::EvalExecutable::allowDirectEvalCache const): * runtime/JSGlobalObject.cpp: (JSC::JSGlobalObject::JSGlobalObject): * runtime/JSGlobalObject.h: (JSC::JSGlobalObject::templateRegistry): Deleted. * runtime/JSTemplateObjectDescriptor.cpp: Renamed from Source/JavaScriptCore/runtime/TemplateRegistry.cpp. (JSC::JSTemplateObjectDescriptor::JSTemplateObjectDescriptor): (JSC::JSTemplateObjectDescriptor::create): (JSC::JSTemplateObjectDescriptor::destroy): (JSC::JSTemplateObjectDescriptor::createTemplateObject): * runtime/JSTemplateObjectDescriptor.h: Renamed from Source/JavaScriptCore/runtime/JSTemplateRegistryKey.h. (JSC::isTemplateObjectDescriptor): * runtime/JSTemplateRegistryKey.cpp: Removed. * runtime/TemplateObjectDescriptor.cpp: Renamed from Source/JavaScriptCore/runtime/TemplateRegistryKey.cpp. (JSC::TemplateObjectDescriptor::~TemplateObjectDescriptor): * runtime/TemplateObjectDescriptor.h: Renamed from Source/JavaScriptCore/runtime/TemplateRegistryKey.h. (JSC::TemplateObjectDescriptor::operator== const): (JSC::TemplateObjectDescriptor::operator!= const): (JSC::TemplateObjectDescriptor::Hasher::hash): (JSC::TemplateObjectDescriptor::Hasher::equal): (JSC::TemplateObjectDescriptor::create): (JSC::TemplateObjectDescriptor::TemplateObjectDescriptor): (JSC::TemplateObjectDescriptor::calculateHash): * runtime/TemplateRegistry.h: Removed. * runtime/TemplateRegistryKeyTable.cpp: Removed. * runtime/TemplateRegistryKeyTable.h: Removed. * runtime/VM.cpp: (JSC::VM::VM): * runtime/VM.h: (JSC::VM::templateRegistryKeyTable): Deleted. * runtime/VMEntryScope.cpp: * CMakeLists.txt: * JavaScriptCore.xcodeproj/project.pbxproj: * Sources.txt: * bytecode/CodeBlock.cpp: (JSC::CodeBlock::setConstantRegisters): * bytecode/DirectEvalCodeCache.cpp: (JSC::DirectEvalCodeCache::setSlow): * bytecode/UnlinkedCodeBlock.h: (JSC::UnlinkedCodeBlock::allowDirectEvalCache const): * bytecompiler/BytecodeGenerator.cpp: (JSC::BytecodeGenerator::addTemplateObjectConstant): (JSC::BytecodeGenerator::emitGetTemplateObject): (JSC::BytecodeGenerator::addTemplateRegistryKeyConstant): Deleted. * bytecompiler/BytecodeGenerator.h: * parser/Parser.cpp: (JSC::Parser::parseInner): (JSC::Parser::parseMemberExpression): * parser/Parser.h: * parser/ParserModes.h: * runtime/EvalExecutable.h: (JSC::EvalExecutable::allowDirectEvalCache const): * runtime/JSGlobalObject.cpp: (JSC::JSGlobalObject::JSGlobalObject): * runtime/JSGlobalObject.h: (JSC::JSGlobalObject::templateRegistry): Deleted. * runtime/JSTemplateObjectDescriptor.cpp: Renamed from Source/JavaScriptCore/runtime/TemplateRegistry.cpp. (JSC::JSTemplateObjectDescriptor::JSTemplateObjectDescriptor): (JSC::JSTemplateObjectDescriptor::create): (JSC::JSTemplateObjectDescriptor::destroy): (JSC::JSTemplateObjectDescriptor::createTemplateObject): * runtime/JSTemplateObjectDescriptor.h: Renamed from Source/JavaScriptCore/runtime/JSTemplateRegistryKey.h. (JSC::isTemplateObjectDescriptor): * runtime/JSTemplateRegistryKey.cpp: Removed. * runtime/TemplateObjectDescriptor.cpp: Renamed from Source/JavaScriptCore/runtime/TemplateRegistryKey.cpp. (JSC::TemplateObjectDescriptor::~TemplateObjectDescriptor): * runtime/TemplateObjectDescriptor.h: Renamed from Source/JavaScriptCore/runtime/TemplateRegistryKey.h. (JSC::TemplateObjectDescriptor::operator== const): (JSC::TemplateObjectDescriptor::operator!= const): (JSC::TemplateObjectDescriptor::Hasher::hash): (JSC::TemplateObjectDescriptor::Hasher::equal): (JSC::TemplateObjectDescriptor::create): (JSC::TemplateObjectDescriptor::TemplateObjectDescriptor): (JSC::TemplateObjectDescriptor::calculateHash): * runtime/TemplateRegistry.h: Removed. * runtime/TemplateRegistryKeyTable.cpp: Removed. * runtime/TemplateRegistryKeyTable.h: Removed. * runtime/VM.cpp: (JSC::VM::VM): * runtime/VM.h: (JSC::VM::templateRegistryKeyTable): Deleted. * runtime/VMEntryScope.cpp: 2018-02-13 Yusuke Suzuki Support GetArrayLength on ArrayStorage in the FTL https://bugs.webkit.org/show_bug.cgi?id=182625 Reviewed by Saam Barati. This patch adds GetArrayLength and CheckArray + ArrayStorage & SlowPutArrayStorage support for FTL. The implementation is trivial; just porting one in DFG to FTL. This fixes several FTL compilation failures in web-tooling-benchmarks while we still need to support ArrayPush, ArrayPop, Arrayify, and PutByVal. * dfg/DFGSpeculativeJIT.cpp: (JSC::DFG::SpeculativeJIT::checkArray): * ftl/FTLCapabilities.cpp: (JSC::FTL::canCompile): * ftl/FTLLowerDFGToB3.cpp: (JSC::FTL::DFG::LowerDFGToB3::compileGetArrayLength): (JSC::FTL::DFG::LowerDFGToB3::isArrayTypeForArrayify): (JSC::FTL::DFG::LowerDFGToB3::isArrayTypeForCheckArray): 2018-02-10 Filip Pizlo Lock down JSFunction https://bugs.webkit.org/show_bug.cgi?id=182652 Reviewed by Saam Barati. This poisons pointers in JSFunction and puts all of the types in the JSFunction hierarchy in isospaces. This is so neutral on JetStream: 0.01% slower with p = 0.969211. * dfg/DFGSpeculativeJIT.cpp: (JSC::DFG::SpeculativeJIT::compileNewFunctionCommon): (JSC::DFG::SpeculativeJIT::compileNewFunction): (JSC::DFG::SpeculativeJIT::compileCreateThis): * dfg/DFGSpeculativeJIT.h: (JSC::DFG::SpeculativeJIT::TrustedImmPtr::TrustedImmPtr): (JSC::DFG::SpeculativeJIT::TrustedImmPtr::weakPointer): (JSC::DFG::SpeculativeJIT::TrustedImmPtr::weakPoisonedPointer): * dfg/DFGSpeculativeJIT64.cpp: (JSC::DFG::SpeculativeJIT::compile): * ftl/FTLLowerDFGToB3.cpp: (JSC::FTL::DFG::LowerDFGToB3::compileGetExecutable): (JSC::FTL::DFG::LowerDFGToB3::compileNewFunction): (JSC::FTL::DFG::LowerDFGToB3::weakPointer): (JSC::FTL::DFG::LowerDFGToB3::weakPoisonedPointer): * ftl/FTLOutput.h: (JSC::FTL::Output::weakPointer): (JSC::FTL::Output::weakPoisonedPointer): * heap/MarkedSpace.cpp: * jit/JITOpcodes.cpp: (JSC::JIT::emit_op_create_this): * jit/ThunkGenerators.cpp: (JSC::virtualThunkFor): (JSC::nativeForGenerator): (JSC::boundThisNoArgsFunctionCallGenerator): * llint/LowLevelInterpreter.asm: * llint/LowLevelInterpreter64.asm: * runtime/JSAsyncFunction.h: (JSC::JSAsyncFunction::subspaceFor): * runtime/JSAsyncGeneratorFunction.h: (JSC::JSAsyncGeneratorFunction::subspaceFor): * runtime/JSBoundFunction.h: (JSC::JSBoundFunction::subspaceFor): * runtime/JSCPoison.h: * runtime/JSCustomGetterSetterFunction.h: (JSC::JSCustomGetterSetterFunction::subspaceFor): * runtime/JSFunction.h: (JSC::JSFunction::subspaceFor): * runtime/JSGeneratorFunction.h: (JSC::JSGeneratorFunction::subspaceFor): * runtime/JSNativeStdFunction.h: (JSC::JSNativeStdFunction::subspaceFor): * runtime/VM.cpp: (JSC::VM::VM): * runtime/VM.h: * wasm/js/WebAssemblyFunction.h: * wasm/js/WebAssemblyWrapperFunction.h: 2018-02-16 Saam Barati Fix bugs from r228411 https://bugs.webkit.org/show_bug.cgi?id=182851 Reviewed by JF Bastien. There was a bug from r228411 where inside the constant folding phase, we used an insertCheck method that didn't handle varargs. This would lead to a crash. When thinking about the fix for that function, I realized a made a couple of mistakes in r228411. One is probably a security bug, and the other is a performance bug because it'll prevent CSE for certain flavors of GetByVal nodes. Both blunders are similar in nature. In r228411, I added code in LICM that inserted a CheckVarargs node with children of another varargs node. However, to construct this new node's children, I just copied the AdjacencyList. This does a shallow copy. What we needed was a deep copy. We needed to create a new vararg AdjacencyList that points to edges that are deep copies of the original varargs children. This patch fixes this goof in LICM. r228411 made it so that PureValue over a varargs node would just compare actual AdjacencyLists structs. So, if you had two GetByVals that had equal santized children, their actual AdjacencyList structs are *not* bitwise equal, since they'll have different firstChild values. Instead, we need to do a deep compare of their adjacency lists. This patch teaches PureValue how to do that. * dfg/DFGClobberize.h: (JSC::DFG::clobberize): * dfg/DFGConstantFoldingPhase.cpp: (JSC::DFG::ConstantFoldingPhase::foldConstants): * dfg/DFGGraph.h: (JSC::DFG::Graph::copyVarargChildren): * dfg/DFGInsertionSet.h: (JSC::DFG::InsertionSet::insertCheck): * dfg/DFGLICMPhase.cpp: (JSC::DFG::LICMPhase::attemptHoist): * dfg/DFGPureValue.cpp: (JSC::DFG::PureValue::dump const): * dfg/DFGPureValue.h: (JSC::DFG::PureValue::PureValue): (JSC::DFG::PureValue::op const): (JSC::DFG::PureValue::hash const): (JSC::DFG::PureValue::operator== const): (JSC::DFG::PureValue::isVarargs const): (JSC::DFG::PureValue::children const): Deleted. * dfg/DFGStrengthReductionPhase.cpp: (JSC::DFG::StrengthReductionPhase::handleNode): (JSC::DFG::StrengthReductionPhase::convertToIdentityOverChild): 2018-02-13 Saam Barati Follup fix to r228411 for 32-bit builds. I missed a place where we used non vararg getter for child2(). * dfg/DFGSpeculativeJIT32_64.cpp: (JSC::DFG::SpeculativeJIT::compile): 2018-02-12 Saam Barati Add a GetIndexMask node and make it an input to GetByVal for array and typed array accesses in DFG SSA https://bugs.webkit.org/show_bug.cgi?id=182633 Reviewed by Keith Miller. This patch introduces a GetIndexMask node to DFG SSA. This is an input to GetByVal for the GetByVal variants that do conservative index masking. The reason I'm adding this node is I realized there were loads of the butterfly index mask inside loops that B3 couldn't reason about because B3 can't arbitrarily hoist loads out of loops if those loops have side exits (because the side exit might be protecting the safety of the load). However, for these loops I analyzed, the DFG would be able to hoist these loads out of loops because it knows about JS semantics to correctly reason about the safety of hoisting the load. This is a 1% speedup on JetStream on Mac and iOS in my testing. This patch also adds some infrastructure for eliminating and doing CSE on varargs nodes. Because this patch makes GetByVal a varargs node, I ran into issues we never had before. We never had a varargs node that could be CSEd or be hoisted out of a loop until I made GetByVal varargs. To make it all work, I added a CheckVarargs node. This is just like Check, but it's varargs. * dfg/DFGAbstractInterpreterInlines.h: (JSC::DFG::AbstractInterpreter::executeEffects): * dfg/DFGAdjacencyList.h: (JSC::DFG::AdjacencyList::AdjacencyList): * dfg/DFGArgumentsEliminationPhase.cpp: * dfg/DFGBackwardsPropagationPhase.cpp: (JSC::DFG::BackwardsPropagationPhase::propagate): * dfg/DFGBasicBlock.cpp: (JSC::DFG::BasicBlock::replaceTerminal): * dfg/DFGBasicBlock.h: (JSC::DFG::BasicBlock::findTerminal const): * dfg/DFGBasicBlockInlines.h: (JSC::DFG::BasicBlock::replaceTerminal): * dfg/DFGByteCodeParser.cpp: (JSC::DFG::ByteCodeParser::parseBlock): * dfg/DFGCFGSimplificationPhase.cpp: (JSC::DFG::CFGSimplificationPhase::mergeBlocks): * dfg/DFGCPSRethreadingPhase.cpp: (JSC::DFG::CPSRethreadingPhase::canonicalizeGetLocalFor): (JSC::DFG::CPSRethreadingPhase::canonicalizeFlushOrPhantomLocalFor): * dfg/DFGCSEPhase.cpp: * dfg/DFGCleanUpPhase.cpp: (JSC::DFG::CleanUpPhase::run): * dfg/DFGClobberize.h: (JSC::DFG::clobberize): * dfg/DFGConstantFoldingPhase.cpp: (JSC::DFG::ConstantFoldingPhase::foldConstants): (JSC::DFG::ConstantFoldingPhase::fixUpsilons): * dfg/DFGDCEPhase.cpp: (JSC::DFG::DCEPhase::run): (JSC::DFG::DCEPhase::fixupBlock): * dfg/DFGDoesGC.cpp: (JSC::DFG::doesGC): * dfg/DFGFixupPhase.cpp: (JSC::DFG::FixupPhase::fixupNode): (JSC::DFG::FixupPhase::fixupChecksInBlock): * dfg/DFGHeapLocation.cpp: (WTF::printInternal): * dfg/DFGHeapLocation.h: * dfg/DFGIntegerCheckCombiningPhase.cpp: (JSC::DFG::IntegerCheckCombiningPhase::handleBlock): * dfg/DFGIntegerRangeOptimizationPhase.cpp: * dfg/DFGLICMPhase.cpp: (JSC::DFG::LICMPhase::attemptHoist): * dfg/DFGMayExit.cpp: * dfg/DFGNode.cpp: (JSC::DFG::Node::remove): (JSC::DFG::Node::convertToIdentityOn): * dfg/DFGNode.h: (JSC::DFG::Node::replaceWith): * dfg/DFGNodeType.h: * dfg/DFGObjectAllocationSinkingPhase.cpp: * dfg/DFGPredictionPropagationPhase.cpp: * dfg/DFGPureValue.cpp: (JSC::DFG::PureValue::dump const): * dfg/DFGPureValue.h: (JSC::DFG::PureValue::PureValue): * dfg/DFGPutStackSinkingPhase.cpp: * dfg/DFGSSAConversionPhase.cpp: (JSC::DFG::SSAConversionPhase::run): * dfg/DFGSSALoweringPhase.cpp: (JSC::DFG::SSALoweringPhase::handleNode): * dfg/DFGSafeToExecute.h: (JSC::DFG::safeToExecute): * dfg/DFGSpeculativeJIT.cpp: (JSC::DFG::SpeculativeJIT::SpeculativeJIT): (JSC::DFG::SpeculativeJIT::compileGetByValOnString): (JSC::DFG::SpeculativeJIT::compileGetByValOnIntTypedArray): (JSC::DFG::SpeculativeJIT::compileGetByValOnFloatTypedArray): (JSC::DFG::SpeculativeJIT::compileGetByValForObjectWithString): (JSC::DFG::SpeculativeJIT::compileGetByValForObjectWithSymbol): (JSC::DFG::SpeculativeJIT::compileGetByValOnDirectArguments): (JSC::DFG::SpeculativeJIT::compileGetByValOnScopedArguments): * dfg/DFGSpeculativeJIT.h: * dfg/DFGSpeculativeJIT32_64.cpp: (JSC::DFG::SpeculativeJIT::compile): * dfg/DFGSpeculativeJIT64.cpp: (JSC::DFG::SpeculativeJIT::compile): * dfg/DFGStoreBarrierClusteringPhase.cpp: * dfg/DFGValidate.cpp: * dfg/DFGVarargsForwardingPhase.cpp: * ftl/FTLCapabilities.cpp: (JSC::FTL::canCompile): * ftl/FTLLowerDFGToB3.cpp: (JSC::FTL::DFG::LowerDFGToB3::compileNode): (JSC::FTL::DFG::LowerDFGToB3::compileGetArrayMask): (JSC::FTL::DFG::LowerDFGToB3::compileGetByVal): (JSC::FTL::DFG::LowerDFGToB3::compileStringCharAt): (JSC::FTL::DFG::LowerDFGToB3::maskedIndex): (JSC::FTL::DFG::LowerDFGToB3::pointerIntoTypedArray): 2018-02-12 Mark Lam Miscellaneous refactoring of offlineasm. https://bugs.webkit.org/show_bug.cgi?id=182702 Reviewed by Filip Pizlo. 1. Refactor out the emission of $asm.comment, $asm.codeOrigin, $asm.annotation, and $asm.debugAnnotation into a recordMetaData method. This standardizes how we emit this metadata and makes all backends do it the same way. 2. Add the ability to include custom offlineasm scripts from WebKitAdditions in the future. * offlineasm/arm.rb: * offlineasm/arm64.rb: * offlineasm/ast.rb: * offlineasm/backends.rb: * offlineasm/cloop.rb: * offlineasm/config.rb: * offlineasm/mips.rb: * offlineasm/risc.rb: * offlineasm/x86.rb: 2018-02-12 Saam Barati DFG::emitCodeToGetArgumentsArrayLength needs to handle NewArrayBuffer/PhantomNewArrayBuffer https://bugs.webkit.org/show_bug.cgi?id=182706 Reviewed by Filip Pizlo. When we added support for PhantomNewArrayBuffer, we forgot to update the emitCodeToGetArgumentsArrayLength function to handle PhantomNewArrayBuffer. This patch adds that support. It's trivial to generate the length for a PhantomNewArrayBuffer node since it's a constant buffer, with a constant length. * dfg/DFGArgumentsUtilities.cpp: (JSC::DFG::emitCodeToGetArgumentsArrayLength): 2018-02-12 Mark Lam Add more support for pointer preparations. https://bugs.webkit.org/show_bug.cgi?id=182703 Reviewed by Saam Barati. * llint/LLIntData.h: (JSC::LLInt::getCodePtr): * llint/LLIntPCRanges.h: (JSC::LLInt::isLLIntPC): * runtime/Options.cpp: (JSC::recomputeDependentOptions): 2018-02-12 Mark Lam Fix missing exception check in RegExpObject::matchGlobal(). https://bugs.webkit.org/show_bug.cgi?id=182701 Reviewed by Michael Saboff. This issue was discovered when running JSC tests on an asm LLInt build with JSC_useJIT=false. * runtime/RegExpObject.cpp: (JSC::RegExpObject::matchGlobal): 2018-02-08 Don Olmstead Remove JavaScriptCore/ForwardingHeaders directory https://bugs.webkit.org/show_bug.cgi?id=182594 Reviewed by Mark Lam. * CMakeLists.txt: * ForwardingHeaders/JavaScriptCore/APICast.h: Removed. * ForwardingHeaders/JavaScriptCore/JSBase.h: Removed. * ForwardingHeaders/JavaScriptCore/JSCTestRunnerUtils.h: Removed. * ForwardingHeaders/JavaScriptCore/JSContextRef.h: Removed. * ForwardingHeaders/JavaScriptCore/JSObjectRef.h: Removed. * ForwardingHeaders/JavaScriptCore/JSObjectRefPrivate.h: Removed. * ForwardingHeaders/JavaScriptCore/JSRetainPtr.h: Removed. * ForwardingHeaders/JavaScriptCore/JSStringRef.h: Removed. * ForwardingHeaders/JavaScriptCore/JSStringRefCF.h: Removed. * ForwardingHeaders/JavaScriptCore/JSTypedArray.h: Removed. * ForwardingHeaders/JavaScriptCore/JSValueRef.h: Removed. * ForwardingHeaders/JavaScriptCore/JavaScript.h: Removed. * ForwardingHeaders/JavaScriptCore/JavaScriptCore.h: Removed. * ForwardingHeaders/JavaScriptCore/OpaqueJSString.h: Removed. * ForwardingHeaders/JavaScriptCore/WebKitAvailability.h: Removed. 2018-02-06 Brian Burg Web Inspector: protocol generator should automatically deduce the correct include style to use https://bugs.webkit.org/show_bug.cgi?id=182505 Reviewed by Timothy Hatcher. Currently the generated imports use a mix of system header imports (powered by forwarding headers) and framework-style includes. Since forwarding headers are going away, this patch stops using system header includes for headers that are JavaScriptCore private headers. Instead, use either a relative include or a framework include. * inspector/scripts/codegen/generate_cpp_alternate_backend_dispatcher_header.py: (CppAlternateBackendDispatcherHeaderGenerator.generate_output): (CppAlternateBackendDispatcherHeaderGenerator): (CppAlternateBackendDispatcherHeaderGenerator._generate_secondary_header_includes): * inspector/scripts/codegen/generate_cpp_backend_dispatcher_header.py: (CppBackendDispatcherHeaderGenerator.generate_output): (CppBackendDispatcherHeaderGenerator._generate_secondary_header_includes): * inspector/scripts/codegen/generate_cpp_backend_dispatcher_implementation.py: (CppBackendDispatcherImplementationGenerator.generate_output): (CppBackendDispatcherImplementationGenerator._generate_secondary_header_includes): * inspector/scripts/codegen/generate_cpp_frontend_dispatcher_header.py: (CppFrontendDispatcherHeaderGenerator.generate_output): (CppFrontendDispatcherHeaderGenerator._generate_secondary_header_includes): * inspector/scripts/codegen/generate_cpp_frontend_dispatcher_implementation.py: (CppFrontendDispatcherImplementationGenerator.generate_output): (CppFrontendDispatcherImplementationGenerator._generate_secondary_header_includes): * inspector/scripts/codegen/generate_cpp_protocol_types_header.py: (CppProtocolTypesHeaderGenerator.generate_output): (CppProtocolTypesHeaderGenerator._generate_secondary_header_includes): * inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py: (CppProtocolTypesImplementationGenerator.generate_output): (CppProtocolTypesImplementationGenerator._generate_secondary_header_includes): * inspector/scripts/codegen/generate_objc_backend_dispatcher_header.py: (ObjCBackendDispatcherHeaderGenerator): Convert existing header lists to the new entries format, which includes the allowable target frameworks and the relative path to the header. * inspector/scripts/codegen/generator.py: (Generator.generate_includes_from_entries): Copied from the same in the builtins code generator. It still works great. * inspector/scripts/tests/all/expected/definitions-with-mac-platform.json-result: * inspector/scripts/tests/generic/expected/commands-with-async-attribute.json-result: * inspector/scripts/tests/generic/expected/commands-with-optional-call-return-parameters.json-result: * inspector/scripts/tests/generic/expected/definitions-with-mac-platform.json-result: * inspector/scripts/tests/generic/expected/domain-availability.json-result: * inspector/scripts/tests/generic/expected/domains-with-varying-command-sizes.json-result: * inspector/scripts/tests/generic/expected/enum-values.json-result: * inspector/scripts/tests/generic/expected/events-with-optional-parameters.json-result: * inspector/scripts/tests/generic/expected/generate-domains-with-feature-guards.json-result: * inspector/scripts/tests/generic/expected/same-type-id-different-domain.json-result: * inspector/scripts/tests/generic/expected/shadowed-optional-type-setters.json-result: * inspector/scripts/tests/generic/expected/type-declaration-aliased-primitive-type.json-result: * inspector/scripts/tests/generic/expected/type-declaration-array-type.json-result: * inspector/scripts/tests/generic/expected/type-declaration-enum-type.json-result: * inspector/scripts/tests/generic/expected/type-declaration-object-type.json-result: * inspector/scripts/tests/generic/expected/type-requiring-runtime-casts.json-result: * inspector/scripts/tests/generic/expected/type-with-open-parameters.json-result: * inspector/scripts/tests/generic/expected/worker-supported-domains.json-result: * inspector/scripts/tests/ios/expected/definitions-with-mac-platform.json-result: * inspector/scripts/tests/mac/expected/definitions-with-mac-platform.json-result: Rebaseline. 2018-02-06 Keith Miller put_to_scope/get_from_scope should not cache lexical scopes when expecting a global object https://bugs.webkit.org/show_bug.cgi?id=182549 Reviewed by Saam Barati. Previously, the llint/baseline caching for put_to_scope and get_from_scope would cache lexical environments when the varInjectionWatchpoint had been fired for global properties. Code in the DFG does not follow this same assumption so we could potentially return the wrong result. Additionally, the baseline would write barrier the global object rather than the lexical enviroment object. This patch makes it so that we do not cache anything other than the global object for when the resolve type is GlobalPropertyWithVarInjectionChecks or GlobalProperty. * assembler/MacroAssembler.cpp: (JSC::MacroAssembler::jitAssert): * assembler/MacroAssembler.h: * jit/JITPropertyAccess.cpp: (JSC::JIT::emit_op_get_from_scope): (JSC::JIT::emit_op_put_to_scope): * runtime/CommonSlowPaths.h: (JSC::CommonSlowPaths::tryCachePutToScopeGlobal): (JSC::CommonSlowPaths::tryCacheGetFromScopeGlobal): * runtime/Options.h: 2018-02-11 Guillaume Emont [MIPS] JSC needs to be built with -latomic https://bugs.webkit.org/show_bug.cgi?id=182610 Reviewed by Žan Doberšek. Since r228149, on MIPS we need to link with -latomic, because __atomic_fetch_add_8 is not available as a compiler intrinsic. * CMakeLists.txt: 2018-01-28 Filip Pizlo Global objects should be able to use TLCs to allocate from different blocks from each other https://bugs.webkit.org/show_bug.cgi?id=182227 Reviewed by JF Bastien. This uses TLCs to create at least `minimumDistanceBetweenCellsFromDifferenOrigins` bytes of distance between objects from different origins, using the following combination of things. For short lets refer to that constant as K. - Since r227721, LargeAllocation puts K bytes padding at the end of each allocation. - Since r227718, MarkedBlock puts at least K bytes in its footer. - Since r227617, global objects can have their own TLCs, which make them allocate from a different set of blocks than other global objects. The TLC of a global object comes into effect when you enter the VM via that global object. - With this change, TLCs and blocks both have security origins. A TLC will only use blocks that share the same security origin or empty blocks (in which case we zero the block and change its security origin). WebCore determines the TLC-GlobalObject mapping. By default, global objects would simply use the VM's default TLC. WebCore makes it so that DOM windows (but not worker global objects) get a TLC based on their document's SecurityOrigin. * JavaScriptCore.xcodeproj/project.pbxproj: * Sources.txt: * heap/BlockDirectory.cpp: (JSC::BlockDirectory::findBlockForAllocation): (JSC::BlockDirectory::prepareForAllocation): * heap/BlockDirectory.h: * heap/LocalAllocator.cpp: (JSC::LocalAllocator::LocalAllocator): (JSC::LocalAllocator::reset): (JSC::LocalAllocator::~LocalAllocator): (JSC::LocalAllocator::allocateSlowCase): (JSC::LocalAllocator::tryAllocateWithoutCollecting): * heap/LocalAllocator.h: (JSC::LocalAllocator::tlc const): * heap/MarkStackMergingConstraint.cpp: * heap/MarkStackMergingConstraint.h: * heap/MarkedBlock.cpp: (JSC::MarkedBlock::Handle::associateWithOrigin): * heap/MarkedBlock.h: (JSC::MarkedBlock::Handle::securityOriginToken const): * heap/SecurityOriginToken.cpp: Added. (JSC::uniqueSecurityOriginToken): * heap/SecurityOriginToken.h: Added. * heap/ThreadLocalCache.cpp: (JSC::ThreadLocalCache::create): (JSC::ThreadLocalCache::ThreadLocalCache): (JSC::ThreadLocalCache::allocateData): (JSC::ThreadLocalCache::installSlow): * heap/ThreadLocalCache.h: (JSC::ThreadLocalCache::securityOriginToken const): * heap/ThreadLocalCacheInlines.h: (JSC::ThreadLocalCache::install): * runtime/JSGlobalObject.cpp: (JSC::JSGlobalObject::JSGlobalObject): (JSC::JSGlobalObject::createThreadLocalCache): * runtime/JSGlobalObject.h: (JSC::JSGlobalObject::threadLocalCache): (JSC::JSGlobalObject::threadLocalCache const): Deleted. * runtime/VMEntryScope.cpp: (JSC::VMEntryScope::VMEntryScope): (JSC::VMEntryScope::~VMEntryScope): * runtime/VMEntryScope.h: 2018-02-05 Don Olmstead JavaScriptCore files should not be included relatively https://bugs.webkit.org/show_bug.cgi?id=182452 Reviewed by Keith Miller. * API/JSCallbackConstructor.h: * CMakeLists.txt: * disassembler/ARM64Disassembler.cpp: * disassembler/ARMv7Disassembler.cpp: * heap/LockDuringMarking.h: * inspector/InjectedScriptBase.h: * inspector/InjectedScriptHost.h: * inspector/JavaScriptCallFrame.h: * inspector/ScriptArguments.h: * inspector/ScriptDebugListener.h: * inspector/ScriptDebugServer.h: * inspector/agents/InspectorAgent.h: * inspector/agents/InspectorConsoleAgent.h: * inspector/agents/InspectorDebuggerAgent.h: * inspector/agents/InspectorHeapAgent.h: * inspector/agents/InspectorRuntimeAgent.h: * inspector/agents/InspectorScriptProfilerAgent.h: * runtime/RegExp.h: 2018-02-05 Commit Queue Unreviewed, rolling out r228012. https://bugs.webkit.org/show_bug.cgi?id=182493 "It regressed ARES-6 by 2-4%" (Requested by saamyjoon on #webkit). Reverted changeset: "[JSC] Clean up ArraySpeciesCreate" https://bugs.webkit.org/show_bug.cgi?id=182434 https://trac.webkit.org/changeset/228012 2018-02-02 Ryan Haddad Rebaseline bindings generator tests after r228032. https://bugs.webkit.org/show_bug.cgi?id=182445 Unreviewed test gardening. * Scripts/tests/builtins/expected/WebCoreJSBuiltins.h-result: 2018-02-02 Saam Barati Make various DFG_ASSERTs provide more data to WTFCrashWithInfo https://bugs.webkit.org/show_bug.cgi?id=182453 Reviewed by JF Bastien and Mark Lam. * dfg/DFGAbstractInterpreterInlines.h: (JSC::DFG::AbstractInterpreter::executeEffects): * dfg/DFGArgumentsEliminationPhase.cpp: * dfg/DFGArgumentsUtilities.cpp: (JSC::DFG::emitCodeToGetArgumentsArrayLength): * dfg/DFGFixupPhase.cpp: (JSC::DFG::FixupPhase::fixupChecksInBlock): * dfg/DFGFlowIndexing.h: (JSC::DFG::FlowIndexing::shadowIndex const): * dfg/DFGLICMPhase.cpp: (JSC::DFG::LICMPhase::run): (JSC::DFG::LICMPhase::attemptHoist): * dfg/DFGLoopPreHeaderCreationPhase.cpp: (JSC::DFG::LoopPreHeaderCreationPhase::run): * dfg/DFGPutStackSinkingPhase.cpp: * dfg/DFGSpeculativeJIT.cpp: (JSC::DFG::SpeculativeJIT::compileArithAbs): (JSC::DFG::SpeculativeJIT::compileArithRounding): (JSC::DFG::SpeculativeJIT::compileToPrimitive): * dfg/DFGSpeculativeJIT64.cpp: (JSC::DFG::SpeculativeJIT::fillJSValue): (JSC::DFG::SpeculativeJIT::fillSpeculateInt32Internal): (JSC::DFG::SpeculativeJIT::fillSpeculateInt32Strict): (JSC::DFG::SpeculativeJIT::fillSpeculateInt52): (JSC::DFG::SpeculativeJIT::fillSpeculateDouble): (JSC::DFG::SpeculativeJIT::fillSpeculateBoolean): (JSC::DFG::SpeculativeJIT::compile): * dfg/DFGStoreBarrierClusteringPhase.cpp: * dfg/DFGStoreBarrierInsertionPhase.cpp: * ftl/FTLLowerDFGToB3.cpp: (JSC::FTL::DFG::LowerDFGToB3::compileGetStack): (JSC::FTL::DFG::LowerDFGToB3::compileArithClz32): (JSC::FTL::DFG::LowerDFGToB3::compileArithAbs): (JSC::FTL::DFG::LowerDFGToB3::compileArithRound): (JSC::FTL::DFG::LowerDFGToB3::compileArithFloor): (JSC::FTL::DFG::LowerDFGToB3::compileArithCeil): (JSC::FTL::DFG::LowerDFGToB3::compileArithTrunc): (JSC::FTL::DFG::LowerDFGToB3::compileArithNegate): (JSC::FTL::DFG::LowerDFGToB3::compilePutById): (JSC::FTL::DFG::LowerDFGToB3::compileGetIndexedPropertyStorage): (JSC::FTL::DFG::LowerDFGToB3::compileGetByVal): (JSC::FTL::DFG::LowerDFGToB3::compileStringFromCharCode): (JSC::FTL::DFG::LowerDFGToB3::compileMultiPutByOffset): (JSC::FTL::DFG::LowerDFGToB3::compileCompareEq): (JSC::FTL::DFG::LowerDFGToB3::compileCompareStrictEq): (JSC::FTL::DFG::LowerDFGToB3::compileIn): (JSC::FTL::DFG::LowerDFGToB3::compare): (JSC::FTL::DFG::LowerDFGToB3::switchStringRecurse): (JSC::FTL::DFG::LowerDFGToB3::lowInt32): (JSC::FTL::DFG::LowerDFGToB3::lowInt52): (JSC::FTL::DFG::LowerDFGToB3::lowCell): (JSC::FTL::DFG::LowerDFGToB3::lowBoolean): (JSC::FTL::DFG::LowerDFGToB3::lowDouble): (JSC::FTL::DFG::LowerDFGToB3::lowJSValue): 2018-02-02 Don Olmstead JS Builtins should include JavaScriptCore headers directly https://bugs.webkit.org/show_bug.cgi?id=182445 Reviewed by Yusuke Suzuki. * Scripts/builtins/builtins_generator.py: * Scripts/tests/builtins/expected/WebCore-AnotherGuardedInternalBuiltin-Separate.js-result: * Scripts/tests/builtins/expected/WebCore-ArbitraryConditionalGuard-Separate.js-result: * Scripts/tests/builtins/expected/WebCore-GuardedBuiltin-Separate.js-result: * Scripts/tests/builtins/expected/WebCore-GuardedInternalBuiltin-Separate.js-result: * Scripts/tests/builtins/expected/WebCore-UnguardedBuiltin-Separate.js-result: * Scripts/tests/builtins/expected/WebCore-xmlCasingTest-Separate.js-result: 2018-02-02 Saam Barati When BytecodeParser inserts Unreachable after ForceOSRExit it needs to update ArgumentPositions for Flushes it inserts https://bugs.webkit.org/show_bug.cgi?id=182368 Reviewed by Mark Lam. When preserving liveness when inserting Unreachable nodes after ForceOSRExit, we must add the VariableAccessData to the given argument position. Otherwise, we may end up with a VariableAccessData that doesn't respect the shouldNeverUnbox bit. If we end up with such a situation, it can lead to invalid IR after the arguments elimination phase optimizes a GetByVal to a GetStack. * dfg/DFGByteCodeParser.cpp: (JSC::DFG::ByteCodeParser::flushImpl): (JSC::DFG::ByteCodeParser::flushForTerminalImpl): (JSC::DFG::ByteCodeParser::flush): (JSC::DFG::ByteCodeParser::flushForTerminal): (JSC::DFG::ByteCodeParser::InlineStackEntry::InlineStackEntry): (JSC::DFG::ByteCodeParser::parse): 2018-02-02 Mark Lam More ARM64_32 fixes. https://bugs.webkit.org/show_bug.cgi?id=182441 Reviewed by Dan Bernstein. I also disabled more dynamicPoisoning code in ARM64_32. This code assumes a 64-bit pointer which is not applicable here. * jit/AssemblyHelpers.cpp: (JSC::AssemblyHelpers::emitDynamicPoison): (JSC::AssemblyHelpers::emitDynamicPoisonOnLoadedType): (JSC::AssemblyHelpers::emitDynamicPoisonOnType): 2018-02-02 Saam Barati MapHash should return true to doesGC in the DFG depending on useKind because it might resolve a rope https://bugs.webkit.org/show_bug.cgi?id=182402 Reviewed by Yusuke Suzuki. * dfg/DFGDoesGC.cpp: (JSC::DFG::doesGC): 2018-02-02 Yusuke Suzuki [JSC] Clean up ArraySpeciesCreate https://bugs.webkit.org/show_bug.cgi?id=182434 Reviewed by Saam Barati. We have duplicate code in filter, map, concatSlowPath. This patch creates a new global private function @arraySpeciesCreate, and use it. * builtins/ArrayPrototype.js: (globalPrivate.arraySpeciesCreate): (filter): (map): (globalPrivate.concatSlowPath): 2018-02-01 Mark Lam Fix broken bounds check in FTL's compileGetMyArgumentByVal(). https://bugs.webkit.org/show_bug.cgi?id=182419 Reviewed by Saam Barati. In compileGetMyArgumentByVal(), it computes: limit = m_out.sub(limit, m_out.constInt32(m_node->numberOfArgumentsToSkip())); ... LValue isOutOfBounds = m_out.aboveOrEqual(originalIndex, limit); where the original "limit" is the number of arguments passed in by the caller. If the original limit is less than numberOfArgumentsToSkip, the resultant limit will be a large unsigned number. As a result, this will defeat the bounds check that follows it. Note: later on in compileGetMyArgumentByVal(), we have to adjust adjust the index value by adding numberOfArgumentsToSkip to it, in order to determine the actual entry in the arguments array to get. The fix is to just add numberOfArgumentsToSkip to index upfront (instead of subtracting it from limit), and doing an overflow speculation check on that addition before doing the bounds check. * ftl/FTLLowerDFGToB3.cpp: (JSC::FTL::DFG::LowerDFGToB3::compileGetMyArgumentByVal): 2018-02-01 Keith Miller Fix crashes due to mishandling custom sections. https://bugs.webkit.org/show_bug.cgi?id=182404 Reviewed by Saam Barati. This also cleans up some of our validation code. We also mistakenly, allowed unknown (different from custom sections with id: 0) section ids. * wasm/WasmModuleParser.cpp: (JSC::Wasm::ModuleParser::parse): * wasm/WasmModuleParser.h: * wasm/WasmSections.h: (JSC::Wasm::isKnownSection): (JSC::Wasm::decodeSection): (JSC::Wasm::validateOrder): (JSC::Wasm::makeString): (JSC::Wasm::isValidSection): Deleted. 2018-02-01 Michael Catanzaro -Wreturn-type warning in DFGObjectAllocationSinkingPhase.cpp https://bugs.webkit.org/show_bug.cgi?id=182389 Reviewed by Yusuke Suzuki. Fix the warning. As a bonus, remove a couple unreachable breaks for good measure. * dfg/DFGObjectAllocationSinkingPhase.cpp: 2018-02-01 Chris Dumez Queue a microtask when a waitUntil() promise is settled https://bugs.webkit.org/show_bug.cgi?id=182372 Reviewed by Mark Lam. Export a symbol so it can be used in WebCore. * runtime/JSGlobalObject.h: 2018-01-31 Don Olmstead [CMake] Make JavaScriptCore headers copies https://bugs.webkit.org/show_bug.cgi?id=182303 Reviewed by Alex Christensen. * CMakeLists.txt: * PlatformGTK.cmake: * PlatformJSCOnly.cmake: * PlatformMac.cmake: * PlatformWPE.cmake: * PlatformWin.cmake: * shell/CMakeLists.txt: * shell/PlatformWin.cmake: 2018-01-31 Saam Barati Replace tryLargeMemalignVirtual with tryLargeZeroedMemalignVirtual and use it to allocate large zeroed memory in Wasm https://bugs.webkit.org/show_bug.cgi?id=182064 Reviewed by Geoffrey Garen. This patch switches WebAssembly Memory to always use bmalloc's zeroed virtual allocation API. This makes it so that we don't dirty the memory to zero it. It's a huge compile time speedup on WasmBench on iOS. * wasm/WasmMemory.cpp: (JSC::Wasm::Memory::create): (JSC::Wasm::Memory::~Memory): (JSC::Wasm::Memory::addressIsInActiveFastMemory): (JSC::Wasm::Memory::grow): (JSC::Wasm::commitZeroPages): Deleted. 2018-01-31 Mark Lam Build fix for CLoop after r227874. https://bugs.webkit.org/show_bug.cgi?id=182155 Not reviewed. Just needed support for lea of a LabelReference in cloop.rb (just like those added for arm64.rb and x86.rb). * offlineasm/cloop.rb: 2018-01-31 Keith Miller Canonicalize aquiring the JSCell lock. https://bugs.webkit.org/show_bug.cgi?id=182320 Reviewed by Michael Saboff. It's currently kinda annoying to figure out where we aquire the a JSCell's lock. This patch adds a helper to make it easier to grep... * bytecode/UnlinkedCodeBlock.cpp: (JSC::UnlinkedCodeBlock::visitChildren): (JSC::UnlinkedCodeBlock::setInstructions): (JSC::UnlinkedCodeBlock::shrinkToFit): * runtime/ErrorInstance.cpp: (JSC::ErrorInstance::finishCreation): (JSC::ErrorInstance::materializeErrorInfoIfNeeded): (JSC::ErrorInstance::visitChildren): * runtime/JSArray.cpp: (JSC::JSArray::shiftCountWithArrayStorage): (JSC::JSArray::unshiftCountWithArrayStorage): * runtime/JSCell.h: (JSC::JSCell::cellLock): * runtime/JSObject.cpp: (JSC::JSObject::visitButterflyImpl): (JSC::JSObject::convertContiguousToArrayStorage): * runtime/JSPropertyNameEnumerator.cpp: (JSC::JSPropertyNameEnumerator::visitChildren): * runtime/SparseArrayValueMap.cpp: (JSC::SparseArrayValueMap::add): (JSC::SparseArrayValueMap::remove): (JSC::SparseArrayValueMap::visitChildren): 2018-01-31 Saam Barati JSC incorrectly interpreting script, sets Global Property instead of Global Lexical variable (LiteralParser / JSONP path) https://bugs.webkit.org/show_bug.cgi?id=182074 Reviewed by Mark Lam. This patch teaches the JSONP evaluator about the global lexical environment. Before, it was using the global object as the global scope, but that's wrong. The global lexical environment is the first node in the global scope chain. * interpreter/Interpreter.cpp: (JSC::Interpreter::executeProgram): * jsc.cpp: (GlobalObject::finishCreation): (shellSupportsRichSourceInfo): (functionDisableRichSourceInfo): * runtime/LiteralParser.cpp: (JSC::LiteralParser::tryJSONPParse): * runtime/LiteralParser.h: 2018-01-31 Saam Barati clean up pushToSaveImmediateWithoutTouchingRegisters a bit https://bugs.webkit.org/show_bug.cgi?id=181774 Reviewed by JF Bastien. This function on ARM64 was considering what to do with the scratch register. And conditionally invalidated what was in it. This is not relevant though, since the function always recovers what was in that register. This patch just switches it to using dataTempRegister directly and updates the comment to describe why it can do so safely. * assembler/MacroAssemblerARM64.h: (JSC::MacroAssemblerARM64::pushToSaveImmediateWithoutTouchingRegisters): 2018-01-30 Mark Lam Apply poisoning to TypedArray vector pointers. https://bugs.webkit.org/show_bug.cgi?id=182155 Reviewed by JF Bastien. The TypeArray's vector pointer is now poisoned. The poison value is chosen based on a TypeArray's jsType. The JSType must be between FirstTypedArrayType and LastTypedArrayType. At runtime, we enforce that the index is well-behaved by masking it against TypedArrayPoisonIndexMask. TypedArrayPoisonIndexMask (16) is the number of TypedArray types (10) rounded up to the next power of 2. Accordingly, we reserve an array of TypedArrayPoisonIndexMask poisons so that we can use index masking on the index, and be guaranteed that the masked index will be within bounds of the poisons array. 1. Fixed both DFG and FTL versions of compileGetTypedArrayByteOffset() to not do any unnecessary work if the TypedArray vector is null. FTL's cagedMayBeNull() is no longer needed because it is only used by compileGetTypedArrayByteOffset(), and we need to enhance it to handle unpoisoning in a TypedArray specific way. So, might as well do the work inline in compileGetTypedArrayByteOffset() instead. 2. Removed an unnecessary null-check in DFGSpeculativeJIT's compileNewTypedArrayWithSize() because there's already a null check above it that ensures that sizeGPR is never null. 3. In LLInt's _llint_op_get_by_val, move the TypedArray length check before the loading of the vector for unpoisoning and uncaging. We don't need the vector if the length is 0. Implementation notes on the need to null check the TypeArray vector: 1. DFG::SpeculativeJIT::jumpForTypedArrayIsNeuteredIfOutOfBounds() does not need a m_poisonedVector null check because the function is a null check. 2. DFG::SpeculativeJIT::compileGetIndexedPropertyStorage() does not need a m_poisonedVector null check because it is followed by a call to cageTypedArrayStorage() which assumes that storageReg cannot be null. 3. DFG::SpeculativeJIT::compileGetTypedArrayByteOffset() already has a m_poisonedVector null check. 4. DFG::SpeculativeJIT::compileNewTypedArrayWithSize() does not need a vector null check because the poisoning code is preceded by a sizeGPR null check, which ensures that the storageGPR (vector to be poisoned) is not null. 5. FTL's compileGetIndexedPropertyStorage() does not need a m_poisonedVector null check because it is followed by a call to caged() which assumes that the vector cannot be null. 6. FTL's compileGetTypedArrayByteOffset() already has a m_poisonedVector null check. 7. FTL's compileNewTypedArray() does not need a vector null check because the poisoning code is preceded by a size null check, which ensures that the storage (vector to be poisoned) is not null. 8. FTL's speculateTypedArrayIsNotNeutered() does not need a m_poisonedVector null check because the function is a null check. 9. IntrinsicGetterAccessCase::emitIntrinsicGetter()'s TypedArrayByteOffsetIntrinsic case needs a null check so that it does not try to unpoison a null vector. 10. JIT::emitIntTypedArrayGetByVal() does not need a vector null check because we already do a length check even before loading the vector. 11. JIT::emitFloatTypedArrayGetByVal() does not need a vector null check because we already do a length check even before loading the vector. 12. JIT::emitIntTypedArrayPutByVal() does not need a vector null check because we already do a length check even before loading the vector. 13. JIT::emitFloatTypedArrayPutByVal() does not need a vector null check because we already do a length check even before loading the vector. 14. LLInt's loadTypedArrayCaged() does not need a vector null check because its client will do a TypedArray length check before calling it. * dfg/DFGFixupPhase.cpp: (JSC::DFG::FixupPhase::checkArray): * dfg/DFGNode.h: (JSC::DFG::Node::hasArrayMode): * dfg/DFGSpeculativeJIT.cpp: (JSC::DFG::SpeculativeJIT::jumpForTypedArrayIsNeuteredIfOutOfBounds): (JSC::DFG::SpeculativeJIT::compileGetIndexedPropertyStorage): (JSC::DFG::SpeculativeJIT::compileGetTypedArrayByteOffset): (JSC::DFG::SpeculativeJIT::compileNewTypedArrayWithSize): * ftl/FTLAbstractHeapRepository.h: * ftl/FTLLowerDFGToB3.cpp: (JSC::FTL::DFG::LowerDFGToB3::compileGetIndexedPropertyStorage): (JSC::FTL::DFG::LowerDFGToB3::compileGetTypedArrayByteOffset): (JSC::FTL::DFG::LowerDFGToB3::compileNewTypedArray): (JSC::FTL::DFG::LowerDFGToB3::speculateTypedArrayIsNotNeutered): (JSC::FTL::DFG::LowerDFGToB3::cagedMayBeNull): Deleted. * jit/IntrinsicEmitter.cpp: (JSC::IntrinsicGetterAccessCase::emitIntrinsicGetter): * jit/JITPropertyAccess.cpp: (JSC::JIT::emitIntTypedArrayGetByVal): (JSC::JIT::emitFloatTypedArrayGetByVal): (JSC::JIT::emitIntTypedArrayPutByVal): (JSC::JIT::emitFloatTypedArrayPutByVal): * llint/LowLevelInterpreter.asm: * llint/LowLevelInterpreter64.asm: * offlineasm/arm64.rb: * offlineasm/x86.rb: * runtime/CagedBarrierPtr.h: * runtime/JSArrayBufferView.cpp: (JSC::JSArrayBufferView::JSArrayBufferView): (JSC::JSArrayBufferView::finalize): (JSC::JSArrayBufferView::neuter): * runtime/JSArrayBufferView.h: (JSC::JSArrayBufferView::vector const): (JSC::JSArrayBufferView::offsetOfPoisonedVector): (JSC::JSArrayBufferView::poisonFor): (JSC::JSArrayBufferView::Poison::key): (JSC::JSArrayBufferView::offsetOfVector): Deleted. * runtime/JSCPoison.cpp: (JSC::initializePoison): * runtime/JSCPoison.h: * runtime/JSGenericTypedArrayViewInlines.h: (JSC::JSGenericTypedArrayView::estimatedSize): (JSC::JSGenericTypedArrayView::visitChildren): (JSC::JSGenericTypedArrayView::slowDownAndWasteMemory): * runtime/JSObject.h: 2018-01-30 Fujii Hironori [Win] Warning fix. https://bugs.webkit.org/show_bug.cgi?id=177007 Reviewed by Yusuke Suzuki. * interpreter/StackVisitor.cpp: (JSC::StackVisitor::Frame::dump const): Changed the type of locationRawBits from unsigned to uintptr_t. * runtime/IntlNumberFormat.cpp: (JSC::IntlNumberFormat::createNumberFormat): Initialize 'style' to avoid potentially uninitialized local variable warning. 2018-01-29 Yusuke Suzuki [JSC] Implement trimStart and trimEnd https://bugs.webkit.org/show_bug.cgi?id=182233 Reviewed by Mark Lam. String.prototype.{trimStart,trimEnd} are now stage 3[1]. String.prototype.{trimLeft,trimRight} are alias to these functions. We rename these functions to trimStart and trimEnd, and put them as trimLeft and trimRight too. [1]: https://tc39.github.io/proposal-string-left-right-trim/ * runtime/StringPrototype.cpp: (JSC::StringPrototype::finishCreation): (JSC::trimString): (JSC::stringProtoFuncTrim): (JSC::stringProtoFuncTrimStart): (JSC::stringProtoFuncTrimEnd): (JSC::stringProtoFuncTrimLeft): Deleted. (JSC::stringProtoFuncTrimRight): Deleted. 2018-01-29 Yusuke Suzuki [JSC] Relax line terminators in String to make JSON subset of JS https://bugs.webkit.org/show_bug.cgi?id=182232 Reviewed by Keith Miller. "Subsume JSON" spec is now stage 3[1]. Before this spec change, JSON can accept \u2028 / \u2029 in string while JS cannot do that. It accidentally made JSON non subset of JS. Now we extend our JS string to accept \u2028 / \u2029 to make JSON subset of JS in this spec change. [1]: https://github.com/tc39/proposal-json-superset * parser/Lexer.cpp: (JSC::Lexer::parseStringSlowCase): 2018-01-29 Jiewen Tan [WebAuthN] Add a compile-time feature flag https://bugs.webkit.org/show_bug.cgi?id=182211 Reviewed by Brent Fulgham. * Configurations/FeatureDefines.xcconfig: 2018-01-29 Michael Saboff REGRESSION (r227341): DFG_ASSERT failure at JSC::DFG::AtTailAbstractState::forNode() https://bugs.webkit.org/show_bug.cgi?id=182249 Reviewed by Keith Miller. Changed clobberize() handling of CompareEq, et al to properly handle comparisons between Untyped and Object values when compared against built in types. Such comparisons can invoke toNumber() or other methods. * dfg/DFGClobberize.h: (JSC::DFG::clobberize): 2018-01-29 Matt Lewis Unreviewed, rolling out r227725. This caused internal failures. Reverted changeset: "JSC Sampling Profiler: Detect tester and testee when sampling in RegExp JIT" https://bugs.webkit.org/show_bug.cgi?id=152729 https://trac.webkit.org/changeset/227725 2018-01-29 Yusuke Suzuki JSC Sampling Profiler: Detect tester and testee when sampling in RegExp JIT https://bugs.webkit.org/show_bug.cgi?id=152729 Reviewed by Saam Barati. This patch extends SamplingProfiler to recognize JIT RegExp execution. We record executing RegExp in VM so that SamplingProfiler can detect it. This is better than the previous VM::isExecutingInRegExpJIT flag approach since 1. isExecutingInRegExpJIT is set after starting executing JIT RegExp code. Thus, if we suspend the thread just before executing this flag, or just after clearing this flag, SamplingProfiler gets invalid frame, and frame validation fails. We should set such a flag before and after executing JIT RegExp code. 2. This removes VM dependency from YarrJIT which is not essential one. We add ExecutionContext enum to RegExp::matchInline not to mark execution if it is done in non JS thread. * bytecode/BytecodeDumper.cpp: (JSC::regexpName): (JSC::BytecodeDumper::dumpRegExps): (JSC::regexpToSourceString): Deleted. * heap/Heap.cpp: (JSC::Heap::addCoreConstraints): * runtime/RegExp.cpp: (JSC::RegExp::compile): (JSC::RegExp::match): (JSC::RegExp::matchConcurrently): (JSC::RegExp::compileMatchOnly): (JSC::RegExp::toSourceString const): * runtime/RegExp.h: * runtime/RegExpInlines.h: (JSC::RegExp::matchInline): * runtime/RegExpMatchesArray.h: (JSC::createRegExpMatchesArray): * runtime/SamplingProfiler.cpp: (JSC::SamplingProfiler::SamplingProfiler): (JSC::SamplingProfiler::timerLoop): (JSC::SamplingProfiler::takeSample): (JSC::SamplingProfiler::processUnverifiedStackTraces): (JSC::SamplingProfiler::StackFrame::nameFromCallee): (JSC::SamplingProfiler::StackFrame::displayName): (JSC::SamplingProfiler::StackFrame::displayNameForJSONTests): (JSC::SamplingProfiler::StackFrame::functionStartLine): (JSC::SamplingProfiler::StackFrame::functionStartColumn): (JSC::SamplingProfiler::StackFrame::sourceID): (JSC::SamplingProfiler::StackFrame::url): (WTF::printInternal): (JSC::SamplingProfiler::~SamplingProfiler): Deleted. * runtime/SamplingProfiler.h: * runtime/VM.h: * yarr/YarrJIT.cpp: (JSC::Yarr::YarrGenerator::generateEnter): (JSC::Yarr::YarrGenerator::generateReturn): (JSC::Yarr::YarrGenerator::YarrGenerator): (JSC::Yarr::jitCompile): * yarr/YarrJIT.h: 2018-01-29 Yusuke Suzuki [DFG][FTL] WeakMap#set should have DFG node https://bugs.webkit.org/show_bug.cgi?id=180015 Reviewed by Saam Barati. This patch adds WeakMapSet and WeakSetAdd DFG nodes to handle them efficiently in DFG and FTL. We also define CSE rules for them. Now, WeakMapSet and WeakSetAdd can offer the results of the subsequent WeakMapGet if CSE allows. * dfg/DFGAbstractInterpreterInlines.h: (JSC::DFG::AbstractInterpreter::executeEffects): * dfg/DFGByteCodeParser.cpp: (JSC::DFG::ByteCodeParser::addVarArgChild): (JSC::DFG::ByteCodeParser::handleIntrinsicCall): * dfg/DFGClobberize.h: (JSC::DFG::clobberize): * dfg/DFGDoesGC.cpp: (JSC::DFG::doesGC): WeakMap operations do not cause GC. * dfg/DFGFixupPhase.cpp: (JSC::DFG::FixupPhase::fixupNode): * dfg/DFGNodeType.h: * dfg/DFGOperations.cpp: * dfg/DFGOperations.h: * dfg/DFGPredictionPropagationPhase.cpp: * dfg/DFGSafeToExecute.h: (JSC::DFG::safeToExecute): * dfg/DFGSpeculativeJIT.cpp: (JSC::DFG::SpeculativeJIT::compileWeakSetAdd): (JSC::DFG::SpeculativeJIT::compileWeakMapSet): * dfg/DFGSpeculativeJIT.h: (JSC::DFG::SpeculativeJIT::callOperation): * 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::compileWeakSetAdd): (JSC::FTL::DFG::LowerDFGToB3::compileWeakMapSet): * jit/JITOperations.h: * runtime/Intrinsic.cpp: (JSC::intrinsicName): * runtime/Intrinsic.h: * runtime/WeakMapPrototype.cpp: (JSC::WeakMapPrototype::finishCreation): * runtime/WeakSetPrototype.cpp: (JSC::WeakSetPrototype::finishCreation): 2018-01-28 Filip Pizlo LargeAllocation should do the same distancing as MarkedBlock https://bugs.webkit.org/show_bug.cgi?id=182226 Reviewed by Saam Barati. This makes LargeAllocation do the same exact distancing that MarkedBlock promises to do. To make that possible, this patch first makes MarkedBlock know exactly how much distancing it is doing: - I've rationalized the payloadSize calculation. In particular, I made MarkedSpace use the calculation done in MarkedBlock. MarkedSpace used to do the math a different way. This keeps the old way just for a static_assert. - The promised amount of distancing is now codified in HeapCell.h as minimumDistanceBetweenCellsFromDifferentOrigins. We assert that the footer size is at least as big as this. I didn't want to just use footer size for this constant because then, if you increased the size of the footer, you'd also add padding to every large allocation. Then this patch just adds minimumDistanceBetweenCellsFromDifferentOrigins to each large allocation. It also zeroes that slice of memory to prevent any information leaks that way. This is perf neutral. Large allocations start out at ~8000 bytes. The amount of padding is ~300 bytes. That's 3.75% space overhead for objects that are ~8000 bytes, zero overhead for smaller objects, and diminishing overhead for larger objects. We allocate very few large objects, so we shouldn't have any real space overhead from this. * heap/HeapCell.h: * heap/LargeAllocation.cpp: (JSC::LargeAllocation::tryCreate): * heap/MarkedBlock.h: * heap/MarkedSpace.h: 2018-01-27 Filip Pizlo Make MarkedBlock::Footer bigger https://bugs.webkit.org/show_bug.cgi?id=182220 Reviewed by JF Bastien. This makes the block footer larger by moving the newlyAllocated bits from the handle into the footer. It used to be profitable to put anything we could into the handle because that would free up payload space inside the block. But now that we want to use the footer for padding, it's profitable to put GC state information - especially data that is used by the GC itself and so is not useful for a Spectre attack - into the footer to increase object distancing. * heap/CellContainer.cpp: (JSC::CellContainer::isNewlyAllocated const): * heap/IsoCellSet.cpp: (JSC::IsoCellSet::sweepToFreeList): * heap/MarkedBlock.cpp: (JSC::MarkedBlock::Handle::Handle): (JSC::MarkedBlock::Footer::Footer): (JSC::MarkedBlock::Handle::stopAllocating): (JSC::MarkedBlock::Handle::lastChanceToFinalize): (JSC::MarkedBlock::Handle::resumeAllocating): (JSC::MarkedBlock::aboutToMarkSlow): (JSC::MarkedBlock::resetAllocated): (JSC::MarkedBlock::Handle::resetAllocated): Deleted. * heap/MarkedBlock.h: (JSC::MarkedBlock::newlyAllocatedVersion const): (JSC::MarkedBlock::isNewlyAllocated): (JSC::MarkedBlock::setNewlyAllocated): (JSC::MarkedBlock::clearNewlyAllocated): (JSC::MarkedBlock::newlyAllocated const): (JSC::MarkedBlock::Handle::newlyAllocatedVersion const): Deleted. (JSC::MarkedBlock::Handle::isNewlyAllocated): Deleted. (JSC::MarkedBlock::Handle::setNewlyAllocated): Deleted. (JSC::MarkedBlock::Handle::clearNewlyAllocated): Deleted. (JSC::MarkedBlock::Handle::newlyAllocated const): Deleted. * heap/MarkedBlockInlines.h: (JSC::MarkedBlock::isNewlyAllocatedStale const): (JSC::MarkedBlock::hasAnyNewlyAllocated): (JSC::MarkedBlock::Handle::isLive): (JSC::MarkedBlock::Handle::specializedSweep): (JSC::MarkedBlock::Handle::newlyAllocatedMode): (JSC::MarkedBlock::Handle::isNewlyAllocatedStale const): Deleted. (JSC::MarkedBlock::Handle::hasAnyNewlyAllocated): Deleted. * heap/MarkedSpace.cpp: (JSC::MarkedSpace::endMarking): * heap/SlotVisitor.cpp: (JSC::SlotVisitor::appendJSCellOrAuxiliary): 2018-01-27 Filip Pizlo MarkedBlock should have a footer instead of a header https://bugs.webkit.org/show_bug.cgi?id=182217 Reviewed by JF Bastien. This moves the MarkedBlock's meta-data from the header to the footer. This doesn't really change anything except for some compile-time constants, so it should not affect performance. This change is to help protect against Spectre attacks on structure checks, which allow for small-offset out-of-bounds access. By putting the meta-data at the end of the block, small OOBs will only get to other objects in the same block or the block footer. The block footer is not super interesting. So, if we combine this with the TLC change (r227617), this means we can use blocks as the mechanism of achieving distance between objects from different origins. We just need to avoid ever putting objects from different origins in the same block. That's what bug 181636 is about. * heap/BlockDirectory.cpp: (JSC::blockHeaderSize): Deleted. (JSC::BlockDirectory::blockSizeForBytes): Deleted. * heap/BlockDirectory.h: * heap/HeapUtil.h: (JSC::HeapUtil::findGCObjectPointersForMarking): * heap/MarkedBlock.cpp: (JSC::MarkedBlock::MarkedBlock): (JSC::MarkedBlock::~MarkedBlock): (JSC::MarkedBlock::Footer::Footer): (JSC::MarkedBlock::Footer::~Footer): (JSC::MarkedBlock::Handle::stopAllocating): (JSC::MarkedBlock::Handle::lastChanceToFinalize): (JSC::MarkedBlock::Handle::resumeAllocating): (JSC::MarkedBlock::aboutToMarkSlow): (JSC::MarkedBlock::resetMarks): (JSC::MarkedBlock::assertMarksNotStale): (JSC::MarkedBlock::Handle::didConsumeFreeList): (JSC::MarkedBlock::markCount): (JSC::MarkedBlock::clearHasAnyMarked): (JSC::MarkedBlock::Handle::didAddToDirectory): (JSC::MarkedBlock::Handle::didRemoveFromDirectory): (JSC::MarkedBlock::Handle::sweep): * heap/MarkedBlock.h: (JSC::MarkedBlock::markingVersion const): (JSC::MarkedBlock::lock): (JSC::MarkedBlock::subspace const): (JSC::MarkedBlock::footer): (JSC::MarkedBlock::footer const): (JSC::MarkedBlock::handle): (JSC::MarkedBlock::handle const): (JSC::MarkedBlock::Handle::blockFooter): (JSC::MarkedBlock::isAtomAligned): (JSC::MarkedBlock::Handle::cellAlign): (JSC::MarkedBlock::blockFor): (JSC::MarkedBlock::vm const): (JSC::MarkedBlock::weakSet): (JSC::MarkedBlock::cellSize): (JSC::MarkedBlock::attributes const): (JSC::MarkedBlock::atomNumber): (JSC::MarkedBlock::areMarksStale): (JSC::MarkedBlock::aboutToMark): (JSC::MarkedBlock::isMarkedRaw): (JSC::MarkedBlock::isMarked): (JSC::MarkedBlock::testAndSetMarked): (JSC::MarkedBlock::marks const): (JSC::MarkedBlock::isAtom): (JSC::MarkedBlock::Handle::forEachCell): (JSC::MarkedBlock::hasAnyMarked const): (JSC::MarkedBlock::noteMarked): (WTF::MarkedBlockHash::hash): (JSC::MarkedBlock::firstAtom): Deleted. * heap/MarkedBlockInlines.h: (JSC::MarkedBlock::marksConveyLivenessDuringMarking): (JSC::MarkedBlock::Handle::isLive): (JSC::MarkedBlock::Handle::specializedSweep): (JSC::MarkedBlock::Handle::forEachLiveCell): (JSC::MarkedBlock::Handle::forEachDeadCell): (JSC::MarkedBlock::Handle::forEachMarkedCell): * heap/MarkedSpace.cpp: * heap/MarkedSpace.h: * llint/LowLevelInterpreter.asm: * llint/LowLevelInterpreter32_64.asm: * llint/LowLevelInterpreter64.asm: 2018-01-27 Yusuke Suzuki DFG strength reduction fails to convert NumberToStringWithValidRadixConstant for 0 to constant '0' https://bugs.webkit.org/show_bug.cgi?id=182213 Reviewed by Mark Lam. toStringWithRadixInternal is originally used for the slow path if the given value is larger than radix or negative. As a result, it does not accept 0 correctly, and produces an empty string. Since DFGStrengthReductionPhase uses this function, it accidentally converts NumberToStringWithValidRadixConstant(0, radix) to an empty string. This patch fixes toStringWithRadixInternal to accept 0. This change fixes twitch.tv's issue. We also add a careful cast to avoid `-INT32_MIN`. It does not produce incorrect value in x86 in practice, but it is UB, and a compiler may assume that the given value is never INT32_MIN and could do an incorrect optimization. * runtime/NumberPrototype.cpp: (JSC::toStringWithRadixInternal): 2018-01-26 Saam Barati Fix emitAllocateWithNonNullAllocator to work on arm https://bugs.webkit.org/show_bug.cgi?id=182187 Reviewed by Filip Pizlo. This patch unifies the x86 and ARM paths in emitAllocateWithNonNullAllocator and makes it so that emitAllocateWithNonNullAllocator uses the macro scratch register on ARM. * ftl/FTLLowerDFGToB3.cpp: (JSC::FTL::DFG::LowerDFGToB3::allocateHeapCell): * jit/AssemblyHelpers.cpp: (JSC::AssemblyHelpers::emitAllocateWithNonNullAllocator): 2018-01-26 Joseph Pecoraro Rebaselining builtin generator tests after r227685. Unreviewed. * Scripts/tests/builtins/expected/JavaScriptCore-Builtin.Promise-Combined.js-result: * Scripts/tests/builtins/expected/JavaScriptCore-Builtin.Promise-Separate.js-result: * Scripts/tests/builtins/expected/JavaScriptCore-Builtin.prototype-Combined.js-result: * Scripts/tests/builtins/expected/JavaScriptCore-Builtin.prototype-Separate.js-result: * Scripts/tests/builtins/expected/JavaScriptCore-BuiltinConstructor-Combined.js-result: * Scripts/tests/builtins/expected/JavaScriptCore-BuiltinConstructor-Separate.js-result: * Scripts/tests/builtins/expected/JavaScriptCore-InternalClashingNames-Combined.js-result: * Scripts/tests/builtins/expected/WebCore-AnotherGuardedInternalBuiltin-Separate.js-result: * Scripts/tests/builtins/expected/WebCore-ArbitraryConditionalGuard-Separate.js-result: * Scripts/tests/builtins/expected/WebCore-GuardedBuiltin-Separate.js-result: * Scripts/tests/builtins/expected/WebCore-GuardedInternalBuiltin-Separate.js-result: * Scripts/tests/builtins/expected/WebCore-UnguardedBuiltin-Separate.js-result: * Scripts/tests/builtins/expected/WebCore-xmlCasingTest-Separate.js-result: It used to be that the builtins generator was minifying by default. That was an accident and we now only minify on Release builds. The generator tests are now getting the default unminified output behavior so they need to update their expectations for some extra whitespace. 2018-01-26 Mark Lam We should only append ParserArenaDeletable pointers to ParserArena::m_deletableObjects. https://bugs.webkit.org/show_bug.cgi?id=182180 Reviewed by Michael Saboff. Some parser Node subclasses extend ParserArenaDeletable via multiple inheritance, but not as the Node's first base class. ParserArena::m_deletableObjects is expecting pointers to objects of the shape of ParserArenaDeletable. We ensure this by allocating the Node subclass, and casting it to ParserArenaDeletable to get the correct pointer to append to ParserArena::m_deletableObjects. To simplify things, we introduce a JSC_MAKE_PARSER_ARENA_DELETABLE_ALLOCATED (analogous to WTF_MAKE_FAST_ALLOCATED) for use in Node subclasses that extends ParserArenaDeletable. * parser/NodeConstructors.h: (JSC::ParserArenaDeletable::operator new): * parser/Nodes.h: * parser/ParserArena.h: (JSC::ParserArena::allocateDeletable): 2018-01-26 Joseph Pecoraro JavaScriptCore builtins should be partially minified in Release builds not Debug builds https://bugs.webkit.org/show_bug.cgi?id=182165 Reviewed by Keith Miller. * Scripts/builtins/builtins_model.py: (BuiltinFunction.fromString): Apply minifications on Release builds instead of Debug builds. Also eliminate leading whitespace. 2018-01-26 Filip Pizlo Disable TLS-based TLCs https://bugs.webkit.org/show_bug.cgi?id=182175 Reviewed by Saam Barati. Check for the new USE(FAST_TLS_FOR_TLC) flag instead of just ENABLE(FAST_TLS_JIT). * heap/BlockDirectory.cpp: (JSC::BlockDirectory::~BlockDirectory): * heap/BlockDirectory.h: * heap/ThreadLocalCache.cpp: (JSC::ThreadLocalCache::installSlow): (JSC::ThreadLocalCache::installData): * heap/ThreadLocalCache.h: * heap/ThreadLocalCacheInlines.h: (JSC::ThreadLocalCache::getImpl): * jit/AssemblyHelpers.cpp: (JSC::AssemblyHelpers::emitAllocateWithNonNullAllocator): * runtime/VM.cpp: (JSC::VM::~VM): * runtime/VM.h: 2018-01-25 Yusuke Suzuki imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/module/errorhandling.html crashes https://bugs.webkit.org/show_bug.cgi?id=181980 Reviewed by Ryosuke Niwa. We accidentally failed to propagate errored promise in instantiate and satify phase if entry.{instantiate,satisfy} promises are set. Since we just returned `entry`, it becomes succeeded promise even if the dependent fetch, instantiate, and satisfy promises are failed. This patch fixes error propagation by returning `entry.instantiate` and `entry.satisfy` correctly. * builtins/ModuleLoaderPrototype.js: (requestInstantiate): (requestSatisfy): 2018-01-25 Mark Lam Gardening: fix 32-bit build after r227643. https://bugs.webkit.org/show_bug.cgi?id=182086 Not reviewed. * jit/AssemblyHelpers.cpp: (JSC::AssemblyHelpers::emitDynamicPoisonOnLoadedType): 2018-01-24 Filip Pizlo DirectArguments should protect itself using dynamic poisoning and precise index masking https://bugs.webkit.org/show_bug.cgi?id=182086 Reviewed by Saam Barati. This implements dynamic poisoning and precise index masking in DirectArguments, using the helpers from and helpers in AssemblyHelpers and FTL::LowerDFGToB3. We use dynamic poisoning for DirectArguments since this object did not have any additional indirection inside it that could have been poisoned. So, we use the xor of the expected type and the actual type as an additional input into the pointer. We use precise index masking for bounds checks, because it's not worth doing index masking unless we know that precise index masking is too slow. * assembler/MacroAssembler.h: (JSC::MacroAssembler::lshiftPtr): (JSC::MacroAssembler::rshiftPtr): * dfg/DFGSpeculativeJIT.cpp: (JSC::DFG::SpeculativeJIT::compileGetByValOnDirectArguments): * ftl/FTLLowerDFGToB3.cpp: (JSC::FTL::DFG::LowerDFGToB3::compileGetByVal): (JSC::FTL::DFG::LowerDFGToB3::compileGetMyArgumentByVal): (JSC::FTL::DFG::LowerDFGToB3::preciseIndexMask64): (JSC::FTL::DFG::LowerDFGToB3::preciseIndexMask32): (JSC::FTL::DFG::LowerDFGToB3::dynamicPoison): (JSC::FTL::DFG::LowerDFGToB3::dynamicPoisonOnLoadedType): (JSC::FTL::DFG::LowerDFGToB3::dynamicPoisonOnType): * jit/AssemblyHelpers.cpp: (JSC::AssemblyHelpers::emitPreciseIndexMask32): (JSC::AssemblyHelpers::emitDynamicPoison): (JSC::AssemblyHelpers::emitDynamicPoisonOnLoadedType): (JSC::AssemblyHelpers::emitDynamicPoisonOnType): * jit/AssemblyHelpers.h: * jit/JITPropertyAccess.cpp: (JSC::JIT::emitDirectArgumentsGetByVal): * runtime/DirectArguments.h: (JSC::DirectArguments::getIndexQuickly const): (JSC::DirectArguments::setIndexQuickly): (JSC::DirectArguments::argument): * runtime/GenericArgumentsInlines.h: 2018-01-25 Mark Lam Rename some local vars from type to typedArrayType for greater clarity. https://bugs.webkit.org/show_bug.cgi?id=182148 Reviewed by Saam Barati. * dfg/DFGSpeculativeJIT.cpp: (JSC::DFG::SpeculativeJIT::compileNewTypedArrayWithSize): * ftl/FTLLowerDFGToB3.cpp: (JSC::FTL::DFG::LowerDFGToB3::compileNewTypedArray): 2018-01-25 Filip Pizlo JSC GC should support TLCs (thread local caches) https://bugs.webkit.org/show_bug.cgi?id=181559 Reviewed by Mark Lam and Saam Barati. This is a big step towards object distancing by site origin. This patch implements TLCs, or thread-local caches, which allow each thread to allocate from its own free lists. It also means that any given thread can context-switch TLCs. This will allow us to do separate allocation for separate site origins. Eventually, once we reshape how MarkedBlock looks, this will allow us to have a hard distancing constraint between objects from different origins. In this new design, every "size class" is represented as a BlockDirectory (formerly known as MarkedAllocator, prior to r226822). This contains a bag of blocks allocated using some aligned memory allocator (which roughly represents which cage you came out of), and anyone using the same allocator can share those blocks - but so long as they are in that BlockDirectory, they will have the size and type of that directory. Previously, each BlockDirectory had exactly one FreeList. Now, each BlockDirectory has a double-linked-list of LocalAllocators, each of which has a FreeList. To decide which LocalAllocator to allocate out of, we need a ThreadLocalCache and a BlockDirectory. The directory gives us an offset-within-the-ThreadLocalCache, which we simply call the Allocator (which is just a POD type that contains a 32-bit offset). Each allocation starts by figuring out what Allocator it wants (often we have this information at JIT time). Then the allocation loads its ThreadLocalCache::Data from a fast TLS slot. Then we add the Allocator offset to the ThreadLocalCache::Data to get the LocalAllocator. Note that we use offsets as opposed to indices to make it easy to do the math on each allocation (if LocalAllocator had a weird size then every allocation would have to do an imul). This is a definite slow-down on GC-heavy benchmarks, but by a small margin, and only on unusually heavy tests. For example, boyer and splay are both 3% regressed, but the Octane geomean is just fine. The JetStream score regressed by 0.5% with p = 0.08 (so maybe there is something there, but it's not significant according to our threshold). Relanding after fixing ARM64 bug in AssemblyHelpers::emitAllocateWithNonNullAllocator(). That function needs to be careful to avoid using the scratch register because the FTL will call it in disallow-scratch-register mode. * JavaScriptCore.xcodeproj/project.pbxproj: * Sources.txt: * b3/B3LowerToAir.cpp: * b3/B3PatchpointSpecial.cpp: (JSC::B3::PatchpointSpecial::admitsStack): * b3/B3StackmapSpecial.cpp: (JSC::B3::StackmapSpecial::forEachArgImpl): (JSC::B3::StackmapSpecial::isArgValidForRep): * b3/B3StackmapValue.cpp: (JSC::B3::StackmapValue::appendSomeRegisterWithClobber): * b3/B3StackmapValue.h: * b3/B3Validate.cpp: * b3/B3ValueRep.cpp: (JSC::B3::ValueRep::addUsedRegistersTo const): (JSC::B3::ValueRep::dump const): (WTF::printInternal): * b3/B3ValueRep.h: (JSC::B3::ValueRep::ValueRep): * bytecode/AccessCase.cpp: (JSC::AccessCase::generateImpl): * bytecode/ObjectAllocationProfile.h: (JSC::ObjectAllocationProfile::ObjectAllocationProfile): (JSC::ObjectAllocationProfile::clear): * bytecode/ObjectAllocationProfileInlines.h: (JSC::ObjectAllocationProfile::initializeProfile): * dfg/DFGSpeculativeJIT.cpp: (JSC::DFG::SpeculativeJIT::emitAllocateRawObject): (JSC::DFG::SpeculativeJIT::compileMakeRope): (JSC::DFG::SpeculativeJIT::compileAllocatePropertyStorage): (JSC::DFG::SpeculativeJIT::compileReallocatePropertyStorage): (JSC::DFG::SpeculativeJIT::compileCreateThis): (JSC::DFG::SpeculativeJIT::compileNewObject): * dfg/DFGSpeculativeJIT.h: (JSC::DFG::SpeculativeJIT::emitAllocateJSCell): (JSC::DFG::SpeculativeJIT::emitAllocateJSObject): * ftl/FTLAbstractHeapRepository.h: * ftl/FTLLowerDFGToB3.cpp: (JSC::FTL::DFG::LowerDFGToB3::compileMakeRope): (JSC::FTL::DFG::LowerDFGToB3::compileMaterializeNewObject): (JSC::FTL::DFG::LowerDFGToB3::allocatePropertyStorageWithSizeImpl): (JSC::FTL::DFG::LowerDFGToB3::allocateHeapCell): (JSC::FTL::DFG::LowerDFGToB3::allocateObject): (JSC::FTL::DFG::LowerDFGToB3::allocatorForSize): (JSC::FTL::DFG::LowerDFGToB3::allocateVariableSizedObject): (JSC::FTL::DFG::LowerDFGToB3::allocateVariableSizedCell): * heap/Allocator.cpp: Added. (JSC::Allocator::cellSize const): * heap/Allocator.h: Added. (JSC::Allocator::Allocator): (JSC::Allocator::offset const): (JSC::Allocator::operator== const): (JSC::Allocator::operator!= const): (JSC::Allocator::operator bool const): * heap/AllocatorInlines.h: Added. (JSC::Allocator::allocate const): (JSC::Allocator::tryAllocate const): * heap/BlockDirectory.cpp: (JSC::BlockDirectory::BlockDirectory): (JSC::BlockDirectory::findBlockForAllocation): (JSC::BlockDirectory::stopAllocating): (JSC::BlockDirectory::prepareForAllocation): (JSC::BlockDirectory::stopAllocatingForGood): (JSC::BlockDirectory::resumeAllocating): (JSC::BlockDirectory::endMarking): (JSC::BlockDirectory::isFreeListedCell): (JSC::BlockDirectory::didConsumeFreeList): Deleted. (JSC::BlockDirectory::tryAllocateWithoutCollecting): Deleted. (JSC::BlockDirectory::allocateIn): Deleted. (JSC::BlockDirectory::tryAllocateIn): Deleted. (JSC::BlockDirectory::doTestCollectionsIfNeeded): Deleted. (JSC::BlockDirectory::allocateSlowCase): Deleted. * heap/BlockDirectory.h: (JSC::BlockDirectory::cellKind const): (JSC::BlockDirectory::allocator const): (JSC::BlockDirectory::freeList const): Deleted. (JSC::BlockDirectory::offsetOfFreeList): Deleted. (JSC::BlockDirectory::offsetOfCellSize): Deleted. * heap/BlockDirectoryInlines.h: (JSC::BlockDirectory::isFreeListedCell const): Deleted. (JSC::BlockDirectory::allocate): Deleted. * heap/CompleteSubspace.cpp: (JSC::CompleteSubspace::CompleteSubspace): (JSC::CompleteSubspace::allocatorFor): (JSC::CompleteSubspace::allocate): (JSC::CompleteSubspace::allocateNonVirtual): (JSC::CompleteSubspace::allocatorForSlow): (JSC::CompleteSubspace::allocateSlow): (JSC::CompleteSubspace::tryAllocateSlow): * heap/CompleteSubspace.h: (JSC::CompleteSubspace::allocatorForSizeStep): (JSC::CompleteSubspace::allocatorForNonVirtual): * heap/FreeList.h: * heap/GCDeferralContext.h: * heap/Heap.cpp: (JSC::Heap::Heap): (JSC::Heap::lastChanceToFinalize): * heap/Heap.h: (JSC::Heap::threadLocalCacheLayout): * heap/IsoCellSet.h: * heap/IsoSubspace.cpp: (JSC::IsoSubspace::IsoSubspace): (JSC::IsoSubspace::allocatorFor): (JSC::IsoSubspace::allocate): (JSC::IsoSubspace::allocateNonVirtual): * heap/IsoSubspace.h: (JSC::IsoSubspace::allocatorForNonVirtual): * heap/LocalAllocator.cpp: Added. (JSC::LocalAllocator::LocalAllocator): (JSC::LocalAllocator::reset): (JSC::LocalAllocator::~LocalAllocator): (JSC::LocalAllocator::stopAllocating): (JSC::LocalAllocator::resumeAllocating): (JSC::LocalAllocator::prepareForAllocation): (JSC::LocalAllocator::stopAllocatingForGood): (JSC::LocalAllocator::allocateSlowCase): (JSC::LocalAllocator::didConsumeFreeList): (JSC::LocalAllocator::tryAllocateWithoutCollecting): (JSC::LocalAllocator::allocateIn): (JSC::LocalAllocator::tryAllocateIn): (JSC::LocalAllocator::doTestCollectionsIfNeeded): (JSC::LocalAllocator::isFreeListedCell const): * heap/LocalAllocator.h: Added. (JSC::LocalAllocator::offsetOfFreeList): (JSC::LocalAllocator::offsetOfCellSize): * heap/LocalAllocatorInlines.h: Added. (JSC::LocalAllocator::allocate): * heap/MarkedSpace.cpp: (JSC::MarkedSpace::stopAllocatingForGood): * heap/MarkedSpace.h: * heap/SlotVisitor.cpp: * heap/SlotVisitor.h: * heap/Subspace.h: * heap/ThreadLocalCache.cpp: Added. (JSC::ThreadLocalCache::create): (JSC::ThreadLocalCache::ThreadLocalCache): (JSC::ThreadLocalCache::~ThreadLocalCache): (JSC::ThreadLocalCache::allocateData): (JSC::ThreadLocalCache::destroyData): (JSC::ThreadLocalCache::installSlow): (JSC::ThreadLocalCache::installData): (JSC::ThreadLocalCache::allocatorSlow): (JSC::ThreadLocalCache::destructor): * heap/ThreadLocalCache.h: Added. (JSC::ThreadLocalCache::offsetOfSize): (JSC::ThreadLocalCache::offsetOfFirstAllocator): * heap/ThreadLocalCacheInlines.h: Added. (JSC::ThreadLocalCache::getImpl): (JSC::ThreadLocalCache::get): (JSC::ThreadLocalCache::install): (JSC::ThreadLocalCache::allocator): (JSC::ThreadLocalCache::tryGetAllocator): * heap/ThreadLocalCacheLayout.cpp: Added. (JSC::ThreadLocalCacheLayout::ThreadLocalCacheLayout): (JSC::ThreadLocalCacheLayout::~ThreadLocalCacheLayout): (JSC::ThreadLocalCacheLayout::allocateOffset): (JSC::ThreadLocalCacheLayout::snapshot): (JSC::ThreadLocalCacheLayout::directory): * heap/ThreadLocalCacheLayout.h: Added. * jit/AssemblyHelpers.cpp: (JSC::AssemblyHelpers::emitAllocateWithNonNullAllocator): (JSC::AssemblyHelpers::emitAllocate): (JSC::AssemblyHelpers::emitAllocateVariableSized): * jit/AssemblyHelpers.h: (JSC::AssemblyHelpers::vm): (JSC::AssemblyHelpers::emitAllocateJSCell): (JSC::AssemblyHelpers::emitAllocateJSObject): (JSC::AssemblyHelpers::emitAllocateJSObjectWithKnownSize): (JSC::AssemblyHelpers::emitAllocateWithNonNullAllocator): Deleted. (JSC::AssemblyHelpers::emitAllocate): Deleted. (JSC::AssemblyHelpers::emitAllocateVariableSized): Deleted. * jit/JITOpcodes.cpp: (JSC::JIT::emit_op_new_object): (JSC::JIT::emit_op_create_this): * jit/JITOpcodes32_64.cpp: (JSC::JIT::emit_op_new_object): (JSC::JIT::emit_op_create_this): * runtime/ButterflyInlines.h: (JSC::Butterfly::createUninitialized): (JSC::Butterfly::tryCreate): (JSC::Butterfly::growArrayRight): * runtime/DirectArguments.cpp: (JSC::DirectArguments::overrideThings): * runtime/GenericArgumentsInlines.h: (JSC::GenericArguments::initModifiedArgumentsDescriptor): * runtime/HashMapImpl.h: (JSC::HashMapBuffer::create): * runtime/JSArray.cpp: (JSC::JSArray::tryCreateUninitializedRestricted): (JSC::JSArray::unshiftCountSlowCase): * runtime/JSArray.h: (JSC::JSArray::tryCreate): * runtime/JSArrayBufferView.cpp: (JSC::JSArrayBufferView::ConstructionContext::ConstructionContext): * runtime/JSCellInlines.h: (JSC::tryAllocateCellHelper): * runtime/JSGlobalObject.cpp: (JSC::JSGlobalObject::JSGlobalObject): * runtime/JSGlobalObject.h: (JSC::JSGlobalObject::threadLocalCache const): * runtime/JSLock.cpp: (JSC::JSLock::didAcquireLock): * runtime/Options.h: * runtime/RegExpMatchesArray.h: (JSC::tryCreateUninitializedRegExpMatchesArray): * runtime/VM.cpp: (JSC::VM::VM): * runtime/VM.h: * runtime/VMEntryScope.cpp: (JSC::VMEntryScope::VMEntryScope): 2018-01-25 Commit Queue Unreviewed, rolling out r227592. https://bugs.webkit.org/show_bug.cgi?id=182110 it made ARM64 (Linux and iOS) crash (Requested by pizlo-mbp on #webkit). Reverted changeset: "JSC GC should support TLCs (thread local caches)" https://bugs.webkit.org/show_bug.cgi?id=181559 https://trac.webkit.org/changeset/227592 2018-01-25 Alejandro G. Castro undefined reference to 'JSC::B3::BasicBlock::fallThrough() const https://bugs.webkit.org/show_bug.cgi?id=180637 Reviewed by Michael Catanzaro. We need to make sure the implementation of the inline functions is compiled when we compile the code using the function, now that the compilation is divided, or we could end up with undefined symbols when the declaration is not inlined, at least with some compilers and optimizations enabled -O2. * b3/B3SwitchValue.cpp: replace the include. 2018-01-20 Filip Pizlo JSC GC should support TLCs (thread local caches) https://bugs.webkit.org/show_bug.cgi?id=181559 Reviewed by Mark Lam and Saam Barati. This is a big step towards object distancing by site origin. This patch implements TLCs, or thread-local caches, which allow each thread to allocate from its own free lists. It also means that any given thread can context-switch TLCs. This will allow us to do separate allocation for separate site origins. Eventually, once we reshape how MarkedBlock looks, this will allow us to have a hard distancing constraint between objects from different origins. In this new design, every "size class" is represented as a BlockDirectory (formerly known as MarkedAllocator, prior to r226822). This contains a bag of blocks allocated using some aligned memory allocator (which roughly represents which cage you came out of), and anyone using the same allocator can share those blocks - but so long as they are in that BlockDirectory, they will have the size and type of that directory. Previously, each BlockDirectory had exactly one FreeList. Now, each BlockDirectory has a double-linked-list of LocalAllocators, each of which has a FreeList. To decide which LocalAllocator to allocate out of, we need a ThreadLocalCache and a BlockDirectory. The directory gives us an offset-within-the-ThreadLocalCache, which we simply call the Allocator (which is just a POD type that contains a 32-bit offset). Each allocation starts by figuring out what Allocator it wants (often we have this information at JIT time). Then the allocation loads its ThreadLocalCache::Data from a fast TLS slot. Then we add the Allocator offset to the ThreadLocalCache::Data to get the LocalAllocator. Note that we use offsets as opposed to indices to make it easy to do the math on each allocation (if LocalAllocator had a weird size then every allocation would have to do an imul). This is a definite slow-down on GC-heavy benchmarks, but by a small margin, and only on unusually heavy tests. For example, boyer and splay are both 3% regressed, but the Octane geomean is just fine. The JetStream score regressed by 0.5% with p = 0.08 (so maybe there is something there, but it's not significant according to our threshold). * JavaScriptCore.xcodeproj/project.pbxproj: * Sources.txt: * b3/B3LowerToAir.cpp: * b3/B3PatchpointSpecial.cpp: (JSC::B3::PatchpointSpecial::admitsStack): * b3/B3StackmapSpecial.cpp: (JSC::B3::StackmapSpecial::forEachArgImpl): (JSC::B3::StackmapSpecial::isArgValidForRep): * b3/B3StackmapValue.cpp: (JSC::B3::StackmapValue::appendSomeRegisterWithClobber): * b3/B3StackmapValue.h: * b3/B3Validate.cpp: * b3/B3ValueRep.cpp: (JSC::B3::ValueRep::addUsedRegistersTo const): (JSC::B3::ValueRep::dump const): (WTF::printInternal): * b3/B3ValueRep.h: (JSC::B3::ValueRep::ValueRep): * bytecode/AccessCase.cpp: (JSC::AccessCase::generateImpl): * bytecode/ObjectAllocationProfile.h: (JSC::ObjectAllocationProfile::ObjectAllocationProfile): (JSC::ObjectAllocationProfile::clear): * bytecode/ObjectAllocationProfileInlines.h: (JSC::ObjectAllocationProfile::initializeProfile): * dfg/DFGSpeculativeJIT.cpp: (JSC::DFG::SpeculativeJIT::emitAllocateRawObject): (JSC::DFG::SpeculativeJIT::compileMakeRope): (JSC::DFG::SpeculativeJIT::compileAllocatePropertyStorage): (JSC::DFG::SpeculativeJIT::compileReallocatePropertyStorage): (JSC::DFG::SpeculativeJIT::compileCreateThis): (JSC::DFG::SpeculativeJIT::compileNewObject): * dfg/DFGSpeculativeJIT.h: (JSC::DFG::SpeculativeJIT::emitAllocateJSCell): (JSC::DFG::SpeculativeJIT::emitAllocateJSObject): * ftl/FTLAbstractHeapRepository.h: * ftl/FTLLowerDFGToB3.cpp: (JSC::FTL::DFG::LowerDFGToB3::compileMakeRope): (JSC::FTL::DFG::LowerDFGToB3::compileMaterializeNewObject): (JSC::FTL::DFG::LowerDFGToB3::allocatePropertyStorageWithSizeImpl): (JSC::FTL::DFG::LowerDFGToB3::allocateHeapCell): (JSC::FTL::DFG::LowerDFGToB3::allocateObject): (JSC::FTL::DFG::LowerDFGToB3::allocatorForSize): (JSC::FTL::DFG::LowerDFGToB3::allocateVariableSizedObject): (JSC::FTL::DFG::LowerDFGToB3::allocateVariableSizedCell): * heap/Allocator.cpp: Added. (JSC::Allocator::cellSize const): * heap/Allocator.h: Added. (JSC::Allocator::Allocator): (JSC::Allocator::offset const): (JSC::Allocator::operator== const): (JSC::Allocator::operator!= const): (JSC::Allocator::operator bool const): * heap/AllocatorInlines.h: Added. (JSC::Allocator::allocate const): (JSC::Allocator::tryAllocate const): * heap/BlockDirectory.cpp: (JSC::BlockDirectory::BlockDirectory): (JSC::BlockDirectory::findBlockForAllocation): (JSC::BlockDirectory::stopAllocating): (JSC::BlockDirectory::prepareForAllocation): (JSC::BlockDirectory::stopAllocatingForGood): (JSC::BlockDirectory::resumeAllocating): (JSC::BlockDirectory::endMarking): (JSC::BlockDirectory::isFreeListedCell): (JSC::BlockDirectory::didConsumeFreeList): Deleted. (JSC::BlockDirectory::tryAllocateWithoutCollecting): Deleted. (JSC::BlockDirectory::allocateIn): Deleted. (JSC::BlockDirectory::tryAllocateIn): Deleted. (JSC::BlockDirectory::doTestCollectionsIfNeeded): Deleted. (JSC::BlockDirectory::allocateSlowCase): Deleted. * heap/BlockDirectory.h: (JSC::BlockDirectory::cellKind const): (JSC::BlockDirectory::allocator const): (JSC::BlockDirectory::freeList const): Deleted. (JSC::BlockDirectory::offsetOfFreeList): Deleted. (JSC::BlockDirectory::offsetOfCellSize): Deleted. * heap/BlockDirectoryInlines.h: (JSC::BlockDirectory::isFreeListedCell const): Deleted. (JSC::BlockDirectory::allocate): Deleted. * heap/CompleteSubspace.cpp: (JSC::CompleteSubspace::CompleteSubspace): (JSC::CompleteSubspace::allocatorFor): (JSC::CompleteSubspace::allocate): (JSC::CompleteSubspace::allocateNonVirtual): (JSC::CompleteSubspace::allocatorForSlow): (JSC::CompleteSubspace::allocateSlow): (JSC::CompleteSubspace::tryAllocateSlow): * heap/CompleteSubspace.h: (JSC::CompleteSubspace::allocatorForSizeStep): (JSC::CompleteSubspace::allocatorForNonVirtual): * heap/FreeList.h: * heap/GCDeferralContext.h: * heap/Heap.cpp: (JSC::Heap::Heap): (JSC::Heap::lastChanceToFinalize): * heap/Heap.h: (JSC::Heap::threadLocalCacheLayout): * heap/IsoCellSet.h: * heap/IsoSubspace.cpp: (JSC::IsoSubspace::IsoSubspace): (JSC::IsoSubspace::allocatorFor): (JSC::IsoSubspace::allocate): (JSC::IsoSubspace::allocateNonVirtual): * heap/IsoSubspace.h: (JSC::IsoSubspace::allocatorForNonVirtual): * heap/LocalAllocator.cpp: Added. (JSC::LocalAllocator::LocalAllocator): (JSC::LocalAllocator::reset): (JSC::LocalAllocator::~LocalAllocator): (JSC::LocalAllocator::stopAllocating): (JSC::LocalAllocator::resumeAllocating): (JSC::LocalAllocator::prepareForAllocation): (JSC::LocalAllocator::stopAllocatingForGood): (JSC::LocalAllocator::allocateSlowCase): (JSC::LocalAllocator::didConsumeFreeList): (JSC::LocalAllocator::tryAllocateWithoutCollecting): (JSC::LocalAllocator::allocateIn): (JSC::LocalAllocator::tryAllocateIn): (JSC::LocalAllocator::doTestCollectionsIfNeeded): (JSC::LocalAllocator::isFreeListedCell const): * heap/LocalAllocator.h: Added. (JSC::LocalAllocator::offsetOfFreeList): (JSC::LocalAllocator::offsetOfCellSize): * heap/LocalAllocatorInlines.h: Added. (JSC::LocalAllocator::allocate): * heap/MarkedSpace.cpp: (JSC::MarkedSpace::stopAllocatingForGood): * heap/MarkedSpace.h: * heap/SlotVisitor.cpp: * heap/SlotVisitor.h: * heap/Subspace.h: * heap/ThreadLocalCache.cpp: Added. (JSC::ThreadLocalCache::create): (JSC::ThreadLocalCache::ThreadLocalCache): (JSC::ThreadLocalCache::~ThreadLocalCache): (JSC::ThreadLocalCache::allocateData): (JSC::ThreadLocalCache::destroyData): (JSC::ThreadLocalCache::installSlow): (JSC::ThreadLocalCache::installData): (JSC::ThreadLocalCache::allocatorSlow): (JSC::ThreadLocalCache::destructor): * heap/ThreadLocalCache.h: Added. (JSC::ThreadLocalCache::offsetOfSize): (JSC::ThreadLocalCache::offsetOfFirstAllocator): * heap/ThreadLocalCacheInlines.h: Added. (JSC::ThreadLocalCache::getImpl): (JSC::ThreadLocalCache::get): (JSC::ThreadLocalCache::install): (JSC::ThreadLocalCache::allocator): (JSC::ThreadLocalCache::tryGetAllocator): * heap/ThreadLocalCacheLayout.cpp: Added. (JSC::ThreadLocalCacheLayout::ThreadLocalCacheLayout): (JSC::ThreadLocalCacheLayout::~ThreadLocalCacheLayout): (JSC::ThreadLocalCacheLayout::allocateOffset): (JSC::ThreadLocalCacheLayout::snapshot): (JSC::ThreadLocalCacheLayout::directory): * heap/ThreadLocalCacheLayout.h: Added. * jit/AssemblyHelpers.cpp: (JSC::AssemblyHelpers::emitAllocateWithNonNullAllocator): (JSC::AssemblyHelpers::emitAllocate): (JSC::AssemblyHelpers::emitAllocateVariableSized): * jit/AssemblyHelpers.h: (JSC::AssemblyHelpers::vm): (JSC::AssemblyHelpers::emitAllocateJSCell): (JSC::AssemblyHelpers::emitAllocateJSObject): (JSC::AssemblyHelpers::emitAllocateJSObjectWithKnownSize): (JSC::AssemblyHelpers::emitAllocateWithNonNullAllocator): Deleted. (JSC::AssemblyHelpers::emitAllocate): Deleted. (JSC::AssemblyHelpers::emitAllocateVariableSized): Deleted. * jit/JITOpcodes.cpp: (JSC::JIT::emit_op_new_object): (JSC::JIT::emit_op_create_this): * jit/JITOpcodes32_64.cpp: (JSC::JIT::emit_op_new_object): (JSC::JIT::emit_op_create_this): * runtime/ButterflyInlines.h: (JSC::Butterfly::createUninitialized): (JSC::Butterfly::tryCreate): (JSC::Butterfly::growArrayRight): * runtime/DirectArguments.cpp: (JSC::DirectArguments::overrideThings): * runtime/GenericArgumentsInlines.h: (JSC::GenericArguments::initModifiedArgumentsDescriptor): * runtime/HashMapImpl.h: (JSC::HashMapBuffer::create): * runtime/JSArray.cpp: (JSC::JSArray::tryCreateUninitializedRestricted): (JSC::JSArray::unshiftCountSlowCase): * runtime/JSArray.h: (JSC::JSArray::tryCreate): * runtime/JSArrayBufferView.cpp: (JSC::JSArrayBufferView::ConstructionContext::ConstructionContext): * runtime/JSCellInlines.h: (JSC::tryAllocateCellHelper): * runtime/JSGlobalObject.cpp: (JSC::JSGlobalObject::JSGlobalObject): * runtime/JSGlobalObject.h: (JSC::JSGlobalObject::threadLocalCache const): * runtime/JSLock.cpp: (JSC::JSLock::didAcquireLock): * runtime/Options.h: * runtime/RegExpMatchesArray.h: (JSC::tryCreateUninitializedRegExpMatchesArray): * runtime/VM.cpp: (JSC::VM::VM): * runtime/VM.h: * runtime/VMEntryScope.cpp: (JSC::VMEntryScope::VMEntryScope): 2018-01-24 Joseph Pecoraro Web Inspector: Simplify update-LegacyInspectorBackendCommands.rb https://bugs.webkit.org/show_bug.cgi?id=182067 Reviewed by Brian Burg. * inspector/scripts/codegen/models.py: (Framework.fromString): (Frameworks): * inspector/scripts/generate-inspector-protocol-bindings.py: (generate_from_specification): Allow framework WebInspectorUI to generate just the backend commands files. 2018-01-23 Mark Lam Update Poisoned pointers to take a Poison class instead of a uintptr_t&. https://bugs.webkit.org/show_bug.cgi?id=182017 Reviewed by Filip Pizlo and JF Bastien. Removed the POISON() macro. Now that we have Poison types, we can just use the the Poison type instead and make the code a bit nicer to read. * API/JSAPIWrapperObject.h: * API/JSCallbackFunction.h: * API/JSCallbackObject.h: * b3/B3LowerMacros.cpp: * b3/testb3.cpp: (JSC::B3::testInterpreter): * bytecode/CodeBlock.h: (JSC::CodeBlock::instructions): (JSC::CodeBlock::instructions const): * dfg/DFGOSRExitCompilerCommon.h: (JSC::DFG::adjustFrameAndStackInOSRExitCompilerThunk): * dfg/DFGSpeculativeJIT.cpp: (JSC::DFG::SpeculativeJIT::compileCheckSubClass): (JSC::DFG::SpeculativeJIT::emitSwitchIntJump): * ftl/FTLLowerDFGToB3.cpp: (JSC::FTL::DFG::LowerDFGToB3::compileCheckSubClass): * jit/JIT.h: * jit/ThunkGenerators.cpp: (JSC::virtualThunkFor): (JSC::nativeForGenerator): (JSC::boundThisNoArgsFunctionCallGenerator): * parser/UnlinkedSourceCode.h: * runtime/ArrayPrototype.h: * runtime/CustomGetterSetter.h: * runtime/DateInstance.h: * runtime/InternalFunction.h: * runtime/JSArrayBuffer.h: * runtime/JSCPoison.cpp: (JSC::initializePoison): * runtime/JSCPoison.h: * runtime/JSGlobalObject.h: * runtime/JSScriptFetchParameters.h: * runtime/JSScriptFetcher.h: * runtime/NativeExecutable.h: * runtime/StructureTransitionTable.h: * runtime/WriteBarrier.h: (JSC::WriteBarrier::poison): Deleted. * wasm/js/JSToWasm.cpp: (JSC::Wasm::createJSToWasmWrapper): * wasm/js/JSWebAssemblyCodeBlock.cpp: (JSC::JSWebAssemblyCodeBlock::JSWebAssemblyCodeBlock): * wasm/js/JSWebAssemblyCodeBlock.h: * wasm/js/JSWebAssemblyInstance.h: (JSC::JSWebAssemblyInstance::poison): * wasm/js/JSWebAssemblyMemory.h: * wasm/js/JSWebAssemblyModule.h: * wasm/js/JSWebAssemblyTable.h: * wasm/js/WasmToJS.cpp: (JSC::Wasm::handleBadI64Use): (JSC::Wasm::wasmToJS): * wasm/js/WebAssemblyFunctionBase.h: * wasm/js/WebAssemblyModuleRecord.h: * wasm/js/WebAssemblyToJSCallee.h: * wasm/js/WebAssemblyWrapperFunction.h: 2018-01-23 Yusuke Suzuki Unreviewed, suppress GCC warnings https://bugs.webkit.org/show_bug.cgi?id=181976 * runtime/TypedArrayType.h: 2018-01-23 Yusuke Suzuki [YARR] Add diagnosis for YarrJIT failures https://bugs.webkit.org/show_bug.cgi?id=181927 Reviewed by Sam Weinig. It is nice if we can see the reason why YarrJIT fails to compile a given pattern. This patch introduces Yarr::JITFailureReason and dumps messages if Options::dumpCompiledRegExpPatterns is specified. * runtime/RegExp.cpp: (JSC::RegExp::compile): (JSC::RegExp::compileMatchOnly): * yarr/YarrJIT.cpp: (JSC::Yarr::YarrGenerator::generateTerm): (JSC::Yarr::YarrGenerator::backtrackTerm): (JSC::Yarr::YarrGenerator::opCompileParenthesesSubpattern): (JSC::Yarr::YarrGenerator::YarrGenerator): (JSC::Yarr::YarrGenerator::compile): (JSC::Yarr::dumpCompileFailure): (JSC::Yarr::jitCompile): * yarr/YarrJIT.h: (JSC::Yarr::YarrCodeBlock::setFallBack): (JSC::Yarr::YarrCodeBlock::fallBack): (JSC::Yarr::YarrCodeBlock::clear): (JSC::Yarr::YarrCodeBlock::YarrCodeBlock): Deleted. (JSC::Yarr::YarrCodeBlock::~YarrCodeBlock): Deleted. (JSC::Yarr::YarrCodeBlock::isFallBack): Deleted. 2018-01-23 Alex Christensen Remove pre-Sierra-OS-specific code in WTF and JavaScriptCore https://bugs.webkit.org/show_bug.cgi?id=182028 Reviewed by Keith Miller. * inspector/remote/cocoa/RemoteInspectorXPCConnection.h: * inspector/remote/cocoa/RemoteInspectorXPCConnection.mm: (Inspector::RemoteInspectorXPCConnection::handleEvent): 2018-01-23 Filip Pizlo Use precise index masking for FTL GetByArgumentByVal https://bugs.webkit.org/show_bug.cgi?id=182006 Reviewed by Keith Miller. This protects speculative out-of-bounds on arguments[index]. Making this work right involved fixing a possible overflow situation with numberOfArgumentsToSkip. * dfg/DFGByteCodeParser.cpp: (JSC::DFG::ByteCodeParser::findArgumentPositionForLocal): * dfg/DFGGraph.cpp: (JSC::DFG::Graph::dump): * dfg/DFGNode.h: (JSC::DFG::Node::hasNumberOfArgumentsToSkip): (JSC::DFG::Node::numberOfArgumentsToSkip): * dfg/DFGStackLayoutPhase.cpp: (JSC::DFG::StackLayoutPhase::run): * ftl/FTLLowerDFGToB3.cpp: (JSC::FTL::DFG::LowerDFGToB3::compileGetMyArgumentByVal): 2018-01-23 David Kilzer Follow-up for: oss-fuzz jsc build is broken: StringImpl.h:27:10: fatal error: 'unicode/ustring.h' file not found Address feedback for this change. * CMakeLists.txt: Change "SYSTEM PUBLIC" to "SYSTEM PRIVATE" per feedback from Konstantin Tokarev. 2018-01-23 Robin Morisset Rollout r219636 https://bugs.webkit.org/show_bug.cgi?id=181997 Unreviewed, as it is a rollout. * dfg/DFGSpeculativeJIT.cpp: (JSC::DFG::SpeculativeJIT::emitAllocateRawObject): * runtime/JSArray.cpp: (JSC::JSArray::tryCreateUninitializedRestricted): * runtime/JSArray.h: (JSC::JSArray::tryCreate): * runtime/JSObject.cpp: (JSC::JSObject::ensureLengthSlow): 2018-01-23 Mark Lam Re-arrange TypedArray JSTypes to match the order of the TypedArrayType enum list. https://bugs.webkit.org/show_bug.cgi?id=181976 Reviewed by Filip Pizlo. 1. The order of TypedArray JSTypes now matches the order the TypedArrayType enum list. I also added static asserts in TypedArrayType.h to enforce this. Also redefined FOR_EACH_TYPED_ARRAY_TYPE() in terms of 2. Define 4 new values: a. FirstTypedArrayType b. LastTypedArrayType c. NumberOfTypedArrayTypesExcludingDataView d. NumberOfTypedArrayTypes Use these everywhere where we iterate or bisect the TypedArray JSTypes. 3. Removed NUMBER_OF_TYPED_ARRAY_TYPES, and use NumberOfTypedArrayTypes instead. 4. Simplify the code that converts between TypedArrayType and JSType. Changed typedArrayTypeForType() to be the mirror image of typeForTypedArrayType(). Previously, typedArrayTypeForType() converts DataViewType to NotTypedArray instead of TypeDataView. Now, it converts to TypeDataView. This does not result in any change of behavior because typedArrayTypeForType() is only called in Structure::hasIndexingHeader(), and its result is passed to isTypedView(), which handles TypeDataView correctly. 5. Also fixed a bug in SpeculativeJIT::compileGetTypedArrayByteOffset(). If the vector is null, we can skip the rest of the checks. While the current code does not result in incorrect behavior, it is inefficient, and communicates wrong information to the reader i.e. implying that there's something in the dataGPR when there's not. The dataGPR should also be null in this case. * dfg/DFGByteCodeParser.cpp: (JSC::DFG::ByteCodeParser::handleConstantInternalFunction): * dfg/DFGSpeculativeJIT.cpp: (JSC::DFG::SpeculativeJIT::compileIsTypedArrayView): (JSC::DFG::SpeculativeJIT::compileGetTypedArrayByteOffset): * ftl/FTLLowerDFGToB3.cpp: (JSC::FTL::DFG::LowerDFGToB3::isTypedArrayView): * ftl/FTLOSRExit.cpp: * llint/LowLevelInterpreter.asm: * llint/LowLevelInterpreter64.asm: * runtime/JSGlobalObject.cpp: (JSC::JSGlobalObject::visitChildren): * runtime/JSType.h: * runtime/TypedArrayType.cpp: (JSC::typeForTypedArrayType): Deleted. * runtime/TypedArrayType.h: (JSC::typedArrayTypeForType): (JSC::typeForTypedArrayType): 2018-01-23 Filip Pizlo DFG should always flush `this` https://bugs.webkit.org/show_bug.cgi?id=181999 Reviewed by Saam Barati and Mark Lam. This is going to make it possible to use precise index masking for arguments-on-the-stack accesses with an index adjusted so that 0 is this. Without this change, we would have no way of masking when the argument count is 0, unless we padded the argument area so that there was always an argument slot after `this` and it was always initialized. This is neutral on all benchmarks. * dfg/DFGByteCodeParser.cpp: (JSC::DFG::ByteCodeParser::flushImpl): (JSC::DFG::ByteCodeParser::flushForTerminalImpl): (JSC::DFG::ByteCodeParser::flush): (JSC::DFG::ByteCodeParser::flushForTerminal): (JSC::DFG::ByteCodeParser::parse): (JSC::DFG::flushImpl): Deleted. (JSC::DFG::flushForTerminalImpl): Deleted. * dfg/DFGPreciseLocalClobberize.h: (JSC::DFG::PreciseLocalClobberizeAdaptor::readTop): 2018-01-23 Filip Pizlo JSC should use a speculation fence on VM entry/exit https://bugs.webkit.org/show_bug.cgi?id=181991 Reviewed by JF Bastien and Mark Lam. This adds a WTF::speculationFence on VM entry and exit. For a microbenchmark that just calls a native function (supplied via an Objective-C block) in a tight loop from JS is a 0% regression on x86 and a 11% regression on ARM64. * runtime/JSLock.cpp: (JSC::JSLock::didAcquireLock): (JSC::JSLock::willReleaseLock): 2018-01-23 Yusuke Suzuki [JSC] JIT requires sizeof(bool) == 1 https://bugs.webkit.org/show_bug.cgi?id=181150 Reviewed by Saam Barati. LLInt and JIT assumes that sizeof(bool) == 1. But it is implementation-dependent in C++ spec. Since this is a mandatory requirement in JSC, we add a static_assert to ensure this. * runtime/InitializeThreading.cpp: 2018-01-23 Robin Morisset Update the argument count in DFGByteCodeParser::handleRecursiveCall https://bugs.webkit.org/show_bug.cgi?id=181739 Reviewed by Saam Barati. When calling a function, its number of arguments is set on the stack. When we turn a recursive tail call into a jump, we should update that stack slot as there is no guarantee that the function was originally called with the same number of arguments. Forgetting to do this is observable through 'arguments.length'. It required adding a new DFG node: 'SetArgumentCountIncludingThis', that takes an unsigned int as its first OpInfo field, and stores it to the stack at the right place. We must be a bit careful in where we put this new node, as it ClobbersExit. We must also fix DFGArgumentsEliminationPhase and DFGPutStackSinkingPhase as they assumed that any node that writes to the stack must write to either an argument or a local. * dfg/DFGAbstractInterpreterInlines.h: (JSC::DFG::AbstractInterpreter::executeEffects): * dfg/DFGArgumentsEliminationPhase.cpp: * dfg/DFGByteCodeParser.cpp: (JSC::DFG::ByteCodeParser::handleRecursiveTailCall): * dfg/DFGClobberize.h: (JSC::DFG::clobberize): * dfg/DFGDoesGC.cpp: (JSC::DFG::doesGC): * dfg/DFGFixupPhase.cpp: (JSC::DFG::FixupPhase::fixupNode): * dfg/DFGMayExit.cpp: * dfg/DFGNode.h: (JSC::DFG::Node::argumentCountIncludingThis): * dfg/DFGNodeType.h: * dfg/DFGPredictionPropagationPhase.cpp: * dfg/DFGPutStackSinkingPhase.cpp: * dfg/DFGSafeToExecute.h: (JSC::DFG::safeToExecute): * dfg/DFGSpeculativeJIT.cpp: (JSC::DFG::SpeculativeJIT::compileSetArgumentCountIncludingThis): * 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::compileSetArgumentCountIncludingThis): 2018-01-22 Michael Saboff DFG abstract interpreter needs to properly model effects of some Math ops https://bugs.webkit.org/show_bug.cgi?id=181886 Reviewed by Saam Barati. Reviewed the processing of the various ArithXXX and CompareXXX and found that several nodes don't handle UntypedUse. Added clobberWorld() for those cases. * dfg/DFGAbstractInterpreter.h: * dfg/DFGAbstractInterpreterInlines.h: (JSC::DFG::AbstractInterpreter::executeEffects): (JSC::DFG::AbstractInterpreter::executeDoubleUnaryOpEffects): 2018-01-21 Wenson Hsieh Add a new feature flag for EXTRA_ZOOM_MODE and reintroduce AdditionalFeatureDefines.h https://bugs.webkit.org/show_bug.cgi?id=181918 Reviewed by Tim Horton. Add EXTRA_ZOOM_MODE to FeatureDefines.xconfig (off by default). * Configurations/FeatureDefines.xcconfig: 2018-01-20 Caio Lima [JSC] NumberPrototype::extractRadixFromArgs incorrectly cast double to int32_t https://bugs.webkit.org/show_bug.cgi?id=181182 Reviewed by Darin Adler. Casting double to integer is undefined behavior when the truncation results into a value that doesn't fit into integer size, according C++ spec[1]. Thus, we are changing bigIntProtoFuncToString and numberProtoFuncToString to remove these source of undefined behavior. [1] - http://en.cppreference.com/w/cpp/language/implicit_conversion * runtime/BigIntPrototype.cpp: (JSC::bigIntProtoFuncToString): * runtime/NumberPrototype.cpp: (JSC::numberProtoFuncToString): (JSC::extractToStringRadixArgument): (JSC::extractRadixFromArgs): Deleted. * runtime/NumberPrototype.h: 2018-01-19 Saam Barati Kill ArithNegate's ArithProfile assert inside BytecodeParser https://bugs.webkit.org/show_bug.cgi?id=181877 Reviewed by Mark Lam. Before this patch, we used to assert that op_negate's result ArithProfile only produces number. It's logically true that negate only produces a number. However, the DFG may incorrectly pick this ArithProfile when doing OSR exit profiling. So we'll end up profiling something that's likely the input to negate. This patch removes the assert. We cede to the fact that Graph::methodOfGettingAValueProfileFor is entirely heuristic based, potentially leading to profiling results being imprecise. * dfg/DFGByteCodeParser.cpp: (JSC::DFG::ByteCodeParser::makeSafe): 2018-01-19 David Kilzer oss-fuzz jsc build is broken: StringImpl.h:27:10: fatal error: 'unicode/ustring.h' file not found Rubber-stamped by JF Bastien. * CMakeLists.txt: Add ICU header search path to LLIntOffsetsExtractor target by reusing JavaScriptCore_SYSTEM_INCLUDE_DIRECTORIES. 2018-01-19 Saam Barati Spread's effects are modeled incorrectly both in AI and in Clobberize https://bugs.webkit.org/show_bug.cgi?id=181867 Reviewed by Michael Saboff. * dfg/DFGAbstractInterpreterInlines.h: (JSC::DFG::AbstractInterpreter::executeEffects): * dfg/DFGClobberize.h: (JSC::DFG::clobberize): 2018-01-19 Keith Miller HaveInternalSDK includes should be "#include?" https://bugs.webkit.org/show_bug.cgi?id=179670 Reviewed by Dan Bernstein. * Configurations/Base.xcconfig: 2018-01-18 JF Bastien Set the minimum executable allocator size properly https://bugs.webkit.org/show_bug.cgi?id=181816 Reviewed by Saam Barati. Executable allocator expects at least two page size's worth of allocation in certain conditions, and that causes some tests to now fail because they ask for less. Set that minimum correctly. We were already rounding up to a page size, so having a minimum of 2 page sizes is fine. * jit/ExecutableAllocator.cpp: (JSC::FixedVMPoolExecutableAllocator::FixedVMPoolExecutableAllocator): 2018-01-18 Michael Saboff Unreviewed build fix for Windows * interpreter/FrameTracers.h: (JSC::assertStackPointerIsAligned): Can't use gcc style inlined assembly on Windows. 2018-01-18 Mark Lam Poisons should be initialized after Options are initialized. https://bugs.webkit.org/show_bug.cgi?id=181807 Reviewed by Keith Miller. This is because poison initialization may depend on options. * runtime/InitializeThreading.cpp: (JSC::initializeThreading): 2018-01-18 Dan Bernstein [Xcode] Streamline and future-proof target-macOS-version-dependent build setting definitions https://bugs.webkit.org/show_bug.cgi?id=181803 Reviewed by Tim Horton. * Configurations/Base.xcconfig: Updated. * Configurations/DebugRelease.xcconfig: Ditto. * Configurations/FeatureDefines.xcconfig: Adopted macOSTargetConditionals helpers. * Configurations/Version.xcconfig: Updated. * Configurations/macOSTargetConditionals.xcconfig: Added. Defines helper build settings useful for defining settings that depend on the target macOS version. 2018-01-18 Michael Saboff REGRESSION (r226068): [X86] Crash in JavaScriptCore ShadowChicken when handling exceptions https://bugs.webkit.org/show_bug.cgi?id=181802 Reviewed by Filip Pizlo. There where a few places where the stack isn't properly aligned for X86 when we call into C++ code. Two places are where we call into exception handling code, the LLInt and from nativeForGenerator. The other place was when we call into the operationOSRWriteBarrier(). Added an assert check that the stack is aligned on X86 platforms in the native call tracing code. This helped find the other cases beyond the original problem. * dfg/DFGOSRExitCompilerCommon.cpp: (JSC::DFG::osrWriteBarrier): * interpreter/FrameTracers.h: (JSC::assertStackPointerIsAligned): (JSC::NativeCallFrameTracer::NativeCallFrameTracer): (JSC::NativeCallFrameTracerWithRestore::NativeCallFrameTracerWithRestore): * jit/ThunkGenerators.cpp: (JSC::nativeForGenerator): * llint/LowLevelInterpreter32_64.asm: 2018-01-18 Commit Queue Unreviewed, rolling out r227096. https://bugs.webkit.org/show_bug.cgi?id=181788 "it caused a 15% octane regression" (Requested by saamyjoon on #webkit). Reverted changeset: "Support MultiGetByOffset in the DFG" https://bugs.webkit.org/show_bug.cgi?id=181466 https://trac.webkit.org/changeset/227096 2018-01-17 Yusuke Suzuki [DFG][FTL] Introduce PhantomNewRegexp and RegExpExecNonGlobalOrSticky https://bugs.webkit.org/show_bug.cgi?id=181535 Reviewed by Saam Barati. When executing the code like `string.match(/regexp/)`, `/regexp/` object is created every time we execute this code. However, user rarely cares about this `/regexp/` object. Typically, it is soon discarded even if it has `lastIndex` information. So we should not create RegExpObject for this typical case. This patch introduces PhantomNewRegexp. We convert NewRegexp node to PhantomNewRegexp in Object Allocation Sinking (OAS) phase. We should do this analysis in OAS phase since we track modifications to `lastIndex` in the OAS phase. Even if `lastIndex` is modified, it may not be read by users. So we have a chance to drop this NewRegexp beacause we carefully model SetRegExpObjectLastIndex and GetRegExpObjectLastIndex in OAS phase. This patch is a first attempt to drop NewRegexp. So we start optimizing it with the simple step: we first drop RegExp with non-global and non-sticky one. We can later extend this optimization for RegExp with global flag. But this is not included in this patch. We convert RegExpExec to RegExpExecNonGlobalOrSticky if we find that the given RegExpObject's RegExp is not global/sticky flagged. Since we do not need to touch `lastIndex` property in this case, RegExpExecNonGlobalOrSticky just takes RegExp instead of RegExpObject. This offers the chance to make NewRegExp unused. We also convert RegExpMatchFast to RegExpExecNonGlobalOrSticky if its RegExpObject's RegExp is non-global and non-sticky, since they are the same behavior. The above optimization completely removes NewRegexp in SixSpeed's regexp-u.{es5,es6}. The resulted execution time is somewhat pure execution time of our Yarr implementation. baseline patched regex-u.es5 34.8557+-0.5963 ^ 6.1507+-0.5526 ^ definitely 5.6670x faster regex-u.es6 89.1919+-3.3851 ^ 32.0917+-0.4260 ^ definitely 2.7793x faster This patch does not change Octane/RegExp so much since it heavily uses String.prototype.replace, which is not handled in this patch right now. We should support StringReplace node in subsequent patches. * dfg/DFGAbstractInterpreterInlines.h: (JSC::DFG::AbstractInterpreter::executeEffects): * dfg/DFGByteCodeParser.cpp: (JSC::DFG::ByteCodeParser::parseBlock): * dfg/DFGClobberize.h: (JSC::DFG::clobberize): * dfg/DFGClobbersExitState.cpp: (JSC::DFG::clobbersExitState): * dfg/DFGDoesGC.cpp: (JSC::DFG::doesGC): * dfg/DFGFixupPhase.cpp: (JSC::DFG::FixupPhase::fixupNode): * dfg/DFGGraph.cpp: (JSC::DFG::Graph::dump): * dfg/DFGMayExit.cpp: * dfg/DFGNode.cpp: (JSC::DFG::Node::convertToRegExpExecNonGlobalOrSticky): * dfg/DFGNode.h: (JSC::DFG::Node::convertToPhantomNewRegexp): (JSC::DFG::Node::convertToSetRegExpObjectLastIndex): (JSC::DFG::Node::hasHeapPrediction): (JSC::DFG::Node::hasCellOperand): (JSC::DFG::Node::isPhantomAllocation): (JSC::DFG::Node::hasIgnoreLastIndexIsWritable): (JSC::DFG::Node::ignoreLastIndexIsWritable): * dfg/DFGNodeType.h: * dfg/DFGObjectAllocationSinkingPhase.cpp: * dfg/DFGOperations.cpp: * dfg/DFGOperations.h: * dfg/DFGPredictionPropagationPhase.cpp: * dfg/DFGPromotedHeapLocation.cpp: (WTF::printInternal): * dfg/DFGPromotedHeapLocation.h: (JSC::DFG::PromotedLocationDescriptor::neededForMaterialization const): * dfg/DFGSafeToExecute.h: (JSC::DFG::safeToExecute): * dfg/DFGSpeculativeJIT.cpp: (JSC::DFG::SpeculativeJIT::compileNewRegexp): (JSC::DFG::SpeculativeJIT::compileSetRegExpObjectLastIndex): (JSC::DFG::SpeculativeJIT::compileRegExpExecNonGlobalOrSticky): * dfg/DFGSpeculativeJIT.h: (JSC::DFG::SpeculativeJIT::callOperation): * dfg/DFGSpeculativeJIT32_64.cpp: (JSC::DFG::SpeculativeJIT::compile): * dfg/DFGSpeculativeJIT64.cpp: (JSC::DFG::SpeculativeJIT::compile): * dfg/DFGStrengthReductionPhase.cpp: (JSC::DFG::StrengthReductionPhase::handleNode): * dfg/DFGValidate.cpp: * ftl/FTLCapabilities.cpp: (JSC::FTL::canCompile): * ftl/FTLLowerDFGToB3.cpp: (JSC::FTL::DFG::LowerDFGToB3::compileNode): (JSC::FTL::DFG::LowerDFGToB3::compileRegExpExecNonGlobalOrSticky): (JSC::FTL::DFG::LowerDFGToB3::compileNewRegexp): (JSC::FTL::DFG::LowerDFGToB3::compileSetRegExpObjectLastIndex): * ftl/FTLOperations.cpp: (JSC::FTL::operationPopulateObjectInOSR): (JSC::FTL::operationMaterializeObjectInOSR): * jit/JITOperations.h: * runtime/RegExpObject.h: (JSC::RegExpObject::create): 2018-01-17 Yusuke Suzuki [FTL] Remove unused helper functions to convert node to PutHint https://bugs.webkit.org/show_bug.cgi?id=181775 Reviewed by Saam Barati. We are using PromotedHeapLocation::createHint. So they are not necessary. * dfg/DFGNode.cpp: (JSC::DFG::Node::convertToPutHint): Deleted. (JSC::DFG::Node::convertToPutStructureHint): Deleted. (JSC::DFG::Node::convertToPutByOffsetHint): Deleted. (JSC::DFG::Node::convertToPutClosureVarHint): Deleted. * dfg/DFGNode.h: 2018-01-17 Yusuke Suzuki Unreviewed, suppress warnings on GCC Since `length` and `p` are always positive or zero, static_cast() does what we want. * runtime/JSBigInt.cpp: (JSC::JSBigInt::parseInt): 2018-01-17 Saam Barati Disable Atomics when SharedArrayBuffer isn’t enabled https://bugs.webkit.org/show_bug.cgi?id=181572 Reviewed by Michael Saboff. * runtime/JSGlobalObject.cpp: (JSC::JSGlobalObject::init): (JSC::createAtomicsProperty): Deleted. 2018-01-17 Saam Barati Support MultiGetByOffset in the DFG https://bugs.webkit.org/show_bug.cgi?id=181466 Reviewed by Keith Miller. This seems to benefit Speedometer in my local testing. It seems like this might be around a 0.5% improvement. * dfg/DFGAbstractInterpreterInlines.h: (JSC::DFG::AbstractInterpreter::executeEffects): * dfg/DFGByteCodeParser.cpp: (JSC::DFG::ByteCodeParser::handleGetById): * dfg/DFGConstantFoldingPhase.cpp: (JSC::DFG::ConstantFoldingPhase::foldConstants): * dfg/DFGGraph.h: (JSC::DFG::Graph::supportsMultiGetByOffset): * dfg/DFGSpeculativeJIT64.cpp: (JSC::DFG::SpeculativeJIT::compile): 2018-01-17 Saam Barati DFG::Node::convertToConstant needs to clear the varargs flags https://bugs.webkit.org/show_bug.cgi?id=181697 Reviewed by Yusuke Suzuki. * dfg/DFGNode.h: (JSC::DFG::Node::convertToConstant): 2018-01-16 JF Bastien Allow dangerous disabling of poison https://bugs.webkit.org/show_bug.cgi?id=181685 Reviewed by Keith Miller. Some tools such as leak detectors and such like to look at real pointers, and poisoned ones confuse them. Add a JSC option to disable poisoning, but log to the console when this is done. * runtime/JSCPoison.cpp: (JSC::initializePoison): * runtime/Options.h: 2018-01-16 Ryan Haddad Unreviewed, rolling out r226937. Tests added with this change are failing due to a missing exception check. Reverted changeset: "[JSC] NumberPrototype::extractRadixFromArgs incorrectly cast double to int32_t" https://bugs.webkit.org/show_bug.cgi?id=181182 https://trac.webkit.org/changeset/226937 2018-01-16 Michael Catanzaro Test programs should only be built in developer mode https://bugs.webkit.org/show_bug.cgi?id=181653 Reviewed by Carlos Garcia Campos. Build test programs only in developer mode, and fix code style. * shell/CMakeLists.txt: 2018-01-15 Michael Catanzaro Improve use of ExportMacros https://bugs.webkit.org/show_bug.cgi?id=181652 Reviewed by Konstantin Tokarev. * API/JSBase.h: Update a comment. * inspector/InspectorBackendDispatcher.h: Use a better, yet equivalent, WTF macro. * runtime/JSExportMacros.h: Simplify the #defines in this file. 2018-01-15 JF Bastien Remove makePoisonedUnique https://bugs.webkit.org/show_bug.cgi?id=181630 Reviewed by Mark Lam. I added a conversion from std::unique_ptr, so we can just use std::make_unique and it'll auto-poison when converted. * bytecode/CodeBlock.h: (JSC::CodeBlock::makePoisonedUnique): Deleted. * runtime/JSGlobalObject.cpp: (JSC::JSGlobalObject::init): * runtime/JSGlobalObject.h: (JSC::JSGlobalObject::makePoisonedUnique): Deleted. 2018-01-15 Michael Catanzaro REGRESSION(r226266): [GTK] RELEASE_ASSERT(reservedZoneSize >= minimumReservedZoneSize) in JSC::VM::updateStackLimits https://bugs.webkit.org/show_bug.cgi?id=181438 Reviewed by Carlos Garcia Campos. Roll out the functional changes of r226266. We'll keep the minor CMake library type setting cleanup, but we have to switch back to building JSC only as a shared library, and we have to get rid of the version script. * PlatformGTK.cmake: * javascriptcoregtk-symbols.map: Removed. 2018-01-14 Saam Barati Unreviewed. r226928 broke the CLOOP build. This patch fixes the CLOOP build. * bytecode/CallLinkStatus.cpp: (JSC::CallLinkStatus::computeFromLLInt): (JSC::CallLinkStatus::computeExitSiteData): 2018-01-13 Mark Lam Replace all use of ConstExprPoisoned with Poisoned. https://bugs.webkit.org/show_bug.cgi?id=181542 Reviewed by JF Bastien. 1. All JSC poisons are now defined in JSCPoison.h. 2. Change all clients to use the new poison values via the POISON() macro. 3. The LLInt code has been updated to handle CodeBlock poison. Some of this code uses the t5 temp register, which is not available on the Windows port. Fortunately, we don't currently do poisoning on the Windows port yet. So, it will just work for now. When poisoning is enabled for the Windows port, this LLInt code will need a Windows specific implementation to workaround its lack of a t5 register. * API/JSAPIWrapperObject.h: * API/JSCallbackFunction.h: * API/JSCallbackObject.h: * JavaScriptCore.xcodeproj/project.pbxproj: * Sources.txt: * assembler/MacroAssemblerCodeRef.h: (JSC::MacroAssemblerCodePtr::emptyValue): (JSC::MacroAssemblerCodePtr::deletedValue): * b3/B3LowerMacros.cpp: * b3/testb3.cpp: (JSC::B3::testInterpreter): * bytecode/CodeBlock.h: (JSC::CodeBlock::instructions): (JSC::CodeBlock::instructions const): (JSC::CodeBlock::makePoisonedUnique): * dfg/DFGOSRExitCompilerCommon.h: (JSC::DFG::adjustFrameAndStackInOSRExitCompilerThunk): * dfg/DFGSpeculativeJIT.cpp: (JSC::DFG::SpeculativeJIT::compileCheckSubClass): (JSC::DFG::SpeculativeJIT::emitSwitchIntJump): * ftl/FTLLowerDFGToB3.cpp: (JSC::FTL::DFG::LowerDFGToB3::compileCheckSubClass): * jit/JIT.h: * jit/ThunkGenerators.cpp: (JSC::virtualThunkFor): (JSC::nativeForGenerator): (JSC::boundThisNoArgsFunctionCallGenerator): * llint/LowLevelInterpreter.asm: * llint/LowLevelInterpreter32_64.asm: * llint/LowLevelInterpreter64.asm: * parser/UnlinkedSourceCode.h: * runtime/ArrayPrototype.h: * runtime/CustomGetterSetter.h: * runtime/DateInstance.h: * runtime/InternalFunction.h: * runtime/JSArrayBuffer.h: * runtime/JSCPoison.cpp: Copied from Source/JavaScriptCore/runtime/JSCPoisonedPtr.cpp. (JSC::initializePoison): * runtime/JSCPoison.h: (): Deleted. * runtime/JSCPoisonedPtr.cpp: Removed. * runtime/JSCPoisonedPtr.h: Removed. * runtime/JSGlobalObject.h: (JSC::JSGlobalObject::makePoisonedUnique): * runtime/JSScriptFetchParameters.h: * runtime/JSScriptFetcher.h: * runtime/NativeExecutable.h: * runtime/StructureTransitionTable.h: (JSC::StructureTransitionTable::map const): (JSC::StructureTransitionTable::weakImpl const): * runtime/WriteBarrier.h: (JSC::WriteBarrier::poison): * wasm/js/JSToWasm.cpp: (JSC::Wasm::createJSToWasmWrapper): * wasm/js/JSWebAssemblyCodeBlock.cpp: (JSC::JSWebAssemblyCodeBlock::JSWebAssemblyCodeBlock): * wasm/js/JSWebAssemblyCodeBlock.h: * wasm/js/JSWebAssemblyInstance.h: * wasm/js/JSWebAssemblyMemory.h: * wasm/js/JSWebAssemblyModule.h: * wasm/js/JSWebAssemblyTable.h: * wasm/js/WasmToJS.cpp: (JSC::Wasm::handleBadI64Use): (JSC::Wasm::wasmToJS): * wasm/js/WebAssemblyFunctionBase.h: * wasm/js/WebAssemblyModuleRecord.h: * wasm/js/WebAssemblyToJSCallee.h: * wasm/js/WebAssemblyWrapperFunction.h: 2018-01-13 Caio Lima [JSC] NumberPrototype::extractRadixFromArgs incorrectly cast double to int32_t https://bugs.webkit.org/show_bug.cgi?id=181182 Reviewed by Darin Adler. Casting double to integer is undefined behavior when the truncation results into a value that doesn't fit into integer size, according C++ spec[1]. Thus, we are changing bigIntProtoFuncToString and numberProtoFuncToString to remove these source of undefined behavior. [1] - http://en.cppreference.com/w/cpp/language/implicit_conversion * runtime/BigIntPrototype.cpp: (JSC::bigIntProtoFuncToString): * runtime/NumberPrototype.cpp: (JSC::numberProtoFuncToString): (JSC::extractRadixFromArgs): Deleted. (JSC::extractToStringRadixArgument): Added. 2018-01-12 Saam Barati Move ExitProfile to UnlinkedCodeBlock so it can be shared amongst CodeBlocks backed by the same UnlinkedCodeBlock https://bugs.webkit.org/show_bug.cgi?id=181545 Reviewed by Michael Saboff. This patch follows the theme of putting optimization profiling information on UnlinkedCodeBlock. This allows the unlinked code cache to remember OSR exit data. This often leads to the first compile of a CodeBlock, backed by an UnlinkedCodeBlock pulled from the code cache, making better compilation decisions, usually resulting in fewer exits, and fewer recompilations. This is a 1% Speedometer progression in my testing. * bytecode/BytecodeDumper.cpp: (JSC::BytecodeDumper::dumpProfilesForBytecodeOffset): * bytecode/CallLinkStatus.cpp: (JSC::CallLinkStatus::computeFromLLInt): (JSC::CallLinkStatus::computeFor): (JSC::CallLinkStatus::computeExitSiteData): (JSC::CallLinkStatus::computeDFGStatuses): * bytecode/CallLinkStatus.h: * bytecode/CodeBlock.h: (JSC::CodeBlock::addFrequentExitSite): Deleted. (JSC::CodeBlock::hasExitSite const): Deleted. (JSC::CodeBlock::exitProfile): Deleted. * bytecode/DFGExitProfile.cpp: (JSC::DFG::ExitProfile::add): (JSC::DFG::QueryableExitProfile::initialize): * bytecode/DFGExitProfile.h: (JSC::DFG::ExitProfile::hasExitSite const): * bytecode/GetByIdStatus.cpp: (JSC::GetByIdStatus::hasExitSite): (JSC::GetByIdStatus::computeFor): (JSC::GetByIdStatus::computeForStubInfo): * bytecode/GetByIdStatus.h: * bytecode/PutByIdStatus.cpp: (JSC::PutByIdStatus::hasExitSite): (JSC::PutByIdStatus::computeFor): (JSC::PutByIdStatus::computeForStubInfo): * bytecode/PutByIdStatus.h: * bytecode/UnlinkedCodeBlock.cpp: (JSC::UnlinkedCodeBlock::livenessAnalysisSlow): * bytecode/UnlinkedCodeBlock.h: (JSC::UnlinkedCodeBlock::hasExitSite const): (JSC::UnlinkedCodeBlock::hasExitSite): (JSC::UnlinkedCodeBlock::exitProfile): * dfg/DFGByteCodeParser.cpp: (JSC::DFG::ByteCodeParser::InlineStackEntry::InlineStackEntry): * dfg/DFGGraph.h: (JSC::DFG::Graph::hasGlobalExitSite): (JSC::DFG::Graph::hasExitSite): * dfg/DFGLICMPhase.cpp: (JSC::DFG::LICMPhase::attemptHoist): * dfg/DFGOSRExitBase.cpp: (JSC::DFG::OSRExitBase::considerAddingAsFrequentExitSiteSlow): 2018-01-12 JF Bastien PoisonedWriteBarrier https://bugs.webkit.org/show_bug.cgi?id=181599 Reviewed by Mark Lam. Allow poisoning of WriteBarrier objects, and use this for WebAssembly because it is perf-neutral, at least on WasmBench on my MBP. If it indeed is perf-neutral according to the bots, start using it in more performance-sensitive places. * heap/HandleTypes.h: * heap/SlotVisitor.h: * heap/SlotVisitorInlines.h: (JSC::SlotVisitor::append): (JSC::SlotVisitor::appendHidden): * runtime/JSCJSValue.h: * runtime/JSCPoison.h: * runtime/Structure.h: * runtime/StructureInlines.h: (JSC::Structure::setPrototypeWithoutTransition): (JSC::Structure::setGlobalObject): (JSC::Structure::setPreviousID): * runtime/WriteBarrier.h: (JSC::WriteBarrierBase::copyFrom): (JSC::WriteBarrierBase::get const): (JSC::WriteBarrierBase::operator* const): (JSC::WriteBarrierBase::operator-> const): (JSC::WriteBarrierBase::clear): (JSC::WriteBarrierBase::slot): (JSC::WriteBarrierBase::operator bool const): (JSC::WriteBarrierBase::setWithoutWriteBarrier): (JSC::WriteBarrierBase::unvalidatedGet const): (JSC::operator==): * runtime/WriteBarrierInlines.h: (JSC::Traits>::set): (JSC::Traits>::setMayBeNull): (JSC::Traits>::setEarlyValue): (JSC::DumbValueTraits>::set): * wasm/WasmInstance.h: * wasm/js/JSWebAssemblyInstance.cpp: (JSC::JSWebAssemblyInstance::JSWebAssemblyInstance): (JSC::JSWebAssemblyInstance::finishCreation): (JSC::JSWebAssemblyInstance::visitChildren): (JSC::JSWebAssemblyInstance::create): * wasm/js/JSWebAssemblyInstance.h: (JSC::JSWebAssemblyInstance::offsetOfPoisonedCallee): * wasm/js/JSWebAssemblyMemory.h: * wasm/js/JSWebAssemblyModule.h: * wasm/js/JSWebAssemblyTable.cpp: (JSC::JSWebAssemblyTable::JSWebAssemblyTable): (JSC::JSWebAssemblyTable::grow): (JSC::JSWebAssemblyTable::clearFunction): * wasm/js/JSWebAssemblyTable.h: * wasm/js/WasmToJS.cpp: (JSC::Wasm::materializeImportJSCell): (JSC::Wasm::handleBadI64Use): (JSC::Wasm::wasmToJS): * wasm/js/WebAssemblyFunctionBase.h: * wasm/js/WebAssemblyModuleRecord.cpp: (JSC::WebAssemblyModuleRecord::link): (JSC::WebAssemblyModuleRecord::evaluate): * wasm/js/WebAssemblyModuleRecord.h: * wasm/js/WebAssemblyToJSCallee.h: * wasm/js/WebAssemblyWrapperFunction.h: 2018-01-12 Saam Barati CheckStructure can be incorrectly subsumed by CheckStructureOrEmpty https://bugs.webkit.org/show_bug.cgi?id=181177 Reviewed by Yusuke Suzuki. The semantics of CheckStructure are such that it does not allow the empty value to flow through it. However, we may eliminate a CheckStructure if it's preceded by a CheckStructureOrEmpty. This doesn't have semantic consequences when validation is turned off. However, with validation on, this trips up our OSR exit machinery that says when an exit is allowed to happen. Consider the following IR: a: GetClosureVar // Or any other node that produces BytecodeTop ... c: CheckStructure(Cell:@a, {s2}) d: PutByOffset(KnownCell:@a, KnownCell:@a, @value) In the TypeCheckHoistingPhase, we may insert CheckStructureOrEmptys like this: a: GetClosureVar e: CheckStructureOrEmpty(@a, {s1}) ... f: CheckStructureOrEmpty(@a, {s2}) c: CheckStructure(Cell:@a, {s2}) d: PutByOffset(KnownCell:@a, KnownCell:@a, @value) This will cause constant folding to change the IR to: a: GetClosureVar e: CheckStructureOrEmpty(@a, {s1}) ... f: CheckStructureOrEmpty(@a, {s2}) d: PutByOffset(KnownCell:@a, KnownCell:@a, @value) Our mayExit analysis determines that the PutByOffset should not exit. Note that AI will determine the only value the PutByOffset can see in @a is the empty value. Because KnownCell filters SpecCell and not SpecCellCheck, when lowering the PutByOffset, we reach a contradiction in AI and emit an OSR exit. However, because mayExit said we couldn't exit, we assert. Note that if we did not run the TypeCheckHoistingPhase on this IR, AI would have determined we would OSR exit at the second CheckStructure. This patch makes it so constant folding produces the following IR: a: GetClosureVar e: CheckStructureOrEmpty(@a, {s1}) g: AssertNotEmpty(@a) ... f: CheckStructureOrEmpty(@a, {s2}) h: AssertNotEmpty(@a) d: PutByOffset(KnownCell:@a, KnownCell:@a, @value) This modification will cause AI to know we will OSR exit before even reaching the PutByOffset. Note that in the original IR, the GetClosureVar won't actually produce the TDZ value. If it did, bytecode would have caused us to emit a CheckNotEmpty before the CheckStructure/PutByOffset combo. That's why this bug is about IR bookkeeping and not an actual error in IR analysis. This patch introduces AssertNotEmpty instead of using CheckNotEmpty to be more congruous with CheckStructure's semantics of crashing on the empty value as input (on 64 bit platforms). * dfg/DFGAbstractInterpreterInlines.h: (JSC::DFG::AbstractInterpreter::executeEffects): * 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): * dfg/DFGNodeType.h: * dfg/DFGPredictionPropagationPhase.cpp: * dfg/DFGSafeToExecute.h: (JSC::DFG::safeToExecute): * 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::compileAssertNotEmpty): 2018-01-12 Joseph Pecoraro Web Inspector: Remove unnecessary raw pointer in InspectorConsoleAgent https://bugs.webkit.org/show_bug.cgi?id=181579 Reviewed by Brian Burg. * inspector/agents/InspectorConsoleAgent.h: * inspector/agents/InspectorConsoleAgent.cpp: (Inspector::InspectorConsoleAgent::clearMessages): (Inspector::InspectorConsoleAgent::addConsoleMessage): Switch from a raw pointer to m_consoleMessages.last(). Also move the expiration check into the if block since it can only happen inside here when the number of console messages changes. (Inspector::InspectorConsoleAgent::discardValues): Also clear the expired message count when messages are cleared. 2018-01-12 Yusuke Suzuki [JSC] Create parallel SlotVisitors apriori https://bugs.webkit.org/show_bug.cgi?id=180907 Reviewed by Saam Barati. The number of SlotVisitors are capped with the number of HeapHelperPool's threads + 2. If we create these SlotVisitors apropri, we do not need to create SlotVisitors dynamically. Then we do not need to grab locks while iterating all the SlotVisitors. In addition, we do not need to consider the case that the number of SlotVisitors increases after setting up VisitCounters in MarkingConstraintSolver since the number of SlotVisitors does not increase any more. * heap/Heap.cpp: (JSC::Heap::Heap): (JSC::Heap::runBeginPhase): * heap/Heap.h: * heap/HeapInlines.h: (JSC::Heap::forEachSlotVisitor): (JSC::Heap::numberOfSlotVisitors): Deleted. * heap/MarkingConstraintSolver.cpp: (JSC::MarkingConstraintSolver::didVisitSomething const): 2018-01-12 Saam Barati Each variant of a polymorphic inlined call should be exitOK at the top of the block https://bugs.webkit.org/show_bug.cgi?id=181562 Reviewed by Yusuke Suzuki. Before this patch, the very first block in the switch for polymorphic call inlining will have exitOK at the top. The others are not guaranteed to. That was just a bug. They're all exitOK at the top. This will lead to crashes in FixupPhase because we won't have a node in a block that has ExitOK, so when we fixup various type checks, we assert out. * dfg/DFGByteCodeParser.cpp: (JSC::DFG::ByteCodeParser::handleInlining): 2018-01-11 Keith Miller Rename ENABLE_ASYNC_ITERATION to ENABLE_JS_ASYNC_ITERATION https://bugs.webkit.org/show_bug.cgi?id=181573 Reviewed by Simon Fraser. * Configurations/FeatureDefines.xcconfig: * runtime/Options.h: 2018-01-11 Michael Saboff REGRESSION(226788): AppStore Crashed @ JavaScriptCore: JSC::MacroAssemblerARM64::pushToSaveImmediateWithoutTouchingRegisters https://bugs.webkit.org/show_bug.cgi?id=181570 Reviewed by Keith Miller. * assembler/MacroAssemblerARM64.h: (JSC::MacroAssemblerARM64::abortWithReason): Reverting these functions to use dataTempRegister and memoryTempRegister as they are JIT release asserts that will crash the program. (JSC::MacroAssemblerARM64::pushToSaveImmediateWithoutTouchingRegisters): Changed this so that it invalidates any cached dataTmpRegister contents if temp register caching is enabled. 2018-01-11 Filip Pizlo Rename MarkedAllocator to BlockDirectory and AllocatorAttributes to CellAttributes https://bugs.webkit.org/show_bug.cgi?id=181543 Rubber stamped by Michael Saboff. In a world that has thread-local caches, the thing we now call the "MarkedAllocator" doesn't really have anything to do with allocation anymore. The allocation will be done by something in the TLC. When you move the allocation logic out of MarkedAllocator, it becomes just a place to find blocks (a "block directory"). Once we do that renaming, the term "allocator attributes" becomes weird. Those are really the attributes of the HeapCellType. So let's call them CellAttributes. * JavaScriptCore.xcodeproj/project.pbxproj: * Sources.txt: * bytecode/AccessCase.cpp: (JSC::AccessCase::generateImpl): * bytecode/ObjectAllocationProfile.h: * bytecode/ObjectAllocationProfileInlines.h: (JSC::ObjectAllocationProfile::initializeProfile): * dfg/DFGSpeculativeJIT.cpp: (JSC::DFG::SpeculativeJIT::emitAllocateRawObject): (JSC::DFG::SpeculativeJIT::compileMakeRope): (JSC::DFG::SpeculativeJIT::compileAllocatePropertyStorage): (JSC::DFG::SpeculativeJIT::compileReallocatePropertyStorage): (JSC::DFG::SpeculativeJIT::compileNewObject): * dfg/DFGSpeculativeJIT.h: (JSC::DFG::SpeculativeJIT::emitAllocateJSCell): (JSC::DFG::SpeculativeJIT::emitAllocateJSObject): * ftl/FTLAbstractHeapRepository.h: * ftl/FTLLowerDFGToB3.cpp: (JSC::FTL::DFG::LowerDFGToB3::compileMakeRope): (JSC::FTL::DFG::LowerDFGToB3::compileMaterializeNewObject): (JSC::FTL::DFG::LowerDFGToB3::allocatePropertyStorageWithSizeImpl): (JSC::FTL::DFG::LowerDFGToB3::allocateHeapCell): (JSC::FTL::DFG::LowerDFGToB3::allocateObject): (JSC::FTL::DFG::LowerDFGToB3::allocatorForSize): * heap/AlignedMemoryAllocator.cpp: (JSC::AlignedMemoryAllocator::registerDirectory): (JSC::AlignedMemoryAllocator::registerAllocator): Deleted. * heap/AlignedMemoryAllocator.h: (JSC::AlignedMemoryAllocator::firstDirectory const): (JSC::AlignedMemoryAllocator::firstAllocator const): Deleted. * heap/AllocatorAttributes.cpp: Removed. * heap/AllocatorAttributes.h: Removed. * heap/BlockDirectory.cpp: Copied from Source/JavaScriptCore/heap/MarkedAllocator.cpp. (JSC::BlockDirectory::BlockDirectory): (JSC::BlockDirectory::setSubspace): (JSC::BlockDirectory::isPagedOut): (JSC::BlockDirectory::findEmptyBlockToSteal): (JSC::BlockDirectory::didConsumeFreeList): (JSC::BlockDirectory::tryAllocateWithoutCollecting): (JSC::BlockDirectory::allocateIn): (JSC::BlockDirectory::tryAllocateIn): (JSC::BlockDirectory::doTestCollectionsIfNeeded): (JSC::BlockDirectory::allocateSlowCase): (JSC::BlockDirectory::blockSizeForBytes): (JSC::BlockDirectory::tryAllocateBlock): (JSC::BlockDirectory::addBlock): (JSC::BlockDirectory::removeBlock): (JSC::BlockDirectory::stopAllocating): (JSC::BlockDirectory::prepareForAllocation): (JSC::BlockDirectory::lastChanceToFinalize): (JSC::BlockDirectory::resumeAllocating): (JSC::BlockDirectory::beginMarkingForFullCollection): (JSC::BlockDirectory::endMarking): (JSC::BlockDirectory::snapshotUnsweptForEdenCollection): (JSC::BlockDirectory::snapshotUnsweptForFullCollection): (JSC::BlockDirectory::findBlockToSweep): (JSC::BlockDirectory::sweep): (JSC::BlockDirectory::shrink): (JSC::BlockDirectory::assertNoUnswept): (JSC::BlockDirectory::parallelNotEmptyBlockSource): (JSC::BlockDirectory::dump const): (JSC::BlockDirectory::dumpBits): (JSC::BlockDirectory::markedSpace const): (JSC::MarkedAllocator::MarkedAllocator): Deleted. (JSC::MarkedAllocator::setSubspace): Deleted. (JSC::MarkedAllocator::isPagedOut): Deleted. (JSC::MarkedAllocator::findEmptyBlockToSteal): Deleted. (JSC::MarkedAllocator::didConsumeFreeList): Deleted. (JSC::MarkedAllocator::tryAllocateWithoutCollecting): Deleted. (JSC::MarkedAllocator::allocateIn): Deleted. (JSC::MarkedAllocator::tryAllocateIn): Deleted. (JSC::MarkedAllocator::doTestCollectionsIfNeeded): Deleted. (JSC::MarkedAllocator::allocateSlowCase): Deleted. (JSC::MarkedAllocator::blockSizeForBytes): Deleted. (JSC::MarkedAllocator::tryAllocateBlock): Deleted. (JSC::MarkedAllocator::addBlock): Deleted. (JSC::MarkedAllocator::removeBlock): Deleted. (JSC::MarkedAllocator::stopAllocating): Deleted. (JSC::MarkedAllocator::prepareForAllocation): Deleted. (JSC::MarkedAllocator::lastChanceToFinalize): Deleted. (JSC::MarkedAllocator::resumeAllocating): Deleted. (JSC::MarkedAllocator::beginMarkingForFullCollection): Deleted. (JSC::MarkedAllocator::endMarking): Deleted. (JSC::MarkedAllocator::snapshotUnsweptForEdenCollection): Deleted. (JSC::MarkedAllocator::snapshotUnsweptForFullCollection): Deleted. (JSC::MarkedAllocator::findBlockToSweep): Deleted. (JSC::MarkedAllocator::sweep): Deleted. (JSC::MarkedAllocator::shrink): Deleted. (JSC::MarkedAllocator::assertNoUnswept): Deleted. (JSC::MarkedAllocator::parallelNotEmptyBlockSource): Deleted. (JSC::MarkedAllocator::dump const): Deleted. (JSC::MarkedAllocator::dumpBits): Deleted. (JSC::MarkedAllocator::markedSpace const): Deleted. * heap/BlockDirectory.h: Copied from Source/JavaScriptCore/heap/MarkedAllocator.h. (JSC::BlockDirectory::attributes const): (JSC::BlockDirectory::forEachBitVector): (JSC::BlockDirectory::forEachBitVectorWithName): (JSC::BlockDirectory::nextDirectory const): (JSC::BlockDirectory::nextDirectoryInSubspace const): (JSC::BlockDirectory::nextDirectoryInAlignedMemoryAllocator const): (JSC::BlockDirectory::setNextDirectory): (JSC::BlockDirectory::setNextDirectoryInSubspace): (JSC::BlockDirectory::setNextDirectoryInAlignedMemoryAllocator): (JSC::BlockDirectory::offsetOfFreeList): (JSC::BlockDirectory::offsetOfCellSize): (JSC::MarkedAllocator::cellSize const): Deleted. (JSC::MarkedAllocator::attributes const): Deleted. (JSC::MarkedAllocator::needsDestruction const): Deleted. (JSC::MarkedAllocator::destruction const): Deleted. (JSC::MarkedAllocator::cellKind const): Deleted. (JSC::MarkedAllocator::heap): Deleted. (JSC::MarkedAllocator::bitvectorLock): Deleted. (JSC::MarkedAllocator::forEachBitVector): Deleted. (JSC::MarkedAllocator::forEachBitVectorWithName): Deleted. (JSC::MarkedAllocator::nextAllocator const): Deleted. (JSC::MarkedAllocator::nextAllocatorInSubspace const): Deleted. (JSC::MarkedAllocator::nextAllocatorInAlignedMemoryAllocator const): Deleted. (JSC::MarkedAllocator::setNextAllocator): Deleted. (JSC::MarkedAllocator::setNextAllocatorInSubspace): Deleted. (JSC::MarkedAllocator::setNextAllocatorInAlignedMemoryAllocator): Deleted. (JSC::MarkedAllocator::subspace const): Deleted. (JSC::MarkedAllocator::freeList const): Deleted. (JSC::MarkedAllocator::offsetOfFreeList): Deleted. (JSC::MarkedAllocator::offsetOfCellSize): Deleted. * heap/BlockDirectoryInlines.h: Copied from Source/JavaScriptCore/heap/MarkedAllocatorInlines.h. (JSC::BlockDirectory::isFreeListedCell const): (JSC::BlockDirectory::allocate): (JSC::BlockDirectory::forEachBlock): (JSC::BlockDirectory::forEachNotEmptyBlock): (JSC::MarkedAllocator::isFreeListedCell const): Deleted. (JSC::MarkedAllocator::allocate): Deleted. (JSC::MarkedAllocator::forEachBlock): Deleted. (JSC::MarkedAllocator::forEachNotEmptyBlock): Deleted. * heap/CellAttributes.cpp: Copied from Source/JavaScriptCore/heap/AllocatorAttributes.cpp. (JSC::CellAttributes::dump const): (JSC::AllocatorAttributes::dump const): Deleted. * heap/CellAttributes.h: Copied from Source/JavaScriptCore/heap/AllocatorAttributes.h. (JSC::CellAttributes::CellAttributes): (JSC::AllocatorAttributes::AllocatorAttributes): Deleted. * heap/CompleteSubspace.cpp: (JSC::CompleteSubspace::allocatorFor): (JSC::CompleteSubspace::allocateNonVirtual): (JSC::CompleteSubspace::allocatorForSlow): (JSC::CompleteSubspace::tryAllocateSlow): * heap/CompleteSubspace.h: (JSC::CompleteSubspace::allocatorForSizeStep): (JSC::CompleteSubspace::allocatorForNonVirtual): * heap/GCDeferralContext.h: * heap/Heap.cpp: (JSC::Heap::updateAllocationLimits): * heap/Heap.h: * heap/HeapCell.h: * heap/HeapCellInlines.h: (JSC::HeapCell::cellAttributes const): (JSC::HeapCell::destructionMode const): (JSC::HeapCell::cellKind const): (JSC::HeapCell::allocatorAttributes const): Deleted. * heap/HeapCellType.cpp: (JSC::HeapCellType::HeapCellType): * heap/HeapCellType.h: (JSC::HeapCellType::attributes const): * heap/IncrementalSweeper.cpp: (JSC::IncrementalSweeper::IncrementalSweeper): (JSC::IncrementalSweeper::sweepNextBlock): (JSC::IncrementalSweeper::startSweeping): (JSC::IncrementalSweeper::stopSweeping): * heap/IncrementalSweeper.h: * heap/IsoCellSet.cpp: (JSC::IsoCellSet::IsoCellSet): (JSC::IsoCellSet::parallelNotEmptyMarkedBlockSource): (JSC::IsoCellSet::addSlow): (JSC::IsoCellSet::didRemoveBlock): (JSC::IsoCellSet::sweepToFreeList): * heap/IsoCellSetInlines.h: (JSC::IsoCellSet::forEachMarkedCell): (JSC::IsoCellSet::forEachLiveCell): * heap/IsoSubspace.cpp: (JSC::IsoSubspace::IsoSubspace): (JSC::IsoSubspace::allocatorFor): (JSC::IsoSubspace::allocateNonVirtual): * heap/IsoSubspace.h: (JSC::IsoSubspace::allocatorForNonVirtual): * heap/LargeAllocation.h: (JSC::LargeAllocation::attributes const): * heap/MarkedAllocator.cpp: Removed. * heap/MarkedAllocator.h: Removed. * heap/MarkedAllocatorInlines.h: Removed. * heap/MarkedBlock.cpp: (JSC::MarkedBlock::Handle::~Handle): (JSC::MarkedBlock::Handle::setIsFreeListed): (JSC::MarkedBlock::Handle::stopAllocating): (JSC::MarkedBlock::Handle::lastChanceToFinalize): (JSC::MarkedBlock::Handle::resumeAllocating): (JSC::MarkedBlock::aboutToMarkSlow): (JSC::MarkedBlock::Handle::didConsumeFreeList): (JSC::MarkedBlock::noteMarkedSlow): (JSC::MarkedBlock::Handle::removeFromDirectory): (JSC::MarkedBlock::Handle::didAddToDirectory): (JSC::MarkedBlock::Handle::didRemoveFromDirectory): (JSC::MarkedBlock::Handle::dumpState): (JSC::MarkedBlock::Handle::subspace const): (JSC::MarkedBlock::Handle::sweep): (JSC::MarkedBlock::Handle::isFreeListedCell const): (JSC::MarkedBlock::Handle::removeFromAllocator): Deleted. (JSC::MarkedBlock::Handle::didAddToAllocator): Deleted. (JSC::MarkedBlock::Handle::didRemoveFromAllocator): Deleted. * heap/MarkedBlock.h: (JSC::MarkedBlock::Handle::directory const): (JSC::MarkedBlock::Handle::attributes const): (JSC::MarkedBlock::attributes const): (JSC::MarkedBlock::Handle::allocator const): Deleted. * heap/MarkedBlockInlines.h: (JSC::MarkedBlock::Handle::isAllocated): (JSC::MarkedBlock::Handle::isLive): (JSC::MarkedBlock::Handle::specializedSweep): (JSC::MarkedBlock::Handle::isEmpty): * heap/MarkedSpace.cpp: (JSC::MarkedSpace::lastChanceToFinalize): (JSC::MarkedSpace::sweep): (JSC::MarkedSpace::stopAllocating): (JSC::MarkedSpace::resumeAllocating): (JSC::MarkedSpace::isPagedOut): (JSC::MarkedSpace::freeBlock): (JSC::MarkedSpace::shrink): (JSC::MarkedSpace::beginMarking): (JSC::MarkedSpace::endMarking): (JSC::MarkedSpace::snapshotUnswept): (JSC::MarkedSpace::assertNoUnswept): (JSC::MarkedSpace::dumpBits): (JSC::MarkedSpace::addBlockDirectory): (JSC::MarkedSpace::addMarkedAllocator): Deleted. * heap/MarkedSpace.h: (JSC::MarkedSpace::firstDirectory const): (JSC::MarkedSpace::directoryLock): (JSC::MarkedSpace::forEachBlock): (JSC::MarkedSpace::forEachDirectory): (JSC::MarkedSpace::firstAllocator const): Deleted. (JSC::MarkedSpace::allocatorLock): Deleted. (JSC::MarkedSpace::forEachAllocator): Deleted. * heap/MarkedSpaceInlines.h: * heap/Subspace.cpp: (JSC::Subspace::initialize): (JSC::Subspace::prepareForAllocation): (JSC::Subspace::findEmptyBlockToSteal): (JSC::Subspace::parallelDirectorySource): (JSC::Subspace::parallelNotEmptyMarkedBlockSource): (JSC::Subspace::sweep): (JSC::Subspace::parallelAllocatorSource): Deleted. * heap/Subspace.h: (JSC::Subspace::attributes const): (JSC::Subspace::didCreateFirstDirectory): (JSC::Subspace::didCreateFirstAllocator): Deleted. * heap/SubspaceInlines.h: (JSC::Subspace::forEachDirectory): (JSC::Subspace::forEachMarkedBlock): (JSC::Subspace::forEachNotEmptyMarkedBlock): (JSC::Subspace::forEachAllocator): Deleted. * jit/AssemblyHelpers.h: (JSC::AssemblyHelpers::emitAllocateWithNonNullAllocator): (JSC::AssemblyHelpers::emitAllocate): (JSC::AssemblyHelpers::emitAllocateJSCell): (JSC::AssemblyHelpers::emitAllocateJSObject): (JSC::AssemblyHelpers::emitAllocateJSObjectWithKnownSize): * jit/JIT.h: * jit/JITOpcodes.cpp: (JSC::JIT::emit_op_new_object): * jit/JITOpcodes32_64.cpp: (JSC::JIT::emit_op_new_object): * runtime/JSDestructibleObjectHeapCellType.cpp: (JSC::JSDestructibleObjectHeapCellType::JSDestructibleObjectHeapCellType): * runtime/JSSegmentedVariableObjectHeapCellType.cpp: (JSC::JSSegmentedVariableObjectHeapCellType::JSSegmentedVariableObjectHeapCellType): * runtime/JSStringHeapCellType.cpp: (JSC::JSStringHeapCellType::JSStringHeapCellType): * runtime/VM.cpp: (JSC::VM::VM): * wasm/js/JSWebAssemblyCodeBlockHeapCellType.cpp: (JSC::JSWebAssemblyCodeBlockHeapCellType::JSWebAssemblyCodeBlockHeapCellType): 2018-01-11 Saam Barati When inserting Unreachable in byte code parser we need to flush all the right things https://bugs.webkit.org/show_bug.cgi?id=181509 Reviewed by Mark Lam. I added code in r226655 that had its own mechanism for preserving liveness when inserting Unreachable nodes after ForceOSRExit. There are two ways to preserve liveness: PhantomLocal and Flush. Certain values *must* be flushed to the stack. I got some of these values wrong, which was leading to a crash when recovering the callee value from an inlined frame. Instead of making the same mistake and repeating similar code again, this patch refactors this logic to be shared with the other liveness preservation code in the DFG bytecode parser. This is what I should have done in my initial patch. * bytecode/InlineCallFrame.h: (JSC::remapOperand): * dfg/DFGByteCodeParser.cpp: (JSC::DFG::flushImpl): (JSC::DFG::flushForTerminalImpl): (JSC::DFG::ByteCodeParser::flush): (JSC::DFG::ByteCodeParser::flushForTerminal): (JSC::DFG::ByteCodeParser::parse): 2018-01-11 Saam Barati JITMathIC code in the FTL is wrong when code gets duplicated https://bugs.webkit.org/show_bug.cgi?id=181525 Reviewed by Michael Saboff and Keith Miller. B3/Air may duplicate code for various reasons. Patchpoint generators inside FTLLower must be aware that they can be called multiple times because of this. The patchpoint for math ICs was not aware of this, and shared state amongst all invocations of the patchpoint's generator. This patch fixes this bug so that each invocation of the patchpoint's generator gets a unique math IC. * bytecode/CodeBlock.h: (JSC::CodeBlock::addMathIC): * ftl/FTLLowerDFGToB3.cpp: (JSC::FTL::DFG::LowerDFGToB3::compileValueAdd): (JSC::FTL::DFG::LowerDFGToB3::compileUnaryMathIC): (JSC::FTL::DFG::LowerDFGToB3::compileBinaryMathIC): (JSC::FTL::DFG::LowerDFGToB3::compileArithAddOrSub): (JSC::FTL::DFG::LowerDFGToB3::compileArithMul): (JSC::FTL::DFG::LowerDFGToB3::compileArithNegate): (JSC::FTL::DFG::LowerDFGToB3::compileMathIC): Deleted. * jit/JITMathIC.h: (JSC::isProfileEmpty): 2018-01-11 Michael Saboff Ensure there are no unsafe uses of MacroAssemblerARM64::dataTempRegister https://bugs.webkit.org/show_bug.cgi?id=181512 Reviewed by Saam Barati. * assembler/MacroAssemblerARM64.h: (JSC::MacroAssemblerARM64::abortWithReason): (JSC::MacroAssemblerARM64::pushToSaveImmediateWithoutTouchingRegisters): All current uses of dataTempRegister in these functions are safe, but it makes sense to fix them in case they might be used elsewhere. 2018-01-04 Filip Pizlo CodeBlocks should be in IsoSubspaces https://bugs.webkit.org/show_bug.cgi?id=180884 Reviewed by Saam Barati. This moves CodeBlocks into IsoSubspaces. Doing so means that we no longer need to have the special CodeBlockSet HashSets of new and old CodeBlocks. We also no longer use WeakReferenceHarvester or UnconditionalFinalizer. Instead: - Code block sweeping is now just eager sweeping. This means that it automatically takes advantage of our unswept set, which roughly corresponds to what CodeBlockSet used to use its eden set for. - Those idea of Executable "weakly visiting" the CodeBlock is replaced by Executable marking a ExecutableToCodeBlockEdge object. That object being marked corresponds to what we used to call CodeBlock "having been weakly visited". This means that CodeBlockSet no longer has to clear the set of weakly visited code blocks. This also means that determining CodeBlock liveness, propagating CodeBlock transitions, and jettisoning CodeBlocks during GC are now the edge's job. The edge is also in an IsoSubspace and it has IsoCellSets to tell us which edges have output constraints (what we used to call CodeBlock's weak reference harvester) and which have unconditional finalizers. - CodeBlock now uses an IsoCellSet to tell if it has an unconditional finalizer. - CodeBlockSet still exists! It has one unified HashSet of CodeBlocks that we use to handle requests from the sampler, debugger, and other facilities. They may want to ask if some pointer corresponds to a CodeBlock during stages of execution during which the GC is unable to answer isLive() queries. The trickiest is the sampling profiler thread. There is no way that the GC's isLive could tell us of a CodeBlock that had already been allocated has now been full constructed. Rolling this back in because it was rolled out by mistake. There was a flaky crash that was happening before and after this change, but we misread the revision numbers at first and thought that this was the cause. * JavaScriptCore.xcodeproj/project.pbxproj: * Sources.txt: * bytecode/CodeBlock.cpp: (JSC::CodeBlock::CodeBlock): (JSC::CodeBlock::finishCreation): (JSC::CodeBlock::finishCreationCommon): (JSC::CodeBlock::~CodeBlock): (JSC::CodeBlock::visitChildren): (JSC::CodeBlock::propagateTransitions): (JSC::CodeBlock::determineLiveness): (JSC::CodeBlock::finalizeUnconditionally): (JSC::CodeBlock::stronglyVisitStrongReferences): (JSC::CodeBlock::hasInstalledVMTrapBreakpoints const): (JSC::CodeBlock::installVMTrapBreakpoints): (JSC::CodeBlock::dumpMathICStats): (JSC::CodeBlock::visitWeakly): Deleted. (JSC::CodeBlock::WeakReferenceHarvester::visitWeakReferences): Deleted. (JSC::CodeBlock::UnconditionalFinalizer::finalizeUnconditionally): Deleted. * bytecode/CodeBlock.h: (JSC::CodeBlock::subspaceFor): (JSC::CodeBlock::ownerEdge const): (JSC::CodeBlock::clearVisitWeaklyHasBeenCalled): Deleted. * bytecode/EvalCodeBlock.h: (JSC::EvalCodeBlock::create): Deleted. (JSC::EvalCodeBlock::createStructure): Deleted. (JSC::EvalCodeBlock::variable): Deleted. (JSC::EvalCodeBlock::numVariables): Deleted. (JSC::EvalCodeBlock::functionHoistingCandidate): Deleted. (JSC::EvalCodeBlock::numFunctionHoistingCandidates): Deleted. (JSC::EvalCodeBlock::EvalCodeBlock): Deleted. (JSC::EvalCodeBlock::unlinkedEvalCodeBlock const): Deleted. * bytecode/ExecutableToCodeBlockEdge.cpp: Added. (JSC::ExecutableToCodeBlockEdge::createStructure): (JSC::ExecutableToCodeBlockEdge::create): (JSC::ExecutableToCodeBlockEdge::visitChildren): (JSC::ExecutableToCodeBlockEdge::visitOutputConstraints): (JSC::ExecutableToCodeBlockEdge::finalizeUnconditionally): (JSC::ExecutableToCodeBlockEdge::activate): (JSC::ExecutableToCodeBlockEdge::deactivate): (JSC::ExecutableToCodeBlockEdge::deactivateAndUnwrap): (JSC::ExecutableToCodeBlockEdge::wrap): (JSC::ExecutableToCodeBlockEdge::wrapAndActivate): (JSC::ExecutableToCodeBlockEdge::ExecutableToCodeBlockEdge): (JSC::ExecutableToCodeBlockEdge::runConstraint): * bytecode/ExecutableToCodeBlockEdge.h: Added. (JSC::ExecutableToCodeBlockEdge::subspaceFor): (JSC::ExecutableToCodeBlockEdge::codeBlock const): (JSC::ExecutableToCodeBlockEdge::unwrap): * bytecode/FunctionCodeBlock.h: (JSC::FunctionCodeBlock::subspaceFor): (JSC::FunctionCodeBlock::createStructure): * bytecode/ModuleProgramCodeBlock.h: (JSC::ModuleProgramCodeBlock::create): Deleted. (JSC::ModuleProgramCodeBlock::createStructure): Deleted. (JSC::ModuleProgramCodeBlock::ModuleProgramCodeBlock): Deleted. * bytecode/ProgramCodeBlock.h: (JSC::ProgramCodeBlock::create): Deleted. (JSC::ProgramCodeBlock::createStructure): Deleted. (JSC::ProgramCodeBlock::ProgramCodeBlock): Deleted. * debugger/Debugger.cpp: (JSC::Debugger::SetSteppingModeFunctor::operator() const): (JSC::Debugger::ToggleBreakpointFunctor::operator() const): (JSC::Debugger::ClearCodeBlockDebuggerRequestsFunctor::operator() const): (JSC::Debugger::ClearDebuggerRequestsFunctor::operator() const): * heap/CodeBlockSet.cpp: (JSC::CodeBlockSet::contains): (JSC::CodeBlockSet::dump const): (JSC::CodeBlockSet::add): (JSC::CodeBlockSet::remove): (JSC::CodeBlockSet::promoteYoungCodeBlocks): Deleted. (JSC::CodeBlockSet::clearMarksForFullCollection): Deleted. (JSC::CodeBlockSet::lastChanceToFinalize): Deleted. (JSC::CodeBlockSet::deleteUnmarkedAndUnreferenced): Deleted. * heap/CodeBlockSet.h: * heap/CodeBlockSetInlines.h: (JSC::CodeBlockSet::iterate): (JSC::CodeBlockSet::iterateViaSubspaces): * heap/ConservativeRoots.cpp: (JSC::ConservativeRoots::genericAddPointer): (JSC::DummyMarkHook::markKnownJSCell): (JSC::CompositeMarkHook::mark): (JSC::CompositeMarkHook::markKnownJSCell): * heap/ConservativeRoots.h: * heap/Heap.cpp: (JSC::Heap::lastChanceToFinalize): (JSC::Heap::finalizeMarkedUnconditionalFinalizers): (JSC::Heap::finalizeUnconditionalFinalizers): (JSC::Heap::beginMarking): (JSC::Heap::deleteUnmarkedCompiledCode): (JSC::Heap::sweepInFinalize): (JSC::Heap::forEachCodeBlockImpl): (JSC::Heap::forEachCodeBlockIgnoringJITPlansImpl): (JSC::Heap::addCoreConstraints): (JSC::Heap::finalizeUnconditionalFinalizersInIsoSubspace): Deleted. * heap/Heap.h: * heap/HeapCell.h: * heap/HeapCellInlines.h: (JSC::HeapCell::subspace const): * heap/HeapInlines.h: (JSC::Heap::forEachCodeBlock): (JSC::Heap::forEachCodeBlockIgnoringJITPlans): * heap/HeapUtil.h: (JSC::HeapUtil::findGCObjectPointersForMarking): * heap/IsoCellSet.cpp: (JSC::IsoCellSet::parallelNotEmptyMarkedBlockSource): * heap/IsoCellSet.h: * heap/IsoCellSetInlines.h: (JSC::IsoCellSet::forEachMarkedCellInParallel): (JSC::IsoCellSet::forEachLiveCell): * heap/LargeAllocation.h: (JSC::LargeAllocation::subspace const): * heap/MarkStackMergingConstraint.cpp: (JSC::MarkStackMergingConstraint::executeImpl): * heap/MarkStackMergingConstraint.h: * heap/MarkedAllocator.cpp: (JSC::MarkedAllocator::parallelNotEmptyBlockSource): * heap/MarkedBlock.cpp: (JSC::MarkedBlock::Handle::didAddToAllocator): (JSC::MarkedBlock::Handle::didRemoveFromAllocator): * heap/MarkedBlock.h: (JSC::MarkedBlock::subspace const): * heap/MarkedBlockInlines.h: (JSC::MarkedBlock::Handle::forEachLiveCell): * heap/MarkedSpaceInlines.h: (JSC::MarkedSpace::forEachLiveCell): * heap/MarkingConstraint.cpp: (JSC::MarkingConstraint::execute): (JSC::MarkingConstraint::doParallelWork): (JSC::MarkingConstraint::finishParallelWork): Deleted. (JSC::MarkingConstraint::doParallelWorkImpl): Deleted. (JSC::MarkingConstraint::finishParallelWorkImpl): Deleted. * heap/MarkingConstraint.h: * heap/MarkingConstraintSet.cpp: (JSC::MarkingConstraintSet::add): * heap/MarkingConstraintSet.h: (JSC::MarkingConstraintSet::add): * heap/MarkingConstraintSolver.cpp: (JSC::MarkingConstraintSolver::execute): (JSC::MarkingConstraintSolver::addParallelTask): (JSC::MarkingConstraintSolver::runExecutionThread): (JSC::MarkingConstraintSolver::didExecute): Deleted. * heap/MarkingConstraintSolver.h: (JSC::MarkingConstraintSolver::TaskWithConstraint::TaskWithConstraint): (JSC::MarkingConstraintSolver::TaskWithConstraint::operator== const): * heap/SimpleMarkingConstraint.cpp: (JSC::SimpleMarkingConstraint::SimpleMarkingConstraint): (JSC::SimpleMarkingConstraint::executeImpl): * heap/SimpleMarkingConstraint.h: (JSC::SimpleMarkingConstraint::SimpleMarkingConstraint): * heap/SlotVisitor.cpp: (JSC::SlotVisitor::addParallelConstraintTask): * heap/SlotVisitor.h: * heap/Subspace.cpp: (JSC::Subspace::sweep): * heap/Subspace.h: * heap/SubspaceInlines.h: (JSC::Subspace::forEachLiveCell): * llint/LowLevelInterpreter.asm: * runtime/EvalExecutable.cpp: (JSC::EvalExecutable::visitChildren): * runtime/EvalExecutable.h: (JSC::EvalExecutable::codeBlock): * runtime/FunctionExecutable.cpp: (JSC::FunctionExecutable::baselineCodeBlockFor): (JSC::FunctionExecutable::visitChildren): * runtime/FunctionExecutable.h: * runtime/JSType.h: * runtime/ModuleProgramExecutable.cpp: (JSC::ModuleProgramExecutable::visitChildren): * runtime/ModuleProgramExecutable.h: * runtime/ProgramExecutable.cpp: (JSC::ProgramExecutable::visitChildren): * runtime/ProgramExecutable.h: * runtime/ScriptExecutable.cpp: (JSC::ScriptExecutable::installCode): (JSC::ScriptExecutable::newReplacementCodeBlockFor): * runtime/VM.cpp: (JSC::VM::VM): * runtime/VM.h: (JSC::VM::SpaceAndFinalizerSet::SpaceAndFinalizerSet): (JSC::VM::SpaceAndFinalizerSet::finalizerSetFor): (JSC::VM::forEachCodeBlockSpace): * runtime/VMTraps.cpp: (JSC::VMTraps::handleTraps): * tools/VMInspector.cpp: (JSC::VMInspector::codeBlockForMachinePC): (JSC::VMInspector::isValidCodeBlock): 2018-01-11 Michael Saboff Add a DOM gadget for Spectre testing https://bugs.webkit.org/show_bug.cgi?id=181351 Reviewed by Ryosuke Niwa. * runtime/Options.h: 2018-01-11 Yusuke Suzuki [DFG][FTL] regExpMatchFast should be handled https://bugs.webkit.org/show_bug.cgi?id=180988 Reviewed by Mark Lam. RegExp.prototype.@@match has a fast path, @regExpMatchFast. This patch annotates this function with RegExpMatchFastIntrinsic, and introduces RegExpMatch DFG node. This paves the way to make NewRegexp PhantomNewRegexp if it is not used except for setting/getting its lastIndex property. To improve RegExp.prototype.@@match's performance more, we make this builtin function small by moving slow path part to `@matchSlow()` private function. It improves SixSpeed regex-u.{es5,es6} largely since they stress String.prototype.match, which calls this regExpMatchFast function. baseline patched regex-u.es5 55.3835+-6.3002 ^ 36.2431+-2.0797 ^ definitely 1.5281x faster regex-u.es6 110.4624+-6.2896 ^ 94.1012+-7.2433 ^ definitely 1.1739x faster * builtins/RegExpPrototype.js: (globalPrivate.matchSlow): (overriddenName.string_appeared_here.match): * dfg/DFGAbstractInterpreterInlines.h: (JSC::DFG::AbstractInterpreter::executeEffects): * dfg/DFGByteCodeParser.cpp: (JSC::DFG::ByteCodeParser::handleIntrinsicCall): * dfg/DFGClobberize.h: (JSC::DFG::clobberize): * dfg/DFGDoesGC.cpp: (JSC::DFG::doesGC): * dfg/DFGFixupPhase.cpp: (JSC::DFG::FixupPhase::fixupNode): * 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::compileRegExpMatch): * 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::compileRegExpMatch): * runtime/Intrinsic.cpp: (JSC::intrinsicName): * runtime/Intrinsic.h: * runtime/JSGlobalObject.cpp: (JSC::JSGlobalObject::init): * runtime/RegExpPrototype.cpp: (JSC::regExpProtoFuncMatchFast): 2018-01-11 Saam Barati Our for-in caching is wrong when we add indexed properties on things in the prototype chain https://bugs.webkit.org/show_bug.cgi?id=181508 Reviewed by Yusuke Suzuki. Our for-in caching would cache structure chains that had prototypes with indexed properties. Clearly this is wrong. This caching breaks when a prototype adds new indexed properties. We would continue to enumerate the old cached state of properties, and not include the new indexed properties. The old code used to prevent caching only if the base structure had indexed properties. This patch extends it to prevent caching if the base, or any structure in the prototype chain, has indexed properties. * runtime/Structure.cpp: (JSC::Structure::canCachePropertyNameEnumerator const): 2018-01-10 JF Bastien Poison small JSObject derivatives which only contain pointers https://bugs.webkit.org/show_bug.cgi?id=181483 Reviewed by Mark Lam. I wrote a script that finds interesting things to poison or generally harden. These stood out because they derive from JSObject and only contain a few pointer or pointer-like fields, and could therefore just be poisoned. This also requires some template "improvements" to our poisoning machinery. Worth noting is that I'm making PoisonedUniquePtr move-assignable and move-constructible from unique_ptr, which makes it a better drop-in replacement because we don't need to use makePoisonedUniquePtr. This means function-locals can be unique_ptr and get the nice RAII pattern, and once the function is done you can just move to the class' PoisonedUniquePtr without worrying. * API/JSAPIWrapperObject.h: (JSC::JSAPIWrapperObject::wrappedObject): * API/JSAPIWrapperObject.mm: (JSC::JSAPIWrapperObject::JSAPIWrapperObject): * API/JSCallbackObject.h: * runtime/ArrayPrototype.h: * runtime/DateInstance.h: * runtime/JSArrayBuffer.cpp: (JSC::JSArrayBuffer::finishCreation): (JSC::JSArrayBuffer::isShared const): (JSC::JSArrayBuffer::sharingMode const): * runtime/JSArrayBuffer.h: * runtime/JSCPoison.h: 2018-01-10 Commit Queue Unreviewed, rolling out r226667 and r226673. https://bugs.webkit.org/show_bug.cgi?id=181488 This caused a flaky crash. (Requested by mlewis13 on #webkit). Reverted changesets: "CodeBlocks should be in IsoSubspaces" https://bugs.webkit.org/show_bug.cgi?id=180884 https://trac.webkit.org/changeset/226667 "REGRESSION (r226667): CodeBlocks should be in IsoSubspaces" https://bugs.webkit.org/show_bug.cgi?id=180884 https://trac.webkit.org/changeset/226673 2018-01-09 David Kilzer REGRESSION (r226667): CodeBlocks should be in IsoSubspaces Fixes the following build error: heap/Heap.cpp:2708:10: error: lambda capture 'this' is not used [-Werror,-Wunused-lambda-capture] * heap/Heap.cpp: (JSC::Heap::addCoreConstraints): Remove 'this' from lambda to fix the build. 2018-01-09 Keith Miller and32 with an Address source on ARM64 did not invalidate dataTempRegister https://bugs.webkit.org/show_bug.cgi?id=181467 Reviewed by Michael Saboff. * assembler/MacroAssemblerARM64.h: (JSC::MacroAssemblerARM64::and32): 2018-01-04 Filip Pizlo CodeBlocks should be in IsoSubspaces https://bugs.webkit.org/show_bug.cgi?id=180884 Reviewed by Saam Barati. This moves CodeBlocks into IsoSubspaces. Doing so means that we no longer need to have the special CodeBlockSet HashSets of new and old CodeBlocks. We also no longer use WeakReferenceHarvester or UnconditionalFinalizer. Instead: - Code block sweeping is now just eager sweeping. This means that it automatically takes advantage of our unswept set, which roughly corresponds to what CodeBlockSet used to use its eden set for. - Those idea of Executable "weakly visiting" the CodeBlock is replaced by Executable marking a ExecutableToCodeBlockEdge object. That object being marked corresponds to what we used to call CodeBlock "having been weakly visited". This means that CodeBlockSet no longer has to clear the set of weakly visited code blocks. This also means that determining CodeBlock liveness, propagating CodeBlock transitions, and jettisoning CodeBlocks during GC are now the edge's job. The edge is also in an IsoSubspace and it has IsoCellSets to tell us which edges have output constraints (what we used to call CodeBlock's weak reference harvester) and which have unconditional finalizers. - CodeBlock now uses an IsoCellSet to tell if it has an unconditional finalizer. - CodeBlockSet still exists! It has one unified HashSet of CodeBlocks that we use to handle requests from the sampler, debugger, and other facilities. They may want to ask if some pointer corresponds to a CodeBlock during stages of execution during which the GC is unable to answer isLive() queries. The trickiest is the sampling profiler thread. There is no way that the GC's isLive could tell us of a CodeBlock that had already been allocated has now been full constructed. * JavaScriptCore.xcodeproj/project.pbxproj: * Sources.txt: * bytecode/CodeBlock.cpp: (JSC::CodeBlock::CodeBlock): (JSC::CodeBlock::finishCreation): (JSC::CodeBlock::finishCreationCommon): (JSC::CodeBlock::~CodeBlock): (JSC::CodeBlock::visitChildren): (JSC::CodeBlock::propagateTransitions): (JSC::CodeBlock::determineLiveness): (JSC::CodeBlock::finalizeUnconditionally): (JSC::CodeBlock::stronglyVisitStrongReferences): (JSC::CodeBlock::hasInstalledVMTrapBreakpoints const): (JSC::CodeBlock::installVMTrapBreakpoints): (JSC::CodeBlock::dumpMathICStats): (JSC::CodeBlock::visitWeakly): Deleted. (JSC::CodeBlock::WeakReferenceHarvester::visitWeakReferences): Deleted. (JSC::CodeBlock::UnconditionalFinalizer::finalizeUnconditionally): Deleted. * bytecode/CodeBlock.h: (JSC::CodeBlock::subspaceFor): (JSC::CodeBlock::ownerEdge const): (JSC::CodeBlock::clearVisitWeaklyHasBeenCalled): Deleted. * bytecode/EvalCodeBlock.h: (JSC::EvalCodeBlock::create): Deleted. (JSC::EvalCodeBlock::createStructure): Deleted. (JSC::EvalCodeBlock::variable): Deleted. (JSC::EvalCodeBlock::numVariables): Deleted. (JSC::EvalCodeBlock::functionHoistingCandidate): Deleted. (JSC::EvalCodeBlock::numFunctionHoistingCandidates): Deleted. (JSC::EvalCodeBlock::EvalCodeBlock): Deleted. (JSC::EvalCodeBlock::unlinkedEvalCodeBlock const): Deleted. * bytecode/ExecutableToCodeBlockEdge.cpp: Added. (JSC::ExecutableToCodeBlockEdge::createStructure): (JSC::ExecutableToCodeBlockEdge::create): (JSC::ExecutableToCodeBlockEdge::visitChildren): (JSC::ExecutableToCodeBlockEdge::visitOutputConstraints): (JSC::ExecutableToCodeBlockEdge::finalizeUnconditionally): (JSC::ExecutableToCodeBlockEdge::activate): (JSC::ExecutableToCodeBlockEdge::deactivate): (JSC::ExecutableToCodeBlockEdge::deactivateAndUnwrap): (JSC::ExecutableToCodeBlockEdge::wrap): (JSC::ExecutableToCodeBlockEdge::wrapAndActivate): (JSC::ExecutableToCodeBlockEdge::ExecutableToCodeBlockEdge): (JSC::ExecutableToCodeBlockEdge::runConstraint): * bytecode/ExecutableToCodeBlockEdge.h: Added. (JSC::ExecutableToCodeBlockEdge::subspaceFor): (JSC::ExecutableToCodeBlockEdge::codeBlock const): (JSC::ExecutableToCodeBlockEdge::unwrap): * bytecode/FunctionCodeBlock.h: (JSC::FunctionCodeBlock::subspaceFor): (JSC::FunctionCodeBlock::createStructure): * bytecode/ModuleProgramCodeBlock.h: (JSC::ModuleProgramCodeBlock::create): Deleted. (JSC::ModuleProgramCodeBlock::createStructure): Deleted. (JSC::ModuleProgramCodeBlock::ModuleProgramCodeBlock): Deleted. * bytecode/ProgramCodeBlock.h: (JSC::ProgramCodeBlock::create): Deleted. (JSC::ProgramCodeBlock::createStructure): Deleted. (JSC::ProgramCodeBlock::ProgramCodeBlock): Deleted. * debugger/Debugger.cpp: (JSC::Debugger::SetSteppingModeFunctor::operator() const): (JSC::Debugger::ToggleBreakpointFunctor::operator() const): (JSC::Debugger::ClearCodeBlockDebuggerRequestsFunctor::operator() const): (JSC::Debugger::ClearDebuggerRequestsFunctor::operator() const): * heap/CodeBlockSet.cpp: (JSC::CodeBlockSet::contains): (JSC::CodeBlockSet::dump const): (JSC::CodeBlockSet::add): (JSC::CodeBlockSet::remove): (JSC::CodeBlockSet::promoteYoungCodeBlocks): Deleted. (JSC::CodeBlockSet::clearMarksForFullCollection): Deleted. (JSC::CodeBlockSet::lastChanceToFinalize): Deleted. (JSC::CodeBlockSet::deleteUnmarkedAndUnreferenced): Deleted. * heap/CodeBlockSet.h: * heap/CodeBlockSetInlines.h: (JSC::CodeBlockSet::iterate): (JSC::CodeBlockSet::iterateViaSubspaces): * heap/ConservativeRoots.cpp: (JSC::ConservativeRoots::genericAddPointer): (JSC::DummyMarkHook::markKnownJSCell): (JSC::CompositeMarkHook::mark): (JSC::CompositeMarkHook::markKnownJSCell): * heap/ConservativeRoots.h: * heap/Heap.cpp: (JSC::Heap::lastChanceToFinalize): (JSC::Heap::finalizeMarkedUnconditionalFinalizers): (JSC::Heap::finalizeUnconditionalFinalizers): (JSC::Heap::beginMarking): (JSC::Heap::deleteUnmarkedCompiledCode): (JSC::Heap::sweepInFinalize): (JSC::Heap::forEachCodeBlockImpl): (JSC::Heap::forEachCodeBlockIgnoringJITPlansImpl): (JSC::Heap::addCoreConstraints): (JSC::Heap::finalizeUnconditionalFinalizersInIsoSubspace): Deleted. * heap/Heap.h: * heap/HeapCell.h: * heap/HeapCellInlines.h: (JSC::HeapCell::subspace const): * heap/HeapInlines.h: (JSC::Heap::forEachCodeBlock): (JSC::Heap::forEachCodeBlockIgnoringJITPlans): * heap/HeapUtil.h: (JSC::HeapUtil::findGCObjectPointersForMarking): * heap/IsoCellSet.cpp: (JSC::IsoCellSet::parallelNotEmptyMarkedBlockSource): * heap/IsoCellSet.h: * heap/IsoCellSetInlines.h: (JSC::IsoCellSet::forEachMarkedCellInParallel): (JSC::IsoCellSet::forEachLiveCell): * heap/LargeAllocation.h: (JSC::LargeAllocation::subspace const): * heap/MarkStackMergingConstraint.cpp: (JSC::MarkStackMergingConstraint::executeImpl): * heap/MarkStackMergingConstraint.h: * heap/MarkedAllocator.cpp: (JSC::MarkedAllocator::parallelNotEmptyBlockSource): * heap/MarkedBlock.cpp: (JSC::MarkedBlock::Handle::didAddToAllocator): (JSC::MarkedBlock::Handle::didRemoveFromAllocator): * heap/MarkedBlock.h: (JSC::MarkedBlock::subspace const): * heap/MarkedBlockInlines.h: (JSC::MarkedBlock::Handle::forEachLiveCell): * heap/MarkedSpaceInlines.h: (JSC::MarkedSpace::forEachLiveCell): * heap/MarkingConstraint.cpp: (JSC::MarkingConstraint::execute): (JSC::MarkingConstraint::doParallelWork): (JSC::MarkingConstraint::finishParallelWork): Deleted. (JSC::MarkingConstraint::doParallelWorkImpl): Deleted. (JSC::MarkingConstraint::finishParallelWorkImpl): Deleted. * heap/MarkingConstraint.h: * heap/MarkingConstraintSet.cpp: (JSC::MarkingConstraintSet::add): * heap/MarkingConstraintSet.h: (JSC::MarkingConstraintSet::add): * heap/MarkingConstraintSolver.cpp: (JSC::MarkingConstraintSolver::execute): (JSC::MarkingConstraintSolver::addParallelTask): (JSC::MarkingConstraintSolver::runExecutionThread): (JSC::MarkingConstraintSolver::didExecute): Deleted. * heap/MarkingConstraintSolver.h: (JSC::MarkingConstraintSolver::TaskWithConstraint::TaskWithConstraint): (JSC::MarkingConstraintSolver::TaskWithConstraint::operator== const): * heap/SimpleMarkingConstraint.cpp: (JSC::SimpleMarkingConstraint::SimpleMarkingConstraint): (JSC::SimpleMarkingConstraint::executeImpl): * heap/SimpleMarkingConstraint.h: (JSC::SimpleMarkingConstraint::SimpleMarkingConstraint): * heap/SlotVisitor.cpp: (JSC::SlotVisitor::addParallelConstraintTask): * heap/SlotVisitor.h: * heap/Subspace.cpp: (JSC::Subspace::sweep): * heap/Subspace.h: * heap/SubspaceInlines.h: (JSC::Subspace::forEachLiveCell): * llint/LowLevelInterpreter.asm: * runtime/EvalExecutable.cpp: (JSC::EvalExecutable::visitChildren): * runtime/EvalExecutable.h: (JSC::EvalExecutable::codeBlock): * runtime/FunctionExecutable.cpp: (JSC::FunctionExecutable::baselineCodeBlockFor): (JSC::FunctionExecutable::visitChildren): * runtime/FunctionExecutable.h: * runtime/JSType.h: * runtime/ModuleProgramExecutable.cpp: (JSC::ModuleProgramExecutable::visitChildren): * runtime/ModuleProgramExecutable.h: * runtime/ProgramExecutable.cpp: (JSC::ProgramExecutable::visitChildren): * runtime/ProgramExecutable.h: * runtime/ScriptExecutable.cpp: (JSC::ScriptExecutable::installCode): (JSC::ScriptExecutable::newReplacementCodeBlockFor): * runtime/VM.cpp: (JSC::VM::VM): * runtime/VM.h: (JSC::VM::SpaceAndFinalizerSet::SpaceAndFinalizerSet): (JSC::VM::SpaceAndFinalizerSet::finalizerSetFor): (JSC::VM::forEachCodeBlockSpace): * runtime/VMTraps.cpp: (JSC::VMTraps::handleTraps): * tools/VMInspector.cpp: (JSC::VMInspector::codeBlockForMachinePC): (JSC::VMInspector::isValidCodeBlock): 2018-01-09 Michael Saboff Unreviewed, rolling out r226600 and r226603 https://bugs.webkit.org/show_bug.cgi?id=181351 Add a DOM gadget for Spectre testing * runtime/Options.h: 2018-01-09 Saam Barati Reduce graph size by replacing terminal nodes in blocks that have a ForceOSRExit with Unreachable https://bugs.webkit.org/show_bug.cgi?id=181409 Reviewed by Keith Miller. When I was looking at profiler data for Speedometer, I noticed that one of the hottest functions in Speedometer is around 1100 bytecode operations long. Only about 100 of those bytecode ops ever execute. However, we ended up spending a lot of time compiling basic blocks that never executed. We often plant ForceOSRExit nodes when we parse bytecodes that have a null value profile. This is the case when such a node never executes. This patch makes it so that anytime a block has a ForceOSRExit, we replace its terminal node with an Unreachable node (and remove all nodes after the ForceOSRExit). This will cut down on graph size when such a block dominates other blocks in the CFG. This allows us to get rid of huge chunks of the CFG in certain programs. When doing this transformation, we also insert Flushes/PhantomLocals to ensure we can recover values that are bytecode live-in to the ForceOSRExit. Using ForceOSRExit as the signal for this is a bit of a hack. It definitely does not get rid of all the CFG that it could. If we decide it's worth it, we could use additional inputs into this mechanism. For example, we could profile if a basic block ever executes inside the LLInt/Baseline, and remove parts of the CFG based on that. When running Speedometer with the concurrent JIT turned off, this patch improves DFG/FTL compile times by around 5%. * dfg/DFGByteCodeParser.cpp: (JSC::DFG::ByteCodeParser::addToGraph): (JSC::DFG::ByteCodeParser::parse): 2018-01-09 Mark Lam ASSERTION FAILED: pair.second->m_type & PropertyNode::Getter https://bugs.webkit.org/show_bug.cgi?id=181388 Reviewed by Saam Barati. When there are duplicate setters or getters, we may end up overwriting a getter with a setter, or vice versa. This patch adds tracking for getters/setters that have been overwritten with duplicates and ignore them. * bytecompiler/NodesCodegen.cpp: (JSC::PropertyListNode::emitBytecode): * parser/NodeConstructors.h: (JSC::PropertyNode::PropertyNode): * parser/Nodes.h: (JSC::PropertyNode::isOverriddenByDuplicate const): (JSC::PropertyNode::setIsOverriddenByDuplicate): 2018-01-08 Zan Dobersek REGRESSION(r225913): about 30 JSC test failures on ARMv7 https://bugs.webkit.org/show_bug.cgi?id=181162 Unreviewed follow-up to r226298. Enable the fast case in DFG::SpeculativeJIT::compileArraySlice() for any 64-bit platform, assuming in good faith that enough GP registers are available on any such configuration. The accompanying comment is adjusted to describe this assumption. * dfg/DFGSpeculativeJIT.cpp: (JSC::DFG::SpeculativeJIT::compileArraySlice): 2018-01-08 JF Bastien WebAssembly: mask indexed accesses to Table https://bugs.webkit.org/show_bug.cgi?id=181412 Reviewed by Saam Barati. WebAssembly Table indexed accesses are user-controlled and bounds-checked. Force allocations of Table data to be a power-of-two, and explicitly mask accesses after bounds-check branches. Rename misleading usage of "size" when "length" of a Table was intended. Rename the Spectre option from "disable" to "enable". * dfg/DFGSpeculativeJIT.cpp: (JSC::DFG::SpeculativeJIT::SpeculativeJIT): * ftl/FTLLowerDFGToB3.cpp: (JSC::FTL::DFG::LowerDFGToB3::LowerDFGToB3): * jit/JIT.cpp: (JSC::JIT::JIT): * runtime/Options.h: * wasm/WasmB3IRGenerator.cpp: (JSC::Wasm::B3IRGenerator::emitCheckAndPreparePointer): (JSC::Wasm::B3IRGenerator::addCallIndirect): * wasm/WasmTable.cpp: (JSC::Wasm::Table::allocatedLength): (JSC::Wasm::Table::setLength): (JSC::Wasm::Table::create): (JSC::Wasm::Table::Table): (JSC::Wasm::Table::grow): (JSC::Wasm::Table::clearFunction): (JSC::Wasm::Table::setFunction): * wasm/WasmTable.h: (JSC::Wasm::Table::length const): (JSC::Wasm::Table::offsetOfLength): (JSC::Wasm::Table::offsetOfMask): (JSC::Wasm::Table::mask const): (JSC::Wasm::Table::isValidLength): * wasm/js/JSWebAssemblyInstance.cpp: (JSC::JSWebAssemblyInstance::create): * wasm/js/JSWebAssemblyTable.cpp: (JSC::JSWebAssemblyTable::JSWebAssemblyTable): (JSC::JSWebAssemblyTable::visitChildren): (JSC::JSWebAssemblyTable::grow): (JSC::JSWebAssemblyTable::getFunction): (JSC::JSWebAssemblyTable::clearFunction): (JSC::JSWebAssemblyTable::setFunction): * wasm/js/JSWebAssemblyTable.h: (JSC::JSWebAssemblyTable::isValidLength): (JSC::JSWebAssemblyTable::length const): (JSC::JSWebAssemblyTable::allocatedLength const): * wasm/js/WebAssemblyModuleRecord.cpp: (JSC::WebAssemblyModuleRecord::evaluate): * wasm/js/WebAssemblyTablePrototype.cpp: (JSC::webAssemblyTableProtoFuncLength): (JSC::webAssemblyTableProtoFuncGrow): (JSC::webAssemblyTableProtoFuncGet): (JSC::webAssemblyTableProtoFuncSet): 2018-01-08 Michael Saboff Add a DOM gadget for Spectre testing https://bugs.webkit.org/show_bug.cgi?id=181351 Reviewed by Michael Saboff. Added a new JSC::Option named enableSpectreGadgets to enable any gadgets added to test Spectre mitigations. * runtime/Options.h: 2018-01-08 Mark Lam Rename CodeBlock::m_vm to CodeBlock::m_poisonedVM. https://bugs.webkit.org/show_bug.cgi?id=181403 Rubber-stamped by JF Bastien. * bytecode/CodeBlock.cpp: (JSC::CodeBlock::CodeBlock): (JSC::CodeBlock::~CodeBlock): (JSC::CodeBlock::setConstantRegisters): (JSC::CodeBlock::propagateTransitions): (JSC::CodeBlock::finalizeLLIntInlineCaches): (JSC::CodeBlock::jettison): (JSC::CodeBlock::predictedMachineCodeSize): * bytecode/CodeBlock.h: (JSC::CodeBlock::vm const): (JSC::CodeBlock::addConstant): (JSC::CodeBlock::heap const): (JSC::CodeBlock::replaceConstant): * llint/LowLevelInterpreter.asm: * llint/LowLevelInterpreter32_64.asm: * llint/LowLevelInterpreter64.asm: 2018-01-07 Mark Lam Apply poisoning to more pointers in JSC. https://bugs.webkit.org/show_bug.cgi?id=181096 Reviewed by JF Bastien. * assembler/MacroAssembler.h: (JSC::MacroAssembler::xorPtr): * assembler/MacroAssemblerARM64.h: (JSC::MacroAssemblerARM64::xor64): * assembler/MacroAssemblerX86_64.h: (JSC::MacroAssemblerX86_64::xor64): - Add xorPtr implementation. * bytecode/CodeBlock.cpp: (JSC::CodeBlock::inferredName const): (JSC::CodeBlock::CodeBlock): (JSC::CodeBlock::finishCreation): (JSC::CodeBlock::~CodeBlock): (JSC::CodeBlock::setConstantRegisters): (JSC::CodeBlock::visitWeakly): (JSC::CodeBlock::visitChildren): (JSC::CodeBlock::propagateTransitions): (JSC::CodeBlock::WeakReferenceHarvester::visitWeakReferences): (JSC::CodeBlock::finalizeLLIntInlineCaches): (JSC::CodeBlock::finalizeBaselineJITInlineCaches): (JSC::CodeBlock::UnconditionalFinalizer::finalizeUnconditionally): (JSC::CodeBlock::jettison): (JSC::CodeBlock::predictedMachineCodeSize): (JSC::CodeBlock::findPC): * bytecode/CodeBlock.h: (JSC::CodeBlock::UnconditionalFinalizer::UnconditionalFinalizer): (JSC::CodeBlock::WeakReferenceHarvester::WeakReferenceHarvester): (JSC::CodeBlock::stubInfoBegin): (JSC::CodeBlock::stubInfoEnd): (JSC::CodeBlock::callLinkInfosBegin): (JSC::CodeBlock::callLinkInfosEnd): (JSC::CodeBlock::instructions): (JSC::CodeBlock::instructions const): (JSC::CodeBlock::vm const): * dfg/DFGOSRExitCompilerCommon.h: (JSC::DFG::adjustFrameAndStackInOSRExitCompilerThunk): * jit/JIT.h: * llint/LLIntOfflineAsmConfig.h: * llint/LowLevelInterpreter.asm: * llint/LowLevelInterpreter64.asm: * parser/UnlinkedSourceCode.h: * runtime/JSCPoison.h: * runtime/JSGlobalObject.cpp: (JSC::JSGlobalObject::init): * runtime/JSGlobalObject.h: * runtime/JSScriptFetchParameters.h: * runtime/JSScriptFetcher.h: * runtime/StructureTransitionTable.h: * wasm/js/JSWebAssemblyCodeBlock.cpp: (JSC::JSWebAssemblyCodeBlock::JSWebAssemblyCodeBlock): (JSC::JSWebAssemblyCodeBlock::visitChildren): (JSC::JSWebAssemblyCodeBlock::UnconditionalFinalizer::finalizeUnconditionally): * wasm/js/JSWebAssemblyCodeBlock.h: 2018-01-06 Yusuke Suzuki Object.getOwnPropertyNames includes "arguments" and "caller" for bound functions https://bugs.webkit.org/show_bug.cgi?id=181321 Reviewed by Saam Barati. According to ECMA262 16.2[1], functions created using the bind method must not have "caller" and "arguments" own properties. [1]: https://tc39.github.io/ecma262/#sec-forbidden-extensions * runtime/JSBoundFunction.cpp: (JSC::JSBoundFunction::finishCreation): 2018-01-05 JF Bastien WebAssembly: poison JS object's secrets https://bugs.webkit.org/show_bug.cgi?id=181339 Reviewed by Mark Lam. Separating WebAssembly's JS objects from their non-JS implementation means that all interesting information lives outside of the JS object itself. This patch poisons each JS object's pointer to non-JS implementation using the poisoning mechanism and a unique key per JS object type origin. * runtime/JSCPoison.h: * wasm/js/JSToWasm.cpp: (JSC::Wasm::createJSToWasmWrapper): JS -> wasm stores the JS object in a stack slot when fast TLS is disabled. This requires that we unpoison the Wasm::Instance. * wasm/js/JSWebAssemblyCodeBlock.h: * wasm/js/JSWebAssemblyInstance.h: (JSC::JSWebAssemblyInstance::offsetOfPoisonedInstance): renamed to be explicit that the pointer is poisoned. * wasm/js/JSWebAssemblyMemory.h: * wasm/js/JSWebAssemblyModule.h: * wasm/js/JSWebAssemblyTable.h: 2018-01-05 Michael Saboff Add ability to disable indexed property masking for testing https://bugs.webkit.org/show_bug.cgi?id=181350 Reviewed by Keith Miller. Made the masking of indexed properties runtime controllable via a new JSC::Option named disableSpectreMitigations. This is done to test the efficacy of that mitigation. The new option has a generic name as it will probably be used to disable future mitigations. * dfg/DFGSpeculativeJIT.cpp: (JSC::DFG::SpeculativeJIT::SpeculativeJIT): (JSC::DFG::SpeculativeJIT::loadFromIntTypedArray): (JSC::DFG::SpeculativeJIT::compileGetByValOnFloatTypedArray): * dfg/DFGSpeculativeJIT.h: * dfg/DFGSpeculativeJIT64.cpp: (JSC::DFG::SpeculativeJIT::compile): * ftl/FTLLowerDFGToB3.cpp: (JSC::FTL::DFG::LowerDFGToB3::LowerDFGToB3): (JSC::FTL::DFG::LowerDFGToB3::maskedIndex): (JSC::FTL::DFG::LowerDFGToB3::pointerIntoTypedArray): * jit/JIT.cpp: (JSC::JIT::JIT): * jit/JIT.h: * jit/JITPropertyAccess.cpp: (JSC::JIT::emitDoubleLoad): (JSC::JIT::emitContiguousLoad): (JSC::JIT::emitArrayStorageLoad): * runtime/Options.h: * wasm/WasmB3IRGenerator.cpp: (JSC::Wasm::B3IRGenerator::emitCheckAndPreparePointer): 2018-01-05 Michael Saboff Allow JSC Config Files to set Restricted Options https://bugs.webkit.org/show_bug.cgi?id=181352 Reviewed by Mark Lam. * runtime/ConfigFile.cpp: (JSC::ConfigFile::parse): 2018-01-04 Keith Miller TypedArrays and Wasm should use index masking. https://bugs.webkit.org/show_bug.cgi?id=181313 Reviewed by Michael Saboff. We should have index masking for our TypedArray code in the DFG/FTL and for Wasm when doing bounds checking. Index masking for Wasm is added to the WasmBoundsCheckValue. Since we don't CSE any WasmBoundsCheckValues we don't need to worry about combining a bounds check for a load and a store. I went with fusing the pointer masking in the WasmBoundsCheckValue since it should reduce additional compiler overhead. * b3/B3LowerToAir.cpp: * b3/B3Validate.cpp: * b3/B3WasmBoundsCheckValue.cpp: (JSC::B3::WasmBoundsCheckValue::WasmBoundsCheckValue): (JSC::B3::WasmBoundsCheckValue::dumpMeta const): * b3/B3WasmBoundsCheckValue.h: (JSC::B3::WasmBoundsCheckValue::pinnedIndexingMask const): * b3/air/AirCustom.h: (JSC::B3::Air::WasmBoundsCheckCustom::generate): * b3/testb3.cpp: (JSC::B3::testWasmBoundsCheck): * dfg/DFGSpeculativeJIT.cpp: (JSC::DFG::SpeculativeJIT::emitAllocateRawObject): (JSC::DFG::SpeculativeJIT::loadFromIntTypedArray): (JSC::DFG::SpeculativeJIT::compileGetByValOnIntTypedArray): (JSC::DFG::SpeculativeJIT::compileGetByValOnFloatTypedArray): (JSC::DFG::SpeculativeJIT::compileNewTypedArrayWithSize): * dfg/DFGSpeculativeJIT.h: * dfg/DFGSpeculativeJIT64.cpp: (JSC::DFG::SpeculativeJIT::compile): * ftl/FTLLowerDFGToB3.cpp: (JSC::FTL::DFG::LowerDFGToB3::compileAtomicsReadModifyWrite): (JSC::FTL::DFG::LowerDFGToB3::compileGetByVal): (JSC::FTL::DFG::LowerDFGToB3::compileNewTypedArray): (JSC::FTL::DFG::LowerDFGToB3::pointerIntoTypedArray): * jit/JITPropertyAccess.cpp: (JSC::JIT::emitIntTypedArrayGetByVal): * runtime/Butterfly.h: (JSC::Butterfly::computeIndexingMask const): (JSC::Butterfly::computeIndexingMaskForVectorLength): Deleted. * runtime/JSArrayBufferView.cpp: (JSC::JSArrayBufferView::JSArrayBufferView): * wasm/WasmB3IRGenerator.cpp: (JSC::Wasm::B3IRGenerator::B3IRGenerator): (JSC::Wasm::B3IRGenerator::restoreWebAssemblyGlobalState): (JSC::Wasm::B3IRGenerator::emitCheckAndPreparePointer): (JSC::Wasm::B3IRGenerator::load): (JSC::Wasm::B3IRGenerator::store): (JSC::Wasm::B3IRGenerator::addCallIndirect): * wasm/WasmBinding.cpp: (JSC::Wasm::wasmToWasm): * wasm/WasmMemory.cpp: (JSC::Wasm::Memory::Memory): (JSC::Wasm::Memory::grow): * wasm/WasmMemory.h: (JSC::Wasm::Memory::offsetOfIndexingMask): * wasm/WasmMemoryInformation.cpp: (JSC::Wasm::PinnedRegisterInfo::get): (JSC::Wasm::PinnedRegisterInfo::PinnedRegisterInfo): * wasm/WasmMemoryInformation.h: (JSC::Wasm::PinnedRegisterInfo::toSave const): * wasm/js/JSToWasm.cpp: (JSC::Wasm::createJSToWasmWrapper): 2018-01-05 Commit Queue Unreviewed, rolling out r226434. https://bugs.webkit.org/show_bug.cgi?id=181322 32bit JSC failure in x86 (Requested by yusukesuzuki on #webkit). Reverted changeset: "[DFG] Unify ToNumber implementation in 32bit and 64bit by changing 32bit Int32Tag and LowestTag" https://bugs.webkit.org/show_bug.cgi?id=181134 https://trac.webkit.org/changeset/226434 2018-01-04 Devin Rousso Web Inspector: replace HTMLCanvasElement with CanvasRenderingContext for instrumentation logic https://bugs.webkit.org/show_bug.cgi?id=180770 Reviewed by Joseph Pecoraro. * inspector/protocol/Canvas.json: 2018-01-04 Commit Queue Unreviewed, rolling out r226405. https://bugs.webkit.org/show_bug.cgi?id=181318 Speculative rollout due to Octane/SplayLatency,Octane/Splay regressions (Requested by yusukesuzuki on #webkit). Reverted changeset: "[JSC] Create parallel SlotVisitors apriori" https://bugs.webkit.org/show_bug.cgi?id=180907 https://trac.webkit.org/changeset/226405 2018-01-04 Saam Barati Do value profiling in to_this https://bugs.webkit.org/show_bug.cgi?id=181299 Reviewed by Filip Pizlo. This patch adds value profiling to to_this. We use the result of the value profiling only for strict mode code when we don't predict that the input is of a specific type. This helps when the input is SpecCellOther. Such cells might implement a custom ToThis, which can produce an arbitrary result. Before this patch, in prediction propagation, we were saying that a ToThis with a SpecCellOther input also produced SpecCellOther. However, this is incorrect, given that the input may implement ToThis that produces an arbitrary result. This is seen inside Speedometer. This patch fixes an OSR exit loop in Speedometer. Interestingly, this patch only does value profiling on the slow path. The fast path of to_this in the LLInt/baseline just perform a structure check. If it passes, the result is the same as the input. Therefore, doing value profiling from the fast path wouldn't actually produce new information for the ValueProfile. * bytecode/BytecodeDumper.cpp: (JSC::BytecodeDumper::dumpBytecode): * bytecode/BytecodeList.json: * bytecode/CodeBlock.cpp: (JSC::CodeBlock::finishCreation): * bytecompiler/BytecodeGenerator.cpp: (JSC::BytecodeGenerator::BytecodeGenerator): (JSC::BytecodeGenerator::emitToThis): * bytecompiler/BytecodeGenerator.h: * dfg/DFGByteCodeParser.cpp: (JSC::DFG::ByteCodeParser::parseBlock): * dfg/DFGNode.h: (JSC::DFG::Node::hasHeapPrediction): * dfg/DFGPredictionPropagationPhase.cpp: * runtime/CommonSlowPaths.cpp: (JSC::SLOW_PATH_DECL): 2018-01-04 Yusuke Suzuki [DFG] Unify ToNumber implementation in 32bit and 64bit by changing 32bit Int32Tag and LowestTag https://bugs.webkit.org/show_bug.cgi?id=181134 Reviewed by Mark Lam. We would like to unify DFG ToNumber implementation in 32bit and 64bit. One problem is that branchIfNumber signature is different between 32bit and 64bit. 32bit implementation requires an additional scratch register. We do not want to allocate an unnecessary register in 64bit implementation. This patch removes the additional register in branchIfNumber/branchIfNotNumber in both 32bit and 64bit implementation. To achieve this goal, we change Int32Tag and LowestTag order. By setting Int32Tag as LowestTag, we can query whether the given tag is a number by checking `<= LowestTag(Int32Tag)`. We also change the order of UndefinedTag, NullTag, and BooleanTag to keep `(UndefinedTag | 1) == NullTag`. We also clean up speculateMisc implementation by adding branchIfMisc/branchIfNotMisc. * dfg/DFGSpeculativeJIT.cpp: (JSC::DFG::SpeculativeJIT::compileValueToInt32): (JSC::DFG::SpeculativeJIT::compileDoubleRep): (JSC::DFG::SpeculativeJIT::speculateNumber): (JSC::DFG::SpeculativeJIT::speculateMisc): (JSC::DFG::SpeculativeJIT::compileNormalizeMapKey): (JSC::DFG::SpeculativeJIT::compileToNumber): * dfg/DFGSpeculativeJIT.h: * dfg/DFGSpeculativeJIT32_64.cpp: (JSC::DFG::SpeculativeJIT::nonSpeculativeNonPeepholeCompareNullOrUndefined): (JSC::DFG::SpeculativeJIT::nonSpeculativePeepholeBranchNullOrUndefined): (JSC::DFG::SpeculativeJIT::compileObjectOrOtherLogicalNot): (JSC::DFG::SpeculativeJIT::emitObjectOrOtherBranch): (JSC::DFG::SpeculativeJIT::compile): * dfg/DFGSpeculativeJIT64.cpp: (JSC::DFG::SpeculativeJIT::compile): * jit/AssemblyHelpers.cpp: (JSC::AssemblyHelpers::branchIfNotType): (JSC::AssemblyHelpers::jitAssertIsJSNumber): (JSC::AssemblyHelpers::emitConvertValueToBoolean): * jit/AssemblyHelpers.h: (JSC::AssemblyHelpers::branchIfMisc): (JSC::AssemblyHelpers::branchIfNotMisc): (JSC::AssemblyHelpers::branchIfNumber): (JSC::AssemblyHelpers::branchIfNotNumber): (JSC::AssemblyHelpers::branchIfNotDoubleKnownNotInt32): (JSC::AssemblyHelpers::emitTypeOf): * jit/JITAddGenerator.cpp: (JSC::JITAddGenerator::generateFastPath): * jit/JITArithmetic32_64.cpp: (JSC::JIT::emitBinaryDoubleOp): * jit/JITDivGenerator.cpp: (JSC::JITDivGenerator::loadOperand): * jit/JITMulGenerator.cpp: (JSC::JITMulGenerator::generateInline): (JSC::JITMulGenerator::generateFastPath): * jit/JITNegGenerator.cpp: (JSC::JITNegGenerator::generateInline): (JSC::JITNegGenerator::generateFastPath): * jit/JITOpcodes32_64.cpp: (JSC::JIT::emit_op_is_number): (JSC::JIT::emit_op_jeq_null): (JSC::JIT::emit_op_jneq_null): (JSC::JIT::emit_op_to_number): (JSC::JIT::emit_op_profile_type): * jit/JITRightShiftGenerator.cpp: (JSC::JITRightShiftGenerator::generateFastPath): * jit/JITSubGenerator.cpp: (JSC::JITSubGenerator::generateInline): (JSC::JITSubGenerator::generateFastPath): * llint/LLIntData.cpp: (JSC::LLInt::Data::performAssertions): * llint/LowLevelInterpreter.asm: * llint/LowLevelInterpreter32_64.asm: * runtime/JSCJSValue.h: 2018-01-04 JF Bastien Add assembler support for x86 lfence and sfence https://bugs.webkit.org/show_bug.cgi?id=181311 Reviewed by Michael Saboff. Useful for testing performance of serializing instructions (hint: it's not good). * assembler/MacroAssemblerX86Common.h: (JSC::MacroAssemblerX86Common::lfence): (JSC::MacroAssemblerX86Common::sfence): * assembler/X86Assembler.h: (JSC::X86Assembler::lfence): (JSC::X86Assembler::sfence): 2018-01-04 Saam Barati Add a new pattern matching rule to Graph::methodOfGettingAValueProfileFor for SetLocal(@nodeWithHeapPrediction) https://bugs.webkit.org/show_bug.cgi?id=181296 Reviewed by Filip Pizlo. Inside Speedometer's Ember test, there is a recompile loop like: a: GetByVal(..., semanticOriginX) b: SetLocal(Cell:@a, semanticOriginX) where the cell check always fails. For reasons I didn't investigate, the baseline JIT's value profiling doesn't accurately capture the GetByVal's result. However, when compiling this cell speculation check in the DFG, we get a null MethodOfGettingAValueProfile inside Graph::methodOfGettingAValueProfileFor for this IR pattern because both @a and @b have the same semantic origin. We should not follow the same semantic origin heuristic when dealing with SetLocal since SetLocal(@nodeWithHeapPrediction) is such a common IR pattern. For patterns like this, we introduce a new heuristic: @NodeThatDoesNotProduceAValue(@nodeWithHeapPrediction). For this IR pattern, we will update the value profile for the semantic origin for @nodeWithHeapPrediction. So, for the Speedometer example above, we will correctly update the GetByVal's value profile, which will prevent an OSR exit loop. * dfg/DFGGraph.cpp: (JSC::DFG::Graph::methodOfGettingAValueProfileFor): 2018-01-04 Keith Miller Array Storage operations sometimes did not update the indexing mask correctly. https://bugs.webkit.org/show_bug.cgi?id=181301 Reviewed by Mark Lam. I will add tests in a follow up patch. See: https://bugs.webkit.org/show_bug.cgi?id=181303 * runtime/JSArray.cpp: (JSC::JSArray::shiftCountWithArrayStorage): * runtime/JSObject.cpp: (JSC::JSObject::increaseVectorLength): 2018-01-04 Yusuke Suzuki [DFG] Define defs for MapSet/SetAdd to participate in CSE https://bugs.webkit.org/show_bug.cgi?id=179911 Reviewed by Saam Barati. With this patch, our MapSet and SetAdd DFG nodes participate in CSE. To handle a bit tricky DFG Map operation nodes, MapSet and SetAdd produce added bucket as its result. Subsequent GetMapBucket will be removed by CSE. * dfg/DFGAbstractInterpreterInlines.h: (JSC::DFG::AbstractInterpreter::executeEffects): * dfg/DFGClobberize.h: (JSC::DFG::clobberize): * dfg/DFGNodeType.h: * dfg/DFGOperations.cpp: * dfg/DFGOperations.h: * dfg/DFGPredictionPropagationPhase.cpp: * dfg/DFGSpeculativeJIT.cpp: (JSC::DFG::SpeculativeJIT::compileSetAdd): (JSC::DFG::SpeculativeJIT::compileMapSet): * dfg/DFGSpeculativeJIT.h: (JSC::DFG::SpeculativeJIT::callOperation): * ftl/FTLLowerDFGToB3.cpp: (JSC::FTL::DFG::LowerDFGToB3::compileSetAdd): (JSC::FTL::DFG::LowerDFGToB3::compileMapSet): * jit/JITOperations.h: * runtime/HashMapImpl.h: (JSC::HashMapImpl::addNormalized): (JSC::HashMapImpl::addNormalizedInternal): 2018-01-04 Yusuke Suzuki [JSC] Remove LocalScope https://bugs.webkit.org/show_bug.cgi?id=181206 Reviewed by Geoffrey Garen. The last user of HandleStack and LocalScope is JSON. But MarkedArgumentBuffer is enough for their use. This patch changes JSON parsing and stringifying to using MarkedArgumentBuffer. And remove HandleStack and LocalScope. We make Stringifier and Walker WTF_FORBID_HEAP_ALLOCATION to place them on the stack. So they can hold JSObject* directly in their fields. * JavaScriptCore.xcodeproj/project.pbxproj: * Sources.txt: * heap/HandleStack.cpp: Removed. * heap/HandleStack.h: Removed. * heap/Heap.cpp: (JSC::Heap::addCoreConstraints): * heap/Heap.h: (JSC::Heap::handleSet): (JSC::Heap::handleStack): Deleted. * heap/Local.h: Removed. * heap/LocalScope.h: Removed. * runtime/JSONObject.cpp: (JSC::Stringifier::Holder::object const): (JSC::gap): (JSC::Stringifier::Stringifier): (JSC::Stringifier::stringify): (JSC::Stringifier::appendStringifiedValue): (JSC::Stringifier::Holder::Holder): (JSC::Stringifier::Holder::appendNextProperty): (JSC::Walker::Walker): (JSC::Walker::callReviver): (JSC::Walker::walk): (JSC::JSONProtoFuncParse): (JSC::JSONProtoFuncStringify): (JSC::JSONParse): (JSC::JSONStringify): 2018-01-04 Yusuke Suzuki [FTL] Optimize ObjectAllocationSinking mergePointerSets by using removeIf https://bugs.webkit.org/show_bug.cgi?id=180238 Reviewed by Saam Barati. We can optimize ObjectAllocationSinking a bit by using removeIf. * dfg/DFGObjectAllocationSinkingPhase.cpp: 2018-01-04 Yusuke Suzuki [JSC] Create parallel SlotVisitors apriori https://bugs.webkit.org/show_bug.cgi?id=180907 Reviewed by Saam Barati. The number of SlotVisitors are capped with the number of HeapHelperPool's threads + 2. If we create these SlotVisitors apriori, we do not need to create SlotVisitors dynamically. Then we do not need to grab locks while iterating all the SlotVisitors. In addition, we do not need to consider the case that the number of SlotVisitors increases after setting up VisitCounters in MarkingConstraintSolver since the number of SlotVisitors does not increase any more. * heap/Heap.cpp: (JSC::Heap::Heap): (JSC::Heap::runBeginPhase): * heap/Heap.h: * heap/HeapInlines.h: (JSC::Heap::forEachSlotVisitor): (JSC::Heap::numberOfSlotVisitors): Deleted. * heap/MarkingConstraintSolver.cpp: (JSC::MarkingConstraintSolver::didVisitSomething const): 2018-01-03 Ting-Wei Lan Replace hard-coded paths in shebangs with #!/usr/bin/env https://bugs.webkit.org/show_bug.cgi?id=181040 Reviewed by Alex Christensen. * Scripts/UpdateContents.py: * Scripts/cssmin.py: * Scripts/generate-combined-inspector-json.py: * Scripts/xxd.pl: * create_hash_table: * generate-bytecode-files: * wasm/generateWasm.py: * wasm/generateWasmOpsHeader.py: * yarr/generateYarrCanonicalizeUnicode: 2018-01-03 Michael Saboff Disable SharedArrayBuffers from Web API https://bugs.webkit.org/show_bug.cgi?id=181266 Reviewed by Saam Barati. Removed SharedArrayBuffer prototype and structure from GlobalObject creation to disable. * runtime/JSGlobalObject.cpp: (JSC::JSGlobalObject::init): (JSC::JSGlobalObject::visitChildren): * runtime/JSGlobalObject.h: (JSC::JSGlobalObject::arrayBufferPrototype const): (JSC::JSGlobalObject::arrayBufferStructure const): 2018-01-03 Michael Saboff Add "noInline" to $vm https://bugs.webkit.org/show_bug.cgi?id=181265 Reviewed by Mark Lam. This would be useful for web based tests. * tools/JSDollarVM.cpp: (JSC::getExecutableForFunction): (JSC::functionNoInline): (JSC::JSDollarVM::finishCreation): 2018-01-03 Michael Saboff Remove unnecessary flushing of Butterfly pointer in functionCpuClflush() https://bugs.webkit.org/show_bug.cgi?id=181263 Reviewed by Mark Lam. Flushing the butterfly pointer provides no benefit and slows this function. * tools/JSDollarVM.cpp: (JSC::functionCpuClflush): 2018-01-03 Saam Barati Fix BytecodeParser op_catch assert to work with useProfiler=1 https://bugs.webkit.org/show_bug.cgi?id=181260 Reviewed by Keith Miller. op_catch was asserting that the current block was empty. This is only true if the profiler isn't enabled. When the profiler is enabled, we will insert a CountExecution node before each bytecode. This patch fixes the assert to work with the profiler. * dfg/DFGByteCodeParser.cpp: (JSC::DFG::ByteCodeParser::parseBlock): 2018-01-03 Per Arne Vollan [Win][Debug] testapi link error. https://bugs.webkit.org/show_bug.cgi?id=181247 Reviewed by Brent Fulgham. Do not set the runtime library compile flag for C files, it is already set to the correct value. * shell/PlatformWin.cmake: 2018-01-03 Robin Morisset Inlining of a function that ends in op_unreachable crashes https://bugs.webkit.org/show_bug.cgi?id=181027 Reviewed by Filip Pizlo. * dfg/DFGByteCodeParser.cpp: (JSC::DFG::ByteCodeParser::allocateTargetableBlock): (JSC::DFG::ByteCodeParser::inlineCall): 2018-01-02 Saam Barati Incorrect assertion inside AccessCase https://bugs.webkit.org/show_bug.cgi?id=181200 Reviewed by Yusuke Suzuki. Consider a PutById compiled to a setter in a function like so: ``` function foo(o) { o.f = o; } ``` The DFG will often assign the same registers to the baseGPR (o in o.f) and the valueRegsPayloadGPR (o in the RHS). The code totally works when these are assigned to the same register. However, we're asserting that they're not the same register. This patch just removes this invalid assertion. * bytecode/AccessCase.cpp: (JSC::AccessCase::generateImpl): 2018-01-02 Caio Lima [ESNext][BigInt] Implement BigIntConstructor and BigIntPrototype https://bugs.webkit.org/show_bug.cgi?id=175359 Reviewed by Yusuke Suzuki. This patch is implementing BigIntConstructor and BigIntPrototype following spec[1, 2]. As addition, we are also implementing BigIntObject warapper to handle ToObject(v) abstract operation when "v" is a BigInt primitive. With these classes, now it's possible to syntetize BigInt.prototype and then call "toString", "valueOf" and "toLocaleString" when the primitive is a BigInt. BigIntConstructor exposes an API to parse other primitives such as Number, Boolean and String to BigInt. We decided to skip parseInt implementation, since it was removed from spec. [1] - https://tc39.github.io/proposal-bigint/#sec-bigint-constructor [2] - https://tc39.github.io/proposal-bigint/#sec-properties-of-the-bigint-prototype-object * CMakeLists.txt: * DerivedSources.make: * JavaScriptCore.xcodeproj/project.pbxproj: * Sources.txt: * jsc.cpp: * runtime/BigIntConstructor.cpp: Added. (JSC::BigIntConstructor::BigIntConstructor): (JSC::BigIntConstructor::finishCreation): (JSC::isSafeInteger): (JSC::toBigInt): (JSC::callBigIntConstructor): (JSC::bigIntConstructorFuncAsUintN): (JSC::bigIntConstructorFuncAsIntN): * runtime/BigIntConstructor.h: Added. (JSC::BigIntConstructor::create): (JSC::BigIntConstructor::createStructure): * runtime/BigIntObject.cpp: Added. (JSC::BigIntObject::BigIntObject): (JSC::BigIntObject::finishCreation): (JSC::BigIntObject::toStringName): (JSC::BigIntObject::defaultValue): * runtime/BigIntObject.h: Added. (JSC::BigIntObject::create): (JSC::BigIntObject::internalValue const): (JSC::BigIntObject::createStructure): * runtime/BigIntPrototype.cpp: Added. (JSC::BigIntPrototype::BigIntPrototype): (JSC::BigIntPrototype::finishCreation): (JSC::toThisBigIntValue): (JSC::bigIntProtoFuncToString): (JSC::bigIntProtoFuncToLocaleString): (JSC::bigIntProtoFuncValueOf): * runtime/BigIntPrototype.h: Added. (JSC::BigIntPrototype::create): (JSC::BigIntPrototype::createStructure): * runtime/IntlCollator.cpp: (JSC::IntlCollator::initializeCollator): * runtime/IntlNumberFormat.cpp: (JSC::IntlNumberFormat::initializeNumberFormat): * runtime/JSBigInt.cpp: (JSC::JSBigInt::createFrom): (JSC::JSBigInt::parseInt): (JSC::JSBigInt::toObject const): * runtime/JSBigInt.h: * runtime/JSCJSValue.cpp: (JSC::JSValue::synthesizePrototype const): * runtime/JSCPoisonedPtr.cpp: * runtime/JSCell.cpp: (JSC::JSCell::toObjectSlow const): * runtime/JSGlobalObject.cpp: (JSC::JSGlobalObject::init): (JSC::JSGlobalObject::visitChildren): * runtime/JSGlobalObject.h: (JSC::JSGlobalObject::bigIntPrototype const): (JSC::JSGlobalObject::bigIntObjectStructure const): * runtime/StructureCache.h: * runtime/StructureInlines.h: (JSC::prototypeForLookupPrimitiveImpl): 2018-01-02 Tim Horton Fix the MathCommon build with a recent compiler https://bugs.webkit.org/show_bug.cgi?id=181216 Reviewed by Sam Weinig. * runtime/MathCommon.cpp: (JSC::fdlibmPow): This cast drops the 'const' qualifier from the pointer to 'one', but it doesn't have to, and it makes the compiler sad. == Rolled over to ChangeLog-2018-01-01 ==