MCPcopy Create free account
hub / github.com/async-profiler/async-profiler / instructionBytes

Method instructionBytes

src/instrument.cpp:379–401  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

377 }
378
379 static u16 instructionBytes(const u8* code, u16 index) {
380 static constexpr unsigned char OPCODE_LENGTH[JVM_OPC_MAX+1] = JVM_OPCODE_LENGTH_INITIALIZER;
381 u8 opcode = code[index];
382 switch (opcode) {
383 case JVM_OPC_wide:
384 return code[index + 1] == JVM_OPC_iinc ? 6 : 4;
385 case JVM_OPC_tableswitch: {
386 u16 default_index = alignUp4(index);
387 int32_t l = get32(code + default_index + 4);
388 int32_t h = get32(code + default_index + 8);
389 u16 branches_count = h - l + 1;
390 return default_index - index + (3 + branches_count) * 4;
391 }
392 case JVM_OPC_lookupswitch: {
393 u16 default_index = alignUp4(index);
394 u16 npairs = (u16) get32(code + default_index + 4);
395 return default_index - index + (npairs + 1) * 8;
396 }
397 default:
398 assert(opcode < JVM_OPC_MAX+1);
399 return OPCODE_LENGTH[opcode];
400 }
401 }
402
403 // Return the new offset delta
404 static u16 updateCurrentFrame(int32_t& current_frame_old, int32_t& current_frame_new,

Callers

nothing calls this directly

Calls 1

alignUp4Function · 0.85

Tested by

no test coverage detected