Browse Source

enable wasm multivalue

Fabian 6 months ago
parent
commit
95d35d1b21
5 changed files with 22 additions and 10 deletions
  1. 1 1
      Cargo.toml
  2. 1 1
      Makefile
  3. 6 6
      src/rust/codegen.rs
  4. 12 0
      src/rust/cpu/fpu.rs
  5. 2 2
      tests/expect/tests/task_switch_test.wast

+ 1 - 1
Cargo.toml

@@ -17,7 +17,7 @@ opt-level = 2
 overflow-checks = false
 
 [profile.dev]
-lto = false
+lto = true
 opt-level = 2
 panic = "abort"
 overflow-checks = false

+ 1 - 1
Makefile

@@ -76,7 +76,7 @@ CARGO_FLAGS_SAFE=\
 		-C link-args="build/zstddeclib.o" \
 		--verbose
 
-CARGO_FLAGS=$(CARGO_FLAGS_SAFE) -C target-feature=+bulk-memory -C target-feature=+simd128
+CARGO_FLAGS=$(CARGO_FLAGS_SAFE) -C target-feature=+bulk-memory -C target-feature=+multivalue -C target-feature=+simd128
 
 CORE_FILES=const.js config.js io.js main.js lib.js buffer.js ide.js pci.js floppy.js \
 	   memory.js dma.js pit.js vga.js ps2.js pic.js rtc.js uart.js hpet.js \

+ 6 - 6
src/rust/codegen.rs

@@ -2435,7 +2435,7 @@ pub fn gen_fpu_get_sti(ctx: &mut JitContext, i: u32) {
     ctx.builder
         .const_i32(global_pointers::sse_scratch_register as i32);
     ctx.builder.const_i32(i as i32);
-    ctx.builder.call_fn2("fpu_get_sti");
+    ctx.builder.call_fn2("fpu_get_sti_jit");
     ctx.builder
         .load_fixed_i64(global_pointers::sse_scratch_register as u32);
     ctx.builder
@@ -2446,7 +2446,7 @@ pub fn gen_fpu_load_m32(ctx: &mut JitContext, modrm_byte: ModrmByte) {
     ctx.builder
         .const_i32(global_pointers::sse_scratch_register as i32);
     gen_modrm_resolve_safe_read32(ctx, modrm_byte);
-    ctx.builder.call_fn2("f32_to_f80");
+    ctx.builder.call_fn2("f32_to_f80_jit");
     ctx.builder
         .load_fixed_i64(global_pointers::sse_scratch_register as u32);
     ctx.builder
@@ -2457,7 +2457,7 @@ pub fn gen_fpu_load_m64(ctx: &mut JitContext, modrm_byte: ModrmByte) {
     ctx.builder
         .const_i32(global_pointers::sse_scratch_register as i32);
     gen_modrm_resolve_safe_read64(ctx, modrm_byte);
-    ctx.builder.call_fn2_i32_i64("f64_to_f80");
+    ctx.builder.call_fn2_i32_i64("f64_to_f80_jit");
     ctx.builder
         .load_fixed_i64(global_pointers::sse_scratch_register as u32);
     ctx.builder
@@ -2469,7 +2469,7 @@ pub fn gen_fpu_load_i16(ctx: &mut JitContext, modrm_byte: ModrmByte) {
         .const_i32(global_pointers::sse_scratch_register as i32);
     gen_modrm_resolve_safe_read16(ctx, modrm_byte);
     sign_extend_i16(ctx.builder);
-    ctx.builder.call_fn2("i32_to_f80");
+    ctx.builder.call_fn2("i32_to_f80_jit");
     ctx.builder
         .load_fixed_i64(global_pointers::sse_scratch_register as u32);
     ctx.builder
@@ -2479,7 +2479,7 @@ pub fn gen_fpu_load_i32(ctx: &mut JitContext, modrm_byte: ModrmByte) {
     ctx.builder
         .const_i32(global_pointers::sse_scratch_register as i32);
     gen_modrm_resolve_safe_read32(ctx, modrm_byte);
-    ctx.builder.call_fn2("i32_to_f80");
+    ctx.builder.call_fn2("i32_to_f80_jit");
     ctx.builder
         .load_fixed_i64(global_pointers::sse_scratch_register as u32);
     ctx.builder
@@ -2489,7 +2489,7 @@ pub fn gen_fpu_load_i64(ctx: &mut JitContext, modrm_byte: ModrmByte) {
     ctx.builder
         .const_i32(global_pointers::sse_scratch_register as i32);
     gen_modrm_resolve_safe_read64(ctx, modrm_byte);
-    ctx.builder.call_fn2_i32_i64("i64_to_f80");
+    ctx.builder.call_fn2_i32_i64("i64_to_f80_jit");
     ctx.builder
         .load_fixed_i64(global_pointers::sse_scratch_register as u32);
     ctx.builder

+ 12 - 0
src/rust/cpu/fpu.rs

@@ -61,6 +61,10 @@ pub unsafe fn fpu_sti_empty(mut i: i32) -> bool {
 }
 
 #[no_mangle]
+pub unsafe fn fpu_get_sti_jit(dst: *mut F80, i: i32) {
+    *dst = fpu_get_sti(i);
+}
+
 pub unsafe fn fpu_get_sti(mut i: i32) -> F80 {
     dbg_assert!(i >= 0 && i < 8);
     i = i + *fpu_stack_ptr as i32 & 7;
@@ -81,6 +85,9 @@ pub unsafe fn fpu_get_sti_f64(mut i: i32) -> f64 {
 }
 
 #[no_mangle]
+pub unsafe fn f32_to_f80_jit(dst: *mut F80, v: i32) {
+    *dst = f32_to_f80(v)
+}
 pub unsafe fn f32_to_f80(v: i32) -> F80 {
     F80::clear_exception_flags();
     let x = F80::of_f32(v);
@@ -88,6 +95,9 @@ pub unsafe fn f32_to_f80(v: i32) -> F80 {
     x
 }
 #[no_mangle]
+pub unsafe fn f64_to_f80_jit(dst: *mut F80, v: u64) {
+    *dst = f64_to_f80(v)
+}
 pub unsafe fn f64_to_f80(v: u64) -> F80 {
     F80::clear_exception_flags();
     let x = F80::of_f64(v);
@@ -110,8 +120,10 @@ pub unsafe fn f80_to_f64(v: F80) -> u64 {
 }
 
 #[no_mangle]
+pub unsafe fn i32_to_f80_jit(dst: *mut F80, v: i32) { *dst = i32_to_f80(v) }
 pub unsafe fn i32_to_f80(v: i32) -> F80 { F80::of_i32(v) }
 #[no_mangle]
+pub unsafe fn i64_to_f80_jit(dst: *mut F80, v: i64) { *dst = i64_to_f80(v) }
 pub unsafe fn i64_to_f80(v: i64) -> F80 { F80::of_i64(v) }
 
 pub unsafe fn fpu_load_i16(addr: i32) -> OrPageFault<F80> {

+ 2 - 2
tests/expect/tests/task_switch_test.wast

@@ -21,7 +21,7 @@
   (type $t19 (func (param i32 i64 i32) (result i32)))
   (type $t20 (func (param i32 i64 i64 i32) (result i32)))
   (import "e" "task_switch_test_jit" (func $e.task_switch_test_jit (type $t1)))
-  (import "e" "fpu_get_sti" (func $e.fpu_get_sti (type $t2)))
+  (import "e" "fpu_get_sti_jit" (func $e.fpu_get_sti_jit (type $t2)))
   (import "e" "fpu_fadd" (func $e.fpu_fadd (type $t18)))
   (import "e" "fpu_pop" (func $e.fpu_pop (type $t0)))
   (import "e" "instr_F4" (func $e.instr_F4 (type $t0)))
@@ -79,7 +79,7 @@
                   (i32.const 4096))
                 (br $B1)))
             (i32.const 1)
-            (call $e.fpu_get_sti
+            (call $e.fpu_get_sti_jit
               (i32.const 1136)
               (i32.const 1))
             (i64.load