//
// PLASMA JIT bytecode compiler tuner
//
include "inc/cmdsys.plh"
include "inc/args.plh"

var arg, val

def atoi(strptr)
    var num, len

    num = 0
    len = ^strptr
    strptr++
    while len and ^strptr >= '0' and ^strptr <= '9'
        num = num * 10 + ^strptr - '0'
        strptr++
        len--
    loop
    return num
end

arg = argNext(argFirst)
if ^arg
    if arg->1 >= '0' and arg->1 <= '9'
        val = atoi(arg)
        if val > 255
            val = 255
        fin
        cmdsys.jitcount = val
        arg = argNext(arg)
        if ^arg
            val = atoi(arg)
            if val > 255
                val = 255
            fin
            cmdsys.jitsize = val
        fin
    else
        puts("Usage: JITUNE WARMUP [CALLCOUNT [MAXSIZE]]\n")
    fin
fin
puts("JIT Call Count: "); puti(cmdsys.jitcount); putln
puts("JIT Max Size:   "); puti(cmdsys.jitsize); putln
done
