Commit 8059db04 authored by weinig@apple.com's avatar weinig@apple.com
Browse files

2008-10-29 Sam Weinig <sam@webkit.org>

        Reviewed by Geoffrey Garen.

        Rename and move the StructureID transition table to its own file.

        * GNUmakefile.am:
        * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj:
        * JavaScriptCore.xcodeproj/project.pbxproj:
        * runtime/StructureID.cpp:
        (JSC::StructureID::addPropertyTransition):
        * runtime/StructureID.h:
        (JSC::StructureID::):
        * runtime/StructureIDTransitionTable.h: Copied from runtime/StructureID.h.
        (JSC::StructureIDTransitionTableHash::hash):
        (JSC::StructureIDTransitionTableHash::equal):



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@37985 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent e2b89383
2008-10-29 Sam Weinig <sam@webkit.org>
Reviewed by Geoffrey Garen.
Rename and move the StructureID transition table to its own file.
* GNUmakefile.am:
* JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj:
* JavaScriptCore.xcodeproj/project.pbxproj:
* runtime/StructureID.cpp:
(JSC::StructureID::addPropertyTransition):
* runtime/StructureID.h:
(JSC::StructureID::):
* runtime/StructureIDTransitionTable.h: Copied from runtime/StructureID.h.
(JSC::StructureIDTransitionTableHash::hash):
(JSC::StructureIDTransitionTableHash::equal):
2008-10-29 Sam Weinig <sam@webkit.org>
Reviewed by Cameron Zwarich.
......
......@@ -230,6 +230,7 @@ javascriptcore_sources += \
JavaScriptCore/runtime/StringPrototype.h \
JavaScriptCore/runtime/StructureID.cpp \
JavaScriptCore/runtime/StructureID.h \
JavaScriptCore/runtime/StructureIDTransitionTable.h \
JavaScriptCore/wrec/CharacterClassConstructor.cpp \
JavaScriptCore/wrec/CharacterClassConstructor.h \
JavaScriptCore/wrec/WREC.cpp \
......
......@@ -880,6 +880,10 @@
RelativePath="..\..\runtime\StructureID.h"
>
</File>
<File
RelativePath="..\..\runtime\StructureIDTransitionTable.h"
>
</File>
<File
RelativePath="..\..\kjs\SymbolTable.h"
>
......
......@@ -282,6 +282,7 @@
BC6AAAE50E1F426500AD87D8 /* ClassInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = BC6AAAE40E1F426500AD87D8 /* ClassInfo.h */; settings = {ATTRIBUTES = (Private, ); }; };
BC756FC90E2031B200DE7D12 /* JSGlobalObjectFunctions.h in Headers */ = {isa = PBXBuildFile; fileRef = BC756FC70E2031B200DE7D12 /* JSGlobalObjectFunctions.h */; };
BC7F8FB90E19D1C3008632C0 /* JSNumberCell.h in Headers */ = {isa = PBXBuildFile; fileRef = BC7F8FB80E19D1C3008632C0 /* JSNumberCell.h */; settings = {ATTRIBUTES = (Private, ); }; };
BC9041480EB9250900FE26FA /* StructureIDTransitionTable.h in Headers */ = {isa = PBXBuildFile; fileRef = BC9041470EB9250900FE26FA /* StructureIDTransitionTable.h */; settings = {ATTRIBUTES = (Private, ); }; };
BCD202C20E1706A7002C7E82 /* RegExpConstructor.h in Headers */ = {isa = PBXBuildFile; fileRef = BCD202BE0E1706A7002C7E82 /* RegExpConstructor.h */; };
BCD202C40E1706A7002C7E82 /* RegExpPrototype.h in Headers */ = {isa = PBXBuildFile; fileRef = BCD202C00E1706A7002C7E82 /* RegExpPrototype.h */; };
BCD202D60E170708002C7E82 /* RegExpConstructor.lut.h in Headers */ = {isa = PBXBuildFile; fileRef = BCD202D50E170708002C7E82 /* RegExpConstructor.lut.h */; };
......@@ -654,6 +655,7 @@
BC7F8FB80E19D1C3008632C0 /* JSNumberCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSNumberCell.h; sourceTree = "<group>"; };
BC7F8FBA0E19D1EF008632C0 /* JSCell.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSCell.cpp; sourceTree = "<group>"; };
BC8F3CCF0DAF17BA00577A80 /* ConstructData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ConstructData.h; sourceTree = "<group>"; };
BC9041470EB9250900FE26FA /* StructureIDTransitionTable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StructureIDTransitionTable.h; sourceTree = "<group>"; };
BC9BB95B0E19680600DF8855 /* InternalFunction.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InternalFunction.cpp; sourceTree = "<group>"; };
BCA62DFE0E2826230004F30D /* CallData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CallData.cpp; sourceTree = "<group>"; };
BCA62DFF0E2826310004F30D /* ConstructData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ConstructData.cpp; sourceTree = "<group>"; };
......@@ -1261,6 +1263,7 @@
BC18C3C60E16EE3300B34460 /* StringPrototype.h */,
BCDE3AB00E6C82CF001453A7 /* StructureID.cpp */,
BCDE3AB10E6C82CF001453A7 /* StructureID.h */,
BC9041470EB9250900FE26FA /* StructureIDTransitionTable.h */,
);
path = runtime;
sourceTree = "<group>";
......@@ -1547,6 +1550,7 @@
140D17D70E8AD4A9000CD17D /* JSBasePrivate.h in Headers */,
869EBCB70E8C6D4A008722CC /* ResultType.h in Headers */,
14F3488F0E95EF8A003648BC /* CollectorHeapIterator.h in Headers */,
BC9041480EB9250900FE26FA /* StructureIDTransitionTable.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......
......@@ -285,7 +285,7 @@ PassRefPtr<StructureID> StructureID::addPropertyTransition(StructureID* structur
StructureID* existingTransition = structureID->m_transitions.singleTransition;
structureID->m_usingSingleTransitionSlot = false;
TransitionTable* transitionTable = new TransitionTable;
StructureIDTransitionTable* transitionTable = new StructureIDTransitionTable;
structureID->m_transitions.table = transitionTable;
transitionTable->add(make_pair(existingTransition->m_nameInPrevious, existingTransition->m_attributesInPrevious), existingTransition);
}
......
......@@ -30,6 +30,7 @@
#include "JSType.h"
#include "JSValue.h"
#include "PropertyMap.h"
#include "StructureIDTransitionTable.h"
#include "TypeInfo.h"
#include "ustring.h"
#include <wtf/HashFunctions.h>
......@@ -46,35 +47,6 @@ namespace JSC {
class PropertyNameArrayData;
class StructureIDChain;
struct TransitionTableHash {
typedef std::pair<RefPtr<UString::Rep>, unsigned> TransitionTableKey;
static unsigned hash(const TransitionTableKey& p)
{
return p.first->computedHash();
}
static bool equal(const TransitionTableKey& a, const TransitionTableKey& b)
{
return a == b;
}
static const bool safeToCompareToEmptyOrDeleted = true;
};
struct TransitionTableHashTraits {
typedef WTF::HashTraits<RefPtr<UString::Rep> > FirstTraits;
typedef WTF::GenericHashTraits<unsigned> SecondTraits;
typedef std::pair<FirstTraits::TraitType, SecondTraits::TraitType> TraitType;
static const bool emptyValueIsZero = FirstTraits::emptyValueIsZero && SecondTraits::emptyValueIsZero;
static TraitType emptyValue() { return std::make_pair(FirstTraits::emptyValue(), SecondTraits::emptyValue()); }
static const bool needsDestruction = FirstTraits::needsDestruction || SecondTraits::needsDestruction;
static void constructDeletedValue(TraitType& slot) { FirstTraits::constructDeletedValue(slot.first); }
static bool isDeletedValue(const TraitType& value) { return FirstTraits::isDeletedValue(value.first); }
};
class StructureID : public RefCounted<StructureID> {
public:
friend class CTI;
......@@ -140,9 +112,6 @@ namespace JSC {
void setHasGetterSetterProperties(bool hasGetterSetterProperties) { m_hasGetterSetterProperties = hasGetterSetterProperties; }
private:
typedef std::pair<RefPtr<UString::Rep>, unsigned> TransitionTableKey;
typedef HashMap<TransitionTableKey, StructureID*, TransitionTableHash, TransitionTableHashTraits> TransitionTable;
StructureID(JSValue* prototype, const TypeInfo&);
static const size_t s_maxTransitionLength = 64;
......@@ -158,7 +127,7 @@ namespace JSC {
size_t m_transitionCount;
union {
StructureID* singleTransition;
TransitionTable* table;
StructureIDTransitionTable* table;
} m_transitions;
RefPtr<PropertyNameArrayData> m_cachedPropertyNameArrayData;
......
/*
* Copyright (C) 2008 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef StructureIDTransitionTable_h
#define StructureIDTransitionTable_h
#include "ustring.h"
#include <wtf/HashFunctions.h>
#include <wtf/HashMap.h>
#include <wtf/HashTraits.h>
#include <wtf/RefPtr.h>
namespace JSC {
class StructureID;
struct StructureIDTransitionTableHash {
typedef std::pair<RefPtr<UString::Rep>, unsigned> Key;
static unsigned hash(const Key& p)
{
return p.first->computedHash();
}
static bool equal(const Key& a, const Key& b)
{
return a == b;
}
static const bool safeToCompareToEmptyOrDeleted = true;
};
struct StructureIDTransitionTableHashTraits {
typedef WTF::HashTraits<RefPtr<UString::Rep> > FirstTraits;
typedef WTF::GenericHashTraits<unsigned> SecondTraits;
typedef std::pair<FirstTraits::TraitType, SecondTraits::TraitType> TraitType;
static const bool emptyValueIsZero = FirstTraits::emptyValueIsZero && SecondTraits::emptyValueIsZero;
static TraitType emptyValue() { return std::make_pair(FirstTraits::emptyValue(), SecondTraits::emptyValue()); }
static const bool needsDestruction = FirstTraits::needsDestruction || SecondTraits::needsDestruction;
static void constructDeletedValue(TraitType& slot) { FirstTraits::constructDeletedValue(slot.first); }
static bool isDeletedValue(const TraitType& value) { return FirstTraits::isDeletedValue(value.first); }
};
typedef HashMap<StructureIDTransitionTableHash::Key, StructureID*, StructureIDTransitionTableHash, StructureIDTransitionTableHashTraits> StructureIDTransitionTable;
} // namespace JSC
#endif // StructureIDTransitionTable_h
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment