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

Changeset 242742 in webkit


Ignore:
Timestamp:
Mar 11, 2019, 2:55:00 PM (7 years ago)
Author:
ysuzuki@apple.com
Message:

[JSC] Reduce # of structures in JSGlobalObject initialization
https://bugs.webkit.org/show_bug.cgi?id=195498

Reviewed by Darin Adler.

Source/JavaScriptCore:

This patch reduces # of structure allocations in JSGlobalObject initialization. Now it becomes 141, it fits in one
MarkedBlock and this patch drops one MarkedBlock used for Structure previously.

  • CMakeLists.txt:
  • DerivedSources-output.xcfilelist:
  • DerivedSources.make:
  • JavaScriptCore.xcodeproj/project.pbxproj:
  • runtime/ArrayIteratorPrototype.cpp:

(JSC::ArrayIteratorPrototype::finishCreation): ArrayIteratorPrototype, MapIteratorPrototype, and StringIteratorPrototype's
"next" properties are referenced by JSGlobalObject::init, and it causes reification of the lazy "next" property and structure
transition anyway. So we should put it eagerly "without-transition" configuration to avoid one structure transition.

  • runtime/ArrayPrototype.cpp:

(JSC::ArrayPrototype::finishCreation): @@unscopable object's structure should be dictionary because (1) it is used as a dictionary
in with-scope-resolution and (2) since with-scope-resolution is C++ runtime function anyway, non-dictionary structure does not add
any performance benefit. This change saves several structures that are not useful.

  • runtime/ClonedArguments.cpp:

(JSC::ClonedArguments::createStructure): Bake CloneArguments's structure with 'without-transition' manner.

  • runtime/JSGlobalObject.cpp:

(JSC::JSGlobalObject::init): Previously we are always call resetProtoype at the end of JSGlobalObject::init. But it is not necessary
since we do not change Prototype of JSGlobalObject. All we want is (1) fixupPrototypeChainWithObjectPrototype's operation and (2) setGlobalThis
operation. Since setGlobalThis part is done in JSGlobalObject::finishCreation, fixupPrototypeChainWithObjectPrototype is only the thing
we should do here.

(JSC::JSGlobalObject::fixupPrototypeChainWithObjectPrototype):
(JSC::JSGlobalObject::resetPrototype): If the Prototype is the same to the current Prototype, we can skip the operation.

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

(JSC::MapIteratorPrototype::finishCreation):

  • runtime/NullGetterFunction.h:
  • runtime/NullSetterFunction.h: Since structures of them are allocated per JSGlobalObject and they are per-JSGlobalObject,

we can use without-transition property addition.

  • runtime/StringIteratorPrototype.cpp:

(JSC::StringIteratorPrototype::finishCreation):

  • runtime/VM.cpp:

(JSC::VM::VM):
(JSC::VM::setIteratorStructureSlow):
(JSC::VM::mapIteratorStructureSlow): These structures are only used in WebCore's main thread.

  • runtime/VM.h:

(JSC::VM::setIteratorStructure):
(JSC::VM::mapIteratorStructure):

Source/WebCore:

  • bindings/js/SerializedScriptValue.cpp:

(WebCore::CloneSerializer::serialize):

Location:
trunk/Source
Files:
18 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/CMakeLists.txt

    r242699 r242742  
    6060set(JavaScriptCore_OBJECT_LUT_SOURCES
    6161    runtime/ArrayConstructor.cpp
    62     runtime/ArrayIteratorPrototype.cpp
    6362    runtime/AsyncFromSyncIteratorPrototype.cpp
    6463    runtime/AsyncGeneratorPrototype.cpp
     
    9695    runtime/SetPrototype.cpp
    9796    runtime/StringConstructor.cpp
    98     runtime/StringIteratorPrototype.cpp
    9997    runtime/StringPrototype.cpp
    10098    runtime/SymbolConstructor.cpp
  • trunk/Source/JavaScriptCore/ChangeLog

    r242722 r242742  
     12019-03-11  Yusuke Suzuki  <ysuzuki@apple.com>
     2
     3        [JSC] Reduce # of structures in JSGlobalObject initialization
     4        https://bugs.webkit.org/show_bug.cgi?id=195498
     5
     6        Reviewed by Darin Adler.
     7
     8        This patch reduces # of structure allocations in JSGlobalObject initialization. Now it becomes 141, it fits in one
     9        MarkedBlock and this patch drops one MarkedBlock used for Structure previously.
     10
     11        * CMakeLists.txt:
     12        * DerivedSources-output.xcfilelist:
     13        * DerivedSources.make:
     14        * JavaScriptCore.xcodeproj/project.pbxproj:
     15        * runtime/ArrayIteratorPrototype.cpp:
     16        (JSC::ArrayIteratorPrototype::finishCreation): ArrayIteratorPrototype, MapIteratorPrototype, and StringIteratorPrototype's
     17        "next" properties are referenced by JSGlobalObject::init, and it causes reification of the lazy "next" property and structure
     18        transition anyway. So we should put it eagerly "without-transition" configuration to avoid one structure transition.
     19
     20        * runtime/ArrayPrototype.cpp:
     21        (JSC::ArrayPrototype::finishCreation): @@unscopable object's structure should be dictionary because (1) it is used as a dictionary
     22        in with-scope-resolution and (2) since with-scope-resolution is C++ runtime function anyway, non-dictionary structure does not add
     23        any performance benefit. This change saves several structures that are not useful.
     24
     25        * runtime/ClonedArguments.cpp:
     26        (JSC::ClonedArguments::createStructure): Bake CloneArguments's structure with 'without-transition' manner.
     27
     28        * runtime/JSGlobalObject.cpp:
     29        (JSC::JSGlobalObject::init): Previously we are always call resetProtoype at the end of JSGlobalObject::init. But it is not necessary
     30        since we do not change [[Prototype]] of JSGlobalObject. All we want is (1) fixupPrototypeChainWithObjectPrototype's operation and (2) setGlobalThis
     31        operation. Since setGlobalThis part is done in JSGlobalObject::finishCreation, fixupPrototypeChainWithObjectPrototype is only the thing
     32        we should do here.
     33
     34        (JSC::JSGlobalObject::fixupPrototypeChainWithObjectPrototype):
     35        (JSC::JSGlobalObject::resetPrototype): If the [[Prototype]] is the same to the current [[Prototype]], we can skip the operation.
     36
     37        * runtime/JSGlobalObject.h:
     38        * runtime/MapIteratorPrototype.cpp:
     39        (JSC::MapIteratorPrototype::finishCreation):
     40        * runtime/NullGetterFunction.h:
     41        * runtime/NullSetterFunction.h: Since structures of them are allocated per JSGlobalObject and they are per-JSGlobalObject,
     42        we can use without-transition property addition.
     43
     44        * runtime/StringIteratorPrototype.cpp:
     45        (JSC::StringIteratorPrototype::finishCreation):
     46        * runtime/VM.cpp:
     47        (JSC::VM::VM):
     48        (JSC::VM::setIteratorStructureSlow):
     49        (JSC::VM::mapIteratorStructureSlow): These structures are only used in WebCore's main thread.
     50        * runtime/VM.h:
     51        (JSC::VM::setIteratorStructure):
     52        (JSC::VM::mapIteratorStructure):
     53
    1542019-03-08  Yusuke Suzuki  <ysuzuki@apple.com>
    255
  • trunk/Source/JavaScriptCore/DerivedSources-output.xcfilelist

    r241660 r242742  
    44$(BUILT_PRODUCTS_DIR)/DerivedSources/JavaScriptCore/AirOpcodeUtils.h
    55$(BUILT_PRODUCTS_DIR)/DerivedSources/JavaScriptCore/ArrayConstructor.lut.h
    6 $(BUILT_PRODUCTS_DIR)/DerivedSources/JavaScriptCore/ArrayIteratorPrototype.lut.h
    76$(BUILT_PRODUCTS_DIR)/DerivedSources/JavaScriptCore/AsyncFromSyncIteratorPrototype.lut.h
    87$(BUILT_PRODUCTS_DIR)/DerivedSources/JavaScriptCore/AsyncGeneratorPrototype.lut.h
     
    5352$(BUILT_PRODUCTS_DIR)/DerivedSources/JavaScriptCore/SetPrototype.lut.h
    5453$(BUILT_PRODUCTS_DIR)/DerivedSources/JavaScriptCore/StringConstructor.lut.h
    55 $(BUILT_PRODUCTS_DIR)/DerivedSources/JavaScriptCore/StringIteratorPrototype.lut.h
    5654$(BUILT_PRODUCTS_DIR)/DerivedSources/JavaScriptCore/StringPrototype.lut.h
    5755$(BUILT_PRODUCTS_DIR)/DerivedSources/JavaScriptCore/SymbolConstructor.lut.h
  • trunk/Source/JavaScriptCore/DerivedSources.make

    r242047 r242742  
    136136    AsyncFromSyncIteratorPrototype.lut.h \
    137137    ArrayConstructor.lut.h \
    138     ArrayIteratorPrototype.lut.h \
    139138    AsyncGeneratorPrototype.lut.h \
    140139    BigIntConstructor.lut.h \
     
    170169    SetPrototype.lut.h \
    171170    StringConstructor.lut.h \
    172     StringIteratorPrototype.lut.h \
    173171    StringPrototype.lut.h \
    174172    SymbolConstructor.lut.h \
  • trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj

    r242699 r242742  
    12871287                996231E918D1804200C03FDA /* InspectorBackendCommands.js in Headers */ = {isa = PBXBuildFile; fileRef = A53243961856A475002ED692 /* InspectorBackendCommands.js */; settings = {ATTRIBUTES = (Private, ); }; };
    12881288                996B73171BDA067F00331B84 /* ArrayConstructor.lut.h in Headers */ = {isa = PBXBuildFile; fileRef = 996B73151BDA05AA00331B84 /* ArrayConstructor.lut.h */; };
    1289                 996B73181BDA068000331B84 /* ArrayIteratorPrototype.lut.h in Headers */ = {isa = PBXBuildFile; fileRef = 996B73161BDA05AA00331B84 /* ArrayIteratorPrototype.lut.h */; };
    12901289                996B73191BDA068000331B84 /* BooleanPrototype.lut.h in Headers */ = {isa = PBXBuildFile; fileRef = 996B73071BD9FA2C00331B84 /* BooleanPrototype.lut.h */; };
    12911290                996B731A1BDA08D100331B84 /* DateConstructor.lut.h in Headers */ = {isa = PBXBuildFile; fileRef = 996B73081BD9FA2C00331B84 /* DateConstructor.lut.h */; };
     
    13001299                996B73231BDA08EF00331B84 /* ReflectObject.lut.h in Headers */ = {isa = PBXBuildFile; fileRef = 996B730F1BD9FA2C00331B84 /* ReflectObject.lut.h */; };
    13011300                996B73251BDA08EF00331B84 /* StringConstructor.lut.h in Headers */ = {isa = PBXBuildFile; fileRef = 996B73111BD9FA2C00331B84 /* StringConstructor.lut.h */; };
    1302                 996B73261BDA08EF00331B84 /* StringIteratorPrototype.lut.h in Headers */ = {isa = PBXBuildFile; fileRef = 996B73121BD9FA2C00331B84 /* StringIteratorPrototype.lut.h */; };
    13031301                996B73271BDA08EF00331B84 /* SymbolConstructor.lut.h in Headers */ = {isa = PBXBuildFile; fileRef = 996B73131BD9FA2C00331B84 /* SymbolConstructor.lut.h */; };
    13041302                996B73281BDA08EF00331B84 /* SymbolPrototype.lut.h in Headers */ = {isa = PBXBuildFile; fileRef = 996B73141BD9FA2C00331B84 /* SymbolPrototype.lut.h */; };
     
    40314029                996B730F1BD9FA2C00331B84 /* ReflectObject.lut.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ReflectObject.lut.h; sourceTree = "<group>"; };
    40324030                996B73111BD9FA2C00331B84 /* StringConstructor.lut.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StringConstructor.lut.h; sourceTree = "<group>"; };
    4033                 996B73121BD9FA2C00331B84 /* StringIteratorPrototype.lut.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StringIteratorPrototype.lut.h; sourceTree = "<group>"; };
    40344031                996B73131BD9FA2C00331B84 /* SymbolConstructor.lut.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SymbolConstructor.lut.h; sourceTree = "<group>"; };
    40354032                996B73141BD9FA2C00331B84 /* SymbolPrototype.lut.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SymbolPrototype.lut.h; sourceTree = "<group>"; };
    40364033                996B73151BDA05AA00331B84 /* ArrayConstructor.lut.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ArrayConstructor.lut.h; sourceTree = "<group>"; };
    4037                 996B73161BDA05AA00331B84 /* ArrayIteratorPrototype.lut.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ArrayIteratorPrototype.lut.h; sourceTree = "<group>"; };
    40384034                998ED6721BED659A00DD8017 /* RemoteControllableTarget.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RemoteControllableTarget.cpp; sourceTree = "<group>"; };
    40394035                998ED6731BED659A00DD8017 /* RemoteControllableTarget.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RemoteControllableTarget.h; sourceTree = "<group>"; };
     
    63656361                                0F6183351C45F3B60072450B /* AirOpcodeUtils.h */,
    63666362                                996B73151BDA05AA00331B84 /* ArrayConstructor.lut.h */,
    6367                                 996B73161BDA05AA00331B84 /* ArrayIteratorPrototype.lut.h */,
    63686363                                E3893A1C2203A7C600E79A74 /* AsyncFromSyncIteratorPrototype.lut.h */,
    63696364                                8B3BF5E31E3D365A0076A87A /* AsyncGeneratorPrototype.lut.h */,
     
    64076402                                7035587F1C418458004BD7BF /* SetPrototype.lut.h */,
    64086403                                996B73111BD9FA2C00331B84 /* StringConstructor.lut.h */,
    6409                                 996B73121BD9FA2C00331B84 /* StringIteratorPrototype.lut.h */,
    64106404                                996B73131BD9FA2C00331B84 /* SymbolConstructor.lut.h */,
    64116405                                996B73141BD9FA2C00331B84 /* SymbolPrototype.lut.h */,
     
    84908484                                0FB7F39515ED8E4600F167B2 /* ArrayConventions.h in Headers */,
    84918485                                A7BDAEC917F4EA1400F6140C /* ArrayIteratorPrototype.h in Headers */,
    8492                                 996B73181BDA068000331B84 /* ArrayIteratorPrototype.lut.h in Headers */,
    84938486                                0F63945515D07057006A597C /* ArrayProfile.h in Headers */,
    84948487                                BC18C3E70E16F5CD00B34460 /* ArrayPrototype.h in Headers */,
     
    97039696                                996B73251BDA08EF00331B84 /* StringConstructor.lut.h in Headers */,
    97049697                                70EC0EC71AA0D7DA00B6AAFA /* StringIteratorPrototype.h in Headers */,
    9705                                 996B73261BDA08EF00331B84 /* StringIteratorPrototype.lut.h in Headers */,
    97069698                                BC18C4680E16F5CD00B34460 /* StringObject.h in Headers */,
    97079699                                BC18C46A0E16F5CD00B34460 /* StringPrototype.h in Headers */,
  • trunk/Source/JavaScriptCore/runtime/ArrayIteratorPrototype.cpp

    r223027 r242742  
    2727#include "ArrayIteratorPrototype.h"
    2828
    29 #include "ArrayIteratorPrototype.lut.h"
    3029#include "IteratorOperations.h"
    3130#include "JSCInlines.h"
     
    3837namespace JSC {
    3938
    40 const ClassInfo ArrayIteratorPrototype::s_info = { "Array Iterator", &Base::s_info, &arrayIteratorPrototypeTable, nullptr, CREATE_METHOD_TABLE(ArrayIteratorPrototype) };
     39const ClassInfo ArrayIteratorPrototype::s_info = { "Array Iterator", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(ArrayIteratorPrototype) };
    4140
    42 /* Source for ArrayIteratorPrototype.lut.h
    43 @begin arrayIteratorPrototypeTable
    44   next      JSBuiltin  DontEnum|Function 0
    45 @end
    46 */
    47 
    48 void ArrayIteratorPrototype::finishCreation(VM& vm, JSGlobalObject*)
     41void ArrayIteratorPrototype::finishCreation(VM& vm, JSGlobalObject* globalObject)
    4942{
    5043    Base::finishCreation(vm);
    5144    ASSERT(inherits(vm, info()));
    5245    putDirectWithoutTransition(vm, vm.propertyNames->toStringTagSymbol, jsString(&vm, "Array Iterator"), PropertyAttribute::DontEnum | PropertyAttribute::ReadOnly);
     46    JSC_BUILTIN_FUNCTION_WITHOUT_TRANSITION(vm.propertyNames->next, arrayIteratorPrototypeNextCodeGenerator, static_cast<unsigned>(PropertyAttribute::DontEnum));
    5347    didBecomePrototype();
    5448}
  • trunk/Source/JavaScriptCore/runtime/ArrayPrototype.cpp

    r242081 r242742  
    9090
    9191    JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION(vm.propertyNames->toLocaleString, arrayProtoFuncToLocaleString, static_cast<unsigned>(PropertyAttribute::DontEnum), 0);
    92     JSC_BUILTIN_FUNCTION_WITHOUT_TRANSITION("concat", arrayPrototypeConcatCodeGenerator, static_cast<unsigned>(PropertyAttribute::DontEnum));
    93     JSC_BUILTIN_FUNCTION_WITHOUT_TRANSITION("fill", arrayPrototypeFillCodeGenerator, static_cast<unsigned>(PropertyAttribute::DontEnum));
     92    JSC_BUILTIN_FUNCTION_WITHOUT_TRANSITION(vm.propertyNames->builtinNames().concatPublicName(), arrayPrototypeConcatCodeGenerator, static_cast<unsigned>(PropertyAttribute::DontEnum));
     93    JSC_BUILTIN_FUNCTION_WITHOUT_TRANSITION(vm.propertyNames->builtinNames().fillPublicName(), arrayPrototypeFillCodeGenerator, static_cast<unsigned>(PropertyAttribute::DontEnum));
    9494    JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION(vm.propertyNames->join, arrayProtoFuncJoin, static_cast<unsigned>(PropertyAttribute::DontEnum), 1);
    9595    JSC_NATIVE_INTRINSIC_FUNCTION_WITHOUT_TRANSITION("pop", arrayProtoFuncPop, static_cast<unsigned>(PropertyAttribute::DontEnum), 0, ArrayPopIntrinsic);
     
    100100    JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION(vm.propertyNames->builtinNames().shiftPrivateName(), arrayProtoFuncShift, PropertyAttribute::DontEnum | PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly, 0);
    101101    JSC_NATIVE_INTRINSIC_FUNCTION_WITHOUT_TRANSITION(vm.propertyNames->slice, arrayProtoFuncSlice, static_cast<unsigned>(PropertyAttribute::DontEnum), 2, ArraySliceIntrinsic);
    102     JSC_BUILTIN_FUNCTION_WITHOUT_TRANSITION("sort", arrayPrototypeSortCodeGenerator, static_cast<unsigned>(PropertyAttribute::DontEnum));
     102    JSC_BUILTIN_FUNCTION_WITHOUT_TRANSITION(vm.propertyNames->builtinNames().sortPublicName(), arrayPrototypeSortCodeGenerator, static_cast<unsigned>(PropertyAttribute::DontEnum));
    103103    JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION("splice", arrayProtoFuncSplice, static_cast<unsigned>(PropertyAttribute::DontEnum), 2);
    104104    JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION("unshift", arrayProtoFuncUnShift, static_cast<unsigned>(PropertyAttribute::DontEnum), 1);
    105     JSC_BUILTIN_FUNCTION_WITHOUT_TRANSITION("every", arrayPrototypeEveryCodeGenerator, static_cast<unsigned>(PropertyAttribute::DontEnum));
    106     JSC_BUILTIN_FUNCTION_WITHOUT_TRANSITION("forEach", arrayPrototypeForEachCodeGenerator, static_cast<unsigned>(PropertyAttribute::DontEnum));
    107     JSC_BUILTIN_FUNCTION_WITHOUT_TRANSITION("some", arrayPrototypeSomeCodeGenerator, static_cast<unsigned>(PropertyAttribute::DontEnum));
     105    JSC_BUILTIN_FUNCTION_WITHOUT_TRANSITION(vm.propertyNames->builtinNames().everyPublicName(), arrayPrototypeEveryCodeGenerator, static_cast<unsigned>(PropertyAttribute::DontEnum));
     106    JSC_BUILTIN_FUNCTION_WITHOUT_TRANSITION(vm.propertyNames->builtinNames().forEachPublicName(), arrayPrototypeForEachCodeGenerator, static_cast<unsigned>(PropertyAttribute::DontEnum));
     107    JSC_BUILTIN_FUNCTION_WITHOUT_TRANSITION(vm.propertyNames->builtinNames().somePublicName(), arrayPrototypeSomeCodeGenerator, static_cast<unsigned>(PropertyAttribute::DontEnum));
    108108    JSC_NATIVE_INTRINSIC_FUNCTION_WITHOUT_TRANSITION("indexOf", arrayProtoFuncIndexOf, static_cast<unsigned>(PropertyAttribute::DontEnum), 1, ArrayIndexOfIntrinsic);
    109109    JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION("lastIndexOf", arrayProtoFuncLastIndexOf, static_cast<unsigned>(PropertyAttribute::DontEnum), 1);
    110     JSC_BUILTIN_FUNCTION_WITHOUT_TRANSITION("filter", arrayPrototypeFilterCodeGenerator, static_cast<unsigned>(PropertyAttribute::DontEnum));
    111     JSC_BUILTIN_FUNCTION_WITHOUT_TRANSITION("flat", arrayPrototypeFlatCodeGenerator, static_cast<unsigned>(PropertyAttribute::DontEnum));
    112     JSC_BUILTIN_FUNCTION_WITHOUT_TRANSITION("flatMap", arrayPrototypeFlatMapCodeGenerator, static_cast<unsigned>(PropertyAttribute::DontEnum));
    113     JSC_BUILTIN_FUNCTION_WITHOUT_TRANSITION("reduce", arrayPrototypeReduceCodeGenerator, static_cast<unsigned>(PropertyAttribute::DontEnum));
    114     JSC_BUILTIN_FUNCTION_WITHOUT_TRANSITION("reduceRight", arrayPrototypeReduceRightCodeGenerator, static_cast<unsigned>(PropertyAttribute::DontEnum));
    115     JSC_BUILTIN_FUNCTION_WITHOUT_TRANSITION("map", arrayPrototypeMapCodeGenerator, static_cast<unsigned>(PropertyAttribute::DontEnum));
     110    JSC_BUILTIN_FUNCTION_WITHOUT_TRANSITION(vm.propertyNames->builtinNames().filterPublicName(), arrayPrototypeFilterCodeGenerator, static_cast<unsigned>(PropertyAttribute::DontEnum));
     111    JSC_BUILTIN_FUNCTION_WITHOUT_TRANSITION(vm.propertyNames->builtinNames().flatPublicName(), arrayPrototypeFlatCodeGenerator, static_cast<unsigned>(PropertyAttribute::DontEnum));
     112    JSC_BUILTIN_FUNCTION_WITHOUT_TRANSITION(vm.propertyNames->builtinNames().flatMapPublicName(), arrayPrototypeFlatMapCodeGenerator, static_cast<unsigned>(PropertyAttribute::DontEnum));
     113    JSC_BUILTIN_FUNCTION_WITHOUT_TRANSITION(vm.propertyNames->builtinNames().reducePublicName(), arrayPrototypeReduceCodeGenerator, static_cast<unsigned>(PropertyAttribute::DontEnum));
     114    JSC_BUILTIN_FUNCTION_WITHOUT_TRANSITION(vm.propertyNames->builtinNames().reduceRightPublicName(), arrayPrototypeReduceRightCodeGenerator, static_cast<unsigned>(PropertyAttribute::DontEnum));
     115    JSC_BUILTIN_FUNCTION_WITHOUT_TRANSITION(vm.propertyNames->builtinNames().mapPublicName(), arrayPrototypeMapCodeGenerator, static_cast<unsigned>(PropertyAttribute::DontEnum));
    116116    JSC_BUILTIN_FUNCTION_WITHOUT_TRANSITION(vm.propertyNames->builtinNames().entriesPublicName(), arrayPrototypeEntriesCodeGenerator, static_cast<unsigned>(PropertyAttribute::DontEnum));
    117117    JSC_BUILTIN_FUNCTION_WITHOUT_TRANSITION(vm.propertyNames->builtinNames().keysPublicName(), arrayPrototypeKeysCodeGenerator, static_cast<unsigned>(PropertyAttribute::DontEnum));
    118     JSC_BUILTIN_FUNCTION_WITHOUT_TRANSITION("find", arrayPrototypeFindCodeGenerator, static_cast<unsigned>(PropertyAttribute::DontEnum));
    119     JSC_BUILTIN_FUNCTION_WITHOUT_TRANSITION("findIndex", arrayPrototypeFindIndexCodeGenerator, static_cast<unsigned>(PropertyAttribute::DontEnum));
    120     JSC_BUILTIN_FUNCTION_WITHOUT_TRANSITION("includes", arrayPrototypeIncludesCodeGenerator, static_cast<unsigned>(PropertyAttribute::DontEnum));
    121     JSC_BUILTIN_FUNCTION_WITHOUT_TRANSITION("copyWithin", arrayPrototypeCopyWithinCodeGenerator, static_cast<unsigned>(PropertyAttribute::DontEnum));
     118    JSC_BUILTIN_FUNCTION_WITHOUT_TRANSITION(vm.propertyNames->builtinNames().findPublicName(), arrayPrototypeFindCodeGenerator, static_cast<unsigned>(PropertyAttribute::DontEnum));
     119    JSC_BUILTIN_FUNCTION_WITHOUT_TRANSITION(vm.propertyNames->builtinNames().findIndexPublicName(), arrayPrototypeFindIndexCodeGenerator, static_cast<unsigned>(PropertyAttribute::DontEnum));
     120    JSC_BUILTIN_FUNCTION_WITHOUT_TRANSITION(vm.propertyNames->builtinNames().includesPublicName(), arrayPrototypeIncludesCodeGenerator, static_cast<unsigned>(PropertyAttribute::DontEnum));
     121    JSC_BUILTIN_FUNCTION_WITHOUT_TRANSITION(vm.propertyNames->builtinNames().copyWithinPublicName(), arrayPrototypeCopyWithinCodeGenerator, static_cast<unsigned>(PropertyAttribute::DontEnum));
    122122
    123123    putDirectWithoutTransition(vm, vm.propertyNames->builtinNames().entriesPrivateName(), getDirect(vm, vm.propertyNames->builtinNames().entriesPublicName()), static_cast<unsigned>(PropertyAttribute::ReadOnly));
     
    127127
    128128    JSObject* unscopables = constructEmptyObject(globalObject->globalExec(), globalObject->nullPrototypeObjectStructure());
    129     const char* unscopableNames[] = {
    130         "copyWithin",
    131         "entries",
    132         "fill",
    133         "find",
    134         "findIndex",
    135         "includes",
    136         "keys",
    137         "values"
     129    unscopables->convertToDictionary(vm);
     130    const Identifier* const unscopableNames[] = {
     131        &vm.propertyNames->builtinNames().copyWithinPublicName(),
     132        &vm.propertyNames->builtinNames().entriesPublicName(),
     133        &vm.propertyNames->builtinNames().fillPublicName(),
     134        &vm.propertyNames->builtinNames().findPublicName(),
     135        &vm.propertyNames->builtinNames().findIndexPublicName(),
     136        &vm.propertyNames->builtinNames().includesPublicName(),
     137        &vm.propertyNames->builtinNames().keysPublicName(),
     138        &vm.propertyNames->builtinNames().valuesPublicName()
    138139    };
    139     for (const char* unscopableName : unscopableNames)
    140         unscopables->putDirect(vm, Identifier::fromString(&vm, unscopableName), jsBoolean(true));
     140    for (const auto* unscopableName : unscopableNames)
     141        unscopables->putDirect(vm, *unscopableName, jsBoolean(true));
    141142    putDirectWithoutTransition(vm, vm.propertyNames->unscopablesSymbol, unscopables, PropertyAttribute::DontEnum | PropertyAttribute::ReadOnly);
    142143}
  • trunk/Source/JavaScriptCore/runtime/ClonedArguments.cpp

    r232337 r242742  
    152152{
    153153    Structure* structure = Structure::create(vm, globalObject, prototype, TypeInfo(ClonedArgumentsType, StructureFlags), info(), indexingType);
    154     PropertyOffset offset;
    155     structure = structure->addPropertyTransition(vm, structure, vm.propertyNames->length, static_cast<unsigned>(PropertyAttribute::DontEnum), offset);
    156     ASSERT(offset == clonedArgumentsLengthPropertyOffset);
     154    structure->addPropertyWithoutTransition(
     155        vm, vm.propertyNames->length, static_cast<unsigned>(PropertyAttribute::DontEnum),
     156        [&] (const GCSafeConcurrentJSLocker&, PropertyOffset offset, PropertyOffset newLastOffset) {
     157            RELEASE_ASSERT(offset == clonedArgumentsLengthPropertyOffset);
     158            structure->setLastOffset(newLastOffset);
     159        });
    157160    return structure;
    158161}
  • trunk/Source/JavaScriptCore/runtime/JSGlobalObject.cpp

    r242650 r242742  
    11611161    }
    11621162
    1163     resetPrototype(vm, getPrototypeDirect(vm));
     1163    fixupPrototypeChainWithObjectPrototype(vm);
    11641164}
    11651165
     
    15861586}
    15871587
    1588 // Set prototype, and also insert the object prototype at the end of the chain.
    1589 void JSGlobalObject::resetPrototype(VM& vm, JSValue prototype)
    1590 {
    1591     setPrototypeDirect(vm, prototype);
    1592 
     1588void JSGlobalObject::fixupPrototypeChainWithObjectPrototype(VM& vm)
     1589{
    15931590    JSObject* oldLastInPrototypeChain = lastInPrototypeChain(vm, this);
    15941591    JSObject* objectPrototype = m_objectPrototype.get();
    15951592    if (oldLastInPrototypeChain != objectPrototype)
    15961593        oldLastInPrototypeChain->setPrototypeDirect(vm, objectPrototype);
    1597 
     1594}
     1595
     1596// Set prototype, and also insert the object prototype at the end of the chain.
     1597void JSGlobalObject::resetPrototype(VM& vm, JSValue prototype)
     1598{
     1599    if (getPrototypeDirect(vm) == prototype)
     1600        return;
     1601    setPrototypeDirect(vm, prototype);
     1602    fixupPrototypeChainWithObjectPrototype(vm);
    15981603    // Whenever we change the prototype of the global object, we need to create a new JSProxy with the correct prototype.
    15991604    setGlobalThis(vm, JSNonDestructibleProxy::create(vm, JSNonDestructibleProxy::createStructure(vm, this, prototype, PureForwardingProxyType), this));
  • trunk/Source/JavaScriptCore/runtime/JSGlobalObject.h

    r242636 r242742  
    10361036
    10371037    JS_EXPORT_PRIVATE void init(VM&);
     1038    void fixupPrototypeChainWithObjectPrototype(VM&);
    10381039
    10391040    JS_EXPORT_PRIVATE static void clearRareData(JSCell*);
  • trunk/Source/JavaScriptCore/runtime/MapIteratorPrototype.cpp

    r223027 r242742  
    4040    didBecomePrototype();
    4141
    42     JSC_BUILTIN_FUNCTION_WITHOUT_TRANSITION("next", mapIteratorPrototypeNextCodeGenerator, static_cast<unsigned>(PropertyAttribute::DontEnum));
    4342    putDirectWithoutTransition(vm, vm.propertyNames->toStringTagSymbol, jsString(&vm, "Map Iterator"), PropertyAttribute::DontEnum | PropertyAttribute::ReadOnly);
     43    JSC_BUILTIN_FUNCTION_WITHOUT_TRANSITION(vm.propertyNames->next, mapIteratorPrototypeNextCodeGenerator, static_cast<unsigned>(PropertyAttribute::DontEnum));
    4444}
    4545
  • trunk/Source/JavaScriptCore/runtime/NullGetterFunction.h

    r242650 r242742  
    3838        // Since NullGetterFunction is per JSGlobalObject, we use put-without-transition in InternalFunction::finishCreation.
    3939        NullGetterFunction* function = new (NotNull, allocateCell< NullGetterFunction>(vm.heap))  NullGetterFunction(vm, structure);
    40         function->finishCreation(vm, String(), NameVisibility::Visible, NameAdditionMode::WithStructureTransition);
     40        function->finishCreation(vm, String(), NameVisibility::Visible, NameAdditionMode::WithoutStructureTransition);
    4141        return function;
    4242    }
  • trunk/Source/JavaScriptCore/runtime/NullSetterFunction.h

    r242650 r242742  
    3838        // Since NullSetterFunction is per JSGlobalObject, we use put-without-transition in InternalFunction::finishCreation.
    3939        NullSetterFunction* function = new (NotNull, allocateCell< NullSetterFunction>(vm.heap))  NullSetterFunction(vm, structure);
    40         function->finishCreation(vm, String(), NameVisibility::Visible, NameAdditionMode::WithStructureTransition);
     40        function->finishCreation(vm, String(), NameVisibility::Visible, NameAdditionMode::WithoutStructureTransition);
    4141        return function;
    4242    }
  • trunk/Source/JavaScriptCore/runtime/StringIteratorPrototype.cpp

    r223027 r242742  
    3333#include "ObjectConstructor.h"
    3434
    35 #include "StringIteratorPrototype.lut.h"
    36 
    3735namespace JSC {
    3836
    39 const ClassInfo StringIteratorPrototype::s_info = { "String Iterator", &Base::s_info, &stringIteratorPrototypeTable, nullptr, CREATE_METHOD_TABLE(StringIteratorPrototype) };
     37const ClassInfo StringIteratorPrototype::s_info = { "String Iterator", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(StringIteratorPrototype) };
    4038
    41 /* Source for StringIteratorPrototype.lut.h
    42 @begin stringIteratorPrototypeTable
    43   next      JSBuiltin    DontEnum|Function 0
    44 @end
    45 */
    46 
    47 void StringIteratorPrototype::finishCreation(VM& vm, JSGlobalObject*)
     39void StringIteratorPrototype::finishCreation(VM& vm, JSGlobalObject* globalObject)
    4840{
    4941    Base::finishCreation(vm);
    5042    ASSERT(inherits(vm, info()));
    5143    putDirectWithoutTransition(vm, vm.propertyNames->toStringTagSymbol, jsString(&vm, "String Iterator"), PropertyAttribute::DontEnum | PropertyAttribute::ReadOnly);
     44    JSC_BUILTIN_FUNCTION_WITHOUT_TRANSITION(vm.propertyNames->next, stringIteratorPrototypeNextCodeGenerator, static_cast<unsigned>(PropertyAttribute::DontEnum));
    5245    didBecomePrototype();
    5346}
  • trunk/Source/JavaScriptCore/runtime/VM.cpp

    r242596 r242742  
    401401    hashMapBucketSetStructure.set(*this, HashMapBucket<HashMapBucketDataKey>::createStructure(*this, 0, jsNull()));
    402402    hashMapBucketMapStructure.set(*this, HashMapBucket<HashMapBucketDataKeyValue>::createStructure(*this, 0, jsNull()));
    403     setIteratorStructure.set(*this, JSSetIterator::createStructure(*this, 0, jsNull()));
    404     mapIteratorStructure.set(*this, JSMapIterator::createStructure(*this, 0, jsNull()));
    405403    bigIntStructure.set(*this, JSBigInt::createStructure(*this, 0, jsNull()));
    406404    executableToCodeBlockEdgeStructure.set(*this, ExecutableToCodeBlockEdge::createStructure(*this, nullptr, jsNull()));
     
    12921290#undef DYNAMIC_SPACE_AND_SET_DEFINE_MEMBER_SLOW
    12931291
     1292Structure* VM::setIteratorStructureSlow()
     1293{
     1294    ASSERT(!m_setIteratorStructure);
     1295    m_setIteratorStructure.set(*this, JSSetIterator::createStructure(*this, 0, jsNull()));
     1296    return m_setIteratorStructure.get();
     1297}
     1298
     1299Structure* VM::mapIteratorStructureSlow()
     1300{
     1301    ASSERT(!m_mapIteratorStructure);
     1302    m_mapIteratorStructure.set(*this, JSMapIterator::createStructure(*this, 0, jsNull()));
     1303    return m_mapIteratorStructure.get();
     1304}
    12941305
    12951306JSCell* VM::sentinelSetBucketSlow()
  • trunk/Source/JavaScriptCore/runtime/VM.h

    r242596 r242742  
    534534    Strong<Structure> hashMapBucketSetStructure;
    535535    Strong<Structure> hashMapBucketMapStructure;
    536     Strong<Structure> setIteratorStructure;
    537     Strong<Structure> mapIteratorStructure;
    538536    Strong<Structure> bigIntStructure;
    539537    Strong<Structure> executableToCodeBlockEdgeStructure;
     538
     539    Strong<Structure> m_setIteratorStructure;
     540    Strong<Structure> m_mapIteratorStructure;
    540541
    541542    Strong<JSCell> emptyPropertyNameEnumerator;
     
    564565    WTF::SymbolRegistry& symbolRegistry() { return m_symbolRegistry; }
    565566
     567    Structure* setIteratorStructure()
     568    {
     569        if (LIKELY(m_setIteratorStructure))
     570            return m_setIteratorStructure.get();
     571        return setIteratorStructureSlow();
     572    }
     573
     574    Structure* mapIteratorStructure()
     575    {
     576        if (LIKELY(m_mapIteratorStructure))
     577            return m_mapIteratorStructure.get();
     578        return mapIteratorStructureSlow();
     579    }
     580
    566581    JSCell* sentinelSetBucket()
    567582    {
     
    908923    void createNativeThunk();
    909924
     925    JS_EXPORT_PRIVATE Structure* setIteratorStructureSlow();
     926    JS_EXPORT_PRIVATE Structure* mapIteratorStructureSlow();
    910927    JSCell* sentinelSetBucketSlow();
    911928    JSCell* sentinelMapBucketSlow();
  • trunk/Source/WebCore/ChangeLog

    r242738 r242742  
     12019-03-11  Yusuke Suzuki  <ysuzuki@apple.com>
     2
     3        [JSC] Reduce # of structures in JSGlobalObject initialization
     4        https://bugs.webkit.org/show_bug.cgi?id=195498
     5
     6        Reviewed by Darin Adler.
     7
     8        * bindings/js/SerializedScriptValue.cpp:
     9        (WebCore::CloneSerializer::serialize):
     10
    1112019-03-11  Brent Fulgham  <bfulgham@apple.com>
    212
  • trunk/Source/WebCore/bindings/js/SerializedScriptValue.cpp

    r242699 r242742  
    16241624                if (!startMap(inMap))
    16251625                    break;
    1626                 JSMapIterator* iterator = JSMapIterator::create(vm, vm.mapIteratorStructure.get(), inMap, IterateKeyValue);
     1626                JSMapIterator* iterator = JSMapIterator::create(vm, vm.mapIteratorStructure(), inMap, IterateKeyValue);
    16271627                m_gcBuffer.appendWithCrashOnOverflow(inMap);
    16281628                m_gcBuffer.appendWithCrashOnOverflow(iterator);
     
    16681668                if (!startSet(inSet))
    16691669                    break;
    1670                 JSSetIterator* iterator = JSSetIterator::create(vm, vm.setIteratorStructure.get(), inSet, IterateKey);
     1670                JSSetIterator* iterator = JSSetIterator::create(vm, vm.setIteratorStructure(), inSet, IterateKey);
    16711671                m_gcBuffer.appendWithCrashOnOverflow(inSet);
    16721672                m_gcBuffer.appendWithCrashOnOverflow(iterator);
Note: See TracChangeset for help on using the changeset viewer.