[webkit-changes] [WebKit/WebKit] 119aaa: [WGSL] Empty programs should be valid

Tadeu Zagallo noreply at github.com
Tue Aug 1 02:31:12 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 119aaa4e834c77d5bc560cd415d0628b619c8a49
      https://github.com/WebKit/WebKit/commit/119aaa4e834c77d5bc560cd415d0628b619c8a49
  Author: Tadeu Zagallo <tzagallo at apple.com>
  Date:   2023-08-01 (Tue, 01 Aug 2023)

  Changed paths:
    M Source/WebGPU/WGSL/AST/ASTBuilder.cpp
    A Source/WebGPU/WGSL/tests/valid/empty.wgsl
    M Source/WebGPU/WGSL/wgslc.cpp

  Log Message:
  -----------
  [WGSL] Empty programs should be valid
https://bugs.webkit.org/show_bug.cgi?id=259655
rdar://113153864

Reviewed by Dan Glastonbury.

This fixes two bugs related to evaluating an empty program:
1) The wgslc executable uses FileSystem::readEntireFile to read the input file,
   which returns nullopt if the file is empty, which is indistinguishable from
   when it fails to open the file. To fix that we check if the file exists first
   and then treat nullopt as an empty file.
2) The ASTBuilder assumed that we would always have had an allocation when saving
   and restoring its state. This caused a crash with empty programs, since no nodes
   are allocated. The fix is simply to check if we actually have an arena before
   trying to read it.

* Source/WebGPU/WGSL/AST/ASTBuilder.cpp:
(WGSL::AST::Builder::saveCurrentState):
(WGSL::AST::Builder::restore):
* Source/WebGPU/WGSL/tests/valid/empty.wgsl: Added.
* Source/WebGPU/WGSL/wgslc.cpp:
(runWGSL):

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




More information about the webkit-changes mailing list