@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.
package/dist/v86.js CHANGED
@@ -18786,7 +18786,6 @@ var CPU = class {
18786
18786
  wasm_memory;
18787
18787
  memory_size;
18788
18788
  mem8;
18789
- mem8_offset = 0;
18790
18789
  mem32s;
18791
18790
  segment_is_null;
18792
18791
  segment_offsets;
@@ -18916,46 +18915,10 @@ var CPU = class {
18916
18915
  this.wasm_memory = wm.wasm_memory;
18917
18916
  this.wasm_patch();
18918
18917
  this.create_jit_imports();
18919
- this.mem8 = new Uint8Array(0);
18920
- this.mem32s = new Int32Array(this.mem8.buffer);
18921
- this.rebuild_wasm_views();
18922
- this.devices = {};
18923
- this.memory_map_read8 = [];
18924
- this.memory_map_write8 = [];
18925
- this.memory_map_read32 = [];
18926
- this.memory_map_write32 = [];
18927
- this.bios = {
18928
- main: null,
18929
- vga: null
18930
- };
18931
- this.fpu_stack_empty[0] = 255;
18932
- this.fpu_stack_ptr[0] = 0;
18933
- this.fpu_control_word[0] = 895;
18934
- this.fpu_status_word[0] = 0;
18935
- this.fpu_ip[0] = 0;
18936
- this.fpu_ip_selector[0] = 0;
18937
- this.fpu_opcode[0] = 0;
18938
- this.fpu_dp[0] = 0;
18939
- this.fpu_dp_selector[0] = 0;
18940
- this.fw_value = [];
18941
- this.fw_pointer = 0;
18942
- this.option_roms = [];
18943
- this.io = void 0;
18944
- this.bus = bus;
18945
- this.set_tsc(0, 0);
18946
- if (false) {
18947
- this.seen_code = {};
18948
- this.seen_code_uncompiled = {};
18949
- }
18950
- }
18951
- /**
18952
- * Rebuild all TypedArray views into WASM linear memory.
18953
- * Must be called after any wasm_memory.grow() since growth
18954
- * detaches the old ArrayBuffer, invalidating all views.
18955
- */
18956
- rebuild_wasm_views() {
18957
18918
  const memory = this.wasm_memory;
18958
18919
  this.memory_size = view(Uint32Array, memory, 812, 1);
18920
+ this.mem8 = new Uint8Array(0);
18921
+ this.mem32s = new Int32Array(this.mem8.buffer);
18959
18922
  this.segment_is_null = view(Uint8Array, memory, 724, 8);
18960
18923
  this.segment_offsets = view(Int32Array, memory, 736, 8);
18961
18924
  this.segment_limits = view(Uint32Array, memory, 768, 8);
@@ -18984,22 +18947,40 @@ var CPU = class {
18984
18947
  this.last_op1 = view(Int32Array, memory, 104, 1);
18985
18948
  this.last_result = view(Int32Array, memory, 112, 1);
18986
18949
  this.current_tsc = view(Uint32Array, memory, 960, 2);
18950
+ this.devices = {};
18987
18951
  this.instruction_pointer = view(Int32Array, memory, 556, 1);
18988
18952
  this.previous_ip = view(Int32Array, memory, 560, 1);
18989
18953
  this.apic_enabled = view(Uint8Array, memory, 548, 1);
18990
18954
  this.acpi_enabled = view(Uint8Array, memory, 552, 1);
18955
+ this.memory_map_read8 = [];
18956
+ this.memory_map_write8 = [];
18957
+ this.memory_map_read32 = [];
18958
+ this.memory_map_write32 = [];
18959
+ this.bios = {
18960
+ main: null,
18961
+ vga: null
18962
+ };
18991
18963
  this.instruction_counter = view(Uint32Array, memory, 664, 1);
18992
18964
  this.reg32 = view(Int32Array, memory, 64, 8);
18993
18965
  this.fpu_st = view(Int32Array, memory, 1152, 4 * 8);
18994
18966
  this.fpu_stack_empty = view(Uint8Array, memory, 816, 1);
18967
+ this.fpu_stack_empty[0] = 255;
18995
18968
  this.fpu_stack_ptr = view(Uint8Array, memory, 1032, 1);
18969
+ this.fpu_stack_ptr[0] = 0;
18996
18970
  this.fpu_control_word = view(Uint16Array, memory, 1036, 1);
18971
+ this.fpu_control_word[0] = 895;
18997
18972
  this.fpu_status_word = view(Uint16Array, memory, 1040, 1);
18973
+ this.fpu_status_word[0] = 0;
18998
18974
  this.fpu_ip = view(Int32Array, memory, 1048, 1);
18975
+ this.fpu_ip[0] = 0;
18999
18976
  this.fpu_ip_selector = view(Int32Array, memory, 1052, 1);
18977
+ this.fpu_ip_selector[0] = 0;
19000
18978
  this.fpu_opcode = view(Int32Array, memory, 1044, 1);
18979
+ this.fpu_opcode[0] = 0;
19001
18980
  this.fpu_dp = view(Int32Array, memory, 1056, 1);
18981
+ this.fpu_dp[0] = 0;
19002
18982
  this.fpu_dp_selector = view(Int32Array, memory, 1060, 1);
18983
+ this.fpu_dp_selector[0] = 0;
19003
18984
  this.reg_xmm32s = view(Int32Array, memory, 832, 8 * 4);
19004
18985
  this.mxcsr = view(Int32Array, memory, 824, 1);
19005
18986
  this.sreg = view(Uint16Array, memory, 668, 8);
@@ -19007,6 +18988,16 @@ var CPU = class {
19007
18988
  this.reg_pdpte = view(Int32Array, memory, 968, 8);
19008
18989
  this.svga_dirty_bitmap_min_offset = view(Uint32Array, memory, 716, 1);
19009
18990
  this.svga_dirty_bitmap_max_offset = view(Uint32Array, memory, 720, 1);
18991
+ this.fw_value = [];
18992
+ this.fw_pointer = 0;
18993
+ this.option_roms = [];
18994
+ this.io = void 0;
18995
+ this.bus = bus;
18996
+ this.set_tsc(0, 0);
18997
+ if (false) {
18998
+ this.seen_code = {};
18999
+ this.seen_code_uncompiled = {};
19000
+ }
19010
19001
  }
19011
19002
  mmap_read8(addr) {
19012
19003
  const value = this.memory_map_read8[addr >>> MMAP_BLOCK_BITS](addr);
@@ -19189,6 +19180,7 @@ var CPU = class {
19189
19180
  state[26] = this.flags[0];
19190
19181
  state[27] = this.flags_changed[0];
19191
19182
  state[28] = this.last_op1[0];
19183
+ state[29] = this.last_result[0];
19192
19184
  state[30] = this.last_op_size[0];
19193
19185
  state[37] = this.instruction_pointer[0];
19194
19186
  state[38] = this.previous_ip[0];
@@ -19309,23 +19301,15 @@ var CPU = class {
19309
19301
  );
19310
19302
  }
19311
19303
  resize_memory(new_size) {
19312
- const mem8_offset = this.mem8_offset;
19313
- const needed_total = mem8_offset + new_size;
19314
- const current_buffer = this.wasm_memory.buffer.byteLength;
19315
- if (needed_total > current_buffer) {
19316
- const grow_pages = Math.ceil(
19317
- (needed_total - current_buffer) / WASM_PAGE_SIZE
19318
- );
19319
- this.wasm_memory.grow(grow_pages);
19320
- this.rebuild_wasm_views();
19321
- }
19322
- this.mem8 = view(Uint8Array, this.wasm_memory, mem8_offset, new_size);
19323
- this.mem32s = view(
19324
- Int32Array,
19325
- this.wasm_memory,
19326
- mem8_offset,
19327
- new_size >> 2
19328
- );
19304
+ const offset = this.mem8.byteOffset;
19305
+ const needed = offset + new_size;
19306
+ const current = this.wasm_memory.buffer.byteLength;
19307
+ if (needed > current) {
19308
+ const pages = Math.ceil((needed - current) / WASM_PAGE_SIZE);
19309
+ this.wasm_memory.grow(pages);
19310
+ }
19311
+ this.mem8 = view(Uint8Array, this.wasm_memory, offset, new_size);
19312
+ this.mem32s = view(Uint32Array, this.wasm_memory, offset, new_size >> 2);
19329
19313
  this.memory_size[0] = new_size;
19330
19314
  }
19331
19315
  set_state(state) {
@@ -19375,6 +19359,7 @@ var CPU = class {
19375
19359
  this.flags[0] = state[26];
19376
19360
  this.flags_changed[0] = state[27];
19377
19361
  this.last_op1[0] = state[28];
19362
+ if (state[29] !== void 0) this.last_result[0] = state[29];
19378
19363
  this.last_op_size[0] = state[30];
19379
19364
  this.instruction_pointer[0] = state[37];
19380
19365
  this.previous_ip[0] = state[38];
@@ -19634,10 +19619,8 @@ var CPU = class {
19634
19619
  this.memory_size[0] === 0,
19635
19620
  "Expected uninitialised memory"
19636
19621
  );
19637
- const memory_offset = this.allocate_memory(size);
19638
- this.rebuild_wasm_views();
19639
19622
  this.memory_size[0] = size;
19640
- this.mem8_offset = memory_offset;
19623
+ const memory_offset = this.allocate_memory(size);
19641
19624
  this.mem8 = view(Uint8Array, this.wasm_memory, memory_offset, size);
19642
19625
  this.mem32s = view(
19643
19626
  Uint32Array,
@@ -19881,21 +19864,6 @@ var CPU = class {
19881
19864
  }
19882
19865
  }
19883
19866
  this.debug_init();
19884
- this.rebuild_wasm_views();
19885
- if (this.mem8_offset > 0) {
19886
- this.mem8 = view(
19887
- Uint8Array,
19888
- this.wasm_memory,
19889
- this.mem8_offset,
19890
- this.memory_size[0]
19891
- );
19892
- this.mem32s = view(
19893
- Uint32Array,
19894
- this.wasm_memory,
19895
- this.mem8_offset,
19896
- this.memory_size[0] >> 2
19897
- );
19898
- }
19899
19867
  }
19900
19868
  load_multiboot(buffer) {
19901
19869
  if (this.bios.main) {
@@ -26209,11 +26177,10 @@ var V86 = class {
26209
26177
  const memory_size = options.memory_size || 64 * 1024 * 1024;
26210
26178
  const vga_memory_size = options.vga_memory_size || 8 * 1024 * 1024;
26211
26179
  const memory_max = options.memory_max || (memory_size + vga_memory_size) * 4;
26212
- const WASM_PAGE_SIZE2 = 65536;
26213
26180
  const wasm_initial_pages = 256;
26214
26181
  const wasm_max_pages = Math.max(
26215
26182
  wasm_initial_pages,
26216
- Math.min(Math.ceil(memory_max / WASM_PAGE_SIZE2), 65536)
26183
+ Math.min(Math.ceil(memory_max / WASM_PAGE_SIZE), 65536)
26217
26184
  );
26218
26185
  const wasm_memory = new WebAssembly.Memory({
26219
26186
  initial: wasm_initial_pages,