WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
107317
Make CompactHTMLToken a little more compact
https://bugs.webkit.org/show_bug.cgi?id=107317
Summary
Make CompactHTMLToken a little more compact
Tony Gentilcore
Reported
2013-01-18 12:59:31 PST
Make CompactHTMLToken a little more compact
Attachments
Patch
(6.88 KB, patch)
2013-01-18 12:59 PST
,
Tony Gentilcore
no flags
Details
Formatted Diff
Diff
Patch
(7.17 KB, patch)
2013-01-18 17:54 PST
,
Tony Gentilcore
no flags
Details
Formatted Diff
Diff
An alternate approach
(5.03 KB, patch)
2013-01-19 04:01 PST
,
Eric Seidel (no email)
no flags
Details
Formatted Diff
Diff
Updated to TOT
(5.00 KB, patch)
2013-01-22 01:48 PST
,
Eric Seidel (no email)
no flags
Details
Formatted Diff
Diff
Patch for landing
(4.71 KB, patch)
2013-01-22 11:35 PST
,
Eric Seidel (no email)
no flags
Details
Formatted Diff
Diff
Patch for landing
(4.85 KB, patch)
2013-01-22 11:42 PST
,
Eric Seidel (no email)
no flags
Details
Formatted Diff
Diff
Patch for landing
(5.00 KB, patch)
2013-01-22 12:32 PST
,
Eric Seidel (no email)
no flags
Details
Formatted Diff
Diff
Patch for landing
(1.34 KB, patch)
2013-01-22 14:16 PST
,
Eric Seidel (no email)
no flags
Details
Formatted Diff
Diff
Show Obsolete
(7)
View All
Add attachment
proposed patch, testcase, etc.
Tony Gentilcore
Comment 1
2013-01-18 12:59:54 PST
Created
attachment 183533
[details]
Patch
Eric Seidel (no email)
Comment 2
2013-01-18 13:07:02 PST
Comment on
attachment 183533
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=183533&action=review
> Source/WebCore/html/parser/BackgroundHTMLParser.cpp:129 > + if (m_token.type() == HTMLTokenTypes::DOCTYPE) > + m_pendingTokens.append(DocTypeCompactHTMLToken(m_token));
How can this work? Aren't we appending these by value, not pointers?
Tony Gentilcore
Comment 3
2013-01-18 13:50:09 PST
(In reply to
comment #2
)
> (From update of
attachment 183533
[details]
) > View in context:
https://bugs.webkit.org/attachment.cgi?id=183533&action=review
> > > Source/WebCore/html/parser/BackgroundHTMLParser.cpp:129 > > + if (m_token.type() == HTMLTokenTypes::DOCTYPE) > > + m_pendingTokens.append(DocTypeCompactHTMLToken(m_token)); > > How can this work? Aren't we appending these by value, not pointers?
Oops, I'll have to think of another way to go about this.
Adam Barth
Comment 4
2013-01-18 14:22:31 PST
Comment on
attachment 183533
[details]
Patch Maybe an OwnPtr to hold the DocType specific values? Normally that will be 0, which is smaller and won't try to ref/deref twice.
Tony Gentilcore
Comment 5
2013-01-18 17:54:57 PST
Created
attachment 183584
[details]
Patch
Eric Seidel (no email)
Comment 6
2013-01-19 04:01:35 PST
Created
attachment 183619
[details]
An alternate approach
Eric Seidel (no email)
Comment 7
2013-01-19 04:02:13 PST
I hope you don't mind me hijacking your bug. Please feel free to obsolete my patch and re-state yours for review if you like!
Adam Barth
Comment 8
2013-01-22 01:24:31 PST
Comment on
attachment 183619
[details]
An alternate approach That's awesome.
Adam Barth
Comment 9
2013-01-22 01:37:08 PST
Comment on
attachment 183619
[details]
An alternate approach View in context:
https://bugs.webkit.org/attachment.cgi?id=183619&action=review
> Source/WebCore/html/parser/CompactHTMLToken.h:71 > + const String& publicIdentifier() const { return m_attributes[0].name(); } > + const String& systemIdentifier() const { return m_attributes[0].value(); }
Can we ASSERT that m_attributes has at least size one? Maybe Vector does that for us?
> Source/WebCore/html/parser/CompactHTMLToken.h:74 > + unsigned m_type : 4;
Can we ASSERT that we have enough bits somehow?
Eric Seidel (no email)
Comment 10
2013-01-22 01:43:52 PST
Comment on
attachment 183619
[details]
An alternate approach View in context:
https://bugs.webkit.org/attachment.cgi?id=183619&action=review
>> Source/WebCore/html/parser/CompactHTMLToken.h:71 >> + const String& systemIdentifier() const { return m_attributes[0].value(); } > > Can we ASSERT that m_attributes has at least size one? Maybe Vector does that for us?
Yup:
http://trac.webkit.org/browser/trunk/Source/WTF/wtf/Vector.h#L553
>> Source/WebCore/html/parser/CompactHTMLToken.h:74 >> + unsigned m_type : 4; > > Can we ASSERT that we have enough bits somehow?
I believe the compiler does this for us (at least GCC) when we assign HTMLTokenTypes::Type to this value. if it were too small it would warn. At least that's my recollection.
Eric Seidel (no email)
Comment 11
2013-01-22 01:48:15 PST
Created
attachment 183930
[details]
Updated to TOT
Darin Adler
Comment 12
2013-01-22 10:19:10 PST
Comment on
attachment 183930
[details]
Updated to TOT View in context:
https://bugs.webkit.org/attachment.cgi?id=183930&action=review
I am not an expert on the parser, but the patch looks fine to me and probably does not require parser expertise.
> Source/WebCore/ChangeLog:13 > + however when I tried to assert that it failed. Presumably because > + Vector<T> is more than void* in size.
Yes, Vector<T> is much more than void* in size!
> Source/WebCore/html/parser/CompactHTMLToken.h:78 > Vector<CompactAttribute> m_attributes;
What’s the typical size of this vector? If it’s typically empty, it could be OwnPtr<Vector>. If it typically has a small number of attributes, maybe it should have inline capacity.
Darin Adler
Comment 13
2013-01-22 10:20:29 PST
Comment on
attachment 183930
[details]
Updated to TOT View in context:
https://bugs.webkit.org/attachment.cgi?id=183930&action=review
>> Source/WebCore/ChangeLog:13 >> + Vector<T> is more than void* in size. > > Yes, Vector<T> is much more than void* in size!
Roughly speaking, it’s got a pointer for the storage, a size, and a capacity. So we pay for the flexibility of being able to efficiently resize. For specialized uses we can use a different data structure that is more compact.
WebKit Review Bot
Comment 14
2013-01-22 10:32:28 PST
Comment on
attachment 183930
[details]
Updated to TOT Rejecting
attachment 183930
[details]
from commit-queue. Failed to run "['/mnt/git/webkit-commit-queue/Tools/Scripts/webkit-patch', '--status-host=queues.webkit.org', '-..." exit_code: 2 cwd: /mnt/git/webkit-commit-queue Last 500 characters of output: -fno-rtti -fno-threadsafe-statics -fvisibility-inlines-hidden -Wsign-compare -c ../../Source/WebCore/html/parser/CompactHTMLToken.cpp -o obj/Source/WebCore/html/parser/webcore_html.CompactHTMLToken.o ../../Source/WebCore/html/parser/CompactHTMLToken.cpp: In constructor 'WebCore::CompactHTMLToken::CompactHTMLToken(const WebCore::HTMLToken&)': ../../Source/WebCore/html/parser/CompactHTMLToken.cpp:55: error: 'stringFromToken' was not declared in this scope ninja: build stopped: subcommand failed. Full output:
http://queues.webkit.org/results/16039638
Eric Seidel (no email)
Comment 15
2013-01-22 11:03:20 PST
Comment on
attachment 183930
[details]
Updated to TOT View in context:
https://bugs.webkit.org/attachment.cgi?id=183930&action=review
>>> Source/WebCore/ChangeLog:13 >>> + Vector<T> is more than void* in size. >> >> Yes, Vector<T> is much more than void* in size! > > Roughly speaking, it’s got a pointer for the storage, a size, and a capacity. So we pay for the flexibility of being able to efficiently resize. For specialized uses we can use a different data structure that is more compact.
Yeah, I forgot about the necessary size member when writing that. :) I didn't realize we had another one for capacity as well.
Eric Seidel (no email)
Comment 16
2013-01-22 11:04:09 PST
Comment on
attachment 183930
[details]
Updated to TOT View in context:
https://bugs.webkit.org/attachment.cgi?id=183930&action=review
>> Source/WebCore/html/parser/CompactHTMLToken.h:78 >> Vector<CompactAttribute> m_attributes; > > What’s the typical size of this vector? If it’s typically empty, it could be OwnPtr<Vector>. If it typically has a small number of attributes, maybe it should have inline capacity.
It's only used for attribute tokens, which are less common than character tokens for sure. We probably should make it OwnPtr<Vector>
Eric Seidel (no email)
Comment 17
2013-01-22 11:35:37 PST
Created
attachment 184026
[details]
Patch for landing
WebKit Review Bot
Comment 18
2013-01-22 11:38:08 PST
Comment on
attachment 184026
[details]
Patch for landing
Attachment 184026
[details]
did not pass chromium-ews (chromium-xvfb): Output:
http://queues.webkit.org/results/16042706
Eric Seidel (no email)
Comment 19
2013-01-22 11:42:43 PST
Created
attachment 184028
[details]
Patch for landing
Eric Seidel (no email)
Comment 20
2013-01-22 11:44:57 PST
Sorry, this was originally part of a fancier patch series. An earlier patch never landed.
WebKit Review Bot
Comment 21
2013-01-22 11:47:26 PST
Comment on
attachment 184028
[details]
Patch for landing Rejecting
attachment 184028
[details]
from commit-queue. Failed to run "['/mnt/git/webkit-commit-queue/Tools/Scripts/webkit-patch', '--status-host=queues.webkit.org', '-..." exit_code: 2 cwd: /mnt/git/webkit-commit-queue Last 500 characters of output: r' ../../Source/WebCore/html/parser/CompactHTMLToken.cpp:55: error: crosses initialization of 'WTF::String publicIdentifier' ../../Source/WebCore/html/parser/CompactHTMLToken.cpp:76: error: jump to case label ../../Source/WebCore/html/parser/CompactHTMLToken.cpp:56: error: crosses initialization of 'WTF::String systemIdentifier' ../../Source/WebCore/html/parser/CompactHTMLToken.cpp:55: error: crosses initialization of 'WTF::String publicIdentifier' ninja: build stopped: subcommand failed. Full output:
http://queues.webkit.org/results/16036725
Eric Seidel (no email)
Comment 22
2013-01-22 12:32:27 PST
Created
attachment 184035
[details]
Patch for landing
WebKit Review Bot
Comment 23
2013-01-22 13:03:11 PST
Comment on
attachment 184035
[details]
Patch for landing Clearing flags on attachment: 184035 Committed
r140453
: <
http://trac.webkit.org/changeset/140453
>
WebKit Review Bot
Comment 24
2013-01-22 13:03:16 PST
All reviewed patches have been landed. Closing bug.
Eric Seidel (no email)
Comment 25
2013-01-22 13:54:19 PST
This broke the Windows builder because MSVC won't compact adjacent bitfields of differing types. I have to change "bool" to "unsigned" and it will work.
Eric Seidel (no email)
Comment 26
2013-01-22 13:54:55 PST
http://build.chromium.org/p/chromium.webkit/builders/WebKit%20Win%20Builder/builds/35188
is the log from the break.
Eric Seidel (no email)
Comment 27
2013-01-22 14:16:00 PST
Reopening to attach new patch.
Eric Seidel (no email)
Comment 28
2013-01-22 14:16:08 PST
Created
attachment 184046
[details]
Patch for landing
Hin-Chung Lam
Comment 29
2013-01-22 14:47:59 PST
Comment on
attachment 184046
[details]
Patch for landing Clearing flags on attachment: 184046 Committed
r140473
: <
http://trac.webkit.org/changeset/140473
>
Hin-Chung Lam
Comment 30
2013-01-22 14:48:02 PST
All reviewed patches have been landed. Closing bug.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug