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

Method rewrite

src/instrument.cpp:342–377  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

340 }
341
342 void rewrite(u8** new_class_data, int* new_class_data_len) {
343 if (VM::jvmti()->Allocate(_dst_capacity, &_dst) != 0) {
344 return;
345 }
346
347 Result res = rewriteClass();
348 if (res == Result::OK) {
349 *new_class_data = _dst;
350 *new_class_data_len = _dst_len;
351 return;
352 }
353
354 VM::jvmti()->Deallocate(_dst);
355
356 std::string class_name = _class_name->toString();
357 std::string method_name = _method_name ? _method_name->toString() : "n/a";
358 switch (res) {
359 case Result::METHOD_TOO_LARGE:
360 Log::warn("Method too large: %s.%s", class_name.c_str(), method_name.c_str());
361 break;
362 case Result::BAD_FULL_FRAME:
363 Log::warn("Unsupported full_frame: %s.%s", class_name.c_str(), method_name.c_str());
364 break;
365 case Result::JUMP_OVERFLOW:
366 Log::warn("Jump overflow: %s.%s", class_name.c_str(), method_name.c_str());
367 break;
368 case Result::PROFILER_CLASS:
369 Log::trace("Skipping instrumentation of %s: internal profiler class", class_name.c_str());
370 break;
371 case Result::ABORTED:
372 // Nothing to do
373 break;
374 default:
375 break;
376 }
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;

Callers 1

ClassFileLoadHookMethod · 0.80

Calls 1

toStringMethod · 0.45

Tested by

no test coverage detected