Browse Source

Fix macros used as expression

Fabian 2 years ago
parent
commit
c5dbd55d53
6 changed files with 51 additions and 21 deletions
  1. 12 4
      src/rust/codegen.rs
  2. 9 3
      src/rust/control_flow.rs
  3. 14 8
      src/rust/cpu/cpu.rs
  4. 3 1
      src/rust/cpu/instructions_0f.rs
  5. 1 1
      src/rust/cpu/memory.rs
  6. 12 4
      src/rust/jit.rs

+ 12 - 4
src/rust/codegen.rs

@@ -995,7 +995,9 @@ pub fn gen_safe_read_write(
         BitSize::QWORD => {
             ctx.builder.call_fn2_ret("safe_read_write64_slow_jit");
         },
-        BitSize::DQWORD => dbg_assert!(false),
+        BitSize::DQWORD => {
+            dbg_assert!(false);
+        },
     }
     ctx.builder.tee_local(&entry_local);
     ctx.builder.const_i32(1);
@@ -1083,7 +1085,9 @@ pub fn gen_safe_read_write(
                 ctx.builder
                     .call_fn3_i32_i64_i32_ret("safe_write64_slow_jit");
             },
-            BitSize::DQWORD => dbg_assert!(false),
+            BitSize::DQWORD => {
+                dbg_assert!(false);
+            },
         }
 
         if cfg!(debug_assertions) {
@@ -1133,7 +1137,9 @@ pub fn gen_safe_read_write(
         BitSize::QWORD => {
             ctx.builder.store_unaligned_i64(0);
         },
-        BitSize::DQWORD => dbg_assert!(false),
+        BitSize::DQWORD => {
+            dbg_assert!(false);
+        },
     }
 
     match value_local {
@@ -2203,7 +2209,9 @@ pub fn gen_condition_fn(ctx: &mut JitContext, condition: u8) {
             0xF => {
                 gen_test_le(ctx, ConditionNegate::True);
             },
-            _ => dbg_assert!(false),
+            _ => {
+                dbg_assert!(false);
+            },
         }
     }
     else {

+ 9 - 3
src/rust/control_flow.rs

@@ -81,7 +81,9 @@ pub enum WasmStructure {
 impl WasmStructure {
     pub fn print(&self, depth: usize) {
         match self {
-            Self::BasicBlock(addr) => dbg_log!("{} 0x{:x}", " ".repeat(depth), addr),
+            Self::BasicBlock(addr) => {
+                dbg_log!("{} 0x{:x}", " ".repeat(depth), addr);
+            },
             Self::Dispatcher(entries) => {
                 dbg_log!("{} Dispatcher entries:", " ".repeat(depth));
                 for e in entries {
@@ -160,7 +162,9 @@ pub fn assert_invariants(blocks: &Vec<WasmStructure>) {
                     check(c, in_tail_block && is_last, is_first, is_first);
                 }
             },
-            &WasmStructure::BasicBlock(addr) => dbg_assert!(addr != ENTRY_NODE_ID),
+            &WasmStructure::BasicBlock(addr) => {
+                dbg_assert!(addr != ENTRY_NODE_ID);
+            },
             WasmStructure::Dispatcher(_) => {
                 dbg_assert!(is_first);
                 //dbg_assert!(in_head_loop); // fails for module dispatcher
@@ -383,7 +387,9 @@ pub fn blockify(blocks: &mut Vec<WasmStructure>, edges: &Graph) {
             blocks.splice(source..i, iter::once(replacement)).collect();
         match &mut blocks[source] {
             WasmStructure::Block(c) => c.extend(children),
-            _ => dbg_assert!(false),
+            _ => {
+                dbg_assert!(false);
+            },
         }
         match &blocks[source + 1] {
             WasmStructure::BasicBlock(_) =>

+ 14 - 8
src/rust/cpu/cpu.rs

@@ -1201,7 +1201,7 @@ pub unsafe fn far_jump(eip: i32, selector: i32, is_call: bool, is_osize_32: bool
 
                 // XXX: Should be checked before side effects
                 if !switch_seg(SS, new_ss) {
-                    dbg_assert!(false)
+                    dbg_assert!(false);
                 };
                 set_stack_reg(new_esp);
 
@@ -3347,8 +3347,12 @@ pub unsafe fn safe_write_slow_jit(
                 value_low as i32,
             ),
             16 => virt_boundary_write16(addr_low, addr_high, value_low as i32),
-            8 => dbg_assert!(false),
-            _ => dbg_assert!(false),
+            8 => {
+                dbg_assert!(false);
+            },
+            _ => {
+                dbg_assert!(false);
+            },
         }
 
         let scratch = jit_paging_scratch_buffer.0.as_mut_ptr() as u32;
@@ -3368,7 +3372,9 @@ pub unsafe fn safe_write_slow_jit(
             32 => memory::mmap_write32(addr_low, value_low as i32),
             16 => memory::mmap_write16(addr_low, (value_low & 0xFFFF) as i32),
             8 => memory::mmap_write8(addr_low, (value_low & 0xFF) as i32),
-            _ => dbg_assert!(false),
+            _ => {
+                dbg_assert!(false);
+            },
         }
 
         let scratch = jit_paging_scratch_buffer.0.as_mut_ptr() as u32;
@@ -3607,10 +3613,10 @@ pub unsafe fn set_mxcsr(new_mxcsr: i32) {
     dbg_assert!(new_mxcsr & !MXCSR_MASK == 0); // checked by caller
 
     if *mxcsr & MXCSR_DAZ == 0 && new_mxcsr & MXCSR_DAZ != 0 {
-        dbg_log!("Warning: Unimplemented MXCSR bit: Denormals Are Zero")
+        dbg_log!("Warning: Unimplemented MXCSR bit: Denormals Are Zero");
     }
     if *mxcsr & MXCSR_FZ == 0 && new_mxcsr & MXCSR_FZ != 0 {
-        dbg_log!("Warning: Unimplemented MXCSR bit: Flush To Zero")
+        dbg_log!("Warning: Unimplemented MXCSR bit: Flush To Zero");
     }
 
     let rounding_mode = new_mxcsr >> MXCSR_RC_SHIFT & 3;
@@ -3618,7 +3624,7 @@ pub unsafe fn set_mxcsr(new_mxcsr: i32) {
         dbg_log!(
             "Warning: Unimplemented MXCSR rounding mode: {}",
             rounding_mode
-        )
+        );
     }
 
     let exception_mask = new_mxcsr >> 7 & 0b111111;
@@ -3626,7 +3632,7 @@ pub unsafe fn set_mxcsr(new_mxcsr: i32) {
         dbg_log!(
             "Warning: Unimplemented MXCSR exception mask: 0b{:b}",
             exception_mask
-        )
+        );
     }
 
     *mxcsr = new_mxcsr;

+ 3 - 1
src/rust/cpu/instructions_0f.rs

@@ -3271,7 +3271,9 @@ pub unsafe fn instr_0FA2() {
             dbg_assert!(ecx < 0x10000);
         },
 
-        x => dbg_log!("cpuid: unimplemented eax: {:x}", x),
+        x => {
+            dbg_log!("cpuid: unimplemented eax: {:x}", x);
+        },
     }
 
     if level == 4 {

+ 1 - 1
src/rust/cpu/memory.rs

@@ -22,7 +22,7 @@ pub static mut mem8: *mut u8 = ptr::null_mut();
 #[no_mangle]
 pub fn allocate_memory(size: u32) -> u32 {
     unsafe {
-        dbg_assert!(mem8.is_null())
+        dbg_assert!(mem8.is_null());
     };
     dbg_log!("Allocate memory size={}m", size >> 20);
     let layout = alloc::Layout::from_size_align(size as usize, 0x1000).unwrap();

+ 12 - 4
src/rust/jit.rs

@@ -1042,8 +1042,12 @@ fn jit_generate_module(
                     result = e.clone();
                     break;
                 },
-                WasmStructure::Loop { .. } => dbg_assert!(false),
-                WasmStructure::BasicBlock(_) => dbg_assert!(false),
+                WasmStructure::Loop { .. } => {
+                    dbg_assert!(false);
+                },
+                WasmStructure::BasicBlock(_) => {
+                    dbg_assert!(false);
+                },
                 // Note: We could use these blocks as entry points, which will yield
                 // more entries for free, but it requires adding those to the dispatcher
                 // It's to be investigated if this yields a performance improvement
@@ -1926,7 +1930,9 @@ fn free_wasm_table_index(ctx: &mut JitState, wasm_table_index: WasmTableIndex) {
     }
 
     match ctx.used_wasm_table_indices.remove(&wasm_table_index) {
-        None => dbg_assert!(false),
+        None => {
+            dbg_assert!(false);
+        },
         Some(_pages) => {
             //dbg_assert!(!pages.is_empty()); // only if CompilingWritten
         },
@@ -1994,7 +2000,9 @@ pub fn jit_dirty_page(ctx: &mut JitState, page: Page) {
 
         for index in &index_to_free {
             match ctx.used_wasm_table_indices.get(&index) {
-                None => dbg_assert!(false),
+                None => {
+                    dbg_assert!(false);
+                },
                 Some(pages) => {
                     for &p in pages {
                         for addr in p.address_range() {