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.
8 * GC Allocation and Write Barrier Helpers
17 //========================================================================
21 //========================================================================
23 // Allocate single-dimensional array given array type
24 OBJECTREF AllocateSzArray(MethodTable *pArrayMT, INT32 length, GC_ALLOC_FLAGS flags = GC_ALLOC_NO_FLAGS, BOOL bAllocateInLargeHeap = FALSE);
25 OBJECTREF AllocateSzArray(TypeHandle arrayType, INT32 length, GC_ALLOC_FLAGS flags = GC_ALLOC_NO_FLAGS, BOOL bAllocateInLargeHeap = FALSE);
27 // The main Array allocation routine, can do multi-dimensional
28 OBJECTREF AllocateArrayEx(MethodTable *pArrayMT, INT32 *pArgs, DWORD dwNumArgs, GC_ALLOC_FLAGS flags = GC_ALLOC_NO_FLAGS, BOOL bAllocateInLargeHeap = FALSE);
29 OBJECTREF AllocateArrayEx(TypeHandle arrayType, INT32 *pArgs, DWORD dwNumArgs, GC_ALLOC_FLAGS flags = GC_ALLOC_NO_FLAGS, BOOL bAllocateInLargeHeap = FALSE);
31 // Create a SD array of primitive types given an element type
32 OBJECTREF AllocatePrimitiveArray(CorElementType type, DWORD cElements);
34 // Allocate SD array of object types given an element type
35 OBJECTREF AllocateObjectArray(DWORD cElements, TypeHandle ElementType, BOOL bAllocateInLargeHeap = FALSE);
38 STRINGREF AllocateString( DWORD cchStringLength );
40 #ifdef FEATURE_UTF8STRING
41 UTF8STRINGREF AllocateUtf8String( DWORD cchStringLength );
42 #endif // FEATURE_UTF8STRING
44 OBJECTREF DupArrayForCloning(BASEARRAYREF pRef);
46 // The JIT requests the EE to specify an allocation helper to use at each new-site.
47 // The EE makes this choice based on whether context boundaries may be involved,
48 // whether the type is a COM object, whether it is a large object,
49 // whether the object requires finalization.
50 // These functions will throw OutOfMemoryException so don't need to check
51 // for NULL return value from them.
53 OBJECTREF AllocateObject(MethodTable *pMT
54 #ifdef FEATURE_COMINTEROP
55 , bool fHandleCom = true
59 extern int StompWriteBarrierEphemeral(bool isRuntimeSuspended);
60 extern int StompWriteBarrierResize(bool isRuntimeSuspended, bool bReqUpperBoundsCheck);
61 extern int SwitchToWriteWatchBarrier(bool isRuntimeSuspended);
62 extern int SwitchToNonWriteWatchBarrier(bool isRuntimeSuspended);
63 extern void FlushWriteBarrierInstructionCache();
65 extern void ThrowOutOfMemoryDimensionsExceeded();
67 //========================================================================
69 // WRITE BARRIER HELPERS
71 //========================================================================
73 void ErectWriteBarrier(OBJECTREF* dst, OBJECTREF ref);
74 void SetCardsAfterBulkCopy(Object **start, size_t len);
75 #endif // _GCHELPERS_H_