From ce30b450cec48688a1cbbfa16c60ec4e6bef6dfa Mon Sep 17 00:00:00 2001 From: Andrey Kvochko Date: Fri, 26 Aug 2016 19:57:51 +0300 Subject: [PATCH] Enabled FunctionEnter/FunctionLeave hooks on ARM (dotnet/coreclr#6939) Commit migrated from https://github.com/dotnet/coreclr/commit/d4c2486486bd884160f55797060fee6eed147281 --- src/coreclr/src/jit/codegencommon.cpp | 2 +- src/coreclr/src/vm/arm/asmhelpers.S | 86 +++++++++++++++++++++++++++++++++++ src/coreclr/src/vm/arm/unixstubs.cpp | 10 ---- 3 files changed, 87 insertions(+), 11 deletions(-) diff --git a/src/coreclr/src/jit/codegencommon.cpp b/src/coreclr/src/jit/codegencommon.cpp index e5bd730..8047230 100755 --- a/src/coreclr/src/jit/codegencommon.cpp +++ b/src/coreclr/src/jit/codegencommon.cpp @@ -7583,7 +7583,7 @@ void CodeGen::genProfilingLeaveCallback(unsigned helper /*= CORINFO_HELP_PROF_FC emitAttr attr = EA_UNKNOWN; if (compiler->info.compRetType == TYP_VOID || - (!compiler->info.compIsVarArgs && (varTypeIsFloating(compiler->info.compRetType) || + (!compiler->info.compIsVarArgs && !compiler->opts.compUseSoftFP && (varTypeIsFloating(compiler->info.compRetType) || compiler->IsHfa(compiler->info.compMethodInfo->args.retTypeClass)))) { r0Trashed = false; diff --git a/src/coreclr/src/vm/arm/asmhelpers.S b/src/coreclr/src/vm/arm/asmhelpers.S index 55bdd9f..b891265 100644 --- a/src/coreclr/src/vm/arm/asmhelpers.S +++ b/src/coreclr/src/vm/arm/asmhelpers.S @@ -636,6 +636,92 @@ ThePreStubPatchLabel: .endm +// +// EXTERN_C void ProfileEnterNaked(FunctionIDOrClientID functionIDOrClientID); +// +NESTED_ENTRY ProfileEnterNaked, _TEXT, NoHandler + PROLOG_PUSH "{r4, r5, r7, r11, lr}" + PROLOG_STACK_SAVE_OFFSET r7, #8 + + // fields of PLATFORM_SPECIFIC_DATA, in reverse order + + // UINT32 r0; // Keep r0 & r1 contiguous to make returning 64-bit results easier + // UINT32 r1; + // void *R11; + // void *Pc; + // union // Float arg registers as 32-bit (s0-s15) and 64-bit (d0-d7) + // { + // UINT32 s[16]; + // UINT64 d[8]; + // }; + // FunctionID functionId; + // void *probeSp; // stack pointer of managed function + // void *profiledSp; // location of arguments on stack + // LPVOID hiddenArg; + // UINT32 flags; + movw r4, #1 + push { /* flags */ r4 } + movw r4, #0 + push { /* hiddenArg */ r4 } + add r5, r11, #8 + push { /* profiledSp */ r5 } + add r5, sp, #32 + push { /* probeSp */ r5 } + push { /* functionId */ r0 } + vpush.64 { d0 - d7 } + push { lr } + push { r11 } + push { /* return value, r4 is NULL */ r4 } + push { /* return value, r4 is NULL */ r4 } + mov r1, sp + bl C_FUNC(ProfileEnter) + EPILOG_STACK_RESTORE_OFFSET r7, #8 + EPILOG_POP "{r4, r5, r7, r11, pc}" +NESTED_END ProfileEnterNaked, _TEXT + +// +// EXTERN_C void ProfileLeaveNaked(FunctionIDOrClientID functionIDOrClientID); +// +NESTED_ENTRY ProfileLeaveNaked, _TEXT, NoHandler + PROLOG_PUSH "{r1, r2, r4, r5, r7, r11, lr}" + PROLOG_STACK_SAVE_OFFSET r7, #16 + + // fields of PLATFORM_SPECIFIC_DATA, in reverse order + + // UINT32 r0; // Keep r0 & r1 contiguous to make returning 64-bit results easier + // UINT32 r1; + // void *R11; + // void *Pc; + // union // Float arg registers as 32-bit (s0-s15) and 64-bit (d0-d7) + // { + // UINT32 s[16]; + // UINT64 d[8]; + // }; + // FunctionID functionId; + // void *probeSp; // stack pointer of managed function + // void *profiledSp; // location of arguments on stack + // LPVOID hiddenArg; + // UINT32 flags; + movw r4, #2 + push { /* flags */ r4 } + movw r4, #0 + push { /* hiddenArg */ r4 } + add r5, r11, #8 + push { /* profiledSp */ r5 } + add r5, sp, #40 + push { /* probeSp */ r5 } + push { /* functionId */ r0 } + vpush.64 { d0 - d7 } + push { lr } + push { r11 } + push { r1 } + push { r2 } + mov r1, sp + bl C_FUNC(ProfileLeave) + EPILOG_STACK_RESTORE_OFFSET r7, #16 + EPILOG_POP "{r1, r2, r4, r5, r7, r11, pc}" +NESTED_END ProfileLeaveNaked, _TEXT + // EXTERN_C int __fastcall HelperMethodFrameRestoreState( // INDEBUG_COMMA(HelperMethodFrame *pFrame) // MachState *pState diff --git a/src/coreclr/src/vm/arm/unixstubs.cpp b/src/coreclr/src/vm/arm/unixstubs.cpp index fa0f204..8a68103 100644 --- a/src/coreclr/src/vm/arm/unixstubs.cpp +++ b/src/coreclr/src/vm/arm/unixstubs.cpp @@ -21,16 +21,6 @@ extern "C" PORTABILITY_ASSERT("Implement for PAL"); } - void ProfileEnterNaked(FunctionIDOrClientID functionIDOrClientID) - { - PORTABILITY_ASSERT("Implement for PAL"); - } - - void ProfileLeaveNaked(FunctionIDOrClientID functionIDOrClientID) - { - PORTABILITY_ASSERT("Implement for PAL"); - } - void ProfileTailcallNaked(FunctionIDOrClientID functionIDOrClientID) { PORTABILITY_ASSERT("Implement for PAL"); -- 2.7.4