haikuwebkit/JSTests/stress/call-varargs-spread-new-arr...

30 lines
665 B
JavaScript
Raw Permalink Normal View History

[FTL] NewArrayBuffer should be sinked if it is only used for spreading https://bugs.webkit.org/show_bug.cgi?id=179762 Reviewed by Saam Barati. JSTests: * stress/call-varargs-double-new-array-buffer.js: Added. (assert): (bar): (foo): * stress/call-varargs-spread-new-array-buffer.js: Added. (assert): (bar): (foo): * stress/call-varargs-spread-new-array-buffer2.js: Added. (assert): (bar): (foo): * stress/forward-varargs-double-new-array-buffer.js: Added. (assert): (test.baz): (test.bar): (test.foo): (test): * stress/new-array-buffer-sinking-osrexit.js: Added. (target): (test): * stress/new-array-with-spread-double-new-array-buffer.js: Added. (shouldBe): (test): * stress/new-array-with-spread-with-phantom-new-array-buffer.js: Added. (shouldBe): (target): (test): * stress/phantom-new-array-buffer-forward-varargs.js: Added. (assert): (test1.bar): (test1.foo): (test1): (test2.bar): (test2.foo): (test3.baz): (test3.bar): (test3.foo): (test4.baz): (test4.bar): (test4.foo): * stress/phantom-new-array-buffer-forward-varargs2.js: Added. (assert): (test.baz): (test.bar): (test.foo): (test): * stress/phantom-new-array-buffer-osr-exit.js: Added. (assert): (baz): (bar): (effects): (foo): Source/JavaScriptCore: This patch extends arguments elimination phase to accept NewArrayBuffer. We can convert NewArrayBuffer to PhantomNewArrayBuffer if it is only used by spreading nodes. This improves SixSpeed spread.es6 by 3.5x. spread.es6 79.1496+-3.5665 ^ 23.6204+-1.8526 ^ definitely 3.3509x faster * dfg/DFGAbstractInterpreterInlines.h: (JSC::DFG::AbstractInterpreter<AbstractStateType>::executeEffects): * dfg/DFGArgumentsEliminationPhase.cpp: * 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::hasNewArrayBufferData): (JSC::DFG::Node::hasVectorLengthHint): (JSC::DFG::Node::hasIndexingType): (JSC::DFG::Node::indexingType): (JSC::DFG::Node::hasCellOperand): (JSC::DFG::Node::isPhantomAllocation): * dfg/DFGNodeType.h: * dfg/DFGOSRAvailabilityAnalysisPhase.cpp: (JSC::DFG::LocalOSRAvailabilityCalculator::executeNode): * dfg/DFGPredictionPropagationPhase.cpp: * dfg/DFGPromotedHeapLocation.cpp: (WTF::printInternal): * dfg/DFGPromotedHeapLocation.h: * dfg/DFGSafeToExecute.h: (JSC::DFG::safeToExecute): * dfg/DFGSpeculativeJIT32_64.cpp: (JSC::DFG::SpeculativeJIT::compile): * dfg/DFGSpeculativeJIT64.cpp: (JSC::DFG::SpeculativeJIT::compile): * dfg/DFGValidate.cpp: * ftl/FTLCapabilities.cpp: (JSC::FTL::canCompile): * ftl/FTLLowerDFGToB3.cpp: (JSC::FTL::DFG::LowerDFGToB3::compileNode): (JSC::FTL::DFG::LowerDFGToB3::compileNewArrayWithSpread): (JSC::FTL::DFG::LowerDFGToB3::compileSpread): (JSC::FTL::DFG::LowerDFGToB3::compileCallOrConstructVarargsSpread): (JSC::FTL::DFG::LowerDFGToB3::compileCallOrConstructVarargs): (JSC::FTL::DFG::LowerDFGToB3::compileForwardVarargs): (JSC::FTL::DFG::LowerDFGToB3::compileForwardVarargsWithSpread): * ftl/FTLOperations.cpp: (JSC::FTL::operationPopulateObjectInOSR): (JSC::FTL::operationMaterializeObjectInOSR): Source/WTF: We add RecursableLambda<>. This can take a lambda and offer a way to call this lambda recursively without introducing additional allocations. C++ lambda is super useful in particular when we need to capture many variables as references. Passing many arguments to a usual function is not a good way. But C++ lambda does not allow us to easily call itself recursively. Our recursableLambda offers `self` function as a first argument of the given lambda. We can call this `self` recursively. auto targetFunction = recursableLambda([] (auto self, ...) -> resultType { self(...); }); While `std::function<> func = [&func] { ... }` allows recursion, it causes heap allocation for std::function<>. `auto func = [&func] { ... }` causes a compile error since we need to deduce an actual type when capturing `func`. * WTF.xcodeproj/project.pbxproj: * wtf/RecursableLambda.h: Added. (WTF::RecursableLambda::RecursableLambda): (WTF::RecursableLambda::operator() const): (WTF::recursableLambda): Canonical link: https://commits.webkit.org/196815@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@226033 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-12-18 11:49:33 +00:00
function assert(b, m = "") {
if (!b)
throw new Error("Bad assert: " + m);
}
noInline(assert);
function bar(...args) {
return args;
}
noInline(bar);
function foo() {
let args = [1, 2, 3];
let x = bar(...args, 42, ...args);
return x;
}
noInline(foo);
for (let i = 0; i < 10000; i++) {
let r = foo();
assert(r.length === 7);
assert(r[0] === 1, JSON.stringify(r));
assert(r[1] === 2, JSON.stringify(r));
assert(r[2] === 3, JSON.stringify(r));
assert(r[3] === 42, JSON.stringify(r));
assert(r[4] === 1, JSON.stringify(r));
assert(r[5] === 2, JSON.stringify(r));
assert(r[6] === 3, JSON.stringify(r));
}