Skip dummy null argument for string constructors under CoreRT ABI (#6498)
authorJan Kotas <jkotas@microsoft.com>
Thu, 28 Jul 2016 19:55:26 +0000 (12:55 -0700)
committerGitHub <noreply@github.com>
Thu, 28 Jul 2016 19:55:26 +0000 (12:55 -0700)
src/jit/importer.cpp

index 98f8183..aa63b8f 100644 (file)
@@ -6830,7 +6830,7 @@ var_types  Compiler::impImportCall(OPCODE                  opcode,
     //-------------------------------------------------------------------------
     // The "this" pointer
 
-    if (!(mflags & CORINFO_FLG_STATIC) || opcode == CEE_NEWOBJ)
+    if (!(mflags & CORINFO_FLG_STATIC) && !((opcode == CEE_NEWOBJ) && (newobjThis == nullptr)))
     {
         GenTreePtr obj;
 
@@ -11736,10 +11736,18 @@ DO_LDFTN:
             // At present this can only be String
             else if (clsFlags & CORINFO_FLG_VAROBJSIZE)
             {
-                // This is the case for variable-sized objects that are not
-                // arrays.  In this case, call the constructor with a null 'this'
-                // pointer
-                newObjThisPtr = gtNewIconNode(0, TYP_REF);
+                if (eeGetEEInfo()->targetAbi == CORINFO_CORERT_ABI)
+                {
+                    // The dummy argument does not exist in CoreRT
+                    newObjThisPtr = nullptr;
+                }
+                else
+                {
+                    // This is the case for variable-sized objects that are not
+                    // arrays.  In this case, call the constructor with a null 'this'
+                    // pointer
+                    newObjThisPtr = gtNewIconNode(0, TYP_REF);
+                }
 
                 /* Remember that this basic block contains 'new' of an object */
                 block->bbFlags |= BBF_HAS_NEWOBJ;