[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 23:34:42 +0000 (23:34 +0000)
committersbarati@apple.com <sbarati@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 11 Sep 2019 23:34:42 +0000 (23:34 +0000)
commitb6d43b9115dafbe9fec676a63bc5d60c01003cf3
tree0d5a944143ae8c33e66130edf98cbeec7ffc95d9
parent93f3e321eb2b314a339ab98f9bcd8bface8f7919
[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@249787 268f45cc-cd09-0410-ab3c-d52691b4dbfc
15 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/Modules/webgpu/WHLSL/WHLSLPruneUnreachableStandardLibraryFunctions.cpp
Source/WebCore/Sources.txt
Source/WebCore/WebCore.xcodeproj/project.pbxproj