Commit 662d3218 authored by mjs's avatar mjs
Browse files

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):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@10563 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 36eaa5b1
2005-09-14 Maciej Stachowiak <mjs@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):
2005-09-16 Adele Peterson <adele@apple.com>
Change by Darin, reviewed by me and Maciej.
......
......@@ -25,8 +25,7 @@
/* End PBXAggregateTarget section */
/* Begin PBXBuildFile section */
65305EAF08A58DDE00F31E73 /* protected_object.h in Headers */ = {isa = PBXBuildFile; fileRef = 65305EAE08A58DDE00F31E73 /* protected_object.h */; settings = {ATTRIBUTES = (Private, ); }; };
65305EB008A58E0900F31E73 /* protected_object.h in Headers */ = {isa = PBXBuildFile; fileRef = 65305EAE08A58DDE00F31E73 /* protected_object.h */; settings = {ATTRIBUTES = (Private, ); }; };
652C107F08DA7B1E0020887D /* protected_reference.h in Headers */ = {isa = PBXBuildFile; fileRef = 652C107E08DA7B1E0020887D /* protected_reference.h */; };
65621E6D089E859700760F35 /* property_slot.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 65621E6B089E859700760F35 /* property_slot.cpp */; };
65621E6E089E859700760F35 /* property_slot.h in Headers */ = {isa = PBXBuildFile; fileRef = 65621E6C089E859700760F35 /* property_slot.h */; settings = {ATTRIBUTES = (Private, ); }; };
65621E6F089E85D300760F35 /* property_slot.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 65621E6B089E859700760F35 /* property_slot.cpp */; };
......@@ -479,7 +478,7 @@
651BDC78080F10CC00F10856 /* fast_malloc.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = fast_malloc.h; sourceTree = "<group>"; };
651F6412039D5B5F0078395C /* dtoa.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = dtoa.cpp; sourceTree = "<group>"; };
651F6413039D5B5F0078395C /* dtoa.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = dtoa.h; sourceTree = "<group>"; };
65305EAE08A58DDE00F31E73 /* protected_object.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = protected_object.h; sourceTree = "<group>"; };
652C107E08DA7B1E0020887D /* protected_reference.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = protected_reference.h; sourceTree = "<group>"; };
6541720E039E08B90058BFEB /* dftables.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = dftables.c; path = pcre/dftables.c; sourceTree = "<group>"; };
6541720F039E08B90058BFEB /* pcre.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = pcre.h; path = pcre/pcre.h; sourceTree = "<group>"; };
65417217039E0B280058BFEB /* pcre-config.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = "pcre-config.h"; path = "pcre/pcre-config.h"; sourceTree = "<group>"; };
......@@ -677,12 +676,12 @@
08FB77AEFE84172EC02AAC07 /* Classes */ = {
isa = PBXGroup;
children = (
65305EAE08A58DDE00F31E73 /* protected_object.h */,
65EF2DF408BECC80000894BB /* shared_ptr.h */,
65621E6B089E859700760F35 /* property_slot.cpp */,
65621E6C089E859700760F35 /* property_slot.h */,
938772E5038BFE19008635CE /* array_instance.h */,
650B68D80639033F009D42DE /* protected_values.cpp */,
652C107E08DA7B1E0020887D /* protected_reference.h */,
650B68D90639033F009D42DE /* protected_values.h */,
65AB004806261CBA0076DE63 /* interpreter_map.cpp */,
65AB004906261CBA0076DE63 /* interpreter_map.h */,
......@@ -888,7 +887,6 @@
isa = PBXHeadersBuildPhase;
buildActionMask = 2147483647;
files = (
65305EAF08A58DDE00F31E73 /* protected_object.h in Headers */,
932F5B400822A1C700736975 /* array_object.h in Headers */,
932F5B420822A1C700736975 /* collector.h in Headers */,
932F5B430822A1C700736975 /* date_object.h in Headers */,
......@@ -967,6 +965,7 @@
93E26C1308B1523D00F85226 /* ucptable.c in Headers */,
93E26CCF08B2921900F85226 /* softlinking.h in Headers */,
65EF2DF508BECC80000894BB /* shared_ptr.h in Headers */,
652C107F08DA7B1E0020887D /* protected_reference.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......@@ -974,7 +973,6 @@
isa = PBXHeadersBuildPhase;
buildActionMask = 2147483647;
files = (
65305EB008A58E0900F31E73 /* protected_object.h in Headers */,
A85D81F8087B2822006A9172 /* array_object.h in Headers */,
A85D81F9087B2822006A9172 /* collector.h in Headers */,
A85D81FA087B2822006A9172 /* date_object.h in Headers */,
......
......@@ -73,7 +73,7 @@ static NPClass _javascriptClass = {
NPClass *NPScriptObjectClass = &_javascriptClass;
static Identifier identiferFromNPIdentifier(const NPUTF8 *name)
static Identifier identifierFromNPIdentifier(const NPUTF8 *name)
{
NPUTF16 *methodName;
unsigned int UTF16Length;
......@@ -148,38 +148,29 @@ bool _NPN_Invoke (NPP npp, NPObject *o, NPIdentifier methodName, const NPVariant
else {
// Lookup the function object.
ExecState *exec = obj->executionContext->interpreter()->globalExec();
Interpreter::lock();
ValueImp *func = obj->imp->get (exec, identiferFromNPIdentifier(i->value.string));
Interpreter::unlock();
InterpreterLock lock;
ValueImp *func = obj->imp->get (exec, identifierFromNPIdentifier(i->value.string));
if (func->isNull()) {
NPN_InitializeVariantAsNull(result);
return false;
}
else if (func->isUndefined()) {
} else if (func->isUndefined()) {
NPN_InitializeVariantAsUndefined(result);
return false;
}
else {
} else {
// Call the function object.
ObjectImp *funcImp = static_cast<ObjectImp*>(func);
ObjectImp *thisObj = const_cast<ObjectImp*>(obj->imp);
List argList = listFromVariantArgs(exec, args, argCount);
Interpreter::lock();
ValueImp *resultV = 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;
}
......@@ -195,7 +186,7 @@ bool _NPN_Evaluate (NPP npp, NPObject *o, NPString *s, NPVariant *variant)
ExecState *exec = obj->executionContext->interpreter()->globalExec();
ValueImp *result;
Interpreter::lock();
InterpreterLock lock;
NPUTF16 *scriptString;
unsigned int UTF16Length;
convertNPStringToUTF16 (s, &scriptString, &UTF16Length); // requires free() of returned memory.
......@@ -211,8 +202,6 @@ bool _NPN_Evaluate (NPP npp, NPObject *o, NPString *s, NPVariant *variant)
else
result = Undefined();
Interpreter::unlock();
free ((void *)scriptString);
convertValueToNPVariant(exec, result, variant);
......@@ -234,15 +223,13 @@ bool _NPN_GetProperty (NPP npp, NPObject *o, NPIdentifier propertyName, NPVarian
PrivateIdentifier *i = (PrivateIdentifier *)propertyName;
Interpreter::lock();
InterpreterLock lock;
ValueImp *result;
if (i->isString) {
result = obj->imp->get (exec, identiferFromNPIdentifier(i->value.string));
}
else {
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);
......@@ -278,21 +265,17 @@ bool _NPN_SetProperty (NPP npp, NPObject *o, NPIdentifier propertyName, const NP
return false;
ExecState *exec = obj->executionContext->interpreter()->globalExec();
Interpreter::lock();
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;
}
......@@ -308,7 +291,7 @@ bool _NPN_RemoveProperty (NPP npp, NPObject *o, NPIdentifier propertyName)
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;
}
}
......@@ -318,14 +301,11 @@ bool _NPN_RemoveProperty (NPP npp, NPObject *o, NPIdentifier propertyName)
}
}
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;
}
......@@ -343,24 +323,14 @@ bool _NPN_HasProperty(NPP npp, NPObject *o, NPIdentifier propertyName)
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;
}
......@@ -379,9 +349,9 @@ bool _NPN_HasMethod(NPP npp, NPObject *o, NPIdentifier methodName)
// Lookup the function object.
ExecState *exec = obj->executionContext->interpreter()->globalExec();
Interpreter::lock();
ValueImp *func = obj->imp->get (exec, identiferFromNPIdentifier(i->value.string));
Interpreter::unlock();
InterpreterLock lock;
ValueImp *func = obj->imp->get (exec, identifierFromNPIdentifier(i->value.string));
if (func->isUndefined()) {
return false;
......@@ -402,8 +372,7 @@ void _NPN_SetException(NPObject *o, const NPUTF8 *message)
if (o->_class == NPScriptObjectClass) {
JavaScriptObject *obj = (JavaScriptObject *)o;
ExecState *exec = obj->executionContext->interpreter()->globalExec();
Interpreter::lock();
InterpreterLock lock;
throwError(exec, GeneralError, message);
Interpreter::unlock();
}
}
......@@ -170,11 +170,10 @@ jobject JSObject::call(jstring methodName, jobjectArray args) const
// Lookup the function object.
ExecState *exec = _root->interpreter()->globalExec();
Interpreter::lock();
InterpreterLock lock;
Identifier identifier(JavaString(methodName).ustring());
ValueImp *func = _imp->get (exec, identifier);
Interpreter::unlock();
if (func->isUndefinedOrNull()) {
// Maybe throw an exception here?
return 0;
......@@ -184,36 +183,29 @@ jobject JSObject::call(jstring methodName, jobjectArray args) const
ObjectImp *funcImp = static_cast<ObjectImp*>(func);
ObjectImp *thisObj = const_cast<ObjectImp*>(_imp);
List argList = listFromJArray(args);
Interpreter::lock();
ValueImp *result = funcImp->call (exec, thisObj, argList);
Interpreter::unlock();
ValueImp *result = funcImp->call(exec, thisObj, argList);
// 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());
ObjectImp *thisObj = const_cast<ObjectImp*>(_imp);
ValueImp *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) {
if (!result)
result = Undefined();
}
}
else
} else
result = Undefined();
Interpreter::unlock();
return convertValueToJObject (result);
}
......@@ -223,21 +215,19 @@ jobject JSObject::getMember(jstring memberName) const
JS_LOG ("(%p) memberName = %s\n", _imp, JavaString(memberName).UTF8String());
ExecState *exec = _root->interpreter()->globalExec();
Interpreter::lock();
InterpreterLock lock;
ValueImp *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 +236,8 @@ void JSObject::removeMember(jstring memberName) const
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 +246,11 @@ jobject JSObject::getSlot(jint index) const
JS_LOG ("index = %ld\n", index);
ExecState *exec = _root->interpreter()->globalExec();
Interpreter::lock();
InterpreterLock lock;
ValueImp *result = _imp->get (exec, (unsigned)index);
Interpreter::unlock();
return convertValueToJObject (result);
return convertValueToJObject(result);
}
......@@ -270,25 +259,20 @@ void JSObject::setSlot(jint index, jobject value) const
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();
InterpreterLock lock;
ObjectImp *thisObj = const_cast<ObjectImp*>(_imp);
ExecState *exec = _root->interpreter()->globalExec();
jstring result = (jstring)convertValueToJValue (exec, thisObj, object_type, "java.lang.String").l;
Interpreter::unlock();
return result;
return (jstring)convertValueToJValue (exec, thisObj, object_type, "java.lang.String").l;
}
void JSObject::finalize() const
......@@ -437,9 +421,8 @@ ValueImp *JSObject::convertJObjectToValue (jobject theObject) const
return imp;
}
Interpreter::lock();
InterpreterLock lock;
RuntimeObjectImp *newImp = new RuntimeObjectImp(new Bindings::JavaInstance (theObject, _root));
Interpreter::unlock();
return newImp;
}
......
......@@ -190,24 +190,22 @@ static List listFromNSArray(ExecState *exec, NSArray *array)
// Lookup the function object.
ExecState *exec = [self _executionContext]->interpreter()->globalExec();
Interpreter::lock();
InterpreterLock lock;
ValueImp *v = convertObjcValueToValue(exec, &name, ObjcObjectType);
Identifier identifier(v->toString(exec));
ValueImp *func = [self _imp]->get (exec, identifier);
Interpreter::unlock();
if (!func || func->isUndefined()) {
// Maybe throw an exception here?
return 0;
}
// Call the function object.
Interpreter::lock();
ObjectImp *funcImp = static_cast<ObjectImp*>(func);
ObjectImp *thisObj = const_cast<ObjectImp*>([self _imp]);
List argList = listFromNSArray(exec, args);
ValueImp *result = funcImp->call (exec, thisObj, argList);
Interpreter::unlock();
if (exec->hadException()) {
LOG_EXCEPTION (exec);
......@@ -226,15 +224,14 @@ static List listFromNSArray(ExecState *exec, NSArray *array)
{
if (![self _executionContext])
return nil;
if (![self _isSafeScript])
return nil;
ExecState *exec = [self _executionContext]->interpreter()->globalExec();
ValueImp *result;
Interpreter::lock();
InterpreterLock lock;
ValueImp *v = convertObjcValueToValue(exec, &script, ObjcObjectType);
Completion completion = [self _executionContext]->interpreter()->evaluate(UString(), 0, v->toString(exec));
......@@ -242,22 +239,18 @@ static List listFromNSArray(ExecState *exec, NSArray *array)
if (type == Normal) {
result = completion.value();
if (!result) {
if (!result)
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;
......@@ -273,10 +266,9 @@ static List listFromNSArray(ExecState *exec, NSArray *array)
ExecState *exec = [self _executionContext]->interpreter()->globalExec();
Interpreter::lock();
InterpreterLock lock;
ValueImp *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);
......@@ -295,10 +287,9 @@ static List listFromNSArray(ExecState *exec, NSArray *array)
ExecState *exec = [self _executionContext]->interpreter()->globalExec();
Interpreter::lock();
InterpreterLock lock;
ValueImp *v = convertObjcValueToValue(exec, &key, ObjcObjectType);
ValueImp *result = [self _imp]->get (exec, Identifier (v->toString(exec)));
Interpreter::unlock();