Skip to content
  • barraclough@apple.com's avatar
    https://bugs.webkit.org/show_bug.cgi?id=33236 · ee9b4368
    barraclough@apple.com authored
    Remove m_identifierTable pointer from UString
    
    Reviewed by Sam Weinig.
    
    JavaScriptCore: 
    
    Currently every string holds a pointer so that during destruction,
    if a string has been used as an identifier, it can remove itself
    from the table.  By instead accessing the identifierTable via a
    thread specific tracking the table associated with the current
    globaldata, we can save the memory cost of this pointer.
    
    * API/APIShims.h:
    (JSC::APIEntryShimWithoutLock::APIEntryShimWithoutLock):
    (JSC::APIEntryShimWithoutLock::~APIEntryShimWithoutLock):
    (JSC::APICallbackShim::APICallbackShim):
    (JSC::APICallbackShim::~APICallbackShim):
    
        - change the API shims to track the identifierTable of the current JSGlobalData.
    
    * API/JSContextRef.cpp:
    (JSContextGroupCreate):
    
        - update creation of JSGlobalData for API usage to use new create method.
        - fix shim instanciation bug in JSGlobalContextCreateInGroup.
    
    * JavaScriptCore.exp:
    * runtime/Completion.cpp:
    (JSC::checkSyntax):
    (JSC::evaluate):
    
        - add asserts to check the identifierTable is being tracked correctly.
    
    * runtime/Identifier.cpp:
    (JSC::IdentifierTable::~IdentifierTable):
    (JSC::IdentifierTable::add):
    (JSC::Identifier::remove):
    (JSC::Identifier::checkSameIdentifierTable):
    (JSC::createIdentifierTableSpecificCallback):
    (JSC::createIdentifierTableSpecific):
    (JSC::createDefaultDataSpecific):
    
        - Use currentIdentifierTable() instead of UStringImpl::m_identifierTable.
        - Define methods to access the thread specific identifier tables.
    
    * runtime/Identifier.h:
    (JSC::ThreadIdentifierTableData::ThreadIdentifierTableData):
    (JSC::defaultIdentifierTable):
    (JSC::setDefaultIdentifierTable):
    (JSC::currentIdentifierTable):
    (JSC::setCurrentIdentifierTable):
    (JSC::resetCurrentIdentifierTable):
    
        - Declare methods to access the thread specific identifier tables.
    
    * runtime/JSGlobalData.cpp:
    (JSC::JSGlobalData::createNonDefault):
    (JSC::JSGlobalData::create):
    (JSC::JSGlobalData::sharedInstance):
    
        - creation of JSGlobalData objects, other than for API usage, associate themselves with the current thread.
    
    * runtime/JSGlobalData.h:
    * runtime/UStringImpl.cpp:
    (JSC::UStringImpl::destroy):
    
        - destroy() method should be using isIdentifier().
    
    * runtime/UStringImpl.h:
    (JSC::UStringImpl::isIdentifier):
    (JSC::UStringImpl::setIsIdentifier):
    (JSC::UStringImpl::checkConsistency):
    (JSC::UStringImpl::UStringImpl):
    
        - replace m_identifierTable with a single m_isIdentifier bit.
    
    * wtf/StringHashFunctions.h:
    (WTF::stringHash):
    
        - change string hash result from 32-bit to 31-bit, to free a bit in UStringImpl for m_isIdentifier.
    
    JavaScriptGlue: 
    
    Add API shims similar to those used in the JSC API to track the current identifierTable.
    
    * JSBase.cpp:
    (JSBase::Release):
    * JSUtils.cpp:
    (JSObjectKJSValue):
    (KJSValueToCFTypeInternal):
    (unprotectGlobalObject):
    (JSGlueAPIEntry::JSGlueAPIEntry):
    (JSGlueAPIEntry::~JSGlueAPIEntry):
    (JSGlueAPICallback::JSGlueAPICallback):
    (JSGlueAPICallback::~JSGlueAPICallback):
    * JSUtils.h:
    * JSValueWrapper.cpp:
    (JSValueWrapper::JSObjectCopyPropertyNames):
    (JSValueWrapper::JSObjectCopyProperty):
    (JSValueWrapper::JSObjectSetProperty):
    (JSValueWrapper::JSObjectCallFunction):
    (JSValueWrapper::JSObjectCopyCFValue):
    * JavaScriptGlue.cpp:
    (JSRunCreate):
    (JSRunEvaluate):
    (JSRunCheckSyntax):
    (JSCollect):
    * JavaScriptGlue.xcodeproj/project.pbxproj:
    * UserObjectImp.cpp:
    (UserObjectImp::callAsFunction):
    
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@52856 268f45cc-cd09-0410-ab3c-d52691b4dbfc
    ee9b4368