From 41386e9cb918eed93b3f13648cbef387e371e451 Mon Sep 17 00:00:00 2001 From: Lorry Tar Creator Date: Wed, 20 May 2015 09:56:07 +0000 Subject: webkitgtk-2.4.9 --- .../JavaScriptCore/API/JSCallbackObjectFunctions.h | 87 ++++++++++------------ 1 file changed, 39 insertions(+), 48 deletions(-) (limited to 'Source/JavaScriptCore/API/JSCallbackObjectFunctions.h') diff --git a/Source/JavaScriptCore/API/JSCallbackObjectFunctions.h b/Source/JavaScriptCore/API/JSCallbackObjectFunctions.h index 585aab194..5be053f1e 100644 --- a/Source/JavaScriptCore/API/JSCallbackObjectFunctions.h +++ b/Source/JavaScriptCore/API/JSCallbackObjectFunctions.h @@ -11,10 +11,10 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR @@ -24,6 +24,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include "APIShims.h" #include "APICast.h" #include "Error.h" #include "ExceptionHelpers.h" @@ -58,7 +59,7 @@ inline JSCallbackObject* JSCallbackObject::asCallbackObject(Enco template JSCallbackObject::JSCallbackObject(ExecState* exec, Structure* structure, JSClassRef jsClass, void* data) : Parent(exec->vm(), structure) - , m_callbackObjectData(std::make_unique(data, jsClass)) + , m_callbackObjectData(adoptPtr(new JSCallbackObjectData(data, jsClass))) { } @@ -67,20 +68,10 @@ JSCallbackObject::JSCallbackObject(ExecState* exec, Structure* structure template JSCallbackObject::JSCallbackObject(VM& vm, JSClassRef jsClass, Structure* structure) : Parent(vm, structure) - , m_callbackObjectData(std::make_unique(nullptr, jsClass)) + , m_callbackObjectData(adoptPtr(new JSCallbackObjectData(0, jsClass))) { } -template -JSCallbackObject::~JSCallbackObject() -{ - JSObjectRef thisRef = toRef(static_cast(this)); - for (JSClassRef jsClass = classRef(); jsClass; jsClass = jsClass->parentClass) { - if (JSObjectFinalizeCallback finalize = jsClass->finalize) - finalize(thisRef); - } -} - template void JSCallbackObject::finishCreation(ExecState* exec) { @@ -113,10 +104,17 @@ void JSCallbackObject::init(ExecState* exec) // initialize from base to derived for (int i = static_cast(initRoutines.size()) - 1; i >= 0; i--) { - JSLock::DropAllLocks dropAllLocks(exec); + APICallbackShim callbackShim(exec); JSObjectInitializeCallback initialize = initRoutines[i]; initialize(toRef(exec), toRef(this)); } + + for (JSClassRef jsClassPtr = classRef(); jsClassPtr; jsClassPtr = jsClassPtr->parentClass) { + if (jsClassPtr->finalize) { + WeakSet::allocate(this, m_callbackObjectData.get(), classRef()); + break; + } + } } template @@ -138,13 +136,13 @@ bool JSCallbackObject::getOwnPropertySlot(JSObject* object, ExecState* e JSObjectRef thisRef = toRef(thisObject); RefPtr propertyNameRef; - if (StringImpl* name = propertyName.uid()) { + if (StringImpl* name = propertyName.publicName()) { for (JSClassRef jsClass = thisObject->classRef(); jsClass; jsClass = jsClass->parentClass) { // optional optimization to bypass getProperty in cases when we only need to know if the property exists if (JSObjectHasPropertyCallback hasProperty = jsClass->hasProperty) { if (!propertyNameRef) propertyNameRef = OpaqueJSString::create(name); - JSLock::DropAllLocks dropAllLocks(exec); + APICallbackShim callbackShim(exec); if (hasProperty(ctx, thisRef, propertyNameRef.get())) { slot.setCustom(thisObject, ReadOnly | DontEnum, callbackGetter); return true; @@ -155,7 +153,7 @@ bool JSCallbackObject::getOwnPropertySlot(JSObject* object, ExecState* e JSValueRef exception = 0; JSValueRef value; { - JSLock::DropAllLocks dropAllLocks(exec); + APICallbackShim callbackShim(exec); value = getProperty(ctx, thisRef, propertyNameRef.get(), &exception); } if (exception) { @@ -230,7 +228,7 @@ void JSCallbackObject::put(JSCell* cell, ExecState* exec, PropertyName p RefPtr propertyNameRef; JSValueRef valueRef = toRef(exec, value); - if (StringImpl* name = propertyName.uid()) { + if (StringImpl* name = propertyName.publicName()) { for (JSClassRef jsClass = thisObject->classRef(); jsClass; jsClass = jsClass->parentClass) { if (JSObjectSetPropertyCallback setProperty = jsClass->setProperty) { if (!propertyNameRef) @@ -238,7 +236,7 @@ void JSCallbackObject::put(JSCell* cell, ExecState* exec, PropertyName p JSValueRef exception = 0; bool result; { - JSLock::DropAllLocks dropAllLocks(exec); + APICallbackShim callbackShim(exec); result = setProperty(ctx, thisRef, propertyNameRef.get(), valueRef, &exception); } if (exception) @@ -255,7 +253,7 @@ void JSCallbackObject::put(JSCell* cell, ExecState* exec, PropertyName p JSValueRef exception = 0; bool result; { - JSLock::DropAllLocks dropAllLocks(exec); + APICallbackShim callbackShim(exec); result = setProperty(ctx, thisRef, entry->propertyNameRef.get(), valueRef, &exception); } if (exception) @@ -268,9 +266,6 @@ void JSCallbackObject::put(JSCell* cell, ExecState* exec, PropertyName p if (OpaqueJSClassStaticFunctionsTable* staticFunctions = jsClass->staticFunctions(exec)) { if (StaticFunctionEntry* entry = staticFunctions->get(name)) { - PropertySlot getSlot(thisObject); - if (Parent::getOwnPropertySlot(thisObject, exec, propertyName, getSlot)) - return Parent::put(thisObject, exec, propertyName, value, slot); if (entry->attributes & kJSPropertyAttributeReadOnly) return; thisObject->JSCallbackObject::putDirect(exec->vm(), propertyName, value); // put as override property @@ -300,7 +295,7 @@ void JSCallbackObject::putByIndex(JSCell* cell, ExecState* exec, unsigne JSValueRef exception = 0; bool result; { - JSLock::DropAllLocks dropAllLocks(exec); + APICallbackShim callbackShim(exec); result = setProperty(ctx, thisRef, propertyNameRef.get(), valueRef, &exception); } if (exception) @@ -317,7 +312,7 @@ void JSCallbackObject::putByIndex(JSCell* cell, ExecState* exec, unsigne JSValueRef exception = 0; bool result; { - JSLock::DropAllLocks dropAllLocks(exec); + APICallbackShim callbackShim(exec); result = setProperty(ctx, thisRef, entry->propertyNameRef.get(), valueRef, &exception); } if (exception) @@ -348,7 +343,7 @@ bool JSCallbackObject::deleteProperty(JSCell* cell, ExecState* exec, Pro JSObjectRef thisRef = toRef(thisObject); RefPtr propertyNameRef; - if (StringImpl* name = propertyName.uid()) { + if (StringImpl* name = propertyName.publicName()) { for (JSClassRef jsClass = thisObject->classRef(); jsClass; jsClass = jsClass->parentClass) { if (JSObjectDeletePropertyCallback deleteProperty = jsClass->deleteProperty) { if (!propertyNameRef) @@ -356,7 +351,7 @@ bool JSCallbackObject::deleteProperty(JSCell* cell, ExecState* exec, Pro JSValueRef exception = 0; bool result; { - JSLock::DropAllLocks dropAllLocks(exec); + APICallbackShim callbackShim(exec); result = deleteProperty(ctx, thisRef, propertyNameRef.get(), &exception); } if (exception) @@ -423,7 +418,7 @@ EncodedJSValue JSCallbackObject::construct(ExecState* exec) JSValueRef exception = 0; JSObject* result; { - JSLock::DropAllLocks dropAllLocks(exec); + APICallbackShim callbackShim(exec); result = toJS(callAsConstructor(execRef, constructorRef, argumentCount, arguments.data(), &exception)); } if (exception) @@ -449,7 +444,7 @@ bool JSCallbackObject::customHasInstance(JSObject* object, ExecState* ex JSValueRef exception = 0; bool result; { - JSLock::DropAllLocks dropAllLocks(exec); + APICallbackShim callbackShim(exec); result = hasInstance(execRef, thisRef, valueRef, &exception); } if (exception) @@ -478,7 +473,7 @@ EncodedJSValue JSCallbackObject::call(ExecState* exec) { JSContextRef execRef = toRef(exec); JSObjectRef functionRef = toRef(exec->callee()); - JSObjectRef thisObjRef = toRef(jsCast(exec->thisValue().toThis(exec, NotStrictMode))); + JSObjectRef thisObjRef = toRef(jsCast(exec->hostThisValue().toThis(exec, NotStrictMode))); for (JSClassRef jsClass = jsCast*>(toJS(functionRef))->classRef(); jsClass; jsClass = jsClass->parentClass) { if (JSObjectCallAsFunctionCallback callAsFunction = jsClass->callAsFunction) { @@ -490,7 +485,7 @@ EncodedJSValue JSCallbackObject::call(ExecState* exec) JSValueRef exception = 0; JSValue result; { - JSLock::DropAllLocks dropAllLocks(exec); + APICallbackShim callbackShim(exec); result = toJS(exec, callAsFunction(execRef, functionRef, thisObjRef, argumentCount, arguments.data(), &exception)); } if (exception) @@ -512,7 +507,7 @@ void JSCallbackObject::getOwnNonIndexPropertyNames(JSObject* object, Exe for (JSClassRef jsClass = thisObject->classRef(); jsClass; jsClass = jsClass->parentClass) { if (JSObjectGetPropertyNamesCallback getPropertyNames = jsClass->getPropertyNames) { - JSLock::DropAllLocks dropAllLocks(exec); + APICallbackShim callbackShim(exec); getPropertyNames(execRef, thisRef, toRef(&propertyNames)); } @@ -522,10 +517,8 @@ void JSCallbackObject::getOwnNonIndexPropertyNames(JSObject* object, Exe for (iterator it = staticValues->begin(); it != end; ++it) { StringImpl* name = it->key.get(); StaticValueEntry* entry = it->value.get(); - if (entry->getProperty && (!(entry->attributes & kJSPropertyAttributeDontEnum) || mode.includeDontEnumProperties())) { - ASSERT(!name->isSymbol()); - propertyNames.add(Identifier::fromString(exec, String(name))); - } + if (entry->getProperty && (!(entry->attributes & kJSPropertyAttributeDontEnum) || (mode == IncludeDontEnumProperties))) + propertyNames.add(Identifier(exec, name)); } } @@ -535,10 +528,8 @@ void JSCallbackObject::getOwnNonIndexPropertyNames(JSObject* object, Exe for (iterator it = staticFunctions->begin(); it != end; ++it) { StringImpl* name = it->key.get(); StaticFunctionEntry* entry = it->value.get(); - if (!(entry->attributes & kJSPropertyAttributeDontEnum) || mode.includeDontEnumProperties()) { - ASSERT(!name->isSymbol()); - propertyNames.add(Identifier::fromString(exec, String(name))); - } + if (!(entry->attributes & kJSPropertyAttributeDontEnum) || (mode == IncludeDontEnumProperties)) + propertyNames.add(Identifier(exec, name)); } } } @@ -573,7 +564,7 @@ JSValue JSCallbackObject::getStaticValue(ExecState* exec, PropertyName p { JSObjectRef thisRef = toRef(this); - if (StringImpl* name = propertyName.uid()) { + if (StringImpl* name = propertyName.publicName()) { for (JSClassRef jsClass = classRef(); jsClass; jsClass = jsClass->parentClass) { if (OpaqueJSClassStaticValuesTable* staticValues = jsClass->staticValues(exec)) { if (StaticValueEntry* entry = staticValues->get(name)) { @@ -581,7 +572,7 @@ JSValue JSCallbackObject::getStaticValue(ExecState* exec, PropertyName p JSValueRef exception = 0; JSValueRef value; { - JSLock::DropAllLocks dropAllLocks(exec); + APICallbackShim callbackShim(exec); value = getProperty(toRef(exec), thisRef, entry->propertyNameRef.get(), &exception); } if (exception) { @@ -600,7 +591,7 @@ JSValue JSCallbackObject::getStaticValue(ExecState* exec, PropertyName p } template -EncodedJSValue JSCallbackObject::staticFunctionGetter(ExecState* exec, JSObject* slotParent, EncodedJSValue, PropertyName propertyName) +EncodedJSValue JSCallbackObject::staticFunctionGetter(ExecState* exec, EncodedJSValue slotParent, EncodedJSValue, PropertyName propertyName) { JSCallbackObject* thisObj = asCallbackObject(slotParent); @@ -609,7 +600,7 @@ EncodedJSValue JSCallbackObject::staticFunctionGetter(ExecState* exec, J if (Parent::getOwnPropertySlot(thisObj, exec, propertyName, slot2)) return JSValue::encode(slot2.getValue(exec, propertyName)); - if (StringImpl* name = propertyName.uid()) { + if (StringImpl* name = propertyName.publicName()) { for (JSClassRef jsClass = thisObj->classRef(); jsClass; jsClass = jsClass->parentClass) { if (OpaqueJSClassStaticFunctionsTable* staticFunctions = jsClass->staticFunctions(exec)) { if (StaticFunctionEntry* entry = staticFunctions->get(name)) { @@ -628,14 +619,14 @@ EncodedJSValue JSCallbackObject::staticFunctionGetter(ExecState* exec, J } template -EncodedJSValue JSCallbackObject::callbackGetter(ExecState* exec, JSObject* slotParent, EncodedJSValue, PropertyName propertyName) +EncodedJSValue JSCallbackObject::callbackGetter(ExecState* exec, EncodedJSValue slotParent, EncodedJSValue, PropertyName propertyName) { JSCallbackObject* thisObj = asCallbackObject(slotParent); JSObjectRef thisRef = toRef(thisObj); RefPtr propertyNameRef; - if (StringImpl* name = propertyName.uid()) { + if (StringImpl* name = propertyName.publicName()) { for (JSClassRef jsClass = thisObj->classRef(); jsClass; jsClass = jsClass->parentClass) { if (JSObjectGetPropertyCallback getProperty = jsClass->getProperty) { if (!propertyNameRef) @@ -643,7 +634,7 @@ EncodedJSValue JSCallbackObject::callbackGetter(ExecState* exec, JSObjec JSValueRef exception = 0; JSValueRef value; { - JSLock::DropAllLocks dropAllLocks(exec); + APICallbackShim callbackShim(exec); value = getProperty(toRef(exec), thisRef, propertyNameRef.get(), &exception); } if (exception) { -- cgit v1.2.1