Commit f025068f authored by mjs's avatar mjs

JavaScriptCore:

        Reviewed by Eric.

	- move HashMap/HashSet code down to JavaScriptCore
	http://bugzilla.opendarwin.org/show_bug.cgi?id=5161

        * JavaScriptCore.xcodeproj/project.pbxproj:
        * kjs/internal.cpp:
        (KJS::interpreterMap): Function that fetches the interpreter map on demand.
        (KJS::InterpreterImp::InterpreterImp): Replace use of InterpreterMap
	class with an appropriate HashMap.
        (KJS::InterpreterImp::clear): ditto
        (KJS::InterpreterImp::interpreterWithGlobalObject): ditto
        * kjs/interpreter_map.cpp: Removed.
        * kjs/interpreter_map.h: Removed.

	The HashMap/HashSet code (copied and slightly tweaked from WebCore)

	* kxmlcore/HashFunctions.h: Added.
        (KXMLCore::4):
        (KXMLCore::8):
        (KXMLCore::):
        (KXMLCore::PointerHash::hash):
        (KXMLCore::PointerHash::equal):
        * kxmlcore/HashMap.h: Added.
        (KXMLCore::extractFirst):
        (KXMLCore::HashMap::HashMap):
        (KXMLCore::::size):
        (KXMLCore::::capacity):
        (KXMLCore::::isEmpty):
        (KXMLCore::::begin):
        (KXMLCore::::end):
        (KXMLCore::::find):
        (KXMLCore::::contains):
        (KXMLCore::::set):
        (KXMLCore::::get):
        (KXMLCore::::remove):
        (KXMLCore::::clear):
        (KXMLCore::deleteAllValues):
        * kxmlcore/HashMapPtrSpec.h: Added.
        (KXMLCore::PointerHashIteratorAdapter::PointerHashIteratorAdapter):
        (KXMLCore::PointerHashIteratorAdapter::operator*):
        (KXMLCore::PointerHashIteratorAdapter::operator->):
        (KXMLCore::PointerHashIteratorAdapter::operator++):
        (KXMLCore::PointerHashIteratorAdapter::operator==):
        (KXMLCore::PointerHashIteratorAdapter::operator!=):
        (KXMLCore::PointerHashConstIteratorAdapter::PointerHashConstIteratorAdapter):
        (KXMLCore::PointerHashConstIteratorAdapter::operator*):
        (KXMLCore::PointerHashConstIteratorAdapter::operator->):
        (KXMLCore::PointerHashConstIteratorAdapter::operator++):
        (KXMLCore::PointerHashConstIteratorAdapter::operator==):
        (KXMLCore::PointerHashConstIteratorAdapter::operator!=):
        (KXMLCore::):
        * kxmlcore/HashSet.h: Added.
        (KXMLCore::identityExtract):
        (KXMLCore::convertAdapter):
        (KXMLCore::HashSet::HashSet):
        (KXMLCore::::size):
        (KXMLCore::::capacity):
        (KXMLCore::::isEmpty):
        (KXMLCore::::begin):
        (KXMLCore::::end):
        (KXMLCore::::find):
        (KXMLCore::::contains):
        (KXMLCore::::insert):
        (KXMLCore::::remove):
        (KXMLCore::::clear):
        * kxmlcore/HashTable.cpp: Added.
        (KXMLCore::HashTableStats::~HashTableStats):
        (KXMLCore::HashTableStats::recordCollisionAtCount):
        * kxmlcore/HashTable.h: Added.
        (KXMLCore::HashTableIterator::skipEmptyBuckets):
        (KXMLCore::HashTableIterator::HashTableIterator):
        (KXMLCore::HashTableIterator::operator*):
        (KXMLCore::HashTableIterator::operator->):
        (KXMLCore::HashTableIterator::operator++):
        (KXMLCore::HashTableIterator::operator==):
        (KXMLCore::HashTableIterator::operator!=):
        (KXMLCore::HashTableConstIterator::HashTableConstIterator):
        (KXMLCore::HashTableConstIterator::operator*):
        (KXMLCore::HashTableConstIterator::operator->):
        (KXMLCore::HashTableConstIterator::skipEmptyBuckets):
        (KXMLCore::HashTableConstIterator::operator++):
        (KXMLCore::HashTableConstIterator::operator==):
        (KXMLCore::HashTableConstIterator::operator!=):
        (KXMLCore::HashTable::HashTable):
        (KXMLCore::HashTable::~HashTable):
        (KXMLCore::HashTable::begin):
        (KXMLCore::HashTable::end):
        (KXMLCore::HashTable::size):
        (KXMLCore::HashTable::capacity):
        (KXMLCore::HashTable::insert):
        (KXMLCore::HashTable::isEmptyBucket):
        (KXMLCore::HashTable::isDeletedBucket):
        (KXMLCore::HashTable::isEmptyOrDeletedBucket):
        (KXMLCore::HashTable::hash):
        (KXMLCore::HashTable::equal):
        (KXMLCore::HashTable::identityConvert):
        (KXMLCore::HashTable::extractKey):
        (KXMLCore::HashTable::lookup):
        (KXMLCore::HashTable::shouldExpand):
        (KXMLCore::HashTable::mustRehashInPlace):
        (KXMLCore::HashTable::shouldShrink):
        (KXMLCore::HashTable::shrink):
        (KXMLCore::HashTable::clearBucket):
        (KXMLCore::HashTable::deleteBucket):
        (KXMLCore::HashTable::makeLookupResult):
        (KXMLCore::HashTable::makeIterator):
        (KXMLCore::HashTable::makeConstIterator):
        (KXMLCore::::lookup):
        (KXMLCore::::insert):
        (KXMLCore::::reinsert):
        (KXMLCore::::find):
        (KXMLCore::::contains):
        (KXMLCore::::remove):
        (KXMLCore::::allocateTable):
        (KXMLCore::::expand):
        (KXMLCore::::rehash):
        (KXMLCore::::clear):
        (KXMLCore::::HashTable):
        (KXMLCore::::swap):
        (KXMLCore::::operator):
        (KXMLCore::::checkTableConsistency):
        (KXMLCore::::checkTableConsistencyExceptSize):
        * kxmlcore/HashTraits.h: Added.
        (KXMLCore::HashTraits::emptyValue):
        (KXMLCore::):
        (KXMLCore::PairHashTraits::emptyValue):
        (KXMLCore::PairHashTraits::deletedValue):

WebCore:

        Reviewed by Eric.

	- move HashMap/HashSet code down to JavaScriptCore; adapt usage to the new header location
	http://bugzilla.opendarwin.org/show_bug.cgi?id=5161

        * ForwardingHeaders/kxmlcore/HashMap.h: Added.
        * ForwardingHeaders/kxmlcore/HashSet.h: Added.
        * ForwardingHeaders/misc/hashmap.h: Removed.
        * ForwardingHeaders/misc/hashset.h: Removed.
        * ForwardingHeaders/misc/pointerhash.h: Removed.
        * WebCore.xcodeproj/project.pbxproj:
        * khtml/css/cssstyleselector.cpp:
        (khtml::CSSRuleSet::getIDRules):
        (khtml::CSSRuleSet::getClassRules):
        (khtml::CSSRuleSet::getTagRules):
        (khtml::CSSRuleSet::getUniversalRules):
        (khtml::CSSRuleSet::addToRuleSet):
        * khtml/css/cssstyleselector.h:
        * khtml/ecma/kjs_binding.cpp:
        * khtml/editing/jsediting.cpp:
        * khtml/html/html_documentimpl.cpp:
        (DOM::addItemToMap):
        * khtml/html/html_documentimpl.h:
        * khtml/html/html_elementimpl.cpp:
        * khtml/html/html_formimpl.cpp:
        (DOM::HTMLFormElementImpl::radioButtonChecked):
        * khtml/html/html_formimpl.h:
        * khtml/html/htmlfactory.cpp:
        (DOM::HTMLElementFactory::createHTMLElement):
        * khtml/html/htmlparser.cpp:
        (HTMLParser::getNode):
        * khtml/xml/dom_atomicstring.cpp:
        * khtml/xml/dom_qname.cpp:
        * khtml/xml/dom_stringimpl.h:
        (KXMLCore::):
        (KXMLCore::CaseInsensitiveHash::hash):
        (KXMLCore::CaseInsensitiveHash::equal):
        * khtml/xml/xml_tokenizer.cpp:
        * kwq/DOM.mm:
        (ObjCEventListener::ObjCEventListener):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@10653 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent c4cc0e09
2005-09-27 Maciej Stachowiak <mjs@apple.com>
Reviewed by Eric.
- move HashMap/HashSet code down to JavaScriptCore
http://bugzilla.opendarwin.org/show_bug.cgi?id=5161
* JavaScriptCore.xcodeproj/project.pbxproj:
* kjs/internal.cpp:
(KJS::interpreterMap): Function that fetches the interpreter map on demand.
(KJS::InterpreterImp::InterpreterImp): Replace use of InterpreterMap
class with an appropriate HashMap.
(KJS::InterpreterImp::clear): ditto
(KJS::InterpreterImp::interpreterWithGlobalObject): ditto
* kjs/interpreter_map.cpp: Removed.
* kjs/interpreter_map.h: Removed.
The HashMap/HashSet code (copied and slightly tweaked from WebCore)
* kxmlcore/HashFunctions.h: Added.
(KXMLCore::4):
(KXMLCore::8):
(KXMLCore::):
(KXMLCore::PointerHash::hash):
(KXMLCore::PointerHash::equal):
* kxmlcore/HashMap.h: Added.
(KXMLCore::extractFirst):
(KXMLCore::HashMap::HashMap):
(KXMLCore::::size):
(KXMLCore::::capacity):
(KXMLCore::::isEmpty):
(KXMLCore::::begin):
(KXMLCore::::end):
(KXMLCore::::find):
(KXMLCore::::contains):
(KXMLCore::::set):
(KXMLCore::::get):
(KXMLCore::::remove):
(KXMLCore::::clear):
(KXMLCore::deleteAllValues):
* kxmlcore/HashMapPtrSpec.h: Added.
(KXMLCore::PointerHashIteratorAdapter::PointerHashIteratorAdapter):
(KXMLCore::PointerHashIteratorAdapter::operator*):
(KXMLCore::PointerHashIteratorAdapter::operator->):
(KXMLCore::PointerHashIteratorAdapter::operator++):
(KXMLCore::PointerHashIteratorAdapter::operator==):
(KXMLCore::PointerHashIteratorAdapter::operator!=):
(KXMLCore::PointerHashConstIteratorAdapter::PointerHashConstIteratorAdapter):
(KXMLCore::PointerHashConstIteratorAdapter::operator*):
(KXMLCore::PointerHashConstIteratorAdapter::operator->):
(KXMLCore::PointerHashConstIteratorAdapter::operator++):
(KXMLCore::PointerHashConstIteratorAdapter::operator==):
(KXMLCore::PointerHashConstIteratorAdapter::operator!=):
(KXMLCore::):
* kxmlcore/HashSet.h: Added.
(KXMLCore::identityExtract):
(KXMLCore::convertAdapter):
(KXMLCore::HashSet::HashSet):
(KXMLCore::::size):
(KXMLCore::::capacity):
(KXMLCore::::isEmpty):
(KXMLCore::::begin):
(KXMLCore::::end):
(KXMLCore::::find):
(KXMLCore::::contains):
(KXMLCore::::insert):
(KXMLCore::::remove):
(KXMLCore::::clear):
* kxmlcore/HashTable.cpp: Added.
(KXMLCore::HashTableStats::~HashTableStats):
(KXMLCore::HashTableStats::recordCollisionAtCount):
* kxmlcore/HashTable.h: Added.
(KXMLCore::HashTableIterator::skipEmptyBuckets):
(KXMLCore::HashTableIterator::HashTableIterator):
(KXMLCore::HashTableIterator::operator*):
(KXMLCore::HashTableIterator::operator->):
(KXMLCore::HashTableIterator::operator++):
(KXMLCore::HashTableIterator::operator==):
(KXMLCore::HashTableIterator::operator!=):
(KXMLCore::HashTableConstIterator::HashTableConstIterator):
(KXMLCore::HashTableConstIterator::operator*):
(KXMLCore::HashTableConstIterator::operator->):
(KXMLCore::HashTableConstIterator::skipEmptyBuckets):
(KXMLCore::HashTableConstIterator::operator++):
(KXMLCore::HashTableConstIterator::operator==):
(KXMLCore::HashTableConstIterator::operator!=):
(KXMLCore::HashTable::HashTable):
(KXMLCore::HashTable::~HashTable):
(KXMLCore::HashTable::begin):
(KXMLCore::HashTable::end):
(KXMLCore::HashTable::size):
(KXMLCore::HashTable::capacity):
(KXMLCore::HashTable::insert):
(KXMLCore::HashTable::isEmptyBucket):
(KXMLCore::HashTable::isDeletedBucket):
(KXMLCore::HashTable::isEmptyOrDeletedBucket):
(KXMLCore::HashTable::hash):
(KXMLCore::HashTable::equal):
(KXMLCore::HashTable::identityConvert):
(KXMLCore::HashTable::extractKey):
(KXMLCore::HashTable::lookup):
(KXMLCore::HashTable::shouldExpand):
(KXMLCore::HashTable::mustRehashInPlace):
(KXMLCore::HashTable::shouldShrink):
(KXMLCore::HashTable::shrink):
(KXMLCore::HashTable::clearBucket):
(KXMLCore::HashTable::deleteBucket):
(KXMLCore::HashTable::makeLookupResult):
(KXMLCore::HashTable::makeIterator):
(KXMLCore::HashTable::makeConstIterator):
(KXMLCore::::lookup):
(KXMLCore::::insert):
(KXMLCore::::reinsert):
(KXMLCore::::find):
(KXMLCore::::contains):
(KXMLCore::::remove):
(KXMLCore::::allocateTable):
(KXMLCore::::expand):
(KXMLCore::::rehash):
(KXMLCore::::clear):
(KXMLCore::::HashTable):
(KXMLCore::::swap):
(KXMLCore::::operator):
(KXMLCore::::checkTableConsistency):
(KXMLCore::::checkTableConsistencyExceptSize):
* kxmlcore/HashTraits.h: Added.
(KXMLCore::HashTraits::emptyValue):
(KXMLCore::):
(KXMLCore::PairHashTraits::emptyValue):
(KXMLCore::PairHashTraits::deletedValue):
2005-09-27 Darin Adler <darin@apple.com>
Reviewed by Maciej.
......
......@@ -32,10 +32,17 @@
6541BD7308E80A17002CBEE7 /* TCSpinLock.h in Headers */ = {isa = PBXBuildFile; fileRef = 6541BD6F08E80A17002CBEE7 /* TCSpinLock.h */; };
6541BD7408E80A17002CBEE7 /* TCSystemAlloc.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6541BD7008E80A17002CBEE7 /* TCSystemAlloc.cpp */; };
6541BD7508E80A17002CBEE7 /* TCSystemAlloc.h in Headers */ = {isa = PBXBuildFile; fileRef = 6541BD7108E80A17002CBEE7 /* TCSystemAlloc.h */; };
6557E8F808EA5D4D0049CDFC /* HashMapPtrSpec.h in Headers */ = {isa = PBXBuildFile; fileRef = 6557E8F708EA5D4D0049CDFC /* HashMapPtrSpec.h */; settings = {ATTRIBUTES = (Private, ); }; };
65621E6D089E859700760F35 /* property_slot.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 65621E6B089E859700760F35 /* property_slot.cpp */; };
65621E6E089E859700760F35 /* property_slot.h in Headers */ = {isa = PBXBuildFile; fileRef = 65621E6C089E859700760F35 /* property_slot.h */; settings = {ATTRIBUTES = (Private, ); }; };
65621E6F089E85D300760F35 /* property_slot.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 65621E6B089E859700760F35 /* property_slot.cpp */; };
65621E70089E85D300760F35 /* property_slot.h in Headers */ = {isa = PBXBuildFile; fileRef = 65621E6C089E859700760F35 /* property_slot.h */; settings = {ATTRIBUTES = (Private, ); }; };
65DFC93008EA173A00F7300B /* HashFunctions.h in Headers */ = {isa = PBXBuildFile; fileRef = 65DFC92A08EA173A00F7300B /* HashFunctions.h */; settings = {ATTRIBUTES = (Private, ); }; };
65DFC93108EA173A00F7300B /* HashMap.h in Headers */ = {isa = PBXBuildFile; fileRef = 65DFC92B08EA173A00F7300B /* HashMap.h */; settings = {ATTRIBUTES = (Private, ); }; };
65DFC93208EA173A00F7300B /* HashSet.h in Headers */ = {isa = PBXBuildFile; fileRef = 65DFC92C08EA173A00F7300B /* HashSet.h */; settings = {ATTRIBUTES = (Private, ); }; };
65DFC93308EA173A00F7300B /* HashTable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 65DFC92D08EA173A00F7300B /* HashTable.cpp */; };
65DFC93408EA173A00F7300B /* HashTable.h in Headers */ = {isa = PBXBuildFile; fileRef = 65DFC92E08EA173A00F7300B /* HashTable.h */; settings = {ATTRIBUTES = (Private, ); }; };
65DFC93508EA173A00F7300B /* HashTraits.h in Headers */ = {isa = PBXBuildFile; fileRef = 65DFC92F08EA173A00F7300B /* HashTraits.h */; settings = {ATTRIBUTES = (Private, ); }; };
65E217BD08E7EECC0023E5F6 /* Assertions.h in Headers */ = {isa = PBXBuildFile; fileRef = 65E217B708E7EECC0023E5F6 /* Assertions.h */; settings = {ATTRIBUTES = (Private, ); }; };
65E217BE08E7EECC0023E5F6 /* Assertions.mm in Sources */ = {isa = PBXBuildFile; fileRef = 65E217B808E7EECC0023E5F6 /* Assertions.mm */; };
65E217BF08E7EECC0023E5F6 /* FastMalloc.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 65E217B908E7EECC0023E5F6 /* FastMalloc.cpp */; };
......@@ -111,7 +118,6 @@
932F5B830822A1C700736975 /* c_class.h in Headers */ = {isa = PBXBuildFile; fileRef = 5182A53B06012C3000CBD2F2 /* c_class.h */; };
932F5B840822A1C700736975 /* NP_jsobject.h in Headers */ = {isa = PBXBuildFile; fileRef = 517BE7F40610E39600221947 /* NP_jsobject.h */; settings = {ATTRIBUTES = (Private, ); }; };
932F5B850822A1C700736975 /* npruntime.h in Headers */ = {isa = PBXBuildFile; fileRef = 5199B1BE061B65BC0070C006 /* npruntime.h */; settings = {ATTRIBUTES = (Private, ); }; };
932F5B870822A1C700736975 /* interpreter_map.h in Headers */ = {isa = PBXBuildFile; fileRef = 65AB004906261CBA0076DE63 /* interpreter_map.h */; };
932F5B880822A1C700736975 /* protect.h in Headers */ = {isa = PBXBuildFile; fileRef = 65C02FBB0637462A003E7EE6 /* protect.h */; settings = {ATTRIBUTES = (Private, ); }; };
932F5B890822A1C700736975 /* protected_values.h in Headers */ = {isa = PBXBuildFile; fileRef = 650B68D90639033F009D42DE /* protected_values.h */; settings = {ATTRIBUTES = (Private, ); }; };
932F5B8A0822A1C700736975 /* WebScriptObject.h in Headers */ = {isa = PBXBuildFile; fileRef = 51863F6F065420E800E9E8DD /* WebScriptObject.h */; settings = {ATTRIBUTES = (Private, ); }; };
......@@ -172,7 +178,6 @@
932F5BC90822A1C700736975 /* c_utility.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5182A4FB06010F8200CBD2F2 /* c_utility.cpp */; };
932F5BCA0822A1C700736975 /* c_class.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5182A53A06012C3000CBD2F2 /* c_class.cpp */; };
932F5BCB0822A1C700736975 /* npruntime.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5199B1BD061B65BC0070C006 /* npruntime.cpp */; };
932F5BCC0822A1C700736975 /* interpreter_map.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 65AB004806261CBA0076DE63 /* interpreter_map.cpp */; };
932F5BCD0822A1C700736975 /* protected_values.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 650B68D80639033F009D42DE /* protected_values.cpp */; };
932F5BCE0822A1C700736975 /* WebScriptObject.mm in Sources */ = {isa = PBXBuildFile; fileRef = 51863FC406542D3100E9E8DD /* WebScriptObject.mm */; };
932F5BCF0822A1C700736975 /* jni_objc.mm in Sources */ = {isa = PBXBuildFile; fileRef = 517EF37306D695930007C1BA /* jni_objc.mm */; };
......@@ -269,7 +274,6 @@
A85D8233087B2822006A9172 /* c_class.h in Headers */ = {isa = PBXBuildFile; fileRef = 5182A53B06012C3000CBD2F2 /* c_class.h */; };
A85D8234087B2822006A9172 /* NP_jsobject.h in Headers */ = {isa = PBXBuildFile; fileRef = 517BE7F40610E39600221947 /* NP_jsobject.h */; settings = {ATTRIBUTES = (Private, ); }; };
A85D8235087B2822006A9172 /* npruntime.h in Headers */ = {isa = PBXBuildFile; fileRef = 5199B1BE061B65BC0070C006 /* npruntime.h */; settings = {ATTRIBUTES = (Private, ); }; };
A85D8236087B2822006A9172 /* interpreter_map.h in Headers */ = {isa = PBXBuildFile; fileRef = 65AB004906261CBA0076DE63 /* interpreter_map.h */; };
A85D8237087B2822006A9172 /* protect.h in Headers */ = {isa = PBXBuildFile; fileRef = 65C02FBB0637462A003E7EE6 /* protect.h */; settings = {ATTRIBUTES = (Private, ); }; };
A85D8238087B2822006A9172 /* protected_values.h in Headers */ = {isa = PBXBuildFile; fileRef = 650B68D90639033F009D42DE /* protected_values.h */; settings = {ATTRIBUTES = (Private, ); }; };
A85D8239087B2822006A9172 /* WebScriptObject.h in Headers */ = {isa = PBXBuildFile; fileRef = 51863F6F065420E800E9E8DD /* WebScriptObject.h */; settings = {ATTRIBUTES = (Private, ); }; };
......@@ -332,7 +336,6 @@
A85D8278087B2822006A9172 /* c_utility.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5182A4FB06010F8200CBD2F2 /* c_utility.cpp */; };
A85D8279087B2822006A9172 /* c_class.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5182A53A06012C3000CBD2F2 /* c_class.cpp */; };
A85D827A087B2822006A9172 /* npruntime.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5199B1BD061B65BC0070C006 /* npruntime.cpp */; };
A85D827B087B2822006A9172 /* interpreter_map.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 65AB004806261CBA0076DE63 /* interpreter_map.cpp */; };
A85D827C087B2822006A9172 /* protected_values.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 650B68D80639033F009D42DE /* protected_values.cpp */; };
A85D827D087B2822006A9172 /* WebScriptObject.mm in Sources */ = {isa = PBXBuildFile; fileRef = 51863FC406542D3100E9E8DD /* WebScriptObject.mm */; };
A85D827E087B2822006A9172 /* jni_objc.mm in Sources */ = {isa = PBXBuildFile; fileRef = 517EF37306D695930007C1BA /* jni_objc.mm */; };
......@@ -499,13 +502,18 @@
6541BD6F08E80A17002CBEE7 /* TCSpinLock.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = TCSpinLock.h; sourceTree = "<group>"; };
6541BD7008E80A17002CBEE7 /* TCSystemAlloc.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = TCSystemAlloc.cpp; sourceTree = "<group>"; };
6541BD7108E80A17002CBEE7 /* TCSystemAlloc.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = TCSystemAlloc.h; sourceTree = "<group>"; };
6557E8F708EA5D4D0049CDFC /* HashMapPtrSpec.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = HashMapPtrSpec.h; sourceTree = "<group>"; };
6560A4CF04B3B3E7008AE952 /* CoreFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreFoundation.framework; path = /System/Library/Frameworks/CoreFoundation.framework; sourceTree = "<absolute>"; };
6560A63D04B3B69F008AE952 /* CoreServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreServices.framework; path = /System/Library/Frameworks/CoreServices.framework; sourceTree = "<absolute>"; };
65621E6B089E859700760F35 /* property_slot.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = property_slot.cpp; sourceTree = "<group>"; };
65621E6C089E859700760F35 /* property_slot.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = property_slot.h; sourceTree = "<group>"; };
65AB004806261CBA0076DE63 /* interpreter_map.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = interpreter_map.cpp; sourceTree = "<group>"; };
65AB004906261CBA0076DE63 /* interpreter_map.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = interpreter_map.h; sourceTree = "<group>"; };
65C02FBB0637462A003E7EE6 /* protect.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = protect.h; sourceTree = "<group>"; };
65DFC92A08EA173A00F7300B /* HashFunctions.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = HashFunctions.h; sourceTree = "<group>"; };
65DFC92B08EA173A00F7300B /* HashMap.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = HashMap.h; sourceTree = "<group>"; };
65DFC92C08EA173A00F7300B /* HashSet.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = HashSet.h; sourceTree = "<group>"; };
65DFC92D08EA173A00F7300B /* HashTable.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = HashTable.cpp; sourceTree = "<group>"; };
65DFC92E08EA173A00F7300B /* HashTable.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = HashTable.h; sourceTree = "<group>"; };
65DFC92F08EA173A00F7300B /* HashTraits.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = HashTraits.h; sourceTree = "<group>"; };
65E217B708E7EECC0023E5F6 /* Assertions.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = Assertions.h; sourceTree = "<group>"; };
65E217B808E7EECC0023E5F6 /* Assertions.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = Assertions.mm; sourceTree = "<group>"; };
65E217B908E7EECC0023E5F6 /* FastMalloc.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = FastMalloc.cpp; sourceTree = "<group>"; };
......@@ -703,8 +711,6 @@
650B68D80639033F009D42DE /* protected_values.cpp */,
652C107E08DA7B1E0020887D /* protected_reference.h */,
650B68D90639033F009D42DE /* protected_values.h */,
65AB004806261CBA0076DE63 /* interpreter_map.cpp */,
65AB004906261CBA0076DE63 /* interpreter_map.h */,
F692A84E0255597D01FF60F7 /* array_object.h */,
F692A84D0255597D01FF60F7 /* array_object.cpp */,
F692A8500255597D01FF60F7 /* bool_object.cpp */,
......@@ -834,6 +840,13 @@
65162EF108E6A21C007556CD /* kxmlcore */ = {
isa = PBXGroup;
children = (
6557E8F708EA5D4D0049CDFC /* HashMapPtrSpec.h */,
65DFC92A08EA173A00F7300B /* HashFunctions.h */,
65DFC92B08EA173A00F7300B /* HashMap.h */,
65DFC92C08EA173A00F7300B /* HashSet.h */,
65DFC92D08EA173A00F7300B /* HashTable.cpp */,
65DFC92E08EA173A00F7300B /* HashTable.h */,
65DFC92F08EA173A00F7300B /* HashTraits.h */,
6541BD6E08E80A17002CBEE7 /* TCPageMap.h */,
6541BD6F08E80A17002CBEE7 /* TCSpinLock.h */,
6541BD7008E80A17002CBEE7 /* TCSystemAlloc.cpp */,
......@@ -982,7 +995,6 @@
932F5B830822A1C700736975 /* c_class.h in Headers */,
932F5B840822A1C700736975 /* NP_jsobject.h in Headers */,
932F5B850822A1C700736975 /* npruntime.h in Headers */,
932F5B870822A1C700736975 /* interpreter_map.h in Headers */,
932F5B880822A1C700736975 /* protect.h in Headers */,
932F5B890822A1C700736975 /* protected_values.h in Headers */,
932F5B8A0822A1C700736975 /* WebScriptObject.h in Headers */,
......@@ -1004,6 +1016,12 @@
6541BD7208E80A17002CBEE7 /* TCPageMap.h in Headers */,
6541BD7308E80A17002CBEE7 /* TCSpinLock.h in Headers */,
6541BD7508E80A17002CBEE7 /* TCSystemAlloc.h in Headers */,
65DFC93008EA173A00F7300B /* HashFunctions.h in Headers */,
65DFC93108EA173A00F7300B /* HashMap.h in Headers */,
65DFC93208EA173A00F7300B /* HashSet.h in Headers */,
65DFC93408EA173A00F7300B /* HashTable.h in Headers */,
65DFC93508EA173A00F7300B /* HashTraits.h in Headers */,
6557E8F808EA5D4D0049CDFC /* HashMapPtrSpec.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......@@ -1073,7 +1091,6 @@
A85D8233087B2822006A9172 /* c_class.h in Headers */,
A85D8234087B2822006A9172 /* NP_jsobject.h in Headers */,
A85D8235087B2822006A9172 /* npruntime.h in Headers */,
A85D8236087B2822006A9172 /* interpreter_map.h in Headers */,
A85D8237087B2822006A9172 /* protect.h in Headers */,
A85D8238087B2822006A9172 /* protected_values.h in Headers */,
A85D8239087B2822006A9172 /* WebScriptObject.h in Headers */,
......@@ -1635,7 +1652,6 @@
932F5BC90822A1C700736975 /* c_utility.cpp in Sources */,
932F5BCA0822A1C700736975 /* c_class.cpp in Sources */,
932F5BCB0822A1C700736975 /* npruntime.cpp in Sources */,
932F5BCC0822A1C700736975 /* interpreter_map.cpp in Sources */,
932F5BCD0822A1C700736975 /* protected_values.cpp in Sources */,
932F5BCE0822A1C700736975 /* WebScriptObject.mm in Sources */,
932F5BCF0822A1C700736975 /* jni_objc.mm in Sources */,
......@@ -1655,6 +1671,7 @@
65E217BE08E7EECC0023E5F6 /* Assertions.mm in Sources */,
65E217BF08E7EECC0023E5F6 /* FastMalloc.cpp in Sources */,
6541BD7408E80A17002CBEE7 /* TCSystemAlloc.cpp in Sources */,
65DFC93308EA173A00F7300B /* HashTable.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......@@ -1732,7 +1749,6 @@
A85D8278087B2822006A9172 /* c_utility.cpp in Sources */,
A85D8279087B2822006A9172 /* c_class.cpp in Sources */,
A85D827A087B2822006A9172 /* npruntime.cpp in Sources */,
A85D827B087B2822006A9172 /* interpreter_map.cpp in Sources */,
A85D827C087B2822006A9172 /* protected_values.cpp in Sources */,
A85D827D087B2822006A9172 /* WebScriptObject.mm in Sources */,
A85D827E087B2822006A9172 /* jni_objc.mm in Sources */,
......
......@@ -34,7 +34,6 @@
#include "error_object.h"
#include "function_object.h"
#include "internal.h"
#include "interpreter_map.h"
#include "lexer.h"
#include "math_object.h"
#include "nodes.h"
......@@ -45,6 +44,8 @@
#include "regexp_object.h"
#include "string_object.h"
#include <kxmlcore/HashMap.h>
#if WIN32
#include <float.h>
#define copysign(a, b) _copysign(a, b)
......@@ -442,6 +443,14 @@ void InterpreterImp::globalClear()
ConstantValues::clear();
}
typedef HashMap<ObjectImp *, InterpreterImp *, PointerHash<ObjectImp *> > InterpreterMap;
static inline InterpreterMap &interpreterMap()
{
static InterpreterMap *map = new InterpreterMap;
return *map;
}
InterpreterImp::InterpreterImp(Interpreter *interp, ObjectImp *glob)
: globExec(interp, 0)
, _context(0)
......@@ -462,7 +471,7 @@ InterpreterImp::InterpreterImp(Interpreter *interp, ObjectImp *glob)
globalInit();
}
InterpreterMap::setInterpreterForGlobalObject(this, glob);
interpreterMap().set(glob, this);
global = glob;
dbg = 0;
......@@ -630,7 +639,7 @@ void InterpreterImp::clear()
s_hook = 0L;
globalClear();
}
InterpreterMap::removeInterpreterForGlobalObject(global);
interpreterMap().remove(global);
}
void InterpreterImp::mark()
......@@ -807,7 +816,7 @@ void InterpreterImp::restoreBuiltins (const SavedBuiltins &builtins)
InterpreterImp *InterpreterImp::interpreterWithGlobalObject(ObjectImp *global)
{
return InterpreterMap::getInterpreterForGlobalObject(global);
return interpreterMap().get(global);
}
......
/*
* This file is part of the KDE libraries
* Copyright (C) 2004 Apple Computer, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
*/
#include "interpreter_map.h"
#include "pointer_hash.h"
#include <stdlib.h>
namespace KJS {
const int _minTableSize = 64;
InterpreterMap::KeyValue *InterpreterMap::_table;
int InterpreterMap::_tableSize;
int InterpreterMap::_tableSizeMask;
int InterpreterMap::_keyCount;
InterpreterImp * InterpreterMap::getInterpreterForGlobalObject(ObjectImp *global)
{
if (!_table)
expand();
unsigned hash = computeHash(global);
int i = hash & _tableSizeMask;
#if DUMP_STATISTICS
++numProbes;
numCollisions += _table[i].key && _table[i].key != global;
#endif
while (ObjectImp *key = _table[i].key) {
if (key == global) {
return _table[i].value;
}
i = (i + 1) & _tableSizeMask;
}
return 0;
}
void InterpreterMap::setInterpreterForGlobalObject(InterpreterImp *interpreter, ObjectImp *global)
{
if (!_table)
expand();
unsigned hash = computeHash(global);
int i = hash & _tableSizeMask;
#if DUMP_STATISTICS
++numProbes;
numCollisions += _table[i].key && _table[i].key != global;
#endif
while (ObjectImp *key = _table[i].key) {
if (key == global) {
_table[i].value = interpreter;
return;
}
i = (i + 1) & _tableSizeMask;
}
_table[i].key = global;
_table[i].value = interpreter;
++_keyCount;
if (_keyCount * 2 >= _tableSize)
expand();
}
inline void InterpreterMap::insert(InterpreterImp *interpreter, ObjectImp *global)
{
unsigned hash = computeHash(global);
int i = hash & _tableSizeMask;
#if DUMP_STATISTICS
++numProbes;
numCollisions += _table[i] != 0;
#endif
while (_table[i].key)
i = (i + 1) & _tableSizeMask;
_table[i].key = global;
_table[i].value = interpreter;
}
void InterpreterMap::removeInterpreterForGlobalObject(ObjectImp *global)
{
unsigned hash = computeHash(global);
ObjectImp *key;
int i = hash & _tableSizeMask;
#if DUMP_STATISTICS
++numProbes;
numCollisions += _table[i].key && _table[i].key == global;
#endif
while ((key = _table[i].key)) {
if (key == global)
break;
i = (i + 1) & _tableSizeMask;
}
if (!key)
return;
_table[i].key = 0;
_table[i].value = 0;
--_keyCount;
if (_keyCount * 6 < _tableSize && _tableSize > _minTableSize) {
shrink();
return;
}
// Reinsert all the items to the right in the same cluster.
while (1) {
i = (i + 1) & _tableSizeMask;
key = _table[i].key;
InterpreterImp *value = _table[i].value;
if (!key)
break;
_table[i].key = 0;
_table[i].value = 0;
insert(value,key);
}
}
void InterpreterMap::expand()
{
rehash(_tableSize == 0 ? _minTableSize : _tableSize * 2);
}
void InterpreterMap::shrink()
{
rehash(_tableSize / 2);
}
void InterpreterMap::rehash(int newTableSize)
{
int oldTableSize = _tableSize;
KeyValue *oldTable = _table;
_tableSize = newTableSize;
_tableSizeMask = newTableSize - 1;
_table = (KeyValue *)calloc(newTableSize, sizeof(KeyValue));
for (int i = 0; i != oldTableSize; ++i)
if (oldTable[i].key)
insert(oldTable[i].value, oldTable[i].key);
free(oldTable);
}
unsigned InterpreterMap::computeHash(ObjectImp *pointer)
{
return pointerHash(pointer);
}
} // namespace
// -*- c-basic-offset: 2 -*-
/*
* This file is part of the KDE libraries
* Copyright (C) 2004 Apple Computer, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
*/
#ifndef _KJS_INTERPRETER_MAP_H_
#define _KJS_INTERPRETER_MAP_H_
namespace KJS {
class ObjectImp;
class InterpreterImp;
class InterpreterMap {
struct KeyValue {
ObjectImp *key;
InterpreterImp *value;
};
public:
static InterpreterImp * getInterpreterForGlobalObject(ObjectImp *global);
static void setInterpreterForGlobalObject(InterpreterImp *interpreter, ObjectImp *global);
static void removeInterpreterForGlobalObject(ObjectImp *global);
private:
static void insert(InterpreterImp *interpreter, ObjectImp *global);
static void expand();
static void shrink();
static void rehash(int newTableSize);
static unsigned computeHash(ObjectImp *pointer);
static KeyValue * InterpreterMap::_table;
static int InterpreterMap::_tableSize;
static int InterpreterMap::_tableSizeMask;
static int InterpreterMap::_keyCount;
};
} // namespace
#endif // _KJS_INTERPRETER_MAP_H_
// -*- mode: c++; c-basic-offset: 4 -*-
/*
* This file is part of the KDE libraries
* Copyright (C) 2005 Apple Computer, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
*/
#ifndef KXMLCORE_HASH_FUNCTIONS_H
#define KXMLCORE_HASH_FUNCTIONS_H
namespace KXMLCore {