Changeset 32587 in webkit for trunk/JavaScriptCore/kjs
- Timestamp:
- Apr 25, 2008, 7:02:31 PM (17 years ago)
- Location:
- trunk/JavaScriptCore/kjs
- Files:
-
- 1 deleted
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/kjs/JSGlobalObject.cpp
r32495 r32587 32 32 33 33 #include "Activation.h" 34 #include "SavedBuiltins.h"35 34 #include "array_object.h" 36 35 #include "bool_object.h" … … 412 411 } 413 412 414 void JSGlobalObject::saveBuiltins(SavedBuiltins& builtins) const415 {416 if (!builtins._internal)417 builtins._internal = new SavedBuiltinsInternal;418 419 builtins._internal->objectConstructor = d()->objectConstructor;420 builtins._internal->functionConstructor = d()->functionConstructor;421 builtins._internal->arrayConstructor = d()->arrayConstructor;422 builtins._internal->booleanConstructor = d()->booleanConstructor;423 builtins._internal->stringConstructor = d()->stringConstructor;424 builtins._internal->numberConstructor = d()->numberConstructor;425 builtins._internal->dateConstructor = d()->dateConstructor;426 builtins._internal->regExpConstructor = d()->regExpConstructor;427 builtins._internal->errorConstructor = d()->errorConstructor;428 builtins._internal->evalErrorConstructor = d()->evalErrorConstructor;429 builtins._internal->rangeErrorConstructor = d()->rangeErrorConstructor;430 builtins._internal->referenceErrorConstructor = d()->referenceErrorConstructor;431 builtins._internal->syntaxErrorConstructor = d()->syntaxErrorConstructor;432 builtins._internal->typeErrorConstructor = d()->typeErrorConstructor;433 builtins._internal->URIErrorConstructor = d()->URIErrorConstructor;434 435 builtins._internal->evalFunction = d()->evalFunction;436 437 builtins._internal->objectPrototype = d()->objectPrototype;438 builtins._internal->functionPrototype = d()->functionPrototype;439 builtins._internal->arrayPrototype = d()->arrayPrototype;440 builtins._internal->booleanPrototype = d()->booleanPrototype;441 builtins._internal->stringPrototype = d()->stringPrototype;442 builtins._internal->numberPrototype = d()->numberPrototype;443 builtins._internal->datePrototype = d()->datePrototype;444 builtins._internal->regExpPrototype = d()->regExpPrototype;445 builtins._internal->errorPrototype = d()->errorPrototype;446 builtins._internal->evalErrorPrototype = d()->evalErrorPrototype;447 builtins._internal->rangeErrorPrototype = d()->rangeErrorPrototype;448 builtins._internal->referenceErrorPrototype = d()->referenceErrorPrototype;449 builtins._internal->syntaxErrorPrototype = d()->syntaxErrorPrototype;450 builtins._internal->typeErrorPrototype = d()->typeErrorPrototype;451 builtins._internal->URIErrorPrototype = d()->URIErrorPrototype;452 }453 454 void JSGlobalObject::restoreBuiltins(const SavedBuiltins& builtins)455 {456 if (!builtins._internal)457 return;458 459 d()->objectConstructor = builtins._internal->objectConstructor;460 d()->functionConstructor = builtins._internal->functionConstructor;461 d()->arrayConstructor = builtins._internal->arrayConstructor;462 d()->booleanConstructor = builtins._internal->booleanConstructor;463 d()->stringConstructor = builtins._internal->stringConstructor;464 d()->numberConstructor = builtins._internal->numberConstructor;465 d()->dateConstructor = builtins._internal->dateConstructor;466 d()->regExpConstructor = builtins._internal->regExpConstructor;467 d()->errorConstructor = builtins._internal->errorConstructor;468 d()->evalErrorConstructor = builtins._internal->evalErrorConstructor;469 d()->rangeErrorConstructor = builtins._internal->rangeErrorConstructor;470 d()->referenceErrorConstructor = builtins._internal->referenceErrorConstructor;471 d()->syntaxErrorConstructor = builtins._internal->syntaxErrorConstructor;472 d()->typeErrorConstructor = builtins._internal->typeErrorConstructor;473 d()->URIErrorConstructor = builtins._internal->URIErrorConstructor;474 475 d()->evalFunction = builtins._internal->evalFunction;476 477 d()->objectPrototype = builtins._internal->objectPrototype;478 d()->functionPrototype = builtins._internal->functionPrototype;479 d()->arrayPrototype = builtins._internal->arrayPrototype;480 d()->booleanPrototype = builtins._internal->booleanPrototype;481 d()->stringPrototype = builtins._internal->stringPrototype;482 d()->numberPrototype = builtins._internal->numberPrototype;483 d()->datePrototype = builtins._internal->datePrototype;484 d()->regExpPrototype = builtins._internal->regExpPrototype;485 d()->errorPrototype = builtins._internal->errorPrototype;486 d()->evalErrorPrototype = builtins._internal->evalErrorPrototype;487 d()->rangeErrorPrototype = builtins._internal->rangeErrorPrototype;488 d()->referenceErrorPrototype = builtins._internal->referenceErrorPrototype;489 d()->syntaxErrorPrototype = builtins._internal->syntaxErrorPrototype;490 d()->typeErrorPrototype = builtins._internal->typeErrorPrototype;491 d()->URIErrorPrototype = builtins._internal->URIErrorPrototype;492 }493 494 413 void JSGlobalObject::mark() 495 414 { -
trunk/JavaScriptCore/kjs/JSGlobalObject.h
r32495 r32587 59 59 class RegExpPrototype; 60 60 class RuntimeMethod; 61 class SavedBuiltins;62 61 class ScopeChain; 63 62 class StringObjectImp; … … 215 214 unsigned pageGroupIdentifier() const { return d()->pageGroupIdentifier; } 216 215 217 void saveBuiltins(SavedBuiltins&) const;218 void restoreBuiltins(const SavedBuiltins&);219 220 216 void setTimeoutTime(unsigned timeoutTime) { d()->timeoutTime = timeoutTime; } 221 217 void startTimeoutCheck(); -
trunk/JavaScriptCore/kjs/JSVariableObject.cpp
r31225 r32587 36 36 37 37 UString::Rep* IdentifierRepHashTraits::nullRepPtr = &UString::Rep::null; // Didn't want to make a whole source file for just this. 38 39 void JSVariableObject::saveLocalStorage(SavedProperties& p) const40 {41 ASSERT(d->symbolTable);42 ASSERT(static_cast<size_t>(d->symbolTable->size()) == d->localStorage.size());43 44 unsigned count = d->symbolTable->size();45 46 p.properties.clear();47 p.count = count;48 49 if (!count)50 return;51 52 p.properties.set(new SavedProperty[count]);53 54 SymbolTable::const_iterator end = d->symbolTable->end();55 for (SymbolTable::const_iterator it = d->symbolTable->begin(); it != end; ++it) {56 size_t i = it->second;57 const LocalStorageEntry& entry = d->localStorage[i];58 p.properties[i].init(it->first.get(), entry.value, entry.attributes);59 }60 }61 62 void JSVariableObject::restoreLocalStorage(const SavedProperties& p)63 {64 unsigned count = p.count;65 d->symbolTable->clear();66 d->localStorage.resize(count);67 SavedProperty* property = p.properties.get();68 for (size_t i = 0; i < count; ++i, ++property) {69 ASSERT(!d->symbolTable->contains(property->name()));70 LocalStorageEntry& entry = d->localStorage[i];71 d->symbolTable->set(property->name(), i);72 entry.value = property->value();73 entry.attributes = property->attributes();74 }75 }76 38 77 39 bool JSVariableObject::deleteProperty(ExecState* exec, const Identifier& propertyName) -
trunk/JavaScriptCore/kjs/JSVariableObject.h
r32259 r32587 40 40 SymbolTable& symbolTable() const { return *d->symbolTable; } 41 41 LocalStorage& localStorage() const { return d->localStorage; } 42 43 void saveLocalStorage(SavedProperties&) const;44 void restoreLocalStorage(const SavedProperties&);45 42 46 43 virtual void putWithAttributes(ExecState*, const Identifier&, JSValue*, unsigned attributes) = 0; -
trunk/JavaScriptCore/kjs/object.h
r31962 r32587 436 436 virtual JSValue* lookupSetter(ExecState*, const Identifier& propertyName); 437 437 438 void saveProperties(SavedProperties &p) const { _prop.save(p); }439 void restoreProperties(const SavedProperties &p) { _prop.restore(p); }440 441 438 virtual bool isActivationObject() const { return false; } 442 439 virtual bool isGlobalObject() const { return false; } -
trunk/JavaScriptCore/kjs/property_map.cpp
r29943 r32587 126 126 static const unsigned deletedSentinelIndex = 1; 127 127 128 SavedProperties::SavedProperties()129 : count(0)130 {131 }132 133 SavedProperties::~SavedProperties()134 {135 }136 137 128 #if !DO_PROPERTYMAP_CONSTENCY_CHECK 138 129 … … 717 708 } 718 709 719 void PropertyMap::save(SavedProperties& s) const720 {721 unsigned count = 0;722 723 if (!m_usingTable) {724 #if USE_SINGLE_ENTRY725 if (m_singleEntryKey && !(m_singleEntryAttributes & (ReadOnly | Function)))726 ++count;727 #endif728 } else {729 unsigned entryCount = m_u.table->keyCount + m_u.table->deletedSentinelCount;730 for (unsigned i = 1; i <= entryCount; ++i)731 if (m_u.table->entries()[i].key && !(m_u.table->entries()[i].attributes & (ReadOnly | Function)))732 ++count;733 }734 735 s.properties.clear();736 s.count = count;737 738 if (count == 0)739 return;740 741 s.properties.set(new SavedProperty[count]);742 743 SavedProperty* prop = s.properties.get();744 745 #if USE_SINGLE_ENTRY746 if (!m_usingTable) {747 prop->init(m_singleEntryKey, m_u.singleEntryValue, m_singleEntryAttributes);748 return;749 }750 #endif751 752 // Save in the right order so we don't lose the order.753 // Another possibility would be to save the indices.754 755 // Allocate a buffer to use to sort the keys.756 Vector<Entry*, smallMapThreshold> sortedEntries(count);757 758 // Get pointers to the entries in the buffer.759 Entry** p = sortedEntries.data();760 unsigned entryCount = m_u.table->keyCount + m_u.table->deletedSentinelCount;761 for (unsigned i = 1; i <= entryCount; ++i) {762 if (m_u.table->entries()[i].key && !(m_u.table->entries()[i].attributes & (ReadOnly | Function)))763 *p++ = &m_u.table->entries()[i];764 }765 ASSERT(p == sortedEntries.data() + count);766 767 // Sort the entries by index.768 qsort(sortedEntries.data(), p - sortedEntries.data(), sizeof(Entry*), comparePropertyMapEntryIndices);769 770 // Put the sorted entries into the saved properties list.771 for (Entry** q = sortedEntries.data(); q != p; ++q, ++prop) {772 Entry* e = *q;773 prop->init(e->key, e->value, e->attributes);774 }775 }776 777 void PropertyMap::restore(const SavedProperties& p)778 {779 for (unsigned i = 0; i != p.count; ++i)780 put(Identifier(p.properties[i].name()), p.properties[i].value(), p.properties[i].attributes());781 }782 783 710 #if DO_PROPERTYMAP_CONSTENCY_CHECK 784 711 -
trunk/JavaScriptCore/kjs/property_map.h
r29943 r32587 57 57 }; 58 58 59 struct SavedProperties {60 SavedProperties();61 ~SavedProperties();62 63 unsigned count;64 OwnArrayPtr<SavedProperty> properties;65 };66 67 59 class PropertyMap : Noncopyable { 68 60 public: … … 80 72 void mark() const; 81 73 void getEnumerablePropertyNames(PropertyNameArray&) const; 82 83 void save(SavedProperties&) const;84 void restore(const SavedProperties&);85 74 86 75 bool hasGetterSetterProperties() const { return m_getterSetterFlag; }
Note:
See TracChangeset
for help on using the changeset viewer.