Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/corert.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Vorlicek <janvorli@microsoft.com>2016-09-30 01:34:20 +0300
committerJan Vorlicek <janvorli@microsoft.com>2016-09-30 01:34:20 +0300
commit47f7ef942fedcef291799acb601a403c3f708b3a (patch)
tree95d222b0ba0dc34b292abf582b07001c7cdb209b /src/Native/Runtime/amd64
parentac9362952911113e3acddb9bef39d9196c4453a7 (diff)
This change implements CastableObject support. The work was done by David Wrighton, I have added support for x86 and ARM32 and investigated few general issues that surfaced during testing.
1. Logic to convert interface dispatch to use universal transition thunk instead of managedcalloutthunk. (This allows interface dispatch to safely throw exceptions if it needs to.) (This is implemented for all platforms) 2. Poor man’s interface type equivalence to allow the new ICastableObject interface to be called directly from the runtime instead of building a specialized calling routine. (We should probably consider implementing the general thing, but this shelveset is big enough as it is.) 3. Small feature adds around COFF emission of pdb records to allow the runtime to have an interface dispatch in it. 4. New CastableObject class 5. Tweak to reflection to allow both ICastable and CastableObject interface dispatch routines to work. 6. Test case for CastableObject 7. Assembly stubs and thunks to make castable object implementation work. [tfs-changeset: 1630177]
Diffstat (limited to 'src/Native/Runtime/amd64')
-rw-r--r--src/Native/Runtime/amd64/StubDispatch.S40
-rw-r--r--src/Native/Runtime/amd64/StubDispatch.asm68
2 files changed, 108 insertions, 0 deletions
diff --git a/src/Native/Runtime/amd64/StubDispatch.S b/src/Native/Runtime/amd64/StubDispatch.S
index baca8fd42..4bc5a22d2 100644
--- a/src/Native/Runtime/amd64/StubDispatch.S
+++ b/src/Native/Runtime/amd64/StubDispatch.S
@@ -6,6 +6,46 @@
#include <unixasmmacros.inc>
#include <AsmOffsets.inc> // generated by the build from AsmOffsets.cpp
+LEAF_ENTRY RhpGetTailCallTLSDispatchCell, _TEXT
+ lea rax, RhpTailCallTLSDispatchCell
+ ret
+LEAF_END RhpGetTailCallTLSDispatchCell, _TEXT
+
+LEAF_ENTRY RhpTailCallTLSDispatchCell, _TEXT
+ // UNIXTODO: Implement this function
+ int 3
+LEAF_END RhpTailCallTLSDispatchCell, _TEXT
+
+LEAF_ENTRY RhpGetCastableObjectDispatchHelper_TailCalled, _TEXT
+ lea rax, RhpCastableObjectDispatchHelper_TailCalled
+ ret
+LEAF_END RhpGetCastableObjectDispatchHelper_TailCalled, _TEXT
+
+LEAF_ENTRY RhpCastableObjectDispatchHelper_TailCalled, _TEXT
+ // UNIXTODO: Implement this function
+ int 3
+LEAF_END RhpCastableObjectDispatchHelper_TailCalled, _TEXT
+
+LEAF_ENTRY RhpCastableObjectDispatchHelper, _TEXT
+ // UNIXTODO: Implement this function
+ int 3
+LEAF_END RhpCastableObjectDispatchHelper, _TEXT
+
+LEAF_ENTRY RhpGetCastableObjectDispatchHelper, _TEXT
+ lea rax, RhpCastableObjectDispatchHelper
+ ret
+LEAF_END RhpGetCastableObjectDispatchHelper, _TEXT
+
+LEAF_ENTRY RhpGetCacheForCastableObject, _TEXT
+ mov rax, [rdi+8]
+ ret
+LEAF_END RhpGetCacheForCastableObject, _TEXT
+
+LEAF_ENTRY RhpSetCacheForCastableObject, _TEXT
+ lea rdi, [rdi+8]
+ jmp RhpCheckedAssignRefESI // Is this the correct form for tailcall?
+LEAF_END RhpSetCacheForCastableObject, _TEXT
+
// Macro that generates a stub consuming a cache with the given number of entries.
.macro DEFINE_INTERFACE_DISPATCH_STUB entries
diff --git a/src/Native/Runtime/amd64/StubDispatch.asm b/src/Native/Runtime/amd64/StubDispatch.asm
index a132cb1fb..ad6c29096 100644
--- a/src/Native/Runtime/amd64/StubDispatch.asm
+++ b/src/Native/Runtime/amd64/StubDispatch.asm
@@ -10,7 +10,75 @@ ifdef FEATURE_CACHED_INTERFACE_DISPATCH
EXTERN RhpCidResolve : PROC
EXTERN RhpUniversalTransition_DebugStepTailCall : PROC
+EXTERN RhpCastableObjectResolve : PROC
+EXTERN RhpCheckedAssignRefEDX : PROC
+
+EXTERN t_TLS_DispatchCell:QWORD
+EXTERN _tls_index:DWORD
+
+LEAF_ENTRY RhpGetTailCallTLSDispatchCell, _TEXT
+ lea rax, RhpTailCallTLSDispatchCell
+ ret
+LEAF_END RhpGetTailCallTLSDispatchCell, _TEXT
+
+LEAF_ENTRY RhpTailCallTLSDispatchCell, _TEXT
+ ;; Load the dispatch cell out of the TLS variable
+ mov rax, gs:[88]
+ mov r10d, _tls_index
+ mov r10, [rax + r10 * 8]
+ mov eax, SECTIONREL t_TLS_DispatchCell
+ mov r10, [r10+rax]
+
+ ;; Load the target of the dispatch cell into rax
+ mov rax, [r10]
+ ;; And tail call to it
+ TAILJMP_RAX
+LEAF_END RhpTailCallTLSDispatchCell, _TEXT
+
+
+LEAF_ENTRY RhpGetCastableObjectDispatchHelper_TailCalled, _TEXT
+ lea rax, RhpCastableObjectDispatchHelper_TailCalled
+ ret
+LEAF_END RhpGetCastableObjectDispatchHelper_TailCalled, _TEXT
+
+LEAF_ENTRY RhpCastableObjectDispatchHelper_TailCalled, _TEXT
+ ;; Load the dispatch cell out of the TLS variable
+ mov rax, gs:[88]
+ mov r10d, _tls_index
+ mov r10, [rax + r10 * 8]
+ mov eax, SECTIONREL t_TLS_DispatchCell
+ mov r10, [r10+rax]
+ jmp RhpCastableObjectDispatchHelper
+LEAF_END RhpCastableObjectDispatchHelper_TailCalled, _TEXT
+
+LEAF_ENTRY RhpCastableObjectDispatchHelper, _TEXT
+ ;; TODO! Implement fast lookup helper to avoid the universal transition each time we
+ ;; hit a CastableObject
+
+ ;; If the initial lookup fails, call into managed under the universal thunk
+ ;; to run the full lookup routine
+ ;; r10 contains indirection cell address, move to r11 where it will be passed by
+ ;; the universal transition thunk as an argument to RhpCastableObjectResolve
+ mov r11, r10
+ lea r10, RhpCastableObjectResolve
+ jmp RhpUniversalTransition_DebugStepTailCall
+LEAF_END RhpCastableObjectDispatchHelper, _TEXT
+
+LEAF_ENTRY RhpGetCastableObjectDispatchHelper, _TEXT
+ lea rax, RhpCastableObjectDispatchHelper
+ ret
+LEAF_END RhpGetCastableObjectDispatchHelper, _TEXT
+
+LEAF_ENTRY RhpGetCacheForCastableObject, _TEXT
+ mov rax, [rcx+8]
+ ret
+LEAF_END RhpGetCacheForCastableObject, _TEXT
+
+LEAF_ENTRY RhpSetCacheForCastableObject, _TEXT
+ lea rcx, [rcx+8]
+ jmp RhpCheckedAssignRefEDX ;; Is this the correct form for tailcall?
+LEAF_END RhpSetCacheForCastableObject, _TEXT
;; Macro that generates code to check a single cache entry.
CHECK_CACHE_ENTRY macro entry