Modified: trunk/JSTests/stress/reflect-set-custom-value.js (280504 => 280505)
--- trunk/JSTests/stress/reflect-set-custom-value.js 2021-07-31 00:07:37 UTC (rev 280504)
+++ trunk/JSTests/stress/reflect-set-custom-value.js 2021-07-31 01:33:44 UTC (rev 280505)
@@ -1,3 +1,14 @@
-const testGetterSetter = $vm.createCustomTestGetterSetter();
-Reflect.set({}, 'customValue', 'foo', testGetterSetter);
-testGetterSetter.customValue = 42;
+{
+ // reified
+ const testGetterSetter = $vm.createCustomTestGetterSetter();
+ Reflect.set({}, 'customValue', 'foo', testGetterSetter);
+ testGetterSetter.customValue = 42;
+}
+
+{
+ // non-reified
+ let tester = $vm.createStaticCustomValue();
+ Reflect.set({}, "testStaticValueSetFlag", 'foo', tester);
+ if (!tester.testStaticValueSetterCalled)
+ throw new Error('Custom value overriden');
+}
Modified: trunk/Source/_javascript_Core/runtime/JSObject.cpp (280504 => 280505)
--- trunk/Source/_javascript_Core/runtime/JSObject.cpp 2021-07-31 00:07:37 UTC (rev 280504)
+++ trunk/Source/_javascript_Core/runtime/JSObject.cpp 2021-07-31 01:33:44 UTC (rev 280505)
@@ -936,9 +936,13 @@
// FIXME: For an accessor with setter, the error message is misleading.
return typeError(globalObject, scope, slot.isStrictMode(), ReadonlyPropertyWriteError);
}
+ if (entry->value->attributes() & PropertyAttribute::CustomValue) {
+ PutValueFunc customSetter = entry->value->propertyPutter();
+ if (customSetter)
+ RELEASE_AND_RETURN(scope, customSetter(structure->globalObject(), JSValue::encode(this), JSValue::encode(value), propertyName));
+ }
// Avoid PutModePut because it fails for non-extensible structures.
- ASSERT(!(entry->value->attributes() & PropertyAttribute::CustomValue));
- putDirect(vm, propertyName, value, attributesForStructure(entry->value->attributes()), slot);
+ putDirect(vm, propertyName, value, attributesForStructure(entry->value->attributes()) & ~PropertyAttribute::CustomValue, slot);
return true;
}
}
Modified: trunk/Source/_javascript_Core/tools/JSDollarVM.cpp (280504 => 280505)
--- trunk/Source/_javascript_Core/tools/JSDollarVM.cpp 2021-07-31 00:07:37 UTC (rev 280504)
+++ trunk/Source/_javascript_Core/tools/JSDollarVM.cpp 2021-07-31 01:33:44 UTC (rev 280505)
@@ -800,6 +800,7 @@
static JSC_DECLARE_CUSTOM_GETTER(testStaticValueGetter);
static JSC_DECLARE_CUSTOM_SETTER(testStaticValuePutter);
+static JSC_DECLARE_CUSTOM_SETTER(testStaticValuePutterSetFlag);
JSC_DEFINE_CUSTOM_GETTER(testStaticValueGetter, (JSGlobalObject*, EncodedJSValue, PropertyName))
{
@@ -820,25 +821,39 @@
return thisObject->putDirect(vm, PropertyName(Identifier::fromString(vm, "testStaticValue")), JSValue::decode(value));
}
+JSC_DEFINE_CUSTOM_SETTER(testStaticValuePutterSetFlag, (JSGlobalObject* globalObject, EncodedJSValue thisValue, EncodedJSValue, PropertyName))
+{
+ DollarVMAssertScope assertScope;
+ VM& vm = globalObject->vm();
+ auto scope = DECLARE_THROW_SCOPE(vm);
+
+ JSObject* thisObject = jsDynamicCast<JSObject*>(vm, JSValue::decode(thisValue));
+ if (!thisObject)
+ return throwVMTypeError(globalObject, scope);
+
+ return thisObject->putDirect(vm, PropertyName(Identifier::fromString(vm, "testStaticValueSetterCalled")), jsBoolean(true));
+}
+
static const struct CompactHashIndex staticCustomValueTableIndex[8] = {
{ 1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
- { -1, -1 },
+ { 3, -1 },
{ 2, -1 },
{ 0, -1 },
{ -1, -1 },
};
-static const struct HashTableValue staticCustomValueTableValues[3] = {
+static const struct HashTableValue staticCustomValueTableValues[4] = {
{ "testStaticValue", static_cast<unsigned>(PropertyAttribute::CustomValue), NoIntrinsic, { (intptr_t)static_cast<GetValueFunc>(testStaticValueGetter), (intptr_t)static_cast<PutValueFunc>(testStaticValuePutter) } },
{ "testStaticValueNoSetter", PropertyAttribute::CustomValue | PropertyAttribute::DontEnum, NoIntrinsic, { (intptr_t)static_cast<GetValueFunc>(testStaticValueGetter), 0 } },
{ "testStaticValueReadOnly", PropertyAttribute::CustomValue | PropertyAttribute::DontEnum | PropertyAttribute::ReadOnly, NoIntrinsic, { (intptr_t)static_cast<GetValueFunc>(testStaticValueGetter), 0 } },
+ { "testStaticValueSetFlag", static_cast<unsigned>(PropertyAttribute::CustomValue), NoIntrinsic, { (intptr_t)static_cast<GetValueFunc>(testStaticValueGetter), (intptr_t)static_cast<PutValueFunc>(testStaticValuePutterSetFlag) } },
};
static const struct HashTable staticCustomValueTable =
- { 3, 7, true, nullptr, staticCustomValueTableValues, staticCustomValueTableIndex };
+ { 4, 7, true, nullptr, staticCustomValueTableValues, staticCustomValueTableIndex };
class StaticCustomValue : public JSNonFinalObject {
using Base = JSNonFinalObject;