Title: [280505] trunk
Revision
280505
Author
tzaga...@apple.com
Date
2021-07-30 18:33:44 -0700 (Fri, 30 Jul 2021)

Log Message

putInlineFastReplacingStaticPropertyIfNeeded should handle custom values
https://bugs.webkit.org/show_bug.cgi?id=227963

Reviewed by Alexey Shvayka.

JSTests:

* stress/reflect-set-custom-value.js:

Source/_javascript_Core:

Follow up after r280463: as it turns out, putInlineFastReplacingStaticPropertyIfNeeded also needs to handle
custom values, similar to how definePropertyOnReceiverSlow was updated. This function will be called when the
target property of the receiver is a custom value and isn't reified. The previous test case was expanded to
test both the reified and non-reified cases.

* runtime/JSObject.cpp:
(JSC::JSObject::putInlineFastReplacingStaticPropertyIfNeeded):
* tools/JSDollarVM.cpp:

Modified Paths

Diff

Modified: trunk/JSTests/ChangeLog (280504 => 280505)


--- trunk/JSTests/ChangeLog	2021-07-31 00:07:37 UTC (rev 280504)
+++ trunk/JSTests/ChangeLog	2021-07-31 01:33:44 UTC (rev 280505)
@@ -1,3 +1,12 @@
+2021-07-30  Tadeu Zagallo  <tzaga...@apple.com>
+
+        putInlineFastReplacingStaticPropertyIfNeeded should handle custom values
+        https://bugs.webkit.org/show_bug.cgi?id=227963
+
+        Reviewed by Alexey Shvayka.
+
+        * stress/reflect-set-custom-value.js:
+
 2021-07-29  Tadeu Zagallo  <tzaga...@apple.com>
 
         definePropertyOnReceiver should check if receiver canPerformFastPutInline

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/ChangeLog (280504 => 280505)


--- trunk/Source/_javascript_Core/ChangeLog	2021-07-31 00:07:37 UTC (rev 280504)
+++ trunk/Source/_javascript_Core/ChangeLog	2021-07-31 01:33:44 UTC (rev 280505)
@@ -1,3 +1,19 @@
+2021-07-30  Tadeu Zagallo  <tzaga...@apple.com>
+
+        putInlineFastReplacingStaticPropertyIfNeeded should handle custom values
+        https://bugs.webkit.org/show_bug.cgi?id=227963
+
+        Reviewed by Alexey Shvayka.
+
+        Follow up after r280463: as it turns out, putInlineFastReplacingStaticPropertyIfNeeded also needs to handle
+        custom values, similar to how definePropertyOnReceiverSlow was updated. This function will be called when the
+        target property of the receiver is a custom value and isn't reified. The previous test case was expanded to
+        test both the reified and non-reified cases.
+
+        * runtime/JSObject.cpp:
+        (JSC::JSObject::putInlineFastReplacingStaticPropertyIfNeeded):
+        * tools/JSDollarVM.cpp:
+
 2021-07-30  Yusuke Suzuki  <ysuz...@apple.com>
 
         Unreviewed, fix wrong access width

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;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to