Merge pull request #5303 from lambdageek/cattr-bcheck
authorAleksey Kliger (λgeek) <akliger@gmail.com>
Fri, 4 Aug 2017 16:29:19 +0000 (12:29 -0400)
committerGitHub <noreply@github.com>
Fri, 4 Aug 2017 16:29:19 +0000 (12:29 -0400)
[custom_attrs] Add bounds checking to custom attribute parsing

35 files changed:
CODEOWNERS
external/ikdasm
mcs/class/System/Mono.Btls/X509CertificateImplBtls.cs
mcs/class/corlib/System.Reflection.Emit/GenericTypeParameterBuilder.cs
mcs/class/corlib/System/Delegate.cs
mcs/class/corlib/Test/System.Reflection.Emit/GenericTypeParameterBuilderTest.cs
mcs/mcs/anonymous.cs
mcs/mcs/convert.cs
mcs/mcs/ecore.cs
mcs/mcs/expression.cs
mcs/mcs/pending.cs
mcs/tests/test-947.cs [new file with mode: 0644]
mcs/tests/test-pattern-08.cs [new file with mode: 0644]
mcs/tests/test-pattern-09.cs [new file with mode: 0644]
mcs/tests/ver-il-net_4_x.xml
mcs/tools/mono-api-html/MemberComparer.cs
mono/btls/CMakeLists.txt
mono/metadata/Makefile.am
mono/metadata/class-internals.h
mono/metadata/metadata-cross-helpers.c
mono/metadata/metadata.c
mono/metadata/object-offsets.h
mono/metadata/profiler-legacy.c [deleted file]
mono/metadata/profiler-private.h
mono/metadata/profiler.c
mono/mini/aot-runtime.c
mono/mini/mini-profiler.c
mono/mini/mini-runtime.c
mono/tests/Makefile.am
msvc/libmonoruntime.vcxproj
msvc/libmonoruntime.vcxproj.filters
msvc/mono.def
msvc/monosgen.def
tools/nuget-hash-extractor/nuget-hash-extractor.cs
tools/offsets-tool/MonoAotOffsetsDumper.cs

index 4a0ef8ae08148a62b958c1d4174838ad14bf1b84..2436953d1e84d39550b60aaf53db2f7d3a1aaef4 100644 (file)
@@ -26,20 +26,32 @@ mcs/errors @marek-safar
 mcs/mcs @marek-safar
 mcs/tests @marek-safar
 mcs/class/corlib/System.Reflection*/ @vargaz @lambdageek
+mcs/class/Mono.Btls.Interface @baulig
+mcs/class/Mono.Data.Tds @egorbo
 mcs/class/Mono.Debugger.Soft @vargaz
 mcs/class/Mono.Options @jonpryor
 mcs/class/Mono.Profiler.Log @alexrp
-mono/metadata/profiler* @alexrp
+mcs/class/Mono.Security/Mono.Security/Interface @baulig
+mcs/class/System/Mono.AppleTls @baulig
+mcs/class/System/Mono.Btls @baulig
+mcs/class/System/Mono.Net.Security @baulig
+mcs/class/System/Mono.Security.Interface @baulig
+mcs/class/System.Data @egorbo
+mono/metadata/*profiler* @alexrp
+mono/metadata/monitor* @brzvlad
+mono/metadata/sgen* @brzvlad
 mono/metadata/threads* @luhenry @kumpera
 mono/metadata/threadpool* @luhenry
 mono/metadata/w32* @luhenry
-mono/mini/profiler* @alexrp
+mono/mini/*profiler* @alexrp
 mono/profiler @alexrp
+mono/sgen @brzvlad
 mono/utils/atomic* @alexrp
 mono/utils/mono-hwcap* @alexrp
 mono/utils/mono-mem* @alexrp
 mono/utils/mono-threads* @luhenry @kumpera
 msvc/*profiler* @alexrp
+msvc/scripts @akoeplinger
 packaging/Windows @akoeplinger
 samples/profiler @alexrp
 samples/size @alexrp
index 1d7d43603791e0236b56d076578657bee44fef6b..3aef9cdd6013fc0620a1817f0b11d8fb90ed2e0f 160000 (submodule)
@@ -1 +1 @@
-Subproject commit 1d7d43603791e0236b56d076578657bee44fef6b
+Subproject commit 3aef9cdd6013fc0620a1817f0b11d8fb90ed2e0f
index b9c83ae438392869f42fe267116e5190ea429c35..29bfb5bbfd1afeab1d6fa49fc47521ba48804562 100644 (file)
@@ -303,6 +303,8 @@ namespace Mono.Btls
                                return PKCS8.PrivateKeyInfo.DecodeRSA (bytes);
                        }
                        set {
+                               if (nativePrivateKey != null)
+                                       nativePrivateKey.Dispose ();
                                nativePrivateKey = null;
                                FallbackImpl.PrivateKey = value;
                        }
@@ -490,6 +492,7 @@ namespace Mono.Btls
                                x509 = null;
                        }
                        if (nativePrivateKey != null) {
+                               nativePrivateKey.Dispose ();
                                nativePrivateKey = null;
                        }
                        subjectName = null;
index 30b6aac80e572f9402afd9b4403a9cf03e23c95b..9bbe8d0d92b32f73ee8976d3aa23780a54250672 100644 (file)
@@ -87,7 +87,7 @@ namespace System.Reflection.Emit
                internal override Type InternalResolve ()
                {
                        if (mbuilder != null)
-                               return MethodBase.GetMethodFromHandle (mbuilder.MethodHandleInternal).GetGenericArguments () [index];
+                               return MethodBase.GetMethodFromHandle (mbuilder.MethodHandleInternal, mbuilder.TypeBuilder.InternalResolve ().TypeHandle).GetGenericArguments () [index];
                        return tbuilder.InternalResolve ().GetGenericArguments () [index];
                }
 
index 4064ed9c90185ac0eec46c390977a61b4340a0f9..120991b2f79a9de061acadac90235eaa9d4b15fc 100644 (file)
@@ -495,8 +495,11 @@ namespace System
 
                public override int GetHashCode ()
                {
-                       /* same implementation as CoreCLR */
-                       return GetType ().GetHashCode ();
+                       MethodInfo m;
+
+                       m = Method;
+
+                       return (m != null ? m.GetHashCode () : GetType ().GetHashCode ()) ^ (m_target != null ? m_target.GetHashCode () : 0);
                }
 
                protected virtual MethodInfo GetMethodImpl ()
index 815c34c5cba9ec72421d19720eee89a0881da33c..cdad1f686bec3bbcd9355a0d4c3e17ca2cf81977 100644 (file)
@@ -353,5 +353,60 @@ namespace MonoTests.System.Reflection.Emit
 
                        Assert.AreEqual (TypeAttributes.Public, gparam.Attributes, "#1");
                }
+
+               [Test]
+               public void ActionConstructorInfoTest ()
+               {
+                       // Regression test for https://bugzilla.xamarin.com/show_bug.cgi?id=58454
+                       //
+                       // Need to check that GenericTypeParameterBuilderTest:InternalResolve() passes the declaring type to GetMethodFromHandle()
+                       //
+                       /* Want to generate:
+
+                          public class Store<TState> {
+                          public Action<TSelection> Subscribe<TSelection> (TState state) {
+                               return new Action<TSelection> (Foo<TSelection>);
+                          }
+                          public static void Foo<X> (X x) { }
+                          }
+
+                          ...  and then: new Store<string>().Subscribe<int>("x");
+                       */
+
+                       SetUp (AssemblyBuilderAccess.Run);
+
+                       var tb = module.DefineType ("Store");
+                       var tparsStore = tb.DefineGenericParameters ("TState");
+
+                       tb.DefineDefaultConstructor (MethodAttributes.Public);
+
+                       var methFoo = tb.DefineMethod ("Foo", MethodAttributes.Public | MethodAttributes.Static);
+                       var tparsFoo = methFoo.DefineGenericParameters ("X");
+                       methFoo.SetReturnType (typeof(void));
+                       methFoo.SetParameters (tparsFoo[0]);
+                       methFoo.GetILGenerator().Emit (OpCodes.Ret);
+
+                       var methSub = tb.DefineMethod ("Subscribe", MethodAttributes.Public | MethodAttributes.Static);
+                       var tparsSub = methSub.DefineGenericParameters ("TSelection");
+                       var actOfSel = typeof(Action<>).MakeGenericType (tparsSub[0]); // Action<TSelection>
+                       methSub.SetReturnType  (actOfSel);
+                       methSub.SetParameters (tparsStore[0]); // TState
+                       var ilg = methSub.GetILGenerator ();
+                       ilg.Emit (OpCodes.Ldnull); // instance == null
+                       ilg.Emit (OpCodes.Ldftn, methFoo.MakeGenericMethod (tparsSub[0])); // ldftn void class Store`1<!TState>::Foo<!!0> (!!0)
+                       var aaa = TypeBuilder.GetConstructor (actOfSel, typeof(Action<>).GetConstructors()[0]);
+                       ilg.Emit (OpCodes.Newobj, aaa); // new Action<TSelection> (Foo<TSelection>);
+                       ilg.Emit (OpCodes.Ret);
+
+                       var tgen = tb.CreateType (); // TState`1
+
+                       var t = tgen.MakeGenericType(typeof(string));
+                       var x = t.GetConstructor(Type.EmptyTypes).Invoke (null); // x = new Store<string> ()
+                       var mgen = t.GetMethod("Subscribe");
+                       var m = mgen.MakeGenericMethod (typeof (int)); // Action<int> Store<string>.Subscribe<int> (string)
+                       var y = m.Invoke (x, new object[] {"hello"}); // x.Subscribte<int> ("hello")
+                       Assert.IsNotNull (y);
+               }
+
        }
 }
index 6cec0e1da6dc57513c0af368e3ec08a8f5ac6848..3ce9b0c9f199189c703238261602f52d1acb5e33 100644 (file)
@@ -839,6 +839,11 @@ namespace Mono.CSharp {
                {
                        GetFieldExpression (ec).EmitAssign (ec, source, leave_copy, false);
                }
+
+               public void EmitAssignFromStack (EmitContext ec)
+               {
+                       GetFieldExpression (ec).EmitAssignFromStack (ec);
+               }
        }
 
        public class HoistedParameter : HoistedVariable
index a99e3fde628b60061aae8448ab3621c23a7fad9c..8fe0e2026ca5842fdc286d456bf41a536f79456b 100644 (file)
@@ -736,8 +736,6 @@ namespace Mono.CSharp {
                        var tupleLiteralElements = (source as TupleLiteral)?.Elements;
 
                        for (int i = 0; i < targetType.Arity; ++i) {
-                               var elementType = srcTypeArgument [i];
-
                                if (tupleLiteralElements != null) {
                                        if (!ImplicitStandardConversionExists (tupleLiteralElements[i].Expr, targetTypeArgument [i])) {
                                                return false;
index d15fbe5e34f6e9592987a466ff17580e9a95fbb9..7704e72b168738451687821fde3c4ddd8b26a7d9 100644 (file)
@@ -2429,7 +2429,12 @@ namespace Mono.CSharp {
 
                public override void FlowAnalysis (FlowAnalysisContext fc)
                {
-                       expr.FlowAnalysis (fc);
+                       orig_expr.FlowAnalysis (fc);
+               }
+
+               public override void FlowAnalysisConditional (FlowAnalysisContext fc)
+               {
+                       orig_expr.FlowAnalysisConditional (fc);
                }
 
                public override SLE.Expression MakeExpression (BuilderContext ctx)
index b9f47b5a361054a9b3675508668144a484c51de8..896980968d82efd168067c2664980380ecbe842c 100644 (file)
@@ -1687,8 +1687,15 @@ namespace Mono.CSharp
                                ec.Emit (OpCodes.Dup);
                                no_value_label = ec.DefineLabel ();
                                ec.Emit (OpCodes.Brfalse_S, no_value_label);
+
+                               if (Variable.HoistedVariant != null)
+                                       ec.EmitThis ();
+
                                expr_unwrap.Emit (ec);
                        } else {
+                               if (Variable?.HoistedVariant != null)
+                                       ec.EmitThis ();
+
                                expr.Emit (ec);
 
                                // Only to make verifier happy
@@ -1708,19 +1715,29 @@ namespace Mono.CSharp
                                        value_on_stack = false;
                                }
 
-                               //
-                               // It's ok to have variable builder create out of order. It simplified emit
-                               // of statements like while (condition) { }
-                               //
-                               if (!Variable.Created)
-                                       Variable.CreateBuilder (ec);
-                               
-                               Variable.EmitAssign (ec);
+                               if (Variable.HoistedVariant != null) {
+                                       Variable.HoistedVariant.EmitAssignFromStack (ec);
 
-                               if (expr_unwrap != null) {
-                                       ec.MarkLabel (no_value_label);
-                               } else if (!value_on_stack) {
-                                       Variable.Emit (ec);
+                                       if (expr_unwrap != null) {
+                                               ec.MarkLabel (no_value_label);
+                                       } else if (!value_on_stack) {
+                                               Variable.HoistedVariant.Emit (ec);
+                                       }
+                               } else {
+                                       //
+                                       // It's ok to have variable builder created out of order. It simplifies emit
+                                       // of statements like while (condition) { }
+                                       //
+                                       if (!Variable.Created)
+                                               Variable.CreateBuilder (ec);
+
+                                       Variable.EmitAssign (ec);
+
+                                       if (expr_unwrap != null) {
+                                               ec.MarkLabel (no_value_label);
+                                       } else if (!value_on_stack) {
+                                               Variable.Emit (ec);
+                                       }
                                }
                        }
                }
index 507b937e2c904310786e8798ee2196d2ef52dcb2..1de765fb4ac041eb7926c501e0aeb235c98579ad 100644 (file)
@@ -545,12 +545,15 @@ namespace Mono.CSharp {
 
                                if (new_implementation) {
                                        MemberFilter filter;
-                                       if (mi.Parameters.Count > 1) {
-                                               var indexer_params = mi.Name [0] == 'g' ? mi.Parameters : IndexerSpec.CreateParametersFromSetter (mi, mi.Parameters.Count - 1);
-                                               filter = new MemberFilter (MemberCache.IndexerNameAlias, 0, MemberKind.Indexer, indexer_params, null);
+                                       bool getter = mi.Name [0] == 'g';
+                                       if (mi.Parameters.Count > (getter ? 0 : 1)) {
+                                               var indexer_params = getter ? mi.Parameters : IndexerSpec.CreateParametersFromSetter (mi, mi.Parameters.Count - 1);
+                                               var ptype = getter ? mi.ReturnType : mi.Parameters.Types [mi.Parameters.Count - 1];
+                                               filter = new MemberFilter (MemberCache.IndexerNameAlias, 0, MemberKind.Indexer, indexer_params, ptype);
                                        } else {
                                                var pname = mi.Name.Substring (4);
-                                               filter = MemberFilter.Property (pname, null);
+                                               var ptype = getter ? mi.ReturnType : mi.Parameters.Types [0];
+                                               filter = MemberFilter.Property (pname, ptype);
                                        }
 
                                        var prop = MemberCache.FindMember (container.CurrentType, filter, BindingRestriction.DeclaredOnly | BindingRestriction.InstanceOnly);
diff --git a/mcs/tests/test-947.cs b/mcs/tests/test-947.cs
new file mode 100644 (file)
index 0000000..f2f8cbb
--- /dev/null
@@ -0,0 +1,29 @@
+interface IA
+{
+       int Prop { get; }
+       int this [int arg] { get; }
+}
+
+abstract class B : IA
+{
+    public long Prop => 4;
+
+       int IA.Prop => 1;
+
+       public long this [int arg] => 2;
+
+       int IA.this [int arg] => 4;
+}
+
+class C : B, IA
+{
+       public static void Main ()
+       {
+       }
+
+       public new string Prop {
+               get { return ""; }
+       }
+
+       public new string this [int arg] => "2";
+}
\ No newline at end of file
diff --git a/mcs/tests/test-pattern-08.cs b/mcs/tests/test-pattern-08.cs
new file mode 100644 (file)
index 0000000..22b7621
--- /dev/null
@@ -0,0 +1,32 @@
+using System.Collections.Generic;
+
+class Expr
+{
+       public int Field;
+       public Expr Next;
+}
+
+static class X
+{
+       public static IEnumerable<int> Test (this Expr expr)
+       {
+               var exprCur = expr;
+               while (exprCur != null)
+               {
+                       if (exprCur is Expr list)
+                       {
+                               yield return list.Field;
+                               exprCur = list.Next;
+                       }
+                       else
+                       {
+                               yield return 2;
+                               yield break;
+                       }
+               }
+       }
+
+       public static void Main ()
+       {
+       }
+}
\ No newline at end of file
diff --git a/mcs/tests/test-pattern-09.cs b/mcs/tests/test-pattern-09.cs
new file mode 100644 (file)
index 0000000..801469e
--- /dev/null
@@ -0,0 +1,33 @@
+using System.Collections.Generic;
+
+class Expr
+{
+       public int Field;
+}
+
+static class X
+{
+       public static IEnumerable<int> Test (Expr expr)
+       {
+               object exprCur = expr;
+               if (exprCur is Expr list) {
+                       yield return list.Field;
+               }
+       }
+
+       public static IEnumerable<string> Test2 (int? expr)
+       {
+               int? exprCur = expr;
+               while (exprCur != null) {
+                       if (exprCur is int list) {
+                               yield return list.ToString ();
+                       }
+               }
+       }       
+
+       public static void Main ()
+       {
+               Test (null);
+               Test2 (3);
+       }
+}
\ No newline at end of file
index 221283df2e4e6f62662a6dcc4d17c30a2e5428bc..eae0f275f16d50e0c382d004bd08313a90350adb 100644 (file)
       </method>
     </type>
   </test>
+  <test name="test-947.cs">
+    <type name="B">
+      <method name="Int64 get_Prop()" attrs="2182">
+        <size>10</size>
+      </method>
+      <method name="Int32 IA.get_Prop()" attrs="2529">
+        <size>9</size>
+      </method>
+      <method name="Int64 get_Item(Int32)" attrs="2182">
+        <size>10</size>
+      </method>
+      <method name="Int32 IA.get_Item(Int32)" attrs="2529">
+        <size>9</size>
+      </method>
+      <method name="Void .ctor()" attrs="6276">
+        <size>7</size>
+      </method>
+    </type>
+    <type name="C">
+      <method name="Void Main()" attrs="150">
+        <size>2</size>
+      </method>
+      <method name="System.String get_Prop()" attrs="2182">
+        <size>14</size>
+      </method>
+      <method name="System.String get_Item(Int32)" attrs="2182">
+        <size>13</size>
+      </method>
+      <method name="Void .ctor()" attrs="6278">
+        <size>7</size>
+      </method>
+    </type>
+  </test>
   <test name="test-95.cs">
     <type name="X">
       <method name="Int32 Main()" attrs="150">
       </method>
     </type>
   </test>
+  <test name="test-pattern-08.cs">
+    <type name="Expr">
+      <method name="Void .ctor()" attrs="6278">
+        <size>7</size>
+      </method>
+    </type>
+    <type name="X">
+      <method name="System.Collections.Generic.IEnumerable`1[System.Int32] Test(Expr)" attrs="150">
+        <size>30</size>
+      </method>
+      <method name="Void Main()" attrs="150">
+        <size>2</size>
+      </method>
+    </type>
+    <type name="X+&lt;Test&gt;c__Iterator0">
+      <method name="Boolean MoveNext()" attrs="486">
+        <size>184</size>
+      </method>
+      <method name="Int32 System.Collections.Generic.IEnumerator&lt;int&gt;.get_Current()" attrs="2529">
+        <size>14</size>
+      </method>
+      <method name="System.Object System.Collections.IEnumerator.get_Current()" attrs="2529">
+        <size>19</size>
+      </method>
+      <method name="Void Dispose()" attrs="486">
+        <size>15</size>
+      </method>
+      <method name="Void Reset()" attrs="486">
+        <size>6</size>
+      </method>
+      <method name="System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()" attrs="481">
+        <size>14</size>
+      </method>
+      <method name="System.Collections.Generic.IEnumerator`1[System.Int32] System.Collections.Generic.IEnumerable&lt;int&gt;.GetEnumerator()" attrs="481">
+        <size>40</size>
+      </method>
+      <method name="Void .ctor()" attrs="6278">
+        <size>7</size>
+      </method>
+    </type>
+  </test>
+  <test name="test-pattern-09.cs">
+    <type name="Expr">
+      <method name="Void .ctor()" attrs="6278">
+        <size>7</size>
+      </method>
+    </type>
+    <type name="X">
+      <method name="System.Collections.Generic.IEnumerable`1[System.Int32] Test(Expr)" attrs="150">
+        <size>30</size>
+      </method>
+      <method name="System.Collections.Generic.IEnumerable`1[System.String] Test2(System.Nullable`1[System.Int32])" attrs="150">
+        <size>30</size>
+      </method>
+      <method name="Void Main()" attrs="150">
+        <size>21</size>
+      </method>
+    </type>
+    <type name="X+&lt;Test&gt;c__Iterator0">
+      <method name="Boolean MoveNext()" attrs="486">
+        <size>124</size>
+      </method>
+      <method name="Int32 System.Collections.Generic.IEnumerator&lt;int&gt;.get_Current()" attrs="2529">
+        <size>14</size>
+      </method>
+      <method name="System.Object System.Collections.IEnumerator.get_Current()" attrs="2529">
+        <size>19</size>
+      </method>
+      <method name="Void Dispose()" attrs="486">
+        <size>15</size>
+      </method>
+      <method name="Void Reset()" attrs="486">
+        <size>6</size>
+      </method>
+      <method name="System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()" attrs="481">
+        <size>14</size>
+      </method>
+      <method name="System.Collections.Generic.IEnumerator`1[System.Int32] System.Collections.Generic.IEnumerable&lt;int&gt;.GetEnumerator()" attrs="481">
+        <size>40</size>
+      </method>
+      <method name="Void .ctor()" attrs="6278">
+        <size>7</size>
+      </method>
+    </type>
+    <type name="X+&lt;Test2&gt;c__Iterator1">
+      <method name="Boolean MoveNext()" attrs="486">
+        <size>161</size>
+      </method>
+      <method name="System.String System.Collections.Generic.IEnumerator&lt;string&gt;.get_Current()" attrs="2529">
+        <size>14</size>
+      </method>
+      <method name="System.Object System.Collections.IEnumerator.get_Current()" attrs="2529">
+        <size>14</size>
+      </method>
+      <method name="Void Dispose()" attrs="486">
+        <size>15</size>
+      </method>
+      <method name="Void Reset()" attrs="486">
+        <size>6</size>
+      </method>
+      <method name="System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()" attrs="481">
+        <size>14</size>
+      </method>
+      <method name="System.Collections.Generic.IEnumerator`1[System.String] System.Collections.Generic.IEnumerable&lt;string&gt;.GetEnumerator()" attrs="481">
+        <size>40</size>
+      </method>
+      <method name="Void .ctor()" attrs="6278">
+        <size>7</size>
+      </method>
+    </type>
+  </test>
   <test name="test-pragma-unrecognized.cs">
     <type name="C">
       <method name="Void Main()" attrs="150">
index 2acb5ca3f5ac98c5c743ea4235ce938a46b4ecb9..72eed73390fec879e2d77b51835d648ec50c38d3 100644 (file)
@@ -374,7 +374,7 @@ namespace Xamarin.ApiDiff {
                                                change.Append (paramSourceType);
                                        }
                                        change.Append (" ");
-                                       if (paramSourceName != paramTargetName) {
+                                       if (!State.IgnoreParameterNameChanges && paramSourceName != paramTargetName) {
                                                change.AppendModified (paramSourceName, paramTargetName, true);
                                        } else {
                                                change.Append (paramSourceName);
@@ -404,12 +404,6 @@ namespace Xamarin.ApiDiff {
                        }
 
                        change.Append (")");
-
-                       // Ignore any parameter name changes if requested.
-                       if (State.IgnoreParameterNameChanges && !change.Breaking) {
-                               change.AnyChange = false;
-                               change.HasIgnoredChanges = true;
-                       }
                }
 
                void RenderVTable (MethodAttributes source, MethodAttributes target, ApiChange change)
index 9f2365d3e50df411bb759a763f70a8b1f4cd038c..d33038d75cfe1fd42710c04b2c560491f96a1925 100644 (file)
@@ -31,7 +31,10 @@ set (CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} ${BTLS_CFLAGS}")
 set (CMAKE_MACOSX_RPATH 1)
 set (MONO_BTLS 1)
 
+set(BUILD_SHARED_LIBS_SAVED "${BUILD_SHARED_LIBS}")
+set(BUILD_SHARED_LIBS OFF)
 add_subdirectory (${BTLS_ROOT} boringssl)
+set(BUILD_SHARED_LIBS "${BUILD_SHARED_LIBS_SAVED}")
 
 include_directories (
        ${SRC_DIR}
index 76abb73aaa7ac4e1350685934fd0e3b9b8baf009..d90f9200ab0417b4178689dd293208d5e47ace00 100644 (file)
@@ -224,7 +224,6 @@ common_sources = \
        w32process-internals.h          \
        profiler.c              \
        profiler-events.h       \
-       profiler-legacy.c       \
        profiler-private.h      \
        rand.h                  \
        rand.c                  \
index 39061bd142a1ec1e5411aaee98f7848babe99d1b..ef8127e14a4ab94e43f545d5eea84ef80f660039 100644 (file)
@@ -492,7 +492,7 @@ struct MonoVTable {
  */
 struct _MonoGenericInst {
 #ifndef MONO_SMALL_CONFIG
-       guint id;                       /* unique ID for debugging */
+       gint32 id;                      /* unique ID for debugging */
 #endif
        guint type_argc    : 22;        /* number of type arguments */
        guint is_open      :  1;        /* if this is an open type */
index 9d0f3afcc99566b1e7a677c7ca6eb719697cd054..119da77be3d79ea710a4b18889cf41eabe3d1dec 100644 (file)
@@ -9,6 +9,7 @@
 
 #include <mono/metadata/class-internals.h>
 #include <mono/metadata/object-internals.h>
+#include <mono/metadata/profiler-private.h>
 #include <mono/metadata/monitor.h>
 #include <mono/metadata/handle.h>
 #ifdef HAVE_SGEN_GC
index 75e9b4aa66ba8abe41b28ffa40af28fdaf88aec1..b41dbf4e8186eff36f490f2a4d4844b032c73295 100644 (file)
@@ -1522,7 +1522,7 @@ builtin_types[] = {
 #define NBUILTIN_TYPES() (sizeof (builtin_types) / sizeof (builtin_types [0]))
 
 static GHashTable *type_cache = NULL;
-static int next_generic_inst_id = 0;
+static gint32 next_generic_inst_id = 0;
 
 /* Protected by image_sets_mutex */
 static MonoImageSet *mscorlib_image_set;
@@ -3160,7 +3160,7 @@ mono_metadata_get_canonical_generic_inst (MonoGenericInst *candidate)
                int size = MONO_SIZEOF_GENERIC_INST + type_argc * sizeof (MonoType *);
                ginst = (MonoGenericInst *)mono_image_set_alloc0 (set, size);
 #ifndef MONO_SMALL_CONFIG
-               ginst->id = ++next_generic_inst_id;
+               ginst->id = InterlockedIncrement (&next_generic_inst_id);
 #endif
                ginst->is_open = is_open;
                ginst->type_argc = type_argc;
index 9f2fa37e04e5c1a7edf0e51ddadc83e6ca9ba57d..a939ca88bf9eb681aa9b634c887ec11d73d77ced 100644 (file)
@@ -141,6 +141,8 @@ DECL_OFFSET(MonoTypedRef, value)
 DECL_OFFSET(MonoThreadsSync, status)
 DECL_OFFSET(MonoThreadsSync, nest)
 
+DECL_OFFSET(MonoProfilerCallContext, method)
+
 #ifdef HAVE_SGEN_GC
 DECL_OFFSET(SgenClientThreadInfo, in_critical_region)
 DECL_OFFSET(SgenThreadInfo, tlab_next)
diff --git a/mono/metadata/profiler-legacy.c b/mono/metadata/profiler-legacy.c
deleted file mode 100644 (file)
index 31ddd48..0000000
+++ /dev/null
@@ -1,138 +0,0 @@
-/*
- * Licensed to the .NET Foundation under one or more agreements.
- * The .NET Foundation licenses this file to you under the MIT license.
- * See the LICENSE file in the project root for more information.
- */
-
-#include <mono/metadata/profiler-private.h>
-
-/*
- * The point of this file is to maintain compatibility with a few profiler API
- * functions used by Xamarin.{Android,iOS,Mac} so that they keep working
- * regardless of which system Mono version is used.
- *
- * TODO: Remove this some day if we're OK with breaking compatibility.
- */
-
-typedef void *MonoLegacyProfiler;
-
-typedef void (*MonoProfileFunc) (MonoLegacyProfiler *prof);
-typedef void (*MonoProfileThreadFunc) (MonoLegacyProfiler *prof, uintptr_t tid);
-typedef void (*MonoProfileGCFunc) (MonoLegacyProfiler *prof, MonoProfilerGCEvent event, int generation);
-typedef void (*MonoProfileGCResizeFunc) (MonoLegacyProfiler *prof, int64_t new_size);
-typedef void (*MonoProfileJitResult) (MonoLegacyProfiler *prof, MonoMethod *method, MonoJitInfo *jinfo, int result);
-
-struct _MonoProfiler {
-       MonoProfilerHandle handle;
-       MonoLegacyProfiler *profiler;
-       MonoProfileFunc shutdown_callback;
-       MonoProfileThreadFunc thread_start, thread_end;
-       MonoProfileGCFunc gc_event;
-       MonoProfileGCResizeFunc gc_heap_resize;
-       MonoProfileJitResult jit_end2;
-};
-
-static MonoProfiler *current;
-
-MONO_API void mono_profiler_install (MonoLegacyProfiler *prof, MonoProfileFunc callback);
-MONO_API void mono_profiler_install_thread (MonoProfileThreadFunc start, MonoProfileThreadFunc end);
-MONO_API void mono_profiler_install_gc (MonoProfileGCFunc callback, MonoProfileGCResizeFunc heap_resize_callback);
-MONO_API void mono_profiler_install_jit_end (MonoProfileJitResult end);
-MONO_API void mono_profiler_set_events (int flags);
-
-static void
-shutdown_cb (MonoProfiler *prof)
-{
-       prof->shutdown_callback (prof->profiler);
-}
-
-void
-mono_profiler_install (MonoLegacyProfiler *prof, MonoProfileFunc callback)
-{
-       current = g_new0 (MonoProfiler, 1);
-       current->handle = mono_profiler_create (current);
-       current->profiler = prof;
-       current->shutdown_callback = callback;
-
-       if (callback)
-               mono_profiler_set_runtime_shutdown_end_callback (current->handle, shutdown_cb);
-}
-
-static void
-thread_start_cb (MonoProfiler *prof, uintptr_t tid)
-{
-       prof->thread_start (prof->profiler, tid);
-}
-
-static void
-thread_stop_cb (MonoProfiler *prof, uintptr_t tid)
-{
-       prof->thread_end (prof->profiler, tid);
-}
-
-void
-mono_profiler_install_thread (MonoProfileThreadFunc start, MonoProfileThreadFunc end)
-{
-       current->thread_start = start;
-       current->thread_end = end;
-
-       if (start)
-               mono_profiler_set_thread_started_callback (current->handle, thread_start_cb);
-
-       if (end)
-               mono_profiler_set_thread_stopped_callback (current->handle, thread_stop_cb);
-}
-
-static void
-gc_event_cb (MonoProfiler *prof, MonoProfilerGCEvent event, uint32_t generation)
-{
-       prof->gc_event (prof->profiler, event, generation);
-}
-
-static void
-gc_resize_cb (MonoProfiler *prof, uintptr_t size)
-{
-       prof->gc_heap_resize (prof->profiler, size);
-}
-
-void
-mono_profiler_install_gc (MonoProfileGCFunc callback, MonoProfileGCResizeFunc heap_resize_callback)
-{
-       current->gc_event = callback;
-       current->gc_heap_resize = heap_resize_callback;
-
-       if (callback)
-               mono_profiler_set_gc_event_callback (current->handle, gc_event_cb);
-
-       if (heap_resize_callback)
-               mono_profiler_set_gc_resize_callback (current->handle, gc_resize_cb);
-}
-
-static void
-jit_done_cb (MonoProfiler *prof, MonoMethod *method, MonoJitInfo *jinfo)
-{
-       prof->jit_end2 (prof->profiler, method, jinfo, 0);
-}
-
-static void
-jit_failed_cb (MonoProfiler *prof, MonoMethod *method)
-{
-       prof->jit_end2 (prof->profiler, method, NULL, 1);
-}
-
-void
-mono_profiler_install_jit_end (MonoProfileJitResult end)
-{
-       current->jit_end2 = end;
-
-       if (end) {
-               mono_profiler_set_jit_done_callback (current->handle, jit_done_cb);
-               mono_profiler_set_jit_failed_callback (current->handle, jit_failed_cb);
-       }
-}
-
-void
-mono_profiler_set_events (int flags)
-{
-       /* Do nothing. */
-}
index 38e353b5b35b30f08789a6804df6fff176775f5e..293c2bd05e974436c41b8987c85a7c585485a11b 100644 (file)
@@ -63,7 +63,7 @@ typedef struct {
        gpointer (*context_get_argument) (MonoProfilerCallContext *, guint32);
        gpointer (*context_get_local) (MonoProfilerCallContext *, guint32);
        gpointer (*context_get_result) (MonoProfilerCallContext *);
-       gpointer (*context_free_buffer) (gpointer);
+       void (*context_free_buffer) (gpointer);
 
 #define _MONO_PROFILER_EVENT(name) \
        volatile gint32 name ## _count;
index 36b864a60e1284849cb371d681efda1aa37b4421..fa3f4eec9d1a6dfff683034165b8f94baaaba0b8 100644 (file)
@@ -567,3 +567,134 @@ update_callback (volatile gpointer *location, gpointer new_, volatile gint32 *co
 #undef MONO_PROFILER_EVENT_3
 #undef MONO_PROFILER_EVENT_4
 #undef _MONO_PROFILER_EVENT
+
+/*
+ * The following code is here to maintain compatibility with a few profiler API
+ * functions used by Xamarin.{Android,iOS,Mac} so that they keep working
+ * regardless of which system Mono version is used.
+ *
+ * TODO: Remove this some day if we're OK with breaking compatibility.
+ */
+
+typedef void *MonoLegacyProfiler;
+
+typedef void (*MonoLegacyProfileFunc) (MonoLegacyProfiler *prof);
+typedef void (*MonoLegacyProfileThreadFunc) (MonoLegacyProfiler *prof, uintptr_t tid);
+typedef void (*MonoLegacyProfileGCFunc) (MonoLegacyProfiler *prof, MonoProfilerGCEvent event, int generation);
+typedef void (*MonoLegacyProfileGCResizeFunc) (MonoLegacyProfiler *prof, int64_t new_size);
+typedef void (*MonoLegacyProfileJitResult) (MonoLegacyProfiler *prof, MonoMethod *method, MonoJitInfo *jinfo, int result);
+
+struct _MonoProfiler {
+       MonoProfilerHandle handle;
+       MonoLegacyProfiler *profiler;
+       MonoLegacyProfileFunc shutdown_callback;
+       MonoLegacyProfileThreadFunc thread_start, thread_end;
+       MonoLegacyProfileGCFunc gc_event;
+       MonoLegacyProfileGCResizeFunc gc_heap_resize;
+       MonoLegacyProfileJitResult jit_end2;
+};
+
+static MonoProfiler *current;
+
+MONO_API void mono_profiler_install (MonoLegacyProfiler *prof, MonoLegacyProfileFunc callback);
+MONO_API void mono_profiler_install_thread (MonoLegacyProfileThreadFunc start, MonoLegacyProfileThreadFunc end);
+MONO_API void mono_profiler_install_gc (MonoLegacyProfileGCFunc callback, MonoLegacyProfileGCResizeFunc heap_resize_callback);
+MONO_API void mono_profiler_install_jit_end (MonoLegacyProfileJitResult end);
+MONO_API void mono_profiler_set_events (int flags);
+
+static void
+shutdown_cb (MonoProfiler *prof)
+{
+       prof->shutdown_callback (prof->profiler);
+}
+
+void
+mono_profiler_install (MonoLegacyProfiler *prof, MonoLegacyProfileFunc callback)
+{
+       current = g_new0 (MonoProfiler, 1);
+       current->handle = mono_profiler_create (current);
+       current->profiler = prof;
+       current->shutdown_callback = callback;
+
+       if (callback)
+               mono_profiler_set_runtime_shutdown_end_callback (current->handle, shutdown_cb);
+}
+
+static void
+thread_start_cb (MonoProfiler *prof, uintptr_t tid)
+{
+       prof->thread_start (prof->profiler, tid);
+}
+
+static void
+thread_stop_cb (MonoProfiler *prof, uintptr_t tid)
+{
+       prof->thread_end (prof->profiler, tid);
+}
+
+void
+mono_profiler_install_thread (MonoLegacyProfileThreadFunc start, MonoLegacyProfileThreadFunc end)
+{
+       current->thread_start = start;
+       current->thread_end = end;
+
+       if (start)
+               mono_profiler_set_thread_started_callback (current->handle, thread_start_cb);
+
+       if (end)
+               mono_profiler_set_thread_stopped_callback (current->handle, thread_stop_cb);
+}
+
+static void
+gc_event_cb (MonoProfiler *prof, MonoProfilerGCEvent event, uint32_t generation)
+{
+       prof->gc_event (prof->profiler, event, generation);
+}
+
+static void
+gc_resize_cb (MonoProfiler *prof, uintptr_t size)
+{
+       prof->gc_heap_resize (prof->profiler, size);
+}
+
+void
+mono_profiler_install_gc (MonoLegacyProfileGCFunc callback, MonoLegacyProfileGCResizeFunc heap_resize_callback)
+{
+       current->gc_event = callback;
+       current->gc_heap_resize = heap_resize_callback;
+
+       if (callback)
+               mono_profiler_set_gc_event_callback (current->handle, gc_event_cb);
+
+       if (heap_resize_callback)
+               mono_profiler_set_gc_resize_callback (current->handle, gc_resize_cb);
+}
+
+static void
+jit_done_cb (MonoProfiler *prof, MonoMethod *method, MonoJitInfo *jinfo)
+{
+       prof->jit_end2 (prof->profiler, method, jinfo, 0);
+}
+
+static void
+jit_failed_cb (MonoProfiler *prof, MonoMethod *method)
+{
+       prof->jit_end2 (prof->profiler, method, NULL, 1);
+}
+
+void
+mono_profiler_install_jit_end (MonoLegacyProfileJitResult end)
+{
+       current->jit_end2 = end;
+
+       if (end) {
+               mono_profiler_set_jit_done_callback (current->handle, jit_done_cb);
+               mono_profiler_set_jit_failed_callback (current->handle, jit_failed_cb);
+       }
+}
+
+void
+mono_profiler_set_events (int flags)
+{
+       /* Do nothing. */
+}
index 55624a6b1219b16eabdb3172e99b0a7f0e7fd426..01c2fe883933e8922c563f7ba899d0e22c4de338 100644 (file)
@@ -4634,24 +4634,6 @@ mono_aot_get_method_checked (MonoDomain *domain, MonoMethod *method, MonoError *
        return code;
 }
 
-/*
- * mono_aot_get_method:
- *
- *   Return a pointer to the AOTed native code for METHOD if it can be found,
- * NULL otherwise.
- * On platforms with function pointers, this doesn't return a function pointer.
- */
-gpointer
-mono_aot_get_method (MonoDomain *domain, MonoMethod *method)
-{
-       MonoError error;
-
-       gpointer res = mono_aot_get_method_checked (domain, method, &error);
-       /* This is external only, so its ok to raise here */
-       mono_error_raise_exception (&error); /* OK to throw, external only without a good alternative */
-       return res;
-}
-
 /**
  * Same as mono_aot_get_method, but we try to avoid loading any metadata from the
  * method.
index 3b6149d92728edccfbec18bc89fd6c087be26dd2..1e79ecc4099b661d95d670ce0f3e9a1187adf50d 100644 (file)
@@ -4,6 +4,8 @@
  * See the LICENSE file in the project root for more information.
  */
 
+#include <config.h>
+
 #include <mono/metadata/abi-details.h>
 #include <mono/metadata/mono-debug.h>
 
@@ -11,6 +13,8 @@
 #include "ir-emit.h"
 #include "mini.h"
 
+#ifndef DISABLE_JIT
+
 void
 mini_profiler_emit_instrumentation_call (MonoCompile *cfg, void *func, gboolean entry, MonoInst **ret, MonoType *rtype)
 {
@@ -64,6 +68,8 @@ mini_profiler_emit_instrumentation_call (MonoCompile *cfg, void *func, gboolean
        mono_emit_jit_icall (cfg, func, iargs);
 }
 
+#endif
+
 void
 mini_profiler_context_enable (void)
 {
index af88efa4abd17461d5d55f6a8530c57bd737542f..745ede4dea08a2ce6f4e8a3ceaf84d03e1a39fcd 100644 (file)
@@ -1735,12 +1735,6 @@ lookup_method (MonoDomain *domain, MonoMethod *method)
        return ji;
 }
 
-MonoJitInfo *
-mono_get_jit_info_from_method (MonoDomain *domain, MonoMethod *method)
-{
-       return lookup_method (domain, method);
-}
-
 MonoClass*
 mini_get_class (MonoMethod *method, guint32 token, MonoGenericContext *context)
 {
index ffdd45cb6b5e50a1872c266a24683ad37cca081f..e93fb7de81fe72e9473bece369a46c8fbe661770 100755 (executable)
@@ -894,6 +894,7 @@ CI_PR_DISABLED_TESTS = \
 
 # appdomain-threadpool-unload.exe creates 100 appdomains, takes too long with llvm
 LLVM_DISABLED_TESTS = \
+       finally_block_ending_in_dead_bb.exe \
        appdomain-threadpool-unload.exe
 
 LLVM = $(filter --llvm, $(MONO_ENV_OPTIONS))
index a5dcc676a18464f773cdbdf0910a7009c1ed4d68..d2e5ad512cd78a353af0e1e05eb4308b9bd287b6 100644 (file)
@@ -82,7 +82,6 @@
     <ClCompile Include="..\mono\metadata\number-ms.c" />\r
     <ClCompile Include="..\mono\metadata\object.c" />\r
     <ClCompile Include="..\mono\metadata\opcodes.c" />\r
-    <ClCompile Include="..\mono\metadata\profiler-legacy.c" />\r
     <ClCompile Include="..\mono\metadata\profiler.c" />\r
     <ClCompile Include="..\mono\metadata\rand.c" />\r
     <ClCompile Include="..\mono\metadata\reflection.c" />\r
index 1655d562e23610215c7d9f051e0bb5e99db3b582..554e61985bdb1745ac9df6d44d0c7d1423bdd6f3 100644 (file)
     <ClCompile Include="..\mono\metadata\w32process-win32.c">\r
       <Filter>Source Files</Filter>\r
     </ClCompile>\r
-    <ClCompile Include="..\mono\metadata\profiler-legacy.c">\r
-      <Filter>Source Files</Filter>\r
-    </ClCompile>\r
     <ClCompile Include="..\mono\metadata\profiler.c">\r
       <Filter>Source Files</Filter>\r
     </ClCompile>\r
index acf9e59d1b4bf8c64de4aec4425b8817984a5076..a07e7c74fd51577db19b4be0b0507adea8849c48 100644 (file)
@@ -2,7 +2,6 @@
 EXPORTS
 MonoFixupCorEE
 mono_add_internal_call
-mono_aot_get_method
 mono_aot_register_module
 mono_array_addr_with_size
 mono_array_class_get
@@ -414,7 +413,6 @@ mono_get_int16_class
 mono_get_int32_class
 mono_get_int64_class
 mono_get_intptr_class
-mono_get_jit_info_from_method
 mono_get_machine_config
 mono_get_method
 mono_get_method_constrained
index 513e2eda72ede1b1ecfbce1ade7d77bd7f090909..5e6485787c7518f6c7c6dffeca576d0927bb5f6a 100644 (file)
@@ -2,7 +2,6 @@
 EXPORTS
 MonoFixupCorEE
 mono_add_internal_call
-mono_aot_get_method
 mono_aot_register_module
 mono_array_addr_with_size
 mono_array_class_get
@@ -416,7 +415,6 @@ mono_get_int16_class
 mono_get_int32_class
 mono_get_int64_class
 mono_get_intptr_class
-mono_get_jit_info_from_method
 mono_get_machine_config
 mono_get_method
 mono_get_method_constrained
index d4e7763f5740a02535143c2f6bb1ec64dc57aad3..56e150e8676726da9ab53b2aa99d4c174a137357 100644 (file)
@@ -34,12 +34,13 @@ class Driver {
                }
        }
 
-       static bool dump_asm, dump_ver;
+       static bool dump_asm, dump_ver, dump_guids_for_msbuild;
        static void Main (string[] args) {
 
                if (args.Length > 1) {
                        dump_asm = args [1].Equals ("asm");
                        dump_ver = args [1].Equals ("ver");
+                       dump_guids_for_msbuild = args [1].Equals ("guids_for_msbuild");
                } else {
                        dump_asm = true;
                }
@@ -61,7 +62,7 @@ class Driver {
                var data = StreamToArray (entry.Open ());
                AppDomain ad = AppDomain.CreateDomain ("parse_" + ++domain_id);
                DoParse p = (DoParse)ad.CreateInstanceAndUnwrap (typeof (DoParse).Assembly.FullName, typeof (DoParse).FullName);
-               p.ParseAssembly (data, version, entry.Name, entry.FullName, dump_asm, dump_ver);
+               p.ParseAssembly (data, version, entry.Name, entry.FullName, dump_asm, dump_ver, dump_guids_for_msbuild);
                AppDomain.Unload (ad);
        }
 }
@@ -92,7 +93,7 @@ class DoParse : MarshalByRefObject {
                return parts[parts.Length - 2];
        }
 
-       public void ParseAssembly (byte[] data, string version, string name, string fullname, bool dump_asm, bool dump_ver) {
+       public void ParseAssembly (byte[] data, string version, string name, string fullname, bool dump_asm, bool dump_ver, bool dump_guids_for_msbuild) {
                var a = Assembly.ReflectionOnlyLoad (data);
                var m = a.GetModules ()[0];
                var id = m.ModuleVersionId.ToString ().ToUpper ();
@@ -106,8 +107,12 @@ class DoParse : MarshalByRefObject {
 
                //IGNORED_ASM_VER (SYS_IO_COMPRESSION, 4, 1, 2, 0),
                var ver = a.GetName ().Version;
-               if (dump_ver)
+               if (dump_ver) {
                        Console.WriteLine ($"IGNORED_ASM_VER ({str}, {ver.Major}, {ver.Minor}, {ver.Build}, {ver.Revision}),");
+               } else if (dump_guids_for_msbuild) {
+                       // This needs to be kept in sync with FilterDeniedAssemblies msbuild task in msbuild
+                       Console.WriteLine ($"{name},{id},{ver.Major},{ver.Minor},{ver.Build},{ver.Revision}");
+               }
                
        }
-}
\ No newline at end of file
+}
index 199b974559eb1b26ef3b42a5408adb544fe475ff..dc474a2e0d83fe74aa8c7892419e2a16f1880646 100644 (file)
@@ -787,7 +787,8 @@ namespace CppSharp
                 "MonoTypedRef",
                 "MonoThreadsSync",
                 "SgenThreadInfo",
-                "SgenClientThreadInfo"
+                "SgenClientThreadInfo",
+                "MonoProfilerCallContext"
             };
 
             DumpClasses(writer, ctx, types);