Bug 128624 - Merge AtomicString, Identifier
Summary: Merge AtomicString, Identifier
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Gavin Barraclough
URL:
Keywords:
: 38015 (view as bug list)
Depends on:
Blocks:
 
Reported: 2014-02-11 13:53 PST by Gavin Barraclough
Modified: 2022-07-21 17:04 PDT (History)
8 users (show)

See Also:


Attachments
Rage hacked, builds, fixed ASSERTions & infinite loops, but almost all tests still failing! (127.17 KB, patch)
2014-02-11 13:55 PST, Gavin Barraclough
no flags Details | Formatted Diff | Diff
New patch (32.46 KB, patch)
2014-03-17 17:15 PDT, Gavin Barraclough
no flags Details | Formatted Diff | Diff
New fix (32.86 KB, patch)
2014-03-17 18:48 PDT, Gavin Barraclough
no flags Details | Formatted Diff | Diff
review fixes, windows build fix, separate out new file. (36.81 KB, patch)
2014-03-19 14:58 PDT, Gavin Barraclough
no flags Details | Formatted Diff | Diff
Tests pass, think the JSC/WTF changes are probably complete. (43.60 KB, patch)
2014-03-20 00:18 PDT, Gavin Barraclough
no flags Details | Formatted Diff | Diff
Patch, with speculative Windows build fix (47.31 KB, patch)
2014-03-20 12:00 PDT, Gavin Barraclough
ggaren: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Gavin Barraclough 2014-02-11 13:53:49 PST
.
Comment 1 Gavin Barraclough 2014-02-11 13:55:28 PST
Created attachment 223898 [details]
Rage hacked, builds, fixed ASSERTions & infinite loops, but almost all tests still failing!
Comment 2 Gavin Barraclough 2014-03-17 17:15:06 PDT
Created attachment 226987 [details]
New patch
Comment 3 Gavin Barraclough 2014-03-17 17:15:30 PDT
JS Perf looks fine.

All benchmarks:
   <arithmetic>                                     149.9601+-1.3387          148.4964+-0.8381          might be 1.0099x faster
   <geometric>                                       19.2674+-0.0367     ^     19.1212+-0.0932        ^ definitely 1.0076x faster
   <harmonic>                                         4.2925+-0.0201            4.2662+-0.0586          might be 1.0062x faster
Comment 4 Gavin Barraclough 2014-03-17 17:16:43 PDT
Oh, patch needs Changelogs & some of those inlines could do with their own header.
Comment 5 WebKit Commit Bot 2014-03-17 17:17:30 PDT
Attachment 226987 [details] did not pass style-queue:


ERROR: Source/JavaScriptCore/runtime/Identifier.h:113:  The parameter name "r" adds no information, so it should be removed.  [readability/parameter_name] [5]
ERROR: Source/JavaScriptCore/runtime/Identifier.h:114:  The parameter name "r" adds no information, so it should be removed.  [readability/parameter_name] [5]
Total errors found: 2 in 21 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 6 Gavin Barraclough 2014-03-17 18:48:48 PDT
Created attachment 226997 [details]
New fix

Still needs changelog, etc.
Comment 7 Andreas Kling 2014-03-17 20:00:23 PDT
Freakin' awesome!
Comment 8 Benjamin Poulain 2014-03-17 20:09:09 PDT
(In reply to comment #7)
> Freakin' awesome!

+1
Comment 9 Darin Adler 2014-03-17 20:18:52 PDT
Comment on attachment 226997 [details]
New fix

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

> Source/JavaScriptCore/runtime/SmallStrings.cpp:62
>          m_reps[i] = StringImpl::createSubstringSharingImpl(baseString, i, 1);
> +        m_reps[i] = AtomicString::add(m_reps[i].get());

Why use m_reps[i] for the intermediate value? Why not do this all on one line.

> Source/JavaScriptCore/runtime/VM.cpp:198
> +    , propertyNames(0)

nullptr?

> Source/WTF/wtf/text/AtomicStringTable.cpp:56
> +    for (auto iter : m_table)

Should name this "string", not "iter".

I prefer "auto*" or "auto&" here to make it clear we don’t have any bad copying going on.

> Source/WTF/wtf/text/AtomicStringTable.cpp:60
>  void AtomicStringTable::destroy(AtomicStringTable* table)

Do we even need this function any more since we have a public destructor now?
Comment 10 Darin Adler 2014-03-17 20:43:58 PDT
Comment on attachment 226997 [details]
New fix

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

Any of these functions that should take or return references rather than pointers?

> Source/JavaScriptCore/runtime/VM.h:296
> +        IdentifierTable* atomicStringTable() const { return identifierTable; }

Consider returning a reference instead of a pointer? Why do we need this function? Just to rename the identifierTable data member?

> Source/WTF/wtf/WTFThreadData.h:55
> +typedef AtomicStringTable IdentifierTable;

Long term would we just get rid of this typedef?
Comment 11 Gavin Barraclough 2014-03-19 14:28:52 PDT
(In reply to comment #9)
> Why use m_reps[i] for the intermediate value? Why not do this all on one line.
> 
> nullptr?
> 
> I prefer "auto*" or "auto&" here to make it clear we don’t have any bad copying going on.

done, done, done.

> > Source/WTF/wtf/text/AtomicStringTable.cpp:60
> >  void AtomicStringTable::destroy(AtomicStringTable* table)
> 
> Do we even need this function any more since we have a public destructor now?

Short answer, yes. Long answer, no.

We still need this because it's used as a part of the mechanism for the main thread / web thread to decide who gets to delete their shared string table. But it's probably an over engineered solution – we probably just an if statement in WTFThreadData's destructor. Let me revise in a follow-on patch.

(In reply to comment #10)
>
> > Source/JavaScriptCore/runtime/VM.h:296
> > +        IdentifierTable* atomicStringTable() const { return identifierTable; }
> 
> Consider returning a reference instead of a pointer?

done,

> Why do we need this function? Just to rename the identifierTable data member?

We use this method so you can call AtomicString::add(VM&, StringImpl*), or AtomicString::add(ExecState&, StringImpl*), template on the first argument type to avoid a layering violation. Hopefully we may be ablate make this go away in a followup patch, if WTFThreadData access is now fast enough we make be able to always look up the string table from the thread data, rather than reading it off the VM in JSC.

> > Source/WTF/wtf/WTFThreadData.h:55
> > +typedef AtomicStringTable IdentifierTable;
> 
> Long term would we just get rid of this typedef?

Yep, definitely. I'll do a followup purge of WTF for use of the work 'Identifier' (e.g. we should probably also remove isIdentifier, all uses -> isAtomic).
Comment 12 Gavin Barraclough 2014-03-19 14:58:55 PDT
Created attachment 227221 [details]
review fixes, windows build fix, separate out new file.

Still missing ChangeLogs, and 2 JSC tests are failing.
Comment 13 Gavin Barraclough 2014-03-20 00:18:05 PDT
Created attachment 227265 [details]
Tests pass, think the JSC/WTF changes are probably complete.

Should probably take another look at that WebCore change, and the Windows build is probably still broke (related). I've added JSC/WTF Changelogs, but still needs some description.
Comment 14 Gavin Barraclough 2014-03-20 12:00:47 PDT
Created attachment 227312 [details]
Patch, with speculative Windows build fix
Comment 15 Geoffrey Garen 2014-03-20 12:03:37 PDT
Comment on attachment 227312 [details]
Patch, with speculative Windows build fix

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

r=me if it blends

> Source/JavaScriptCore/ChangeLog:9
> +        WTF::StringImpl currently supports two uniquing mechanism - AtomicString and
> +        Identifer - that is one too many.

So, you're saying we should unique our uniquing?
Comment 16 Gavin Barraclough 2014-03-20 12:27:02 PDT
Transmitting file data ............................
Committed revision 165982.
Comment 17 Gavin Barraclough 2014-03-20 13:04:29 PDT
Build fix in revision 165990.
Comment 19 Ryosuke Niwa 2022-07-21 17:04:29 PDT
*** Bug 38015 has been marked as a duplicate of this bug. ***