Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,8 @@ static bool SPCOptimizationsEnabled()
Assembly objectAssembly = Assembly.GetAssembly(typeof(object));
object[] attribs = objectAssembly.GetCustomAttributes(typeof(DebuggableAttribute),
false);
if (attribs.Length == 0)
return true; // Assume corelib is optimized in this case
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding <DebuggerSupport>true</DebuggerSupport> to the project file would make the attribute visible, but ILC has its own optimization switch so CoreLib having this attribute still doesn't necessarily imply how optimized it is.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MichalStrehovsky do we run runtime tests with NativeAOT in full debug mode?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So can you tell me how to properly check it here?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MichalStrehovsky do we run runtime tests with NativeAOT in full debug mode?

We do have such legs, I'm not sure if they include this test too. It would be in the runtime or runtime-nativeaot-outerloop if it exists.

So can you tell me how to properly check it here?

Native AOT will use the same settings for optimizing both CoreLib and user code so enabling the attribute and looking for the attribute on Assembly.GetEntryAssembly would give the answer.

I guess I don't understand why this is looking at whether corelib is optimized. Why does that affect stack allocations in this test?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess I don't understand why this is looking at whether corelib is optimized. Why does that affect stack allocations in this test?

Maybe the way we build the tests, optimization of CoreLib always matches optimization of the test?

If that's the case, all that's needed is to add <DebuggerSupport>true</DebuggerSupport> to the test project and this will work the same. It will also fail the same if there's ever mismatch between test optimization and corelib optimization.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess I don't understand why this is looking at whether corelib is optimized. Why does that affect stack allocations in this test?

I am not the original author (I presume the authors no longer work in the team), but looks like the test tries to be agile and validate that nothing is stack-allocated under debug maybe? 🤷

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not the original author (I presume the authors no longer work in the team), but looks like the test tries to be agile and validate that nothing is stack-allocated under debug maybe?

Right, but for that one would check whether the test is optimized, not corelib. One can build the test with <Optimize>true</Optimize> and have corelib from a debug build. I assume the test would fail in that case.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(I mean in the JIT case. It would also fail in the AOT case because I believe the test is looking at the wrong assembly.)

Copy link
Member Author

@EgorBo EgorBo Jul 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ended up removing these bits and the test is still working fine (it's always optimized due to <Optimize>true</Optimize>)

DebuggableAttribute debuggableAttribute = attribs[0] as DebuggableAttribute;
return ((debuggableAttribute == null) || !debuggableAttribute.IsJITOptimizerDisabled);
}
Expand Down