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:
authorMorgan Brown <morganb@microsoft.com>2017-07-26 00:55:07 +0300
committerMorgan Brown <morganb@microsoft.com>2017-09-15 01:33:27 +0300
commit4076cc4c2a59cf97798d3994aacb1e60a1a61312 (patch)
tree527ce9f20cf347a129451e69cfec01c893ed5286 /src/ILCompiler.WebAssembly
parent1f7d328bf4a6559235887a78a7ecc4caee0d913a (diff)
Adds pinvoke handling (without marshaling and with the assumption that everything is statically linked). Also enables LLVM module verification output and disables data writing while it's broken
Diffstat (limited to 'src/ILCompiler.WebAssembly')
-rw-r--r--src/ILCompiler.WebAssembly/src/CodeGen/ILToWebAssemblyImporter.cs22
-rw-r--r--src/ILCompiler.WebAssembly/src/CodeGen/WebAssemblyObjectWriter.cs3
2 files changed, 19 insertions, 6 deletions
diff --git a/src/ILCompiler.WebAssembly/src/CodeGen/ILToWebAssemblyImporter.cs b/src/ILCompiler.WebAssembly/src/CodeGen/ILToWebAssemblyImporter.cs
index 5ed3cd84d..bf179d69a 100644
--- a/src/ILCompiler.WebAssembly/src/CodeGen/ILToWebAssemblyImporter.cs
+++ b/src/ILCompiler.WebAssembly/src/CodeGen/ILToWebAssemblyImporter.cs
@@ -358,7 +358,11 @@ namespace Internal.IL
return LLVM.ArrayType(LLVM.Int8Type(), (uint)type.GetElementSize().AsInt);
case TypeFlags.Enum:
- return GetLLVMTypeForTypeDesc(type.UnderlyingType);
+ return GetLLVMTypeForTypeDesc(type.UnderlyingType);
+
+ case TypeFlags.Void:
+ return LLVM.VoidType();
+
default:
throw new NotImplementedException(type.Category.ToString());
}
@@ -429,8 +433,8 @@ namespace Internal.IL
private void ImportCall(ILOpcode opcode, int token)
{
- MethodDesc method = (MethodDesc)_methodIL.GetObject(token);
- if(method.IsRawPInvoke())
+ MethodDesc callee = (MethodDesc)_methodIL.GetObject(token);
+ if (callee.IsPInvoke)
{
ImportRawPInvoke(method);
return;
@@ -448,7 +452,7 @@ namespace Internal.IL
// argument offset
uint argOffset = 0;
- for(int index=0; index< callee.Signature.Length; index++)
+ for (int index = 0; index < callee.Signature.Length; index++)
{
LLVMValueRef toStore = _stack.Pop().LLVMValue;
@@ -485,8 +489,16 @@ namespace Internal.IL
LLVM.SetLinkage(nativeFunc, LLVMLinkage.LLVMDLLImportLinkage);
}
+ LLVMValueRef[] arguments = new LLVMValueRef[method.Signature.Length];
+ for(int i = 0; i < arguments.Length; i++)
+ {
+ // Arguments are reversed on the stack
+ arguments[arguments.Length - i - 1] = _stack.Pop().LLVMValue;
+ }
+
+ var ReturnValue = LLVM.BuildCall(_builder, nativeFunc, arguments, String.Empty);
- //LLVM.BuildCall(_builder, nativeFunc)
+ // TODO: Do something with the return value
}
private void ImportCalli(int token)
diff --git a/src/ILCompiler.WebAssembly/src/CodeGen/WebAssemblyObjectWriter.cs b/src/ILCompiler.WebAssembly/src/CodeGen/WebAssemblyObjectWriter.cs
index 7d63e5c69..4aacad6a9 100644
--- a/src/ILCompiler.WebAssembly/src/CodeGen/WebAssemblyObjectWriter.cs
+++ b/src/ILCompiler.WebAssembly/src/CodeGen/WebAssemblyObjectWriter.cs
@@ -166,6 +166,7 @@ namespace ILCompiler.DependencyAnalysis
}
EmitNativeMain();
+ LLVM.VerifyModule(Module, LLVMVerifierFailureAction.LLVMPrintMessageAction, out IntPtr unused);
LLVM.WriteBitcodeToFile(Module, _objectFilePath);
LLVM.DumpModule(Module);
//throw new NotImplementedException(); // This function isn't complete
@@ -593,7 +594,7 @@ namespace ILCompiler.DependencyAnalysis
//ObjectNodeSection managedCodeSection = null;
var listOfOffsets = new List<int>();
- foreach (DependencyNode depNode in nodes)
+ foreach (DependencyNode depNode in /*nodes*/ new DependencyNode[0])
{
ObjectNode node = depNode as ObjectNode;
if (node == null)