"literal" object and "const" var should get advantage when trace.

RESOLVED INVALID

Status

()

RESOLVED INVALID
8 years ago
6 years ago

People

(Reporter: lyricconch, Unassigned)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

(Reporter)

Description

8 years ago
User-Agent:       Mozilla/5.0 (Windows NT 5.1; rv:2.0b7) Gecko/20100101 Firefox/4.0b7
Build Identifier: 

function cmpt(fna, fnb, loop, that){
    // function gc() null;
    // function elapsed() Date.now();
    function dummy() null;
    var loop= loop||1, args= Array.slice(arguments,4);
    var i, t, t0, ta, tb;
    var [a0,a1,a2,a3,a4,a5,a6,a7,a8,a9]= args, reta=null, retb=null;
    if(that===null||that===undefined){
        for(gc(),i=loop,t=elapsed();i--;) dummy(a0,a1,a2);
        t0= elapsed()-t;
        for(gc(),i=loop,t=elapsed();i--;) reta=fna(a0,a1,a2);
        ta= elapsed()-t;
        for(gc(),i=loop,t=elapsed();i--;) retb=fnb(a0,a1,a2);
        tb= elapsed()-t;
    }else{
        for(gc(),i=loop,t=elapsed();i--;) dummy.apply(that,args); 
        t0= elapsed()-t;
        for(gc(),i=loop,t=elapsed();i--;) reta=fna.apply(that,args);
        ta= elapsed()-t;
        for(gc(),i=loop,t=elapsed();i--;) retb=fnb.apply(that,args);
        tb= elapsed()-t;
    }
    print("arg: %50s \nreta: %50s\nretb: %50s".
        format(args.toSource(), reta, retb));   
    print("time: A=%nms, B=%nms. @0=%nms @T=%nms".
        format(ta-t0, tb-t0, t0, t0+ta+tb));
    //print("A: ", fna.toString().replace(/\s+/g," "));
    //print("B: ", fnb.toString().replace(/\s+/g," "));
}

var f3a= (function f(a){for(var i=1000,b;i--;) b=/a/.test("a"); return b.toString()})
var f3b= (function f(a){for(var i=1000,b;i--;) b=f.a.test("a"); return b.toString()})
f3b.a=/a/;

var f4a= (function f(a){for(var i=1000,b;i--;) b=["ab","cd"].indexOf("cd"); return b.toString()})
var f4b= (function f(a){for(var i=1000,b;i--;) b=f.a.indexOf("cd"); return b.toString()})
f4b.a=["ab","cd"];

js> cmpt(f3a,f3b,100)
arg: []
reta: true
retb: true
time: A=1090ms, B=772ms. @0=4ms @T=1874ms
js> cmpt(f4a,f4b,100)
arg: []
reta: 1
retb: 1
time: A=1315ms, B=953ms. @0=10ms @T=2298ms

Reproducible: Always

Actual Results:  
delta(Ta,Tb)/avg(Ta,Tb) is too large.

Expected Results:  
abs(Ta-Tb) < 0.1*(Ta+Tb)

dis(f3a)
...
00013:  trace 0
*00016:  regexp /a/
00019:  callprop "test"
00022:  string "a"
00025:  call 1
...

dis(f3b)
...
00013:  trace 0
*00016:  callee
*00017:  getprop "a"
00020:  callprop "test"
00023:  string "a"
00026:  call 1

the "regexp" bytecode is need to optimize to get better performace.


dis(f4a)
...
00013:  trace 0
**00016:  string "ab"
**00019:  string "cd"
**00022:  newarray 2
**00025:  callprop "indexOf"
**00028:  string "cd"
00031:  call 1
00034:  setlocal 1
...

these five opcodes should be merge together...
there should be something like "stackcache"
maybe it can be like this:

00013:  trace 0 (snapshot init)
*****:  loadfast 0, +?? (load from snapshot[0], when hits, goto 00031)
**00016:  string "ab"
**00019:  string "cd"
**00022:  newarray 2
**00025:  callprop "indexOf"
**00028:  string "cd"
*******  snapshot 0,2 (store top and top-1 to snapshot[0])
00031:  call 1
00034:  setlocal 1

loadfast and snapshot can use in "const".

Comment 1

6 years ago
Tracer is gone.
Status: UNCONFIRMED → RESOLVED
Last Resolved: 6 years ago
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.