[webkit-changes] [WebKit/WebKit] e8c125: [WGSL] Constant values might not match type

Tadeu Zagallo noreply at github.com
Wed May 31 03:31:14 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: e8c12535c74ae70cd22109daed317e6fe4df2f73
      https://github.com/WebKit/WebKit/commit/e8c12535c74ae70cd22109daed317e6fe4df2f73
  Author: Tadeu Zagallo <tzagallo at apple.com>
  Date:   2023-05-31 (Wed, 31 May 2023)

  Changed paths:
    M Source/WebGPU/WGSL/ConstantFunctions.h
    M Source/WebGPU/WGSL/ConstantRewriter.cpp
    M Source/WebGPU/WGSL/ConstantValue.h
    M Source/WebGPU/WGSL/tests/valid/constants.wgsl

  Log Message:
  -----------
  [WGSL] Constant values might not match type
https://bugs.webkit.org/show_bug.cgi?id=257491
rdar://110007144

Reviewed by Myles C. Maxfield.

Because AbtractInt values can be promoted to floats, the inferred type might
might not match the constant value, since the constant value is derived from
the AST node. In the original implementation, I tried to account for that by
checking the inferred type for the literal node, but that does not cover all
cases. The new test case shows that for calls nested at multiple levels that
can still be an issue. Instead we add new helper functions to ConstantValue
that allow promoting an AbstractInt to double, to match the behavior of the
type system.

* Source/WebGPU/WGSL/ConstantFunctions.h:
(WGSL::constantPow):
* Source/WebGPU/WGSL/ConstantRewriter.cpp:
(WGSL::ConstantRewriter::evaluate):
* Source/WebGPU/WGSL/ConstantValue.h:
(WGSL::ConstantValue::isNumber const):
(WGSL::ConstantValue::toDouble const):
* Source/WebGPU/WGSL/tests/valid/constants.wgsl:

Canonical link: https://commits.webkit.org/264726@main




More information about the webkit-changes mailing list