Changeset 31147 in webkit for trunk/JavaScriptCore/kjs/object.cpp


Ignore:
Timestamp:
Mar 18, 2008, 9:23:21 PM (17 years ago)
Author:
Darin Adler
Message:

JavaScriptCore:

2008-03-18 Darin Adler <Darin Adler>

Reviewed by Maciej.

  • Speed up JavaScript built-in properties by changing the hash table to take advantage of the identifier objects

5% speedup for Acid3 test 26

  • JavaScriptCore.exp: Updated.
  • kjs/create_hash_table: Compute size of hash table large enough so that there are no collisions, but don't generate the hash table.
  • kjs/identifier.h: Made the add function that returns a PassRefPtr public.
  • kjs/lexer.cpp: (KJS::Lexer::lex): Updated for change to HashTable interface.
  • kjs/lookup.cpp: (KJS::HashTable::changeKeysToIdentifiers): Added. Finds the identifier for each property so the equality comparision can be done with pointer comparision.
  • kjs/lookup.h: Made the key be a union of char* with UString::Rep* so it can hold identifiers. Added a keysAreIdentifiers flag to the HashTable. Changed the Lookup functions to be member functions of HashTable instead.
  • kjs/object.cpp: (KJS::JSObject::deleteProperty): Update for change to HashTable. (KJS::JSObject::findPropertyHashEntry): Ditto. (KJS::JSObject::getPropertyAttributes): Ditto. (KJS::JSObject::getPropertyNames): Ditto.

WebCore:

2008-03-18 Darin Adler <Darin Adler>

Reviewed by Maciej.

  • Speed up JavaScript built-in properties by changing the hash table to take advantage of the identifier objects

5% speedup for Acid3 test 26

  • bindings/js/JSDOMWindowBase.cpp: (WebCore::JSDOMWindowBase::getOwnPropertySlot): Update for change to HashTable. (WebCore::JSDOMWindowBase::put): Ditto.
  • bindings/js/JSDOMWindowCustom.cpp: (WebCore::JSDOMWindow::customGetOwnPropertySlot): Ditto.
  • bindings/js/JSHTMLInputElementBase.cpp: (WebCore::JSHTMLInputElementBase::getOwnPropertySlot): Ditto.
  • bindings/js/JSHistoryCustom.cpp: (WebCore::JSHistory::customGetOwnPropertySlot): Ditto.
  • bindings/js/JSLocation.cpp: (WebCore::JSLocation::customGetOwnPropertySlot): Ditto. (WebCore::JSLocation::put): Ditto.
  • bindings/js/kjs_binding.cpp: (WebCore::nonCachingStaticFunctionGetter): Ditto.
  • bindings/scripts/CodeGeneratorJS.pm: Same changes as in the create_hash_table script.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/kjs/object.cpp

    r31145 r31147  
    315315  // Look in the static hashtable of properties
    316316  const HashEntry* entry = findPropertyHashEntry(propertyName);
    317   if (entry && entry->attr & DontDelete)
     317  if (entry && entry->attributes & DontDelete)
    318318    return false; // this builtin property can't be deleted
     319  // FIXME: Should the code here actually do some deletion?
    319320  return true;
    320321}
     
    378379const HashEntry* JSObject::findPropertyHashEntry(const Identifier& propertyName) const
    379380{
    380   for (const ClassInfo *info = classInfo(); info; info = info->parentClass) {
    381     if (const HashTable *propHashTable = info->propHashTable) {
    382       if (const HashEntry *e = Lookup::findEntry(propHashTable, propertyName))
    383         return e;
    384     }
    385   }
    386   return 0;
     381    for (const ClassInfo* info = classInfo(); info; info = info->parentClass) {
     382        if (const HashTable* propHashTable = info->propHashTable) {
     383            if (const HashEntry* e = propHashTable->entry(propertyName))
     384                return e;
     385        }
     386    }
     387    return 0;
    387388}
    388389
     
    488489  const HashEntry* e = findPropertyHashEntry(propertyName);
    489490  if (e) {
    490     attributes = e->attr;
     491    attributes = e->attributes;
    491492    return true;
    492493  }
     
    497498void JSObject::getPropertyNames(ExecState* exec, PropertyNameArray& propertyNames)
    498499{
    499    _prop.getEnumerablePropertyNames(propertyNames);
    500 
    501   // Add properties from the static hashtable of properties
    502   const ClassInfo *info = classInfo();
    503   while (info) {
    504     if (info->propHashTable) {
    505       int size = info->propHashTable->size;
    506       const HashEntry *e = info->propHashTable->entries;
    507       for (int i = 0; i < size; ++i, ++e) {
    508         if (e->s && !(e->attr & DontEnum))
    509           propertyNames.add(e->s);
    510       }
    511     }
    512     info = info->parentClass;
    513   }
    514   if (_proto->isObject())
    515      static_cast<JSObject*>(_proto)->getPropertyNames(exec, propertyNames);
     500    _prop.getEnumerablePropertyNames(propertyNames);
     501
     502    // Add properties from the static hashtables of properties
     503    for (const ClassInfo* info = classInfo(); info; info = info->parentClass) {
     504        const HashTable* table = info->propHashTable;
     505        if (!table)
     506            continue;
     507        if (!table->table)
     508            table->createTable();
     509        ASSERT(table->table);
     510        int hashSizeMask = table->hashSizeMask;
     511        const HashEntry* e = table->table;
     512        for (int i = 0; i <= hashSizeMask; ++i, ++e) {
     513            if (e->key && !(e->attributes & DontEnum))
     514                propertyNames.add(Identifier(e->key));
     515        }
     516    }
     517
     518    if (_proto->isObject())
     519        static_cast<JSObject*>(_proto)->getPropertyNames(exec, propertyNames);
    516520}
    517521
Note: See TracChangeset for help on using the changeset viewer.