Skip to content

Instantly share code, notes, and snippets.

@ianterrell
Last active August 29, 2015 14:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ianterrell/2c8acbfaee2c41f0988f to your computer and use it in GitHub Desktop.
Save ianterrell/2c8acbfaee2c41f0988f to your computer and use it in GitHub Desktop.
function execute_loop() {
var vmfunc, pathtab, path;
var pathstart, pathend;
if (resumefuncop) {
//qlog("### at resume time, storing value " + resumevalue + " at funcop " + resumefuncop.key);
store_operand_by_funcop(resumefuncop, resumevalue);
resumefuncop = null;
resumevalue = 0;
}
pathstart = new Date().getTime(); //###stats
pathcalls = 0;
while (!done_executing) {
pathcalls++;
if (pathcalls % 100 == 0) {
qlog("### pc now " + pc.toString(16) + "; path calls = " + pathcalls);
}
vmfunc = frame.vmfunc;
pathtab = vmfunc[iosysmode];
path = pathtab[pc];
if (path === undefined) {
vmfunc.pathaddrs[pc] = true;
path = compile_path(vmfunc, pc, iosysmode);
paths_compiled++; //###stats
if (pc < ramstart) {
pathtab[pc] = path;
paths_cached++; //###stats
}
}
pathcalls++;
total_path_calls++; //###stats
try {
path();
}
catch (ex) {
if (ex === ReturnedFromMain) {
done_executing = true;
vm_stopped = true;
}
else {
/* Some other exception. */
throw ex;
}
}
}
pathend = new Date().getTime(); //###stats
total_execution_time += (pathend-pathstart) / 1000.0; //###stats
if (vm_stopped) {
/* If the library resumes us after exiting, we'll call glk_exit()
again. That's the library's problem. */
Glk.glk_exit();
}
Glk.update();
qlog("### done executing; path time = " + (pathend-pathstart) + " ms; path calls = " + pathcalls);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment