Commit 3e1ce6e5 authored by darin's avatar darin

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


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@2738 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 6d927229
2002-11-18 Darin Adler <darin@apple.com>
- 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.
2002-11-18 Darin Adler <darin@apple.com>
- fix worst speed problems on the sort page of the iBench JavaScript test
......
2002-11-18 Darin Adler <darin@apple.com>
- 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.
2002-11-18 Darin Adler <darin@apple.com>
- fix worst speed problems on the sort page of the iBench JavaScript test
......
2002-11-18 Darin Adler <darin@apple.com>
- 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.
2002-11-18 Darin Adler <darin@apple.com>
- fix worst speed problems on the sort page of the iBench JavaScript test
......
......@@ -202,8 +202,10 @@ static int compareByStringForQSort(const void *a, const void *b)
void ArrayInstanceImp::sort(ExecState *exec)
{
int lengthNotIncludingUndefined = pushUndefinedObjectsToEnd();
execForCompareByStringForQSort = exec;
qsort(storage, length, sizeof(ValueImp *), compareByStringForQSort);
qsort(storage, lengthNotIncludingUndefined, sizeof(ValueImp *), compareByStringForQSort);
execForCompareByStringForQSort = 0;
}
......@@ -235,12 +237,32 @@ static int compareWithCompareFunctionForQSort(const void *a, const void *b)
void ArrayInstanceImp::sort(ExecState *exec, Object &compareFunction)
{
int lengthNotIncludingUndefined = pushUndefinedObjectsToEnd();
CompareWithCompareFunctionArguments args(exec, compareFunction.imp());
compareWithCompareFunctionArguments = &args;
qsort(storage, length, sizeof(ValueImp *), compareWithCompareFunctionForQSort);
qsort(storage, lengthNotIncludingUndefined, sizeof(ValueImp *), compareWithCompareFunctionForQSort);
compareWithCompareFunctionArguments = 0;
}
unsigned ArrayInstanceImp::pushUndefinedObjectsToEnd()
{
ValueImp *undefined = UndefinedImp::staticUndefined;
unsigned o = 0;
for (unsigned i = 0; i != length; ++i) {
ValueImp *v = storage[i];
if (v && v != undefined) {
if (o != i)
storage[o] = v;
o++;
}
}
if (o != length)
memset(storage + o, 0, sizeof(ValueImp *) * (length - o));
return o;
}
// ------------------------------ ArrayPrototypeImp ----------------------------
const ClassInfo ArrayPrototypeImp::info = {"Array", &ArrayInstanceImp::info, &arrayTable, 0};
......
......@@ -55,6 +55,8 @@ namespace KJS {
private:
void setLength(unsigned newLength);
unsigned pushUndefinedObjectsToEnd();
unsigned length;
unsigned capacity;
ValueImp **storage;
......
......@@ -317,59 +317,5 @@ void Interpreter::finalCheck()
}
#endif
// ------------------------------ ExecState --------------------------------------
namespace KJS {
class ExecStateImp
{
public:
ExecStateImp(Interpreter *interp, ContextImp *con)
: interpreter(interp), context(con) {};
Interpreter *interpreter;
ContextImp *context;
Value exception;
};
};
ExecState::~ExecState()
{
delete rep;
}
Interpreter *ExecState::interpreter() const
{
return rep->interpreter;
}
const Context ExecState::context() const
{
return rep->context;
}
void ExecState::setException(const Value &e)
{
rep->exception = e;
}
void ExecState::clearException()
{
rep->exception = Value();
}
Value ExecState::exception() const
{
return rep->exception;
}
bool ExecState::hadException() const
{
return !rep->exception.isNull();
}
ExecState::ExecState(Interpreter *interp, ContextImp *con)
{
rep = new ExecStateImp(interp,con);
}
void Interpreter::virtual_hook( int, void* )
{ /*BASE::virtual_hook( id, data );*/ }
......@@ -368,30 +368,31 @@ namespace KJS {
friend class FunctionImp;
friend class GlobalFuncImp;
public:
virtual ~ExecState();
/**
* Returns the interpreter associated with this execution state
*
* @return The interpreter executing the script
*/
Interpreter *interpreter() const;
Interpreter *interpreter() const { return _interpreter; }
/**
* Returns the execution context associated with this execution state
*
* @return The current execution state context
*/
const Context context() const;
const Context context() const { return _context; }
void setException(const Value &e);
void clearException();
Value exception() const;
bool hadException() const;
void setException(const Value &e) { _exception = e; }
void clearException() { _exception = Value(); }
Value exception() const { return _exception; }
bool hadException() const { return !_exception.isNull(); }
private:
ExecState(Interpreter *interp, ContextImp *con);
ExecStateImp *rep;
ExecState(Interpreter *interp, ContextImp *con)
: _interpreter(interp), _context(con) { }
Interpreter *_interpreter;
ContextImp *_context;
Value _exception;
};
}; // namespace
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment