@aptre/v86 0.6.1 → 0.6.3

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.
@@ -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);
@@ -19225,6 +19216,7 @@ var V86Starter = (() => {
19225
19216
  state[26] = this.flags[0];
19226
19217
  state[27] = this.flags_changed[0];
19227
19218
  state[28] = this.last_op1[0];
19219
+ state[29] = this.last_result[0];
19228
19220
  state[30] = this.last_op_size[0];
19229
19221
  state[37] = this.instruction_pointer[0];
19230
19222
  state[38] = this.previous_ip[0];
@@ -19345,23 +19337,15 @@ var V86Starter = (() => {
19345
19337
  );
19346
19338
  }
19347
19339
  resize_memory(new_size) {
19348
- const mem8_offset = this.mem8_offset;
19349
- const needed_total = mem8_offset + new_size;
19350
- const current_buffer = this.wasm_memory.buffer.byteLength;
19351
- if (needed_total > current_buffer) {
19352
- const grow_pages = Math.ceil(
19353
- (needed_total - current_buffer) / WASM_PAGE_SIZE
19354
- );
19355
- this.wasm_memory.grow(grow_pages);
19356
- this.rebuild_wasm_views();
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
- );
19340
+ const offset = this.mem8.byteOffset;
19341
+ const needed = offset + new_size;
19342
+ const current = this.wasm_memory.buffer.byteLength;
19343
+ if (needed > current) {
19344
+ const pages = Math.ceil((needed - current) / WASM_PAGE_SIZE);
19345
+ this.wasm_memory.grow(pages);
19346
+ }
19347
+ this.mem8 = view(Uint8Array, this.wasm_memory, offset, new_size);
19348
+ this.mem32s = view(Uint32Array, this.wasm_memory, offset, new_size >> 2);
19365
19349
  this.memory_size[0] = new_size;
19366
19350
  }
19367
19351
  set_state(state) {
@@ -19411,6 +19395,7 @@ var V86Starter = (() => {
19411
19395
  this.flags[0] = state[26];
19412
19396
  this.flags_changed[0] = state[27];
19413
19397
  this.last_op1[0] = state[28];
19398
+ if (state[29] !== void 0) this.last_result[0] = state[29];
19414
19399
  this.last_op_size[0] = state[30];
19415
19400
  this.instruction_pointer[0] = state[37];
19416
19401
  this.previous_ip[0] = state[38];
@@ -19670,10 +19655,8 @@ var V86Starter = (() => {
19670
19655
  this.memory_size[0] === 0,
19671
19656
  "Expected uninitialised memory"
19672
19657
  );
19673
- const memory_offset = this.allocate_memory(size);
19674
- this.rebuild_wasm_views();
19675
19658
  this.memory_size[0] = size;
19676
- this.mem8_offset = memory_offset;
19659
+ const memory_offset = this.allocate_memory(size);
19677
19660
  this.mem8 = view(Uint8Array, this.wasm_memory, memory_offset, size);
19678
19661
  this.mem32s = view(
19679
19662
  Uint32Array,
@@ -19917,21 +19900,6 @@ var V86Starter = (() => {
19917
19900
  }
19918
19901
  }
19919
19902
  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
19903
  }
19936
19904
  load_multiboot(buffer) {
19937
19905
  if (this.bios.main) {
@@ -26246,11 +26214,10 @@ ${e.stack || e.message}`
26246
26214
  const memory_size = options.memory_size || 64 * 1024 * 1024;
26247
26215
  const vga_memory_size = options.vga_memory_size || 8 * 1024 * 1024;
26248
26216
  const memory_max = options.memory_max || (memory_size + vga_memory_size) * 4;
26249
- const WASM_PAGE_SIZE2 = 65536;
26250
26217
  const wasm_initial_pages = 256;
26251
26218
  const wasm_max_pages = Math.max(
26252
26219
  wasm_initial_pages,
26253
- Math.min(Math.ceil(memory_max / WASM_PAGE_SIZE2), 65536)
26220
+ Math.min(Math.ceil(memory_max / WASM_PAGE_SIZE), 65536)
26254
26221
  );
26255
26222
  const wasm_memory = new WebAssembly.Memory({
26256
26223
  initial: wasm_initial_pages,