This repository was archived by the owner on Jan 23, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Revert removal of SuppressGCTransition from SystemNative_GetTimestamp() #27473
Merged
AaronRobinsonMSFT
merged 6 commits into
dotnet:master
from
AaronRobinsonMSFT:coreclr_27465
Oct 29, 2019
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
673a083
Revert removal of SuppressGCTransition from SystemNative_GetTimestamp()
AaronRobinsonMSFT 8a8ef7a
Insert the GC_POLL as a new statement immediately after the statement…
AaronRobinsonMSFT bb28a07
Apply format to JIT code.
AaronRobinsonMSFT 310f901
Insert GC_POLL before statement with unmanaged call.
AaronRobinsonMSFT 64e7516
JIT test for insertion of GCPoll
AaronRobinsonMSFT 6f491f8
Test build breaks on non-Windows platforms.
AaronRobinsonMSFT File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| cmake_minimum_required (VERSION 2.6) | ||
| project (GCPollNative) | ||
|
|
||
| set(SOURCES | ||
| GCPollNative.cpp | ||
| ) | ||
|
|
||
| add_library (GCPollNative SHARED ${SOURCES}) | ||
|
|
||
| # add the install targets | ||
| install (TARGETS GCPollNative DESTINATION bin) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| // 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. | ||
|
|
||
| #include <cstdio> | ||
| #include <cstdint> | ||
| #include <atomic> | ||
|
|
||
| #if defined(_MSC_VER) | ||
|
|
||
| #define STDMETHODCALLTYPE __stdcall | ||
| #define EXPORT(type) extern "C" type __declspec(dllexport) | ||
|
|
||
| #else // !defined(_MSC_VER) | ||
|
|
||
| #ifdef __i386__ | ||
| #define STDMETHODCALLTYPE __attribute__((stdcall)) | ||
| #else | ||
| #define STDMETHODCALLTYPE | ||
| #endif | ||
| #define EXPORT(type) extern "C" __attribute__((visibility("default"))) type | ||
|
|
||
| #endif // defined(_MSC_VER) | ||
|
|
||
| namespace | ||
| { | ||
| std::atomic<uint64_t> _n{ 0 }; | ||
|
|
||
| template<typename T> | ||
| T NextUInt(T t) | ||
| { | ||
| return (T)((++_n) + t); | ||
| } | ||
| } | ||
|
|
||
| EXPORT(uint32_t) STDMETHODCALLTYPE NextUInt32(uint32_t t) | ||
| { | ||
| return NextUInt(t); | ||
| } | ||
|
|
||
| EXPORT(uint64_t) STDMETHODCALLTYPE NextUInt64(uint64_t t) | ||
| { | ||
| return NextUInt(t); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,108 @@ | ||
| // 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. | ||
|
|
||
| using System; | ||
| using System.Runtime.InteropServices; | ||
|
|
||
| static class GCPollNative | ||
| { | ||
| // Simple function that can be marked as SuppressGCTransition which will | ||
| // result in a GCPoll insertion. | ||
| [DllImport(nameof(GCPollNative))] | ||
| [SuppressGCTransition] | ||
| public static extern uint NextUInt32(uint n); | ||
|
|
||
| // Simple function that can be marked as SuppressGCTransition which will | ||
| // result in a GCPoll insertion. | ||
| [DllImport(nameof(GCPollNative))] | ||
| [SuppressGCTransition] | ||
| public static extern ulong NextUInt64(ulong n); | ||
| } | ||
|
|
||
| class InsertGCPoll | ||
| { | ||
| private static int PropNextInt32 => (int)GCPollNative.NextUInt32(0); | ||
| private static long PropNextInt64 => (long)GCPollNative.NextUInt64(0); | ||
|
|
||
| private static void AccessAsProperty32() | ||
| { | ||
| int a = PropNextInt32; | ||
| int b = PropNextInt32; | ||
| DisplayValues(a, b); | ||
| } | ||
|
|
||
| private static void AccessAsProperty64() | ||
| { | ||
| long a = PropNextInt64; | ||
| long b = PropNextInt64; | ||
| DisplayValues(a, b); | ||
| } | ||
|
|
||
| private static void DisplayValues<T>(T a, T b) | ||
| { | ||
| Console.WriteLine($"{a} {b}"); | ||
| } | ||
|
|
||
| private static void BranchOnProperty32() | ||
| { | ||
| if (-1 == PropNextInt32) | ||
| { | ||
| Console.WriteLine(""); | ||
| } | ||
| } | ||
|
|
||
| private static void BranchOnProperty64() | ||
| { | ||
| if (-1 == PropNextInt64) | ||
| { | ||
| Console.WriteLine(""); | ||
| } | ||
| } | ||
|
|
||
| private static void CompoundStatementBranchOnProperty() | ||
| { | ||
| if (-1 == (PropNextInt64 + PropNextInt32 - PropNextInt64 + PropNextInt64 - PropNextInt32)) | ||
| { | ||
| Console.WriteLine(""); | ||
| } | ||
| } | ||
|
|
||
| private static void LoopOn32() | ||
| { | ||
| uint i = 0; | ||
| for (int j = 0; j < 10 || i < 32; ++j) | ||
| { | ||
| i += GCPollNative.NextUInt32(1); | ||
| } | ||
| } | ||
|
|
||
| private static void LoopOn64() | ||
| { | ||
| ulong i = 0; | ||
| for (int j = 0; j < 10 || i < 32; ++j) | ||
| { | ||
| i += GCPollNative.NextUInt64(1); | ||
| } | ||
| } | ||
|
|
||
| public static int Main() | ||
| { | ||
| try | ||
| { | ||
| AccessAsProperty32(); | ||
| AccessAsProperty64(); | ||
| BranchOnProperty32(); | ||
| BranchOnProperty64(); | ||
| CompoundStatementBranchOnProperty(); | ||
| LoopOn32(); | ||
| LoopOn64(); | ||
| } | ||
| catch (Exception e) | ||
| { | ||
| Console.WriteLine(e.ToString()); | ||
| return 101; | ||
| } | ||
| return 100; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
| <PropertyGroup> | ||
| <OutputType>Exe</OutputType> | ||
| <AllowUnsafeBlocks>true</AllowUnsafeBlocks> | ||
| </PropertyGroup> | ||
| <PropertyGroup> | ||
| <Optimize>True</Optimize> | ||
| </PropertyGroup> | ||
| <ItemGroup> | ||
| <Compile Include="InsertGCPoll.cs" /> | ||
| </ItemGroup> | ||
| <ItemGroup> | ||
| <ProjectReference Include="CMakeLists.txt" /> | ||
| </ItemGroup> | ||
| </Project> |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.