Bug 158144

Summary: Web Inspector: ReportExtraMemoryCost IDL attribute should also be used to generate estimatedSize method
Product: WebKit Reporter: Joseph Pecoraro <joepeck>
Component: Web InspectorAssignee: Joseph Pecoraro <joepeck>
Status: RESOLVED FIXED    
Severity: Normal CC: bburg, cdumez, cgarcia, commit-queue, esprehn+autocc, ggaren, graouts, joepeck, kondapallykalyan, mark.lam, mattbaker, nvasilyev, timothy, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: All   
OS: All   
Attachments:
Description Flags
[PATCH] Proposed Fix
darin: review+, bburg: commit-queue-
[PATCH] For Landing none

Description Joseph Pecoraro 2016-05-26 20:09:41 PDT
* SUMMARY
ReportExtraMemoryCost IDL attribute should also be used to generate estimatedSize method.

The pattern for including the JSCell estimatedSize() method is "if a cell reports extra memory to the Heap, it should also include that in its estimated size". We were missing this for WebCore objects (of which there are only a few). The existing ReportExtraMemoryCost IDL attribute already handles reporting extra memory to the Heap using wrapper().memoryCost(). The exact same thing can be used in estimatedSize().
Comment 1 Radar WebKit Bug Importer 2016-05-26 20:11:24 PDT
<rdar://problem/26510790>
Comment 2 Joseph Pecoraro 2016-05-26 20:15:41 PDT
Created attachment 279942 [details]
[PATCH] Proposed Fix
Comment 3 Darin Adler 2016-05-28 21:19:04 PDT
Comment on attachment 279942 [details]
[PATCH] Proposed Fix

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

> Source/WebCore/bindings/scripts/CodeGeneratorJS.pm:1049
> +    my $needsEstimatedSize = InstanceNeedsEstimatedSize($interface);

Seems better to just call this the one place it’s used instead of putting it into a local variable.

> Source/WebCore/bindings/scripts/CodeGeneratorJS.pm:2012
> +    my $needsEstimatedSize = InstanceNeedsEstimatedSize($interface);

Seems better to just call this the one place it’s used instead of putting it into a local variable.

> Source/WebCore/bindings/scripts/CodeGeneratorJS.pm:3276
> +        push(@implContent, "    ASSERT_GC_OBJECT_INHERITS(thisObject, info());\n");

It seems peculiar to do this assertion after the jsCast. Doesn’t the JSCast do this check already? If it doesn’t then I’d suggest asserting first.

> Source/WebCore/bindings/scripts/CodeGeneratorJS.pm:3278
> +        push(@implContent, "    size_t extraSize = thisObject->wrapped().memoryCost();\n");
> +        push(@implContent, "    return Base::estimatedSize(thisObject) + extraSize;\n");

This would read better without the local variable, I think.
Comment 4 Joseph Pecoraro 2016-05-31 16:50:34 PDT
Created attachment 280199 [details]
[PATCH] For Landing
Comment 5 WebKit Commit Bot 2016-05-31 17:44:42 PDT
Comment on attachment 280199 [details]
[PATCH] For Landing

Clearing flags on attachment: 280199

Committed r201541: <http://trac.webkit.org/changeset/201541>