Changeset 247144 in webkit
- Timestamp:
- Jul 4, 2019 11:53:37 AM (5 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r247142 r247144 1 2019-07-04 Ryan Haddad <ryanhaddad@apple.com> 2 3 Unreviewed, rolling out r247127. 4 5 Broke the watchOS build. 6 7 Reverted changeset: 8 9 "[WHLSL] Remove the phase resolveCallsInFunctions" 10 https://bugs.webkit.org/show_bug.cgi?id=199474 11 https://trac.webkit.org/changeset/247127 12 1 13 2019-07-03 Simon Fraser <simon.fraser@apple.com> 2 14 -
trunk/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLCallExpression.h
r247127 r247144 68 68 bool isCast() { return m_castReturnType; } 69 69 NamedType* castReturnType() { return m_castReturnType; } 70 bool hasOverloads() const { return static_cast<bool>(m_overloads); } 71 Optional<Vector<std::reference_wrapper<FunctionDeclaration>, 1>>& overloads() { return m_overloads; } 72 void setOverloads(const Vector<std::reference_wrapper<FunctionDeclaration>, 1>& overloads) 73 { 74 ASSERT(!hasOverloads()); 75 m_overloads = overloads; 76 } 70 77 71 78 FunctionDeclaration& function() … … 84 91 String m_name; 85 92 Vector<UniqueRef<Expression>> m_arguments; 93 Optional<Vector<std::reference_wrapper<FunctionDeclaration>, 1>> m_overloads; 86 94 FunctionDeclaration* m_function { nullptr }; 87 95 NamedType* m_castReturnType { nullptr }; -
trunk/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLPropertyAccessExpression.h
r247127 r247144 58 58 virtual String anderFunctionName() const = 0; 59 59 60 Vector<std::reference_wrapper<FunctionDeclaration>, 1>& possibleGetterOverloads() { return m_possibleGetterOverloads; } 61 Vector<std::reference_wrapper<FunctionDeclaration>, 1>& possibleSetterOverloads() { return m_possibleSetterOverloads; } 62 Vector<std::reference_wrapper<FunctionDeclaration>, 1>& possibleAnderOverloads() { return m_possibleAnderOverloads; } 60 63 FunctionDeclaration* getterFunction() { return m_getterFunction; } 61 64 FunctionDeclaration* anderFunction() { return m_anderFunction; } 62 65 FunctionDeclaration* threadAnderFunction() { return m_threadAnderFunction; } 63 66 FunctionDeclaration* setterFunction() { return m_setterFunction; } 67 68 void setPossibleGetterOverloads(const Vector<std::reference_wrapper<FunctionDeclaration>, 1>& overloads) 69 { 70 m_possibleGetterOverloads = overloads; 71 } 72 void setPossibleAnderOverloads(const Vector<std::reference_wrapper<FunctionDeclaration>, 1>& overloads) 73 { 74 m_possibleAnderOverloads = overloads; 75 } 76 void setPossibleSetterOverloads(const Vector<std::reference_wrapper<FunctionDeclaration>, 1>& overloads) 77 { 78 m_possibleSetterOverloads = overloads; 79 } 64 80 65 81 void setGetterFunction(FunctionDeclaration* getterFunction) … … 89 105 private: 90 106 UniqueRef<Expression> m_base; 107 Vector<std::reference_wrapper<FunctionDeclaration>, 1> m_possibleGetterOverloads; 108 Vector<std::reference_wrapper<FunctionDeclaration>, 1> m_possibleSetterOverloads; 109 Vector<std::reference_wrapper<FunctionDeclaration>, 1> m_possibleAnderOverloads; 91 110 FunctionDeclaration* m_getterFunction { nullptr }; 92 111 FunctionDeclaration* m_anderFunction { nullptr }; -
trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLAutoInitializeVariables.cpp
r247127 r247144 73 73 callExpression->setType(type->clone()); 74 74 callExpression->setTypeAnnotation(AST::RightValue()); 75 callExpression->setOverloads(m_castFunctions); 75 76 Vector<std::reference_wrapper<ResolvingType>> argumentTypes; 76 auto* function = resolveFunctionOverload( m_castFunctions, argumentTypes, type);77 auto* function = resolveFunctionOverload(*callExpression->overloads(), argumentTypes, type); 77 78 if (!function) { 78 79 setError(); -
trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLChecker.cpp
r247127 r247144 47 47 #include "WHLSLMakeArrayReferenceExpression.h" 48 48 #include "WHLSLMakePointerExpression.h" 49 #include "WHLSLNameContext.h"50 49 #include "WHLSLPointerType.h" 51 50 #include "WHLSLProgram.h" … … 218 217 } 219 218 220 static AST::FunctionDeclaration* resolveFunction(Program& program, Vector<std::reference_wrapper<AST::FunctionDeclaration>, 1>* possibleOverloads, Vector<std::reference_wrapper<ResolvingType>>& types, const String& name, Lexer::Token origin, const Intrinsics& intrinsics, AST::NamedType* castReturnType = nullptr) 221 { 222 if (possibleOverloads) { 223 if (AST::FunctionDeclaration* function = resolveFunctionOverload(*possibleOverloads, types, castReturnType)) 224 return function; 225 } 219 static AST::FunctionDeclaration* resolveFunction(Program& program, Vector<std::reference_wrapper<AST::FunctionDeclaration>, 1>& possibleOverloads, Vector<std::reference_wrapper<ResolvingType>>& types, const String& name, Lexer::Token origin, const Intrinsics& intrinsics, AST::NamedType* castReturnType = nullptr) 220 { 221 if (AST::FunctionDeclaration* function = resolveFunctionOverload(possibleOverloads, types, castReturnType)) 222 return function; 226 223 227 224 if (auto newFunction = resolveByInstantiation(name, origin, types, intrinsics)) { … … 1024 1021 if (additionalArgumentType) 1025 1022 getterArgumentTypes.append(*additionalArgumentType); 1026 auto getterName = propertyAccessExpression.getterFunctionName(); 1027 auto* getterFunctions = m_program.nameContext().getFunctions(getterName); 1028 getterFunction = resolveFunction(m_program, getterFunctions, getterArgumentTypes, getterName, propertyAccessExpression.origin(), m_intrinsics); 1029 if (getterFunction) 1023 if ((getterFunction = resolveFunction(m_program, propertyAccessExpression.possibleGetterOverloads(), getterArgumentTypes, propertyAccessExpression.getterFunctionName(), propertyAccessExpression.origin(), m_intrinsics))) 1030 1024 getterReturnType = &getterFunction->type(); 1031 1025 } … … 1040 1034 if (additionalArgumentType) 1041 1035 anderArgumentTypes.append(*additionalArgumentType); 1042 auto anderName = propertyAccessExpression.anderFunctionName(); 1043 auto* anderFunctions = m_program.nameContext().getFunctions(anderName); 1044 anderFunction = resolveFunction(m_program, anderFunctions, anderArgumentTypes, anderName, propertyAccessExpression.origin(), m_intrinsics); 1045 if (anderFunction) 1036 if ((anderFunction = resolveFunction(m_program, propertyAccessExpression.possibleAnderOverloads(), anderArgumentTypes, propertyAccessExpression.anderFunctionName(), propertyAccessExpression.origin(), m_intrinsics))) 1046 1037 anderReturnType = &downcast<AST::PointerType>(anderFunction->type()).elementType(); // FIXME: https://bugs.webkit.org/show_bug.cgi?id=198164 Enforce the return of anders will always be a pointer 1047 1038 } … … 1055 1046 if (additionalArgumentType) 1056 1047 threadAnderArgumentTypes.append(*additionalArgumentType); 1057 auto anderName = propertyAccessExpression.anderFunctionName(); 1058 auto* anderFunctions = m_program.nameContext().getFunctions(anderName); 1059 threadAnderFunction = resolveFunction(m_program, anderFunctions, threadAnderArgumentTypes, anderName, propertyAccessExpression.origin(), m_intrinsics); 1060 if (threadAnderFunction) 1048 if ((threadAnderFunction = resolveFunction(m_program, propertyAccessExpression.possibleAnderOverloads(), threadAnderArgumentTypes, propertyAccessExpression.anderFunctionName(), propertyAccessExpression.origin(), m_intrinsics))) 1061 1049 threadAnderReturnType = &downcast<AST::PointerType>(threadAnderFunction->type()).elementType(); // FIXME: https://bugs.webkit.org/show_bug.cgi?id=198164 Enforce the return of anders will always be a pointer 1062 1050 } … … 1102 1090 setterArgumentTypes.append(*additionalArgumentType); 1103 1091 setterArgumentTypes.append(fieldResolvingType); 1104 auto setterName = propertyAccessExpression.setterFunctionName(); 1105 auto* setterFunctions = m_program.nameContext().getFunctions(setterName); 1106 setterFunction = resolveFunction(m_program, setterFunctions, setterArgumentTypes, setterName, propertyAccessExpression.origin(), m_intrinsics); 1092 setterFunction = resolveFunction(m_program, propertyAccessExpression.possibleSetterOverloads(), setterArgumentTypes, propertyAccessExpression.setterFunctionName(), propertyAccessExpression.origin(), m_intrinsics); 1107 1093 if (setterFunction) 1108 1094 setterReturnType = &setterFunction->type(); … … 1484 1470 // We don't want to recurse to the same node twice. 1485 1471 1486 NameContext& nameContext = m_program.nameContext(); 1487 auto* functions = nameContext.getFunctions(callExpression.name()); 1488 if (!functions) { 1489 if (auto* types = nameContext.getTypes(callExpression.name())) { 1490 if (types->size() == 1) { 1491 if ((functions = nameContext.getFunctions("operator cast"_str))) 1492 callExpression.setCastData((*types)[0].get()); 1493 } 1494 } 1495 } 1496 if (!functions) { 1497 setError(); 1498 return; 1499 } 1500 1501 auto* function = resolveFunction(m_program, functions, types, callExpression.name(), callExpression.origin(), m_intrinsics, callExpression.castReturnType()); 1472 ASSERT(callExpression.hasOverloads()); 1473 auto* function = resolveFunction(m_program, *callExpression.overloads(), types, callExpression.name(), callExpression.origin(), m_intrinsics, callExpression.castReturnType()); 1502 1474 if (!function) { 1503 1475 setError(); -
trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLNameResolver.cpp
r247127 r247144 62 62 , m_parentNameResolver(&parentResolver) 63 63 { 64 m_isResolvingCalls = parentResolver.m_isResolvingCalls; 64 65 setCurrentFunctionDefinition(parentResolver.m_currentFunction); 65 66 } … … 73 74 void NameResolver::visit(AST::TypeReference& typeReference) 74 75 { 76 if (m_isResolvingCalls) 77 return; 78 75 79 ScopedSetAdder<AST::TypeReference*> adder(m_typeReferences, &typeReference); 76 80 if (!adder.isNewEntry()) { … … 200 204 void NameResolver::visit(AST::PropertyAccessExpression& propertyAccessExpression) 201 205 { 206 if (m_isResolvingCalls) { 207 if (auto* getterFunctions = m_nameContext.getFunctions(propertyAccessExpression.getterFunctionName())) 208 propertyAccessExpression.setPossibleGetterOverloads(*getterFunctions); 209 if (auto* setterFunctions = m_nameContext.getFunctions(propertyAccessExpression.setterFunctionName())) 210 propertyAccessExpression.setPossibleSetterOverloads(*setterFunctions); 211 if (auto* anderFunctions = m_nameContext.getFunctions(propertyAccessExpression.anderFunctionName())) 212 propertyAccessExpression.setPossibleAnderOverloads(*anderFunctions); 213 } 202 214 Visitor::visit(propertyAccessExpression); 203 215 } … … 230 242 void NameResolver::visit(AST::CallExpression& callExpression) 231 243 { 244 if (m_isResolvingCalls) { 245 if (!callExpression.hasOverloads()) { 246 if (auto* functions = m_nameContext.getFunctions(callExpression.name())) 247 callExpression.setOverloads(*functions); 248 else { 249 if (auto* types = m_nameContext.getTypes(callExpression.name())) { 250 if (types->size() == 1) { 251 if (auto* functions = m_nameContext.getFunctions("operator cast"_str)) { 252 callExpression.setCastData((*types)[0].get()); 253 callExpression.setOverloads(*functions); 254 } 255 } 256 } 257 } 258 } 259 if (!callExpression.hasOverloads()) { 260 setError(); 261 return; 262 } 263 } 232 264 Visitor::visit(callExpression); 233 265 } … … 304 336 } 305 337 338 bool resolveCallsInFunctions(Program& program, NameResolver& nameResolver) 339 { 340 nameResolver.setIsResolvingCalls(true); 341 for (auto& functionDefinition : program.functionDefinitions()) { 342 nameResolver.setCurrentFunctionDefinition(&functionDefinition); 343 nameResolver.checkErrorAndVisit(functionDefinition); 344 if (nameResolver.error()) 345 return false; 346 } 347 nameResolver.setCurrentFunctionDefinition(nullptr); 348 nameResolver.setIsResolvingCalls(false); 349 return true; 350 } 351 306 352 } // namespace WHLSL 307 353 -
trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLNameResolver.h
r247127 r247144 52 52 } 53 53 54 void setIsResolvingCalls(bool isResolvingCalls) { m_isResolvingCalls = isResolvingCalls; } 55 54 56 private: 55 57 void visit(AST::NativeFunctionDeclaration&) override; … … 72 74 AST::FunctionDefinition* m_currentFunction { nullptr }; 73 75 NameResolver* m_parentNameResolver { nullptr }; 76 bool m_isResolvingCalls { false }; 74 77 }; 75 78 76 79 bool resolveNamesInTypes(Program&, NameResolver&); 77 80 bool resolveTypeNamesInFunctions(Program&, NameResolver&); 81 bool resolveCallsInFunctions(Program&, NameResolver&); 78 82 79 83 } // namespace WHLSL -
trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLPrepare.cpp
r247127 r247144 129 129 CHECK_PASS(resolveTypeNamesInFunctions, program, nameResolver); 130 130 CHECK_PASS(synthesizeConstructors, program); 131 CHECK_PASS(resolveCallsInFunctions, program, nameResolver); 131 132 CHECK_PASS(checkDuplicateFunctions, program); 132 133
Note: See TracChangeset
for help on using the changeset viewer.