Ignore:
Timestamp:
May 16, 2011, 9:08:18 PM (14 years ago)
Author:
[email protected]
Message:

2011-05-16 Geoffrey Garen <[email protected]>

Reviewed by Geoffrey Garen.

Global object initialization is expensive
https://bugs.webkit.org/show_bug.cgi?id=60933


Changed a bunch of globals to allocate their properties lazily, and changed
the global object to allocate a bunch of its globals lazily.


This reduces the footprint of a global object from 287 objects with 58
functions for 24K to 173 objects with 20 functions for 15K.

Large patch, but it's all mechanical.

  • create_hash_table: Added a special case for fromCharCode, since it uses a custom "thunk generator".
  • heap/Heap.cpp: (JSC::TypeCounter::operator()): Fixed a bug where the type counter would overcount objects that were owned through more than one mechanism because it was getting in the way of counting the results for this patch.
  • interpreter/CallFrame.h: (JSC::ExecState::arrayConstructorTable): (JSC::ExecState::arrayPrototypeTable): (JSC::ExecState::booleanPrototypeTable): (JSC::ExecState::dateConstructorTable): (JSC::ExecState::errorPrototypeTable): (JSC::ExecState::globalObjectTable): (JSC::ExecState::numberConstructorTable): (JSC::ExecState::numberPrototypeTable): (JSC::ExecState::objectPrototypeTable): (JSC::ExecState::regExpPrototypeTable): (JSC::ExecState::stringConstructorTable): Added new tables.
  • runtime/ArrayConstructor.cpp: (JSC::ArrayConstructor::ArrayConstructor): (JSC::ArrayConstructor::getOwnPropertySlot): (JSC::ArrayConstructor::getOwnPropertyDescriptor):
  • runtime/ArrayConstructor.h: (JSC::ArrayConstructor::createStructure):
  • runtime/ArrayPrototype.cpp: (JSC::ArrayPrototype::getOwnPropertySlot): (JSC::ArrayPrototype::getOwnPropertyDescriptor):
  • runtime/ArrayPrototype.h:
  • runtime/BooleanPrototype.cpp: (JSC::BooleanPrototype::BooleanPrototype): (JSC::BooleanPrototype::getOwnPropertySlot): (JSC::BooleanPrototype::getOwnPropertyDescriptor):
  • runtime/BooleanPrototype.h: (JSC::BooleanPrototype::createStructure):
  • runtime/DateConstructor.cpp: (JSC::DateConstructor::DateConstructor): (JSC::DateConstructor::getOwnPropertySlot): (JSC::DateConstructor::getOwnPropertyDescriptor):
  • runtime/DateConstructor.h: (JSC::DateConstructor::createStructure):
  • runtime/ErrorPrototype.cpp: (JSC::ErrorPrototype::ErrorPrototype): (JSC::ErrorPrototype::getOwnPropertySlot): (JSC::ErrorPrototype::getOwnPropertyDescriptor):
  • runtime/ErrorPrototype.h: (JSC::ErrorPrototype::createStructure): Standardized these objects to use static tables for function properties.
  • runtime/JSGlobalData.cpp: (JSC::JSGlobalData::JSGlobalData): (JSC::JSGlobalData::~JSGlobalData):
  • runtime/JSGlobalData.h: Added new tables.
  • runtime/JSGlobalObject.cpp: (JSC::JSGlobalObject::reset): (JSC::JSGlobalObject::addStaticGlobals): (JSC::JSGlobalObject::getOwnPropertySlot): (JSC::JSGlobalObject::getOwnPropertyDescriptor):
  • runtime/JSGlobalObject.h:
  • runtime/JSGlobalObjectFunctions.cpp:
  • runtime/JSGlobalObjectFunctions.h: Changed JSGlobalObject to use a static table for its global functions. This required uninlining some things to avoid a circular header dependency. However, those things probably shouldn't have been inlined in the first place.


Even more global object properties can be made lazy, but that requires
more in-depth changes.

  • runtime/MathObject.cpp:
  • runtime/NumberConstructor.cpp: (JSC::NumberConstructor::getOwnPropertySlot): (JSC::NumberConstructor::getOwnPropertyDescriptor):
  • runtime/NumberPrototype.cpp: (JSC::NumberPrototype::NumberPrototype): (JSC::NumberPrototype::getOwnPropertySlot): (JSC::NumberPrototype::getOwnPropertyDescriptor):
  • runtime/NumberPrototype.h: (JSC::NumberPrototype::createStructure):
  • runtime/ObjectPrototype.cpp: (JSC::ObjectPrototype::ObjectPrototype): (JSC::ObjectPrototype::put): (JSC::ObjectPrototype::getOwnPropertySlot): (JSC::ObjectPrototype::getOwnPropertyDescriptor):
  • runtime/ObjectPrototype.h: (JSC::ObjectPrototype::createStructure):
  • runtime/RegExpPrototype.cpp: (JSC::RegExpPrototype::RegExpPrototype): (JSC::RegExpPrototype::getOwnPropertySlot): (JSC::RegExpPrototype::getOwnPropertyDescriptor):
  • runtime/RegExpPrototype.h: (JSC::RegExpPrototype::createStructure):
  • runtime/StringConstructor.cpp: (JSC::StringConstructor::StringConstructor): (JSC::StringConstructor::getOwnPropertySlot): (JSC::StringConstructor::getOwnPropertyDescriptor):
  • runtime/StringConstructor.h: (JSC::StringConstructor::createStructure): Standardized these objects to use static tables for function properties.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/interpreter/CallFrame.h

    r81191 r86653  
    22 *  Copyright (C) 1999-2001 Harri Porten ([email protected])
    33 *  Copyright (C) 2001 Peter Kelly ([email protected])
    4  *  Copyright (C) 2003, 2007, 2008 Apple Inc. All rights reserved.
     4 *  Copyright (C) 2003, 2007, 2008, 2011 Apple Inc. All rights reserved.
    55 *
    66 *  This library is free software; you can redistribute it and/or
     
    7676        void dumpCaller();
    7777#endif
    78         static const HashTable* arrayTable(CallFrame* callFrame) { return callFrame->globalData().arrayTable; }
     78        static const HashTable* arrayConstructorTable(CallFrame* callFrame) { return callFrame->globalData().arrayConstructorTable; }
     79        static const HashTable* arrayPrototypeTable(CallFrame* callFrame) { return callFrame->globalData().arrayPrototypeTable; }
     80        static const HashTable* booleanPrototypeTable(CallFrame* callFrame) { return callFrame->globalData().booleanPrototypeTable; }
    7981        static const HashTable* dateTable(CallFrame* callFrame) { return callFrame->globalData().dateTable; }
     82        static const HashTable* dateConstructorTable(CallFrame* callFrame) { return callFrame->globalData().dateConstructorTable; }
     83        static const HashTable* errorPrototypeTable(CallFrame* callFrame) { return callFrame->globalData().errorPrototypeTable; }
     84        static const HashTable* globalObjectTable(CallFrame* callFrame) { return callFrame->globalData().globalObjectTable; }
    8085        static const HashTable* jsonTable(CallFrame* callFrame) { return callFrame->globalData().jsonTable; }
    8186        static const HashTable* mathTable(CallFrame* callFrame) { return callFrame->globalData().mathTable; }
    82         static const HashTable* numberTable(CallFrame* callFrame) { return callFrame->globalData().numberTable; }
     87        static const HashTable* numberConstructorTable(CallFrame* callFrame) { return callFrame->globalData().numberConstructorTable; }
     88        static const HashTable* numberPrototypeTable(CallFrame* callFrame) { return callFrame->globalData().numberPrototypeTable; }
    8389        static const HashTable* objectConstructorTable(CallFrame* callFrame) { return callFrame->globalData().objectConstructorTable; }
     90        static const HashTable* objectPrototypeTable(CallFrame* callFrame) { return callFrame->globalData().objectPrototypeTable; }
    8491        static const HashTable* regExpTable(CallFrame* callFrame) { return callFrame->globalData().regExpTable; }
    8592        static const HashTable* regExpConstructorTable(CallFrame* callFrame) { return callFrame->globalData().regExpConstructorTable; }
     93        static const HashTable* regExpPrototypeTable(CallFrame* callFrame) { return callFrame->globalData().regExpPrototypeTable; }
    8694        static const HashTable* stringTable(CallFrame* callFrame) { return callFrame->globalData().stringTable; }
     95        static const HashTable* stringConstructorTable(CallFrame* callFrame) { return callFrame->globalData().stringConstructorTable; }
    8796
    8897        static CallFrame* create(Register* callFrameBase) { return static_cast<CallFrame*>(callFrameBase); }
Note: See TracChangeset for help on using the changeset viewer.