+2002-11-18 Darin Adler <darin@apple.com>
+
+ - reduced the creation of Value objects and hoisted the property map
+ into Object for another gain of about 6%
+
+ * JavaScriptCore.pbproj/project.pbxproj: Made property_map.h public.
+ * kjs/array_object.cpp:
+ (compareWithCompareFunctionForQSort): Don't wrap the ValueImp * in a Value
+ just to add it to a list.
+ (ArrayProtoFuncImp::call): Pass the globalObject directly so we don't have
+ to ref/deref.
+ * kjs/function.cpp:
+ (FunctionImp::call): Use a reference for the global object to avoid ref/deref.
+ (GlobalFuncImp::call): Ditto.
+ * kjs/internal.cpp:
+ (BooleanImp::toObject): Put the object directly into the list, don't create a Value.
+ (StringImp::toObject): Ditto.
+ (NumberImp::toObject): Ditto.
+ (InterpreterImp::evaluate): Use a reference for the global object.
+ * kjs/internal.h: Return a reference for the global object.
+ * kjs/interpreter.cpp: (Interpreter::globalObject): Ditto.
+ * kjs/interpreter.h: Ditto.
+ * kjs/object.cpp: Use _prop directly in the object, not a separate pointer.
+ * kjs/object.h: Ditto.
+ * kjs/types.cpp: Added List methods that work directly with ValueImp.
+ (List::append): Added a ValueImp version.
+ (List::prepend): Ditto.
+ (List::appendList): Work directly with the ValueImp's.
+ (List::prependList): Ditto.
+ (List::copy): Use appendList.
+ (List::empty): Use a shared global List.
+ * kjs/types.h: Update for above changes.
+
2002-11-18 Darin Adler <darin@apple.com>
* kjs/property_map.cpp: Oops, copyright goes to Apple, not me.
+2002-11-18 Darin Adler <darin@apple.com>
+
+ - reduced the creation of Value objects and hoisted the property map
+ into Object for another gain of about 6%
+
+ * JavaScriptCore.pbproj/project.pbxproj: Made property_map.h public.
+ * kjs/array_object.cpp:
+ (compareWithCompareFunctionForQSort): Don't wrap the ValueImp * in a Value
+ just to add it to a list.
+ (ArrayProtoFuncImp::call): Pass the globalObject directly so we don't have
+ to ref/deref.
+ * kjs/function.cpp:
+ (FunctionImp::call): Use a reference for the global object to avoid ref/deref.
+ (GlobalFuncImp::call): Ditto.
+ * kjs/internal.cpp:
+ (BooleanImp::toObject): Put the object directly into the list, don't create a Value.
+ (StringImp::toObject): Ditto.
+ (NumberImp::toObject): Ditto.
+ (InterpreterImp::evaluate): Use a reference for the global object.
+ * kjs/internal.h: Return a reference for the global object.
+ * kjs/interpreter.cpp: (Interpreter::globalObject): Ditto.
+ * kjs/interpreter.h: Ditto.
+ * kjs/object.cpp: Use _prop directly in the object, not a separate pointer.
+ * kjs/object.h: Ditto.
+ * kjs/types.cpp: Added List methods that work directly with ValueImp.
+ (List::append): Added a ValueImp version.
+ (List::prepend): Ditto.
+ (List::appendList): Work directly with the ValueImp's.
+ (List::prependList): Ditto.
+ (List::copy): Use appendList.
+ (List::empty): Use a shared global List.
+ * kjs/types.h: Update for above changes.
+
2002-11-18 Darin Adler <darin@apple.com>
* kjs/property_map.cpp: Oops, copyright goes to Apple, not me.
+2002-11-18 Darin Adler <darin@apple.com>
+
+ - reduced the creation of Value objects and hoisted the property map
+ into Object for another gain of about 6%
+
+ * JavaScriptCore.pbproj/project.pbxproj: Made property_map.h public.
+ * kjs/array_object.cpp:
+ (compareWithCompareFunctionForQSort): Don't wrap the ValueImp * in a Value
+ just to add it to a list.
+ (ArrayProtoFuncImp::call): Pass the globalObject directly so we don't have
+ to ref/deref.
+ * kjs/function.cpp:
+ (FunctionImp::call): Use a reference for the global object to avoid ref/deref.
+ (GlobalFuncImp::call): Ditto.
+ * kjs/internal.cpp:
+ (BooleanImp::toObject): Put the object directly into the list, don't create a Value.
+ (StringImp::toObject): Ditto.
+ (NumberImp::toObject): Ditto.
+ (InterpreterImp::evaluate): Use a reference for the global object.
+ * kjs/internal.h: Return a reference for the global object.
+ * kjs/interpreter.cpp: (Interpreter::globalObject): Ditto.
+ * kjs/interpreter.h: Ditto.
+ * kjs/object.cpp: Use _prop directly in the object, not a separate pointer.
+ * kjs/object.h: Ditto.
+ * kjs/types.cpp: Added List methods that work directly with ValueImp.
+ (List::append): Added a ValueImp version.
+ (List::prepend): Ditto.
+ (List::appendList): Work directly with the ValueImp's.
+ (List::prependList): Ditto.
+ (List::copy): Use appendList.
+ (List::empty): Use a shared global List.
+ * kjs/types.h: Update for above changes.
+
2002-11-18 Darin Adler <darin@apple.com>
* kjs/property_map.cpp: Oops, copyright goes to Apple, not me.
fileRef = F692A87A0255597D01FF60F7;
isa = PBXBuildFile;
settings = {
+ ATTRIBUTES = (
+ Private,
+ );
};
};
F692A8B70255597D01FF60F7 = {
CompareWithCompareFunctionArguments *args = compareWithCompareFunctionArguments;
args->arguments.clear();
- args->arguments.append(Value(*(ValueImp **)a));
- args->arguments.append(Value(*(ValueImp **)b));
+ args->arguments.append(*(ValueImp **)a);
+ args->arguments.append(*(ValueImp **)b);
return args->compareFunction->call(args->exec, args->globalObject, args->arguments)
.toInt32(args->exec);
}
List l;
l.append(jObj);
l.append(minObj);
- Object thisObj = exec->interpreter()->globalObject();
- cmp = sortFunction.call(exec,thisObj, l ).toInt32(exec);
+ cmp = sortFunction.call(exec, exec->interpreter()->globalObject(), l).toInt32(exec);
} else {
cmp = (jObj.toString(exec) < minObj.toString(exec)) ? -1 : 1;
}
Value FunctionImp::call(ExecState *exec, Object &thisObj, const List &args)
{
- Object globalObj = exec->interpreter()->globalObject();
+ Object &globalObj = exec->interpreter()->globalObject();
Debugger *dbg = exec->interpreter()->imp()->debugger();
int sid = -1;
progNode->ref();
// enter a new execution context
- Object glob(exec->interpreter()->globalObject());
Object thisVal(Object::dynamicCast(exec->context().thisValue()));
- ContextImp *ctx = new ContextImp(glob,
+ ContextImp *ctx = new ContextImp(exec->interpreter()->globalObject(),
exec,
thisVal,
EvalCode,
Object BooleanImp::toObject(ExecState *exec) const
{
List args;
- args.append(Boolean(const_cast<BooleanImp*>(this)));
+ args.append(const_cast<BooleanImp*>(this));
return Object::dynamicCast(exec->interpreter()->builtinBoolean().construct(exec,args));
}
Object StringImp::toObject(ExecState *exec) const
{
List args;
- args.append(Value(const_cast<StringImp*>(this)));
+ args.append(const_cast<StringImp*>(this));
return Object::dynamicCast(exec->interpreter()->builtinString().construct(exec,args));
}
Object NumberImp::toObject(ExecState *exec) const
{
List args;
- args.append(Number(const_cast<NumberImp*>(this)));
+ args.append(const_cast<NumberImp*>(this));
return Object::dynamicCast(exec->interpreter()->builtinNumber().construct(exec,args));
}
recursion++;
progNode->ref();
- Object globalObj = globalObject();
+ Object &globalObj = globalObject();
Object thisObj = globalObject();
if (!thisV.isNull()) {
InterpreterImp(Interpreter *interp, const Object &glob);
~InterpreterImp();
- Object globalObject() const { return global; }
+ Object &globalObject() const { return const_cast<Object &>(global); }
Interpreter* interpreter() const { return m_interpreter; }
void initGlobalObject();
delete rep;
}
-Object Interpreter::globalObject() const
+Object &Interpreter::globalObject() const
{
return rep->globalObject();
}
* Returns the object that is used as the global object during all script
* execution performed by this interpreter
*/
- Object globalObject() const;
+ Object &globalObject() const;
void initGlobalObject();
#include "operations.h"
#include "error_object.h"
#include "nodes.h"
-#include "property_map.h"
namespace KJS {
// ------------------------------ ObjectImp ------------------------------------
ObjectImp::ObjectImp(const Object &proto)
- : _prop(0), _proto(static_cast<ObjectImp*>(proto.imp())), _internalValue(0L), _scope(true)
+ : _proto(static_cast<ObjectImp*>(proto.imp())), _internalValue(0L), _scope(true)
{
//fprintf(stderr,"ObjectImp::ObjectImp %p\n",(void*)this);
- _prop = new PropertyMap();
}
ObjectImp::ObjectImp() :
_scope(true)
{
//fprintf(stderr,"ObjectImp::ObjectImp %p\n",(void*)this);
- _prop = 0;
_proto = NullImp::staticNull;
_internalValue = 0L;
- _prop = new PropertyMap();
}
ObjectImp::~ObjectImp()
{
//fprintf(stderr,"ObjectImp::~ObjectImp %p\n",(void*)this);
- delete _prop;
}
void ObjectImp::mark()
if (_proto && !_proto->marked())
_proto->mark();
- _prop->mark();
+ _prop.mark();
if (_internalValue && !_internalValue->marked())
_internalValue->mark();
// to look up in the prototype, it might already exist there)
ValueImp* ObjectImp::getDirect(const UString& propertyName) const
{
- return _prop->get(propertyName);
+ return _prop.get(propertyName);
}
// ECMA 8.6.2.2
return;
}
- _prop->put(propertyName,value.imp(),attr);
+ _prop.put(propertyName,value.imp(),attr);
}
void ObjectImp::put(ExecState *exec, unsigned propertyName,
bool ObjectImp::canPut(ExecState *, const UString &propertyName) const
{
int attributes;
- ValueImp *v = _prop->get(propertyName, attributes);
+ ValueImp *v = _prop.get(propertyName, attributes);
if (v)
return!(attributes & ReadOnly);
// ECMA 8.6.2.4
bool ObjectImp::hasProperty(ExecState *exec, const UString &propertyName) const
{
- if (_prop->get(propertyName))
+ if (_prop.get(propertyName))
return true;
// Look in the static hashtable of properties
bool ObjectImp::deleteProperty(ExecState */*exec*/, const UString &propertyName)
{
int attributes;
- ValueImp *v = _prop->get(propertyName, attributes);
+ ValueImp *v = _prop.get(propertyName, attributes);
if (v) {
if ((attributes & DontDelete))
return false;
- _prop->remove(propertyName);
+ _prop.remove(propertyName);
return true;
}
void ObjectImp::deleteAllProperties( ExecState * )
{
- _prop->clear();
+ _prop.clear();
}
// ECMA 8.6.2.6
if (_proto && _proto->dispatchType() == ObjectType && recursive)
list = static_cast<ObjectImp*>(_proto)->propList(exec,recursive);
- _prop->addEnumerablesToReferenceList(list, Object(this));
+ _prop.addEnumerablesToReferenceList(list, Object(this));
// Add properties from the static hashtable of properties
const ClassInfo *info = classInfo();
#include "value.h"
#include "types.h"
#include "reference_list.h"
+#include "property_map.h"
namespace KJS {
- class PropertyMap;
class HashTable;
class HashEntry;
class ListImp;
ValueImp* getDirect(const UString& propertyName) const;
private:
const HashEntry* findPropertyHashEntry( const UString& propertyName ) const;
- PropertyMap *_prop;
+ PropertyMap _prop;
ValueImp *_proto;
ValueImp *_internalValue;
List _scope;
protected:
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;
};
// ------------------------------ ListIterator ---------------------------------
-ListIterator::ListIterator(ListNode *n) : node(n)
-{
-}
-
-ListIterator::ListIterator(const List &l)
- : node(l.hook->next)
-{
-}
-
ValueImp* ListIterator::operator->() const
{
return node->member;
}
-// operator Value* () const { return node->member; }
Value ListIterator::operator*() const
{
return Value(node->member);
}
-// operator Value*() const { return node->member; }
Value ListIterator::operator++()
{
node = node->next;
return Value(n->member);
}
-bool ListIterator::operator==(const ListIterator &it) const
-{
- return (node==it.node);
-}
-
-bool ListIterator::operator!=(const ListIterator &it) const
-{
- return (node!=it.node);
-}
-
// ------------------------------ List -----------------------------------------
List::List(bool needsMarking)
hook->prev = n;
}
+void List::append(ValueImp *val)
+{
+ ListNode *n = new ListNode(val, hook->prev, hook);
+ if (!m_needsMarking) {
+ val->ref();
+ }
+ hook->prev->next = n;
+ hook->prev = n;
+}
+
void List::prepend(const Value& val)
{
ListNode *n = new ListNode(val, hook, hook->next);
hook->next = n;
}
+void List::prepend(ValueImp *val)
+{
+ ListNode *n = new ListNode(val, hook->prev, hook);
+ if (!m_needsMarking) {
+ val->ref();
+ }
+ hook->next->prev = n;
+ hook->next = n;
+}
+
void List::appendList(const List& lst)
{
- ListIterator it = lst.begin();
- ListIterator e = lst.end();
- while(it != e) {
- append(*it);
- ++it;
+ ListNode *otherHook = lst.hook;
+ ListNode *o = otherHook->next;
+ while (o != otherHook) {
+ append(o->member);
+ o = o->next;
}
}
void List::prependList(const List& lst)
{
- ListIterator it = lst.end();
- ListIterator e = lst.begin();
- while(it != e) {
- --it;
- prepend(*it);
+ ListNode *otherHook = lst.hook;
+ ListNode *o = otherHook->prev;
+ while (o != otherHook) {
+ prepend(o->member);
+ o = o->prev;
}
}
List List::copy() const
{
List newList;
-
- ListIterator e = end();
- ListIterator it = begin();
-
- while(it != e) {
- newList.append(*it);
- ++it;
- }
-
+ newList.appendList(*this);
return newList;
}
return at(i);
}
-const List List::empty()
+const List &List::empty()
{
- return List();
+ static List l;
+ return l;
}
*/
class ListIterator {
friend class List;
- ListIterator();
- ListIterator(ListNode *n);
+ ListIterator() : node(0) { }
+ ListIterator(ListNode *n) : node(n) { }
public:
/**
* Construct an iterator that points to the first element of the list.
* @return A pointer to the element the iterator operates on.
*/
ValueImp* operator->() const;
- // operator Value* () const { return node->member; }
Value operator*() const;
- /**
- * Conversion to @ref KJS::Value*
- * @return A pointer to the element the iterator operates on.
- */
- // operator Value*() const { return node->member; }
/**
* Postfix increment operator.
* @return The element after the increment.
* @return True if the two iterators operate on the same list element.
* False otherwise.
*/
- bool operator==(const ListIterator &it) const;
+ 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;
+ bool operator!=(const ListIterator &it) const { return node != it.node; }
private:
ListNode *node;
};
* @param val Pointer to object.
*/
void append(const Value& val);
+ void append(ValueImp *val);
/**
* Insert an object at the beginning of the list.
*
* @param val Pointer to object.
*/
void prepend(const Value& val);
+ void prepend(ValueImp *val);
/**
* Appends the items of another list at the end of this one.
*/
* Remove val from list.
*/
void remove(const Value &val);
+ void remove(ValueImp *val);
/**
* Remove all elements from the list.
*/
* 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();
+ static const List &empty();
#ifdef KJS_DEBUG_MEM
static void globalClear();
#endif
+2002-11-18 Darin Adler <darin@apple.com>
+
+ * force-js-clean-timestamp: Another Object change.
+
2002-11-18 David Hyatt <hyatt@apple.com>
Implement phased painting to correct the paint order of blocks,
+2002-11-18 Darin Adler <darin@apple.com>
+
+ * force-js-clean-timestamp: Another Object change.
+
2002-11-18 David Hyatt <hyatt@apple.com>
Implement phased painting to correct the paint order of blocks,
+2002-11-18 Darin Adler <darin@apple.com>
+
+ * force-js-clean-timestamp: Another Object change.
+
2002-11-18 David Hyatt <hyatt@apple.com>
Implement phased painting to correct the paint order of blocks,
-Object field removed 11/18 - Darin
+property maps hoisted in Object 11/18 - Darin