Changeset 247189 in webkit


Ignore:
Timestamp:
Jul 5, 2019 5:33:01 PM (5 years ago)
Author:
rmorisset@apple.com
Message:

[WHLSL] The checker does not need to keep a separate m_typeAnnotations map
https://bugs.webkit.org/show_bug.cgi?id=199537

Reviewed by Myles C. Maxfield.

Nothing is ever deleted from it, and all of its contents are eventually copied into the expressions.
We might as well put the type annotations directly into the expressions in the first place.
It is about a 5% speedup of the checker.

No new test as there is no inteded functional change.

  • Modules/webgpu/WHLSL/WHLSLChecker.cpp:

(WebCore::WHLSL::Checker::assignTypes):
(WebCore::WHLSL::Checker::getInfo):
(WebCore::WHLSL::Checker::assignType):
(WebCore::WHLSL::Checker::forwardType):
(WebCore::WHLSL::Checker::visit):

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r247187 r247189  
     12019-07-05  Robin Morisset  <rmorisset@apple.com>
     2
     3        [WHLSL] The checker does not need to keep a separate m_typeAnnotations map
     4        https://bugs.webkit.org/show_bug.cgi?id=199537
     5
     6        Reviewed by Myles C. Maxfield.
     7
     8        Nothing is ever deleted from it, and all of its contents are eventually copied into the expressions.
     9        We might as well put the type annotations directly into the expressions in the first place.
     10        It is about a 5% speedup of the checker.
     11
     12        No new test as there is no inteded functional change.
     13
     14        * Modules/webgpu/WHLSL/WHLSLChecker.cpp:
     15        (WebCore::WHLSL::Checker::assignTypes):
     16        (WebCore::WHLSL::Checker::getInfo):
     17        (WebCore::WHLSL::Checker::assignType):
     18        (WebCore::WHLSL::Checker::forwardType):
     19        (WebCore::WHLSL::Checker::visit):
     20
    1212019-07-05  Youenn Fablet  <youenn@apple.com> and Simon Fraser  <simon.fraser@apple.com>
    222
  • trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLChecker.cpp

    r247174 r247189  
    513513
    514514    HashMap<AST::Expression*, std::unique_ptr<ResolvingType>> m_typeMap;
    515     HashMap<AST::Expression*, AST::TypeAnnotation> m_typeAnnotations;
    516515    HashSet<String> m_vertexEntryPoints;
    517516    HashSet<String> m_fragmentEntryPoints;
     
    557556    }
    558557
    559     for (auto& keyValuePair : m_typeAnnotations)
    560         keyValuePair.key->setTypeAnnotation(WTFMove(keyValuePair.value));
    561558    return true;
    562559}
     
    779776    ASSERT(typeIterator != m_typeMap.end());
    780777
    781     auto typeAnnotationIterator = m_typeAnnotations.find(&expression);
    782     ASSERT(typeAnnotationIterator != m_typeAnnotations.end());
    783     if (requiresLeftValue && typeAnnotationIterator->value.isRightValue()) {
     778    const auto& typeAnnotation = expression.typeAnnotation();
     779    if (requiresLeftValue && typeAnnotation.isRightValue()) {
    784780        setError();
    785781        return WTF::nullopt;
    786782    }
    787     return {{ *typeIterator->value, typeAnnotationIterator->value }};
     783    return {{ *typeIterator->value, typeAnnotation }};
    788784}
    789785
     
    809805    auto addResult = m_typeMap.add(&expression, std::make_unique<ResolvingType>(WTFMove(unnamedType)));
    810806    ASSERT_UNUSED(addResult, addResult.isNewEntry);
    811     auto typeAnnotationAddResult = m_typeAnnotations.add(&expression, WTFMove(typeAnnotation));
    812     ASSERT_UNUSED(typeAnnotationAddResult, typeAnnotationAddResult.isNewEntry);
     807    expression.setTypeAnnotation(WTFMove(typeAnnotation));
    813808}
    814809
     
    817812    auto addResult = m_typeMap.add(&expression, std::make_unique<ResolvingType>(WTFMove(resolvableTypeReference)));
    818813    ASSERT_UNUSED(addResult, addResult.isNewEntry);
    819     auto typeAnnotationAddResult = m_typeAnnotations.add(&expression, WTFMove(typeAnnotation));
    820     ASSERT_UNUSED(typeAnnotationAddResult, typeAnnotationAddResult.isNewEntry);
     814    expression.setTypeAnnotation(WTFMove(typeAnnotation));
    821815}
    822816
     
    830824        ASSERT_UNUSED(addResult, addResult.isNewEntry);
    831825    }));
    832     auto typeAnnotationAddResult = m_typeAnnotations.add(&expression, WTFMove(typeAnnotation));
    833     ASSERT_UNUSED(typeAnnotationAddResult, typeAnnotationAddResult.isNewEntry);
     826    expression.setTypeAnnotation(WTFMove(typeAnnotation));
    834827}
    835828
     
    839832    if (!leftInfo)
    840833        return;
    841 
    842     if (leftInfo->typeAnnotation.isRightValue()) {
    843         setError();
    844         return;
    845     }
    846834
    847835    auto rightInfo = recurseAndGetInfo(assignmentExpression.right());
Note: See TracChangeset for help on using the changeset viewer.