⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 245973 in webkit


Ignore:
Timestamp:
May 31, 2019, 11:16:45 AM (7 years ago)
Author:
sbarati@apple.com
Message:

[WHLSL] Make sure we properly emit code for "&*x"
https://bugs.webkit.org/show_bug.cgi?id=198198

Reviewed by Myles C. Maxfield.

Source/WebCore:

I ran into this when trying to test zero-filling code, so let's just fix it.
The issue is that the property resolver ends up emitting code that looks like
"&*x". The semantics of this are such that it should result in just x.
However, we emitted Metal code in such a way where we'd end up with a pointer
to a temporary value. To fix this, DereferenceExpression will emit code that results
in a reference type. Then, MakePointerExpression will correctly return the
pointer backing that reference type.

Because of this, we also no longer need to pattern match the lhs of assignment
expressions since we will now be assigning to a reference type.

Test: webgpu/whlsl-store-to-property-updates-properly.html

  • Modules/webgpu/WHLSL/Metal/WHLSLFunctionWriter.cpp:

(WebCore::WHLSL::Metal::FunctionDefinitionWriter::visit):

LayoutTests:

  • webgpu/whlsl-store-to-property-updates-properly-expected.html: Added.
  • webgpu/whlsl-store-to-property-updates-properly.html: Added.
Location:
trunk
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r245964 r245973  
     12019-05-31  Saam Barati  <sbarati@apple.com>
     2
     3        [WHLSL] Make sure we properly emit code for "&*x"
     4        https://bugs.webkit.org/show_bug.cgi?id=198198
     5
     6        Reviewed by Myles C. Maxfield.
     7
     8        * webgpu/whlsl-store-to-property-updates-properly-expected.html: Added.
     9        * webgpu/whlsl-store-to-property-updates-properly.html: Added.
     10
    1112019-05-31  Ryan Haddad  <ryanhaddad@apple.com>
    212
  • trunk/Source/WebCore/ChangeLog

    r245972 r245973  
     12019-05-31  Saam Barati  <sbarati@apple.com>
     2
     3        [WHLSL] Make sure we properly emit code for "&*x"
     4        https://bugs.webkit.org/show_bug.cgi?id=198198
     5
     6        Reviewed by Myles C. Maxfield.
     7
     8        I ran into this when trying to test zero-filling code, so let's just fix it.
     9        The issue is that the property resolver ends up emitting code that looks like
     10        "&*x". The semantics of this are such that it should result in just x.
     11        However, we emitted Metal code in such a way where we'd end up with a pointer
     12        to a temporary value. To fix this, DereferenceExpression will emit code that results
     13        in a reference type. Then, MakePointerExpression will correctly return the
     14        pointer backing that reference type.
     15       
     16        Because of this, we also no longer need to pattern match the lhs of assignment
     17        expressions since we will now be assigning to a reference type.
     18
     19        Test: webgpu/whlsl-store-to-property-updates-properly.html
     20
     21        * Modules/webgpu/WHLSL/Metal/WHLSLFunctionWriter.cpp:
     22        (WebCore::WHLSL::Metal::FunctionDefinitionWriter::visit):
     23
    1242019-05-31  Geoffrey Garen  <ggaren@apple.com>
    225
  • trunk/Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLFunctionWriter.cpp

    r245945 r245973  
    458458void FunctionDefinitionWriter::visit(AST::AssignmentExpression& assignmentExpression)
    459459{
    460     if (is<AST::DereferenceExpression>(assignmentExpression.left())) {
    461         checkErrorAndVisit(downcast<AST::DereferenceExpression>(assignmentExpression.left()).pointer());
    462         auto leftName = m_stack.takeLast();
    463         checkErrorAndVisit(assignmentExpression.right());
    464         auto rightName = m_stack.takeLast();
    465         m_stringBuilder.append(makeString('*', leftName, " = ", rightName, ";\n"));
    466         m_stack.append(rightName);
    467         return;
    468     }
    469460    checkErrorAndVisit(assignmentExpression.left());
    470461    auto leftName = m_stack.takeLast();
     
    511502    auto right = m_stack.takeLast();
    512503    auto variableName = generateNextVariableName();
    513     m_stringBuilder.append(makeString(m_typeNamer.mangledNameForType(dereferenceExpression.resolvedType()), ' ', variableName, " = *", right, ";\n"));
     504    m_stringBuilder.append(makeString(AST::toString(*dereferenceExpression.typeAnnotation().leftAddressSpace()), ' ', m_typeNamer.mangledNameForType(dereferenceExpression.resolvedType()), "& ", variableName, " = *", right, ";\n"));
    514505    m_stack.append(variableName);
    515506}
Note: See TracChangeset for help on using the changeset viewer.