Title: [246515] trunk
Revision
246515
Author
[email protected]
Date
2019-06-17 14:44:23 -0700 (Mon, 17 Jun 2019)

Log Message

[WHLSL] Make .length work
https://bugs.webkit.org/show_bug.cgi?id=198890

Reviewed by Myles Maxfield.

Source/WebCore:

This patch makes accessing .length on buffers work. To make this work as
expected, I've fixed a handful of small bugs:
        
- The checker was not calling resolveByInstantiation for getters. This patch
  modifies the checker to do that, so we can now resolve a getter to
  "operator.length". I also refactored the checker to have a helper method
  that both does overload resolution and resolveByInstantiation to make it
  difficult to forget to call resolveByInstantiation.
- The property resolver had a bug where it would return a non-null value
  in anderCallArgument for array references even when there was no ander and
  no thread ander function. This patch makes it now return null if there is
  neither an ander nor a thread ander.
- The metal codegen incorrectly unpacked the length of buffers. It swapped the
  bottom four bytes and the top four bytes of the size_t value. This patch
  corrects that. This was also a cause of flakiness in various tests since
  we ended up with a length much larger than expected, leading to bounds
  checks always passing in our tests.
- This patch also fixes our tests to specify the output buffer length
  properly for various programs.

Test: webgpu/whlsl-buffer-length.html

* Modules/webgpu/WHLSL/Metal/WHLSLEntryPointScaffolding.cpp:
(WebCore::WHLSL::Metal::EntryPointScaffolding::unpackResourcesAndNamedBuiltIns):
* Modules/webgpu/WHLSL/WHLSLChecker.cpp:
(WebCore::WHLSL::resolveFunction):
(WebCore::WHLSL::Checker::finishVisiting):
(WebCore::WHLSL::Checker::visit):
* Modules/webgpu/WHLSL/WHLSLPropertyResolver.cpp:
(WebCore::WHLSL::anderCallArgument):

LayoutTests:

* TestExpectations:
* webgpu/whlsl-buffer-length-expected.txt: Added.
* webgpu/whlsl-buffer-length.html: Added.
* webgpu/whlsl-buffer-vertex.html:
* webgpu/whlsl-compute.html:
* webgpu/whlsl-null-dereference.html:
* webgpu/whlsl-oob-access.html:

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (246514 => 246515)


--- trunk/LayoutTests/ChangeLog	2019-06-17 20:40:08 UTC (rev 246514)
+++ trunk/LayoutTests/ChangeLog	2019-06-17 21:44:23 UTC (rev 246515)
@@ -1,3 +1,18 @@
+2019-06-17  Saam Barati  <[email protected]>
+
+        [WHLSL] Make .length work
+        https://bugs.webkit.org/show_bug.cgi?id=198890
+
+        Reviewed by Myles Maxfield.
+
+        * TestExpectations:
+        * webgpu/whlsl-buffer-length-expected.txt: Added.
+        * webgpu/whlsl-buffer-length.html: Added.
+        * webgpu/whlsl-buffer-vertex.html:
+        * webgpu/whlsl-compute.html:
+        * webgpu/whlsl-null-dereference.html:
+        * webgpu/whlsl-oob-access.html:
+
 2019-06-17  Shawn Roberts  <[email protected]>
 
         scrollingcoordinator/ios/sync-layer-positions-after-scroll.html is a flaky failure on iOS Simulator

Modified: trunk/LayoutTests/TestExpectations (246514 => 246515)


--- trunk/LayoutTests/TestExpectations	2019-06-17 20:40:08 UTC (rev 246514)
+++ trunk/LayoutTests/TestExpectations	2019-06-17 21:44:23 UTC (rev 246515)
@@ -3413,6 +3413,3 @@
 
 # iOS only
 fast/dom/linkify-phone-numbers.html [ ImageOnlyFailure ]
-
-# FIXME: Should be fixed by: https://bugs.webkit.org/show_bug.cgi?id=198890
-webgpu/whlsl-oob-access.html [ Pass Failure ]

Added: trunk/LayoutTests/webgpu/whlsl-buffer-length-expected.txt (0 => 246515)


--- trunk/LayoutTests/webgpu/whlsl-buffer-length-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/webgpu/whlsl-buffer-length-expected.txt	2019-06-17 21:44:23 UTC (rev 246515)
@@ -0,0 +1,5 @@
+PASS successfullyParsed is true
+
+TEST COMPLETE
+PASS resultUint32Array[0] is 1337
+

Added: trunk/LayoutTests/webgpu/whlsl-buffer-length.html (0 => 246515)


--- trunk/LayoutTests/webgpu/whlsl-buffer-length.html	                        (rev 0)
+++ trunk/LayoutTests/webgpu/whlsl-buffer-length.html	2019-06-17 21:44:23 UTC (rev 246515)
@@ -0,0 +1,76 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+</head>
+<body>
+<script>
+const shaderSource = `
+[numthreads(1, 1, 1)]
+compute void computeShader(device uint[] buffer : register(u0), float3 threadID : SV_DispatchThreadID) {
+    buffer[0] = buffer.length;
+}
+`;
+let resultUint32Array;
+async function start() {
+    const adapter = await navigator.gpu.requestAdapter();
+    const device = await adapter.requestDevice();
+
+    const shaderModule = device.createShaderModule({code: shaderSource, isWHLSL: true});
+    const computeStage = {module: shaderModule, entryPoint: "computeShader"};
+
+    const bindGroupLayoutDescriptor = {bindings: [{binding: 0, visibility: 7, type: "storage-buffer"}]};
+    const bindGroupLayout = device.createBindGroupLayout(bindGroupLayoutDescriptor);
+    const pipelineLayoutDescriptor = {bindGroupLayouts: [bindGroupLayout]};
+    const pipelineLayout = device.createPipelineLayout(pipelineLayoutDescriptor);
+
+    const computePipelineDescriptor = {computeStage, layout: pipelineLayout};
+    const computePipeline = device.createComputePipeline(computePipelineDescriptor);
+
+    const size = Uint32Array.BYTES_PER_ELEMENT * 1337;
+
+    const bufferDescriptor = {size, usage: GPUBufferUsage.MAP_WRITE | GPUBufferUsage.TRANSFER_SRC};
+    const buffer = device.createBuffer(bufferDescriptor);
+    const bufferArrayBuffer = await buffer.mapWriteAsync();
+    const bufferUint32Array = new Uint32Array(bufferArrayBuffer);
+    bufferUint32Array[0] = 0;
+    buffer.unmap();
+
+    const resultsBufferDescriptor = {size, usage: GPUBufferUsage.STORAGE | GPUBufferUsage.TRANSFER_DST | GPUBufferUsage.MAP_READ};
+    const resultsBuffer = device.createBuffer(resultsBufferDescriptor);
+
+    const bufferBinding = {buffer: resultsBuffer, size};
+    const bindGroupBinding = {binding: 0, resource: bufferBinding};
+    const bindGroupDescriptor = {layout: bindGroupLayout, bindings: [bindGroupBinding]};
+    const bindGroup = device.createBindGroup(bindGroupDescriptor);
+
+    const commandEncoder = device.createCommandEncoder(); // {}
+    commandEncoder.copyBufferToBuffer(buffer, 0, resultsBuffer, 0, 1 * Uint32Array.BYTES_PER_ELEMENT);
+    const computePassEncoder = commandEncoder.beginComputePass();
+    computePassEncoder.setPipeline(computePipeline);
+    computePassEncoder.setBindGroup(0, bindGroup);
+    computePassEncoder.dispatch(1, 1, 1);
+    computePassEncoder.endPass();
+    const commandBuffer = commandEncoder.finish();
+    device.getQueue().submit([commandBuffer]);
+
+    const resultsArrayBuffer = await resultsBuffer.mapReadAsync();
+    resultUint32Array = new Uint32Array(resultsArrayBuffer);
+    shouldBe("resultUint32Array[0]", "1337");
+    resultsBuffer.unmap();
+}
+if (window.testRunner)
+    testRunner.waitUntilDone();
+window.addEventListener("load", function() {
+    start().then(function() {
+        if (window.testRunner)
+            testRunner.notifyDone();
+    }, function() {
+        if (window.testRunner)
+            testRunner.notifyDone();
+    });
+});
+</script>
+<script src=""
+</body>
+</html>

Modified: trunk/LayoutTests/webgpu/whlsl-buffer-vertex.html (246514 => 246515)


--- trunk/LayoutTests/webgpu/whlsl-buffer-vertex.html	2019-06-17 20:40:08 UTC (rev 246514)
+++ trunk/LayoutTests/webgpu/whlsl-buffer-vertex.html	2019-06-17 21:44:23 UTC (rev 246515)
@@ -38,7 +38,9 @@
     const renderPipelineDescriptor = {vertexStage, fragmentStage, primitiveTopology, rasterizationState, colorStates, depthStencilState, vertexInput, sampleCount: 1, layout: pipelineLayout};
     const renderPipeline = device.createRenderPipeline(renderPipelineDescriptor);
 
-    const resourceBufferDescriptor = {size: 4 * 4 * Float32Array.BYTES_PER_ELEMENT, usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.MAP_WRITE};
+    const size = 4 * 4 * Float32Array.BYTES_PER_ELEMENT;
+
+    const resourceBufferDescriptor = {size, usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.MAP_WRITE};
     const resourceBuffer = device.createBuffer(resourceBufferDescriptor);
     const resourceBufferArrayBuffer = await resourceBuffer.mapWriteAsync();
     const resourceBufferFloat32Array = new Float32Array(resourceBufferArrayBuffer);
@@ -60,7 +62,7 @@
     resourceBufferFloat32Array[15] = 1;
     resourceBuffer.unmap();
 
-    const bufferBinding = {buffer: resourceBuffer, size: 4};
+    const bufferBinding = {buffer: resourceBuffer, size};
     const bindGroupBinding = {binding: 0, resource: bufferBinding};
     const bindGroupDescriptor = {layout: bindGroupLayout, bindings: [bindGroupBinding]};
     const bindGroup = device.createBindGroup(bindGroupDescriptor);

Modified: trunk/LayoutTests/webgpu/whlsl-compute.html (246514 => 246515)


--- trunk/LayoutTests/webgpu/whlsl-compute.html	2019-06-17 20:40:08 UTC (rev 246514)
+++ trunk/LayoutTests/webgpu/whlsl-compute.html	2019-06-17 21:44:23 UTC (rev 246515)
@@ -27,7 +27,9 @@
     const computePipelineDescriptor = {computeStage, layout: pipelineLayout};
     const computePipeline = device.createComputePipeline(computePipelineDescriptor);
 
-    const bufferDescriptor = {size: Float32Array.BYTES_PER_ELEMENT * 8, usage: GPUBufferUsage.MAP_WRITE | GPUBufferUsage.TRANSFER_SRC};
+    const size = Float32Array.BYTES_PER_ELEMENT * 8;
+
+    const bufferDescriptor = {size, usage: GPUBufferUsage.MAP_WRITE | GPUBufferUsage.TRANSFER_SRC};
     const buffer = device.createBuffer(bufferDescriptor);
     const bufferArrayBuffer = await buffer.mapWriteAsync();
     const bufferFloat32Array = new Float32Array(bufferArrayBuffer);
@@ -41,16 +43,16 @@
     bufferFloat32Array[7] = 8;
     buffer.unmap();
 
-    const resultsBufferDescriptor = {size: Float32Array.BYTES_PER_ELEMENT * 8, usage: GPUBufferUsage.STORAGE | GPUBufferUsage.TRANSFER_DST | GPUBufferUsage.MAP_READ};
+    const resultsBufferDescriptor = {size, usage: GPUBufferUsage.STORAGE | GPUBufferUsage.TRANSFER_DST | GPUBufferUsage.MAP_READ};
     const resultsBuffer = device.createBuffer(resultsBufferDescriptor);
 
-    const bufferBinding = {buffer: resultsBuffer, size: 4};
+    const bufferBinding = {buffer: resultsBuffer, size};
     const bindGroupBinding = {binding: 0, resource: bufferBinding};
     const bindGroupDescriptor = {layout: bindGroupLayout, bindings: [bindGroupBinding]};
     const bindGroup = device.createBindGroup(bindGroupDescriptor);
 
     const commandEncoder = device.createCommandEncoder(); // {}
-    commandEncoder.copyBufferToBuffer(buffer, 0, resultsBuffer, 0, Float32Array.BYTES_PER_ELEMENT * 8);
+    commandEncoder.copyBufferToBuffer(buffer, 0, resultsBuffer, 0, size);
     const computePassEncoder = commandEncoder.beginComputePass();
     computePassEncoder.setPipeline(computePipeline);
     computePassEncoder.setBindGroup(0, bindGroup);

Modified: trunk/LayoutTests/webgpu/whlsl-null-dereference.html (246514 => 246515)


--- trunk/LayoutTests/webgpu/whlsl-null-dereference.html	2019-06-17 20:40:08 UTC (rev 246514)
+++ trunk/LayoutTests/webgpu/whlsl-null-dereference.html	2019-06-17 21:44:23 UTC (rev 246515)
@@ -63,7 +63,9 @@
     const computePipelineDescriptor = {computeStage, layout: pipelineLayout};
     const computePipeline = device.createComputePipeline(computePipelineDescriptor);
 
-    const bufferDescriptor = {size: Float32Array.BYTES_PER_ELEMENT * 8, usage: GPUBufferUsage.MAP_WRITE | GPUBufferUsage.TRANSFER_SRC};
+    const size = Float32Array.BYTES_PER_ELEMENT * 8;
+
+    const bufferDescriptor = {size, usage: GPUBufferUsage.MAP_WRITE | GPUBufferUsage.TRANSFER_SRC};
     const buffer = device.createBuffer(bufferDescriptor);
     const bufferArrayBuffer = await buffer.mapWriteAsync();
     const bufferFloat32Array = new Float32Array(bufferArrayBuffer);
@@ -77,16 +79,16 @@
     bufferFloat32Array[7] = 8;
     buffer.unmap();
 
-    const resultsBufferDescriptor = {size: Float32Array.BYTES_PER_ELEMENT * 8, usage: GPUBufferUsage.STORAGE | GPUBufferUsage.TRANSFER_DST | GPUBufferUsage.MAP_READ};
+    const resultsBufferDescriptor = {size, usage: GPUBufferUsage.STORAGE | GPUBufferUsage.TRANSFER_DST | GPUBufferUsage.MAP_READ};
     const resultsBuffer = device.createBuffer(resultsBufferDescriptor);
 
-    const bufferBinding = {buffer: resultsBuffer, size: 4};
+    const bufferBinding = {buffer: resultsBuffer, size};
     const bindGroupBinding = {binding: 0, resource: bufferBinding};
     const bindGroupDescriptor = {layout: bindGroupLayout, bindings: [bindGroupBinding]};
     const bindGroup = device.createBindGroup(bindGroupDescriptor);
 
     const commandEncoder = device.createCommandEncoder(); // {}
-    commandEncoder.copyBufferToBuffer(buffer, 0, resultsBuffer, 0, Float32Array.BYTES_PER_ELEMENT * 8);
+    commandEncoder.copyBufferToBuffer(buffer, 0, resultsBuffer, 0, size);
     const computePassEncoder = commandEncoder.beginComputePass();
     computePassEncoder.setPipeline(computePipeline);
     computePassEncoder.setBindGroup(0, bindGroup);

Modified: trunk/LayoutTests/webgpu/whlsl-oob-access.html (246514 => 246515)


--- trunk/LayoutTests/webgpu/whlsl-oob-access.html	2019-06-17 20:40:08 UTC (rev 246514)
+++ trunk/LayoutTests/webgpu/whlsl-oob-access.html	2019-06-17 21:44:23 UTC (rev 246515)
@@ -30,7 +30,9 @@
     const computePipelineDescriptor = {computeStage, layout: pipelineLayout};
     const computePipeline = device.createComputePipeline(computePipelineDescriptor);
 
-    const bufferDescriptor = {size: Float32Array.BYTES_PER_ELEMENT * 8, usage: GPUBufferUsage.MAP_WRITE | GPUBufferUsage.TRANSFER_SRC};
+    const size = Float32Array.BYTES_PER_ELEMENT * 8;
+
+    const bufferDescriptor = {size, usage: GPUBufferUsage.MAP_WRITE | GPUBufferUsage.TRANSFER_SRC};
     const buffer = device.createBuffer(bufferDescriptor);
     const bufferArrayBuffer = await buffer.mapWriteAsync();
     const bufferFloat32Array = new Float32Array(bufferArrayBuffer);
@@ -44,16 +46,16 @@
     bufferFloat32Array[7] = 8;
     buffer.unmap();
 
-    const resultsBufferDescriptor = {size: Float32Array.BYTES_PER_ELEMENT * 8, usage: GPUBufferUsage.STORAGE | GPUBufferUsage.TRANSFER_DST | GPUBufferUsage.MAP_READ};
+    const resultsBufferDescriptor = {size, usage: GPUBufferUsage.STORAGE | GPUBufferUsage.TRANSFER_DST | GPUBufferUsage.MAP_READ};
     const resultsBuffer = device.createBuffer(resultsBufferDescriptor);
 
-    const bufferBinding = {buffer: resultsBuffer, size: 4};
+    const bufferBinding = {buffer: resultsBuffer, size};
     const bindGroupBinding = {binding: 0, resource: bufferBinding};
     const bindGroupDescriptor = {layout: bindGroupLayout, bindings: [bindGroupBinding]};
     const bindGroup = device.createBindGroup(bindGroupDescriptor);
 
     const commandEncoder = device.createCommandEncoder(); // {}
-    commandEncoder.copyBufferToBuffer(buffer, 0, resultsBuffer, 0, Float32Array.BYTES_PER_ELEMENT * 8);
+    commandEncoder.copyBufferToBuffer(buffer, 0, resultsBuffer, 0, size);
     const computePassEncoder = commandEncoder.beginComputePass();
     computePassEncoder.setPipeline(computePipeline);
     computePassEncoder.setBindGroup(0, bindGroup);

Modified: trunk/Source/WebCore/ChangeLog (246514 => 246515)


--- trunk/Source/WebCore/ChangeLog	2019-06-17 20:40:08 UTC (rev 246514)
+++ trunk/Source/WebCore/ChangeLog	2019-06-17 21:44:23 UTC (rev 246515)
@@ -1,3 +1,41 @@
+2019-06-17  Saam Barati  <[email protected]>
+
+        [WHLSL] Make .length work
+        https://bugs.webkit.org/show_bug.cgi?id=198890
+
+        Reviewed by Myles Maxfield.
+
+        This patch makes accessing .length on buffers work. To make this work as
+        expected, I've fixed a handful of small bugs:
+        
+        - The checker was not calling resolveByInstantiation for getters. This patch
+          modifies the checker to do that, so we can now resolve a getter to
+          "operator.length". I also refactored the checker to have a helper method
+          that both does overload resolution and resolveByInstantiation to make it
+          difficult to forget to call resolveByInstantiation.
+        - The property resolver had a bug where it would return a non-null value
+          in anderCallArgument for array references even when there was no ander and
+          no thread ander function. This patch makes it now return null if there is
+          neither an ander nor a thread ander.
+        - The metal codegen incorrectly unpacked the length of buffers. It swapped the
+          bottom four bytes and the top four bytes of the size_t value. This patch
+          corrects that. This was also a cause of flakiness in various tests since
+          we ended up with a length much larger than expected, leading to bounds
+          checks always passing in our tests.
+        - This patch also fixes our tests to specify the output buffer length
+          properly for various programs.
+
+        Test: webgpu/whlsl-buffer-length.html
+
+        * Modules/webgpu/WHLSL/Metal/WHLSLEntryPointScaffolding.cpp:
+        (WebCore::WHLSL::Metal::EntryPointScaffolding::unpackResourcesAndNamedBuiltIns):
+        * Modules/webgpu/WHLSL/WHLSLChecker.cpp:
+        (WebCore::WHLSL::resolveFunction):
+        (WebCore::WHLSL::Checker::finishVisiting):
+        (WebCore::WHLSL::Checker::visit):
+        * Modules/webgpu/WHLSL/WHLSLPropertyResolver.cpp:
+        (WebCore::WHLSL::anderCallArgument):
+
 2019-06-17  Ryan Haddad  <[email protected]>
 
         Unreviewed, rolling out r246501.

Modified: trunk/Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLEntryPointScaffolding.cpp (246514 => 246515)


--- trunk/Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLEntryPointScaffolding.cpp	2019-06-17 20:40:08 UTC (rev 246514)
+++ trunk/Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLEntryPointScaffolding.cpp	2019-06-17 21:44:23 UTC (rev 246515)
@@ -315,9 +315,9 @@
                 auto& unnamedType = *m_entryPointItems.inputs[iterator->value].unnamedType;
                 auto mangledTypeName = m_typeNamer.mangledNameForType(downcast<AST::ReferenceType>(unnamedType).elementType());
 
-                stringBuilder.append(makeString("size_t ", lengthTemporaryName, " = ", variableName, '.', lengthElementName, ".x;\n"));
+                stringBuilder.append(makeString("size_t ", lengthTemporaryName, " = ", variableName, '.', lengthElementName, ".y;\n"));
                 stringBuilder.append(makeString(lengthTemporaryName, " = ", lengthTemporaryName, " << 32;\n"));
-                stringBuilder.append(makeString(lengthTemporaryName, " = ", lengthTemporaryName, " | ", variableName, '.', lengthElementName, ".y;\n"));
+                stringBuilder.append(makeString(lengthTemporaryName, " = ", lengthTemporaryName, " | ", variableName, '.', lengthElementName, ".x;\n"));
                 stringBuilder.append(makeString(lengthTemporaryName, " = ", lengthTemporaryName, " / sizeof(", mangledTypeName, ");\n"));
                 stringBuilder.append(makeString("if (", lengthTemporaryName, " > 0xFFFFFFFF) ", lengthTemporaryName, " = 0xFFFFFFFF;\n"));
                 stringBuilder.append(makeString(mangledInputPath(path), " = { ", variableName, '.', elementName, ", static_cast<uint32_t>(", lengthTemporaryName, ") };\n"));

Modified: trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLChecker.cpp (246514 => 246515)


--- trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLChecker.cpp	2019-06-17 20:40:08 UTC (rev 246514)
+++ trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLChecker.cpp	2019-06-17 21:44:23 UTC (rev 246515)
@@ -215,6 +215,19 @@
     return WTF::nullopt;
 }
 
+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)
+{
+    if (AST::FunctionDeclaration* function = resolveFunctionOverload(possibleOverloads, types, castReturnType))
+        return function;
+
+    if (auto newFunction = resolveByInstantiation(name, origin, types, intrinsics)) {
+        program.append(WTFMove(*newFunction));
+        return &program.nativeFunctionDeclarations().last();
+    }
+
+    return nullptr;
+}
+
 static bool checkSemantics(Vector<EntryPointItem>& inputItems, Vector<EntryPointItem>& outputItems, const Optional<AST::EntryPointType>& entryPointType, const Intrinsics& intrinsics)
 {
     {
@@ -1004,7 +1017,7 @@
         Vector<std::reference_wrapper<ResolvingType>> getterArgumentTypes { baseInfo->resolvingType };
         if (additionalArgumentType)
             getterArgumentTypes.append(*additionalArgumentType);
-        if ((getterFunction = resolveFunctionOverload(propertyAccessExpression.possibleGetterOverloads(), getterArgumentTypes)))
+        if ((getterFunction = resolveFunction(m_program, propertyAccessExpression.possibleGetterOverloads(), getterArgumentTypes, propertyAccessExpression.getterFunctionName(), propertyAccessExpression.origin(), m_intrinsics)))
             getterReturnType = &getterFunction->type();
     }
 
@@ -1017,13 +1030,8 @@
             Vector<std::reference_wrapper<ResolvingType>> anderArgumentTypes { argumentType };
             if (additionalArgumentType)
                 anderArgumentTypes.append(*additionalArgumentType);
-            if ((anderFunction = resolveFunctionOverload(propertyAccessExpression.possibleAnderOverloads(), anderArgumentTypes)))
+            if ((anderFunction = resolveFunction(m_program, propertyAccessExpression.possibleAnderOverloads(), anderArgumentTypes, propertyAccessExpression.anderFunctionName(), propertyAccessExpression.origin(), m_intrinsics)))
                 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
-            else if (auto newFunction = resolveByInstantiation(propertyAccessExpression.anderFunctionName(), propertyAccessExpression.origin(), anderArgumentTypes, m_intrinsics)) {
-                m_program.append(WTFMove(*newFunction));
-                anderFunction = &m_program.nativeFunctionDeclarations().last();
-                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
-            }
         }
     }
 
@@ -1034,13 +1042,8 @@
         Vector<std::reference_wrapper<ResolvingType>> threadAnderArgumentTypes { argumentType };
         if (additionalArgumentType)
             threadAnderArgumentTypes.append(*additionalArgumentType);
-        if ((threadAnderFunction = resolveFunctionOverload(propertyAccessExpression.possibleAnderOverloads(), threadAnderArgumentTypes)))
+        if ((threadAnderFunction = resolveFunction(m_program, propertyAccessExpression.possibleAnderOverloads(), threadAnderArgumentTypes, propertyAccessExpression.anderFunctionName(), propertyAccessExpression.origin(), m_intrinsics)))
             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
-        else if (auto newFunction = resolveByInstantiation(propertyAccessExpression.anderFunctionName(), propertyAccessExpression.origin(), threadAnderArgumentTypes, m_intrinsics)) {
-            m_program.append(WTFMove(*newFunction));
-            threadAnderFunction = &m_program.nativeFunctionDeclarations().last();
-            threadAnderReturnType = &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
-        }
     }
 
     if (leftAddressSpace && !anderFunction && !getterFunction) {
@@ -1083,7 +1086,7 @@
         if (additionalArgumentType)
             setterArgumentTypes.append(*additionalArgumentType);
         setterArgumentTypes.append(fieldResolvingType);
-        setterFunction = resolveFunctionOverload(propertyAccessExpression.possibleSetterOverloads(), setterArgumentTypes);
+        setterFunction = resolveFunction(m_program, propertyAccessExpression.possibleSetterOverloads(), setterArgumentTypes, propertyAccessExpression.setterFunctionName(), propertyAccessExpression.origin(), m_intrinsics);
         if (setterFunction)
             setterReturnType = &setterFunction->type();
     }
@@ -1468,15 +1471,8 @@
     // We don't want to recurse to the same node twice.
 
     ASSERT(callExpression.hasOverloads());
-    auto* function = resolveFunctionOverload(*callExpression.overloads(), types, callExpression.castReturnType());
+    auto* function = resolveFunction(m_program, *callExpression.overloads(), types, callExpression.name(), callExpression.origin(), m_intrinsics, callExpression.castReturnType());
     if (!function) {
-        if (auto newFunction = resolveByInstantiation(callExpression.name(), callExpression.origin(), types, m_intrinsics)) {
-            m_program.append(WTFMove(*newFunction));
-            function = &m_program.nativeFunctionDeclarations().last();
-        }
-    }
-
-    if (!function) {
         setError();
         return;
     }

Modified: trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLPropertyResolver.cpp (246514 => 246515)


--- trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLPropertyResolver.cpp	2019-06-17 20:40:08 UTC (rev 246514)
+++ trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLPropertyResolver.cpp	2019-06-17 21:44:23 UTC (rev 246515)
@@ -142,6 +142,8 @@
 
 static Optional<AnderCallArgumentResult> anderCallArgument(UniqueRef<AST::_expression_>& _expression_, bool anderFunction, bool threadAnderFunction)
 {
+    if (!anderFunction && !threadAnderFunction)
+        return WTF::nullopt;
     auto& unifyNode = _expression_->resolvedType().unifyNode();
     if (is<AST::UnnamedType>(unifyNode)) {
         auto& unnamedType = downcast<AST::UnnamedType>(unifyNode);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to