Added Tracer to testFunctionCall().

git-svn-id: svn://10.0.0.236/trunk@67521 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
beard%netscape.com 2000-04-28 13:31:39 +00:00
parent d3a31f301a
commit d1a4dfc205
2 changed files with 50 additions and 44 deletions

View File

@ -123,6 +123,28 @@ static void readEvalPrint(FILE *in, World &world)
stdOut << '\n';
}
/**
* Poor man's instruction tracing facility.
*/
class Tracer : public Context::Listener {
typedef InstructionStream::difference_type InstructionOffset;
void listen(Context* /*context*/, InstructionIterator pc,
JSValues* registers, ICodeModule* iCode)
{
InstructionOffset offset = (pc - iCode->its_iCode->begin());
printFormat(stdOut, "%04X: ", offset);
Instruction* i = *pc;
stdOut << *i;
if (i->count() > 0) {
stdOut << " [";
i->printOperands(stdOut, *registers);
stdOut << "]\n";
} else {
stdOut << '\n';
}
}
};
static void testICG(World &world)
{
//
@ -252,6 +274,9 @@ static float64 testFunctionCall(World &world, float64 n)
{
JSObject glob;
Context cx(world, &glob);
Tracer t;
cx.addListener(&t);
uint32 position = 0;
//StringAtom& global = world.identifiers[widenCString("global")];
StringAtom& sum = world.identifiers[widenCString("sum")];
@ -298,28 +323,6 @@ static float64 testFunctionCall(World &world, float64 n)
return result.f64;
}
/**
* Poor man's instruction tracing facility.
*/
class Tracer : public Context::Listener {
typedef InstructionStream::difference_type InstructionOffset;
void listen(Context* /*context*/, InstructionIterator pc,
JSValues* registers, ICodeModule* iCode)
{
InstructionOffset offset = (pc - iCode->its_iCode->begin());
printFormat(stdOut, "%04X: ", offset);
Instruction* i = *pc;
stdOut << *i;
if (i->count() > 0) {
stdOut << " [";
i->printOperands(stdOut, *registers);
stdOut << "]\n";
} else {
stdOut << '\n';
}
}
};
static float64 testFactorial(World &world, float64 n)
{
JSObject glob;

View File

@ -123,6 +123,28 @@ static void readEvalPrint(FILE *in, World &world)
stdOut << '\n';
}
/**
* Poor man's instruction tracing facility.
*/
class Tracer : public Context::Listener {
typedef InstructionStream::difference_type InstructionOffset;
void listen(Context* /*context*/, InstructionIterator pc,
JSValues* registers, ICodeModule* iCode)
{
InstructionOffset offset = (pc - iCode->its_iCode->begin());
printFormat(stdOut, "%04X: ", offset);
Instruction* i = *pc;
stdOut << *i;
if (i->count() > 0) {
stdOut << " [";
i->printOperands(stdOut, *registers);
stdOut << "]\n";
} else {
stdOut << '\n';
}
}
};
static void testICG(World &world)
{
//
@ -252,6 +274,9 @@ static float64 testFunctionCall(World &world, float64 n)
{
JSObject glob;
Context cx(world, &glob);
Tracer t;
cx.addListener(&t);
uint32 position = 0;
//StringAtom& global = world.identifiers[widenCString("global")];
StringAtom& sum = world.identifiers[widenCString("sum")];
@ -298,28 +323,6 @@ static float64 testFunctionCall(World &world, float64 n)
return result.f64;
}
/**
* Poor man's instruction tracing facility.
*/
class Tracer : public Context::Listener {
typedef InstructionStream::difference_type InstructionOffset;
void listen(Context* /*context*/, InstructionIterator pc,
JSValues* registers, ICodeModule* iCode)
{
InstructionOffset offset = (pc - iCode->its_iCode->begin());
printFormat(stdOut, "%04X: ", offset);
Instruction* i = *pc;
stdOut << *i;
if (i->count() > 0) {
stdOut << " [";
i->printOperands(stdOut, *registers);
stdOut << "]\n";
} else {
stdOut << '\n';
}
}
};
static float64 testFactorial(World &world, float64 n)
{
JSObject glob;