Changeset 247124 in webkit


Ignore:
Timestamp:
Jul 3, 2019 6:06:35 PM (5 years ago)
Author:
rmorisset@apple.com
Message:

[WHLSL] Make the destructor of VariableDeclaration non-virtual
https://bugs.webkit.org/show_bug.cgi?id=199460

Reviewed by Myles C. Maxfield.

Three steps:

  • Remove WHLSL::AST::Value, inlining it into its children (it is trivial, it just has one field m_origin with a getter and nothing else)
  • Mark WHLSL::AST::VariableDeclaration final
  • Now that it inherits from nothing and nothing can inherit from it, there is no reason for it to have any virtual method, including its destructor.

This not only saves 8 bytes from every variable declaration (for the virtual table pointer), it also should make destructing the AST at the end of compilation a bit faster by removing the virtual destructor call.

No new tests as there is no intended functional change.

  • Modules/webgpu/WHLSL/AST/WHLSLAST.h:
  • Modules/webgpu/WHLSL/AST/WHLSLExpression.h:

(WebCore::WHLSL::AST::Expression::Expression):
(WebCore::WHLSL::AST::Expression::origin const):

  • Modules/webgpu/WHLSL/AST/WHLSLStatement.h:

(WebCore::WHLSL::AST::Statement::Statement):
(WebCore::WHLSL::AST::Statement::origin const):

  • Modules/webgpu/WHLSL/AST/WHLSLValue.h: Removed.
  • Modules/webgpu/WHLSL/AST/WHLSLVariableDeclaration.h:
  • Modules/webgpu/WHLSL/WHLSLParser.h:
  • WebCore.xcodeproj/project.pbxproj:
Location:
trunk/Source/WebCore
Files:
1 deleted
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r247123 r247124  
     12019-07-03  Robin Morisset  <rmorisset@apple.com>
     2
     3        [WHLSL] Make the destructor of VariableDeclaration non-virtual
     4        https://bugs.webkit.org/show_bug.cgi?id=199460
     5
     6        Reviewed by Myles C. Maxfield.
     7
     8        Three steps:
     9        - Remove WHLSL::AST::Value, inlining it into its children (it is trivial, it just has one field m_origin with a getter and nothing else)
     10        - Mark WHLSL::AST::VariableDeclaration final
     11        - Now that it inherits from nothing and nothing can inherit from it, there is no reason for it to have any virtual method, including its destructor.
     12
     13        This not only saves 8 bytes from every variable declaration (for the virtual table pointer), it also should make destructing the AST at the end of compilation a bit faster by removing the virtual destructor call.
     14
     15        No new tests as there is no intended functional change.
     16
     17        * Modules/webgpu/WHLSL/AST/WHLSLAST.h:
     18        * Modules/webgpu/WHLSL/AST/WHLSLExpression.h:
     19        (WebCore::WHLSL::AST::Expression::Expression):
     20        (WebCore::WHLSL::AST::Expression::origin const):
     21        * Modules/webgpu/WHLSL/AST/WHLSLStatement.h:
     22        (WebCore::WHLSL::AST::Statement::Statement):
     23        (WebCore::WHLSL::AST::Statement::origin const):
     24        * Modules/webgpu/WHLSL/AST/WHLSLValue.h: Removed.
     25        * Modules/webgpu/WHLSL/AST/WHLSLVariableDeclaration.h:
     26        * Modules/webgpu/WHLSL/WHLSLParser.h:
     27        * WebCore.xcodeproj/project.pbxproj:
     28
    1292019-07-03  Sihui Liu  <sihui_liu@apple.com>
    230
  • trunk/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLAST.h

    r247105 r247124  
    9999#include "WHLSLUnsignedIntegerLiteral.h"
    100100#include "WHLSLUnsignedIntegerLiteralType.h"
    101 #include "WHLSLValue.h"
    102101#include "WHLSLVariableDeclaration.h"
    103102#include "WHLSLVariableDeclarationsStatement.h"
  • trunk/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLExpression.h

    r246550 r247124  
    3131#include "WHLSLLexer.h"
    3232#include "WHLSLUnnamedType.h"
    33 #include "WHLSLValue.h"
    3433#include <wtf/Optional.h>
    3534#include <wtf/UniqueRef.h>
     
    4140namespace AST {
    4241
    43 class Expression : public Value {
    44     using Base = Value;
     42class Expression {
    4543public:
    4644    Expression(Lexer::Token&& origin)
    47         : Base(WTFMove(origin))
     45        : m_origin(WTFMove(origin))
    4846    {
    4947    }
     
    115113    virtual bool isEnumerationMemberLiteral() const { return false; }
    116114
     115    Lexer::Token origin() const { return m_origin; }
     116
    117117private:
     118    Lexer::Token m_origin;
    118119    Optional<UniqueRef<UnnamedType>> m_type;
    119120    Optional<TypeAnnotation> m_typeAnnotation;
  • trunk/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLStatement.h

    r245945 r247124  
    2929
    3030#include "WHLSLLexer.h"
    31 #include "WHLSLValue.h"
    3231#include <wtf/UniqueRef.h>
    3332
     
    3837namespace AST {
    3938
    40 class Statement : public Value {
    41     using Base = Value;
     39class Statement {
    4240public:
    4341    Statement(Lexer::Token&& origin)
    44         : Base(WTFMove(origin))
     42        : m_origin(WTFMove(origin))
    4543    {
    4644    }
     
    6664    virtual bool isVariableDeclarationsStatement() const { return false; }
    6765    virtual bool isWhileLoop() const { return false; }
     66
     67    Lexer::Token origin() const { return m_origin; }
     68
     69private:
     70    Lexer::Token m_origin;
    6871};
    6972
  • trunk/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLVariableDeclaration.h

    r247110 r247124  
    3333#include "WHLSLSemantic.h"
    3434#include "WHLSLType.h"
    35 #include "WHLSLValue.h"
    3635#include <memory>
    3736#include <wtf/UniqueRef.h>
     
    4544namespace AST {
    4645
    47 class VariableDeclaration : public Value {
    48     using Base = Value;
     46class VariableDeclaration final {
     47// Final because we made the destructor non-virtual.
    4948public:
    5049    VariableDeclaration(Lexer::Token&& origin, Qualifiers&& qualifiers, Optional<UniqueRef<UnnamedType>>&& type, String&& name, std::unique_ptr<Semantic>&& semantic, std::unique_ptr<Expression>&& initializer)
    51         : Base(WTFMove(origin))
     50        : m_origin(WTFMove(origin))
    5251        , m_qualifiers(WTFMove(qualifiers))
    5352        , m_type(WTFMove(type))
     
    5857    }
    5958
    60     virtual ~VariableDeclaration() = default;
     59    ~VariableDeclaration() = default;
    6160
    6261    VariableDeclaration(const VariableDeclaration&) = delete;
     
    8584        m_initializer = WTFMove(expression);
    8685    }
     86    Lexer::Token origin() const { return m_origin; }
    8787
    8888private:
     89    Lexer::Token m_origin;
    8990    Qualifiers m_qualifiers;
    9091    Optional<UniqueRef<UnnamedType>> m_type;
  • trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLParser.h

    r247110 r247124  
    8989#include "WHLSLTypeReference.h"
    9090#include "WHLSLUnsignedIntegerLiteral.h"
    91 #include "WHLSLValue.h"
    9291#include "WHLSLVariableDeclaration.h"
    9392#include "WHLSLVariableDeclarationsStatement.h"
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r247115 r247124  
    1329713297                C21BF6FA21CD89BE00227979 /* WHLSLBaseSemantic.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLBaseSemantic.h; sourceTree = "<group>"; };
    1329813298                C21BF6FB21CD89BE00227979 /* WHLSLDoWhileLoop.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLDoWhileLoop.h; sourceTree = "<group>"; };
    13299                 C21BF6FC21CD89BF00227979 /* WHLSLValue.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLValue.h; sourceTree = "<group>"; };
    1330013299                C21BF6FD21CD89C000227979 /* WHLSLFunctionDeclaration.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLFunctionDeclaration.h; sourceTree = "<group>"; };
    1330113300                C21BF6FE21CD89C100227979 /* WHLSLStructureElement.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLStructureElement.h; sourceTree = "<group>"; };
     
    1717717176                                1CB69B3B21DF041E006E846A /* WHLSLUnsignedIntegerLiteralType.cpp */,
    1717817177                                1CB69B3721DED66B006E846A /* WHLSLUnsignedIntegerLiteralType.h */,
    17179                                 C21BF6FC21CD89BF00227979 /* WHLSLValue.h */,
    1718017178                                C21BF71021CD89D000227979 /* WHLSLVariableDeclaration.h */,
    1718117179                                C21BF71421CD89D300227979 /* WHLSLVariableDeclarationsStatement.h */,
Note: See TracChangeset for help on using the changeset viewer.