[Tizen] Unify dnetmemoryenumlib terms to match the codebase (#291)
[platform/upstream/coreclr.git] / src / vm / gchelpers.h
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  * GCHELPERS.H
7  *
8  * GC Allocation and Write Barrier Helpers
9  *
10
11  *
12  */
13
14 #ifndef _GCHELPERS_H_
15 #define _GCHELPERS_H_
16
17 //========================================================================
18 //
19 //      ALLOCATION HELPERS
20 //
21 //========================================================================
22
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);
26
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);
30
31 // Create a SD array of primitive types given an element type
32 OBJECTREF AllocatePrimitiveArray(CorElementType type, DWORD cElements);
33
34 // Allocate SD array of object types given an element type
35 OBJECTREF AllocateObjectArray(DWORD cElements, TypeHandle ElementType, BOOL bAllocateInLargeHeap = FALSE);
36
37 // Allocate a string
38 STRINGREF AllocateString( DWORD cchStringLength );
39
40 #ifdef FEATURE_UTF8STRING
41 UTF8STRINGREF AllocateUtf8String( DWORD cchStringLength );
42 #endif // FEATURE_UTF8STRING
43
44 OBJECTREF DupArrayForCloning(BASEARRAYREF pRef);
45
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.
52
53 OBJECTREF AllocateObject(MethodTable *pMT
54 #ifdef FEATURE_COMINTEROP
55                          , bool fHandleCom = true
56 #endif
57     );
58
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();
64
65 extern void ThrowOutOfMemoryDimensionsExceeded();
66
67 //========================================================================
68 //
69 //      WRITE BARRIER HELPERS
70 //
71 //========================================================================
72
73 void ErectWriteBarrier(OBJECTREF* dst, OBJECTREF ref);
74 void SetCardsAfterBulkCopy(Object **start, size_t len);
75 #endif // _GCHELPERS_H_