| 1 | // Licensed to the .NET Foundation under one or more agreements. |
| 2 | // The .NET Foundation licenses this file to you under the MIT license. |
| 3 | // See the LICENSE file in the project root for more information. |
| 4 | |
| 5 | // =========================================================================== |
| 6 | // File: JITinterfaceGen.CPP |
| 7 | // |
| 8 | // This contains the AMD64 version of InitJITHelpers1(). |
| 9 | // |
| 10 | // =========================================================================== |
| 11 | |
| 12 | |
| 13 | #include "common.h" |
| 14 | #include "clrtypes.h" |
| 15 | #include "jitinterface.h" |
| 16 | #include "eeconfig.h" |
| 17 | #include "excep.h" |
| 18 | #include "comdelegate.h" |
| 19 | #include "field.h" |
| 20 | #include "ecall.h" |
| 21 | |
| 22 | #ifdef _WIN64 |
| 23 | |
| 24 | // These are the fastest(?) versions of JIT helpers as they have the code to GetThread patched into them |
| 25 | // that does not make a call. |
| 26 | EXTERN_C Object* JIT_TrialAllocSFastMP_InlineGetThread(CORINFO_CLASS_HANDLE typeHnd_); |
| 27 | EXTERN_C Object* JIT_BoxFastMP_InlineGetThread (CORINFO_CLASS_HANDLE type, void* unboxedData); |
| 28 | EXTERN_C Object* AllocateStringFastMP_InlineGetThread (CLR_I4 cch); |
| 29 | EXTERN_C Object* JIT_NewArr1OBJ_MP_InlineGetThread (CORINFO_CLASS_HANDLE arrayMT, INT_PTR size); |
| 30 | EXTERN_C Object* JIT_NewArr1VC_MP_InlineGetThread (CORINFO_CLASS_HANDLE arrayMT, INT_PTR size); |
| 31 | |
| 32 | // This next set is the fast version that invoke GetThread but is still faster than the VM implementation (i.e. |
| 33 | // the "slow" versions). |
| 34 | EXTERN_C Object* JIT_TrialAllocSFastMP(CORINFO_CLASS_HANDLE typeHnd_); |
| 35 | EXTERN_C Object* JIT_TrialAllocSFastSP(CORINFO_CLASS_HANDLE typeHnd_); |
| 36 | EXTERN_C Object* JIT_BoxFastMP (CORINFO_CLASS_HANDLE type, void* unboxedData); |
| 37 | EXTERN_C Object* JIT_BoxFastUP (CORINFO_CLASS_HANDLE type, void* unboxedData); |
| 38 | EXTERN_C Object* AllocateStringFastMP (CLR_I4 cch); |
| 39 | EXTERN_C Object* AllocateStringFastUP (CLR_I4 cch); |
| 40 | |
| 41 | EXTERN_C Object* JIT_NewArr1OBJ_MP (CORINFO_CLASS_HANDLE arrayMT, INT_PTR size); |
| 42 | EXTERN_C Object* JIT_NewArr1OBJ_UP (CORINFO_CLASS_HANDLE arrayMT, INT_PTR size); |
| 43 | EXTERN_C Object* JIT_NewArr1VC_MP (CORINFO_CLASS_HANDLE arrayMT, INT_PTR size); |
| 44 | EXTERN_C Object* JIT_NewArr1VC_UP (CORINFO_CLASS_HANDLE arrayMT, INT_PTR size); |
| 45 | |
| 46 | #ifdef _TARGET_AMD64_ |
| 47 | extern WriteBarrierManager g_WriteBarrierManager; |
| 48 | #endif // _TARGET_AMD64_ |
| 49 | |
| 50 | #endif // _WIN64 |
| 51 | |
| 52 | /*********************************************************************/ |
| 53 | // Initialize the part of the JIT helpers that require very little of |
| 54 | // EE infrastructure to be in place. |
| 55 | /*********************************************************************/ |
| 56 | #ifndef _TARGET_X86_ |
| 57 | |
| 58 | void InitJITHelpers1() |
| 59 | { |
| 60 | STANDARD_VM_CONTRACT; |
| 61 | |
| 62 | _ASSERTE(g_SystemInfo.dwNumberOfProcessors != 0); |
| 63 | |
| 64 | #if defined(_TARGET_AMD64_) |
| 65 | |
| 66 | g_WriteBarrierManager.Initialize(); |
| 67 | |
| 68 | // Allocation helpers, faster but non-logging |
| 69 | if (!((TrackAllocationsEnabled()) || |
| 70 | (LoggingOn(LF_GCALLOC, LL_INFO10)) |
| 71 | #ifdef _DEBUG |
| 72 | || (g_pConfig->ShouldInjectFault(INJECTFAULT_GCHEAP) != 0) |
| 73 | #endif // _DEBUG |
| 74 | )) |
| 75 | { |
| 76 | #ifdef FEATURE_PAL |
| 77 | SetJitHelperFunction(CORINFO_HELP_NEWSFAST, JIT_NewS_MP_FastPortable); |
| 78 | SetJitHelperFunction(CORINFO_HELP_NEWSFAST_ALIGN8, JIT_NewS_MP_FastPortable); |
| 79 | SetJitHelperFunction(CORINFO_HELP_NEWARR_1_VC, JIT_NewArr1VC_MP_FastPortable); |
| 80 | SetJitHelperFunction(CORINFO_HELP_NEWARR_1_OBJ, JIT_NewArr1OBJ_MP_FastPortable); |
| 81 | |
| 82 | ECall::DynamicallyAssignFCallImpl(GetEEFuncEntryPoint(AllocateString_MP_FastPortable), ECall::FastAllocateString); |
| 83 | #else // FEATURE_PAL |
| 84 | // if (multi-proc || server GC) |
| 85 | if (GCHeapUtilities::UseThreadAllocationContexts()) |
| 86 | { |
| 87 | SetJitHelperFunction(CORINFO_HELP_NEWSFAST, JIT_TrialAllocSFastMP_InlineGetThread); |
| 88 | SetJitHelperFunction(CORINFO_HELP_NEWSFAST_ALIGN8, JIT_TrialAllocSFastMP_InlineGetThread); |
| 89 | SetJitHelperFunction(CORINFO_HELP_BOX, JIT_BoxFastMP_InlineGetThread); |
| 90 | SetJitHelperFunction(CORINFO_HELP_NEWARR_1_VC, JIT_NewArr1VC_MP_InlineGetThread); |
| 91 | SetJitHelperFunction(CORINFO_HELP_NEWARR_1_OBJ, JIT_NewArr1OBJ_MP_InlineGetThread); |
| 92 | |
| 93 | ECall::DynamicallyAssignFCallImpl(GetEEFuncEntryPoint(AllocateStringFastMP_InlineGetThread), ECall::FastAllocateString); |
| 94 | } |
| 95 | else |
| 96 | { |
| 97 | // Replace the 1p slow allocation helpers with faster version |
| 98 | // |
| 99 | // When we're running Workstation GC on a single proc box we don't have |
| 100 | // InlineGetThread versions because there is no need to call GetThread |
| 101 | SetJitHelperFunction(CORINFO_HELP_NEWSFAST, JIT_TrialAllocSFastSP); |
| 102 | SetJitHelperFunction(CORINFO_HELP_NEWSFAST_ALIGN8, JIT_TrialAllocSFastSP); |
| 103 | SetJitHelperFunction(CORINFO_HELP_BOX, JIT_BoxFastUP); |
| 104 | SetJitHelperFunction(CORINFO_HELP_NEWARR_1_VC, JIT_NewArr1VC_UP); |
| 105 | SetJitHelperFunction(CORINFO_HELP_NEWARR_1_OBJ, JIT_NewArr1OBJ_UP); |
| 106 | |
| 107 | ECall::DynamicallyAssignFCallImpl(GetEEFuncEntryPoint(AllocateStringFastUP), ECall::FastAllocateString); |
| 108 | } |
| 109 | #endif // FEATURE_PAL |
| 110 | } |
| 111 | #endif // _TARGET_AMD64_ |
| 112 | } |
| 113 | |
| 114 | #endif // !_TARGET_X86_ |
| 115 | |