Title: [212430] trunk
Revision
212430
Author
utatane....@gmail.com
Date
2017-02-16 04:41:06 -0800 (Thu, 16 Feb 2017)

Log Message

[JSC] Update module namespace object according to the latest ECMA262
https://bugs.webkit.org/show_bug.cgi?id=168280

Reviewed by Saam Barati.

JSTests:

* modules/namespace-object-symbol-iterator-name.js:
* modules/namespace-object-typed-array-fast-path.js:
* modules/namespace.js:
(shouldBe.JSON.stringify.Reflect.getOwnPropertyDescriptor):
(shouldThrow):

Source/_javascript_Core:

Reflect updates to the module namespace object.

1. @@iterator property is dropped[1].
2. @@toStringTag property becomes non-configurable[1].
3. delete with Symbol should be delegated to the JSObject's one[2].

[1]: https://tc39.github.io/ecma262/#sec-module-namespace-objects
[2]: https://github.com/tc39/ecma262/pull/767

* runtime/JSModuleNamespaceObject.cpp:
(JSC::JSModuleNamespaceObject::finishCreation):
(JSC::JSModuleNamespaceObject::deleteProperty):
(JSC::moduleNamespaceObjectSymbolIterator): Deleted.

Modified Paths

Diff

Modified: trunk/JSTests/ChangeLog (212429 => 212430)


--- trunk/JSTests/ChangeLog	2017-02-16 12:16:26 UTC (rev 212429)
+++ trunk/JSTests/ChangeLog	2017-02-16 12:41:06 UTC (rev 212430)
@@ -1,3 +1,16 @@
+2017-02-16  Yusuke Suzuki  <utatane....@gmail.com>
+
+        [JSC] Update module namespace object according to the latest ECMA262
+        https://bugs.webkit.org/show_bug.cgi?id=168280
+
+        Reviewed by Saam Barati.
+
+        * modules/namespace-object-symbol-iterator-name.js:
+        * modules/namespace-object-typed-array-fast-path.js:
+        * modules/namespace.js:
+        (shouldBe.JSON.stringify.Reflect.getOwnPropertyDescriptor):
+        (shouldThrow):
+
 2017-02-11  Yusuke Suzuki  <utatane....@gmail.com>
 
         [JSC] Implement (Shared)ArrayBuffer.prototype.byteLength

Modified: trunk/JSTests/modules/namespace-object-symbol-iterator-name.js (212429 => 212430)


--- trunk/JSTests/modules/namespace-object-symbol-iterator-name.js	2017-02-16 12:16:26 UTC (rev 212429)
+++ trunk/JSTests/modules/namespace-object-symbol-iterator-name.js	2017-02-16 12:41:06 UTC (rev 212430)
@@ -1,4 +1,4 @@
 import { shouldBe } from "./resources/assert.js";
 import * as ns from "./namespace-object-symbol-iterator-name.js";
 
-shouldBe(ns[Symbol.iterator].name, "[Symbol.iterator]");
+shouldBe(ns[Symbol.iterator], undefined);

Modified: trunk/JSTests/modules/namespace-object-typed-array-fast-path.js (212429 => 212430)


--- trunk/JSTests/modules/namespace-object-typed-array-fast-path.js	2017-02-16 12:16:26 UTC (rev 212429)
+++ trunk/JSTests/modules/namespace-object-typed-array-fast-path.js	2017-02-16 12:41:06 UTC (rev 212430)
@@ -4,4 +4,4 @@
 export let hello = 44;
 
 let array = new Uint8Array(ns);
-shouldBe(array.length, 2);
+shouldBe(array.length, 0);

Modified: trunk/JSTests/modules/namespace.js (212429 => 212430)


--- trunk/JSTests/modules/namespace.js	2017-02-16 12:16:26 UTC (rev 212429)
+++ trunk/JSTests/modules/namespace.js	2017-02-16 12:41:06 UTC (rev 212430)
@@ -21,7 +21,7 @@
 shouldBe('Matcha' in namespace, true);
 shouldBe('Mocha' in namespace, true);
 shouldBe('default' in namespace, true);
-shouldBe(Symbol.iterator in namespace, true);
+shouldBe(Symbol.iterator in namespace, false);
 shouldBe('Tea' in namespace, false);
 
 shouldBe(namespace.__proto__, undefined);
@@ -61,15 +61,9 @@
 
 // These names should be shown in the code point order.
 shouldBe(JSON.stringify(Object.getOwnPropertyNames(namespace)), `["Cappuccino","Cocoa","Matcha","Mocha","default"]`);
-shouldBe(Object.getOwnPropertySymbols(namespace).length, 2);
-shouldBe(Object.getOwnPropertySymbols(namespace)[0], Symbol.iterator);
-shouldBe(Object.getOwnPropertySymbols(namespace)[1], Symbol.toStringTag);
+shouldBe(Object.getOwnPropertySymbols(namespace).length, 1);
+shouldBe(Object.getOwnPropertySymbols(namespace)[0], Symbol.toStringTag);
 
-shouldBe(typeof namespace[Symbol.iterator], 'function');
-var array = Array.from(namespace);
-// These names should be shown in the code point order.
-shouldBe(JSON.stringify(array), `["Cappuccino","Cocoa","Matcha","Mocha","default"]`);
-
 // The imported binding properties of the namespace object seen as writable, but, it does not mean that it is writable by users.
 shouldBe(JSON.stringify(Reflect.getOwnPropertyDescriptor(namespace, "Cocoa")), `{"value":"Cocoa","writable":true,"enumerable":true,"configurable":false}`);
 shouldBe(JSON.stringify(Reflect.getOwnPropertyDescriptor(namespace, "Matcha")), `{"value":"Matcha","writable":true,"enumerable":true,"configurable":false}`);
@@ -79,10 +73,9 @@
     namespace.Cocoa = 'Cocoa';
 }, `TypeError: Attempted to assign to readonly property.`);
 
-// In the case of non imported properties, we just return the original descriptor.
-// But still these properties cannot be changed.
-shouldBe(JSON.stringify(Reflect.getOwnPropertyDescriptor(namespace, Symbol.iterator)), `{"writable":true,"enumerable":false,"configurable":true}`);
+shouldBe(JSON.stringify(Reflect.getOwnPropertyDescriptor(namespace, Symbol.toStringTag)), `{"value":"Module","writable":false,"enumerable":false,"configurable":false}`);
 shouldThrow(() => {
-    namespace[Symbol.iterator] = 42;
+    namespace[Symbol.toStringTag] = 42;
 }, `TypeError: Attempted to assign to readonly property.`);
 
+shouldBe(Reflect.deleteProperty(namespace, Symbol.toStringTag), false);

Modified: trunk/Source/_javascript_Core/ChangeLog (212429 => 212430)


--- trunk/Source/_javascript_Core/ChangeLog	2017-02-16 12:16:26 UTC (rev 212429)
+++ trunk/Source/_javascript_Core/ChangeLog	2017-02-16 12:41:06 UTC (rev 212430)
@@ -1,3 +1,24 @@
+2017-02-16  Yusuke Suzuki  <utatane....@gmail.com>
+
+        [JSC] Update module namespace object according to the latest ECMA262
+        https://bugs.webkit.org/show_bug.cgi?id=168280
+
+        Reviewed by Saam Barati.
+
+        Reflect updates to the module namespace object.
+
+        1. @@iterator property is dropped[1].
+        2. @@toStringTag property becomes non-configurable[1].
+        3. delete with Symbol should be delegated to the JSObject's one[2].
+
+        [1]: https://tc39.github.io/ecma262/#sec-module-namespace-objects
+        [2]: https://github.com/tc39/ecma262/pull/767
+
+        * runtime/JSModuleNamespaceObject.cpp:
+        (JSC::JSModuleNamespaceObject::finishCreation):
+        (JSC::JSModuleNamespaceObject::deleteProperty):
+        (JSC::moduleNamespaceObjectSymbolIterator): Deleted.
+
 2017-02-16  Carlos Garcia Campos  <cgar...@igalia.com>
 
         Unreviewed. Fix the build after r212424.

Modified: trunk/Source/_javascript_Core/runtime/JSModuleNamespaceObject.cpp (212429 => 212430)


--- trunk/Source/_javascript_Core/runtime/JSModuleNamespaceObject.cpp	2017-02-16 12:16:26 UTC (rev 212429)
+++ trunk/Source/_javascript_Core/runtime/JSModuleNamespaceObject.cpp	2017-02-16 12:41:06 UTC (rev 212430)
@@ -30,15 +30,11 @@
 #include "Error.h"
 #include "JSCInlines.h"
 #include "JSModuleEnvironment.h"
-#include "JSPropertyNameIterator.h"
 
 namespace JSC {
 
-static EncodedJSValue JSC_HOST_CALL moduleNamespaceObjectSymbolIterator(ExecState*);
-
 const ClassInfo JSModuleNamespaceObject::s_info = { "ModuleNamespaceObject", &Base::s_info, nullptr, CREATE_METHOD_TABLE(JSModuleNamespaceObject) };
 
-
 JSModuleNamespaceObject::JSModuleNamespaceObject(VM& vm, Structure* structure)
     : Base(vm, structure)
     , m_exports()
@@ -45,7 +41,7 @@
 {
 }
 
-void JSModuleNamespaceObject::finishCreation(ExecState* exec, JSGlobalObject* globalObject, AbstractModuleRecord* moduleRecord, const IdentifierSet& exports)
+void JSModuleNamespaceObject::finishCreation(ExecState* exec, JSGlobalObject*, AbstractModuleRecord* moduleRecord, const IdentifierSet& exports)
 {
     VM& vm = exec->vm();
     auto scope = DECLARE_THROW_SCOPE(vm);
@@ -69,9 +65,7 @@
         m_exports.add(identifier);
 
     m_moduleRecord.set(vm, this, moduleRecord);
-    JSFunction* iteratorFunction = JSFunction::create(vm, globalObject, 0, ASCIILiteral("[Symbol.iterator]"), moduleNamespaceObjectSymbolIterator, NoIntrinsic);
-    putDirect(vm, vm.propertyNames->iteratorSymbol, iteratorFunction, DontEnum);
-    putDirect(vm, vm.propertyNames->toStringTagSymbol, jsString(&vm, "Module"), DontEnum | ReadOnly);
+    putDirect(vm, vm.propertyNames->toStringTagSymbol, jsString(&vm, "Module"), DontEnum | DontDelete | ReadOnly);
 
     // http://www.ecma-international.org/ecma-262/6.0/#sec-module-namespace-exotic-objects-getprototypeof
     // http://www.ecma-international.org/ecma-262/6.0/#sec-module-namespace-exotic-objects-setprototypeof-v
@@ -181,10 +175,13 @@
     return false;
 }
 
-bool JSModuleNamespaceObject::deleteProperty(JSCell* cell, ExecState*, PropertyName propertyName)
+bool JSModuleNamespaceObject::deleteProperty(JSCell* cell, ExecState* exec, PropertyName propertyName)
 {
     // http://www.ecma-international.org/ecma-262/6.0/#sec-module-namespace-exotic-objects-delete-p
     JSModuleNamespaceObject* thisObject = jsCast<JSModuleNamespaceObject*>(cell);
+    if (propertyName.isSymbol())
+        return JSObject::deleteProperty(thisObject, exec, propertyName);
+
     return !thisObject->m_exports.contains(propertyName.uid());
 }
 
@@ -208,15 +205,4 @@
     return false;
 }
 
-EncodedJSValue JSC_HOST_CALL moduleNamespaceObjectSymbolIterator(ExecState* exec)
-{
-    VM& vm = exec->vm();
-    auto scope = DECLARE_THROW_SCOPE(vm);
-
-    JSModuleNamespaceObject* object = jsDynamicCast<JSModuleNamespaceObject*>(vm, exec->thisValue());
-    if (!object)
-        return throwVMTypeError(exec, scope, ASCIILiteral("|this| should be a module namespace object"));
-    return JSValue::encode(JSPropertyNameIterator::create(exec, exec->lexicalGlobalObject()->propertyNameIteratorStructure(), object));
-}
-
 } // namespace JSC
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to