-
Notifications
You must be signed in to change notification settings - Fork 503
Get Array1 to work #36
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| using System; | ||
| using System.Collections.Generic; | ||
| using System.Linq; | ||
| using System.Text; | ||
| using System.Threading.Tasks; | ||
|
|
||
| using Internal.TypeSystem; | ||
|
|
||
| namespace ILToNative | ||
| { | ||
| public enum JitHelperId | ||
| { | ||
| RngChkFail, | ||
| } | ||
|
|
||
| class JitHelper | ||
| { | ||
| Compilation _compilation; | ||
|
|
||
| public JitHelper(Compilation compilation, JitHelperId id) | ||
| { | ||
| _compilation = compilation; | ||
|
|
||
| this.Id = id; | ||
| } | ||
|
|
||
| public JitHelperId Id { get; private set; } | ||
|
|
||
| public string MangledName | ||
| { | ||
| get | ||
| { | ||
| switch (this.Id) | ||
| { | ||
| case JitHelperId.RngChkFail: | ||
| return "__range_check_fail"; | ||
|
|
||
| default: | ||
| throw new NotImplementedException(); | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| } | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -203,15 +203,15 @@ void Get_CORINFO_SIG_INFO(MethodDesc method, out CORINFO_SIG_INFO sig) | |
|
|
||
| sig.numArgs = (ushort)signature.Length; | ||
|
|
||
| sig.args = (CORINFO_ARG_LIST_STRUCT_ * )0; // CORINFO_ARG_LIST_STRUCT_ is argument index | ||
| sig.args = (CORINFO_ARG_LIST_STRUCT_*)0; // CORINFO_ARG_LIST_STRUCT_ is argument index | ||
|
|
||
| // TODO: Shared generic | ||
| sig.sigInst.classInst = null; | ||
| sig.sigInst.classInstCount = 0; | ||
| sig.sigInst.methInst = null; | ||
| sig.sigInst.methInstCount = 0; | ||
|
|
||
| sig.pSig = (byte * )ObjectToHandle(signature); | ||
| sig.pSig = (byte*)ObjectToHandle(signature); | ||
| sig.cbSig = 0; // Not used by the JIT | ||
| sig.scope = null; // Not used by the JIT | ||
| sig.token = 0; // Not used by the JIT | ||
|
|
@@ -246,7 +246,7 @@ void Get_CORINFO_SIG_INFO(TypeDesc[] locals, out CORINFO_SIG_INFO sig) | |
| sig.token = 0; // Not used by the JIT | ||
| } | ||
|
|
||
| CorInfoType asCorInfoType(TypeDesc type, out CORINFO_CLASS_STRUCT_* structType) | ||
| CorInfoType asCorInfoType(TypeDesc type) | ||
| { | ||
| if (type.IsEnum) | ||
| { | ||
|
|
@@ -258,20 +258,29 @@ CorInfoType asCorInfoType(TypeDesc type, out CORINFO_CLASS_STRUCT_* structType) | |
| Debug.Assert((CorInfoType)TypeFlags.Void == CorInfoType.CORINFO_TYPE_VOID); | ||
| Debug.Assert((CorInfoType)TypeFlags.Double == CorInfoType.CORINFO_TYPE_DOUBLE); | ||
|
|
||
| structType = null; | ||
| return (CorInfoType)type.Category; | ||
| } | ||
|
|
||
| if (type.IsByRef) | ||
| { | ||
| return CorInfoType.CORINFO_TYPE_BYREF; | ||
| } | ||
|
|
||
| if (type.IsValueType) | ||
| { | ||
| structType = ObjectToHandle(type); | ||
| return CorInfoType.CORINFO_TYPE_VALUECLASS; | ||
| } | ||
|
|
||
| structType = null; | ||
| return CorInfoType.CORINFO_TYPE_CLASS; | ||
| } | ||
|
|
||
| CorInfoType asCorInfoType(TypeDesc type, out CORINFO_CLASS_STRUCT_* structType) | ||
| { | ||
| var corInfoType = asCorInfoType(type); | ||
| structType = (corInfoType == CorInfoType.CORINFO_TYPE_VALUECLASS) ? ObjectToHandle(type) : null; | ||
| return corInfoType; | ||
| } | ||
|
|
||
| uint getMethodAttribsInternal(MethodDesc method) | ||
| { | ||
| CorInfoFlag result = 0; | ||
|
|
@@ -501,8 +510,12 @@ bool isValidStringRef(IntPtr _this, CORINFO_MODULE_STRUCT_* module, uint metaTOK | |
| [return: MarshalAs(UnmanagedType.Bool)] | ||
| bool shouldEnforceCallvirtRestriction(IntPtr _this, CORINFO_MODULE_STRUCT_* scope) | ||
| { throw new NotImplementedException(); } | ||
|
|
||
| CorInfoType asCorInfoType(IntPtr _this, CORINFO_CLASS_STRUCT_* cls) | ||
| { throw new NotImplementedException(); } | ||
| { | ||
| var type = HandleToObject(cls); | ||
| return asCorInfoType(type); | ||
| } | ||
|
|
||
| byte* getClassName(IntPtr _this, CORINFO_CLASS_STRUCT_* cls) | ||
| { | ||
|
|
@@ -598,14 +611,7 @@ void LongLifetimeFree(IntPtr _this, void* obj) | |
| uint getClassSize(IntPtr _this, CORINFO_CLASS_STRUCT_* cls) | ||
| { | ||
| TypeDesc type = HandleToObject(cls); | ||
| if (type.IsValueType) | ||
| { | ||
| return (uint)((MetadataType)type).InstanceFieldSize; | ||
| } | ||
| else | ||
| { | ||
| return (uint)type.Context.Target.PointerSize; | ||
| } | ||
| return (uint)type.GetElementSize(); | ||
| } | ||
|
|
||
| uint getClassAlignmentRequirement(IntPtr _this, CORINFO_CLASS_STRUCT_* cls, [MarshalAs(UnmanagedType.Bool)]bool fDoubleAlignHint) | ||
|
|
@@ -704,6 +710,16 @@ void getReadyToRunHelper(IntPtr _this, ref CORINFO_RESOLVED_TOKEN pResolvedToken | |
| pLookup.addr = (void*)ObjectToHandle(_compilation.GetReadyToRunHelper(ReadyToRunHelperId.NewHelper, type)); | ||
| } | ||
| break; | ||
| case CorInfoHelpFunc.CORINFO_HELP_READYTORUN_NEWARR_1: | ||
| { | ||
| var type = HandleToObject(pResolvedToken.hClass); | ||
| var arrayType = type.Context.GetArrayType(type); | ||
| _compilation.AddType(arrayType); | ||
| _compilation.MarkAsConstructed(arrayType); | ||
|
|
||
| pLookup.addr = (void*)ObjectToHandle(_compilation.GetReadyToRunHelper(ReadyToRunHelperId.NewArr1, arrayType)); | ||
| } | ||
| break; | ||
| case CorInfoHelpFunc.CORINFO_HELP_READYTORUN_ISINSTANCEOF: | ||
| { | ||
| var type = HandleToObject(pResolvedToken.hClass); | ||
|
|
@@ -740,8 +756,12 @@ void classMustBeLoadedBeforeCodeIsRun(IntPtr _this, CORINFO_CLASS_STRUCT_* cls) | |
|
|
||
| CORINFO_CLASS_STRUCT_* getBuiltinClass(IntPtr _this, CorInfoClassId classId) | ||
| { throw new NotImplementedException(); } | ||
|
|
||
| CorInfoType getTypeForPrimitiveValueClass(IntPtr _this, CORINFO_CLASS_STRUCT_* cls) | ||
| { throw new NotImplementedException(); } | ||
| { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should just do: Implement a new asCorInfoType method - copy the existing asCorInfoType method with two arguments, delete the second out argument and all places where it is assigned to. (The complex implementation from desktop/CoreCLR is not needed here because of we are not going to have the weird handling of struct as primitives that x86 JIT has.)
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I considered this first, but I felt this wasn't accurately emulating the Desktop. I see why now.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also I noticed post your comment, that I left uninitialized null for Byref case originally. |
||
| return asCorInfoType(HandleToObject(cls)); | ||
| } | ||
|
|
||
| [return: MarshalAs(UnmanagedType.Bool)] | ||
| bool canCast(IntPtr _this, CORINFO_CLASS_STRUCT_* child, CORINFO_CLASS_STRUCT_* parent) | ||
| { throw new NotImplementedException(); } | ||
|
|
@@ -1036,7 +1056,15 @@ uint getThreadTLSIndex(IntPtr _this, ref void* ppIndirection) | |
| SIZE_T* getAddrModuleDomainID(IntPtr _this, CORINFO_MODULE_STRUCT_* module) | ||
| { throw new NotImplementedException(); } | ||
| void* getHelperFtn(IntPtr _this, CorInfoHelpFunc ftnNum, ref void* ppIndirection) | ||
| { throw new NotImplementedException(); } | ||
| { | ||
| switch (ftnNum) | ||
| { | ||
| case CorInfoHelpFunc.CORINFO_HELP_RNGCHKFAIL: | ||
| return (void*)ObjectToHandle(_compilation.GetJitHelper(JitHelperId.RngChkFail)); | ||
| default: | ||
| throw new NotImplementedException(); | ||
| } | ||
| } | ||
| void getFunctionEntryPoint(IntPtr _this, CORINFO_METHOD_STRUCT_* ftn, ref CORINFO_CONST_LOOKUP pResult, CORINFO_ACCESS_FLAGS accessFlags) | ||
| { throw new NotImplementedException(); } | ||
| void getFunctionFixedEntryPoint(IntPtr _this, CORINFO_METHOD_STRUCT_* ftn, ref CORINFO_CONST_LOOKUP pResult) | ||
|
|
||
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 please also update the order of arguments in ILToNative\src\CppCodeGen\ILToCppImporter.cs
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.
Done, thanks!