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

Method finish

cranelift/codegen/src/machinst/buffer.rs:1627–1682  ·  view source on GitHub ↗

Finish any deferred emissions and/or fixups.

(
        mut self,
        constants: &VCodeConstants,
        ctrl_plane: &mut ControlPlane,
    )

Source from the content-addressed store, hash-verified

1625
1626 /// Finish any deferred emissions and/or fixups.
1627 pub fn finish(
1628 mut self,
1629 constants: &VCodeConstants,
1630 ctrl_plane: &mut ControlPlane,
1631 ) -> MachBufferFinalized<Stencil> {
1632 let _tt = timing::vcode_emit_finish();
1633
1634 self.finish_emission_maybe_forcing_veneers(ForceVeneers::No, ctrl_plane);
1635
1636 let alignment = self.finish_constants(constants);
1637
1638 // Resolve all labels to their offsets.
1639 let finalized_relocs = self
1640 .relocs
1641 .iter()
1642 .map(|reloc| FinalizedMachReloc {
1643 offset: reloc.offset,
1644 kind: reloc.kind,
1645 addend: reloc.addend,
1646 target: match &reloc.target {
1647 RelocTarget::ExternalName(name) => {
1648 FinalizedRelocTarget::ExternalName(name.clone())
1649 }
1650 RelocTarget::Label(label) => {
1651 FinalizedRelocTarget::Func(self.resolve_label_offset(*label))
1652 }
1653 },
1654 })
1655 .collect();
1656
1657 let finalized_exception_handlers = self
1658 .exception_handlers
1659 .iter()
1660 .map(|handler| handler.finalize(|label| self.resolve_label_offset(label)))
1661 .collect();
1662
1663 let mut srclocs = self.srclocs;
1664 srclocs.sort_by_key(|entry| entry.start);
1665
1666 MachBufferFinalized {
1667 data: self.data,
1668 relocs: finalized_relocs,
1669 traps: self.traps,
1670 call_sites: self.call_sites,
1671 patchable_call_sites: self.patchable_call_sites,
1672 exception_handlers: finalized_exception_handlers,
1673 srclocs,
1674 debug_tags: self.debug_tags,
1675 debug_tag_pool: self.debug_tag_pool,
1676 user_stack_maps: self.user_stack_maps,
1677 unwind_info: self.unwind_info,
1678 alignment,
1679 frame_layout: self.frame_layout,
1680 nop_units: I::gen_nop_units(),
1681 }
1682 }
1683
1684 /// Add an external relocation at the given offset.

Callers 11

test_elide_jump_to_nextFunction · 0.45
test_flip_condFunction · 0.45
test_islandFunction · 0.45
test_island_backwardFunction · 0.45
test_multiple_redirectFunction · 0.45
test_handle_branch_cycleFunction · 0.45
metadata_recordsFunction · 0.45

Calls 12

ExternalNameEnum · 0.85
finish_constantsMethod · 0.80
collectMethod · 0.80
resolve_label_offsetMethod · 0.80
sort_by_keyMethod · 0.80
FuncClass · 0.50
mapMethod · 0.45
iterMethod · 0.45
cloneMethod · 0.45
finalizeMethod · 0.45
into_vecMethod · 0.45

Tested by 11

test_elide_jump_to_nextFunction · 0.36
test_flip_condFunction · 0.36
test_islandFunction · 0.36
test_island_backwardFunction · 0.36
test_multiple_redirectFunction · 0.36
test_handle_branch_cycleFunction · 0.36
metadata_recordsFunction · 0.36