Bug 152203 - CachedScript could have a copy-free path for all-ASCII scripts.
Summary: CachedScript could have a copy-free path for all-ASCII scripts.
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore JavaScript (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Andreas Kling
URL:
Keywords: Performance
Depends on:
Blocks:
 
Reported: 2015-12-11 16:52 PST by Andreas Kling
Modified: 2015-12-13 13:31 PST (History)
12 users (show)

See Also:


Attachments
Patch for EWS (31.80 KB, patch)
2015-12-12 13:58 PST, Andreas Kling
no flags Details | Formatted Diff | Diff
Patch (32.46 KB, patch)
2015-12-12 22:17 PST, Andreas Kling
no flags Details | Formatted Diff | Diff
Patch (32.57 KB, patch)
2015-12-13 01:26 PST, Andreas Kling
koivisto: review+
Details | Formatted Diff | Diff
Patch for landing (32.71 KB, patch)
2015-12-13 11:09 PST, Andreas Kling
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Andreas Kling 2015-12-11 16:52:27 PST
If a script resource consists of nothing but ASCII characters, we could have CachedScript::script() return a String that just wraps the internal SharedBuffer's contents instead of dragging the data through TextDecoder.
Comment 1 Andreas Kling 2015-12-12 13:58:02 PST
Created attachment 267242 [details]
Patch for EWS
Comment 2 Andreas Kling 2015-12-12 22:17:50 PST
Created attachment 267254 [details]
Patch
Comment 3 Andreas Kling 2015-12-13 01:26:51 PST
Created attachment 267256 [details]
Patch
Comment 4 Antti Koivisto 2015-12-13 01:45:01 PST
Comment on attachment 267256 [details]
Patch

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

Nice, r=me

> Source/WebCore/loader/cache/CachedScript.h:65
> +    enum ASCIIResourceOptimizationState { Unknown, Optimized, NotOptimized };
> +    ASCIIResourceOptimizationState m_ASCIIOptimizationState { Unknown };

Maybe this could be more explicit about what "Optimized" means? Something along the lines of DataAndDecodedStringHaveSameBytes.
Comment 5 Andreas Kling 2015-12-13 11:09:10 PST
Created attachment 267265 [details]
Patch for landing
Comment 6 WebKit Commit Bot 2015-12-13 12:03:49 PST
Comment on attachment 267265 [details]
Patch for landing

Clearing flags on attachment: 267265

Committed r194017: <http://trac.webkit.org/changeset/194017>
Comment 7 WebKit Commit Bot 2015-12-13 12:03:55 PST
All reviewed patches have been landed.  Closing bug.
Comment 8 Darin Adler 2015-12-13 13:31:17 PST
Comment on attachment 267256 [details]
Patch

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

> Source/WebCore/loader/cache/CachedScript.cpp:74
> +    return encoding == "UTF-8" || encoding == "ISO-8859-1" || encoding == "ASCII";

This seems to be way too conservative. Almost all encodings would answer yes for this. Pretty much everything except for UTF-16 and UTF-32, and I think TextEncoding can answer this question. It's strange to be asking this given just a string rather than TextEncoding.