Changeset 128138 in webkit
- Timestamp:
- Sep 10, 2012 6:22:17 PM (12 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r128137 r128138 1 2012-09-10 Adam Barth <abarth@chromium.org> 2 3 [V8] We don't us the global handle map for anything useful---let's remove it 4 https://bugs.webkit.org/show_bug.cgi?id=96343 5 6 Reviewed by Kentaro Hara. 7 8 The global handle map was a dream of tracking all the persistent V8 9 handles in WebCore. Unfortunately, it has never been complete, and I'm 10 not aware of us using it for anything. This patch removes what little 11 is left of it. 12 13 * bindings/v8/NPV8Object.cpp: 14 (WebCore::freeV8NPObject): 15 (WebCore::npCreateV8ScriptObject): 16 * bindings/v8/V8GCController.cpp: 17 (WebCore): 18 (WebCore::V8GCController::gcEpilogue): 19 (WebCore::V8GCController::collectGarbage): 20 * bindings/v8/V8GCController.h: 21 (V8GCController): 22 * bindings/v8/V8PerIsolateData.h: 23 (WebCore): 24 (V8PerIsolateData): 25 1 26 2012-09-10 John Bates <jbates@google.com> 2 27 -
trunk/Source/WebCore/bindings/v8/NPV8Object.cpp
r127757 r128138 103 103 } 104 104 105 #ifndef NDEBUG106 V8GCController::unregisterGlobalHandle(v8NpObject, v8NpObject->v8Object);107 #endif108 105 v8NpObject->v8Object.Dispose(); 109 106 free(v8NpObject); … … 177 174 V8NPObject* v8npObject = reinterpret_cast<V8NPObject*>(_NPN_CreateObject(npp, &V8NPObjectClass)); 178 175 v8npObject->v8Object = v8::Persistent<v8::Object>::New(object); 179 #ifndef NDEBUG180 V8GCController::registerGlobalHandle(NPOBJECT, v8npObject, v8npObject->v8Object);181 #endif182 176 v8npObject->rootObject = root; 183 177 -
trunk/Source/WebCore/bindings/v8/V8GCController.cpp
r126926 r128138 68 68 namespace WebCore { 69 69 70 #ifndef NDEBUG71 // Keeps track of global handles created (not JS wrappers72 // of DOM objects). Often these global handles are source73 // of leaks.74 //75 // If you want to let a C++ object hold a persistent handle76 // to a JS object, you should register the handle here to77 // keep track of leaks.78 //79 // When creating a persistent handle, call:80 //81 // #ifndef NDEBUG82 // V8GCController::registerGlobalHandle(type, host, handle);83 // #endif84 //85 // When releasing the handle, call:86 //87 // #ifndef NDEBUG88 // V8GCController::unregisterGlobalHandle(type, host, handle);89 // #endif90 //91 92 static GlobalHandleMap& currentGlobalHandleMap()93 {94 return V8PerIsolateData::current()->globalHandleMap();95 }96 97 // The function is the place to set the break point to inspect98 // live global handles. Leaks are often come from leaked global handles.99 static void enumerateGlobalHandles()100 {101 GlobalHandleMap& globalHandleMap = currentGlobalHandleMap();102 for (GlobalHandleMap::iterator it = globalHandleMap.begin(), end = globalHandleMap.end(); it != end; ++it) {103 GlobalHandleInfo* info = it->second;104 UNUSED_PARAM(info);105 v8::Value* handle = it->first;106 UNUSED_PARAM(handle);107 }108 }109 110 void V8GCController::registerGlobalHandle(GlobalHandleType type, void* host, v8::Persistent<v8::Value> handle)111 {112 GlobalHandleMap& globalHandleMap = currentGlobalHandleMap();113 ASSERT(!globalHandleMap.contains(*handle));114 globalHandleMap.set(*handle, new GlobalHandleInfo(host, type));115 }116 117 void V8GCController::unregisterGlobalHandle(void* host, v8::Persistent<v8::Value> handle)118 {119 GlobalHandleMap& globalHandleMap = currentGlobalHandleMap();120 ASSERT(globalHandleMap.contains(*handle));121 GlobalHandleInfo* info = globalHandleMap.take(*handle);122 ASSERT(info->m_host == host);123 delete info;124 }125 #endif // ifndef NDEBUG126 127 70 typedef HashMap<Node*, v8::Object*> DOMNodeMap; 128 71 typedef HashMap<void*, v8::Object*> DOMObjectMap; … … 476 419 int V8GCController::workingSetEstimateMB = 0; 477 420 478 namespace {479 480 481 } // anonymous namespace482 483 421 void V8GCController::gcEpilogue() 484 422 { … … 501 439 EnsureWeakDOMNodeVisitor weakDOMNodeVisitor; 502 440 visitDOMNodes(&weakDOMNodeVisitor); 503 504 enumerateGlobalHandles();505 441 #endif 506 442 … … 537 473 v8::HandleScope handleScope; 538 474 539 v8::Persistent<v8::Context> context = v8::Context::New(); 540 if (context.IsEmpty()) 475 ScopedPersistent<v8::Context> context; 476 477 context.adopt(v8::Context::New()); 478 if (context.isEmpty()) 541 479 return; 542 { 543 v8::Context::Scope scope(context); 480 481 { 482 v8::Context::Scope scope(context.get()); 544 483 v8::Local<v8::String> source = v8::String::New("if (gc) gc();"); 545 484 v8::Local<v8::String> name = v8::String::New("gc"); … … 550 489 } 551 490 } 552 context.Dispose(); 491 492 context.clear(); 553 493 } 554 494 -
trunk/Source/WebCore/bindings/v8/V8GCController.h
r126123 r128138 36 36 namespace WebCore { 37 37 38 #ifndef NDEBUG 38 class V8GCController { 39 public: 40 static void gcPrologue(); 41 static void gcEpilogue(); 39 42 40 #define GlobalHandleTypeList(V) \ 41 V(PROXY) \ 42 V(NPOBJECT) \ 43 V(SCHEDULED_ACTION) \ 44 V(EVENT_LISTENER) \ 45 V(NODE_FILTER) \ 46 V(SCRIPTINSTANCE) \ 47 V(SCRIPTVALUE) \ 48 V(DATASOURCE) 43 static void checkMemoryUsage(); 44 static void hintForCollectGarbage(); 45 static void collectGarbage(); 49 46 50 51 // Host information of persistent handles. 52 enum GlobalHandleType { 53 #define ENUM(name) name, 54 GlobalHandleTypeList(ENUM) 55 #undef ENUM 56 }; 57 58 class GlobalHandleInfo { 59 public: 60 GlobalHandleInfo(void* host, GlobalHandleType type) : m_host(host), m_type(type) { } 61 void* m_host; 62 GlobalHandleType m_type; 63 }; 64 65 #endif // NDEBUG 66 67 class V8GCController { 68 public: 69 #ifndef NDEBUG 70 // For debugging and leak detection purpose. 71 static void registerGlobalHandle(GlobalHandleType, void*, v8::Persistent<v8::Value>); 72 static void unregisterGlobalHandle(void*, v8::Persistent<v8::Value>); 73 #endif 74 75 static void gcPrologue(); 76 static void gcEpilogue(); 77 78 static void checkMemoryUsage(); 79 static void hintForCollectGarbage(); 80 static void collectGarbage(); 81 82 private: 83 // Estimate of current working set. 84 static int workingSetEstimateMB; 85 }; 47 private: 48 static int workingSetEstimateMB; 49 }; 86 50 87 51 } -
trunk/Source/WebCore/bindings/v8/V8PerIsolateData.h
r128127 r128138 48 48 49 49 typedef WTF::Vector<DOMDataStore*> DOMDataList; 50 51 #ifndef NDEBUG52 class GlobalHandleInfo;53 typedef HashMap<v8::Value*, GlobalHandleInfo*> GlobalHandleMap;54 #endif55 50 56 51 class V8PerIsolateData { … … 112 107 113 108 #ifndef NDEBUG 114 GlobalHandleMap& globalHandleMap() { return m_globalHandleMap; }115 116 109 int internalScriptRecursionLevel() const { return m_internalScriptRecursionLevel; } 117 110 int incrementInternalScriptRecursionLevel() { return ++m_internalScriptRecursionLevel; } … … 156 149 157 150 #ifndef NDEBUG 158 GlobalHandleMap m_globalHandleMap;159 151 int m_internalScriptRecursionLevel; 160 152 #endif
Note: See TracChangeset
for help on using the changeset viewer.