From f1e3a294668122b47d8b145e3bc195f631ec3aaa Mon Sep 17 00:00:00 2001 From: "wibling@chromium.org" Date: Tue, 9 Sep 2014 14:03:48 +0000 Subject: [PATCH] Revert "Revert of [oilpan]: optimize the way we allocate persistent handles in wrappers. (patchset #6 id:100001 of https://codereview.chromium.org/52535 3002/)" Reland the wrapper persistent change using placement new for the constructor and no use of destructors. Also when constructing the object we make no assumption about the content of the slot. This reverts commit 1738b5c841f11dd45dadefcd7b3e8ab6bab4eccb. R=ager@chromium.org, fdegans@chromium.org, haraken@chromium.org, oilpan-reviews@chromium.org, zerny@chromium.org BUG=411240 Review URL: https://codereview.chromium.org/556823003 git-svn-id: svn://svn.chromium.org/blink/trunk@181645 bbb929c8-8fbe-4397-9dbb-9b2b20218538 --- Source/bindings/core/v8/NPV8Object.cpp | 2 +- Source/bindings/core/v8/V8DOMWrapper.h | 6 +- Source/bindings/core/v8/WrapperTypeInfo.h | 16 +- .../core/v8/custom/V8ArrayBufferCustom.cpp | 2 +- .../core/v8/custom/V8ArrayBufferCustom.h | 2 +- .../v8/custom/V8InjectedScriptManager.cpp | 6 +- .../core/v8/custom/V8TypedArrayCustom.h | 4 +- Source/bindings/templates/interface.cpp | 6 +- Source/bindings/templates/interface.h | 2 +- .../tests/results/V8SVGTestInterface.cpp | 2 +- .../tests/results/V8SVGTestInterface.h | 2 +- .../tests/results/V8TestException.cpp | 2 +- .../bindings/tests/results/V8TestException.h | 2 +- .../tests/results/V8TestInterface.cpp | 2 +- .../bindings/tests/results/V8TestInterface.h | 2 +- .../tests/results/V8TestInterface2.cpp | 2 +- .../bindings/tests/results/V8TestInterface2.h | 2 +- .../tests/results/V8TestInterface3.cpp | 2 +- .../bindings/tests/results/V8TestInterface3.h | 2 +- .../results/V8TestInterfaceCheckSecurity.cpp | 2 +- .../results/V8TestInterfaceCheckSecurity.h | 2 +- .../results/V8TestInterfaceConstructor.cpp | 2 +- .../results/V8TestInterfaceConstructor.h | 2 +- .../results/V8TestInterfaceConstructor2.cpp | 2 +- .../results/V8TestInterfaceConstructor2.h | 2 +- .../results/V8TestInterfaceConstructor3.cpp | 2 +- .../results/V8TestInterfaceConstructor3.h | 2 +- .../results/V8TestInterfaceConstructor4.cpp | 2 +- .../results/V8TestInterfaceConstructor4.h | 2 +- .../V8TestInterfaceCustomConstructor.cpp | 2 +- .../V8TestInterfaceCustomConstructor.h | 2 +- .../tests/results/V8TestInterfaceDocument.cpp | 4 +- .../tests/results/V8TestInterfaceDocument.h | 2 +- .../tests/results/V8TestInterfaceEmpty.cpp | 2 +- .../tests/results/V8TestInterfaceEmpty.h | 2 +- .../V8TestInterfaceEventConstructor.cpp | 4 +- .../results/V8TestInterfaceEventConstructor.h | 2 +- .../results/V8TestInterfaceEventTarget.cpp | 4 +- .../results/V8TestInterfaceEventTarget.h | 2 +- .../V8TestInterfaceGarbageCollected.cpp | 4 +- .../results/V8TestInterfaceGarbageCollected.h | 2 +- .../V8TestInterfaceNamedConstructor.cpp | 2 +- .../results/V8TestInterfaceNamedConstructor.h | 2 +- .../V8TestInterfaceNamedConstructor2.cpp | 2 +- .../V8TestInterfaceNamedConstructor2.h | 2 +- .../tests/results/V8TestInterfaceNode.cpp | 4 +- .../tests/results/V8TestInterfaceNode.h | 2 +- .../V8TestInterfaceNotScriptWrappable.cpp | 2 +- .../V8TestInterfaceNotScriptWrappable.h | 2 +- .../V8TestInterfaceWillBeGarbageCollected.cpp | 4 +- .../V8TestInterfaceWillBeGarbageCollected.h | 2 +- Source/bindings/tests/results/V8TestNode.cpp | 4 +- Source/bindings/tests/results/V8TestNode.h | 2 +- .../bindings/tests/results/V8TestObject.cpp | 2 +- Source/bindings/tests/results/V8TestObject.h | 2 +- .../tests/results/V8TestSpecialOperations.cpp | 2 +- .../tests/results/V8TestSpecialOperations.h | 2 +- .../V8TestSpecialOperationsNotEnumerable.cpp | 2 +- .../V8TestSpecialOperationsNotEnumerable.h | 2 +- .../bindings/tests/results/V8TestTypedefs.cpp | 2 +- .../bindings/tests/results/V8TestTypedefs.h | 2 +- .../core/inspector/InjectedScriptManager.cpp | 7 + Source/core/inspector/InjectedScriptManager.h | 11 +- Source/platform/heap/BUILD.gn | 1 + Source/platform/heap/Handle.cpp | 77 +++++++ Source/platform/heap/Handle.h | 193 ++++++++++++++++++ Source/platform/heap/ThreadState.cpp | 44 +++- Source/platform/heap/ThreadState.h | 12 ++ Source/platform/heap/blink_heap.gypi | 1 + 69 files changed, 428 insertions(+), 82 deletions(-) create mode 100644 Source/platform/heap/Handle.cpp diff --git a/Source/bindings/core/v8/NPV8Object.cpp b/Source/bindings/core/v8/NPV8Object.cpp index 7e3283bd8c7..3bc172b11ea 100644 --- a/Source/bindings/core/v8/NPV8Object.cpp +++ b/Source/bindings/core/v8/NPV8Object.cpp @@ -50,7 +50,7 @@ using namespace blink; namespace { -PersistentNode* createPersistentHandle(ScriptWrappableBase* internalPointer) +WrapperPersistentNode* createPersistentHandle(ScriptWrappableBase* internalPointer) { ASSERT_NOT_REACHED(); return 0; diff --git a/Source/bindings/core/v8/V8DOMWrapper.h b/Source/bindings/core/v8/V8DOMWrapper.h index 75007edf224..8f06c3dbbcc 100644 --- a/Source/bindings/core/v8/V8DOMWrapper.h +++ b/Source/bindings/core/v8/V8DOMWrapper.h @@ -60,7 +60,7 @@ class V8DOMWrapper { static v8::Handle associateObjectWithWrapperNonTemplate(Node*, const WrapperTypeInfo*, v8::Handle, v8::Isolate*); static void setNativeInfo(v8::Handle, const WrapperTypeInfo*, ScriptWrappableBase* internalPointer); static void setNativeInfoForHiddenWrapper(v8::Handle, const WrapperTypeInfo*, ScriptWrappableBase* internalPointer); - static void setNativeInfoWithPersistentHandle(v8::Handle, const WrapperTypeInfo*, ScriptWrappableBase* internalPointer, PersistentNode*); + static void setNativeInfoWithPersistentHandle(v8::Handle, const WrapperTypeInfo*, ScriptWrappableBase* internalPointer, WrapperPersistentNode*); static void clearNativeInfo(v8::Handle, const WrapperTypeInfo*); static bool isDOMWrapper(v8::Handle); @@ -104,7 +104,7 @@ inline void V8DOMWrapper::setNativeInfoForHiddenWrapper(v8::Handle w wrapper->SetAlignedPointerInInternalField(v8DOMWrapperTypeIndex, const_cast(wrapperTypeInfo)); } -inline void V8DOMWrapper::setNativeInfoWithPersistentHandle(v8::Handle wrapper, const WrapperTypeInfo* wrapperTypeInfo, ScriptWrappableBase* internalPointer, PersistentNode* handle) +inline void V8DOMWrapper::setNativeInfoWithPersistentHandle(v8::Handle wrapper, const WrapperTypeInfo* wrapperTypeInfo, ScriptWrappableBase* internalPointer, WrapperPersistentNode* handle) { ASSERT(wrapper->InternalFieldCount() >= 3); ASSERT(internalPointer); @@ -142,7 +142,7 @@ inline v8::Handle V8DOMWrapper::associateObjectWithWrapper(PassRefPt template inline v8::Handle V8DOMWrapper::associateObjectWithWrapper(T* object, const WrapperTypeInfo* wrapperTypeInfo, v8::Handle wrapper, v8::Isolate* isolate) { - setNativeInfoWithPersistentHandle(wrapper, wrapperTypeInfo, V8T::toScriptWrappableBase(object), new Persistent(object)); + setNativeInfoWithPersistentHandle(wrapper, wrapperTypeInfo, V8T::toScriptWrappableBase(object), WrapperPersistent::create(object)); ASSERT(isDOMWrapper(wrapper)); DOMDataStore::setWrapper(object, wrapper, isolate, wrapperTypeInfo); return wrapper; diff --git a/Source/bindings/core/v8/WrapperTypeInfo.h b/Source/bindings/core/v8/WrapperTypeInfo.h index fa640e0d800..cd921f08fb7 100644 --- a/Source/bindings/core/v8/WrapperTypeInfo.h +++ b/Source/bindings/core/v8/WrapperTypeInfo.h @@ -52,7 +52,7 @@ static const int v8PrototypeInternalFieldcount = 1; typedef v8::Handle (*DomTemplateFunction)(v8::Isolate*); typedef void (*RefObjectFunction)(ScriptWrappableBase* internalPointer); typedef void (*DerefObjectFunction)(ScriptWrappableBase* internalPointer); -typedef PersistentNode* (*CreatePersistentHandleFunction)(ScriptWrappableBase* internalPointer); +typedef WrapperPersistentNode* (*CreatePersistentHandleFunction)(ScriptWrappableBase* internalPointer); typedef ActiveDOMObject* (*ToActiveDOMObjectFunction)(v8::Handle); typedef EventTarget* (*ToEventTargetFunction)(v8::Handle); typedef void (*ResolveWrapperReachabilityFunction)(ScriptWrappableBase* internalPointer, const v8::Persistent&, v8::Isolate*); @@ -128,7 +128,7 @@ struct WrapperTypeInfo { refObjectFunction(internalPointer); } - PersistentNode* createPersistentHandle(ScriptWrappableBase* internalPointer) const + WrapperPersistentNode* createPersistentHandle(ScriptWrappableBase* internalPointer) const { ASSERT(createPersistentHandleFunction); return createPersistentHandleFunction(internalPointer); @@ -220,26 +220,26 @@ inline const WrapperTypeInfo* toWrapperTypeInfo(v8::Handle wrapper) return getInternalField(wrapper); } -inline const PersistentNode* toPersistentHandle(const v8::Handle& wrapper) +inline const WrapperPersistentNode* toPersistentHandle(const v8::Handle& wrapper) { // Persistent handle is stored in the last internal field. - return static_cast(wrapper->GetAlignedPointerFromInternalField(wrapper->InternalFieldCount() - 1)); + return static_cast(wrapper->GetAlignedPointerFromInternalField(wrapper->InternalFieldCount() - 1)); } inline void releaseObject(v8::Handle wrapper) { const WrapperTypeInfo* typeInfo = toWrapperTypeInfo(wrapper); if (typeInfo->gcType == WrapperTypeInfo::GarbageCollectedObject) { - const PersistentNode* handle = toPersistentHandle(wrapper); + const WrapperPersistentNode* handle = toPersistentHandle(wrapper); // This will be null iff a wrapper for a hidden wrapper object, // see V8DOMWrapper::setNativeInfoForHiddenWrapper(). - delete handle; + WrapperPersistentNode::destroy(handle); } else if (typeInfo->gcType == WrapperTypeInfo::WillBeGarbageCollectedObject) { #if ENABLE(OILPAN) - const PersistentNode* handle = toPersistentHandle(wrapper); + const WrapperPersistentNode* handle = toPersistentHandle(wrapper); // This will be null iff a wrapper for a hidden wrapper object, // see V8DOMWrapper::setNativeInfoForHiddenWrapper(). - delete handle; + WrapperPersistentNode::destroy(handle); #else ASSERT(typeInfo->derefObjectFunction); typeInfo->derefObjectFunction(toScriptWrappableBase(wrapper)); diff --git a/Source/bindings/core/v8/custom/V8ArrayBufferCustom.cpp b/Source/bindings/core/v8/custom/V8ArrayBufferCustom.cpp index 66410b24c2d..7a0ea24d7d9 100644 --- a/Source/bindings/core/v8/custom/V8ArrayBufferCustom.cpp +++ b/Source/bindings/core/v8/custom/V8ArrayBufferCustom.cpp @@ -73,7 +73,7 @@ void V8ArrayBuffer::derefObject(ScriptWrappableBase* internalPointer) toImpl(internalPointer)->deref(); } -PersistentNode* V8ArrayBuffer::createPersistentHandle(ScriptWrappableBase* internalPointer) +WrapperPersistentNode* V8ArrayBuffer::createPersistentHandle(ScriptWrappableBase* internalPointer) { ASSERT_NOT_REACHED(); return 0; diff --git a/Source/bindings/core/v8/custom/V8ArrayBufferCustom.h b/Source/bindings/core/v8/custom/V8ArrayBufferCustom.h index 1a684a783c3..03702112a06 100644 --- a/Source/bindings/core/v8/custom/V8ArrayBufferCustom.h +++ b/Source/bindings/core/v8/custom/V8ArrayBufferCustom.h @@ -56,7 +56,7 @@ class V8ArrayBuffer { static ArrayBuffer* toImplWithTypeCheck(v8::Isolate*, v8::Handle); static void refObject(ScriptWrappableBase* internalPointer); static void derefObject(ScriptWrappableBase* internalPointer); - static PersistentNode* createPersistentHandle(ScriptWrappableBase* internalPointer); + static WrapperPersistentNode* createPersistentHandle(ScriptWrappableBase* internalPointer); static const WrapperTypeInfo wrapperTypeInfo; static const int internalFieldCount = v8DefaultWrapperInternalFieldCount; diff --git a/Source/bindings/core/v8/custom/V8InjectedScriptManager.cpp b/Source/bindings/core/v8/custom/V8InjectedScriptManager.cpp index c160830df18..7cb08e493e8 100644 --- a/Source/bindings/core/v8/custom/V8InjectedScriptManager.cpp +++ b/Source/bindings/core/v8/custom/V8InjectedScriptManager.cpp @@ -72,12 +72,16 @@ static v8::Local createInjectedScriptHostV8Wrapper(PassRefPtrWillBeR // Create a weak reference to the v8 wrapper of InspectorBackend to deref // InspectorBackend when the wrapper is garbage collected. InjectedScriptManager::CallbackData* callbackData = injectedScriptManager->createCallbackData(injectedScriptManager); +#if ENABLE(OILPAN) + callbackData->hostPtr = WrapperPersistent::create(host.get()); +#else callbackData->host = host.get(); +#endif callbackData->handle.set(isolate, wrapper); callbackData->handle.setWeak(callbackData, &InjectedScriptManager::setWeakCallback); #if ENABLE(OILPAN) - V8DOMWrapper::setNativeInfoWithPersistentHandle(wrapper, &V8InjectedScriptHost::wrapperTypeInfo, host->toScriptWrappableBase(), &callbackData->host); + V8DOMWrapper::setNativeInfoWithPersistentHandle(wrapper, &V8InjectedScriptHost::wrapperTypeInfo, host->toScriptWrappableBase(), callbackData->hostPtr); #else V8DOMWrapper::setNativeInfo(wrapper, &V8InjectedScriptHost::wrapperTypeInfo, host->toScriptWrappableBase()); #endif diff --git a/Source/bindings/core/v8/custom/V8TypedArrayCustom.h b/Source/bindings/core/v8/custom/V8TypedArrayCustom.h index 9f2d4e7e37b..c38087a9353 100644 --- a/Source/bindings/core/v8/custom/V8TypedArrayCustom.h +++ b/Source/bindings/core/v8/custom/V8TypedArrayCustom.h @@ -56,7 +56,7 @@ class V8TypedArray { static TypedArray* toImplWithTypeCheck(v8::Isolate*, v8::Handle); static void refObject(ScriptWrappableBase* internalPointer); static void derefObject(ScriptWrappableBase* internalPointer); - static PersistentNode* createPersistentHandle(ScriptWrappableBase* internalPointer); + static WrapperPersistentNode* createPersistentHandle(ScriptWrappableBase* internalPointer); static const WrapperTypeInfo wrapperTypeInfo; static const int internalFieldCount = v8DefaultWrapperInternalFieldCount; @@ -210,7 +210,7 @@ void V8TypedArray::derefObject(ScriptWrappableBase* internalPointer) } template -PersistentNode* V8TypedArray::createPersistentHandle(ScriptWrappableBase* internalPointer) +WrapperPersistentNode* V8TypedArray::createPersistentHandle(ScriptWrappableBase* internalPointer) { ASSERT_NOT_REACHED(); return 0; diff --git a/Source/bindings/templates/interface.cpp b/Source/bindings/templates/interface.cpp index 21272949c6b..680d262aec6 100644 --- a/Source/bindings/templates/interface.cpp +++ b/Source/bindings/templates/interface.cpp @@ -1246,13 +1246,13 @@ void {{v8_class}}::derefObject(ScriptWrappableBase* internalPointer) {% endif %} } -PersistentNode* {{v8_class}}::createPersistentHandle(ScriptWrappableBase* internalPointer) +WrapperPersistentNode* {{v8_class}}::createPersistentHandle(ScriptWrappableBase* internalPointer) { {% if gc_type == 'GarbageCollectedObject' %} - return new Persistent<{{cpp_class}}>(internalPointer->toImpl<{{cpp_class}}>()); + return WrapperPersistent<{{cpp_class}}>::create(internalPointer->toImpl<{{cpp_class}}>()); {% elif gc_type == 'WillBeGarbageCollectedObject' %} #if ENABLE(OILPAN) - return new Persistent<{{cpp_class}}>(internalPointer->toImpl<{{cpp_class}}>()); + return WrapperPersistent<{{cpp_class}}>::create(internalPointer->toImpl<{{cpp_class}}>()); #else ASSERT_NOT_REACHED(); return 0; diff --git a/Source/bindings/templates/interface.h b/Source/bindings/templates/interface.h index 4c09d08af9e..22719e3ca82 100644 --- a/Source/bindings/templates/interface.h +++ b/Source/bindings/templates/interface.h @@ -53,7 +53,7 @@ class {{v8_class}} { static const WrapperTypeInfo wrapperTypeInfo; static void refObject(ScriptWrappableBase* internalPointer); static void derefObject(ScriptWrappableBase* internalPointer); - static PersistentNode* createPersistentHandle(ScriptWrappableBase* internalPointer); + static WrapperPersistentNode* createPersistentHandle(ScriptWrappableBase* internalPointer); {% if has_visit_dom_wrapper %} static void visitDOMWrapper(ScriptWrappableBase* internalPointer, const v8::Persistent&, v8::Isolate*); {% endif %} diff --git a/Source/bindings/tests/results/V8SVGTestInterface.cpp b/Source/bindings/tests/results/V8SVGTestInterface.cpp index a1eebec18fb..6b50f7b6c89 100644 --- a/Source/bindings/tests/results/V8SVGTestInterface.cpp +++ b/Source/bindings/tests/results/V8SVGTestInterface.cpp @@ -118,7 +118,7 @@ void V8SVGTestInterface::derefObject(ScriptWrappableBase* internalPointer) internalPointer->toImpl()->deref(); } -PersistentNode* V8SVGTestInterface::createPersistentHandle(ScriptWrappableBase* internalPointer) +WrapperPersistentNode* V8SVGTestInterface::createPersistentHandle(ScriptWrappableBase* internalPointer) { ASSERT_NOT_REACHED(); return 0; diff --git a/Source/bindings/tests/results/V8SVGTestInterface.h b/Source/bindings/tests/results/V8SVGTestInterface.h index 0f6ab0013ed..138fd45868f 100644 --- a/Source/bindings/tests/results/V8SVGTestInterface.h +++ b/Source/bindings/tests/results/V8SVGTestInterface.h @@ -29,7 +29,7 @@ class V8SVGTestInterface { static const WrapperTypeInfo wrapperTypeInfo; static void refObject(ScriptWrappableBase* internalPointer); static void derefObject(ScriptWrappableBase* internalPointer); - static PersistentNode* createPersistentHandle(ScriptWrappableBase* internalPointer); + static WrapperPersistentNode* createPersistentHandle(ScriptWrappableBase* internalPointer); static const int internalFieldCount = v8DefaultWrapperInternalFieldCount + 0; static inline ScriptWrappableBase* toScriptWrappableBase(SVGTestInterface* impl) { diff --git a/Source/bindings/tests/results/V8TestException.cpp b/Source/bindings/tests/results/V8TestException.cpp index 1707d3964d8..ce3da3b3c25 100644 --- a/Source/bindings/tests/results/V8TestException.cpp +++ b/Source/bindings/tests/results/V8TestException.cpp @@ -135,7 +135,7 @@ void V8TestException::derefObject(ScriptWrappableBase* internalPointer) internalPointer->toImpl()->deref(); } -PersistentNode* V8TestException::createPersistentHandle(ScriptWrappableBase* internalPointer) +WrapperPersistentNode* V8TestException::createPersistentHandle(ScriptWrappableBase* internalPointer) { ASSERT_NOT_REACHED(); return 0; diff --git a/Source/bindings/tests/results/V8TestException.h b/Source/bindings/tests/results/V8TestException.h index 81941581225..baea007deee 100644 --- a/Source/bindings/tests/results/V8TestException.h +++ b/Source/bindings/tests/results/V8TestException.h @@ -29,7 +29,7 @@ class V8TestException { static const WrapperTypeInfo wrapperTypeInfo; static void refObject(ScriptWrappableBase* internalPointer); static void derefObject(ScriptWrappableBase* internalPointer); - static PersistentNode* createPersistentHandle(ScriptWrappableBase* internalPointer); + static WrapperPersistentNode* createPersistentHandle(ScriptWrappableBase* internalPointer); static const int internalFieldCount = v8DefaultWrapperInternalFieldCount + 0; static inline ScriptWrappableBase* toScriptWrappableBase(TestException* impl) { diff --git a/Source/bindings/tests/results/V8TestInterface.cpp b/Source/bindings/tests/results/V8TestInterface.cpp index 5218913e5c5..64d81a5d931 100644 --- a/Source/bindings/tests/results/V8TestInterface.cpp +++ b/Source/bindings/tests/results/V8TestInterface.cpp @@ -2085,7 +2085,7 @@ void V8TestInterface::derefObject(ScriptWrappableBase* internalPointer) internalPointer->toImpl()->deref(); } -PersistentNode* V8TestInterface::createPersistentHandle(ScriptWrappableBase* internalPointer) +WrapperPersistentNode* V8TestInterface::createPersistentHandle(ScriptWrappableBase* internalPointer) { ASSERT_NOT_REACHED(); return 0; diff --git a/Source/bindings/tests/results/V8TestInterface.h b/Source/bindings/tests/results/V8TestInterface.h index 730f97b9238..09404a32df2 100644 --- a/Source/bindings/tests/results/V8TestInterface.h +++ b/Source/bindings/tests/results/V8TestInterface.h @@ -38,7 +38,7 @@ class V8TestInterface { static const WrapperTypeInfo wrapperTypeInfo; static void refObject(ScriptWrappableBase* internalPointer); static void derefObject(ScriptWrappableBase* internalPointer); - static PersistentNode* createPersistentHandle(ScriptWrappableBase* internalPointer); + static WrapperPersistentNode* createPersistentHandle(ScriptWrappableBase* internalPointer); static void visitDOMWrapper(ScriptWrappableBase* internalPointer, const v8::Persistent&, v8::Isolate*); static ActiveDOMObject* toActiveDOMObject(v8::Handle); static void implementsCustomVoidMethodMethodCustom(const v8::FunctionCallbackInfo&); diff --git a/Source/bindings/tests/results/V8TestInterface2.cpp b/Source/bindings/tests/results/V8TestInterface2.cpp index 3912d29aa18..80af27d1b14 100644 --- a/Source/bindings/tests/results/V8TestInterface2.cpp +++ b/Source/bindings/tests/results/V8TestInterface2.cpp @@ -517,7 +517,7 @@ void V8TestInterface2::derefObject(ScriptWrappableBase* internalPointer) internalPointer->toImpl()->deref(); } -PersistentNode* V8TestInterface2::createPersistentHandle(ScriptWrappableBase* internalPointer) +WrapperPersistentNode* V8TestInterface2::createPersistentHandle(ScriptWrappableBase* internalPointer) { ASSERT_NOT_REACHED(); return 0; diff --git a/Source/bindings/tests/results/V8TestInterface2.h b/Source/bindings/tests/results/V8TestInterface2.h index ea77d37483f..2d984f27f3e 100644 --- a/Source/bindings/tests/results/V8TestInterface2.h +++ b/Source/bindings/tests/results/V8TestInterface2.h @@ -29,7 +29,7 @@ class V8TestInterface2 { static const WrapperTypeInfo wrapperTypeInfo; static void refObject(ScriptWrappableBase* internalPointer); static void derefObject(ScriptWrappableBase* internalPointer); - static PersistentNode* createPersistentHandle(ScriptWrappableBase* internalPointer); + static WrapperPersistentNode* createPersistentHandle(ScriptWrappableBase* internalPointer); static void visitDOMWrapper(ScriptWrappableBase* internalPointer, const v8::Persistent&, v8::Isolate*); static void constructorCallback(const v8::FunctionCallbackInfo&); static const int internalFieldCount = v8DefaultWrapperInternalFieldCount + 0; diff --git a/Source/bindings/tests/results/V8TestInterface3.cpp b/Source/bindings/tests/results/V8TestInterface3.cpp index 8b8140e6d42..50437f043ce 100644 --- a/Source/bindings/tests/results/V8TestInterface3.cpp +++ b/Source/bindings/tests/results/V8TestInterface3.cpp @@ -140,7 +140,7 @@ void V8TestInterface3::derefObject(ScriptWrappableBase* internalPointer) internalPointer->toImpl()->deref(); } -PersistentNode* V8TestInterface3::createPersistentHandle(ScriptWrappableBase* internalPointer) +WrapperPersistentNode* V8TestInterface3::createPersistentHandle(ScriptWrappableBase* internalPointer) { ASSERT_NOT_REACHED(); return 0; diff --git a/Source/bindings/tests/results/V8TestInterface3.h b/Source/bindings/tests/results/V8TestInterface3.h index e014f7d5e07..e7c1a139e58 100644 --- a/Source/bindings/tests/results/V8TestInterface3.h +++ b/Source/bindings/tests/results/V8TestInterface3.h @@ -29,7 +29,7 @@ class V8TestInterface3 { static const WrapperTypeInfo wrapperTypeInfo; static void refObject(ScriptWrappableBase* internalPointer); static void derefObject(ScriptWrappableBase* internalPointer); - static PersistentNode* createPersistentHandle(ScriptWrappableBase* internalPointer); + static WrapperPersistentNode* createPersistentHandle(ScriptWrappableBase* internalPointer); static void visitDOMWrapper(ScriptWrappableBase* internalPointer, const v8::Persistent&, v8::Isolate*); static void indexedPropertyGetterCustom(uint32_t, const v8::PropertyCallbackInfo&); static void indexedPropertySetterCustom(uint32_t, v8::Local, const v8::PropertyCallbackInfo&); diff --git a/Source/bindings/tests/results/V8TestInterfaceCheckSecurity.cpp b/Source/bindings/tests/results/V8TestInterfaceCheckSecurity.cpp index 74618434ecd..346cf73684c 100644 --- a/Source/bindings/tests/results/V8TestInterfaceCheckSecurity.cpp +++ b/Source/bindings/tests/results/V8TestInterfaceCheckSecurity.cpp @@ -534,7 +534,7 @@ void V8TestInterfaceCheckSecurity::derefObject(ScriptWrappableBase* internalPoin internalPointer->toImpl()->deref(); } -PersistentNode* V8TestInterfaceCheckSecurity::createPersistentHandle(ScriptWrappableBase* internalPointer) +WrapperPersistentNode* V8TestInterfaceCheckSecurity::createPersistentHandle(ScriptWrappableBase* internalPointer) { ASSERT_NOT_REACHED(); return 0; diff --git a/Source/bindings/tests/results/V8TestInterfaceCheckSecurity.h b/Source/bindings/tests/results/V8TestInterfaceCheckSecurity.h index 8f731c69903..0d239a0e87c 100644 --- a/Source/bindings/tests/results/V8TestInterfaceCheckSecurity.h +++ b/Source/bindings/tests/results/V8TestInterfaceCheckSecurity.h @@ -29,7 +29,7 @@ class V8TestInterfaceCheckSecurity { static const WrapperTypeInfo wrapperTypeInfo; static void refObject(ScriptWrappableBase* internalPointer); static void derefObject(ScriptWrappableBase* internalPointer); - static PersistentNode* createPersistentHandle(ScriptWrappableBase* internalPointer); + static WrapperPersistentNode* createPersistentHandle(ScriptWrappableBase* internalPointer); static const int internalFieldCount = v8DefaultWrapperInternalFieldCount + 0; static inline ScriptWrappableBase* toScriptWrappableBase(TestInterfaceCheckSecurity* impl) { diff --git a/Source/bindings/tests/results/V8TestInterfaceConstructor.cpp b/Source/bindings/tests/results/V8TestInterfaceConstructor.cpp index c9e215a197a..811e909ab01 100644 --- a/Source/bindings/tests/results/V8TestInterfaceConstructor.cpp +++ b/Source/bindings/tests/results/V8TestInterfaceConstructor.cpp @@ -348,7 +348,7 @@ void V8TestInterfaceConstructor::derefObject(ScriptWrappableBase* internalPointe internalPointer->toImpl()->deref(); } -PersistentNode* V8TestInterfaceConstructor::createPersistentHandle(ScriptWrappableBase* internalPointer) +WrapperPersistentNode* V8TestInterfaceConstructor::createPersistentHandle(ScriptWrappableBase* internalPointer) { ASSERT_NOT_REACHED(); return 0; diff --git a/Source/bindings/tests/results/V8TestInterfaceConstructor.h b/Source/bindings/tests/results/V8TestInterfaceConstructor.h index c15a4532458..da02ee109bc 100644 --- a/Source/bindings/tests/results/V8TestInterfaceConstructor.h +++ b/Source/bindings/tests/results/V8TestInterfaceConstructor.h @@ -35,7 +35,7 @@ class V8TestInterfaceConstructor { static const WrapperTypeInfo wrapperTypeInfo; static void refObject(ScriptWrappableBase* internalPointer); static void derefObject(ScriptWrappableBase* internalPointer); - static PersistentNode* createPersistentHandle(ScriptWrappableBase* internalPointer); + static WrapperPersistentNode* createPersistentHandle(ScriptWrappableBase* internalPointer); static void constructorCallback(const v8::FunctionCallbackInfo&); static const int internalFieldCount = v8DefaultWrapperInternalFieldCount + 0; static inline ScriptWrappableBase* toScriptWrappableBase(TestInterfaceConstructor* impl) diff --git a/Source/bindings/tests/results/V8TestInterfaceConstructor2.cpp b/Source/bindings/tests/results/V8TestInterfaceConstructor2.cpp index 922d263bc27..3ca0536724b 100644 --- a/Source/bindings/tests/results/V8TestInterfaceConstructor2.cpp +++ b/Source/bindings/tests/results/V8TestInterfaceConstructor2.cpp @@ -226,7 +226,7 @@ void V8TestInterfaceConstructor2::derefObject(ScriptWrappableBase* internalPoint internalPointer->toImpl()->deref(); } -PersistentNode* V8TestInterfaceConstructor2::createPersistentHandle(ScriptWrappableBase* internalPointer) +WrapperPersistentNode* V8TestInterfaceConstructor2::createPersistentHandle(ScriptWrappableBase* internalPointer) { ASSERT_NOT_REACHED(); return 0; diff --git a/Source/bindings/tests/results/V8TestInterfaceConstructor2.h b/Source/bindings/tests/results/V8TestInterfaceConstructor2.h index 386bc3f0208..f2711f92980 100644 --- a/Source/bindings/tests/results/V8TestInterfaceConstructor2.h +++ b/Source/bindings/tests/results/V8TestInterfaceConstructor2.h @@ -29,7 +29,7 @@ class V8TestInterfaceConstructor2 { static const WrapperTypeInfo wrapperTypeInfo; static void refObject(ScriptWrappableBase* internalPointer); static void derefObject(ScriptWrappableBase* internalPointer); - static PersistentNode* createPersistentHandle(ScriptWrappableBase* internalPointer); + static WrapperPersistentNode* createPersistentHandle(ScriptWrappableBase* internalPointer); static void constructorCallback(const v8::FunctionCallbackInfo&); static const int internalFieldCount = v8DefaultWrapperInternalFieldCount + 0; static inline ScriptWrappableBase* toScriptWrappableBase(TestInterfaceConstructor2* impl) diff --git a/Source/bindings/tests/results/V8TestInterfaceConstructor3.cpp b/Source/bindings/tests/results/V8TestInterfaceConstructor3.cpp index c15141e813e..457f15d0e95 100644 --- a/Source/bindings/tests/results/V8TestInterfaceConstructor3.cpp +++ b/Source/bindings/tests/results/V8TestInterfaceConstructor3.cpp @@ -116,7 +116,7 @@ void V8TestInterfaceConstructor3::derefObject(ScriptWrappableBase* internalPoint internalPointer->toImpl()->deref(); } -PersistentNode* V8TestInterfaceConstructor3::createPersistentHandle(ScriptWrappableBase* internalPointer) +WrapperPersistentNode* V8TestInterfaceConstructor3::createPersistentHandle(ScriptWrappableBase* internalPointer) { ASSERT_NOT_REACHED(); return 0; diff --git a/Source/bindings/tests/results/V8TestInterfaceConstructor3.h b/Source/bindings/tests/results/V8TestInterfaceConstructor3.h index b07b5603709..bceff28645b 100644 --- a/Source/bindings/tests/results/V8TestInterfaceConstructor3.h +++ b/Source/bindings/tests/results/V8TestInterfaceConstructor3.h @@ -29,7 +29,7 @@ class V8TestInterfaceConstructor3 { static const WrapperTypeInfo wrapperTypeInfo; static void refObject(ScriptWrappableBase* internalPointer); static void derefObject(ScriptWrappableBase* internalPointer); - static PersistentNode* createPersistentHandle(ScriptWrappableBase* internalPointer); + static WrapperPersistentNode* createPersistentHandle(ScriptWrappableBase* internalPointer); static void constructorCallback(const v8::FunctionCallbackInfo&); static const int internalFieldCount = v8DefaultWrapperInternalFieldCount + 0; static inline ScriptWrappableBase* toScriptWrappableBase(TestInterfaceConstructor3* impl) diff --git a/Source/bindings/tests/results/V8TestInterfaceConstructor4.cpp b/Source/bindings/tests/results/V8TestInterfaceConstructor4.cpp index 3401743c1ca..6267c072708 100644 --- a/Source/bindings/tests/results/V8TestInterfaceConstructor4.cpp +++ b/Source/bindings/tests/results/V8TestInterfaceConstructor4.cpp @@ -153,7 +153,7 @@ void V8TestInterfaceConstructor4::derefObject(ScriptWrappableBase* internalPoint internalPointer->toImpl()->deref(); } -PersistentNode* V8TestInterfaceConstructor4::createPersistentHandle(ScriptWrappableBase* internalPointer) +WrapperPersistentNode* V8TestInterfaceConstructor4::createPersistentHandle(ScriptWrappableBase* internalPointer) { ASSERT_NOT_REACHED(); return 0; diff --git a/Source/bindings/tests/results/V8TestInterfaceConstructor4.h b/Source/bindings/tests/results/V8TestInterfaceConstructor4.h index e6e44677a45..0177f85afb3 100644 --- a/Source/bindings/tests/results/V8TestInterfaceConstructor4.h +++ b/Source/bindings/tests/results/V8TestInterfaceConstructor4.h @@ -29,7 +29,7 @@ class V8TestInterfaceConstructor4 { static const WrapperTypeInfo wrapperTypeInfo; static void refObject(ScriptWrappableBase* internalPointer); static void derefObject(ScriptWrappableBase* internalPointer); - static PersistentNode* createPersistentHandle(ScriptWrappableBase* internalPointer); + static WrapperPersistentNode* createPersistentHandle(ScriptWrappableBase* internalPointer); static void constructorCallback(const v8::FunctionCallbackInfo&); static const int internalFieldCount = v8DefaultWrapperInternalFieldCount + 0; static inline ScriptWrappableBase* toScriptWrappableBase(TestInterfaceConstructor4* impl) diff --git a/Source/bindings/tests/results/V8TestInterfaceCustomConstructor.cpp b/Source/bindings/tests/results/V8TestInterfaceCustomConstructor.cpp index 1d5191d7cef..4a678feafa5 100644 --- a/Source/bindings/tests/results/V8TestInterfaceCustomConstructor.cpp +++ b/Source/bindings/tests/results/V8TestInterfaceCustomConstructor.cpp @@ -100,7 +100,7 @@ void V8TestInterfaceCustomConstructor::derefObject(ScriptWrappableBase* internal internalPointer->toImpl()->deref(); } -PersistentNode* V8TestInterfaceCustomConstructor::createPersistentHandle(ScriptWrappableBase* internalPointer) +WrapperPersistentNode* V8TestInterfaceCustomConstructor::createPersistentHandle(ScriptWrappableBase* internalPointer) { ASSERT_NOT_REACHED(); return 0; diff --git a/Source/bindings/tests/results/V8TestInterfaceCustomConstructor.h b/Source/bindings/tests/results/V8TestInterfaceCustomConstructor.h index db3e8b26f3f..d319e6dac69 100644 --- a/Source/bindings/tests/results/V8TestInterfaceCustomConstructor.h +++ b/Source/bindings/tests/results/V8TestInterfaceCustomConstructor.h @@ -29,7 +29,7 @@ class V8TestInterfaceCustomConstructor { static const WrapperTypeInfo wrapperTypeInfo; static void refObject(ScriptWrappableBase* internalPointer); static void derefObject(ScriptWrappableBase* internalPointer); - static PersistentNode* createPersistentHandle(ScriptWrappableBase* internalPointer); + static WrapperPersistentNode* createPersistentHandle(ScriptWrappableBase* internalPointer); static void constructorCallback(const v8::FunctionCallbackInfo&); static void constructorCustom(const v8::FunctionCallbackInfo&); static const int internalFieldCount = v8DefaultWrapperInternalFieldCount + 0; diff --git a/Source/bindings/tests/results/V8TestInterfaceDocument.cpp b/Source/bindings/tests/results/V8TestInterfaceDocument.cpp index 331ad57cb49..a08a0ebc744 100644 --- a/Source/bindings/tests/results/V8TestInterfaceDocument.cpp +++ b/Source/bindings/tests/results/V8TestInterfaceDocument.cpp @@ -93,10 +93,10 @@ void V8TestInterfaceDocument::derefObject(ScriptWrappableBase* internalPointer) #endif } -PersistentNode* V8TestInterfaceDocument::createPersistentHandle(ScriptWrappableBase* internalPointer) +WrapperPersistentNode* V8TestInterfaceDocument::createPersistentHandle(ScriptWrappableBase* internalPointer) { #if ENABLE(OILPAN) - return new Persistent(internalPointer->toImpl()); + return WrapperPersistent::create(internalPointer->toImpl()); #else ASSERT_NOT_REACHED(); return 0; diff --git a/Source/bindings/tests/results/V8TestInterfaceDocument.h b/Source/bindings/tests/results/V8TestInterfaceDocument.h index 60c0c23d415..162cdbce497 100644 --- a/Source/bindings/tests/results/V8TestInterfaceDocument.h +++ b/Source/bindings/tests/results/V8TestInterfaceDocument.h @@ -30,7 +30,7 @@ class V8TestInterfaceDocument { static const WrapperTypeInfo wrapperTypeInfo; static void refObject(ScriptWrappableBase* internalPointer); static void derefObject(ScriptWrappableBase* internalPointer); - static PersistentNode* createPersistentHandle(ScriptWrappableBase* internalPointer); + static WrapperPersistentNode* createPersistentHandle(ScriptWrappableBase* internalPointer); static EventTarget* toEventTarget(v8::Handle); #if ENABLE(OILPAN) static const int persistentHandleIndex = v8DefaultWrapperInternalFieldCount + 0; diff --git a/Source/bindings/tests/results/V8TestInterfaceEmpty.cpp b/Source/bindings/tests/results/V8TestInterfaceEmpty.cpp index c65f45b5add..9d0a5963a9d 100644 --- a/Source/bindings/tests/results/V8TestInterfaceEmpty.cpp +++ b/Source/bindings/tests/results/V8TestInterfaceEmpty.cpp @@ -81,7 +81,7 @@ void V8TestInterfaceEmpty::derefObject(ScriptWrappableBase* internalPointer) internalPointer->toImpl()->deref(); } -PersistentNode* V8TestInterfaceEmpty::createPersistentHandle(ScriptWrappableBase* internalPointer) +WrapperPersistentNode* V8TestInterfaceEmpty::createPersistentHandle(ScriptWrappableBase* internalPointer) { ASSERT_NOT_REACHED(); return 0; diff --git a/Source/bindings/tests/results/V8TestInterfaceEmpty.h b/Source/bindings/tests/results/V8TestInterfaceEmpty.h index 366b51059c2..4b2a6a34198 100644 --- a/Source/bindings/tests/results/V8TestInterfaceEmpty.h +++ b/Source/bindings/tests/results/V8TestInterfaceEmpty.h @@ -29,7 +29,7 @@ class V8TestInterfaceEmpty { static const WrapperTypeInfo wrapperTypeInfo; static void refObject(ScriptWrappableBase* internalPointer); static void derefObject(ScriptWrappableBase* internalPointer); - static PersistentNode* createPersistentHandle(ScriptWrappableBase* internalPointer); + static WrapperPersistentNode* createPersistentHandle(ScriptWrappableBase* internalPointer); static const int internalFieldCount = v8DefaultWrapperInternalFieldCount + 0; static inline ScriptWrappableBase* toScriptWrappableBase(TestInterfaceEmpty* impl) { diff --git a/Source/bindings/tests/results/V8TestInterfaceEventConstructor.cpp b/Source/bindings/tests/results/V8TestInterfaceEventConstructor.cpp index d28cc0edc21..976d9084905 100644 --- a/Source/bindings/tests/results/V8TestInterfaceEventConstructor.cpp +++ b/Source/bindings/tests/results/V8TestInterfaceEventConstructor.cpp @@ -388,10 +388,10 @@ void V8TestInterfaceEventConstructor::derefObject(ScriptWrappableBase* internalP #endif } -PersistentNode* V8TestInterfaceEventConstructor::createPersistentHandle(ScriptWrappableBase* internalPointer) +WrapperPersistentNode* V8TestInterfaceEventConstructor::createPersistentHandle(ScriptWrappableBase* internalPointer) { #if ENABLE(OILPAN) - return new Persistent(internalPointer->toImpl()); + return WrapperPersistent::create(internalPointer->toImpl()); #else ASSERT_NOT_REACHED(); return 0; diff --git a/Source/bindings/tests/results/V8TestInterfaceEventConstructor.h b/Source/bindings/tests/results/V8TestInterfaceEventConstructor.h index 952d456e8e2..a7ece0afb78 100644 --- a/Source/bindings/tests/results/V8TestInterfaceEventConstructor.h +++ b/Source/bindings/tests/results/V8TestInterfaceEventConstructor.h @@ -31,7 +31,7 @@ class V8TestInterfaceEventConstructor { static const WrapperTypeInfo wrapperTypeInfo; static void refObject(ScriptWrappableBase* internalPointer); static void derefObject(ScriptWrappableBase* internalPointer); - static PersistentNode* createPersistentHandle(ScriptWrappableBase* internalPointer); + static WrapperPersistentNode* createPersistentHandle(ScriptWrappableBase* internalPointer); static void constructorCallback(const v8::FunctionCallbackInfo&); #if ENABLE(OILPAN) static const int persistentHandleIndex = v8DefaultWrapperInternalFieldCount + 0; diff --git a/Source/bindings/tests/results/V8TestInterfaceEventTarget.cpp b/Source/bindings/tests/results/V8TestInterfaceEventTarget.cpp index 12f8e902352..6a0a5044d25 100644 --- a/Source/bindings/tests/results/V8TestInterfaceEventTarget.cpp +++ b/Source/bindings/tests/results/V8TestInterfaceEventTarget.cpp @@ -129,10 +129,10 @@ void V8TestInterfaceEventTarget::derefObject(ScriptWrappableBase* internalPointe #endif } -PersistentNode* V8TestInterfaceEventTarget::createPersistentHandle(ScriptWrappableBase* internalPointer) +WrapperPersistentNode* V8TestInterfaceEventTarget::createPersistentHandle(ScriptWrappableBase* internalPointer) { #if ENABLE(OILPAN) - return new Persistent(internalPointer->toImpl()); + return WrapperPersistent::create(internalPointer->toImpl()); #else ASSERT_NOT_REACHED(); return 0; diff --git a/Source/bindings/tests/results/V8TestInterfaceEventTarget.h b/Source/bindings/tests/results/V8TestInterfaceEventTarget.h index ef010e2ed9c..8e5a1f7d695 100644 --- a/Source/bindings/tests/results/V8TestInterfaceEventTarget.h +++ b/Source/bindings/tests/results/V8TestInterfaceEventTarget.h @@ -36,7 +36,7 @@ class V8TestInterfaceEventTarget { static const WrapperTypeInfo wrapperTypeInfo; static void refObject(ScriptWrappableBase* internalPointer); static void derefObject(ScriptWrappableBase* internalPointer); - static PersistentNode* createPersistentHandle(ScriptWrappableBase* internalPointer); + static WrapperPersistentNode* createPersistentHandle(ScriptWrappableBase* internalPointer); static EventTarget* toEventTarget(v8::Handle); static const int eventListenerCacheIndex = v8DefaultWrapperInternalFieldCount + 0; #if ENABLE(OILPAN) diff --git a/Source/bindings/tests/results/V8TestInterfaceGarbageCollected.cpp b/Source/bindings/tests/results/V8TestInterfaceGarbageCollected.cpp index abbaec9948b..b51c4df57ab 100644 --- a/Source/bindings/tests/results/V8TestInterfaceGarbageCollected.cpp +++ b/Source/bindings/tests/results/V8TestInterfaceGarbageCollected.cpp @@ -180,9 +180,9 @@ void V8TestInterfaceGarbageCollected::derefObject(ScriptWrappableBase* internalP { } -PersistentNode* V8TestInterfaceGarbageCollected::createPersistentHandle(ScriptWrappableBase* internalPointer) +WrapperPersistentNode* V8TestInterfaceGarbageCollected::createPersistentHandle(ScriptWrappableBase* internalPointer) { - return new Persistent(internalPointer->toImpl()); + return WrapperPersistent::create(internalPointer->toImpl()); } template<> diff --git a/Source/bindings/tests/results/V8TestInterfaceGarbageCollected.h b/Source/bindings/tests/results/V8TestInterfaceGarbageCollected.h index 1ddaae25dd2..75bad57e764 100644 --- a/Source/bindings/tests/results/V8TestInterfaceGarbageCollected.h +++ b/Source/bindings/tests/results/V8TestInterfaceGarbageCollected.h @@ -30,7 +30,7 @@ class V8TestInterfaceGarbageCollected { static const WrapperTypeInfo wrapperTypeInfo; static void refObject(ScriptWrappableBase* internalPointer); static void derefObject(ScriptWrappableBase* internalPointer); - static PersistentNode* createPersistentHandle(ScriptWrappableBase* internalPointer); + static WrapperPersistentNode* createPersistentHandle(ScriptWrappableBase* internalPointer); static EventTarget* toEventTarget(v8::Handle); static void constructorCallback(const v8::FunctionCallbackInfo&); static const int eventListenerCacheIndex = v8DefaultWrapperInternalFieldCount + 0; diff --git a/Source/bindings/tests/results/V8TestInterfaceNamedConstructor.cpp b/Source/bindings/tests/results/V8TestInterfaceNamedConstructor.cpp index ec4c4bda432..29d02eebc70 100644 --- a/Source/bindings/tests/results/V8TestInterfaceNamedConstructor.cpp +++ b/Source/bindings/tests/results/V8TestInterfaceNamedConstructor.cpp @@ -192,7 +192,7 @@ void V8TestInterfaceNamedConstructor::derefObject(ScriptWrappableBase* internalP internalPointer->toImpl()->deref(); } -PersistentNode* V8TestInterfaceNamedConstructor::createPersistentHandle(ScriptWrappableBase* internalPointer) +WrapperPersistentNode* V8TestInterfaceNamedConstructor::createPersistentHandle(ScriptWrappableBase* internalPointer) { ASSERT_NOT_REACHED(); return 0; diff --git a/Source/bindings/tests/results/V8TestInterfaceNamedConstructor.h b/Source/bindings/tests/results/V8TestInterfaceNamedConstructor.h index f493294c406..4cdff170819 100644 --- a/Source/bindings/tests/results/V8TestInterfaceNamedConstructor.h +++ b/Source/bindings/tests/results/V8TestInterfaceNamedConstructor.h @@ -35,7 +35,7 @@ class V8TestInterfaceNamedConstructor { static const WrapperTypeInfo wrapperTypeInfo; static void refObject(ScriptWrappableBase* internalPointer); static void derefObject(ScriptWrappableBase* internalPointer); - static PersistentNode* createPersistentHandle(ScriptWrappableBase* internalPointer); + static WrapperPersistentNode* createPersistentHandle(ScriptWrappableBase* internalPointer); static ActiveDOMObject* toActiveDOMObject(v8::Handle); static const int internalFieldCount = v8DefaultWrapperInternalFieldCount + 0; static inline ScriptWrappableBase* toScriptWrappableBase(TestInterfaceNamedConstructor* impl) diff --git a/Source/bindings/tests/results/V8TestInterfaceNamedConstructor2.cpp b/Source/bindings/tests/results/V8TestInterfaceNamedConstructor2.cpp index 995757a76b8..11ba2918830 100644 --- a/Source/bindings/tests/results/V8TestInterfaceNamedConstructor2.cpp +++ b/Source/bindings/tests/results/V8TestInterfaceNamedConstructor2.cpp @@ -127,7 +127,7 @@ void V8TestInterfaceNamedConstructor2::derefObject(ScriptWrappableBase* internal internalPointer->toImpl()->deref(); } -PersistentNode* V8TestInterfaceNamedConstructor2::createPersistentHandle(ScriptWrappableBase* internalPointer) +WrapperPersistentNode* V8TestInterfaceNamedConstructor2::createPersistentHandle(ScriptWrappableBase* internalPointer) { ASSERT_NOT_REACHED(); return 0; diff --git a/Source/bindings/tests/results/V8TestInterfaceNamedConstructor2.h b/Source/bindings/tests/results/V8TestInterfaceNamedConstructor2.h index 1a3ea62d3fe..c13feeda9c8 100644 --- a/Source/bindings/tests/results/V8TestInterfaceNamedConstructor2.h +++ b/Source/bindings/tests/results/V8TestInterfaceNamedConstructor2.h @@ -35,7 +35,7 @@ class V8TestInterfaceNamedConstructor2 { static const WrapperTypeInfo wrapperTypeInfo; static void refObject(ScriptWrappableBase* internalPointer); static void derefObject(ScriptWrappableBase* internalPointer); - static PersistentNode* createPersistentHandle(ScriptWrappableBase* internalPointer); + static WrapperPersistentNode* createPersistentHandle(ScriptWrappableBase* internalPointer); static const int internalFieldCount = v8DefaultWrapperInternalFieldCount + 0; static inline ScriptWrappableBase* toScriptWrappableBase(TestInterfaceNamedConstructor2* impl) { diff --git a/Source/bindings/tests/results/V8TestInterfaceNode.cpp b/Source/bindings/tests/results/V8TestInterfaceNode.cpp index f8891b843e1..3fc0ecc3a55 100644 --- a/Source/bindings/tests/results/V8TestInterfaceNode.cpp +++ b/Source/bindings/tests/results/V8TestInterfaceNode.cpp @@ -355,10 +355,10 @@ void V8TestInterfaceNode::derefObject(ScriptWrappableBase* internalPointer) #endif } -PersistentNode* V8TestInterfaceNode::createPersistentHandle(ScriptWrappableBase* internalPointer) +WrapperPersistentNode* V8TestInterfaceNode::createPersistentHandle(ScriptWrappableBase* internalPointer) { #if ENABLE(OILPAN) - return new Persistent(internalPointer->toImpl()); + return WrapperPersistent::create(internalPointer->toImpl()); #else ASSERT_NOT_REACHED(); return 0; diff --git a/Source/bindings/tests/results/V8TestInterfaceNode.h b/Source/bindings/tests/results/V8TestInterfaceNode.h index 0028790bda4..383da9152a7 100644 --- a/Source/bindings/tests/results/V8TestInterfaceNode.h +++ b/Source/bindings/tests/results/V8TestInterfaceNode.h @@ -30,7 +30,7 @@ class V8TestInterfaceNode { static const WrapperTypeInfo wrapperTypeInfo; static void refObject(ScriptWrappableBase* internalPointer); static void derefObject(ScriptWrappableBase* internalPointer); - static PersistentNode* createPersistentHandle(ScriptWrappableBase* internalPointer); + static WrapperPersistentNode* createPersistentHandle(ScriptWrappableBase* internalPointer); static EventTarget* toEventTarget(v8::Handle); #if ENABLE(OILPAN) static const int persistentHandleIndex = v8DefaultWrapperInternalFieldCount + 0; diff --git a/Source/bindings/tests/results/V8TestInterfaceNotScriptWrappable.cpp b/Source/bindings/tests/results/V8TestInterfaceNotScriptWrappable.cpp index c88c159cb6a..f80fe73048d 100644 --- a/Source/bindings/tests/results/V8TestInterfaceNotScriptWrappable.cpp +++ b/Source/bindings/tests/results/V8TestInterfaceNotScriptWrappable.cpp @@ -158,7 +158,7 @@ void V8TestInterfaceNotScriptWrappable::derefObject(ScriptWrappableBase* interna internalPointer->toImpl()->deref(); } -PersistentNode* V8TestInterfaceNotScriptWrappable::createPersistentHandle(ScriptWrappableBase* internalPointer) +WrapperPersistentNode* V8TestInterfaceNotScriptWrappable::createPersistentHandle(ScriptWrappableBase* internalPointer) { ASSERT_NOT_REACHED(); return 0; diff --git a/Source/bindings/tests/results/V8TestInterfaceNotScriptWrappable.h b/Source/bindings/tests/results/V8TestInterfaceNotScriptWrappable.h index ecb3772ccf1..b7ced7fe344 100644 --- a/Source/bindings/tests/results/V8TestInterfaceNotScriptWrappable.h +++ b/Source/bindings/tests/results/V8TestInterfaceNotScriptWrappable.h @@ -29,7 +29,7 @@ class V8TestInterfaceNotScriptWrappable { static const WrapperTypeInfo wrapperTypeInfo; static void refObject(ScriptWrappableBase* internalPointer); static void derefObject(ScriptWrappableBase* internalPointer); - static PersistentNode* createPersistentHandle(ScriptWrappableBase* internalPointer); + static WrapperPersistentNode* createPersistentHandle(ScriptWrappableBase* internalPointer); static const int internalFieldCount = v8DefaultWrapperInternalFieldCount + 0; static inline ScriptWrappableBase* toScriptWrappableBase(TestInterfaceNotScriptWrappable* impl) { diff --git a/Source/bindings/tests/results/V8TestInterfaceWillBeGarbageCollected.cpp b/Source/bindings/tests/results/V8TestInterfaceWillBeGarbageCollected.cpp index b916b51ee04..7f5372d552b 100644 --- a/Source/bindings/tests/results/V8TestInterfaceWillBeGarbageCollected.cpp +++ b/Source/bindings/tests/results/V8TestInterfaceWillBeGarbageCollected.cpp @@ -231,10 +231,10 @@ void V8TestInterfaceWillBeGarbageCollected::derefObject(ScriptWrappableBase* int #endif } -PersistentNode* V8TestInterfaceWillBeGarbageCollected::createPersistentHandle(ScriptWrappableBase* internalPointer) +WrapperPersistentNode* V8TestInterfaceWillBeGarbageCollected::createPersistentHandle(ScriptWrappableBase* internalPointer) { #if ENABLE(OILPAN) - return new Persistent(internalPointer->toImpl()); + return WrapperPersistent::create(internalPointer->toImpl()); #else ASSERT_NOT_REACHED(); return 0; diff --git a/Source/bindings/tests/results/V8TestInterfaceWillBeGarbageCollected.h b/Source/bindings/tests/results/V8TestInterfaceWillBeGarbageCollected.h index 48678beddb0..40cc337fa94 100644 --- a/Source/bindings/tests/results/V8TestInterfaceWillBeGarbageCollected.h +++ b/Source/bindings/tests/results/V8TestInterfaceWillBeGarbageCollected.h @@ -36,7 +36,7 @@ class V8TestInterfaceWillBeGarbageCollected { static const WrapperTypeInfo wrapperTypeInfo; static void refObject(ScriptWrappableBase* internalPointer); static void derefObject(ScriptWrappableBase* internalPointer); - static PersistentNode* createPersistentHandle(ScriptWrappableBase* internalPointer); + static WrapperPersistentNode* createPersistentHandle(ScriptWrappableBase* internalPointer); static EventTarget* toEventTarget(v8::Handle); static void constructorCallback(const v8::FunctionCallbackInfo&); static const int eventListenerCacheIndex = v8DefaultWrapperInternalFieldCount + 0; diff --git a/Source/bindings/tests/results/V8TestNode.cpp b/Source/bindings/tests/results/V8TestNode.cpp index e3d9364599a..6d2cf94bf7d 100644 --- a/Source/bindings/tests/results/V8TestNode.cpp +++ b/Source/bindings/tests/results/V8TestNode.cpp @@ -244,10 +244,10 @@ void V8TestNode::derefObject(ScriptWrappableBase* internalPointer) #endif } -PersistentNode* V8TestNode::createPersistentHandle(ScriptWrappableBase* internalPointer) +WrapperPersistentNode* V8TestNode::createPersistentHandle(ScriptWrappableBase* internalPointer) { #if ENABLE(OILPAN) - return new Persistent(internalPointer->toImpl()); + return WrapperPersistent::create(internalPointer->toImpl()); #else ASSERT_NOT_REACHED(); return 0; diff --git a/Source/bindings/tests/results/V8TestNode.h b/Source/bindings/tests/results/V8TestNode.h index 14c8bb7c5cd..10b3a9d5513 100644 --- a/Source/bindings/tests/results/V8TestNode.h +++ b/Source/bindings/tests/results/V8TestNode.h @@ -30,7 +30,7 @@ class V8TestNode { static const WrapperTypeInfo wrapperTypeInfo; static void refObject(ScriptWrappableBase* internalPointer); static void derefObject(ScriptWrappableBase* internalPointer); - static PersistentNode* createPersistentHandle(ScriptWrappableBase* internalPointer); + static WrapperPersistentNode* createPersistentHandle(ScriptWrappableBase* internalPointer); static EventTarget* toEventTarget(v8::Handle); static void constructorCallback(const v8::FunctionCallbackInfo&); #if ENABLE(OILPAN) diff --git a/Source/bindings/tests/results/V8TestObject.cpp b/Source/bindings/tests/results/V8TestObject.cpp index 61f20c48373..048cb40b215 100644 --- a/Source/bindings/tests/results/V8TestObject.cpp +++ b/Source/bindings/tests/results/V8TestObject.cpp @@ -10747,7 +10747,7 @@ void V8TestObject::derefObject(ScriptWrappableBase* internalPointer) internalPointer->toImpl()->deref(); } -PersistentNode* V8TestObject::createPersistentHandle(ScriptWrappableBase* internalPointer) +WrapperPersistentNode* V8TestObject::createPersistentHandle(ScriptWrappableBase* internalPointer) { ASSERT_NOT_REACHED(); return 0; diff --git a/Source/bindings/tests/results/V8TestObject.h b/Source/bindings/tests/results/V8TestObject.h index 0f4fa3d3f83..437a5de31c4 100644 --- a/Source/bindings/tests/results/V8TestObject.h +++ b/Source/bindings/tests/results/V8TestObject.h @@ -51,7 +51,7 @@ class V8TestObject { static const WrapperTypeInfo wrapperTypeInfo; static void refObject(ScriptWrappableBase* internalPointer); static void derefObject(ScriptWrappableBase* internalPointer); - static PersistentNode* createPersistentHandle(ScriptWrappableBase* internalPointer); + static WrapperPersistentNode* createPersistentHandle(ScriptWrappableBase* internalPointer); static void customVoidMethodMethodCustom(const v8::FunctionCallbackInfo&); #if ENABLE(CONDITION) static void conditionalConditionCustomVoidMethodMethodCustom(const v8::FunctionCallbackInfo&); diff --git a/Source/bindings/tests/results/V8TestSpecialOperations.cpp b/Source/bindings/tests/results/V8TestSpecialOperations.cpp index 66b4fc37c00..c233e41c898 100644 --- a/Source/bindings/tests/results/V8TestSpecialOperations.cpp +++ b/Source/bindings/tests/results/V8TestSpecialOperations.cpp @@ -211,7 +211,7 @@ void V8TestSpecialOperations::derefObject(ScriptWrappableBase* internalPointer) internalPointer->toImpl()->deref(); } -PersistentNode* V8TestSpecialOperations::createPersistentHandle(ScriptWrappableBase* internalPointer) +WrapperPersistentNode* V8TestSpecialOperations::createPersistentHandle(ScriptWrappableBase* internalPointer) { ASSERT_NOT_REACHED(); return 0; diff --git a/Source/bindings/tests/results/V8TestSpecialOperations.h b/Source/bindings/tests/results/V8TestSpecialOperations.h index 083af71850a..ce25f02f070 100644 --- a/Source/bindings/tests/results/V8TestSpecialOperations.h +++ b/Source/bindings/tests/results/V8TestSpecialOperations.h @@ -29,7 +29,7 @@ class V8TestSpecialOperations { static const WrapperTypeInfo wrapperTypeInfo; static void refObject(ScriptWrappableBase* internalPointer); static void derefObject(ScriptWrappableBase* internalPointer); - static PersistentNode* createPersistentHandle(ScriptWrappableBase* internalPointer); + static WrapperPersistentNode* createPersistentHandle(ScriptWrappableBase* internalPointer); static const int internalFieldCount = v8DefaultWrapperInternalFieldCount + 0; static inline ScriptWrappableBase* toScriptWrappableBase(TestSpecialOperations* impl) { diff --git a/Source/bindings/tests/results/V8TestSpecialOperationsNotEnumerable.cpp b/Source/bindings/tests/results/V8TestSpecialOperationsNotEnumerable.cpp index c3fc4b5d7f2..0c4eb99980e 100644 --- a/Source/bindings/tests/results/V8TestSpecialOperationsNotEnumerable.cpp +++ b/Source/bindings/tests/results/V8TestSpecialOperationsNotEnumerable.cpp @@ -121,7 +121,7 @@ void V8TestSpecialOperationsNotEnumerable::derefObject(ScriptWrappableBase* inte internalPointer->toImpl()->deref(); } -PersistentNode* V8TestSpecialOperationsNotEnumerable::createPersistentHandle(ScriptWrappableBase* internalPointer) +WrapperPersistentNode* V8TestSpecialOperationsNotEnumerable::createPersistentHandle(ScriptWrappableBase* internalPointer) { ASSERT_NOT_REACHED(); return 0; diff --git a/Source/bindings/tests/results/V8TestSpecialOperationsNotEnumerable.h b/Source/bindings/tests/results/V8TestSpecialOperationsNotEnumerable.h index ab6eece6987..7f610c75875 100644 --- a/Source/bindings/tests/results/V8TestSpecialOperationsNotEnumerable.h +++ b/Source/bindings/tests/results/V8TestSpecialOperationsNotEnumerable.h @@ -29,7 +29,7 @@ class V8TestSpecialOperationsNotEnumerable { static const WrapperTypeInfo wrapperTypeInfo; static void refObject(ScriptWrappableBase* internalPointer); static void derefObject(ScriptWrappableBase* internalPointer); - static PersistentNode* createPersistentHandle(ScriptWrappableBase* internalPointer); + static WrapperPersistentNode* createPersistentHandle(ScriptWrappableBase* internalPointer); static const int internalFieldCount = v8DefaultWrapperInternalFieldCount + 0; static inline ScriptWrappableBase* toScriptWrappableBase(TestSpecialOperationsNotEnumerable* impl) { diff --git a/Source/bindings/tests/results/V8TestTypedefs.cpp b/Source/bindings/tests/results/V8TestTypedefs.cpp index 89b1803f112..0986be7207f 100644 --- a/Source/bindings/tests/results/V8TestTypedefs.cpp +++ b/Source/bindings/tests/results/V8TestTypedefs.cpp @@ -376,7 +376,7 @@ void V8TestTypedefs::derefObject(ScriptWrappableBase* internalPointer) internalPointer->toImpl()->deref(); } -PersistentNode* V8TestTypedefs::createPersistentHandle(ScriptWrappableBase* internalPointer) +WrapperPersistentNode* V8TestTypedefs::createPersistentHandle(ScriptWrappableBase* internalPointer) { ASSERT_NOT_REACHED(); return 0; diff --git a/Source/bindings/tests/results/V8TestTypedefs.h b/Source/bindings/tests/results/V8TestTypedefs.h index 40c63937189..85364a88950 100644 --- a/Source/bindings/tests/results/V8TestTypedefs.h +++ b/Source/bindings/tests/results/V8TestTypedefs.h @@ -29,7 +29,7 @@ class V8TestTypedefs { static const WrapperTypeInfo wrapperTypeInfo; static void refObject(ScriptWrappableBase* internalPointer); static void derefObject(ScriptWrappableBase* internalPointer); - static PersistentNode* createPersistentHandle(ScriptWrappableBase* internalPointer); + static WrapperPersistentNode* createPersistentHandle(ScriptWrappableBase* internalPointer); static void constructorCallback(const v8::FunctionCallbackInfo&); static const int internalFieldCount = v8DefaultWrapperInternalFieldCount + 0; static inline ScriptWrappableBase* toScriptWrappableBase(TestTypedefs* impl) diff --git a/Source/core/inspector/InjectedScriptManager.cpp b/Source/core/inspector/InjectedScriptManager.cpp index c402941d615..0cc27c1b593 100644 --- a/Source/core/inspector/InjectedScriptManager.cpp +++ b/Source/core/inspector/InjectedScriptManager.cpp @@ -42,6 +42,13 @@ namespace blink { +#if ENABLE(OILPAN) +InjectedScriptManager::CallbackData::~CallbackData() +{ + WrapperPersistent::destroy(hostPtr); +} +#endif + PassOwnPtrWillBeRawPtr InjectedScriptManager::createForPage() { return adoptPtrWillBeNoop(new InjectedScriptManager(&InjectedScriptManager::canAccessInspectedWindow)); diff --git a/Source/core/inspector/InjectedScriptManager.h b/Source/core/inspector/InjectedScriptManager.h index 289613a5dbf..f35fb937731 100644 --- a/Source/core/inspector/InjectedScriptManager.h +++ b/Source/core/inspector/InjectedScriptManager.h @@ -49,8 +49,17 @@ class InjectedScriptManager : public NoBaseWillBeGarbageCollectedFinalized handle; - RefPtrWillBePersistent host; +#if ENABLE(OILPAN) + WrapperPersistent* hostPtr; +#else + RefPtr host; +#endif InjectedScriptManager* injectedScriptManager; + +#if ENABLE(OILPAN) + CallbackData() : hostPtr(0) { } + ~CallbackData(); +#endif }; static PassOwnPtrWillBeRawPtr createForPage(); diff --git a/Source/platform/heap/BUILD.gn b/Source/platform/heap/BUILD.gn index 8a4c2cc50bb..b8f67d08be2 100644 --- a/Source/platform/heap/BUILD.gn +++ b/Source/platform/heap/BUILD.gn @@ -7,6 +7,7 @@ visibility = [ "//third_party/WebKit/Source/*" ] source_set("heap") { sources = [ "AddressSanitizer.h", + "Handle.cpp", "Handle.h", "Heap.cpp", "Heap.h", diff --git a/Source/platform/heap/Handle.cpp b/Source/platform/heap/Handle.cpp new file mode 100644 index 00000000000..f1cf96c6611 --- /dev/null +++ b/Source/platform/heap/Handle.cpp @@ -0,0 +1,77 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "config.h" +#include "platform/heap/Handle.h" + +namespace blink { + +bool WrapperPersistentRegion::removeIfNotLast(WrapperPersistentRegion** headPtr) +{ + ASSERT(!m_count); + // We are the last region in the list if both the region's m_prev and + // m_next are 0. + if (!m_prev && !m_next) + return false; + if (m_prev) { + m_prev->m_next = m_next; + } else { + ASSERT(*headPtr == this); + *headPtr = m_next; + } + if (m_next) + m_next->m_prev = m_prev; + m_prev = 0; + m_next = 0; + return true; +} + +void WrapperPersistentRegion::insertHead(WrapperPersistentRegion** headPtr, WrapperPersistentRegion* newHead) +{ + ASSERT(headPtr); + WrapperPersistentRegion* oldHead = *headPtr; + if (oldHead) { + ASSERT(!oldHead->m_prev); + oldHead->m_prev = newHead; + } + newHead->m_prev = 0; + newHead->m_next = oldHead; + *headPtr = newHead; +} + +WrapperPersistentRegion* WrapperPersistentRegion::removeHead(WrapperPersistentRegion** headPtr) +{ + // We only call this if there is at least one element in the list. + ASSERT(headPtr && *headPtr); + WrapperPersistentRegion* oldHead = *headPtr; + ASSERT(!oldHead->m_prev); + *headPtr = oldHead->m_next; + oldHead->m_next = 0; + ASSERT(!(*headPtr) || (*headPtr)->m_prev == oldHead); + if (*headPtr) + (*headPtr)->m_prev = 0; + return oldHead; +} + +Address WrapperPersistentRegion::outOfLineAllocate(ThreadState* state, WrapperPersistentRegion** regionPtr) +{ + Address persistentSlot = 0; + // The caller has already tried allocating in the passed-in region, start + // from the next. + for (WrapperPersistentRegion* current = (*regionPtr)->m_next; current; current = current->m_next) { + persistentSlot = current->allocate(); + if (persistentSlot) { + *regionPtr = current; + return persistentSlot; + } + } + ASSERT(!persistentSlot); + WrapperPersistentRegion* newRegion = state->takeWrapperPersistentRegion(); + persistentSlot = newRegion->allocate(); + *regionPtr = newRegion; + ASSERT(persistentSlot); + return persistentSlot; +} + +} diff --git a/Source/platform/heap/Handle.h b/Source/platform/heap/Handle.h index 62c77340532..277b9f7b6be 100644 --- a/Source/platform/heap/Handle.h +++ b/Source/platform/heap/Handle.h @@ -150,6 +150,199 @@ class PersistentNode { friend class ThreadState; }; + +const int wrapperPersistentsPerRegion = 256; +const size_t wrapperPersistentOffsetMask = ~static_cast(3); +const size_t wrapperPersistentLiveBitMask = 1; + +class WrapperPersistentNode { + ALLOW_ONLY_INLINE_ALLOCATION(); + WTF_MAKE_NONCOPYABLE(WrapperPersistentNode); +public: + bool isAlive() { return m_regionOffset & wrapperPersistentLiveBitMask; } + + WrapperPersistentRegion* region() + { + return reinterpret_cast( + reinterpret_cast
(this) - regionOffset()); + } + + virtual void trace(Visitor* visitor) { } + + static inline void destroy(const WrapperPersistentNode*); + +protected: + WrapperPersistentNode() : m_raw(0), m_regionOffset(0) { } + WrapperPersistentNode(void *raw, size_t regionOffset) : m_raw(raw), m_regionOffset(regionOffset) { } + +private: + size_t regionOffset() { return m_regionOffset & wrapperPersistentOffsetMask; } + + WrapperPersistentNode* takeSlot() + { + // The slot should not be alive at the point where it is allocated. + ASSERT(!isAlive()); + WrapperPersistentNode* nextFree = reinterpret_cast(m_raw); + m_raw = 0; + return nextFree; + } + + WrapperPersistentNode* freeSlot(WrapperPersistentNode* nextFree) + { + m_regionOffset &= ~wrapperPersistentLiveBitMask; + m_raw = nextFree; + return this; + } + + // Don't allow delete being called on wrapper persistent nodes. We + // do use placement new to initialize the slot with the right vtable. See + // WrapperPersistent below. + void operator delete(void*); + +protected: + // m_raw is used both to point to the object when the WrapperPersistentNode is used/alive + // and to point to the next free wrapperPersistentNode in the region when the node is + // unused/dead. + void* m_raw; + + // The m_regionOffset field encodes liveness of the slot as well as being an + // offset from this node to the base of the containing WrapperPersistentRegion. + size_t m_regionOffset; + + friend class WrapperPersistentRegion; +}; + +template +class WrapperPersistent FINAL : public WrapperPersistentNode { + ALLOW_ONLY_INLINE_ALLOCATION(); +public: + static WrapperPersistent* create(T* raw); + + virtual void trace(Visitor* visitor) OVERRIDE + { + ASSERT(isAlive()); + visitor->mark(static_cast(m_raw)); + } + +private: + WrapperPersistent() { } + + // We need to use a constructor to initialize the allocated slot since it + // has a vtable which must be set to the WrapperPersistent type. + WrapperPersistent(T* raw, size_t regionOffset) : WrapperPersistentNode(raw, regionOffset) { } + + // Don't allow delete being called on wrapper persistents. + void operator delete(void*); +}; + +class PLATFORM_EXPORT WrapperPersistentRegion { + WTF_MAKE_NONCOPYABLE(WrapperPersistentRegion); +public: + WrapperPersistentRegion() + { + WrapperPersistentNode* nextFree = 0; + for (int i = wrapperPersistentsPerRegion - 1; i >= 0; --i) { + size_t regionOffset = reinterpret_cast
(&m_entries[i]) - reinterpret_cast
(this); + // Setup the free slot with an offset to the containing region's base and a pointer to the next + // free slot in the region. + ASSERT(!(regionOffset & ~wrapperPersistentOffsetMask)); + new (&m_entries[i]) WrapperPersistentNode(nextFree, regionOffset); + nextFree = &m_entries[i]; + } + m_prev = 0; + m_next = 0; + m_freeHead = nextFree; + m_count = 0; + } + + Address allocate() + { + if (!m_freeHead) { + ASSERT(m_count == wrapperPersistentsPerRegion); + return 0; + } + // We have a free persistent slot in this region. + WrapperPersistentNode* freeSlot = m_freeHead; + // Take the slot and advance m_freeHead to the next free slot. + m_freeHead = freeSlot->takeSlot(); + ASSERT(m_count < wrapperPersistentsPerRegion); + m_count++; + return reinterpret_cast
(freeSlot); + } + + void free(WrapperPersistentNode* object) + { + ASSERT(object); + m_freeHead = object->freeSlot(m_freeHead); + ASSERT(m_count > 0); + m_count--; + if (!m_count) + ThreadState::current()->freeWrapperPersistentRegion(this); + } + + bool removeIfNotLast(WrapperPersistentRegion** headPtr); + static void insertHead(WrapperPersistentRegion** headPtr, WrapperPersistentRegion* newHead); + static WrapperPersistentRegion* removeHead(WrapperPersistentRegion** headPtr); + static Address outOfLineAllocate(ThreadState*, WrapperPersistentRegion**); + static void trace(WrapperPersistentRegion* head, Visitor* visitor) + { + for (WrapperPersistentRegion* current = head; current; current = current->m_next) + current->traceRegion(visitor); + } + +private: + void traceRegion(Visitor* visitor) + { + size_t live = 0; + +#ifdef NDEBUG + for (int i = 0; i < wrapperPersistentsPerRegion && live < m_count; ++i) { +#else + // In DEBUG mode we scan all entries to validate we only have m_count + // live entries. + for (int i = 0; i < wrapperPersistentsPerRegion; ++i) { +#endif + if (m_entries[i].isAlive()) { + m_entries[i].trace(visitor); + live++; + } + } + ASSERT(live == m_count); + } + + WrapperPersistentRegion* m_prev; + WrapperPersistentRegion* m_next; + WrapperPersistentNode* m_freeHead; + size_t m_count; + WrapperPersistentNode m_entries[wrapperPersistentsPerRegion]; +}; + +template +WrapperPersistent* WrapperPersistent::create(T* raw) +{ + ThreadState* state = ThreadState::current(); + WrapperPersistentRegion* region = state->wrapperRoots(); + ASSERT(region); + Address persistentSlot = region->allocate(); + if (!persistentSlot) + persistentSlot = WrapperPersistentRegion::outOfLineAllocate(state, ®ion); + ASSERT(persistentSlot); + ASSERT(!reinterpret_cast(persistentSlot)->isAlive()); + + size_t regionOffset = persistentSlot - reinterpret_cast
(region); + regionOffset |= wrapperPersistentLiveBitMask; + + // We use placement new to call the constructor to ensure that we setup the + // vtable correctly. + return new (persistentSlot) WrapperPersistent(raw, regionOffset); +} + +void WrapperPersistentNode::destroy(const WrapperPersistentNode* node) +{ + WrapperPersistentNode* persistent = const_cast(node); + persistent->region()->free(persistent); +} + // RootsAccessor for Persistent that provides access to thread-local list // of persistent handles. Can only be used to create handles that // are constructed and destructed on the same thread. diff --git a/Source/platform/heap/ThreadState.cpp b/Source/platform/heap/ThreadState.cpp index dc651aece9d..be6bedd19b9 100644 --- a/Source/platform/heap/ThreadState.cpp +++ b/Source/platform/heap/ThreadState.cpp @@ -95,6 +95,9 @@ static void* getStackStart() #endif } +// The maximum number of WrapperPersistentRegions to keep around in the +// m_pooledWrapperPersistentRegions pool. +static const size_t MaxPooledWrapperPersistentRegionCount = 2; WTF::ThreadSpecific* ThreadState::s_threadSpecific = 0; uint8_t ThreadState::s_mainThreadStateStorage[sizeof(ThreadState)]; @@ -265,7 +268,6 @@ class SafePointBarrier { ThreadCondition m_resume; }; - BaseHeapPage::BaseHeapPage(PageMemory* storage, const GCInfo* gcInfo, ThreadState* state) : m_storage(storage) , m_gcInfo(gcInfo) @@ -292,6 +294,9 @@ template<> struct InitializeHeaps<0> { ThreadState::ThreadState() : m_thread(currentThread()) + , m_liveWrapperPersistents(new WrapperPersistentRegion()) + , m_pooledWrapperPersistents(0) + , m_pooledWrapperPersistentRegionCount(0) , m_persistents(adoptPtr(new PersistentAnchor())) , m_startOfStack(reinterpret_cast(getStackStart())) , m_endOfStack(reinterpret_cast(getStackStart())) @@ -330,6 +335,14 @@ ThreadState::~ThreadState() for (int i = 0; i < NumberOfHeaps; i++) delete m_heaps[i]; deleteAllValues(m_interruptors); + while (m_liveWrapperPersistents) { + WrapperPersistentRegion* region = WrapperPersistentRegion::removeHead(&m_liveWrapperPersistents); + delete region; + } + while (m_pooledWrapperPersistents) { + WrapperPersistentRegion* region = WrapperPersistentRegion::removeHead(&m_pooledWrapperPersistents); + delete region; + } **s_threadSpecific = 0; } @@ -561,6 +574,7 @@ void ThreadState::visitStack(Visitor* visitor) void ThreadState::visitPersistents(Visitor* visitor) { m_persistents->trace(visitor); + WrapperPersistentRegion::trace(m_liveWrapperPersistents, visitor); } bool ThreadState::checkAndMarkPointer(Visitor* visitor, Address address) @@ -680,6 +694,34 @@ bool ThreadState::popAndInvokeWeakPointerCallback(Visitor* visitor) return m_weakCallbackStack->popAndInvokeCallback(&m_weakCallbackStack, visitor); } +WrapperPersistentRegion* ThreadState::takeWrapperPersistentRegion() +{ + WrapperPersistentRegion* region; + if (m_pooledWrapperPersistentRegionCount) { + region = WrapperPersistentRegion::removeHead(&m_pooledWrapperPersistents); + m_pooledWrapperPersistentRegionCount--; + } else { + region = new WrapperPersistentRegion(); + } + ASSERT(region); + WrapperPersistentRegion::insertHead(&m_liveWrapperPersistents, region); + return region; +} + +void ThreadState::freeWrapperPersistentRegion(WrapperPersistentRegion* region) +{ + if (!region->removeIfNotLast(&m_liveWrapperPersistents)) + return; + + // Region was removed, ie. it was not the last region in the list. + if (m_pooledWrapperPersistentRegionCount < MaxPooledWrapperPersistentRegionCount) { + WrapperPersistentRegion::insertHead(&m_pooledWrapperPersistents, region); + m_pooledWrapperPersistentRegionCount++; + } else { + delete region; + } +} + PersistentNode* ThreadState::globalRoots() { AtomicallyInitializedStatic(PersistentNode*, anchor = new PersistentAnchor); diff --git a/Source/platform/heap/ThreadState.h b/Source/platform/heap/ThreadState.h index f8be43aba42..53c0cd0966d 100644 --- a/Source/platform/heap/ThreadState.h +++ b/Source/platform/heap/ThreadState.h @@ -56,6 +56,7 @@ class HeapContainsCache; class HeapObjectHeader; class PageMemory; class PersistentNode; +class WrapperPersistentRegion; class Visitor; class SafePointBarrier; class SafePointAwareMutexLocker; @@ -546,6 +547,14 @@ class PLATFORM_EXPORT ThreadState { BaseHeapPage* contains(void* pointer) { return contains(reinterpret_cast
(pointer)); } BaseHeapPage* contains(const void* pointer) { return contains(const_cast(pointer)); } + WrapperPersistentRegion* wrapperRoots() const + { + ASSERT(m_liveWrapperPersistents); + return m_liveWrapperPersistents; + } + WrapperPersistentRegion* takeWrapperPersistentRegion(); + void freeWrapperPersistentRegion(WrapperPersistentRegion*); + // List of persistent roots allocated on the given thread. PersistentNode* roots() const { return m_persistents.get(); } @@ -670,6 +679,9 @@ class PLATFORM_EXPORT ThreadState { static uint8_t s_mainThreadStateStorage[]; ThreadIdentifier m_thread; + WrapperPersistentRegion* m_liveWrapperPersistents; + WrapperPersistentRegion* m_pooledWrapperPersistents; + size_t m_pooledWrapperPersistentRegionCount; OwnPtr m_persistents; StackState m_stackState; intptr_t* m_startOfStack; diff --git a/Source/platform/heap/blink_heap.gypi b/Source/platform/heap/blink_heap.gypi index 696547941ff..34e032a5089 100644 --- a/Source/platform/heap/blink_heap.gypi +++ b/Source/platform/heap/blink_heap.gypi @@ -32,6 +32,7 @@ 'variables': { 'platform_heap_files': [ 'AddressSanitizer.h', + 'Handle.cpp', 'Handle.h', 'Heap.cpp', 'Heap.h',