|
|
Chromium Code Reviews|
Created:
4 years, 3 months ago by dominicc (has gone to gerrit) Modified:
4 years, 3 months ago CC:
blink-reviews, blink-reviews-bindings_chromium.org, blink-reviews-dom_chromium.org, blink-reviews-html_chromium.org, chromium-reviews, dglazkov+blink, dominicc+watchlist_chromium.org, eae+blinkwatch, kinuko+watch, loading-reviews+parser_chromium.org, rwlbuis, sof, webcomponents-bugzilla_chromium.org Target Ref:
refs/pending/heads/master Project:
chromium Visibility:
Public. |
DescriptionMake custom element name checks faster and fewer
This makes some changes to make things faster, suggested by esprehn
in Issue 631931 and discussion:
- Weakens some CHECKs that custom elements should be created to DCHECKs.
- Specializes 8-bit strings.
- Does a quick reject for names without hyphens.
- Does one fewer name checks in the createElement case.
BUG=631931, 639383
Committed: https://crrev.com/a67c4b53027ee270f17241d7a594ac10aef33790
Cr-Commit-Position: refs/heads/master@{#416959}
Patch Set 1 #Patch Set 2 : Lift the is8Bit check. #
Total comments: 5
Patch Set 3 : Fresh start. No ExceptionState pointers. #
Total comments: 7
Patch Set 4 : Raw chars. #Patch Set 5 : Raw 16-bit chars, too. #
Total comments: 3
Patch Set 6 : More feedback #
Total comments: 2
Messages
Total messages: 41 (25 generated)
Description was changed from ========== Merge element creation paths to remove a redundant name check. Element creation is a bit of a twisty maze of passages, all slightly different. Custom elements added checks for custom element names in multiple places. This folds custom element creation for createElement into HTMLElementFactory::createHTMLElement, avoiding a name check. This entails passing an optional ExceptionState to the HTMLElementFactory for the createElement case. It also weakens some CHECKs that custom elements should be created to DCHECKs. BUG=631931,639383 ========== to ========== Merge element creation paths to remove a redundant name check. Element creation is a bit of a twisty maze of passages, all slightly different. Custom elements added checks for custom element names in multiple places. This folds custom element creation for createElement into HTMLElementFactory::createHTMLElement, avoiding a name check. This entails passing an optional ExceptionState to the HTMLElementFactory for the createElement case. It also makes some changes to make things faster, suggested by esprehn in Issue 639383: - Weakens some CHECKs that custom elements should be created to DCHECKs. - Lifts the is8Bit check on custom element tag names to once per string. BUG=631931,639383 ==========
The CQ bit was checked by dominicc@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
dominicc@chromium.org changed reviewers: + esprehn@chromium.org
PTAL FYI perf tryjob up at https://codereview.chromium.org/2292433002
Description was changed from ========== Merge element creation paths to remove a redundant name check. Element creation is a bit of a twisty maze of passages, all slightly different. Custom elements added checks for custom element names in multiple places. This folds custom element creation for createElement into HTMLElementFactory::createHTMLElement, avoiding a name check. This entails passing an optional ExceptionState to the HTMLElementFactory for the createElement case. It also makes some changes to make things faster, suggested by esprehn in Issue 639383: - Weakens some CHECKs that custom elements should be created to DCHECKs. - Lifts the is8Bit check on custom element tag names to once per string. BUG=631931,639383 ========== to ========== Merge element creation paths to remove a redundant name check. Element creation is a bit of a twisty maze of passages, all slightly different. Custom elements added checks for custom element names in multiple places. This folds custom element creation for createElement into HTMLElementFactory::createHTMLElement, avoiding a name check. This entails passing an optional ExceptionState to the HTMLElementFactory for the createElement case. It also makes some changes to make things faster, suggested by esprehn in Issue 631931: - Weakens some CHECKs that custom elements should be created to DCHECKs. - Lifts the is8Bit check on custom element tag names to once per string. BUG=631931,639383 ==========
kouhei@chromium.org changed reviewers: + kouhei@chromium.org
https://codereview.chromium.org/2288653002/diff/20001/third_party/WebKit/Sour... File third_party/WebKit/Source/build/scripts/templates/ElementFactory.h.tmpl (right): https://codereview.chromium.org/2288653002/diff/20001/third_party/WebKit/Sour... third_party/WebKit/Source/build/scripts/templates/ElementFactory.h.tmpl:28: ExceptionState* = 0, nullptr https://codereview.chromium.org/2288653002/diff/20001/third_party/WebKit/Sour... File third_party/WebKit/Source/core/dom/custom/CustomElement.h (right): https://codereview.chromium.org/2288653002/diff/20001/third_party/WebKit/Sour... third_party/WebKit/Source/core/dom/custom/CustomElement.h:39: if (!name.length() || name[0] < 'a' || name[0] > 'z') Can we refactor the name[0] check as a platform/text/Character method?
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: linux_android_rel_ng on master.tryserver.chromium.android (JOB_FAILED, https://build.chromium.org/p/tryserver.chromium.android/builders/linux_androi...)
https://codereview.chromium.org/2288653002/diff/20001/third_party/WebKit/Sour... File third_party/WebKit/Source/bindings/core/v8/ScriptCustomElementDefinition.cpp (right): https://codereview.chromium.org/2288653002/diff/20001/third_party/WebKit/Sour... third_party/WebKit/Source/bindings/core/v8/ScriptCustomElementDefinition.cpp:168: : createElementSync(document, tagName); merge them together, there should be a single path with ASSERT_NO_EXCEPTION as the default. https://codereview.chromium.org/2288653002/diff/20001/third_party/WebKit/Sour... File third_party/WebKit/Source/bindings/core/v8/ScriptCustomElementDefinition.h (right): https://codereview.chromium.org/2288653002/diff/20001/third_party/WebKit/Sour... third_party/WebKit/Source/bindings/core/v8/ScriptCustomElementDefinition.h:72: HTMLElement* createElementSync(Document&, const QualifiedName&, ExceptionState&); I think I'd give these different names? Having this method which is the same as the virtual above is confusing. https://codereview.chromium.org/2288653002/diff/20001/third_party/WebKit/Sour... File third_party/WebKit/Source/core/dom/custom/CustomElement.h (right): https://codereview.chromium.org/2288653002/diff/20001/third_party/WebKit/Sour... third_party/WebKit/Source/core/dom/custom/CustomElement.h:72: static HTMLElement* createCustomElementSync(Document&, const AtomicString& localName, ExceptionState*); We normally do ExceptionState& and then default argument = ASSERT_NO_EXCEPTION
The CQ bit was checked by dominicc@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
PTAL FYI perf tryjob at https://codereview.chromium.org/2307533002
Description was changed from ========== Merge element creation paths to remove a redundant name check. Element creation is a bit of a twisty maze of passages, all slightly different. Custom elements added checks for custom element names in multiple places. This folds custom element creation for createElement into HTMLElementFactory::createHTMLElement, avoiding a name check. This entails passing an optional ExceptionState to the HTMLElementFactory for the createElement case. It also makes some changes to make things faster, suggested by esprehn in Issue 631931: - Weakens some CHECKs that custom elements should be created to DCHECKs. - Lifts the is8Bit check on custom element tag names to once per string. BUG=631931,639383 ========== to ========== Make custom element name checks faster and fewer This makes some changes to make things faster, suggested by esprehn in Issue 631931 and discussion: - Weakens some CHECKs that custom elements should be created to DCHECKs. - Specializes 8-bit strings. - Does a quick reject for names without hyphens. - Does one fewer name checks in the createElement case. BUG=631931,639383 ==========
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: win_chromium_rel_ng on master.tryserver.chromium.win (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.win/builders/win_chromium_rel_...)
PTAL Perf job result looks OK for createElement. It claims ID getters regressed 30%! Looked at a profile and it's unsurprising--a ton of time in id attribute getter callback. Wonder if this is bot weather. I will rerun the job. https://codereview.chromium.org/2303793003
https://codereview.chromium.org/2288653002/diff/40001/third_party/WebKit/Sour... File third_party/WebKit/Source/core/dom/custom/CustomElement.h (right): https://codereview.chromium.org/2288653002/diff/40001/third_party/WebKit/Sour... third_party/WebKit/Source/core/dom/custom/CustomElement.h:42: // Note: All valid names start with an ASCII character. for v1 we could just lookup the element in the registry hash table too since we don't need to do upgrades for things outside the document? return registry.contains(name); why do we care if the element is a custom element but isn't registered? https://codereview.chromium.org/2288653002/diff/40001/third_party/WebKit/Sour... third_party/WebKit/Source/core/dom/custom/CustomElement.h:48: if (!Character::isPotentialCustomElementName8BitChar(name[i])) this is checking is8Bit and isNull() repeatedly inside the loop in the operator[] accessor of AtomicString. const LChar* characters = name.characters8(); then use characters[i] in the loop https://codereview.chromium.org/2288653002/diff/40001/third_party/WebKit/Sour... third_party/WebKit/Source/core/dom/custom/CustomElement.h:54: U16_NEXT(name.characters16(), i, name.length(), ch); ditto, you're checking for null repeatedly inside the loop, before the loop do: const UChar* characters = name.characters16(); https://codereview.chromium.org/2288653002/diff/40001/third_party/WebKit/Sour... File third_party/WebKit/Source/platform/text/Character.h (right): https://codereview.chromium.org/2288653002/diff/40001/third_party/WebKit/Sour... third_party/WebKit/Source/platform/text/Character.h:86: return 'a' <= ch && ch <= 'z'; what about upper case? You can just call isASCIILower in the code though, no need for this method https://codereview.chromium.org/2288653002/diff/40001/third_party/WebKit/Sour... third_party/WebKit/Source/platform/text/Character.h:88: static bool isPotentialCustomElementName8BitChar(UChar ch) LChar? or template<typename CharType>. Widening the type to UChar makes the code below slower https://codereview.chromium.org/2288653002/diff/40001/third_party/WebKit/Sour... third_party/WebKit/Source/platform/text/Character.h:94: || (0xc0 <= ch && ch != 0xd7 && ch != 0xf7); btw I don't know why this is in platform/, can we put all of these methods in dom/ ? You can do that in another patch though
https://codereview.chromium.org/2288653002/diff/40001/third_party/WebKit/Sour... File third_party/WebKit/Source/core/dom/custom/CustomElement.h (right): https://codereview.chromium.org/2288653002/diff/40001/third_party/WebKit/Sour... third_party/WebKit/Source/core/dom/custom/CustomElement.h:48: if (!Character::isPotentialCustomElementName8BitChar(name[i])) On 2016/09/02 at 00:53:20, esprehn wrote: > this is checking is8Bit and isNull() repeatedly inside the loop in the operator[] accessor of AtomicString. > > const LChar* characters = name.characters8(); > > then use characters[i] in the loop This is also doing bounds checks, so you can save 3 branches per character here. https://cs.chromium.org/chromium/src/third_party/WebKit/Source/wtf/text/WTFSt... https://cs.chromium.org/chromium/src/third_party/WebKit/Source/wtf/text/Strin...
The CQ bit was checked by dominicc@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was checked by dominicc@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
On 2016/09/02 at 00:55:31, esprehn wrote: > https://codereview.chromium.org/2288653002/diff/40001/third_party/WebKit/Sour... > File third_party/WebKit/Source/core/dom/custom/CustomElement.h (right): > > https://codereview.chromium.org/2288653002/diff/40001/third_party/WebKit/Sour... > third_party/WebKit/Source/core/dom/custom/CustomElement.h:48: if (!Character::isPotentialCustomElementName8BitChar(name[i])) > On 2016/09/02 at 00:53:20, esprehn wrote: > > this is checking is8Bit and isNull() repeatedly inside the loop in the operator[] accessor of AtomicString. > > > > const LChar* characters = name.characters8(); > > > > then use characters[i] in the loop > > This is also doing bounds checks, so you can save 3 branches per character here. > > https://cs.chromium.org/chromium/src/third_party/WebKit/Source/wtf/text/WTFSt... > > https://cs.chromium.org/chromium/src/third_party/WebKit/Source/wtf/text/Strin... I thought that's what I pay my optimizing compiler writer for? :P OK, here's one that's more raw.
I think you missed my question about just looking up names in the registry. I understand the need for this check when doing defineElement, but not when doing createElement https://codereview.chromium.org/2288653002/diff/80001/third_party/WebKit/Sour... File third_party/WebKit/Source/platform/text/Character.h (right): https://codereview.chromium.org/2288653002/diff/80001/third_party/WebKit/Sour... third_party/WebKit/Source/platform/text/Character.h:86: return 'a' <= ch && ch <= 'z'; Can we just use isASCIILower :) https://codereview.chromium.org/2288653002/diff/80001/third_party/WebKit/Sour... third_party/WebKit/Source/platform/text/Character.h:88: static bool isPotentialCustomElementName8BitChar(UChar ch) LChar since this is 8bit https://codereview.chromium.org/2288653002/diff/80001/third_party/WebKit/Sour... third_party/WebKit/Source/platform/text/Character.h:91: return ('a' <= ch && ch <= 'z') isASCIILower || isASCIIDigit || ...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: This issue passed the CQ dry run.
The CQ bit was checked by dominicc@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
On 2016/09/02 at 09:22:24, esprehn wrote:
> I think you missed my question about just looking up names in the registry. I
understand the need for this check when doing defineElement, but not when doing
createElement
Sorry, yes, I did miss that.
Custom elements which don't have a definition are still processed differently to
other elements. Compare
document.createElement('foo')
document.createElement('x-foo')
for example: foo is HTMLUnknownElement; x-foo is HTMLElement. foo is not an
upgrade candidate; x-foo is an upgrade candidate.
You had another question/point about putting these in CustomElement instead of
Character. Koji wrote it so he will know, but I guess it was expedient because
all of the lookup table machinery is built for Character. And Kouhei asked to
then keep the related things together, see comment 8.
You had another question about uppercase letters or lowercasing the name. This
is simply a matter of what is allowed by the spec--only lowercase a-z are
allowed as initial letters.
>
https://codereview.chromium.org/2288653002/diff/80001/third_party/WebKit/Sour...
> File third_party/WebKit/Source/platform/text/Character.h (right):
>
>
https://codereview.chromium.org/2288653002/diff/80001/third_party/WebKit/Sour...
> third_party/WebKit/Source/platform/text/Character.h:86: return 'a' <= ch && ch
<= 'z';
> Can we just use isASCIILower :)
OK, done.
>
https://codereview.chromium.org/2288653002/diff/80001/third_party/WebKit/Sour...
> third_party/WebKit/Source/platform/text/Character.h:88: static bool
isPotentialCustomElementName8BitChar(UChar ch)
> LChar since this is 8bit
Done!
>
https://codereview.chromium.org/2288653002/diff/80001/third_party/WebKit/Sour...
> third_party/WebKit/Source/platform/text/Character.h:91: return ('a' <= ch &&
ch <= 'z')
> isASCIILower || isASCIIDigit || ...
Done!
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: This issue passed the CQ dry run.
lgtm, though I'd really like us to file a spec bug and just not allow stuff outside ASCII in v1. It makes all of this stuff much slower permitting emoji and random latin1 stuff in there. :/ https://codereview.chromium.org/2288653002/diff/100001/third_party/WebKit/Sou... File third_party/WebKit/Source/platform/text/Character.h (right): https://codereview.chromium.org/2288653002/diff/100001/third_party/WebKit/Sou... third_party/WebKit/Source/platform/text/Character.h:89: || ch == '-' || ch == '.' || ch == '_' || ch == 0xb7 what char is 0xb7? https://codereview.chromium.org/2288653002/diff/100001/third_party/WebKit/Sou... third_party/WebKit/Source/platform/text/Character.h:90: || (0xc0 <= ch && ch != 0xd7 && ch != 0xf7); What latin1 chars are these?
On Tue, Sep 6, 2016 at 8:54 PM, <esprehn@chromium.org> wrote: > lgtm, though I'd really like us to file a spec bug and just not allow stuff > outside ASCII in v1. It makes all of this stuff much slower permitting > emoji and > random latin1 stuff in there. :/ > I don't think these name checks are that expensive, but I've filed a bug just the same; maybe you could chime in there: https://github.com/whatwg/html/issues/1754 It makes sense to me to be liberal in what characters are allowed; HTML allows a wide range of characters for element names already and this seems consistent with that. > > https://codereview.chromium.org/2288653002/diff/100001/ > third_party/WebKit/Source/platform/text/Character.h > File third_party/WebKit/Source/platform/text/Character.h (right): > > https://codereview.chromium.org/2288653002/diff/100001/ > third_party/WebKit/Source/platform/text/Character.h#newcode89 > third_party/WebKit/Source/platform/text/Character.h:89: || ch == '-' || > ch == '.' || ch == '_' || ch == 0xb7 > what char is 0xb7? > Georgian middle dot; I think that's something like punctuation. > https://codereview.chromium.org/2288653002/diff/100001/ > third_party/WebKit/Source/platform/text/Character.h#newcode90 > third_party/WebKit/Source/platform/text/Character.h:90: || (0xc0 <= ch > && ch != 0xd7 && ch != 0xf7); > What latin1 chars are these? > > https://codereview.chromium.org/2288653002/ > Multiplication and division signs. FWIW these character ranges have history, from XML via HTML or something. -- You received this message because you are subscribed to the Google Groups "Blink Reviews" group. To unsubscribe from this group and stop receiving emails from it, send an email to blink-reviews+unsubscribe@chromium.org.
On Tue, Sep 6, 2016 at 8:54 PM, <esprehn@chromium.org> wrote: > lgtm, though I'd really like us to file a spec bug and just not allow stuff > outside ASCII in v1. It makes all of this stuff much slower permitting > emoji and > random latin1 stuff in there. :/ > I don't think these name checks are that expensive, but I've filed a bug just the same; maybe you could chime in there: https://github.com/whatwg/html/issues/1754 It makes sense to me to be liberal in what characters are allowed; HTML allows a wide range of characters for element names already and this seems consistent with that. > > https://codereview.chromium.org/2288653002/diff/100001/ > third_party/WebKit/Source/platform/text/Character.h > File third_party/WebKit/Source/platform/text/Character.h (right): > > https://codereview.chromium.org/2288653002/diff/100001/ > third_party/WebKit/Source/platform/text/Character.h#newcode89 > third_party/WebKit/Source/platform/text/Character.h:89: || ch == '-' || > ch == '.' || ch == '_' || ch == 0xb7 > what char is 0xb7? > Georgian middle dot; I think that's something like punctuation. > https://codereview.chromium.org/2288653002/diff/100001/ > third_party/WebKit/Source/platform/text/Character.h#newcode90 > third_party/WebKit/Source/platform/text/Character.h:90: || (0xc0 <= ch > && ch != 0xd7 && ch != 0xf7); > What latin1 chars are these? > > https://codereview.chromium.org/2288653002/ > Multiplication and division signs. FWIW these character ranges have history, from XML via HTML or something. -- You received this message because you are subscribed to the Google Groups "Chromium-reviews" group. To unsubscribe from this group and stop receiving emails from it, send an email to chromium-reviews+unsubscribe@chromium.org.
The CQ bit was checked by dominicc@chromium.org
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
Message was sent while issue was closed.
Committed patchset #6 (id:100001)
Message was sent while issue was closed.
Description was changed from ========== Make custom element name checks faster and fewer This makes some changes to make things faster, suggested by esprehn in Issue 631931 and discussion: - Weakens some CHECKs that custom elements should be created to DCHECKs. - Specializes 8-bit strings. - Does a quick reject for names without hyphens. - Does one fewer name checks in the createElement case. BUG=631931,639383 ========== to ========== Make custom element name checks faster and fewer This makes some changes to make things faster, suggested by esprehn in Issue 631931 and discussion: - Weakens some CHECKs that custom elements should be created to DCHECKs. - Specializes 8-bit strings. - Does a quick reject for names without hyphens. - Does one fewer name checks in the createElement case. BUG=631931,639383 Committed: https://crrev.com/a67c4b53027ee270f17241d7a594ac10aef33790 Cr-Commit-Position: refs/heads/master@{#416959} ==========
Message was sent while issue was closed.
Patchset 6 (id:??) landed as https://crrev.com/a67c4b53027ee270f17241d7a594ac10aef33790 Cr-Commit-Position: refs/heads/master@{#416959} |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
