Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: a509a5dd2a1c39679bfc2754492e55e5aa84660a
      
https://github.com/WebKit/WebKit/commit/a509a5dd2a1c39679bfc2754492e55e5aa84660a
  Author: Sosuke Suzuki <aosuk...@gmail.com>
  Date:   2024-12-10 (Tue, 10 Dec 2024)

  Changed paths:
    A JSTests/microbenchmarks/string-prototype-at-negative-index-16.js
    A JSTests/microbenchmarks/string-prototype-at-negative-index.js
    A JSTests/microbenchmarks/string-prototype-at-out-of-bounds.js
    A JSTests/microbenchmarks/string-prototype-at-positive-index.js
    A JSTests/stress/string-prototype-at-oob-16.js
    A JSTests/stress/string-prototype-at-oob.js
    A JSTests/stress/string-prototype-at.js
    M Source/JavaScriptCore/builtins/StringPrototype.js
    M Source/JavaScriptCore/dfg/DFGAbstractInterpreterInlines.h
    M Source/JavaScriptCore/dfg/DFGArrayMode.h
    M Source/JavaScriptCore/dfg/DFGBackwardsPropagationPhase.cpp
    M Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp
    M Source/JavaScriptCore/dfg/DFGClobberize.h
    M Source/JavaScriptCore/dfg/DFGDoesGC.cpp
    M Source/JavaScriptCore/dfg/DFGFixupPhase.cpp
    M Source/JavaScriptCore/dfg/DFGNode.h
    M Source/JavaScriptCore/dfg/DFGNodeType.h
    M Source/JavaScriptCore/dfg/DFGPredictionPropagationPhase.cpp
    M Source/JavaScriptCore/dfg/DFGSafeToExecute.h
    M Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp
    M Source/JavaScriptCore/dfg/DFGSpeculativeJIT32_64.cpp
    M Source/JavaScriptCore/dfg/DFGSpeculativeJIT64.cpp
    M Source/JavaScriptCore/ftl/FTLCapabilities.cpp
    M Source/JavaScriptCore/ftl/FTLLowerDFGToB3.cpp
    M Source/JavaScriptCore/runtime/Intrinsic.h
    M Source/JavaScriptCore/runtime/StringPrototype.cpp

  Log Message:
  -----------
  [JSC] Optimze `String#at` in DFG/FTL
https://bugs.webkit.org/show_bug.cgi?id=217139

Reviewed by Yusuke Suzuki.

This patch optimizes `String.prototype.at`. It reuses most of the optimizations 
made for
`String.prototype.charAt`, although there are some differences according to the 
specifications[1][2]:

- Returns undefined instead of an empty string when out of bounds
- Treats the `index` as `length + index` when the `index` is negative

                                            TipOfTree                  Patched

string-prototype-at-negative-index        2.0051+-0.0882     ^      
1.1322+-0.0331        ^ definitely 1.7709x faster
string-prototype-at-out-of-bounds         1.4258+-0.0943     ^      
1.1240+-0.0281        ^ definitely 1.2685x faster
string-prototype-at-positive-index        1.7500+-0.0490     ^      
1.2082+-0.1981        ^ definitely 1.4484x faster

* JSTests/microbenchmarks/string-prototype-at-negative-index.js: Added.
(test):
* JSTests/microbenchmarks/string-prototype-at-out-of-bounds.js: Added.
(test):
* JSTests/microbenchmarks/string-prototype-at-positive-index.js: Added.
(test):
* Source/JavaScriptCore/builtins/StringPrototype.js:
(at): Deleted.
* Source/JavaScriptCore/dfg/DFGAbstractInterpreterInlines.h:
(JSC::DFG::AbstractInterpreter<AbstractStateType>::executeEffects):
* Source/JavaScriptCore/dfg/DFGArrayMode.h:
(JSC::DFG::ArrayMode::ArrayMode):
* Source/JavaScriptCore/dfg/DFGBackwardsPropagationPhase.cpp:
(JSC::DFG::BackwardsPropagationPhase::propagate):
* Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp:
(JSC::DFG::ByteCodeParser::handleIntrinsicCall):
* Source/JavaScriptCore/dfg/DFGClobberize.h:
(JSC::DFG::clobberize):
* Source/JavaScriptCore/dfg/DFGDoesGC.cpp:
(JSC::DFG::doesGC):
* Source/JavaScriptCore/dfg/DFGFixupPhase.cpp:
(JSC::DFG::FixupPhase::fixupNode):
* Source/JavaScriptCore/dfg/DFGNode.h:
(JSC::DFG::Node::hasArrayMode):
* Source/JavaScriptCore/dfg/DFGNodeType.h:
* Source/JavaScriptCore/dfg/DFGPredictionPropagationPhase.cpp:
* Source/JavaScriptCore/dfg/DFGSafeToExecute.h:
(JSC::DFG::safeToExecute):
* Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp:
(JSC::DFG::SpeculativeJIT::compileGetByValOnString):
* Source/JavaScriptCore/dfg/DFGSpeculativeJIT32_64.cpp:
(JSC::DFG::SpeculativeJIT::compile):
* Source/JavaScriptCore/dfg/DFGSpeculativeJIT64.cpp:
(JSC::DFG::SpeculativeJIT::compile):
* Source/JavaScriptCore/ftl/FTLCapabilities.cpp:
(JSC::FTL::canCompile):
* Source/JavaScriptCore/ftl/FTLLowerDFGToB3.cpp:
(JSC::FTL::DFG::LowerDFGToB3::compileNode):
(JSC::FTL::DFG::LowerDFGToB3::compileStringCharAtImpl):
(JSC::FTL::DFG::LowerDFGToB3::compileStringAt):
* Source/JavaScriptCore/runtime/Intrinsic.h:
* Source/JavaScriptCore/runtime/StringPrototype.cpp:
(JSC::StringPrototype::finishCreation):
(JSC::JSC_DEFINE_HOST_FUNCTION):

Canonical link: https://commits.webkit.org/287653@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to