Changeset 10857 in webkit for trunk/JavaScriptCore/kjs


Ignore:
Timestamp:
Oct 15, 2005, 5:46:25 PM (20 years ago)
Author:
mjs
Message:

Reverted fix for this bug, because it was part of a time range that caused a performance
regression:

<rdar://problem/4260481> Remove Reference type from JavaScriptCore

Location:
trunk/JavaScriptCore/kjs
Files:
5 added
2 deleted
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/kjs/array_instance.h

    r10744 r10857  
    4040    virtual bool deleteProperty(ExecState *exec, const Identifier &propertyName);
    4141    virtual bool deleteProperty(ExecState *exec, unsigned propertyName);
    42     virtual void getPropertyNames(ExecState *exec, IdentifierSequencedSet& propertyNames);
     42    virtual ReferenceList propList(ExecState *exec, bool recursive);
    4343
    4444    virtual void mark();
  • trunk/JavaScriptCore/kjs/array_object.cpp

    r10744 r10857  
    2929#include "object.h"
    3030#include "operations.h"
     31#include "reference_list.h"
    3132#include "types.h"
    3233#include "value.h"
    33 #include "IdentifierSequencedSet.h"
    3434
    3535#include "array_object.lut.h"
     
    186186}
    187187
    188 void ArrayInstanceImp::getPropertyNames(ExecState *exec, IdentifierSequencedSet& propertyNames)
    189 {
     188ReferenceList ArrayInstanceImp::propList(ExecState *exec, bool recursive)
     189{
     190  ReferenceList properties = ObjectImp::propList(exec,recursive);
     191
    190192  // avoid fetching this every time through the loop
    191193  ValueImp *undefined = jsUndefined();
     
    193195  for (unsigned i = 0; i < storageLength; ++i) {
    194196    ValueImp *imp = storage[i];
    195     if (imp && imp != undefined)
    196       propertyNames.insert(Identifier::from(i));
    197   }
    198 
    199   ObjectImp::getPropertyNames(exec, propertyNames);
     197    if (imp && imp != undefined) {
     198      properties.append(Reference(this, i));
     199    }
     200  }
     201  return properties;
    200202}
    201203
     
    229231
    230232  if (newLength < length) {
    231     IdentifierSequencedSet sparseProperties;
    232    
    233     _prop.getSparseArrayPropertyNames(sparseProperties);
    234 
    235     IdentifierSequencedSetIterator end = sparseProperties.end();
    236    
    237     for (IdentifierSequencedSetIterator it = sparseProperties.begin(); it != end; ++it) {
    238       Identifier name = *it;
     233    ReferenceList sparseProperties;
     234   
     235    _prop.addSparseArrayPropertiesToReferenceList(sparseProperties, this);
     236   
     237    ReferenceListIterator it = sparseProperties.begin();
     238    while (it != sparseProperties.end()) {
     239      Reference ref = it++;
    239240      bool ok;
    240       unsigned index = name.toArrayIndex(&ok);
    241       if (ok && index > newLength)
    242         deleteProperty(exec, name);
     241      unsigned index = ref.getPropertyName(exec).toArrayIndex(&ok);
     242      if (ok && index > newLength) {
     243        ref.deleteValue(exec);
     244      }
    243245    }
    244246  }
     
    347349    }
    348350   
    349     IdentifierSequencedSet sparseProperties;
    350     _prop.getSparseArrayPropertyNames(sparseProperties);
    351     unsigned newLength = o + sparseProperties.size();
    352 
    353     if (newLength > storageLength)
     351    ReferenceList sparseProperties;
     352    _prop.addSparseArrayPropertiesToReferenceList(sparseProperties, this);
     353    unsigned newLength = o + sparseProperties.length();
     354
     355    if (newLength > storageLength) {
    354356      resizeStorage(newLength);
    355 
    356     IdentifierSequencedSetIterator end = sparseProperties.end();
    357     for (IdentifierSequencedSetIterator it = sparseProperties.begin(); it != end; ++it) {
    358       Identifier name = *it;
    359       storage[o] = get(exec, name);
    360       ObjectImp::deleteProperty(exec, name);
     357    }
     358
     359    ReferenceListIterator it = sparseProperties.begin();
     360    while (it != sparseProperties.end()) {
     361      Reference ref = it++;
     362      storage[o] = ref.getValue(exec);
     363      ObjectImp::deleteProperty(exec, ref.getPropertyName(exec));
    361364      o++;
    362365    }
  • trunk/JavaScriptCore/kjs/nodes.cpp

    r10757 r10857  
    4444#include "operations.h"
    4545#include "ustring.h"
    46 #include "IdentifierSequencedSet.h"
     46#include "reference_list.h"
    4747
    4848using namespace KJS;
     
    17701770  ObjectImp *v;
    17711771  Completion c;
    1772   IdentifierSequencedSet propertyNames;
     1772  ReferenceList propList;
    17731773
    17741774  if (varDecl) {
     
    17891789  KJS_CHECKEXCEPTION
    17901790  v = e->toObject(exec);
    1791   v->getPropertyNames(exec, propertyNames);
    1792 
    1793   IdentifierSequencedSetIterator end = propertyNames.end();
    1794   for (IdentifierSequencedSetIterator it = propertyNames.begin(); it != end; ++it) {
    1795     const Identifier &name = *it;
    1796     if (!v->hasProperty(exec, name))
     1791  propList = v->propList(exec);
     1792
     1793  ReferenceListIterator propIt = propList.begin();
     1794
     1795  while (propIt != propList.end()) {
     1796    Identifier name = propIt->getPropertyName(exec);
     1797    if (!v->hasProperty(exec, name)) {
     1798      propIt++;
    17971799      continue;
     1800    }
    17981801
    17991802    ValueImp *str = jsString(name.ustring());
     
    18571860      }
    18581861    }
     1862
     1863    propIt++;
    18591864  }
    18601865
  • trunk/JavaScriptCore/kjs/nodes.h

    r10744 r10857  
    3535  class PropertyNode;
    3636  class PropertyValueNode;
     37  class Reference;
    3738  class RegExp;
    3839  class SourceElementsNode;
  • trunk/JavaScriptCore/kjs/object.cpp

    r10744 r10857  
    2929#include "interpreter.h"
    3030#include "lookup.h"
    31 #include "IdentifierSequencedSet.h"
     31#include "reference_list.h"
    3232
    3333#include <assert.h>
     
    375375}
    376376
    377 void ObjectImp::getPropertyNames(ExecState *exec, IdentifierSequencedSet &propertyNames)
    378 {
    379   _prop.getEnumerablePropertyNames(propertyNames);
     377ReferenceList ObjectImp::propList(ExecState *exec, bool recursive)
     378{
     379  ReferenceList list;
     380  if (_proto->isObject() && recursive)
     381    list = static_cast<ObjectImp*>(_proto)->propList(exec,recursive);
     382
     383  _prop.addEnumerablesToReferenceList(list, this);
    380384
    381385  // Add properties from the static hashtable of properties
     
    386390      const HashEntry *e = info->propHashTable->entries;
    387391      for (int i = 0; i < size; ++i, ++e) {
    388         if (e->s && !(e->attr & DontEnum))
    389           propertyNames.insert(e->s);
     392        if ( e->s && !(e->attr & DontEnum) )
     393          list.append(Reference(this, e->s)); /// ######### check for duplicates with the propertymap
    390394      }
    391395    }
     
    393397  }
    394398
    395   if (_proto->isObject())
    396     static_cast<ObjectImp*>(_proto)->getPropertyNames(exec, propertyNames);
     399  return list;
    397400}
    398401
  • trunk/JavaScriptCore/kjs/object.h

    r10744 r10857  
    4848  class HashEntry;
    4949  class ListImp;
    50   class IdentifierSequencedSet;
    5150
    5251  // ECMA 262-3 8.6.1
     
    424423     *
    425424     * @param exec The current execution state
    426      * @param propertyNames A list of property names to be filled in by this call
     425     * @param recursive Whether or not properties in the object's prototype
     426     * chain should be
     427     * included in the list.
     428     * @return A List of References to properties of the object.
    427429     **/
    428     virtual void getPropertyNames(ExecState *exec, IdentifierSequencedSet& propertyNames);
     430    virtual ReferenceList propList(ExecState *exec, bool recursive = true);
    429431
    430432    /**
  • trunk/JavaScriptCore/kjs/property_map.cpp

    r10744 r10857  
    2626#include "object.h"
    2727#include "protect.h"
    28 #include "IdentifierSequencedSet.h"
     28#include "reference_list.h"
    2929
    3030#include <algorithm>
     
    7575
    7676// lastIndexUsed is an ever-increasing index used to identify the order items
    77 // were inserted into the property map. It's vital that getEnumerablePropertyNames
     77// were inserted into the property map. It's vital that addEnumerablesToReferenceList
    7878// return the properties in the order they were added for compatibility with other
    7979// browsers' JavaScript implementations.
     
    567567}
    568568
    569 void PropertyMap::getEnumerablePropertyNames(IdentifierSequencedSet& propertyNames) const
     569void PropertyMap::addEnumerablesToReferenceList(ReferenceList &list, ObjectImp *base) const
    570570{
    571571    if (!_table) {
     
    573573        UString::Rep *key = _singleEntry.key;
    574574        if (key && !(_singleEntry.attributes & DontEnum))
    575             propertyNames.insert(Identifier(key));
     575            list.append(Reference(base, Identifier(key)));
    576576#endif
    577577        return;
     
    599599    qsort(sortedEnumerables, p - sortedEnumerables, sizeof(sortedEnumerables[0]), comparePropertyMapEntryIndices);
    600600
    601     // Put the keys of the sorted entries into the list.
     601    // Put the keys of the sorted entries into the reference list.
    602602    Entry **q = sortedEnumerables;
    603     while (q != p) {
    604         propertyNames.insert(Identifier(q[0]->key));
    605         ++q;
    606     }
     603    while (q != p)
     604        list.append(Reference(base, Identifier((*q++)->key)));
    607605
    608606    // Deallocate the buffer.
     
    611609}
    612610
    613 void PropertyMap::getSparseArrayPropertyNames(IdentifierSequencedSet& propertyNames) const
     611void PropertyMap::addSparseArrayPropertiesToReferenceList(ReferenceList &list, ObjectImp *base) const
    614612{
    615613    if (!_table) {
     
    621619            k.toUInt32(&fitsInUInt32);
    622620            if (fitsInUInt32)
    623                 propertyNames.insert(Identifier(key));
     621                list.append(Reference(base, Identifier(key)));
    624622        }
    625623#endif
     
    636634            k.toUInt32(&fitsInUInt32);
    637635            if (fitsInUInt32)
    638                 propertyNames.insert(Identifier(key));
     636                list.append(Reference(base, Identifier(key)));
    639637        }
    640638    }
  • trunk/JavaScriptCore/kjs/property_map.h

    r10744 r10857  
    2828namespace KJS {
    2929
    30     class IdentifierSequencedSet;
    3130    class ObjectImp;
     31    class ReferenceList;
    3232    class ValueImp;
    3333   
     
    8282
    8383        void mark() const;
    84         void getEnumerablePropertyNames(IdentifierSequencedSet&) const;
    85         void getSparseArrayPropertyNames(IdentifierSequencedSet&) const;
     84        void addEnumerablesToReferenceList(ReferenceList &, ObjectImp *) const;
     85        void addSparseArrayPropertiesToReferenceList(ReferenceList &, ObjectImp *) const;
    8686
    8787        void save(SavedProperties &) const;
  • trunk/JavaScriptCore/kjs/protect.h

    r10744 r10857  
    2525#define _KJS_PROTECT_H_
    2626
     27#include "reference.h"
    2728#include "value.h"
    2829#include "protected_values.h"
  • trunk/JavaScriptCore/kjs/ustring.h

    r10744 r10857  
    241241
    242242  public:
    243     typedef Rep Impl;
    244 
    245243    /**
    246244     * Constructs a null string.
     
    464462    static void globalClear();
    465463#endif
    466 
    467     Impl *impl() const { return rep; }
    468464  private:
    469465    UString(Rep *r) { attach(r); }
Note: See TracChangeset for help on using the changeset viewer.