Diff
Modified: trunk/Source/WebCore/ChangeLog (246427 => 246428)
--- trunk/Source/WebCore/ChangeLog 2019-06-14 05:20:00 UTC (rev 246427)
+++ trunk/Source/WebCore/ChangeLog 2019-06-14 05:45:43 UTC (rev 246428)
@@ -1,3 +1,52 @@
+2019-06-13 Myles C. Maxfield <mmaxfi...@apple.com>
+
+ [WHLSL] Remove unnecessary ASSERT()s and clean up visitor lambdas
+ https://bugs.webkit.org/show_bug.cgi?id=198706
+
+ Reviewed by Dean Jackson, Saam Barati, and Robin Morisset.
+
+ 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 <mmaxfi...@apple.com>
[WHLSL] Hook up compute
Modified: trunk/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLConstantExpression.h (246427 => 246428)
--- trunk/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLConstantExpression.h 2019-06-14 05:20:00 UTC (rev 246427)
+++ trunk/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLConstantExpression.h 2019-06-14 05:45:43 UTC (rev 246428)
@@ -88,14 +88,14 @@
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
Modified: trunk/Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLEntryPointScaffolding.cpp (246427 => 246428)
--- trunk/Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLEntryPointScaffolding.cpp 2019-06-14 05:20:00 UTC (rev 246427)
+++ trunk/Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLEntryPointScaffolding.cpp 2019-06-14 05:45:43 UTC (rev 246428)
@@ -148,7 +148,6 @@
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 @@
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 @@
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"));
Modified: trunk/Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLFunctionWriter.cpp (246427 => 246428)
--- trunk/Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLFunctionWriter.cpp 2019-06-14 05:20:00 UTC (rev 246427)
+++ trunk/Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLFunctionWriter.cpp 2019-06-14 05:45:43 UTC (rev 246428)
@@ -397,7 +397,6 @@
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 @@
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 {
Modified: trunk/Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLNativeFunctionWriter.cpp (246427 => 246428)
--- trunk/Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLNativeFunctionWriter.cpp 2019-06-14 05:20:00 UTC (rev 246427)
+++ trunk/Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLNativeFunctionWriter.cpp 2019-06-14 05:45:43 UTC (rev 246428)
@@ -134,7 +134,6 @@
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 @@
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 @@
}
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());
Modified: trunk/Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLNativeTypeWriter.cpp (246427 => 246428)
--- trunk/Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLNativeTypeWriter.cpp 2019-06-14 05:20:00 UTC (rev 246427)
+++ trunk/Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLNativeTypeWriter.cpp 2019-06-14 05:45:43 UTC (rev 246428)
@@ -71,9 +71,7 @@
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 @@
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")
Modified: trunk/Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLTypeNamer.cpp (246427 => 246428)
--- trunk/Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLTypeNamer.cpp 2019-06-14 05:20:00 UTC (rev 246427)
+++ trunk/Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLTypeNamer.cpp 2019-06-14 05:45:43 UTC (rev 246428)
@@ -201,7 +201,6 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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"));
}
Modified: trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLChecker.cpp (246427 => 246428)
--- trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLChecker.cpp 2019-06-14 05:20:00 UTC (rev 246427)
+++ trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLChecker.cpp 2019-06-14 05:45:43 UTC (rev 246428)
@@ -656,14 +656,12 @@
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 @@
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 @@
}
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 @@
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 @@
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 @@
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 @@
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 @@
return;
}
} else {
- ASSERT(is<AST::EnumerationDefinition>(*valueType));
HashSet<AST::EnumerationMember*> values;
for (auto& switchCase : switchStatement.switchCases()) {
switchCase.value()->visit(WTF::makeVisitor([&](AST::EnumerationMemberLiteral& enumerationMemberLiteral) {
Modified: trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLInferTypes.cpp (246427 => 246428)
--- trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLInferTypes.cpp 2019-06-14 05:20:00 UTC (rev 246427)
+++ trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLInferTypes.cpp 2019-06-14 05:45:43 UTC (rev 246428)
@@ -188,7 +188,6 @@
return typeArguments.isEmpty();
}
- ASSERT(is<AST::NativeTypeDeclaration>(possibleType));
auto& nativeTypeDeclaration = downcast<AST::NativeTypeDeclaration>(possibleType);
if (nativeTypeDeclaration.typeArguments().size() != typeArguments.size())
return false;
Modified: trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLIntrinsics.cpp (246427 => 246428)
--- trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLIntrinsics.cpp 2019-06-14 05:20:00 UTC (rev 246427)
+++ trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLIntrinsics.cpp 2019-06-14 05:45:43 UTC (rev 246428)
@@ -347,11 +347,7 @@
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 @@
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 @@
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 @@
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)
Modified: trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLIntrinsics.h (246427 => 246428)
--- trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLIntrinsics.h 2019-06-14 05:20:00 UTC (rev 246427)
+++ trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLIntrinsics.h 2019-06-14 05:45:43 UTC (rev 246428)
@@ -231,7 +231,7 @@
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;
Modified: trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLPropertyResolver.cpp (246427 => 246428)
--- trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLPropertyResolver.cpp 2019-06-14 05:20:00 UTC (rev 246427)
+++ trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLPropertyResolver.cpp 2019-06-14 05:45:43 UTC (rev 246428)
@@ -306,7 +306,6 @@
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 @@
return;
}
ASSERT(!assignmentExpression.left().typeAnnotation().isRightValue());
- ASSERT(is<AST::PropertyAccessExpression>(assignmentExpression.left()));
auto type = assignmentExpression.right().resolvedType().clone();
Modified: trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLVisitor.cpp (246427 => 246428)
--- trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLVisitor.cpp 2019-06-14 05:20:00 UTC (rev 246427)
+++ trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLVisitor.cpp 2019-06-14 05:45:43 UTC (rev 246428)
@@ -59,10 +59,8 @@
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 @@
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 @@
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 @@
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)