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:
authorMichal Strehovský <michals@microsoft.com>2015-10-30 03:58:31 +0300
committerMichal Strehovský <michals@microsoft.com>2015-10-30 20:38:32 +0300
commit2be2afe7406b06cb4b898714c9097db0b4d7df8b (patch)
treed9c7ef1ec6376807af040d6597d7ea2ab28c4b82 /src/JitInterface
parentcd2240562c458c97a986073e89fedf0d4022eb71 (diff)
Set of fixes that let us compile Hello World on Linux
We need a blacklist of methods that can't be passed to the JIT because we will throw from JitInterface - on Linux we can't catch the exception because it involves going across the native stack. There's also a few methods that don't throw a managed exception, but crash. The stack was pretty useless. I marked them specially on the list. I also added a miserable implementation of System V struct passing classification. Not sure how correct it is, and it definitely isn't complete. You need a protojit.so on Linux to run (yep, remove the "lib" prefix).
Diffstat (limited to 'src/JitInterface')
-rw-r--r--src/JitInterface/src/CorInfoImpl.cs48
-rw-r--r--src/JitInterface/src/CorInfoTypes.cs36
2 files changed, 66 insertions, 18 deletions
diff --git a/src/JitInterface/src/CorInfoImpl.cs b/src/JitInterface/src/CorInfoImpl.cs
index 72154bf23..88fa18057 100644
--- a/src/JitInterface/src/CorInfoImpl.cs
+++ b/src/JitInterface/src/CorInfoImpl.cs
@@ -22,14 +22,8 @@ namespace Internal.JitInterface
{
IntPtr _comp;
- [DllImport("kernel32.dll", SetLastError = true)]
- extern static IntPtr LoadLibraryEx(string s, IntPtr handle, int flags);
-
- [DllImport("kernel32.dll")]
- extern static IntPtr GetProcAddress(IntPtr handle, string s);
-
- [UnmanagedFunctionPointerAttribute(CallingConvention.StdCall)]
- delegate IntPtr _getJIT();
+ [DllImport("protojit")]
+ extern static IntPtr getJit();
IntPtr _jit;
@@ -47,15 +41,7 @@ namespace Internal.JitInterface
_comp = CreateUnmanagedInstance();
- string clrjitPath = AppContext.BaseDirectory + "\\protojit.dll";
- IntPtr jit = LoadLibraryEx(clrjitPath, new IntPtr(0), 0x1300);
-
- IntPtr proc = GetProcAddress(jit, "getJit");
- if (proc == new IntPtr(0))
- throw new Exception("JIT initialization failed");
-
- var getJIT = Marshal.GetDelegateForFunctionPointer<_getJIT>(proc);
- _jit = getJIT();
+ _jit = getJit();
_compile = Marshal.GetDelegateForFunctionPointer<_compileMethod>(**((IntPtr**)_jit));
}
@@ -1360,8 +1346,34 @@ namespace Internal.JitInterface
byte* findNameOfToken(IntPtr _this, CORINFO_MODULE_STRUCT_* moduleHandle, mdToken token, byte* szFQName, UIntPtr FQNameCapacity)
{ throw new NotImplementedException(); }
+
bool getSystemVAmd64PassStructInRegisterDescriptor(IntPtr _this, CORINFO_CLASS_STRUCT_* structHnd, SYSTEMV_AMD64_CORINFO_STRUCT_REG_PASSING_DESCRIPTOR* structPassInRegDescPtr)
- { throw new NotImplementedException(); }
+ {
+ TypeDesc type = HandleToObject(structHnd);
+
+ if (type.IsValueType)
+ {
+ // TODO: actually implement
+ // https://github.com/dotnet/corert/issues/158
+ if (type.GetElementSize() <= 8)
+ {
+ structPassInRegDescPtr->passedInRegisters = true;
+ structPassInRegDescPtr->eightByteCount = 1;
+ structPassInRegDescPtr->eightByteClassifications0 = SystemVClassificationType.SystemVClassificationTypeInteger;
+ structPassInRegDescPtr->eightByteSizes0 = (byte)type.GetElementSize();
+ structPassInRegDescPtr->eightByteOffsets0 = 0;
+ }
+ else
+ structPassInRegDescPtr->passedInRegisters = false;
+ }
+ else
+ {
+ structPassInRegDescPtr->passedInRegisters = false;
+ }
+
+ return true;
+ }
+
int getIntConfigValue(IntPtr _this, String name, int defaultValue)
{ throw new NotImplementedException(); }
short* getStringConfigValue(IntPtr _this, String name)
diff --git a/src/JitInterface/src/CorInfoTypes.cs b/src/JitInterface/src/CorInfoTypes.cs
index 4baf48779..585834816 100644
--- a/src/JitInterface/src/CorInfoTypes.cs
+++ b/src/JitInterface/src/CorInfoTypes.cs
@@ -1090,8 +1090,44 @@ namespace Internal.JitInterface
};
+ // System V struct passing
+ // The Classification types are described in the ABI spec at http://www.x86-64.org/documentation/abi.pdf
+ public enum SystemVClassificationType : byte
+ {
+ SystemVClassificationTypeUnknown = 0,
+ SystemVClassificationTypeStruct = 1,
+ SystemVClassificationTypeNoClass = 2,
+ SystemVClassificationTypeMemory = 3,
+ SystemVClassificationTypeInteger = 4,
+ SystemVClassificationTypeIntegerReference = 5,
+ SystemVClassificationTypeSSE = 6,
+ // SystemVClassificationTypeSSEUp = Unused, // Not supported by the CLR.
+ // SystemVClassificationTypeX87 = Unused, // Not supported by the CLR.
+ // SystemVClassificationTypeX87Up = Unused, // Not supported by the CLR.
+ // SystemVClassificationTypeComplexX87 = Unused, // Not supported by the CLR.
+ SystemVClassificationTypeMAX = 7,
+ };
+
public struct SYSTEMV_AMD64_CORINFO_STRUCT_REG_PASSING_DESCRIPTOR
{
+ public byte _passedInRegisters;
+ // Whether the struct is passable/passed (this includes struct returning) in registers.
+ public bool passedInRegisters { get { return _passedInRegisters != 0; } set { _passedInRegisters = value ? (byte)1 : (byte)0; } }
+
+ // Number of eightbytes for this struct.
+ public byte eightByteCount;
+
+ // The eightbytes type classification.
+ public SystemVClassificationType eightByteClassifications0;
+ public SystemVClassificationType eightByteClassifications1;
+
+ // The size of the eightbytes (an eightbyte could include padding. This represents the no padding size of the eightbyte).
+ public byte eightByteSizes0;
+ public byte eightByteSizes1;
+
+ // The start offset of the eightbytes (in bytes).
+ public byte eightByteOffsets0;
+ public byte eightByteOffsets1;
};
// DEBUGGER DATQA