- Revision
- 128138
- Author
- [email protected]
- Date
- 2012-09-10 18:22:17 -0700 (Mon, 10 Sep 2012)
Log Message
[V8] We don't us the global handle map for anything useful---let's remove it
https://bugs.webkit.org/show_bug.cgi?id=96343
Patch by Adam Barth <[email protected]> on 2012-09-10
Reviewed by Kentaro Hara.
The global handle map was a dream of tracking all the persistent V8
handles in WebCore. Unfortunately, it has never been complete, and I'm
not aware of us using it for anything. This patch removes what little
is left of it.
* bindings/v8/NPV8Object.cpp:
(WebCore::freeV8NPObject):
(WebCore::npCreateV8ScriptObject):
* bindings/v8/V8GCController.cpp:
(WebCore):
(WebCore::V8GCController::gcEpilogue):
(WebCore::V8GCController::collectGarbage):
* bindings/v8/V8GCController.h:
(V8GCController):
* bindings/v8/V8PerIsolateData.h:
(WebCore):
(V8PerIsolateData):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (128137 => 128138)
--- trunk/Source/WebCore/ChangeLog 2012-09-11 01:19:31 UTC (rev 128137)
+++ trunk/Source/WebCore/ChangeLog 2012-09-11 01:22:17 UTC (rev 128138)
@@ -1,3 +1,28 @@
+2012-09-10 Adam Barth <[email protected]>
+
+ [V8] We don't us the global handle map for anything useful---let's remove it
+ https://bugs.webkit.org/show_bug.cgi?id=96343
+
+ Reviewed by Kentaro Hara.
+
+ The global handle map was a dream of tracking all the persistent V8
+ handles in WebCore. Unfortunately, it has never been complete, and I'm
+ not aware of us using it for anything. This patch removes what little
+ is left of it.
+
+ * bindings/v8/NPV8Object.cpp:
+ (WebCore::freeV8NPObject):
+ (WebCore::npCreateV8ScriptObject):
+ * bindings/v8/V8GCController.cpp:
+ (WebCore):
+ (WebCore::V8GCController::gcEpilogue):
+ (WebCore::V8GCController::collectGarbage):
+ * bindings/v8/V8GCController.h:
+ (V8GCController):
+ * bindings/v8/V8PerIsolateData.h:
+ (WebCore):
+ (V8PerIsolateData):
+
2012-09-10 John Bates <[email protected]>
[chromium] Fix trace event macro naming issue
Modified: trunk/Source/WebCore/bindings/v8/NPV8Object.cpp (128137 => 128138)
--- trunk/Source/WebCore/bindings/v8/NPV8Object.cpp 2012-09-11 01:19:31 UTC (rev 128137)
+++ trunk/Source/WebCore/bindings/v8/NPV8Object.cpp 2012-09-11 01:22:17 UTC (rev 128138)
@@ -102,9 +102,6 @@
staticV8NPObjectMap()->clear();
}
-#ifndef NDEBUG
- V8GCController::unregisterGlobalHandle(v8NpObject, v8NpObject->v8Object);
-#endif
v8NpObject->v8Object.Dispose();
free(v8NpObject);
}
@@ -176,9 +173,6 @@
V8NPObject* v8npObject = reinterpret_cast<V8NPObject*>(_NPN_CreateObject(npp, &V8NPObjectClass));
v8npObject->v8Object = v8::Persistent<v8::Object>::New(object);
-#ifndef NDEBUG
- V8GCController::registerGlobalHandle(NPOBJECT, v8npObject, v8npObject->v8Object);
-#endif
v8npObject->rootObject = root;
iter->second.append(v8npObject);
Modified: trunk/Source/WebCore/bindings/v8/V8GCController.cpp (128137 => 128138)
--- trunk/Source/WebCore/bindings/v8/V8GCController.cpp 2012-09-11 01:19:31 UTC (rev 128137)
+++ trunk/Source/WebCore/bindings/v8/V8GCController.cpp 2012-09-11 01:22:17 UTC (rev 128138)
@@ -67,63 +67,6 @@
namespace WebCore {
-#ifndef NDEBUG
-// Keeps track of global handles created (not JS wrappers
-// of DOM objects). Often these global handles are source
-// of leaks.
-//
-// If you want to let a C++ object hold a persistent handle
-// to a JS object, you should register the handle here to
-// keep track of leaks.
-//
-// When creating a persistent handle, call:
-//
-// #ifndef NDEBUG
-// V8GCController::registerGlobalHandle(type, host, handle);
-// #endif
-//
-// When releasing the handle, call:
-//
-// #ifndef NDEBUG
-// V8GCController::unregisterGlobalHandle(type, host, handle);
-// #endif
-//
-
-static GlobalHandleMap& currentGlobalHandleMap()
-{
- return V8PerIsolateData::current()->globalHandleMap();
-}
-
-// The function is the place to set the break point to inspect
-// live global handles. Leaks are often come from leaked global handles.
-static void enumerateGlobalHandles()
-{
- GlobalHandleMap& globalHandleMap = currentGlobalHandleMap();
- for (GlobalHandleMap::iterator it = globalHandleMap.begin(), end = globalHandleMap.end(); it != end; ++it) {
- GlobalHandleInfo* info = it->second;
- UNUSED_PARAM(info);
- v8::Value* handle = it->first;
- UNUSED_PARAM(handle);
- }
-}
-
-void V8GCController::registerGlobalHandle(GlobalHandleType type, void* host, v8::Persistent<v8::Value> handle)
-{
- GlobalHandleMap& globalHandleMap = currentGlobalHandleMap();
- ASSERT(!globalHandleMap.contains(*handle));
- globalHandleMap.set(*handle, new GlobalHandleInfo(host, type));
-}
-
-void V8GCController::unregisterGlobalHandle(void* host, v8::Persistent<v8::Value> handle)
-{
- GlobalHandleMap& globalHandleMap = currentGlobalHandleMap();
- ASSERT(globalHandleMap.contains(*handle));
- GlobalHandleInfo* info = globalHandleMap.take(*handle);
- ASSERT(info->m_host == host);
- delete info;
-}
-#endif // ifndef NDEBUG
-
typedef HashMap<Node*, v8::Object*> DOMNodeMap;
typedef HashMap<void*, v8::Object*> DOMObjectMap;
@@ -475,11 +418,6 @@
int V8GCController::workingSetEstimateMB = 0;
-namespace {
-
-
-} // anonymous namespace
-
void V8GCController::gcEpilogue()
{
v8::HandleScope scope;
@@ -500,8 +438,6 @@
EnsureWeakDOMNodeVisitor weakDOMNodeVisitor;
visitDOMNodes(&weakDOMNodeVisitor);
-
- enumerateGlobalHandles();
#endif
#if PLATFORM(CHROMIUM)
@@ -536,11 +472,14 @@
{
v8::HandleScope handleScope;
- v8::Persistent<v8::Context> context = v8::Context::New();
- if (context.IsEmpty())
+ ScopedPersistent<v8::Context> context;
+
+ context.adopt(v8::Context::New());
+ if (context.isEmpty())
return;
+
{
- v8::Context::Scope scope(context);
+ v8::Context::Scope scope(context.get());
v8::Local<v8::String> source = v8::String::New("if (gc) gc();");
v8::Local<v8::String> name = v8::String::New("gc");
v8::Handle<v8::Script> script = v8::Script::Compile(source, name);
@@ -549,7 +488,8 @@
script->Run();
}
}
- context.Dispose();
+
+ context.clear();
}
} // namespace WebCore
Modified: trunk/Source/WebCore/bindings/v8/V8GCController.h (128137 => 128138)
--- trunk/Source/WebCore/bindings/v8/V8GCController.h 2012-09-11 01:19:31 UTC (rev 128137)
+++ trunk/Source/WebCore/bindings/v8/V8GCController.h 2012-09-11 01:22:17 UTC (rev 128138)
@@ -35,55 +35,19 @@
namespace WebCore {
-#ifndef NDEBUG
+class V8GCController {
+public:
+ static void gcPrologue();
+ static void gcEpilogue();
-#define GlobalHandleTypeList(V) \
- V(PROXY) \
- V(NPOBJECT) \
- V(SCHEDULED_ACTION) \
- V(EVENT_LISTENER) \
- V(NODE_FILTER) \
- V(SCRIPTINSTANCE) \
- V(SCRIPTVALUE) \
- V(DATASOURCE)
+ static void checkMemoryUsage();
+ static void hintForCollectGarbage();
+ static void collectGarbage();
+private:
+ static int workingSetEstimateMB;
+};
- // Host information of persistent handles.
- enum GlobalHandleType {
-#define ENUM(name) name,
- GlobalHandleTypeList(ENUM)
-#undef ENUM
- };
-
- class GlobalHandleInfo {
- public:
- GlobalHandleInfo(void* host, GlobalHandleType type) : m_host(host), m_type(type) { }
- void* m_host;
- GlobalHandleType m_type;
- };
-
-#endif // NDEBUG
-
- class V8GCController {
- public:
-#ifndef NDEBUG
- // For debugging and leak detection purpose.
- static void registerGlobalHandle(GlobalHandleType, void*, v8::Persistent<v8::Value>);
- static void unregisterGlobalHandle(void*, v8::Persistent<v8::Value>);
-#endif
-
- static void gcPrologue();
- static void gcEpilogue();
-
- static void checkMemoryUsage();
- static void hintForCollectGarbage();
- static void collectGarbage();
-
- private:
- // Estimate of current working set.
- static int workingSetEstimateMB;
- };
-
}
#endif // V8GCController_h
Modified: trunk/Source/WebCore/bindings/v8/V8PerIsolateData.h (128137 => 128138)
--- trunk/Source/WebCore/bindings/v8/V8PerIsolateData.h 2012-09-11 01:19:31 UTC (rev 128137)
+++ trunk/Source/WebCore/bindings/v8/V8PerIsolateData.h 2012-09-11 01:22:17 UTC (rev 128138)
@@ -48,11 +48,6 @@
typedef WTF::Vector<DOMDataStore*> DOMDataList;
-#ifndef NDEBUG
-class GlobalHandleInfo;
-typedef HashMap<v8::Value*, GlobalHandleInfo*> GlobalHandleMap;
-#endif
-
class V8PerIsolateData {
public:
static V8PerIsolateData* create(v8::Isolate*);
@@ -111,8 +106,6 @@
int nextDependentRetainedId() { return m_nextDependentRetainedId++; }
#ifndef NDEBUG
- GlobalHandleMap& globalHandleMap() { return m_globalHandleMap; }
-
int internalScriptRecursionLevel() const { return m_internalScriptRecursionLevel; }
int incrementInternalScriptRecursionLevel() { return ++m_internalScriptRecursionLevel; }
int decrementInternalScriptRecursionLevel() { return --m_internalScriptRecursionLevel; }
@@ -155,7 +148,6 @@
int m_nextDependentRetainedId;
#ifndef NDEBUG
- GlobalHandleMap m_globalHandleMap;
int m_internalScriptRecursionLevel;
#endif
OwnPtr<GCEventData> m_gcEventData;