Changeset 36032 in webkit for trunk/JavaScriptCore/kjs
- Timestamp:
- Sep 2, 2008, 7:31:45 PM (17 years ago)
- Location:
- trunk/JavaScriptCore/kjs
- Files:
-
- 2 added
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/kjs/JSActivation.cpp
r36016 r36032 80 80 // activation object getter properties or a prototype. 81 81 ASSERT(!hasGetterSetterProperties()); 82 ASSERT(prototype() == jsNull());82 ASSERT(prototype()->isNull()); 83 83 return false; 84 84 } -
trunk/JavaScriptCore/kjs/JSArray.cpp
r36016 r36032 126 126 #endif 127 127 128 JSArray::JSArray( DummyConstructTag)129 : JSObject( StructureID::create(jsNull()))128 JSArray::JSArray(PassRefPtr<StructureID> structureID) 129 : JSObject(structureID) 130 130 { 131 131 unsigned initialCapacity = 0; -
trunk/JavaScriptCore/kjs/JSArray.h
r36016 r36032 39 39 class JSArray : public JSObject { 40 40 public: 41 enum DummyConstructTag { DummyConstruct }; 42 JSArray(DummyConstructTag); 41 JSArray(PassRefPtr<StructureID>); 43 42 JSArray(JSObject* prototype, unsigned initialLength); 44 43 JSArray(ExecState* exec, JSObject* prototype, const ArgList& initialValues); -
trunk/JavaScriptCore/kjs/JSGlobalData.cpp
r36016 r36032 77 77 , stringTable(&KJS::stringTable) 78 78 #endif 79 , stringStructureID(StructureID::create(jsNull()))80 , numberStructureID(StructureID::create(jsNull()))81 79 , nullProtoStructureID(StructureID::create(jsNull())) 82 80 , identifierTable(createIdentifierTable()) -
trunk/JavaScriptCore/kjs/JSGlobalData.h
r36016 r36032 74 74 const HashTable* stringTable; 75 75 76 RefPtr<StructureID> stringStructureID;77 RefPtr<StructureID> numberStructureID;78 76 RefPtr<StructureID> nullProtoStructureID; 79 77 -
trunk/JavaScriptCore/kjs/JSImmediate.cpp
r36016 r36032 41 41 return constructBooleanFromImmediateBoolean(exec, const_cast<JSValue*>(v)); 42 42 43 JSNotAnObjectErrorStub* exception = createNotAnObjectErrorStub(exec, v == jsNull());43 JSNotAnObjectErrorStub* exception = createNotAnObjectErrorStub(exec, v->isNull()); 44 44 exec->setException(exception); 45 45 return new (exec) JSNotAnObject(exec, exception); … … 54 54 return exec->lexicalGlobalObject()->booleanPrototype(); 55 55 56 JSNotAnObjectErrorStub* exception = createNotAnObjectErrorStub(exec, v == jsNull());56 JSNotAnObjectErrorStub* exception = createNotAnObjectErrorStub(exec, v->isNull()); 57 57 exec->setException(exception); 58 58 return new (exec) JSNotAnObject(exec, exception); … … 68 68 if (v == jsBoolean(true)) 69 69 return "true"; 70 if (v == jsNull())70 if (v->isNull()) 71 71 return "null"; 72 72 ASSERT(v == jsUndefined()); -
trunk/JavaScriptCore/kjs/JSObject.cpp
r36016 r36032 39 39 #include <wtf/Assertions.h> 40 40 41 #define JAVASCRIPT_MARK_TRACING 0 41 #define JSOBJECT_MARK_TRACING 0 42 43 #if JSOBJECT_MARK_TRACING 44 45 #define JSOBJECT_MARK_BEGIN() \ 46 static int markStackDepth = 0; \ 47 for (int i = 0; i < markStackDepth; i++) \ 48 putchar('-'); \ 49 printf("%s (%p)\n", className().UTF8String().c_str(), this); \ 50 markStackDepth++; \ 51 52 #define JSOBJECT_MARK_END() \ 53 markStackDepth--; 54 55 #else // JSOBJECT_MARK_TRACING 56 57 #define JSOBJECT_MARK_BEGIN() 58 #define JSOBJECT_MARK_END() 59 60 #endif // JSOBJECT_MARK_TRACING 42 61 43 62 namespace KJS { … … 47 66 void JSObject::mark() 48 67 { 68 JSOBJECT_MARK_BEGIN(); 69 49 70 JSCell::mark(); 50 51 #if JAVASCRIPT_MARK_TRACING52 static int markStackDepth = 0;53 markStackDepth++;54 for (int i = 0; i < markStackDepth; i++)55 putchar('-');56 printf("%s (%p)\n", className().UTF8String().c_str(), this);57 #endif58 59 71 m_structureID->mark(); 60 72 m_propertyMap.mark(); 61 73 62 #if JAVASCRIPT_MARK_TRACING 63 markStackDepth--; 64 #endif 74 JSOBJECT_MARK_END(); 65 75 } 66 76 … … 93 103 94 104 // Setting __proto__ to a non-object, non-null value is silently ignored to match Mozilla. 95 if (!proto && value != jsNull())105 if (!proto && !value->isNull()) 96 106 return; 97 107 … … 112 122 for (JSObject* obj = this; !obj->m_propertyMap.hasGetterSetterProperties(); obj = static_cast<JSObject*>(prototype)) { 113 123 prototype = obj->prototype(); 114 if (prototype == jsNull()) {124 if (prototype->isNull()) { 115 125 putDirect(propertyName, value, 0, true, slot); 116 126 return; … … 145 155 146 156 prototype = obj->prototype(); 147 if (prototype == jsNull())157 if (prototype->isNull()) 148 158 break; 149 159 } … … 478 488 m_propertyMap.remove(propertyName); 479 489 if (!m_structureID->isDictionary()) { 480 RefPtr<StructureID> structureID = StructureID:: dictionaryTransition(m_structureID);490 RefPtr<StructureID> structureID = StructureID::toDictionaryTransition(m_structureID); 481 491 setStructureID(structureID.release()); 482 492 } … … 496 506 } 497 507 498 PassRefPtr<StructureID>JSObject::createInheritorID()508 StructureID* JSObject::createInheritorID() 499 509 { 500 510 m_inheritorID = StructureID::create(this); 501 return m_inheritorID ;511 return m_inheritorID.get(); 502 512 } 503 513 -
trunk/JavaScriptCore/kjs/JSObject.h
r36016 r36032 31 31 #include "PropertyMap.h" 32 32 #include "PropertySlot.h" 33 #include "PutPropertySlot.h" 33 34 #include "ScopeChain.h" 34 35 #include "StructureID.h" … … 53 54 54 55 class JSObject : public JSCell { 56 friend class BatchedTransitionOptimizer; 57 55 58 public: 56 59 JSObject(PassRefPtr<StructureID>); … … 65 68 void setPrototype(JSValue* prototype); 66 69 67 PassRefPtr<StructureID>inheritorID();70 StructureID* inheritorID(); 68 71 69 72 virtual UString className() const; … … 153 156 const HashEntry* findPropertyHashEntry(ExecState*, const Identifier& propertyName) const; 154 157 void setStructureID(PassRefPtr<StructureID>); 155 PassRefPtr<StructureID>createInheritorID();158 StructureID* createInheritorID(); 156 159 157 160 PropertyMap m_propertyMap; … … 162 165 163 166 inline JSObject::JSObject(JSObject* prototype) 164 : JSCell(prototype->inheritorID() .releaseRef()) // ~JSObject balances this ref()167 : JSCell(prototype->inheritorID()) 165 168 { 166 169 ASSERT(m_structureID); 167 170 ASSERT(this->prototype()); 168 ASSERT(this->prototype() == jsNull() || Heap::heap(this) == Heap::heap(this->prototype())); 171 ASSERT(this->prototype()->isNull() || Heap::heap(this) == Heap::heap(this->prototype())); 172 m_structureID->ref(); // ~JSObject balances this ref() 169 173 } 170 174 … … 199 203 } 200 204 201 inline PassRefPtr<StructureID>JSObject::inheritorID()205 inline StructureID* JSObject::inheritorID() 202 206 { 203 207 if (m_inheritorID) -
trunk/JavaScriptCore/kjs/JSString.cpp
r36006 r36032 91 91 slot.setBase(this); 92 92 JSObject* object; 93 for (JSValue* prototype = exec->lexicalGlobalObject()->stringPrototype(); prototype != jsNull(); prototype = object->prototype()) {93 for (JSValue* prototype = exec->lexicalGlobalObject()->stringPrototype(); !prototype->isNull(); prototype = object->prototype()) { 94 94 ASSERT(prototype->isObject()); 95 95 object = static_cast<JSObject*>(prototype); -
trunk/JavaScriptCore/kjs/PropertyMap.cpp
r36018 r36032 332 332 m_singleEntryAttributes = static_cast<short>(attributes); 333 333 checkConsistency(); 334 slot.setNewProperty(slotBase, KJS_INVALID_OFFSET);334 slot.setNewProperty(slotBase, WTF::notFound); 335 335 return; 336 336 } -
trunk/JavaScriptCore/kjs/PropertyMap.h
r36016 r36032 24 24 #include "PropertySlot.h" 25 25 #include "identifier.h" 26 #include <wtf/NotFound.h> 26 27 27 28 namespace KJS { … … 105 106 } 106 107 107 size_t offsetForLocation(JSValue** location) { return m_usingTable ? offsetForTableLocation(location) : KJS_INVALID_OFFSET; }108 size_t offsetForLocation(JSValue** location) { return m_usingTable ? offsetForTableLocation(location) : WTF::notFound; } 108 109 109 110 void mark() const; -
trunk/JavaScriptCore/kjs/PropertySlot.h
r36016 r36032 26 26 #include "identifier.h" 27 27 #include <wtf/Assertions.h> 28 #include <wtf/NotFound.h> 28 29 29 30 namespace KJS { … … 35 36 #define KJS_VALUE_SLOT_MARKER 0 36 37 #define KJS_REGISTER_SLOT_MARKER reinterpret_cast<GetValueFunc>(1) 37 #define KJS_INVALID_OFFSET static_cast<size_t>(-1)38 38 39 39 class PropertySlot { 40 40 public: 41 41 PropertySlot() 42 : m_offset( KJS_INVALID_OFFSET)42 : m_offset(WTF::notFound) 43 43 { 44 44 clearBase(); … … 48 48 explicit PropertySlot(JSValue* base) 49 49 : m_slotBase(base) 50 , m_offset( KJS_INVALID_OFFSET)50 , m_offset(WTF::notFound) 51 51 { 52 52 clearValue(); … … 73 73 } 74 74 75 bool isCacheable() const { return m_offset != KJS_INVALID_OFFSET; }75 bool isCacheable() const { return m_offset != WTF::notFound; } 76 76 size_t cachedOffset() const 77 77 { … … 220 220 size_t m_offset; 221 221 }; 222 223 class PutPropertySlot {224 public:225 enum SlotType {226 Invalid,227 ExistingProperty,228 NewProperty,229 };230 231 PutPropertySlot()232 : m_type(Invalid)233 , m_base(0)234 {235 }236 237 void setExistingProperty(JSObject* base, size_t offset)238 {239 m_type = ExistingProperty;240 m_base = base;241 m_offset = offset;242 }243 244 void setNewProperty(JSObject* base, size_t offset)245 {246 m_type = NewProperty;247 m_base = base;248 m_offset = offset;249 }250 251 SlotType type() const { return m_type; }252 JSObject* slotBase() const { return m_base; }253 254 bool isCacheable() const { return m_type != Invalid; }255 size_t cachedOffset() const {256 ASSERT(isCacheable());257 return m_offset;258 }259 260 private:261 SlotType m_type;262 JSObject* m_base;263 size_t m_offset;264 };265 222 266 223 } // namespace KJS -
trunk/JavaScriptCore/kjs/StructureID.cpp
r36018 r36032 29 29 30 30 #include "identifier.h" 31 #include "JS Cell.h"31 #include "JSObject.h" 32 32 #include <wtf/RefPtr.h> 33 33 … … 54 54 55 55 if (structureID->m_transitionCount > s_maxTransitionLength) 56 return dictionaryTransition(structureID);56 return toDictionaryTransition(structureID); 57 57 58 58 RefPtr<StructureID> transition = create(structureID->m_prototype); … … 66 66 } 67 67 68 PassRefPtr<StructureID> StructureID:: dictionaryTransition(StructureID* structureID)68 PassRefPtr<StructureID> StructureID::toDictionaryTransition(StructureID* structureID) 69 69 { 70 70 ASSERT(!structureID->m_isDictionary); … … 72 72 RefPtr<StructureID> transition = create(structureID->m_prototype); 73 73 transition->m_isDictionary = true; 74 transition->m_transitionCount = structureID->m_transitionCount + 1;75 74 return transition.release(); 75 } 76 77 PassRefPtr<StructureID> StructureID::fromDictionaryTransition(StructureID* structureID) 78 { 79 ASSERT(structureID->m_isDictionary); 80 81 // Since dictionary StructureIDs are not shared, and no opcodes specialize 82 // for them, we don't need to allocate a new StructureID when transitioning 83 // to non-dictionary status. 84 structureID->m_isDictionary = false; 85 return structureID; 76 86 } 77 87 … … 99 109 100 110 StructureIDChain::StructureIDChain(StructureID* structureID) 101 : m_size(0)102 111 { 112 size_t size = 0; 113 103 114 StructureID* tmp = structureID; 104 while ( tmp->prototype() != jsNull()) {105 ++ m_size;115 while (!tmp->prototype()->isNull()) { 116 ++size; 106 117 tmp = static_cast<JSCell*>(tmp->prototype())->structureID(); 107 118 } 108 119 109 m_vector.set(new RefPtr<StructureID>[ m_size]);120 m_vector.set(new RefPtr<StructureID>[size]); 110 121 111 for (size_t i = 0; i < m_size; ++i) {122 for (size_t i = 0; i < size; ++i) { 112 123 m_vector[i] = structureID; 113 structureID = static_cast<JS Cell*>(structureID->prototype())->structureID();124 structureID = static_cast<JSObject*>(structureID->prototype())->structureID(); 114 125 } 115 126 } -
trunk/JavaScriptCore/kjs/StructureID.h
r36016 r36032 49 49 static PassRefPtr<StructureID> addPropertyTransition(StructureID*, const Identifier& name); 50 50 static PassRefPtr<StructureID> getterSetterTransition(StructureID*); 51 static PassRefPtr<StructureID> dictionaryTransition(StructureID*); 51 static PassRefPtr<StructureID> toDictionaryTransition(StructureID*); 52 static PassRefPtr<StructureID> fromDictionaryTransition(StructureID*); 52 53 53 54 ~StructureID(); … … 67 68 68 69 private: 69 typedef HashMap<RefPtr<UString::Rep>, StructureID*, WTF::IdentifierRepHash, HashTraits<RefPtr<UString::Rep> > > TransitionTable;70 typedef HashMap<RefPtr<UString::Rep>, StructureID*, IdentifierRepHash, HashTraits<RefPtr<UString::Rep> > > TransitionTable; 70 71 71 72 StructureID(JSValue* prototype); … … 94 95 StructureIDChain(StructureID* structureID); 95 96 96 size_t m_size;97 97 OwnArrayPtr<RefPtr<StructureID> > m_vector; 98 98 }; -
trunk/JavaScriptCore/kjs/SymbolTable.h
r36016 r36032 119 119 }; 120 120 121 typedef HashMap<RefPtr<UString::Rep>, SymbolTableEntry, WTF::IdentifierRepHash, HashTraits<RefPtr<UString::Rep> >, SymbolTableIndexHashTraits> SymbolTable;121 typedef HashMap<RefPtr<UString::Rep>, SymbolTableEntry, IdentifierRepHash, HashTraits<RefPtr<UString::Rep> >, SymbolTableIndexHashTraits> SymbolTable; 122 122 123 123 } // namespace KJS -
trunk/JavaScriptCore/kjs/ustring.h
r36016 r36032 337 337 } 338 338 339 struct IdentifierRepHash : PtrHash<RefPtr<KJS::UString::Rep> > { 340 static unsigned hash(const RefPtr<KJS::UString::Rep>& key) { return key->computedHash(); } 341 static unsigned hash(KJS::UString::Rep* key) { return key->computedHash(); } 342 }; 343 339 344 } // namespace KJS 340 345 … … 370 375 }; 371 376 372 struct IdentifierRepHash : PtrHash<RefPtr<KJS::UString::Rep> > {373 static unsigned hash(const RefPtr<KJS::UString::Rep>& key) { return key->computedHash(); }374 static unsigned hash(KJS::UString::Rep* key) { return key->computedHash(); }375 };376 377 377 } // namespace WTF 378 378
Note:
See TracChangeset
for help on using the changeset viewer.