Changeset 239975 in webkit
- Timestamp:
- Jan 14, 2019 10:01:44 PM (5 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 4 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r239974 r239975 1 2019-01-14 Myles C. Maxfield <mmaxfield@apple.com> 2 3 [WHLSL] Implement the Type Checker 4 https://bugs.webkit.org/show_bug.cgi?id=193080 5 6 Reviewed by Dean Jackson. 7 8 This is a translation of https://github.com/gpuweb/WHLSL/blob/master/Source/Checker.mjs into C++. 9 10 The Checker passes types between nested expressions. An inner expression figures out what type it is, and 11 passes that information up to an outer expression. This is done via reading/writing into a HashMap, 12 because all the type information needs to be saved so that the Metal codegen can emit the correct types. 13 14 These types can have two forms: A regular type (like "int[]") or a ResolvableType. ResolvableTypes 15 represent literals, since a literal needs to know its context before it knows what type it should be. So, 16 if you have a function like "void foo(int x)" and you have a call like "foo(3)", the 3's ResolvableType 17 gets passed to the CallExpression, which then unifies it with the function's parameter type, thereby 18 resolving the 3 to be an int. 19 20 There are a few examples where multiple expressions will have the same type: "return (foo, 3)." If those 21 types are regular types, then it's no problem; we can just clone() the type and stick both in the HashMap. 22 However, if the type is a ResolvableType, an outer expression will only resolve that type once, so the two 23 ResolvableTypes can't be distinct. The Checker solves this problem by making a reference-counted wrapper 24 around ResolvableTypes and using that in the HashMap instead. 25 26 Once all the ResolvableTypes have been resolved, a second pass runs through the entire HashMap and assigns 27 the known types to all the expressions. LValues and their associated address spaces are held in a parallel 28 HashMap, and are assigned to the expression at the same time. The type is an Optional<AddressSpace> because 29 address spaces are only relevant if the value is an lvalue; if it's nullopt then that means the expression 30 is an rvalue. 31 32 No new tests because it isn't hooked up yet. Not enough of the compiler exists to have any meaningful sort 33 of test. When enough of the compiler is present, I'll port the reference implementation's test suite. 34 35 * Modules/webgpu/WHLSL/WHLSLChecker.cpp: Added. 36 (WebCore::WHLSL::resolveWithOperatorAnderIndexer): 37 (WebCore::WHLSL::resolveWithOperatorLength): 38 (WebCore::WHLSL::resolveWithReferenceComparator): 39 (WebCore::WHLSL::resolveByInstantiation): 40 (WebCore::WHLSL::checkSemantics): 41 (WebCore::WHLSL::checkOperatorOverload): 42 (WebCore::WHLSL::Checker::Checker): 43 (WebCore::WHLSL::Checker::visit): 44 (WebCore::WHLSL::Checker::assignTypes): 45 (WebCore::WHLSL::Checker::checkShaderType): 46 (WebCore::WHLSL::matchAndCommit): 47 (WebCore::WHLSL::Checker::recurseAndGetInfo): 48 (WebCore::WHLSL::Checker::getInfo): 49 (WebCore::WHLSL::Checker::assignType): 50 (WebCore::WHLSL::Checker::forwardType): 51 (WebCore::WHLSL::getUnnamedType): 52 (WebCore::WHLSL::Checker::finishVisitingPropertyAccess): 53 (WebCore::WHLSL::Checker::recurseAndWrapBaseType): 54 (WebCore::WHLSL::Checker::isBoolType): 55 (WebCore::WHLSL::Checker::recurseAndRequireBoolType): 56 (WebCore::WHLSL::check): 57 * Modules/webgpu/WHLSL/WHLSLChecker.h: Added. 58 * Modules/webgpu/WHLSL/WHLSLGatherEntryPointItems.cpp: Added. 59 (WebCore::WHLSL::Gatherer::Gatherer): 60 (WebCore::WHLSL::Gatherer::reset): 61 (WebCore::WHLSL::Gatherer::takeEntryPointItems): 62 (WebCore::WHLSL::Gatherer::visit): 63 (WebCore::WHLSL::gatherEntryPointItems): 64 * Modules/webgpu/WHLSL/WHLSLGatherEntryPointItems.h: Added. 65 (WebCore::WHLSL::EntryPointItem::EntryPointItem): 66 * Sources.txt: 67 * WebCore.xcodeproj/project.pbxproj: 68 1 69 2019-01-14 Alex Christensen <achristensen@webkit.org> 2 70 -
trunk/Source/WebCore/Sources.txt
r239902 r239975 310 310 Modules/webgpu/WHLSL/WHLSLLexer.cpp 311 311 Modules/webgpu/WHLSL/WHLSLParser.cpp 312 Modules/webgpu/WHLSL/WHLSLChecker.cpp 313 Modules/webgpu/WHLSL/WHLSLGatherEntryPointItems.cpp 312 314 Modules/webgpu/WHLSL/WHLSLCheckDuplicateFunctions.cpp 313 315 Modules/webgpu/WHLSL/WHLSLRecursiveTypeChecker.cpp -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r239930 r239975 6414 6414 1C81B9560E97330800266E07 /* InspectorController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InspectorController.h; sourceTree = "<group>"; }; 6415 6415 1C81B9570E97330800266E07 /* InspectorController.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InspectorController.cpp; sourceTree = "<group>"; }; 6416 1C840B9721EC400700D0500D /* WHLSLChecker.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLChecker.h; sourceTree = "<group>"; }; 6417 1C840B9921EC400800D0500D /* WHLSLGatherEntryPointItems.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WHLSLGatherEntryPointItems.cpp; sourceTree = "<group>"; }; 6418 1C840B9A21EC400900D0500D /* WHLSLGatherEntryPointItems.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLGatherEntryPointItems.h; sourceTree = "<group>"; }; 6419 1C840B9B21EC400900D0500D /* WHLSLChecker.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WHLSLChecker.cpp; sourceTree = "<group>"; }; 6416 6420 1C81B9580E97330800266E07 /* InspectorClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InspectorClient.h; sourceTree = "<group>"; }; 6417 6421 1C840B7D21EBE0B800D0500D /* WHLSLEntryPointType.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLEntryPointType.h; sourceTree = "<group>"; }; … … 25417 25421 C234A9B221E92C1F003C984D /* WHLSLCheckDuplicateFunctions.cpp */, 25418 25422 C234A9AE21E92C1A003C984D /* WHLSLCheckDuplicateFunctions.h */, 25423 1C840B9B21EC400900D0500D /* WHLSLChecker.cpp */, 25424 1C840B9721EC400700D0500D /* WHLSLChecker.h */, 25425 1C840B9921EC400800D0500D /* WHLSLGatherEntryPointItems.cpp */, 25426 1C840B9A21EC400900D0500D /* WHLSLGatherEntryPointItems.h */, 25419 25427 C234A99A21E90F56003C984D /* WHLSLInferTypes.cpp */, 25420 25428 C234A99B21E90F57003C984D /* WHLSLInferTypes.h */,
Note: See TracChangeset
for help on using the changeset viewer.