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 Kotas <jkotas@microsoft.com>2016-05-17 01:02:38 +0300
committerJan Kotas <jkotas@microsoft.com>2016-05-17 01:02:38 +0300
commit10d475ef6233e5baf6db91eb9edb5f426685298e (patch)
tree64ffe65ca9d0f751991056baf2cdb58a05123808 /src/Native/Runtime/threadstore.inl
parenta7e7db720420872e9814966a86144d41871364fc (diff)
Reduce assembly code in PInvoke helpers
- Reduce amount of assembly code in PInvoke helpers by moving all slow paths to C++ - Share code between the slow paths of assembly and portable helpers - Improve performance of the portable helpers by making the access to current thread and the trap thread statics inlineable (e.g. the portable RhpReversePInvoke2 helper has only two extra instructions compared to what the hand-optimized assembly helper would have) [tfs-changeset: 1605153]
Diffstat (limited to 'src/Native/Runtime/threadstore.inl')
-rw-r--r--src/Native/Runtime/threadstore.inl40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/Native/Runtime/threadstore.inl b/src/Native/Runtime/threadstore.inl
new file mode 100644
index 000000000..1fbf862d5
--- /dev/null
+++ b/src/Native/Runtime/threadstore.inl
@@ -0,0 +1,40 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+EXTERN_C DECLSPEC_THREAD ThreadBuffer tls_CurrentThread;
+
+// static
+inline Thread * ThreadStore::RawGetCurrentThread()
+{
+ return (Thread *) &tls_CurrentThread;
+}
+
+// static
+inline Thread * ThreadStore::GetCurrentThread()
+{
+ Thread * pCurThread = RawGetCurrentThread();
+
+ // If this assert fires, and you only need the Thread pointer if the thread has ever previously
+ // entered the runtime, then you should be using GetCurrentThreadIfAvailable instead.
+ ASSERT(pCurThread->IsInitialized());
+ return pCurThread;
+}
+
+// static
+inline Thread * ThreadStore::GetCurrentThreadIfAvailable()
+{
+ Thread * pCurThread = RawGetCurrentThread();
+ if (pCurThread->IsInitialized())
+ return pCurThread;
+
+ return NULL;
+}
+
+EXTERN_C volatile UInt32 RhpTrapThreads;
+
+// static
+inline bool ThreadStore::IsTrapThreadsRequested()
+{
+ return (RhpTrapThreads != 0);
+}