Enable CALLNAME and add test case for it so we can call global functions.

This commit is contained in:
Andreas Gal 2008-07-16 15:40:35 -07:00
parent fe50e4724a
commit 7f119dc35a
2 changed files with 24 additions and 4 deletions

View File

@ -1973,7 +1973,23 @@ bool TraceRecorder::record_JSOP_SETELEM()
bool TraceRecorder::record_JSOP_CALLNAME() bool TraceRecorder::record_JSOP_CALLNAME()
{ {
return false; JSObject* obj = cx->fp->scopeChain;
if (obj != globalObj)
return false;
LIns* obj_ins = lir->insLoadi(lir->insLoadi(cx_ins, offsetof(JSContext, fp)),
offsetof(JSStackFrame, scopeChain));
JSObject* obj2;
JSPropCacheEntry* entry;
if (!test_property_cache(obj, obj_ins, obj2, entry))
ABORT_TRACE("missed prop");
if (!PCVAL_IS_OBJECT(entry->vword))
ABORT_TRACE("PCE not object");
stack(0, lir->insImmPtr(PCVAL_TO_OBJECT(entry->vword)));
stack(1, obj_ins);
return true;
} }
JSBool JSBool

View File

@ -211,9 +211,12 @@ function mod()
} }
test("mod", mod(), "4.5,0,42,4,NaN"); test("mod", mod(), "4.5,0,42,4,NaN");
function global_func() {
return 1;
}
function call() function call()
{ {
var q1 = 0, q2 = 0; var q1 = 0, q2 = 0, q3 = 0;
function f1() { function f1() {
return 1; return 1;
} }
@ -223,8 +226,9 @@ function call()
for (var i = 0; i < 100; ++i) { for (var i = 0; i < 100; ++i) {
q1 += f1(); q1 += f1();
q2 += f2(f1); q2 += f2(f1);
q3 += global_func();
} }
var ret = [q1, q2]; var ret = [q1, q2, q3];
return ret; return ret;
} }
test("call", call(), "100,100"); test("call", call(), "100,100,100");