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.
(JSC::APIEntryShimWithoutLock::APIEntryShimWithoutLock):
(JSC::APIEntryShimWithoutLock::~APIEntryShimWithoutLock):
(JSC::APICallbackShim::APICallbackShim):
(JSC::APICallbackShim::~APICallbackShim):
- change the API shims to track the identifierTable of the current JSGlobalData.
(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.
(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.
(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().
(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::Release):
(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):
(JSRunCreate):
(JSRunEvaluate):
(JSRunCheckSyntax):
(JSCollect):
- JavaScriptGlue.xcodeproj/project.pbxproj:
- UserObjectImp.cpp:
(UserObjectImp::callAsFunction):
|