Changeset 212430 in webkit


Ignore:
Timestamp:
Feb 16, 2017 4:41:06 AM (7 years ago)
Author:
Yusuke Suzuki
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/JavaScriptCore:

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.

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/JSTests/ChangeLog

    r212196 r212430  
     12017-02-16  Yusuke Suzuki  <utatane.tea@gmail.com>
     2
     3        [JSC] Update module namespace object according to the latest ECMA262
     4        https://bugs.webkit.org/show_bug.cgi?id=168280
     5
     6        Reviewed by Saam Barati.
     7
     8        * modules/namespace-object-symbol-iterator-name.js:
     9        * modules/namespace-object-typed-array-fast-path.js:
     10        * modules/namespace.js:
     11        (shouldBe.JSON.stringify.Reflect.getOwnPropertyDescriptor):
     12        (shouldThrow):
     13
    1142017-02-11  Yusuke Suzuki  <utatane.tea@gmail.com>
    215
  • trunk/JSTests/modules/namespace-object-symbol-iterator-name.js

    r204160 r212430  
    22import * as ns from "./namespace-object-symbol-iterator-name.js";
    33
    4 shouldBe(ns[Symbol.iterator].name, "[Symbol.iterator]");
     4shouldBe(ns[Symbol.iterator], undefined);
  • trunk/JSTests/modules/namespace-object-typed-array-fast-path.js

    r204248 r212430  
    55
    66let array = new Uint8Array(ns);
    7 shouldBe(array.length, 2);
     7shouldBe(array.length, 0);
  • trunk/JSTests/modules/namespace.js

    r198023 r212430  
    2222shouldBe('Mocha' in namespace, true);
    2323shouldBe('default' in namespace, true);
    24 shouldBe(Symbol.iterator in namespace, true);
     24shouldBe(Symbol.iterator in namespace, false);
    2525shouldBe('Tea' in namespace, false);
    2626
     
    6262// These names should be shown in the code point order.
    6363shouldBe(JSON.stringify(Object.getOwnPropertyNames(namespace)), `["Cappuccino","Cocoa","Matcha","Mocha","default"]`);
    64 shouldBe(Object.getOwnPropertySymbols(namespace).length, 2);
    65 shouldBe(Object.getOwnPropertySymbols(namespace)[0], Symbol.iterator);
    66 shouldBe(Object.getOwnPropertySymbols(namespace)[1], Symbol.toStringTag);
    67 
    68 shouldBe(typeof namespace[Symbol.iterator], 'function');
    69 var array = Array.from(namespace);
    70 // These names should be shown in the code point order.
    71 shouldBe(JSON.stringify(array), `["Cappuccino","Cocoa","Matcha","Mocha","default"]`);
     64shouldBe(Object.getOwnPropertySymbols(namespace).length, 1);
     65shouldBe(Object.getOwnPropertySymbols(namespace)[0], Symbol.toStringTag);
    7266
    7367// The imported binding properties of the namespace object seen as writable, but, it does not mean that it is writable by users.
     
    8074}, `TypeError: Attempted to assign to readonly property.`);
    8175
    82 // In the case of non imported properties, we just return the original descriptor.
    83 // But still these properties cannot be changed.
    84 shouldBe(JSON.stringify(Reflect.getOwnPropertyDescriptor(namespace, Symbol.iterator)), `{"writable":true,"enumerable":false,"configurable":true}`);
     76shouldBe(JSON.stringify(Reflect.getOwnPropertyDescriptor(namespace, Symbol.toStringTag)), `{"value":"Module","writable":false,"enumerable":false,"configurable":false}`);
    8577shouldThrow(() => {
    86     namespace[Symbol.iterator] = 42;
     78    namespace[Symbol.toStringTag] = 42;
    8779}, `TypeError: Attempted to assign to readonly property.`);
    8880
     81shouldBe(Reflect.deleteProperty(namespace, Symbol.toStringTag), false);
  • trunk/Source/JavaScriptCore/ChangeLog

    r212426 r212430  
     12017-02-16  Yusuke Suzuki  <utatane.tea@gmail.com>
     2
     3        [JSC] Update module namespace object according to the latest ECMA262
     4        https://bugs.webkit.org/show_bug.cgi?id=168280
     5
     6        Reviewed by Saam Barati.
     7
     8        Reflect updates to the module namespace object.
     9
     10        1. @@iterator property is dropped[1].
     11        2. @@toStringTag property becomes non-configurable[1].
     12        3. delete with Symbol should be delegated to the JSObject's one[2].
     13
     14        [1]: https://tc39.github.io/ecma262/#sec-module-namespace-objects
     15        [2]: https://github.com/tc39/ecma262/pull/767
     16
     17        * runtime/JSModuleNamespaceObject.cpp:
     18        (JSC::JSModuleNamespaceObject::finishCreation):
     19        (JSC::JSModuleNamespaceObject::deleteProperty):
     20        (JSC::moduleNamespaceObjectSymbolIterator): Deleted.
     21
    1222017-02-16  Carlos Garcia Campos  <cgarcia@igalia.com>
    223
  • trunk/Source/JavaScriptCore/runtime/JSModuleNamespaceObject.cpp

    r211247 r212430  
    3131#include "JSCInlines.h"
    3232#include "JSModuleEnvironment.h"
    33 #include "JSPropertyNameIterator.h"
    3433
    3534namespace JSC {
    3635
    37 static EncodedJSValue JSC_HOST_CALL moduleNamespaceObjectSymbolIterator(ExecState*);
    38 
    3936const ClassInfo JSModuleNamespaceObject::s_info = { "ModuleNamespaceObject", &Base::s_info, nullptr, CREATE_METHOD_TABLE(JSModuleNamespaceObject) };
    40 
    4137
    4238JSModuleNamespaceObject::JSModuleNamespaceObject(VM& vm, Structure* structure)
     
    4642}
    4743
    48 void JSModuleNamespaceObject::finishCreation(ExecState* exec, JSGlobalObject* globalObject, AbstractModuleRecord* moduleRecord, const IdentifierSet& exports)
     44void JSModuleNamespaceObject::finishCreation(ExecState* exec, JSGlobalObject*, AbstractModuleRecord* moduleRecord, const IdentifierSet& exports)
    4945{
    5046    VM& vm = exec->vm();
     
    7066
    7167    m_moduleRecord.set(vm, this, moduleRecord);
    72     JSFunction* iteratorFunction = JSFunction::create(vm, globalObject, 0, ASCIILiteral("[Symbol.iterator]"), moduleNamespaceObjectSymbolIterator, NoIntrinsic);
    73     putDirect(vm, vm.propertyNames->iteratorSymbol, iteratorFunction, DontEnum);
    74     putDirect(vm, vm.propertyNames->toStringTagSymbol, jsString(&vm, "Module"), DontEnum | ReadOnly);
     68    putDirect(vm, vm.propertyNames->toStringTagSymbol, jsString(&vm, "Module"), DontEnum | DontDelete | ReadOnly);
    7569
    7670    // http://www.ecma-international.org/ecma-262/6.0/#sec-module-namespace-exotic-objects-getprototypeof
     
    182176}
    183177
    184 bool JSModuleNamespaceObject::deleteProperty(JSCell* cell, ExecState*, PropertyName propertyName)
     178bool JSModuleNamespaceObject::deleteProperty(JSCell* cell, ExecState* exec, PropertyName propertyName)
    185179{
    186180    // http://www.ecma-international.org/ecma-262/6.0/#sec-module-namespace-exotic-objects-delete-p
    187181    JSModuleNamespaceObject* thisObject = jsCast<JSModuleNamespaceObject*>(cell);
     182    if (propertyName.isSymbol())
     183        return JSObject::deleteProperty(thisObject, exec, propertyName);
     184
    188185    return !thisObject->m_exports.contains(propertyName.uid());
    189186}
     
    209206}
    210207
    211 EncodedJSValue JSC_HOST_CALL moduleNamespaceObjectSymbolIterator(ExecState* exec)
    212 {
    213     VM& vm = exec->vm();
    214     auto scope = DECLARE_THROW_SCOPE(vm);
    215 
    216     JSModuleNamespaceObject* object = jsDynamicCast<JSModuleNamespaceObject*>(vm, exec->thisValue());
    217     if (!object)
    218         return throwVMTypeError(exec, scope, ASCIILiteral("|this| should be a module namespace object"));
    219     return JSValue::encode(JSPropertyNameIterator::create(exec, exec->lexicalGlobalObject()->propertyNameIteratorStructure(), object));
    220 }
    221 
    222208} // namespace JSC
Note: See TracChangeset for help on using the changeset viewer.