[webkit-changes] [WebKit/WebKit] 3bced5: [JSC] Optimize ParseInt(number) cases in DFG / FTL...

Yusuke Suzuki noreply at github.com
Mon Feb 6 23:44:33 PST 2023


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 3bced5e977458a7ce70a1d9d592c0a93263ebefe
      https://github.com/WebKit/WebKit/commit/3bced5e977458a7ce70a1d9d592c0a93263ebefe
  Author: Yusuke Suzuki <ysuzuki at apple.com>
  Date:   2023-02-06 (Mon, 06 Feb 2023)

  Changed paths:
    A JSTests/stress/parse-int-double.js
    M Source/JavaScriptCore/dfg/DFGClobberize.h
    M Source/JavaScriptCore/dfg/DFGFixupPhase.cpp
    M Source/JavaScriptCore/dfg/DFGOperations.cpp
    M Source/JavaScriptCore/dfg/DFGOperations.h
    M Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp
    M Source/JavaScriptCore/ftl/FTLLowerDFGToB3.cpp
    M Source/JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp
    M Source/JavaScriptCore/runtime/ParseInt.h

  Log Message:
  -----------
  [JSC] Optimize ParseInt(number) cases in DFG / FTL too
https://bugs.webkit.org/show_bug.cgi?id=251828
rdar://105109063

Reviewed by Mark Lam.

This patch implements ParseInt(number) case optimizations in DFG / FTL. Interestingly, we have this optimizations in runtime C++ code.
But we missed this in DFG / FTL. When the input number is 0.000001 < n < 1e+21, it will not show exponential part as a result of toString.
So, we can just return std::trunc(n) as a result of parseInt(number) for them. Negative version is a bit more interesting since we should
filter out -1.0 < n cases instead of -0.000001 since they can become -0.0.

In this patch, we extend existing optimization with maxSafeInteger() & negative cases. We apply it in operation functions in DFG / FTL.
Also, we add DoubleRepUse / Int32Use specialized versions for ParseInt DFG node so that we can optimize this pattern further.

This improves JetStream2/string-unpack-code-SP by 7-10%.

* JSTests/stress/parse-int-double.js: Added.
(shouldBe):
(parseIntDouble):
* Source/JavaScriptCore/dfg/DFGClobberize.h:
(JSC::DFG::clobberize):
* Source/JavaScriptCore/dfg/DFGFixupPhase.cpp:
(JSC::DFG::FixupPhase::fixupNode):
* Source/JavaScriptCore/dfg/DFGOperations.cpp:
(JSC::DFG::JSC_DEFINE_JIT_OPERATION):
* Source/JavaScriptCore/dfg/DFGOperations.h:
* Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp:
* Source/JavaScriptCore/ftl/FTLLowerDFGToB3.cpp:
(JSC::FTL::DFG::LowerDFGToB3::compileCompareStrictEq):
* Source/JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp:
(JSC::JSC_DEFINE_HOST_FUNCTION):
* Source/JavaScriptCore/runtime/ParseInt.h:
(JSC::parseIntDouble):

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




More information about the webkit-changes mailing list