v86 0.5.254 → 0.5.262

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/build/libv86.js CHANGED
@@ -340,8 +340,9 @@ M.prototype.get_instruction_stats=function(){var a=this.v86.cpu;var b="";var c="
340
340
  b+="JIT_CACHE_SIZE="+a.wm.exports.jit_get_cache_size()+"\n";b+="FLAT_SEGMENTS="+a.wm.exports.has_flat_segmentation()+"\n";b+="wasm memory size: "+(a.wasm_memory.buffer.byteLength>>20)+"m\n";b=b+"Config:\nJIT_DISABLED="+(a.wm.exports.get_jit_config(0)+"\n");b+="MAX_PAGES="+a.wm.exports.get_jit_config(1)+"\n";b+="JIT_USE_LOOP_SAFETY="+!!a.wm.exports.get_jit_config(2)+"\n";b+="MAX_EXTRA_BASIC_BLOCKS="+a.wm.exports.get_jit_config(3)+"\n";a=[fb(a,!1,!1,!1,!1),fb(a,!0,!1,!1,!1),fb(a,!1,!0,!1,!1),fb(a,!1,
341
341
  !1,!0,!1),fb(a,!1,!1,!1,!0)].join("\n\n");return b+a};function sc(a){this.message=a||"File not found"}sc.prototype=Error.prototype;"undefined"!==typeof module&&"undefined"!==typeof module.exports?module.exports.V86=M:"undefined"!==typeof window?window.V86=M:"function"===typeof importScripts&&(self.V86=M);function E(a,b){this.stopping=this.running=!1;this.idle=!0;this.tick_counter=0;this.worker=null;this.cpu=new O(a,b,()=>{this.idle&&this.next_tick(0)});this.bus=a;this.register_yield()}E.prototype.run=function(){this.stopping=!1;this.running||(this.running=!0,this.bus.send("emulator-started"));this.next_tick(0)};E.prototype.do_tick=function(){if(this.stopping||!this.running)this.stopping=this.running=!1,this.bus.send("emulator-stopped");else{this.idle=!1;var a=this.cpu.main_loop();this.next_tick(a)}};
342
342
  E.prototype.next_tick=function(a){const b=++this.tick_counter;this.idle=!0;this.yield(a,b)};E.prototype.yield_callback=function(a){a===this.tick_counter&&this.do_tick()};E.prototype.stop=function(){this.running&&(this.stopping=!0)};E.prototype.destroy=function(){this.unregister_yield()};E.prototype.restart=function(){this.cpu.reset_cpu();this.cpu.load_bios()};E.prototype.init=function(a){this.cpu.init(a,this.bus);this.bus.send("emulator-ready")};
343
- if("undefined"!==typeof process)E.prototype.yield=function(a,b){1>a?global.setImmediate(c=>this.yield_callback(c),b):setTimeout(c=>this.yield_callback(c),a,b)},E.prototype.register_yield=function(){},E.prototype.unregister_yield=function(){};else if("undefined"!==typeof Worker){function a(){let b;globalThis.onmessage=function(c){const d=c.data.t;b=b&&clearTimeout(b);1>d?postMessage(c.data.tick):b=setTimeout(()=>postMessage(c.data.tick),d)}}E.prototype.register_yield=function(){const b=URL.createObjectURL(new Blob(["("+
344
- a.toString()+")()"],{type:"text/javascript"}));this.worker=new Worker(b);this.worker.onmessage=c=>this.yield_callback(c.data);URL.revokeObjectURL(b)};E.prototype.yield=function(b,c){this.worker.postMessage({t:b,tick:c})};E.prototype.unregister_yield=function(){this.worker&&this.worker.terminate();this.worker=null}}else E.prototype.yield=function(a){setTimeout(()=>{this.do_tick()},a)},E.prototype.register_yield=function(){},E.prototype.unregister_yield=function(){};
343
+ if("undefined"!==typeof process)E.prototype.yield=function(a,b){1>a?global.setImmediate(c=>this.yield_callback(c),b):setTimeout(c=>this.yield_callback(c),a,b)},E.prototype.register_yield=function(){},E.prototype.unregister_yield=function(){};else if(window.scheduler&&"function"===typeof window.scheduler.postTask&&!location.href.includes("dont-use-scheduling-api"))E.prototype.yield=function(a,b){a=Math.max(0,a);window.scheduler.postTask(()=>this.yield_callback(b),{delay:a})},E.prototype.register_yield=
344
+ function(){},E.prototype.unregister_yield=function(){};else if("undefined"!==typeof Worker){function a(){let b;globalThis.onmessage=function(c){const d=c.data.t;b=b&&clearTimeout(b);1>d?postMessage(c.data.tick):b=setTimeout(()=>postMessage(c.data.tick),d)}}E.prototype.register_yield=function(){const b=URL.createObjectURL(new Blob(["("+a.toString()+")()"],{type:"text/javascript"}));this.worker=new Worker(b);this.worker.onmessage=c=>this.yield_callback(c.data);URL.revokeObjectURL(b)};E.prototype.yield=
345
+ function(b,c){this.worker.postMessage({t:b,tick:c})};E.prototype.unregister_yield=function(){this.worker&&this.worker.terminate();this.worker=null}}else E.prototype.yield=function(a){setTimeout(()=>{this.do_tick()},a)},E.prototype.register_yield=function(){},E.prototype.unregister_yield=function(){};
345
346
  E.prototype.save_state=function(){for(var a=[],b=cb(this.cpu,a),c=[],d=0,e=0;e<a.length;e++){var f=a[e].byteLength;c[e]={offset:d,length:f};d+=f;d=d+3&-4}e=JSON.stringify({buffer_infos:c,state:b});e=(new TextEncoder).encode(e);b=16+e.length;b=b+3&-4;f=b+d;d=new ArrayBuffer(f);var g=new Int32Array(d,0,4);(new Uint8Array(d,16,e.length)).set(e);b=new Uint8Array(d,b);g[0]=-2039052682;g[1]=6;g[2]=f;g[3]=e.length;for(e=0;e<a.length;e++)b.set(a[e],c[e].offset);return d};
346
347
  E.prototype.restore_state=function(a){return eb(this.cpu,a)};if("object"===typeof performance&&performance.now)E.microtick=performance.now.bind(performance);else if("function"===typeof require){const {performance:a}=require("perf_hooks");E.microtick=a.now.bind(a)}else E.microtick="object"===typeof process&&process.hrtime?function(){var a=process.hrtime();return 1E3*a[0]+a[1]/1E6}:Date.now;function tc(a){this.cpu=a;var b=a.io;a.devices.pci.register_device({pci_id:56,pci_space:[134,128,19,113,7,0,128,2,8,0,128,6,0,0,128,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,9,1,0,0],pci_bars:[],name:"acpi"});this.timer_imprecision_offset=this.timer_last_value=0;this.status=1;this.pm1_enable=this.pm1_status=0;this.last_timer=this.get_timer(E.microtick());this.gpe=new Uint8Array(4);b.register_read(45056,this,void 0,function(){return this.pm1_status});
347
348
  b.register_write(45056,this,void 0,function(c){z(c,4);this.pm1_status&=~c});b.register_read(45058,this,void 0,function(){return this.pm1_enable});b.register_write(45058,this,void 0,function(c){z(c);this.pm1_enable=c});b.register_read(45060,this,function(){return this.status&255},function(){return this.status});b.register_write(45060,this,void 0,function(c){z(c);this.status=c});b.register_read(45064,this,void 0,void 0,function(){return this.get_timer(E.microtick())&16777215});b.register_read(45024,
@@ -644,7 +645,7 @@ this.devices.uart0&&this.devices.uart0.set_state(a[54]);this.devices.fdc&&this.d
644
645
  this.devices.pci.set_state(a[48]);this.devices.pit&&this.devices.pit.set_state(a[58]);this.devices.net&&this.devices.net.set_state(a[59]);this.set_state_pic(a[60]);this.devices.sb16&&this.devices.sb16.set_state(a[61]);this.devices.uart1&&this.devices.uart1.set_state(a[79]);this.devices.uart2&&this.devices.uart2.set_state(a[80]);this.devices.uart3&&this.devices.uart3.set_state(a[81]);this.devices.virtio_console&&this.devices.virtio_console.set_state(a[82]);this.devices.virtio_net&&this.devices.virtio_net.set_state(a[83]);
645
646
  this.devices.virtio_balloon&&this.devices.virtio_balloon.set_state(a[84]);this.fw_value=a[62];a[63]&&this.set_state_ioapic(a[63]);this.tss_size_32[0]=a[64];this.reg_xmm32s.set(a[66]);this.fpu_st.set(a[67]);this.fpu_stack_empty[0]=a[68];this.fpu_stack_ptr[0]=a[69];this.fpu_control_word[0]=a[70];this.fpu_ip[0]=a[71];this.fpu_ip_selector[0]=a[72];this.fpu_dp[0]=a[73];this.fpu_dp_selector[0]=a[74];this.fpu_opcode[0]=a[75];b=new ma(a[78].buffer);this.unpack_memory(b,a[77]);this.update_state_flags();this.full_clear_tlb();
646
647
  this.jit_clear_cache()};O.prototype.set_state_pic=function(a){const b=new Uint8Array(this.wasm_memory.buffer,this.get_pic_addr_master(),13),c=new Uint8Array(this.wasm_memory.buffer,this.get_pic_addr_slave(),13);b[0]=a[0];b[1]=a[1];b[2]=a[2];b[3]=a[3];b[4]=a[4];const d=a[5];b[6]=a[6];b[7]=a[7];b[8]=a[8];b[9]=a[9];b[10]=a[10];b[11]=a[11];b[12]=a[12];c[0]=d[0];c[1]=d[1];c[2]=d[2];c[3]=d[3];c[4]=d[4];c[6]=d[6];c[7]=d[7];c[8]=d[8];c[9]=d[9];c[10]=d[10];c[11]=d[11];c[12]=d[12]};
647
- O.prototype.set_state_apic=function(a){if(a instanceof Array){const b=new Int32Array(this.wasm_memory.buffer,this.get_apic_addr(),46);b[0]=a[0];b[1]=a[1];b[2]=a[2];b[3]=a[3];b[4]=a[4];b[7]=a[6];b[8]=a[7];b[9]=a[8];b[10]=a[9];b[11]=a[10];b[12]=a[11];b[13]=a[12];b[14]=a[13];b.set(a[15],16);b.set(a[15],24);b.set(a[16],32);b[40]=a[17];b[41]=a[18];b[42]=a[19];b[43]=a[20];b[44]=a[21];b[45]=a[22]||65536}else(new Uint8Array(this.wasm_memory.buffer,this.get_apic_addr(),184)).set(a)};
648
+ O.prototype.set_state_apic=function(a){if(a instanceof Array){const b=new Int32Array(this.wasm_memory.buffer,this.get_apic_addr(),46);b[0]=a[0];b[1]=a[1];b[2]=a[2];b[3]=a[3];b[4]=a[4];b[8]=a[6];b[9]=a[7];b[10]=a[8];b[11]=a[9];b[12]=a[10];b[13]=a[11];b[14]=a[12];b[15]=a[13];b.set(a[15],16);b.set(a[15],24);b.set(a[16],32);b[40]=a[17];b[41]=a[18];b[42]=a[19];b[43]=a[20];b[44]=a[21];b[45]=a[22]||65536}else(new Uint8Array(this.wasm_memory.buffer,this.get_apic_addr(),184)).set(a)};
648
649
  O.prototype.set_state_ioapic=function(a){if(a instanceof Array){const b=new Int32Array(this.wasm_memory.buffer,this.get_ioapic_addr(),52);b.set(a[0],0);b.set(a[1],24);b[48]=a[2];b[49]=a[3];b[50]=a[4];b[51]=a[5]}else(new Uint8Array(this.wasm_memory.buffer,this.get_ioapic_addr(),208)).set(a)};
649
650
  O.prototype.pack_memory=function(){var a=this.mem8.length>>12,b=[];for(var c=0;c<a;c++)this.is_memory_zeroed(c<<12,4096)||b.push(c);a=new ma(a);c=new Uint8Array(b.length<<12);for(const [d,e]of b.entries())a.set(e,1),b=e<<12,b=this.mem8.subarray(b,b+4096),c.set(b,d<<12);return{bitmap:a,packed_memory:c}};
650
651
  O.prototype.unpack_memory=function(a,b){this.zero_memory(0,this.memory_size[0]);const c=this.memory_size[0]>>12;let d=0;for(let f=0;f<c;f++)if(a.get(f)){var e=d<<12;e=b.subarray(e,e+4096);this.mem8.set(e,f<<12);d++}};