[SCM] WebKit Debian packaging branch, debian/unstable, updated. debian/1.1.15-1-40151-g37bb677
darin
darin at 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sat Sep 26 07:45:33 UTC 2009
The following commit has been merged in the debian/unstable branch:
commit af4a300fadba7f3569339e6d92fbb19ed267944e
Author: darin <darin at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Sat Jun 14 02:12:59 2003 +0000
Reviewed by Dave.
- fixed 3178438 -- return elements in order of addition in for..in loop (other browsers seem to)
- fixed 3292067 -- REGRESSION (64-65): albertsons.com "Shop A to Z" menus are not sorted alphabetically
* kjs/property_map.h: Add index field to hash table entry and index parameter to insert function.
* kjs/property_map.cpp:
(PropertyMap::put): Set an index for new map entries to an ever-increasing number based on a global.
(PropertyMap::insert): Take an index parameter.
(PropertyMap::expand): Preserve the indices as we rehash the table.
(comparePropertyMapEntryIndices): Added. Compares two property map entries by index.
(PropertyMap::addEnumerablesToReferenceList): Sort the proprty map entries by index before adding
them to the reference list.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@4547 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/JavaScriptCore/ChangeLog b/JavaScriptCore/ChangeLog
index f94bcbb..98550da 100644
--- a/JavaScriptCore/ChangeLog
+++ b/JavaScriptCore/ChangeLog
@@ -1,3 +1,19 @@
+2003-06-13 Darin Adler <darin at apple.com>
+
+ Reviewed by Dave.
+
+ - fixed 3178438 -- return elements in order of addition in for..in loop (other browsers seem to)
+ - fixed 3292067 -- REGRESSION (64-65): albertsons.com "Shop A to Z" menus are not sorted alphabetically
+
+ * kjs/property_map.h: Add index field to hash table entry and index parameter to insert function.
+ * kjs/property_map.cpp:
+ (PropertyMap::put): Set an index for new map entries to an ever-increasing number based on a global.
+ (PropertyMap::insert): Take an index parameter.
+ (PropertyMap::expand): Preserve the indices as we rehash the table.
+ (comparePropertyMapEntryIndices): Added. Compares two property map entries by index.
+ (PropertyMap::addEnumerablesToReferenceList): Sort the proprty map entries by index before adding
+ them to the reference list.
+
=== Safari-84 ===
2003-06-10 Vicki Murley <vicki at apple.com>
diff --git a/JavaScriptCore/ChangeLog-2003-10-25 b/JavaScriptCore/ChangeLog-2003-10-25
index f94bcbb..98550da 100644
--- a/JavaScriptCore/ChangeLog-2003-10-25
+++ b/JavaScriptCore/ChangeLog-2003-10-25
@@ -1,3 +1,19 @@
+2003-06-13 Darin Adler <darin at apple.com>
+
+ Reviewed by Dave.
+
+ - fixed 3178438 -- return elements in order of addition in for..in loop (other browsers seem to)
+ - fixed 3292067 -- REGRESSION (64-65): albertsons.com "Shop A to Z" menus are not sorted alphabetically
+
+ * kjs/property_map.h: Add index field to hash table entry and index parameter to insert function.
+ * kjs/property_map.cpp:
+ (PropertyMap::put): Set an index for new map entries to an ever-increasing number based on a global.
+ (PropertyMap::insert): Take an index parameter.
+ (PropertyMap::expand): Preserve the indices as we rehash the table.
+ (comparePropertyMapEntryIndices): Added. Compares two property map entries by index.
+ (PropertyMap::addEnumerablesToReferenceList): Sort the proprty map entries by index before adding
+ them to the reference list.
+
=== Safari-84 ===
2003-06-10 Vicki Murley <vicki at apple.com>
diff --git a/JavaScriptCore/kjs/property_map.cpp b/JavaScriptCore/kjs/property_map.cpp
index 0d647a1..bf58523 100644
--- a/JavaScriptCore/kjs/property_map.cpp
+++ b/JavaScriptCore/kjs/property_map.cpp
@@ -29,7 +29,8 @@
#define DUMP_STATISTICS 0
#define USE_SINGLE_ENTRY 1
-// At the time I added USE_SINGLE_ENTRY, the optimization still gave a 1.5% performance boost so I couldn't remove it.
+// At the time I added USE_SINGLE_ENTRY, the optimization still gave a 1.5%
+// performance boost to the iBench JavaScript benchmark so I didn't remove it.
#if !DO_CONSISTENCY_CHECK
#define checkConsistency() ((void)0)
@@ -37,6 +38,16 @@
namespace KJS {
+// Choose a number for the following so that most property maps are smaller,
+// but it's not going to blow out the stack to allocate this number of pointers.
+const int smallMapThreshold = 1024;
+
+// Ever-increasing index used to identify the order items were inserted into
+// the property map. It's vital that addEnumerablesToReferenceList return
+// the properties in the order they were added for compatibility with other
+// browsers' JavaScript implementations.
+static int lastIndexUsed;
+
#if DUMP_STATISTICS
static int numProbes;
@@ -251,6 +262,7 @@ void PropertyMap::put(const Identifier &name, ValueImp *value, int attributes)
_singleEntry.key = rep;
_singleEntry.value = value;
_singleEntry.attributes = attributes;
+ _singleEntry.index = ++lastIndexUsed;
checkConsistency();
return;
}
@@ -292,12 +304,13 @@ void PropertyMap::put(const Identifier &name, ValueImp *value, int attributes)
_table->entries[i].key = rep;
_table->entries[i].value = value;
_table->entries[i].attributes = attributes;
+ _table->entries[i].index = ++lastIndexUsed;
++_table->keyCount;
checkConsistency();
}
-void PropertyMap::insert(UString::Rep *key, ValueImp *value, int attributes)
+void PropertyMap::insert(UString::Rep *key, ValueImp *value, int attributes, int index)
{
assert(_table);
@@ -321,6 +334,7 @@ void PropertyMap::insert(UString::Rep *key, ValueImp *value, int attributes)
_table->entries[i].key = key;
_table->entries[i].value = value;
_table->entries[i].attributes = attributes;
+ _table->entries[i].index = index;
}
void PropertyMap::expand()
@@ -340,7 +354,7 @@ void PropertyMap::expand()
#if USE_SINGLE_ENTRY
UString::Rep *key = _singleEntry.key;
if (key) {
- insert(key, _singleEntry.value, _singleEntry.attributes);
+ insert(key, _singleEntry.value, _singleEntry.attributes, _singleEntry.index);
_singleEntry.key = 0;
// update the count, because single entries don't count towards
// the table key count
@@ -356,7 +370,8 @@ void PropertyMap::expand()
if (key == &UString::Rep::null)
key->deref();
else
- insert(key, oldTable->entries[i].value, oldTable->entries[i].attributes);
+ insert(key, oldTable->entries[i].value,
+ oldTable->entries[i].attributes, oldTable->entries[i].index);
}
}
@@ -449,6 +464,17 @@ void PropertyMap::mark() const
}
}
+static int comparePropertyMapEntryIndices(const void *a, const void *b)
+{
+ int ia = static_cast<PropertyMapHashTableEntry * const *>(a)[0]->index;
+ int ib = static_cast<PropertyMapHashTableEntry * const *>(b)[0]->index;
+ if (ia < ib)
+ return -1;
+ if (ia > ib)
+ return +1;
+ return 0;
+}
+
void PropertyMap::addEnumerablesToReferenceList(ReferenceList &list, const Object &base) const
{
if (!_table) {
@@ -460,11 +486,33 @@ void PropertyMap::addEnumerablesToReferenceList(ReferenceList &list, const Objec
return;
}
+ // Allocate a buffer to use to sort the keys.
+ Entry *fixedSizeBuffer[smallMapThreshold];
+ Entry **sortedEnumerables;
+ if (_table->keyCount <= smallMapThreshold)
+ sortedEnumerables = fixedSizeBuffer;
+ else
+ sortedEnumerables = new Entry *[_table->keyCount];
+
+ // Get pointers to the enumerable entries in the buffer.
+ Entry **p = sortedEnumerables;
for (int i = 0; i != _table->size; ++i) {
- UString::Rep *key = _table->entries[i].key;
- if (key && !(_table->entries[i].attributes & DontEnum))
- list.append(Reference(base, Identifier(key)));
+ Entry *e = &_table->entries[i];
+ if (e->key && !(e->attributes & DontEnum))
+ *p++ = e;
}
+
+ // Sort the entries by index.
+ qsort(sortedEnumerables, p - sortedEnumerables, sizeof(sortedEnumerables[0]), comparePropertyMapEntryIndices);
+
+ // Put the keys of the sorted entries into the reference list.
+ Entry **q = sortedEnumerables;
+ while (q != p)
+ list.append(Reference(base, Identifier((*q++)->key)));
+
+ // Deallocate the buffer.
+ if (sortedEnumerables != fixedSizeBuffer)
+ delete [] sortedEnumerables;
}
void PropertyMap::addSparseArrayPropertiesToReferenceList(ReferenceList &list, const Object &base) const
diff --git a/JavaScriptCore/kjs/property_map.h b/JavaScriptCore/kjs/property_map.h
index 6f26e51..a63e20f 100644
--- a/JavaScriptCore/kjs/property_map.h
+++ b/JavaScriptCore/kjs/property_map.h
@@ -55,6 +55,7 @@ namespace KJS {
UString::Rep *key;
ValueImp *value;
int attributes;
+ int index;
};
class PropertyMap {
@@ -80,7 +81,7 @@ namespace KJS {
static bool keysMatch(const UString::Rep *, const UString::Rep *);
void expand();
- void insert(UString::Rep *, ValueImp *value, int attributes);
+ void insert(UString::Rep *, ValueImp *value, int attributes, int index);
void checkConsistency();
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list