Skip to content

Commit

Permalink
Fix macros used as expression
Browse files Browse the repository at this point in the history
  • Loading branch information
copy committed Oct 28, 2021
1 parent 6def710 commit c5dbd55
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 21 deletions.
16 changes: 12 additions & 4 deletions src/rust/codegen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down
12 changes: 9 additions & 3 deletions src/rust/control_flow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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(_) =>
Expand Down
22 changes: 14 additions & 8 deletions src/rust/cpu/cpu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -3607,26 +3613,26 @@ 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;
if *mxcsr >> MXCSR_RC_SHIFT & 3 == 0 && rounding_mode != 0 {
dbg_log!(
"Warning: Unimplemented MXCSR rounding mode: {}",
rounding_mode
)
);
}

let exception_mask = new_mxcsr >> 7 & 0b111111;
if exception_mask != 0b111111 {
dbg_log!(
"Warning: Unimplemented MXCSR exception mask: 0b{:b}",
exception_mask
)
);
}

*mxcsr = new_mxcsr;
Expand Down
4 changes: 3 additions & 1 deletion src/rust/cpu/instructions_0f.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/rust/cpu/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
16 changes: 12 additions & 4 deletions src/rust/jit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
},
Expand Down Expand Up @@ -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() {
Expand Down

0 comments on commit c5dbd55

Please sign in to comment.