Reviewed by Darin.
authorap@webkit.org <ap@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 2 Jul 2008 07:00:53 +0000 (07:00 +0000)
committerap@webkit.org <ap@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 2 Jul 2008 07:00:53 +0000 (07:00 +0000)
commit8f161ff56d5a6f44e88258fc2698fedcc0d56f6c
tree79a9f88371c3c45d97bee121c1631aa656a42717
parentd0c059130df557b0d0fc2f176cd8ac207e514ce8
    Reviewed by Darin.

        Disable JSLock for per-thread contexts.

        No change on SunSpider.

        * kjs/JSGlobalData.h:
        * kjs/JSGlobalData.cpp:
        (KJS::JSGlobalData::JSGlobalData):
        (KJS::JSGlobalData::sharedInstance):
        Added isSharedInstance as a better way to tell whether the instance is shared (legacy).

        * kjs/JSLock.cpp:
        (KJS::createJSLockCount):
        (KJS::JSLock::lockCount):
        (KJS::setLockCount):
        (KJS::JSLock::JSLock):
        (KJS::JSLock::lock):
        (KJS::JSLock::unlock):
        (KJS::JSLock::currentThreadIsHoldingLock):
        (KJS::JSLock::DropAllLocks::DropAllLocks):
        (KJS::JSLock::DropAllLocks::~DropAllLocks):
        * kjs/JSLock.h:
        (KJS::JSLock::JSLock):
        (KJS::JSLock::~JSLock):
        Made JSLock and JSLock::DropAllLocks constructors take a parameter to decide whether to
        actually lock a mutex, or only to increment recursion count. We cannot turn it into no-op
        if we want to keep existing assertions working.
        Made recursion count per-thread, now that locks may not lock.

        * API/JSBase.cpp:
        (JSEvaluateScript): Take JSLock after casting JSContextRef to ExecState* (which doesn't need
        locking in any case), so that a decision whether to actually lock can be made.
        (JSCheckScriptSyntax): Ditto.
        (JSGarbageCollect): Only lock while collecting the shared heap, not the per-thread one.

        * API/JSObjectRef.cpp:
        (JSClassCreate): Don't lock, as there is no reason to.
        (JSClassRetain): Ditto.
        (JSClassRelease): Ditto.
        (JSPropertyNameArrayRetain): Ditto.
        (JSPropertyNameArrayRelease): Only lock while deleting the array, as that may touch
        identifier table.
        (JSPropertyNameAccumulatorAddName): Adding a string also involves an identifier table
        lookup, and possibly modification.

        * API/JSStringRef.cpp:
        (JSStringCreateWithCharacters):
        (JSStringCreateWithUTF8CString):
        (JSStringRetain):
        (JSStringRelease):
        (JSStringGetUTF8CString):
        (JSStringIsEqual):
        * API/JSStringRefCF.cpp:
        (JSStringCreateWithCFString):
        JSStringRef operations other than releasing do not need locking.

        * VM/Machine.cpp: Don't include unused JSLock.h.

        * kjs/CollectorHeapIntrospector.cpp: (KJS::CollectorHeapIntrospector::statistics):
        Don't take the lock for real, as heap introspection pauses the process anyway. It seems that
        the existing code could cause deadlocks.

        * kjs/Shell.cpp:
        (functionGC):
        (main):
        (jscmain):
        The test tool uses a per-thread context, so no real locking is required.

        * kjs/collector.h:
        (KJS::Heap::setGCProtectNeedsLocking): Optionally protect m_protectedValues access with a
        per-heap mutex. This is only needed for WebCore Database code, which violates the "no data
        migration between threads" by using ProtectedPtr on a background thread.
        (KJS::Heap::isShared): Keep a shared flag here, as well.

        * kjs/protect.h:
        (KJS::::ProtectedPtr):
        (KJS::::~ProtectedPtr):
        (KJS::::operator):
        (KJS::operator==):
        (KJS::operator!=):
        ProtectedPtr is ony used from WebCore, so it doesn't need to take JSLock. An assertion in
        Heap::protect/unprotect guards agains possible future unlocked uses of ProtectedPtr in JSC.

        * kjs/collector.cpp:
        (KJS::Heap::Heap): Initialize m_isShared.
        (KJS::Heap::~Heap): No need to lock for real during destruction, but must keep assertions
        in sweep() working.
        (KJS::destroyRegisteredThread): Registered thread list is only accessed for shared heap,
        so locking is always needed here.
        (KJS::Heap::registerThread): Ditto.
        (KJS::Heap::markStackObjectsConservatively): Use m_isShared instead of comparing to a shared
        instance for a small speedup.
        (KJS::Heap::setGCProtectNeedsLocking): Create m_protectedValuesMutex. There is currently no
        way to undo this - and ideally, Database code will be fixed to lo longer require this quirk.
        (KJS::Heap::protect): Take m_protectedValuesMutex (if it exists) while accessing
        m_protectedValues.
        (KJS::Heap::unprotect): Ditto.
        (KJS::Heap::markProtectedObjects): Ditto.
        (KJS::Heap::protectedGlobalObjectCount): Ditto.
        (KJS::Heap::protectedObjectCount): Ditto.
        (KJS::Heap::protectedObjectTypeCounts): Ditto.

        * kjs/ustring.cpp:
        * kjs/ustring.h:
        Don't include JSLock.h, which is no longer used here. As a result, an explicit include had
        to be added to many files in JavaScriptGlue, WebCore and WebKit.

        * kjs/JSGlobalObject.cpp:
        (KJS::JSGlobalObject::init):
        * API/JSCallbackConstructor.cpp:
        (KJS::constructJSCallback):
        * API/JSCallbackFunction.cpp:
        (KJS::JSCallbackFunction::call):
        * API/JSCallbackObjectFunctions.h:
        (KJS::::init):
        (KJS::::getOwnPropertySlot):
        (KJS::::put):
        (KJS::::deleteProperty):
        (KJS::::construct):
        (KJS::::hasInstance):
        (KJS::::call):
        (KJS::::getPropertyNames):
        (KJS::::toNumber):
        (KJS::::toString):
        (KJS::::staticValueGetter):
        (KJS::::callbackGetter):
        * API/JSContextRef.cpp:
        (JSGlobalContextCreate):
        (JSGlobalContextRetain):
        (JSGlobalContextRelease):
        * API/JSValueRef.cpp:
        (JSValueIsEqual):
        (JSValueIsStrictEqual):
        (JSValueIsInstanceOfConstructor):
        (JSValueMakeNumber):
        (JSValueMakeString):
        (JSValueToNumber):
        (JSValueToStringCopy):
        (JSValueToObject):
        (JSValueProtect):
        (JSValueUnprotect):
        * JavaScriptCore.exp:
        * kjs/PropertyNameArray.h:
        (KJS::PropertyNameArray::globalData):
        * kjs/interpreter.cpp:
        (KJS::Interpreter::checkSyntax):
        (KJS::Interpreter::evaluate):
        Pass a parameter to JSLock/JSLock::DropAllLocks to decide whether the lock needs to be taken.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@34947 268f45cc-cd09-0410-ab3c-d52691b4dbfc
93 files changed:
JavaScriptCore/API/JSBase.cpp
JavaScriptCore/API/JSCallbackConstructor.cpp
JavaScriptCore/API/JSCallbackFunction.cpp
JavaScriptCore/API/JSCallbackObjectFunctions.h
JavaScriptCore/API/JSContextRef.cpp
JavaScriptCore/API/JSObjectRef.cpp
JavaScriptCore/API/JSStringRef.cpp
JavaScriptCore/API/JSStringRefCF.cpp
JavaScriptCore/API/JSValueRef.cpp
JavaScriptCore/ChangeLog
JavaScriptCore/JavaScriptCore.exp
JavaScriptCore/VM/Machine.cpp
JavaScriptCore/kjs/CollectorHeapIntrospector.cpp
JavaScriptCore/kjs/JSGlobalData.cpp
JavaScriptCore/kjs/JSGlobalData.h
JavaScriptCore/kjs/JSGlobalObject.cpp
JavaScriptCore/kjs/JSLock.cpp
JavaScriptCore/kjs/JSLock.h
JavaScriptCore/kjs/PropertyNameArray.h
JavaScriptCore/kjs/Shell.cpp
JavaScriptCore/kjs/collector.cpp
JavaScriptCore/kjs/collector.h
JavaScriptCore/kjs/interpreter.cpp
JavaScriptCore/kjs/protect.h
JavaScriptCore/kjs/ustring.cpp
JavaScriptCore/kjs/ustring.h
JavaScriptGlue/ChangeLog
JavaScriptGlue/ForwardingHeaders/wtf/Locker.h [new file with mode: 0644]
JavaScriptGlue/ForwardingHeaders/wtf/Threading.h [new file with mode: 0644]
JavaScriptGlue/JSBase.cpp
JavaScriptGlue/JSUtils.cpp
JavaScriptGlue/JSUtils.h
JavaScriptGlue/JSValueWrapper.cpp
JavaScriptGlue/JavaScriptGlue.cpp
JavaScriptGlue/UserObjectImp.cpp
WebCore/ChangeLog
WebCore/bindings/js/GCController.cpp
WebCore/bindings/js/JSCustomSQLStatementCallback.cpp
WebCore/bindings/js/JSCustomSQLStatementErrorCallback.cpp
WebCore/bindings/js/JSCustomSQLTransactionCallback.cpp
WebCore/bindings/js/JSCustomSQLTransactionErrorCallback.cpp
WebCore/bindings/js/JSCustomVoidCallback.cpp
WebCore/bindings/js/JSCustomXPathNSResolver.cpp
WebCore/bindings/js/JSDOMWindowBase.cpp
WebCore/bindings/js/JSEventCustom.cpp
WebCore/bindings/js/JSEventListener.cpp
WebCore/bindings/js/JSNodeFilterCondition.cpp
WebCore/bindings/js/ScheduledAction.cpp
WebCore/bindings/js/ScriptController.cpp
WebCore/bindings/objc/WebScriptObject.mm
WebCore/bridge/NP_jsobject.cpp
WebCore/bridge/c/c_class.cpp
WebCore/bridge/c/c_instance.cpp
WebCore/bridge/c/c_runtime.cpp
WebCore/bridge/c/c_utility.cpp
WebCore/bridge/jni/jni_class.cpp
WebCore/bridge/jni/jni_instance.cpp
WebCore/bridge/jni/jni_jsobject.mm
WebCore/bridge/jni/jni_objc.mm
WebCore/bridge/jni/jni_runtime.cpp
WebCore/bridge/jni/jni_runtime.h
WebCore/bridge/jni/jni_utility.cpp
WebCore/bridge/npruntime.cpp
WebCore/bridge/objc/objc_instance.mm
WebCore/bridge/objc/objc_runtime.mm
WebCore/bridge/objc/objc_utility.mm
WebCore/bridge/runtime.cpp
WebCore/bridge/runtime_root.cpp
WebCore/dom/Document.cpp
WebCore/dom/Node.cpp
WebCore/history/CachedPage.cpp
WebCore/html/HTMLPlugInElement.cpp
WebCore/loader/FrameLoader.cpp
WebCore/page/Frame.cpp
WebCore/page/InspectorController.cpp
WebCore/page/JavaScriptCallFrame.cpp
WebCore/page/JavaScriptProfileNode.cpp
WebCore/page/mac/FrameMac.mm
WebCore/storage/Database.cpp
WebCore/xml/XMLHttpRequest.cpp
WebKit/mac/ChangeLog
WebKit/mac/Misc/WebCoreStatistics.mm
WebKit/mac/Plugins/WebBaseNetscapePluginView.mm
WebKit/mac/Plugins/WebPluginController.mm
WebKit/mac/WebView/WebFrame.mm
WebKit/mac/WebView/WebScriptDebugDelegate.mm
WebKit/mac/WebView/WebView.mm
WebKit/qt/Api/qwebframe.cpp
WebKit/qt/ChangeLog
WebKit/win/ChangeLog
WebKit/win/WebCoreStatistics.cpp
WebKit/win/WebScriptCallFrame.cpp
WebKit/win/WebView.cpp