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
path: root/src
diff options
context:
space:
mode:
authorBlealtan <blealtan@outlook.com>2018-08-02 00:19:42 +0300
committerMorgan Brown <morganbr@users.noreply.github.com>2018-08-02 00:19:42 +0300
commit62843a047f469a44b623591be5f8681e1d111e64 (patch)
treec036b4c546edafc1886042f286e61875be15e64e /src
parentbaf3dabd49ac3adc0595ee984253b505190a86f0 (diff)
WASM: Multidimensional array instantiation fix (#6096)
* Handle multidimensional array instantiation (#5421) newobj instruction on multidimensional array is now processed with ArrayHelpers.NewObjArray. Enabled instantiating multidimensional arrays. * Add testing for multidimensional array instantiation. Only nullity and lengths are checked due to get & set not working on multidimensional arrays.
Diffstat (limited to 'src')
-rw-r--r--src/ILCompiler.WebAssembly/src/CodeGen/ILToWebAssemblyImporter.cs23
1 files changed, 22 insertions, 1 deletions
diff --git a/src/ILCompiler.WebAssembly/src/CodeGen/ILToWebAssemblyImporter.cs b/src/ILCompiler.WebAssembly/src/CodeGen/ILToWebAssemblyImporter.cs
index a4567950c..677b18eeb 100644
--- a/src/ILCompiler.WebAssembly/src/CodeGen/ILToWebAssemblyImporter.cs
+++ b/src/ILCompiler.WebAssembly/src/CodeGen/ILToWebAssemblyImporter.cs
@@ -1022,7 +1022,28 @@ namespace Internal.IL
if (opcode == ILOpcode.newobj)
{
TypeDesc newType = callee.OwningType;
- if (newType.IsString)
+ if (newType.IsArray)
+ {
+ var paramCnt = callee.Signature.Length;
+ var eeTypeDesc = _compilation.TypeSystemContext.SystemModule.GetKnownType("Internal.Runtime", "EEType").MakePointerType();
+ LLVMValueRef dimensions = LLVM.BuildArrayAlloca(_builder, LLVMTypeRef.Int32Type(), BuildConstInt32(paramCnt), "newobj_array_pdims_" + _currentOffset);
+ for (int i = paramCnt - 1; i >= 0; --i)
+ {
+ LLVM.BuildStore(_builder, _stack.Pop().ValueAsInt32(_builder, true),
+ LLVM.BuildGEP(_builder, dimensions, new LLVMValueRef[] { BuildConstInt32(i) }, "pdims_ptr"));
+ }
+ var arguments = new StackEntry[]
+ {
+ new LoadExpressionEntry(StackValueKind.ValueType, "eeType", GetEETypePointerForTypeDesc(newType, true), eeTypeDesc),
+ new Int32ConstantEntry(paramCnt),
+ new AddressExpressionEntry(StackValueKind.ValueType, "newobj_array_pdims", dimensions)
+ };
+ MetadataType helperType = _compilation.TypeSystemContext.SystemModule.GetKnownType("Internal.Runtime.CompilerHelpers", "ArrayHelpers");
+ MethodDesc helperMethod = helperType.GetKnownMethod("NewObjArray", null);
+ PushNonNull(HandleCall(helperMethod, helperMethod.Signature, arguments, forcedReturnType: newType));
+ return;
+ }
+ else if (newType.IsString)
{
// String constructors actually look like regular method calls
IMethodNode node = _compilation.NodeFactory.StringAllocator(callee);