summaryrefslogtreecommitdiff
path: root/Source/JavaScriptCore/API/JSCallbackObjectFunctions.h
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@lorry>2017-06-27 06:07:23 +0000
committerLorry Tar Creator <lorry-tar-importer@lorry>2017-06-27 06:07:23 +0000
commit1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c (patch)
tree46dcd36c86e7fbc6e5df36deb463b33e9967a6f7 /Source/JavaScriptCore/API/JSCallbackObjectFunctions.h
parent32761a6cee1d0dee366b885b7b9c777e67885688 (diff)
downloadWebKitGtk-tarball-master.tar.gz
Diffstat (limited to 'Source/JavaScriptCore/API/JSCallbackObjectFunctions.h')
-rw-r--r--Source/JavaScriptCore/API/JSCallbackObjectFunctions.h216
1 files changed, 133 insertions, 83 deletions
diff --git a/Source/JavaScriptCore/API/JSCallbackObjectFunctions.h b/Source/JavaScriptCore/API/JSCallbackObjectFunctions.h
index 5be053f1e..ee3ee2f31 100644
--- a/Source/JavaScriptCore/API/JSCallbackObjectFunctions.h
+++ b/Source/JavaScriptCore/API/JSCallbackObjectFunctions.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2006, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2006, 2008, 2016 Apple Inc. All rights reserved.
* Copyright (C) 2007 Eric Seidel <eric@webkit.org>
*
* Redistribution and use in source and binary forms, with or without
@@ -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 COMPUTER, INC. ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY APPLE 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 COMPUTER, INC. OR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE 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,7 +24,6 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include "APIShims.h"
#include "APICast.h"
#include "Error.h"
#include "ExceptionHelpers.h"
@@ -45,21 +44,22 @@ namespace JSC {
template <class Parent>
inline JSCallbackObject<Parent>* JSCallbackObject<Parent>::asCallbackObject(JSValue value)
{
- ASSERT(asObject(value)->inherits(info()));
+ ASSERT(asObject(value)->inherits(*value.getObject()->vm(), info()));
return jsCast<JSCallbackObject*>(asObject(value));
}
template <class Parent>
-inline JSCallbackObject<Parent>* JSCallbackObject<Parent>::asCallbackObject(EncodedJSValue value)
+inline JSCallbackObject<Parent>* JSCallbackObject<Parent>::asCallbackObject(EncodedJSValue encodedValue)
{
- ASSERT(asObject(JSValue::decode(value))->inherits(info()));
- return jsCast<JSCallbackObject*>(asObject(JSValue::decode(value)));
+ JSValue value = JSValue::decode(encodedValue);
+ ASSERT(asObject(value)->inherits(*value.getObject()->vm(), info()));
+ return jsCast<JSCallbackObject*>(asObject(value));
}
template <class Parent>
JSCallbackObject<Parent>::JSCallbackObject(ExecState* exec, Structure* structure, JSClassRef jsClass, void* data)
: Parent(exec->vm(), structure)
- , m_callbackObjectData(adoptPtr(new JSCallbackObjectData(data, jsClass)))
+ , m_callbackObjectData(std::make_unique<JSCallbackObjectData>(data, jsClass))
{
}
@@ -68,15 +68,32 @@ JSCallbackObject<Parent>::JSCallbackObject(ExecState* exec, Structure* structure
template <class Parent>
JSCallbackObject<Parent>::JSCallbackObject(VM& vm, JSClassRef jsClass, Structure* structure)
: Parent(vm, structure)
- , m_callbackObjectData(adoptPtr(new JSCallbackObjectData(0, jsClass)))
+ , m_callbackObjectData(std::make_unique<JSCallbackObjectData>(nullptr, jsClass))
{
}
template <class Parent>
+JSCallbackObject<Parent>::~JSCallbackObject()
+{
+ VM* vm = this->HeapCell::vm();
+ vm->currentlyDestructingCallbackObject = this;
+ ASSERT(m_classInfo);
+ vm->currentlyDestructingCallbackObjectClassInfo = m_classInfo;
+ JSObjectRef thisRef = toRef(static_cast<JSObject*>(this));
+ for (JSClassRef jsClass = classRef(); jsClass; jsClass = jsClass->parentClass) {
+ if (JSObjectFinalizeCallback finalize = jsClass->finalize)
+ finalize(thisRef);
+ }
+ vm->currentlyDestructingCallbackObject = nullptr;
+ vm->currentlyDestructingCallbackObjectClassInfo = nullptr;
+}
+
+template <class Parent>
void JSCallbackObject<Parent>::finishCreation(ExecState* exec)
{
- Base::finishCreation(exec->vm());
- ASSERT(Parent::inherits(info()));
+ VM& vm = exec->vm();
+ Base::finishCreation(vm);
+ ASSERT(Parent::inherits(vm, info()));
init(exec);
}
@@ -84,7 +101,7 @@ void JSCallbackObject<Parent>::finishCreation(ExecState* exec)
template <class Parent>
void JSCallbackObject<Parent>::finishCreation(VM& vm)
{
- ASSERT(Parent::inherits(info()));
+ ASSERT(Parent::inherits(vm, info()));
ASSERT(Parent::isGlobalObject());
Base::finishCreation(vm);
init(jsCast<JSGlobalObject*>(this)->globalExec());
@@ -104,17 +121,12 @@ void JSCallbackObject<Parent>::init(ExecState* exec)
// initialize from base to derived
for (int i = static_cast<int>(initRoutines.size()) - 1; i >= 0; i--) {
- APICallbackShim callbackShim(exec);
+ JSLock::DropAllLocks dropAllLocks(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;
- }
- }
+
+ m_classInfo = this->classInfo();
}
template <class Parent>
@@ -131,18 +143,21 @@ String JSCallbackObject<Parent>::className(const JSObject* object)
template <class Parent>
bool JSCallbackObject<Parent>::getOwnPropertySlot(JSObject* object, ExecState* exec, PropertyName propertyName, PropertySlot& slot)
{
+ VM& vm = exec->vm();
+ auto scope = DECLARE_THROW_SCOPE(vm);
+
JSCallbackObject* thisObject = jsCast<JSCallbackObject*>(object);
JSContextRef ctx = toRef(exec);
JSObjectRef thisRef = toRef(thisObject);
RefPtr<OpaqueJSString> propertyNameRef;
- if (StringImpl* name = propertyName.publicName()) {
+ if (StringImpl* name = propertyName.uid()) {
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);
- APICallbackShim callbackShim(exec);
+ JSLock::DropAllLocks dropAllLocks(exec);
if (hasProperty(ctx, thisRef, propertyNameRef.get())) {
slot.setCustom(thisObject, ReadOnly | DontEnum, callbackGetter);
return true;
@@ -153,11 +168,11 @@ bool JSCallbackObject<Parent>::getOwnPropertySlot(JSObject* object, ExecState* e
JSValueRef exception = 0;
JSValueRef value;
{
- APICallbackShim callbackShim(exec);
+ JSLock::DropAllLocks dropAllLocks(exec);
value = getProperty(ctx, thisRef, propertyNameRef.get(), &exception);
}
if (exception) {
- exec->vm().throwException(exec, toJS(exec, exception));
+ throwException(exec, scope, toJS(exec, exception));
slot.setValue(thisObject, ReadOnly | DontEnum, jsUndefined());
return true;
}
@@ -198,6 +213,9 @@ bool JSCallbackObject<Parent>::getOwnPropertySlotByIndex(JSObject* object, ExecS
template <class Parent>
JSValue JSCallbackObject<Parent>::defaultValue(const JSObject* object, ExecState* exec, PreferredPrimitiveType hint)
{
+ VM& vm = exec->vm();
+ auto scope = DECLARE_THROW_SCOPE(vm);
+
const JSCallbackObject* thisObject = jsCast<const JSCallbackObject*>(object);
JSContextRef ctx = toRef(exec);
JSObjectRef thisRef = toRef(thisObject);
@@ -208,7 +226,7 @@ JSValue JSCallbackObject<Parent>::defaultValue(const JSObject* object, ExecState
JSValueRef exception = 0;
JSValueRef result = convertToType(ctx, thisRef, jsHint, &exception);
if (exception) {
- exec->vm().throwException(exec, toJS(exec, exception));
+ throwException(exec, scope, toJS(exec, exception));
return jsUndefined();
}
if (result)
@@ -220,15 +238,18 @@ JSValue JSCallbackObject<Parent>::defaultValue(const JSObject* object, ExecState
}
template <class Parent>
-void JSCallbackObject<Parent>::put(JSCell* cell, ExecState* exec, PropertyName propertyName, JSValue value, PutPropertySlot& slot)
+bool JSCallbackObject<Parent>::put(JSCell* cell, ExecState* exec, PropertyName propertyName, JSValue value, PutPropertySlot& slot)
{
+ VM& vm = exec->vm();
+ auto scope = DECLARE_THROW_SCOPE(vm);
+
JSCallbackObject* thisObject = jsCast<JSCallbackObject*>(cell);
JSContextRef ctx = toRef(exec);
JSObjectRef thisRef = toRef(thisObject);
RefPtr<OpaqueJSString> propertyNameRef;
JSValueRef valueRef = toRef(exec, value);
- if (StringImpl* name = propertyName.publicName()) {
+ if (StringImpl* name = propertyName.uid()) {
for (JSClassRef jsClass = thisObject->classRef(); jsClass; jsClass = jsClass->parentClass) {
if (JSObjectSetPropertyCallback setProperty = jsClass->setProperty) {
if (!propertyNameRef)
@@ -236,40 +257,42 @@ void JSCallbackObject<Parent>::put(JSCell* cell, ExecState* exec, PropertyName p
JSValueRef exception = 0;
bool result;
{
- APICallbackShim callbackShim(exec);
+ JSLock::DropAllLocks dropAllLocks(exec);
result = setProperty(ctx, thisRef, propertyNameRef.get(), valueRef, &exception);
}
if (exception)
- exec->vm().throwException(exec, toJS(exec, exception));
+ throwException(exec, scope, toJS(exec, exception));
if (result || exception)
- return;
+ return result;
}
if (OpaqueJSClassStaticValuesTable* staticValues = jsClass->staticValues(exec)) {
if (StaticValueEntry* entry = staticValues->get(name)) {
if (entry->attributes & kJSPropertyAttributeReadOnly)
- return;
+ return false;
if (JSObjectSetPropertyCallback setProperty = entry->setProperty) {
JSValueRef exception = 0;
bool result;
{
- APICallbackShim callbackShim(exec);
+ JSLock::DropAllLocks dropAllLocks(exec);
result = setProperty(ctx, thisRef, entry->propertyNameRef.get(), valueRef, &exception);
}
if (exception)
- exec->vm().throwException(exec, toJS(exec, exception));
+ throwException(exec, scope, toJS(exec, exception));
if (result || exception)
- return;
+ return result;
}
}
}
if (OpaqueJSClassStaticFunctionsTable* staticFunctions = jsClass->staticFunctions(exec)) {
if (StaticFunctionEntry* entry = staticFunctions->get(name)) {
+ PropertySlot getSlot(thisObject, PropertySlot::InternalMethodType::VMInquiry);
+ if (Parent::getOwnPropertySlot(thisObject, exec, propertyName, getSlot))
+ return Parent::put(thisObject, exec, propertyName, value, slot);
if (entry->attributes & kJSPropertyAttributeReadOnly)
- return;
- thisObject->JSCallbackObject<Parent>::putDirect(exec->vm(), propertyName, value); // put as override property
- return;
+ return false;
+ return thisObject->JSCallbackObject<Parent>::putDirect(vm, propertyName, value); // put as override property
}
}
}
@@ -279,8 +302,11 @@ void JSCallbackObject<Parent>::put(JSCell* cell, ExecState* exec, PropertyName p
}
template <class Parent>
-void JSCallbackObject<Parent>::putByIndex(JSCell* cell, ExecState* exec, unsigned propertyIndex, JSValue value, bool shouldThrow)
+bool JSCallbackObject<Parent>::putByIndex(JSCell* cell, ExecState* exec, unsigned propertyIndex, JSValue value, bool shouldThrow)
{
+ VM& vm = exec->vm();
+ auto scope = DECLARE_THROW_SCOPE(vm);
+
JSCallbackObject* thisObject = jsCast<JSCallbackObject*>(cell);
JSContextRef ctx = toRef(exec);
JSObjectRef thisRef = toRef(thisObject);
@@ -295,30 +321,30 @@ void JSCallbackObject<Parent>::putByIndex(JSCell* cell, ExecState* exec, unsigne
JSValueRef exception = 0;
bool result;
{
- APICallbackShim callbackShim(exec);
+ JSLock::DropAllLocks dropAllLocks(exec);
result = setProperty(ctx, thisRef, propertyNameRef.get(), valueRef, &exception);
}
if (exception)
- exec->vm().throwException(exec, toJS(exec, exception));
+ throwException(exec, scope, toJS(exec, exception));
if (result || exception)
- return;
+ return result;
}
if (OpaqueJSClassStaticValuesTable* staticValues = jsClass->staticValues(exec)) {
if (StaticValueEntry* entry = staticValues->get(propertyName.impl())) {
if (entry->attributes & kJSPropertyAttributeReadOnly)
- return;
+ return false;
if (JSObjectSetPropertyCallback setProperty = entry->setProperty) {
JSValueRef exception = 0;
bool result;
{
- APICallbackShim callbackShim(exec);
+ JSLock::DropAllLocks dropAllLocks(exec);
result = setProperty(ctx, thisRef, entry->propertyNameRef.get(), valueRef, &exception);
}
if (exception)
- exec->vm().throwException(exec, toJS(exec, exception));
+ throwException(exec, scope, toJS(exec, exception));
if (result || exception)
- return;
+ return result;
}
}
}
@@ -326,7 +352,7 @@ void JSCallbackObject<Parent>::putByIndex(JSCell* cell, ExecState* exec, unsigne
if (OpaqueJSClassStaticFunctionsTable* staticFunctions = jsClass->staticFunctions(exec)) {
if (StaticFunctionEntry* entry = staticFunctions->get(propertyName.impl())) {
if (entry->attributes & kJSPropertyAttributeReadOnly)
- return;
+ return false;
break;
}
}
@@ -338,12 +364,15 @@ void JSCallbackObject<Parent>::putByIndex(JSCell* cell, ExecState* exec, unsigne
template <class Parent>
bool JSCallbackObject<Parent>::deleteProperty(JSCell* cell, ExecState* exec, PropertyName propertyName)
{
+ VM& vm = exec->vm();
+ auto scope = DECLARE_THROW_SCOPE(vm);
+
JSCallbackObject* thisObject = jsCast<JSCallbackObject*>(cell);
JSContextRef ctx = toRef(exec);
JSObjectRef thisRef = toRef(thisObject);
RefPtr<OpaqueJSString> propertyNameRef;
- if (StringImpl* name = propertyName.publicName()) {
+ if (StringImpl* name = propertyName.uid()) {
for (JSClassRef jsClass = thisObject->classRef(); jsClass; jsClass = jsClass->parentClass) {
if (JSObjectDeletePropertyCallback deleteProperty = jsClass->deleteProperty) {
if (!propertyNameRef)
@@ -351,11 +380,11 @@ bool JSCallbackObject<Parent>::deleteProperty(JSCell* cell, ExecState* exec, Pro
JSValueRef exception = 0;
bool result;
{
- APICallbackShim callbackShim(exec);
+ JSLock::DropAllLocks dropAllLocks(exec);
result = deleteProperty(ctx, thisRef, propertyNameRef.get(), &exception);
}
if (exception)
- exec->vm().throwException(exec, toJS(exec, exception));
+ throwException(exec, scope, toJS(exec, exception));
if (result || exception)
return true;
}
@@ -395,16 +424,19 @@ ConstructType JSCallbackObject<Parent>::getConstructData(JSCell* cell, Construct
for (JSClassRef jsClass = thisObject->classRef(); jsClass; jsClass = jsClass->parentClass) {
if (jsClass->callAsConstructor) {
constructData.native.function = construct;
- return ConstructTypeHost;
+ return ConstructType::Host;
}
}
- return ConstructTypeNone;
+ return ConstructType::None;
}
template <class Parent>
EncodedJSValue JSCallbackObject<Parent>::construct(ExecState* exec)
{
- JSObject* constructor = exec->callee();
+ VM& vm = exec->vm();
+ auto scope = DECLARE_THROW_SCOPE(vm);
+
+ JSObject* constructor = exec->jsCallee();
JSContextRef execRef = toRef(exec);
JSObjectRef constructorRef = toRef(constructor);
@@ -418,11 +450,11 @@ EncodedJSValue JSCallbackObject<Parent>::construct(ExecState* exec)
JSValueRef exception = 0;
JSObject* result;
{
- APICallbackShim callbackShim(exec);
+ JSLock::DropAllLocks dropAllLocks(exec);
result = toJS(callAsConstructor(execRef, constructorRef, argumentCount, arguments.data(), &exception));
}
if (exception)
- exec->vm().throwException(exec, toJS(exec, exception));
+ throwException(exec, scope, toJS(exec, exception));
return JSValue::encode(result);
}
}
@@ -434,6 +466,9 @@ EncodedJSValue JSCallbackObject<Parent>::construct(ExecState* exec)
template <class Parent>
bool JSCallbackObject<Parent>::customHasInstance(JSObject* object, ExecState* exec, JSValue value)
{
+ VM& vm = exec->vm();
+ auto scope = DECLARE_THROW_SCOPE(vm);
+
JSCallbackObject* thisObject = jsCast<JSCallbackObject*>(object);
JSContextRef execRef = toRef(exec);
JSObjectRef thisRef = toRef(thisObject);
@@ -444,11 +479,11 @@ bool JSCallbackObject<Parent>::customHasInstance(JSObject* object, ExecState* ex
JSValueRef exception = 0;
bool result;
{
- APICallbackShim callbackShim(exec);
+ JSLock::DropAllLocks dropAllLocks(exec);
result = hasInstance(execRef, thisRef, valueRef, &exception);
}
if (exception)
- exec->vm().throwException(exec, toJS(exec, exception));
+ throwException(exec, scope, toJS(exec, exception));
return result;
}
}
@@ -462,18 +497,21 @@ CallType JSCallbackObject<Parent>::getCallData(JSCell* cell, CallData& callData)
for (JSClassRef jsClass = thisObject->classRef(); jsClass; jsClass = jsClass->parentClass) {
if (jsClass->callAsFunction) {
callData.native.function = call;
- return CallTypeHost;
+ return CallType::Host;
}
}
- return CallTypeNone;
+ return CallType::None;
}
template <class Parent>
EncodedJSValue JSCallbackObject<Parent>::call(ExecState* exec)
{
+ VM& vm = exec->vm();
+ auto scope = DECLARE_THROW_SCOPE(vm);
+
JSContextRef execRef = toRef(exec);
- JSObjectRef functionRef = toRef(exec->callee());
- JSObjectRef thisObjRef = toRef(jsCast<JSObject*>(exec->hostThisValue().toThis(exec, NotStrictMode)));
+ JSObjectRef functionRef = toRef(exec->jsCallee());
+ JSObjectRef thisObjRef = toRef(jsCast<JSObject*>(exec->thisValue().toThis(exec, NotStrictMode)));
for (JSClassRef jsClass = jsCast<JSCallbackObject<Parent>*>(toJS(functionRef))->classRef(); jsClass; jsClass = jsClass->parentClass) {
if (JSObjectCallAsFunctionCallback callAsFunction = jsClass->callAsFunction) {
@@ -485,11 +523,11 @@ EncodedJSValue JSCallbackObject<Parent>::call(ExecState* exec)
JSValueRef exception = 0;
JSValue result;
{
- APICallbackShim callbackShim(exec);
+ JSLock::DropAllLocks dropAllLocks(exec);
result = toJS(exec, callAsFunction(execRef, functionRef, thisObjRef, argumentCount, arguments.data(), &exception));
}
if (exception)
- exec->vm().throwException(exec, toJS(exec, exception));
+ throwException(exec, scope, toJS(exec, exception));
return JSValue::encode(result);
}
}
@@ -507,7 +545,7 @@ void JSCallbackObject<Parent>::getOwnNonIndexPropertyNames(JSObject* object, Exe
for (JSClassRef jsClass = thisObject->classRef(); jsClass; jsClass = jsClass->parentClass) {
if (JSObjectGetPropertyNamesCallback getPropertyNames = jsClass->getPropertyNames) {
- APICallbackShim callbackShim(exec);
+ JSLock::DropAllLocks dropAllLocks(exec);
getPropertyNames(execRef, thisRef, toRef(&propertyNames));
}
@@ -517,8 +555,10 @@ void JSCallbackObject<Parent>::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)))
- propertyNames.add(Identifier(exec, name));
+ if (entry->getProperty && (!(entry->attributes & kJSPropertyAttributeDontEnum) || mode.includeDontEnumProperties())) {
+ ASSERT(!name->isSymbol());
+ propertyNames.add(Identifier::fromString(exec, String(name)));
+ }
}
}
@@ -528,8 +568,10 @@ void JSCallbackObject<Parent>::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))
- propertyNames.add(Identifier(exec, name));
+ if (!(entry->attributes & kJSPropertyAttributeDontEnum) || mode.includeDontEnumProperties()) {
+ ASSERT(!name->isSymbol());
+ propertyNames.add(Identifier::fromString(exec, String(name)));
+ }
}
}
}
@@ -562,9 +604,12 @@ bool JSCallbackObject<Parent>::inherits(JSClassRef c) const
template <class Parent>
JSValue JSCallbackObject<Parent>::getStaticValue(ExecState* exec, PropertyName propertyName)
{
+ VM& vm = exec->vm();
+ auto scope = DECLARE_THROW_SCOPE(vm);
+
JSObjectRef thisRef = toRef(this);
- if (StringImpl* name = propertyName.publicName()) {
+ if (StringImpl* name = propertyName.uid()) {
for (JSClassRef jsClass = classRef(); jsClass; jsClass = jsClass->parentClass) {
if (OpaqueJSClassStaticValuesTable* staticValues = jsClass->staticValues(exec)) {
if (StaticValueEntry* entry = staticValues->get(name)) {
@@ -572,11 +617,11 @@ JSValue JSCallbackObject<Parent>::getStaticValue(ExecState* exec, PropertyName p
JSValueRef exception = 0;
JSValueRef value;
{
- APICallbackShim callbackShim(exec);
+ JSLock::DropAllLocks dropAllLocks(exec);
value = getProperty(toRef(exec), thisRef, entry->propertyNameRef.get(), &exception);
}
if (exception) {
- exec->vm().throwException(exec, toJS(exec, exception));
+ throwException(exec, scope, toJS(exec, exception));
return jsUndefined();
}
if (value)
@@ -591,21 +636,23 @@ JSValue JSCallbackObject<Parent>::getStaticValue(ExecState* exec, PropertyName p
}
template <class Parent>
-EncodedJSValue JSCallbackObject<Parent>::staticFunctionGetter(ExecState* exec, EncodedJSValue slotParent, EncodedJSValue, PropertyName propertyName)
+EncodedJSValue JSCallbackObject<Parent>::staticFunctionGetter(ExecState* exec, EncodedJSValue thisValue, PropertyName propertyName)
{
- JSCallbackObject* thisObj = asCallbackObject(slotParent);
+ VM& vm = exec->vm();
+ auto scope = DECLARE_THROW_SCOPE(vm);
+
+ JSCallbackObject* thisObj = asCallbackObject(thisValue);
// Check for cached or override property.
- PropertySlot slot2(thisObj);
+ PropertySlot slot2(thisObj, PropertySlot::InternalMethodType::VMInquiry);
if (Parent::getOwnPropertySlot(thisObj, exec, propertyName, slot2))
return JSValue::encode(slot2.getValue(exec, propertyName));
- if (StringImpl* name = propertyName.publicName()) {
+ if (StringImpl* name = propertyName.uid()) {
for (JSClassRef jsClass = thisObj->classRef(); jsClass; jsClass = jsClass->parentClass) {
if (OpaqueJSClassStaticFunctionsTable* staticFunctions = jsClass->staticFunctions(exec)) {
if (StaticFunctionEntry* entry = staticFunctions->get(name)) {
if (JSObjectCallAsFunctionCallback callAsFunction = entry->callAsFunction) {
- VM& vm = exec->vm();
JSObject* o = JSCallbackFunction::create(vm, thisObj->globalObject(), callAsFunction, name);
thisObj->putDirect(vm, propertyName, o, entry->attributes);
return JSValue::encode(o);
@@ -615,18 +662,21 @@ EncodedJSValue JSCallbackObject<Parent>::staticFunctionGetter(ExecState* exec, E
}
}
- return JSValue::encode(exec->vm().throwException(exec, createReferenceError(exec, ASCIILiteral("Static function property defined with NULL callAsFunction callback."))));
+ return JSValue::encode(throwException(exec, scope, createReferenceError(exec, ASCIILiteral("Static function property defined with NULL callAsFunction callback."))));
}
template <class Parent>
-EncodedJSValue JSCallbackObject<Parent>::callbackGetter(ExecState* exec, EncodedJSValue slotParent, EncodedJSValue, PropertyName propertyName)
+EncodedJSValue JSCallbackObject<Parent>::callbackGetter(ExecState* exec, EncodedJSValue thisValue, PropertyName propertyName)
{
- JSCallbackObject* thisObj = asCallbackObject(slotParent);
+ VM& vm = exec->vm();
+ auto scope = DECLARE_THROW_SCOPE(vm);
+
+ JSCallbackObject* thisObj = asCallbackObject(thisValue);
JSObjectRef thisRef = toRef(thisObj);
RefPtr<OpaqueJSString> propertyNameRef;
- if (StringImpl* name = propertyName.publicName()) {
+ if (StringImpl* name = propertyName.uid()) {
for (JSClassRef jsClass = thisObj->classRef(); jsClass; jsClass = jsClass->parentClass) {
if (JSObjectGetPropertyCallback getProperty = jsClass->getProperty) {
if (!propertyNameRef)
@@ -634,11 +684,11 @@ EncodedJSValue JSCallbackObject<Parent>::callbackGetter(ExecState* exec, Encoded
JSValueRef exception = 0;
JSValueRef value;
{
- APICallbackShim callbackShim(exec);
+ JSLock::DropAllLocks dropAllLocks(exec);
value = getProperty(toRef(exec), thisRef, propertyNameRef.get(), &exception);
}
if (exception) {
- exec->vm().throwException(exec, toJS(exec, exception));
+ throwException(exec, scope, toJS(exec, exception));
return JSValue::encode(jsUndefined());
}
if (value)
@@ -647,7 +697,7 @@ EncodedJSValue JSCallbackObject<Parent>::callbackGetter(ExecState* exec, Encoded
}
}
- return JSValue::encode(exec->vm().throwException(exec, createReferenceError(exec, ASCIILiteral("hasProperty callback returned true for a property that doesn't exist."))));
+ return JSValue::encode(throwException(exec, scope, createReferenceError(exec, ASCIILiteral("hasProperty callback returned true for a property that doesn't exist."))));
}
} // namespace JSC