Repository: dotnet/runtime
File: src/coreclr/vm/arm64/asmhelpers.S (Assembly)

Code before:
LOCAL_LABEL(CallJittedMethodRetU1_NoSwiftError):
    ldr x9, [fp, #24]
    str x2, [x9]
    ldr x9, [fp, #16]
    str x0, [x9]
    EPILOG_STACK_RESTORE
    EPILOG_RESTORE_REG_PAIR_INDEXED fp, lr, 48
    EPILOG_RETURN
NESTED_END CallJittedMethodRetU1, _TEXT

// X0 - routines array
// X1 - interpreter stack args location
// X2 - interpreter stack return value location
// X3 - stack arguments size (properly aligned)
// X4 - address of continuation return value
NESTED_ENTRY CallJittedMethodRetU2, _TEXT, NoHandler
    PROLOG_SAVE_REG_PAIR_INDEXED fp, lr, -48
    stp x2, x4, [fp, #16]
    str xzr, [fp, #40]
    sub sp, sp, x3
    mov x10, x0
    mov x9, x1
    ldr x11, [x10], #8
    blr x11
    uxth x0, w0
    ldr x11, [fp, #40]
    cbz x11, LOCAL_LABEL(CallJittedMethodRetU2_NoSwiftError)
    str x21, [x11]
LOCAL_LABEL(CallJittedMethodRetU2_NoSwiftError):
    ldr x9, [fp, #24]
    str x2, [x9]
    ldr x9, [fp, #16]
    str x0, [x9]
    EPILOG_STACK_RESTORE
    EPILOG_RESTORE_REG_PAIR_INDEXED fp, lr, 48
    EPILOG_RETURN
NESTED_END CallJittedMethodRetU2, _TEXT

// X0 - routines array
// X1 - interpreter stack args location
// X2 - interpreter stack return value location
// X3 - stack arguments size (properly aligned)
// X4 - address of continuation return value
NESTED_ENTRY CallJittedMethodRet2I8, _TEXT, NoHandler
    PROLOG_SAVE_REG_PAIR_INDEXED fp, lr, -32
    stp x2, x4, [fp, #16]
    sub sp, sp, x3
    mov x10, x0
    mov x9, x1
    ldr x11, [x10], #8
    blr x11

Review comment (suggestion):
Please pull these swift specific changes out and do them separately. Notably, I don't see where in our current CallStubGenerator we guarantee that the routine count includes the NULL that you are checking for here.

Code after:
NESTED_ENTRY CallJittedMethodRetU2, _TEXT, NoHandler
    PROLOG_SAVE_REG_PAIR_INDEXED fp, lr, -32
    stp x2, x4, [fp, #16]
    sub sp, sp, x3
    mov x10, x0
    mov x9, x1
    ldr x11, [x10], #8
    blr x11
    uxth x0, w0
    ldr x9, [fp, #24]
    str x2, [x9]
    ldr x9, [fp, #16]
    str x0, [x9]
    EPILOG_STACK_RESTORE
    EPILOG_RESTORE_REG_PAIR_INDEXED fp, lr, 32
    EPILOG_RETURN
NESTED_END CallJittedMethodRetU2, _TEXT

// X0 - routines array
// X1 - interpreter stack args location
// X2 - interpreter stack return value location
// X3 - stack arguments size (properly aligned)
// X4 - address of continuation return value
NESTED_ENTRY CallJittedMethodRet2I8, _TEXT, NoHandler
    PROLOG_SAVE_REG_PAIR_INDEXED fp, lr, -32
    stp x2, x4, [fp, #16]
    sub sp, sp, x3
    mov x10, x0
    mov x9, x1
    ldr x11, [x10], #8
    blr x11
    ldr x9, [fp, #24]
    str x2, [x9]
    ldr x9, [fp, #16]
    stp x0, x1, [x9]
    EPILOG_STACK_RESTORE
    EPILOG_RESTORE_REG_PAIR_INDEXED fp, lr, 32
    EPILOG_RETURN
NESTED_END CallJittedMethodRet2I8, _TEXT

// X0 - routines array
// X1 - interpreter stack args location
// X2 - interpreter stack return value location
// X3 - stack arguments size (properly aligned)
// X4 - address of continuation return value
NESTED_ENTRY CallJittedMethodRetDouble, _TEXT, NoHandler
    PROLOG_SAVE_REG_PAIR_INDEXED fp, lr, -32
    stp x2, x4, [fp, #16]
    sub sp, sp, x3
    mov x10, x0
    mov x9, x1