[webkit-changes] cvs commit: WebCore/kwq KWQKHTMLPart.mm KWQPageState.mm KWQTimer.h KWQTimer.mm WebCoreBridge.mm WebCoreJavaScript.mm WebCoreScriptDebugger.mm

Maciej mjs at opensource.apple.com
Thu Sep 15 19:34:22 PDT 2005


mjs         05/09/15 19:34:21

  Modified:    .        Tag: Safari-2-0-branch ChangeLog Makefile.am
               bindings Tag: Safari-2-0-branch NP_jsobject.cpp runtime.cpp
                        runtime_root.h testbindings.cpp testbindings.mm
               bindings/jni Tag: Safari-2-0-branch jni_jsobject.cpp
               bindings/objc Tag: Safari-2-0-branch WebScriptObject.mm
               kjs      Tag: Safari-2-0-branch fast_malloc.cpp
                        fast_malloc.h identifier.h internal.cpp internal.h
                        interpreter.cpp interpreter.h nodes.h protect.h
                        protected_values.cpp string_object.cpp testkjs.cpp
               .        Tag: Safari-2-0-branch ChangeLog Makefile.am
               khtml/dom Tag: Safari-2-0-branch dom_misc.h
               khtml/ecma Tag: Safari-2-0-branch kjs_events.cpp
                        kjs_events.h kjs_proxy.cpp kjs_traversal.cpp
                        kjs_traversal.h kjs_window.cpp kjs_window.h
                        xmlhttprequest.cpp
               khtml/misc Tag: Safari-2-0-branch main_thread_malloc.cpp
               kwq      Tag: Safari-2-0-branch KWQKHTMLPart.mm
                        KWQPageState.mm KWQTimer.h KWQTimer.mm
                        WebCoreBridge.mm WebCoreJavaScript.mm
                        WebCoreScriptDebugger.mm
  Log:
  JavaScriptCore:
  
          Reviewed by Geoff.
  
  	- fixed <rdar://problem/4214783> REGRESSION: kjs_fast_malloc crash due to lack of locking on multiple threads (seen selecting volumes in the installer)
  
  	Make sure to lock using the InterpreterLock class in all places that need it
  	(including anything that uses the collector, the parser, the protect count hash table,
  	and anything that allocates via fast_malloc).
  
  	Also added assertions to ensure that the locking rules are followed for the relevant
  	resources.
  
          * Makefile.am:
          * bindings/NP_jsobject.cpp:
          (identifierFromNPIdentifier):
          (_NPN_Invoke):
          (_NPN_Evaluate):
          (_NPN_GetProperty):
          (_NPN_SetProperty):
          (_NPN_RemoveProperty):
          (_NPN_HasProperty):
          (_NPN_HasMethod):
          (_NPN_SetException):
          * bindings/jni/jni_jsobject.cpp:
          (JSObject::call):
          (JSObject::eval):
          (JSObject::getMember):
          (JSObject::setMember):
          (JSObject::removeMember):
          (JSObject::getSlot):
          (JSObject::setSlot):
          (JSObject::toString):
          (JSObject::convertJObjectToValue):
          * bindings/objc/WebScriptObject.mm:
          (-[WebScriptObject callWebScriptMethod:withArguments:]):
          (-[WebScriptObject evaluateWebScript:]):
          (-[WebScriptObject setValue:forKey:]):
          (-[WebScriptObject valueForKey:]):
          (-[WebScriptObject removeWebScriptKey:]):
          (-[WebScriptObject stringRepresentation]):
          (-[WebScriptObject webScriptValueAtIndex:]):
          (-[WebScriptObject setWebScriptValueAtIndex:value:]):
          (+[WebScriptObject _convertValueToObjcValue:KJS::originExecutionContext:Bindings::executionContext:Bindings::]):
          * bindings/runtime.cpp:
          (Instance::createRuntimeObject):
          * bindings/runtime_root.h:
          * bindings/testbindings.cpp:
          (main):
          * bindings/testbindings.mm:
          (main):
          * kjs/fast_malloc.cpp:
          (KJS::kjs_fast_malloc):
          (KJS::kjs_fast_calloc):
          (KJS::kjs_fast_free):
          (KJS::kjs_fast_realloc):
          * kjs/fast_malloc.h:
          * kjs/identifier.h:
          * kjs/internal.cpp:
          (InterpreterImp::InterpreterImp):
          (InterpreterImp::clear):
          (InterpreterImp::mark):
          (InterpreterImp::checkSyntax):
          (InterpreterImp::evaluate):
          * kjs/internal.h:
          (KJS::InterpreterImp::globalObject):
          * kjs/interpreter.cpp:
          (Interpreter::evaluate):
          * kjs/interpreter.h:
          (KJS::InterpreterLock::InterpreterLock):
          (KJS::InterpreterLock::~InterpreterLock):
          * kjs/nodes.h:
          * kjs/protect.h:
          (KJS::ProtectedValue::ProtectedValue):
          (KJS::ProtectedValue::~ProtectedValue):
          (KJS::ProtectedValue::operator=):
          (KJS::ProtectedObject::ProtectedObject):
          (KJS::ProtectedObject::~ProtectedObject):
          (KJS::ProtectedObject::operator=):
          (KJS::ProtectedReference::ProtectedReference):
          (KJS::ProtectedReference::~ProtectedReference):
          (KJS::ProtectedReference::operator=):
          * kjs/protected_object.h:
          * kjs/protected_values.cpp:
          (KJS::ProtectedValues::getProtectCount):
          (KJS::ProtectedValues::increaseProtectCount):
          (KJS::ProtectedValues::decreaseProtectCount):
          * kjs/string_object.cpp:
          (StringObjectImp::StringObjectImp):
          * kjs/testkjs.cpp:
          (main):
  
  WebCore:
  
          Reviewed by Geoff.
  
  	- fixed <rdar://problem/4214783> REGRESSION: kjs_fast_malloc crash due to lack of locking on multiple threads (seen selecting volumes in the installer)
  
  	Make sure to lock using the InterpreterLock class in all places that need it
  	(including anything that uses the collector, the parser, the protect count hash table,
  	and anything that allocates via fast_malloc).
  
  	Added assertions to ensure that main_thread_malloc and friends are
  	only called on the main thread.
  
  	Also changed main_thread_free to schedule a free on the main
  	thread if called from a background thread. This contingency is
  	rare, but unavoidable in the case that JavaScript runs on
  	background threads, since then objects can be garbage collected on
  	any thread.
  
          Test cases added: Node, this is impossible to reproduce in Safari without the use of
  	PAC files.
  
          * Makefile.am:
          * khtml/dom/dom_misc.h:
          * khtml/ecma/kjs_events.cpp:
          (JSAbstractEventListener::handleEvent):
          (JSLazyEventListener::parseCode):
          (KJS::getDOMEvent):
          * khtml/ecma/kjs_events.h:
          * khtml/ecma/kjs_proxy.cpp:
          (KJSProxyImpl::~KJSProxyImpl):
          (KJSProxyImpl::evaluate):
          (KJSProxyImpl::clear):
          (KJSProxyImpl::createHTMLEventHandler):
          (KJSProxyImpl::initScript):
          * khtml/ecma/kjs_traversal.cpp:
          (JSNodeFilterCondition::acceptNode):
          * khtml/ecma/kjs_traversal.h:
          * khtml/ecma/kjs_window.cpp:
          (Window::clear):
          (ScheduledAction::execute):
          * khtml/ecma/kjs_window.h:
          * khtml/ecma/xmlhttprequest.cpp:
          (KJS::XMLHttpRequest::send):
          (KJS::XMLHttpRequest::abort):
          (KJS::XMLHttpRequest::slotFinished):
          * khtml/misc/main_thread_malloc.cpp:
          (khtml::main_thread_malloc):
          (khtml::main_thread_calloc):
          (khtml::main_thread_free):
          (khtml::main_thread_realloc):
          (khtml::initialize_scheduled_free_list):
          (khtml::drain_scheduled_free_list):
          (khtml::schedule_free_on_main_thread):
          (khtml::public_fREe):
          * kwq/KWQKHTMLPart.mm:
          (KWQKHTMLPart::bindingRootObject):
          (KWQKHTMLPart::windowScriptObject):
          (KWQKHTMLPart::saveLocationProperties):
          (KWQKHTMLPart::restoreLocationProperties):
          (KWQKHTMLPart::openURLFromPageCache):
          (KWQKHTMLPart::cleanupPluginRootObjects):
          * kwq/KWQPageState.mm:
          (-[KWQPageState clear]):
          * kwq/KWQTimer.h:
          * kwq/KWQTimer.mm:
          (-[KWQMainThreadPerformTarget initWithFunction:]):
          (-[KWQMainThreadPerformTarget callFunction:]):
          (QTimer::immediateSingleShotOnMainThread):
          * kwq/WebCoreBridge.mm:
          (-[WebCoreBridge saveDocumentToPageCache]):
          * kwq/WebCoreJavaScript.mm:
          (+[WebCoreJavaScript rootObjectClasses]):
          (+[WebCoreJavaScript garbageCollect]):
          * kwq/WebCoreScriptDebugger.mm:
          (-[WebCoreScriptCallFrame evaluateWebScript:]):
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.677.6.35 +92 -0     JavaScriptCore/ChangeLog
  
  Index: ChangeLog
  ===================================================================
  RCS file: /cvs/root/JavaScriptCore/ChangeLog,v
  retrieving revision 1.677.6.34
  retrieving revision 1.677.6.35
  diff -u -r1.677.6.34 -r1.677.6.35
  --- ChangeLog	2 Sep 2005 22:56:29 -0000	1.677.6.34
  +++ ChangeLog	16 Sep 2005 02:33:56 -0000	1.677.6.35
  @@ -1,3 +1,95 @@
  +2005-09-14  Maciej Stachowiak  <mjs at apple.com>
  +
  +        Reviewed by Geoff.
  +
  +	- fixed <rdar://problem/4214783> REGRESSION: kjs_fast_malloc crash due to lack of locking on multiple threads (seen selecting volumes in the installer)
  +
  +	Make sure to lock using the InterpreterLock class in all places that need it
  +	(including anything that uses the collector, the parser, the protect count hash table,
  +	and anything that allocates via fast_malloc).
  +
  +	Also added assertions to ensure that the locking rules are followed for the relevant
  +	resources.
  +
  +        * Makefile.am:
  +        * bindings/NP_jsobject.cpp:
  +        (identifierFromNPIdentifier):
  +        (_NPN_Invoke):
  +        (_NPN_Evaluate):
  +        (_NPN_GetProperty):
  +        (_NPN_SetProperty):
  +        (_NPN_RemoveProperty):
  +        (_NPN_HasProperty):
  +        (_NPN_HasMethod):
  +        (_NPN_SetException):
  +        * bindings/jni/jni_jsobject.cpp:
  +        (JSObject::call):
  +        (JSObject::eval):
  +        (JSObject::getMember):
  +        (JSObject::setMember):
  +        (JSObject::removeMember):
  +        (JSObject::getSlot):
  +        (JSObject::setSlot):
  +        (JSObject::toString):
  +        (JSObject::convertJObjectToValue):
  +        * bindings/objc/WebScriptObject.mm:
  +        (-[WebScriptObject callWebScriptMethod:withArguments:]):
  +        (-[WebScriptObject evaluateWebScript:]):
  +        (-[WebScriptObject setValue:forKey:]):
  +        (-[WebScriptObject valueForKey:]):
  +        (-[WebScriptObject removeWebScriptKey:]):
  +        (-[WebScriptObject stringRepresentation]):
  +        (-[WebScriptObject webScriptValueAtIndex:]):
  +        (-[WebScriptObject setWebScriptValueAtIndex:value:]):
  +        (+[WebScriptObject _convertValueToObjcValue:KJS::originExecutionContext:Bindings::executionContext:Bindings::]):
  +        * bindings/runtime.cpp:
  +        (Instance::createRuntimeObject):
  +        * bindings/runtime_root.h:
  +        * bindings/testbindings.cpp:
  +        (main):
  +        * bindings/testbindings.mm:
  +        (main):
  +        * kjs/fast_malloc.cpp:
  +        (KJS::kjs_fast_malloc):
  +        (KJS::kjs_fast_calloc):
  +        (KJS::kjs_fast_free):
  +        (KJS::kjs_fast_realloc):
  +        * kjs/fast_malloc.h:
  +        * kjs/identifier.h:
  +        * kjs/internal.cpp:
  +        (InterpreterImp::InterpreterImp):
  +        (InterpreterImp::clear):
  +        (InterpreterImp::mark):
  +        (InterpreterImp::checkSyntax):
  +        (InterpreterImp::evaluate):
  +        * kjs/internal.h:
  +        (KJS::InterpreterImp::globalObject):
  +        * kjs/interpreter.cpp:
  +        (Interpreter::evaluate):
  +        * kjs/interpreter.h:
  +        (KJS::InterpreterLock::InterpreterLock):
  +        (KJS::InterpreterLock::~InterpreterLock):
  +        * kjs/nodes.h:
  +        * kjs/protect.h:
  +        (KJS::ProtectedValue::ProtectedValue):
  +        (KJS::ProtectedValue::~ProtectedValue):
  +        (KJS::ProtectedValue::operator=):
  +        (KJS::ProtectedObject::ProtectedObject):
  +        (KJS::ProtectedObject::~ProtectedObject):
  +        (KJS::ProtectedObject::operator=):
  +        (KJS::ProtectedReference::ProtectedReference):
  +        (KJS::ProtectedReference::~ProtectedReference):
  +        (KJS::ProtectedReference::operator=):
  +        * kjs/protected_object.h:
  +        * kjs/protected_values.cpp:
  +        (KJS::ProtectedValues::getProtectCount):
  +        (KJS::ProtectedValues::increaseProtectCount):
  +        (KJS::ProtectedValues::decreaseProtectCount):
  +        * kjs/string_object.cpp:
  +        (StringObjectImp::StringObjectImp):
  +        * kjs/testkjs.cpp:
  +        (main):
  +
   === Safari-416.6 ===
   
   2005-09-02  Adele Peterson  <adele at apple.com>
  
  
  
  1.27.10.2 +1 -2      JavaScriptCore/Makefile.am
  
  Index: Makefile.am
  ===================================================================
  RCS file: /cvs/root/JavaScriptCore/Makefile.am,v
  retrieving revision 1.27.10.1
  retrieving revision 1.27.10.2
  diff -u -r1.27.10.1 -r1.27.10.2
  --- Makefile.am	1 Aug 2005 23:56:52 -0000	1.27.10.1
  +++ Makefile.am	16 Sep 2005 02:33:58 -0000	1.27.10.2
  @@ -1,7 +1,6 @@
  -SUBDIRS = pcre kjs
  -
   all-am:
   	xcodebuild -target All -configuration $(BUILDSTYLE) OBJROOT=$(SYMROOTS) SYMROOT=$(SYMROOTS) DSTROOT=$(SYMROOTS)
  +
   clean-am:
   	xcodebuild -target All clean OBJROOT=$(SYMROOTS) SYMROOT=$(SYMROOTS) DSTROOT=$(SYMROOTS)
   	rm -rf $(SYMROOTS)/JavaScriptCore.build
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.18.8.3  +36 -69    JavaScriptCore/bindings/NP_jsobject.cpp
  
  Index: NP_jsobject.cpp
  ===================================================================
  RCS file: /cvs/root/JavaScriptCore/bindings/NP_jsobject.cpp,v
  retrieving revision 1.18.8.2
  retrieving revision 1.18.8.3
  diff -u -r1.18.8.2 -r1.18.8.3
  --- NP_jsobject.cpp	10 Aug 2005 02:45:49 -0000	1.18.8.2
  +++ NP_jsobject.cpp	16 Sep 2005 02:34:00 -0000	1.18.8.3
  @@ -73,7 +73,7 @@
   
   NPClass *NPScriptObjectClass = &_javascriptClass;
   
  -Identifier identiferFromNPIdentifier(const NPUTF8 *name)
  +static Identifier identifierFromNPIdentifier(const NPUTF8 *name)
   {
       NPUTF16 *methodName;
       unsigned int UTF16Length;
  @@ -148,38 +148,29 @@
   	else {
   	    // Lookup the function object.
   	    ExecState *exec = obj->executionContext->interpreter()->globalExec();
  -	    Interpreter::lock();
  -	    Value func = obj->imp->get (exec, identiferFromNPIdentifier(i->value.string));
  -	    Interpreter::unlock();
  +	    InterpreterLock lock;
  +	    Value func = obj->imp->get (exec, identifierFromNPIdentifier(i->value.string));
   
   	    if (func.isNull()) {
   		NPN_InitializeVariantAsNull(result);
   		return false;
  -	    }
  -	    else if ( func.type() == UndefinedType) {
  +	    } else if (func.type() == UndefinedType) {
   		NPN_InitializeVariantAsUndefined(result);
   		return false;
  -	    }
  -	    else {
  +	    } else {
   		// Call the function object.
   		ObjectImp *funcImp = static_cast<ObjectImp*>(func.imp());
   		Object thisObj = Object(const_cast<ObjectImp*>(obj->imp));
   		List argList = listFromVariantArgs(exec, args, argCount);
  -		Interpreter::lock();
   		Value resultV = Object(funcImp).call (exec, thisObj, argList);
  -		Interpreter::unlock();
   
   		// Convert and return the result of the function call.
   		convertValueToNPVariant(exec, resultV, result);
   		return true;
   	    }
   	}
  -    }
  -    else {
  -        if (o->_class->invoke) {
  -            return o->_class->invoke (o, methodName, args, argCount, result);
  -        }
  -    }
  +    } else if (o->_class->invoke)
  +        return o->_class->invoke (o, methodName, args, argCount, result);
       
       return true;
   }
  @@ -196,7 +187,7 @@
           Object thisObj = Object(const_cast<ObjectImp*>(obj->imp));
           Value result;
           
  -        Interpreter::lock();
  +        InterpreterLock lock;
           NPUTF16 *scriptString;
           unsigned int UTF16Length;
           convertNPStringToUTF16 (s, &scriptString, &UTF16Length);    // requires free() of returned memory.
  @@ -212,8 +203,6 @@
           else
               result = Undefined();
               
  -        Interpreter::unlock();
  -        
           free ((void *)scriptString);
           
           convertValueToNPVariant(exec, result, variant);
  @@ -235,7 +224,7 @@
   
           PrivateIdentifier *i = (PrivateIdentifier *)propertyName;
           if (i->isString) {
  -            if (!obj->imp->hasProperty (exec, identiferFromNPIdentifier(i->value.string))) {
  +            if (!obj->imp->hasProperty (exec, identifierFromNPIdentifier(i->value.string))) {
                   NPN_InitializeVariantAsNull(variant);
                   return false;
               }
  @@ -247,16 +236,13 @@
               }
           }
           
  -        Interpreter::lock();
  +        InterpreterLock lock;
           Value result;
  -        if (i->isString) {
  -            result = obj->imp->get (exec, identiferFromNPIdentifier(i->value.string));
  -        }
  -        else {
  +        if (i->isString)
  +            result = obj->imp->get (exec, identifierFromNPIdentifier(i->value.string));
  +        else
               result = obj->imp->get (exec, i->value.number);
  -        }
  -        Interpreter::unlock();
  -
  +        
           if (result.isNull()) {
               NPN_InitializeVariantAsNull(variant);
               return false;
  @@ -291,22 +277,17 @@
   	    return false;
   
           ExecState *exec = obj->executionContext->interpreter()->globalExec();
  -        Interpreter::lock();
  -        Value result;
  +        InterpreterLock lock;
           PrivateIdentifier *i = (PrivateIdentifier *)propertyName;
  -        if (i->isString) {
  -            obj->imp->put (exec, identiferFromNPIdentifier(i->value.string), convertNPVariantToValue(exec, variant));
  -        }
  -        else {
  -            obj->imp->put (exec, i->value.number, convertNPVariantToValue(exec, variant));
  -        }
  -        Interpreter::unlock();
  +        if (i->isString)
  +            obj->imp->put(exec, identifierFromNPIdentifier(i->value.string), convertNPVariantToValue(exec, variant));
  +        else
  +            obj->imp->put(exec, i->value.number, convertNPVariantToValue(exec, variant));
           
           return true;
  -    }
  -    else if (o->_class->setProperty) {
  +    } else if (o->_class->setProperty)
           return o->_class->setProperty (o, propertyName, variant);
  -    }
  +
       return false;
   }
   
  @@ -322,7 +303,7 @@
   
           PrivateIdentifier *i = (PrivateIdentifier *)propertyName;
           if (i->isString) {
  -            if (!obj->imp->hasProperty (exec, identiferFromNPIdentifier(i->value.string))) {
  +            if (!obj->imp->hasProperty (exec, identifierFromNPIdentifier(i->value.string))) {
                   return false;
               }
           }
  @@ -332,14 +313,11 @@
               }
           }
   
  -        Interpreter::lock();
  -        if (i->isString) {
  -            obj->imp->deleteProperty (exec, identiferFromNPIdentifier(i->value.string));
  -        }
  -        else {
  +        InterpreterLock lock;
  +        if (i->isString)
  +            obj->imp->deleteProperty (exec, identifierFromNPIdentifier(i->value.string));
  +        else
               obj->imp->deleteProperty (exec, i->value.number);
  -        }
  -        Interpreter::unlock();
           
           return true;
       }
  @@ -357,24 +335,14 @@
           ExecState *exec = obj->executionContext->interpreter()->globalExec();
   
           PrivateIdentifier *i = (PrivateIdentifier *)propertyName;
  -        // String identifier?
  -        if (i->isString) {
  -            ExecState *exec = obj->executionContext->interpreter()->globalExec();
  -            Interpreter::lock();
  -            bool result = obj->imp->hasProperty (exec, identiferFromNPIdentifier(i->value.string));
  -            Interpreter::unlock();
  -            return result;
  -        }
  +        InterpreterLock lock;
  +
  +        if (i->isString)
  +            return obj->imp->hasProperty(exec, identifierFromNPIdentifier(i->value.string));
           
  -        // Numeric identifer
  -        Interpreter::lock();
  -        bool result = obj->imp->hasProperty (exec, i->value.number);
  -        Interpreter::unlock();
  -        return result;
  -    }
  -    else if (o->_class->hasProperty) {
  +        return obj->imp->hasProperty(exec, i->value.number);
  +    } else if (o->_class->hasProperty)
           return o->_class->hasProperty (o, propertyName);
  -    }
       
       return false;
   }
  @@ -393,9 +361,9 @@
               
           // Lookup the function object.
           ExecState *exec = obj->executionContext->interpreter()->globalExec();
  -        Interpreter::lock();
  -        Value func = obj->imp->get (exec, identiferFromNPIdentifier(i->value.string));
  -        Interpreter::unlock();
  +
  +        InterpreterLock lock;
  +        Value func = obj->imp->get (exec, identifierFromNPIdentifier(i->value.string));
   
           if (func.isNull() || func.type() == UndefinedType) {
               return false;
  @@ -416,9 +384,8 @@
       if (o->_class == NPScriptObjectClass) {
           JavaScriptObject *obj = (JavaScriptObject *)o; 
           ExecState *exec = obj->executionContext->interpreter()->globalExec();
  -        Interpreter::lock();
  +        InterpreterLock lock;
           Object err = Error::create(exec, GeneralError, message);
           exec->setException (err);
  -        Interpreter::unlock();
       }
   }
  
  
  
  1.18.8.1  +2 -5      JavaScriptCore/bindings/runtime.cpp
  
  Index: runtime.cpp
  ===================================================================
  RCS file: /cvs/root/JavaScriptCore/bindings/runtime.cpp,v
  retrieving revision 1.18
  retrieving revision 1.18.8.1
  diff -u -r1.18 -r1.18.8.1
  --- runtime.cpp	12 Feb 2005 00:58:13 -0000	1.18
  +++ runtime.cpp	16 Sep 2005 02:34:00 -0000	1.18.8.1
  @@ -130,11 +130,8 @@
   {
       Instance *interfaceObject = Instance::createBindingForLanguageInstance (language, (void *)nativeInstance, executionContext);
       
  -    Interpreter::lock();
  -    Object theObject(new RuntimeObjectImp(interfaceObject,true));
  -    Interpreter::unlock();
  -    
  -    return theObject;
  +    InterpreterLock lock;
  +    return Object(new RuntimeObjectImp(interfaceObject,true));
   }
   
   void *Instance::createLanguageInstanceForValue (ExecState *exec, BindingLanguage language, const Object &value, const RootObject *origin, const RootObject *current)
  
  
  
  1.6.10.2  +1 -0      JavaScriptCore/bindings/runtime_root.h
  
  Index: runtime_root.h
  ===================================================================
  RCS file: /cvs/root/JavaScriptCore/bindings/runtime_root.h,v
  retrieving revision 1.6.10.1
  retrieving revision 1.6.10.2
  diff -u -r1.6.10.1 -r1.6.10.2
  --- runtime_root.h	22 Jul 2005 01:18:15 -0000	1.6.10.1
  +++ runtime_root.h	16 Sep 2005 02:34:00 -0000	1.6.10.2
  @@ -28,6 +28,7 @@
   #include <JavaScriptCore/interpreter.h>
   #include <JavaScriptCore/object.h>
   #include <JavaScriptCore/jni_jsobject.h>
  +#include <JavaScriptCore/protect.h>
   
   namespace KJS {
   
  
  
  
  1.5.12.1  +1 -3      JavaScriptCore/bindings/testbindings.cpp
  
  Index: testbindings.cpp
  ===================================================================
  RCS file: /cvs/root/JavaScriptCore/bindings/testbindings.cpp,v
  retrieving revision 1.5
  retrieving revision 1.5.12.1
  diff -u -r1.5 -r1.5.12.1
  --- testbindings.cpp	24 Jun 2004 00:36:33 -0000	1.5
  +++ testbindings.cpp	16 Sep 2005 02:34:00 -0000	1.5.12.1
  @@ -372,7 +372,7 @@
       
       bool ret = true;
       {
  -        Interpreter::lock();
  +        InterpreterLock lock;
           
           // create interpreter w/ global object
           Object global(new GlobalImp());
  @@ -414,8 +414,6 @@
                   
           NPN_ReleaseObject ((NPObject *)myObject);
           
  -        Interpreter::unlock();
  -        
       } // end block, so that Interpreter and global get deleted
       
       return ret ? 0 : 3;
  
  
  
  1.10.8.1  +1 -3      JavaScriptCore/bindings/testbindings.mm
  
  Index: testbindings.mm
  ===================================================================
  RCS file: /cvs/root/JavaScriptCore/bindings/testbindings.mm,v
  retrieving revision 1.10
  retrieving revision 1.10.8.1
  diff -u -r1.10 -r1.10.8.1
  --- testbindings.mm	21 Jan 2005 00:41:59 -0000	1.10
  +++ testbindings.mm	16 Sep 2005 02:34:00 -0000	1.10.8.1
  @@ -239,7 +239,7 @@
       {
           NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
           
  -        Interpreter::lock();
  +        InterpreterLock lock;
           
           // create interpreter w/ global object
           Object global(new GlobalImp());
  @@ -281,8 +281,6 @@
           
           [myInterface release];
           
  -        Interpreter::unlock();
  -        
   #if MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_3
           [pool release];
   #else
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.10.10.3 +25 -42    JavaScriptCore/bindings/jni/jni_jsobject.cpp
  
  Index: jni_jsobject.cpp
  ===================================================================
  RCS file: /cvs/root/JavaScriptCore/bindings/jni/jni_jsobject.cpp,v
  retrieving revision 1.10.10.2
  retrieving revision 1.10.10.3
  diff -u -r1.10.10.2 -r1.10.10.3
  --- jni_jsobject.cpp	10 Aug 2005 02:45:50 -0000	1.10.10.2
  +++ jni_jsobject.cpp	16 Sep 2005 02:34:01 -0000	1.10.10.3
  @@ -170,11 +170,10 @@
   
       // Lookup the function object.
       ExecState *exec = _root->interpreter()->globalExec();
  -    Interpreter::lock();
  +    InterpreterLock lock;
       
       Identifier identifier(JavaString(methodName).ustring());
       Value func = _imp->get (exec, identifier);
  -    Interpreter::unlock();
       if (func.isNull() || func.type() == UndefinedType) {
           // Maybe throw an exception here?
           return 0;
  @@ -184,36 +183,30 @@
       ObjectImp *funcImp = static_cast<ObjectImp*>(func.imp());
       Object thisObj = Object(const_cast<ObjectImp*>(_imp));
       List argList = listFromJArray(args);
  -    Interpreter::lock();
  +
       Value result = Object(funcImp).call (exec, thisObj, argList);
  -    Interpreter::unlock();
   
  -    // Convert and return the result of the function call.
  -    return convertValueToJObject (result);
  +    return convertValueToJObject(result);
   }
   
   jobject JSObject::eval(jstring script) const
   {
       JS_LOG ("script = %s\n", JavaString(script).UTF8String());
  -
  +    
       Object thisObj = Object(const_cast<ObjectImp*>(_imp));
       Value result;
       
  -    Interpreter::lock();
  -
  +    InterpreterLock lock;
  +    
       Completion completion = _root->interpreter()->evaluate(UString(), 0, JavaString(script).ustring(),thisObj);
       ComplType type = completion.complType();
       
       if (type == Normal) {
           result = completion.value();
  -        if (result.isNull()) {
  +        if (result.isNull())
               result = Undefined();
  -        }
  -    }
  -    else
  +    } else
           result = Undefined();
  -
  -    Interpreter::unlock();
       
       return convertValueToJObject (result);
   }
  @@ -224,20 +217,18 @@
   
       ExecState *exec = _root->interpreter()->globalExec();
   
  -    Interpreter::lock();
  +    InterpreterLock lock;
       Value result = _imp->get (exec, Identifier (JavaString(memberName).ustring()));
  -    Interpreter::unlock();
   
  -    return convertValueToJObject (result);
  +    return convertValueToJObject(result);
   }
   
   void JSObject::setMember(jstring memberName, jobject value) const
   {
       JS_LOG ("memberName = %s, value = %p\n", JavaString(memberName).UTF8String(), value);
       ExecState *exec = _root->interpreter()->globalExec();
  -    Interpreter::lock();
  -    _imp->put (exec, Identifier (JavaString(memberName).ustring()), convertJObjectToValue(value));
  -    Interpreter::unlock();
  +    InterpreterLock lock;
  +    _imp->put(exec, Identifier (JavaString(memberName).ustring()), convertJObjectToValue(value));
   }
   
   
  @@ -246,9 +237,8 @@
       JS_LOG ("memberName = %s\n", JavaString(memberName).UTF8String());
   
       ExecState *exec = _root->interpreter()->globalExec();
  -    Interpreter::lock();
  -    _imp->deleteProperty (exec, Identifier (JavaString(memberName).ustring()));
  -    Interpreter::unlock();
  +    InterpreterLock lock;
  +    _imp->deleteProperty(exec, Identifier (JavaString(memberName).ustring()));
   }
   
   
  @@ -257,11 +247,11 @@
       JS_LOG ("index = %ld\n", index);
   
       ExecState *exec = _root->interpreter()->globalExec();
  -    Interpreter::lock();
  +
  +    InterpreterLock lock;
       Value result = _imp->get (exec, (unsigned)index);
  -    Interpreter::unlock();
   
  -    return convertValueToJObject (result);
  +    return convertValueToJObject(result);
   }
   
   
  @@ -270,25 +260,21 @@
       JS_LOG ("index = %ld, value = %p\n", index, value);
   
       ExecState *exec = _root->interpreter()->globalExec();
  -    Interpreter::lock();
  -    _imp->put (exec, (unsigned)index, convertJObjectToValue(value));
  -    Interpreter::unlock();
  +    InterpreterLock lock;
  +    _imp->put(exec, (unsigned)index, convertJObjectToValue(value));
   }
   
   
   jstring JSObject::toString() const
   {
       JS_LOG ("\n");
  -
  -    Interpreter::lock();
  -    Object thisObj = Object(const_cast<ObjectImp*>(_imp));
  -    ExecState *exec = _root->interpreter()->globalExec();
       
  -    jstring result = (jstring)convertValueToJValue (exec, thisObj, object_type, "java.lang.String").l;
  +    InterpreterLock lock;
  +    Object thisObj = Object(const_cast<ObjectImp*>(_imp));
   
  -    Interpreter::unlock();
  +    ExecState *exec = _root->interpreter()->globalExec();
       
  -    return result;
  +    return (jstring)convertValueToJValue (exec, thisObj, object_type, "java.lang.String").l;
   }
   
   void JSObject::finalize() const
  @@ -437,11 +423,8 @@
           return KJS::Object(const_cast<KJS::ObjectImp*>(imp));
       }
   
  -    Interpreter::lock();
  -    KJS::RuntimeObjectImp *newImp = new KJS::RuntimeObjectImp(new Bindings::JavaInstance (theObject, _root));
  -    Interpreter::unlock();
  -
  -    return KJS::Object(newImp);
  +    InterpreterLock lock;
  +    return KJS::Object(new RuntimeObjectImp(new Bindings::JavaInstance (theObject, _root)));
   }
   
   KJS::List JSObject::listFromJArray(jobjectArray jArray) const
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.17.8.3  +23 -42    JavaScriptCore/bindings/objc/WebScriptObject.mm
  
  Index: WebScriptObject.mm
  ===================================================================
  RCS file: /cvs/root/JavaScriptCore/bindings/objc/WebScriptObject.mm,v
  retrieving revision 1.17.8.2
  retrieving revision 1.17.8.3
  diff -u -r1.17.8.2 -r1.17.8.3
  --- WebScriptObject.mm	10 Aug 2005 02:45:50 -0000	1.17.8.2
  +++ WebScriptObject.mm	16 Sep 2005 02:34:02 -0000	1.17.8.3
  @@ -191,24 +191,21 @@
       // Lookup the function object.
       ExecState *exec = [self _executionContext]->interpreter()->globalExec();
   
  -    Interpreter::lock();
  +    InterpreterLock lock;
       
       Value v = convertObjcValueToValue(exec, &name, ObjcObjectType);
       Identifier identifier(v.toString(exec));
       Value func = [self _imp]->get (exec, identifier);
  -    Interpreter::unlock();
       if (func.isNull() || func.type() == UndefinedType) {
           // Maybe throw an exception here?
           return 0;
       }
   
       // Call the function object.    
  -    Interpreter::lock();
       ObjectImp *funcImp = static_cast<ObjectImp*>(func.imp());
       Object thisObj = Object(const_cast<ObjectImp*>([self _imp]));
       List argList = listFromNSArray(exec, args);
       Value result = Object(funcImp).call (exec, thisObj, argList);
  -    Interpreter::unlock();
   
       if (exec->hadException()) {
           LOG_EXCEPTION (exec);
  @@ -227,16 +224,16 @@
   {
       if (![self _executionContext])
           return nil;
  -
  +    
       if (![self _isSafeScript])
   	return nil;
  -
  +    
       ExecState *exec = [self _executionContext]->interpreter()->globalExec();
  -
  +    
       Object thisObj = Object(const_cast<ObjectImp*>([self _imp]));
       Value result;
       
  -    Interpreter::lock();
  +    InterpreterLock lock;
       
       Value v = convertObjcValueToValue(exec, &script, ObjcObjectType);
       Completion completion = [self _executionContext]->interpreter()->evaluate(UString(), 0, v.toString(exec));
  @@ -244,22 +241,18 @@
       
       if (type == Normal) {
           result = completion.value();
  -        if (result.isNull()) {
  +        if (result.isNull())
               result = Undefined();
  -        }
  -    }
  -    else
  +    } else
           result = Undefined();
  -
  -    Interpreter::unlock();
       
       if (exec->hadException()) {
           LOG_EXCEPTION (exec);
           result = Undefined();
       }
  -
  +    
       id resultObj = [WebScriptObject _convertValueToObjcValue:result originExecutionContext:[self _originExecutionContext] executionContext:[self _executionContext]];
  -
  +    
       _didExecute(self);
       
       return resultObj;
  @@ -275,10 +268,9 @@
   
       ExecState *exec = [self _executionContext]->interpreter()->globalExec();
   
  -    Interpreter::lock();
  +    InterpreterLock lock;
       Value v = convertObjcValueToValue(exec, &key, ObjcObjectType);
       [self _imp]->put (exec, Identifier (v.toString(exec)), (convertObjcValueToValue(exec, &value, ObjcObjectType)));
  -    Interpreter::unlock();
   
       if (exec->hadException()) {
           LOG_EXCEPTION (exec);
  @@ -297,10 +289,9 @@
   
       ExecState *exec = [self _executionContext]->interpreter()->globalExec();
   
  -    Interpreter::lock();
  +    InterpreterLock lock;
       Value v = convertObjcValueToValue(exec, &key, ObjcObjectType);
       Value result = [self _imp]->get (exec, Identifier (v.toString(exec)));
  -    Interpreter::unlock();
       
       if (exec->hadException()) {
           LOG_EXCEPTION (exec);
  @@ -324,10 +315,9 @@
   
       ExecState *exec = [self _executionContext]->interpreter()->globalExec();
   
  -    Interpreter::lock();
  +    InterpreterLock lock;
       Value v = convertObjcValueToValue(exec, &key, ObjcObjectType);
       [self _imp]->deleteProperty (exec, Identifier (v.toString(exec)));
  -    Interpreter::unlock();
   
       if (exec->hadException()) {
           LOG_EXCEPTION (exec);
  @@ -341,14 +331,12 @@
       if (![self _isSafeScript])
   	return @"Undefined";
   
  -    Interpreter::lock();
  +    InterpreterLock lock;
       Object thisObj = Object(const_cast<ObjectImp*>([self _imp]));
       ExecState *exec = [self _executionContext]->interpreter()->globalExec();
       
       id result = convertValueToObjcValue(exec, thisObj, ObjcObjectType).objectValue;
   
  -    Interpreter::unlock();
  -    
       id resultObj = [result description];
   
       _didExecute(self);
  @@ -365,9 +353,8 @@
   	return nil;
   
       ExecState *exec = [self _executionContext]->interpreter()->globalExec();
  -    Interpreter::lock();
  +    InterpreterLock lock;
       Value result = [self _imp]->get (exec, (unsigned)index);
  -    Interpreter::unlock();
   
       if (exec->hadException()) {
           LOG_EXCEPTION (exec);
  @@ -390,9 +377,8 @@
   	return;
   
       ExecState *exec = [self _executionContext]->interpreter()->globalExec();
  -    Interpreter::lock();
  +    InterpreterLock lock;
       [self _imp]->put (exec, (unsigned)index, (convertObjcValueToValue(exec, &value, ObjcObjectType)));
  -    Interpreter::unlock();
   
       if (exec->hadException()) {
           LOG_EXCEPTION (exec);
  @@ -413,32 +399,28 @@
   
   + (id)_convertValueToObjcValue:(KJS::Value)value originExecutionContext:(const Bindings::RootObject *)originExecutionContext executionContext:(const Bindings::RootObject *)executionContext
   {
  -    id result = 0;
  -
       // First see if we have a ObjC instance.
       if (value.type() == KJS::ObjectType){
           ObjectImp *objectImp = static_cast<ObjectImp*>(value.imp());
   	Interpreter *intepreter = executionContext->interpreter();
   	ExecState *exec = intepreter->globalExec();
  -        Interpreter::lock();
  +        InterpreterLock lock;
   	
           if (objectImp->classInfo() != &KJS::RuntimeObjectImp::info) {
   	    Value runtimeObject = objectImp->get(exec, "__apple_runtime_object");
   	    if (!runtimeObject.isNull() && runtimeObject.type() == KJS::ObjectType)
   		objectImp = static_cast<RuntimeObjectImp*>(runtimeObject.imp());
   	}
  -        
  -        Interpreter::unlock();
   
           if (objectImp->classInfo() == &KJS::RuntimeObjectImp::info) {
               RuntimeObjectImp *imp = static_cast<RuntimeObjectImp *>(objectImp);
               ObjcInstance *instance = static_cast<ObjcInstance*>(imp->getInternalInstance());
               if (instance)
  -                result = instance->getObject();
  +                return instance->getObject();
           }
           // Convert to a WebScriptObject
           else {
  -	    result = (id)intepreter->createLanguageInstanceForValue (exec, Instance::ObjectiveCLanguage, value.toObject(exec), originExecutionContext, executionContext);
  +	    return (id)intepreter->createLanguageInstanceForValue (exec, Instance::ObjectiveCLanguage, value.toObject(exec), originExecutionContext, executionContext);
           }
       }
       
  @@ -448,28 +430,27 @@
           UString u = s->value();
           
           NSString *string = [NSString stringWithCharacters:(const unichar*)u.data() length:u.size()];
  -        result = string;
  +        return string;
       }
       
       // Convert JavaScript Number value to NSNumber?
       else if (value.type() == KJS::NumberType) {
           Number n = Number::dynamicCast(value);
  -        result = [NSNumber numberWithDouble:n.value()];
  +        return [NSNumber numberWithDouble:n.value()];
       }
       
       else if (value.type() == KJS::BooleanType) {
           KJS::BooleanImp *b = static_cast<KJS::BooleanImp*>(value.imp());
  -        result = [NSNumber numberWithBool:b->value()];
  +        return [NSNumber numberWithBool:b->value()];
       }
       
       // Convert JavaScript Undefined types to WebUndefined
       else if (value.type() == KJS::UndefinedType) {
  -        result = [WebUndefined undefined];
  +        return [WebUndefined undefined];
       }
       
       // Other types (UnspecifiedType and NullType) converted to 0.
  -    
  -    return result;
  +    return 0;
   }
   
   @end
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.6.2   +34 -0     JavaScriptCore/kjs/fast_malloc.cpp
  
  Index: fast_malloc.cpp
  ===================================================================
  RCS file: /cvs/root/JavaScriptCore/kjs/fast_malloc.cpp,v
  retrieving revision 1.1.6.1
  retrieving revision 1.1.6.2
  diff -u -r1.1.6.1 -r1.1.6.2
  --- fast_malloc.cpp	2 Sep 2005 22:27:39 -0000	1.1.6.1
  +++ fast_malloc.cpp	16 Sep 2005 02:34:02 -0000	1.1.6.2
  @@ -228,8 +228,40 @@
   #define MORECORE_CANNOT_TRIM 1
   #define MALLOC_FAILURE_ACTION abort()
   
  +#include "internal.h"
  +
   namespace KJS {
   
  +#ifndef NDEBUG
  +
  +// In debugging builds, use the system malloc for its debugging features.
  +
  +void *kjs_fast_malloc(size_t n)
  +{
  +    assert(InterpreterImp::lockCount() > 0);
  +    return malloc(n);
  +}
  +
  +void *kjs_fast_calloc(size_t n_elements, size_t element_size)
  +{
  +    assert(InterpreterImp::lockCount() > 0);
  +    return calloc(n_elements, element_size);
  +}
  +
  +void kjs_fast_free(void* p)
  +{
  +    assert(InterpreterImp::lockCount() > 0);
  +    free(p);
  +}
  +
  +void *kjs_fast_realloc(void* p, size_t n)
  +{
  +    assert(InterpreterImp::lockCount() > 0);
  +    return realloc(p, n);
  +}
  +
  +#else
  +
   /*
     WIN32 sets up defaults for MS environment and compilers.
     Otherwise defaults are for unix.
  @@ -5423,6 +5455,8 @@
   
   #endif /* WIN32 */
   
  +#endif // NDEBUG
  +
   };  /* end of namespace KJS */
   
   /* ------------------------------------------------------------
  
  
  
  1.1.6.1   +0 -14     JavaScriptCore/kjs/fast_malloc.h
  
  Index: fast_malloc.h
  ===================================================================
  RCS file: /cvs/root/JavaScriptCore/kjs/fast_malloc.h,v
  retrieving revision 1.1
  retrieving revision 1.1.6.1
  diff -u -r1.1 -r1.1.6.1
  --- fast_malloc.h	15 Apr 2005 01:26:26 -0000	1.1
  +++ fast_malloc.h	16 Sep 2005 02:34:03 -0000	1.1.6.1
  @@ -30,18 +30,6 @@
   // while holding the collector lock (this is true whenenever the interpreter is
   // executing or GC is taking place).
   
  -
  -#ifndef NDEBUG
  -
  -#define kjs_fast_malloc malloc
  -#define kjs_fast_calloc calloc
  -#define kjs_fast_free free
  -#define kjs_fast_realloc realloc
  -
  -#define KJS_FAST_ALLOCATED
  -
  -#else
  -
   namespace KJS {
   
   void *kjs_fast_malloc(size_t n);
  @@ -55,6 +43,4 @@
   void* operator new(size_t s) { return KJS::kjs_fast_malloc(s); } \
   void operator delete(void* p) { KJS::kjs_fast_free(p); }
   
  -#endif
  -
   #endif /* _FAST_MALLOC_H_ */
  
  
  
  1.14.12.1 +1 -0      JavaScriptCore/kjs/identifier.h
  
  Index: identifier.h
  ===================================================================
  RCS file: /cvs/root/JavaScriptCore/kjs/identifier.h,v
  retrieving revision 1.14
  retrieving revision 1.14.12.1
  diff -u -r1.14 -r1.14.12.1
  --- identifier.h	3 Aug 2004 22:45:51 -0000	1.14
  +++ identifier.h	16 Sep 2005 02:34:03 -0000	1.14.12.1
  @@ -108,6 +108,7 @@
           macro(arguments) \
           macro(callee) \
           macro(constructor) \
  +        macro(fromCharCode) \
           macro(length) \
           macro(message) \
           macro(name) \
  
  
  
  1.53.10.5 +13 -30    JavaScriptCore/kjs/internal.cpp
  
  Index: internal.cpp
  ===================================================================
  RCS file: /cvs/root/JavaScriptCore/kjs/internal.cpp,v
  retrieving revision 1.53.10.4
  retrieving revision 1.53.10.5
  diff -u -r1.53.10.4 -r1.53.10.5
  --- internal.cpp	28 Aug 2005 23:26:52 -0000	1.53.10.4
  +++ internal.cpp	16 Sep 2005 02:34:03 -0000	1.53.10.5
  @@ -1,4 +1,3 @@
  -// -*- c-basic-offset: 2 -*-
   /*
    *  This file is part of the KDE libraries
    *  Copyright (C) 1999-2002 Harri Porten (porten at kde.org)
  @@ -547,7 +546,8 @@
   {
     // add this interpreter to the global chain
     // as a root set for garbage collection
  -  lockInterpreter();
  +  InterpreterLock lock;
  +
     m_interpreter = interp;
     if (s_hook) {
       prev = s_hook;
  @@ -571,7 +571,6 @@
     initGlobalObject();
   
     recursion = 0;
  -  unlockInterpreter();
   }
   
   void InterpreterImp::lock()
  @@ -727,9 +726,8 @@
   {
     //fprintf(stderr,"InterpreterImp::clear\n");
     // remove from global chain (see init())
  -#if APPLE_CHANGES
  -  lockInterpreter();
  -#endif
  +  InterpreterLock lock;
  +
     next->prev = prev;
     prev->next = next;
     s_hook = next;
  @@ -740,10 +738,6 @@
       globalClear();
     }
     InterpreterMap::removeInterpreterForGlobalObject(global.imp());
  -
  -#if APPLE_CHANGES
  -  unlockInterpreter();
  -#endif
   }
   
   void InterpreterImp::mark()
  @@ -767,10 +761,14 @@
       m_interpreter->mark();
     if (_context)
       _context->mark();
  +  if (!globExec->_exception.isNull())
  +      globExec->_exception.imp()->mark();
   }
   
   bool InterpreterImp::checkSyntax(const UString &code)
   {
  +  InterpreterLock lock;
  +
     // Parser::parse() returns 0 in a syntax error occurs, so we just check for that
     SharedPtr<ProgramNode> progNode = Parser::parse(UString(), 0, code.data(),code.size(),0,0,0);
     return progNode;
  @@ -778,20 +776,18 @@
   
   Completion InterpreterImp::evaluate(const UString &code, const Value &thisV, const UString &sourceURL, int startingLineNumber)
   {
  -#if APPLE_CHANGES
  -  lockInterpreter();
  -#endif
  +  InterpreterLock lock;
  +
     // prevent against infinite recursion
     if (recursion >= 20) {
   #if APPLE_CHANGES
       Completion result = Completion(Throw,Error::create(globExec,GeneralError,"Recursion too deep"));
  -    unlockInterpreter();
       return result;
   #else
       return Completion(Throw,Error::create(globExec,GeneralError,"Recursion too deep"));
   #endif
     }
  -  
  +
     // parse the source code
     int sid;
     int errLine;
  @@ -802,23 +798,13 @@
     if (dbg) {
       bool cont = dbg->sourceParsed(globExec,sid,sourceURL,code,errLine);
       if (!cont)
  -#if APPLE_CHANGES
  -      {
  -	unlockInterpreter();
  -	return Completion(Break);
  -      }
  -#else
         return Completion(Break);
  -#endif
     }
     
     // no program node means a syntax error occurred
     if (!progNode) {
       Object err = Error::create(globExec,SyntaxError,errMsg.ascii(),errLine, -1, &sourceURL);
       err.put(globExec,"sid",Number(sid));
  -#if APPLE_CHANGES
  -    unlockInterpreter();
  -#endif
       return Completion(Throw,err);
     }
   
  @@ -826,7 +812,7 @@
   
     recursion++;
   
  -  Object &globalObj = globalObject();
  +  Object globalObj = globalObject();
     Object thisObj = globalObject();
   
     if (!thisV.isNull()) {
  @@ -847,16 +833,13 @@
     else {
       // execute the code
       ContextImp ctx(globalObj, this, thisObj);
  -    ExecState newExec(m_interpreter,&ctx);
  +    ExecState newExec(m_interpreter, &ctx);
       progNode->processVarDecls(&newExec);
       res = progNode->execute(&newExec);
     }
   
     recursion--;
   
  -#if APPLE_CHANGES
  -  unlockInterpreter();
  -#endif
     return res;
   }
   
  
  
  
  1.25.10.4 +2 -1      JavaScriptCore/kjs/internal.h
  
  Index: internal.h
  ===================================================================
  RCS file: /cvs/root/JavaScriptCore/kjs/internal.h,v
  retrieving revision 1.25.10.3
  retrieving revision 1.25.10.4
  diff -u -r1.25.10.3 -r1.25.10.4
  --- internal.h	28 Aug 2005 23:26:52 -0000	1.25.10.3
  +++ internal.h	16 Sep 2005 02:34:03 -0000	1.25.10.4
  @@ -28,6 +28,7 @@
   #include "ustring.h"
   #include "value.h"
   #include "object.h"
  +#include "protect.h"
   #include "types.h"
   #include "interpreter.h"
   #include "scope_chain.h"
  @@ -261,7 +262,7 @@
       InterpreterImp(Interpreter *interp, const Object &glob);
       ~InterpreterImp();
   
  -    ProtectedObject &globalObject() const { return const_cast<ProtectedObject &>(global); }
  +    Object &globalObject() { return global; }
       Interpreter* interpreter() const { return m_interpreter; }
   
       void initGlobalObject();
  
  
  
  1.24.8.2  +1 -2      JavaScriptCore/kjs/interpreter.cpp
  
  Index: interpreter.cpp
  ===================================================================
  RCS file: /cvs/root/JavaScriptCore/kjs/interpreter.cpp,v
  retrieving revision 1.24.8.1
  retrieving revision 1.24.8.2
  diff -u -r1.24.8.1 -r1.24.8.2
  --- interpreter.cpp	2 Aug 2005 20:39:11 -0000	1.24.8.1
  +++ interpreter.cpp	16 Sep 2005 02:34:03 -0000	1.24.8.2
  @@ -126,14 +126,13 @@
   
   #if APPLE_CHANGES
     if (shouldPrintExceptions() && comp.complType() == Throw) {
  -    lock();
  +    InterpreterLock lock;
       ExecState *exec = rep->globalExec();
       char *f = strdup(sourceURL.ascii());
       const char *message = comp.value().toObject(exec).toString(exec).ascii();
       printf("[%d] %s:%s\n", getpid(), f, message);
   
       free(f);
  -    unlock();
     }
   #endif
   
  
  
  
  1.22.8.2  +12 -4     JavaScriptCore/kjs/interpreter.h
  
  Index: interpreter.h
  ===================================================================
  RCS file: /cvs/root/JavaScriptCore/kjs/interpreter.h,v
  retrieving revision 1.22.8.1
  retrieving revision 1.22.8.2
  diff -u -r1.22.8.1 -r1.22.8.2
  --- interpreter.h	2 Aug 2005 20:39:11 -0000	1.22.8.1
  +++ interpreter.h	16 Sep 2005 02:34:03 -0000	1.22.8.2
  @@ -1,4 +1,3 @@
  -// -*- c-basic-offset: 2 -*-
   /*
    *  This file is part of the KDE libraries
    *  Copyright (C) 1999-2001 Harri Porten (porten at kde.org)
  @@ -28,7 +27,6 @@
   #include "value.h"
   #include "object.h"
   #include "types.h"
  -#include "protect.h"
   
   #if APPLE_CHANGES
   
  @@ -467,9 +465,19 @@
           : _interpreter(interp), _context(con) { }
       Interpreter *_interpreter;
       ContextImp *_context;
  -    ProtectedValue _exception;
  +    Value _exception;
     };
   
  -}; // namespace
  +    class InterpreterLock
  +    {
  +    public:
  +        InterpreterLock() { Interpreter::lock(); }
  +        ~InterpreterLock() { Interpreter::unlock(); }
  +    private:
  +        InterpreterLock(const InterpreterLock &);
  +        InterpreterLock &operator =(const InterpreterLock &);
  +    };
  +
  +} // namespace
   
   #endif // _KJS_INTERPRETER_H_
  
  
  
  1.19.12.3 +4 -3      JavaScriptCore/kjs/nodes.h
  
  Index: nodes.h
  ===================================================================
  RCS file: /cvs/root/JavaScriptCore/kjs/nodes.h,v
  retrieving revision 1.19.12.2
  retrieving revision 1.19.12.3
  diff -u -r1.19.12.2 -r1.19.12.3
  --- nodes.h	28 Aug 2005 23:26:53 -0000	1.19.12.2
  +++ nodes.h	16 Sep 2005 02:34:04 -0000	1.19.12.3
  @@ -38,12 +38,13 @@
   
   namespace KJS {
   
  +  class ProgramNode;
  +  class PropertyNode;
  +  class PropertyValueNode;
  +  class Reference;
     class RegExp;
     class SourceElementsNode;
  -  class ProgramNode;
     class SourceStream;
  -  class PropertyValueNode;
  -  class PropertyNode;
   
     enum Operator { OpEqual,
   		  OpEqEq,
  
  
  
  1.4.10.1  +90 -40    JavaScriptCore/kjs/protect.h
  
  Index: protect.h
  ===================================================================
  RCS file: /cvs/root/JavaScriptCore/kjs/protect.h,v
  retrieving revision 1.4
  retrieving revision 1.4.10.1
  diff -u -r1.4 -r1.4.10.1
  --- protect.h	8 Dec 2004 22:54:45 -0000	1.4
  +++ protect.h	16 Sep 2005 02:34:04 -0000	1.4.10.1
  @@ -28,6 +28,7 @@
   #include "reference.h"
   #include "value.h"
   #include "protected_values.h"
  +#include "interpreter.h"
   
   namespace KJS {
   
  @@ -57,25 +58,41 @@
       
       class ProtectedValue : public Value {
       public:
  -      ProtectedValue() : Value() {}
  -      ProtectedValue(const Value&v)  : Value(v) { gcProtectNullTolerant(v.imp()); };
  -      ProtectedValue(const ProtectedValue&v)  : Value(v) { gcProtectNullTolerant(v.imp()); };
  -      ~ProtectedValue() { gcUnprotectNullTolerant(imp());}
  -      ProtectedValue& operator=(const Value &v)
  +        ProtectedValue() : Value() {}
  +        ProtectedValue(const Value&v) 
  +            : Value(v) 
  +        {
  +            InterpreterLock lock;
  +            gcProtectNullTolerant(v.imp()); 
  +        }
  +        ProtectedValue(const ProtectedValue&v)  
  +            : Value(v)
  +        {
  +            InterpreterLock lock;
  +            gcProtectNullTolerant(v.imp()); 
  +        }
  +        ~ProtectedValue() 
  +        {
  +            InterpreterLock lock;
  +            gcUnprotectNullTolerant(imp());
  +        }
  +        ProtectedValue& operator=(const Value &v)
   	{ 
  -	  ValueImp *old = imp();
  -	  Value::operator=(v); 
  -	  gcProtectNullTolerant(v.imp());
  -	  gcUnprotectNullTolerant(old); 
  -	  return *this;
  +            InterpreterLock lock;
  +            ValueImp *old = imp();
  +            Value::operator=(v); 
  +            gcProtectNullTolerant(v.imp());
  +            gcUnprotectNullTolerant(old); 
  +            return *this;
   	}
  -      ProtectedValue& operator=(const ProtectedValue &v)
  +        ProtectedValue& operator=(const ProtectedValue &v)
   	{ 
  -	  ValueImp *old = imp();
  -	  Value::operator=(v); 
  -	  gcProtectNullTolerant(v.imp());
  -	  gcUnprotectNullTolerant(old); 
  -	  return *this;
  +            InterpreterLock lock;
  +            ValueImp *old = imp();
  +            Value::operator=(v); 
  +            gcProtectNullTolerant(v.imp());
  +            gcUnprotectNullTolerant(old); 
  +            return *this;
   	}
       private:
         explicit ProtectedValue(ValueImp *v);
  @@ -84,25 +101,45 @@
   
       class ProtectedObject : public Object {
       public:
  -      ProtectedObject() : Object() {}
  -      ProtectedObject(const Object &o)  : Object(o) { gcProtectNullTolerant(o.imp()); };
  -      ProtectedObject(const ProtectedObject &o)  : Object(o) { gcProtectNullTolerant(o.imp()); };
  -      ~ProtectedObject() { gcUnprotectNullTolerant(imp());}
  -      ProtectedObject& operator=(const Object &o)
  +        ProtectedObject() : Object() {}
  +        ProtectedObject(const Object &o)
  +            : Object(o)
  +        {
  +            InterpreterLock lock;
  +            gcProtectNullTolerant(o.imp()); 
  +        }
  +
  +        ProtectedObject(const ProtectedObject &o) 
  +          : Object(o) 
  +        {
  +            InterpreterLock lock;
  +            gcProtectNullTolerant(o.imp()); 
  +        }
  +
  +        ~ProtectedObject()
  +        { 
  +            InterpreterLock lock;
  +            gcUnprotectNullTolerant(imp());
  +        }
  +
  +        ProtectedObject& operator=(const Object &o)
   	{ 
  -	  ValueImp *old = imp();
  -	  Object::operator=(o); 
  -	  gcProtectNullTolerant(o.imp());
  -	  gcUnprotectNullTolerant(old); 
  -	  return *this;
  +            InterpreterLock lock;
  +            ValueImp *old = imp();
  +            Object::operator=(o); 
  +            gcProtectNullTolerant(o.imp());
  +            gcUnprotectNullTolerant(old); 
  +            return *this;
   	}
  -      ProtectedObject& operator=(const ProtectedObject &o)
  +
  +        ProtectedObject& operator=(const ProtectedObject &o)
   	{ 
  -	  ValueImp *old = imp();
  -	  Object::operator=(o); 
  -	  gcProtectNullTolerant(o.imp());
  -	  gcUnprotectNullTolerant(old); 
  -	  return *this;
  +            InterpreterLock lock;
  +            ValueImp *old = imp();
  +            Object::operator=(o); 
  +            gcProtectNullTolerant(o.imp());
  +            gcUnprotectNullTolerant(old); 
  +            return *this;
   	}
       private:
         explicit ProtectedObject(ObjectImp *o);
  @@ -111,16 +148,29 @@
   
       class ProtectedReference : public Reference {
       public:
  -      ProtectedReference(const Reference&r)  : Reference(r) { gcProtectNullTolerant(r.base.imp()); };
  -      ~ProtectedReference() { gcUnprotectNullTolerant(base.imp());}
  -      ProtectedReference& operator=(const Reference &r)
  +        ProtectedReference(const Reference&r)
  +            : Reference(r) 
  +        {
  +            InterpreterLock lock;
  +            gcProtectNullTolerant(r.base.imp()); 
  +        }
  +
  +        ~ProtectedReference() 
  +        { 
  +            InterpreterLock lock;
  +            gcUnprotectNullTolerant(base.imp());
  +        }
  +
  +        ProtectedReference& operator=(const Reference &r)
   	{ 
  -	  ValueImp *old = base.imp();
  -	  Reference::operator=(r); 
  -	  gcProtectNullTolerant(r.base.imp());
  -	  gcUnprotectNullTolerant(old); 
  -	  return *this;
  +            InterpreterLock lock;
  +            ValueImp *old = base.imp();
  +            Reference::operator=(r); 
  +            gcProtectNullTolerant(r.base.imp());
  +            gcUnprotectNullTolerant(old); 
  +            return *this;
   	}
  +
       private:
         ProtectedReference();
         ProtectedReference(const Object& b, const Identifier& p);
  
  
  
  1.3.8.1   +6 -0      JavaScriptCore/kjs/protected_values.cpp
  
  Index: protected_values.cpp
  ===================================================================
  RCS file: /cvs/root/JavaScriptCore/kjs/protected_values.cpp,v
  retrieving revision 1.3
  retrieving revision 1.3.8.1
  diff -u -r1.3 -r1.3.8.1
  --- protected_values.cpp	18 Dec 2004 00:43:37 -0000	1.3
  +++ protected_values.cpp	16 Sep 2005 02:34:04 -0000	1.3.8.1
  @@ -22,6 +22,7 @@
   
   #include "protected_values.h"
   #include "simple_number.h"
  +#include "internal.h"
   
   namespace KJS {
   
  @@ -34,6 +35,9 @@
   
   int ProtectedValues::getProtectCount(ValueImp *k)
   {
  +    assert(k);
  +    assert(InterpreterImp::lockCount() > 0);
  +
       if (!_table)
   	return 0;
   
  @@ -61,6 +65,7 @@
   void ProtectedValues::increaseProtectCount(ValueImp *k)
   {
       assert(k);
  +    assert(InterpreterImp::lockCount() > 0);
   
       if (SimpleNumber::is(k))
         return;
  @@ -110,6 +115,7 @@
   void ProtectedValues::decreaseProtectCount(ValueImp *k)
   {
       assert(k);
  +    assert(InterpreterImp::lockCount() > 0);
   
       if (SimpleNumber::is(k))
         return;
  
  
  
  1.31.8.4  +1 -2      JavaScriptCore/kjs/string_object.cpp
  
  Index: string_object.cpp
  ===================================================================
  RCS file: /cvs/root/JavaScriptCore/kjs/string_object.cpp,v
  retrieving revision 1.31.8.3
  retrieving revision 1.31.8.4
  diff -u -r1.31.8.3 -r1.31.8.4
  --- string_object.cpp	2 Aug 2005 21:26:20 -0000	1.31.8.3
  +++ string_object.cpp	16 Sep 2005 02:34:04 -0000	1.31.8.4
  @@ -682,8 +682,7 @@
     // ECMA 15.5.3.1 String.prototype
     putDirect(prototypePropertyName, stringProto, DontEnum|DontDelete|ReadOnly);
   
  -  static Identifier fromCharCode("fromCharCode");
  -  putDirect(fromCharCode, new StringObjectFuncImp(exec,funcProto), DontEnum);
  +  putDirect(fromCharCodePropertyName, new StringObjectFuncImp(exec, funcProto), DontEnum);
   
     // no. of arguments for constructor
     putDirect(lengthPropertyName, NumberImp::one(), ReadOnly|DontDelete|DontEnum);
  
  
  
  1.11.12.1 +2 -4      JavaScriptCore/kjs/testkjs.cpp
  
  Index: testkjs.cpp
  ===================================================================
  RCS file: /cvs/root/JavaScriptCore/kjs/testkjs.cpp,v
  retrieving revision 1.11
  retrieving revision 1.11.12.1
  diff -u -r1.11 -r1.11.12.1
  --- testkjs.cpp	12 Aug 2004 17:21:29 -0000	1.11
  +++ testkjs.cpp	16 Sep 2005 02:34:05 -0000	1.11.12.1
  @@ -95,7 +95,7 @@
   
     bool ret = true;
     {
  -    Interpreter::lock();
  +    InterpreterLock lock;
   
       Object global(new GlobalImp());
   
  @@ -163,9 +163,7 @@
   
         free(code);
       }
  -
  -    Interpreter::unlock();
  -  } // end block, so that Interpreter and global get deleted
  +  } // end block, so that interpreter gets deleted
   
     if (ret)
       fprintf(stderr, "OK.\n");
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.26  +79 -0     WebCore/ChangeLog
  
  Index: ChangeLog
  ===================================================================
  RCS file: /cvs/root/WebCore/ChangeLog,v
  retrieving revision 1.1.2.25
  retrieving revision 1.1.2.26
  diff -u -r1.1.2.25 -r1.1.2.26
  --- ChangeLog	13 Sep 2005 00:32:00 -0000	1.1.2.25
  +++ ChangeLog	16 Sep 2005 02:34:07 -0000	1.1.2.26
  @@ -1,3 +1,82 @@
  +2005-09-14  Maciej Stachowiak  <mjs at apple.com>
  +
  +        Reviewed by Geoff.
  +
  +	- fixed <rdar://problem/4214783> REGRESSION: kjs_fast_malloc crash due to lack of locking on multiple threads (seen selecting volumes in the installer)
  +
  +	Make sure to lock using the InterpreterLock class in all places that need it
  +	(including anything that uses the collector, the parser, the protect count hash table,
  +	and anything that allocates via fast_malloc).
  +
  +	Added assertions to ensure that main_thread_malloc and friends are
  +	only called on the main thread.
  +
  +	Also changed main_thread_free to schedule a free on the main
  +	thread if called from a background thread. This contingency is
  +	rare, but unavoidable in the case that JavaScript runs on
  +	background threads, since then objects can be garbage collected on
  +	any thread.
  +	
  +        Test cases added: Node, this is impossible to reproduce in Safari without the use of
  +	PAC files.
  +
  +        * Makefile.am:
  +        * khtml/dom/dom_misc.h:
  +        * khtml/ecma/kjs_events.cpp:
  +        (JSAbstractEventListener::handleEvent):
  +        (JSLazyEventListener::parseCode):
  +        (KJS::getDOMEvent):
  +        * khtml/ecma/kjs_events.h:
  +        * khtml/ecma/kjs_proxy.cpp:
  +        (KJSProxyImpl::~KJSProxyImpl):
  +        (KJSProxyImpl::evaluate):
  +        (KJSProxyImpl::clear):
  +        (KJSProxyImpl::createHTMLEventHandler):
  +        (KJSProxyImpl::initScript):
  +        * khtml/ecma/kjs_traversal.cpp:
  +        (JSNodeFilterCondition::acceptNode):
  +        * khtml/ecma/kjs_traversal.h:
  +        * khtml/ecma/kjs_window.cpp:
  +        (Window::clear):
  +        (ScheduledAction::execute):
  +        * khtml/ecma/kjs_window.h:
  +        * khtml/ecma/xmlhttprequest.cpp:
  +        (KJS::XMLHttpRequest::send):
  +        (KJS::XMLHttpRequest::abort):
  +        (KJS::XMLHttpRequest::slotFinished):
  +        * khtml/misc/main_thread_malloc.cpp:
  +        (khtml::main_thread_malloc):
  +        (khtml::main_thread_calloc):
  +        (khtml::main_thread_free):
  +        (khtml::main_thread_realloc):
  +        (khtml::initialize_scheduled_free_list):
  +        (khtml::drain_scheduled_free_list):
  +        (khtml::schedule_free_on_main_thread):
  +        (khtml::public_fREe):
  +        * kwq/KWQKHTMLPart.mm:
  +        (KWQKHTMLPart::bindingRootObject):
  +        (KWQKHTMLPart::windowScriptObject):
  +        (KWQKHTMLPart::saveLocationProperties):
  +        (KWQKHTMLPart::restoreLocationProperties):
  +        (KWQKHTMLPart::openURLFromPageCache):
  +        (KWQKHTMLPart::cleanupPluginRootObjects):
  +        * kwq/KWQPageState.mm:
  +        (-[KWQPageState clear]):
  +        * kwq/KWQTimer.h:
  +        * kwq/KWQTimer.mm:
  +        (-[KWQMainThreadPerformTarget initWithFunction:]):
  +        (-[KWQMainThreadPerformTarget callFunction:]):
  +        (QTimer::immediateSingleShotOnMainThread):
  +        * kwq/WebCoreBridge.mm:
  +        (-[WebCoreBridge saveDocumentToPageCache]):
  +        * kwq/WebCoreJavaScript.mm:
  +        (+[WebCoreJavaScript rootObjectClasses]):
  +        (+[WebCoreJavaScript garbageCollect]):
  +        * kwq/WebCoreScriptDebugger.mm:
  +        (-[WebCoreScriptCallFrame evaluateWebScript:]):
  +
  +2005-09-14  Maciej Stachowiak  <mjs at apple.com>
  +
   === WebCore-417 ===
   
   2005-09-12  Timothy Hatcher  <timothy at apple.com>
  
  
  
  1.28.18.4 +0 -2      WebCore/Makefile.am
  
  Index: Makefile.am
  ===================================================================
  RCS file: /cvs/root/WebCore/Makefile.am,v
  retrieving revision 1.28.18.3
  retrieving revision 1.28.18.4
  diff -u -r1.28.18.3 -r1.28.18.4
  --- Makefile.am	25 Aug 2005 23:21:09 -0000	1.28.18.3
  +++ Makefile.am	16 Sep 2005 02:34:08 -0000	1.28.18.4
  @@ -1,5 +1,3 @@
  -SUBDIRS = khtml kwq
  -
   all-am:
   	xcodebuild -configuration $(BUILDSTYLE) OBJROOT=$(SYMROOTS) SYMROOT=$(SYMROOTS) DSTROOT=$(SYMROOTS) 
   clean-am:
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.8.16.1  +5 -1      WebCore/khtml/dom/dom_misc.h
  
  Index: dom_misc.h
  ===================================================================
  RCS file: /cvs/root/WebCore/khtml/dom/dom_misc.h,v
  retrieving revision 1.8
  retrieving revision 1.8.16.1
  diff -u -r1.8 -r1.8.16.1
  --- dom_misc.h	18 May 2004 20:20:39 -0000	1.8
  +++ dom_misc.h	16 Sep 2005 02:34:10 -0000	1.8.16.1
  @@ -51,8 +51,12 @@
       // An implementation object will delete itself, if it has
       // no DOMObject referencing it, and deleteMe() returns true.
       unsigned int _ref;
  +
  +private:
  +  DomShared(const DomShared &);
  +  DomShared &operator=(const DomShared &);
   };
   
  -}; // namespace
  +} // namespace
   
   #endif
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.42.8.7  +21 -31    WebCore/khtml/ecma/kjs_events.cpp
  
  Index: kjs_events.cpp
  ===================================================================
  RCS file: /cvs/root/WebCore/khtml/ecma/kjs_events.cpp,v
  retrieving revision 1.42.8.6
  retrieving revision 1.42.8.7
  diff -u -r1.42.8.6 -r1.42.8.7
  --- kjs_events.cpp	31 Aug 2005 00:49:24 -0000	1.42.8.6
  +++ kjs_events.cpp	16 Sep 2005 02:34:10 -0000	1.42.8.7
  @@ -18,6 +18,7 @@
    *  License along with this library; if not, write to the Free Software
    *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    */
  +
   #include "khtml_part.h"
   #include "kjs_window.h"
   #include "kjs_events.h"
  @@ -35,6 +36,7 @@
   using namespace KJS;
   
   using DOM::DocumentImpl;
  +using DOM::DOMString;
   using DOM::EventImpl;
   using DOM::KeyboardEvent;
   using DOM::MouseRelatedEventImpl;
  @@ -66,8 +68,12 @@
     KJSProxy *proxy = 0;
     if (part)
         proxy = KJSProxy::proxy( part );
  +  if (!proxy)
  +    return;
  +
  +  if (listener.implementsCall()) {
  +    InterpreterLock lock;
   
  -  if (proxy && listener.implementsCall()) {
       ref();
   
       KJS::ScriptInterpreter *interpreter = static_cast<KJS::ScriptInterpreter *>(proxy->interpreter());
  @@ -83,23 +89,17 @@
       interpreter->setCurrentEvent( &evt );
   
       Object thisObj;
  -    if (isWindowEvent) {
  +    if (isWindowEvent) 
           thisObj = win;
  -    } else {
  -        KJS::Interpreter::lock();
  +    else 
           thisObj = Object::dynamicCast(getDOMNode(exec,evt.currentTarget()));
  -        KJS::Interpreter::unlock();
  -    }
   
  -    KJS::Interpreter::lock();
       Value retval = listener.call(exec, thisObj, args);
  -    KJS::Interpreter::unlock();
   
       window->setCurrentEvent( 0 );
       interpreter->setCurrentEvent( 0 );
  -#if APPLE_CHANGES
  -    if ( exec->hadException() ) {
  -        KJS::Interpreter::lock();
  +
  +    if (exec->hadException()) {
           char *message = exec->exception().toObject(exec).get(exec, messagePropertyName).toString(exec).ascii();
           int lineNumber =  exec->exception().toObject(exec).get(exec, "line").toInt32(exec);
           QString sourceURL;
  @@ -108,27 +108,24 @@
             UString uSourceURL = exec->exception().toObject(exec).get(exec, "sourceURL").toString(exec);
             sourceURL = uSourceURL.qstring();
           }
  -        KJS::Interpreter::unlock();
           if (Interpreter::shouldPrintExceptions()) {
   	    printf("(event handler):%s\n", message);
   	}
           KWQ(part)->addMessageToConsole(message, lineNumber, sourceURL);
  -        exec->clearException();
  -    }
  -#else
  -    if ( exec->hadException() )
  -        exec->clearException();
  -#endif
   
  -    else if (html)
  -    {
  +        if (Interpreter::shouldPrintExceptions())
  +            printf("(event handler):%s\n", message);
  +        exec->clearException();
  +    } else if (html) {
           QVariant ret = ValueToVariant(exec, retval);
           if (ret.type() == QVariant::Bool && ret.toBool() == false)
               evt.preventDefault();
       }
  -    DOM::DocumentImpl::updateDocumentsRendering();
  -    deref();
     }
  +
  +  DOM::DocumentImpl::updateDocumentsRendering();
  +  
  +  deref();
   }
   
   DOM::DOMString JSAbstractEventListener::eventListenerType()
  @@ -266,7 +263,7 @@
         KJS::ScriptInterpreter *interpreter = static_cast<KJS::ScriptInterpreter *>(proxy->interpreter());
         ExecState *exec = interpreter->globalExec();
   
  -      KJS::Interpreter::lock();
  +      InterpreterLock lock;
         //KJS::Constructor constr(KJS::Global::current().get("Function").imp());
         KJS::Object constr = interpreter->builtinFunction();
         KJS::List args;
  @@ -277,8 +274,6 @@
         args.append(KJS::String(code));
         listener = constr.construct(exec, args, sourceURL, lineNumber); // ### is globalExec ok ?
   
  -      KJS::Interpreter::unlock();
  -
         if (exec->hadException()) {
   	exec->clearException();
   
  @@ -294,10 +289,7 @@
           KJS::Interpreter::unlock();
           
           if (!thisObj.isNull()) {
  -          KJS::Interpreter::lock();
             static_cast<DOMNode*>(thisObj.imp())->pushEventHandlerScope(exec, scope);
  -          KJS::Interpreter::unlock();
  -          
             listener.setScope(scope);
           }
         }
  @@ -533,7 +525,7 @@
       return Null();
     ScriptInterpreter* interp = static_cast<ScriptInterpreter *>(exec->dynamicInterpreter());
   
  -  KJS::Interpreter::lock();
  +  InterpreterLock lock;
   
     DOMObject *ret = interp->getDOMObject(ei);
     if (!ret) {
  @@ -553,8 +545,6 @@
       interp->putDOMObject(ei, ret);
     }
   
  -  KJS::Interpreter::unlock();
  -
     return Value(ret);
   }
   
  
  
  
  1.24.8.3  +3 -3      WebCore/khtml/ecma/kjs_events.h
  
  Index: kjs_events.h
  ===================================================================
  RCS file: /cvs/root/WebCore/khtml/ecma/kjs_events.h,v
  retrieving revision 1.24.8.2
  retrieving revision 1.24.8.3
  diff -u -r1.24.8.2 -r1.24.8.3
  --- kjs_events.h	31 Aug 2005 00:49:24 -0000	1.24.8.2
  +++ kjs_events.h	16 Sep 2005 02:34:10 -0000	1.24.8.3
  @@ -1,4 +1,3 @@
  -// -*- c-basic-offset: 2 -*-
   /*
    *  This file is part of the KDE libraries
    *  Copyright (C) 2001 Peter Kelly (pmk at post.com)
  @@ -19,12 +18,13 @@
    *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    */
   
  -#ifndef _KJS_EVENTS_H_
  -#define _KJS_EVENTS_H_
  +#ifndef KJS_EVENTS_H
  +#define KJS_EVENTS_H
   
   #include "ecma/kjs_dom.h"
   #include "ecma/kjs_html.h"
   #include "dom/dom2_events.h"
  +#include <kjs/protect.h>
   
   namespace DOM {
       class ClipboardImpl;
  
  
  
  1.18.8.3  +15 -25    WebCore/khtml/ecma/kjs_proxy.cpp
  
  Index: kjs_proxy.cpp
  ===================================================================
  RCS file: /cvs/root/WebCore/khtml/ecma/kjs_proxy.cpp,v
  retrieving revision 1.18.8.2
  retrieving revision 1.18.8.3
  diff -u -r1.18.8.2 -r1.18.8.3
  --- kjs_proxy.cpp	22 Jul 2005 03:09:49 -0000	1.18.8.2
  +++ kjs_proxy.cpp	16 Sep 2005 02:34:11 -0000	1.18.8.3
  @@ -1,4 +1,3 @@
  -// -*- c-basic-offset: 2 -*-
   /*
    *  This file is part of the KDE libraries
    *  Copyright (C) 1999-2001 Harri Porten (porten at kde.org)
  @@ -30,6 +29,8 @@
   
   using namespace KJS;
   
  +using DOM::EventListener;
  +
   extern "C" {
     KJSProxy *kjs_html_init(KHTMLPart *khtmlpart);
   }
  @@ -75,20 +76,22 @@
   
   KJSProxyImpl::~KJSProxyImpl()
   {
  -  //kdDebug() << "KJSProxyImpl::~KJSProxyImpl deleting interpreter " << m_script << endl;
  +  InterpreterLock lock;
     delete m_script;
  +
   #ifndef NDEBUG
     s_count--;
     // If it was the last interpreter, we should have nothing left
   #ifdef KJS_DEBUG_MEM
  -  if ( s_count == 0 )
  +  if (s_count == 0)
       Interpreter::finalCheck();
   #endif
   #endif
   }
   
   QVariant KJSProxyImpl::evaluate(QString filename, int baseLine,
  -                                const QString&str, const DOM::Node &n) {
  +                                const QString&str, const DOM::Node &n) 
  +{
     // evaluate code. Returns the JS return value or an invalid QVariant
     // if there was none, an error occured or the type couldn't be converted.
   
  @@ -98,42 +101,32 @@
     // expected value in all cases.
     // See smart window.open policy for where this is used.
     bool inlineCode = filename.isNull();
  -  //kdDebug(6070) << "KJSProxyImpl::evaluate inlineCode=" << inlineCode << endl;
   
   #ifdef KJS_DEBUGGER
  -  // ###    KJSDebugWin::instance()->attach(m_script);
     if (inlineCode)
       filename = "(unknown file)";
     if (KJSDebugWin::instance())
       KJSDebugWin::instance()->setNextSourceInfo(filename,baseLine);
  -  //    KJSDebugWin::instance()->setMode(KJS::Debugger::Step);
  -#else
  -  Q_UNUSED(baseLine);
   #endif
   
     m_script->setInlineCode(inlineCode);
  -  KJS::Value thisNode = n.isNull() ? Window::retrieve( m_part ) : getDOMNode(m_script->globalExec(),n);
   
  -  KJS::Interpreter::lock();
  -  UString code( str );
  -  KJS::Interpreter::unlock();
  +  InterpreterLock lock;
   
  +  Value thisNode = n.isNull() ? Window::retrieve( m_part ) : getDOMNode(m_script->globalExec(),n);
  +  UString code(str);
     Completion comp = m_script->evaluate(filename, baseLine, code, thisNode);
  +
     bool success = ( comp.complType() == Normal ) || ( comp.complType() == ReturnValue );  
  -#ifdef KJS_DEBUGGER
  -    //    KJSDebugWin::instance()->setCode(QString::null);
  -#endif
   
     // let's try to convert the return value
     if (success && !comp.value().isNull())
       return ValueToVariant( m_script->globalExec(), comp.value());
   
  -  if ( comp.complType() == Throw ) {
  -    KJS::Interpreter::lock();
  +  if (comp.complType() == Throw) {
       UString errorMessage = comp.value().toString(m_script->globalExec());
       int lineNumber =  comp.value().toObject(m_script->globalExec()).get(m_script->globalExec(), "line").toInt32(m_script->globalExec());
       UString sourceURL = comp.value().toObject(m_script->globalExec()).get(m_script->globalExec(), "sourceURL").toString(m_script->globalExec());
  -    KJS::Interpreter::unlock();
   
   #if APPLE_CHANGES
       KWQ(m_part)->addMessageToConsole(errorMessage.qstring(), lineNumber, sourceURL.qstring());
  @@ -153,7 +146,6 @@
       KJSDebugWin *debugWin = KJSDebugWin::instance();
       if (debugWin && debugWin->currentScript() == m_script) {
           debugWin->setMode(KJSDebugWin::Stop);
  -//        debugWin->leaveSession();
       }
   #endif
       Window *win = Window::retrieveWindow(m_part);
  @@ -172,6 +164,7 @@
   #endif
   
     initScript();
  +  InterpreterLock lock;
     return KJS::Window::retrieveWindow(m_part)->getJSLazyEventListener(code,node,m_handlerLineno);
   }
   
  @@ -265,9 +258,8 @@
       return;
   
     // Build the global object - which is a Window instance
  -  KJS::Interpreter::lock();
  -  Object globalObject( new Window(m_part) );
  -  KJS::Interpreter::unlock();
  +  KJS::InterpreterLock lock;
  +  Object globalObject(new Window(m_part));
   
     // Create a KJS interpreter for this part
     m_script = new KJS::ScriptInterpreter(globalObject, m_part);
  @@ -276,10 +268,8 @@
     m_script->setDebuggingEnabled(m_debugEnabled);
   #endif
     //m_script->enableDebug();
  -  KJS::Interpreter::lock();
     globalObject.put(m_script->globalExec(),
   		   "debug", Value(new TestFunctionImp()), Internal);
  -  KJS::Interpreter::unlock();
   
   #if APPLE_CHANGES
     QString userAgent = KWQ(m_part)->userAgent();
  
  
  
  1.8.18.3  +4 -1      WebCore/khtml/ecma/kjs_traversal.cpp
  
  Index: kjs_traversal.cpp
  ===================================================================
  RCS file: /cvs/root/WebCore/khtml/ecma/kjs_traversal.cpp,v
  retrieving revision 1.8.18.2
  retrieving revision 1.8.18.3
  diff -u -r1.8.18.2 -r1.8.18.3
  --- kjs_traversal.cpp	22 Jul 2005 01:18:30 -0000	1.8.18.2
  +++ kjs_traversal.cpp	16 Sep 2005 02:34:11 -0000	1.8.18.3
  @@ -1,4 +1,3 @@
  -// -*- c-basic-offset: 2 -*-
   /*
    *  This file is part of the KDE libraries
    *  Copyright (C) 2001 Peter Kelly (pmk at post.com)
  @@ -20,12 +19,14 @@
   
   #include "kjs_traversal.h"
   #include "kjs_traversal.lut.h"
  +
   #include "kjs_proxy.h"
   #include <dom/dom_node.h>
   #include <xml/dom_nodeimpl.h>
   #include <xml/dom_docimpl.h>
   #include <khtmlview.h>
   #include <kdebug.h>
  +#include <kjs/protect.h>
   
   using namespace KJS;
   
  @@ -324,7 +325,9 @@
   {
       KHTMLPart *part = static_cast<DOM::DocumentImpl *>(node.handle()->docPtr()->document())->part();
       KJSProxy *proxy = KJSProxy::proxy(part);
  +
       if (proxy && filter.implementsCall()) {
  +        InterpreterLock lock;
           ExecState *exec = proxy->interpreter()->globalExec();
           List args;
           args.append(getDOMNode(exec,node));
  
  
  
  1.5.18.1  +1 -1      WebCore/khtml/ecma/kjs_traversal.h
  
  Index: kjs_traversal.h
  ===================================================================
  RCS file: /cvs/root/WebCore/khtml/ecma/kjs_traversal.h,v
  retrieving revision 1.5
  retrieving revision 1.5.18.1
  diff -u -r1.5 -r1.5.18.1
  --- kjs_traversal.h	4 May 2004 22:37:59 -0000	1.5
  +++ kjs_traversal.h	16 Sep 2005 02:34:11 -0000	1.5.18.1
  @@ -103,6 +103,6 @@
       ProtectedObject filter;
     };
   
  -}; // namespace
  +} // namespace
   
   #endif
  
  
  
  1.146.8.11 +16 -21    WebCore/khtml/ecma/kjs_window.cpp
  
  Index: kjs_window.cpp
  ===================================================================
  RCS file: /cvs/root/WebCore/khtml/ecma/kjs_window.cpp,v
  retrieving revision 1.146.8.10
  retrieving revision 1.146.8.11
  diff -u -r1.146.8.10 -r1.146.8.11
  --- kjs_window.cpp	31 Aug 2005 00:49:24 -0000	1.146.8.10
  +++ kjs_window.cpp	16 Sep 2005 02:34:11 -0000	1.146.8.11
  @@ -1555,21 +1555,21 @@
   
   void Window::clear( ExecState *exec )
   {
  -  KJS::Interpreter::lock();
  +  InterpreterLock lock;
     if (m_returnValueSlot)
       if (ValueImp *returnValue = getDirect("returnValue"))
         *m_returnValueSlot = returnValue;
     kdDebug(6070) << "Window::clear " << this << endl;
     delete winq;
     winq = new WindowQObject(this);
  -  // Get rid of everything, those user vars could hold references to DOM nodes
  +
     deleteAllProperties( exec );
  -  // Really delete those properties, so that the DOM nodes get deref'ed
  -  KJS::Collector::collect();
  +  // there's likely to be lots of garbage now
  +  Collector::collect();
  +
     // Now recreate a working global object for the next URL that will use us
     KJS::Interpreter *interpreter = KJSProxy::proxy( m_part )->interpreter();
     interpreter->initGlobalObject();
  -  KJS::Interpreter::unlock();
   }
   
   void Window::setCurrentEvent( DOM::Event *evt )
  @@ -2129,43 +2129,38 @@
   void ScheduledAction::execute(Window *window)
   {
     ScriptInterpreter *interpreter = static_cast<ScriptInterpreter *>(KJSProxy::proxy(window->m_part)->interpreter());
  -
  +  
     interpreter->setProcessingTimerCallback(true);
  -
  +  
     //kdDebug(6070) << "ScheduledAction::execute " << this << endl;
     if (isFunction) {
       if (func.implementsCall()) {
         // #### check this
         Q_ASSERT( window->m_part );
  -      if ( window->m_part )
  -      {
  -        KJS::Interpreter *interpreter = KJSProxy::proxy( window->m_part )->interpreter();
  +      if (window->m_part) {
  +        Interpreter *interpreter = KJSProxy::proxy(window->m_part)->interpreter();
           ExecState *exec = interpreter->globalExec();
           Q_ASSERT( window == interpreter->globalObject().imp() );
           Object obj( window );
  -	Interpreter::lock();
  +	InterpreterLock lock;
           func.call(exec,obj,args); // note that call() creates its own execution state for the func call
  -	Interpreter::unlock();
  +        
   	if ( exec->hadException() ) {
   #if APPLE_CHANGES
  -          Interpreter::lock();
             char *message = exec->exception().toObject(exec).get(exec, messagePropertyName).toString(exec).ascii();
             int lineNumber =  exec->exception().toObject(exec).get(exec, "line").toInt32(exec);
  -          Interpreter::unlock();
  -	  if (Interpreter::shouldPrintExceptions()) {
  +	  if (Interpreter::shouldPrintExceptions())
   	    printf("(timer):%s\n", message);
  -	  }
  +
             KWQ(window->m_part)->addMessageToConsole(message, lineNumber, QString());
   #endif
   	  exec->clearException();
  -	}
  +        }
         }
       }
  -  }
  -  else {
  +  } else
       window->m_part->executeScript(code);
  -  }
  -
  +  
     // Update our document's rendering following the execution of the timeout callback.
     DOM::DocumentImpl *doc = static_cast<DOM::DocumentImpl*>(window->m_part->document().handle());
     doc->updateRendering();
  
  
  
  1.34.8.7  +1 -0      WebCore/khtml/ecma/kjs_window.h
  
  Index: kjs_window.h
  ===================================================================
  RCS file: /cvs/root/WebCore/khtml/ecma/kjs_window.h,v
  retrieving revision 1.34.8.6
  retrieving revision 1.34.8.7
  diff -u -r1.34.8.6 -r1.34.8.7
  --- kjs_window.h	2 Aug 2005 21:26:15 -0000	1.34.8.6
  +++ kjs_window.h	16 Sep 2005 02:34:12 -0000	1.34.8.7
  @@ -28,6 +28,7 @@
   #include <qptrlist.h>
   
   #include "kjs_binding.h"
  +#include <kjs/protect.h>
   
   class QTimer;
   class KHTMLView;
  
  
  
  1.26.8.7  +9 -4      WebCore/khtml/ecma/xmlhttprequest.cpp
  
  Index: xmlhttprequest.cpp
  ===================================================================
  RCS file: /cvs/root/WebCore/khtml/ecma/xmlhttprequest.cpp,v
  retrieving revision 1.26.8.6
  retrieving revision 1.26.8.7
  diff -u -r1.26.8.6 -r1.26.8.7
  --- xmlhttprequest.cpp	24 Aug 2005 00:03:37 -0000	1.26.8.6
  +++ xmlhttprequest.cpp	16 Sep 2005 02:34:12 -0000	1.26.8.7
  @@ -1,4 +1,3 @@
  -// -*- c-basic-offset: 2 -*-
   /*
    *  This file is part of the KDE libraries
    *  Copyright (C) 2004 Apple Computer, Inc.
  @@ -358,7 +357,10 @@
     }
   #endif
   
  -  gcProtect (this);
  +  {
  +    InterpreterLock lock;
  +    gcProtect(this);
  +  }
     
     qObject->connect( job, SIGNAL( result( KIO::Job* ) ),
   		    SLOT( slotFinished( KIO::Job* ) ) );
  @@ -396,8 +398,10 @@
     }
     aborted = true;
   
  -  if (hadJob)
  +  if (hadJob) {
  +    InterpreterLock lock;
       gcUnprotect(this);
  +  }
   }
   
   void XMLHttpRequest::setRequestHeader(const QString& name, const QString &value)
  @@ -542,7 +546,8 @@
       decoder = 0;
     }
   
  -  gcUnprotect (this);
  +  InterpreterLock lock;
  +  gcUnprotect(this);
   }
   
   void XMLHttpRequest::slotRedirection(KIO::Job*, const KURL& url)
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.2   +84 -0     WebCore/khtml/misc/main_thread_malloc.cpp
  
  Index: main_thread_malloc.cpp
  ===================================================================
  RCS file: /cvs/root/WebCore/khtml/misc/main_thread_malloc.cpp,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- main_thread_malloc.cpp	2 Sep 2005 22:27:40 -0000	1.1.2.1
  +++ main_thread_malloc.cpp	16 Sep 2005 02:34:15 -0000	1.1.2.2
  @@ -231,6 +231,37 @@
   
   namespace khtml {
   
  +#ifndef NDEBUG
  +
  +// In debugging builds, use the system malloc for its debugging features.
  +
  +void *main_thread_malloc(size_t n)
  +{
  +    assert(pthread_main_np());
  +    return malloc(n);
  +}
  +
  +void *main_thread_calloc(size_t n_elements, size_t element_size)
  +{
  +    assert(pthread_main_np());
  +    return calloc(n_elements, element_size);
  +}
  +
  +void main_thread_free(void* p)
  +{
  +    // it's ok to main_thread_free on a non-main thread - the actual
  +    // free will be scheduled on the main thread in that case.
  +    free(p);
  +}
  +
  +void *main_thread_realloc(void* p, size_t n)
  +{
  +    assert(pthread_main_np());
  +    return realloc(p, n);
  +}
  +
  +#else
  +
   /*
     WIN32 sets up defaults for MS environment and compilers.
     Otherwise defaults are for unix.
  @@ -1578,7 +1609,58 @@
     return m;
   }
   
  +
  +static pthread_once_t free_mutex_once = PTHREAD_ONCE_INIT;
  +static pthread_mutex_t free_mutex;
  +static int scheduled_free_size;
  +static int scheduled_free_capacity;
  +static int scheduled_free_list;
  +bool free_is_scheduled;
  +
  +static void initialize_scheduled_free_list()
  +{
  +    pthread_mutex_init(&free_mutex, NULL);
  +}
  +
  +static void drain_scheduled_free_list()
  +{
  +    pthread_mutex_lock(&free_mutex);
  +    if (free_is_scheduled) {
  +        for(int i = 0; i < scheduled_free_size; i++) {
  +            main_thread_free(scheduled_free_list[i]);
  +        }
  +        free(scheduled_free_list);
  +        scheduled_free_list = NULL;
  +        scheduled_free_size = 0;
  +        scheduled_free_capacity = 0;
  +        free_is_scheduled = false;
  +    }
  +    pthread_mutex_unlock(&free_mutex);
  +}
  +
  +static void schedule_free_on_main_thread(Void_t* m)
  +{
  +    pthread_once(&free_mutex_once, initialize_scheduled_free_list);
  +
  +    pthread_mutex_lock(&free_mutex);
  +    if (scheduled_free_size == scheduled_free_capacity) {
  +        scheduled_free_capacity = scheduled_free_capacity == 0 ? 16 : scheduled_free_capacity * 1.2;
  +        scheduled_free_list = (Void_t**)realloc(scheduled_free_list, sizeof(Void_t*) * scheduled_free_capacity);
  +    }
  +    scheduled_free_list[scheduled_free_size++] = m;
  +    if (!free_is_scheduled) {
  +        QTimer::immediateSingleShotOnMainThread(0, drain_scheduled_free_list);
  +        free_is_scheduled = true;
  +    }
  +    pthread_mutex_unlock(&free_mutex);
  +}
  +
   void public_fREe(Void_t* m) {
  +  if (!pthread_main_np()) {
  +      schedule_free_on_main_thread(m);
  +      return;
  +  }
  +
     if (MALLOC_PREACTION != 0) {
       return;
     }
  @@ -5424,6 +5506,8 @@
   
   #endif /* WIN32 */
   
  +#endif // NDEBUG
  +
   };  /* end of namespace KJS */
   
   /* ------------------------------------------------------------
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.628.6.8 +16 -9     WebCore/kwq/KWQKHTMLPart.mm
  
  Index: KWQKHTMLPart.mm
  ===================================================================
  RCS file: /cvs/root/WebCore/kwq/KWQKHTMLPart.mm,v
  retrieving revision 1.628.6.7
  retrieving revision 1.628.6.8
  diff -u -r1.628.6.7 -r1.628.6.8
  --- KWQKHTMLPart.mm	16 Aug 2005 01:42:47 -0000	1.628.6.7
  +++ KWQKHTMLPart.mm	16 Sep 2005 02:34:16 -0000	1.628.6.8
  @@ -79,6 +79,7 @@
   
   #import <JavaScriptCore/identifier.h>
   #import <JavaScriptCore/property_map.h>
  +#import <JavaScriptCore/interpreter.h>
   #import <JavaScriptCore/runtime.h>
   #import <JavaScriptCore/runtime_root.h>
   #import <JavaScriptCore/WebScriptObjectPrivate.h>
  @@ -153,6 +154,7 @@
   using KIO::Job;
   
   using KJS::Interpreter;
  +using KJS::InterpreterLock;
   using KJS::Location;
   using KJS::SavedBuiltins;
   using KJS::SavedProperties;
  @@ -1429,6 +1431,7 @@
   KJS::Bindings::RootObject *KWQKHTMLPart::bindingRootObject()
   {
       if (!_bindingRoot) {
  +        InterpreterLock lock;
           _bindingRoot = new KJS::Bindings::RootObject(0);    // The root gets deleted by JavaScriptCore.
           KJS::ObjectImp *win = static_cast<KJS::ObjectImp *>(KJS::Window::retrieveWindow(this));
           _bindingRoot->setRootObjectImp (win);
  @@ -1441,7 +1444,8 @@
   WebScriptObject *KWQKHTMLPart::windowScriptObject()
   {
       if (!_windowScriptObject) {
  -        KJS::ObjectImp *win = static_cast<KJS::ObjectImp *>(KJS::Window::retrieveWindow(this));
  +        KJS::InterpreterLock lock;
  +        KJS::ObjectImp *win = KJS::Window::retrieveWindow(this);
           _windowScriptObject = KWQRetainNSRelease([[WebScriptObject alloc] _initWithObjectImp:win originExecutionContext:bindingRootObject() executionContext:bindingRootObject()]);
       }
   
  @@ -1514,9 +1518,8 @@
   {
       Window *window = Window::retrieveWindow(this);
       if (window) {
  -        Interpreter::lock();
  +        InterpreterLock lock;
           Location *location = window->location();
  -        Interpreter::unlock();
           location->saveProperties(*locationProperties);
       }
   }
  @@ -1532,9 +1535,8 @@
   {
       Window *window = Window::retrieveWindow(this);
       if (window) {
  -        Interpreter::lock();
  +        InterpreterLock lock;
           Location *location = window->location();
  -        Interpreter::unlock();
           location->restoreProperties(*locationProperties);
       }
   }
  @@ -1632,10 +1634,13 @@
       doc->setParseMode ([state parseMode]);
       
       updatePolicyBaseURL();
  -        
  -    restoreWindowProperties (windowProperties);
  -    restoreLocationProperties (locationProperties);
  -    restoreInterpreterBuiltins (*interpreterBuiltins);
  +
  +    { // scope the lock
  +        InterpreterLock lock;
  +        restoreWindowProperties (windowProperties);
  +        restoreLocationProperties (locationProperties);
  +        restoreInterpreterBuiltins (*interpreterBuiltins);
  +    }
   
       if (actions)
           resumeActions (actions, state);
  @@ -3936,6 +3941,8 @@
   
   void KWQKHTMLPart::cleanupPluginRootObjects()
   {
  +    InterpreterLock lock;
  +
       KJS::Bindings::RootObject *root;
       while ((root = rootObjects.getLast())) {
           root->removeAllNativeReferences ();
  
  
  
  1.17.8.2  +7 -0      WebCore/kwq/KWQPageState.mm
  
  Index: KWQPageState.mm
  ===================================================================
  RCS file: /cvs/root/WebCore/kwq/KWQPageState.mm,v
  retrieving revision 1.17.8.1
  retrieving revision 1.17.8.2
  diff -u -r1.17.8.1 -r1.17.8.2
  --- KWQPageState.mm	24 May 2005 22:08:50 -0000	1.17.8.1
  +++ KWQPageState.mm	16 Sep 2005 02:34:17 -0000	1.17.8.2
  @@ -25,6 +25,7 @@
   
   #import "KWQPageState.h"
   
  +#import <JavaScriptCore/interpreter.h>
   #import <JavaScriptCore/property_map.h>
   
   #import "dom_docimpl.h"
  @@ -39,6 +40,8 @@
   
   using khtml::RenderObject;
   
  +using KJS::Interpreter;
  +using KJS::InterpreterLock;
   using KJS::SavedProperties;
   using KJS::SavedBuiltins;
   
  @@ -96,12 +99,16 @@
   
       delete URL;
       URL = 0;
  +
  +    InterpreterLock lock;
  +
       delete windowProperties;
       windowProperties = 0;
       delete locationProperties;
       locationProperties = 0;
       delete interpreterBuiltins;
       interpreterBuiltins = 0;
  +
       [self _cleanupPausedActions];
   }
   
  
  
  
  1.10.74.1 +2 -0      WebCore/kwq/KWQTimer.h
  
  Index: KWQTimer.h
  ===================================================================
  RCS file: /cvs/root/WebCore/kwq/KWQTimer.h,v
  retrieving revision 1.10
  retrieving revision 1.10.74.1
  diff -u -r1.10 -r1.10.74.1
  --- KWQTimer.h	22 Jan 2003 00:12:36 -0000	1.10
  +++ KWQTimer.h	16 Sep 2005 02:34:17 -0000	1.10.74.1
  @@ -47,6 +47,8 @@
       
       static void singleShot(int msec, QObject *receiver, const char *member);
       
  +    static void immediateSingleShotOnMainThread(void (*func)());
  +
       // This is just a hack used by KWQKHTMLPart. The monitor function
       // gets called when the timer starts and when it is stopped before firing,
       // but not when the timer fires.
  
  
  
  1.15.10.1 +30 -0     WebCore/kwq/KWQTimer.mm
  
  Index: KWQTimer.mm
  ===================================================================
  RCS file: /cvs/root/WebCore/kwq/KWQTimer.mm,v
  retrieving revision 1.15
  retrieving revision 1.15.10.1
  diff -u -r1.15 -r1.15.10.1
  --- KWQTimer.mm	9 Nov 2004 21:52:20 -0000	1.15
  +++ KWQTimer.mm	16 Sep 2005 02:34:17 -0000	1.15.10.1
  @@ -159,3 +159,33 @@
                                       repeats:NO];
   }
   
  + at interface KWQMainThreadPerformTarget : NSObject
  +{
  +    void (*_func)();
  +}
  +
  +- (id)initWithFunction:(void (*)())func;
  +- (void)callFunction:(id)ignore;
  + at end
  +
  + at implementation KWQMainThreadPerformTarget
  +- (id)initWithFunction:(void (*)())func
  +{
  +    if ((self = [super init])) {
  +        _func = func;
  +    }
  +    return self;
  +}
  +
  +- (void)callFunction:(id)ignore
  +{
  +    _func();
  +}
  +
  + at end
  +
  +void QTimer::immediateSingleShotOnMainThread(void (*func)())
  +{
  +    [[[KWQMainThreadPerformTarget alloc] initWithFunction:func] performSelectorOnMainThread:@selector(callFunction) withObject:nil waitUntilDone:NO];
  +}
  +
  
  
  
  1.382.2.8 +7 -2      WebCore/kwq/WebCoreBridge.mm
  
  Index: WebCoreBridge.mm
  ===================================================================
  RCS file: /cvs/root/WebCore/kwq/WebCoreBridge.mm,v
  retrieving revision 1.382.2.7
  retrieving revision 1.382.2.8
  diff -u -r1.382.2.7 -r1.382.2.8
  --- WebCoreBridge.mm	9 Aug 2005 23:52:19 -0000	1.382.2.7
  +++ WebCoreBridge.mm	16 Sep 2005 02:34:18 -0000	1.382.2.8
  @@ -60,11 +60,12 @@
   #import "visible_units.h"
   #import "xml_tokenizer.h"
   
  -#import <JavaScriptCore/npruntime.h>
  +#import <JavaScriptCore/interpreter.h>
   #import <JavaScriptCore/jni_jsobject.h>
  +#import <JavaScriptCore/npruntime.h>
   #import <JavaScriptCore/object.h>
  -#import <JavaScriptCore/runtime_root.h>
   #import <JavaScriptCore/property_map.h>
  +#import <JavaScriptCore/runtime_root.h>
   
   #import "KWQAssertions.h"
   #import "KWQCharsets.h"
  @@ -136,6 +137,8 @@
   using khtml::VisiblePosition;
   
   using KJS::ExecState;
  +using KJS::Interpreter;
  +using KJS::InterpreterLock;
   using KJS::ObjectImp;
   using KJS::SavedProperties;
   using KJS::SavedBuiltins;
  @@ -467,6 +470,8 @@
       }
       _part->clearTimers();
   
  +    InterpreterLock lock;
  +
       SavedProperties *windowProperties = new SavedProperties;
       _part->saveWindowProperties(windowProperties);
   
  
  
  
  1.7.26.1  +4 -6      WebCore/kwq/WebCoreJavaScript.mm
  
  Index: WebCoreJavaScript.mm
  ===================================================================
  RCS file: /cvs/root/WebCore/kwq/WebCoreJavaScript.mm,v
  retrieving revision 1.7
  retrieving revision 1.7.26.1
  diff -u -r1.7 -r1.7.26.1
  --- WebCoreJavaScript.mm	21 Dec 2003 20:40:23 -0000	1.7
  +++ WebCoreJavaScript.mm	16 Sep 2005 02:34:18 -0000	1.7.26.1
  @@ -30,6 +30,7 @@
   
   using KJS::Collector;
   using KJS::Interpreter;
  +using KJS::InterpreterLock;
   
   @implementation WebCoreJavaScript
   
  @@ -55,17 +56,14 @@
   
   + (NSSet *)rootObjectClasses
   {
  -    Interpreter::lock();
  -    NSSet *classes = (NSSet *)Collector::rootObjectClasses();
  -    Interpreter::unlock();
  -    return [classes autorelease];
  +    InterpreterLock lock;
  +    return [(NSSet *)Collector::rootObjectClasses() autorelease];
   }
   
   + (void)garbageCollect
   {
  -    Interpreter::lock();
  +    InterpreterLock lock;
       while (Collector::collect()) { }
  -    Interpreter::unlock();
   }
   
   + (BOOL)shouldPrintExceptions
  
  
  
  1.1.2.3   +1 -2      WebCore/kwq/WebCoreScriptDebugger.mm
  
  Index: WebCoreScriptDebugger.mm
  ===================================================================
  RCS file: /cvs/root/WebCore/kwq/WebCoreScriptDebugger.mm,v
  retrieving revision 1.1.2.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- WebCoreScriptDebugger.mm	2 Aug 2005 22:50:21 -0000	1.1.2.2
  +++ WebCoreScriptDebugger.mm	16 Sep 2005 02:34:18 -0000	1.1.2.3
  @@ -330,12 +330,11 @@
       // evaluate
       Value result;
       if (!eval.isNull()) {
  -        Interpreter::lock();
  +        InterpreterLock lock;
           Object dummy;
           List args;
           args.append(String(code));
           result = eval.call(state, dummy, args);
  -        Interpreter::unlock();
       }
       else {
           // no "eval", or no context (i.e. global scope) - use global fallback
  
  
  



More information about the webkit-changes mailing list