|
| 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 | + |
| 4 | +; *********************************************************************** |
| 5 | +; File: JitHelpers_InlineGetThread.asm, see history in jithelp.asm |
| 6 | +; |
| 7 | +; *********************************************************************** |
| 8 | + |
| 9 | +include AsmMacros.inc |
| 10 | +include asmconstants.inc |
| 11 | + |
| 12 | +CopyValueClassUnchecked equ ?CopyValueClassUnchecked@@YAXPEAX0PEAVMethodTable@@@Z |
| 13 | +JIT_Box equ ?JIT_Box@@YAPEAVObject@@PEAUCORINFO_CLASS_STRUCT_@@PEAX@Z |
| 14 | + |
| 15 | +extern CopyValueClassUnchecked:proc |
| 16 | +extern JIT_Box:proc |
| 17 | + |
| 18 | +; HCIMPL2(Object*, JIT_Box, CORINFO_CLASS_HANDLE type, void* unboxedData) |
| 19 | +NESTED_ENTRY JIT_BoxFastMP, _TEXT |
| 20 | + |
| 21 | + ; m_BaseSize is guaranteed to be a multiple of 8. |
| 22 | + mov r8d, [rcx + OFFSET__MethodTable__m_BaseSize] |
| 23 | + |
| 24 | + INLINE_GET_ALLOC_CONTEXT r11 |
| 25 | + mov r10, [r11 + OFFSETOF__gc_alloc_context__alloc_limit] |
| 26 | + mov rax, [r11 + OFFSETOF__gc_alloc_context__alloc_ptr] |
| 27 | + |
| 28 | + add r8, rax |
| 29 | + |
| 30 | + cmp r8, r10 |
| 31 | + ja AllocFailed |
| 32 | + |
| 33 | + test rdx, rdx |
| 34 | + je NullRef |
| 35 | + |
| 36 | + mov [r11 + OFFSETOF__gc_alloc_context__alloc_ptr], r8 |
| 37 | + mov [rax], rcx |
| 38 | + |
| 39 | + ; Check whether the object contains pointers |
| 40 | + test dword ptr [rcx + OFFSETOF__MethodTable__m_dwFlags], MethodTable__enum_flag_ContainsPointers |
| 41 | + jnz ContainsPointers |
| 42 | + |
| 43 | + ; We have no pointers - emit a simple inline copy loop |
| 44 | + ; Copy the contents from the end |
| 45 | + mov ecx, [rcx + OFFSET__MethodTable__m_BaseSize] |
| 46 | + sub ecx, 18h ; sizeof(ObjHeader) + sizeof(Object) + last slot |
| 47 | + |
| 48 | +align 16 |
| 49 | + CopyLoop: |
| 50 | + mov r8, [rdx+rcx] |
| 51 | + mov [rax+rcx+8], r8 |
| 52 | + sub ecx, 8 |
| 53 | + jge CopyLoop |
| 54 | + REPRET |
| 55 | + |
| 56 | + ContainsPointers: |
| 57 | + ; Do call to CopyValueClassUnchecked(object, data, pMT) |
| 58 | + push_vol_reg rax |
| 59 | + alloc_stack 20h |
| 60 | + END_PROLOGUE |
| 61 | + |
| 62 | + mov r8, rcx |
| 63 | + lea rcx, [rax + 8] |
| 64 | + call CopyValueClassUnchecked |
| 65 | + |
| 66 | + add rsp, 20h |
| 67 | + pop rax |
| 68 | + ret |
| 69 | + |
| 70 | + AllocFailed: |
| 71 | + NullRef: |
| 72 | + jmp JIT_Box |
| 73 | +NESTED_END JIT_BoxFastMP, _TEXT |
| 74 | + |
| 75 | + end |
0 commit comments