Changeset 181214 in webkit


Ignore:
Timestamp:
Mar 7, 2015, 2:20:54 PM (10 years ago)
Author:
commit-queue@webkit.org
Message:

Unreviewed, rolling out r181010.
https://bugs.webkit.org/show_bug.cgi?id=142442

Broke media/video-src-invalid-poster.html (Requested by kling
on #webkit).

Reverted changeset:

"Stale entries in WeakGCMaps are keeping tons of WeakBlocks
alive unnecessarily."
https://bugs.webkit.org/show_bug.cgi?id=142115
http://trac.webkit.org/changeset/181010

Location:
trunk/Source
Files:
2 deleted
16 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/API/JSWeakObjectMapRefInternal.h

    r181010 r181214  
    4242struct OpaqueJSWeakObjectMap : public RefCounted<OpaqueJSWeakObjectMap> {
    4343public:
    44     static Ref<OpaqueJSWeakObjectMap> create(JSC::VM& vm, void* data, JSWeakMapDestroyedCallback callback)
     44    static PassRefPtr<OpaqueJSWeakObjectMap> create(void* data, JSWeakMapDestroyedCallback callback)
    4545    {
    46         return adoptRef(*new OpaqueJSWeakObjectMap(vm, data, callback));
     46        return adoptRef(new OpaqueJSWeakObjectMap(data, callback));
    4747    }
    4848
     
    5555
    5656private:
    57     OpaqueJSWeakObjectMap(JSC::VM& vm, void* data, JSWeakMapDestroyedCallback callback)
    58         : m_map(vm)
    59         , m_data(data)
     57    OpaqueJSWeakObjectMap(void* data, JSWeakMapDestroyedCallback callback)
     58        : m_data(data)
    6059        , m_callback(callback)
    6160    {
  • trunk/Source/JavaScriptCore/API/JSWeakObjectMapRefPrivate.cpp

    r181010 r181214  
    3333#include "JSCInlines.h"
    3434#include "Weak.h"
    35 #include "WeakGCMapInlines.h"
    3635#include <wtf/HashMap.h>
    3736#include <wtf/text/StringHash.h>
     
    4847    ExecState* exec = toJS(context);
    4948    JSLockHolder locker(exec);
    50     RefPtr<OpaqueJSWeakObjectMap> map = OpaqueJSWeakObjectMap::create(exec->vm(), privateData, callback);
     49    RefPtr<OpaqueJSWeakObjectMap> map = OpaqueJSWeakObjectMap::create(privateData, callback);
    5150    exec->lexicalGlobalObject()->registerWeakMap(map.get());
    5251    return map.get();
  • trunk/Source/JavaScriptCore/API/JSWrapperMap.mm

    r181010 r181214  
    3838#import "ObjcRuntimeExtras.h"
    3939#import "WeakGCMap.h"
    40 #import "WeakGCMapInlines.h"
    4140#import <wtf/HashSet.h>
    4241#import <wtf/TCSpinLock.h>
     
    548547    JSContext *m_context;
    549548    NSMutableDictionary *m_classMap;
    550     std::unique_ptr<JSC::WeakGCMap<id, JSC::JSObject>> m_cachedJSWrappers;
     549    JSC::WeakGCMap<id, JSC::JSObject> m_cachedJSWrappers;
    551550    NSMapTable *m_cachedObjCWrappers;
    552551}
     
    561560    NSPointerFunctionsOptions valueOptions = NSPointerFunctionsWeakMemory | NSPointerFunctionsObjectPersonality;
    562561    m_cachedObjCWrappers = [[NSMapTable alloc] initWithKeyOptions:keyOptions valueOptions:valueOptions capacity:0];
    563 
    564     m_cachedJSWrappers = std::make_unique<JSC::WeakGCMap<id, JSC::JSObject>>(toJS([context JSGlobalContextRef])->vm());
    565 
     562   
    566563    m_context = context;
    567564    m_classMap = [[NSMutableDictionary alloc] init];
     
    594591- (JSValue *)jsWrapperForObject:(id)object
    595592{
    596     JSC::JSObject* jsWrapper = m_cachedJSWrappers->get(object);
     593    JSC::JSObject* jsWrapper = m_cachedJSWrappers.get(object);
    597594    if (jsWrapper)
    598595        return [JSValue valueWithJSValueRef:toRef(jsWrapper) inContext:m_context];
     
    610607    // (2) A long lived object may rack up many JSValues. When the contexts are released these will unprotect the associated JavaScript objects,
    611608    //     but still, would probably nicer if we made it so that only one associated object was required, broadcasting object dealloc.
    612     m_cachedJSWrappers->set(object, jsWrapper);
     609    m_cachedJSWrappers.set(object, jsWrapper);
    613610    return [JSValue valueWithJSValueRef:toRef(jsWrapper) inContext:m_context];
    614611}
  • trunk/Source/JavaScriptCore/ChangeLog

    r181213 r181214  
     12015-03-07  Commit Queue  <commit-queue@webkit.org>
     2
     3        Unreviewed, rolling out r181010.
     4        https://bugs.webkit.org/show_bug.cgi?id=142442
     5
     6        Broke media/video-src-invalid-poster.html (Requested by kling
     7        on #webkit).
     8
     9        Reverted changeset:
     10
     11        "Stale entries in WeakGCMaps are keeping tons of WeakBlocks
     12        alive unnecessarily."
     13        https://bugs.webkit.org/show_bug.cgi?id=142115
     14        http://trac.webkit.org/changeset/181010
     15
    1162015-03-07  Ryosuke Niwa  <rniwa@webkit.org>
    217
  • trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj

    r181084 r181214  
    14361436                A7FCC26D17A0B6AA00786D1A /* FTLSwitchCase.h in Headers */ = {isa = PBXBuildFile; fileRef = A7FCC26C17A0B6AA00786D1A /* FTLSwitchCase.h */; settings = {ATTRIBUTES = (Private, ); }; };
    14371437                A8A4748E151A8306004123FF /* libWTF.a in Frameworks */ = {isa = PBXBuildFile; fileRef = A8A4748D151A8306004123FF /* libWTF.a */; };
    1438                 AD86A93E1AA4D88D002FE77F /* WeakGCMapInlines.h in Headers */ = {isa = PBXBuildFile; fileRef = AD86A93D1AA4D87C002FE77F /* WeakGCMapInlines.h */; settings = {ATTRIBUTES = (Private, ); }; };
    14391438                ADDB1F6318D77DBE009B58A8 /* OpaqueRootSet.h in Headers */ = {isa = PBXBuildFile; fileRef = ADDB1F6218D77DB7009B58A8 /* OpaqueRootSet.h */; settings = {ATTRIBUTES = (Private, ); }; };
    14401439                ADE39FFF16DD144B0003CD4A /* PropertyTable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AD1CF06816DCAB2D00B97123 /* PropertyTable.cpp */; };
     
    31623161                A8E894330CD0603F00367179 /* JSGlobalObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSGlobalObject.h; sourceTree = "<group>"; };
    31633162                AD1CF06816DCAB2D00B97123 /* PropertyTable.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PropertyTable.cpp; sourceTree = "<group>"; };
    3164                 AD86A93D1AA4D87C002FE77F /* WeakGCMapInlines.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WeakGCMapInlines.h; sourceTree = "<group>"; };
    31653163                ADDB1F6218D77DB7009B58A8 /* OpaqueRootSet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OpaqueRootSet.h; sourceTree = "<group>"; };
    31663164                B59F89371891AD3300D5CCDC /* UnlinkedInstructionStream.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UnlinkedInstructionStream.h; sourceTree = "<group>"; };
     
    46534651                                FED94F2D171E3E2300BE77A4 /* WatchdogMac.cpp */,
    46544652                                14BFCE6810CDB1FC00364CCE /* WeakGCMap.h */,
    4655                                 AD86A93D1AA4D87C002FE77F /* WeakGCMapInlines.h */,
    46564653                                A7CA3ADD17DA41AE006538AF /* WeakMapConstructor.cpp */,
    46574654                                A7CA3ADE17DA41AE006538AF /* WeakMapConstructor.h */,
     
    55495546                                0F8023EA1613832B00A0BA45 /* ByValInfo.h in Headers */,
    55505547                                BC18C3ED0E16F5CD00B34460 /* CallData.h in Headers */,
    5551                                 AD86A93E1AA4D88D002FE77F /* WeakGCMapInlines.h in Headers */,
    55525548                                1429D8DE0ED2205B00B89619 /* CallFrame.h in Headers */,
    55535549                                A7C1EAEF17987AB600299DB2 /* CallFrameInlines.h in Headers */,
  • trunk/Source/JavaScriptCore/heap/Heap.cpp

    r181060 r181214  
    10671067
    10681068    reapWeakHandles();
    1069     pruneStaleEntriesFromWeakGCMaps();
    10701069    sweepArrayBuffers();
    10711070    snapshotMarkedSpace();
     
    11791178    GCPHASE(ReapingWeakHandles);
    11801179    m_objectSpace.reapWeakSets();
    1181 }
    1182 
    1183 void Heap::pruneStaleEntriesFromWeakGCMaps()
    1184 {
    1185     GCPHASE(PruningStaleEntriesFromWeakGCMaps);
    1186     if (m_operationInProgress != FullCollection)
    1187         return;
    1188     for (auto& pruneCallback : m_weakGCMaps.values())
    1189         pruneCallback();
    11901180}
    11911181
  • trunk/Source/JavaScriptCore/heap/Heap.h

    r181060 r181214  
    229229
    230230    static bool isZombified(JSCell* cell) { return *(void**)cell == zombifiedBits; }
    231 
    232     void registerWeakGCMap(void* weakGCMap, std::function<void()> pruningCallback);
    233     void unregisterWeakGCMap(void* weakGCMap);
    234231
    235232private:
     
    307304
    308305    void reapWeakHandles();
    309     void pruneStaleEntriesFromWeakGCMaps();
    310306    void sweepArrayBuffers();
    311307    void snapshotMarkedSpace();
     
    401397    unsigned m_delayedReleaseRecursionCount;
    402398#endif
    403 
    404     HashMap<void*, std::function<void()>> m_weakGCMaps;
    405399};
    406400
  • trunk/Source/JavaScriptCore/heap/HeapInlines.h

    r181019 r181214  
    320320    return *m_markListSet;
    321321}
    322 
    323 inline void Heap::registerWeakGCMap(void* weakGCMap, std::function<void()> pruningCallback)
    324 {
    325     m_weakGCMaps.add(weakGCMap, WTF::move(pruningCallback));
    326 }
    327 
    328 inline void Heap::unregisterWeakGCMap(void* weakGCMap)
    329 {
    330     m_weakGCMaps.remove(weakGCMap);
    331 }
    332322   
    333323} // namespace JSC
  • trunk/Source/JavaScriptCore/runtime/JSCInlines.h

    r181010 r181214  
    5252#include "SlotVisitorInlines.h"
    5353#include "StructureInlines.h"
    54 #include "WeakGCMapInlines.h"
    5554
    5655#endif // JSCInlines_h
  • trunk/Source/JavaScriptCore/runtime/JSGlobalObject.cpp

    r181084 r181214  
    124124#include "SymbolPrototype.h"
    125125#include "VariableWatchpointSetInlines.h"
    126 #include "WeakGCMapInlines.h"
    127126#include "WeakMapConstructor.h"
    128127#include "WeakMapPrototype.h"
  • trunk/Source/JavaScriptCore/runtime/PrototypeMap.h

    r181010 r181214  
    3434class JSObject;
    3535class Structure;
    36 class VM;
    3736
    3837// Tracks the canonical structure an object should be allocated with when inheriting from a given prototype.
    3938class PrototypeMap {
    4039public:
    41     explicit PrototypeMap(VM& vm)
    42         : m_prototypes(vm)
    43         , m_structures(vm)
    44     {
    45     }
    46 
    4740    JS_EXPORT_PRIVATE Structure* emptyObjectStructureForPrototype(JSObject*, unsigned inlineCapacity);
    4841    void clearEmptyObjectStructureForPrototype(JSObject*, unsigned inlineCapacity);
  • trunk/Source/JavaScriptCore/runtime/Structure.cpp

    r181010 r181214  
    3737#include "StructureChain.h"
    3838#include "StructureRareDataInlines.h"
    39 #include "WeakGCMapInlines.h"
    4039#include <wtf/CommaPrinter.h>
    4140#include <wtf/ProcessID.h>
     
    9291        // This handles the second transition being added
    9392        // (or the first transition being despecified!)
    94         setMap(new TransitionMap(vm));
     93        setMap(new TransitionMap());
    9594        add(vm, existingTransition);
    9695    }
  • trunk/Source/JavaScriptCore/runtime/VM.cpp

    r181077 r181214  
    8484#include "TypeProfilerLog.h"
    8585#include "UnlinkedCodeBlock.h"
    86 #include "WeakGCMapInlines.h"
    8786#include "WeakMapData.h"
    8887#include <wtf/ProcessID.h>
     
    155154    , propertyNames(nullptr)
    156155    , emptyList(new MarkedArgumentBuffer)
    157     , stringCache(*this)
    158     , prototypeMap(*this)
    159156    , keywords(std::make_unique<Keywords>(*this))
    160157    , interpreter(0)
  • trunk/Source/JavaScriptCore/runtime/WeakGCMap.h

    r181010 r181214  
    11/*
    2  * Copyright (C) 2009, 2015 Apple Inc. All rights reserved.
     2 * Copyright (C) 2009 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    4848    typedef typename HashMapType::const_iterator const_iterator;
    4949
    50     explicit WeakGCMap(VM&);
    51     ~WeakGCMap();
     50    WeakGCMap()
     51        : m_gcThreshold(minGCThreshold)
     52    {
     53    }
    5254
    5355    ValueArg* get(const KeyType& key) const
     
    5860    AddResult set(const KeyType& key, ValueType value)
    5961    {
     62        gcMapIfNeeded();
    6063        return m_map.set(key, WTF::move(value));
    6164    }
     
    6366    ALWAYS_INLINE AddResult add(const KeyType& key, ValueType value)
    6467    {
     68        gcMapIfNeeded();
    6569        AddResult addResult = m_map.fastAdd(key, nullptr);
    6670        if (!addResult.iterator->value) { // New value or found a zombie value.
     
    100104    }
    101105
    102     void pruneStaleEntries();
     106private:
     107    static const int minGCThreshold = 3;
    103108
    104 private:
     109    NEVER_INLINE void gcMap()
     110    {
     111        Vector<KeyType, 4> zombies;
     112
     113        for (iterator it = m_map.begin(), end = m_map.end(); it != end; ++it) {
     114            if (!it->value)
     115                zombies.append(it->key);
     116        }
     117
     118        for (size_t i = 0; i < zombies.size(); ++i)
     119            m_map.remove(zombies[i]);
     120    }
     121
     122    void gcMapIfNeeded()
     123    {
     124        if (m_map.size() < m_gcThreshold)
     125            return;
     126
     127        gcMap();
     128        m_gcThreshold = std::max(minGCThreshold, m_map.size() * 2 - 1);
     129    }
     130
    105131    HashMapType m_map;
    106     VM& m_vm;
     132    int m_gcThreshold;
    107133};
     134
     135template<typename KeyArg, typename RawMappedArg, typename HashArg, typename KeyTraitsArg>
     136const int WeakGCMap<KeyArg, RawMappedArg, HashArg, KeyTraitsArg>::minGCThreshold;
    108137
    109138} // namespace JSC
  • trunk/Source/WebCore/ChangeLog

    r181212 r181214  
     12015-03-07  Commit Queue  <commit-queue@webkit.org>
     2
     3        Unreviewed, rolling out r181010.
     4        https://bugs.webkit.org/show_bug.cgi?id=142442
     5
     6        Broke media/video-src-invalid-poster.html (Requested by kling
     7        on #webkit).
     8
     9        Reverted changeset:
     10
     11        "Stale entries in WeakGCMaps are keeping tons of WeakBlocks
     12        alive unnecessarily."
     13        https://bugs.webkit.org/show_bug.cgi?id=142115
     14        http://trac.webkit.org/changeset/181010
     15
    1162015-03-07  Darin Adler  <darin@apple.com>
    217
  • trunk/Source/WebCore/bindings/js/ScriptCachedFrameData.cpp

    r181010 r181214  
    3939#include "PageConsoleClient.h"
    4040#include "PageGroup.h"
    41 #include "ScriptController.h"
    4241#include <heap/StrongInlines.h>
    4342#include <profiler/Profile.h>
    4443#include <runtime/JSLock.h>
    45 #include <runtime/WeakGCMapInlines.h>
     44#include "ScriptController.h"
    4645
    4746using namespace JSC;
Note: See TracChangeset for help on using the changeset viewer.