Changeset 78634 in webkit for trunk/Source/JavaScriptCore/runtime/Structure.cpp
- Timestamp:
- Feb 15, 2011, 3:54:06 PM (14 years ago)
- Author:
- [email protected]
- Message:
-
2011-02-14 Oliver Hunt <[email protected]>
Reviewed by Gavin Barraclough and Geoff Garen.
Refactor handles and weak pointers to become nicer and more automatic
https://bugs.webkit.org/show_bug.cgi?id=54415
Move to a true handle based mechanism for GC value protection. This
also allows us to switch to a more sensible behaviour for weak pointers
in which weak pointers are automatically updated.
This allows us to remove the old (and convoluted) that required all
objects that may be held by a weak reference to be aware of the reference
and manually clear them in their destructors.
This also adds a few new data types to JSC that we use to efficiently
allocate and return the underlying handle storage.
This patch is largely renaming and removing now unnecessary destructors
from objects.
- API/JSClassRef.cpp: (OpaqueJSClass::create): (OpaqueJSClassContextData::OpaqueJSClassContextData): (OpaqueJSClass::contextData): (OpaqueJSClass::prototype):
- API/JSClassRef.h:
- CMakeLists.txt:
- GNUmakefile.am:
- JavaScriptCore.exp:
- JavaScriptCore.gypi:
- JavaScriptCore.pro:
- JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def:
- JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj:
- JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCoreCommon.vsprops:
- JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCoreGenerated.make:
- JavaScriptCore.vcproj/WTF/WTF.vcproj:
- JavaScriptCore.vcproj/jsc/jscCommon.vsprops:
- JavaScriptCore.xcodeproj/project.pbxproj:
- collector/handles/Global.h: Added.
New Global handle type used to keep gc objects live, even if they're not
marked.
(JSC::Global::Global):
(JSC::Global::~Global):
(JSC::Global::set):
We can only assign directly to a global from another global.
In all other cases we need the JSGlobalData to be provided
explicitly so we use a set function.
(JSC::Global::operator=):
(JSC::Global::clear):
(JSC::Global::isHashTableDeletedValue):
(JSC::Global::internalSet):
- collector/handles/Handle.h: Added.
Root "Handle" type used for immutable handles and to provide the basic
APIs needed for pointer-like behaviour.
(JSC::HandleBase::operator!):
(JSC::HandleBase::operator UnspecifiedBoolType*):
(JSC::HandleBase::isEmpty):
(JSC::HandleBase::HandleBase):
(JSC::HandleBase::slot):
(JSC::HandleBase::invalidate):
(JSC::HandleBase::setSlot):
(JSC::HandleTypes::getFromSlot):
(JSC::HandleTypes::toJSValue):
(JSC::HandleTypes::validateUpcast):
(JSC::HandleConverter::operator->):
(JSC::HandleConverter::operator*):
(JSC::Handle::Handle):
(JSC::Handle::get):
(JSC::Handle::wrapSlot):
(JSC::operator==):
(JSC::operator!=):
- collector/handles/HandleHeap.cpp: Added.
New heap for global handles.
(JSC::HandleHeap::HandleHeap):
(JSC::HandleHeap::grow):
(JSC::HandleHeap::markStrongHandles):
(JSC::HandleHeap::updateAfterMark):
(JSC::HandleHeap::clearWeakPointers):
(JSC::HandleHeap::writeBarrier):
- collector/handles/HandleHeap.h: Added. (JSC::HandleHeap::heapFor): (JSC::HandleHeap::toHandle): (JSC::HandleHeap::toNode): (JSC::HandleHeap::allocate): (JSC::HandleHeap::deallocate): (JSC::HandleHeap::makeWeak):
Convert a hard handle into weak handle that does not
protect the object it points to.
(JSC::HandleHeap::makeSelfDestroying):
Converts a handle to a weak handle that will be returned
to the free list when the referenced object dies.
(JSC::HandleHeap::Node::Node):
(JSC::HandleHeap::Node::slot):
(JSC::HandleHeap::Node::handleHeap):
(JSC::HandleHeap::Node::setFinalizer):
(JSC::HandleHeap::Node::makeWeak):
(JSC::HandleHeap::Node::isWeak):
(JSC::HandleHeap::Node::makeSelfDestroying):
(JSC::HandleHeap::Node::isSelfDestroying):
(JSC::HandleHeap::Node::finalizer):
(JSC::HandleHeap::Node::setPrev):
(JSC::HandleHeap::Node::prev):
(JSC::HandleHeap::Node::setNext):
(JSC::HandleHeap::Node::next):
- interpreter/Interpreter.cpp: (JSC::Interpreter::Interpreter):
- interpreter/Interpreter.h:
- interpreter/RegisterFile.cpp: (JSC::RegisterFile::globalObjectCollected):
- interpreter/RegisterFile.h: (JSC::RegisterFile::RegisterFile):
- runtime/GCHandle.cpp: Removed.
- runtime/GCHandle.h: Removed.
- runtime/Heap.cpp: (JSC::Heap::Heap): (JSC::Heap::destroy): (JSC::Heap::markRoots):
- runtime/Heap.h: (JSC::Heap::allocateGlobalHandle): (JSC::Heap::reportExtraMemoryCost):
- runtime/JSGlobalData.cpp: (JSC::JSGlobalData::JSGlobalData):
- runtime/JSGlobalData.h: (JSC::JSGlobalData::allocateGlobalHandle):
- runtime/JSGlobalObject.cpp: (JSC::JSGlobalObject::~JSGlobalObject):
- runtime/JSPropertyNameIterator.cpp: (JSC::JSPropertyNameIterator::create): (JSC::JSPropertyNameIterator::~JSPropertyNameIterator):
- runtime/JSPropertyNameIterator.h: (JSC::JSPropertyNameIterator::createStructure): (JSC::Structure::setEnumerationCache): (JSC::Structure::clearEnumerationCache):
- runtime/Protect.h:
- runtime/Structure.cpp: (JSC::Structure::~Structure):
- runtime/Structure.h:
- runtime/WeakGCPtr.h: (JSC::WeakGCPtrBase::get): (JSC::WeakGCPtrBase::clear): (JSC::WeakGCPtrBase::operator!): (JSC::WeakGCPtrBase::operator UnspecifiedBoolType*): (JSC::WeakGCPtrBase::~WeakGCPtrBase): (JSC::WeakGCPtrBase::WeakGCPtrBase): (JSC::WeakGCPtrBase::internalSet): (JSC::LazyWeakGCPtr::LazyWeakGCPtr): (JSC::LazyWeakGCPtr::set): (JSC::WeakGCPtr::WeakGCPtr): (JSC::WeakGCPtr::operator=):
- runtime/WriteBarrier.h:
- wtf/BlockStack.h: Added. (WTF::::BlockStack): (WTF::::~BlockStack): (WTF::::blocks): (WTF::::grow): (WTF::::shrink):
- wtf/SentinelLinkedList.h: Added. (WTF::::SentinelLinkedList): (WTF::::begin): (WTF::::end): (WTF::::push): (WTF::::remove):
- wtf/SinglyLinkedList.h: Added. (WTF::::SinglyLinkedList): (WTF::::isEmpty): (WTF::::push): (WTF::::pop):
2011-02-14 Oliver Hunt <[email protected]>
Reviewed by Gavin Barraclough and Geoff Garen.
Refactor handles and weak pointers to become nicer and more automatic
https://bugs.webkit.org/show_bug.cgi?id=54415
Update to use new Global<> type
- JSRun.cpp: (JSRun::JSRun): (JSRun::GlobalObject):
- JSRun.h:
- JSValueWrapper.cpp: (JSValueWrapper::JSValueWrapper):
- JSValueWrapper.h:
2011-02-14 Oliver Hunt <[email protected]>
Reviewed by Gavin Barraclough and Geoff Garen.
Refactor handles and weak pointers to become nicer and more automatic
https://bugs.webkit.org/show_bug.cgi?id=54415
Update WebCore to use the new Global<> type rather than ProtectedJSValue
and gc[Un]Protect. Also update to use new WeakGCPtr APIs, and remove now
unnecessary destructors.
- ForwardingHeaders/collector/handles/Global.h: Added.
- WebCore.vcproj/WebCore.vcproj:
- WebCore.vcproj/copyForwardingHeaders.cmd:
- bindings/js/JSCallbackData.h: (WebCore::JSCallbackData::JSCallbackData):
- bindings/js/JSCustomVoidCallback.h:
- bindings/js/JSDOMBinding.cpp: (WebCore::forgetDOMNode): (WebCore::cacheDOMNodeWrapper):
- bindings/js/JSDOMWindowBase.h:
- bindings/js/JSDOMWindowShell.cpp: (WebCore::JSDOMWindowShell::setWindow):
- bindings/js/JSDataGridDataSource.h:
- bindings/js/JSEventListener.cpp: (WebCore::JSEventListener::JSEventListener):
- bindings/js/JSEventListener.h: (WebCore::JSEventListener::setWrapper):
- bindings/js/JSLazyEventListener.cpp: (WebCore::JSLazyEventListener::initializeJSFunction):
- bindings/js/ScheduledAction.cpp: (WebCore::ScheduledAction::ScheduledAction): (WebCore::ScheduledAction::executeFunctionInContext):
- bindings/js/ScheduledAction.h: (WebCore::ScheduledAction::ScheduledAction):
- bindings/js/ScriptCachedFrameData.cpp: (WebCore::ScriptCachedFrameData::ScriptCachedFrameData): (WebCore::ScriptCachedFrameData::restore):
- bindings/js/ScriptCachedFrameData.h:
- bindings/js/ScriptCallStackFactory.cpp: (WebCore::createScriptArguments):
- bindings/js/ScriptController.cpp: (WebCore::ScriptController::createWindowShell): (WebCore::ScriptController::evaluateInWorld): (WebCore::ScriptController::clearWindowShell): (WebCore::ScriptController::attachDebugger):
- bindings/js/ScriptController.h:
- bindings/js/ScriptFunctionCall.cpp: (WebCore::ScriptFunctionCall::call): (WebCore::ScriptCallback::call):
- bindings/js/ScriptObject.cpp: (WebCore::ScriptObject::ScriptObject):
- bindings/js/ScriptObject.h:
- bindings/js/ScriptState.cpp: (WebCore::ScriptStateProtectedPtr::ScriptStateProtectedPtr): (WebCore::ScriptStateProtectedPtr::get):
- bindings/js/ScriptState.h:
- bindings/js/ScriptValue.cpp: (WebCore::ScriptValue::isFunction): (WebCore::ScriptValue::deserialize):
- bindings/js/ScriptValue.h: (WebCore::ScriptValue::ScriptValue): (WebCore::ScriptValue::hasNoValue):
- bindings/js/ScriptWrappable.h: (WebCore::ScriptWrappable::ScriptWrappable): (WebCore::ScriptWrappable::setWrapper):
- bindings/js/WorkerScriptController.cpp: (WebCore::WorkerScriptController::WorkerScriptController): (WebCore::WorkerScriptController::~WorkerScriptController): (WebCore::WorkerScriptController::initScript): (WebCore::WorkerScriptController::evaluate):
- bindings/js/WorkerScriptController.h: (WebCore::WorkerScriptController::workerContextWrapper):
- bindings/scripts/CodeGeneratorJS.pm:
- bridge/NP_jsobject.cpp: (_NPN_InvokeDefault): (_NPN_Invoke): (_NPN_Evaluate): (_NPN_Construct):
- bridge/jsc/BridgeJSC.cpp: (JSC::Bindings::Instance::Instance): (JSC::Bindings::Instance::~Instance): (JSC::Bindings::Instance::willDestroyRuntimeObject): (JSC::Bindings::Instance::willInvalidateRuntimeObject):
- bridge/jsc/BridgeJSC.h:
- bridge/runtime_object.cpp: (JSC::Bindings::RuntimeObject::invalidate):
- bridge/runtime_root.cpp: (JSC::Bindings::RootObject::RootObject): (JSC::Bindings::RootObject::invalidate): (JSC::Bindings::RootObject::globalObject): (JSC::Bindings::RootObject::updateGlobalObject):
- bridge/runtime_root.h:
- dom/EventListener.h:
- dom/EventTarget.h: (WebCore::EventTarget::markJSEventListeners):
- xml/XMLHttpRequest.cpp:
Qt bindings courtesy of Csaba Osztrogonác
- bridge/qt/qt_runtime.cpp: (JSC::Bindings::QtRuntimeConnectionMethod::call): (JSC::Bindings::QtConnectionObject::QtConnectionObject): (JSC::Bindings::QtConnectionObject::execute): (JSC::Bindings::QtConnectionObject::match):
- bridge/qt/qt_runtime.h:
2011-02-14 Oliver Hunt <[email protected]>
Reviewed by Gavin Barraclough and Geoff Garen.
Refactor handles and weak pointers to become nicer and more automatic
https://bugs.webkit.org/show_bug.cgi?id=54415
Update to use Global<> instead of ProtectedPtr, and refactored slightly
to get global data to places it's needed for when we're assigning to
Global<>s
- ForwardingHeaders/collector/handles/Global.h: Added.
- Plugins/Hosted/NetscapePluginInstanceProxy.h:
- Plugins/Hosted/NetscapePluginInstanceProxy.mm: (WebKit::NetscapePluginInstanceProxy::LocalObjectMap::get): (WebKit::NetscapePluginInstanceProxy::LocalObjectMap::idForObject): (WebKit::NetscapePluginInstanceProxy::LocalObjectMap::forget): (WebKit::NetscapePluginInstanceProxy::getWindowNPObject): (WebKit::NetscapePluginInstanceProxy::getPluginElementNPObject): (WebKit::NetscapePluginInstanceProxy::evaluate): (WebKit::NetscapePluginInstanceProxy::invoke): (WebKit::NetscapePluginInstanceProxy::invokeDefault): (WebKit::NetscapePluginInstanceProxy::construct): (WebKit::NetscapePluginInstanceProxy::addValueToArray):
- WebView/WebScriptDebugger.h:
- WebView/WebScriptDebugger.mm: (WebScriptDebugger::WebScriptDebugger):
2011-02-14 Oliver Hunt <[email protected]>
Reviewed by Gavin Barraclough and Geoff Garen.
Refactor handles and weak pointers to become nicer and more automatic
https://bugs.webkit.org/show_bug.cgi?id=54415
Update code to new Global<> API, and refactor to get global data to
necessary points.
- WebProcess/Plugins/Netscape/NPJSObject.cpp: (WebKit::NPJSObject::create): (WebKit::NPJSObject::NPJSObject): (WebKit::NPJSObject::initialize): (WebKit::NPJSObject::invokeDefault): (WebKit::NPJSObject::construct): (WebKit::NPJSObject::invoke):
- WebProcess/Plugins/Netscape/NPJSObject.h:
- WebProcess/Plugins/Netscape/NPRuntimeObjectMap.cpp: (WebKit::NPRuntimeObjectMap::getOrCreateNPObject): (WebKit::NPRuntimeObjectMap::convertJSValueToNPVariant): (WebKit::NPRuntimeObjectMap::evaluate):
- WebProcess/Plugins/Netscape/NPRuntimeObjectMap.h:
- WebProcess/Plugins/PluginView.cpp: (WebKit::PluginView::windowScriptNPObject): (WebKit::PluginView::pluginElementNPObject):
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/runtime/Structure.cpp
r77151 r78634 267 267 268 268 } 269 ASSERT(!m_enumerationCache.hasDeadObject());270 269 271 270 if (m_propertyTable) {