⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 242382 in webkit


Ignore:
Timestamp:
Mar 4, 2019, 1:20:14 PM (7 years ago)
Author:
ysuzuki@apple.com
Message:

[JSC] Make Reflect lazily-allocated by dropping @Reflect references from builtin JS
https://bugs.webkit.org/show_bug.cgi?id=195250

Reviewed by Saam Barati.

By removing @Reflect from builtin JS, we can make Reflect object allocation lazy.
We move @ownKeys function from @Reflect to @Object to remove @Reflect reference.

We also remove m_intlObject field from JSGlobalObject since we no longer use it.

  • builtins/BuiltinNames.h:
  • builtins/GlobalOperations.js:

(globalPrivate.copyDataProperties):
(globalPrivate.copyDataPropertiesNoExclusions):

  • runtime/JSGlobalObject.cpp:

(JSC::createReflectProperty):
(JSC::JSGlobalObject::init):
(JSC::JSGlobalObject::visitChildren):

  • runtime/JSGlobalObject.h:
  • runtime/ObjectConstructor.cpp:

(JSC::ObjectConstructor::finishCreation):
(JSC::objectConstructorOwnKeys):

  • runtime/ReflectObject.cpp:

(JSC::ReflectObject::finishCreation):

Location:
trunk/Source/JavaScriptCore
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r242365 r242382  
     12019-03-04  Yusuke Suzuki  <ysuzuki@apple.com>
     2
     3        [JSC] Make Reflect lazily-allocated by dropping @Reflect references from builtin JS
     4        https://bugs.webkit.org/show_bug.cgi?id=195250
     5
     6        Reviewed by Saam Barati.
     7
     8        By removing @Reflect from builtin JS, we can make Reflect object allocation lazy.
     9        We move @ownKeys function from @Reflect to @Object to remove @Reflect reference.
     10
     11        We also remove m_intlObject field from JSGlobalObject since we no longer use it.
     12
     13        * builtins/BuiltinNames.h:
     14        * builtins/GlobalOperations.js:
     15        (globalPrivate.copyDataProperties):
     16        (globalPrivate.copyDataPropertiesNoExclusions):
     17        * runtime/JSGlobalObject.cpp:
     18        (JSC::createReflectProperty):
     19        (JSC::JSGlobalObject::init):
     20        (JSC::JSGlobalObject::visitChildren):
     21        * runtime/JSGlobalObject.h:
     22        * runtime/ObjectConstructor.cpp:
     23        (JSC::ObjectConstructor::finishCreation):
     24        (JSC::objectConstructorOwnKeys):
     25        * runtime/ReflectObject.cpp:
     26        (JSC::ReflectObject::finishCreation):
     27
    1282019-03-04  Yusuke Suzuki  <ysuzuki@apple.com>
    229
  • trunk/Source/JavaScriptCore/builtins/BuiltinNames.h

    r242365 r242382  
    6565    macro(RegExp) \
    6666    macro(Promise) \
    67     macro(Reflect) \
    6867    macro(InternalPromise) \
    6968    macro(trunc) \
     
    7170    macro(defineProperty) \
    7271    macro(getPrototypeOf) \
    73     macro(getOwnPropertyDescriptor) \
    7472    macro(getOwnPropertyNames) \
    7573    macro(ownKeys) \
     
    8280    macro(BuiltinDescribe) \
    8381    macro(homeObject) \
    84     macro(templateRegistryKey) \
    8582    macro(enqueueJob) \
    8683    macro(hostPromiseRejectionTracker) \
  • trunk/Source/JavaScriptCore/builtins/GlobalOperations.js

    r239761 r242382  
    9797
    9898    let from = @toObject(source);
    99     let keys = @Reflect.@ownKeys(from);
     99    let keys = @ownKeys(from);
    100100    let keysLength = keys.length;
    101101    for (let i = 0; i < keysLength; i++) {
     
    124124
    125125    let from = @toObject(source);
    126     let keys = @Reflect.@ownKeys(from);
     126    let keys = @ownKeys(from);
    127127    let keysLength = keys.length;
    128128    for (let i = 0; i < keysLength; i++) {
  • trunk/Source/JavaScriptCore/runtime/JSGlobalObject.cpp

    r242365 r242382  
    223223}
    224224
     225static JSValue createReflectProperty(VM& vm, JSObject* object)
     226{
     227    JSGlobalObject* global = jsCast<JSGlobalObject*>(object);
     228    return ReflectObject::create(vm, global, ReflectObject::createStructure(vm, global, global->objectPrototype()));
     229}
     230
    225231static JSValue createConsoleProperty(VM& vm, JSObject* object)
    226232{
     
    322328  URIError              JSGlobalObject::m_URIErrorStructure          DontEnum|ClassStructure
    323329  Proxy                 createProxyProperty                          DontEnum|PropertyCallback
     330  Reflect               createReflectProperty                        DontEnum|PropertyCallback
    324331  JSON                  createJSONProperty                           DontEnum|PropertyCallback
    325332  Math                  createMathProperty                           DontEnum|PropertyCallback
     
    834841    IntlObject* intl = IntlObject::create(vm, IntlObject::createStructure(vm, this, m_objectPrototype.get()));
    835842    putDirectWithoutTransition(vm, vm.propertyNames->Intl, intl, static_cast<unsigned>(PropertyAttribute::DontEnum));
    836     m_intlObject.set(vm, this, intl);
    837843#endif // ENABLE(INTL)
    838     ReflectObject* reflectObject = ReflectObject::create(vm, this, ReflectObject::createStructure(vm, this, m_objectPrototype.get()));
    839     putDirectWithoutTransition(vm, vm.propertyNames->Reflect, reflectObject, static_cast<unsigned>(PropertyAttribute::DontEnum));
    840844
    841845    m_moduleLoader.initLater(
     
    854858
    855859    JSFunction* privateFuncPropertyIsEnumerable = JSFunction::create(vm, this, 0, String(), globalFuncPropertyIsEnumerable);
     860    JSFunction* privateFuncOwnKeys = JSFunction::create(vm, this, 0, String(), globalFuncOwnKeys);
    856861    JSFunction* privateFuncImportModule = JSFunction::create(vm, this, 0, String(), globalFuncImportModule);
    857862    JSFunction* privateFuncMakeTypeError = JSFunction::create(vm, this, 0, String(), globalFuncMakeTypeError);
     
    925930        GlobalPropertyInfo(vm.propertyNames->undefinedKeyword, jsUndefined(), PropertyAttribute::DontEnum | PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly),
    926931        GlobalPropertyInfo(vm.propertyNames->builtinNames().propertyIsEnumerablePrivateName(), privateFuncPropertyIsEnumerable, PropertyAttribute::DontEnum | PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly),
     932        GlobalPropertyInfo(vm.propertyNames->builtinNames().ownKeysPrivateName(), privateFuncOwnKeys, PropertyAttribute::DontEnum | PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly),
    927933        GlobalPropertyInfo(vm.propertyNames->builtinNames().importModulePrivateName(), privateFuncImportModule, PropertyAttribute::DontEnum | PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly),
    928934        GlobalPropertyInfo(vm.propertyNames->builtinNames().enqueueJobPrivateName(), JSFunction::create(vm, this, 0, String(), enqueueJob), PropertyAttribute::DontEnum | PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly),
     
    941947        GlobalPropertyInfo(vm.propertyNames->builtinNames().truncPrivateName(), privateFuncTrunc, PropertyAttribute::DontEnum | PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly),
    942948        GlobalPropertyInfo(vm.propertyNames->builtinNames().PromisePrivateName(), promiseConstructor, PropertyAttribute::DontEnum | PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly),
    943         GlobalPropertyInfo(vm.propertyNames->builtinNames().ReflectPrivateName(), reflectObject, PropertyAttribute::DontEnum | PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly),
    944949        GlobalPropertyInfo(vm.propertyNames->builtinNames().InternalPromisePrivateName(), internalPromiseConstructor, PropertyAttribute::DontEnum | PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly),
    945950
     
    15971602
    15981603#if ENABLE(INTL)
    1599     visitor.append(thisObject->m_intlObject);
    16001604    visitor.append(thisObject->m_defaultCollator);
    16011605    thisObject->m_collatorStructure.visit(visitor);
  • trunk/Source/JavaScriptCore/runtime/JSGlobalObject.h

    r242365 r242382  
    275275
    276276#if ENABLE(INTL)
    277     WriteBarrier<IntlObject> m_intlObject;
    278277    WriteBarrier<IntlCollator> m_defaultCollator;
    279278    LazyProperty<JSGlobalObject, Structure> m_collatorStructure;
  • trunk/Source/JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp

    r242365 r242382  
    840840}
    841841
     842EncodedJSValue JSC_HOST_CALL globalFuncOwnKeys(ExecState* exec)
     843{
     844    VM& vm = exec->vm();
     845    auto scope = DECLARE_THROW_SCOPE(vm);
     846    JSObject* object = exec->argument(0).toObject(exec);
     847    RETURN_IF_EXCEPTION(scope, encodedJSValue());
     848    RELEASE_AND_RETURN(scope, JSValue::encode(ownPropertyKeys(exec, object, PropertyNameMode::StringsAndSymbols, DontEnumPropertiesMode::Include)));
     849}
     850
    842851#if ENABLE(INTL)
    843852EncodedJSValue JSC_HOST_CALL globalFuncDateTimeFormat(ExecState* exec)
  • trunk/Source/JavaScriptCore/runtime/JSGlobalObjectFunctions.h

    r242365 r242382  
    5757EncodedJSValue JSC_HOST_CALL globalFuncImportModule(ExecState*);
    5858EncodedJSValue JSC_HOST_CALL globalFuncPropertyIsEnumerable(ExecState*);
     59EncodedJSValue JSC_HOST_CALL globalFuncOwnKeys(ExecState*);
    5960EncodedJSValue JSC_HOST_CALL globalFuncDateTimeFormat(ExecState*);
    6061
  • trunk/Source/JavaScriptCore/runtime/ReflectObject.cpp

    r236697 r242382  
    7979}
    8080
    81 void ReflectObject::finishCreation(VM& vm, JSGlobalObject* globalObject)
     81void ReflectObject::finishCreation(VM& vm, JSGlobalObject*)
    8282{
    8383    Base::finishCreation(vm);
    8484    ASSERT(inherits(vm, info()));
    85 
    86     JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION(vm.propertyNames->builtinNames().ownKeysPrivateName(), reflectObjectOwnKeys, PropertyAttribute::DontEnum | PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly, 1);
    87     JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION(vm.propertyNames->builtinNames().getOwnPropertyDescriptorPrivateName(), reflectObjectGetOwnPropertyDescriptor, PropertyAttribute::DontEnum | PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly, 2);
    8885}
    8986
Note: See TracChangeset for help on using the changeset viewer.