Bug 133425

Summary: Add a LazyNeverDestroyed class template and use it
Product: WebKit Reporter: Anders Carlsson <andersca>
Component: New BugsAssignee: Anders Carlsson <andersca>
Status: RESOLVED FIXED    
Severity: Normal CC: benjamin, cmarcelo, commit-queue, japhet
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Patch
none
Patch
none
Patch
none
Patch
none
Patch darin: review+

Description Anders Carlsson 2014-05-31 13:35:05 PDT
Add a LazyNeverDestroyed class template and use it
Comment 1 Anders Carlsson 2014-05-31 13:42:16 PDT
Created attachment 232321 [details]
Patch
Comment 2 Darin Adler 2014-05-31 15:00:33 PDT
Comment on attachment 232321 [details]
Patch

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

> Source/JavaScriptCore/dfg/DFGFunctionWhitelist.cpp:43
> +        functionWhitelist.construct(Options::dfgFunctionWhitelistFile());

Bug in the Windows compiler?

     1>C:\cygwin\home\buildbot\WebKit\WebKitBuild\Release\include\private\wtf/NeverDestroyed.h(91): error C2248: 'JSC::DFG::FunctionWhitelist::FunctionWhitelist' : cannot access private member declared in class 'JSC::DFG::FunctionWhitelist' (..\dfg\DFGFunctionWhitelist.cpp)
                 c:\cygwin\home\buildbot\webkit\source\javascriptcore\dfg\DFGFunctionWhitelist.h(46) : see declaration of 'JSC::DFG::FunctionWhitelist::FunctionWhitelist'
                 c:\cygwin\home\buildbot\webkit\source\javascriptcore\dfg\DFGFunctionWhitelist.h(38) : see declaration of 'JSC::DFG::FunctionWhitelist'
                 ..\dfg\DFGFunctionWhitelist.cpp(43) : see reference to function template instantiation 'void WTF::LazyNeverDestroyed<JSC::DFG::FunctionWhitelist>::construct<JSC::optionString&>(JSC::optionString &)' being compiled
                 ..\dfg\DFGFunctionWhitelist.cpp(43) : see reference to function template instantiation 'void WTF::LazyNeverDestroyed<JSC::DFG::FunctionWhitelist>::construct<JSC::optionString&>(JSC::optionString &)' being compiled

> Source/WTF/wtf/Forward.h:30
> +template<typename T> class LazyNeverDestroyed;
>  template<typename T> class NeverDestroyed;

Are these two forward declarations ever helpful?

> Source/WTF/wtf/NeverDestroyed.h:126
>  using WTF::NeverDestroyed;

Should the plain old NeverDestroyed be reimplemented using LazyNeverDestroyed?
Comment 3 Anders Carlsson 2014-05-31 15:31:39 PDT
(In reply to comment #2)
> (From update of attachment 232321 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=232321&action=review
> 
> > Source/JavaScriptCore/dfg/DFGFunctionWhitelist.cpp:43
> > +        functionWhitelist.construct(Options::dfgFunctionWhitelistFile());
> 
> Bug in the Windows compiler?
> 
>      1>C:\cygwin\home\buildbot\WebKit\WebKitBuild\Release\include\private\wtf/NeverDestroyed.h(91): error C2248: 'JSC::DFG::FunctionWhitelist::FunctionWhitelist' : cannot access private member declared in class 'JSC::DFG::FunctionWhitelist' (..\dfg\DFGFunctionWhitelist.cpp)
>                  c:\cygwin\home\buildbot\webkit\source\javascriptcore\dfg\DFGFunctionWhitelist.h(46) : see declaration of 'JSC::DFG::FunctionWhitelist::FunctionWhitelist'
>                  c:\cygwin\home\buildbot\webkit\source\javascriptcore\dfg\DFGFunctionWhitelist.h(38) : see declaration of 'JSC::DFG::FunctionWhitelist'
>                  ..\dfg\DFGFunctionWhitelist.cpp(43) : see reference to function template instantiation 'void WTF::LazyNeverDestroyed<JSC::DFG::FunctionWhitelist>::construct<JSC::optionString&>(JSC::optionString &)' being compiled
>                  ..\dfg\DFGFunctionWhitelist.cpp(43) : see reference to function template instantiation 'void WTF::LazyNeverDestroyed<JSC::DFG::FunctionWhitelist>::construct<JSC::optionString&>(JSC::optionString &)' being compiled

Hmm, I'll see what I can do to fix it.

> 
> > Source/WTF/wtf/Forward.h:30
> > +template<typename T> class LazyNeverDestroyed;
> >  template<typename T> class NeverDestroyed;
> 
> Are these two forward declarations ever helpful?

They are useful for friend declarations.

> 
> > Source/WTF/wtf/NeverDestroyed.h:126
> >  using WTF::NeverDestroyed;
> 
> Should the plain old NeverDestroyed be reimplemented using LazyNeverDestroyed?

I had done that initially, but then I had to change all friend declarations to use LazyNeverDestroyed.
Comment 4 Anders Carlsson 2014-05-31 15:35:34 PDT
Created attachment 232323 [details]
Patch
Comment 5 Anders Carlsson 2014-05-31 16:32:54 PDT
Created attachment 232324 [details]
Patch
Comment 6 Anders Carlsson 2014-05-31 16:53:31 PDT
Created attachment 232326 [details]
Patch
Comment 7 Darin Adler 2014-05-31 20:52:37 PDT
Comment on attachment 232326 [details]
Patch

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

> Source/WebCore/workers/DefaultSharedWorkerRepository.h:60
> +        friend class LazyNeverDestroyed<DefaultSharedWorkerRepository>;

1>C:\cygwin\home\buildbot\WebKit\WebKitBuild\Release\include\private\wtf/NeverDestroyed.h(91): error C2248: 'WebCore::DefaultSharedWorkerRepository::DefaultSharedWorkerRepository' : cannot access private member declared in class 'WebCore::DefaultSharedWorkerRepository' (..\workers\DefaultSharedWorkerRepository.cpp)
                 c:\cygwin\home\buildbot\webkit\source\webcore\workers\DefaultSharedWorkerRepository.h(82) : see declaration of 'WebCore::DefaultSharedWorkerRepository::DefaultSharedWorkerRepository'
                 c:\cygwin\home\buildbot\webkit\source\webcore\workers\DefaultSharedWorkerRepository.h(58) : see declaration of 'WebCore::DefaultSharedWorkerRepository'
                 ..\workers\DefaultSharedWorkerRepository.cpp(337) : see reference to function template instantiation 'void WTF::LazyNeverDestroyed<WebCore::DefaultSharedWorkerRepository>::construct<>(void)' being compiled
                 ..\workers\DefaultSharedWorkerRepository.cpp(337) : see reference to function template instantiation 'void WTF::LazyNeverDestroyed<WebCore::DefaultSharedWorkerRepository>::construct<>(void)' being compiled
Comment 8 Anders Carlsson 2014-06-01 08:36:50 PDT
Created attachment 232344 [details]
Patch
Comment 9 Anders Carlsson 2014-06-01 10:15:04 PDT
Created attachment 232347 [details]
Patch
Comment 10 Anders Carlsson 2014-06-01 15:31:42 PDT
Committed r169518: <http://trac.webkit.org/changeset/169518>