MCPcopy Create free account
hub / github.com/IntegralPilot/rustc_codegen_jvm / widen_branches

Method widen_branches

src/lower2/translator.rs:717–776  ·  view source on GitHub ↗
(&mut self)

Source from the content-addressed store, hash-verified

715 return Ok(());
716 };
717 self.jvm_instructions
718 .push(get_load_instruction(&Type::I64, element_offset)?);
719 self.jvm_instructions
720 .push(get_load_instruction(&Type::I64, byte_offset)?);
721 let pointer_class = self.constant_pool.add_class(oomir::POINTER_CLASS)?;
722 let materialize = self.constant_pool.add_method_ref(
723 pointer_class,
724 "materializeRelative",
725 &format!("(L{};JJ)L{};", oomir::POINTER_CLASS, oomir::POINTER_CLASS),
726 )?;
727 self.jvm_instructions
728 .push(Instruction::Invokestatic(materialize));
729 Ok(())
730 }
731
732 fn load_deferred_pointer_components(
733 &mut self,
734 operand: &oomir::Operand,
735 ) -> Result<bool, jvm::Error> {
736 let oomir::Operand::Variable { name, ty } = operand else {
737 return Ok(false);
738 };
739 if !matches!(ty, Type::Pointer(_))
740 || self.direct_this_aliases.contains(name)
741 || !self.deferred_pointer_variables.contains(name)
742 {
743 return Ok(false);
744 }
745
746 let pointer_slot = self.get_or_assign_local(name, ty);
747 let (element_offset, byte_offset) = self.pointer_offset_slots(pointer_slot);
748 self.jvm_instructions
749 .push(get_load_instruction(ty, pointer_slot)?);
750 self.jvm_instructions
751 .push(get_load_instruction(&Type::I64, element_offset)?);
752 self.jvm_instructions
753 .push(get_load_instruction(&Type::I64, byte_offset)?);
754 Ok(true)
755 }
756
757 fn load_pointer_components(&mut self, operand: &oomir::Operand) -> Result<(), jvm::Error> {
758 if self.load_deferred_pointer_components(operand)? {
759 return Ok(());
760 }
761 if matches!(
762 operand,
763 oomir::Operand::Variable { name, ty: Type::Pointer(_) }
764 if self.direct_this_aliases.contains(name)
765 ) {
766 let pointer_ty = get_operand_type(operand);
767 self.load_jvm_receiver_as_pointer(operand, &pointer_ty)?;
768 self.jvm_instructions.push(Instruction::Lconst_0);
769 self.jvm_instructions.push(Instruction::Lconst_0);
770 return Ok(());
771 }
772 self.load_operand(operand)?;
773 self.jvm_instructions.push(Instruction::Lconst_0);
774 self.jvm_instructions.push(Instruction::Lconst_0);

Callers 1

translateMethod · 0.80

Calls 7

instruction_byte_offsetsFunction · 0.85
branch_offset_fits_i16Function · 0.85
lenMethod · 0.80
retarget_after_insertMethod · 0.80
to_stringMethod · 0.80

Tested by

no test coverage detected