[webkit-changes] [WebKit/WebKit] 3bb064: [WGSL] Add validation to integer division during c...
Tadeu Zagallo
noreply at github.com
Fri Nov 3 07:31:51 PDT 2023
Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 3bb0644a3e365f3db62b6a8781078b4b53d27a96
https://github.com/WebKit/WebKit/commit/3bb0644a3e365f3db62b6a8781078b4b53d27a96
Author: Tadeu Zagallo <tzagallo at apple.com>
Date: 2023-11-03 (Fri, 03 Nov 2023)
Changed paths:
M Source/WebGPU/WGSL/GlobalVariableRewriter.cpp
M Source/WebGPU/WGSL/Metal/MetalCodeGenerator.cpp
M Source/WebGPU/WGSL/Metal/MetalFunctionWriter.cpp
M Source/WebGPU/WGSL/TypeCheck.cpp
M Source/WebGPU/WGSL/WGSLShaderModule.h
M Source/WebGPU/WGSL/tests/lit.cfg
A Source/WebGPU/WGSL/tests/valid/division.wgsl
M Tools/TestWebKitAPI/Tests/WGSL/MetalGenerationTests.cpp
Log Message:
-----------
[WGSL] Add validation to integer division during code generation
https://bugs.webkit.org/show_bug.cgi?id=264106
rdar://117865769
Reviewed by Mike Wyrzykowski.
According to the spec, the runtime behavior for integer division needs to handle
the following two corner cases:
- x / 0 = x
- INT_MIN / -1 = INT_MIN
The latter matches the default Metal behavior, but considering it's technically
undefined behavior, it seems safer to handle it explicitly.
* Source/WebGPU/WGSL/GlobalVariableRewriter.cpp:
(WGSL::RewriteGlobalVariables::getPacking):
* Source/WebGPU/WGSL/Metal/MetalCodeGenerator.cpp:
(WGSL::Metal::metalCodePrologue):
* Source/WebGPU/WGSL/Metal/MetalFunctionWriter.cpp:
(WGSL::Metal::FunctionDefinitionWriter::emitNecessaryHelpers):
(WGSL::Metal::FunctionDefinitionWriter::visit):
* Source/WebGPU/WGSL/TypeCheck.cpp:
(WGSL::TypeChecker::visit):
* Source/WebGPU/WGSL/WGSLShaderModule.h:
(WGSL::ShaderModule::usesDivision const):
(WGSL::ShaderModule::setUsesDivision):
(WGSL::ShaderModule::clearUsesDivision):
* Source/WebGPU/WGSL/tests/lit.cfg:
* Source/WebGPU/WGSL/tests/valid/division.wgsl: Added.
Canonical link: https://commits.webkit.org/270174@main
More information about the webkit-changes
mailing list