Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 5d1761dffb0059dae2de405ab872b7bbd2798576
      
https://github.com/WebKit/WebKit/commit/5d1761dffb0059dae2de405ab872b7bbd2798576
  Author: Sosuke Suzuki <[email protected]>
  Date:   2026-09-13 (Sun, 13 Sep 2026)

  Changed paths:
    A JSTests/stress/string-index-dce-bounds-check.js
    M Source/JavaScriptCore/dfg/DFGSSALoweringPhase.cpp
    M Source/JavaScriptCore/ftl/FTLLowerDFGToB3.cpp

  Log Message:
  -----------
  [JSC] Extract `CheckInBounds` from `StringAt` and `StringCodePointAt`
https://bugs.webkit.org/show_bug.cgi?id=323640

Reviewed by Yusuke Suzuki.

StringAt and StringCodePointAt speculate that the index is in bounds, and
the abstract interpreter types their result on the strength of that check,
so a user such as `string.codePointAt(index) === undefined` folds to a
constant. The node then has no users left, and MovHintRemoval + DCE in the
FTL pipeline remove it together with its bounds check, so out-of-bounds
indices keep returning the folded constant without exiting.

Extract the bounds check into a CheckInBounds node in SSA lowering, as
existing implementation for StringCharCodeAt. The check survives DCE on its own,
while an unused node stays removable. StringAt with an in-bounds array mode
now checks the index before it is normalized, so a negative index exits
with OutOfBounds and the next compile picks the out-of-bounds mode, which
handles negative indices inline without exiting.

Test: JSTests/stress/string-index-must-generate-dce.js

* JSTests/stress/string-index-dce-bounds-check.js: Added.
(shouldBe):
(codePointAtIsUndefined):
(atIsUndefined):
(charCodeAtIsNaN):
(atNegative):
* Source/JavaScriptCore/dfg/DFGSSALoweringPhase.cpp:
(JSC::DFG::SSALoweringPhase::handleNode):
* Source/JavaScriptCore/ftl/FTLLowerDFGToB3.cpp:
(JSC::FTL::DFG::LowerDFGToB3::compileStringCharAtImpl):
(JSC::FTL::DFG::LowerDFGToB3::compileStringCodePointAt):

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



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to