Changeset 247419 in webkit


Ignore:
Timestamp:
Jul 13, 2019 10:43:41 AM (5 years ago)
Author:
rmorisset@apple.com
Message:

[WHLSL] Return statements don't need to keep track of the function they're in
https://bugs.webkit.org/show_bug.cgi?id=199763

Reviewed by Myles C. Maxfield.

Return::m_function is only used in the Checker, and it can easily enough keep track of the current function.
This means we no longer need to keep track of the current function in the NameResolver, and we can save 8 bytes per Return

Since I was touching the NameResolver I also removed a few pointless overrides of Visitor::visit().

No new tests as there is no intended functional change.

  • Modules/webgpu/WHLSL/AST/WHLSLReturn.h:
  • Modules/webgpu/WHLSL/WHLSLChecker.cpp:

(WebCore::WHLSL::Checker::visit):

  • Modules/webgpu/WHLSL/WHLSLNameResolver.cpp:

(WebCore::WHLSL::NameResolver::NameResolver):
(WebCore::WHLSL::resolveTypeNamesInFunctions):

  • Modules/webgpu/WHLSL/WHLSLNameResolver.h:
Location:
trunk/Source/WebCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r247418 r247419  
     12019-07-13  Robin Morisset  <rmorisset@apple.com>
     2
     3        [WHLSL] Return statements don't need to keep track of the function they're in
     4        https://bugs.webkit.org/show_bug.cgi?id=199763
     5
     6        Reviewed by Myles C. Maxfield.
     7
     8        Return::m_function is only used in the Checker, and it can easily enough keep track of the current function.
     9        This means we no longer need to keep track of the current function in the NameResolver, and we can save 8 bytes per Return
     10
     11        Since I was touching the NameResolver I also removed a few pointless overrides of Visitor::visit().
     12
     13        No new tests as there is no intended functional change.
     14
     15        * Modules/webgpu/WHLSL/AST/WHLSLReturn.h:
     16        * Modules/webgpu/WHLSL/WHLSLChecker.cpp:
     17        (WebCore::WHLSL::Checker::visit):
     18        * Modules/webgpu/WHLSL/WHLSLNameResolver.cpp:
     19        (WebCore::WHLSL::NameResolver::NameResolver):
     20        (WebCore::WHLSL::resolveTypeNamesInFunctions):
     21        * Modules/webgpu/WHLSL/WHLSLNameResolver.h:
     22
    1232019-07-13  Andres Gonzalez  <andresg_22@apple.com>
    224
  • trunk/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLReturn.h

    r247341 r247419  
    5757    Expression* value() { return m_value.get(); }
    5858
    59     FunctionDefinition* function() { return m_function; }
    60     void setFunction(FunctionDefinition* functionDefinition) { m_function = functionDefinition; }
    61 
    6259private:
    6360    std::unique_ptr<Expression> m_value;
    64     FunctionDefinition* m_function { nullptr };
    6561};
    6662
  • trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLChecker.cpp

    r247329 r247419  
    518518    const Intrinsics& m_intrinsics;
    519519    Program& m_program;
     520    AST::FunctionDefinition* m_currentFunction { nullptr };
    520521};
    521522
     
    573574void Checker::visit(AST::FunctionDefinition& functionDefinition)
    574575{
     576    m_currentFunction = &functionDefinition;
    575577    if (functionDefinition.entryPointType()) {
    576578        if (!checkShaderType(functionDefinition)) {
     
    11451147        if (!valueInfo)
    11461148            return;
    1147         if (!matchAndCommit(valueInfo->resolvingType, returnStatement.function()->type()))
     1149        if (!matchAndCommit(valueInfo->resolvingType, m_currentFunction->type()))
    11481150            setError();
    11491151        return;
    11501152    }
    11511153
    1152     if (!matches(returnStatement.function()->type(), m_intrinsics.voidType()))
     1154    if (!matches(m_currentFunction->type(), m_intrinsics.voidType()))
    11531155        setError();
    11541156}
  • trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLNameResolver.cpp

    r247329 r247419  
    2929#if ENABLE(WEBGPU)
    3030
    31 #include "WHLSLCallExpression.h"
    3231#include "WHLSLDoWhileLoop.h"
    3332#include "WHLSLDotExpression.h"
     
    3938#include "WHLSLNameContext.h"
    4039#include "WHLSLProgram.h"
    41 #include "WHLSLPropertyAccessExpression.h"
    4240#include "WHLSLReplaceWith.h"
    4341#include "WHLSLResolveOverloadImpl.h"
    44 #include "WHLSLReturn.h"
    4542#include "WHLSLScopedSetAdder.h"
    4643#include "WHLSLTypeReference.h"
     
    6259    , m_parentNameResolver(&parentResolver)
    6360{
    64     setCurrentFunctionDefinition(parentResolver.m_currentFunction);
    6561}
    6662
     
    189185        return;
    190186    }
    191 }
    192 
    193 void NameResolver::visit(AST::Return& returnStatement)
    194 {
    195     ASSERT(m_currentFunction);
    196     returnStatement.setFunction(m_currentFunction);
    197     Visitor::visit(returnStatement);
    198 }
    199 
    200 void NameResolver::visit(AST::PropertyAccessExpression& propertyAccessExpression)
    201 {
    202     Visitor::visit(propertyAccessExpression);
    203187}
    204188
     
    227211}
    228212
    229 void NameResolver::visit(AST::CallExpression& callExpression)
    230 {
    231     Visitor::visit(callExpression);
    232 }
    233 
    234213void NameResolver::visit(AST::EnumerationMemberLiteral& enumerationMemberLiteral)
    235214{
     
    289268{
    290269    for (auto& functionDefinition : program.functionDefinitions()) {
    291         nameResolver.setCurrentFunctionDefinition(&functionDefinition);
    292270        nameResolver.checkErrorAndVisit(functionDefinition);
    293271        if (nameResolver.error())
    294272            return false;
    295273    }
    296     nameResolver.setCurrentFunctionDefinition(nullptr);
    297274    for (auto& nativeFunctionDeclaration : program.nativeFunctionDeclarations()) {
    298275        nameResolver.checkErrorAndVisit(nativeFunctionDeclaration);
  • trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLNameResolver.h

    r247171 r247419  
    4545    virtual ~NameResolver();
    4646
    47     void setCurrentFunctionDefinition(AST::FunctionDefinition* functionDefinition)
    48     {
    49         m_currentFunction = functionDefinition;
    50     }
    51 
    5247private:
    5348    void visit(AST::FunctionDefinition&) override;
     
    6156    void visit(AST::VariableDeclaration&) override;
    6257    void visit(AST::VariableReference&) override;
    63     void visit(AST::Return&) override;
    64     void visit(AST::PropertyAccessExpression&) override;
    6558    void visit(AST::DotExpression&) override;
    66     void visit(AST::CallExpression&) override;
    6759    void visit(AST::EnumerationMemberLiteral&) override;
    6860
    6961    NameContext& m_nameContext;
    7062    HashSet<AST::TypeReference*> m_typeReferences;
    71     AST::FunctionDefinition* m_currentFunction { nullptr };
    7263    NameResolver* m_parentNameResolver { nullptr };
    7364};
Note: See TracChangeset for help on using the changeset viewer.