Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix singlepass panic #4520

Merged
merged 1 commit into from
Mar 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/compiler-singlepass/src/codegen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6681,7 +6681,7 @@ impl<'a, M: Machine> FuncGen<'a, M> {
let address_map =
get_function_address_map(self.machine.instructions_address_map(), data, body_len);
let traps = self.machine.collect_trap_information();
let mut body = self.machine.assembler_finalize();
let mut body = self.machine.assembler_finalize()?;
body.shrink_to_fit();

Ok((
Expand Down
2 changes: 1 addition & 1 deletion lib/compiler-singlepass/src/machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ pub trait Machine {
fn new_machine_state(&self) -> MachineState;

/// Finalize the assembler
fn assembler_finalize(self) -> Vec<u8>;
fn assembler_finalize(self) -> Result<Vec<u8>, CompileError>;

/// get_offset of Assembler
fn get_offset(&self) -> Offset;
Expand Down
6 changes: 4 additions & 2 deletions lib/compiler-singlepass/src/machine_arm64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2290,8 +2290,10 @@ impl Machine for MachineARM64 {
}

// assembler finalize
fn assembler_finalize(self) -> Vec<u8> {
self.assembler.finalize().unwrap()
fn assembler_finalize(self) -> Result<Vec<u8>, CompileError> {
self.assembler.finalize().map_err(|e| {
CompileError::Codegen(format!("Assembler failed finalization with: {:?}", e))
})
}

fn get_offset(&self) -> Offset {
Expand Down
6 changes: 4 additions & 2 deletions lib/compiler-singlepass/src/machine_x64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2499,8 +2499,10 @@ impl Machine for MachineX86_64 {
}

// assembler finalize
fn assembler_finalize(self) -> Vec<u8> {
self.assembler.finalize().unwrap()
fn assembler_finalize(self) -> Result<Vec<u8>, CompileError> {
self.assembler.finalize().map_err(|e| {
CompileError::Codegen(format!("Assembler failed finalization with: {:?}", e))
})
}

fn get_offset(&self) -> Offset {
Expand Down
Loading