Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/corert.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/Common/src/TypeSystem/Interop/InteropStateManager.cs')
-rw-r--r--src/Common/src/TypeSystem/Interop/InteropStateManager.cs48
1 files changed, 45 insertions, 3 deletions
diff --git a/src/Common/src/TypeSystem/Interop/InteropStateManager.cs b/src/Common/src/TypeSystem/Interop/InteropStateManager.cs
index aeed8f19a..3e71c1382 100644
--- a/src/Common/src/TypeSystem/Interop/InteropStateManager.cs
+++ b/src/Common/src/TypeSystem/Interop/InteropStateManager.cs
@@ -22,6 +22,7 @@ namespace Internal.TypeSystem
private readonly PInvokeDelegateWrapperHashtable _pInvokeDelegateWrapperHashtable;
private readonly InlineArrayHashTable _inlineArrayHashtable;
private readonly PInvokeLazyFixupFieldHashtable _pInvokeLazyFixupFieldHashtable;
+ private readonly PInvokeCalliHashtable _pInvokeCalliHashtable;
public InteropStateManager(ModuleDesc generatedAssembly)
{
@@ -33,6 +34,7 @@ namespace Internal.TypeSystem
_pInvokeDelegateWrapperHashtable = new PInvokeDelegateWrapperHashtable(this, _generatedAssembly);
_inlineArrayHashtable = new InlineArrayHashTable(this, _generatedAssembly);
_pInvokeLazyFixupFieldHashtable = new PInvokeLazyFixupFieldHashtable(_generatedAssembly.GetGlobalModuleType());
+ _pInvokeCalliHashtable = new PInvokeCalliHashtable(this, _generatedAssembly.GetGlobalModuleType());
}
//
// Delegate Marshalling Stubs
@@ -155,8 +157,7 @@ namespace Internal.TypeSystem
Debug.Assert(managedType is MetadataType);
-
- var methodKey = new StructMarshallingThunkKey((MetadataType)managedType, StructMarshallingThunkType.NativeToManage);
+ var methodKey = new StructMarshallingThunkKey((MetadataType)managedType, StructMarshallingThunkType.NativeToManaged);
return _structMarshallingThunkHashtable.GetOrCreateValue(methodKey);
}
@@ -172,7 +173,6 @@ namespace Internal.TypeSystem
Debug.Assert(managedType is MetadataType);
-
var methodKey = new StructMarshallingThunkKey((MetadataType)managedType, StructMarshallingThunkType.Cleanup);
return _structMarshallingThunkHashtable.GetOrCreateValue(methodKey);
}
@@ -187,6 +187,11 @@ namespace Internal.TypeSystem
return _pInvokeLazyFixupFieldHashtable.GetOrCreateValue(method);
}
+ public MethodDesc GetPInvokeCalliStub(MethodSignature signature)
+ {
+ return _pInvokeCalliHashtable.GetOrCreateValue(signature);
+ }
+
private class NativeStructTypeHashtable : LockFreeReaderHashtable<MetadataType, NativeStructType>
{
protected override int GetKeyHashCode(MetadataType key)
@@ -473,5 +478,42 @@ namespace Internal.TypeSystem
_owningType = owningType;
}
}
+
+ private class PInvokeCalliHashtable : LockFreeReaderHashtable<MethodSignature, CalliMarshallingMethodThunk>
+ {
+ private readonly InteropStateManager _interopStateManager;
+ private readonly TypeDesc _owningType;
+
+ protected override int GetKeyHashCode(MethodSignature key)
+ {
+ return key.GetHashCode();
+ }
+
+ protected override int GetValueHashCode(CalliMarshallingMethodThunk value)
+ {
+ return value.TargetSignature.GetHashCode();
+ }
+
+ protected override bool CompareKeyToValue(MethodSignature key, CalliMarshallingMethodThunk value)
+ {
+ return key.Equals(value.TargetSignature);
+ }
+
+ protected override bool CompareValueToValue(CalliMarshallingMethodThunk value1, CalliMarshallingMethodThunk value2)
+ {
+ return value1.TargetSignature.Equals(value2.TargetSignature);
+ }
+
+ protected override CalliMarshallingMethodThunk CreateValueFromKey(MethodSignature key)
+ {
+ return new CalliMarshallingMethodThunk(key, _owningType, _interopStateManager);
+ }
+
+ public PInvokeCalliHashtable(InteropStateManager interopStateManager, TypeDesc owningType)
+ {
+ _interopStateManager = interopStateManager;
+ _owningType = owningType;
+ }
+ }
}
}