This commit is contained in:
Andreas Gal 2008-07-01 19:44:24 -07:00
commit 7eba55b32b
2 changed files with 38 additions and 1 deletions

View File

@ -386,7 +386,7 @@ TraceRecorder::readstack(void* p, char *prefix, int index)
if (prefix) {
char name[16];
JS_ASSERT(strlen(prefix) < 10);
JS_snprintf(name, 15, "$%s%d", prefix, index);
JS_snprintf(name, sizeof name, "$%s%d", prefix, index);
lirbuf->names->addName(ins, name);
}
#endif

37
js/src/trace-test.js Normal file
View File

@ -0,0 +1,37 @@
function test(desc, expected, actual)
{
if (expected == actual)
return print(desc, ": passed");
print(desc, ": FAILED: ", typeof(expected), "(", expected, ") != ",
typeof(actual), "(", actual, ")");
}
function ifInsideLoop()
{
var cond = true, count = 0;
for (var i = 0; i < 5000; i++) {
if (cond)
count++;
}
return count;
}
test("tracing if", ifInsideLoop(), 5000);
function bitwiseAnd(bitwiseAndValue) {
for (var i = 0; i < 60000000; i++)
bitwiseAndValue = bitwiseAndValue & i;
return bitwiseAndValue;
}
test("bitwise and with arg/var", bitwiseAnd(12341234), 0)
function equalInt()
{
var i1 = 55, eq = 0;
for (var i = 0; i < 5000; i++) {
if (i1 == 55)
eq++;
}
return eq;
}
test("int equality", equalInt(), 5000);