Changeset 248303 in webkit
- Timestamp:
- Aug 6, 2019, 10:37:08 AM (7 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 16 edited
- 2 copied
-
ChangeLog (modified) (1 diff)
-
Modules/webgpu/WHLSL/AST/WHLSLAddressEscapeMode.h (copied) (copied from trunk/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLMakePointerExpression.h ) (2 diffs)
-
Modules/webgpu/WHLSL/AST/WHLSLFunctionDeclaration.h (modified) (4 diffs)
-
Modules/webgpu/WHLSL/AST/WHLSLMakeArrayReferenceExpression.h (modified) (3 diffs)
-
Modules/webgpu/WHLSL/AST/WHLSLMakePointerExpression.h (modified) (3 diffs)
-
Modules/webgpu/WHLSL/WHLSLChecker.cpp (modified) (3 diffs)
-
Modules/webgpu/WHLSL/WHLSLParser.cpp (modified) (7 diffs)
-
Modules/webgpu/WHLSL/WHLSLParser.h (modified) (3 diffs)
-
Modules/webgpu/WHLSL/WHLSLParsingMode.h (copied) (copied from trunk/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLMakePointerExpression.h ) (1 diff)
-
Modules/webgpu/WHLSL/WHLSLPrepare.cpp (modified) (1 diff)
-
Modules/webgpu/WHLSL/WHLSLPreserveVariableLifetimes.cpp (modified) (4 diffs)
-
Modules/webgpu/WHLSL/WHLSLPropertyResolver.cpp (modified) (7 diffs)
-
Modules/webgpu/WHLSL/WHLSLStandardLibraryUtilities.cpp (modified) (3 diffs)
-
Modules/webgpu/WHLSL/WHLSLSynthesizeArrayOperatorLength.cpp (modified) (1 diff)
-
Modules/webgpu/WHLSL/WHLSLSynthesizeConstructors.cpp (modified) (3 diffs)
-
Modules/webgpu/WHLSL/WHLSLSynthesizeEnumerationFunctions.cpp (modified) (4 diffs)
-
Modules/webgpu/WHLSL/WHLSLSynthesizeStructureAccessors.cpp (modified) (1 diff)
-
WebCore.xcodeproj/project.pbxproj (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r248301 r248303 1 2019-08-06 Saam Barati <sbarati@apple.com> 2 3 [WHLSL] Reduce the number of variables that make it into the global struct by skipping stdlib functions and internal uses of MakePointerExpression/MakeArrayReference 4 https://bugs.webkit.org/show_bug.cgi?id=200463 5 6 Reviewed by Myles C. Maxfield. 7 8 This patch makes it so that we put fewer variables in the global struct. 9 This decreases end-to-end running time in compute_boids by 30% (with p = 0.0001). 10 11 We achieve this in two ways: 12 1. We track if each function is user code or "standard library" code. We also 13 count native functions as the standard library. We know a priori that the 14 standard library never escapes any variables. So the preserve variable 15 lifetimes phase skips analyzing all standard library functions and also 16 skips passing the global struct to any standard library functions. 17 18 2. We internally emit MakePointerExpression/MakeArrayReferenceExpression nodes in 19 the compiler in various phases. We sometimes emit these nodes in such a way 20 that we know that this address-of expression does not cause the variable to 21 escape. We now mark each address-of expressions as either: 22 - Conservatively escaping. We conservatively do this for all user code. 23 - Not escaping. This means that this address-of operation definitely does 24 not escape the variable. If a variable never has an escaping use, we will 25 omit putting this variable in the struct. 26 27 * Modules/webgpu/WHLSL/AST/WHLSLAddressEscapeMode.h: Added. 28 * Modules/webgpu/WHLSL/AST/WHLSLFunctionDeclaration.h: 29 (WebCore::WHLSL::AST::FunctionDeclaration::FunctionDeclaration): 30 (WebCore::WHLSL::AST::FunctionDeclaration::parsingMode const): 31 * Modules/webgpu/WHLSL/AST/WHLSLMakeArrayReferenceExpression.h: 32 (WebCore::WHLSL::AST::MakeArrayReferenceExpression::MakeArrayReferenceExpression): 33 (WebCore::WHLSL::AST::MakeArrayReferenceExpression::mightEscape const): 34 * Modules/webgpu/WHLSL/AST/WHLSLMakePointerExpression.h: 35 (WebCore::WHLSL::AST::MakePointerExpression::MakePointerExpression): 36 (WebCore::WHLSL::AST::MakePointerExpression::mightEscape const): 37 * Modules/webgpu/WHLSL/WHLSLChecker.cpp: 38 (WebCore::WHLSL::resolveWithOperatorAnderIndexer): 39 (WebCore::WHLSL::resolveWithOperatorLength): 40 (WebCore::WHLSL::resolveWithReferenceComparator): 41 * Modules/webgpu/WHLSL/WHLSLParser.cpp: 42 (WebCore::WHLSL::Parser::parse): 43 (WebCore::WHLSL::Parser::parseComputeFunctionDeclaration): 44 (WebCore::WHLSL::Parser::parseVertexOrFragmentFunctionDeclaration): 45 (WebCore::WHLSL::Parser::parseRegularFunctionDeclaration): 46 (WebCore::WHLSL::Parser::parseOperatorFunctionDeclaration): 47 (WebCore::WHLSL::Parser::parsePossiblePrefix): 48 * Modules/webgpu/WHLSL/WHLSLParser.h: 49 * Modules/webgpu/WHLSL/WHLSLParsingMode.h: Added. 50 * Modules/webgpu/WHLSL/WHLSLPrepare.cpp: 51 (WebCore::WHLSL::prepareShared): 52 * Modules/webgpu/WHLSL/WHLSLPreserveVariableLifetimes.cpp: 53 * Modules/webgpu/WHLSL/WHLSLPropertyResolver.cpp: 54 (WebCore::WHLSL::wrapAnderCallArgument): 55 (WebCore::WHLSL::modify): 56 (WebCore::WHLSL::PropertyResolver::visit): 57 * Modules/webgpu/WHLSL/WHLSLStandardLibraryUtilities.cpp: 58 (WebCore::WHLSL::includeStandardLibrary): 59 * Modules/webgpu/WHLSL/WHLSLSynthesizeArrayOperatorLength.cpp: 60 (WebCore::WHLSL::synthesizeArrayOperatorLength): 61 * Modules/webgpu/WHLSL/WHLSLSynthesizeConstructors.cpp: 62 (WebCore::WHLSL::synthesizeConstructors): 63 * Modules/webgpu/WHLSL/WHLSLSynthesizeEnumerationFunctions.cpp: 64 (WebCore::WHLSL::synthesizeEnumerationFunctions): 65 * Modules/webgpu/WHLSL/WHLSLSynthesizeStructureAccessors.cpp: 66 (WebCore::WHLSL::synthesizeStructureAccessors): 67 * WebCore.xcodeproj/project.pbxproj: 68 1 69 2019-08-06 Jer Noble <jer.noble@apple.com> 2 70 -
trunk/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLAddressEscapeMode.h
r248302 r248303 28 28 #if ENABLE(WEBGPU) 29 29 30 #include "WHLSLExpression.h"31 #include <wtf/FastMalloc.h>32 #include <wtf/UniqueRef.h>33 34 30 namespace WebCore { 35 31 … … 38 34 namespace AST { 39 35 40 class MakePointerExpression : public Expression { 41 WTF_MAKE_FAST_ALLOCATED; 42 public: 43 MakePointerExpression(CodeLocation location, UniqueRef<Expression>&& leftValue) 44 : Expression(location) 45 , m_leftValue(WTFMove(leftValue)) 46 { 47 } 48 49 virtual ~MakePointerExpression() = default; 50 51 MakePointerExpression(const MakePointerExpression&) = delete; 52 MakePointerExpression(MakePointerExpression&&) = default; 53 54 bool isMakePointerExpression() const override { return true; } 55 56 Expression& leftValue() { return m_leftValue; } 57 58 private: 59 UniqueRef<Expression> m_leftValue; 36 enum class AddressEscapeMode : uint8_t { 37 Escapes, // Conservatively, this address-of operation might escape. 38 DoesNotEscape // This address-of operation definitely does not escape. 60 39 }; 61 40 62 41 } // namespace AST 63 42 64 } 43 } // namespace WHLSL 65 44 66 } 45 } // namespace WebCore 67 46 68 SPECIALIZE_TYPE_TRAITS_WHLSL_EXPRESSION(MakePointerExpression, isMakePointerExpression()) 69 70 #endif 47 #endif // ENABLE(WEBGPU) -
trunk/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLFunctionDeclaration.h
r247878 r248303 31 31 #include "WHLSLEntryPointType.h" 32 32 #include "WHLSLFunctionAttribute.h" 33 #include "WHLSLParsingMode.h" 33 34 #include "WHLSLSemantic.h" 34 35 #include "WHLSLUnnamedType.h" … … 47 48 WTF_MAKE_FAST_ALLOCATED; 48 49 public: 49 FunctionDeclaration(CodeLocation location, AttributeBlock&& attributeBlock, Optional<EntryPointType> entryPointType, Ref<UnnamedType> type, String&& name, VariableDeclarations&& parameters, std::unique_ptr<Semantic>&& semantic, bool isOperator )50 FunctionDeclaration(CodeLocation location, AttributeBlock&& attributeBlock, Optional<EntryPointType> entryPointType, Ref<UnnamedType> type, String&& name, VariableDeclarations&& parameters, std::unique_ptr<Semantic>&& semantic, bool isOperator, ParsingMode parsingMode) 50 51 : m_codeLocation(location) 51 52 , m_attributeBlock(WTFMove(attributeBlock)) 52 53 , m_entryPointType(entryPointType) 53 , m_isOperator(WTFMove(isOperator)) 54 , m_isOperator(isOperator) 55 , m_parsingMode(parsingMode) 54 56 , m_type(WTFMove(type)) 55 57 , m_name(WTFMove(name)) … … 80 82 const CodeLocation& codeLocation() const { return m_codeLocation; } 81 83 84 ParsingMode parsingMode() const { return m_parsingMode; } 85 82 86 private: 83 87 CodeLocation m_codeLocation; … … 85 89 Optional<EntryPointType> m_entryPointType; 86 90 bool m_isOperator; 91 ParsingMode m_parsingMode; 87 92 Ref<UnnamedType> m_type; 88 93 String m_name; -
trunk/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLMakeArrayReferenceExpression.h
r247834 r248303 28 28 #if ENABLE(WEBGPU) 29 29 30 #include "WHLSLAddressEscapeMode.h" 30 31 #include "WHLSLExpression.h" 31 32 #include <wtf/FastMalloc.h> … … 41 42 WTF_MAKE_FAST_ALLOCATED; 42 43 public: 43 MakeArrayReferenceExpression(CodeLocation location, UniqueRef<Expression>&& leftValue )44 MakeArrayReferenceExpression(CodeLocation location, UniqueRef<Expression>&& leftValue, AddressEscapeMode addressEscapeMode) 44 45 : Expression(location) 45 46 , m_leftValue(WTFMove(leftValue)) 47 , m_addressEscapeMode(addressEscapeMode) 46 48 { 47 49 } … … 56 58 Expression& leftValue() { return m_leftValue; } 57 59 60 bool mightEscape() const { return m_addressEscapeMode == AddressEscapeMode::Escapes; } 61 58 62 private: 59 63 UniqueRef<Expression> m_leftValue; 64 AddressEscapeMode m_addressEscapeMode; 60 65 }; 61 66 -
trunk/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLMakePointerExpression.h
r247834 r248303 28 28 #if ENABLE(WEBGPU) 29 29 30 #include "WHLSLAddressEscapeMode.h" 30 31 #include "WHLSLExpression.h" 31 32 #include <wtf/FastMalloc.h> … … 41 42 WTF_MAKE_FAST_ALLOCATED; 42 43 public: 43 MakePointerExpression(CodeLocation location, UniqueRef<Expression>&& leftValue )44 MakePointerExpression(CodeLocation location, UniqueRef<Expression>&& leftValue, AddressEscapeMode addressEscapeMode) 44 45 : Expression(location) 45 46 , m_leftValue(WTFMove(leftValue)) 47 , m_addressEscapeMode(addressEscapeMode) 46 48 { 47 49 } … … 56 58 Expression& leftValue() { return m_leftValue; } 57 59 60 bool mightEscape() const { return m_addressEscapeMode == AddressEscapeMode::Escapes; } 61 58 62 private: 59 63 UniqueRef<Expression> m_leftValue; 64 AddressEscapeMode m_addressEscapeMode; 60 65 }; 61 66 -
trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLChecker.cpp
r248022 r248303 126 126 parameters.append(makeUniqueRef<AST::VariableDeclaration>(location, AST::Qualifiers(), &firstArgument, String(), nullptr, nullptr)); 127 127 parameters.append(makeUniqueRef<AST::VariableDeclaration>(location, AST::Qualifiers(), AST::TypeReference::wrap(location, intrinsics.uintType()), String(), nullptr, nullptr)); 128 return AST::NativeFunctionDeclaration(AST::FunctionDeclaration(location, AST::AttributeBlock(), WTF::nullopt, WTFMove(returnType), String("operator&[]", String::ConstructFromLiteral), WTFMove(parameters), nullptr, isOperator ));128 return AST::NativeFunctionDeclaration(AST::FunctionDeclaration(location, AST::AttributeBlock(), WTF::nullopt, WTFMove(returnType), String("operator&[]", String::ConstructFromLiteral), WTFMove(parameters), nullptr, isOperator, ParsingMode::StandardLibrary)); 129 129 } 130 130 … … 135 135 AST::VariableDeclarations parameters; 136 136 parameters.append(makeUniqueRef<AST::VariableDeclaration>(location, AST::Qualifiers(), &firstArgument, String(), nullptr, nullptr)); 137 return AST::NativeFunctionDeclaration(AST::FunctionDeclaration(location, AST::AttributeBlock(), WTF::nullopt, WTFMove(returnType), String("operator.length", String::ConstructFromLiteral), WTFMove(parameters), nullptr, isOperator ));137 return AST::NativeFunctionDeclaration(AST::FunctionDeclaration(location, AST::AttributeBlock(), WTF::nullopt, WTFMove(returnType), String("operator.length", String::ConstructFromLiteral), WTFMove(parameters), nullptr, isOperator, ParsingMode::StandardLibrary)); 138 138 } 139 139 … … 157 157 parameters.append(makeUniqueRef<AST::VariableDeclaration>(location, AST::Qualifiers(), argumentType.copyRef(), String(), nullptr, nullptr)); 158 158 parameters.append(makeUniqueRef<AST::VariableDeclaration>(location, AST::Qualifiers(), WTFMove(argumentType), String(), nullptr, nullptr)); 159 return AST::NativeFunctionDeclaration(AST::FunctionDeclaration(location, AST::AttributeBlock(), WTF::nullopt, WTFMove(returnType), String("operator==", String::ConstructFromLiteral), WTFMove(parameters), nullptr, isOperator ));159 return AST::NativeFunctionDeclaration(AST::FunctionDeclaration(location, AST::AttributeBlock(), WTF::nullopt, WTFMove(returnType), String("operator==", String::ConstructFromLiteral), WTFMove(parameters), nullptr, isOperator, ParsingMode::StandardLibrary)); 160 160 } 161 161 -
trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLParser.cpp
r247917 r248303 60 60 61 61 // FIXME: https://bugs.webkit.org/show_bug.cgi?id=195682 Return a better error code from this, and report it to JavaScript. 62 auto Parser::parse(Program& program, StringView stringView, Mode mode) -> Expected<void, Error>62 auto Parser::parse(Program& program, StringView stringView, ParsingMode mode) -> Expected<void, Error> 63 63 { 64 64 m_lexer = Lexer(stringView); … … 95 95 } 96 96 case Token::Type::Native: { 97 ASSERT(m_mode == Mode::StandardLibrary);97 ASSERT(m_mode == ParsingMode::StandardLibrary); 98 98 auto furtherToken = peekFurther(); 99 99 if (!furtherToken) … … 987 987 988 988 bool isOperator = false; 989 return AST::FunctionDeclaration({ origin->startOffset(), endOffset }, WTFMove(*attributeBlock), AST::EntryPointType::Compute, WTFMove(*type), name->stringView(m_lexer).toString(), WTFMove(*parameters), WTFMove(*semantic), isOperator );989 return AST::FunctionDeclaration({ origin->startOffset(), endOffset }, WTFMove(*attributeBlock), AST::EntryPointType::Compute, WTFMove(*type), name->stringView(m_lexer).toString(), WTFMove(*parameters), WTFMove(*semantic), isOperator, m_mode); 990 990 } 991 991 … … 1005 1005 1006 1006 bool isOperator = false; 1007 return AST::FunctionDeclaration({ entryPoint->startOffset(), endOffset }, { }, entryPointType, WTFMove(*type), name->stringView(m_lexer).toString(), WTFMove(*parameters), WTFMove(*semantic), isOperator );1007 return AST::FunctionDeclaration({ entryPoint->startOffset(), endOffset }, { }, entryPointType, WTFMove(*type), name->stringView(m_lexer).toString(), WTFMove(*parameters), WTFMove(*semantic), isOperator, m_mode); 1008 1008 } 1009 1009 … … 1024 1024 auto endOffset = m_lexer.peek().startOffset(); 1025 1025 1026 return AST::FunctionDeclaration({ origin->startOffset(), endOffset }, { }, WTF::nullopt, WTFMove(*type), name->stringView(m_lexer).toString(), WTFMove(*parameters), WTFMove(*semantic), isOperator );1026 return AST::FunctionDeclaration({ origin->startOffset(), endOffset }, { }, WTF::nullopt, WTFMove(*type), name->stringView(m_lexer).toString(), WTFMove(*parameters), WTFMove(*semantic), isOperator, m_mode); 1027 1027 } 1028 1028 … … 1037 1037 1038 1038 bool isOperator = true; 1039 return AST::FunctionDeclaration({ origin->startOffset(), endOffset }, { }, WTF::nullopt, WTFMove(*type), "operator cast"_str, WTFMove(*parameters), WTFMove(*semantic), isOperator );1039 return AST::FunctionDeclaration({ origin->startOffset(), endOffset }, { }, WTF::nullopt, WTFMove(*type), "operator cast"_str, WTFMove(*parameters), WTFMove(*semantic), isOperator, m_mode); 1040 1040 } 1041 1041 … … 1938 1938 } 1939 1939 case Token::Type::And: 1940 return { makeUniqueRef<AST::MakePointerExpression>(location, WTFMove(*next) ) };1940 return { makeUniqueRef<AST::MakePointerExpression>(location, WTFMove(*next), AST::AddressEscapeMode::Escapes) }; 1941 1941 case Token::Type::At: 1942 return { makeUniqueRef<AST::MakeArrayReferenceExpression>(location, WTFMove(*next) ) };1942 return { makeUniqueRef<AST::MakeArrayReferenceExpression>(location, WTFMove(*next), AST::AddressEscapeMode::Escapes) }; 1943 1943 default: 1944 1944 ASSERT(prefix->type == Token::Type::Star); -
trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLParser.h
r247878 r248303 28 28 #if ENABLE(WEBGPU) 29 29 30 #include "WHLSLArrayReferenceType.h" 31 #include "WHLSLArrayType.h" 32 #include "WHLSLAssignmentExpression.h" 33 #include "WHLSLBaseFunctionAttribute.h" 34 #include "WHLSLBaseSemantic.h" 35 #include "WHLSLBlock.h" 36 #include "WHLSLBooleanLiteral.h" 37 #include "WHLSLBreak.h" 38 #include "WHLSLBuiltInSemantic.h" 39 #include "WHLSLCallExpression.h" 40 #include "WHLSLCommaExpression.h" 41 #include "WHLSLConstantExpression.h" 42 #include "WHLSLContinue.h" 43 #include "WHLSLDereferenceExpression.h" 44 #include "WHLSLDoWhileLoop.h" 45 #include "WHLSLDotExpression.h" 46 #include "WHLSLEffectfulExpressionStatement.h" 47 #include "WHLSLEnumerationDefinition.h" 48 #include "WHLSLEnumerationMember.h" 30 #include "WHLSLAST.h" 49 31 #include "WHLSLError.h" 50 #include "WHLSLExpression.h"51 #include "WHLSLFallthrough.h"52 #include "WHLSLFloatLiteral.h"53 #include "WHLSLForLoop.h"54 #include "WHLSLFunctionAttribute.h"55 #include "WHLSLFunctionDeclaration.h"56 #include "WHLSLFunctionDefinition.h"57 #include "WHLSLIfStatement.h"58 #include "WHLSLIndexExpression.h"59 #include "WHLSLIntegerLiteral.h"60 32 #include "WHLSLLexer.h" 61 #include "WHLSLLogicalExpression.h" 62 #include "WHLSLLogicalNotExpression.h" 63 #include "WHLSLMakeArrayReferenceExpression.h" 64 #include "WHLSLMakePointerExpression.h" 65 #include "WHLSLNativeFunctionDeclaration.h" 66 #include "WHLSLNativeTypeDeclaration.h" 67 #include "WHLSLNullLiteral.h" 68 #include "WHLSLNumThreadsFunctionAttribute.h" 69 #include "WHLSLPointerType.h" 33 #include "WHLSLParsingMode.h" 70 34 #include "WHLSLProgram.h" 71 #include "WHLSLPropertyAccessExpression.h"72 #include "WHLSLQualifier.h"73 #include "WHLSLReadModifyWriteExpression.h"74 #include "WHLSLReferenceType.h"75 #include "WHLSLResourceSemantic.h"76 #include "WHLSLReturn.h"77 #include "WHLSLSemantic.h"78 #include "WHLSLSpecializationConstantSemantic.h"79 #include "WHLSLStageInOutSemantic.h"80 #include "WHLSLStatement.h"81 #include "WHLSLStructureDefinition.h"82 #include "WHLSLStructureElement.h"83 #include "WHLSLSwitchCase.h"84 #include "WHLSLSwitchStatement.h"85 #include "WHLSLTernaryExpression.h"86 #include "WHLSLType.h"87 #include "WHLSLTypeArgument.h"88 #include "WHLSLTypeDefinition.h"89 #include "WHLSLTypeReference.h"90 #include "WHLSLUnsignedIntegerLiteral.h"91 #include "WHLSLVariableDeclaration.h"92 #include "WHLSLVariableDeclarationsStatement.h"93 #include "WHLSLVariableReference.h"94 #include "WHLSLWhileLoop.h"95 35 #include <wtf/Expected.h> 96 36 #include <wtf/Optional.h> … … 103 43 class Parser { 104 44 public: 105 enum class Mode { 106 StandardLibrary, 107 User 108 }; 109 110 Expected<void, Error> parse(Program&, StringView, Mode); 45 Expected<void, Error> parse(Program&, StringView, ParsingMode); 111 46 112 47 private: … … 233 168 234 169 Lexer m_lexer; 235 Mode m_mode;170 ParsingMode m_mode; 236 171 }; 237 172 -
trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLParsingMode.h
r248302 r248303 28 28 #if ENABLE(WEBGPU) 29 29 30 #include "WHLSLExpression.h"31 #include <wtf/FastMalloc.h>32 #include <wtf/UniqueRef.h>33 34 30 namespace WebCore { 35 31 36 32 namespace WHLSL { 37 33 38 namespace AST { 39 40 class MakePointerExpression : public Expression { 41 WTF_MAKE_FAST_ALLOCATED; 42 public: 43 MakePointerExpression(CodeLocation location, UniqueRef<Expression>&& leftValue) 44 : Expression(location) 45 , m_leftValue(WTFMove(leftValue)) 46 { 47 } 48 49 virtual ~MakePointerExpression() = default; 50 51 MakePointerExpression(const MakePointerExpression&) = delete; 52 MakePointerExpression(MakePointerExpression&&) = default; 53 54 bool isMakePointerExpression() const override { return true; } 55 56 Expression& leftValue() { return m_leftValue; } 57 58 private: 59 UniqueRef<Expression> m_leftValue; 34 enum class ParsingMode : uint8_t { 35 StandardLibrary, 36 User 60 37 }; 61 38 62 } // namespace AST39 } // namespace WHLSL 63 40 64 } 41 } // namespace WebCore 65 42 66 } 67 68 SPECIALIZE_TYPE_TRAITS_WHLSL_EXPRESSION(MakePointerExpression, isMakePointerExpression()) 69 70 #endif 43 #endif // ENABLE(WEBGPU) -
trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLPrepare.cpp
r247834 r248303 158 158 { 159 159 PhaseTimer phaseTimer("parse", phaseTimes); 160 auto parseResult = parser.parse(program, whlslSource, Pars er::Mode::User);160 auto parseResult = parser.parse(program, whlslSource, ParsingMode::User); 161 161 if (!parseResult) { 162 162 if (dumpPassFailure) -
trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLPreserveVariableLifetimes.cpp
r247878 r248303 78 78 void visit(AST::MakePointerExpression& makePointerExpression) override 79 79 { 80 escapeVariableUse(makePointerExpression.leftValue()); 80 if (makePointerExpression.mightEscape()) 81 escapeVariableUse(makePointerExpression.leftValue()); 81 82 } 82 83 83 84 void visit(AST::MakeArrayReferenceExpression& makeArrayReferenceExpression) override 84 85 { 85 escapeVariableUse(makeArrayReferenceExpression.leftValue()); 86 if (makeArrayReferenceExpression.mightEscape()) 87 escapeVariableUse(makeArrayReferenceExpression.leftValue()); 86 88 } 87 89 … … 134 136 void visit(AST::FunctionDefinition& functionDefinition) override 135 137 { 138 if (functionDefinition.parsingMode() == ParsingMode::StandardLibrary) 139 return; 140 136 141 bool isEntryPoint = !!functionDefinition.entryPointType(); 137 142 if (isEntryPoint) { … … 147 152 auto structDeclarationStatement = makeUniqueRef<AST::VariableDeclarationsStatement>(functionDefinition.codeLocation(), WTFMove(structVariableDeclarations)); 148 153 149 auto makePointerExpression = std::make_unique<AST::MakePointerExpression>(functionDefinition.codeLocation(), WTFMove(structVariableReference) );154 auto makePointerExpression = std::make_unique<AST::MakePointerExpression>(functionDefinition.codeLocation(), WTFMove(structVariableReference), AST::AddressEscapeMode::DoesNotEscape); 150 155 makePointerExpression->setType(m_pointerToStructType.copyRef()); 151 156 makePointerExpression->setTypeAnnotation(AST::RightValue()); … … 191 196 // This works because it's illegal to call an entrypoint. Therefore, we can only 192 197 // call functions where we've already appended this struct as its final parameter. 193 if (!callExpression.function().isNativeFunctionDeclaration() )198 if (!callExpression.function().isNativeFunctionDeclaration() && callExpression.function().parsingMode() != ParsingMode::StandardLibrary) 194 199 callExpression.arguments().append(makeStructVariableReference()); 195 200 } -
trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLPropertyResolver.cpp
r247878 r248303 99 99 100 100 template <typename ExpressionConstructor, typename TypeConstructor> 101 static Optional<AnderCallArgumentResult> wrapAnderCallArgument(UniqueRef<AST::Expression>& expression, Ref<AST::UnnamedType> baseType, bool anderFunction, bool threadAnderFunction) 102 { 101 static Optional<AnderCallArgumentResult> wrapAnderCallArgument(UniqueRef<AST::Expression>& expression, Ref<AST::UnnamedType> baseType, AST::FunctionDeclaration* anderFunction, AST::FunctionDeclaration* threadAnderFunction) 102 { 103 auto functionEscapeMode = [] (AST::FunctionDeclaration& functionDeclaration) { 104 if (functionDeclaration.isNativeFunctionDeclaration() || functionDeclaration.parsingMode() == ParsingMode::StandardLibrary) 105 return AST::AddressEscapeMode::DoesNotEscape; 106 return AST::AddressEscapeMode::Escapes; 107 }; 108 103 109 auto location = expression->codeLocation(); 104 110 if (auto addressSpace = expression->typeAnnotation().leftAddressSpace()) { 105 111 if (!anderFunction) 106 112 return WTF::nullopt; 107 auto makeArrayReference = makeUniqueRef<ExpressionConstructor>(location, WTFMove(expression) );113 auto makeArrayReference = makeUniqueRef<ExpressionConstructor>(location, WTFMove(expression), functionEscapeMode(*anderFunction)); 108 114 makeArrayReference->setType(TypeConstructor::create(location, *addressSpace, WTFMove(baseType))); 109 115 makeArrayReference->setTypeAnnotation(AST::RightValue()); … … 125 131 variableReference2->setTypeAnnotation(AST::LeftValue { AST::AddressSpace::Thread }); 126 132 127 auto expression = makeUniqueRef<ExpressionConstructor>(location, WTFMove(variableReference2) );133 auto expression = makeUniqueRef<ExpressionConstructor>(location, WTFMove(variableReference2), functionEscapeMode(*threadAnderFunction)); 128 134 auto resultType = TypeConstructor::create(location, AST::AddressSpace::Thread, WTFMove(baseType)); 129 135 expression->setType(resultType.copyRef()); … … 141 147 } 142 148 143 static Optional<AnderCallArgumentResult> anderCallArgument(UniqueRef<AST::Expression>& expression, bool anderFunction, boolthreadAnderFunction)149 static Optional<AnderCallArgumentResult> anderCallArgument(UniqueRef<AST::Expression>& expression, AST::FunctionDeclaration* anderFunction, AST::FunctionDeclaration* threadAnderFunction) 144 150 { 145 151 if (!anderFunction && !threadAnderFunction) … … 173 179 // *operator&.foo(&v) = newValue 174 180 auto leftValue = leftValueFactory(); 175 auto argument = anderCallArgument(leftValue, true, true);181 auto argument = anderCallArgument(leftValue, relevantAnder, relevantAnder); 176 182 ASSERT(argument); 177 183 ASSERT(!argument->variableDeclaration); … … 234 240 // *operator&.foo(&v) 235 241 auto leftValue = leftValueFactory(); 236 auto argument = anderCallArgument(leftValue, true, true);242 auto argument = anderCallArgument(leftValue, relevantAnder, relevantAnder); 237 243 ASSERT(argument); 238 244 ASSERT(!argument->variableDeclaration); … … 363 369 // Step 1: 364 370 { 365 auto makePointerExpression = makeUniqueRef<AST::MakePointerExpression>(innerLeftExpression.codeLocation(), WTFMove(leftExpression) );371 auto makePointerExpression = makeUniqueRef<AST::MakePointerExpression>(innerLeftExpression.codeLocation(), WTFMove(leftExpression), AST::AddressEscapeMode::DoesNotEscape); 366 372 makePointerExpression->setType(AST::PointerType::create(innerLeftExpression.codeLocation(), *innerLeftExpression.typeAnnotation().leftAddressSpace(), innerLeftExpression.resolvedType())); 367 373 makePointerExpression->setTypeAnnotation(AST::RightValue()); … … 560 566 561 567 { 562 auto makePointerExpression = makeUniqueRef<AST::MakePointerExpression>(leftValueLocation, readModifyWriteExpression.takeLeftValue() );568 auto makePointerExpression = makeUniqueRef<AST::MakePointerExpression>(leftValueLocation, readModifyWriteExpression.takeLeftValue(), AST::AddressEscapeMode::DoesNotEscape); 563 569 makePointerExpression->setType(pointerType.copyRef()); 564 570 makePointerExpression->setTypeAnnotation(AST::RightValue()); -
trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLStandardLibraryUtilities.cpp
r247834 r248303 80 80 static NeverDestroyed<String> standardLibrary(decompressAndDecodeStandardLibrary()); 81 81 if (parseFullStandardLibrary) { 82 auto parseResult = parser.parse(program, standardLibrary.get(), Pars er::Mode::StandardLibrary);82 auto parseResult = parser.parse(program, standardLibrary.get(), ParsingMode::StandardLibrary); 83 83 if (!parseResult) { 84 84 dataLogLn("failed to parse the (full) standard library: ", Lexer::errorString(StringView(standardLibrary), parseResult.error())); … … 91 91 92 92 auto stringView = StringView(standardLibrary.get()).substring(0, firstFunctionOffsetInStandardLibrary()); 93 auto parseResult = parser.parse(program, stringView, Pars er::Mode::StandardLibrary);93 auto parseResult = parser.parse(program, stringView, ParsingMode::StandardLibrary); 94 94 ASSERT_UNUSED(parseResult, parseResult); 95 95 … … 111 111 continue; 112 112 auto stringView = StringView(standardLibrary.get()).substring(iterator->value.start, iterator->value.end - iterator->value.start); 113 auto parseResult = parser.parse(program, stringView, Pars er::Mode::StandardLibrary);113 auto parseResult = parser.parse(program, stringView, ParsingMode::StandardLibrary); 114 114 if (!parseResult) { 115 115 dataLogLn("failed to parse the (partial) standard library: ", Lexer::errorString(stringView, parseResult.error())); -
trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLSynthesizeArrayOperatorLength.cpp
r247878 r248303 70 70 AST::VariableDeclarations parameters; 71 71 parameters.append(WTFMove(variableDeclaration)); 72 AST::NativeFunctionDeclaration nativeFunctionDeclaration(AST::FunctionDeclaration(location, AST::AttributeBlock(), WTF::nullopt, AST::TypeReference::wrap(location, program.intrinsics().uintType()), "operator.length"_str, WTFMove(parameters), nullptr, isOperator ));72 AST::NativeFunctionDeclaration nativeFunctionDeclaration(AST::FunctionDeclaration(location, AST::AttributeBlock(), WTF::nullopt, AST::TypeReference::wrap(location, program.intrinsics().uintType()), "operator.length"_str, WTFMove(parameters), nullptr, isOperator, ParsingMode::StandardLibrary)); 73 73 if (!program.append(WTFMove(nativeFunctionDeclaration))) 74 74 return makeUnexpected(Error("Cannot synthesize operator.length for array type.")); -
trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLSynthesizeConstructors.cpp
r247878 r248303 163 163 AST::VariableDeclarations parameters; 164 164 parameters.append(WTFMove(variableDeclaration)); 165 AST::NativeFunctionDeclaration copyConstructor(AST::FunctionDeclaration(location, AST::AttributeBlock(), WTF::nullopt, unnamedType, "operator cast"_str, WTFMove(parameters), nullptr, isOperator ));165 AST::NativeFunctionDeclaration copyConstructor(AST::FunctionDeclaration(location, AST::AttributeBlock(), WTF::nullopt, unnamedType, "operator cast"_str, WTFMove(parameters), nullptr, isOperator, ParsingMode::StandardLibrary)); 166 166 program.append(WTFMove(copyConstructor)); 167 167 } 168 168 169 AST::NativeFunctionDeclaration defaultConstructor(AST::FunctionDeclaration(location, AST::AttributeBlock(), WTF::nullopt, unnamedType, "operator cast"_str, AST::VariableDeclarations(), nullptr, isOperator ));169 AST::NativeFunctionDeclaration defaultConstructor(AST::FunctionDeclaration(location, AST::AttributeBlock(), WTF::nullopt, unnamedType, "operator cast"_str, AST::VariableDeclarations(), nullptr, isOperator, ParsingMode::StandardLibrary)); 170 170 if (!program.append(WTFMove(defaultConstructor))) 171 171 return makeUnexpected(Error("Could not synthesize default constructor")); … … 183 183 AST::VariableDeclarations parameters; 184 184 parameters.append(WTFMove(variableDeclaration)); 185 AST::NativeFunctionDeclaration copyConstructor(AST::FunctionDeclaration(location, AST::AttributeBlock(), WTF::nullopt, AST::TypeReference::wrap(location, namedType.get()), "operator cast"_str, WTFMove(parameters), nullptr, isOperator ));185 AST::NativeFunctionDeclaration copyConstructor(AST::FunctionDeclaration(location, AST::AttributeBlock(), WTF::nullopt, AST::TypeReference::wrap(location, namedType.get()), "operator cast"_str, WTFMove(parameters), nullptr, isOperator, ParsingMode::StandardLibrary)); 186 186 program.append(WTFMove(copyConstructor)); 187 187 … … 191 191 continue; 192 192 } 193 AST::NativeFunctionDeclaration defaultConstructor(AST::FunctionDeclaration(location, AST::AttributeBlock(), WTF::nullopt, AST::TypeReference::wrap(location, namedType.get()), "operator cast"_str, AST::VariableDeclarations(), nullptr, isOperator ));193 AST::NativeFunctionDeclaration defaultConstructor(AST::FunctionDeclaration(location, AST::AttributeBlock(), WTF::nullopt, AST::TypeReference::wrap(location, namedType.get()), "operator cast"_str, AST::VariableDeclarations(), nullptr, isOperator, ParsingMode::StandardLibrary)); 194 194 if (!program.append(WTFMove(defaultConstructor))) 195 195 return makeUnexpected(Error("Could not synthesize default constructor")); -
trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLSynthesizeEnumerationFunctions.cpp
r247878 r248303 48 48 parameters.append(WTFMove(variableDeclaration1)); 49 49 parameters.append(WTFMove(variableDeclaration2)); 50 AST::NativeFunctionDeclaration nativeFunctionDeclaration(AST::FunctionDeclaration(location, AST::AttributeBlock(), WTF::nullopt, AST::TypeReference::wrap(location, program.intrinsics().boolType()), "operator=="_str, WTFMove(parameters), nullptr, isOperator ));50 AST::NativeFunctionDeclaration nativeFunctionDeclaration(AST::FunctionDeclaration(location, AST::AttributeBlock(), WTF::nullopt, AST::TypeReference::wrap(location, program.intrinsics().boolType()), "operator=="_str, WTFMove(parameters), nullptr, isOperator, ParsingMode::StandardLibrary)); 51 51 if (!program.append(WTFMove(nativeFunctionDeclaration))) 52 52 return makeUnexpected(Error("Cannot create operator== for enum type.")); … … 57 57 AST::VariableDeclarations parameters; 58 58 parameters.append(WTFMove(variableDeclaration)); 59 AST::NativeFunctionDeclaration nativeFunctionDeclaration(AST::FunctionDeclaration(location, AST::AttributeBlock(), WTF::nullopt, enumerationDefinition->type(), "operator.value"_str, WTFMove(parameters), nullptr, isOperator ));59 AST::NativeFunctionDeclaration nativeFunctionDeclaration(AST::FunctionDeclaration(location, AST::AttributeBlock(), WTF::nullopt, enumerationDefinition->type(), "operator.value"_str, WTFMove(parameters), nullptr, isOperator, ParsingMode::StandardLibrary)); 60 60 if (!program.append(WTFMove(nativeFunctionDeclaration))) 61 61 return makeUnexpected(Error("Cannot create operator.value for enum type.")); … … 66 66 AST::VariableDeclarations parameters; 67 67 parameters.append(WTFMove(variableDeclaration)); 68 AST::NativeFunctionDeclaration nativeFunctionDeclaration(AST::FunctionDeclaration(location, AST::AttributeBlock(), WTF::nullopt, enumerationDefinition->type(), "operator cast"_str, WTFMove(parameters), nullptr, isOperator ));68 AST::NativeFunctionDeclaration nativeFunctionDeclaration(AST::FunctionDeclaration(location, AST::AttributeBlock(), WTF::nullopt, enumerationDefinition->type(), "operator cast"_str, WTFMove(parameters), nullptr, isOperator, ParsingMode::StandardLibrary)); 69 69 if (!program.append(WTFMove(nativeFunctionDeclaration))) 70 70 return makeUnexpected(Error("Cannot create copy constructor for enum type.")); … … 75 75 AST::VariableDeclarations parameters; 76 76 parameters.append(WTFMove(variableDeclaration)); 77 AST::NativeFunctionDeclaration nativeFunctionDeclaration(AST::FunctionDeclaration(location, AST::AttributeBlock(), WTF::nullopt, AST::TypeReference::wrap(location, enumerationDefinition), "operator cast"_str, WTFMove(parameters), nullptr, isOperator ));77 AST::NativeFunctionDeclaration nativeFunctionDeclaration(AST::FunctionDeclaration(location, AST::AttributeBlock(), WTF::nullopt, AST::TypeReference::wrap(location, enumerationDefinition), "operator cast"_str, WTFMove(parameters), nullptr, isOperator, ParsingMode::StandardLibrary)); 78 78 if (!program.append(WTFMove(nativeFunctionDeclaration))) 79 79 return makeUnexpected(Error("Cannot create 'operator cast' for enum type.")); -
trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLSynthesizeStructureAccessors.cpp
r247878 r248303 52 52 parameters.append(WTFMove(variableDeclaration)); 53 53 auto returnType = AST::PointerType::create(structureElement.codeLocation(), addressSpace, structureElement.type()); 54 AST::NativeFunctionDeclaration nativeFunctionDeclaration(AST::FunctionDeclaration(structureElement.codeLocation(), AST::AttributeBlock(), WTF::nullopt, WTFMove(returnType), makeString("operator&.", structureElement.name()), WTFMove(parameters), nullptr, isOperator ));54 AST::NativeFunctionDeclaration nativeFunctionDeclaration(AST::FunctionDeclaration(structureElement.codeLocation(), AST::AttributeBlock(), WTF::nullopt, WTFMove(returnType), makeString("operator&.", structureElement.name()), WTFMove(parameters), nullptr, isOperator, ParsingMode::StandardLibrary)); 55 55 return nativeFunctionDeclaration; 56 56 }; -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r248282 r248303 8320 8320 526724F11CB2FDF60075974D /* TextTrackRepresentationCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = TextTrackRepresentationCocoa.mm; sourceTree = "<group>"; }; 8321 8321 526724F21CB2FDF60075974D /* TextTrackRepresentationCocoa.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextTrackRepresentationCocoa.h; sourceTree = "<group>"; }; 8322 52914C2A22F93E4E00578150 /* WHLSLParsingMode.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLParsingMode.h; sourceTree = "<group>"; }; 8323 52914C2C22F93E5D00578150 /* WHLSLAddressEscapeMode.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLAddressEscapeMode.h; sourceTree = "<group>"; }; 8322 8324 52B0D4BD1C57FD1E0077CE53 /* PlatformView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PlatformView.h; sourceTree = "<group>"; }; 8323 8325 52B0D4BF1C57FD660077CE53 /* VideoFullscreenChangeObserver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VideoFullscreenChangeObserver.h; sourceTree = "<group>"; }; … … 17056 17058 children = ( 17057 17059 1C840B9021EC30F900D0500D /* WHLSLAddressSpace.h */, 17060 52914C2C22F93E5D00578150 /* WHLSLAddressEscapeMode.h */, 17058 17061 C21BF72521CD89E200227979 /* WHLSLArrayReferenceType.h */, 17059 17062 C21BF70921CD89CA00227979 /* WHLSLArrayType.h */, … … 25527 25530 C21BF73721CD8A0200227979 /* WHLSLParser.cpp */, 25528 25531 C21BF73821CD8A0300227979 /* WHLSLParser.h */, 25532 52914C2A22F93E4E00578150 /* WHLSLParsingMode.h */, 25529 25533 C24A57AF21FAD53F004C6DD1 /* WHLSLPipelineDescriptor.h */, 25530 25534 C24A57BA21FEAFEA004C6DD1 /* WHLSLPrepare.cpp */,
Note:
See TracChangeset
for help on using the changeset viewer.