[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:07:21 UTC 2009
The following commit has been merged in the debian/unstable branch:
commit ff399e06cbd4c377790ab638d4c439d49a586b7f
Author: darin <darin at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Sat Nov 23 07:49:05 2002 +0000
JavaScriptCore:
- replaced List class with a vector rather than a linked list, changed it
to use a pool of instances instead of all the nodes allocated off of the
heap; gives 10% gain on iBench
* kjs/list.h: Complete rewrite.
* kjs/list.cpp: Ditto.
* kjs/array_object.cpp: (compareWithCompareFunctionForQSort): Go back to
doing a clear and two appends here. Fast with the new list implementation.
* kjs/collector.h: Remove _COLLECTOR hack and just make rootObjectClasses
return a const void *.
* kjs/collector.cpp: Remove _COLLECTOR hack, and various other minor tweaks.
WebCore:
* khtml/ecma/kjs_window.cpp: Remove _COLLECTOR hack.
* kwq/WebCoreJavaScript.h:
* kwq/WebCoreJavaScript.mm:
(+[WebCoreJavaScript rootObjectClasses]):
Update for name change -- root object classes, not all live object classes.
* force-js-clean-timestamp: Make sure we don't have more build problems.
WebKit:
* Misc.subproj/WebCoreStatistics.h:
* Misc.subproj/WebCoreStatistics.m:
(+[WebCoreStatistics javaScriptRootObjectClasses]):
Update for name change -- root object classes, not all live object classes.
WebBrowser:
* Debug/CacheController.m: (-[CacheController refreshJavaScriptStatisticsMatrix]):
Update for name change -- root object classes, not all live object classes.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@2843 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/JavaScriptCore/ChangeLog b/JavaScriptCore/ChangeLog
index 8a907bd..4e5592e 100644
--- a/JavaScriptCore/ChangeLog
+++ b/JavaScriptCore/ChangeLog
@@ -1,5 +1,21 @@
2002-11-22 Darin Adler <darin at apple.com>
+ - replaced List class with a vector rather than a linked list, changed it
+ to use a pool of instances instead of all the nodes allocated off of the
+ heap; gives 10% gain on iBench
+
+ * kjs/list.h: Complete rewrite.
+ * kjs/list.cpp: Ditto.
+
+ * kjs/array_object.cpp: (compareWithCompareFunctionForQSort): Go back to
+ doing a clear and two appends here. Fast with the new list implementation.
+
+ * kjs/collector.h: Remove _COLLECTOR hack and just make rootObjectClasses
+ return a const void *.
+ * kjs/collector.cpp: Remove _COLLECTOR hack, and various other minor tweaks.
+
+2002-11-22 Darin Adler <darin at apple.com>
+
- prepare to reimplement KJS::List; move to its own file, add statistics
* kjs/function_object.cpp: (FunctionProtoFuncImp::call): Use new copyTail()
diff --git a/JavaScriptCore/ChangeLog-2002-12-03 b/JavaScriptCore/ChangeLog-2002-12-03
index 8a907bd..4e5592e 100644
--- a/JavaScriptCore/ChangeLog-2002-12-03
+++ b/JavaScriptCore/ChangeLog-2002-12-03
@@ -1,5 +1,21 @@
2002-11-22 Darin Adler <darin at apple.com>
+ - replaced List class with a vector rather than a linked list, changed it
+ to use a pool of instances instead of all the nodes allocated off of the
+ heap; gives 10% gain on iBench
+
+ * kjs/list.h: Complete rewrite.
+ * kjs/list.cpp: Ditto.
+
+ * kjs/array_object.cpp: (compareWithCompareFunctionForQSort): Go back to
+ doing a clear and two appends here. Fast with the new list implementation.
+
+ * kjs/collector.h: Remove _COLLECTOR hack and just make rootObjectClasses
+ return a const void *.
+ * kjs/collector.cpp: Remove _COLLECTOR hack, and various other minor tweaks.
+
+2002-11-22 Darin Adler <darin at apple.com>
+
- prepare to reimplement KJS::List; move to its own file, add statistics
* kjs/function_object.cpp: (FunctionProtoFuncImp::call): Use new copyTail()
diff --git a/JavaScriptCore/ChangeLog-2003-10-25 b/JavaScriptCore/ChangeLog-2003-10-25
index 8a907bd..4e5592e 100644
--- a/JavaScriptCore/ChangeLog-2003-10-25
+++ b/JavaScriptCore/ChangeLog-2003-10-25
@@ -1,5 +1,21 @@
2002-11-22 Darin Adler <darin at apple.com>
+ - replaced List class with a vector rather than a linked list, changed it
+ to use a pool of instances instead of all the nodes allocated off of the
+ heap; gives 10% gain on iBench
+
+ * kjs/list.h: Complete rewrite.
+ * kjs/list.cpp: Ditto.
+
+ * kjs/array_object.cpp: (compareWithCompareFunctionForQSort): Go back to
+ doing a clear and two appends here. Fast with the new list implementation.
+
+ * kjs/collector.h: Remove _COLLECTOR hack and just make rootObjectClasses
+ return a const void *.
+ * kjs/collector.cpp: Remove _COLLECTOR hack, and various other minor tweaks.
+
+2002-11-22 Darin Adler <darin at apple.com>
+
- prepare to reimplement KJS::List; move to its own file, add statistics
* kjs/function_object.cpp: (FunctionProtoFuncImp::call): Use new copyTail()
diff --git a/JavaScriptCore/kjs/array_object.cpp b/JavaScriptCore/kjs/array_object.cpp
index 2fe7216..914e36f 100644
--- a/JavaScriptCore/kjs/array_object.cpp
+++ b/JavaScriptCore/kjs/array_object.cpp
@@ -267,8 +267,9 @@ static int compareWithCompareFunctionForQSort(const void *a, const void *b)
{
CompareWithCompareFunctionArguments *args = compareWithCompareFunctionArguments;
- args->arguments.replaceFirst(*(ValueImp **)a);
- args->arguments.replaceLast(*(ValueImp **)b);
+ args->arguments.clear();
+ args->arguments.append(*(ValueImp **)a);
+ args->arguments.append(*(ValueImp **)b);
return args->compareFunction->call(args->exec, args->globalObject, args->arguments)
.toInt32(args->exec);
}
diff --git a/JavaScriptCore/kjs/collector.cpp b/JavaScriptCore/kjs/collector.cpp
index 8e17c40..7f61064 100644
--- a/JavaScriptCore/kjs/collector.cpp
+++ b/JavaScriptCore/kjs/collector.cpp
@@ -1,8 +1,7 @@
// -*- c-basic-offset: 2 -*-
/*
* This file is part of the KDE libraries
- * Copyright (C) 1999-2000 Harri Porten (porten at kde.org)
- * Copyright (C) 2001 Peter Kelly (pmk at post.com)
+ * Copyright (C) 2002 Apple Computer, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -20,17 +19,17 @@
*
*/
+#include "collector.h"
+
+#include "value.h"
+#include "internal.h"
+
#if APPLE_CHANGES
-#define _COLLECTOR
#include <CoreFoundation/CoreFoundation.h>
#include <cxxabi.h>
#endif
-#include <collector.h>
-#include <value.h>
-#include <internal.h>
-
-using namespace KJS;
+namespace KJS {
// tunable parameters
static const int CELL_SIZE = 56;
@@ -359,8 +358,7 @@ int Collector::numReferencedObjects()
return count;
}
-// FIXME: Rename. Root object classes are more useful than live object classes.
-CFSetRef Collector::liveObjectClasses()
+const void *Collector::rootObjectClasses()
{
CFMutableSetRef classes = CFSetCreateMutable(NULL, 0, &kCFTypeSetCallBacks);
@@ -404,3 +402,5 @@ CFSetRef Collector::liveObjectClasses()
}
#endif // APPLE_CHANGES
+
+} // namespace KJS
diff --git a/JavaScriptCore/kjs/collector.h b/JavaScriptCore/kjs/collector.h
index 1708e41..15be15b 100644
--- a/JavaScriptCore/kjs/collector.h
+++ b/JavaScriptCore/kjs/collector.h
@@ -23,12 +23,6 @@
#ifndef _KJSCOLLECTOR_H_
#define _KJSCOLLECTOR_H_
-#if APPLE_CHANGES
-#if !defined(__OBJC__) && !defined(_COLLECTOR)
-typedef void *CFSetRef;
-#endif
-#endif
-
#define KJS_MEM_LIMIT 500000
namespace KJS {
@@ -70,7 +64,7 @@ namespace KJS {
static int numInterpreters();
static int numGCNotAllowedObjects();
static int numReferencedObjects();
- static CFSetRef liveObjectClasses();
+ static const void *rootObjectClasses(); // actually returns CFSetRef
#endif
private:
static bool memoryFull;
@@ -78,5 +72,4 @@ namespace KJS {
};
-
#endif /* _KJSCOLLECTOR_H_ */
diff --git a/JavaScriptCore/kjs/list.cpp b/JavaScriptCore/kjs/list.cpp
index 37c22f0..a06c6c2 100644
--- a/JavaScriptCore/kjs/list.cpp
+++ b/JavaScriptCore/kjs/list.cpp
@@ -1,8 +1,6 @@
-// -*- c-basic-offset: 2 -*-
/*
* This file is part of the KDE libraries
- * Copyright (C) 1999-2001 Harri Porten (porten at kde.org)
- * Copyright (C) 2001 Peter Kelly (pmk at post.com)
+ * Copyright (C) 2002 Apple Computer, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -21,23 +19,38 @@
*
*/
-#include "value.h"
-#include "object.h"
-#include "types.h"
-#include "interpreter.h"
-
-#include <assert.h>
-#include <math.h>
-#include <stdio.h>
+#include "list.h"
#include "internal.h"
-#include "collector.h"
-#include "operations.h"
-#include "error_object.h"
-#include "nodes.h"
#define DUMP_STATISTICS 0
+namespace KJS {
+
+// tunable parameters
+const int poolSize = 16; // must be a power of 2
+const int inlineValuesSize = 4;
+
+// derived constants
+const int poolSizeMask = poolSize - 1;
+
+enum ListImpState { unusedInPool = 0, usedInPool, usedOnHeap, immortal };
+
+struct ListImp : ListImpBase
+{
+ ListImpState state;
+ ValueImp *values[inlineValuesSize];
+ int capacity;
+ ValueImp **overflow;
+
+#if DUMP_STATISTICS
+ int sizeHighWaterMark;
+#endif
+};
+
+static ListImp pool[poolSize];
+static int poolCursor;
+
#if DUMP_STATISTICS
static int numLists;
@@ -48,9 +61,6 @@ static int listSizeHighWaterMark;
static int numListsDestroyed;
static int numListsBiggerThan[17];
-static int numNodesAllocated;
-static int numNodesWouldNeedToBeCopied;
-
struct ListStatisticsExitLogger { ~ListStatisticsExitLogger(); };
static ListStatisticsExitLogger logger;
@@ -60,371 +70,171 @@ ListStatisticsExitLogger::~ListStatisticsExitLogger()
printf("\nKJS::List statistics:\n\n");
printf("%d lists were allocated\n", numLists);
printf("%d lists was the high water mark\n", numListsHighWaterMark);
- printf("largest list had %d elements\n\n", listSizeHighWaterMark);
- printf("%d nodes were allocated\n", numNodesAllocated);
- printf("%d node copies would have been necessary if lists didn't share\n\n", numNodesWouldNeedToBeCopied);
- for (int i = 0; i < 17; i++) {
- printf("%.1f%% of the lists (%d) had more than %d element%s\n",
- 100.0 * numListsBiggerThan[i] / numListsDestroyed,
- numListsBiggerThan[i],
- i, i == 1 ? "" : "s");
+ printf("largest list had %d elements\n", listSizeHighWaterMark);
+ if (numListsDestroyed) {
+ putc('\n', stdout);
+ for (int i = 0; i < 17; i++) {
+ printf("%.1f%% of the lists (%d) had more than %d element%s\n",
+ 100.0 * numListsBiggerThan[i] / numListsDestroyed,
+ numListsBiggerThan[i],
+ i, i == 1 ? "" : "s");
+ }
+ putc('\n', stdout);
}
}
#endif
-namespace KJS {
-
- struct ListNode {
- ListNode(const Value &val, ListNode *p, ListNode *n)
- : member(val.imp()), prev(p), next(n) { }
- ListNode(ValueImp *val, ListNode *p, ListNode *n)
- : member(val), prev(p), next(n) { }
- ValueImp *member;
- ListNode *prev, *next;
- };
-
- struct ListHookNode : public ListNode {
- ListHookNode() : ListNode(0, this, this), listRefCount(1), nodesRefCount(1)
-#if DUMP_STATISTICS
- , sizeHighWaterMark(0)
-#endif
- { }
+static inline ListImp *allocateListImp()
+{
+ // Find a free one in the pool.
+ int c = poolCursor;
+ int i = c;
+ do {
+ ListImp *imp = &pool[i];
+ ListImpState s = imp->state;
+ i = (i + 1) & poolSizeMask;
+ if (s == unusedInPool) {
+ poolCursor = i;
+ imp->state = usedInPool;
+ return imp;
+ }
+ } while (i != c);
- int listRefCount;
- int nodesRefCount;
-
-#if DUMP_STATISTICS
- int sizeHighWaterMark;
-#endif
- };
-
-// ------------------------------ ListIterator ---------------------------------
-
-ValueImp* ListIterator::operator->() const
-{
- return node->member;
-}
-
-Value ListIterator::operator*() const
-{
- return Value(node->member);
+ ListImp *imp = new ListImp;
+ imp->state = usedOnHeap;
+ return imp;
}
-Value ListIterator::operator++()
+static inline void deallocateListImp(ListImp *imp)
{
- node = node->next;
- return Value(node->member);
+ if (imp->state == usedInPool)
+ imp->state = unusedInPool;
+ else
+ delete imp;
}
-Value ListIterator::operator++(int)
+List::List() : _impBase(allocateListImp())
{
- const ListNode *n = node;
- ++*this;
- return Value(n->member);
-}
-
-Value ListIterator::operator--()
-{
- node = node->prev;
- return Value(node->member);
-}
+ ListImp *imp = static_cast<ListImp *>(_impBase);
+ imp->size = 0;
+ imp->refCount = 1;
+ imp->capacity = 0;
+ imp->overflow = 0;
-Value ListIterator::operator--(int)
-{
- const ListNode *n = node;
- --*this;
- return Value(n->member);
-}
-
-// ------------------------------ List -----------------------------------------
-
-List::List() : hook(new ListHookNode)
-{
-#if DUMP_STATISTICS
- if (++numLists > numListsHighWaterMark)
- numListsHighWaterMark = numLists;
-#endif
-}
-
-List::List(const List& l) : hook(l.hook)
-{
#if DUMP_STATISTICS
- if (++numLists > numListsHighWaterMark)
- numListsHighWaterMark = numLists;
- numNodesWouldNeedToBeCopied += size();
+ if (++numLists > numListsHighWaterMark)
+ numListsHighWaterMark = numLists;
+ imp->sizeHighWaterMark = 0;
#endif
-
- ++hook->listRefCount;
- if (hook->nodesRefCount++ == 0)
- refAll();
}
-List& List::operator=(const List& l)
+inline void List::derefValues()
{
- List(l).swap(*this);
- return *this;
+ ListImp *imp = static_cast<ListImp *>(_impBase);
+
+ int size = imp->size;
+
+ int inlineSize = MIN(size, inlineValuesSize);
+ for (int i = 0; i != inlineSize; ++i)
+ imp->values[i]->deref();
+
+ int overflowSize = size - inlineSize;
+ ValueImp **overflow = imp->overflow;
+ for (int i = 0; i != overflowSize; ++i)
+ overflow[i]->deref();
}
-List::~List()
+void List::release()
{
+ ListImp *imp = static_cast<ListImp *>(_impBase);
+
#if DUMP_STATISTICS
- --numLists;
-#endif
-
- if (--hook->nodesRefCount == 0)
- derefAll();
-
- if (--hook->listRefCount == 0) {
-#if DUMP_STATISTICS
+ --numLists;
++numListsDestroyed;
for (int i = 0; i < 17; i++)
- if (hook->sizeHighWaterMark > i)
- ++numListsBiggerThan[i];
+ if (imp->sizeHighWaterMark > i)
+ ++numListsBiggerThan[i];
#endif
- assert(hook->nodesRefCount == 0);
- clearInternal();
- delete hook;
- }
+ derefValues();
+ delete [] imp->overflow;
+ deallocateListImp(imp);
}
-void List::append(const Value& val)
+ValueImp *List::impAt(int i) const
{
- ListNode *n = new ListNode(val, hook->prev, hook);
- if (hook->nodesRefCount)
- n->member->ref();
- hook->prev->next = n;
- hook->prev = n;
-
-#if DUMP_STATISTICS
- ++numNodesAllocated;
- int s = size();
- if (s > hook->sizeHighWaterMark) {
- hook->sizeHighWaterMark = s;
- if (s > listSizeHighWaterMark)
- listSizeHighWaterMark = s;
- }
-#endif
+ ListImp *imp = static_cast<ListImp *>(_impBase);
+ if ((unsigned)i >= (unsigned)imp->size)
+ return UndefinedImp::staticUndefined;
+ if (i < inlineValuesSize)
+ return imp->values[i];
+ return imp->overflow[i - inlineValuesSize];
}
-void List::append(ValueImp *val)
+void List::clear()
{
- ListNode *n = new ListNode(val, hook->prev, hook);
- if (hook->nodesRefCount)
- val->ref();
- hook->prev->next = n;
- hook->prev = n;
-
-#if DUMP_STATISTICS
- ++numNodesAllocated;
- int s = size();
- if (s > hook->sizeHighWaterMark) {
- hook->sizeHighWaterMark = s;
- if (s > listSizeHighWaterMark)
- listSizeHighWaterMark = s;
- }
-#endif
+ derefValues();
+ _impBase->size = 0;
}
-#if 0
-
-void List::prepend(const Value& val)
+void List::append(ValueImp *v)
{
- ListNode *n = new ListNode(val, hook, hook->next);
- if (hook->nodesRefCount)
- n->member->ref();
- hook->next->prev = n;
- hook->next = n;
-
-#if DUMP_STATISTICS
- ++numNodesAllocated;
- int s = size();
- if (s > hook->sizeHighWaterMark) {
- hook->sizeHighWaterMark = s;
- if (s > listSizeHighWaterMark)
- listSizeHighWaterMark = s;
- }
-#endif
-}
-
-#endif
+ ListImp *imp = static_cast<ListImp *>(_impBase);
-void List::prepend(ValueImp *val)
-{
- ListNode *n = new ListNode(val, hook, hook->next);
- if (hook->nodesRefCount)
- val->ref();
- hook->next->prev = n;
- hook->next = n;
+ int i = imp->size++;
#if DUMP_STATISTICS
- ++numNodesAllocated;
- int s = size();
- if (s > hook->sizeHighWaterMark) {
- hook->sizeHighWaterMark = s;
- if (s > listSizeHighWaterMark)
- listSizeHighWaterMark = s;
- }
+ if (imp->size > listSizeHighWaterMark)
+ listSizeHighWaterMark = imp->size;
#endif
-}
-
-void List::prependList(const List& lst)
-{
- ListNode *otherHook = lst.hook;
- ListNode *n = otherHook->prev;
- while (n != otherHook) {
- prepend(n->member);
- n = n->prev;
- }
-}
-
-void List::removeFirst()
-{
- erase(hook->next);
-}
-
-#if 0
-
-void List::removeLast()
-{
- erase(hook->prev);
-}
-void List::remove(const Value &val)
-{
- if (val.isNull())
- return;
- for (ListNode *n = hook->next; n != hook; n = n->next)
- if (n->member == val.imp()) {
- erase(n);
- return;
+ v->ref();
+
+ if (i < inlineValuesSize) {
+ imp->values[i] = v;
+ return;
}
+
+ if (i >= imp->capacity) {
+ int newCapacity = i * 2;
+ ValueImp **newOverflow = new ValueImp * [newCapacity - inlineValuesSize];
+ ValueImp **oldOverflow = imp->overflow;
+ int oldOverflowSize = i - inlineValuesSize;
+ for (int j = 0; j != oldOverflowSize; j++)
+ newOverflow[j] = oldOverflow[j];
+ delete [] oldOverflow;
+ imp->overflow = newOverflow;
+ imp->capacity = newCapacity;
+ }
+
+ imp->overflow[i - inlineValuesSize] = v;
}
-#endif
-
-void List::clear()
-{
- if (hook->nodesRefCount)
- derefAll();
- clearInternal();
-}
-
-void List::clearInternal()
-{
- ListNode *n = hook->next;
- while (n != hook) {
- n = n->next;
- delete n->prev;
- }
-
- hook->next = hook;
- hook->prev = hook;
-}
-
-List List::copy() const
-{
- List newList;
- newList.prependList(*this);
- return newList;
-}
-
-ListIterator List::begin() const
-{
- return ListIterator(hook->next);
-}
-
-ListIterator List::end() const
-{
- return ListIterator(hook);
-}
-
-bool List::isEmpty() const
+List List::copyTail() const
{
- return hook->prev == hook;
-}
+ List copy;
-int List::size() const
-{
- int s = 0;
- for (ListNode *n = hook->next; n != hook; n = n->next)
- s++;
- return s;
-}
+ ListImp *imp = static_cast<ListImp *>(_impBase);
-Value List::at(int i) const
-{
- if (i < 0 || i >= size())
- return Undefined();
+ int size = imp->size;
- ListIterator it = begin();
- int j = 0;
- while ((j++ < i))
- it++;
+ int inlineSize = MIN(size, inlineValuesSize);
+ for (int i = 0; i != inlineSize; ++i)
+ copy.append(imp->values[i]);
- return *it;
-}
+ ValueImp **overflow = imp->overflow;
+ int overflowSize = size - inlineSize;
+ for (int i = 0; i != overflowSize; ++i)
+ copy.append(overflow[i]);
-Value List::operator[](int i) const
-{
- return at(i);
+ return copy;
}
const List &List::empty()
{
- static List l;
- return l;
-}
-
-void List::erase(ListNode *n)
-{
- if (n != hook) {
- if (hook->nodesRefCount)
- n->member->deref();
- n->next->prev = n->prev;
- n->prev->next = n->next;
- delete n;
- }
-}
-
-void List::refAll()
-{
- for (ListNode *n = hook->next; n != hook; n = n->next)
- n->member->ref();
-}
-
-void List::derefAll()
-{
- for (ListNode *n = hook->next; n != hook; n = n->next)
- n->member->deref();
-}
-
-void List::swap(List &other)
-{
- ListHookNode *tmp = hook;
- hook = other.hook;
- other.hook = tmp;
-}
-
-void List::replaceFirst(ValueImp *v)
-{
- ListNode *n = hook->next;
- if (hook->nodesRefCount) {
- v->ref();
- n->member->deref();
- }
- n->member = v;
-}
-
-void List::replaceLast(ValueImp *v)
-{
- ListNode *n = hook->prev;
- if (hook->nodesRefCount) {
- v->ref();
- n->member->deref();
- }
- n->member = v;
+ static List emptyList;
+ return emptyList;
}
} // namespace KJS
diff --git a/JavaScriptCore/kjs/list.h b/JavaScriptCore/kjs/list.h
index 5941887..73761d7 100644
--- a/JavaScriptCore/kjs/list.h
+++ b/JavaScriptCore/kjs/list.h
@@ -1,7 +1,7 @@
/*
* This file is part of the KDE libraries
* Copyright (C) 1999-2001 Harri Porten (porten at kde.org)
- * Copyright (C) 2001 Peter Kelly (pmk at post.com)
+ * Copyright (C) 2002 Apple Computer, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -27,149 +27,158 @@
namespace KJS {
- class List;
- class ListIterator;
- class ListNode;
- class ListHookNode;
-
- /**
- * @short Iterator for @ref KJS::List objects.
- */
- class ListIterator {
- friend class List;
- ListIterator() : node(0) { }
- ListIterator(ListNode *n) : node(n) { }
- public:
- /**
- * Construct an iterator that points to the first element of the list.
- * @param l The list the iterator will operate on.
- */
- ListIterator(const List &l);
- /**
- * Dereference the iterator.
- * @return A pointer to the element the iterator operates on.
- */
- ValueImp* operator->() const;
- Value operator*() const;
- /**
- * Postfix increment operator.
- * @return The element after the increment.
- */
- Value operator++();
- /**
- * Prefix increment operator.
- */
- Value operator++(int);
- /**
- * Postfix decrement operator.
- */
- Value operator--();
- /**
- * Prefix decrement operator.
- */
- Value operator--(int);
- /**
- * Compare the iterator with another one.
- * @return True if the two iterators operate on the same list element.
- * False otherwise.
- */
- bool operator==(const ListIterator &it) const { return node == it.node; }
- /**
- * Check for inequality with another iterator.
- * @return True if the two iterators operate on different list elements.
- */
- bool operator!=(const ListIterator &it) const { return node != it.node; }
- private:
- ListNode *node;
- };
-
- /**
- * @short Native list type.
- *
- * List is a native ECMAScript type. List values are only used for
- * intermediate results of expression evaluation and cannot be stored
- * as properties of objects.
- *
- * The list is explicitly shared. Note that while copy() returns a
- * copy of the list the referenced objects are still shared.
- */
- class List {
- friend class ListIterator;
- public:
- List();
- List(const List& l);
- List &operator=(const List& l);
-
- ~List();
-
- List copyTail() const { List result = copy(); result.removeFirst(); return result; }
+ struct ListImpBase {
+ int size;
+ int refCount;
+ };
+
+ class ListIterator;
/**
- * Append an object to the end of the list.
+ * @short Native list type.
*
- * @param val Pointer to object.
- */
- void append(const Value& val);
- void append(ValueImp *val);
- /**
- * Remove all elements from the list.
- */
- void clear();
-
- /**
- * @return A @ref KJS::ListIterator pointing to the first element.
- */
- ListIterator begin() const;
- /**
- * @return A @ref KJS::ListIterator pointing to the last element.
- */
- ListIterator end() const;
- /**
- * @return true if the list is empty. false otherwise.
- */
- bool isEmpty() const;
- /**
- * @return the current size of the list.
- */
- int size() const;
- /**
- * Retrieve an element at an indexed position. If you want to iterate
- * trough the whole list using @ref KJS::ListIterator will be faster.
+ * List is a native ECMAScript type. List values are only used for
+ * intermediate results of expression evaluation and cannot be stored
+ * as properties of objects.
*
- * @param i List index.
- * @return Return the element at position i. @ref KJS::Undefined if the
- * index is out of range.
+ * The list is explicitly shared. Note that while copyTail() returns a
+ * copy of the list the referenced objects are still shared.
*/
- Value at(int i) const;
- /**
- * Equivalent to @ref at.
- */
- Value operator[](int i) const;
+ class List {
+ public:
+ List();
+ ~List() { deref(); }
- /**
- * Returns a pointer to a static instance of an empty list. Useful if a
- * function has a @ref KJS::List parameter.
- */
- static const List &empty();
+ List(const List &b) : _impBase(b._impBase) { ++_impBase->refCount; }
+ List &operator=(const List &);
+
+ /**
+ * Append an object to the end of the list.
+ *
+ * @param val Pointer to object.
+ */
+ void append(const Value& val) { append(val.imp()); }
+ void append(ValueImp *val);
+ /**
+ * Remove all elements from the list.
+ */
+ void clear();
+ /**
+ * Make a copy of the list, omitting the first element.
+ */
+ List copyTail() const;
- void replaceFirst(ValueImp *);
- void replaceLast(ValueImp *);
+ /**
+ * @return true if the list is empty. false otherwise.
+ */
+ bool isEmpty() const { return _impBase->size == 0; }
+ /**
+ * @return the current size of the list.
+ */
+ int size() const { return _impBase->size; }
+ /**
+ * @return A @ref KJS::ListIterator pointing to the first element.
+ */
+ ListIterator begin() const;
+ /**
+ * @return A @ref KJS::ListIterator pointing to the last element.
+ */
+ ListIterator end() const;
+
+ /**
+ * Retrieve an element at an indexed position. If you want to iterate
+ * trough the whole list using @ref KJS::ListIterator will be faster.
+ *
+ * @param i List index.
+ * @return Return the element at position i. @ref KJS::Undefined if the
+ * index is out of range.
+ */
+ Value at(int i) const { return Value(impAt(i)); }
+ /**
+ * Equivalent to @ref at.
+ */
+ Value operator[](int i) const { return Value(impAt(i)); }
+
+ ValueImp *impAt(int i) const;
- private:
+ /**
+ * Returns a pointer to a static instance of an empty list. Useful if a
+ * function has a @ref KJS::List parameter.
+ */
+ static const List &empty();
+
+ private:
+ ListImpBase *_impBase;
+
+ void deref() { if (--_impBase->refCount == 0) release(); }
- void removeFirst();
- List copy() const;
- void prepend(ValueImp *val);
- void prependList(const List& lst);
- void erase(ListNode *n);
- void clearInternal();
- void refAll();
- void derefAll();
- void swap(List &other);
-
- ListHookNode *hook;
- };
+ void release();
+ void derefValues();
+ };
-}; // namespace KJS
+ /**
+ * @short Iterator for @ref KJS::List objects.
+ */
+ class ListIterator {
+ public:
+ /**
+ * Construct an iterator that points to the first element of the list.
+ * @param l The list the iterator will operate on.
+ */
+ ListIterator(const List &l) : _list(&l), _i(0) { }
+ ListIterator(const List &l, int index) : _list(&l), _i(index) { }
+ /**
+ * Dereference the iterator.
+ * @return A pointer to the element the iterator operates on.
+ */
+ ValueImp *operator->() const { return _list->impAt(_i); }
+ Value operator*() const { return Value(_list->impAt(_i)); }
+ /**
+ * Prefix increment operator.
+ * @return The element after the increment.
+ */
+ Value operator++() { return Value(_list->impAt(++_i)); }
+ /**
+ * Postfix increment operator.
+ */
+ Value operator++(int) { return Value(_list->impAt(_i++)); }
+ /**
+ * Prefix decrement operator.
+ */
+ Value operator--() { return Value(_list->impAt(--_i)); }
+ /**
+ * Postfix decrement operator.
+ */
+ Value operator--(int) { return Value(_list->impAt(_i--)); }
+ /**
+ * Compare the iterator with another one.
+ * @return True if the two iterators operate on the same list element.
+ * False otherwise.
+ */
+ bool operator==(const ListIterator &it) const { return _i == it._i; }
+ /**
+ * Check for inequality with another iterator.
+ * @return True if the two iterators operate on different list elements.
+ */
+ bool operator!=(const ListIterator &it) const { return _i != it._i; }
+
+ private:
+ const List *_list;
+ int _i;
+ };
+
+ inline ListIterator List::begin() const { return ListIterator(*this); }
+ inline ListIterator List::end() const { return ListIterator(*this, size()); }
+
+ inline List &List::operator=(const List &b)
+ {
+ ListImpBase *bImpBase = b._impBase;
+ ++bImpBase->refCount;
+ deref();
+ _impBase = bImpBase;
+ return *this;
+ }
+
+ }; // namespace KJS
#endif // KJS_LIST_H
diff --git a/WebCore/ChangeLog-2002-12-03 b/WebCore/ChangeLog-2002-12-03
index 40fdf9c..825389f 100644
--- a/WebCore/ChangeLog-2002-12-03
+++ b/WebCore/ChangeLog-2002-12-03
@@ -1,3 +1,14 @@
+2002-11-22 Darin Adler <darin at apple.com>
+
+ * khtml/ecma/kjs_window.cpp: Remove _COLLECTOR hack.
+
+ * kwq/WebCoreJavaScript.h:
+ * kwq/WebCoreJavaScript.mm:
+ (+[WebCoreJavaScript rootObjectClasses]):
+ Update for name change -- root object classes, not all live object classes.
+
+ * force-js-clean-timestamp: Make sure we don't have more build problems.
+
2002-11-22 David Hyatt <hyatt at apple.com>
Fix for 3107658, text doubling problem caused by layers being
diff --git a/WebCore/ChangeLog-2003-10-25 b/WebCore/ChangeLog-2003-10-25
index 40fdf9c..825389f 100644
--- a/WebCore/ChangeLog-2003-10-25
+++ b/WebCore/ChangeLog-2003-10-25
@@ -1,3 +1,14 @@
+2002-11-22 Darin Adler <darin at apple.com>
+
+ * khtml/ecma/kjs_window.cpp: Remove _COLLECTOR hack.
+
+ * kwq/WebCoreJavaScript.h:
+ * kwq/WebCoreJavaScript.mm:
+ (+[WebCoreJavaScript rootObjectClasses]):
+ Update for name change -- root object classes, not all live object classes.
+
+ * force-js-clean-timestamp: Make sure we don't have more build problems.
+
2002-11-22 David Hyatt <hyatt at apple.com>
Fix for 3107658, text doubling problem caused by layers being
diff --git a/WebCore/ChangeLog-2005-08-23 b/WebCore/ChangeLog-2005-08-23
index 40fdf9c..825389f 100644
--- a/WebCore/ChangeLog-2005-08-23
+++ b/WebCore/ChangeLog-2005-08-23
@@ -1,3 +1,14 @@
+2002-11-22 Darin Adler <darin at apple.com>
+
+ * khtml/ecma/kjs_window.cpp: Remove _COLLECTOR hack.
+
+ * kwq/WebCoreJavaScript.h:
+ * kwq/WebCoreJavaScript.mm:
+ (+[WebCoreJavaScript rootObjectClasses]):
+ Update for name change -- root object classes, not all live object classes.
+
+ * force-js-clean-timestamp: Make sure we don't have more build problems.
+
2002-11-22 David Hyatt <hyatt at apple.com>
Fix for 3107658, text doubling problem caused by layers being
diff --git a/WebCore/force-js-clean-timestamp b/WebCore/force-js-clean-timestamp
index 6efee9f..729a290 100644
--- a/WebCore/force-js-clean-timestamp
+++ b/WebCore/force-js-clean-timestamp
@@ -1 +1 @@
-ScopeChain API 11/21 - Darin
+List 11/22 - Darin
diff --git a/WebCore/khtml/ecma/kjs_window.cpp b/WebCore/khtml/ecma/kjs_window.cpp
index 5fadf97..8d31780 100644
--- a/WebCore/khtml/ecma/kjs_window.cpp
+++ b/WebCore/khtml/ecma/kjs_window.cpp
@@ -35,7 +35,6 @@
#if APPLE_CHANGES
#include "KWQLogging.h"
-#define _COLLECTOR
#endif
#include <kjs/collector.h>
#include "kjs_proxy.h"
diff --git a/WebCore/kwq/WebCoreJavaScript.h b/WebCore/kwq/WebCoreJavaScript.h
index 7379678..31119d5 100644
--- a/WebCore/kwq/WebCoreJavaScript.h
+++ b/WebCore/kwq/WebCoreJavaScript.h
@@ -34,7 +34,7 @@
+ (int)objectCount;
+ (int)noGCAllowedObjectCount;
+ (int)referencedObjectCount;
-+ (NSSet *)liveObjectClasses;
++ (NSSet *)rootObjectClasses;
+ (void)garbageCollect;
diff --git a/WebCore/kwq/WebCoreJavaScript.mm b/WebCore/kwq/WebCoreJavaScript.mm
index d5c54ac..e579bfd 100644
--- a/WebCore/kwq/WebCoreJavaScript.mm
+++ b/WebCore/kwq/WebCoreJavaScript.mm
@@ -51,9 +51,9 @@ using KJS::Collector;
return Collector::numReferencedObjects();
}
-+ (NSSet *)liveObjectClasses
++ (NSSet *)rootObjectClasses
{
- return [(NSSet *)Collector::liveObjectClasses() autorelease];
+ return [(NSSet *)Collector::rootObjectClasses() autorelease];
}
+ (void)garbageCollect
diff --git a/WebKit/ChangeLog b/WebKit/ChangeLog
index 6a3ac76..60c2f41 100644
--- a/WebKit/ChangeLog
+++ b/WebKit/ChangeLog
@@ -1,3 +1,10 @@
+2002-11-22 Darin Adler <darin at apple.com>
+
+ * Misc.subproj/WebCoreStatistics.h:
+ * Misc.subproj/WebCoreStatistics.m:
+ (+[WebCoreStatistics javaScriptRootObjectClasses]):
+ Update for name change -- root object classes, not all live object classes.
+
2002-11-22 Chris Blumenberg <cblu at apple.com>
Fixed assertion while loading local files.
diff --git a/WebKit/ChangeLog-2002-12-03 b/WebKit/ChangeLog-2002-12-03
index 6a3ac76..60c2f41 100644
--- a/WebKit/ChangeLog-2002-12-03
+++ b/WebKit/ChangeLog-2002-12-03
@@ -1,3 +1,10 @@
+2002-11-22 Darin Adler <darin at apple.com>
+
+ * Misc.subproj/WebCoreStatistics.h:
+ * Misc.subproj/WebCoreStatistics.m:
+ (+[WebCoreStatistics javaScriptRootObjectClasses]):
+ Update for name change -- root object classes, not all live object classes.
+
2002-11-22 Chris Blumenberg <cblu at apple.com>
Fixed assertion while loading local files.
diff --git a/WebKit/Misc.subproj/WebCoreStatistics.h b/WebKit/Misc.subproj/WebCoreStatistics.h
index 136084f..e287b2d 100644
--- a/WebKit/Misc.subproj/WebCoreStatistics.h
+++ b/WebKit/Misc.subproj/WebCoreStatistics.h
@@ -20,7 +20,7 @@
+ (int)javaScriptInterpretersCount;
+ (int)javaScriptNoGCAllowedObjectsCount;
+ (int)javaScriptReferencedObjectsCount;
-+ (NSSet *)javaScriptLiveObjectClasses;
++ (NSSet *)javaScriptRootObjectClasses;
+ (void)garbageCollectJavaScriptObjects;
@end
diff --git a/WebKit/Misc.subproj/WebCoreStatistics.m b/WebKit/Misc.subproj/WebCoreStatistics.m
index 5973dba..cf3ad83 100644
--- a/WebKit/Misc.subproj/WebCoreStatistics.m
+++ b/WebKit/Misc.subproj/WebCoreStatistics.m
@@ -48,9 +48,9 @@
return [WebCoreJavaScript referencedObjectCount];
}
-+ (NSSet *)javaScriptLiveObjectClasses
++ (NSSet *)javaScriptRootObjectClasses
{
- return [WebCoreJavaScript liveObjectClasses];
+ return [WebCoreJavaScript rootObjectClasses];
}
+ (void)garbageCollectJavaScriptObjects
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list