Refactor SimpleJITTrapSink/FaerieTrapSink into NullTrapSink.

This publishes it for use outside of simpljie/faerie as well.
This commit is contained in:
Dan Gohman
2018-04-17 11:22:11 -07:00
parent 1f43ec09f3
commit 58380f38e8
5 changed files with 18 additions and 20 deletions

View File

@@ -1,6 +1,6 @@
//! Defines `SimpleJITBackend`.
use cretonne_codegen::binemit::{Addend, CodeOffset, Reloc, RelocSink, TrapSink};
use cretonne_codegen::binemit::{Addend, CodeOffset, Reloc, RelocSink, NullTrapSink};
use cretonne_codegen::isa::TargetIsa;
use cretonne_codegen::result::CtonError;
use cretonne_codegen::{self, ir, settings};
@@ -100,7 +100,9 @@ impl<'simple_jit_backend> Backend for SimpleJITBackend {
"TODO: handle OOM etc.",
);
let mut reloc_sink = SimpleJITRelocSink::new();
let mut trap_sink = SimpleJITTrapSink {};
// Ignore traps for now. For now, frontends should just avoid generating code
// that traps.
let mut trap_sink = NullTrapSink {};
ctx.emit_to_memory(ptr, &mut reloc_sink, &mut trap_sink, &*self.isa);
Ok(Self::CompiledFunction {
@@ -356,10 +358,3 @@ impl RelocSink for SimpleJITRelocSink {
unimplemented!();
}
}
struct SimpleJITTrapSink {}
impl TrapSink for SimpleJITTrapSink {
// Ignore traps for now. For now, frontends should just avoid generating code that traps.
fn trap(&mut self, _offset: CodeOffset, _srcloc: ir::SourceLoc, _code: ir::TrapCode) {}
}