WebKit Bugzilla
Attachment 373441 Details for
Bug 199460
: [WHLSL] Make the destructor of VariableDeclaration non-virtual
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-199460-20190703171547.patch (text/plain), 11.19 KB, created by
Robin Morisset
on 2019-07-03 17:15:48 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Robin Morisset
Created:
2019-07-03 17:15:48 PDT
Size:
11.19 KB
patch
obsolete
>Subversion Revision: 247115 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index e5314278b1683f86214441f57ae760daf61d378f..8267c4b0956740774cdfc9d4fb6ab2f48bb93ebb 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,31 @@ >+2019-07-03 Robin Morisset <rmorisset@apple.com> >+ >+ [WHLSL] Make the destructor of VariableDeclaration non-virtual >+ https://bugs.webkit.org/show_bug.cgi?id=199460 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ 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: >+ > 2019-07-02 Myles C. Maxfield <mmaxfield@apple.com> > > [WHLSL] Standard library is too big to directly include in WebCore >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLAST.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLAST.h >index 5a01e3f66c904c87727ba8870454b342fde3e81c..5794d4ecdb7fd90988efbb7fb0bc98462e56c12d 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLAST.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLAST.h >@@ -98,7 +98,6 @@ > #include "WHLSLUnnamedType.h" > #include "WHLSLUnsignedIntegerLiteral.h" > #include "WHLSLUnsignedIntegerLiteralType.h" >-#include "WHLSLValue.h" > #include "WHLSLVariableDeclaration.h" > #include "WHLSLVariableDeclarationsStatement.h" > #include "WHLSLVariableReference.h" >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLExpression.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLExpression.h >index fd70f1b95327281dd5948f5d5b7c49b518b5c634..b7ccc44949c12266953ba4c5222986bc34dffea0 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLExpression.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLExpression.h >@@ -30,7 +30,6 @@ > #include "WHLSLAddressSpace.h" > #include "WHLSLLexer.h" > #include "WHLSLUnnamedType.h" >-#include "WHLSLValue.h" > #include <wtf/Optional.h> > #include <wtf/UniqueRef.h> > >@@ -40,11 +39,10 @@ namespace WHLSL { > > namespace AST { > >-class Expression : public Value { >- using Base = Value; >+class Expression { > public: > Expression(Lexer::Token&& origin) >- : Base(WTFMove(origin)) >+ : m_origin(WTFMove(origin)) > { > } > >@@ -114,7 +112,10 @@ public: > virtual bool isVariableReference() const { return false; } > virtual bool isEnumerationMemberLiteral() const { return false; } > >+ Lexer::Token origin() const { return m_origin; } >+ > private: >+ Lexer::Token m_origin; > Optional<UniqueRef<UnnamedType>> m_type; > Optional<TypeAnnotation> m_typeAnnotation; > }; >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLStatement.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLStatement.h >index 57f1bf3b93ecc260a647b72cfb57fc98a5e9c624..0c24566e6144e93bd850405dde22b2e1e15cbfc4 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLStatement.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLStatement.h >@@ -28,7 +28,6 @@ > #if ENABLE(WEBGPU) > > #include "WHLSLLexer.h" >-#include "WHLSLValue.h" > #include <wtf/UniqueRef.h> > > namespace WebCore { >@@ -37,11 +36,10 @@ namespace WHLSL { > > namespace AST { > >-class Statement : public Value { >- using Base = Value; >+class Statement { > public: > Statement(Lexer::Token&& origin) >- : Base(WTFMove(origin)) >+ : m_origin(WTFMove(origin)) > { > } > >@@ -65,6 +63,11 @@ public: > virtual bool isTrap() const { return false; } > virtual bool isVariableDeclarationsStatement() const { return false; } > virtual bool isWhileLoop() const { return false; } >+ >+ Lexer::Token origin() const { return m_origin; } >+ >+private: >+ Lexer::Token m_origin; > }; > > using Statements = Vector<UniqueRef<Statement>>; >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLValue.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLValue.h >deleted file mode 100644 >index 4179d3d031dbc856e8bbee3e4b112bf5573fdcb6..0000000000000000000000000000000000000000 >--- a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLValue.h >+++ /dev/null >@@ -1,63 +0,0 @@ >-/* >- * Copyright (C) 2019 Apple Inc. All rights reserved. >- * >- * Redistribution and use in source and binary forms, with or without >- * modification, are permitted provided that the following conditions >- * are met: >- * 1. Redistributions of source code must retain the above copyright >- * notice, this list of conditions and the following disclaimer. >- * 2. Redistributions in binary form must reproduce the above copyright >- * notice, this list of conditions and the following disclaimer in the >- * documentation and/or other materials provided with the distribution. >- * >- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >- * THE POSSIBILITY OF SUCH DAMAGE. >- */ >- >-#pragma once >- >-#if ENABLE(WEBGPU) >- >-namespace WebCore { >- >-namespace WHLSL { >- >-namespace AST { >- >-class Value { >-public: >- Value(Lexer::Token&& origin) >- : m_origin(WTFMove(origin)) >- { >- } >- >- virtual ~Value() = default; >- >- explicit Value(const Value&) = default; >- Value(Value&&) = default; >- >- Value& operator=(const Value&) = default; >- Value& operator=(Value&&) = default; >- >- Lexer::Token origin() const { return m_origin; } >- >-protected: >- Lexer::Token m_origin; >-}; >- >-} // namespace AST >- >-} >- >-} >- >-#endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLVariableDeclaration.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLVariableDeclaration.h >index 6a4393a8a29ab202bf5ba21b2cf4bddb4f68cdae..c0dc8d481f6001bd2edc91d9c718a6d60bf1e7e3 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLVariableDeclaration.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLVariableDeclaration.h >@@ -32,7 +32,6 @@ > #include "WHLSLQualifier.h" > #include "WHLSLSemantic.h" > #include "WHLSLType.h" >-#include "WHLSLValue.h" > #include <memory> > #include <wtf/UniqueRef.h> > #include <wtf/Vector.h> >@@ -44,11 +43,11 @@ namespace WHLSL { > > namespace AST { > >-class VariableDeclaration : public Value { >- using Base = Value; >+class VariableDeclaration final { >+// Final because we made the destructor non-virtual. > public: > VariableDeclaration(Lexer::Token&& origin, Qualifiers&& qualifiers, Optional<UniqueRef<UnnamedType>>&& type, String&& name, std::unique_ptr<Semantic>&& semantic, std::unique_ptr<Expression>&& initializer) >- : Base(WTFMove(origin)) >+ : m_origin(WTFMove(origin)) > , m_qualifiers(WTFMove(qualifiers)) > , m_type(WTFMove(type)) > , m_name(WTFMove(name)) >@@ -57,7 +56,7 @@ public: > { > } > >- virtual ~VariableDeclaration() = default; >+ ~VariableDeclaration() = default; > > VariableDeclaration(const VariableDeclaration&) = delete; > VariableDeclaration(VariableDeclaration&&) = default; >@@ -84,8 +83,10 @@ public: > ASSERT(expression); > m_initializer = WTFMove(expression); > } >+ Lexer::Token origin() const { return m_origin; } > > private: >+ Lexer::Token m_origin; > Qualifiers m_qualifiers; > Optional<UniqueRef<UnnamedType>> m_type; > String m_name; >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLParser.h b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLParser.h >index dd858e60dab85e978788aa8f99a4c20508ff0d72..b4482a4469edc15e533190630741f768791db747 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLParser.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLParser.h >@@ -88,7 +88,6 @@ > #include "WHLSLTypeDefinition.h" > #include "WHLSLTypeReference.h" > #include "WHLSLUnsignedIntegerLiteral.h" >-#include "WHLSLValue.h" > #include "WHLSLVariableDeclaration.h" > #include "WHLSLVariableDeclarationsStatement.h" > #include "WHLSLVariableReference.h" >diff --git a/Source/WebCore/WebCore.xcodeproj/project.pbxproj b/Source/WebCore/WebCore.xcodeproj/project.pbxproj >index 79762ff56144192bdb5cef6f709bf881cf41bc36..cdbaadab6d374644cc32b774c34db4633bc6383c 100644 >--- a/Source/WebCore/WebCore.xcodeproj/project.pbxproj >+++ b/Source/WebCore/WebCore.xcodeproj/project.pbxproj >@@ -13296,7 +13296,6 @@ > C21BF6F921CD89BD00227979 /* WHLSLSemantic.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLSemantic.h; sourceTree = "<group>"; }; > C21BF6FA21CD89BE00227979 /* WHLSLBaseSemantic.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLBaseSemantic.h; sourceTree = "<group>"; }; > C21BF6FB21CD89BE00227979 /* WHLSLDoWhileLoop.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLDoWhileLoop.h; sourceTree = "<group>"; }; >- C21BF6FC21CD89BF00227979 /* WHLSLValue.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLValue.h; sourceTree = "<group>"; }; > C21BF6FD21CD89C000227979 /* WHLSLFunctionDeclaration.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLFunctionDeclaration.h; sourceTree = "<group>"; }; > C21BF6FE21CD89C100227979 /* WHLSLStructureElement.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLStructureElement.h; sourceTree = "<group>"; }; > C21BF6FF21CD89C200227979 /* WHLSLIfStatement.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLIfStatement.h; sourceTree = "<group>"; }; >@@ -17176,7 +17175,6 @@ > C21BF72B21CD89E800227979 /* WHLSLUnsignedIntegerLiteral.h */, > 1CB69B3B21DF041E006E846A /* WHLSLUnsignedIntegerLiteralType.cpp */, > 1CB69B3721DED66B006E846A /* WHLSLUnsignedIntegerLiteralType.h */, >- C21BF6FC21CD89BF00227979 /* WHLSLValue.h */, > C21BF71021CD89D000227979 /* WHLSLVariableDeclaration.h */, > C21BF71421CD89D300227979 /* WHLSLVariableDeclarationsStatement.h */, > C21BF71321CD89D200227979 /* WHLSLVariableReference.h */,
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 199460
: 373441