Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 119aaa4e834c77d5bc560cd415d0628b619c8a49
      
https://github.com/WebKit/WebKit/commit/119aaa4e834c77d5bc560cd415d0628b619c8a49
  Author: Tadeu Zagallo <[email protected]>
  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


_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to