MCPcopy Create free account
hub / github.com/dylan-sutton-chavez/edge-python / fuse_method_calls

Function fuse_method_calls

compiler/src/modules/vm/cache.rs:278–297  ·  view source on GitHub ↗

Fuse adjacent LoadAttr+Call(0) into CallMethod+CallMethodArgs; only safe when Call has no args. */

(chunk: &SSAChunk)

Source from the content-addressed store, hash-verified

276
277/* Fuse adjacent LoadAttr+Call(0) into CallMethod+CallMethodArgs; only safe when Call has no args. */
278fn fuse_method_calls(chunk: &SSAChunk) -> Vec<Instruction> {
279 let src = &chunk.instructions;
280 let n = src.len();
281 let mut out = src.clone();
282
283 let mut i = 0;
284 while i + 1 < n {
285 if src[i].opcode == OpCode::LoadAttr
286 && src[i + 1].opcode == OpCode::Call
287 && src[i + 1].operand == 0
288 {
289 out[i].opcode = OpCode::CallMethod;
290 out[i + 1].opcode = OpCode::CallMethodArgs;
291 i += 2;
292 continue;
293 }
294 i += 1;
295 }
296 out
297}

Callers 1

ensure_fusedMethod · 0.85

Calls 1

lenMethod · 0.45

Tested by

no test coverage detected