MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / test_island_backward

Function test_island_backward

cranelift/codegen/src/machinst/buffer.rs:2737–2787  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2735
2736 #[test]
2737 fn test_island_backward() {
2738 let info = emit_info();
2739 let mut buf = MachBuffer::new();
2740 let mut state = <Inst as MachInstEmit>::State::default();
2741 let constants = Default::default();
2742
2743 buf.reserve_labels_for_blocks(4);
2744
2745 buf.bind_label(label(0), state.ctrl_plane_mut());
2746 let inst = Inst::Nop4;
2747 inst.emit(&mut buf, &info, &mut state);
2748
2749 buf.bind_label(label(1), state.ctrl_plane_mut());
2750 let inst = Inst::Nop4;
2751 inst.emit(&mut buf, &info, &mut state);
2752
2753 buf.bind_label(label(2), state.ctrl_plane_mut());
2754 while buf.cur_offset() < 2000000 {
2755 let inst = Inst::Nop4;
2756 inst.emit(&mut buf, &info, &mut state);
2757 }
2758
2759 buf.bind_label(label(3), state.ctrl_plane_mut());
2760 let inst = Inst::CondBr {
2761 kind: CondBrKind::NotZero(xreg(0), OperandSize::Size64),
2762 taken: target(0),
2763 not_taken: target(1),
2764 };
2765 inst.emit(&mut buf, &info, &mut state);
2766
2767 let buf = buf.finish(&constants, state.ctrl_plane_mut());
2768
2769 assert_eq!(2000000 + 12, buf.total_size());
2770
2771 let mut buf2 = MachBuffer::new();
2772 let mut state = Default::default();
2773 let inst = Inst::CondBr {
2774 kind: CondBrKind::NotZero(xreg(0), OperandSize::Size64),
2775 taken: BranchTarget::ResolvedOffset(8),
2776 not_taken: BranchTarget::ResolvedOffset(4 - (2000000 + 4)),
2777 };
2778 inst.emit(&mut buf2, &info, &mut state);
2779 let inst = Inst::Jump {
2780 dest: BranchTarget::ResolvedOffset(-(2000000 + 8)),
2781 };
2782 inst.emit(&mut buf2, &info, &mut state);
2783
2784 let buf2 = buf2.finish(&constants, state.ctrl_plane_mut());
2785
2786 assert_eq!(&buf.data[2000000..], &buf2.data[..]);
2787 }
2788
2789 #[test]
2790 fn test_multiple_redirect() {

Callers

nothing calls this directly

Calls 11

emit_infoFunction · 0.85
labelFunction · 0.85
bind_labelMethod · 0.80
cur_offsetMethod · 0.80
targetFunction · 0.70
newFunction · 0.50
xregFunction · 0.50
ctrl_plane_mutMethod · 0.45
emitMethod · 0.45
finishMethod · 0.45

Tested by

no test coverage detected