Changeset 205335 in webkit


Ignore:
Timestamp:
Sep 1, 2016 8:42:09 PM (8 years ago)
Author:
Yusuke Suzuki
Message:

Add toJS for JSC::PrivateName
https://bugs.webkit.org/show_bug.cgi?id=161522

Reviewed by Ryosuke Niwa.

Source/JavaScriptCore:

Add the export annotation.
And we perform refactoring RefPtr<SymbolImpl> => Ref<SymbolImpl> for PrivateName,
since PrivateName never holds null SymbolImpl pointer. And along with this change,
we changed SymbolImpl* to SymbolImpl& in PrivateName::uid() callers.

  • runtime/Completion.cpp:

(JSC::createSymbolForEntryPointModule):

  • runtime/IdentifierInlines.h:

(JSC::Identifier::fromUid):

  • runtime/JSFunction.cpp:

(JSC::JSFunction::setFunctionName):

  • runtime/PrivateName.h:

(JSC::PrivateName::PrivateName):
(JSC::PrivateName::uid): Ugly const_cast. But const annotation is meaningless for SymbolImpl.
StringImpl should be observed as an immutable object. (Of course, its hash members etc. are mutable.
But most of the users (One of the exceptions is the concurrent JIT compiling thread!) should not care about this.)
(JSC::PrivateName::operator==):
(JSC::PrivateName::operator!=):

  • runtime/PropertyName.h:

(JSC::PropertyName::PropertyName):

  • runtime/Symbol.cpp:

(JSC::Symbol::finishCreation):

  • runtime/Symbol.h:
  • runtime/SymbolConstructor.cpp:

(JSC::symbolConstructorKeyFor):

Source/WebCore:

JSC::PrivateName is the wrapper to create and hold the ES6 Symbol instance.
This patch adds toJS support for JSC::PrivateName.
Later, the module integration patch will use this feature to call
DeferredWrapper::{resolve,reject} with JSC::PrivateName.

  • bindings/js/JSDOMBinding.h:

(WebCore::toJS):

Location:
trunk/Source
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r205333 r205335  
     12016-09-01  Yusuke Suzuki  <utatane.tea@gmail.com>
     2
     3        Add toJS for JSC::PrivateName
     4        https://bugs.webkit.org/show_bug.cgi?id=161522
     5
     6        Reviewed by Ryosuke Niwa.
     7
     8        Add the export annotation.
     9        And we perform refactoring RefPtr<SymbolImpl> => Ref<SymbolImpl> for PrivateName,
     10        since PrivateName never holds null SymbolImpl pointer. And along with this change,
     11        we changed SymbolImpl* to SymbolImpl& in PrivateName::uid() callers.
     12
     13        * runtime/Completion.cpp:
     14        (JSC::createSymbolForEntryPointModule):
     15        * runtime/IdentifierInlines.h:
     16        (JSC::Identifier::fromUid):
     17        * runtime/JSFunction.cpp:
     18        (JSC::JSFunction::setFunctionName):
     19        * runtime/PrivateName.h:
     20        (JSC::PrivateName::PrivateName):
     21        (JSC::PrivateName::uid): Ugly const_cast. But const annotation is meaningless for SymbolImpl.
     22        StringImpl should be observed as an immutable object. (Of course, its hash members etc. are mutable.
     23        But most of the users (One of the exceptions is the concurrent JIT compiling thread!) should not care about this.)
     24        (JSC::PrivateName::operator==):
     25        (JSC::PrivateName::operator!=):
     26        * runtime/PropertyName.h:
     27        (JSC::PropertyName::PropertyName):
     28        * runtime/Symbol.cpp:
     29        (JSC::Symbol::finishCreation):
     30        * runtime/Symbol.h:
     31        * runtime/SymbolConstructor.cpp:
     32        (JSC::symbolConstructorKeyFor):
     33
    1342016-09-01  Dan Bernstein  <mitz@apple.com>
    235
  • trunk/Source/JavaScriptCore/runtime/Completion.cpp

    r205278 r205335  
    143143    // Generate the unique key for the source-provided module.
    144144    PrivateName privateName(PrivateName::Description, "EntryPointModule");
    145     return Symbol::create(vm, *privateName.uid());
     145    return Symbol::create(vm, privateName.uid());
    146146}
    147147
  • trunk/Source/JavaScriptCore/runtime/IdentifierInlines.h

    r196785 r205335  
    8686inline Identifier Identifier::fromUid(const PrivateName& name)
    8787{
    88     return *name.uid();
     88    return name.uid();
    8989}
    9090
  • trunk/Source/JavaScriptCore/runtime/JSFunction.cpp

    r205198 r205335  
    600600    String name;
    601601    if (value.isSymbol()) {
    602         SymbolImpl* uid = asSymbol(value)->privateName().uid();
    603         if (uid->isNullSymbol())
     602        SymbolImpl& uid = asSymbol(value)->privateName().uid();
     603        if (uid.isNullSymbol())
    604604            name = emptyString();
    605605        else
    606             name = makeString('[', String(uid), ']');
     606            name = makeString('[', String(&uid), ']');
    607607    } else {
    608608        VM& vm = exec->vm();
  • trunk/Source/JavaScriptCore/runtime/PrivateName.h

    r201782 r205335  
    3939
    4040    explicit PrivateName(SymbolImpl& uid)
    41         : m_uid(&uid)
     41        : m_uid(uid)
    4242    {
    4343    }
     
    4949    }
    5050
    51     SymbolImpl* uid() const { return m_uid.get(); }
     51    SymbolImpl& uid() const { return const_cast<SymbolImpl&>(m_uid.get()); }
    5252
    53     bool operator==(const PrivateName& other) const { return uid() == other.uid(); }
    54     bool operator!=(const PrivateName& other) const { return uid() != other.uid(); }
     53    bool operator==(const PrivateName& other) const { return &uid() == &other.uid(); }
     54    bool operator!=(const PrivateName& other) const { return &uid() != &other.uid(); }
    5555
    5656private:
    57     RefPtr<SymbolImpl> m_uid;
     57    Ref<SymbolImpl> m_uid;
    5858};
    5959
  • trunk/Source/JavaScriptCore/runtime/PropertyName.h

    r189154 r205335  
    4646
    4747    PropertyName(const PrivateName& propertyName)
    48         : m_impl(propertyName.uid())
     48        : m_impl(&propertyName.uid())
    4949    {
    5050        ASSERT(m_impl);
  • trunk/Source/JavaScriptCore/runtime/Symbol.cpp

    r205198 r205335  
    5959    ASSERT(inherits(info()));
    6060
    61     vm.symbolImplToSymbolMap.set(m_privateName.uid(), this);
     61    vm.symbolImplToSymbolMap.set(&m_privateName.uid(), this);
    6262}
    6363
  • trunk/Source/JavaScriptCore/runtime/Symbol.h

    r203895 r205335  
    5050    static Symbol* create(VM&);
    5151    static Symbol* create(ExecState*, JSString* description);
    52     static Symbol* create(VM&, SymbolImpl& uid);
     52    JS_EXPORT_PRIVATE static Symbol* create(VM&, SymbolImpl& uid);
    5353
    5454    const PrivateName& privateName() const { return m_privateName; }
  • trunk/Source/JavaScriptCore/runtime/SymbolConstructor.cpp

    r205198 r205335  
    118118        return JSValue::encode(throwTypeError(exec, scope, SymbolKeyForTypeError));
    119119
    120     SymbolImpl* uid = asSymbol(symbolValue)->privateName().uid();
    121     if (!uid->symbolRegistry())
     120    SymbolImpl& uid = asSymbol(symbolValue)->privateName().uid();
     121    if (!uid.symbolRegistry())
    122122        return JSValue::encode(jsUndefined());
    123123
    124     ASSERT(uid->symbolRegistry() == &vm.symbolRegistry());
    125     return JSValue::encode(jsString(exec, vm.symbolRegistry().keyForSymbol(*uid)));
     124    ASSERT(uid.symbolRegistry() == &vm.symbolRegistry());
     125    return JSValue::encode(jsString(exec, vm.symbolRegistry().keyForSymbol(uid)));
    126126}
    127127
  • trunk/Source/WebCore/ChangeLog

    r205333 r205335  
     12016-09-01  Yusuke Suzuki  <utatane.tea@gmail.com>
     2
     3        Add toJS for JSC::PrivateName
     4        https://bugs.webkit.org/show_bug.cgi?id=161522
     5
     6        Reviewed by Ryosuke Niwa.
     7
     8        JSC::PrivateName is the wrapper to create and hold the ES6 Symbol instance.
     9        This patch adds toJS support for JSC::PrivateName.
     10        Later, the module integration patch will use this feature to call
     11        DeferredWrapper::{resolve,reject} with JSC::PrivateName.
     12
     13        * bindings/js/JSDOMBinding.h:
     14        (WebCore::toJS):
     15
    1162016-09-01  Dan Bernstein  <mitz@apple.com>
    217
  • trunk/Source/WebCore/bindings/js/JSDOMBinding.h

    r205324 r205335  
    265265template<typename T> JSC::JSValue toJS(JSC::ExecState*, JSDOMGlobalObject*, const Vector<RefPtr<T>>&);
    266266JSC::JSValue toJS(JSC::ExecState*, JSDOMGlobalObject*, const String&);
     267JSC::JSValue toJS(JSC::ExecState*, JSDOMGlobalObject*, const JSC::PrivateName&);
    267268
    268269JSC::JSValue toJSIterator(JSC::ExecState&, JSDOMGlobalObject&, JSC::JSValue);
     
    577578}
    578579
     580inline JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject*, const JSC::PrivateName& privateName)
     581{
     582    return JSC::Symbol::create(exec->vm(), privateName.uid());
     583}
     584
    579585inline JSC::JSValue toJSIterator(JSC::ExecState& state, JSDOMGlobalObject&, JSC::JSValue value)
    580586{
Note: See TracChangeset for help on using the changeset viewer.