Ignore:
Timestamp:
Apr 27, 2012, 10:57:46 PM (13 years ago)
Author:
[email protected]
Message:

Made WeakSet::allocate() static and removed its JSGlobalData argument
https://bugs.webkit.org/show_bug.cgi?id=85128

Reviewed by Anders Carlsson.

../JavaScriptCore:

This is a step toward faster finalization.

WeakSet::allocate() now deduces which WeakSet to allocate from based on
its JSCell* argument. (Currently, there's only one WeakSet, but soon
there will be many.)

This was a global replace of "globalData.heap.weakSet()->allocate" with
"WeakSet::allocate", plus by-hand removal of the JSGlobalData argument.

  • heap/WeakSetInlines.h: Copied from Source/JavaScriptCore/heap/WeakSet.h.

I had to split out WeakSet::allocate() in to a separate header to avoid
a cycle.

(JSC::WeakSet::allocate): We can mask the pointer we're passed to
figure out where to allocate our WeakImpl. (Soon, we'll use this to
associate the WeakImpl with the GC block it references.)

../WebCore:

Mechanically removed JSGlobalData arguments from PassWeak<T> and Weak<T> allocation.

  • bindings/js/JSDOMBinding.cpp:

(WebCore::jsStringSlowCase):

  • bindings/js/JSEventListener.h:

(WebCore::JSEventListener::setWrapper):

  • bindings/js/JSNodeFilterCondition.cpp:

(WebCore::JSNodeFilterCondition::JSNodeFilterCondition):

  • bindings/js/ScriptWrappable.h:

(WebCore::ScriptWrappable::setWrapper):

  • bridge/jsc/BridgeJSC.cpp:

(JSC::Bindings::Instance::createRuntimeObject):

  • bridge/qt/qt_runtime.cpp:

(JSC::Bindings::QtRuntimeMethod::finishCreation):

  • bridge/runtime_root.cpp:

(JSC::Bindings::RootObject::addRuntimeObject):

../WebKit2:

Mechanically removed JSGlobalData arguments from PassWeak<T> and Weak<T> allocation.

  • WebProcess/Plugins/Netscape/NPRuntimeObjectMap.cpp:

(WebKit::NPRuntimeObjectMap::getOrCreateJSObject):

File:
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/heap/WeakSetInlines.h

    r115538 r115545  
    2424 */
    2525
    26 #ifndef WeakSet_h
    27 #define WeakSet_h
     26#ifndef WeakSetInlines_h
     27#define WeakSetInlines_h
    2828
    29 #include "WeakBlock.h"
     29#include "WeakSet.h"
    3030
    3131namespace JSC {
    3232
    33 class Heap;
    34 class WeakImpl;
    35 
    36 class WeakSet {
    37 public:
    38     WeakSet(Heap*);
    39     void finalizeAll();
    40     ~WeakSet();
    41 
    42     WeakImpl* allocate(JSValue, WeakHandleOwner* = 0, void* context = 0);
    43     static void deallocate(WeakImpl*);
    44 
    45     void visitLiveWeakImpls(HeapRootVisitor&);
    46     void visitDeadWeakImpls(HeapRootVisitor&);
    47 
    48     void sweep();
    49     void resetAllocator();
    50 
    51     void shrink();
    52 
    53 private:
    54     JS_EXPORT_PRIVATE WeakBlock::FreeCell* findAllocator();
    55     WeakBlock::FreeCell* tryFindAllocator();
    56     WeakBlock::FreeCell* addAllocator();
    57     void removeAllocator(WeakBlock*);
    58 
    59     WeakBlock::FreeCell* m_allocator;
    60     WeakBlock* m_nextAllocator;
    61     DoublyLinkedList<WeakBlock> m_blocks;
    62     Heap* m_heap;
    63 };
    64 
    65 inline WeakSet::WeakSet(Heap* heap)
    66     : m_allocator(0)
    67     , m_nextAllocator(0)
    68     , m_heap(heap)
    69 {
    70 }
    71 
    7233inline WeakImpl* WeakSet::allocate(JSValue jsValue, WeakHandleOwner* weakHandleOwner, void* context)
    7334{
    74     WeakBlock::FreeCell* allocator = m_allocator;
     35    WeakSet& weakSet = *Heap::heap(jsValue.asCell())->weakSet();
     36    WeakBlock::FreeCell* allocator = weakSet.m_allocator;
    7537    if (UNLIKELY(!allocator))
    76         allocator = findAllocator();
    77     m_allocator = allocator->next;
     38        allocator = weakSet.findAllocator();
     39    weakSet.m_allocator = allocator->next;
    7840
    7941    WeakImpl* weakImpl = WeakBlock::asWeakImpl(allocator);
     
    8143}
    8244
    83 inline void WeakSet::deallocate(WeakImpl* weakImpl)
    84 {
    85     weakImpl->setState(WeakImpl::Deallocated);
    86 }
    87 
    8845} // namespace JSC
    8946
    90 #endif // WeakSet_h
     47#endif // WeakSetInlines_h
Note: See TracChangeset for help on using the changeset viewer.