message: feat(compiler) Another small refactor in arm trampoline handling
diff: @@ -19,9 +19,9 @@ fn trampolines_add(
  address: usize,
  baseaddress: usize,
  ) -> usize {
  - if map.contains_key(&address) {
  - *map.get(&address).unwrap()
  - } else {
  + if let Some(target) = map.get(&address) {
  + return *target;
  + }
  let ret = map.len();
  if ret == trampoline.slots {
  panic!("No more slot in Trampolines");
  @@ -29,7 +29,6 @@ fn trampolines_add(
  map.insert(address, baseaddress + ret * trampoline.size);
  baseaddress + ret * trampoline.size
  }
  -}
  fn use_trampoline(
  address: usize,
  @@ -77,7 +76,7 @@ fn apply_relocation(
  jt_offsets: &PrimaryMap<LocalFunctionIndex, JumpTableOffsets>,
  allocated_sections: &PrimaryMap<SectionIndex, SectionBodyPtr>,
  trampolines: &Option<TrampolinesSection>,
  - map: &mut HashMap<usize, usize>,
  + trampolines_map: &mut HashMap<usize, usize>,
  ) {
  let target_func_address: usize = match r.reloc_target {
  RelocationTarget::LocalFunc(index) => *allocated_functions[index].ptr as usize,
  @@ -118,9 +117,12 @@ fn apply_relocation(
  RelocationKind::Arm64Call => unsafe {
  let (reloc_address, mut reloc_delta) = r.for_address(body, target_func_address as u64);
  if (reloc_delta as i64).abs() >= 0x1000_0000 {
  - let new_address =
  - match use_trampoline(target_func_address, allocated_sections, trampolines, map)
  - {
  + let new_address = match use_trampoline(
  + target_func_address,
  + allocated_sections,
  + trampolines,
  + trampolines_map,
  + ) {
  Some(new_address) => new_address,
  _ => panic!(
  "Relocation to big for {:?} for {:?} with {:x}, current val {:x}",
  @@ -180,7 +182,7 @@ pub fn link_module(
  section_relocations: &PrimaryMap<SectionIndex, Vec<Relocation>>,
  trampolines: &Option<TrampolinesSection>,
  ) {
  - let mut map = fill_trampolin_map(allocated_sections, trampolines);
  + let mut trampolines_map = fill_trampolin_map(allocated_sections, trampolines);
  for (i, section_relocs) in section_relocations.iter() {
  let body = *allocated_sections[i] as usize;
  for r in section_relocs {
  @@ -191,7 +193,7 @@ pub fn link_module(
  jt_offsets,
  allocated_sections,
  trampolines,
  - &mut map,
  + &mut trampolines_map,
  );
  }
  }
  @@ -205,7 +207,7 @@ pub fn link_module(
  jt_offsets,
  allocated_sections,
  trampolines,
  - &mut map,
  + &mut trampolines_map,
  );
  }
  }
  