fix issue 5569. (#5612)

* add regression test file.

* fix issute5569.

* enable code length check.
This commit is contained in:
yuyang
2023-01-31 02:01:33 +08:00
committed by GitHub
parent e835255fbf
commit 77cf547f41
2 changed files with 403 additions and 7 deletions

View File

@@ -27,6 +27,9 @@ impl EmitInfo {
/// load constant by put the constant in the code stream.
/// calculate the pc and using load instruction.
/// This is only allow used in the emit stage.
/// Because of those instruction must execute together.
/// see https://github.com/bytecodealliance/wasmtime/pull/5612
#[derive(Clone, Copy)]
pub(crate) enum LoadConstant {
U32(u32),
@@ -464,14 +467,13 @@ impl MachInstEmit for Inst {
x.emit(&[], sink, emit_info, state)
}
&Inst::RawData { ref data } => {
// emit_island if need, right now data is not very long.
let length = data.len() as CodeOffset;
if sink.island_needed(length) {
sink.emit_island(length);
}
// Right now we only put a u32 or u64 in this instruction.
// It is not very long, no need to check if need `emit_island`.
// If data is very long , this is a bug because RawData is typecial
// use to load some data and rely on some positon in the code stream.
// and we may exceed `Inst::worst_case_size`.
// for more information see https://github.com/bytecodealliance/wasmtime/pull/5612.
sink.put_data(&data[..]);
// safe to disable code length check.
start_off = sink.cur_offset();
}
&Inst::Lui { rd, ref imm } => {
let rd = allocs.next_writable(rd);