Skip to content

add WeakMapImpl.h and WeakMapImplInlines.h to build - #8

Merged
Jarred-Sumner merged 1 commit into
oven-sh:mainfrom
silversquirl:main
May 17, 2023
Merged

Jarred-Sumner merged 1 commit into
oven-sh:mainfrom
silversquirl:main

Conversation

@silversquirl

Copy link
Copy Markdown

Required for oven-sh/bun#2785

@Jarred-Sumner
Jarred-Sumner merged commit 7efd9eb into oven-sh:main May 17, 2023
Jarred-Sumner pushed a commit that referenced this pull request Dec 30, 2024
https://bugs.webkit.org/show_bug.cgi?id=281902
rdar://136486349

Reviewed by Mike Wyrzykowski.

Metal: Ensure potentially infinite loops have defined behavior

The MSL compiler would omit infinite loops and assume number domains
based on the omission logic. This would induce incorrect number domains
in case the infinite loops would be invokable. Infinite loops are
undefined in C++ and thus in MSL. It is the job of the programmer
to ensure undefined behavior cannot happen.

Consider GLSL loop like:
uniform float i;
...
    if (i != 0.5) for(;;) { }
    gl_FragColor = vec4(i);

Historically this would emit MSL loop in spirit of:
    if (i != 0.5) {
      bool c = true;
      while (c) { }
    }
    ANGLE_fragmentOut.gl_FragColor = metal::float4(i, i, i, i);

Since This could cause the MSL compiler to optimize the function to
equivalent of:
    ANGLE_fragmentOut.gl_FragColor = metal::float4(0.5, 0.5, 0.5, 0.5);

Presumably this loop omission would happen at the clang frontend part.

Before, was worked around by emitting asm statements to the MSL:
    bool c = true;
    while (c) {
        __asm__("");
    }

The asm injection would would work for this particular source pattern,
presumably because injecting the asm would avoid the loop omission at
the clang frontend part.

The MSL/C++ code is still UB, though. The asm statement does not cause
anything that C++ would consider as "forward progress" of the loop. The
success was just due to how the backend worked. The bitcode produced
would be similar to:

4:
    tail call void asm sideeffect "", ""() #6, !srcloc !28
    br label %4, !llvm.loop !29

Here, the compiler can be seen to simply fail to detect a loop that
does not make forward progress.

Considering GLSL of form:
uniform int f;
...
    for (;;) { if (f <= 1) break; }

With asm injection to the loop, this would produce:

5:
    tail call void asm sideeffect "", ""() #8, !srcloc !29
    %6 = load i32, i32 addrspace(2)* %4, align 4, !tbaa !30
    %7 = icmp slt i32 %6, 2
    br i1 %7, label %8, label %5
8:

This code is still assumed to make progress. The backend optimizer is
free to assume that the condition holds, since the load to break the
loop is from constant address space. I.e. uniform f does not change its
value during the loop.

Instead of injecting asm, inject a read of unused volatile variable.
The volatile variable access is defined in C++ as forward progress.
This means infinite loop containing such read is considered defined.
To simplify the implementation and to avoid volatile writes, the read
is to a dummy variable instead of the loop condition bool.

The tests here do not pass completely for MSL backend. In case the
compiler would omit the infinite loop (unpatched code), they would fail
with demonstration of how the values behave. After fixing, the loops
cause timeout but Metal backend does not have implementation to report
context loss. Also, the ReadPixels is just for demostration purposes of the
unpatched code.

* Source/ThirdParty/ANGLE/src/compiler/translator/msl/EmitMetal.cpp:
(GenMetalTraverser::GenMetalTraverser):
(GenMetalTraverser::emitLoopBody):
(GenMetalTraverser::emitForwardProgressStore):
(GenMetalTraverser::emitForwardProgressSignal):
(GenMetalTraverser::visitForLoop):
(GenMetalTraverser::visitWhileLoop):
(GenMetalTraverser::visitDoWhileLoop):
* Source/ThirdParty/ANGLE/src/tests/angle_end2end_tests.gni:
* Source/ThirdParty/ANGLE/src/tests/gl_tests/TimeoutDrawTest.cpp: Added.
(angle::TimeoutDrawTest::TimeoutDrawTest):
(angle::TEST_P):

Originally-landed-as: 283286.350@safari-7620-branch (b82d94e). rdar://141318430
Canonical link: https://commits.webkit.org/288020@main
Jarred-Sumner pushed a commit that referenced this pull request Feb 21, 2025
https://bugs.webkit.org/show_bug.cgi?id=288102
rdar://145222010

Reviewed by Yusuke Suzuki.

Added the notion of a string list to a parsed RegExp that is in the form of
  /^(?:break|case|which|do|for)/ with an optional trailing $.
Such a RegExp will not backtrack and therefore we can streamline the code we emit for such a pattern.

This change involves recognizing beginning of string anchored alternations of strings while parsing and
then treating the generation of JIT code differently for these patterns.  This includes changing how
conditional branching works, specifically that instead of the "fall through on match" for each term,
to a "jump on match" for the whole alternation.

The current code generated for the "case" elternative is:
   8:Term PatternCharacter checked-offset:(3) 'c'
               <156> 0x11381430c:    add      w1, w1, #2
               <160> 0x113814310:    cmp      w1, w2
               <164> 0x113814314:    b.hi     0x113814444 -> <468>
  10:Term PatternCharacter checked-offset:(4) 'c'
               <168> 0x113814318:    sub      x17, x0, #4
               <172> 0x11381431c:    ldr      w17, [x17, x1]
               <176> 0x113814320:    movz     w16, #0x6163
               <180> 0x113814324:    movk     w16, #0x6573, lsl #16 -> 0x65736163
               <184> 0x113814328:    cmp      w17, w16
               <188> 0x11381432c:    b.ne     0x113814444 -> <468>
  11:Term PatternCharacter checked-offset:(4) 'a' already handled
  12:Term PatternCharacter checked-offset:(4) 's' already handled
  13:Term PatternCharacter checked-offset:(4) 'e' already handled
  14:NestedAlternativeNext minimum-size:(5),checked-offset:(5)
               <192> 0x113814330:    movz     x16, #0x4444
               <196> 0x113814334:    movk     x16, #0x1381, lsl #16
               <200> 0x113814338:    movk     x16, #0x8001, lsl #32
               <204> 0x11381433c:    movk     x16, #0xc973, lsl #48 -> 0x113814444 JIT PC
               <208> 0x113814340:    stur     x16, [sp, #8]
               <212> 0x113814344:    b        0x113814404 -> <404>
With some additional backtracking code:
   9:NestedAlternativeNext minimum-size:(4),checked-offset:(4)
               <468> 0x113814444:    sub      w1, w1, #2
               <472> 0x113814448:    b        0x113814348 -> <216>

With this change, the processing of "case" becomes:
   9:StringListAlternativeNext minimum-size:(4),checked-offset:(4)
               <132> 0x12a8285c4:    sub      w1, w1, #1
               <136> 0x12a8285c8:    cmp      w1, w2
               <140> 0x12a8285cc:    b.hi     0x12a8285e8 -> <168>
  10:Term PatternCharacter checked-offset:(4) 'c'
               <144> 0x12a8285d0:    sub      x17, x0, #4
               <148> 0x12a8285d4:    ldr      w17, [x17, x1]
               <152> 0x12a8285d8:    movz     w16, #0x6163
               <156> 0x12a8285dc:    movk     w16, #0x6573, lsl #16 -> 0x65736163
               <160> 0x12a8285e0:    cmp      w17, w16
               <164> 0x12a8285e4:    b.eq     0x12a82866c -> <300>
  11:Term PatternCharacter checked-offset:(4) 'a' already handled
  12:Term PatternCharacter checked-offset:(4) 's' already handled
  13:Term PatternCharacter checked-offset:(4) 'e' already handled
  14:StringListAlternativeNext minimum-size:(5),checked-offset:(5)
With no backtracking code.

We are able to eliminate one branch and the saving of the continuation PC for backtracking.
The code size to process these string list RegExp is reduces.  For the example RegExp above,
the prior version created 1940 bytes (485 instructions) of code while the code created with this
1392 bytes (345 instructions) of code, a nearly 30% reduction in code.

This change is a ~18% progression on the new regexp-keyword-parsing microbenchmark:

                                 Baseline               YarrStringList

regexp-keyword-parsing      136.7065+-0.9807     ^    116.0161+-1.1791        ^ definitely 1.1783x faster

<geometric>                 136.7065+-0.9807     ^    116.0161+-1.1791        ^ definitely 1.1783x faster

* JSTests/microbenchmarks/regexp-keyword-parsing.js: Added.
(arrayToString):
(objectToString):
(dumpValue):
(compareArray):
(compareGroups):
(testRegExp):
(testRegExpSyntaxError):
(let.re.break.case.catch.continue.debugger.default.else.finally.if):
(let.re1.break.case.catch.continue.debugger.default.else.finally.if):
* JSTests/stress/regexp-parsing-tokens.js: Added.
(arrayToString):
(objectToString):
(dumpValue):
(compareArray):
(compareGroups):
(testRegExp):
(testRegExpSyntaxError):
* Source/JavaScriptCore/yarr/YarrJIT.cpp:
* Source/JavaScriptCore/yarr/YarrPattern.cpp:
(JSC::Yarr::YarrPatternConstructor::atomParenthesesEnd):
(JSC::Yarr::YarrPatternConstructor::checkForTerminalParentheses):
(JSC::Yarr::PatternAlternative::dump):
(JSC::Yarr::PatternTerm::dump):
* Source/JavaScriptCore/yarr/YarrPattern.h:
(JSC::Yarr::PatternTerm::PatternTerm):
(JSC::Yarr::PatternAlternative::PatternAlternative):

Canonical link: https://commits.webkit.org/290791@main
190n pushed a commit that referenced this pull request Feb 25, 2025
https://bugs.webkit.org/show_bug.cgi?id=288102
rdar://145222010

Reviewed by Yusuke Suzuki.

Added the notion of a string list to a parsed RegExp that is in the form of
  /^(?:break|case|which|do|for)/ with an optional trailing $.
Such a RegExp will not backtrack and therefore we can streamline the code we emit for such a pattern.

This change involves recognizing beginning of string anchored alternations of strings while parsing and
then treating the generation of JIT code differently for these patterns.  This includes changing how
conditional branching works, specifically that instead of the "fall through on match" for each term,
to a "jump on match" for the whole alternation.

Fixed a bug in the original version where we weren't properly checking the nested alternatives to see
if they only contain fixed single count PatternCharacter terms.

The current code generated for the "case" elternative is:
   8:Term PatternCharacter checked-offset:(3) 'c'
               <156> 0x11381430c:    add      w1, w1, #2
               <160> 0x113814310:    cmp      w1, w2
               <164> 0x113814314:    b.hi     0x113814444 -> <468>
  10:Term PatternCharacter checked-offset:(4) 'c'
               <168> 0x113814318:    sub      x17, x0, #4
               <172> 0x11381431c:    ldr      w17, [x17, x1]
               <176> 0x113814320:    movz     w16, #0x6163
               <180> 0x113814324:    movk     w16, #0x6573, lsl #16 -> 0x65736163
               <184> 0x113814328:    cmp      w17, w16
               <188> 0x11381432c:    b.ne     0x113814444 -> <468>
  11:Term PatternCharacter checked-offset:(4) 'a' already handled
  12:Term PatternCharacter checked-offset:(4) 's' already handled
  13:Term PatternCharacter checked-offset:(4) 'e' already handled
  14:NestedAlternativeNext minimum-size:(5),checked-offset:(5)
               <192> 0x113814330:    movz     x16, #0x4444
               <196> 0x113814334:    movk     x16, #0x1381, lsl #16
               <200> 0x113814338:    movk     x16, #0x8001, lsl #32
               <204> 0x11381433c:    movk     x16, #0xc973, lsl #48 -> 0x113814444 JIT PC
               <208> 0x113814340:    stur     x16, [sp, #8]
               <212> 0x113814344:    b        0x113814404 -> <404>
With some additional backtracking code:
   9:NestedAlternativeNext minimum-size:(4),checked-offset:(4)
               <468> 0x113814444:    sub      w1, w1, #2
               <472> 0x113814448:    b        0x113814348 -> <216>

With this change, the processing of "case" becomes:
   9:StringListAlternativeNext minimum-size:(4),checked-offset:(4)
               <132> 0x12a8285c4:    sub      w1, w1, #1
               <136> 0x12a8285c8:    cmp      w1, w2
               <140> 0x12a8285cc:    b.hi     0x12a8285e8 -> <168>
  10:Term PatternCharacter checked-offset:(4) 'c'
               <144> 0x12a8285d0:    sub      x17, x0, #4
               <148> 0x12a8285d4:    ldr      w17, [x17, x1]
               <152> 0x12a8285d8:    movz     w16, #0x6163
               <156> 0x12a8285dc:    movk     w16, #0x6573, lsl #16 -> 0x65736163
               <160> 0x12a8285e0:    cmp      w17, w16
               <164> 0x12a8285e4:    b.eq     0x12a82866c -> <300>
  11:Term PatternCharacter checked-offset:(4) 'a' already handled
  12:Term PatternCharacter checked-offset:(4) 's' already handled
  13:Term PatternCharacter checked-offset:(4) 'e' already handled
  14:StringListAlternativeNext minimum-size:(5),checked-offset:(5)
With no backtracking code.

We are able to eliminate one branch and the saving of the continuation PC for backtracking.
The code size to process these string list RegExp is reduces.  For the example RegExp above,
the prior version created 1940 bytes (485 instructions) of code while the code created with this
1392 bytes (345 instructions) of code, a nearly 30% reduction in code.

This change is a ~18% progression on the new regexp-keyword-parsing microbenchmark:

                                 Baseline               YarrStringList

regexp-keyword-parsing      136.7065+-0.9807     ^    116.0161+-1.1791        ^ definitely 1.1783x faster

<geometric>                 136.7065+-0.9807     ^    116.0161+-1.1791        ^ definitely 1.1783x faster

* JSTests/microbenchmarks/regexp-keyword-parsing.js: Added.
(arrayToString):
(objectToString):
(dumpValue):
(compareArray):
(compareGroups):
(testRegExp):
(testRegExpSyntaxError):
(let.re.break.case.catch.continue.debugger.default.else.finally.if):
(let.re1.break.case.catch.continue.debugger.default.else.finally.if):
* JSTests/stress/regexp-parsing-tokens.js: Added.
(arrayToString):
(objectToString):
(dumpValue):
(compareArray):
(compareGroups):
(testRegExp):
(testRegExpSyntaxError):
* Source/JavaScriptCore/yarr/YarrJIT.cpp:
* Source/JavaScriptCore/yarr/YarrPattern.cpp:
(JSC::Yarr::YarrPatternConstructor::atomParenthesesEnd):
(JSC::Yarr::YarrPatternConstructor::checkForTerminalParentheses):
(JSC::Yarr::PatternAlternative::dump):
(JSC::Yarr::PatternTerm::dump):
* Source/JavaScriptCore/yarr/YarrPattern.h:
(JSC::Yarr::PatternTerm::PatternTerm):
(JSC::Yarr::PatternAlternative::PatternAlternative):

Canonical link: https://commits.webkit.org/290982@main
Jarred-Sumner pushed a commit that referenced this pull request May 20, 2025
https://bugs.webkit.org/show_bug.cgi?id=292725
rdar://150797746

Reviewed by Justin Michaud and Daniel Liu.

This patch hardens how IPInt dispatches opcodes for better CFI protection. Since IPInt does an offset based
dispatch the previous dispatch was something like:

```
macro dispatchToNextIPIntInstruction()
    // x7 is set to _ipInt_instruction_base on entry to IPInt entry/call return.
    loadb [PC], x0
    emit "add x0, x7, x0, lsl #8"
    emit "br x0"
end

align 256
_ipint_dispatch_base:
.first_wasm_bytecode:
// stuff
dispatchToNextIPIntInstruction()

align 256
.second_wasm_bytecode:
// stuff
dispatchToNextIPIntInstruction()
...
align 256
.255_wasm_bytecode:
// stuff
dispatchToNextIPIntInstruction()
```
In the old system no matter what value [PC] points to there are 256 offsets reachable, all of which are
either a valid opcode or a slab of `brk`s.

However, this still means if an attacker is able to return to the IPInt interpreter on some path that
doesn't reset x7 then they'll be able to implement a JOP attack. One example would be to build a fake
object with a vtable pointing to one of the "C function" labels (e.g. _first_wasm_bytecode_validate,
which is used for offset validation).

After this change dispatch is now:

```
macro dispatchToNextIPIntInstruction()
    loadb something, x0
    pcrtoaddr _ipint_dispatch_base, x7
    emit "add x0, x7, x0, lsl #8"
    emit "br x0"
end
```

which makes it clearly impossible to get a PAC bypass in IPInt dispatch. Since there's no longer
a semi-pinned register with the base pointer this patch removes all that associated code.

Additionally, this change adds a names for all the dispatch starts to make the
code a bit easier to read.

Lastly, the SIMD prefix opcode was missing a security guard so this patch adds that too.

Canonical link: https://commits.webkit.org/294973@main
Jarred-Sumner pushed a commit that referenced this pull request Jun 14, 2025
https://bugs.webkit.org/show_bug.cgi?id=294344
rdar://153095450

Reviewed by Keith Miller.

Relanding Keith's change with some fixes for x64. In x64, we cannot
directly get label address, so instead of doing it, we store them into
JSCConfig and load it.

This patch hardens how IPInt dispatches opcodes for better CFI protection. Since IPInt does an offset based
dispatch the previous dispatch was something like:

```
macro dispatchToNextIPIntInstruction()
    // x7 is set to _ipInt_instruction_base on entry to IPInt entry/call return.
    loadb [PC], x0
    emit "add x0, x7, x0, lsl #8"
    emit "br x0"
end

align 256
_ipint_dispatch_base:
.first_wasm_bytecode:
// stuff
dispatchToNextIPIntInstruction()

align 256
.second_wasm_bytecode:
// stuff
dispatchToNextIPIntInstruction()
...
align 256
.255_wasm_bytecode:
// stuff
dispatchToNextIPIntInstruction()
```
In the old system no matter what value [PC] points to there are 256 offsets reachable, all of which are
either a valid opcode or a slab of `brk`s.

However, this still means if an attacker is able to return to the IPInt interpreter on some path that
doesn't reset x7 then they'll be able to implement a JOP attack. One example would be to build a fake
object with a vtable pointing to one of the "C function" labels (e.g. _first_wasm_bytecode_validate,
which is used for offset validation).

After this change dispatch is now:

```
macro dispatchToNextIPIntInstruction()
    loadb something, x0
    pcrtoaddr _ipint_dispatch_base, x7
    emit "add x0, x7, x0, lsl #8"
    emit "br x0"
end
```

which makes it clearly impossible to get a PAC bypass in IPInt dispatch. Since there's no longer
a semi-pinned register with the base pointer this patch removes all that associated code.

Additionally, this change adds a names for all the dispatch starts to make the
code a bit easier to read.

Lastly, the SIMD prefix opcode was missing a security guard so this patch adds that too.

* Source/JavaScriptCore/llint/InPlaceInterpreter.asm:
* Source/JavaScriptCore/llint/InPlaceInterpreter.cpp:
(JSC::IPInt::initialize):
* Source/JavaScriptCore/llint/InPlaceInterpreter.h:
* Source/JavaScriptCore/llint/InPlaceInterpreter32_64.asm:
* Source/JavaScriptCore/llint/InPlaceInterpreter64.asm:
* Source/JavaScriptCore/llint/LowLevelInterpreter.asm:
* Source/JavaScriptCore/runtime/JSCConfig.h:

Canonical link: https://commits.webkit.org/296121@main
robobun pushed a commit that referenced this pull request Jan 22, 2026
…n to fix deadlock

https://bugs.webkit.org/show_bug.cgi?id=305674
rdar://168319182

Reviewed by Yusuke Suzuki.

The WASM debugger can deadlock when Thread #8 suspends Thread #4 via
thread_suspend() while Thread #4 is in the middle of ref counting operations.
The suspended thread may hold a WordLock (used for thread-safe ref counting),
and when the suspending thread tries to create a RefPtr copy, it blocks
waiting for the same lock.

The deadlock sequence:
1. Thread #4 acquires WordLock in strongDeref() destructor
2. Thread #8 suspends Thread #4 via thread_suspend() Mach kernel trap
3. Thread #4 is frozen mid-unlock, WordLock never released
4. Thread #8's lambda calls vm.apiLock().ownerThread(), creating RefPtr copy
5. RefPtr copy triggers strongRef() which tries to acquire same WordLock
6. Deadlock: Thread #4 suspended holding lock, Thread #8 blocked waiting

The fix adds ownerThreadUID() methods that return the thread UID directly
without creating temporary RefPtr objects, avoiding all ref counting
operations and the associated lock contention.

Canonical link: https://commits.webkit.org/305766@main
pull Bot referenced this pull request in coleleavitt/WebKit Jul 19, 2026
…ems and crossSizeForFlexLines

https://bugs.webkit.org/show_bug.cgi?id=318494

Reviewed by Antti Koivisto.

Cross sizing was fused into one per-line function (returning the line's extent,
its baseline groups, and the next offset at once) wrapped by
computeCrossSizeForFlexLines. FlexLayout::layout splits it instead: #7
hypotheticalCrossSizeForFlexItems returns each item's hypothetical cross size,
and #8 crossSizeForFlexLines turns those into each line's cross size. Match that
shape -- both now return plain Vector<LayoutUnit> lists, so an FFC body ports in.

crossSizeForFlexLines keeps legacy's line-size arithmetic (the running
first/last-baseline maxes with a shared descent), so this preserves behavior
rather than adopting FFC's group max. The row-flow container height growth moves
to the line-state assembly (once per line by the line's cross size, which equals
the old per-item maximum), and the baseline sharing groups are built in
performBaselineAlignment where they are used -- safe because baseline items are
never align-self:stretch, so nothing relayouts them between sizing and alignment.
LineState no longer carries the groups.

performFlexLayout now runs its sizing and alignment phases as
performContentSizing() and performContentAlignment() lambdas, matching
FlexLayout::layout. layoutFlexLines, computeCrossSizeForFlexLines, and the
FlexLineResult struct are gone.

No change in behavior.

* Source/WebCore/rendering/RenderFlexibleBox.h:
* Source/WebCore/rendering/RenderFlexibleBox.cpp:
(WebCore::RenderFlexibleBox::LineState::LineState):
(WebCore::RenderFlexibleBox::performFlexLayout):
(WebCore::RenderFlexibleBox::hypotheticalCrossSizeForFlexItems):
(WebCore::RenderFlexibleBox::crossSizeForFlexLines):
(WebCore::RenderFlexibleBox::handleCrossAxisAlignmentForFlexItems):
(WebCore::RenderFlexibleBox::performBaselineAlignment):
(WebCore::RenderFlexibleBox::computeCrossSizeForFlexLines): Deleted.
(WebCore::RenderFlexibleBox::layoutFlexLines): Deleted.

Canonical link: https://commits.webkit.org/316954@main
pull Bot referenced this pull request in coleleavitt/WebKit Jul 19, 2026
…xItem and marginBoxAscentForFlexItem instead of reading the renderer

https://bugs.webkit.org/show_bug.cgi?id=318518

Reviewed by Antti Koivisto.

Following 318517, which captured each flex item's used cross size into
computeCrossSizeForFlexItems's list, route the remaining post-stretch cross-axis
alignment reads through that list. availableAlignmentSpaceForFlexItem and
marginBoxAscentForFlexItem now take the used cross size as an argument rather than
reading crossAxisExtentForFlexItem (the renderer's border box) themselves.

Their post-stretch callers (handleCrossAxisAlignmentForFlexItems and
performBaselineAlignment) pass crossSizes[itemIndex] -- the value captured in #11,
which nothing relays out before these phases, so it is exactly what they read from
the renderer before. The two callers that run outside that window pass
crossAxisExtentForFlexItem directly, unchanged: crossSizeForFlexLines (#8, before
the stretch pass, and only for baseline items, which are never stretched) and the
out-of-flow static-position path, whose item is not in the list. So the used
cross size now flows through the algorithm's list for the whole post-stretch
alignment path; the only renderer cross-size reads left are #8 and the external
baseline queries (firstLineBaseline / baselinePosition).

No change in behavior.

* Source/WebCore/rendering/RenderFlexibleBox.h:
* Source/WebCore/rendering/RenderFlexibleBox.cpp:
(WebCore::RenderFlexibleBox::availableAlignmentSpaceForFlexItem):
(WebCore::RenderFlexibleBox::marginBoxAscentForFlexItem):
(WebCore::RenderFlexibleBox::staticCrossAxisPositionForPositionedFlexItem):
(WebCore::RenderFlexibleBox::crossSizeForFlexLines):
(WebCore::RenderFlexibleBox::handleCrossAxisAlignmentForFlexItems):
(WebCore::RenderFlexibleBox::performBaselineAlignment):

Canonical link: https://commits.webkit.org/316980@main
robobun added a commit that referenced this pull request Jul 22, 2026
ARM64 .xdata encodes FunctionLength in 18 bits of instruction count, so one
RUNTIME_FUNCTION covers at most ~1 MB; the 512 MB pool needs an entry per
chunk. All full-size chunks share one .xdata, the tail chunk a second. The
unwind codes describe stp fp, lr, [sp, #-16]!; mov fp, sp (set_fp,
save_fplr_x 1, end). The handler thunk is ldr x16, #8; br x16; .quad
jscJITSEHHandler.

Also drops the Chromium-style k-prefixed constants in the x64 path in favour
of the UNW_FLAG_EHANDLER winnt.h macro and inline values.
dylan-conway pushed a commit that referenced this pull request Jul 23, 2026
* JSC(win-x64): register RtlAddFunctionTable unwind info for the fixed JIT pool

On Windows x64 JavaScriptCore's JIT code has no RUNTIME_FUNCTION entries, so
RtlLookupFunctionEntry returns NULL for any JIT PC and frame-based SEH
dispatch cannot unwind through a JIT frame. This breaks
RtlCaptureStackBackTrace at the first JIT frame and makes
SetUnhandledExceptionFilter unreachable for faults under JIT.

Reserve the first page of the fixed executable pool for a single
RUNTIME_FUNCTION + UNWIND_INFO covering the rest of the pool and register it
with RtlAddFunctionTable. The unwind codes describe the push rbp; mov rbp, rsp
prologue every JIT tier emits (AssemblyHelpers::emitFunctionPrologue and
LLInt functionPrologue), so rbp-chain unwinding is valid for the whole range.
An EHANDLER thunk jumps to jscJITSEHHandler, which by default returns
ExceptionContinueSearch; embedders can install a language-specific handler via
JSC::setJITExceptionHandlerWin.

This mirrors V8's RegisterNonABICompliantCodeRange
(src/diagnostics/unwinding-info-win64.cc).

* JSC(win): add ARM64 unwind-info path and use WebKit-style naming

ARM64 .xdata encodes FunctionLength in 18 bits of instruction count, so one
RUNTIME_FUNCTION covers at most ~1 MB; the 512 MB pool needs an entry per
chunk. All full-size chunks share one .xdata, the tail chunk a second. The
unwind codes describe stp fp, lr, [sp, #-16]!; mov fp, sp (set_fp,
save_fplr_x 1, end). The handler thunk is ldr x16, #8; br x16; .quad
jscJITSEHHandler.

Also drops the Chromium-style k-prefixed constants in the x64 path in favour
of the UNW_FLAG_EHANDLER winnt.h macro and inline values.

* JSC(win): use memory_order_relaxed for the JIT SEH globals

Both are set once during single-threaded JSC::initialize() before any thread
that could read them exists; matches the m_bytesAllocated pattern in this
file.

* JSC(win): use WTF::Atomic instead of std::atomic

* JSC(win): use RtlAddGrowableFunctionTable so out-of-process walkers see the entry

RtlAddFunctionTable works for in-process SEH and RtlVirtualUnwind, but
out-of-process stack walkers (ETW, WPA, WinDbg) read the growable-table
list from the target process. This is why V8's RtlAddFunctionTable path is
the 'exception handling only' Win7 fallback and SpiderMonkey's
RegisterExecutableMemory (js/src/jit/ProcessExecutableMemory.cpp) calls the
growable API under the comment 'Required for enabling Stackwalking on
windows using external tools'.

RtlAddGrowableFunctionTable writes into the record region, so write-protect
only after it returns.

* JSC(win): register unwind info for the LLInt and wasm IPInt ranges too

vmEntryToJavaScript and the LLInt bytecode handlers are emitted by
offlineasm into .text without .seh_* directives (and ARM64 builds the LLInt
TU with -fno-unwind-tables), so they have no static .pdata. Every JS stack
has at least one such frame, so SEH / RtlCaptureStackBackTrace would still
derail there even with the JIT pool covered.

Register a second growable table over [llintPCRangeStart, llintPCRangeEnd)
(and the wasm IPInt range) using the same prologue unwind codes. The unwind
info lives in image .data so RUNTIME_FUNCTION.UnwindData can address it as
an image-base-relative RVA; the handler is in image .text so no thunk is
needed. Two fixed .data slots cover both callers.

* JSC(win): fix build and registerImageUnwindInfoWin correctness

- Link ntdll for RtlAddGrowableFunctionTable (kernel32 has no forwarder,
  unlike RtlAddFunctionTable).
- registerImageUnwindInfoWin: pass imageBase as RangeBase. RVAs are
  image-base-relative, and RangeBase is what RtlLookupFunctionEntry returns
  as *ImageBase and resolves all RVAs against; the previous rangeStart base
  never matched so the LLInt table was dead.
- Use &__ImageBase instead of GetModuleHandleW(nullptr) so the base is
  correct if JSC is ever linked as a DLL.
- Drop the separate wasmIPInt registration: those labels sit between
  llintPCRangeStart/End in LowLevelInterpreter.asm, so the LLInt
  registration already covers them. One .data slot now suffices.

* JSC(win): drop the dynamic LLInt unwind registration

RtlLookupFunctionEntry for a PC inside a loaded module consults only that
module's static .pdata; dynamic growable tables are for anonymous memory. The
LLInt table therefore never resolved (verified on Windows 10/11 x64 and ARM64
via Bun CI build 78474).

V8 solves this at build time by emitting .pdata/.xdata for its embedded
builtins (platform-embedded-file-writer-win.cc). The JSC equivalent is
offlineasm emitting .seh_* directives; that belongs in a separate change. A
comment pointing at it is left where the dynamic registration used to be.

The JIT pool registration (anonymous memory) is validated working on both
arches and stays.
Jarred-Sumner pushed a commit that referenced this pull request Sep 4, 2026
https://bugs.webkit.org/show_bug.cgi?id=322779
rdar://186041838

Reviewed by Keith Miller.

riscLowerTest lowers every masked test-and-branch:

    btpnz t0, 8, .foo

into an and into a temporary followed by a compare-and-branch on it:

    and x13, x0, #8
    cbnz x13, .foo

When the mask is a single bit, ARM64 has an instruction for exactly this:

    tbnz x0, #3, .foo

Only local-label targets are folded.

* Source/JavaScriptCore/offlineasm/arm64.rb:
* Source/JavaScriptCore/offlineasm/risc.rb:

Canonical link: https://commits.webkit.org/320266@main
samm-git pushed a commit to samm-git/WebKit that referenced this pull request Oct 22, 2026
…e / jfalse follows

https://bugs.webkit.org/show_bug.cgi?id=327327
rdar://189865582

Reviewed by Keith Miller and Tadeu Zagallo.

Currently, when we have a code like,

    function notInstance(term) {
        if (!(term instanceof Pair))
            return term;
        return term.car;
    }

`instanceof` creates a graph due to multiple complicated arms, and then
all of boolean results are combined into one phi, and then we jump based
on this phi result. However this form pessimizes the optimizations.

    oven-sh#3  MatchStructure arm         D@74: MatchStructure(D@63, Object=>true)
                                   D@76: SetLocal(D@74, loc5)
                                   D@77: Jump(T:oven-sh#7)
    oven-sh#4  value-not-object arm       D@59: JSConstant(False)
                                   D@61: SetLocal(D@59, loc5)
                                   D@62: Jump(T:oven-sh#7)
    oven-sh#5  custom hasInstance arm     D@47: InstanceOfCustom(...)
                                   D@49: SetLocal(D@47, loc5)
                                   D@50: Jump(T:oven-sh#7)

    oven-sh#7 (bc#25)  preds: oven-sh#5 oven-sh#3 oven-sh#4    D@78: GetLocal(loc5)
                                   D@79: Branch(D@78, T:oven-sh#9, F:oven-sh#8)
    oven-sh#8 (bc#28)  return term
    oven-sh#9 (bc#30)  CheckStructure(term, [Object]); GetByOffset(car); Return

In the above graph, due to unified blocks, D@74 MatchStructure's
filtering result is gone, and CheckStructure remains while we already
did Structure check via MatchStructure in one of the most common case.

So, we connect each jump directly when `instanceof` result is used with
`jtrue` / `jfalse`, like

    oven-sh#3  MatchStructure arm         D@74: MatchStructure(D@63, Object=>true)
                                   D@76: SetLocal(D@74, loc5)
                                   D@77: Branch(D@74, T:oven-sh#8, F:oven-sh#7)
    oven-sh#4  value-not-object arm       D@59: JSConstant(False)
                                   D@61: SetLocal(D@59, loc5)
                                   D@62: Branch(D@59, T:oven-sh#8, F:oven-sh#7)
    oven-sh#5  custom hasInstance arm     D@47: InstanceOfCustom(...)
                                   D@49: SetLocal(D@47, loc5)
                                   D@50: Branch(D@47, T:oven-sh#8, F:oven-sh#7)

    oven-sh#7 (bc#28)  preds: oven-sh#5 oven-sh#3 oven-sh#4    return term
    oven-sh#8 (bc#30)  preds: oven-sh#5 oven-sh#3 oven-sh#4    CheckStructure(term, [Object]); GetByOffset(car); Return

                                   D@76: SetLocal(D@74, loc5)
                                   D@77: Jump(T:oven-sh#7)
                                   D@61: SetLocal(D@59, loc5)
                                   D@62: Jump(T:oven-sh#7)
                                   D@49: SetLocal(D@47, loc5)
                                   D@50: Jump(T:oven-sh#7)

                                   D@79: Branch(D@78, T:oven-sh#9, F:oven-sh#8)

Then, eventually each MatchStructure, etc. are foled into constant, and
proper constant is propagated through the following blocks instead of
propagating the phi.

Test: JSTests/stress/instanceof-branch-fusion.js

* JSTests/stress/instanceof-branch-fusion.js: Added.
(shouldBe):
(Pair):
(Custom.Symbol.hasInstance):
(Custom):
(notInstance):
(isInstance):
(resultUsedAfterBranch):
(custom):
(loop):
(customJtrue):
(argumentDst):
(longBody):
(longBodyExpected):
(inlinedPredicate):
(inlinedCaller):
(catch):
* Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp:
(JSC::DFG::ByteCodeParser::parseBlock):

Canonical link: https://commits.webkit.org/323664@main
samm-git pushed a commit to samm-git/WebKit that referenced this pull request Nov 4, 2026
…widest item, not the sum of its lines

https://bugs.webkit.org/show_bug.cgi?id=327945
<rdar://problem/190313974>

Reviewed by Antti Koivisto.

CSS Flexbox 9.9.2: a multi-line column container's max-content width is the sum of the cross sizes of the flex lines it gets under a cross-axis max-content constraint, plus the gaps.
We used its widest item, as if the items stayed on a single line.

FlexLayout::maximumContentSizeForMultilineColumn now runs flex steps 9.2 to 9.4 oven-sh#8 with each item at its max-content width and sums the line cross sizes and gaps.
It skips this when the items can't wrap and none is baseline-aligned; percentages resolve against zero, and the cached block sizes stay untouched.
Items laid out this way are marked for layout, and so is the container, since grid and flex parents can ask a laid-out container again.
Grid now lays out dirty baseline-aligned items before each track sizing pass, and css3/flexbox multiline tests expect the summed line widths.

Tests: imported/w3c/web-platform-tests/css/css-flexbox/intrinsic-size/col-wrap-baseline-001.html
       imported/w3c/web-platform-tests/css/css-flexbox/intrinsic-size/col-wrap-calc-size-001.html
       imported/w3c/web-platform-tests/css/css-flexbox/intrinsic-size/col-wrap-grid-item-001.html
       imported/w3c/web-platform-tests/css/css-flexbox/intrinsic-size/col-wrap-percentage-001.html

* LayoutTests/TestExpectations:
* LayoutTests/css3/flexbox/multiline-justify-content.html:
* LayoutTests/css3/flexbox/multiline.html:
* LayoutTests/imported/w3c/web-platform-tests/css/css-flexbox/alignment/multiline-align-self-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/css-flexbox/flex-container-max-content-002.tentative-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/css-flexbox/inline-flexbox-wrap-vertically-width-calculation-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/css-flexbox/intrinsic-size/col-wrap-005-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/css-flexbox/intrinsic-size/col-wrap-019-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/css-flexbox/intrinsic-size/col-wrap-baseline-001-expected.txt: Added.
* LayoutTests/imported/w3c/web-platform-tests/css/css-flexbox/intrinsic-size/col-wrap-baseline-001.html: Added.
* LayoutTests/imported/w3c/web-platform-tests/css/css-flexbox/intrinsic-size/col-wrap-calc-size-001-expected.txt: Added.
* LayoutTests/imported/w3c/web-platform-tests/css/css-flexbox/intrinsic-size/col-wrap-calc-size-001.html: Added.
* LayoutTests/imported/w3c/web-platform-tests/css/css-flexbox/intrinsic-size/col-wrap-grid-item-001-expected.txt: Added.
* LayoutTests/imported/w3c/web-platform-tests/css/css-flexbox/intrinsic-size/col-wrap-grid-item-001.html: Added.
* LayoutTests/imported/w3c/web-platform-tests/css/css-flexbox/intrinsic-size/col-wrap-percentage-001-expected.txt: Added.
* LayoutTests/imported/w3c/web-platform-tests/css/css-flexbox/intrinsic-size/col-wrap-percentage-001.html: Added.
* Source/WebCore/layout/formattingContexts/flex/FlexFormattingContext.cpp:
(WebCore::FlexFormattingContext::layout): Report the line wraps to the Inspector here, so computing the intrinsic widths does not.
(WebCore::FlexFormattingContext::maximumContentSizeForMultilineColumn): Added.
(WebCore::FlexFormattingContext::computeFlexLines):
(WebCore::FlexFormattingContext::crossSizeForFlexLines):
(WebCore::FlexFormattingContext::performBaselineAlignment):
(WebCore::FlexFormattingContext::flexItemCrossSizeIsDefinite):
* Source/WebCore/layout/formattingContexts/flex/FlexFormattingContext.h:
* Source/WebCore/layout/formattingContexts/flex/FlexFormattingUtils.cpp:
(WebCore::FlexFormattingUtils::participatesInBaselineAlignment): Added.
(WebCore::FlexFormattingUtils::participatesInBaselineAlignment const): Added.
(WebCore::FlexFormattingUtils::maximumContentSizeNeedsFlexLines): Added.
* Source/WebCore/layout/formattingContexts/flex/FlexFormattingUtils.h:
* Source/WebCore/layout/integration/flex/FlexIntegrationUtils.cpp:
(WebCore::LayoutIntegration::FlexIntegrationUtils::computeBlockAxisContentSizeForFlexItem):
(WebCore::LayoutIntegration::FlexIntegrationUtils::isComputingIntrinsicLogicalWidths const): Added.
* Source/WebCore/layout/integration/flex/FlexIntegrationUtils.h:
* Source/WebCore/layout/integration/flex/LayoutIntegrationFlexLayout.cpp:
(WebCore::LayoutIntegration::FlexLayout::computeIntrinsicLogicalWidths):
(WebCore::LayoutIntegration::FlexLayout::intrinsicLogicalWidthsForFlexItem const): Added.
(WebCore::LayoutIntegration::FlexLayout::FlexItemsAtMaxContentWidthScope::FlexItemsAtMaxContentWidthScope): Added.
(WebCore::LayoutIntegration::FlexLayout::FlexItemsAtMaxContentWidthScope::~FlexItemsAtMaxContentWidthScope): Added.
(WebCore::LayoutIntegration::FlexLayout::maximumContentSizeForMultilineColumn): Added.
(WebCore::LayoutIntegration::FlexLayout::setFlexItemContentLogicalHeightFromLayout):
(WebCore::LayoutIntegration::FlexLayout::computeIntrinsicLogicalWidths const): Deleted.
* Source/WebCore/layout/integration/flex/LayoutIntegrationFlexLayout.h:
* Source/WebCore/rendering/GridTrackSizingAlgorithm.cpp:
(WebCore::GridTrackSizingAlgorithm::setup):
* Source/WebCore/rendering/RenderFlexibleBox.cpp:
(WebCore::RenderFlexibleBox::computeIntrinsicLogicalWidths const):

Canonical link: https://commits.webkit.org/324662@main
dylan-conway pushed a commit that referenced this pull request Nov 8, 2026
`bool isWaitOfCall` is the tenth word of the arguments. On arm64 eight go in registers, so it lies in the
frame of the caller (lockAcquire(), rlockAcquire(), simpleQueueGet(), threadHandleJoin()), under which the
thread sleeps, and clang stores a bool there with `strb`: one byte, with seven of whatever the word
was before behind it. If that was the address of a cell that ends in 00, it still points into the cell:
the kind of word that was taken out of waitUntil()'s own frame.

Seen in the code that clang makes for aarch64-linux-gnu of a model of the call (-O2):
`strb w9, [sp, #8]` for the bool, `stp x8, x9, [sp]` with a word in its place. No arm64 build has
been run. On x86-64 four bytes are written, which is enough.

README: Ctypes::functionCall() has two slots that no instruction names, not one.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants