Bug 144602 - [Content Extensions] Use less memory when writing byte code to file
Summary: [Content Extensions] Use less memory when writing byte code to file
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore Misc. (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Alex Christensen
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-05-04 15:55 PDT by Alex Christensen
Modified: 2015-05-05 10:14 PDT (History)
0 users

See Also:


Attachments
Patch (12.80 KB, patch)
2015-05-04 15:57 PDT, Alex Christensen
no flags Details | Formatted Diff | Diff
Patch (19.05 KB, patch)
2015-05-04 16:55 PDT, Alex Christensen
darin: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Alex Christensen 2015-05-04 15:55:20 PDT
Right now we keep several copies of all the data in memory at the same time.  We only need one copy of one DFA's byte code alive at a time.
Comment 1 Alex Christensen 2015-05-04 15:57:22 PDT
Created attachment 252343 [details]
Patch
Comment 2 Darin Adler 2015-05-04 16:04:09 PDT
Comment on attachment 252343 [details]
Patch

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

> Source/WebKit2/UIProcess/API/APIUserContentExtensionStore.cpp:77
> +const size_t ContentExtensionFileHeaderSize = sizeof(uint32_t) + 2 * sizeof(uint64_t);

Why do this instead of sizeof(ContentExtensionMetaData)? Because of alignment, I suspect the expression above will be wrong.
Comment 3 Alex Christensen 2015-05-04 16:06:01 PDT
Comment on attachment 252343 [details]
Patch

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

>> Source/WebKit2/UIProcess/API/APIUserContentExtensionStore.cpp:77
>> +const size_t ContentExtensionFileHeaderSize = sizeof(uint32_t) + 2 * sizeof(uint64_t);
> 
> Why do this instead of sizeof(ContentExtensionMetaData)? Because of alignment, I suspect the expression above will be wrong.

When writing the header, we only want to write 20 bytes.  Otherwise we would be writing uninitialized memory to file.
Comment 4 Alex Christensen 2015-05-04 16:55:39 PDT
Created attachment 252355 [details]
Patch
Comment 5 Darin Adler 2015-05-05 09:07:52 PDT
Comment on attachment 252355 [details]
Patch

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

> Source/WebKit2/UIProcess/API/APIUserContentExtensionStore.cpp:84
>  static Data encodeContentExtensionMetaData(const ContentExtensionMetaData& metaData)

I think you want to add this to the end of this function:

    ASSERT(encoder.bufferSize() == ContentExtensionFileHeaderSize);

> Source/WebKit2/UIProcess/API/APIUserContentExtensionStore.cpp:218
> +    memset(invalidHeader, 0xff, sizeof(invalidHeader));

We normally use capitalized hex, 0xFF, in WebKit code.
Comment 6 Alex Christensen 2015-05-05 10:14:43 PDT
http://trac.webkit.org/changeset/183817