WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
37978
Unify JSC::IdentifierTable and WebCore::AtomicStringTable implementations.
https://bugs.webkit.org/show_bug.cgi?id=37978
Summary
Unify JSC::IdentifierTable and WebCore::AtomicStringTable implementations.
Gavin Barraclough
Reported
2010-04-22 00:34:43 PDT
These two classes both implement a HashSet of uniqued StringImpls, with translator classes to avoid unnecessary object creation. The only difference between the classes is which flag (isIdentifier or inTable) is set. Combine the two classes using a template predicated on which flag to use.
Attachments
The patch
(41.49 KB, patch)
2010-04-22 00:42 PDT
,
Gavin Barraclough
no flags
Details
Formatted Diff
Diff
Fix review bot issues
(41.49 KB, patch)
2010-04-22 00:47 PDT
,
Gavin Barraclough
ggaren
: review+
Details
Formatted Diff
Diff
Show Obsolete
(1)
View All
Add attachment
proposed patch, testcase, etc.
Gavin Barraclough
Comment 1
2010-04-22 00:42:19 PDT
Created
attachment 54036
[details]
The patch
WebKit Review Bot
Comment 2
2010-04-22 00:44:47 PDT
Attachment 54036
[details]
did not pass style-queue: Failed to run "['WebKitTools/Scripts/check-webkit-style']" exit_code: 1 JavaScriptCore/wtf/text/AtomicStringTable.h:32: Alphabetical sorting problem. [build/include_order] [4] JavaScriptCore/wtf/text/AtomicStringTable.h:53: Tests for true/false, null/non-null, and zero/non-zero should all be done without equality comparisons. [readability/comparison_to_zero] [5] Total errors found: 2 in 16 files If any of these errors are false positives, please file a bug against check-webkit-style.
Gavin Barraclough
Comment 3
2010-04-22 00:47:01 PDT
Created
attachment 54038
[details]
Fix review bot issues
Geoffrey Garen
Comment 4
2010-04-22 09:58:45 PDT
Comment on
attachment 54038
[details]
Fix review bot issues Looks good. A few hashtable comments: + LiteralTable* literalTable = globalData->literalTable; + const LiteralTable::iterator& iter = literalTable->find(c); + if (iter != literalTable->end()) return iter->second; - pair<HashSet<UString::Rep*>::iterator, bool> addResult = identifierTable.add<const char*, IdentifierCStringTranslator>(c); - - // If the string is newly-translated, then we need to adopt it. - // The boolean in the pair tells us if that is so. - RefPtr<UString::Rep> addedString = addResult.second ? adoptRef(*addResult.first) : *addResult.first; - - literalIdentifierTable.add(c, addedString.get()); - + RefPtr<StringImpl> addedString = globalData->identifierTable->add(c); + literalTable->add(c, addedString.get()); return addedString.release(); I'm surprised that we have a separate table for char*. Weird. Maybe it's just legacy code that can go away? Anyhoo, "literalTable->find" followed by "literalTable->add" is a double-lookup. The idiom for avoiding double-lookup is: pair<iterator, bool> result = literalTable->add(c, 0); if (!result.second) // pre-existing entry return result.first->second; ... result.first->second = addedString.get(); +template<bool isIdentifierTable> +IdentifierOrAtomicStringTable<isIdentifierTable>::~IdentifierOrAtomicStringTable() +{ + HashSet<StringImpl*>::iterator end = m_table.end(); + for (HashSet<StringImpl*>::iterator iter = m_table.begin(); iter != end; ++iter) { + if (isIdentifierTable) + (*iter)->setIsIdentifier(false); + else + (*iter)->setIsAtomic(false); + } +} This would probably be more efficient if you wrote two copies of the loop, and moved the isIdentifierTable test out of the loop. We know that isIdentifierTable is constant inside the loop, but GCC probably doesn't. r=me
Gavin Barraclough
Comment 5
2010-04-22 12:39:08 PDT
> I'm surprised that we have a separate table for char*. Weird. Maybe it's just > legacy code that can go away?
This table holds RefPtrs rather than StringImpl*s, I think the idea is to prevernt thrash creating & destroying string objects for literal strings in JSC's source. I'm not sure if it's still necessary, but would rather not change in this patch.
> Anyhoo, "literalTable->find" followed by "literalTable->add" is a > double-lookup. The idiom for avoiding double-lookup is:
*nod, will do.
> This would probably be more efficient if you wrote two copies of the loop, and > moved the isIdentifierTable test out of the loop. We know that > isIdentifierTable is constant inside the loop, but GCC probably doesn't.
If you think about it, GCC absolutely must know all template parameter values to code generate to be able to code specialize, which is the whole purpose of templates. This is more obvious in the case where the template parameter is a type, also holds where the template parameter is a value. Still, happy to rejig the check out the loop to make it more obvious that no redundant checking is going on.
Gavin Barraclough
Comment 6
2010-04-22 13:38:57 PDT
Transmitting file data ................ Committed revision 58114.
WebKit Review Bot
Comment 7
2010-04-22 13:55:29 PDT
http://trac.webkit.org/changeset/58114
might have broken Qt Linux Release
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