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

Function build_stack_map_attributes

src/lower2/stackmaps.rs:232–305  ·  view source on GitHub ↗
(
    instructions: &[Instruction],
    initial_locals: &[FrameValue],
    local_hints: &[FrameValue],
    max_locals: u16,
    constant_pool: &mut InternedConstantPool,
    context: &str,
)

Source from the content-addressed store, hash-verified

230
231 let descriptor = jvm::JavaString::from(descriptor);
232 let (params, _) = FieldType::parse_method_descriptor(&descriptor)?;
233 for param in &params {
234 push_local_value(&mut locals, frame_value_from_field_type(param));
235 }
236 Ok(locals)
237}
238
239pub(super) fn local_hints_for_oomir_locals(
240 local_var_map: &HashMap<(String, oomir::Type), u16>,
241 max_locals: u16,
242) -> Vec<FrameValue> {
243 let mut hints = vec![FrameValue::Top; max_locals as usize];
244 for ((_, ty), local_index) in local_var_map {
245 set_slot_value(&mut hints, *local_index, frame_value_from_oomir_type(ty));
246 }
247 hints
248}
249
250pub(super) fn build_stack_map_attributes(
251 instructions: &[Instruction],
252 initial_locals: &[FrameValue],
253 local_hints: &[FrameValue],
254 max_locals: u16,
255 constant_pool: &mut InternedConstantPool,
256 context: &str,
257 exception_table: &[ExceptionTableEntry],
258) -> jvm::Result<Vec<Attribute>> {
259 let analysis = solve_frame_states(
260 instructions,
261 initial_locals,
262 local_hints,
263 max_locals as usize,
264 constant_pool,
265 context,
266 exception_table,
267 )?;
268 build_stack_map_attributes_from_analysis(
269 instructions,
270 initial_locals,
271 constant_pool,
272 exception_table,
273 &analysis,
274 )
275}
276
277pub(super) fn build_stack_map_attributes_from_analysis(
278 instructions: &[Instruction],
279 initial_locals: &[FrameValue],
280 constant_pool: &mut InternedConstantPool,
281 exception_table: &[ExceptionTableEntry],
282 analysis: &FrameAnalysis,
283) -> jvm::Result<Vec<Attribute>> {
284 let mut target_offsets = branch_targets(instructions);
285 target_offsets.extend(exception_table.iter().map(|entry| entry.handler_pc));
286 if instructions.is_empty() || target_offsets.is_empty() {
287 return Ok(Vec::new());
288 }
289

Callers 2

translateMethod · 0.85

Calls 8

solve_frame_statesFunction · 0.85
locals_for_stack_mapFunction · 0.85
stack_for_stack_mapFunction · 0.85
compact_stack_frameFunction · 0.85
add_utf8Method · 0.80
to_stringMethod · 0.80
branch_targetsFunction · 0.70

Tested by

no test coverage detected