[WHLSL] Ensure structs/arrays with pointers as fields are disallowed
authorsbarati@apple.com <sbarati@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 11 Sep 2019 07:17:17 +0000 (07:17 +0000)
committersbarati@apple.com <sbarati@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 11 Sep 2019 07:17:17 +0000 (07:17 +0000)
commit29411b42ddffc746c471d8ef927ae626be98e38d
tree485bfe58c8b553a583ec583ce13c05773f41070e
parent7089d51497e9049ff00f29fef525f479ce035edd
[WHLSL] Ensure structs/arrays with pointers as fields are disallowed
https://bugs.webkit.org/show_bug.cgi?id=201525

Reviewed by Robin Morisset.

Source/WebCore:

This patch adds a pass which both ensures that references are always initialized with
concrete values and that we support logical mode validation by disallowing nested references.

Specifically, the pass:

1. Disallows structs to have fields which are references. This prevents us from having to
figure out how to default initialize such a struct. We could relax this in the future if we
did an analysis on which structs contain reference fields, and ensure such struct variables
always have initializers. This would also require us to create constructors for structs which
initialize each field.
2. We also do the same for arrays.
3. References can only be one level deep. So no pointers to pointers. No references to
references, etc. This is to support logical mode validation rules.

Test: webgpu/whlsl/ensure-proper-pointer-usage.html

* Modules/webgpu/WHLSL/WHLSLCheckReferenceTypes.cpp: Added.
(WebCore::WHLSL::checkReferenceTypes):
* Modules/webgpu/WHLSL/WHLSLCheckReferenceTypes.h: Added.
* Modules/webgpu/WHLSL/WHLSLChecker.cpp:
(WebCore::WHLSL::Checker::visit):
* Modules/webgpu/WHLSL/WHLSLPrepare.cpp:
(WebCore::WHLSL::prepareShared):
* Sources.txt:
* WebCore.xcodeproj/project.pbxproj:

LayoutTests:

This patch fixes a bug in our test harness where we forgot to wait for the gpu
device to load before running test harness tests. This patch fixes this oversight
and asserts that we have always finished loading before running a test.

* webgpu/whlsl/array-spec-tests.html:
* webgpu/whlsl/ensure-proper-pointer-usage-expected.txt: Added.
* webgpu/whlsl/ensure-proper-pointer-usage.html: Added.
* webgpu/whlsl/js/test-harness.js:
(Harness):
(Harness.prototype.async.requestDevice):
(Harness.prototype.async.callTypedFunction):
(Harness.prototype.async.checkCompileFail):
* webgpu/whlsl/pointer-spec-tests.html:
* webgpu/whlsl/test-harness-test.html:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@249758 268f45cc-cd09-0410-ab3c-d52691b4dbfc
14 files changed:
LayoutTests/ChangeLog
LayoutTests/webgpu/whlsl/array-spec-tests.html
LayoutTests/webgpu/whlsl/ensure-proper-pointer-usage-expected.txt [new file with mode: 0644]
LayoutTests/webgpu/whlsl/ensure-proper-pointer-usage.html [new file with mode: 0644]
LayoutTests/webgpu/whlsl/js/test-harness.js
LayoutTests/webgpu/whlsl/pointer-spec-tests.html
LayoutTests/webgpu/whlsl/test-harness-test.html
Source/WebCore/ChangeLog
Source/WebCore/Modules/webgpu/WHLSL/WHLSLCheckReferenceTypes.cpp [new file with mode: 0644]
Source/WebCore/Modules/webgpu/WHLSL/WHLSLCheckReferenceTypes.h [new file with mode: 0644]
Source/WebCore/Modules/webgpu/WHLSL/WHLSLChecker.cpp
Source/WebCore/Modules/webgpu/WHLSL/WHLSLPrepare.cpp
Source/WebCore/Sources.txt
Source/WebCore/WebCore.xcodeproj/project.pbxproj