Skip to content
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

Fix nullability annotations for ProfileOptimization.StartProfile #33945

Merged
merged 1 commit into from
Mar 24, 2020
Merged
Show file tree
Hide file tree
Changes from all 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 @@ -24,7 +24,7 @@ public partial class AssemblyLoadContext
internal static extern void InternalSetProfileRoot(string directoryPath);

[DllImport(RuntimeHelpers.QCall, CharSet = CharSet.Unicode)]
internal static extern void InternalStartProfile(string profile, IntPtr ptrNativeAssemblyLoadContext);
internal static extern void InternalStartProfile(string? profile, IntPtr ptrNativeAssemblyLoadContext);

[DllImport(RuntimeHelpers.QCall, CharSet = CharSet.Unicode)]
private static extern void LoadFromPath(IntPtr ptrNativeAssemblyLoadContext, string? ilPath, string? niPath, ObjectHandleOnStack retAssembly);
Expand Down Expand Up @@ -173,7 +173,7 @@ public void SetProfileOptimizationRoot(string directoryPath)
}

// Start profile optimization for the specified profile name.
public void StartProfileOptimization(string profile)
public void StartProfileOptimization(string? profile)
{
InternalStartProfile(profile, _nativeAssemblyLoadContext);
}
Expand Down
6 changes: 3 additions & 3 deletions src/coreclr/src/vm/multicorejit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1009,7 +1009,7 @@ PCODE MulticoreJitRecorder::RequestMethodCode(MethodDesc * pMethod, MulticoreJit
// API Function: SettProfileRoot, store information with MulticoreJitManager class
// Threading: protected by InterlockedExchange(m_fMulticoreJITEnabled)

void MulticoreJitManager::SetProfileRoot(AppDomain * pDomain, const WCHAR * pProfilePath)
void MulticoreJitManager::SetProfileRoot(const WCHAR * pProfilePath)
{
STANDARD_VM_CONTRACT;

Expand Down Expand Up @@ -1211,7 +1211,7 @@ void MulticoreJitManager::AutoStartProfile(AppDomain * pDomain)
{
int suffix = (int) InterlockedIncrement(& g_nMulticoreAutoStart);

SetProfileRoot(pDomain, W("")); // Fake a SetProfileRoot call
SetProfileRoot(W("")); // Fake a SetProfileRoot call

StartProfile(
pDomain,
Expand Down Expand Up @@ -1438,7 +1438,7 @@ void QCALLTYPE MultiCoreJITNative::InternalSetProfileRoot(__in_z LPCWSTR wszProf

AppDomain * pDomain = GetAppDomain();

pDomain->GetMulticoreJitManager().SetProfileRoot(pDomain, wszProfilePath);
pDomain->GetMulticoreJitManager().SetProfileRoot(wszProfilePath);

END_QCALL;
}
2 changes: 1 addition & 1 deletion src/coreclr/src/vm/multicorejit.h
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ class MulticoreJitManager
void AutoStartProfile(AppDomain * pDomain);

// Multicore JIT API function: SetProfileRoot
void SetProfileRoot(AppDomain * pDomain, const WCHAR * pProfilePath);
void SetProfileRoot(const WCHAR * pProfilePath);

// Multicore JIT API function: StartProfile
void StartProfile(AppDomain * pDomain, ICLRPrivBinder * pBinderContext, const WCHAR * pProfile, int suffix = -1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public static void SetProfileRoot(string directoryPath)
AssemblyLoadContext.Default.SetProfileOptimizationRoot(directoryPath);
}

public static void StartProfile(string profile)
public static void StartProfile(string? profile)
{
AssemblyLoadContext.Default.StartProfileOptimization(profile);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,33 @@ namespace System.Runtime.Tests
{
public class ProfileOptimizationTest : FileCleanupTestBase
{
[Fact]
[Theory]
[InlineData(false)]
[InlineData(true)]
[ActiveIssue("https://github.com/dotnet/runtime/issues/31853", TestRuntimes.Mono)]
public void ProfileOptimization_CheckFileExists()
public void ProfileOptimization_CheckFileExists(bool stopProfile)
{
string profileFile = GetTestFileName();

RemoteExecutor.Invoke((_profileFile) =>
RemoteExecutor.Invoke((_profileFile, _stopProfile) =>
{
// Perform the test work
ProfileOptimization.SetProfileRoot(Path.GetDirectoryName(_profileFile));
ProfileOptimization.StartProfile(Path.GetFileName(_profileFile));

}, profileFile).Dispose();
if (bool.Parse(_stopProfile))
{
ProfileOptimization.StartProfile(null);
CheckProfileFileExists(_profileFile);
}

}, profileFile, stopProfile.ToString()).Dispose();

CheckProfileFileExists(profileFile);
}

static void CheckProfileFileExists(string profileFile)
{
// profileFile should deterministically exist now -- if not, wait 5 seconds
bool existed = File.Exists(profileFile);
if (!existed)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public event System.Action<System.Runtime.Loader.AssemblyLoadContext>? Unloading
protected virtual System.IntPtr LoadUnmanagedDll(string unmanagedDllName) { throw null; }
protected System.IntPtr LoadUnmanagedDllFromPath(string unmanagedDllPath) { throw null; }
public void SetProfileOptimizationRoot(string directoryPath) { }
public void StartProfileOptimization(string profile) { }
public void StartProfileOptimization(string? profile) { }
public override string ToString() { throw null; }
public void Unload() { }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
Expand Down
2 changes: 1 addition & 1 deletion src/libraries/System.Runtime/ref/System.Runtime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8573,7 +8573,7 @@ public void Dispose() { }
public static partial class ProfileOptimization
{
public static void SetProfileRoot(string directoryPath) { }
public static void StartProfile(string profile) { }
public static void StartProfile(string? profile) { }
}
[System.AttributeUsageAttribute(System.AttributeTargets.Constructor | System.AttributeTargets.Method, AllowMultiple=false, Inherited=false)]
public sealed partial class TargetedPatchingOptOutAttribute : System.Attribute
Expand Down