Bug 205723 - [WTF] Allow MediaTime static constants
Summary: [WTF] Allow MediaTime static constants
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Template Framework (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Alicia Boya García
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2020-01-03 06:58 PST by Alicia Boya García
Modified: 2022-01-25 14:39 PST (History)
14 users (show)

See Also:


Attachments
Patch (4.22 KB, patch)
2020-01-03 07:02 PST, Alicia Boya García
no flags Details | Formatted Diff | Diff
Patch (6.39 KB, patch)
2020-01-06 10:12 PST, Alicia Boya García
no flags Details | Formatted Diff | Diff
Patch (7.41 KB, patch)
2020-01-07 06:13 PST, Alicia Boya García
no flags Details | Formatted Diff | Diff
Patch (8.00 KB, patch)
2020-01-07 08:00 PST, Alicia Boya García
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Alicia Boya García 2020-01-03 06:58:41 PST
Despite all its convenience methods, at its core MediaTime is a rather
trivial class with only integral members. Despite this, since it had a
destructor declared, this made the class non-trivially destructible
even if the implementation was empty, and therefore clang did not
allow to use it for static variables unless done in form of a pointer.

By removing the destructor this restriction is lifted and we don't
need heap allocations for static MediaTime objects.

Previous usages of heap allocation for static MediaTime objects have
been rewritten to take advantage of this. Test coverage is provided by
successful compilation without [-Werror,-Wexit-time-destructors]
errors and existing tests.
Comment 1 Alicia Boya García 2020-01-03 07:02:37 PST
Created attachment 386680 [details]
Patch
Comment 2 Darin Adler 2020-01-03 19:40:25 PST
Comment on attachment 386680 [details]
Patch

Great change! Looks like getting rid of the destructor helped the compiler notice quite a few unused MediaTime variables so need to fix those too. Also seems like this points to the direction where we could make this class compatible with constexpr so more of it could be evaluated at compile time.
Comment 3 Alicia Boya García 2020-01-06 10:12:22 PST
Created attachment 386859 [details]
Patch
Comment 4 Darin Adler 2020-01-06 13:26:13 PST
Comment on attachment 386859 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=386859&action=review

> Source/WebCore/platform/graphics/cocoa/WebCoreDecompressionSession.mm:478
> +    (void) endTime; // Only used for logs, we need this to avoid "unused variable" errors in Release.

Even better solution:

    #if !LOG_DISABLED
        MediaTime endTime = PAL::toMediaTime(CMBufferQueueGetEndPresentationTimeStamp(m_producerQueue.get()));
    #endif
Comment 5 Alicia Boya García 2020-01-07 06:13:15 PST
Created attachment 386963 [details]
Patch
Comment 6 Alicia Boya García 2020-01-07 08:00:43 PST
Created attachment 386973 [details]
Patch
Comment 7 WebKit Commit Bot 2020-01-08 07:57:10 PST
Comment on attachment 386973 [details]
Patch

Clearing flags on attachment: 386973

Committed r254200: <https://trac.webkit.org/changeset/254200>
Comment 8 WebKit Commit Bot 2020-01-08 07:57:12 PST
All reviewed patches have been landed.  Closing bug.
Comment 9 Radar WebKit Bug Importer 2020-01-08 07:58:14 PST
<rdar://problem/58408671>