-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[NativeAOT] Emit Align8 flag for thread statics #105931
Conversation
src/coreclr/nativeaot/Common/src/Internal/Runtime/MethodTable.cs
Outdated
Show resolved
Hide resolved
Co-authored-by: yowl <scott.waye@hubse.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you also make it so that we don't have GCStaticEETypes that only differ by RequiresAlign8 bit on platforms that don't have Align8 concept? (we don't set RequiresAlign8
on MethodTables on these platforms either).
src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/NativeLayoutVertexNode.cs
Outdated
Show resolved
Hide resolved
src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/GCStaticsNode.cs
Outdated
Show resolved
Hide resolved
Nevermind, I forgot that I didn't use |
Co-authored-by: Michal Strehovský <MichalStrehovsky@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do dynamic (MakeGenericType
) thread statics need any additional attention (e. g. a test)?
src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/NodeFactory.cs
Outdated
Show resolved
Hide resolved
Test would be nice. I am not really sure how these are treated internally in ILC / NAOT runtime, so I am not sure if I am qualified to check this. |
Something along these lines: private class ThreadStaticAlignCheck1<T>
{
[ThreadStatic]
[FixedAddressValueType]
internal static ReturnArea returnArea = default;
}
private class ThreadStaticAlignCheck2<T>
{
[ThreadStatic]
[FixedAddressValueType]
internal static ReturnArea returnArea = default;
}
public static void RunGeneric<T>()
{
// Assume that these are allocated sequentially, use a padding object of size 12 (mod 8 is not 0)
// to move the alignment of the second AddressOfReturnArea in case the first is coincidentally aligned 8.
var ts1Addr = ThreadStaticAlignCheck1<T>.returnArea.AddressOfReturnArea();
var p = new Padder();
var ts2Addr = ThreadStaticAlignCheck2<T>.returnArea.AddressOfReturnArea();
if (((nint)ts1Addr) % 8 != 0)
throw new Exception();
if (((nint)ts2Addr) % 8 != 0)
throw new Exception();
}
class Atom { } And add this to typeof(ThreadStaticAlignmentTest).GetMethod("RunGeneric").MakeGenericMethod(GetAtom()).Invoke(null, []);
[MethodImpl(MethodImplOptions.NoInlining)]
static void GetAtom() => typeof(Atom); |
Thanks, I will check it on my Raspberry Pi once I get to office. |
Test added, it passes on my machine (tm). |
/azp run runtime-nativeaot-outerloop |
Azure Pipelines successfully started running 1 pipeline(s). |
/ba-g infra indicates failures, but the logs at https://helix.dot.net/api/2019-06-17/jobs/7c253045-5363-4f2c-a180-622d4c896b69/workitems/System.IO.FileSystem.DisabledFileLocking.Tests/console look good |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
Fixes #103234
Contributes to #97729