Ignore:
Timestamp:
Jan 6, 2010, 11:33:29 AM (15 years ago)
Author:
[email protected]
Message:

https://bugs.webkit.org/show_bug.cgi?id=33236
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.

(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):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/API/JSContextRef.cpp

    r52791 r52856  
    4747{
    4848    initializeThreading();
    49     return toRef(JSGlobalData::create().releaseRef());
     49    return toRef(JSGlobalData::createNonDefault().releaseRef());
    5050}
    5151
     
    8585
    8686    JSLock lock(LockForReal);
    87     RefPtr<JSGlobalData> globalData = group ? PassRefPtr<JSGlobalData>(toJS(group)) : JSGlobalData::create();
    88     APIEntryShim(globalData.get(), false);
     87    RefPtr<JSGlobalData> globalData = group ? PassRefPtr<JSGlobalData>(toJS(group)) : JSGlobalData::createNonDefault();
     88
     89    APIEntryShim entryShim(globalData.get(), false);
    8990
    9091#if ENABLE(JSC_MULTIPLE_THREADS)
Note: See TracChangeset for help on using the changeset viewer.