WebKit Bugzilla
Attachment 372066 Details for
Bug 198706
: [WHLSL] Remove unnecessary ASSERT()s and clean up visitor lambdas
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-198706-20190613104448.patch (text/plain), 37.80 KB, created by
Myles C. Maxfield
on 2019-06-13 10:44:49 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Myles C. Maxfield
Created:
2019-06-13 10:44:49 PDT
Size:
37.80 KB
patch
obsolete
>Subversion Revision: 246396 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 234d6f635cbcbab97e524a7c0e3dd94e3e803c07..27037af52d0502beb07b900c3f20190cac2f4f48 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,52 @@ >+2019-06-12 Myles C. Maxfield <mmaxfield@apple.com> >+ >+ [WHLSL] Remove unnecessary ASSERT()s and clean up visitor lambdas >+ https://bugs.webkit.org/show_bug.cgi?id=198706 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Some minor refactoring. >+ >+ If the code is going to unconditionally downcast<Foo>(bar), there's no need >+ to guard that with an ASSERT(is<Foo>(bar)) because the downcast() call will >+ do that automatically. >+ >+ No new tests because there is no behavior change. >+ >+ * Modules/webgpu/WHLSL/AST/WHLSLConstantExpression.h: >+ (WebCore::WHLSL::AST::ConstantExpression::visit): >+ (WebCore::WHLSL::AST::ConstantExpression::visit const): >+ * Modules/webgpu/WHLSL/Metal/WHLSLEntryPointScaffolding.cpp: >+ (WebCore::WHLSL::Metal::EntryPointScaffolding::resourceHelperTypes): >+ (WebCore::WHLSL::Metal::EntryPointScaffolding::mangledOutputPath): >+ (WebCore::WHLSL::Metal::EntryPointScaffolding::unpackResourcesAndNamedBuiltIns): >+ * Modules/webgpu/WHLSL/Metal/WHLSLFunctionWriter.cpp: >+ (WebCore::WHLSL::Metal::FunctionDefinitionWriter::visit): >+ (WebCore::WHLSL::Metal::FunctionDefinitionWriter::constantExpressionString): >+ * Modules/webgpu/WHLSL/Metal/WHLSLNativeFunctionWriter.cpp: >+ (WebCore::WHLSL::Metal::writeNativeFunction): >+ * Modules/webgpu/WHLSL/Metal/WHLSLNativeTypeWriter.cpp: >+ (WebCore::WHLSL::Metal::writeNativeType): >+ * Modules/webgpu/WHLSL/Metal/WHLSLTypeNamer.cpp: >+ (WebCore::WHLSL::Metal::find): >+ (WebCore::WHLSL::Metal::TypeNamer::createNameNode): >+ (WebCore::WHLSL::Metal::TypeNamer::insert): >+ (WebCore::WHLSL::Metal::TypeNamer::emitUnnamedTypeDefinition): >+ (WebCore::WHLSL::Metal::TypeNamer::emitNamedTypeDefinition): >+ * Modules/webgpu/WHLSL/WHLSLChecker.cpp: >+ (WebCore::WHLSL::Checker::visit): >+ (WebCore::WHLSL::argumentTypeForAndOverload): >+ * Modules/webgpu/WHLSL/WHLSLInferTypes.cpp: >+ (WebCore::WHLSL::inferTypesForTypeArguments): >+ * Modules/webgpu/WHLSL/WHLSLIntrinsics.cpp: >+ (WebCore::WHLSL::Intrinsics::addFullTexture): >+ (WebCore::WHLSL::Intrinsics::addDepthTexture): >+ * Modules/webgpu/WHLSL/WHLSLPropertyResolver.cpp: >+ (WebCore::WHLSL::modify): >+ (WebCore::WHLSL::PropertyResolver::visit): >+ * Modules/webgpu/WHLSL/WHLSLVisitor.cpp: >+ (WebCore::WHLSL::Visitor::visit): >+ > 2019-06-12 Myles C. Maxfield <mmaxfield@apple.com> > > [WHLSL] Hook up compute >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLConstantExpression.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLConstantExpression.h >index 8eeceb08b04cd28c9b8d359644fdf0ecec523306..7656f62b55bb0a7122e278083a71a3690ed57ddf 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLConstantExpression.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLConstantExpression.h >@@ -88,14 +88,14 @@ public: > return WTF::get<IntegerLiteral>(m_variant); > } > >- template<typename T> void visit(T&& t) >+ template <typename Visitor> auto visit(const Visitor& visitor) -> decltype(WTF::visit(visitor, std::declval<Variant<IntegerLiteral, UnsignedIntegerLiteral, FloatLiteral, NullLiteral, BooleanLiteral, EnumerationMemberLiteral>&>())) > { >- WTF::visit(WTFMove(t), m_variant); >+ return WTF::visit(visitor, m_variant); > } > >- template<typename T> void visit(T&& t) const >+ template <typename Visitor> auto visit(const Visitor& visitor) const -> decltype(WTF::visit(visitor, std::declval<Variant<IntegerLiteral, UnsignedIntegerLiteral, FloatLiteral, NullLiteral, BooleanLiteral, EnumerationMemberLiteral>&>())) > { >- WTF::visit(WTFMove(t), m_variant); >+ return WTF::visit(visitor, m_variant); > } > > ConstantExpression clone() const >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLEntryPointScaffolding.cpp b/Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLEntryPointScaffolding.cpp >index 3baa37fa54c755fd134ebc232457f7d2247449db..01fb71e240bfa295d5486357b340959d68b9d0e9 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLEntryPointScaffolding.cpp >+++ b/Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLEntryPointScaffolding.cpp >@@ -148,7 +148,6 @@ String EntryPointScaffolding::resourceHelperTypes() > if (iterator == m_resourceMap.end()) > continue; > auto& unnamedType = *m_entryPointItems.inputs[iterator->value].unnamedType; >- ASSERT(is<AST::ReferenceType>(unnamedType)); > auto& referenceType = downcast<AST::ReferenceType>(unnamedType); > auto mangledTypeName = m_typeNamer.mangledNameForType(referenceType.elementType()); > auto addressSpace = toString(referenceType.addressSpace()); >@@ -277,10 +276,7 @@ String EntryPointScaffolding::mangledOutputPath(Vector<String>& path) > > AST::StructureDefinition* structureDefinition = nullptr; > auto& unifyNode = m_functionDefinition.type().unifyNode(); >- ASSERT(is<AST::NamedType>(unifyNode)); >- auto& namedType = downcast<AST::NamedType>(unifyNode); >- ASSERT(is<AST::StructureDefinition>(namedType)); >- structureDefinition = &downcast<AST::StructureDefinition>(namedType); >+ structureDefinition = &downcast<AST::StructureDefinition>(downcast<AST::NamedType>(unifyNode)); > for (auto& component : path) { > ASSERT(structureDefinition); > auto* next = structureDefinition->find(component); >@@ -317,9 +313,7 @@ String EntryPointScaffolding::unpackResourcesAndNamedBuiltIns() > auto lengthTemporaryName = m_namedBindGroups[i].namedBindings[j].lengthInformation->temporaryName; > > auto& unnamedType = *m_entryPointItems.inputs[iterator->value].unnamedType; >- ASSERT(is<AST::ReferenceType>(unnamedType)); >- auto& referenceType = downcast<AST::ReferenceType>(unnamedType); >- auto mangledTypeName = m_typeNamer.mangledNameForType(referenceType.elementType()); >+ auto mangledTypeName = m_typeNamer.mangledNameForType(downcast<AST::ReferenceType>(unnamedType).elementType()); > > stringBuilder.append(makeString("size_t ", lengthTemporaryName, " = ", variableName, '.', lengthElementName, ".x;\n")); > stringBuilder.append(makeString(lengthTemporaryName, " = ", lengthTemporaryName, " << 32;\n")); >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLFunctionWriter.cpp b/Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLFunctionWriter.cpp >index c02cbc5b04704b87eca4437b07563a1e71d74daa..009d4313d1d3e57aa36a4b47c1491874c0ecdac4 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLFunctionWriter.cpp >+++ b/Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLFunctionWriter.cpp >@@ -397,7 +397,6 @@ void FunctionDefinitionWriter::visit(AST::FloatLiteral& floatLiteral) > void FunctionDefinitionWriter::visit(AST::NullLiteral& nullLiteral) > { > auto& unifyNode = nullLiteral.resolvedType().unifyNode(); >- ASSERT(is<AST::UnnamedType>(unifyNode)); > auto& unnamedType = downcast<AST::UnnamedType>(unifyNode); > bool isArrayReferenceType = is<AST::ArrayReferenceType>(unnamedType); > >@@ -620,23 +619,21 @@ void FunctionDefinitionWriter::visit(AST::VariableReference& variableReference) > > String FunctionDefinitionWriter::constantExpressionString(AST::ConstantExpression& constantExpression) > { >- String result; >- constantExpression.visit(WTF::makeVisitor([&](AST::IntegerLiteral& integerLiteral) { >- result = makeString("", integerLiteral.value()); >- }, [&](AST::UnsignedIntegerLiteral& unsignedIntegerLiteral) { >- result = makeString("", unsignedIntegerLiteral.value()); >- }, [&](AST::FloatLiteral& floatLiteral) { >- result = makeString("", floatLiteral.value()); >- }, [&](AST::NullLiteral&) { >- result = "nullptr"_str; >- }, [&](AST::BooleanLiteral& booleanLiteral) { >- result = booleanLiteral.value() ? "true"_str : "false"_str; >- }, [&](AST::EnumerationMemberLiteral& enumerationMemberLiteral) { >+ return constantExpression.visit(WTF::makeVisitor([&](AST::IntegerLiteral& integerLiteral) -> String { >+ return makeString("", integerLiteral.value()); >+ }, [&](AST::UnsignedIntegerLiteral& unsignedIntegerLiteral) -> String { >+ return makeString("", unsignedIntegerLiteral.value()); >+ }, [&](AST::FloatLiteral& floatLiteral) -> String { >+ return makeString("", floatLiteral.value()); >+ }, [&](AST::NullLiteral&) -> String { >+ return "nullptr"_str; >+ }, [&](AST::BooleanLiteral& booleanLiteral) -> String { >+ return booleanLiteral.value() ? "true"_str : "false"_str; >+ }, [&](AST::EnumerationMemberLiteral& enumerationMemberLiteral) -> String { > ASSERT(enumerationMemberLiteral.enumerationDefinition()); > ASSERT(enumerationMemberLiteral.enumerationDefinition()); >- result = makeString(m_typeNamer.mangledNameForType(*enumerationMemberLiteral.enumerationDefinition()), '.', m_typeNamer.mangledNameForEnumerationMember(*enumerationMemberLiteral.enumerationMember())); >+ return makeString(m_typeNamer.mangledNameForType(*enumerationMemberLiteral.enumerationDefinition()), '.', m_typeNamer.mangledNameForEnumerationMember(*enumerationMemberLiteral.enumerationMember())); > })); >- return result; > } > > class RenderFunctionDefinitionWriter : public FunctionDefinitionWriter { >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLNativeFunctionWriter.cpp b/Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLNativeFunctionWriter.cpp >index 3afb1801848f10499a168e5f486a0d2d40b595b7..db3947b16c84d107f4e6de9d1166df856416f8b4 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLNativeFunctionWriter.cpp >+++ b/Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLNativeFunctionWriter.cpp >@@ -134,7 +134,6 @@ String writeNativeFunction(AST::NativeFunctionDeclaration& nativeFunctionDeclara > ASSERT(nativeFunctionDeclaration.parameters().size() == 1); > auto metalParameterName = typeNamer.mangledNameForType(*nativeFunctionDeclaration.parameters()[0]->type()); > auto& parameterType = nativeFunctionDeclaration.parameters()[0]->type()->unifyNode(); >- ASSERT(is<AST::UnnamedType>(parameterType)); > auto& unnamedParameterType = downcast<AST::UnnamedType>(parameterType); > if (is<AST::ArrayType>(unnamedParameterType)) { > auto& arrayParameterType = downcast<AST::ArrayType>(unnamedParameterType); >@@ -351,13 +350,11 @@ String writeNativeFunction(AST::NativeFunctionDeclaration& nativeFunctionDeclara > if (nativeFunctionDeclaration.name().startsWith("Interlocked"_str)) { > if (nativeFunctionDeclaration.name() == "InterlockedCompareExchange") { > ASSERT(nativeFunctionDeclaration.parameters().size() == 4); >- ASSERT(is<AST::PointerType>(*nativeFunctionDeclaration.parameters()[0]->type())); > auto& firstArgumentPointer = downcast<AST::PointerType>(*nativeFunctionDeclaration.parameters()[0]->type()); > auto firstArgumentAddressSpace = firstArgumentPointer.addressSpace(); > auto firstArgumentPointee = typeNamer.mangledNameForType(firstArgumentPointer.elementType()); > auto secondArgument = typeNamer.mangledNameForType(*nativeFunctionDeclaration.parameters()[1]->type()); > auto thirdArgument = typeNamer.mangledNameForType(*nativeFunctionDeclaration.parameters()[2]->type()); >- ASSERT(is<AST::PointerType>(*nativeFunctionDeclaration.parameters()[3]->type())); > auto& fourthArgumentPointer = downcast<AST::PointerType>(*nativeFunctionDeclaration.parameters()[3]->type()); > auto fourthArgumentAddressSpace = fourthArgumentPointer.addressSpace(); > auto fourthArgumentPointee = typeNamer.mangledNameForType(fourthArgumentPointer.elementType()); >@@ -369,12 +366,10 @@ String writeNativeFunction(AST::NativeFunctionDeclaration& nativeFunctionDeclara > } > > ASSERT(nativeFunctionDeclaration.parameters().size() == 3); >- ASSERT(is<AST::PointerType>(*nativeFunctionDeclaration.parameters()[0]->type())); > auto& firstArgumentPointer = downcast<AST::PointerType>(*nativeFunctionDeclaration.parameters()[0]->type()); > auto firstArgumentAddressSpace = firstArgumentPointer.addressSpace(); > auto firstArgumentPointee = typeNamer.mangledNameForType(firstArgumentPointer.elementType()); > auto secondArgument = typeNamer.mangledNameForType(*nativeFunctionDeclaration.parameters()[1]->type()); >- ASSERT(is<AST::PointerType>(*nativeFunctionDeclaration.parameters()[2]->type())); > auto& thirdArgumentPointer = downcast<AST::PointerType>(*nativeFunctionDeclaration.parameters()[2]->type()); > auto thirdArgumentAddressSpace = thirdArgumentPointer.addressSpace(); > auto thirdArgumentPointee = typeNamer.mangledNameForType(thirdArgumentPointer.elementType()); >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLNativeTypeWriter.cpp b/Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLNativeTypeWriter.cpp >index 4948d9dd3767fb8fcd6a841686e9aaab92873052..f57d5c077cc4d2fd99ad1204c147c1a8d41945d3 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLNativeTypeWriter.cpp >+++ b/Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLNativeTypeWriter.cpp >@@ -71,9 +71,7 @@ String writeNativeType(AST::NativeTypeDeclaration& nativeTypeDeclaration) > ASSERT(WTF::holds_alternative<UniqueRef<AST::TypeReference>>(nativeTypeDeclaration.typeArguments()[0])); > auto& typeReference = WTF::get<UniqueRef<AST::TypeReference>>(nativeTypeDeclaration.typeArguments()[0]); > auto& unifyNode = typeReference->unifyNode(); >- ASSERT(is<AST::NamedType>(unifyNode)); > auto& namedType = downcast<AST::NamedType>(unifyNode); >- ASSERT(is<AST::NativeTypeDeclaration>(namedType)); > auto& parameterType = downcast<AST::NativeTypeDeclaration>(namedType); > auto prefix = ([&]() -> String { > if (parameterType.name() == "bool") >@@ -116,9 +114,7 @@ String writeNativeType(AST::NativeTypeDeclaration& nativeTypeDeclaration) > ASSERT(WTF::holds_alternative<UniqueRef<AST::TypeReference>>(nativeTypeDeclaration.typeArguments()[0])); > auto& typeReference = WTF::get<UniqueRef<AST::TypeReference>>(nativeTypeDeclaration.typeArguments()[0]); > auto& unifyNode = typeReference->unifyNode(); >- ASSERT(is<AST::NamedType>(unifyNode)); > auto& namedType = downcast<AST::NamedType>(unifyNode); >- ASSERT(is<AST::NativeTypeDeclaration>(namedType)); > auto& parameterType = downcast<AST::NativeTypeDeclaration>(namedType); > auto prefix = ([&]() -> String { > if (parameterType.name() == "half") >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLTypeNamer.cpp b/Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLTypeNamer.cpp >index 41138dda6f8bb3ca22f46cd621003823f804c956..c3d82725ad09db1423c41de2494ba613376cf6d3 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLTypeNamer.cpp >+++ b/Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLTypeNamer.cpp >@@ -201,7 +201,6 @@ static BaseTypeNameNode& find(AST::UnnamedType& unnamedType, Vector<UniqueRef<Ba > return find(downcast<AST::PointerType>(unnamedType).elementType(), types).children(); > if (is<AST::ArrayReferenceType>(unnamedType)) > return find(downcast<AST::ArrayReferenceType>(unnamedType).elementType(), types).children(); >- ASSERT(is<AST::ArrayType>(unnamedType)); > return find(downcast<AST::ArrayType>(unnamedType).type(), types).children(); > })(); > auto iterator = findInVector(unnamedType, vectorToSearch); >@@ -306,7 +305,6 @@ UniqueRef<BaseTypeNameNode> TypeNamer::createNameNode(AST::UnnamedType& unnamedT > auto& arrayReferenceType = downcast<AST::ArrayReferenceType>(unnamedType); > return makeUniqueRef<ArrayReferenceTypeNameNode>(parent, generateNextTypeName(), arrayReferenceType.addressSpace()); > } >- ASSERT(is<AST::ArrayType>(unnamedType)); > auto& arrayType = downcast<AST::ArrayType>(unnamedType); > return makeUniqueRef<ArrayTypeNameNode>(parent, generateNextTypeName(), arrayType.numElements()); > } >@@ -327,7 +325,6 @@ size_t TypeNamer::insert(AST::UnnamedType& unnamedType, Vector<UniqueRef<BaseTyp > vectorToInsertInto = &item->children(); > parent = &item; > } else { >- ASSERT(is<AST::ArrayType>(unnamedType)); > auto& item = types[insert(downcast<AST::ArrayType>(unnamedType).type(), types)]; > vectorToInsertInto = &item->children(); > parent = &item; >@@ -399,7 +396,6 @@ void TypeNamer::emitUnnamedTypeDefinition(BaseTypeNameNode& baseTypeNameNode, Ha > stringBuilder.append(" uint length;\n"); > stringBuilder.append("};\n"); > } else { >- ASSERT(is<ArrayTypeNameNode>(baseTypeNameNode)); > auto& arrayType = downcast<ArrayTypeNameNode>(baseTypeNameNode); > ASSERT(baseTypeNameNode.parent()); > stringBuilder.append(makeString("typedef Array<", arrayType.parent()->mangledName(), ", ", arrayType.numElements(), "> ", arrayType.mangledName(), ";\n")); >@@ -418,7 +414,6 @@ void TypeNamer::emitNamedTypeDefinition(AST::NamedType& namedType, HashSet<AST:: > if (is<AST::EnumerationDefinition>(namedType)) { > auto& enumerationDefinition = downcast<AST::EnumerationDefinition>(namedType); > auto& baseType = enumerationDefinition.type().unifyNode(); >- ASSERT(is<AST::NamedType>(baseType)); > stringBuilder.append(makeString("enum class ", mangledNameForType(enumerationDefinition), " : ", mangledNameForType(downcast<AST::NamedType>(baseType)), " {\n")); > for (auto& enumerationMember : enumerationDefinition.enumerationMembers()) > stringBuilder.append(makeString(" ", mangledNameForEnumerationMember(enumerationMember), ",\n")); >@@ -432,7 +427,6 @@ void TypeNamer::emitNamedTypeDefinition(AST::NamedType& namedType, HashSet<AST:: > stringBuilder.append(makeString(" ", mangledNameForType(structureElement.type()), ' ', mangledNameForStructureElement(structureElement), ";\n")); > stringBuilder.append("};\n"); > } else { >- ASSERT(is<AST::TypeDefinition>(namedType)); > auto& typeDefinition = downcast<AST::TypeDefinition>(namedType); > stringBuilder.append(makeString("typedef ", mangledNameForType(typeDefinition.type()), ' ', mangledNameForType(typeDefinition), ";\n")); > } >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLChecker.cpp b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLChecker.cpp >index 1561a4f050daf57fbe123dbe60e10418d0419fa4..35c70c97b240d4a298911c2f9c2a41662df278ad 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLChecker.cpp >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLChecker.cpp >@@ -656,14 +656,12 @@ void Checker::visit(AST::EnumerationDefinition& enumerationDefinition) > auto enumerationMembers = enumerationDefinition.enumerationMembers(); > > auto matchAndCommitMember = [&](AST::EnumerationMember& member) -> bool { >- bool success = false; >- member.value()->visit(WTF::makeVisitor([&](AST::Expression& value) { >+ return member.value()->visit(WTF::makeVisitor([&](AST::Expression& value) -> bool { > auto valueInfo = recurseAndGetInfo(value); > if (!valueInfo) >- return; >- success = static_cast<bool>(matchAndCommit(valueInfo->resolvingType, *baseType)); >+ return false; >+ return static_cast<bool>(matchAndCommit(valueInfo->resolvingType, *baseType)); > })); >- return success; > }; > > for (auto& member : enumerationMembers) { >@@ -679,13 +677,13 @@ void Checker::visit(AST::EnumerationDefinition& enumerationDefinition) > int64_t nextValue = 0; > for (auto& member : enumerationMembers) { > if (member.get().value()) { >- int64_t value; >- member.get().value()->visit(WTF::makeVisitor([&](AST::IntegerLiteral& integerLiteral) { >- value = integerLiteral.valueForSelectedType(); >- }, [&](AST::UnsignedIntegerLiteral& unsignedIntegerLiteral) { >- value = unsignedIntegerLiteral.valueForSelectedType(); >- }, [&](auto&) { >+ auto value = member.get().value()->visit(WTF::makeVisitor([&](AST::IntegerLiteral& integerLiteral) -> int64_t { >+ return integerLiteral.valueForSelectedType(); >+ }, [&](AST::UnsignedIntegerLiteral& unsignedIntegerLiteral) -> int64_t { >+ return unsignedIntegerLiteral.valueForSelectedType(); >+ }, [&](auto&) -> int64_t { > ASSERT_NOT_REACHED(); >+ return 0; > })); > nextValue = baseType->successor()(value); > } else { >@@ -706,14 +704,14 @@ void Checker::visit(AST::EnumerationDefinition& enumerationDefinition) > } > > auto getValue = [&](AST::EnumerationMember& member) -> int64_t { >- int64_t value; > ASSERT(member.value()); >- member.value()->visit(WTF::makeVisitor([&](AST::IntegerLiteral& integerLiteral) { >- value = integerLiteral.value(); >- }, [&](AST::UnsignedIntegerLiteral& unsignedIntegerLiteral) { >- value = unsignedIntegerLiteral.value(); >- }, [&](auto&) { >+ auto value = member.value()->visit(WTF::makeVisitor([&](AST::IntegerLiteral& integerLiteral) -> int64_t { >+ return integerLiteral.value(); >+ }, [&](AST::UnsignedIntegerLiteral& unsignedIntegerLiteral) -> int64_t { >+ return unsignedIntegerLiteral.value(); >+ }, [&](auto&) -> int64_t { > ASSERT_NOT_REACHED(); >+ return 0; > })); > return value; > }; >@@ -977,7 +975,6 @@ static Optional<UniqueRef<AST::UnnamedType>> argumentTypeForAndOverload(AST::Unn > return { makeUniqueRef<AST::PointerType>(Lexer::Token(namedType.origin()), addressSpace, AST::TypeReference::wrap(Lexer::Token(namedType.origin()), namedType)) }; > } > >- ASSERT(is<AST::UnnamedType>(unifyNode)); > auto& unnamedType = downcast<AST::UnnamedType>(unifyNode); > > if (is<AST::ArrayReferenceType>(unnamedType)) >@@ -1305,20 +1302,19 @@ void Checker::visit(AST::SwitchStatement& switchStatement) > hasDefault = true; > continue; > } >- bool success; >- switchCase.value()->visit(WTF::makeVisitor([&](AST::IntegerLiteral& integerLiteral) { >- success = static_cast<bool>(matchAndCommit(*valueType, integerLiteral.type())); >- }, [&](AST::UnsignedIntegerLiteral& unsignedIntegerLiteral) { >- success = static_cast<bool>(matchAndCommit(*valueType, unsignedIntegerLiteral.type())); >- }, [&](AST::FloatLiteral& floatLiteral) { >- success = static_cast<bool>(matchAndCommit(*valueType, floatLiteral.type())); >- }, [&](AST::NullLiteral& nullLiteral) { >- success = static_cast<bool>(matchAndCommit(*valueType, nullLiteral.type())); >- }, [&](AST::BooleanLiteral&) { >- success = matches(*valueType, m_intrinsics.boolType()); >- }, [&](AST::EnumerationMemberLiteral& enumerationMemberLiteral) { >+ auto success = switchCase.value()->visit(WTF::makeVisitor([&](AST::IntegerLiteral& integerLiteral) -> bool { >+ return static_cast<bool>(matchAndCommit(*valueType, integerLiteral.type())); >+ }, [&](AST::UnsignedIntegerLiteral& unsignedIntegerLiteral) -> bool { >+ return static_cast<bool>(matchAndCommit(*valueType, unsignedIntegerLiteral.type())); >+ }, [&](AST::FloatLiteral& floatLiteral) -> bool { >+ return static_cast<bool>(matchAndCommit(*valueType, floatLiteral.type())); >+ }, [&](AST::NullLiteral& nullLiteral) -> bool { >+ return static_cast<bool>(matchAndCommit(*valueType, nullLiteral.type())); >+ }, [&](AST::BooleanLiteral&) -> bool { >+ return matches(*valueType, m_intrinsics.boolType()); >+ }, [&](AST::EnumerationMemberLiteral& enumerationMemberLiteral) -> bool { > ASSERT(enumerationMemberLiteral.enumerationDefinition()); >- success = matches(*valueType, *enumerationMemberLiteral.enumerationDefinition()); >+ return matches(*valueType, *enumerationMemberLiteral.enumerationDefinition()); > })); > if (!success) { > setError(); >@@ -1339,31 +1335,37 @@ void Checker::visit(AST::SwitchStatement& switchStatement) > return; > } > >- bool success = true; >- firstCase.value()->visit(WTF::makeVisitor([&](AST::IntegerLiteral& firstIntegerLiteral) { >- secondCase.value()->visit(WTF::makeVisitor([&](AST::IntegerLiteral& secondIntegerLiteral) { >- success = firstIntegerLiteral.value() != secondIntegerLiteral.value(); >- }, [&](AST::UnsignedIntegerLiteral& secondUnsignedIntegerLiteral) { >- success = static_cast<int64_t>(firstIntegerLiteral.value()) != static_cast<int64_t>(secondUnsignedIntegerLiteral.value()); >- }, [](auto&) { >+ auto success = firstCase.value()->visit(WTF::makeVisitor([&](AST::IntegerLiteral& firstIntegerLiteral) -> bool { >+ return secondCase.value()->visit(WTF::makeVisitor([&](AST::IntegerLiteral& secondIntegerLiteral) -> bool { >+ return firstIntegerLiteral.value() != secondIntegerLiteral.value(); >+ }, [&](AST::UnsignedIntegerLiteral& secondUnsignedIntegerLiteral) -> bool { >+ return static_cast<int64_t>(firstIntegerLiteral.value()) != static_cast<int64_t>(secondUnsignedIntegerLiteral.value()); >+ }, [](auto&) -> bool { >+ return true; > })); >- }, [&](AST::UnsignedIntegerLiteral& firstUnsignedIntegerLiteral) { >- secondCase.value()->visit(WTF::makeVisitor([&](AST::IntegerLiteral& secondIntegerLiteral) { >- success = static_cast<int64_t>(firstUnsignedIntegerLiteral.value()) != static_cast<int64_t>(secondIntegerLiteral.value()); >- }, [&](AST::UnsignedIntegerLiteral& secondUnsignedIntegerLiteral) { >- success = firstUnsignedIntegerLiteral.value() != secondUnsignedIntegerLiteral.value(); >- }, [](auto&) { >+ }, [&](AST::UnsignedIntegerLiteral& firstUnsignedIntegerLiteral) -> bool { >+ return secondCase.value()->visit(WTF::makeVisitor([&](AST::IntegerLiteral& secondIntegerLiteral) -> bool { >+ return static_cast<int64_t>(firstUnsignedIntegerLiteral.value()) != static_cast<int64_t>(secondIntegerLiteral.value()); >+ }, [&](AST::UnsignedIntegerLiteral& secondUnsignedIntegerLiteral) -> bool { >+ return firstUnsignedIntegerLiteral.value() != secondUnsignedIntegerLiteral.value(); >+ }, [](auto&) -> bool { >+ return true; > })); >- }, [&](AST::EnumerationMemberLiteral& firstEnumerationMemberLiteral) { >- secondCase.value()->visit(WTF::makeVisitor([&](AST::IntegerLiteral&) { >- }, [&](AST::EnumerationMemberLiteral& secondEnumerationMemberLiteral) { >+ }, [&](AST::EnumerationMemberLiteral& firstEnumerationMemberLiteral) -> bool { >+ return secondCase.value()->visit(WTF::makeVisitor([&](AST::EnumerationMemberLiteral& secondEnumerationMemberLiteral) -> bool { > ASSERT(firstEnumerationMemberLiteral.enumerationMember()); > ASSERT(secondEnumerationMemberLiteral.enumerationMember()); >- success = firstEnumerationMemberLiteral.enumerationMember() != secondEnumerationMemberLiteral.enumerationMember(); >- }, [](auto&) { >+ return firstEnumerationMemberLiteral.enumerationMember() != secondEnumerationMemberLiteral.enumerationMember(); >+ }, [](auto&) -> bool { >+ return true; > })); >- }, [](auto&) { >+ }, [](auto&) -> bool { >+ return true; > })); >+ if (!success) { >+ setError(); >+ return; >+ } > } > } > >@@ -1372,13 +1374,13 @@ void Checker::visit(AST::SwitchStatement& switchStatement) > HashSet<int64_t> values; > bool zeroValueExists; > for (auto& switchCase : switchStatement.switchCases()) { >- int64_t value; >- switchCase.value()->visit(WTF::makeVisitor([&](AST::IntegerLiteral& integerLiteral) { >- value = integerLiteral.valueForSelectedType(); >- }, [&](AST::UnsignedIntegerLiteral& unsignedIntegerLiteral) { >- value = unsignedIntegerLiteral.valueForSelectedType(); >- }, [](auto&) { >+ auto value = switchCase.value()->visit(WTF::makeVisitor([&](AST::IntegerLiteral& integerLiteral) -> int64_t { >+ return integerLiteral.valueForSelectedType(); >+ }, [&](AST::UnsignedIntegerLiteral& unsignedIntegerLiteral) -> int64_t { >+ return unsignedIntegerLiteral.valueForSelectedType(); >+ }, [](auto&) -> int64_t { > ASSERT_NOT_REACHED(); >+ return 0; > })); > if (!value) > zeroValueExists = true; >@@ -1405,7 +1407,6 @@ void Checker::visit(AST::SwitchStatement& switchStatement) > return; > } > } else { >- ASSERT(is<AST::EnumerationDefinition>(*valueType)); > HashSet<AST::EnumerationMember*> values; > for (auto& switchCase : switchStatement.switchCases()) { > switchCase.value()->visit(WTF::makeVisitor([&](AST::EnumerationMemberLiteral& enumerationMemberLiteral) { >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLInferTypes.cpp b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLInferTypes.cpp >index f565cfd089020e04587189a8c4bff121964b4363..9b31d92a01120b60364cee5b18d5a013a6b2e1a2 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLInferTypes.cpp >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLInferTypes.cpp >@@ -188,7 +188,6 @@ bool inferTypesForTypeArguments(AST::NamedType& possibleType, AST::TypeArguments > return typeArguments.isEmpty(); > } > >- ASSERT(is<AST::NativeTypeDeclaration>(possibleType)); > auto& nativeTypeDeclaration = downcast<AST::NativeTypeDeclaration>(possibleType); > if (nativeTypeDeclaration.typeArguments().size() != typeArguments.size()) > return false; >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLIntrinsics.cpp b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLIntrinsics.cpp >index cb9d8d1fc85afd8d13d9fb6cc0225a4b84c38362..c8bffb82caecfe98fb252f98ff28ffb8a35e6a7a 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLIntrinsics.cpp >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLIntrinsics.cpp >@@ -347,11 +347,7 @@ bool Intrinsics::addMatrix(AST::NativeTypeDeclaration& nativeTypeDeclaration) > > bool Intrinsics::addFullTexture(AST::NativeTypeDeclaration& nativeTypeDeclaration, AST::TypeReference& innerType) > { >- unsigned textureTypeIndex = WTF_ARRAY_LENGTH(m_textureTypeNames); >- for (unsigned i = 0; i < WTF_ARRAY_LENGTH(m_textureTypeNames); ++i) { >- if (nativeTypeDeclaration.name() == m_textureTypeNames[i]) >- textureTypeIndex = i; >- } >+ auto textureTypeIndex = std::find(m_textureTypeNames, m_textureTypeNames + WTF_ARRAY_LENGTH(m_textureTypeNames), nativeTypeDeclaration.name()) - m_textureTypeNames; > if (textureTypeIndex == WTF_ARRAY_LENGTH(m_textureTypeNames)) > return false; > >@@ -377,9 +373,9 @@ bool Intrinsics::addFullTexture(AST::NativeTypeDeclaration& nativeTypeDeclaratio > return true; > } > >-bool Intrinsics::addDepthTexture(AST::NativeTypeDeclaration& nativeTypeDeclaration, AST::TypeReference& innerType) >+void Intrinsics::addDepthTexture(AST::NativeTypeDeclaration& nativeTypeDeclaration, AST::TypeReference& innerType) > { >- AST::NativeTypeDeclaration** texture; >+ AST::NativeTypeDeclaration** texture = nullptr; > if (nativeTypeDeclaration.name() == "TextureDepth2D") > texture = m_textureDepth2D; > else if (nativeTypeDeclaration.name() == "RWTextureDepth2D") >@@ -388,19 +384,14 @@ bool Intrinsics::addDepthTexture(AST::NativeTypeDeclaration& nativeTypeDeclarati > texture = m_textureDepth2DArray; > else if (nativeTypeDeclaration.name() == "RWTextureDepth2DArray") > texture = m_rwTextureDepth2DArray; >- else if (nativeTypeDeclaration.name() == "TextureDepthCube") >+ else { >+ ASSERT(nativeTypeDeclaration.name() == "TextureDepthCube"); > texture = m_textureDepthCube; >- else >- ASSERT_NOT_REACHED(); >- unsigned innerTypeIndex = WTF_ARRAY_LENGTH(m_depthTextureInnerTypes); >- for (unsigned i = 0; i < WTF_ARRAY_LENGTH(m_depthTextureInnerTypes); ++i) { >- if (innerType.name() == m_depthTextureInnerTypes[i]) >- innerTypeIndex = i; > } >+ auto innerTypeIndex = std::find(m_depthTextureInnerTypes, m_depthTextureInnerTypes + WTF_ARRAY_LENGTH(m_depthTextureInnerTypes), innerType.name()) - m_depthTextureInnerTypes; > ASSERT(innerTypeIndex != WTF_ARRAY_LENGTH(m_depthTextureInnerTypes)); > nativeTypeDeclaration.setIsTexture(); > texture[innerTypeIndex] = &nativeTypeDeclaration; >- return true; > } > > void Intrinsics::addTexture(AST::NativeTypeDeclaration& nativeTypeDeclaration) >@@ -413,8 +404,8 @@ void Intrinsics::addTexture(AST::NativeTypeDeclaration& nativeTypeDeclaration) > m_textureSet.add(&nativeTypeDeclaration); > return; > } >- if (addDepthTexture(nativeTypeDeclaration, innerType)) >- m_textureSet.add(&nativeTypeDeclaration); >+ addDepthTexture(nativeTypeDeclaration, innerType); >+ m_textureSet.add(&nativeTypeDeclaration); > } > > void Intrinsics::add(AST::NativeTypeDeclaration& nativeTypeDeclaration) >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLIntrinsics.h b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLIntrinsics.h >index d23bf9787d80b998c793951ec750f1a791e92f4f..ad857c5f94eaf1352a31537154347d062ed0bba2 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLIntrinsics.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLIntrinsics.h >@@ -231,7 +231,7 @@ private: > bool addVector(AST::NativeTypeDeclaration&); > bool addMatrix(AST::NativeTypeDeclaration&); > bool addFullTexture(AST::NativeTypeDeclaration&, AST::TypeReference&); >- bool addDepthTexture(AST::NativeTypeDeclaration&, AST::TypeReference&); >+ void addDepthTexture(AST::NativeTypeDeclaration&, AST::TypeReference&); > void addTexture(AST::NativeTypeDeclaration&); > > HashSet<const AST::NativeTypeDeclaration*> m_textureSet; >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLPropertyResolver.cpp b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLPropertyResolver.cpp >index f80da99758d849a2ec189634f3f3244a4151956d..75b4ae3d3cc5b9381be3b5106e357eab95d5f7a7 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLPropertyResolver.cpp >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLPropertyResolver.cpp >@@ -306,7 +306,6 @@ static Optional<ModifyResult> modify(AST::PropertyAccessExpression& propertyAcce > if (iterator->base().typeAnnotation().leftAddressSpace()) > break; > ASSERT(!iterator->base().typeAnnotation().isRightValue()); >- ASSERT(is<AST::PropertyAccessExpression>(iterator->base())); > iterator = &downcast<AST::PropertyAccessExpression>(iterator->base()); > } > auto leftExpression = iterator->takeBase(); >@@ -519,7 +518,6 @@ void PropertyResolver::visit(AST::AssignmentExpression& assignmentExpression) > return; > } > ASSERT(!assignmentExpression.left().typeAnnotation().isRightValue()); >- ASSERT(is<AST::PropertyAccessExpression>(assignmentExpression.left())); > > auto type = assignmentExpression.right().resolvedType().clone(); > >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLVisitor.cpp b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLVisitor.cpp >index 2063d2a46dd0aa4fa6f15c4f8842439e6283c60f..3443d53638aef126889d332b3f5a7f356e947ee0 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLVisitor.cpp >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLVisitor.cpp >@@ -59,10 +59,8 @@ void Visitor::visit(AST::UnnamedType& unnamedType) > checkErrorAndVisit(downcast<AST::PointerType>(unnamedType)); > else if (is<AST::ArrayReferenceType>(unnamedType)) > checkErrorAndVisit(downcast<AST::ArrayReferenceType>(unnamedType)); >- else { >- ASSERT(is<AST::ArrayType>(unnamedType)); >+ else > checkErrorAndVisit(downcast<AST::ArrayType>(unnamedType)); >- } > } > > void Visitor::visit(AST::NamedType& namedType) >@@ -73,10 +71,8 @@ void Visitor::visit(AST::NamedType& namedType) > checkErrorAndVisit(downcast<AST::StructureDefinition>(namedType)); > else if (is<AST::EnumerationDefinition>(namedType)) > checkErrorAndVisit(downcast<AST::EnumerationDefinition>(namedType)); >- else { >- ASSERT(is<AST::NativeTypeDeclaration>(namedType)); >+ else > checkErrorAndVisit(downcast<AST::NativeTypeDeclaration>(namedType)); >- } > } > > void Visitor::visit(AST::TypeDefinition& typeDefinition) >@@ -336,10 +332,8 @@ void Visitor::visit(AST::Statement& statement) > checkErrorAndVisit(downcast<AST::Trap>(statement)); > else if (is<AST::VariableDeclarationsStatement>(statement)) > checkErrorAndVisit(downcast<AST::VariableDeclarationsStatement>(statement)); >- else { >- ASSERT(is<AST::WhileLoop>(statement)); >+ else > checkErrorAndVisit(downcast<AST::WhileLoop>(statement)); >- } > } > > void Visitor::visit(AST::Break&) >@@ -396,10 +390,8 @@ void Visitor::visit(AST::Expression& expression) > checkErrorAndVisit(downcast<AST::UnsignedIntegerLiteral>(expression)); > else if (is<AST::EnumerationMemberLiteral>(expression)) > checkErrorAndVisit(downcast<AST::EnumerationMemberLiteral>(expression)); >- else { >- ASSERT(is<AST::VariableReference>(expression)); >+ else > checkErrorAndVisit(downcast<AST::VariableReference>(expression)); >- } > } > > void Visitor::visit(AST::DotExpression& dotExpression)
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
Flags:
dino
:
review+
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 198706
:
371724
|
372022
| 372066