Changeset 181214 in webkit
- Timestamp:
- Mar 7, 2015, 2:20:54 PM (10 years ago)
- Location:
- trunk/Source
- Files:
-
- 2 deleted
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/API/JSWeakObjectMapRefInternal.h
r181010 r181214 42 42 struct OpaqueJSWeakObjectMap : public RefCounted<OpaqueJSWeakObjectMap> { 43 43 public: 44 static Ref<OpaqueJSWeakObjectMap> create(JSC::VM& vm,void* data, JSWeakMapDestroyedCallback callback)44 static PassRefPtr<OpaqueJSWeakObjectMap> create(void* data, JSWeakMapDestroyedCallback callback) 45 45 { 46 return adoptRef( *new OpaqueJSWeakObjectMap(vm,data, callback));46 return adoptRef(new OpaqueJSWeakObjectMap(data, callback)); 47 47 } 48 48 … … 55 55 56 56 private: 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) 60 59 , m_callback(callback) 61 60 { -
trunk/Source/JavaScriptCore/API/JSWeakObjectMapRefPrivate.cpp
r181010 r181214 33 33 #include "JSCInlines.h" 34 34 #include "Weak.h" 35 #include "WeakGCMapInlines.h"36 35 #include <wtf/HashMap.h> 37 36 #include <wtf/text/StringHash.h> … … 48 47 ExecState* exec = toJS(context); 49 48 JSLockHolder locker(exec); 50 RefPtr<OpaqueJSWeakObjectMap> map = OpaqueJSWeakObjectMap::create( exec->vm(),privateData, callback);49 RefPtr<OpaqueJSWeakObjectMap> map = OpaqueJSWeakObjectMap::create(privateData, callback); 51 50 exec->lexicalGlobalObject()->registerWeakMap(map.get()); 52 51 return map.get(); -
trunk/Source/JavaScriptCore/API/JSWrapperMap.mm
r181010 r181214 38 38 #import "ObjcRuntimeExtras.h" 39 39 #import "WeakGCMap.h" 40 #import "WeakGCMapInlines.h"41 40 #import <wtf/HashSet.h> 42 41 #import <wtf/TCSpinLock.h> … … 548 547 JSContext *m_context; 549 548 NSMutableDictionary *m_classMap; 550 std::unique_ptr<JSC::WeakGCMap<id, JSC::JSObject>> m_cachedJSWrappers;549 JSC::WeakGCMap<id, JSC::JSObject> m_cachedJSWrappers; 551 550 NSMapTable *m_cachedObjCWrappers; 552 551 } … … 561 560 NSPointerFunctionsOptions valueOptions = NSPointerFunctionsWeakMemory | NSPointerFunctionsObjectPersonality; 562 561 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 566 563 m_context = context; 567 564 m_classMap = [[NSMutableDictionary alloc] init]; … … 594 591 - (JSValue *)jsWrapperForObject:(id)object 595 592 { 596 JSC::JSObject* jsWrapper = m_cachedJSWrappers ->get(object);593 JSC::JSObject* jsWrapper = m_cachedJSWrappers.get(object); 597 594 if (jsWrapper) 598 595 return [JSValue valueWithJSValueRef:toRef(jsWrapper) inContext:m_context]; … … 610 607 // (2) A long lived object may rack up many JSValues. When the contexts are released these will unprotect the associated JavaScript objects, 611 608 // 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); 613 610 return [JSValue valueWithJSValueRef:toRef(jsWrapper) inContext:m_context]; 614 611 } -
trunk/Source/JavaScriptCore/ChangeLog
r181213 r181214 1 2015-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 1 16 2015-03-07 Ryosuke Niwa <rniwa@webkit.org> 2 17 -
trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
r181084 r181214 1436 1436 A7FCC26D17A0B6AA00786D1A /* FTLSwitchCase.h in Headers */ = {isa = PBXBuildFile; fileRef = A7FCC26C17A0B6AA00786D1A /* FTLSwitchCase.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1437 1437 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, ); }; };1439 1438 ADDB1F6318D77DBE009B58A8 /* OpaqueRootSet.h in Headers */ = {isa = PBXBuildFile; fileRef = ADDB1F6218D77DB7009B58A8 /* OpaqueRootSet.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1440 1439 ADE39FFF16DD144B0003CD4A /* PropertyTable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AD1CF06816DCAB2D00B97123 /* PropertyTable.cpp */; }; … … 3162 3161 A8E894330CD0603F00367179 /* JSGlobalObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSGlobalObject.h; sourceTree = "<group>"; }; 3163 3162 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>"; };3165 3163 ADDB1F6218D77DB7009B58A8 /* OpaqueRootSet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OpaqueRootSet.h; sourceTree = "<group>"; }; 3166 3164 B59F89371891AD3300D5CCDC /* UnlinkedInstructionStream.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UnlinkedInstructionStream.h; sourceTree = "<group>"; }; … … 4653 4651 FED94F2D171E3E2300BE77A4 /* WatchdogMac.cpp */, 4654 4652 14BFCE6810CDB1FC00364CCE /* WeakGCMap.h */, 4655 AD86A93D1AA4D87C002FE77F /* WeakGCMapInlines.h */,4656 4653 A7CA3ADD17DA41AE006538AF /* WeakMapConstructor.cpp */, 4657 4654 A7CA3ADE17DA41AE006538AF /* WeakMapConstructor.h */, … … 5549 5546 0F8023EA1613832B00A0BA45 /* ByValInfo.h in Headers */, 5550 5547 BC18C3ED0E16F5CD00B34460 /* CallData.h in Headers */, 5551 AD86A93E1AA4D88D002FE77F /* WeakGCMapInlines.h in Headers */,5552 5548 1429D8DE0ED2205B00B89619 /* CallFrame.h in Headers */, 5553 5549 A7C1EAEF17987AB600299DB2 /* CallFrameInlines.h in Headers */, -
trunk/Source/JavaScriptCore/heap/Heap.cpp
r181060 r181214 1067 1067 1068 1068 reapWeakHandles(); 1069 pruneStaleEntriesFromWeakGCMaps();1070 1069 sweepArrayBuffers(); 1071 1070 snapshotMarkedSpace(); … … 1179 1178 GCPHASE(ReapingWeakHandles); 1180 1179 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();1190 1180 } 1191 1181 -
trunk/Source/JavaScriptCore/heap/Heap.h
r181060 r181214 229 229 230 230 static bool isZombified(JSCell* cell) { return *(void**)cell == zombifiedBits; } 231 232 void registerWeakGCMap(void* weakGCMap, std::function<void()> pruningCallback);233 void unregisterWeakGCMap(void* weakGCMap);234 231 235 232 private: … … 307 304 308 305 void reapWeakHandles(); 309 void pruneStaleEntriesFromWeakGCMaps();310 306 void sweepArrayBuffers(); 311 307 void snapshotMarkedSpace(); … … 401 397 unsigned m_delayedReleaseRecursionCount; 402 398 #endif 403 404 HashMap<void*, std::function<void()>> m_weakGCMaps;405 399 }; 406 400 -
trunk/Source/JavaScriptCore/heap/HeapInlines.h
r181019 r181214 320 320 return *m_markListSet; 321 321 } 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 }332 322 333 323 } // namespace JSC -
trunk/Source/JavaScriptCore/runtime/JSCInlines.h
r181010 r181214 52 52 #include "SlotVisitorInlines.h" 53 53 #include "StructureInlines.h" 54 #include "WeakGCMapInlines.h"55 54 56 55 #endif // JSCInlines_h -
trunk/Source/JavaScriptCore/runtime/JSGlobalObject.cpp
r181084 r181214 124 124 #include "SymbolPrototype.h" 125 125 #include "VariableWatchpointSetInlines.h" 126 #include "WeakGCMapInlines.h"127 126 #include "WeakMapConstructor.h" 128 127 #include "WeakMapPrototype.h" -
trunk/Source/JavaScriptCore/runtime/PrototypeMap.h
r181010 r181214 34 34 class JSObject; 35 35 class Structure; 36 class VM;37 36 38 37 // Tracks the canonical structure an object should be allocated with when inheriting from a given prototype. 39 38 class PrototypeMap { 40 39 public: 41 explicit PrototypeMap(VM& vm)42 : m_prototypes(vm)43 , m_structures(vm)44 {45 }46 47 40 JS_EXPORT_PRIVATE Structure* emptyObjectStructureForPrototype(JSObject*, unsigned inlineCapacity); 48 41 void clearEmptyObjectStructureForPrototype(JSObject*, unsigned inlineCapacity); -
trunk/Source/JavaScriptCore/runtime/Structure.cpp
r181010 r181214 37 37 #include "StructureChain.h" 38 38 #include "StructureRareDataInlines.h" 39 #include "WeakGCMapInlines.h"40 39 #include <wtf/CommaPrinter.h> 41 40 #include <wtf/ProcessID.h> … … 92 91 // This handles the second transition being added 93 92 // (or the first transition being despecified!) 94 setMap(new TransitionMap( vm));93 setMap(new TransitionMap()); 95 94 add(vm, existingTransition); 96 95 } -
trunk/Source/JavaScriptCore/runtime/VM.cpp
r181077 r181214 84 84 #include "TypeProfilerLog.h" 85 85 #include "UnlinkedCodeBlock.h" 86 #include "WeakGCMapInlines.h"87 86 #include "WeakMapData.h" 88 87 #include <wtf/ProcessID.h> … … 155 154 , propertyNames(nullptr) 156 155 , emptyList(new MarkedArgumentBuffer) 157 , stringCache(*this)158 , prototypeMap(*this)159 156 , keywords(std::make_unique<Keywords>(*this)) 160 157 , interpreter(0) -
trunk/Source/JavaScriptCore/runtime/WeakGCMap.h
r181010 r181214 1 1 /* 2 * Copyright (C) 2009 , 2015Apple Inc. All rights reserved.2 * Copyright (C) 2009 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 48 48 typedef typename HashMapType::const_iterator const_iterator; 49 49 50 explicit WeakGCMap(VM&); 51 ~WeakGCMap(); 50 WeakGCMap() 51 : m_gcThreshold(minGCThreshold) 52 { 53 } 52 54 53 55 ValueArg* get(const KeyType& key) const … … 58 60 AddResult set(const KeyType& key, ValueType value) 59 61 { 62 gcMapIfNeeded(); 60 63 return m_map.set(key, WTF::move(value)); 61 64 } … … 63 66 ALWAYS_INLINE AddResult add(const KeyType& key, ValueType value) 64 67 { 68 gcMapIfNeeded(); 65 69 AddResult addResult = m_map.fastAdd(key, nullptr); 66 70 if (!addResult.iterator->value) { // New value or found a zombie value. … … 100 104 } 101 105 102 void pruneStaleEntries(); 106 private: 107 static const int minGCThreshold = 3; 103 108 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 105 131 HashMapType m_map; 106 VM& m_vm;132 int m_gcThreshold; 107 133 }; 134 135 template<typename KeyArg, typename RawMappedArg, typename HashArg, typename KeyTraitsArg> 136 const int WeakGCMap<KeyArg, RawMappedArg, HashArg, KeyTraitsArg>::minGCThreshold; 108 137 109 138 } // namespace JSC -
trunk/Source/WebCore/ChangeLog
r181212 r181214 1 2015-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 1 16 2015-03-07 Darin Adler <darin@apple.com> 2 17 -
trunk/Source/WebCore/bindings/js/ScriptCachedFrameData.cpp
r181010 r181214 39 39 #include "PageConsoleClient.h" 40 40 #include "PageGroup.h" 41 #include "ScriptController.h"42 41 #include <heap/StrongInlines.h> 43 42 #include <profiler/Profile.h> 44 43 #include <runtime/JSLock.h> 45 #include <runtime/WeakGCMapInlines.h>44 #include "ScriptController.h" 46 45 47 46 using namespace JSC;
Note:
See TracChangeset
for help on using the changeset viewer.