[webkit-changes] [WebKit/WebKit] af2e0a: [WGSL] Use arena allocation for AST nodes

Tadeu Zagallo noreply at github.com
Thu Apr 27 06:19:16 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: af2e0abfcb43006136e679feae74c9e61f54da56
      https://github.com/WebKit/WebKit/commit/af2e0abfcb43006136e679feae74c9e61f54da56
  Author: Tadeu Zagallo <tzagallo at apple.com>
  Date:   2023-04-27 (Thu, 27 Apr 2023)

  Changed paths:
    A Source/WebGPU/WGSL/AST/ASTBuilder.cpp
    A Source/WebGPU/WGSL/AST/ASTBuilder.h
    M Source/WebGPU/WGSL/AST/ASTStructureMember.h
    M Source/WebGPU/WGSL/EntryPointRewriter.cpp
    M Source/WebGPU/WGSL/GlobalVariableRewriter.cpp
    M Source/WebGPU/WGSL/MangleNames.cpp
    M Source/WebGPU/WGSL/Metal/MetalFunctionWriter.cpp
    M Source/WebGPU/WGSL/Parser.cpp
    M Source/WebGPU/WGSL/ParserPrivate.h
    M Source/WebGPU/WGSL/TypeCheck.cpp
    M Source/WebGPU/WGSL/WGSLShaderModule.h
    M Source/WebGPU/WebGPU.xcodeproj/project.pbxproj
    M Tools/TestWebKitAPI/Tests/WGSL/ParserTests.cpp

  Log Message:
  -----------
  [WGSL] Use arena allocation for AST nodes
https://bugs.webkit.org/show_bug.cgi?id=255917
rdar://108496324

Reviewed by Myles C. Maxfield.

The AST was originally implemented using only unique references/pointers, which
made it really difficult to transform the AST. Currently we have a mix of Ref(Ptr)
and unique references/pointers, which is unnecessary since all the nodes have the
same lifecycle. To simplify things, we switch to an arena allocator, inspired by
the JSC's ParserArena. I converted only a single leaf node, StructureMember, to
use the new AST builder as a proof of concept, but more nodes can be converted
incrementally later.

* Source/WebGPU/WGSL/AST/ASTBuilder.cpp: Added.
(WGSL::AST::Builder::arena):
(WGSL::AST::Builder::~Builder):
(WGSL::AST::Builder::allocateArena):
* Source/WebGPU/WGSL/AST/ASTBuilder.h: Added.
(WGSL::AST::Builder::construct):
(WGSL::AST::Builder::alignSize):
* Source/WebGPU/WGSL/AST/ASTStringDumper.cpp:
(WGSL::AST::StringDumper::visitPointerVector):
(WGSL::AST::StringDumper::visit):
* Source/WebGPU/WGSL/AST/ASTStringDumper.h:
* Source/WebGPU/WGSL/AST/ASTStructureMember.h:
* Source/WebGPU/WGSL/AST/ASTVisitor.cpp:
(WGSL::AST::Visitor::visit):
* Source/WebGPU/WGSL/EntryPointRewriter.cpp:
(WGSL::EntryPointRewriter::constructInputStruct):
(WGSL::EntryPointRewriter::visit):
* Source/WebGPU/WGSL/GlobalVariableRewriter.cpp:
(WGSL::RewriteGlobalVariables::insertStructs):
* Source/WebGPU/WGSL/MangleNames.cpp:
(WGSL::NameManglerVisitor::visit):
* Source/WebGPU/WGSL/Metal/MetalFunctionWriter.cpp:
(WGSL::Metal::FunctionDefinitionWriter::visit):
* Source/WebGPU/WGSL/Parser.cpp:
(WGSL::Parser<Lexer>::parseStructure):
(WGSL::Parser<Lexer>::parseStructureMember): Deleted.
* Source/WebGPU/WGSL/ParserPrivate.h:
(WGSL::Parser::Parser):
* Source/WebGPU/WGSL/TypeCheck.cpp:
(WGSL::TypeChecker::visitStructMembers):
* Source/WebGPU/WGSL/WGSLShaderModule.h:
(WGSL::ShaderModule::astBuilder):
* Source/WebGPU/WebGPU.xcodeproj/project.pbxproj:

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




More information about the webkit-changes mailing list