Skip to content

Commit

Permalink
Avoid more globals
Browse files Browse the repository at this point in the history
  • Loading branch information
copy committed Apr 4, 2021
1 parent 91f9a8a commit b7b3c1b
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/cpu.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,9 @@ function CPU(bus, wm)
{
this.do_many_cycles_count = 0;
this.do_many_cycles_total = 0;

this.seen_code = {};
this.seen_code_uncompiled = {};
}

//Object.seal(this);
Expand Down Expand Up @@ -1237,9 +1240,6 @@ CPU.prototype.cycle = function()
this.cycle_internal();
};

var seen_code = {};
var seen_code_uncompiled = {};

CPU.prototype.codegen_finalize = function(wasm_table_index, start, state_flags, ptr, len)
{
ptr >>>= 0;
Expand All @@ -1251,7 +1251,7 @@ CPU.prototype.codegen_finalize = function(wasm_table_index, start, state_flags,

if(DEBUG)
{
if(DUMP_GENERATED_WASM && !seen_code[start])
if(DUMP_GENERATED_WASM && !this.seen_code[start])
{
this.debug.dump_wasm(code);

Expand Down Expand Up @@ -1280,7 +1280,7 @@ CPU.prototype.codegen_finalize = function(wasm_table_index, start, state_flags,
}
}

seen_code[start] = (seen_code[start] || 0) + 1;
this.seen_code[start] = (this.seen_code[start] || 0) + 1;

if(this.test_hook_did_generate_wasm)
{
Expand Down Expand Up @@ -1338,9 +1338,9 @@ CPU.prototype.log_uncompiled_code = function(start, end)
return;
}

if((seen_code_uncompiled[start] || 0) < 100)
if((this.seen_code_uncompiled[start] || 0) < 100)
{
seen_code_uncompiled[start] = (seen_code_uncompiled[start] || 0) + 1;
this.seen_code_uncompiled[start] = (this.seen_code_uncompiled[start] || 0) + 1;

end += 8; // final jump is not included

Expand Down

0 comments on commit b7b3c1b

Please sign in to comment.