@aptre/v86 0.6.1 → 0.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/v86.browser.js +41 -76
- package/dist/v86.browser.js.map +3 -3
- package/dist/v86.js +41 -76
- package/dist/v86.js.map +3 -3
- package/package.json +1 -1
- package/src/browser/starter.ts +6 -2
- package/src/cpu.ts +85 -91
package/dist/v86.browser.js
CHANGED
|
@@ -18822,7 +18822,6 @@ var V86Starter = (() => {
|
|
|
18822
18822
|
wasm_memory;
|
|
18823
18823
|
memory_size;
|
|
18824
18824
|
mem8;
|
|
18825
|
-
mem8_offset = 0;
|
|
18826
18825
|
mem32s;
|
|
18827
18826
|
segment_is_null;
|
|
18828
18827
|
segment_offsets;
|
|
@@ -18952,46 +18951,10 @@ var V86Starter = (() => {
|
|
|
18952
18951
|
this.wasm_memory = wm.wasm_memory;
|
|
18953
18952
|
this.wasm_patch();
|
|
18954
18953
|
this.create_jit_imports();
|
|
18955
|
-
this.mem8 = new Uint8Array(0);
|
|
18956
|
-
this.mem32s = new Int32Array(this.mem8.buffer);
|
|
18957
|
-
this.rebuild_wasm_views();
|
|
18958
|
-
this.devices = {};
|
|
18959
|
-
this.memory_map_read8 = [];
|
|
18960
|
-
this.memory_map_write8 = [];
|
|
18961
|
-
this.memory_map_read32 = [];
|
|
18962
|
-
this.memory_map_write32 = [];
|
|
18963
|
-
this.bios = {
|
|
18964
|
-
main: null,
|
|
18965
|
-
vga: null
|
|
18966
|
-
};
|
|
18967
|
-
this.fpu_stack_empty[0] = 255;
|
|
18968
|
-
this.fpu_stack_ptr[0] = 0;
|
|
18969
|
-
this.fpu_control_word[0] = 895;
|
|
18970
|
-
this.fpu_status_word[0] = 0;
|
|
18971
|
-
this.fpu_ip[0] = 0;
|
|
18972
|
-
this.fpu_ip_selector[0] = 0;
|
|
18973
|
-
this.fpu_opcode[0] = 0;
|
|
18974
|
-
this.fpu_dp[0] = 0;
|
|
18975
|
-
this.fpu_dp_selector[0] = 0;
|
|
18976
|
-
this.fw_value = [];
|
|
18977
|
-
this.fw_pointer = 0;
|
|
18978
|
-
this.option_roms = [];
|
|
18979
|
-
this.io = void 0;
|
|
18980
|
-
this.bus = bus;
|
|
18981
|
-
this.set_tsc(0, 0);
|
|
18982
|
-
if (false) {
|
|
18983
|
-
this.seen_code = {};
|
|
18984
|
-
this.seen_code_uncompiled = {};
|
|
18985
|
-
}
|
|
18986
|
-
}
|
|
18987
|
-
/**
|
|
18988
|
-
* Rebuild all TypedArray views into WASM linear memory.
|
|
18989
|
-
* Must be called after any wasm_memory.grow() since growth
|
|
18990
|
-
* detaches the old ArrayBuffer, invalidating all views.
|
|
18991
|
-
*/
|
|
18992
|
-
rebuild_wasm_views() {
|
|
18993
18954
|
const memory = this.wasm_memory;
|
|
18994
18955
|
this.memory_size = view(Uint32Array, memory, 812, 1);
|
|
18956
|
+
this.mem8 = new Uint8Array(0);
|
|
18957
|
+
this.mem32s = new Int32Array(this.mem8.buffer);
|
|
18995
18958
|
this.segment_is_null = view(Uint8Array, memory, 724, 8);
|
|
18996
18959
|
this.segment_offsets = view(Int32Array, memory, 736, 8);
|
|
18997
18960
|
this.segment_limits = view(Uint32Array, memory, 768, 8);
|
|
@@ -19020,22 +18983,40 @@ var V86Starter = (() => {
|
|
|
19020
18983
|
this.last_op1 = view(Int32Array, memory, 104, 1);
|
|
19021
18984
|
this.last_result = view(Int32Array, memory, 112, 1);
|
|
19022
18985
|
this.current_tsc = view(Uint32Array, memory, 960, 2);
|
|
18986
|
+
this.devices = {};
|
|
19023
18987
|
this.instruction_pointer = view(Int32Array, memory, 556, 1);
|
|
19024
18988
|
this.previous_ip = view(Int32Array, memory, 560, 1);
|
|
19025
18989
|
this.apic_enabled = view(Uint8Array, memory, 548, 1);
|
|
19026
18990
|
this.acpi_enabled = view(Uint8Array, memory, 552, 1);
|
|
18991
|
+
this.memory_map_read8 = [];
|
|
18992
|
+
this.memory_map_write8 = [];
|
|
18993
|
+
this.memory_map_read32 = [];
|
|
18994
|
+
this.memory_map_write32 = [];
|
|
18995
|
+
this.bios = {
|
|
18996
|
+
main: null,
|
|
18997
|
+
vga: null
|
|
18998
|
+
};
|
|
19027
18999
|
this.instruction_counter = view(Uint32Array, memory, 664, 1);
|
|
19028
19000
|
this.reg32 = view(Int32Array, memory, 64, 8);
|
|
19029
19001
|
this.fpu_st = view(Int32Array, memory, 1152, 4 * 8);
|
|
19030
19002
|
this.fpu_stack_empty = view(Uint8Array, memory, 816, 1);
|
|
19003
|
+
this.fpu_stack_empty[0] = 255;
|
|
19031
19004
|
this.fpu_stack_ptr = view(Uint8Array, memory, 1032, 1);
|
|
19005
|
+
this.fpu_stack_ptr[0] = 0;
|
|
19032
19006
|
this.fpu_control_word = view(Uint16Array, memory, 1036, 1);
|
|
19007
|
+
this.fpu_control_word[0] = 895;
|
|
19033
19008
|
this.fpu_status_word = view(Uint16Array, memory, 1040, 1);
|
|
19009
|
+
this.fpu_status_word[0] = 0;
|
|
19034
19010
|
this.fpu_ip = view(Int32Array, memory, 1048, 1);
|
|
19011
|
+
this.fpu_ip[0] = 0;
|
|
19035
19012
|
this.fpu_ip_selector = view(Int32Array, memory, 1052, 1);
|
|
19013
|
+
this.fpu_ip_selector[0] = 0;
|
|
19036
19014
|
this.fpu_opcode = view(Int32Array, memory, 1044, 1);
|
|
19015
|
+
this.fpu_opcode[0] = 0;
|
|
19037
19016
|
this.fpu_dp = view(Int32Array, memory, 1056, 1);
|
|
19017
|
+
this.fpu_dp[0] = 0;
|
|
19038
19018
|
this.fpu_dp_selector = view(Int32Array, memory, 1060, 1);
|
|
19019
|
+
this.fpu_dp_selector[0] = 0;
|
|
19039
19020
|
this.reg_xmm32s = view(Int32Array, memory, 832, 8 * 4);
|
|
19040
19021
|
this.mxcsr = view(Int32Array, memory, 824, 1);
|
|
19041
19022
|
this.sreg = view(Uint16Array, memory, 668, 8);
|
|
@@ -19043,6 +19024,16 @@ var V86Starter = (() => {
|
|
|
19043
19024
|
this.reg_pdpte = view(Int32Array, memory, 968, 8);
|
|
19044
19025
|
this.svga_dirty_bitmap_min_offset = view(Uint32Array, memory, 716, 1);
|
|
19045
19026
|
this.svga_dirty_bitmap_max_offset = view(Uint32Array, memory, 720, 1);
|
|
19027
|
+
this.fw_value = [];
|
|
19028
|
+
this.fw_pointer = 0;
|
|
19029
|
+
this.option_roms = [];
|
|
19030
|
+
this.io = void 0;
|
|
19031
|
+
this.bus = bus;
|
|
19032
|
+
this.set_tsc(0, 0);
|
|
19033
|
+
if (false) {
|
|
19034
|
+
this.seen_code = {};
|
|
19035
|
+
this.seen_code_uncompiled = {};
|
|
19036
|
+
}
|
|
19046
19037
|
}
|
|
19047
19038
|
mmap_read8(addr) {
|
|
19048
19039
|
const value = this.memory_map_read8[addr >>> MMAP_BLOCK_BITS](addr);
|
|
@@ -19345,23 +19336,15 @@ var V86Starter = (() => {
|
|
|
19345
19336
|
);
|
|
19346
19337
|
}
|
|
19347
19338
|
resize_memory(new_size) {
|
|
19348
|
-
const
|
|
19349
|
-
const
|
|
19350
|
-
const
|
|
19351
|
-
if (
|
|
19352
|
-
const
|
|
19353
|
-
|
|
19354
|
-
|
|
19355
|
-
|
|
19356
|
-
|
|
19357
|
-
}
|
|
19358
|
-
this.mem8 = view(Uint8Array, this.wasm_memory, mem8_offset, new_size);
|
|
19359
|
-
this.mem32s = view(
|
|
19360
|
-
Int32Array,
|
|
19361
|
-
this.wasm_memory,
|
|
19362
|
-
mem8_offset,
|
|
19363
|
-
new_size >> 2
|
|
19364
|
-
);
|
|
19339
|
+
const offset = this.mem8.byteOffset;
|
|
19340
|
+
const needed = offset + new_size;
|
|
19341
|
+
const current = this.wasm_memory.buffer.byteLength;
|
|
19342
|
+
if (needed > current) {
|
|
19343
|
+
const pages = Math.ceil((needed - current) / WASM_PAGE_SIZE);
|
|
19344
|
+
this.wasm_memory.grow(pages);
|
|
19345
|
+
}
|
|
19346
|
+
this.mem8 = view(Uint8Array, this.wasm_memory, offset, new_size);
|
|
19347
|
+
this.mem32s = view(Uint32Array, this.wasm_memory, offset, new_size >> 2);
|
|
19365
19348
|
this.memory_size[0] = new_size;
|
|
19366
19349
|
}
|
|
19367
19350
|
set_state(state) {
|
|
@@ -19670,10 +19653,8 @@ var V86Starter = (() => {
|
|
|
19670
19653
|
this.memory_size[0] === 0,
|
|
19671
19654
|
"Expected uninitialised memory"
|
|
19672
19655
|
);
|
|
19673
|
-
const memory_offset = this.allocate_memory(size);
|
|
19674
|
-
this.rebuild_wasm_views();
|
|
19675
19656
|
this.memory_size[0] = size;
|
|
19676
|
-
|
|
19657
|
+
const memory_offset = this.allocate_memory(size);
|
|
19677
19658
|
this.mem8 = view(Uint8Array, this.wasm_memory, memory_offset, size);
|
|
19678
19659
|
this.mem32s = view(
|
|
19679
19660
|
Uint32Array,
|
|
@@ -19917,21 +19898,6 @@ var V86Starter = (() => {
|
|
|
19917
19898
|
}
|
|
19918
19899
|
}
|
|
19919
19900
|
this.debug_init();
|
|
19920
|
-
this.rebuild_wasm_views();
|
|
19921
|
-
if (this.mem8_offset > 0) {
|
|
19922
|
-
this.mem8 = view(
|
|
19923
|
-
Uint8Array,
|
|
19924
|
-
this.wasm_memory,
|
|
19925
|
-
this.mem8_offset,
|
|
19926
|
-
this.memory_size[0]
|
|
19927
|
-
);
|
|
19928
|
-
this.mem32s = view(
|
|
19929
|
-
Uint32Array,
|
|
19930
|
-
this.wasm_memory,
|
|
19931
|
-
this.mem8_offset,
|
|
19932
|
-
this.memory_size[0] >> 2
|
|
19933
|
-
);
|
|
19934
|
-
}
|
|
19935
19901
|
}
|
|
19936
19902
|
load_multiboot(buffer) {
|
|
19937
19903
|
if (this.bios.main) {
|
|
@@ -26246,11 +26212,10 @@ ${e.stack || e.message}`
|
|
|
26246
26212
|
const memory_size = options.memory_size || 64 * 1024 * 1024;
|
|
26247
26213
|
const vga_memory_size = options.vga_memory_size || 8 * 1024 * 1024;
|
|
26248
26214
|
const memory_max = options.memory_max || (memory_size + vga_memory_size) * 4;
|
|
26249
|
-
const WASM_PAGE_SIZE2 = 65536;
|
|
26250
26215
|
const wasm_initial_pages = 256;
|
|
26251
26216
|
const wasm_max_pages = Math.max(
|
|
26252
26217
|
wasm_initial_pages,
|
|
26253
|
-
Math.min(Math.ceil(memory_max /
|
|
26218
|
+
Math.min(Math.ceil(memory_max / WASM_PAGE_SIZE), 65536)
|
|
26254
26219
|
);
|
|
26255
26220
|
const wasm_memory = new WebAssembly.Memory({
|
|
26256
26221
|
initial: wasm_initial_pages,
|