Skip to content
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
9 changes: 4 additions & 5 deletions src/coreclr/src/inc/readytorun.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,10 @@ struct READYTORUN_SECTION

enum ReadyToRunFlag
{
// Set if the original IL assembly was platform-neutral
READYTORUN_FLAG_PLATFORM_NEUTRAL_SOURCE = 0x00000001,
READYTORUN_FLAG_SKIP_TYPE_VALIDATION = 0x00000002,
// Set of methods with native code was determined using profile data
READYTORUN_FLAG_PARTIAL = 0x00000004,
READYTORUN_FLAG_PLATFORM_NEUTRAL_SOURCE = 0x00000001, // Set if the original IL assembly was platform-neutral
READYTORUN_FLAG_SKIP_TYPE_VALIDATION = 0x00000002, // Set of methods with native code was determined using profile data
READYTORUN_FLAG_PARTIAL = 0x00000004,
READYTORUN_FLAG_NONSHARED_PINVOKE_STUBS = 0x00000008 // PInvoke stubs compiled into image are non-shareable (no secret parameter)
};

enum ReadyToRunSectionType
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@ internal struct ReadyToRunHeader
};
#pragma warning restore 0169

enum ReadyToRunFlag
{
READYTORUN_FLAG_PLATFORM_NEUTRAL_SOURCE = 0x00000001, // Set if the original IL assembly was platform-neutral
READYTORUN_FLAG_SKIP_TYPE_VALIDATION = 0x00000002, // Set of methods with native code was determined using profile data
READYTORUN_FLAG_PARTIAL = 0x00000004,
READYTORUN_FLAG_NONSHARED_PINVOKE_STUBS = 0x00000008 // PInvoke stubs compiled into image are non-shareable (no secret parameter)
};

//
// ReadyToRunSectionType IDs are used by the runtime to look up specific global data sections
// from each module linked into the final binary. New sections should be added at the bottom
Expand Down
17 changes: 5 additions & 12 deletions src/coreclr/src/tools/crossgen2/Common/JitInterface/CorInfoImpl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -659,6 +659,11 @@ private uint getMethodAttribsInternal(MethodDesc method)
if (method.IsPInvoke)
{
result |= CorInfoFlag.CORINFO_FLG_PINVOKE;

if (method.IsRawPInvoke())
{
result |= CorInfoFlag.CORINFO_FLG_FORCEINLINE;
}
}

#if READYTORUN
Expand Down Expand Up @@ -774,14 +779,6 @@ private CorInfoInline canInline(CORINFO_METHOD_STRUCT_* callerHnd, CORINFO_METHO
MethodDesc callerMethod = HandleToObject(callerHnd);
MethodDesc calleeMethod = HandleToObject(calleeHnd);

#if READYTORUN
// IL stubs don't inline well
if (calleeMethod.IsPInvoke)
{
return CorInfoInline.INLINE_NEVER;
}
#endif

if (_compilation.CanInline(callerMethod, calleeMethod))
{
// No restrictions on inlining
Expand Down Expand Up @@ -3066,10 +3063,6 @@ private uint getJitFlags(ref CORJIT_FLAGS flags, uint sizeInBytes)
if (this.MethodBeingCompiled.IsPInvoke)
{
flags.Set(CorJitFlag.CORJIT_FLAG_IL_STUB);

#if READYTORUN
flags.Set(CorJitFlag.CORJIT_FLAG_PUBLISH_SECRET_PARAM);
#endif
}

if (this.MethodBeingCompiled.IsNoOptimization)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// 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 Internal.TypeSystem;

namespace Internal.IL.Stubs
{
partial class PInvokeTargetNativeMethod
{
public override string DiagnosticName
{
get
{
return _declMethod.DiagnosticName;
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// 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 Internal.TypeSystem;

namespace Internal.IL.Stubs
{
partial class PInvokeTargetNativeMethod : IPrefixMangledMethod
{
MethodDesc IPrefixMangledMethod.BaseMethod
{
get
{
return _declMethod;
}
}

string IPrefixMangledMethod.Prefix
{
get
{
return "rawpinvoke";
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// 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 Internal.TypeSystem;

namespace Internal.IL.Stubs
{
// Functionality related to deterministic ordering of types
partial class PInvokeTargetNativeMethod
{
protected internal override int ClassCode => -1626939381;

protected internal override int CompareToImpl(MethodDesc other, TypeSystemComparer comparer)
{
var otherMethod = (PInvokeTargetNativeMethod)other;
return comparer.Compare(_declMethod, otherMethod._declMethod);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
// 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 Internal.TypeSystem;

namespace Internal.IL.Stubs
{
/// <summary>
/// Synthetic method that represents the actual PInvoke target method.
/// All parameters are simple types. There will be no code
/// generated for this method. Instead, a static reference to a symbol will be emitted.
/// </summary>
public sealed partial class PInvokeTargetNativeMethod : MethodDesc
{
private readonly MethodDesc _declMethod;
private readonly MethodSignature _signature;

public MethodDesc Target
{
get
{
return _declMethod;
}
}

public PInvokeTargetNativeMethod(MethodDesc declMethod, MethodSignature signature)
{
_declMethod = declMethod;
_signature = signature;
}

public override TypeSystemContext Context
{
get
{
return _declMethod.Context;
}
}

public override TypeDesc OwningType
{
get
{
return _declMethod.OwningType;
}
}

public override MethodSignature Signature
{
get
{
return _signature;
}
}

public override string Name
{
get
{
return _declMethod.Name;
}
}

public override bool HasCustomAttribute(string attributeNamespace, string attributeName)
{
return false;
}

public override bool IsPInvoke
{
get
{
return true;
}
}

public override bool IsNoInlining
{
get
{
// This method does not have real IL body. NoInlining stops the JIT asking for it.
return true;
}
}

public override PInvokeMetadata GetPInvokeMethodMetadata()
{
return _declMethod.GetPInvokeMethodMetadata();
}
}
}
Loading