s/oxide//

This commit is contained in:
Fabian 2020-12-31 19:14:29 -06:00
parent 4ab8ef9fdd
commit 48a9847d16
6 changed files with 48 additions and 50 deletions

View file

@ -1,5 +1,5 @@
[package]
name = "v86oxide"
name = "v86"
version = "0.1.0"
publish = false

View file

@ -17,9 +17,9 @@ ifeq ($(STRIP_DEBUG),true)
STRIP_DEBUG_FLAG=--v86-strip-debug
endif
default: build/v86oxide-debug.wasm
all: build/v86_all.js build/libv86.js build/v86oxide.wasm
all-debug: build/libv86-debug.js build/v86oxide-debug.wasm
default: build/v86-debug.wasm
all: build/v86_all.js build/libv86.js build/v86.wasm
all-debug: build/libv86-debug.js build/v86-debug.wasm
browser: build/v86_all.js
# Used for nodejs builds and in order to profile code.
@ -174,26 +174,26 @@ src/rust/gen/analyzer0f_16.rs: $(ANALYZER_DEPENDENCIES)
src/rust/gen/analyzer0f_32.rs: $(ANALYZER_DEPENDENCIES)
./gen/generate_analyzer.js --output-dir build/ --table analyzer0f_32
build/v86oxide.wasm: $(RUST_FILES) Cargo.toml
build/v86.wasm: $(RUST_FILES) Cargo.toml
mkdir -p build/
-ls -lh build/v86oxide.wasm
-ls -lh build/v86.wasm
cargo +nightly rustc --release $(CARGO_FLAGS)
./tools/wasm-patch-indirect-function-table.js < build/wasm32-unknown-unknown/release/v86oxide.wasm > build/v86oxide.wasm
ls -lh build/v86oxide.wasm
./tools/wasm-patch-indirect-function-table.js < build/wasm32-unknown-unknown/release/v86.wasm > build/v86.wasm
ls -lh build/v86.wasm
build/v86oxide-debug.wasm: $(RUST_FILES) Cargo.toml
build/v86-debug.wasm: $(RUST_FILES) Cargo.toml
mkdir -p build/
-ls -lh build/v86oxide-debug.wasm
-ls -lh build/v86-debug.wasm
cargo +nightly rustc $(CARGO_FLAGS)
./tools/wasm-patch-indirect-function-table.js < build/wasm32-unknown-unknown/debug/v86oxide.wasm > build/v86oxide-debug.wasm
ls -lh build/v86oxide-debug.wasm
./tools/wasm-patch-indirect-function-table.js < build/wasm32-unknown-unknown/debug/v86.wasm > build/v86-debug.wasm
ls -lh build/v86-debug.wasm
clean:
-rm build/libv86.js
-rm build/libv86-debug.js
-rm build/v86_all.js
-rm build/v86oxide.wasm
-rm build/v86oxide-debug.wasm
-rm build/v86.wasm
-rm build/v86-debug.wasm
-rm $(INSTRUCTION_TABLES)
-rm $(addsuffix .bak,$(INSTRUCTION_TABLES))
-rm $(addsuffix .diff,$(INSTRUCTION_TABLES))

View file

@ -74,21 +74,21 @@ const print_stats = {
for(let i = 0; i < stat_names.length; i++)
{
let stat = cpu.v86oxide.exports["profiler_stat_get"](i);
let stat = cpu.wm.exports["profiler_stat_get"](i);
stat = stat >= 100e6 ? Math.round(stat / 1e6) + "m" : stat >= 100e3 ? Math.round(stat / 1e3) + "k" : stat;
text += stat_names[i] + "=" + stat + "\n";
}
text += "\n";
const tlb_entries = cpu.v86oxide.exports["get_valid_tlb_entries_count"]();
const global_tlb_entries = cpu.v86oxide.exports["get_valid_global_tlb_entries_count"]();
const tlb_entries = cpu.wm.exports["get_valid_tlb_entries_count"]();
const global_tlb_entries = cpu.wm.exports["get_valid_global_tlb_entries_count"]();
const nonglobal_tlb_entries = tlb_entries - global_tlb_entries;
text += "TLB_ENTRIES=" + tlb_entries + " (" + global_tlb_entries + " global, " + nonglobal_tlb_entries + " non-global)\n";
text += "CACHE_UNUSED=" + cpu.v86oxide.exports["jit_unused_cache_stat"]() + "\n";
text += "WASM_TABLE_FREE=" + cpu.v86oxide.exports["jit_get_wasm_table_index_free_list_count"]() + "\n";
text += "FLAT_SEGMENTS=" + cpu.v86oxide.exports["has_flat_segmentation"]() + "\n";
text += "CACHE_UNUSED=" + cpu.wm.exports["jit_unused_cache_stat"]() + "\n";
text += "WASM_TABLE_FREE=" + cpu.wm.exports["jit_get_wasm_table_index_free_list_count"]() + "\n";
text += "FLAT_SEGMENTS=" + cpu.wm.exports["has_flat_segmentation"]() + "\n";
text += "do_many_cycles avg: " + do_many_cycles_total / do_many_cycles_count + "\n";
@ -105,7 +105,7 @@ const print_stats = {
for(let i = 0; i < JIT_CACHE_ARRAY_SIZE; i++)
{
const address = cpu.v86oxide.exports["jit_get_entry_address"](i);
const address = cpu.wm.exports["jit_get_entry_address"](i);
if(address !== 0)
{
@ -138,8 +138,8 @@ const print_stats = {
for(let i = 0; i < JIT_CACHE_ARRAY_SIZE; i++)
{
const length = cpu.v86oxide.exports["jit_get_entry_length"](i);
pending_count += cpu.v86oxide.exports["jit_get_entry_pending"](i);
const length = cpu.wm.exports["jit_get_entry_length"](i);
pending_count += cpu.wm.exports["jit_get_entry_pending"](i);
histogram[length] = (histogram[length] || 0) + 1;
}
@ -196,10 +196,10 @@ const print_stats = {
{
for(let is_mem of [false, true])
{
const count = cpu.v86oxide.exports["get_opstats_buffer"](compiled, jit_exit, unguarded_register, wasm_size, opcode, false, is_mem, fixed_g);
const count = cpu.wm.exports["get_opstats_buffer"](compiled, jit_exit, unguarded_register, wasm_size, opcode, false, is_mem, fixed_g);
counts.push({ opcode, count, is_mem, fixed_g });
const count_0f = cpu.v86oxide.exports["get_opstats_buffer"](compiled, jit_exit, unguarded_register, wasm_size, opcode, true, is_mem, fixed_g);
const count_0f = cpu.wm.exports["get_opstats_buffer"](compiled, jit_exit, unguarded_register, wasm_size, opcode, true, is_mem, fixed_g);
counts.push({ opcode: 0x0f00 | opcode, count: count_0f, is_mem, fixed_g });
}
}

View file

@ -186,29 +186,29 @@ function V86Starter(options)
"__indirect_function_table": wasm_table,
};
let v86oxide_bin = DEBUG ? "v86oxide-debug.wasm" : "v86oxide.wasm";
let v86_bin = DEBUG ? "v86-debug.wasm" : "v86.wasm";
if(options["oxide_path"])
if(options["wasm_path"])
{
v86oxide_bin = options["oxide_path"];
v86_bin = options["wasm_path"];
}
else if(typeof window === "undefined" && typeof __dirname === "string")
{
v86oxide_bin = __dirname + "/" + v86oxide_bin;
v86_bin = __dirname + "/" + v86_bin;
}
else
{
v86oxide_bin = "build/" + v86oxide_bin;
v86_bin = "build/" + v86_bin;
}
v86util.load_wasm(
v86oxide_bin,
v86_bin,
{ "env": wasm_shared_funcs },
v86oxide => {
wasm_memory = v86oxide.exports.memory;
v86oxide.exports["rust_setup"]();
v86_wasm => {
wasm_memory = v86_wasm.exports.memory;
v86_wasm.exports["rust_setup"]();
const emulator = this.v86 = new v86(this.emulator_bus, v86oxide, v86oxide);
const emulator = this.v86 = new v86(this.emulator_bus, v86_wasm);
cpu = emulator.cpu;
this.continue_init(emulator, options);

View file

@ -11,14 +11,13 @@ var CPU_LOG_VERBOSE = false;
/** @constructor */
function CPU(bus, wm, v86oxide)
function CPU(bus, wm)
{
this.wm = wm;
this.v86oxide = v86oxide;
this.wasm_patch(wm);
this.create_jit_imports();
const memory = v86oxide.instance.exports.memory;
const memory = this.wm.instance.exports.memory;
this.wasm_memory = memory;
@ -218,7 +217,7 @@ CPU.prototype.wasmgen_get_module_code = function()
const ptr = this.jit_get_op_ptr();
const len = this.jit_get_op_len();
const output_buffer_view = new Uint8Array(this.v86oxide.instance.exports.memory.buffer, ptr, len);
const output_buffer_view = new Uint8Array(this.wm.instance.exports.memory.buffer, ptr, len);
return output_buffer_view;
};
@ -233,9 +232,9 @@ CPU.prototype.create_jit_imports = function()
}
// put all imports that don't change on the prototype
JITImports.prototype["m"] = this.v86oxide.memory;
JITImports.prototype["m"] = this.wm.memory;
const exports = this.v86oxide.instance.exports;
const exports = this.wm.instance.exports;
JITImports.prototype["m"] = exports["memory"];
@ -256,7 +255,7 @@ CPU.prototype.create_jit_imports = function()
CPU.prototype.wasm_patch = function(wm)
{
const get_optional_import = (name) => {
return this.v86oxide.exports[name];
return this.wm.exports[name];
};
const get_import = (name) =>
@ -764,9 +763,9 @@ CPU.prototype.create_memory = function(size)
const memory_offset = this.allocate_memory(size);
this.mem8 = v86util.view(Uint8Array, this.v86oxide.instance.exports.memory, memory_offset, size);
this.mem16 = v86util.view(Uint16Array, this.v86oxide.instance.exports.memory, memory_offset, size >> 1);
this.mem32s = v86util.view(Uint32Array, this.v86oxide.instance.exports.memory, memory_offset, size >> 2);
this.mem8 = v86util.view(Uint8Array, this.wm.instance.exports.memory, memory_offset, size);
this.mem16 = v86util.view(Uint16Array, this.wm.instance.exports.memory, memory_offset, size >> 1);
this.mem32s = v86util.view(Uint32Array, this.wm.instance.exports.memory, memory_offset, size >> 2);
};
CPU.prototype.init = function(settings, device_bus)
@ -1499,7 +1498,7 @@ CPU.prototype.dump_function_code = function(block_ptr, count)
const SIZEOF_BASIC_BLOCK_IN_DWORDS = 7;
const mem32 = new Int32Array(this.v86oxide.instance.exports.memory.buffer);
const mem32 = new Int32Array(this.wm.instance.exports.memory.buffer);
dbg_assert((block_ptr & 3) === 0);

View file

@ -2,10 +2,9 @@
/**
* @constructor
* @param {Object=} wm
* @param {Object=} codegen
* @param {Object=} wasm
*/
function v86(bus, wm, codegen)
function v86(bus, wasm)
{
/** @type {boolean} */
this.running = false;
@ -14,7 +13,7 @@ function v86(bus, wm, codegen)
this.stopped = false;
/** @type {CPU} */
this.cpu = new CPU(bus, wm, codegen);
this.cpu = new CPU(bus, wasm);
this.bus = bus;
bus.register("cpu-init", this.init, this);