Skip to content

WebGL bot should run tests with GPU Process enabled - #24

Closed
ryanhaddad wants to merge 1 commit into
WebKit:mainfrom
ryanhaddad:eng/webgl-gpup-bot
Closed

ryanhaddad wants to merge 1 commit into
WebKit:mainfrom
ryanhaddad:eng/webgl-gpup-bot

Conversation

@ryanhaddad

@ryanhaddad ryanhaddad commented Oct 21, 2021 •

Copy link
Copy Markdown
Contributor

abbb58f

WebGL bot should run tests with GPU Process enabled
https://bugs.webkit.org/show_bug.cgi?id=232107

Reviewed by NOBODY (OOPS!).

* CISupport/build-webkit-org/config.json:

@ryanhaddad

Copy link
Copy Markdown
Contributor Author

@ryanhaddad ryanhaddad closed this Oct 22, 2021
webkit-early-warning-system pushed a commit to MenloDorian/Webkit that referenced this pull request Jun 23, 2022
https://bugs.webkit.org/show_bug.cgi?id=241905

Reviewed by Yusuke Suzuki.

offlineasm used to emit this LLInt code:
    ".loc 1 996\n"        "ldr x19, [x0] \n"                   // LowLevelInterpreter.asm:996
    ".loc 1 997\n"        "ldr x20, [x0, WebKit#8] \n"               // LowLevelInterpreter.asm:997
    ".loc 1 998\n"        "ldr x21, [x0, WebKit#16] \n"              // LowLevelInterpreter.asm:998
    ".loc 1 999\n"        "ldr x22, [x0, WebKit#24] \n"              // LowLevelInterpreter.asm:999
    ...
    ".loc 1 1006\n"       "ldr d8, [x0, WebKit#80] \n"               // LowLevelInterpreter.asm:1006
    ".loc 1 1007\n"       "ldr d9, [x0, WebKit#88] \n"               // LowLevelInterpreter.asm:1007
    ".loc 1 1008\n"       "ldr d10, [x0, WebKit#96] \n"              // LowLevelInterpreter.asm:1008
    ".loc 1 1009\n"       "ldr d11, [x0, WebKit#104] \n"             // LowLevelInterpreter.asm:1009
    ...

Now, it can emit this instead:
    ".loc 1 996\n"        "ldp x19, x20, [x0, #0] \n"          // LowLevelInterpreter.asm:996
    ".loc 1 997\n"        "ldp x21, x22, [x0, WebKit#16] \n"         // LowLevelInterpreter.asm:997
    ...
    ".loc 1 1001\n"       "ldp d8, d9, [x0, WebKit#80] \n"           // LowLevelInterpreter.asm:1001
    ".loc 1 1002\n"       "ldp d10, d11, [x0, WebKit#96] \n"         // LowLevelInterpreter.asm:1002
    ...

Also, there was some code that kept recomputing the base address of a sequence of load/store
instructions.  For example,
    ".loc 6 902\n"        "add x13, sp, x10, lsl WebKit#3 \n"        // WebAssembly.asm:902
                          "ldr x0, [x13, WebKit#48] \n"
                          "add x13, sp, x10, lsl WebKit#3 \n"
                          "ldr x1, [x13, WebKit#56] \n"
                          "add x13, sp, x10, lsl WebKit#3 \n"
                          "ldr x2, [x13, WebKit#64] \n"
                          "add x13, sp, x10, lsl WebKit#3 \n"
                          "ldr x3, [x13, WebKit#72] \n"
    ...

For such places, we observe that the base address is the same for every load/store instruction
in the sequence, and precompute it in the LLInt asm code to help out the offline asm.  This
allows the offlineasm to now emit this more efficient code instead:
    ".loc 6 896\n"        "add x10, sp, x10, lsl WebKit#3 \n"        // WebAssembly.asm:896
    ".loc 6 898\n"        "ldp x0, x1, [x10, WebKit#48] \n"          // WebAssembly.asm:898
                          "ldp x2, x3, [x10, WebKit#64] \n"
    ...

* Source/JavaScriptCore/llint/LowLevelInterpreter.asm:
* Source/JavaScriptCore/llint/WebAssembly.asm:
* Source/JavaScriptCore/offlineasm/arm64.rb:
* Source/JavaScriptCore/offlineasm/instructions.rb:

Canonical link: https://commits.webkit.org/251799@main
webkit-early-warning-system pushed a commit to justinmichaud/WebKit that referenced this pull request Aug 3, 2022
https://bugs.webkit.org/show_bug.cgi?id=243358

Reviewed by Yusuke Suzuki.

Add support for ARM64 disassembler comments in jit code. We use a global map of code
address -> comments, which is updated during linking. Comments do nothing when
dumpDisassembly=0.

Also, we opt-out some MacroAssembler files from unified builds to fix build
errors caused by a RegisterID symbol conflict that this patch accidentally exposes.

Here is an example of a comment:

```
comment(scratchGPR, " = callFrame->callee->executableOrRareData");
emitGetFromCallFrameHeaderPtr(CallFrameSlot::callee, scratchGPR);
loadPtr(Address(scratchGPR, JSFunction::offsetOfExecutableOrRareData()), scratchGPR);
auto hasExecutable = branchTestPtr(Zero, scratchGPR, TrustedImm32(JSFunction::rareDataTag));
loadPtr(Address(scratchGPR, FunctionRareData::offsetOfExecutable() - JSFunction::rareDataTag), scratchGPR);
hasExecutable.link(this);
comment(scratchGPR, " = (", scratchGPR, ": Executable)->codeBlock");
loadPtr(Address(scratchGPR, FunctionExecutable::offsetOfCodeBlockFor(kind)), scratchGPR);
```

becomes

```
<44> 0x12e51c02c:    ldur     x1, [fp, WebKit#24]; %x1 = callFrame->callee->executableOrRareData
<48> 0x12e51c030:    ldur     x1, [x1, WebKit#24]
<52> 0x12e51c034:    tbz      x1, #0, 0x12e51c03c -> <60>
<56> 0x12e51c038:    ldur     x1, [x1, WebKit#47]
<60> 0x12e51c03c:    ldur     x1, [x1, WebKit#96]; %x1 = (%x1: Executable)->codeBlock
```

* Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj:
* Source/JavaScriptCore/Sources.txt:
* Source/JavaScriptCore/assembler/AbstractMacroAssembler.h:
(JSC::AbstractMacroAssembler::comment):
(JSC::AbstractMacroAssembler::lineComment):
(JSC::AbstractMacroAssembler::commentImpl):
* Source/JavaScriptCore/assembler/Comments.cpp: Copied from Source/JavaScriptCore/disassembler/ARM64Disassembler.cpp.
(JSC::CommentRegistry::initialize):
(JSC::CommentRegistry::singleton):
* Source/JavaScriptCore/assembler/Comments.h: Added.
(JSC::CommentRegistry::WTF_RETURNS_LOCK):
(JSC::CommentRegistry::registerCodeRange):
(JSC::CommentRegistry::unregisterCodeRange):
(JSC::CommentRegistry::comment):
(JSC::CommentRegistry::orderedKey):
(JSC::CommentRegistry::orderedKeyInverse):
* Source/JavaScriptCore/assembler/LinkBuffer.cpp:
(JSC::LinkBuffer::linkCode):
(JSC::LinkBuffer::linkComments):
* Source/JavaScriptCore/assembler/LinkBuffer.h:
* Source/JavaScriptCore/disassembler/ARM64Disassembler.cpp:
(JSC::tryToDisassemble):
* Source/JavaScriptCore/jit/AssemblyHelpers.cpp:
(JSC::AssemblyHelpers::jitAssertCodeBlockOnCallFrameWithType):
(JSC::AssemblyHelpers::jitAssertCodeBlockMatchesCurrentCalleeCodeBlockOnCallFrame):
* Source/JavaScriptCore/jit/ExecutableAllocator.cpp:
(JSC::ExecutableMemoryHandle::~ExecutableMemoryHandle):
* Source/JavaScriptCore/runtime/InitializeThreading.cpp:
(JSC::initialize):

remove unified sources for macroasm

Canonical link: https://commits.webkit.org/253085@main
@ryanhaddad
ryanhaddad deleted the eng/webgl-gpup-bot branch February 4, 2025 20:54
webkit-commit-queue pushed a commit that referenced this pull request Mar 15, 2026
rdar://172148530
https://bugs.webkit.org/show_bug.cgi?id=309547

Reviewed by Ryosuke Niwa and BJ Burg.

FontCascade.h was the #24 most expensive header in WebCore by total parse
time (328 inclusions × 535ms average = 175s). This patch reduces that to
328 × 366ms = 120s, a ~32% improvement, moving it to #36.

Changes to FontCascade.h:
- Remove includes of FloatSegment.h, FontCascadeFonts.h, Path.h,
  TextSpacing.h, CheckedRef.h, HashSet.h, CharacterProperties.h,
  CharacterNames.h, and RuntimeApplicationChecksCocoa.h, replacing them
  with forward declarations where needed.
- Move inline method bodies (primaryFont, fallbackRangesAt, isFixedPitch,
  canTakeFixedPitchFastContentMeasuring, fontSelector, isPlatformFont,
  metricsOfPrimaryFont, tabWidth, widthForTextUsingSimplifiedMeasuring,
  widthOfSpaceString, treatAsSpace, treatAsZeroWidthSpace,
  treatAsZeroWidthSpaceInComplexScript, normalizeSpaces,
  isCharacterWhoseGlyphsShouldBeDeletedForTextRendering,
  isInvisibleReplacementObjectCharacter) to FontCascadeInlines.h.
- Extract CodePath and CustomFontNotReadyAction enums to a new
  lightweight FontCascadeEnums.h so downstream headers can reference
  these types without pulling in all of FontCascade.h.
- Move GlyphGeometryCacheEntry out of FontCascadeFonts to namespace
  scope so it can be forward-declared in FontCascade.h.

Changes to Font.h:
- Remove includes of GlyphPage.h, Hasher.h, StringHash.h,
  OpenTypeMathData.h, and OpenTypeVerticalData.h.
- Move inline method bodies (boundsForGlyph, boundsForGlyphs,
  widthForGlyph, verticalData) to a new FontInlines.h.

~90 .cpp/.mm files are updated to add explicit includes for headers they
previously obtained transitively.

Tests: Tools/TestWebKitAPI/Tests/WebCore/ComplexTextController.cpp
       Tools/TestWebKitAPI/Tests/WebCore/MonospaceFontTests.cpp
       Tools/TestWebKitAPI/Tests/WebCore/cg/BifurcatedGraphicsContextTestsCG.cpp

* Source/WebCore/WebCore.xcodeproj/project.pbxproj:
* Source/WebCore/accessibility/AXTextMarker.cpp:
* Source/WebCore/accessibility/cocoa/AccessibilityObjectCocoa.mm:
* Source/WebCore/css/parser/SizesAttributeParser.cpp:
* Source/WebCore/dom/DocumentMarkerController.cpp:
* Source/WebCore/dom/ImageOverlay.cpp:
* Source/WebCore/editing/Editor.cpp:
* Source/WebCore/editing/TextManipulationController.cpp:
* Source/WebCore/editing/cocoa/EditingHTMLConverter.mm:
* Source/WebCore/editing/cocoa/NodeHTMLConverter.mm:
* Source/WebCore/editing/cocoa/WebContentReaderCocoa.mm:
* Source/WebCore/html/HTMLAnchorElement.cpp:
* Source/WebCore/html/HTMLTextFormControlElement.cpp:
* Source/WebCore/html/NumberInputType.cpp:
* Source/WebCore/html/canvas/CanvasRenderingContext2DBase.cpp:
* Source/WebCore/html/canvas/CanvasRenderingContext2DBase.h:
* Source/WebCore/html/canvas/OffscreenCanvasRenderingContext2D.cpp:
* Source/WebCore/inspector/InspectorOverlay.cpp:
* Source/WebCore/inspector/agents/InspectorCSSAgent.cpp:
* Source/WebCore/layout/formattingContexts/inline/InlineContentBreaker.cpp:
* Source/WebCore/layout/formattingContexts/inline/InlineContentConstrainer.cpp:
* Source/WebCore/layout/formattingContexts/inline/InlineItemsBuilder.cpp:
* Source/WebCore/layout/formattingContexts/inline/InlineLevelBox.h:
* Source/WebCore/layout/formattingContexts/inline/InlineLevelBoxInlines.h:
* Source/WebCore/layout/formattingContexts/inline/display/InlineDisplayContentBuilder.cpp:
* Source/WebCore/layout/formattingContexts/inline/text/TextUtil.cpp:
* Source/WebCore/layout/formattingContexts/inline/text/TextUtil.h:
* Source/WebCore/layout/integration/LayoutIntegrationBoxGeometryUpdater.cpp:
* Source/WebCore/layout/integration/inline/InlineIteratorBoxModernPath.h:
* Source/WebCore/layout/integration/inline/InlineIteratorSVGTextBox.cpp:
* Source/WebCore/layout/integration/inline/LayoutIntegrationInlineContentBuilder.cpp:
* Source/WebCore/layout/layouttree/LayoutTreeBuilder.cpp:
* Source/WebCore/loader/cache/CachedImage.cpp:
* Source/WebCore/page/DebugPageOverlays.cpp:
* Source/WebCore/platform/graphics/ComplexTextController.cpp:
* Source/WebCore/platform/graphics/Font.cpp:
* Source/WebCore/platform/graphics/Font.h:
(WebCore::Font::ctFont const):
(WebCore::Font::verticalData const): Deleted.
(WebCore::Font::boundsForGlyph const): Deleted.
(WebCore::Font::boundsForGlyphs const): Deleted.
(WebCore::Font::widthForGlyph const): Deleted.
* Source/WebCore/platform/graphics/FontCascade.cpp:
(WebCore::FontCascade::widthForSimpleTextSlow const):
* Source/WebCore/platform/graphics/FontCascade.h:
(WebCore::FontCascade::primaryFont const): Deleted.
(WebCore::FontCascade::fallbackRangesAt const): Deleted.
(WebCore::FontCascade::isFixedPitch const): Deleted.
(WebCore::FontCascade::canTakeFixedPitchFastContentMeasuring const): Deleted.
(WebCore::FontCascade::fontSelector const): Deleted.
(WebCore::FontCascade::tabWidth const): Deleted.
(WebCore::FontCascade::widthForTextUsingSimplifiedMeasuring const): Deleted.
* Source/WebCore/platform/graphics/FontCascadeEnums.h: Copied from Source/WebKit/WebProcess/WebCoreSupport/mac/WebPopupMenuMac.mm.
* Source/WebCore/platform/graphics/FontCascadeFonts.h:
* Source/WebCore/platform/graphics/FontCascadeInlines.h:
(WebCore::FontCascade::primaryFont const):
(WebCore::FontCascade::fallbackRangesAt const):
(WebCore::FontCascade::isFixedPitch const):
(WebCore::FontCascade::canTakeFixedPitchFastContentMeasuring const):
(WebCore::FontCascade::fontSelector const):
(WebCore::FontCascade::tabWidth const):
(WebCore::FontCascade::widthForTextUsingSimplifiedMeasuring const):
(WebCore::FontCascade::isPlatformFont const):
(WebCore::FontCascade::metricsOfPrimaryFont const):
(WebCore::FontCascade::isInvisibleReplacementObjectCharacter):
(WebCore::FontCascade::treatAsSpace):
(WebCore::FontCascade::isCharacterWhoseGlyphsShouldBeDeletedForTextRendering):
(WebCore::FontCascade::treatAsZeroWidthSpace):
(WebCore::FontCascade::treatAsZeroWidthSpaceInComplexScript):
(WebCore::FontCascade::normalizeSpaces):
(WebCore::FontCascade::widthOfSpaceString const):
* Source/WebCore/platform/graphics/FontInlines.h: Added.
(WebCore::Font::verticalData const):
(WebCore::Font::boundsForGlyph const):
(WebCore::Font::boundsForGlyphs const):
(WebCore::Font::widthForGlyph const):
* Source/WebCore/platform/graphics/TextMeasurementCache.h:
* Source/WebCore/platform/graphics/WidthIterator.cpp:
* Source/WebCore/platform/graphics/ca/PlatformCALayer.mm:
* Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp:
* Source/WebCore/platform/graphics/coretext/ComplexTextControllerCoreText.mm:
* Source/WebCore/platform/graphics/coretext/DrawGlyphsRecorder.cpp:
* Source/WebCore/platform/graphics/coretext/FontCascadeCoreText.cpp:
* Source/WebCore/platform/graphics/opentype/OpenTypeVerticalData.cpp:
* Source/WebCore/platform/mock/MockRealtimeVideoSource.cpp:
* Source/WebCore/platform/text/TextSpacing.cpp:
* Source/WebCore/platform/text/TextSpacing.h:
* Source/WebCore/rendering/LegacyInlineFlowBox.cpp:
* Source/WebCore/rendering/RenderBlock.cpp:
* Source/WebCore/rendering/RenderCombineText.cpp:
* Source/WebCore/rendering/RenderEmbeddedObject.cpp:
* Source/WebCore/rendering/RenderFileUploadControl.cpp:
* Source/WebCore/rendering/RenderImage.cpp:
* Source/WebCore/rendering/RenderInline.cpp:
* Source/WebCore/rendering/RenderLayerBacking.cpp:
* Source/WebCore/rendering/RenderListBox.cpp:
* Source/WebCore/rendering/RenderReplaced.cpp:
* Source/WebCore/rendering/RenderText.cpp:
* Source/WebCore/rendering/TextBoxPainter.cpp:
* Source/WebCore/rendering/line/LineInlineHeaders.h:
* Source/WebCore/rendering/mathml/MathOperator.cpp:
* Source/WebCore/rendering/mathml/RenderMathMLFraction.cpp:
* Source/WebCore/rendering/mathml/RenderMathMLOperator.cpp:
* Source/WebCore/rendering/mathml/RenderMathMLScripts.cpp:
* Source/WebCore/rendering/mathml/RenderMathMLToken.cpp:
* Source/WebCore/rendering/style/RenderStyle.cpp:
* Source/WebCore/rendering/svg/RenderSVGInlineText.cpp:
* Source/WebCore/rendering/svg/RenderSVGText.cpp:
* Source/WebCore/rendering/svg/SVGInlineTextBox.cpp:
* Source/WebCore/rendering/svg/SVGTextBoxPainter.cpp:
* Source/WebCore/rendering/svg/SVGTextLayoutEngineBaseline.cpp:
* Source/WebCore/rendering/updating/RenderTreeBuilderFirstLetter.cpp:
* Source/WebCore/style/InlineTextBoxStyle.cpp:
* Source/WebCore/style/StyleBuilderCustom.h:
* Source/WebCore/style/StyleExtractorCustom.h:
* Source/WebCore/style/StyleInterpolationFunctions.h:
* Source/WebCore/style/StyleResolver.cpp:
* Source/WebCore/style/computed/StyleComputedStyleBase.cpp:
* Source/WebCore/style/values/primitives/StyleLengthResolution.cpp:
* Source/WebKit/WebProcess/WebCoreSupport/mac/WebPopupMenuMac.mm:
* Source/WebKitLegacy/mac/DOM/DOM.mm:
* Source/WebKitLegacy/mac/WebCoreSupport/PopupMenuMac.mm:
* Tools/TestWebKitAPI/Tests/WebCore/ComplexTextController.cpp:
* Tools/TestWebKitAPI/Tests/WebCore/MonospaceFontTests.cpp:
* Tools/TestWebKitAPI/Tests/WebCore/cg/BifurcatedGraphicsContextTestsCG.cpp:

Canonical link: https://commits.webkit.org/309288@main
Wowfunhappy referenced this pull request in Wowfunhappy/WebKit Jun 15, 2026
…NSMenu menuTypeForEvent: (#23/#24)

containsString: is 10.10+ and not polyfilled -> crashed WebContent on any date/time input;
use rangeOfString:. +[NSMenu menuTypeForEvent:] is 10.10+ -> threw mid-click on WebKit1
popovers/Prefs>Extensions; guard it.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Wowfunhappy referenced this pull request in Wowfunhappy/WebKit Jun 18, 2026
The backport installed a global NSEvent monitor (+[WKView installEventMonitorOnce]) that intercepted mouse/scroll/key events and dispatched them to WKView, on the belief that layer-tree mirror subviews intercepted hit-testing. That was a MISDIAGNOSIS: WKView hosts the WebContent layer tree as a plain CALayer sublayer of its backing layer (MinimalPageClient enterAcceleratedCompositingMode/setRemoteLayerTreeRootNode, [[m_view layer] addSublayer:]) with ZERO NSView subviews. CALayers don't participate in NSView -hitTest:, so nothing ever intercepted events. Worse, the monitor consumed events before -[NSWindow sendEvent:] (where AppKit activates the window on click), creating the very click-to-activate problem it then re-patched.

Remove the monitor and rely on AppKit's natural responder chain; WKView's own scrollWheel:/keyDown:/mouseDown:/mouseMoved: handlers receive events directly. Keep the -hitTest: override as upstream-equivalent insurance (upstream WebViewImpl::hitTest does the same redirect).

Verified live: main-view links/scroll/typing/right-click; hover (#17) fires :hover on a fresh page AND with the address bar focused; Reader scroll (#39) works via natural routing to the topmost ReaderWKView; and every secondary WKView that relied on the monitor -- uBlock popover (#14/#23), Web Inspector (#16), App Store (#72), Top Sites (#13), Preferences>Extensions (#24) -- stays interactive. No crashes. Retires the #62 event-monitor keystone and supersedes #39's monitor routing. (The DDG-logo black box, a separate #56 IOSurface-backing symptom, is root-caused but not fixed here.)

Co-Authored-By: Claude Opus 4.8 <[email protected]>
airspeedswift added a commit to airspeedswift/webkit that referenced this pull request Sep 1, 2026
…ee invariants by comment

A safety sweep of yesterday's three finished-token commits found seven hazards removed from the
replaced C++ against seven the port's own boundary introduced -- plus three invariants that used to
be structural and had become conventions. One to one is not a win, and four of the port-side items
were cheap enough to close in one change. They are ledger entries S13 and R1-R3.

`resolveValuePointer` used the *one*-argument `std::span::subspan`, which bounds the start and says
nothing about the count. libc++ hardening is on for every WebCore configuration
(Configurations/CommonBase.xcconfig:122), so the start really was checked -- but `value()` is
`StringView { valueDataCharRaw, valueLength, valueIs8Bit }`, a raw pointer and a trusted count, and
`valueLength` crossed the language boundary unexamined. The C++ this replaced,
`CSSTokenizerInputStream::rangeAt`, clamped both through `StringView::substring` and was
structurally incapable of over-reading, so the boundary went from silently wrong on a bad length to
out of bounds on one. The two-argument overload adds `count <= size() - offset` and returns the
identical pointer. cssprobe/probes/extentcheck demonstrates the difference against this header
rather than a transcription, with the input mmap'd flush against a PROT_NONE page: at offset 60
length 32 of a 64-byte input the old spelling resolves happily and then takes SIGBUS reading the
value's own characters, and the new one traps inside the resolve. Three positive controls -- an
interior value, a value ending exactly at `size()`, and a valueless token that must stay null --
pass on both spellings, so the new check is not merely stricter. Isolated at -O2 with the same
hardening mode the resolve is 13 instructions before and 16 after.

`CSSParserToken`'s bits-taking constructor is private now, with `CSSSwiftTokenSink` as its one
friend. Its precondition -- the bits have been through `resolveValuePointer` -- cannot be put in the
type, because while Swift owns the token the pointer slot holds an offset and nothing in C++ can
tell the difference; the design this replaced could not get that wrong, since the island emitted a
different struct with a `uint32_t valueStart`. A comment was the entire enforcement. It has to be
`tryAppend(CSSParserToken { bits })` rather than `tryConstructAndAppend(bits)`, because Vector
constructs in place and the access check is then made in Vector's context, so friendship would have
had to name Vector and would have widened rather than narrowed. Verified by trying it: a
construction from `CSSTokenizer::tokenCount`, which is not the friend, fails with "calling a private
constructor of class 'WebCore::CSSParserToken'". `cssParserTokenBitsCanRepresentOffsets` now says
what it is actually for: `__PAGEZERO` is 4 GB, the check keeps every parked offset inside it, so a
mis-sequenced resolve faults deterministically instead of reading heap. That is a memory-safety
property and its comment claimed only representability.

The union's active member was a function of the pipeline phase as well as of `type`, and only
`bitsCarryPendingNumber` -- which reads `type` -- stood between `pendingNumberRange` and a
`numericValue` that no factory had written. A `makeSimpleTokenBits(NumberToken, ...)` would have had
its double read out as an offset and a length. `hasParkedNumberRange` is that missing writer-side
half, written beside the member it discriminates and required before `takeChunk` reads the range, so
the read is no longer through a member nothing wrote. It costs nothing: the bitfields summed to 24
bits, so it lands in the free eight of the same allocation unit, and `sizeof(CSSParserToken)` is
still 24 -- now asserted, since "there were eight bits free" is a layout claim. The parked range is
also bounded against the input, because it is a second pair of offsets the island computed and
`rangeAt`'s own check is an `ASSERT` that is compiled out. Negative control: with the discriminant
deliberately cleared in a throwaway build, failcheck's two cases containing numbers fail
construction and the six without one are untouched.

The observer records and the tokens are two parallel buffers with nothing relating their counts, and
a desync feeds `addToken`/`addComment` another token's offsets -- which is entry S7's exact failure,
and S7 shipped. `takeChunk` now counts the non-comment records and requires that to equal
`tokenCount` before the walk, so a violation never reaches the wrapper, and records arriving with no
wrapper at all fail too. It fails the tokenization rather than asserting: the island has no
fallback, and an `ASSERT` is compiled out of exactly the builds where this matters. One pass over a
buffer that is empty on every production tokenization. Negative control: with one record dropped in
a throwaway build, all 58 non-observer csscheck cases still pass and the process dies on the first
line of the inspector phase.

Throughput, and the honest reading is that the 8-bit ratio moved for a reason that is not the
island. Parent and this commit, 15 interleaved rounds on the real captured stylesheets, with a
duplicate-of-one-arm control: the duplicate agrees to 0.002 at 8-bit and 0.001 at 16-bit, and every
gate-off arm reads 0.995-1.007. At 16-bit, where the C++ side's absolute throughput moves by at most
1.6%, the island ratio goes 0.967 -> 0.952: a real cost of about 1.5 points, which is what the
per-token instructions predict. At 8-bit the ratio goes 1.060 -> 0.972, but the *denominator* rose
4.5-11.5% -- 554.8 -> 618.6 MB/s on bigdom -- and the C++ symbols say that cannot be a code change:
1840 C++ symbols, 1834 identical, `CSSTokenizer::CSSTokenizer` at 258 instructions on both sides,
and the six that differ are four out-of-line `CSSParserToken` constructors at +1 each (a byte-aligned
`ldrb`/`orr lsl WebKit#24` becoming `ldr`/`and #0xfe000000`, because the new bit moved the preserved field
off a byte boundary) plus `consumeColor` at -1. So the 8-bit denominator moved by code layout, and
the island's own 8-bit absolute change is -3.9% to +0.9%, geomean -2.3%, well inside an envelope the
denominator itself demonstrates is at least 7%. `takeChunk` is 236 -> 381 instructions, of which 63
are SIMD in a loop clang auto-vectorized out of the record count -- inside `if (m_wrapper)`, so
production never executes it.

Kept at that price, because safety is not tradeable here. The cheaper spelling exists and is not
taken in this commit: specializing the resolve on `m_characterSize`, which is fixed for the whole
tokenization, would remove both multiplies and make the checked version cost one instruction rather
than three. That is an optimisation and belongs in its own change, where it can be measured on its
own.

No Swift changed, so the island's `unsafe` markers are unmoved: 2 plus 2 `_unsafeCxxSpan` in
CSSTokenizerSwift.swift, 0 in CSSUnitTrieSwift.swift and CSSParserFastPathsSwift.swift. 29
non-comment lines of C++ added against 7 removed, all of it checks rather than translation.
airspeedswift added a commit to airspeedswift/webkit that referenced this pull request Sep 4, 2026
…ee invariants by comment

A safety sweep of yesterday's three finished-token commits found seven hazards removed from the
replaced C++ against seven the port's own boundary introduced -- plus three invariants that used to
be structural and had become conventions. One to one is not a win, and four of the port-side items
were cheap enough to close in one change. They are ledger entries S13 and R1-R3.

`resolveValuePointer` used the *one*-argument `std::span::subspan`, which bounds the start and says
nothing about the count. libc++ hardening is on for every WebCore configuration
(Configurations/CommonBase.xcconfig:122), so the start really was checked -- but `value()` is
`StringView { valueDataCharRaw, valueLength, valueIs8Bit }`, a raw pointer and a trusted count, and
`valueLength` crossed the language boundary unexamined. The C++ this replaced,
`CSSTokenizerInputStream::rangeAt`, clamped both through `StringView::substring` and was
structurally incapable of over-reading, so the boundary went from silently wrong on a bad length to
out of bounds on one. The two-argument overload adds `count <= size() - offset` and returns the
identical pointer. cssprobe/probes/extentcheck demonstrates the difference against this header
rather than a transcription, with the input mmap'd flush against a PROT_NONE page: at offset 60
length 32 of a 64-byte input the old spelling resolves happily and then takes SIGBUS reading the
value's own characters, and the new one traps inside the resolve. Three positive controls -- an
interior value, a value ending exactly at `size()`, and a valueless token that must stay null --
pass on both spellings, so the new check is not merely stricter. Isolated at -O2 with the same
hardening mode the resolve is 13 instructions before and 16 after.

`CSSParserToken`'s bits-taking constructor is private now, with `CSSSwiftTokenSink` as its one
friend. Its precondition -- the bits have been through `resolveValuePointer` -- cannot be put in the
type, because while Swift owns the token the pointer slot holds an offset and nothing in C++ can
tell the difference; the design this replaced could not get that wrong, since the island emitted a
different struct with a `uint32_t valueStart`. A comment was the entire enforcement. It has to be
`tryAppend(CSSParserToken { bits })` rather than `tryConstructAndAppend(bits)`, because Vector
constructs in place and the access check is then made in Vector's context, so friendship would have
had to name Vector and would have widened rather than narrowed. Verified by trying it: a
construction from `CSSTokenizer::tokenCount`, which is not the friend, fails with "calling a private
constructor of class 'WebCore::CSSParserToken'". `cssParserTokenBitsCanRepresentOffsets` now says
what it is actually for: `__PAGEZERO` is 4 GB, the check keeps every parked offset inside it, so a
mis-sequenced resolve faults deterministically instead of reading heap. That is a memory-safety
property and its comment claimed only representability.

The union's active member was a function of the pipeline phase as well as of `type`, and only
`bitsCarryPendingNumber` -- which reads `type` -- stood between `pendingNumberRange` and a
`numericValue` that no factory had written. A `makeSimpleTokenBits(NumberToken, ...)` would have had
its double read out as an offset and a length. `hasParkedNumberRange` is that missing writer-side
half, written beside the member it discriminates and required before `takeChunk` reads the range, so
the read is no longer through a member nothing wrote. It costs nothing: the bitfields summed to 24
bits, so it lands in the free eight of the same allocation unit, and `sizeof(CSSParserToken)` is
still 24 -- now asserted, since "there were eight bits free" is a layout claim. The parked range is
also bounded against the input, because it is a second pair of offsets the island computed and
`rangeAt`'s own check is an `ASSERT` that is compiled out. Negative control: with the discriminant
deliberately cleared in a throwaway build, failcheck's two cases containing numbers fail
construction and the six without one are untouched.

The observer records and the tokens are two parallel buffers with nothing relating their counts, and
a desync feeds `addToken`/`addComment` another token's offsets -- which is entry S7's exact failure,
and S7 shipped. `takeChunk` now counts the non-comment records and requires that to equal
`tokenCount` before the walk, so a violation never reaches the wrapper, and records arriving with no
wrapper at all fail too. It fails the tokenization rather than asserting: the island has no
fallback, and an `ASSERT` is compiled out of exactly the builds where this matters. One pass over a
buffer that is empty on every production tokenization. Negative control: with one record dropped in
a throwaway build, all 58 non-observer csscheck cases still pass and the process dies on the first
line of the inspector phase.

Throughput, and the honest reading is that the 8-bit ratio moved for a reason that is not the
island. Parent and this commit, 15 interleaved rounds on the real captured stylesheets, with a
duplicate-of-one-arm control: the duplicate agrees to 0.002 at 8-bit and 0.001 at 16-bit, and every
gate-off arm reads 0.995-1.007. At 16-bit, where the C++ side's absolute throughput moves by at most
1.6%, the island ratio goes 0.967 -> 0.952: a real cost of about 1.5 points, which is what the
per-token instructions predict. At 8-bit the ratio goes 1.060 -> 0.972, but the *denominator* rose
4.5-11.5% -- 554.8 -> 618.6 MB/s on bigdom -- and the C++ symbols say that cannot be a code change:
1840 C++ symbols, 1834 identical, `CSSTokenizer::CSSTokenizer` at 258 instructions on both sides,
and the six that differ are four out-of-line `CSSParserToken` constructors at +1 each (a byte-aligned
`ldrb`/`orr lsl WebKit#24` becoming `ldr`/`and #0xfe000000`, because the new bit moved the preserved field
off a byte boundary) plus `consumeColor` at -1. So the 8-bit denominator moved by code layout, and
the island's own 8-bit absolute change is -3.9% to +0.9%, geomean -2.3%, well inside an envelope the
denominator itself demonstrates is at least 7%. `takeChunk` is 236 -> 381 instructions, of which 63
are SIMD in a loop clang auto-vectorized out of the record count -- inside `if (m_wrapper)`, so
production never executes it.

Kept at that price, because safety is not tradeable here. The cheaper spelling exists and is not
taken in this commit: specializing the resolve on `m_characterSize`, which is fixed for the whole
tokenization, would remove both multiplies and make the checked version cost one instruction rather
than three. That is an optimisation and belongs in its own change, where it can be measured on its
own.

No Swift changed, so the island's `unsafe` markers are unmoved: 2 plus 2 `_unsafeCxxSpan` in
CSSTokenizerSwift.swift, 0 in CSSUnitTrieSwift.swift and CSSParserFastPathsSwift.swift. 29
non-comment lines of C++ added against 7 removed, all of it checks rather than translation.
airspeedswift added a commit to airspeedswift/webkit that referenced this pull request Sep 8, 2026
…ee invariants by comment

A safety sweep of yesterday's three finished-token commits found seven hazards removed from the
replaced C++ against seven the port's own boundary introduced -- plus three invariants that used to
be structural and had become conventions. One to one is not a win, and four of the port-side items
were cheap enough to close in one change. They are ledger entries S13 and R1-R3.

`resolveValuePointer` used the *one*-argument `std::span::subspan`, which bounds the start and says
nothing about the count. libc++ hardening is on for every WebCore configuration
(Configurations/CommonBase.xcconfig:122), so the start really was checked -- but `value()` is
`StringView { valueDataCharRaw, valueLength, valueIs8Bit }`, a raw pointer and a trusted count, and
`valueLength` crossed the language boundary unexamined. The C++ this replaced,
`CSSTokenizerInputStream::rangeAt`, clamped both through `StringView::substring` and was
structurally incapable of over-reading, so the boundary went from silently wrong on a bad length to
out of bounds on one. The two-argument overload adds `count <= size() - offset` and returns the
identical pointer. cssprobe/probes/extentcheck demonstrates the difference against this header
rather than a transcription, with the input mmap'd flush against a PROT_NONE page: at offset 60
length 32 of a 64-byte input the old spelling resolves happily and then takes SIGBUS reading the
value's own characters, and the new one traps inside the resolve. Three positive controls -- an
interior value, a value ending exactly at `size()`, and a valueless token that must stay null --
pass on both spellings, so the new check is not merely stricter. Isolated at -O2 with the same
hardening mode the resolve is 13 instructions before and 16 after.

`CSSParserToken`'s bits-taking constructor is private now, with `CSSSwiftTokenSink` as its one
friend. Its precondition -- the bits have been through `resolveValuePointer` -- cannot be put in the
type, because while Swift owns the token the pointer slot holds an offset and nothing in C++ can
tell the difference; the design this replaced could not get that wrong, since the island emitted a
different struct with a `uint32_t valueStart`. A comment was the entire enforcement. It has to be
`tryAppend(CSSParserToken { bits })` rather than `tryConstructAndAppend(bits)`, because Vector
constructs in place and the access check is then made in Vector's context, so friendship would have
had to name Vector and would have widened rather than narrowed. Verified by trying it: a
construction from `CSSTokenizer::tokenCount`, which is not the friend, fails with "calling a private
constructor of class 'WebCore::CSSParserToken'". `cssParserTokenBitsCanRepresentOffsets` now says
what it is actually for: `__PAGEZERO` is 4 GB, the check keeps every parked offset inside it, so a
mis-sequenced resolve faults deterministically instead of reading heap. That is a memory-safety
property and its comment claimed only representability.

The union's active member was a function of the pipeline phase as well as of `type`, and only
`bitsCarryPendingNumber` -- which reads `type` -- stood between `pendingNumberRange` and a
`numericValue` that no factory had written. A `makeSimpleTokenBits(NumberToken, ...)` would have had
its double read out as an offset and a length. `hasParkedNumberRange` is that missing writer-side
half, written beside the member it discriminates and required before `takeChunk` reads the range, so
the read is no longer through a member nothing wrote. It costs nothing: the bitfields summed to 24
bits, so it lands in the free eight of the same allocation unit, and `sizeof(CSSParserToken)` is
still 24 -- now asserted, since "there were eight bits free" is a layout claim. The parked range is
also bounded against the input, because it is a second pair of offsets the island computed and
`rangeAt`'s own check is an `ASSERT` that is compiled out. Negative control: with the discriminant
deliberately cleared in a throwaway build, failcheck's two cases containing numbers fail
construction and the six without one are untouched.

The observer records and the tokens are two parallel buffers with nothing relating their counts, and
a desync feeds `addToken`/`addComment` another token's offsets -- which is entry S7's exact failure,
and S7 shipped. `takeChunk` now counts the non-comment records and requires that to equal
`tokenCount` before the walk, so a violation never reaches the wrapper, and records arriving with no
wrapper at all fail too. It fails the tokenization rather than asserting: the island has no
fallback, and an `ASSERT` is compiled out of exactly the builds where this matters. One pass over a
buffer that is empty on every production tokenization. Negative control: with one record dropped in
a throwaway build, all 58 non-observer csscheck cases still pass and the process dies on the first
line of the inspector phase.

Throughput, and the honest reading is that the 8-bit ratio moved for a reason that is not the
island. Parent and this commit, 15 interleaved rounds on the real captured stylesheets, with a
duplicate-of-one-arm control: the duplicate agrees to 0.002 at 8-bit and 0.001 at 16-bit, and every
gate-off arm reads 0.995-1.007. At 16-bit, where the C++ side's absolute throughput moves by at most
1.6%, the island ratio goes 0.967 -> 0.952: a real cost of about 1.5 points, which is what the
per-token instructions predict. At 8-bit the ratio goes 1.060 -> 0.972, but the *denominator* rose
4.5-11.5% -- 554.8 -> 618.6 MB/s on bigdom -- and the C++ symbols say that cannot be a code change:
1840 C++ symbols, 1834 identical, `CSSTokenizer::CSSTokenizer` at 258 instructions on both sides,
and the six that differ are four out-of-line `CSSParserToken` constructors at +1 each (a byte-aligned
`ldrb`/`orr lsl WebKit#24` becoming `ldr`/`and #0xfe000000`, because the new bit moved the preserved field
off a byte boundary) plus `consumeColor` at -1. So the 8-bit denominator moved by code layout, and
the island's own 8-bit absolute change is -3.9% to +0.9%, geomean -2.3%, well inside an envelope the
denominator itself demonstrates is at least 7%. `takeChunk` is 236 -> 381 instructions, of which 63
are SIMD in a loop clang auto-vectorized out of the record count -- inside `if (m_wrapper)`, so
production never executes it.

Kept at that price, because safety is not tradeable here. The cheaper spelling exists and is not
taken in this commit: specializing the resolve on `m_characterSize`, which is fixed for the whole
tokenization, would remove both multiplies and make the checked version cost one instruction rather
than three. That is an optimisation and belongs in its own change, where it can be measured on its
own.

No Swift changed, so the island's `unsafe` markers are unmoved: 2 plus 2 `_unsafeCxxSpan` in
CSSTokenizerSwift.swift, 0 in CSSUnitTrieSwift.swift and CSSParserFastPathsSwift.swift. 29
non-comment lines of C++ added against 7 removed, all of it checks rather than translation.
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