Bug 109750 - StartTagScanner should be thread-safe
Summary: StartTagScanner should be thread-safe
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Adam Barth
URL:
Keywords:
Depends on:
Blocks: 106127
  Show dependency treegraph
 
Reported: 2013-02-13 14:34 PST by Adam Barth
Modified: 2013-02-13 18:17 PST (History)
4 users (show)

See Also:


Attachments
Patch (10.18 KB, patch)
2013-02-13 14:39 PST, Adam Barth
no flags Details | Formatted Diff | Diff
Patch for landing (10.17 KB, patch)
2013-02-13 18:02 PST, Adam Barth
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Adam Barth 2013-02-13 14:34:16 PST
StartTagScanner should be thread-safe
Comment 1 Adam Barth 2013-02-13 14:39:06 PST
Created attachment 188186 [details]
Patch
Comment 2 Eric Seidel (no email) 2013-02-13 15:00:14 PST
Comment on attachment 188186 [details]
Patch

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

> Source/WebCore/html/parser/HTMLPreloadScanner.cpp:109
> +        if (m_tagId == UnknownTagId)
>              return;

I think this is very clever.  It's not clear to me that the HTMLTagIdentifier stuff needs to leak out of this class at all.  It could just be private to StartTagScanner?  I assume it's part of a larger plan you have for world domination, hence being separate?

> Source/WebCore/html/parser/HTMLPreloadScanner.cpp:112
>              AtomicString attributeName(iter->name);

I believe this will crash on the background thread, no?  It looks like you don't even use it as Atomic, but making it Atomic does prevent a copy in teh common case on the main thread.
Comment 3 Adam Barth 2013-02-13 15:04:02 PST
(In reply to comment #2)
> (From update of attachment 188186 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=188186&action=review
> 
> > Source/WebCore/html/parser/HTMLPreloadScanner.cpp:109
> > +        if (m_tagId == UnknownTagId)
> >              return;
> 
> I think this is very clever.  It's not clear to me that the HTMLTagIdentifier stuff needs to leak out of this class at all.  It could just be private to StartTagScanner?  I assume it's part of a larger plan you have for world domination, hence being separate?

It's going to leak out of the class, but hopefully not out of the file.  For example, I plan to use it in processPossibleStyleTag as well.

> > Source/WebCore/html/parser/HTMLPreloadScanner.cpp:112
> >              AtomicString attributeName(iter->name);
> 
> I believe this will crash on the background thread, no?  It looks like you don't even use it as Atomic, but making it Atomic does prevent a copy in teh common case on the main thread.

Yeah, processAttributes(const HTMLToken::AttributeList& attributes) is going to be main thread only.  I plan to add a processAttributes that takes a CompactHTMLToken::AttributeList or whatever the actual type is called.  I can add an ASSERT(isMainThread()) to this function if that would be helpful.
Comment 4 Adam Barth 2013-02-13 16:09:40 PST
Review ping.  This patch is blocking this stack of patches.  :)
Comment 5 Eric Seidel (no email) 2013-02-13 16:21:12 PST
Comment on attachment 188186 [details]
Patch

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

LGTM.

>>> Source/WebCore/html/parser/HTMLPreloadScanner.cpp:112
>>>              AtomicString attributeName(iter->name);
>> 
>> I believe this will crash on the background thread, no?  It looks like you don't even use it as Atomic, but making it Atomic does prevent a copy in teh common case on the main thread.
> 
> Yeah, processAttributes(const HTMLToken::AttributeList& attributes) is going to be main thread only.  I plan to add a processAttributes that takes a CompactHTMLToken::AttributeList or whatever the actual type is called.  I can add an ASSERT(isMainThread()) to this function if that would be helpful.

I think ASSERTing when we should be on the main thread is helpful, yes.
Comment 6 Adam Barth 2013-02-13 18:02:09 PST
Created attachment 188243 [details]
Patch for landing
Comment 7 Adam Barth 2013-02-13 18:17:53 PST
Comment on attachment 188243 [details]
Patch for landing

Clearing flags on attachment: 188243

Committed r142840: <http://trac.webkit.org/changeset/142840>
Comment 8 Adam Barth 2013-02-13 18:17:55 PST
All reviewed patches have been landed.  Closing bug.