Title: [270664] trunk
Revision
270664
Author
[email protected]
Date
2020-12-10 20:14:18 -0800 (Thu, 10 Dec 2020)

Log Message

Align [[DefineOwnProperty]] method of mapped arguments object with the spec
https://bugs.webkit.org/show_bug.cgi?id=219750

Reviewed by Yusuke Suzuki.

JSTests:

* test262/expectations.yaml: Mark 5 test cases as passing.

Source/_javascript_Core:

This patch reimplements [[DefineOwnProperty]] method to resemble the spec [1] as
closely as possible, aligning JSC with V8 and SpiderMonkey on remaining test262 cases.

Unlike the spec [2], JSC doesn't materialize mapped indices with initial values,
so putDirectIndex() is performed on the first call to handle incomplete descriptors.

Even though there is a possibility to avoid JSObject storage puts for a handful of
super rare descriptors, it's not worth the increased complexity.

[1]: https://tc39.es/ecma262/#sec-arguments-exotic-objects-defineownproperty-p-desc
[2]: https://tc39.es/ecma262/#sec-createmappedargumentsobject (step 15.b)

* runtime/GenericArgumentsInlines.h:
(JSC::GenericArguments<Type>::defineOwnProperty):

Modified Paths

Diff

Modified: trunk/JSTests/ChangeLog (270663 => 270664)


--- trunk/JSTests/ChangeLog	2020-12-11 02:14:41 UTC (rev 270663)
+++ trunk/JSTests/ChangeLog	2020-12-11 04:14:18 UTC (rev 270664)
@@ -1,3 +1,12 @@
+2020-12-10  Alexey Shvayka  <[email protected]>
+
+        Align [[DefineOwnProperty]] method of mapped arguments object with the spec
+        https://bugs.webkit.org/show_bug.cgi?id=219750
+
+        Reviewed by Yusuke Suzuki.
+
+        * test262/expectations.yaml: Mark 5 test cases as passing.
+
 2020-12-09  Michael Catanzaro  <[email protected]>
 
         stress/intl-datetimeformat-formatrange.js and stress/intl-datetimeformat-formatrange-relevant-extensions.js fail with ICU 65.1

Modified: trunk/JSTests/test262/expectations.yaml (270663 => 270664)


--- trunk/JSTests/test262/expectations.yaml	2020-12-11 02:14:41 UTC (rev 270663)
+++ trunk/JSTests/test262/expectations.yaml	2020-12-11 04:14:18 UTC (rev 270664)
@@ -907,16 +907,6 @@
 test/intl402/Locale/prototype/minimize/removing-likely-subtags-first-adds-likely-subtags.js:
   default: 'Test262Error: "und".minimize() should be "en" Expected SameValue(«en-u-va-posix», «en») to be true'
   strict mode: 'Test262Error: "und".minimize() should be "en" Expected SameValue(«en-u-va-posix», «en») to be true'
-test/language/arguments-object/mapped/nonconfigurable-nonenumerable-nonwritable-descriptors-set-by-arguments.js:
-  default: 'Test262Error: Expected obj[0] to have enumerable:false.'
-test/language/arguments-object/mapped/nonconfigurable-nonenumerable-nonwritable-descriptors-set-by-param.js:
-  default: 'Test262Error: Expected obj[0] to have enumerable:false.'
-test/language/arguments-object/mapped/nonconfigurable-nonwritable-descriptors-define-property-consecutive.js:
-  default: 'Test262Error: Expected obj[0] to have configurable:false.'
-test/language/arguments-object/mapped/nonconfigurable-nonwritable-descriptors-set-by-arguments.js:
-  default: 'Test262Error: Expected obj[0] to have configurable:false.'
-test/language/arguments-object/mapped/nonconfigurable-nonwritable-descriptors-set-by-param.js:
-  default: 'Test262Error: Expected obj[0] to have configurable:false.'
 test/language/block-scope/syntax/redeclaration/async-function-name-redeclaration-attempt-with-async-function.js:
   default: 'Test262: This statement should not be evaluated.'
 test/language/block-scope/syntax/redeclaration/async-function-name-redeclaration-attempt-with-async-generator.js:

Modified: trunk/Source/_javascript_Core/ChangeLog (270663 => 270664)


--- trunk/Source/_javascript_Core/ChangeLog	2020-12-11 02:14:41 UTC (rev 270663)
+++ trunk/Source/_javascript_Core/ChangeLog	2020-12-11 04:14:18 UTC (rev 270664)
@@ -1,3 +1,25 @@
+2020-12-10  Alexey Shvayka  <[email protected]>
+
+        Align [[DefineOwnProperty]] method of mapped arguments object with the spec
+        https://bugs.webkit.org/show_bug.cgi?id=219750
+
+        Reviewed by Yusuke Suzuki.
+
+        This patch reimplements [[DefineOwnProperty]] method to resemble the spec [1] as
+        closely as possible, aligning JSC with V8 and SpiderMonkey on remaining test262 cases.
+
+        Unlike the spec [2], JSC doesn't materialize mapped indices with initial values,
+        so putDirectIndex() is performed on the first call to handle incomplete descriptors.
+
+        Even though there is a possibility to avoid JSObject storage puts for a handful of
+        super rare descriptors, it's not worth the increased complexity.
+
+        [1]: https://tc39.es/ecma262/#sec-arguments-exotic-objects-defineownproperty-p-desc
+        [2]: https://tc39.es/ecma262/#sec-createmappedargumentsobject (step 15.b)
+
+        * runtime/GenericArgumentsInlines.h:
+        (JSC::GenericArguments<Type>::defineOwnProperty):
+
 2020-12-10  Tadeu Zagallo  <[email protected]>
 
         Add a JSC API to allow acquiring the JSLock

Modified: trunk/Source/_javascript_Core/runtime/GenericArgumentsInlines.h (270663 => 270664)


--- trunk/Source/_javascript_Core/runtime/GenericArgumentsInlines.h	2020-12-11 02:14:41 UTC (rev 270663)
+++ trunk/Source/_javascript_Core/runtime/GenericArgumentsInlines.h	2020-12-11 04:14:18 UTC (rev 270664)
@@ -209,6 +209,7 @@
     return deletedProperty;
 }
 
+// https://tc39.es/ecma262/#sec-arguments-exotic-objects-defineownproperty-p-desc
 template<typename Type>
 bool GenericArguments<Type>::defineOwnProperty(JSObject* object, JSGlobalObject* globalObject, PropertyName ident, const PropertyDescriptor& descriptor, bool shouldThrow)
 {
@@ -221,56 +222,47 @@
         || ident == vm.propertyNames->iteratorSymbol) {
         thisObject->overrideThingsIfNecessary(globalObject);
         RETURN_IF_EXCEPTION(scope, false);
-    } else {
-        Optional<uint32_t> optionalIndex = parseIndex(ident);
-        if (optionalIndex) {
-            uint32_t index = optionalIndex.value();
-            if (!descriptor.isAccessorDescriptor() && thisObject->isMappedArgument(optionalIndex.value())) {
-                // If the property is not deleted and we are using a non-accessor descriptor, then
-                // make sure that the aliased argument sees the value.
+    } else if (Optional<uint32_t> optionalIndex = parseIndex(ident)) {
+        uint32_t index = optionalIndex.value();
+        bool isMapped = thisObject->isMappedArgument(index);
+        PropertyDescriptor newDescriptor = descriptor;
+
+        if (isMapped) {
+            if (thisObject->isModifiedArgumentDescriptor(index)) {
+                if (!descriptor.value() && descriptor.writablePresent() && !descriptor.writable())
+                    newDescriptor.setValue(thisObject->getIndexQuickly(index));
+            } else
+                thisObject->putDirectIndex(globalObject, index, thisObject->getIndexQuickly(index));
+
+            scope.assertNoException();
+        }
+
+        bool status = thisObject->defineOwnIndexedProperty(globalObject, index, newDescriptor, shouldThrow);
+        if (!status) {
+            ASSERT(!isMapped || thisObject->isModifiedArgumentDescriptor(index));
+            RELEASE_AND_RETURN(scope, false);
+        }
+
+        scope.assertNoException();
+        thisObject->setModifiedArgumentDescriptor(globalObject, index);
+        RETURN_IF_EXCEPTION(scope, false);
+
+        if (isMapped) {
+            if (descriptor.isAccessorDescriptor())
+                thisObject->unmapArgument(globalObject, index);
+            else {
                 if (descriptor.value())
                     thisObject->setIndexQuickly(vm, index, descriptor.value());
-            
-                // If the property is not deleted and we are using a non-accessor, writable,
-                // configurable and enumerable descriptor and isn't modified, then we are done.
-                // The argument continues to be aliased.
-                if (descriptor.writable() && descriptor.configurable() && descriptor.enumerable() && !thisObject->isModifiedArgumentDescriptor(index))
-                    return true;
-                
-                if (!thisObject->isModifiedArgumentDescriptor(index)) {
-                    // If it is a new entry, we need to put direct to initialize argument[i] descriptor properly
-                    JSValue value = thisObject->getIndexQuickly(index);
-                    ASSERT(value);
-                    object->putDirectMayBeIndex(globalObject, ident, value);
-                    scope.assertNoException();
-
-                    thisObject->setModifiedArgumentDescriptor(globalObject, index);
-                    RETURN_IF_EXCEPTION(scope, false);
-                }
-            }
-            
-            if (thisObject->isMappedArgument(index)) {
-                // Just unmap arguments if its descriptor contains {writable: false}.
-                // Check https://tc39.github.io/ecma262/#sec-createunmappedargumentsobject
-                // and https://tc39.github.io/ecma262/#sec-createmappedargumentsobject to verify that all data
-                // property from arguments object are {writable: true, configurable: true, enumerable: true} by default
-                if ((descriptor.writablePresent() && !descriptor.writable()) || descriptor.isAccessorDescriptor()) {
-                    if (!descriptor.isAccessorDescriptor()) {
-                        JSValue value = thisObject->getIndexQuickly(index);
-                        ASSERT(value);
-                        object->putDirectMayBeIndex(globalObject, ident, value);
-                        scope.assertNoException();
-                    }
+                if (descriptor.writablePresent() && !descriptor.writable())
                     thisObject->unmapArgument(globalObject, index);
-                    RETURN_IF_EXCEPTION(scope, false);
-                    thisObject->setModifiedArgumentDescriptor(globalObject, index);
-                    RETURN_IF_EXCEPTION(scope, false);
-                }
             }
+
+            RETURN_IF_EXCEPTION(scope, false);
         }
+
+        return true;
     }
 
-    // Now just let the normal object machinery do its thing.
     RELEASE_AND_RETURN(scope, Base::defineOwnProperty(object, globalObject, ident, descriptor, shouldThrow));
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to