Title: [272542] branches/safari-611-branch
Revision
272542
Author
[email protected]
Date
2021-02-08 13:24:36 -0800 (Mon, 08 Feb 2021)

Log Message

Cherry-pick r270664. rdar://problem/74105714

    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):

    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@270664 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Modified Paths

Diff

Modified: branches/safari-611-branch/JSTests/ChangeLog (272541 => 272542)


--- branches/safari-611-branch/JSTests/ChangeLog	2021-02-08 21:24:32 UTC (rev 272541)
+++ branches/safari-611-branch/JSTests/ChangeLog	2021-02-08 21:24:36 UTC (rev 272542)
@@ -1,5 +1,47 @@
 2021-02-08  Russell Epstein  <[email protected]>
 
+        Cherry-pick r270664. rdar://problem/74105714
+
+    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):
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@270664 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    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.
+
+2021-02-08  Russell Epstein  <[email protected]>
+
         Cherry-pick r271731. rdar://problem/74105559
 
     [JSC] JSPromise should not propagate TerminatedExecutionError

Modified: branches/safari-611-branch/JSTests/test262/expectations.yaml (272541 => 272542)


--- branches/safari-611-branch/JSTests/test262/expectations.yaml	2021-02-08 21:24:32 UTC (rev 272541)
+++ branches/safari-611-branch/JSTests/test262/expectations.yaml	2021-02-08 21:24:36 UTC (rev 272542)
@@ -886,16 +886,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: branches/safari-611-branch/Source/_javascript_Core/ChangeLog (272541 => 272542)


--- branches/safari-611-branch/Source/_javascript_Core/ChangeLog	2021-02-08 21:24:32 UTC (rev 272541)
+++ branches/safari-611-branch/Source/_javascript_Core/ChangeLog	2021-02-08 21:24:36 UTC (rev 272542)
@@ -1,5 +1,60 @@
 2021-02-08  Russell Epstein  <[email protected]>
 
+        Cherry-pick r270664. rdar://problem/74105714
+
+    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):
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@270664 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    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):
+
+2021-02-08  Russell Epstein  <[email protected]>
+
         Cherry-pick r271767. rdar://problem/74105427
 
     Obj-C API should do correct type checks when using a 32-bit address space

Modified: branches/safari-611-branch/Source/_javascript_Core/runtime/GenericArgumentsInlines.h (272541 => 272542)


--- branches/safari-611-branch/Source/_javascript_Core/runtime/GenericArgumentsInlines.h	2021-02-08 21:24:32 UTC (rev 272541)
+++ branches/safari-611-branch/Source/_javascript_Core/runtime/GenericArgumentsInlines.h	2021-02-08 21:24:36 UTC (rev 272542)
@@ -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