Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(380)

Issue 2828643002: Make customElements.define faster

Created:
3 years, 8 months ago by dominicc (has gone to gerrit)
Modified:
3 years, 7 months ago
CC:
blink-reviews, blink-reviews-bindings_chromium.org, blink-reviews-dom_chromium.org, chromium-reviews, dglazkov+blink, dominicc+watchlist_chromium.org, eae+blinkwatch, rwlbuis, sof, webcomponents-bugzilla_chromium.org
Target Ref:
refs/heads/master
Project:
chromium
Visibility:
Public.

Description

This cuts the overhead of customElements.define by roughly half, by: - Keeping custom element callbacks alive with wrapper tracing, not maps. Reading and writing maps is apparently slow. - Looking up the definition for a constructor with constructor, private symbol, array index; instead of private symbol to retrieve a map, map lookup, string marshal, hash lookup. - Retrieving callbacks uses one handle scope instead of creating one per retrieval. - Constructing a definition moves the observed attributes hash to the definition instead of copying it. This does not change behavior. BUG=710184

Patch Set 1 #

Patch Set 2 : Try to make Android builder happy. #

Total comments: 5

Patch Set 3 : Bring patch to head, some doc improvements. #

Patch Set 4 : Better comments. #

Patch Set 5 : Bring patch to head plus more optimizations. #

Patch Set 6 : Revert layout test change. #

Patch Set 7 : Remove some unneeded casts. #

Total comments: 8
Unified diffs Side-by-side diffs Delta from patch set Stats (+229 lines, -223 lines) Patch
M third_party/WebKit/Source/bindings/core/v8/ScriptCustomElementDefinition.h View 1 2 3 4 4 chunks +11 lines, -8 lines 0 comments Download
M third_party/WebKit/Source/bindings/core/v8/ScriptCustomElementDefinition.cpp View 1 2 3 4 5 6 4 chunks +65 lines, -92 lines 1 comment Download
M third_party/WebKit/Source/bindings/core/v8/ScriptCustomElementDefinitionBuilder.h View 1 2 3 4 2 chunks +15 lines, -6 lines 0 comments Download
M third_party/WebKit/Source/bindings/core/v8/ScriptCustomElementDefinitionBuilder.cpp View 1 2 3 4 6 chunks +50 lines, -53 lines 2 comments Download
M third_party/WebKit/Source/bindings/core/v8/TraceWrapperReference.md View 7 chunks +7 lines, -8 lines 0 comments Download
M third_party/WebKit/Source/core/dom/custom/CustomElementDefinition.h View 1 2 3 4 2 chunks +9 lines, -8 lines 1 comment Download
M third_party/WebKit/Source/core/dom/custom/CustomElementDefinition.cpp View 1 2 3 4 1 chunk +2 lines, -2 lines 0 comments Download
M third_party/WebKit/Source/core/dom/custom/CustomElementDefinitionBuilder.h View 2 chunks +3 lines, -2 lines 0 comments Download
M third_party/WebKit/Source/core/dom/custom/CustomElementRegistry.h View 4 chunks +9 lines, -4 lines 2 comments Download
M third_party/WebKit/Source/core/dom/custom/CustomElementRegistry.cpp View 1 2 5 chunks +17 lines, -5 lines 1 comment Download
M third_party/WebKit/Source/core/dom/custom/CustomElementRegistryTest.cpp View 1 2 1 chunk +2 lines, -2 lines 0 comments Download
M third_party/WebKit/Source/core/dom/custom/CustomElementTestHelpers.h View 1 2 3 4 2 chunks +4 lines, -3 lines 0 comments Download
M third_party/WebKit/Source/core/dom/custom/CustomElementTestHelpers.cpp View 1 chunk +2 lines, -1 line 0 comments Download
M third_party/WebKit/Source/core/dom/custom/README.md View 1 2 2 chunks +17 lines, -24 lines 0 comments Download
M third_party/WebKit/Source/platform/bindings/V8PerContextData.h View 1 2 3 4 2 chunks +16 lines, -0 lines 1 comment Download
M third_party/WebKit/Source/platform/bindings/V8PrivateProperty.h View 1 2 3 4 1 chunk +0 lines, -5 lines 0 comments Download

Messages

Total messages: 34 (25 generated)
dominicc (has gone to gerrit)
This is a bit messy WIP but early feedback appreciated. Getting rid of the map ...
3 years, 8 months ago (2017-04-19 08:01:03 UTC) #4
dominicc (has gone to gerrit)
On 2017/04/19 at 08:01:03, dominicc wrote: > This is a bit messy WIP but early ...
3 years, 8 months ago (2017-04-19 08:20:04 UTC) #7
Michael Lippautz
Looked at the tracing-related parts. https://codereview.chromium.org/2828643002/diff/20001/third_party/WebKit/Source/bindings/core/v8/ScriptCustomElementDefinition.cpp File third_party/WebKit/Source/bindings/core/v8/ScriptCustomElementDefinition.cpp (right): https://codereview.chromium.org/2828643002/diff/20001/third_party/WebKit/Source/bindings/core/v8/ScriptCustomElementDefinition.cpp#newcode158 third_party/WebKit/Source/bindings/core/v8/ScriptCustomElementDefinition.cpp:158: visitor->TraceWrappers(connected_callback_); Continued from the ...
3 years, 8 months ago (2017-04-19 08:49:12 UTC) #10
haraken
Using the wrapper tracing looks nice, but would you help me understand why this CL ...
3 years, 8 months ago (2017-04-19 09:20:57 UTC) #11
dominicc (has gone to gerrit)
On 2017/04/19 at 09:20:57, haraken wrote: > Using the wrapper tracing looks nice, but would ...
3 years, 8 months ago (2017-04-20 01:01:19 UTC) #14
dominicc (has gone to gerrit)
On 2017/04/19 at 08:49:12, mlippautz wrote: > Looked at the tracing-related parts. > > https://codereview.chromium.org/2828643002/diff/20001/third_party/WebKit/Source/bindings/core/v8/ScriptCustomElementDefinition.cpp ...
3 years, 8 months ago (2017-04-20 01:05:38 UTC) #15
dominicc (has gone to gerrit)
PTAL kochi: core/dom/custom haraken, mlippautz: Wrapper tracing blink-reviews-bindings: Bindings
3 years, 7 months ago (2017-04-28 04:35:35 UTC) #30
kochi
https://codereview.chromium.org/2828643002/diff/120001/third_party/WebKit/Source/core/dom/custom/CustomElementRegistry.cpp File third_party/WebKit/Source/core/dom/custom/CustomElementRegistry.cpp (right): https://codereview.chromium.org/2828643002/diff/120001/third_party/WebKit/Source/core/dom/custom/CustomElementRegistry.cpp#newcode266 third_party/WebKit/Source/core/dom/custom/CustomElementRegistry.cpp:266: CustomElementDefinition::Id id) const { Add DCHECK(id <= difinitions_.size())? https://codereview.chromium.org/2828643002/diff/120001/third_party/WebKit/Source/core/dom/custom/CustomElementRegistry.h ...
3 years, 7 months ago (2017-04-28 06:24:16 UTC) #31
haraken
3 years, 7 months ago (2017-04-28 08:49:30 UTC) #34
It looks like this CL is making a lot of changes in one go. Maybe can we split
the CL into a couple of pieces?

https://codereview.chromium.org/2828643002/diff/120001/third_party/WebKit/Sou...
File
third_party/WebKit/Source/bindings/core/v8/ScriptCustomElementDefinition.cpp
(right):

https://codereview.chromium.org/2828643002/diff/120001/third_party/WebKit/Sou...
third_party/WebKit/Source/bindings/core/v8/ScriptCustomElementDefinition.cpp:134:
visitor->TraceWrappers(constructor_.Cast<v8::Value>());

Won't visitor->TraceWrappers(constructor_) work?

https://codereview.chromium.org/2828643002/diff/120001/third_party/WebKit/Sou...
File
third_party/WebKit/Source/bindings/core/v8/ScriptCustomElementDefinitionBuilder.cpp
(right):

https://codereview.chromium.org/2828643002/diff/120001/third_party/WebKit/Sou...
third_party/WebKit/Source/bindings/core/v8/ScriptCustomElementDefinitionBuilder.cpp:70:
return script_state_->ContextIsValid();

What is this change for?

https://codereview.chromium.org/2828643002/diff/120001/third_party/WebKit/Sou...
third_party/WebKit/Source/bindings/core/v8/ScriptCustomElementDefinitionBuilder.cpp:76:
v8::TryCatch try_catch(isolate);

Are you intentionally moving the TryCatch scope to the caller sites?

https://codereview.chromium.org/2828643002/diff/120001/third_party/WebKit/Sou...
File third_party/WebKit/Source/core/dom/custom/CustomElementDefinition.h
(right):

https://codereview.chromium.org/2828643002/diff/120001/third_party/WebKit/Sou...
third_party/WebKit/Source/core/dom/custom/CustomElementDefinition.h:9: #include
"bindings/core/v8/ScriptWrappable.h"  // For TraceWrapperBase

We normally don't add this kind of comment.

https://codereview.chromium.org/2828643002/diff/120001/third_party/WebKit/Sou...
File third_party/WebKit/Source/platform/bindings/V8PerContextData.h (right):

https://codereview.chromium.org/2828643002/diff/120001/third_party/WebKit/Sou...
third_party/WebKit/Source/platform/bindings/V8PerContextData.h:152: // to its
definition.

Can we use V8PrivateProperty instead?

Powered by Google App Engine
This is Rietveld 408576698