diff options
author | dotnet-bot <dotnet-bot@microsoft.com> | 2015-01-30 14:14:42 -0800 |
---|---|---|
committer | dotnet-bot <dotnet-bot@microsoft.com> | 2015-01-30 14:14:42 -0800 |
commit | ef1e2ab328087c61a6878c1e84f4fc5d710aebce (patch) | |
tree | dee1bbb89e9d722e16b0d1485e3cdd1b6c8e2cfa /src/vm/gchelpers.h | |
download | coreclr-ef1e2ab328087c61a6878c1e84f4fc5d710aebce.tar.gz coreclr-ef1e2ab328087c61a6878c1e84f4fc5d710aebce.tar.bz2 coreclr-ef1e2ab328087c61a6878c1e84f4fc5d710aebce.zip |
Initial commit to populate CoreCLR repo
[tfs-changeset: 1407945]
Diffstat (limited to 'src/vm/gchelpers.h')
-rw-r--r-- | src/vm/gchelpers.h | 124 |
1 files changed, 124 insertions, 0 deletions
diff --git a/src/vm/gchelpers.h b/src/vm/gchelpers.h new file mode 100644 index 0000000000..4a192972d3 --- /dev/null +++ b/src/vm/gchelpers.h @@ -0,0 +1,124 @@ +// +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. +// + +/* + * GCHELPERS.H + * + * GC Allocation and Write Barrier Helpers + * + + * + */ + +#ifndef _GCHELPERS_H_ +#define _GCHELPERS_H_ + +//======================================================================== +// +// ALLOCATION HELPERS +// +//======================================================================== + +OBJECTREF AllocateValueSzArray(TypeHandle elementType, INT32 length); + // The main Array allocation routine, can do multi-dimensional +OBJECTREF AllocateArrayEx(TypeHandle arrayClass, INT32 *pArgs, DWORD dwNumArgs, BOOL bAllocateInLargeHeap = FALSE + DEBUG_ARG(BOOL bDontSetAppDomain = FALSE)); + // Optimized verion of above +OBJECTREF FastAllocatePrimitiveArray(MethodTable* arrayType, DWORD cElements, BOOL bAllocateInLargeHeap = FALSE); + + +#if defined(_TARGET_X86_) + + // for x86, we generate efficient allocators for some special cases + // these are called via inline wrappers that call the generated allocators + // via function pointers. + + + // Create a SD array of primitive types +typedef HCCALL2_PTR(Object*, FastPrimitiveArrayAllocatorFuncPtr, CorElementType type, DWORD cElements); + +extern FastPrimitiveArrayAllocatorFuncPtr fastPrimitiveArrayAllocator; + + // The fast version always allocates in the normal heap +OBJECTREF AllocatePrimitiveArray(CorElementType type, DWORD cElements); + + // The slow version is distinguished via overloading by an additional parameter +OBJECTREF AllocatePrimitiveArray(CorElementType type, DWORD cElements, BOOL bAllocateInLargeHeap); + + +// Allocate SD array of object pointers. StubLinker-generated asm code might +// implement this, so the element TypeHandle is passed as a PVOID to avoid any +// struct calling convention weirdness. +typedef HCCALL2_PTR(Object*, FastObjectArrayAllocatorFuncPtr, /*TypeHandle*/PVOID ArrayType, DWORD cElements); + +extern FastObjectArrayAllocatorFuncPtr fastObjectArrayAllocator; + + // The fast version always allocates in the normal heap +OBJECTREF AllocateObjectArray(DWORD cElements, TypeHandle ElementType); + + // The slow version is distinguished via overloading by an additional parameter +OBJECTREF AllocateObjectArray(DWORD cElements, TypeHandle ElementType, BOOL bAllocateInLargeHeap); + + + // Allocate string +typedef HCCALL1_PTR(StringObject*, FastStringAllocatorFuncPtr, DWORD cchArrayLength); + +extern FastStringAllocatorFuncPtr fastStringAllocator; + +STRINGREF AllocateString( DWORD cchStringLength ); + + // The slow version, implemented in gcscan.cpp +STRINGREF SlowAllocateString( DWORD cchStringLength ); + +#else + +// On other platforms, go to the (somewhat less efficient) implementations in gcscan.cpp + + // Create a SD array of primitive types +OBJECTREF AllocatePrimitiveArray(CorElementType type, DWORD cElements, BOOL bAllocateInLargeHeap = FALSE); + + // Allocate SD array of object pointers +OBJECTREF AllocateObjectArray(DWORD cElements, TypeHandle ElementType, BOOL bAllocateInLargeHeap = FALSE); + +STRINGREF SlowAllocateString( DWORD cchStringLength ); + +inline STRINGREF AllocateString( DWORD cchStringLength ) +{ + WRAPPER_NO_CONTRACT; + + return SlowAllocateString( cchStringLength ); +} + +#endif + +OBJECTREF DupArrayForCloning(BASEARRAYREF pRef, BOOL bAllocateInLargeHeap = FALSE); + +// The JIT requests the EE to specify an allocation helper to use at each new-site. +// The EE makes this choice based on whether context boundaries may be involved, +// whether the type is a COM object, whether it is a large object, +// whether the object requires finalization. +// These functions will throw OutOfMemoryException so don't need to check +// for NULL return value from them. + +OBJECTREF AllocateObject(MethodTable *pMT +#ifdef FEATURE_COMINTEROP + , bool fHandleCom = true +#endif + ); + +extern void StompWriteBarrierEphemeral(); +extern void StompWriteBarrierResize(BOOL bReqUpperBoundsCheck); + +extern void ThrowOutOfMemoryDimensionsExceeded(); + +//======================================================================== +// +// WRITE BARRIER HELPERS +// +//======================================================================== + +void ErectWriteBarrier(OBJECTREF* dst, OBJECTREF ref); + +#endif // _GCHELPERS_H_ |