Remove prefix handling from jit and exceptions
This commit is contained in:
parent
92568a7ef2
commit
3a473aad79
|
@ -3017,11 +3017,6 @@ CPU.prototype.verw = function(selector)
|
|||
}
|
||||
};
|
||||
|
||||
CPU.prototype.is_asize_32 = function()
|
||||
{
|
||||
return Boolean(this.is_32[0]) !== ((this.prefixes[0] & PREFIX_MASK_ADDRSIZE) === PREFIX_MASK_ADDRSIZE);
|
||||
};
|
||||
|
||||
CPU.prototype.lss16 = function(addr, reg, seg)
|
||||
{
|
||||
var new_reg = this.safe_read16(addr),
|
||||
|
|
|
@ -829,26 +829,6 @@ fn gen_safe_write(
|
|||
ctx.builder.free_local(entry_local);
|
||||
}
|
||||
|
||||
pub fn gen_clear_prefixes(ctx: &mut JitContext) {
|
||||
let instruction_body = &mut ctx.builder.instruction_body;
|
||||
instruction_body.const_i32(global_pointers::PREFIXES as i32); // load address of prefixes
|
||||
instruction_body.const_i32(0);
|
||||
instruction_body.store_aligned_i32(0);
|
||||
}
|
||||
|
||||
pub fn gen_add_prefix_bits(ctx: &mut JitContext, mask: u32) {
|
||||
dbg_assert!(mask < 0x100);
|
||||
|
||||
let instruction_body = &mut ctx.builder.instruction_body;
|
||||
instruction_body.const_i32(global_pointers::PREFIXES as i32); // load address of prefixes
|
||||
|
||||
instruction_body.load_aligned_i32(global_pointers::PREFIXES); // load old value
|
||||
instruction_body.const_i32(mask as i32);
|
||||
instruction_body.or_i32();
|
||||
|
||||
instruction_body.store_aligned_i32(0);
|
||||
}
|
||||
|
||||
pub fn gen_jmp_rel16(builder: &mut WasmBuilder, rel16: u16) {
|
||||
let cs_offset_addr = global_pointers::get_seg_offset(regs::CS);
|
||||
builder.instruction_body.load_aligned_i32(cs_offset_addr);
|
||||
|
@ -1087,7 +1067,6 @@ pub fn gen_task_switch_test(ctx: &mut JitContext) {
|
|||
gen_move_registers_from_locals_to_memory(ctx);
|
||||
gen_fn0_const(ctx.builder, "task_switch_test_jit");
|
||||
|
||||
gen_clear_prefixes(ctx);
|
||||
ctx.builder.instruction_body.return_();
|
||||
|
||||
ctx.builder.instruction_body.block_end();
|
||||
|
@ -1116,7 +1095,6 @@ pub fn gen_task_switch_test_mmx(ctx: &mut JitContext) {
|
|||
gen_move_registers_from_locals_to_memory(ctx);
|
||||
gen_fn0_const(ctx.builder, "task_switch_test_mmx_jit");
|
||||
|
||||
gen_clear_prefixes(ctx);
|
||||
ctx.builder.instruction_body.return_();
|
||||
|
||||
ctx.builder.instruction_body.block_end();
|
||||
|
@ -1668,7 +1646,6 @@ pub fn gen_trigger_ud(ctx: &mut JitContext) {
|
|||
);
|
||||
gen_fn0_const(ctx.builder, "trigger_ud");
|
||||
gen_debug_track_jit_exit(ctx.builder, ctx.start_of_current_instruction);
|
||||
gen_clear_prefixes(ctx);
|
||||
ctx.builder.instruction_body.return_();
|
||||
}
|
||||
|
||||
|
@ -1680,7 +1657,6 @@ pub fn gen_trigger_gp(ctx: &mut JitContext, error_code: u32) {
|
|||
);
|
||||
gen_fn1_const(ctx.builder, "trigger_gp", error_code);
|
||||
gen_debug_track_jit_exit(ctx.builder, ctx.start_of_current_instruction);
|
||||
gen_clear_prefixes(ctx);
|
||||
ctx.builder.instruction_body.return_();
|
||||
}
|
||||
|
||||
|
|
|
@ -1298,7 +1298,6 @@ pub unsafe fn trigger_pagefault_jit(fault: PageFault) {
|
|||
// invalidate tlb entry
|
||||
let page = ((addr as u32) >> 12) as i32;
|
||||
*tlb_data.offset(page as isize) = 0;
|
||||
*prefixes = 0;
|
||||
if DEBUG {
|
||||
if cpu_exception_hook(CPU_EXCEPTION_PF) {
|
||||
return;
|
||||
|
@ -1342,7 +1341,6 @@ pub unsafe fn trigger_pagefault(fault: PageFault) {
|
|||
// invalidate tlb entry
|
||||
let page = ((addr as u32) >> 12) as i32;
|
||||
*tlb_data.offset(page as isize) = 0;
|
||||
*prefixes = 0;
|
||||
*instruction_pointer = *previous_ip;
|
||||
call_interrupt_vector(
|
||||
CPU_EXCEPTION_PF,
|
||||
|
@ -1823,12 +1821,10 @@ pub unsafe fn cycle_internal() {
|
|||
let initial_tsc = *timestamp_counter;
|
||||
let wasm_table_index = (entry & 0xFFFF) as u16;
|
||||
let initial_state = (entry >> 16) as u16;
|
||||
dbg_assert!(*prefixes == 0);
|
||||
call_indirect1(
|
||||
(wasm_table_index as u32).wrapping_add(WASM_TABLE_OFFSET as u32) as i32,
|
||||
initial_state,
|
||||
);
|
||||
dbg_assert!(*prefixes == 0);
|
||||
profiler::stat_increment_by(
|
||||
RUN_FROM_CACHE_STEPS,
|
||||
(*timestamp_counter - initial_tsc) as u64,
|
||||
|
@ -2003,8 +1999,6 @@ pub unsafe fn run_prefix_instruction() {
|
|||
run_instruction(return_on_pagefault!(read_imm8()) | (is_osize_32() as i32) << 8);
|
||||
}
|
||||
|
||||
pub unsafe fn clear_prefixes() { *prefixes = 0 }
|
||||
|
||||
pub unsafe fn segment_prefix_op(seg: i32) {
|
||||
dbg_assert!(seg <= 5);
|
||||
*prefixes = (*prefixes as i32 | seg + 1) as u8;
|
||||
|
@ -2025,7 +2019,6 @@ pub unsafe fn do_many_cycles_native() {
|
|||
|
||||
pub unsafe fn trigger_de() {
|
||||
dbg_log!("#de");
|
||||
*prefixes = 0;
|
||||
*instruction_pointer = *previous_ip;
|
||||
if DEBUG {
|
||||
if cpu_exception_hook(CPU_EXCEPTION_DE) {
|
||||
|
@ -2039,7 +2032,6 @@ pub unsafe fn trigger_de() {
|
|||
pub unsafe fn trigger_ud() {
|
||||
dbg_log!("#ud");
|
||||
dbg_trace();
|
||||
*prefixes = 0;
|
||||
*instruction_pointer = *previous_ip;
|
||||
if DEBUG {
|
||||
if cpu_exception_hook(CPU_EXCEPTION_UD) {
|
||||
|
@ -2052,7 +2044,6 @@ pub unsafe fn trigger_ud() {
|
|||
pub unsafe fn trigger_nm() {
|
||||
dbg_log!("#nm eip={:x}", *previous_ip);
|
||||
dbg_trace();
|
||||
*prefixes = 0;
|
||||
*instruction_pointer = *previous_ip;
|
||||
if DEBUG {
|
||||
if cpu_exception_hook(CPU_EXCEPTION_NM) {
|
||||
|
@ -2065,7 +2056,6 @@ pub unsafe fn trigger_nm() {
|
|||
#[no_mangle]
|
||||
pub unsafe fn trigger_gp(code: i32) {
|
||||
dbg_log!("#gp");
|
||||
*prefixes = 0;
|
||||
*instruction_pointer = *previous_ip;
|
||||
if DEBUG {
|
||||
if cpu_exception_hook(CPU_EXCEPTION_GP) {
|
||||
|
@ -2991,7 +2981,6 @@ pub unsafe fn translate_address_system_write(address: i32) -> OrPageFault<u32> {
|
|||
#[no_mangle]
|
||||
pub unsafe fn trigger_np(code: i32) {
|
||||
dbg_log!("#np");
|
||||
*prefixes = 0;
|
||||
*instruction_pointer = *previous_ip;
|
||||
if DEBUG {
|
||||
if cpu_exception_hook(CPU_EXCEPTION_NP) {
|
||||
|
@ -3004,7 +2993,6 @@ pub unsafe fn trigger_np(code: i32) {
|
|||
#[no_mangle]
|
||||
pub unsafe fn trigger_ss(code: i32) {
|
||||
dbg_log!("#ss");
|
||||
*prefixes = 0;
|
||||
*instruction_pointer = *previous_ip;
|
||||
if DEBUG {
|
||||
if cpu_exception_hook(CPU_EXCEPTION_SS) {
|
||||
|
|
|
@ -11,7 +11,7 @@ pub const PAGE_FAULT: u32 = 540;
|
|||
pub const INSTRUCTION_POINTER: u32 = 556;
|
||||
pub const PREVIOUS_IP: u32 = 560;
|
||||
pub const CR: u32 = 580;
|
||||
pub const PREFIXES: u32 = 648;
|
||||
|
||||
pub const TIMESTAMP_COUNTER: u32 = 664;
|
||||
pub const SREG: u32 = 668;
|
||||
pub const SEGMENT_OFFSETS: u32 = 736;
|
||||
|
|
|
@ -1185,7 +1185,6 @@ fn jit_generate_module(
|
|||
ctx.builder.instruction_body.block_end();
|
||||
codegen::gen_move_registers_from_locals_to_memory(ctx);
|
||||
codegen::gen_fn0_const(ctx.builder, "trigger_pagefault_end_jit");
|
||||
codegen::gen_clear_prefixes(ctx);
|
||||
ctx.builder.instruction_body.return_();
|
||||
}
|
||||
|
||||
|
|
|
@ -49,14 +49,11 @@ pub fn jit_handle_prefix(ctx: &mut JitContext, instr_flags: &mut u32) {
|
|||
ctx,
|
||||
instr_flags,
|
||||
);
|
||||
codegen::gen_clear_prefixes(ctx);
|
||||
}
|
||||
|
||||
pub fn jit_handle_segment_prefix(segment: u32, ctx: &mut JitContext, instr_flags: &mut u32) {
|
||||
dbg_assert!(segment <= 5);
|
||||
ctx.cpu.prefixes |= segment + 1;
|
||||
// TODO: Could merge multiple prefix updates into one
|
||||
codegen::gen_add_prefix_bits(ctx, segment + 1);
|
||||
jit_handle_prefix(ctx, instr_flags)
|
||||
}
|
||||
|
||||
|
@ -88,14 +85,10 @@ pub fn instr_65_jit(ctx: &mut JitContext, instr_flags: &mut u32) {
|
|||
|
||||
pub fn instr_66_jit(ctx: &mut JitContext, instr_flags: &mut u32) {
|
||||
ctx.cpu.prefixes |= PREFIX_66;
|
||||
// TODO: Could merge multiple prefix updates into one
|
||||
codegen::gen_add_prefix_bits(ctx, PREFIX_66);
|
||||
jit_handle_prefix(ctx, instr_flags)
|
||||
}
|
||||
pub fn instr_67_jit(ctx: &mut JitContext, instr_flags: &mut u32) {
|
||||
ctx.cpu.prefixes |= PREFIX_67;
|
||||
// TODO: Could merge multiple prefix updates into one
|
||||
codegen::gen_add_prefix_bits(ctx, PREFIX_67);
|
||||
jit_handle_prefix(ctx, instr_flags)
|
||||
}
|
||||
pub fn instr_F0_jit(ctx: &mut JitContext, instr_flags: &mut u32) {
|
||||
|
@ -104,14 +97,10 @@ pub fn instr_F0_jit(ctx: &mut JitContext, instr_flags: &mut u32) {
|
|||
}
|
||||
pub fn instr_F2_jit(ctx: &mut JitContext, instr_flags: &mut u32) {
|
||||
ctx.cpu.prefixes |= PREFIX_F2;
|
||||
// string/sse prefix: Don't generate code to update prefixes at runtime. This means runtime
|
||||
// instructions can't inspect the prefixes for this flags
|
||||
jit_handle_prefix(ctx, instr_flags)
|
||||
}
|
||||
pub fn instr_F3_jit(ctx: &mut JitContext, instr_flags: &mut u32) {
|
||||
ctx.cpu.prefixes |= PREFIX_F3;
|
||||
// string/sse prefix: Don't generate code to update prefixes at runtime. This means runtime
|
||||
// instructions can't inspect the prefixes for this flags
|
||||
jit_handle_prefix(ctx, instr_flags)
|
||||
}
|
||||
|
||||
|
@ -2367,7 +2356,6 @@ pub fn instr16_D9_4_mem_jit(ctx: &mut JitContext, modrm_byte: u8) {
|
|||
ctx.builder.instruction_body.if_void();
|
||||
codegen::gen_debug_track_jit_exit(ctx.builder, ctx.start_of_current_instruction);
|
||||
codegen::gen_move_registers_from_locals_to_memory(ctx);
|
||||
codegen::gen_clear_prefixes(ctx);
|
||||
ctx.builder.instruction_body.return_();
|
||||
ctx.builder.instruction_body.block_end();
|
||||
}
|
||||
|
@ -2419,7 +2407,6 @@ pub fn instr16_D9_6_mem_jit(ctx: &mut JitContext, modrm_byte: u8) {
|
|||
ctx.builder.instruction_body.if_void();
|
||||
codegen::gen_debug_track_jit_exit(ctx.builder, ctx.start_of_current_instruction);
|
||||
codegen::gen_move_registers_from_locals_to_memory(ctx);
|
||||
codegen::gen_clear_prefixes(ctx);
|
||||
ctx.builder.instruction_body.return_();
|
||||
ctx.builder.instruction_body.block_end();
|
||||
}
|
||||
|
@ -2517,7 +2504,6 @@ pub fn instr_DB_5_mem_jit(ctx: &mut JitContext, modrm_byte: u8) {
|
|||
ctx.builder.instruction_body.if_void();
|
||||
codegen::gen_debug_track_jit_exit(ctx.builder, ctx.start_of_current_instruction);
|
||||
codegen::gen_move_registers_from_locals_to_memory(ctx);
|
||||
codegen::gen_clear_prefixes(ctx);
|
||||
ctx.builder.instruction_body.return_();
|
||||
ctx.builder.instruction_body.block_end();
|
||||
}
|
||||
|
@ -4156,7 +4142,6 @@ pub fn instr_0FF7_reg_jit(ctx: &mut JitContext, r1: u32, r2: u32) {
|
|||
ctx.builder.instruction_body.if_void();
|
||||
codegen::gen_debug_track_jit_exit(ctx.builder, ctx.start_of_current_instruction);
|
||||
codegen::gen_move_registers_from_locals_to_memory(ctx);
|
||||
codegen::gen_clear_prefixes(ctx);
|
||||
ctx.builder.instruction_body.return_();
|
||||
ctx.builder.instruction_body.block_end();
|
||||
}
|
||||
|
@ -4189,7 +4174,6 @@ pub fn instr_660FF7_reg_jit(ctx: &mut JitContext, r1: u32, r2: u32) {
|
|||
ctx.builder.instruction_body.if_void();
|
||||
codegen::gen_debug_track_jit_exit(ctx.builder, ctx.start_of_current_instruction);
|
||||
codegen::gen_move_registers_from_locals_to_memory(ctx);
|
||||
codegen::gen_clear_prefixes(ctx);
|
||||
ctx.builder.instruction_body.return_();
|
||||
ctx.builder.instruction_body.block_end();
|
||||
}
|
||||
|
|
|
@ -392,8 +392,5 @@
|
|||
(i32.const 92)
|
||||
(get_local $l9))
|
||||
(call $e.trigger_pagefault_end_jit)
|
||||
(i32.store
|
||||
(i32.const 648)
|
||||
(i32.const 0))
|
||||
(return))
|
||||
(unreachable))))
|
||||
|
|
|
@ -284,8 +284,5 @@
|
|||
(i32.const 92)
|
||||
(get_local $l9))
|
||||
(call $e.trigger_pagefault_end_jit)
|
||||
(i32.store
|
||||
(i32.const 648)
|
||||
(i32.const 0))
|
||||
(return))
|
||||
(unreachable))))
|
||||
|
|
|
@ -282,8 +282,5 @@
|
|||
(i32.const 92)
|
||||
(get_local $l9))
|
||||
(call $e.trigger_pagefault_end_jit)
|
||||
(i32.store
|
||||
(i32.const 648)
|
||||
(i32.const 0))
|
||||
(return))
|
||||
(unreachable))))
|
||||
|
|
|
@ -361,8 +361,5 @@
|
|||
(i32.const 92)
|
||||
(get_local $l9))
|
||||
(call $e.trigger_pagefault_end_jit)
|
||||
(i32.store
|
||||
(i32.const 648)
|
||||
(i32.const 0))
|
||||
(return))
|
||||
(unreachable))))
|
||||
|
|
|
@ -505,8 +505,5 @@
|
|||
(i32.const 92)
|
||||
(get_local $l9))
|
||||
(call $e.trigger_pagefault_end_jit)
|
||||
(i32.store
|
||||
(i32.const 648)
|
||||
(i32.const 0))
|
||||
(return))
|
||||
(unreachable))))
|
||||
|
|
|
@ -417,8 +417,5 @@
|
|||
(i32.const 92)
|
||||
(get_local $l9))
|
||||
(call $e.trigger_pagefault_end_jit)
|
||||
(i32.store
|
||||
(i32.const 648)
|
||||
(i32.const 0))
|
||||
(return))
|
||||
(unreachable))))
|
||||
|
|
|
@ -220,8 +220,5 @@
|
|||
(i32.const 92)
|
||||
(get_local $l9))
|
||||
(call $e.trigger_pagefault_end_jit)
|
||||
(i32.store
|
||||
(i32.const 648)
|
||||
(i32.const 0))
|
||||
(return))
|
||||
(unreachable))))
|
||||
|
|
|
@ -256,8 +256,5 @@
|
|||
(i32.const 92)
|
||||
(get_local $l9))
|
||||
(call $e.trigger_pagefault_end_jit)
|
||||
(i32.store
|
||||
(i32.const 648)
|
||||
(i32.const 0))
|
||||
(return))
|
||||
(unreachable))))
|
||||
|
|
|
@ -258,8 +258,5 @@
|
|||
(i32.const 92)
|
||||
(get_local $l9))
|
||||
(call $e.trigger_pagefault_end_jit)
|
||||
(i32.store
|
||||
(i32.const 648)
|
||||
(i32.const 0))
|
||||
(return))
|
||||
(unreachable))))
|
||||
|
|
|
@ -136,9 +136,6 @@
|
|||
(i32.const 92)
|
||||
(get_local $l9))
|
||||
(call $e.task_switch_test_jit)
|
||||
(i32.store
|
||||
(i32.const 648)
|
||||
(i32.const 0))
|
||||
(return)))
|
||||
(call $e.fpu_fadd
|
||||
(i32.const 1)
|
||||
|
@ -256,8 +253,5 @@
|
|||
(i32.const 92)
|
||||
(get_local $l9))
|
||||
(call $e.trigger_pagefault_end_jit)
|
||||
(i32.store
|
||||
(i32.const 648)
|
||||
(i32.const 0))
|
||||
(return))
|
||||
(unreachable))))
|
||||
|
|
|
@ -106,12 +106,6 @@
|
|||
(i32.load
|
||||
(i32.const 556))
|
||||
(i32.const 4)))
|
||||
(i32.store
|
||||
(i32.const 648)
|
||||
(i32.or
|
||||
(i32.load
|
||||
(i32.const 648))
|
||||
(i32.const 32)))
|
||||
(if $I6
|
||||
(i32.and
|
||||
(i32.load8_u
|
||||
|
@ -151,9 +145,6 @@
|
|||
(i32.const 92)
|
||||
(get_local $l9))
|
||||
(call $e.task_switch_test_mmx_jit)
|
||||
(i32.store
|
||||
(i32.const 648)
|
||||
(i32.const 0))
|
||||
(return)))
|
||||
(i32.store
|
||||
(i32.const 64)
|
||||
|
@ -206,9 +197,6 @@
|
|||
(set_local $l9
|
||||
(i32.load
|
||||
(i32.const 92)))
|
||||
(i32.store
|
||||
(i32.const 648)
|
||||
(i32.const 0))
|
||||
(i32.store
|
||||
(i32.const 64)
|
||||
(get_local $l2))
|
||||
|
@ -349,8 +337,5 @@
|
|||
(i32.const 92)
|
||||
(get_local $l9))
|
||||
(call $e.trigger_pagefault_end_jit)
|
||||
(i32.store
|
||||
(i32.const 648)
|
||||
(i32.const 0))
|
||||
(return))
|
||||
(unreachable))))
|
||||
|
|
|
@ -311,8 +311,5 @@
|
|||
(i32.const 92)
|
||||
(get_local $l9))
|
||||
(call $e.trigger_pagefault_end_jit)
|
||||
(i32.store
|
||||
(i32.const 648)
|
||||
(i32.const 0))
|
||||
(return))
|
||||
(unreachable))))
|
||||
|
|
Loading…
Reference in a new issue