Changeset 2753 in webkit for trunk/JavaScriptCore


Ignore:
Timestamp:
Nov 18, 2002, 11:57:11 PM (23 years ago)
Author:
darin
Message:

JavaScriptCore:

  • 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.

WebCore:

  • force-js-clean-timestamp: Another Object change.
Location:
trunk/JavaScriptCore
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/ChangeLog

    r2751 r2753  
     12002-11-18  Darin Adler  <[email protected]>
     2
     3        - reduced the creation of Value objects and hoisted the property map
     4        into Object for another gain of about 6%
     5
     6        * JavaScriptCore.pbproj/project.pbxproj: Made property_map.h public.
     7        * kjs/array_object.cpp:
     8        (compareWithCompareFunctionForQSort): Don't wrap the ValueImp * in a Value
     9        just to add it to a list.
     10        (ArrayProtoFuncImp::call): Pass the globalObject directly so we don't have
     11        to ref/deref.
     12        * kjs/function.cpp:
     13        (FunctionImp::call): Use a reference for the global object to avoid ref/deref.
     14        (GlobalFuncImp::call): Ditto.
     15        * kjs/internal.cpp:
     16        (BooleanImp::toObject): Put the object directly into the list, don't create a Value.
     17        (StringImp::toObject): Ditto.
     18        (NumberImp::toObject): Ditto.
     19        (InterpreterImp::evaluate): Use a reference for the global object.
     20        * kjs/internal.h: Return a reference for the global object.
     21        * kjs/interpreter.cpp: (Interpreter::globalObject): Ditto.
     22        * kjs/interpreter.h: Ditto.
     23        * kjs/object.cpp: Use _prop directly in the object, not a separate pointer.
     24        * kjs/object.h: Ditto.
     25        * kjs/types.cpp: Added List methods that work directly with ValueImp.
     26        (List::append): Added a ValueImp version.
     27        (List::prepend): Ditto.
     28        (List::appendList): Work directly with the ValueImp's.
     29        (List::prependList): Ditto.
     30        (List::copy): Use appendList.
     31        (List::empty): Use a shared global List.
     32        * kjs/types.h: Update for above changes.
     33
    1342002-11-18  Darin Adler  <[email protected]>
    235
  • trunk/JavaScriptCore/ChangeLog-2002-12-03

    r2751 r2753  
     12002-11-18  Darin Adler  <[email protected]>
     2
     3        - reduced the creation of Value objects and hoisted the property map
     4        into Object for another gain of about 6%
     5
     6        * JavaScriptCore.pbproj/project.pbxproj: Made property_map.h public.
     7        * kjs/array_object.cpp:
     8        (compareWithCompareFunctionForQSort): Don't wrap the ValueImp * in a Value
     9        just to add it to a list.
     10        (ArrayProtoFuncImp::call): Pass the globalObject directly so we don't have
     11        to ref/deref.
     12        * kjs/function.cpp:
     13        (FunctionImp::call): Use a reference for the global object to avoid ref/deref.
     14        (GlobalFuncImp::call): Ditto.
     15        * kjs/internal.cpp:
     16        (BooleanImp::toObject): Put the object directly into the list, don't create a Value.
     17        (StringImp::toObject): Ditto.
     18        (NumberImp::toObject): Ditto.
     19        (InterpreterImp::evaluate): Use a reference for the global object.
     20        * kjs/internal.h: Return a reference for the global object.
     21        * kjs/interpreter.cpp: (Interpreter::globalObject): Ditto.
     22        * kjs/interpreter.h: Ditto.
     23        * kjs/object.cpp: Use _prop directly in the object, not a separate pointer.
     24        * kjs/object.h: Ditto.
     25        * kjs/types.cpp: Added List methods that work directly with ValueImp.
     26        (List::append): Added a ValueImp version.
     27        (List::prepend): Ditto.
     28        (List::appendList): Work directly with the ValueImp's.
     29        (List::prependList): Ditto.
     30        (List::copy): Use appendList.
     31        (List::empty): Use a shared global List.
     32        * kjs/types.h: Update for above changes.
     33
    1342002-11-18  Darin Adler  <[email protected]>
    235
  • trunk/JavaScriptCore/ChangeLog-2003-10-25

    r2751 r2753  
     12002-11-18  Darin Adler  <[email protected]>
     2
     3        - reduced the creation of Value objects and hoisted the property map
     4        into Object for another gain of about 6%
     5
     6        * JavaScriptCore.pbproj/project.pbxproj: Made property_map.h public.
     7        * kjs/array_object.cpp:
     8        (compareWithCompareFunctionForQSort): Don't wrap the ValueImp * in a Value
     9        just to add it to a list.
     10        (ArrayProtoFuncImp::call): Pass the globalObject directly so we don't have
     11        to ref/deref.
     12        * kjs/function.cpp:
     13        (FunctionImp::call): Use a reference for the global object to avoid ref/deref.
     14        (GlobalFuncImp::call): Ditto.
     15        * kjs/internal.cpp:
     16        (BooleanImp::toObject): Put the object directly into the list, don't create a Value.
     17        (StringImp::toObject): Ditto.
     18        (NumberImp::toObject): Ditto.
     19        (InterpreterImp::evaluate): Use a reference for the global object.
     20        * kjs/internal.h: Return a reference for the global object.
     21        * kjs/interpreter.cpp: (Interpreter::globalObject): Ditto.
     22        * kjs/interpreter.h: Ditto.
     23        * kjs/object.cpp: Use _prop directly in the object, not a separate pointer.
     24        * kjs/object.h: Ditto.
     25        * kjs/types.cpp: Added List methods that work directly with ValueImp.
     26        (List::append): Added a ValueImp version.
     27        (List::prepend): Ditto.
     28        (List::appendList): Work directly with the ValueImp's.
     29        (List::prependList): Ditto.
     30        (List::copy): Use appendList.
     31        (List::empty): Use a shared global List.
     32        * kjs/types.h: Update for above changes.
     33
    1342002-11-18  Darin Adler  <[email protected]>
    235
  • trunk/JavaScriptCore/JavaScriptCore.pbproj/project.pbxproj

    r2083 r2753  
    13321332                        isa = PBXBuildFile;
    13331333                        settings = {
     1334                                ATTRIBUTES = (
     1335                                        Private,
     1336                                );
    13341337                        };
    13351338                };
  • trunk/JavaScriptCore/kjs/array_object.cpp

    r2738 r2753  
    230230   
    231231    args->arguments.clear();
    232     args->arguments.append(Value(*(ValueImp **)a));
    233     args->arguments.append(Value(*(ValueImp **)b));
     232    args->arguments.append(*(ValueImp **)a);
     233    args->arguments.append(*(ValueImp **)b);
    234234    return args->compareFunction->call(args->exec, args->globalObject, args->arguments)
    235235        .toInt32(args->exec);
     
    531531                l.append(jObj);
    532532                l.append(minObj);
    533                 Object thisObj = exec->interpreter()->globalObject();
    534                 cmp = sortFunction.call(exec,thisObj, l ).toInt32(exec);
     533                cmp = sortFunction.call(exec, exec->interpreter()->globalObject(), l).toInt32(exec);
    535534            } else {
    536535              cmp = (jObj.toString(exec) < minObj.toString(exec)) ? -1 : 1;
  • trunk/JavaScriptCore/kjs/function.cpp

    r2736 r2753  
    8080Value FunctionImp::call(ExecState *exec, Object &thisObj, const List &args)
    8181{
    82   Object globalObj = exec->interpreter()->globalObject();
     82  Object &globalObj = exec->interpreter()->globalObject();
    8383
    8484  Debugger *dbg = exec->interpreter()->imp()->debugger();
     
    369369
    370370      // enter a new execution context
    371       Object glob(exec->interpreter()->globalObject());
    372371      Object thisVal(Object::dynamicCast(exec->context().thisValue()));
    373       ContextImp *ctx = new ContextImp(glob,
     372      ContextImp *ctx = new ContextImp(exec->interpreter()->globalObject(),
    374373                                       exec,
    375374                                       thisVal,
  • trunk/JavaScriptCore/kjs/internal.cpp

    r2748 r2753  
    187187{
    188188  List args;
    189   args.append(Boolean(const_cast<BooleanImp*>(this)));
     189  args.append(const_cast<BooleanImp*>(this));
    190190  return Object::dynamicCast(exec->interpreter()->builtinBoolean().construct(exec,args));
    191191}
     
    216216{
    217217  List args;
    218   args.append(Value(const_cast<StringImp*>(this)));
     218  args.append(const_cast<StringImp*>(this));
    219219  return Object::dynamicCast(exec->interpreter()->builtinString().construct(exec,args));
    220220}
     
    245245{
    246246  List args;
    247   args.append(Number(const_cast<NumberImp*>(this)));
     247  args.append(const_cast<NumberImp*>(this));
    248248  return Object::dynamicCast(exec->interpreter()->builtinNumber().construct(exec,args));
    249249}
     
    735735  progNode->ref();
    736736
    737   Object globalObj = globalObject();
     737  Object &globalObj = globalObject();
    738738  Object thisObj = globalObject();
    739739
  • trunk/JavaScriptCore/kjs/internal.h

    r2741 r2753  
    241241    ~InterpreterImp();
    242242
    243     Object globalObject() const { return global; }
     243    Object &globalObject() const { return const_cast<Object &>(global); }
    244244    Interpreter* interpreter() const { return m_interpreter; }
    245245
  • trunk/JavaScriptCore/kjs/interpreter.cpp

    r2738 r2753  
    109109}
    110110
    111 Object Interpreter::globalObject() const
     111Object &Interpreter::globalObject() const
    112112{
    113113  return rep->globalObject();
  • trunk/JavaScriptCore/kjs/interpreter.h

    r2738 r2753  
    146146     * execution performed by this interpreter
    147147     */
    148     Object globalObject() const;
     148    Object &globalObject() const;
    149149
    150150    void initGlobalObject();
  • trunk/JavaScriptCore/kjs/object.cpp

    r2741 r2753  
    3838#include "error_object.h"
    3939#include "nodes.h"
    40 #include "property_map.h"
    4140
    4241namespace KJS {
     
    6261
    6362ObjectImp::ObjectImp(const Object &proto)
    64   : _prop(0), _proto(static_cast<ObjectImp*>(proto.imp())), _internalValue(0L), _scope(true)
     63  : _proto(static_cast<ObjectImp*>(proto.imp())), _internalValue(0L), _scope(true)
    6564{
    6665  //fprintf(stderr,"ObjectImp::ObjectImp %p\n",(void*)this);
    67   _prop = new PropertyMap();
    6866}
    6967
     
    7270{
    7371  //fprintf(stderr,"ObjectImp::ObjectImp %p\n",(void*)this);
    74   _prop = 0;
    7572  _proto = NullImp::staticNull;
    7673  _internalValue = 0L;
    77   _prop = new PropertyMap();
    7874}
    7975
     
    8177{
    8278  //fprintf(stderr,"ObjectImp::~ObjectImp %p\n",(void*)this);
    83   delete _prop;
    8479}
    8580
     
    9287    _proto->mark();
    9388
    94   _prop->mark();
     89  _prop.mark();
    9590
    9691  if (_internalValue && !_internalValue->marked())
     
    171166ValueImp* ObjectImp::getDirect(const UString& propertyName) const
    172167{
    173   return _prop->get(propertyName);
     168  return _prop.get(propertyName);
    174169}
    175170
     
    199194  }
    200195
    201   _prop->put(propertyName,value.imp(),attr);
     196  _prop.put(propertyName,value.imp(),attr);
    202197}
    203198
     
    212207{
    213208  int attributes;
    214   ValueImp *v = _prop->get(propertyName, attributes);
     209  ValueImp *v = _prop.get(propertyName, attributes);
    215210  if (v)
    216211    return!(attributes & ReadOnly);
     
    229224bool ObjectImp::hasProperty(ExecState *exec, const UString &propertyName) const
    230225{
    231   if (_prop->get(propertyName))
     226  if (_prop.get(propertyName))
    232227    return true;
    233228
     
    254249{
    255250  int attributes;
    256   ValueImp *v = _prop->get(propertyName, attributes);
     251  ValueImp *v = _prop.get(propertyName, attributes);
    257252  if (v) {
    258253    if ((attributes & DontDelete))
    259254      return false;
    260     _prop->remove(propertyName);
     255    _prop.remove(propertyName);
    261256    return true;
    262257  }
     
    276271void ObjectImp::deleteAllProperties( ExecState * )
    277272{
    278   _prop->clear();
     273  _prop.clear();
    279274}
    280275
     
    397392    list = static_cast<ObjectImp*>(_proto)->propList(exec,recursive);
    398393
    399   _prop->addEnumerablesToReferenceList(list, Object(this));
     394  _prop.addEnumerablesToReferenceList(list, Object(this));
    400395
    401396  // Add properties from the static hashtable of properties
  • trunk/JavaScriptCore/kjs/object.h

    r2749 r2753  
    4141#include "types.h"
    4242#include "reference_list.h"
     43#include "property_map.h"
    4344
    4445namespace KJS {
    4546
    46   class PropertyMap;
    4747  class HashTable;
    4848  class HashEntry;
     
    583583  private:
    584584    const HashEntry* findPropertyHashEntry( const UString& propertyName ) const;
    585     PropertyMap *_prop;
     585    PropertyMap _prop;
    586586    ValueImp *_proto;
    587587    ValueImp *_internalValue;
  • trunk/JavaScriptCore/kjs/types.cpp

    r2748 r2753  
    4747    ListNode(const Value &val, ListNode *p, ListNode *n)
    4848      : member(val.imp()), prev(p), next(n) {};
     49    ListNode(ValueImp *val, ListNode *p, ListNode *n)
     50      : member(val), prev(p), next(n) {};
    4951    ValueImp *member;
    5052    ListNode *prev, *next;
     
    6264// ------------------------------ ListIterator ---------------------------------
    6365
    64 ListIterator::ListIterator(ListNode *n) : node(n)
    65 {
    66 }
    67 
    68 ListIterator::ListIterator(const List &l)
    69   : node(l.hook->next)
    70 {
    71 }
    72 
    7366ValueImp* ListIterator::operator->() const
    7467{
     
    7669}
    7770
    78 //    operator Value* () const { return node->member; }
    7971Value ListIterator::operator*() const
    8072{
     
    8274}
    8375
    84 //    operator Value*() const { return node->member; }
    8576Value ListIterator::operator++()
    8677{
     
    10798  --*this;
    10899  return Value(n->member);
    109 }
    110 
    111 bool ListIterator::operator==(const ListIterator &it) const
    112 {
    113   return (node==it.node);
    114 }
    115 
    116 bool ListIterator::operator!=(const ListIterator &it) const
    117 {
    118   return (node!=it.node);
    119100}
    120101
     
    183164}
    184165
     166void List::append(ValueImp *val)
     167{
     168  ListNode *n = new ListNode(val, hook->prev, hook);
     169  if (!m_needsMarking) {
     170    val->ref();
     171  }
     172  hook->prev->next = n;
     173  hook->prev = n;
     174}
     175
    185176void List::prepend(const Value& val)
    186177{
     
    193184}
    194185
     186void List::prepend(ValueImp *val)
     187{
     188  ListNode *n = new ListNode(val, hook->prev, hook);
     189  if (!m_needsMarking) {
     190    val->ref();
     191  }
     192  hook->next->prev = n;
     193  hook->next = n;
     194}
     195
    195196void List::appendList(const List& lst)
    196197{
    197   ListIterator it = lst.begin();
    198   ListIterator e = lst.end();
    199   while(it != e) {
    200     append(*it);
    201     ++it;
     198  ListNode *otherHook = lst.hook;
     199  ListNode *o = otherHook->next;
     200  while (o != otherHook) {
     201    append(o->member);
     202    o = o->next;
    202203  }
    203204}
     
    205206void List::prependList(const List& lst)
    206207{
    207   ListIterator it = lst.end();
    208   ListIterator e = lst.begin();
    209   while(it != e) {
    210     --it;
    211     prepend(*it);
     208  ListNode *otherHook = lst.hook;
     209  ListNode *o = otherHook->prev;
     210  while (o != otherHook) {
     211    prepend(o->member);
     212    o = o->prev;
    212213  }
    213214}
     
    261262{
    262263  List newList;
    263 
    264   ListIterator e = end();
    265   ListIterator it = begin();
    266 
    267   while(it != e) {
    268     newList.append(*it);
    269     ++it;
    270   }
    271 
     264  newList.appendList(*this);
    272265  return newList;
    273266}
     
    316309}
    317310
    318 const List List::empty()
    319 {
    320   return List();
     311const List &List::empty()
     312{
     313  static List l;
     314  return l;
    321315}
    322316
  • trunk/JavaScriptCore/kjs/types.h

    r2748 r2753  
    4343  class ListIterator {
    4444    friend class List;
    45     ListIterator();
    46     ListIterator(ListNode *n);
     45    ListIterator() : node(0) { }
     46    ListIterator(ListNode *n) : node(n) { }
    4747  public:
    4848    /**
     
    5656     */
    5757    ValueImp* operator->() const;
    58     //    operator Value* () const { return node->member; }
    5958    Value operator*() const;
    60     /**
    61      * Conversion to @ref KJS::Value*
    62      * @return A pointer to the element the iterator operates on.
    63      */
    64     //    operator Value*() const { return node->member; }
    6559    /**
    6660     * Postfix increment operator.
     
    8579     * False otherwise.
    8680     */
    87     bool operator==(const ListIterator &it) const;
     81    bool operator==(const ListIterator &it) const { return node == it.node; }
    8882    /**
    8983     * Check for inequality with another iterator.
    9084     * @return True if the two iterators operate on different list elements.
    9185     */
    92     bool operator!=(const ListIterator &it) const;
     86    bool operator!=(const ListIterator &it) const { return node != it.node; }
    9387  private:
    9488    ListNode *node;
     
    120114     */
    121115    void append(const Value& val);
     116    void append(ValueImp *val);
    122117    /**
    123118     * Insert an object at the beginning of the list.
     
    126121     */
    127122    void prepend(const Value& val);
     123    void prepend(ValueImp *val);
    128124    /**
    129125     * Appends the items of another list at the end of this one.
     
    147143     */
    148144    void remove(const Value &val);
     145    void remove(ValueImp *val);
    149146    /**
    150147     * Remove all elements from the list.
     
    190187     * function has a @ref KJS::List parameter.
    191188     */
    192     static const List empty();
     189    static const List &empty();
    193190#ifdef KJS_DEBUG_MEM
    194191    static void globalClear();
Note: See TracChangeset for help on using the changeset viewer.