// JNI dlsym lookup stub for @CriticalNative.
ENTRY art_jni_dlsym_lookup_critical_stub
// The hidden arg holding the tagged method is t0 (loaded by compiled JNI stub, compiled
// managed code, or `art_quick_generic_jni_trampoline`). Bit 0set means generic JNI.
// For generic JNI we already have a managed frame, so we reuse the art_jni_dlsym_lookup_stub.
// Note: 'bnez' doesn't always have enough range (+/-4KB) to reach art_jni_dlsym_lookup_stub so
// 'tail' is used instead.
andi t6, t0, 1
beqz t6, .Lcritical_not_generic_jni
tail art_jni_dlsym_lookup_stub
.Lcritical_not_generic_jni:
// Save args, the hidden arg and caller PC. No CFI needed for args and the hidden arg.
SAVE_ALL_ARGS_INCREASE_FRAME 2*8
SAVE_GPR t0, (ALL_ARGS_SIZE + 0)
SAVE_GPR ra, (ALL_ARGS_SIZE + 8)
// Reserve space for a SaveRefsAndArgs managed frame, either for the actual runtime
// method or for a GenericJNI frame which is similar but has a native method and a tag.
// Add space for RA and padding to keep the stack 16-byte aligned.
INCREASE_FRAME (FRAME_SIZE_SAVE_REFS_AND_ARGS + 16)
// Prepare the return address for managed stack walk of the SaveRefsAndArgs frame.
// If we're coming from JNI stub with tail call, it is RA. If we're coming from
// JNI stub that saved the return address, it will be the last value we copy below.
// If we're coming directly from compiled code, it is RA, set further down.
mv t4, ra
// Move the stack args if any. Calculate the base address of the managed frame in the process.
addi t1, sp, 16
beqz t2, .Lcritical_skip_copy_args
.Lcritical_copy_args_loop: ld t3, FRAME_SIZE_SAVE_REFS_AND_ARGS+0(t1) ld t4, FRAME_SIZE_SAVE_REFS_AND_ARGS+8(t1)
addi t2, t2, -16
sd t3, 0-16(t1)
sd t4, 8-16(t1)
addi t1, t1, 16
bnez t2, .Lcritical_copy_args_loop
.Lcritical_skip_copy_args:
// Spill registers for the SaveRefsAndArgs frame above the stack args.
// Note that the runtime shall not examine the args here, otherwise we would have to
// move them in registers and stack to account for the difference between managed and
// native ABIs. Do not update CFI while we hold the frame address in T1 and the values
// in registers are unchanged.
// stack slot (0*8)(t1) is for ArtMethod*
fsd fa0, (1*8)(t1)
fsd fa1, (2*8)(t1)
fsd fa2, (3*8)(t1)
fsd fa3, (4*8)(t1)
fsd fa4, (5*8)(t1)
fsd fa5, (6*8)(t1)
fsd fa6, (7*8)(t1)
fsd fa7, (8*8)(t1)
sd fp, (9*8)(t1) // x8, frame pointer
// s1 (x9) is the ART thread register
// a0 (x10) is the method pointer
sd a1, (10*8)(t1) // x11
sd a2, (11*8)(t1) // x12
sd a3, (12*8)(t1) // x13
sd a4, (13*8)(t1) // x14
sd a5, (14*8)(t1) // x15
sd a6, (15*8)(t1) // x16
sd a7, (16*8)(t1) // x17
sd s2, (17*8)(t1) // x18
sd s3, (18*8)(t1) // x19
sd s4, (19*8)(t1) // x20
sd s5, (20*8)(t1) // x21
sd s6, (21*8)(t1) // x22
sd s7, (22*8)(t1) // x23
sd s8, (23*8)(t1) // x24
sd s9, (24*8)(t1) // x25
sd s10, (25*8)(t1) // x26
sd s11, (26*8)(t1) // x27
sd t4, (27*8)(t1) // t4: Save return address for tail call from JNI stub.
// (If there were any stack args, we're storing the value that's already there.
// For direct calls from compiled managed code, we shall overwrite this below.)
// Move the managed frame address to native callee-save register fp (x8) and update CFI.
mv fp, t1
// Skip args FA0-FA7, A1-A7
CFI_EXPRESSION_BREG 8, 8, (9*8)
CFI_EXPRESSION_BREG 18, 8, (17*8)
CFI_EXPRESSION_BREG 19, 8, (18*8)
CFI_EXPRESSION_BREG 20, 8, (19*8)
CFI_EXPRESSION_BREG 21, 8, (20*8)
CFI_EXPRESSION_BREG 22, 8, (21*8)
CFI_EXPRESSION_BREG 23, 8, (22*8)
CFI_EXPRESSION_BREG 24, 8, (23*8)
CFI_EXPRESSION_BREG 25, 8, (24*8)
CFI_EXPRESSION_BREG 26, 8, (25*8)
CFI_EXPRESSION_BREG 27, 8, (26*8)
// The saved return PC for managed stack walk is not necessarily our RA.
// Save our return PC below the managed frame.
sd ra, -__SIZEOF_POINTER__(fp)
CFI_EXPRESSION_BREG 1, 8, -__SIZEOF_POINTER__
// When coming from a compiled method, the return PC for managed stack walk is RA.
// (When coming from a compiled stub, the correct return PC is already stored above.)
sd ra, (FRAME_SIZE_SAVE_REFS_AND_ARGS - __SIZEOF_POINTER__)(fp)
// Replace the target method with the SaveRefsAndArgs runtime method.
LOAD_RUNTIME_INSTANCE t0 ld t0, RUNTIME_SAVE_REFS_AND_ARGS_METHOD_OFFSET(t0)
mv t1, fp // Prepare untagged managed SP for the runtime method.
.Lcritical_skip_prepare_runtime_method:
// Store the method on the bottom of the managed frame.
sd t0, (fp)
// Place (maybe tagged) managed SP in Thread::Current()->top_quick_frame.
sd t1, THREAD_TOP_QUICK_FRAME_OFFSET(xSELF)
// Preserve the native arg register A0 in callee-save register S2 (x18) which was saved above.
mv s2, a0
// Remove the frame reservation.
DECREASE_FRAME (FRAME_SIZE_SAVE_REFS_AND_ARGS + 16)
// Do the tail call.
jr t0
.Lcritical_deliver_exception:
CFI_RESTORE_STATE_AND_DEF_CFA sp, FRAME_SIZE_SAVE_REFS_AND_ARGS + 16
// If this is called from a method that catches the exception, all callee-save registers need
// to be saved, so that the exception handling code can read them in case they contain live
// values later used by that method. This includes callee-save FP registers which are not
// saved in a SaveRefsAndArgs frame, so we cannot reuse the managed frame we have built above.
// That's why we checked for exception after restoring registers from that frame.
// We need to build a SaveAllCalleeSaves frame instead. Args are irrelevant at this
// point but keep the area allocated for stack args to keep CFA definition simple.
#if FRAME_SIZE_SAVE_ALL_CALLEE_SAVES > FRAME_SIZE_SAVE_REFS_AND_ARGS
#error "Expanding stack frame from kSaveRefsAndArgs to kSaveAllCalleeSaves is not implemented."
#endif
DECREASE_FRAME FRAME_SIZE_SAVE_REFS_AND_ARGS - FRAME_SIZE_SAVE_ALL_CALLEE_SAVES
// Calculate the base address of the managed frame.
addi t1, t1, 16 + FRAME_SIZE_SAVE_REFS_AND_ARGS - FRAME_SIZE_SAVE_ALL_CALLEE_SAVES
// Spill registers for the SaveAllCalleeSaves frame above the stack args area. Do not update
// CFI while we hold the frame address in T1 and the values in registers are unchanged.
// stack slot (0*8)(t1) is for ArtMethod*
// stack slot (1*8)(t1) is for padding
// FP callee-saves.
fsd fs0, (8*2)(t1) // f8
fsd fs1, (8*3)(t1) // f9
fsd fs2, (8*4)(t1) // f18
fsd fs3, (8*5)(t1) // f19
fsd fs4, (8*6)(t1) // f20
fsd fs5, (8*7)(t1) // f21
fsd fs6, (8*8)(t1) // f22
fsd fs7, (8*9)(t1) // f23
fsd fs8, (8*10)(t1) // f24
fsd fs9, (8*11)(t1) // f25
fsd fs10, (8*12)(t1) // f26
fsd fs11, (8*13)(t1) // f27
// GP callee-saves
sd s0, (8*14)(t1) // x8/fp, frame pointer
// s1 (x9) is the ART thread register
sd s2, (8*15)(t1) // x18
sd s3, (8*16)(t1) // x19
sd s4, (8*17)(t1) // x20
sd s5, (8*18)(t1) // x21
sd s6, (8*19)(t1) // x22
sd s7, (8*20)(t1) // x23
sd s8, (8*21)(t1) // x24
sd s9, (8*22)(t1) // x25
sd s10, (8*23)(t1) // x26
sd s11, (8*24)(t1) // x27
// Keep the caller PC for managed stack walk.
// Save our return PC below the managed frame.
sd ra, -__SIZEOF_POINTER__(fp)
CFI_EXPRESSION_BREG 1, 8, -__SIZEOF_POINTER__
// Store ArtMethod* Runtime::callee_save_methods_[kSaveAllCalleeSaves] to the managed frame.
LOAD_RUNTIME_INSTANCE t0 ld t0, RUNTIME_SAVE_ALL_CALLEE_SAVES_METHOD_OFFSET(t0)
sd t0, (fp)
// Place the managed frame SP in Thread::Current()->top_quick_frame.
sd fp, THREAD_TOP_QUICK_FRAME_OFFSET(xSELF)
DELIVER_PENDING_EXCEPTION_FRAME_READY
END art_jni_dlsym_lookup_critical_stub
/* *Readbarrierforthemethod'sdeclaringclassneededbyJNIstubforstaticmethods. *(We'reusingapointertothedeclaringclassin`ArtMethod`as`jclass`.)
*/
// The method argument is already in a0 for call to `artJniReadBarrier(ArtMethod*)`.
JNI_SAVE_MANAGED_ARGS_TRAMPOLINE art_jni_read_barrier, artJniReadBarrier
/* *EntryfromJNIstubthatcalls`artJniUnlockObject()`.Notethatfailureto *unlockisfatal,sowedonotneedtocheckforexceptions. *Customcallingconvention: *T0holdsthenon-nullobjecttounlock. *Callee-saveregistershavebeensavedandcanbeusedastemporaries. *Returnregistersa0andfa0needtobepreserved.
*/
// This is also the slow path for art_jni_unlock_object.
JNI_SAVE_RETURN_VALUE_TRAMPOLINE art_jni_unlock_object_no_inline, artJniUnlockObject, t0, xSELF
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.12 Sekunden
(vorverarbeitet am 2026-06-29)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.