Changeset 2738 in webkit for trunk/JavaScriptCore


Ignore:
Timestamp:
Nov 18, 2002, 2:49:26 PM (23 years ago)
Author:
darin
Message:
  • simplified the ExecState class, which was showing up in profiles

Sped up JavaScript iBench by 6%.

  • kjs/interpreter.h: Removed the level of indirection, and made it all inline.
  • kjs/interpreter.cpp: Removed ExecState implementation from here altogether.
  • fixed an oversight in my sort speedup
  • kjs/array_object.h: Add pushUndefinedObjectsToEnd.
  • kjs/array_object.cpp: (ArrayInstanceImp::sort): Call pushUndefinedObjectsToEnd. (ArrayInstanceImp::pushUndefinedObjectsToEnd): Added. Pushes all undefined to the end of the array.
Location:
trunk/JavaScriptCore
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/ChangeLog

    r2736 r2738  
     12002-11-18  Darin Adler  <[email protected]>
     2
     3        - simplified the ExecState class, which was showing up in profiles
     4       
     5        Sped up JavaScript iBench by 6%.
     6
     7        * kjs/interpreter.h: Removed the level of indirection, and made it all inline.
     8        * kjs/interpreter.cpp: Removed ExecState implementation from here altogether.
     9
     10        - fixed an oversight in my sort speedup
     11
     12        * kjs/array_object.h: Add pushUndefinedObjectsToEnd.
     13        * kjs/array_object.cpp:
     14        (ArrayInstanceImp::sort): Call pushUndefinedObjectsToEnd.
     15        (ArrayInstanceImp::pushUndefinedObjectsToEnd): Added.
     16        Pushes all undefined to the end of the array.
     17
    1182002-11-18  Darin Adler  <[email protected]>
    219
  • trunk/JavaScriptCore/ChangeLog-2002-12-03

    r2736 r2738  
     12002-11-18  Darin Adler  <[email protected]>
     2
     3        - simplified the ExecState class, which was showing up in profiles
     4       
     5        Sped up JavaScript iBench by 6%.
     6
     7        * kjs/interpreter.h: Removed the level of indirection, and made it all inline.
     8        * kjs/interpreter.cpp: Removed ExecState implementation from here altogether.
     9
     10        - fixed an oversight in my sort speedup
     11
     12        * kjs/array_object.h: Add pushUndefinedObjectsToEnd.
     13        * kjs/array_object.cpp:
     14        (ArrayInstanceImp::sort): Call pushUndefinedObjectsToEnd.
     15        (ArrayInstanceImp::pushUndefinedObjectsToEnd): Added.
     16        Pushes all undefined to the end of the array.
     17
    1182002-11-18  Darin Adler  <[email protected]>
    219
  • trunk/JavaScriptCore/ChangeLog-2003-10-25

    r2736 r2738  
     12002-11-18  Darin Adler  <[email protected]>
     2
     3        - simplified the ExecState class, which was showing up in profiles
     4       
     5        Sped up JavaScript iBench by 6%.
     6
     7        * kjs/interpreter.h: Removed the level of indirection, and made it all inline.
     8        * kjs/interpreter.cpp: Removed ExecState implementation from here altogether.
     9
     10        - fixed an oversight in my sort speedup
     11
     12        * kjs/array_object.h: Add pushUndefinedObjectsToEnd.
     13        * kjs/array_object.cpp:
     14        (ArrayInstanceImp::sort): Call pushUndefinedObjectsToEnd.
     15        (ArrayInstanceImp::pushUndefinedObjectsToEnd): Added.
     16        Pushes all undefined to the end of the array.
     17
    1182002-11-18  Darin Adler  <[email protected]>
    219
  • trunk/JavaScriptCore/kjs/array_object.cpp

    r2736 r2738  
    203203void ArrayInstanceImp::sort(ExecState *exec)
    204204{
     205    int lengthNotIncludingUndefined = pushUndefinedObjectsToEnd();
     206   
    205207    execForCompareByStringForQSort = exec;
    206     qsort(storage, length, sizeof(ValueImp *), compareByStringForQSort);
     208    qsort(storage, lengthNotIncludingUndefined, sizeof(ValueImp *), compareByStringForQSort);
    207209    execForCompareByStringForQSort = 0;
    208210}
     
    236238void ArrayInstanceImp::sort(ExecState *exec, Object &compareFunction)
    237239{
     240    int lengthNotIncludingUndefined = pushUndefinedObjectsToEnd();
     241   
    238242    CompareWithCompareFunctionArguments args(exec, compareFunction.imp());
    239243    compareWithCompareFunctionArguments = &args;
    240     qsort(storage, length, sizeof(ValueImp *), compareWithCompareFunctionForQSort);
     244    qsort(storage, lengthNotIncludingUndefined, sizeof(ValueImp *), compareWithCompareFunctionForQSort);
    241245    compareWithCompareFunctionArguments = 0;
     246}
     247
     248unsigned ArrayInstanceImp::pushUndefinedObjectsToEnd()
     249{
     250    ValueImp *undefined = UndefinedImp::staticUndefined;
     251
     252    unsigned o = 0;
     253    for (unsigned i = 0; i != length; ++i) {
     254        ValueImp *v = storage[i];
     255        if (v && v != undefined) {
     256            if (o != i)
     257                storage[o] = v;
     258            o++;
     259        }
     260    }
     261    if (o != length)
     262        memset(storage + o, 0, sizeof(ValueImp *) * (length - o));
     263    return o;
    242264}
    243265
  • trunk/JavaScriptCore/kjs/array_object.h

    r2736 r2738  
    5656    void setLength(unsigned newLength);
    5757   
     58    unsigned pushUndefinedObjectsToEnd();
     59   
    5860    unsigned length;
    5961    unsigned capacity;
  • trunk/JavaScriptCore/kjs/interpreter.cpp

    r2256 r2738  
    318318#endif
    319319
    320 // ------------------------------ ExecState --------------------------------------
    321 
    322 namespace KJS {
    323   class ExecStateImp
    324   {
    325   public:
    326     ExecStateImp(Interpreter *interp, ContextImp *con)
    327       : interpreter(interp), context(con) {};
    328     Interpreter *interpreter;
    329     ContextImp *context;
    330     Value exception;
    331   };
    332 };
    333 
    334 ExecState::~ExecState()
    335 {
    336   delete rep;
    337 }
    338 
    339 Interpreter *ExecState::interpreter() const
    340 {
    341   return rep->interpreter;
    342 }
    343 
    344 const Context ExecState::context() const
    345 {
    346   return rep->context;
    347 }
    348 
    349 void ExecState::setException(const Value &e)
    350 {
    351   rep->exception = e;
    352 }
    353 
    354 void ExecState::clearException()
    355 {
    356   rep->exception = Value();
    357 }
    358 
    359 Value ExecState::exception() const
    360 {
    361   return rep->exception;
    362 }
    363 
    364 bool ExecState::hadException() const
    365 {
    366   return !rep->exception.isNull();
    367 }
    368 
    369 ExecState::ExecState(Interpreter *interp, ContextImp *con)
    370 {
    371   rep = new ExecStateImp(interp,con);
    372 }
    373 
    374320void Interpreter::virtual_hook( int, void* )
    375321{ /*BASE::virtual_hook( id, data );*/ }
  • trunk/JavaScriptCore/kjs/interpreter.h

    r1024 r2738  
    369369    friend class GlobalFuncImp;
    370370  public:
    371     virtual ~ExecState();
    372 
    373371    /**
    374372     * Returns the interpreter associated with this execution state
     
    376374     * @return The interpreter executing the script
    377375     */
    378     Interpreter *interpreter() const;
     376    Interpreter *interpreter() const { return _interpreter; }
    379377
    380378    /**
     
    383381     * @return The current execution state context
    384382     */
    385     const Context context() const;
    386 
    387     void setException(const Value &e);
    388     void clearException();
    389     Value exception() const;
    390     bool hadException() const;
     383    const Context context() const { return _context; }
     384
     385    void setException(const Value &e) { _exception = e; }
     386    void clearException() { _exception = Value(); }
     387    Value exception() const { return _exception; }
     388    bool hadException() const { return !_exception.isNull(); }
    391389
    392390  private:
    393     ExecState(Interpreter *interp, ContextImp *con);
    394     ExecStateImp *rep;
     391    ExecState(Interpreter *interp, ContextImp *con)
     392        : _interpreter(interp), _context(con) { }
     393    Interpreter *_interpreter;
     394    ContextImp *_context;
     395    Value _exception;
    395396  };
    396397
Note: See TracChangeset for help on using the changeset viewer.