Windows 32-bit x86 AOT assembler didn't compile due to incorrect symbol mangling.
# Process this file with autoconf to produce a configure script.
#AC_PREREQ([2.62])
-AC_INIT(mono, [4.5.0],
+AC_INIT(mono, [4.5.1],
[http://bugzilla.xamarin.com/enter_bug.cgi?classification=Mono])
AC_CONFIG_SRCDIR([README.md])
host_win32=yes
mono_cv_clang=no
if test "x$cross_compiling" = "xno"; then
- if test "x$host" == "x$build" -a "x$host" == "x$target"; then
+ if test "x$host" = "x$build" -a "x$host" = "x$target"; then
target_win32=yes
fi
else
- if test "x$host" == "x$target"; then
+ if test "x$host" = "x$target"; then
target_win32=yes
fi
fi
AC_ARG_ENABLE(bcl-opt, [ --disable-bcl-opt BCL is compiled with no optimizations (allows accurate BCL debugging)], test_bcl_opt=$enableval, test_bcl_opt=yes)
AC_ARG_ENABLE(perf-events, [ --enable-perf-events Enable using `perf` for profiling on Linux], test_perf_events=$enableval, test_perf_events=no)
-if test "x$test_perf_events" == "xyes"; then
+if test "x$test_perf_events" = "xyes"; then
AC_DEFINE(ENABLE_PERF_EVENTS, 1, [Enable using `perf` for profiling on Linux])
AC_SUBST(ENABLE_PERF_EVENTS)
fi
AC_MSG_CHECKING(LLVM version)
AC_MSG_RESULT($llvm_version $llvm_api_version)
if echo $llvm_version | grep -q 'mono'; then
- if test "x$enable_llvm_version_check" == "xyes"; then
+ if test "x$enable_llvm_version_check" = "xyes"; then
if test "$llvm_version" != "$expected_llvm_version"; then
AC_MSG_ERROR([Expected llvm version $expected_llvm_version, but llvm-config --version returned $llvm_version"])
fi
llvm_jit_libs=""
fi
LLVM_LIBS=`$LLVM_CONFIG --libs analysis core bitwriter $llvm_jit_libs`
- if test "x$LLVM_LIBS" == "x"; then
+ if test "x$LLVM_LIBS" = "x"; then
echo "$LLVM_CONFIG --libs failed."
exit 1
fi
AOT_SUPPORTED="yes"
CPPFLAGS="$CPPFLAGS -D__ARM_EABI__"
;;
+ arm*-netbsd*-eabi*)
+ TARGET=ARM;
+ arch_target=arm;
+ ACCESS_UNALIGNED="no"
+ CPPFLAGS="$CPPFLAGS -D__ARM_EABI__"
+ ;;
# TODO: make proper support for NaCl host.
# arm*-*nacl)
# TARGET=ARM;
;;
esac
;;
+ arm*-netbsd*-eabi*)
+ TARGET=ARM;
+ arch_target=arm;
+ AC_DEFINE(TARGET_ARM, 1, [...])
+ ACCESS_UNALIGNED="no"
+ CPPFLAGS="$CPPFLAGS -D__ARM_EABI__"
+ # Can't use tls, since it depends on the runtime detection of tls offsets
+ # in mono-compiler.h
+ with_tls=pthread
+ target_mach=no
+ ;;
i686*-linux-*)
TARGET=X86;
arch_target=x86;
GTKX11="libgtk-x11-2.0.dylib"
;;
*-*-*netbsd*)
- LIBC="libc.so.12"
- INTL="libintl.so.0"
+ LIBC="libc.so"
+ INTL="libintl.so"
+ SQLITE="libsqlite.so"
+ SQLITE3="libsqlite3.so"
;;
*-*-kfreebsd*-gnu)
LIBC="libc.so.0.1"
-Subproject commit 8c7937a9e7cc3f61f9ceb6a9d6f19fefdf1672b0
+Subproject commit 5b907267935346d2fe110d226bf3a62abcbd0dc6
.IP \[bu] 2
\f[I]sample[=TYPE[/FREQ]]\f[]: collect statistical samples of the
program behaviour.
-The default is to collect a 1000 times per second the instruction
-pointer.
-This is equivalent to the value \[lq]cycles/1000\[rq] for
+The default is to collect a 100 times per second (100 Hz) the
+instruction pointer.
+This is equivalent to the value \[lq]cycles/100\[rq] for
\f[I]TYPE\f[].
On some systems, like with recent Linux kernels, it is possible to
cause the sampling to happen for other events provided by the
collect \f[I]NUM\f[] frames at the most.
The default is 8.
.IP \[bu] 2
+\f[I]maxsamples=NUM\f[]: stop allocating reusable sample events
+once \f[I]NUM\f[] events have been allocated (a value of zero for
+all intents and purposes means unlimited). By default, the value
+of this setting is the number of CPU cores multiplied by 1000. This
+is usually a good enough value for typical desktop and mobile apps.
+If you're losing too many samples due to this default (which is
+possible in apps with an unusually high amount of threads), you
+may want to tinker with this value to find a good balance between
+sample hit rate and performance impact on the app. The way it works
+is that sample events are enqueued for reuse after they're flushed
+to the output file; if a thread gets a sampling signal but there are
+no sample events in the reuse queue and the profiler has reached the
+maximum number of sample allocations, the sample gets dropped. So a
+higher number for this setting will increase the chance that a
+thread is able to collect a sample, but also necessarily means that
+there will be more work done by the profiler. You can run Mono with
+the \f[I]--stats\f[] option to see statistics about sample events.
+.IP \[bu] 2
\f[I]calldepth=NUM\f[]: ignore method enter/leave events when the
call chain depth is bigger than NUM.
.IP \[bu] 2
thisdir = class
-# Note that Mono.Security and System.Security aren't listed.
-# We may have to add those if 'mcs' starts using them.
-basic_SUBDIRS := corlib System System.XML System Mono.Security System.Core
+basic_SUBDIRS := corlib Mono.Security System System.XML System.Core
# resgen is corlib specific so we need to wait until corlib is build
# and build it just a step before first dll needs it
build_SUBDIRS := \
corlib \
+ Mono.Security \
System \
System.XML \
- System Mono.Security \
Mono.Posix \
System.Core \
Mono.Cecil \
mobile_common_dirs := \
corlib \
+ Mono.Security \
System \
System.Core \
System.XML \
- Mono.Security \
- System \
I18N \
System.ServiceModel.Internals \
SMDiagnostics \
monotouch_runtime_dirs := \
corlib \
+ Mono.Security \
System \
System.Core \
System.XML \
xammac_4_5_dirs := \
corlib \
+ Mono.Security \
System \
Mono.Posix \
System.Core \
System.XML \
- Mono.Security \
- System \
I18N \
System.ServiceModel.Internals \
SMDiagnostics \
net_4_x_dirs := \
corlib \
+ Mono.Security \
System \
System.XML \
Mono.CompilerServices.SymbolWriter \
Mono.Posix \
System.Core \
- Mono.Security \
System.Security \
System.Configuration \
$(resgen_dir) \
Microsoft.VisualC \
WebMatrix.Data \
monodoc \
+ System.Deployment \
+ System.Web.Mobile \
+ System.Web.RegularExpressions \
+ System.Workflow.Activities \
+ System.Workflow.ComponentModel \
+ System.Workflow.Runtime \
$(pcl_facade_dirs)
xbuild_2_0_dirs := \
ha = SHA1.Create ();
hash = GetHash (ha);
break;
+ case 32:
+ ha = SHA256.Create ();
+ hash = GetHash (ha);
+ break;
+ case 48:
+ ha = SHA384.Create ();
+ hash = GetHash (ha);
+ break;
+ case 64:
+ ha = SHA512.Create ();
+ hash = GetHash (ha);
+ break;
default:
reason = 5;
Close ();
case 20:
hashName = "SHA1";
break;
+ case 32:
+ hashName = "SHA256";
+ break;
+ case 48:
+ hashName = "SHA384";
+ break;
+ case 64:
+ hashName = "SHA512";
+ break;
}
HashAlgorithm ha = HashAlgorithm.Create (hashName);
if (!messageDigest.CompareValue (ha.ComputeHash (signature)))
+++ /dev/null
-NAME=rabbitmq-dotnet-client
-NAME_VSN=${NAME}-${RABBIT_VSN}
-
-RELEASE_DIR=releases/${NAME}/v${RABBIT_VSN}
-
-STAGE_RELEASE_DIR=charlotte:/home/rabbitmq/stage-extras/releases/${NAME}
-LIVE_RELEASE_DIR=charlotte:/home/rabbitmq/live-extras/releases/${NAME}
-
-RSYNC_CMD=rsync -irvl --delete-after
-
-TMPXMLZIP=${NAME_VSN}-tmp-xmldoc.zip
-
-ifeq "$(RABBIT_VSN)" ""
-rabbit-vsn:
- @echo "RABBIT_VSN is not set"
- @false
-else
-rabbit-vsn:
-endif
-
-deploy-stage: rabbit-vsn ensure-deliverables
- ${RSYNC_CMD} --exclude=${TMPXMLZIP} releases/${NAME}/ ${STAGE_RELEASE_DIR}
-
-deploy-live: rabbit-vsn ensure-deliverables
- ${RSYNC_CMD} --exclude=${TMPXMLZIP} releases/${NAME}/ ${LIVE_RELEASE_DIR}
-
-ensure-deliverables: rabbit-vsn
- file ${RELEASE_DIR}/${NAME_VSN}.zip
- file ${RELEASE_DIR}/${NAME_VSN}-api-guide.pdf
- file ${RELEASE_DIR}/${NAME_VSN}-user-guide.pdf
- file ${RELEASE_DIR}/${NAME_VSN}-wcf-service-model.pdf
- file ${RELEASE_DIR}/${NAME_VSN}-net-2.0.zip
- file ${RELEASE_DIR}/${NAME_VSN}-net-2.0-htmldoc.zip
- file ${RELEASE_DIR}/${NAME_VSN}-net-2.0-htmldoc
- file ${RELEASE_DIR}/${NAME_VSN}-net-3.0-wcf.zip
- file ${RELEASE_DIR}/${NAME_VSN}-net-3.0-wcf-htmldoc.zip
- file ${RELEASE_DIR}/${NAME_VSN}-net-3.0-wcf-htmldoc
-
-ensure-prerequisites: rabbit-vsn
- dpkg -p htmldoc plotutils transfig graphviz > /dev/null
-
-ensure-release-dir: rabbit-vsn
- touch ${RELEASE_DIR}/
-
-ensure-docs: rabbit-vsn
- file ${RELEASE_DIR}/${NAME_VSN}-net-2.0-htmldoc.zip
- file ${RELEASE_DIR}/${TMPXMLZIP}
-
-doc: rabbit-vsn ensure-prerequisites ensure-release-dir ensure-docs
- rm -rf build/tmpdoc build/doc
- mkdir -p build/tmpdoc/html build/tmpdoc/xml
- unzip -j ${RELEASE_DIR}/${NAME_VSN}-net-2.0-htmldoc.zip -d build/tmpdoc/html
- unzip -j ${RELEASE_DIR}/${NAME_VSN}-tmp-xmldoc.zip -d build/tmpdoc/xml
- cd docs && ./api-guide.sh && \
- mv api-guide.pdf ../${RELEASE_DIR}/${NAME_VSN}-api-guide.pdf
- $(MAKE) -C docs
- mv build/doc/userguide/user-guide.pdf ${RELEASE_DIR}/${NAME_VSN}-user-guide.pdf
- cp docs/"RabbitMQ Service Model.pdf" \
- ${RELEASE_DIR}/${NAME_VSN}-wcf-service-model.pdf
- cd ${RELEASE_DIR} && \
- rm -rf ${NAME_VSN}-net-2.0-htmldoc && \
- unzip ${NAME_VSN}-net-2.0-htmldoc.zip && \
- rm -rf unzip ${NAME_VSN}-net-3.0-wcf-htmldoc && \
- unzip ${NAME_VSN}-net-3.0-wcf-htmldoc.zip
$(bare_libdir)/System.Xml.dll:
(cd ../System.XML; $(MAKE) $@)
+
+run-test:
+ $(MAKE) -C Test/standalone
\ No newline at end of file
public virtual Type GetConfigType (string typeName, bool throwOnError)
{
Type type = Type.GetType (typeName);
+
+ // This code is in System.Configuration.dll, but some of the classes we might want to load here are in System.dll.
+ if (type == null)
+ type = Type.GetType (typeName + ",System");
+
if (type == null && throwOnError)
throw new ConfigurationErrorsException ("Type '" + typeName + "' not found.");
return type;
-TESTS = t1.exe t2.exe t3.exe t4.exe t5.exe t6.exe t7.exe t8.exe t9.exe t10.exe t11.exe t12.exe t15.exe t16.exe t17.exe t18.exe t19.exe t20.exe t21.exe t22.exe t23.exe t24.exe t25.exe t26.exe t27.exe t28.exe t29.exe t30.exe t31.exe t32.exe t33.exe t34.exe t35.exe t36.exe t37.exe t38.exe t39.exe t40.exe t41.exe t42.exe t43.exe t44.exe t45.exe t46.exe t47.exe
-# t13.exe t14.exe
+thisdir = class/System.Configuration/Test/standalone
+SUBDIRS =
+include ../../../../build/rules.make
+
+TESTS = t1.exe t2.exe t3.exe t4.exe t5.exe t6.exe t7.exe t8.exe t9.exe t10.exe t11.exe t12.exe t15.exe t16.exe t17.exe t18.exe t19.exe t20.exe t21.exe t22.exe t23.exe t24.exe t25.exe t28.exe t29.exe t30.exe t31.exe t32.exe t33.exe t34.exe t35.exe t36.exe t37.exe t38.exe t39.exe t40.exe t41.exe t42.exe t43.exe t44.exe t45.exe t46.exe t47.exe t48.exe
+# t13.exe t14.exe t26.exe t27.exe
check: local compare
local: $(TESTS)
@for i in $(TESTS); do \
echo running test $$i; \
- MONO_PATH=../../../lib/net_4_x mono --debug $$i > $$i.result; \
+ MONO_PATH="$(topdir)/class/lib/$(PROFILE)$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH" $(RUNTIME) $(RUNTIME_FLAGS) $$i > $$i.result; \
done
compare:
- @for i in $(TESTS); do \
- echo -n "$$i: "; \
- if diff --strip-trailing-cr $$i.expected $$i.result >/dev/null ; then echo " OK"; else echo " FAILED"; fi; \
- done
+ @ECODE=0; \
+ for i in $(TESTS); do \
+ printf "$$i: "; \
+ if diff --strip-trailing-cr $$i.expected $$i.result >/dev/null ; then echo " OK"; else echo " FAILED"; ECODE=1; fi; \
+ done; \
+ exit $$ECODE
clean:
rm -f *.exe *.mdb *.result
t36.exe : t36.cs t36-lib.cs
- gmcs /debug -r:System.Configuration.dll -t:library t36-lib.cs
- gmcs /debug -r:System.Configuration.dll -r:t36-lib.dll t36.cs
+ $(CSCOMPILE) -r:$(topdir)/class/lib/$(PROFILE)/System.Configuration.dll -t:library t36-lib.cs
+ $(CSCOMPILE) -r:$(topdir)/class/lib/$(PROFILE)/System.Configuration.dll -r:t36-lib.dll t36.cs
t46.exe : t46.cs t46-lib.cs
- gmcs /debug -r:System.Configuration.dll -t:library t46-lib.cs
- gmcs /debug -r:System.Configuration.dll -r:t46-lib.dll /out:$@ Assert.cs t46.cs
+ $(CSCOMPILE) -r:$(topdir)/class/lib/$(PROFILE)/System.Configuration.dll -t:library t46-lib.cs
+ $(CSCOMPILE) -r:$(topdir)/class/lib/$(PROFILE)/System.Configuration.dll -r:t46-lib.dll /out:$@ Assert.cs t46.cs
%.exe: %.cs
- gmcs /debug /out:$@ Assert.cs $< -r:System.Configuration.dll -r:System.Web.dll -r:System.Data.dll
+ $(CSCOMPILE) /out:$@ Assert.cs $< -r:$(topdir)/class/lib/$(PROFILE)/System.Configuration.dll -r:$(topdir)/class/lib/$(PROFILE)/System.Web.dll -r:$(topdir)/class/lib/$(PROFILE)/System.Data.dll -r:$(topdir)/class/lib/$(PROFILE)/System.dll -r:$(topdir)/class/lib/$(PROFILE)/System.Xml.dll
+
--- /dev/null
+using System;
+using System.Collections;
+
+// Bugzilla #39669
+
+namespace TestConfigSection
+{
+ class Test
+ {
+ public static int Main (string[] args)
+ {
+ Hashtable testCustomSection = (Hashtable)System.Configuration.ConfigurationManager.GetSection ("TestCustomSection");
+ string proxyServer = (string)testCustomSection["ProxyServer"];
+
+ if (proxyServer == null)
+ throw new Exception("Custom section value is null");
+
+ if (proxyServer != "server.example.com")
+ throw new Exception("Custom section value is incorrect");
+
+ return 0;
+ }
+ }
+}
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<configuration>
+ <configSections>
+ <section name="TestCustomSection" type="System.Configuration.DictionarySectionHandler" />
+ </configSections>
+ <TestCustomSection>
+ <add key="ProxyServer" value="server.example.com" />
+ <add key="ConnectOnStart" value="false" />
+ </TestCustomSection>
+</configuration>
\ No newline at end of file
--- /dev/null
+//
+// AssemblyInfo.cs
+//
+// Authors:
+// Marek Safar (marek.safar@gmail.com)
+//
+// Copyright 2016 Xamarin Inc (http://www.xamarin.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Reflection;
+using System.Resources;
+using System.Security;
+using System.Security.Permissions;
+using System.Diagnostics;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about the assembly
+
+[assembly: AssemblyTitle ("System.Deployment.dll")]
+[assembly: AssemblyDescription ("System.Deployment.dll")]
+[assembly: AssemblyDefaultAlias ("System.Deployment.dll")]
+
+[assembly: AssemblyCompany (Consts.MonoCompany)]
+[assembly: AssemblyProduct (Consts.MonoProduct)]
+[assembly: AssemblyCopyright (Consts.MonoCopyright)]
+[assembly: AssemblyVersion (Consts.FxVersion)]
+[assembly: SatelliteContractVersion (Consts.FxVersion)]
+[assembly: AssemblyInformationalVersion (Consts.FxFileVersion)]
+[assembly: AssemblyFileVersion (Consts.FxFileVersion)]
+
+[assembly: CLSCompliant (true)]
+
--- /dev/null
+thisdir = class/System.Deployment
+SUBDIRS =
+include ../../build/rules.make
+
+LIBRARY = System.Deployment.dll
+
+LIB_REFS =
+LIB_MCS_FLAGS = -delaysign -keyfile:../msfinal.pub
+
+include ../../build/library.make
--- /dev/null
+../../build/common/Consts.cs
+Assembly/AssemblyInfo.cs
<Types>
<Namespace Name="System.Net.Http">
<Type Name="ByteArrayContent" Kind="Class" />
+ <Type Name="CFNetworkHandler" Kind="Class" />
<Type Name="ClientCertificateOption" Kind="Enumeration" />
<Type Name="DelegatingHandler" Kind="Class" />
<Type Name="FormUrlEncodedContent" Kind="Class" />
LIB_REFS = System.Core System
LIB_MCS_FLAGS = $(EXTRA_LIB_MCS_FLAGS)
+ifeq (monodroid,$(PROFILE))
+LIB_MCS_FLAGS += -d:XAMARIN_MODERN
+endif
TEST_LIB_REFS = System System.Core
TEST_MCS_FLAGS =
--- /dev/null
+using System;
+using System.Reflection;
+
+namespace System.Net.Http {
+ public partial class HttpClient {
+
+ public HttpClient ()
+ : this (GetDefaultHandler (), true)
+ {
+ }
+
+ static HttpMessageHandler GetDefaultHandler ()
+ {
+ Type type = Type.GetType("Android.Runtime.AndroidEnvironment, Mono.Android");
+ if (type == null)
+ return GetFallback ("Invalid Mono.Android assembly? Cannot find Android.Runtime.AndroidEnvironment");
+
+ MethodInfo method = type.GetMethod ("GetHttpMessageHandler", BindingFlags.Static | BindingFlags.NonPublic);
+ if (method == null)
+ return GetFallback ("Your Xamarin.Android version does not support obtaining of the custom HttpClientHandler");
+
+ object ret = method.Invoke (null, null);
+ if (ret == null)
+ return GetFallback ("Xamarin.Android returned no custom HttpClientHandler");
+
+ var handler = ret as HttpMessageHandler;
+ if (handler == null)
+ return GetFallback ($"{ret?.GetType()} is not a valid HttpMessageHandler");
+ return handler;
+ }
+
+ static HttpMessageHandler GetFallback (string message)
+ {
+ Console.WriteLine (message + ". Defaulting to System.Net.Http.HttpClientHandler");
+ return new HttpClientHandler ();
+ }
+ }
+}
--- /dev/null
+#include System.Net.Http.dll.sources
+System.Net.Http/HttpClient.android.cs
--- /dev/null
+//
+// AssemblyInfo.cs
+//
+// Authors:
+// Marek Safar (marek.safar@gmail.com)
+//
+// Copyright 2016 Xamarin Inc (http://www.xamarin.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Reflection;
+using System.Resources;
+using System.Security;
+using System.Security.Permissions;
+using System.Diagnostics;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about the assembly
+
+[assembly: AssemblyTitle ("System.Web.Mobile.dll")]
+[assembly: AssemblyDescription ("System.Web.Mobile.dll")]
+[assembly: AssemblyDefaultAlias ("System.Web.Mobile.dll")]
+
+[assembly: AssemblyCompany (Consts.MonoCompany)]
+[assembly: AssemblyProduct (Consts.MonoProduct)]
+[assembly: AssemblyCopyright (Consts.MonoCopyright)]
+[assembly: AssemblyVersion (Consts.FxVersion)]
+[assembly: SatelliteContractVersion (Consts.FxVersion)]
+[assembly: AssemblyInformationalVersion (Consts.FxFileVersion)]
+[assembly: AssemblyFileVersion (Consts.FxFileVersion)]
+
+[assembly: CLSCompliant (true)]
+
--- /dev/null
+thisdir = class/System.Web.Mobile
+SUBDIRS =
+include ../../build/rules.make
+
+LIBRARY = System.Web.Mobile.dll
+
+LIB_REFS =
+LIB_MCS_FLAGS = -delaysign -keyfile:../msfinal.pub
+
+include ../../build/library.make
--- /dev/null
+../../build/common/Consts.cs
+Assembly/AssemblyInfo.cs
--- /dev/null
+//
+// AssemblyInfo.cs
+//
+// Authors:
+// Marek Safar (marek.safar@gmail.com)
+//
+// Copyright 2016 Xamarin Inc (http://www.xamarin.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Reflection;
+using System.Resources;
+using System.Security;
+using System.Security.Permissions;
+using System.Diagnostics;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about the assembly
+
+[assembly: AssemblyTitle ("System.Web.RegularExpressions.dll")]
+[assembly: AssemblyDescription ("System.Web.RegularExpressions.dll")]
+[assembly: AssemblyDefaultAlias ("System.Web.RegularExpressions.dll")]
+
+[assembly: AssemblyCompany (Consts.MonoCompany)]
+[assembly: AssemblyProduct (Consts.MonoProduct)]
+[assembly: AssemblyCopyright (Consts.MonoCopyright)]
+[assembly: AssemblyVersion (Consts.FxVersion)]
+[assembly: SatelliteContractVersion (Consts.FxVersion)]
+[assembly: AssemblyInformationalVersion (Consts.FxFileVersion)]
+[assembly: AssemblyFileVersion (Consts.FxFileVersion)]
+
+[assembly: CLSCompliant (true)]
+
--- /dev/null
+thisdir = class/System.Web.RegularExpressions
+SUBDIRS =
+include ../../build/rules.make
+
+LIBRARY = System.Web.RegularExpressions.dll
+
+LIB_REFS =
+LIB_MCS_FLAGS = -delaysign -keyfile:../msfinal.pub
+
+include ../../build/library.make
--- /dev/null
+../../build/common/Consts.cs
+Assembly/AssemblyInfo.cs
--- /dev/null
+//
+// AssemblyInfo.cs
+//
+// Authors:
+// Marek Safar (marek.safar@gmail.com)
+//
+// Copyright 2016 Xamarin Inc (http://www.xamarin.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Reflection;
+using System.Resources;
+using System.Security;
+using System.Security.Permissions;
+using System.Diagnostics;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about the assembly
+
+[assembly: AssemblyTitle ("System.Workflow.Activities.dll")]
+[assembly: AssemblyDescription ("System.Workflow.Activities.dll")]
+[assembly: AssemblyDefaultAlias ("System.Workflow.Activities.dll")]
+
+[assembly: AssemblyCompany (Consts.MonoCompany)]
+[assembly: AssemblyProduct (Consts.MonoProduct)]
+[assembly: AssemblyCopyright (Consts.MonoCopyright)]
+[assembly: AssemblyVersion (Consts.FxVersion)]
+[assembly: SatelliteContractVersion (Consts.FxVersion)]
+[assembly: AssemblyInformationalVersion (Consts.FxFileVersion)]
+[assembly: AssemblyFileVersion (Consts.FxFileVersion)]
+
+[assembly: CLSCompliant (true)]
+
--- /dev/null
+thisdir = class/System.Workflow.Activities
+SUBDIRS =
+include ../../build/rules.make
+
+LIBRARY = System.Workflow.Activities.dll
+
+LIB_REFS =
+LIB_MCS_FLAGS = -delaysign -keyfile:../winfx.pub
+
+include ../../build/library.make
--- /dev/null
+../../build/common/Consts.cs
+Assembly/AssemblyInfo.cs
--- /dev/null
+//
+// AssemblyInfo.cs
+//
+// Authors:
+// Marek Safar (marek.safar@gmail.com)
+//
+// Copyright 2016 Xamarin Inc (http://www.xamarin.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Reflection;
+using System.Resources;
+using System.Security;
+using System.Security.Permissions;
+using System.Diagnostics;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about the assembly
+
+[assembly: AssemblyTitle ("System.Workflow.ComponentModel.dll")]
+[assembly: AssemblyDescription ("System.Workflow.ComponentModel.dll")]
+[assembly: AssemblyDefaultAlias ("System.Workflow.ComponentModel.dll")]
+
+[assembly: AssemblyCompany (Consts.MonoCompany)]
+[assembly: AssemblyProduct (Consts.MonoProduct)]
+[assembly: AssemblyCopyright (Consts.MonoCopyright)]
+[assembly: AssemblyVersion (Consts.FxVersion)]
+[assembly: SatelliteContractVersion (Consts.FxVersion)]
+[assembly: AssemblyInformationalVersion (Consts.FxFileVersion)]
+[assembly: AssemblyFileVersion (Consts.FxFileVersion)]
+
+[assembly: CLSCompliant (true)]
+
--- /dev/null
+thisdir = class/System.Workflow.ComponentModel
+SUBDIRS =
+include ../../build/rules.make
+
+LIBRARY = System.Workflow.ComponentModel.dll
+
+LIB_REFS =
+LIB_MCS_FLAGS = -delaysign -keyfile:../winfx.pub
+
+include ../../build/library.make
--- /dev/null
+../../build/common/Consts.cs
+Assembly/AssemblyInfo.cs
--- /dev/null
+//
+// AssemblyInfo.cs
+//
+// Authors:
+// Marek Safar (marek.safar@gmail.com)
+//
+// Copyright 2016 Xamarin Inc (http://www.xamarin.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Reflection;
+using System.Resources;
+using System.Security;
+using System.Security.Permissions;
+using System.Diagnostics;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about the assembly
+
+[assembly: AssemblyTitle ("System.Workflow.Runtime.dll")]
+[assembly: AssemblyDescription ("System.Workflow.Runtime.dll")]
+[assembly: AssemblyDefaultAlias ("System.Workflow.Runtime.dll")]
+
+[assembly: AssemblyCompany (Consts.MonoCompany)]
+[assembly: AssemblyProduct (Consts.MonoProduct)]
+[assembly: AssemblyCopyright (Consts.MonoCopyright)]
+[assembly: AssemblyVersion (Consts.FxVersion)]
+[assembly: SatelliteContractVersion (Consts.FxVersion)]
+[assembly: AssemblyInformationalVersion (Consts.FxFileVersion)]
+[assembly: AssemblyFileVersion (Consts.FxFileVersion)]
+
+[assembly: CLSCompliant (true)]
+
--- /dev/null
+thisdir = class/System.Workflow.Runtime
+SUBDIRS =
+include ../../build/rules.make
+
+LIBRARY = System.Workflow.Runtime.dll
+
+LIB_REFS =
+LIB_MCS_FLAGS = -delaysign -keyfile:../winfx.pub
+
+include ../../build/library.make
--- /dev/null
+../../build/common/Consts.cs
+Assembly/AssemblyInfo.cs
ifdef MOBILE_PROFILE
LIB_MCS_FLAGS += -d:INSIDE_SYSTEM -d:SECURITY_DEP
else
-EXTERN_ALIAS_FLAGS = -d:MONO_SECURITY_ALIAS -d:MONO_X509_ALIAS
+EXTERN_ALIAS_FLAGS = -d:MONO_SECURITY_ALIAS
endif
#
ifeq (secxml/, $(intermediate))
LOCAL_MCS_FLAGS =
LIB_REFS += bare/System.Xml MonoSecurity=Mono.Security
-LIB_MCS_FLAGS += -d:SECURITY_DEP -d:XML_DEP -r:PrebuiltSystem=$(bare_libdir)/System.dll $(EXTERN_ALIAS_FLAGS)
+LIB_MCS_FLAGS += -d:SECURITY_DEP -d:XML_DEP $(EXTERN_ALIAS_FLAGS)
endif
#
#
ifndef intermediate
LIB_REFS += System.Xml MonoSecurity=Mono.Security
-LIB_MCS_FLAGS += -d:SECURITY_DEP -d:XML_DEP -r:PrebuiltSystem=$(secxml_libdir)/System.dll $(EXTERN_ALIAS_FLAGS)
+LIB_MCS_FLAGS += -d:SECURITY_DEP -d:XML_DEP $(EXTERN_ALIAS_FLAGS)
ifndef MOBILE_PROFILE
LIB_REFS += System.Configuration
#if SECURITY_DEP
-#if MONO_X509_ALIAS
-extern alias PrebuiltSystem;
-#endif
#if MONO_SECURITY_ALIAS
extern alias MonoSecurity;
#endif
#else
using MSI = Mono.Security.Interface;
#endif
-#if MONO_X509_ALIAS
-using XX509CertificateCollection = PrebuiltSystem::System.Security.Cryptography.X509Certificates.X509CertificateCollection;
-using XX509Chain = PrebuiltSystem::System.Security.Cryptography.X509Certificates.X509Chain;
-#else
-using XX509CertificateCollection = System.Security.Cryptography.X509Certificates.X509CertificateCollection;
-using XX509Chain = System.Security.Cryptography.X509Certificates.X509Chain;
-#endif
using System;
using System.IO;
if (callback == null)
return null;
- return (h, c, ch, e) => callback (h, c, (X509Chain)(object)ch, (SslPolicyErrors)e);
+ return (h, c, ch, e) => callback (h, c, ch, (SslPolicyErrors)e);
}
internal static MSI.MonoLocalCertificateSelectionCallback PublicToMono (LocalCertificateSelectionCallback callback)
if (callback == null)
return null;
- return (t, lc, rc, ai) => callback (null, t, (XX509CertificateCollection)(object)lc, rc, ai);
+ return (t, lc, rc, ai) => callback (null, t, lc, rc, ai);
}
internal static MSI.MonoRemoteCertificateValidationCallback InternalToMono (RemoteCertValidationCallback callback)
if (callback == null)
return null;
- return (h, c, ch, e) => callback (h, c, (X509Chain)(object)ch, (SslPolicyErrors)e);
+ return (h, c, ch, e) => callback (h, c, ch, (SslPolicyErrors)e);
}
internal static RemoteCertificateValidationCallback InternalToPublic (string hostname, RemoteCertValidationCallback callback)
if (callback == null)
return null;
- return (t, lc, rc, ai) => callback (t, (XX509CertificateCollection)(object)lc, rc, ai);
+ return (t, lc, rc, ai) => callback (t, lc, rc, ai);
}
internal static RemoteCertificateValidationCallback MonoToPublic (MSI.MonoRemoteCertificateValidationCallback callback)
if (callback == null)
return null;
- return (t, c, ch, e) => callback (null, c, (XX509Chain)(object)ch, (MSI.MonoSslPolicyErrors)e);
+ return (t, c, ch, e) => callback (null, c, ch, (MSI.MonoSslPolicyErrors)e);
}
internal static LocalCertificateSelectionCallback MonoToPublic (MSI.MonoLocalCertificateSelectionCallback callback)
if (callback == null)
return null;
- return (s, t, lc, rc, ai) => callback (t, (XX509CertificateCollection)(object)lc, rc, ai);
+ return (s, t, lc, rc, ai) => callback (t, lc, rc, ai);
}
internal static RemoteCertValidationCallback MonoToInternal (MSI.MonoRemoteCertificateValidationCallback callback)
if (callback == null)
return null;
- return (h, c, ch, e) => callback (h, c, (XX509Chain)(object)ch, (MSI.MonoSslPolicyErrors)e);
+ return (h, c, ch, e) => callback (h, c, ch, (MSI.MonoSslPolicyErrors)e);
}
internal static LocalCertSelectionCallback MonoToInternal (MSI.MonoLocalCertificateSelectionCallback callback)
if (callback == null)
return null;
- return (t, lc, rc, ai) => callback (t, (XX509CertificateCollection)(object)lc, rc, ai);
+ return (t, lc, rc, ai) => callback (t, lc, rc, ai);
}
}
#if MONO_SECURITY_ALIAS
extern alias MonoSecurity;
#endif
-#if MONO_X509_ALIAS
-extern alias PrebuiltSystem;
-#endif
#if MONO_SECURITY_ALIAS
using MonoSecurity::Mono.Security.Interface;
using MSX = Mono.Security.X509;
using Mono.Security.X509.Extensions;
#endif
-#if MONO_X509_ALIAS
-using XX509CertificateCollection = PrebuiltSystem::System.Security.Cryptography.X509Certificates.X509CertificateCollection;
-using XX509Chain = PrebuiltSystem::System.Security.Cryptography.X509Certificates.X509Chain;
-#else
using XX509CertificateCollection = System.Security.Cryptography.X509Certificates.X509CertificateCollection;
using XX509Chain = System.Security.Cryptography.X509Certificates.X509Chain;
-#endif
using System;
using System.Net;
public ValidationResult ValidateCertificate (string host, bool serverMode, X509Certificate leaf, XX509Chain xchain)
{
try {
- var chain = (X509Chain)(object)xchain;
+ var chain = xchain;
var result = ValidateChain (host, serverMode, leaf, chain, null, 0);
if (tlsStream != null)
tlsStream.CertificateValidationFailed = result == null || !result.Trusted || result.UserDenied;
bool providerValidated = false;
if (provider != null && provider.HasCustomSystemCertificateValidator) {
var xerrors = (MonoSslPolicyErrors)errors;
- var xchain = (XX509Chain)(object)chain;
+ var xchain = chain;
providerValidated = provider.InvokeSystemCertificateValidator (this, host, server, certs, wantsChain, ref xchain, out result, ref xerrors, ref status11);
- chain = (X509Chain)(object)xchain;
+ chain = xchain;
errors = (SslPolicyErrors)xerrors;
} else if (wantsChain) {
chain = SystemCertificateValidator.CreateX509Chain (certs);
public bool InvokeSystemValidator (string targetHost, bool serverMode, XX509CertificateCollection certificates, XX509Chain xchain, ref MonoSslPolicyErrors xerrors, ref int status11)
{
- X509Chain chain = (X509Chain)(object)xchain;
+ X509Chain chain = xchain;
var errors = (SslPolicyErrors)xerrors;
var result = SystemCertificateValidator.Evaluate (settings, targetHost, certificates, chain, ref errors, ref status11);
xerrors = (MonoSslPolicyErrors)errors;
// THE SOFTWARE.
#if SECURITY_DEP
-#if MONO_X509_ALIAS
-extern alias PrebuiltSystem;
-#endif
#if MONO_SECURITY_ALIAS
extern alias MonoSecurity;
#endif
-#if MONO_X509_ALIAS
-using X509CertificateCollection = PrebuiltSystem::System.Security.Cryptography.X509Certificates.X509CertificateCollection;
-#endif
#if MONO_SECURITY_ALIAS
using MSI = MonoSecurity::Mono.Security.Interface;
#else
#if MONO_SECURITY_ALIAS
extern alias MonoSecurity;
#endif
-#if MONO_X509_ALIAS
-extern alias PrebuiltSystem;
-#endif
#if MONO_SECURITY_ALIAS
using MonoSecurity::Mono.Security.Interface;
#else
using Mono.Security.Interface;
#endif
-#if MONO_X509_ALIAS
-using XX509CertificateCollection = PrebuiltSystem::System.Security.Cryptography.X509Certificates.X509CertificateCollection;
-#else
using XX509CertificateCollection = System.Security.Cryptography.X509Certificates.X509CertificateCollection;
#endif
-#endif
using System;
using System.IO;
#if SECURITY_DEP
-#if MONO_X509_ALIAS
-extern alias PrebuiltSystem;
-#endif
#if MONO_SECURITY_ALIAS
extern alias MonoSecurity;
#endif
using Mono.Security.Protocol.Tls;
using Mono.Security.Interface;
#endif
-#if MONO_X509_ALIAS
-using X509CertificateCollection = PrebuiltSystem::System.Security.Cryptography.X509Certificates.X509CertificateCollection;
-#endif
using CipherAlgorithmType = System.Security.Authentication.CipherAlgorithmType;
using HashAlgorithmType = System.Security.Authentication.HashAlgorithmType;
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#if SECURITY_DEP
-#if MONO_X509_ALIAS
-extern alias PrebuiltSystem;
-#endif
#if MONO_SECURITY_ALIAS
extern alias MonoSecurity;
#endif
-#if MONO_X509_ALIAS
-using XHttpWebRequest = PrebuiltSystem::System.Net.HttpWebRequest;
-using XSslProtocols = PrebuiltSystem::System.Security.Authentication.SslProtocols;
-using XX509CertificateCollection = PrebuiltSystem::System.Security.Cryptography.X509Certificates.X509CertificateCollection;
-#else
using XHttpWebRequest = System.Net.HttpWebRequest;
using XSslProtocols = System.Security.Authentication.SslProtocols;
using XX509CertificateCollection = System.Security.Cryptography.X509Certificates.X509CertificateCollection;
-#endif
#if MONO_SECURITY_ALIAS
using MonoSecurity::Mono.Security.Interface;
#if SECURITY_DEP
-#if MONO_X509_ALIAS
-extern alias PrebuiltSystem;
-#endif
#if MONO_SECURITY_ALIAS
extern alias MonoSecurity;
#endif
#else
using MSI = Mono.Security.Interface;
#endif
-#if MONO_X509_ALIAS
-using XX509CertificateCollection = PrebuiltSystem::System.Security.Cryptography.X509Certificates.X509CertificateCollection;
-
-using XTransportContext = PrebuiltSystem::System.Net.TransportContext;
-using XAuthenticatedStream = PrebuiltSystem::System.Net.Security.AuthenticatedStream;
-
-using XCipherAlgorithmType = PrebuiltSystem::System.Security.Authentication.CipherAlgorithmType;
-using XHashAlgorithmType = PrebuiltSystem::System.Security.Authentication.HashAlgorithmType;
-using XExchangeAlgorithmType = PrebuiltSystem::System.Security.Authentication.ExchangeAlgorithmType;
-using XSslProtocols = PrebuiltSystem::System.Security.Authentication.SslProtocols;
-#else
-using XX509CertificateCollection = System.Security.Cryptography.X509Certificates.X509CertificateCollection;
-
-using XTransportContext = System.Net.TransportContext;
-using XAuthenticatedStream = System.Net.Security.AuthenticatedStream;
-
-using XCipherAlgorithmType = System.Security.Authentication.CipherAlgorithmType;
-using XHashAlgorithmType = System.Security.Authentication.HashAlgorithmType;
-using XExchangeAlgorithmType = System.Security.Authentication.ExchangeAlgorithmType;
-using XSslProtocols = System.Security.Authentication.SslProtocols;
-#endif
using System;
using System.IO;
Impl.AuthenticateAsClient (targetHost);
}
- public void AuthenticateAsClient (string targetHost, XX509CertificateCollection clientCertificates, XSslProtocols enabledSslProtocols, bool checkCertificateRevocation)
+ public void AuthenticateAsClient (string targetHost, X509CertificateCollection clientCertificates, SslProtocols enabledSslProtocols, bool checkCertificateRevocation)
{
- Impl.AuthenticateAsClient (targetHost, clientCertificates, (SslProtocols)enabledSslProtocols, checkCertificateRevocation);
+ Impl.AuthenticateAsClient (targetHost, clientCertificates, enabledSslProtocols, checkCertificateRevocation);
}
public IAsyncResult BeginAuthenticateAsClient (string targetHost, AsyncCallback asyncCallback, object asyncState)
return Impl.BeginAuthenticateAsClient (targetHost, asyncCallback, asyncState);
}
- public IAsyncResult BeginAuthenticateAsClient (string targetHost, XX509CertificateCollection clientCertificates, XSslProtocols enabledSslProtocols, bool checkCertificateRevocation, AsyncCallback asyncCallback, object asyncState)
+ public IAsyncResult BeginAuthenticateAsClient (string targetHost, X509CertificateCollection clientCertificates, SslProtocols enabledSslProtocols, bool checkCertificateRevocation, AsyncCallback asyncCallback, object asyncState)
{
- return Impl.BeginAuthenticateAsClient (targetHost, clientCertificates, (SslProtocols)enabledSslProtocols, checkCertificateRevocation, asyncCallback, asyncState);
+ return Impl.BeginAuthenticateAsClient (targetHost, clientCertificates, enabledSslProtocols, checkCertificateRevocation, asyncCallback, asyncState);
}
public void EndAuthenticateAsClient (IAsyncResult asyncResult)
Impl.AuthenticateAsServer (serverCertificate);
}
- public void AuthenticateAsServer (X509Certificate serverCertificate, bool clientCertificateRequired, XSslProtocols enabledSslProtocols, bool checkCertificateRevocation)
+ public void AuthenticateAsServer (X509Certificate serverCertificate, bool clientCertificateRequired, SslProtocols enabledSslProtocols, bool checkCertificateRevocation)
{
- Impl.AuthenticateAsServer (serverCertificate, clientCertificateRequired, (SslProtocols)enabledSslProtocols, checkCertificateRevocation);
+ Impl.AuthenticateAsServer (serverCertificate, clientCertificateRequired, enabledSslProtocols, checkCertificateRevocation);
}
public IAsyncResult BeginAuthenticateAsServer (X509Certificate serverCertificate, AsyncCallback asyncCallback, object asyncState)
return Impl.BeginAuthenticateAsServer (serverCertificate, asyncCallback, asyncState);
}
- public IAsyncResult BeginAuthenticateAsServer (X509Certificate serverCertificate, bool clientCertificateRequired, XSslProtocols enabledSslProtocols, bool checkCertificateRevocation, AsyncCallback asyncCallback, object asyncState)
+ public IAsyncResult BeginAuthenticateAsServer (X509Certificate serverCertificate, bool clientCertificateRequired, SslProtocols enabledSslProtocols, bool checkCertificateRevocation, AsyncCallback asyncCallback, object asyncState)
{
- return Impl.BeginAuthenticateAsServer (serverCertificate, clientCertificateRequired, (SslProtocols)enabledSslProtocols, checkCertificateRevocation, asyncCallback, asyncState);
+ return Impl.BeginAuthenticateAsServer (serverCertificate, clientCertificateRequired, enabledSslProtocols, checkCertificateRevocation, asyncCallback, asyncState);
}
public void EndAuthenticateAsServer (IAsyncResult asyncResult)
return Impl.AuthenticateAsClientAsync (targetHost);
}
- public Task AuthenticateAsClientAsync (string targetHost, XX509CertificateCollection clientCertificates, XSslProtocols enabledSslProtocols, bool checkCertificateRevocation)
+ public Task AuthenticateAsClientAsync (string targetHost, X509CertificateCollection clientCertificates, SslProtocols enabledSslProtocols, bool checkCertificateRevocation)
{
- return Impl.AuthenticateAsClientAsync (targetHost, clientCertificates, (SslProtocols)enabledSslProtocols, checkCertificateRevocation);
+ return Impl.AuthenticateAsClientAsync (targetHost, clientCertificates, enabledSslProtocols, checkCertificateRevocation);
}
public Task AuthenticateAsServerAsync (X509Certificate serverCertificate)
return Impl.AuthenticateAsServerAsync (serverCertificate);
}
- public Task AuthenticateAsServerAsync (X509Certificate serverCertificate, bool clientCertificateRequired, XSslProtocols enabledSslProtocols, bool checkCertificateRevocation)
+ public Task AuthenticateAsServerAsync (X509Certificate serverCertificate, bool clientCertificateRequired, SslProtocols enabledSslProtocols, bool checkCertificateRevocation)
{
- return Impl.AuthenticateAsServerAsync (serverCertificate, clientCertificateRequired, (SslProtocols)enabledSslProtocols, checkCertificateRevocation);
+ return Impl.AuthenticateAsServerAsync (serverCertificate, clientCertificateRequired, enabledSslProtocols, checkCertificateRevocation);
}
public void Flush ()
Impl.EndWrite (asyncResult);
}
- public XTransportContext TransportContext {
- get { return (XTransportContext)(object)Impl.TransportContext; }
+ public TransportContext TransportContext {
+ get { return Impl.TransportContext; }
}
public bool IsAuthenticated {
get { return Impl.IsServer; }
}
- public XCipherAlgorithmType CipherAlgorithm {
- get { return (XCipherAlgorithmType)Impl.CipherAlgorithm; }
+ public CipherAlgorithmType CipherAlgorithm {
+ get { return Impl.CipherAlgorithm; }
}
public int CipherStrength {
get { return Impl.CipherStrength; }
}
- public XHashAlgorithmType HashAlgorithm {
- get { return (XHashAlgorithmType)Impl.HashAlgorithm; }
+ public HashAlgorithmType HashAlgorithm {
+ get { return Impl.HashAlgorithm; }
}
public int HashStrength {
get { return Impl.HashStrength; }
}
- public XExchangeAlgorithmType KeyExchangeAlgorithm {
- get { return (XExchangeAlgorithmType)Impl.KeyExchangeAlgorithm; }
+ public ExchangeAlgorithmType KeyExchangeAlgorithm {
+ get { return Impl.KeyExchangeAlgorithm; }
}
public int KeyExchangeStrength {
Impl.SetLength (value);
}
- public XAuthenticatedStream AuthenticatedStream {
- get { return (XAuthenticatedStream)(Stream)Impl.AuthenticatedStream; }
+ public AuthenticatedStream AuthenticatedStream {
+ get { return Impl.AuthenticatedStream; }
}
public int ReadTimeout {
get { return Impl.RemoteCertificate; }
}
- public XSslProtocols SslProtocol {
- get { return (XSslProtocols)Impl.SslProtocol; }
+ public SslProtocols SslProtocol {
+ get { return Impl.SslProtocol; }
}
public MSI.MonoTlsProvider Provider {
#if SECURITY_DEP
-#if MONO_X509_ALIAS
-extern alias PrebuiltSystem;
-#endif
#if MONO_SECURITY_ALIAS
extern alias MonoSecurity;
#endif
#else
using MSI = Mono.Security.Interface;
#endif
-#if MONO_X509_ALIAS
-using XSslProtocols = PrebuiltSystem::System.Security.Authentication.SslProtocols;
-using XX509CertificateCollection = PrebuiltSystem::System.Security.Cryptography.X509Certificates.X509CertificateCollection;
-#else
-using XSslProtocols = System.Security.Authentication.SslProtocols;
-using XX509CertificateCollection = System.Security.Cryptography.X509Certificates.X509CertificateCollection;
-#endif
-
-using CipherAlgorithmType = System.Security.Authentication.CipherAlgorithmType;
-using HashAlgorithmType = System.Security.Authentication.HashAlgorithmType;
-using ExchangeAlgorithmType = System.Security.Authentication.ExchangeAlgorithmType;
using System;
using System.IO;
Impl.AuthenticateAsClient (targetHost);
}
- public void AuthenticateAsClient (string targetHost, XX509CertificateCollection clientCertificates, SslProtocols enabledSslProtocols, bool checkCertificateRevocation)
+ public void AuthenticateAsClient (string targetHost, X509CertificateCollection clientCertificates, SslProtocols enabledSslProtocols, bool checkCertificateRevocation)
{
- Impl.AuthenticateAsClient (targetHost, (XX509CertificateCollection)(object)clientCertificates, (XSslProtocols)enabledSslProtocols, checkCertificateRevocation);
+ Impl.AuthenticateAsClient (targetHost, clientCertificates, enabledSslProtocols, checkCertificateRevocation);
}
public IAsyncResult BeginAuthenticateAsClient (string targetHost, AsyncCallback asyncCallback, object asyncState)
return Impl.BeginAuthenticateAsClient (targetHost, asyncCallback, asyncState);
}
- public IAsyncResult BeginAuthenticateAsClient (string targetHost, XX509CertificateCollection clientCertificates, SslProtocols enabledSslProtocols, bool checkCertificateRevocation, AsyncCallback asyncCallback, object asyncState)
+ public IAsyncResult BeginAuthenticateAsClient (string targetHost, X509CertificateCollection clientCertificates, SslProtocols enabledSslProtocols, bool checkCertificateRevocation, AsyncCallback asyncCallback, object asyncState)
{
- return Impl.BeginAuthenticateAsClient (targetHost, (XX509CertificateCollection)(object)clientCertificates, (XSslProtocols)enabledSslProtocols, checkCertificateRevocation, asyncCallback, asyncState);
+ return Impl.BeginAuthenticateAsClient (targetHost, clientCertificates, enabledSslProtocols, checkCertificateRevocation, asyncCallback, asyncState);
}
public void EndAuthenticateAsClient (IAsyncResult asyncResult)
public void AuthenticateAsServer (X509Certificate serverCertificate, bool clientCertificateRequired, SslProtocols enabledSslProtocols, bool checkCertificateRevocation)
{
- Impl.AuthenticateAsServer (serverCertificate, clientCertificateRequired, (XSslProtocols)enabledSslProtocols, checkCertificateRevocation);
+ Impl.AuthenticateAsServer (serverCertificate, clientCertificateRequired, enabledSslProtocols, checkCertificateRevocation);
}
public IAsyncResult BeginAuthenticateAsServer (X509Certificate serverCertificate, AsyncCallback asyncCallback, object asyncState)
public IAsyncResult BeginAuthenticateAsServer (X509Certificate serverCertificate, bool clientCertificateRequired, SslProtocols enabledSslProtocols, bool checkCertificateRevocation, AsyncCallback asyncCallback, object asyncState)
{
- return Impl.BeginAuthenticateAsServer (serverCertificate, clientCertificateRequired, (XSslProtocols)enabledSslProtocols, checkCertificateRevocation, asyncCallback, asyncState);
+ return Impl.BeginAuthenticateAsServer (serverCertificate, clientCertificateRequired, enabledSslProtocols, checkCertificateRevocation, asyncCallback, asyncState);
}
public void EndAuthenticateAsServer (IAsyncResult asyncResult)
return Impl.AuthenticateAsClientAsync (targetHost);
}
- public Task AuthenticateAsClientAsync (string targetHost, XX509CertificateCollection clientCertificates, SslProtocols enabledSslProtocols, bool checkCertificateRevocation)
+ public Task AuthenticateAsClientAsync (string targetHost, X509CertificateCollection clientCertificates, SslProtocols enabledSslProtocols, bool checkCertificateRevocation)
{
- return Impl.AuthenticateAsClientAsync (targetHost, clientCertificates, (XSslProtocols)enabledSslProtocols, checkCertificateRevocation);
+ return Impl.AuthenticateAsClientAsync (targetHost, clientCertificates, enabledSslProtocols, checkCertificateRevocation);
}
public Task AuthenticateAsServerAsync (X509Certificate serverCertificate)
public Task AuthenticateAsServerAsync (X509Certificate serverCertificate, bool clientCertificateRequired, SslProtocols enabledSslProtocols, bool checkCertificateRevocation)
{
- return Impl.AuthenticateAsServerAsync (serverCertificate, clientCertificateRequired, (XSslProtocols)enabledSslProtocols, checkCertificateRevocation);
+ return Impl.AuthenticateAsServerAsync (serverCertificate, clientCertificateRequired, enabledSslProtocols, checkCertificateRevocation);
}
public void Flush ()
}
public TransportContext TransportContext {
- get { return (TransportContext)(object)Impl.TransportContext; }
+ get { return Impl.TransportContext; }
}
public bool IsAuthenticated {
}
public AuthenticatedStream AuthenticatedStream {
- get { return (AuthenticatedStream)(object)Impl.AuthenticatedStream; }
+ get { return Impl.AuthenticatedStream; }
}
public int ReadTimeout {
#if SECURITY_DEP
-#if MONO_X509_ALIAS
-extern alias PrebuiltSystem;
-#endif
#if MONO_SECURITY_ALIAS
extern alias MonoSecurity;
#endif
#else
using MSI = Mono.Security.Interface;
#endif
-#if MONO_X509_ALIAS
-using XHttpWebRequest = PrebuiltSystem::System.Net.HttpWebRequest;
-using XX509CertificateCollection = PrebuiltSystem::System.Security.Cryptography.X509Certificates.X509CertificateCollection;
-#else
-using XHttpWebRequest = System.Net.HttpWebRequest;
-using XX509CertificateCollection = System.Security.Cryptography.X509Certificates.X509CertificateCollection;
-#endif
using System;
using System.IO;
MSI.IMonoTlsContext IMonoTlsProvider.CreateTlsContext (
string hostname, bool serverMode, MSI.TlsProtocols protocolFlags,
- X509Certificate serverCertificate, XX509CertificateCollection clientCertificates,
+ X509Certificate serverCertificate, X509CertificateCollection clientCertificates,
bool remoteCertRequired, bool checkCertName, bool checkCertRevocationStatus,
MSI.MonoEncryptionPolicy encryptionPolicy, MSI.MonoTlsSettings settings)
{
return CreateTlsContextImpl (
hostname, serverMode, protocolFlags,
- serverCertificate, (X509CertificateCollection)(object)clientCertificates,
+ serverCertificate, clientCertificates,
remoteCertRequired, encryptionPolicy, settings);
}
internal override MSI.IMonoTlsContext CreateTlsContext (
string hostname, bool serverMode, MSI.TlsProtocols protocolFlags,
- X509Certificate serverCertificate, XX509CertificateCollection clientCertificates,
+ X509Certificate serverCertificate, X509CertificateCollection clientCertificates,
bool remoteCertRequired, MSI.MonoEncryptionPolicy encryptionPolicy,
MSI.MonoTlsSettings settings)
{
return CreateTlsContextImpl (
hostname, serverMode, (MSI.TlsProtocols)protocolFlags,
- serverCertificate, (X509CertificateCollection)(object)clientCertificates,
+ serverCertificate, clientCertificates,
remoteCertRequired, (MSI.MonoEncryptionPolicy)encryptionPolicy,
settings);
}
#if SECURITY_DEP
-#if MONO_X509_ALIAS
-extern alias PrebuiltSystem;
-#endif
#if MONO_SECURITY_ALIAS
extern alias MonoSecurity;
#endif
#else
using MSI = Mono.Security.Interface;
#endif
-#if MONO_X509_ALIAS
-using XHttpWebRequest = PrebuiltSystem::System.Net.HttpWebRequest;
-using XX509CertificateCollection = PrebuiltSystem::System.Security.Cryptography.X509Certificates.X509CertificateCollection;
-#else
-using XHttpWebRequest = System.Net.HttpWebRequest;
-using XX509CertificateCollection = System.Security.Cryptography.X509Certificates.X509CertificateCollection;
-#endif
using System;
using System.IO;
public MSI.IMonoTlsContext CreateTlsContext (
string hostname, bool serverMode, MSI.TlsProtocols protocolFlags,
- X509Certificate serverCertificate, XX509CertificateCollection clientCertificates,
+ X509Certificate serverCertificate, X509CertificateCollection clientCertificates,
bool remoteCertRequired, bool checkCertName, bool checkCertRevocationStatus,
MSI.MonoEncryptionPolicy encryptionPolicy, MSI.MonoTlsSettings settings)
{
return provider.CreateTlsContext (
hostname, serverMode, protocolFlags,
- serverCertificate, (XX509CertificateCollection)(object)clientCertificates,
+ serverCertificate, clientCertificates,
remoteCertRequired, (MSI.MonoEncryptionPolicy)encryptionPolicy,
settings);
}
#if MONO_SECURITY_ALIAS
extern alias MonoSecurity;
#endif
-#if MONO_X509_ALIAS
-extern alias PrebuiltSystem;
-#endif
#if MONO_SECURITY_ALIAS
using MonoSecurity::Mono.Security.Interface;
#else
using Mono.Security.Interface;
#endif
-#if MONO_X509_ALIAS
-using XX509CertificateCollection = PrebuiltSystem::System.Security.Cryptography.X509Certificates.X509CertificateCollection;
-#else
using XX509CertificateCollection = System.Security.Cryptography.X509Certificates.X509CertificateCollection;
#endif
-#endif
using System;
using System.IO;
try {
sslStream.AuthenticateAsClient (
- request.Address.Host, (XX509CertificateCollection)(object)request.ClientCertificates,
+ request.Address.Host, request.ClientCertificates,
(SslProtocols)ServicePointManager.SecurityProtocol,
ServicePointManager.CheckCertificateRevocationList);
#if MONO_SECURITY_ALIAS
extern alias MonoSecurity;
#endif
-#if MONO_X509_ALIAS
-extern alias PrebuiltSystem;
-#endif
#if MONO_SECURITY_ALIAS
using MonoSecurity::Mono.Security.Interface;
using MSX = Mono.Security.X509;
using Mono.Security.X509.Extensions;
#endif
-#if MONO_X509_ALIAS
-using XX509CertificateCollection = PrebuiltSystem::System.Security.Cryptography.X509Certificates.X509CertificateCollection;
-using XX509Chain = PrebuiltSystem::System.Security.Cryptography.X509Certificates.X509Chain;
-#else
using XX509CertificateCollection = System.Security.Cryptography.X509Certificates.X509CertificateCollection;
using XX509Chain = System.Security.Cryptography.X509Certificates.X509Chain;
-#endif
using System;
using System.Net;
#if MONO_SECURITY_ALIAS
extern alias MonoSecurity;
#endif
-#if MONO_X509_ALIAS
-extern alias PrebuiltSystem;
-#endif
#if MONO_SECURITY_ALIAS
using MX = MonoSecurity::Mono.Security.X509;
using MX = Mono.Security.X509;
using Mono.Security.Interface;
#endif
-#if MONO_X509_ALIAS
-using XX509CertificateCollection = PrebuiltSystem::System.Security.Cryptography.X509Certificates.X509CertificateCollection;
-#else
-using XX509CertificateCollection = System.Security.Cryptography.X509Certificates.X509CertificateCollection;
-#endif
using System.Runtime.InteropServices;
using System.Security.Authentication.ExtendedProtection;
internal static class GlobalSSPI
{
- internal static SSPIInterface Create (string hostname, bool serverMode, SchProtocols protocolFlags, X509Certificate serverCertificate, XX509CertificateCollection clientCertificates,
+ internal static SSPIInterface Create (string hostname, bool serverMode, SchProtocols protocolFlags, X509Certificate serverCertificate, X509CertificateCollection clientCertificates,
bool remoteCertRequired, bool checkCertName, bool checkCertRevocationStatus, EncryptionPolicy encryptionPolicy,
LocalCertSelectionCallback certSelectionDelegate, RemoteCertValidationCallback remoteValidationCallback, SSPIConfiguration userConfig)
{
internal static X509Certificate2 GetRemoteCertificate (SafeDeleteContext safeContext, out X509Certificate2Collection remoteCertificateStore)
{
- XX509CertificateCollection monoCollection;
+ X509CertificateCollection monoCollection;
if (safeContext == null || safeContext.IsInvalid) {
remoteCertificateStore = null;
return null;
//
#if CONFIGURATION_DEP
-extern alias PrebuiltSystem;
-using TypeDescriptor = PrebuiltSystem.System.ComponentModel.TypeDescriptor;
-
using System;
using System.Collections.Generic;
using System.ComponentModel;
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-#if CONFIGURATION_DEP
-extern alias PrebuiltSystem;
-using NameValueCollection = PrebuiltSystem.System.Collections.Specialized.NameValueCollection;
-#endif
-
using System.Reflection;
using System.Collections.Specialized;
// Copyright (C) 2005, 2006 Novell, Inc (http://www.novell.com)
//
-#if CONFIGURATION_DEP
-extern alias PrebuiltSystem;
-using NameValueCollection = PrebuiltSystem.System.Collections.Specialized.NameValueCollection;
-#endif
#if CONFIGURATION_DEP
using System.IO;
using System.Xml.Serialization;
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-#if CONFIGURATION_DEP
-extern alias PrebuiltSystem;
-using NameValueCollection = PrebuiltSystem.System.Collections.Specialized.NameValueCollection;
-#endif
-
using System;
using System.Collections;
using System.Collections.Specialized;
#if CONFIGURATION_DEP
-extern alias PrebuiltSystem;
-
using System;
using System.Collections;
using System.Collections.Generic;
+using System.Collections.Specialized;
using System.Configuration;
using System.Globalization;
using System.IO;
using System.Text;
using System.Xml;
-using NameValueCollection = PrebuiltSystem.System.Collections.Specialized.NameValueCollection;
-
namespace System.Configuration
{
// location to store user configuration settings.
//
#if CONFIGURATION_DEP
-#if CONFIGURATION_DEP
-extern alias PrebuiltSystem;
-using NameValueCollection = PrebuiltSystem.System.Collections.Specialized.NameValueCollection;
-#endif
using System;
using System.Collections.Specialized;
return;
// e.Name
- string name = path.Substring (fullPathNoLastSlash.Length + 1);
+ string name = (path.Length > fullPathNoLastSlash.Length) ? path.Substring (fullPathNoLastSlash.Length + 1) : String.Empty;
// only post events that match filter pattern. check both old and new paths for renames
if (!fsw.Pattern.IsMatch (path) && (newPath == null || !fsw.Pattern.IsMatch (newPath)))
return;
if (action == FileAction.RenamedNewName) {
- string newName = newPath.Substring (fullPathNoLastSlash.Length + 1);
+ string newName = (newPath.Length > fullPathNoLastSlash.Length) ? newPath.Substring (fullPathNoLastSlash.Length + 1) : String.Empty;
renamed = new RenamedEventArgs (WatcherChangeTypes.Renamed, fsw.Path, newName, name);
}
#if MONO_SECURITY_ALIAS
extern alias MonoSecurity;
#endif
-#if MONO_X509_ALIAS
-extern alias PrebuiltSystem;
-#endif
#if MONO_SECURITY_ALIAS
using MSI = MonoSecurity::Mono.Security.Interface;
#else
using MSI = Mono.Security.Interface;
#endif
-#if MONO_X509_ALIAS
-using X509CertificateCollection = PrebuiltSystem::System.Security.Cryptography.X509Certificates.X509CertificateCollection;
-#else
-using X509CertificateCollection = System.Security.Cryptography.X509Certificates.X509CertificateCollection;
-#endif
using System.Security.Cryptography.X509Certificates;
#endif
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#if SECURITY_DEP && !MONO_FEATURE_NEW_TLS
-#if MONO_X509_ALIAS
-extern alias PrebuiltSystem;
-using X509CertificateCollection = PrebuiltSystem::System.Security.Cryptography.X509Certificates.X509CertificateCollection;
-#endif
using System.Security.Cryptography.X509Certificates;
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#if !MONO_FEATURE_NEW_TLS
-#if MONO_X509_ALIAS
-extern alias PrebuiltSystem;
-using X509CertificateCollection = PrebuiltSystem::System.Security.Cryptography.X509Certificates.X509CertificateCollection;
-#endif
using System.Security.Cryptography.X509Certificates;
#if !MONO_FEATURE_NEW_TLS
#if SECURITY_DEP
-#if MONO_X509_ALIAS
-extern alias PrebuiltSystem;
-#endif
#if MONO_SECURITY_ALIAS
extern alias MonoSecurity;
#endif
#else
using Mono.Security.Interface;
#endif
-#if MONO_X509_ALIAS
-using XSslProtocols = PrebuiltSystem::System.Security.Authentication.SslProtocols;
-using XX509CertificateCollection = PrebuiltSystem::System.Security.Cryptography.X509Certificates.X509CertificateCollection;
-#else
-using XSslProtocols = System.Security.Authentication.SslProtocols;
-using XX509CertificateCollection = System.Security.Cryptography.X509Certificates.X509CertificateCollection;
-#endif
using CipherAlgorithmType = System.Security.Authentication.CipherAlgorithmType;
using HashAlgorithmType = System.Security.Authentication.HashAlgorithmType;
internal delegate X509Certificate LocalCertSelectionCallback (
string targetHost,
- XX509CertificateCollection localCertificates,
+ X509CertificateCollection localCertificates,
X509Certificate remoteCertificate,
string[] acceptableIssuers);
Impl.AuthenticateAsClient (targetHost);
}
- public virtual void AuthenticateAsClient (string targetHost, XX509CertificateCollection clientCertificates, SslProtocols enabledSslProtocols, bool checkCertificateRevocation)
+ public virtual void AuthenticateAsClient (string targetHost, X509CertificateCollection clientCertificates, SslProtocols enabledSslProtocols, bool checkCertificateRevocation)
{
- Impl.AuthenticateAsClient (targetHost, (XX509CertificateCollection)(object)clientCertificates, (XSslProtocols)enabledSslProtocols, checkCertificateRevocation);
+ Impl.AuthenticateAsClient (targetHost, clientCertificates, enabledSslProtocols, checkCertificateRevocation);
}
// [HostProtection (ExternalThreading=true)]
}
// [HostProtection (ExternalThreading=true)]
- public virtual IAsyncResult BeginAuthenticateAsClient (string targetHost, XX509CertificateCollection clientCertificates, SslProtocols enabledSslProtocols, bool checkCertificateRevocation, AsyncCallback asyncCallback, object asyncState)
+ public virtual IAsyncResult BeginAuthenticateAsClient (string targetHost, X509CertificateCollection clientCertificates, SslProtocols enabledSslProtocols, bool checkCertificateRevocation, AsyncCallback asyncCallback, object asyncState)
{
- return Impl.BeginAuthenticateAsClient (targetHost, (XX509CertificateCollection)(object)clientCertificates, (XSslProtocols)enabledSslProtocols, checkCertificateRevocation, asyncCallback, asyncState);
+ return Impl.BeginAuthenticateAsClient (targetHost, clientCertificates, enabledSslProtocols, checkCertificateRevocation, asyncCallback, asyncState);
}
public virtual void EndAuthenticateAsClient (IAsyncResult asyncResult)
public virtual void AuthenticateAsServer (X509Certificate serverCertificate, bool clientCertificateRequired, SslProtocols enabledSslProtocols, bool checkCertificateRevocation)
{
- Impl.AuthenticateAsServer (serverCertificate, clientCertificateRequired, (XSslProtocols)enabledSslProtocols, checkCertificateRevocation);
+ Impl.AuthenticateAsServer (serverCertificate, clientCertificateRequired, enabledSslProtocols, checkCertificateRevocation);
}
// [HostProtection (ExternalThreading=true)]
public virtual IAsyncResult BeginAuthenticateAsServer (X509Certificate serverCertificate, bool clientCertificateRequired, SslProtocols enabledSslProtocols, bool checkCertificateRevocation, AsyncCallback asyncCallback, object asyncState)
{
- return Impl.BeginAuthenticateAsServer (serverCertificate, clientCertificateRequired, (XSslProtocols)enabledSslProtocols, checkCertificateRevocation, asyncCallback, asyncState);
+ return Impl.BeginAuthenticateAsServer (serverCertificate, clientCertificateRequired, enabledSslProtocols, checkCertificateRevocation, asyncCallback, asyncState);
}
public virtual void EndAuthenticateAsServer (IAsyncResult asyncResult)
return Impl.AuthenticateAsClientAsync (targetHost);
}
- public virtual Task AuthenticateAsClientAsync (string targetHost, XX509CertificateCollection clientCertificates, SslProtocols enabledSslProtocols, bool checkCertificateRevocation)
+ public virtual Task AuthenticateAsClientAsync (string targetHost, X509CertificateCollection clientCertificates, SslProtocols enabledSslProtocols, bool checkCertificateRevocation)
{
- return Impl.AuthenticateAsClientAsync (targetHost, clientCertificates, (XSslProtocols)enabledSslProtocols, checkCertificateRevocation);
+ return Impl.AuthenticateAsClientAsync (targetHost, clientCertificates, enabledSslProtocols, checkCertificateRevocation);
}
public virtual Task AuthenticateAsServerAsync (X509Certificate serverCertificate)
public virtual Task AuthenticateAsServerAsync (X509Certificate serverCertificate, bool clientCertificateRequired, SslProtocols enabledSslProtocols, bool checkCertificateRevocation)
{
- return Impl.AuthenticateAsServerAsync (serverCertificate, clientCertificateRequired, (XSslProtocols)enabledSslProtocols, checkCertificateRevocation);
+ return Impl.AuthenticateAsServerAsync (serverCertificate, clientCertificateRequired, enabledSslProtocols, checkCertificateRevocation);
}
public override bool IsAuthenticated {
#if MONO_SECURITY_ALIAS
extern alias MonoSecurity;
#endif
-#if MONO_X509_ALIAS
-extern alias PrebuiltSystem;
-#endif
#if MONO_SECURITY_ALIAS
using MSI = MonoSecurity::Mono.Security.Interface;
#else
using MSI = Mono.Security.Interface;
#endif
-#if MONO_X509_ALIAS
-using XX509CertificateCollection = PrebuiltSystem::System.Security.Cryptography.X509Certificates.X509CertificateCollection;
-#else
-using XX509CertificateCollection = System.Security.Cryptography.X509Certificates.X509CertificateCollection;
-#endif
using System.IO;
using System.Net.Sockets;
//
#if CONFIGURATION_DEP
-extern alias PrebuiltSystem;
-
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Xml;
-using TypeConverter = PrebuiltSystem::System.ComponentModel.TypeConverter;
-
namespace System.Security.Authentication.ExtendedProtection.Configuration
{
internal static class ConfigUtil
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#if SECURITY_DEP
-#if MONO_X509_ALIAS
-extern alias PrebuiltSystem;
-#endif
-#if MONO_X509_ALIAS
-using XX509CertificateCollection = PrebuiltSystem::System.Security.Cryptography.X509Certificates.X509CertificateCollection;
-#else
using XX509CertificateCollection = System.Security.Cryptography.X509Certificates.X509CertificateCollection;
-#endif
using System;
using System.Runtime.InteropServices;
#if MONO_SECURITY_ALIAS
extern alias MonoSecurity;
#endif
-#if MONO_X509_ALIAS
-extern alias PrebuiltSystem;
-#endif
#if MONO_SECURITY_ALIAS
using MonoSecurity::Mono.Security.Interface;
var provider = MonoTlsProviderFactory.GetProvider ();
if (provider.HasNativeCertificates) {
var impl = provider.GetNativeCertificate (rawData, password, keyStorageFlags);
- return (X509Certificate2Impl)(object)impl;
+ return impl;
} else {
var impl = new X509Certificate2ImplMono ();
impl.Import (rawData, password, keyStorageFlags);
var provider = MonoTlsProviderFactory.GetProvider ();
if (provider.HasNativeCertificates) {
var impl = provider.GetNativeCertificate (cert);
- return (X509Certificate2Impl)(object)impl;
+ return impl;
}
var impl2 = cert.Impl as X509Certificate2Impl;
if (impl2 != null)
[TestFixture]
public class ClientWebSocketTest
{
- const string EchoServerUrl = "ws://echo.websocket.org";
+ const string EchoServerUrl = "ws://corefx-net.cloudapp.net/WebSocket/EchoWebSocket.ashx";
int Port = NetworkHelpers.FindFreePort ();
HttpListener listener;
ClientWebSocket socket;
else
sb.AppendFormat ("<0x{0:x5} + 0x{1:x5}> {2}", frame.GetMethodAddress (), frame.GetNativeOffset (), unknown);
} else {
- StackTraceHelper.GetFullNameForStackTrace (sb, frame.GetMethod ());
+ GetFullNameForStackTrace (sb, frame.GetMethod ());
if (frame.GetILOffset () == -1) {
sb.AppendFormat (" <0x{0:x5} + 0x{1:x5}>", frame.GetMethodAddress (), frame.GetNativeOffset ());
return i != 0;
}
+ public static void GetFullNameForStackTrace (StringBuilder sb, MethodBase mi)
+ {
+ var declaringType = mi.DeclaringType;
+ if (declaringType.IsGenericType && !declaringType.IsGenericTypeDefinition)
+ declaringType = declaringType.GetGenericTypeDefinition ();
+
+ // Get generic definition
+ const BindingFlags bindingflags = BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic;
+ foreach (var m in declaringType.GetMethods (bindingflags)) {
+ if (m.MetadataToken == mi.MetadataToken) {
+ mi = m;
+ break;
+ }
+ }
+
+ sb.Append (declaringType.ToString ());
+
+ sb.Append (".");
+ sb.Append (mi.Name);
+
+ if (mi.IsGenericMethod) {
+ Type[] gen_params = mi.GetGenericArguments ();
+ sb.Append ("[");
+ for (int j = 0; j < gen_params.Length; j++) {
+ if (j > 0)
+ sb.Append (",");
+ sb.Append (gen_params [j].Name);
+ }
+ sb.Append ("]");
+ }
+
+ ParameterInfo[] p = mi.GetParameters ();
+
+ sb.Append (" (");
+ for (int i = 0; i < p.Length; ++i) {
+ if (i > 0)
+ sb.Append (", ");
+
+ Type pt = p[i].ParameterType;
+ if (pt.IsGenericType && ! pt.IsGenericTypeDefinition)
+ pt = pt.GetGenericTypeDefinition ();
+
+ sb.Append (pt.ToString());
+
+ if (p [i].Name != null) {
+ sb.Append (" ");
+ sb.Append (p [i].Name);
+ }
+ }
+ sb.Append (")");
+ }
+
public override string ToString ()
{
StringBuilder sb = new StringBuilder ();
+++ /dev/null
-//
-// System.Diagnostics.StackTraceHelper.cs
-//
-// Author:
-// Marcos Henrich (marcos.henrich@xamarin.com)
-//
-// Copyright (C) Xamarin, Inc (http://www.xamarin.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace System.Diagnostics {
-
- using System.Text;
-#if INSIDE_CORLIB
- using System.Reflection;
-#else
- using IKVM.Reflection;
- using IKVM.Reflection.Reader;
- using Type = IKVM.Reflection.Type;
-#endif
- // This class exists so tools such as mono-symbolicate can use it directly.
- class StackTraceHelper {
-
- public static void GetFullNameForStackTrace (StringBuilder sb, MethodBase mi)
- {
- var declaringType = mi.DeclaringType;
- if (declaringType.IsGenericType && !declaringType.IsGenericTypeDefinition)
- declaringType = declaringType.GetGenericTypeDefinition ();
-
- // Get generic definition
- var bindingflags = BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic;
- foreach (var m in declaringType.GetMethods (bindingflags)) {
- if (m.MetadataToken == mi.MetadataToken) {
- mi = m;
- break;
- }
- }
-
- sb.Append (declaringType.ToString ());
-
- sb.Append (".");
- sb.Append (mi.Name);
-
- if (mi.IsGenericMethod) {
- Type[] gen_params = mi.GetGenericArguments ();
- sb.Append ("[");
- for (int j = 0; j < gen_params.Length; j++) {
- if (j > 0)
- sb.Append (",");
- sb.Append (gen_params [j].Name);
- }
- sb.Append ("]");
- }
-
- ParameterInfo[] p = mi.GetParameters ();
-
- sb.Append (" (");
- for (int i = 0; i < p.Length; ++i) {
- if (i > 0)
- sb.Append (", ");
-
- Type pt = p[i].ParameterType;
- if (pt.IsGenericType && ! pt.IsGenericTypeDefinition)
- pt = pt.GetGenericTypeDefinition ();
-
- sb.Append (pt.ToString());
-
- if (p [i].Name != null) {
- sb.Append (" ");
- sb.Append (p [i].Name);
- }
- }
- sb.Append (")");
- }
- }
-}
public static bool Wait(object obj, int millisecondsTimeout, bool exitContext) {
try {
- if (exitContext) {
-#if MONOTOUCH
- throw new NotSupportedException ("exitContext == true is not supported");
-#else
+#if !DISABLE_REMOTING
+ if (exitContext)
SynchronizationAttribute.ExitContext ();
#endif
- }
return Wait (obj, millisecondsTimeout);
}
finally {
- if (exitContext) SynchronizationAttribute.EnterContext ();
+#if !DISABLE_REMOTING
+ if (exitContext)
+ SynchronizationAttribute.EnterContext ();
+#endif
}
}
public static bool Wait(object obj, TimeSpan timeout, bool exitContext) {
try {
- if (exitContext) {
-#if MONOTOUCH
- throw new NotSupportedException ("exitContext == true is not supported");
-#else
+#if !DISABLE_REMOTING
+ if (exitContext)
SynchronizationAttribute.ExitContext ();
#endif
- }
return Wait (obj, timeout);
}
finally {
- if (exitContext) SynchronizationAttribute.EnterContext ();
+#if !DISABLE_REMOTING
+ if (exitContext)
+ SynchronizationAttribute.EnterContext ();
+#endif
}
}
static int WaitMultiple(WaitHandle[] waitHandles, int millisecondsTimeout, bool exitContext, bool WaitAll)
{
-#if MONOTOUCH
- if (exitContext)
- throw new NotSupportedException ("exitContext == true is not supported");
-#endif
-
int release_last = -1;
try {
+#if !DISABLE_REMOTING
if (exitContext)
SynchronizationAttribute.ExitContext ();
+#endif
for (int i = 0; i < waitHandles.Length; ++i) {
try {
}
if (WaitAll)
- return WaitAll_internal (waitHandles, millisecondsTimeout, exitContext);
+ return WaitAll_internal (waitHandles, millisecondsTimeout);
else
- return WaitAny_internal (waitHandles, millisecondsTimeout, exitContext);
+ return WaitAny_internal (waitHandles, millisecondsTimeout);
} finally {
for (int i = release_last; i >= 0; --i) {
waitHandles [i].SafeWaitHandle.DangerousRelease ();
}
+#if !DISABLE_REMOTING
if (exitContext)
SynchronizationAttribute.EnterContext ();
+#endif
}
}
[MethodImplAttribute(MethodImplOptions.InternalCall)]
- private static extern int WaitAll_internal(WaitHandle[] handles, int ms, bool exitContext);
+ private static extern int WaitAll_internal(WaitHandle[] handles, int ms);
[MethodImplAttribute(MethodImplOptions.InternalCall)]
- private static extern int WaitAny_internal(WaitHandle[] handles, int ms, bool exitContext);
+ private static extern int WaitAny_internal(WaitHandle[] handles, int ms);
static int WaitOneNative (SafeHandle waitableSafeHandle, uint millisecondsTimeout, bool hasThreadAffinity, bool exitContext)
{
-#if MONOTOUCH
- if (exitContext)
- throw new NotSupportedException ("exitContext == true is not supported");
-#endif
-
bool release = false;
try {
+#if !DISABLE_REMOTING
if (exitContext)
SynchronizationAttribute.ExitContext ();
+#endif
waitableSafeHandle.DangerousAddRef (ref release);
- return WaitOne_internal (waitableSafeHandle.DangerousGetHandle (), (int) millisecondsTimeout, exitContext);
+ return WaitOne_internal (waitableSafeHandle.DangerousGetHandle (), (int) millisecondsTimeout);
} finally {
if (release)
waitableSafeHandle.DangerousRelease ();
+#if !DISABLE_REMOTING
if (exitContext)
SynchronizationAttribute.EnterContext ();
+#endif
}
}
[MethodImplAttribute(MethodImplOptions.InternalCall)]
- static extern int WaitOne_internal(IntPtr handle, int ms, bool exitContext);
+ static extern int WaitOne_internal(IntPtr handle, int ms);
static int SignalAndWaitOne (SafeWaitHandle waitHandleToSignal,SafeWaitHandle waitHandleToWaitOn, int millisecondsTimeout, bool hasThreadAffinity, bool exitContext)
{
waitHandleToSignal.DangerousAddRef (ref releaseHandleToSignal);
waitHandleToWaitOn.DangerousAddRef (ref releaseHandleToWaitOn);
- return SignalAndWait_Internal (waitHandleToSignal.DangerousGetHandle (), waitHandleToWaitOn.DangerousGetHandle (), millisecondsTimeout, exitContext);
+ return SignalAndWait_Internal (waitHandleToSignal.DangerousGetHandle (), waitHandleToWaitOn.DangerousGetHandle (), millisecondsTimeout);
} finally {
if (releaseHandleToSignal)
waitHandleToSignal.DangerousRelease ();
}
[MethodImplAttribute(MethodImplOptions.InternalCall)]
- static extern int SignalAndWait_Internal (IntPtr toSignal, IntPtr toWaitOn, int ms, bool exitContext);
+ static extern int SignalAndWait_Internal (IntPtr toSignal, IntPtr toWaitOn, int ms);
}
}
* of icalls, do not require an increment.
*/
#pragma warning disable 169
- private const int mono_corlib_version = 145;
+ private const int mono_corlib_version = 146;
#pragma warning restore 169
[ComVisible (true)]
}
}
- delegate int IntNoArgs ();
+ public delegate int IntNoArgs ();
[Test]
public void CreateDelegateWithAbstractMethods ()
System.Diagnostics/Debugger.cs
System.Diagnostics/StackFrame.cs
System.Diagnostics/StackTrace.cs
-System.Diagnostics/StackTraceHelper.cs
System.Diagnostics.Tracing/EventAttribute.cs
System.Diagnostics.Tracing/EventCommand.cs
System.Diagnostics.Tracing/EventSource.cs
--- /dev/null
+// CS0023: The `?' operator cannot be applied to operand of type `T'
+// Line: 11
+
+class C2<T>
+{
+ C2<T> i;
+ T field;
+
+ public void Foo ()
+ {
+ var x = i?.field;
+ }
+}
\ No newline at end of file
--- /dev/null
+// CS0023: The `?' operator cannot be applied to operand of type `T'
+// Line: 13
+
+interface IFoo<T>
+{
+ T Call ();
+}
+
+class C1
+{
+ U Foo<T, U> (IFoo<T> t)
+ {
+ return t?.Call ();
+ }
+}
--- /dev/null
+// CS0023: The `?' operator cannot be applied to operand of type `T'
+// Line: 8
+
+class X
+{
+ static void Bug<T>(System.Func<T> func)
+ {
+ var r = func?.Invoke ();
+ }
+}
\ No newline at end of file
-// CS0029: Cannot implicitly convert type `B [cs0029-26, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]' to `B [CS0029-26-lib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=36f3ae7e947792e3]'
+// CS0029: Cannot implicitly convert type `B [cs0029-26, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null -- *PATH*/cs0029-26.cs]' to `B [CS0029-26-lib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=36f3ae7e947792e3 -- *PATH*/CS0029-26-lib.dll]'
// Line: 16
// Compiler options: -r:R1=CS0029-26-lib.dll
--- /dev/null
+// CS0266: Cannot implicitly convert type `Foo<int>.FooEvent' to `Foo<string>.FooEvent'. An explicit conversion exists (are you missing a cast?)
+// Line: 12
+
+class Foo<T> {
+ public event FooEvent Event;
+ public delegate T FooEvent();
+}
+
+class CompilerCrashTest {
+ static void Main() {
+ Foo<string> foo = new Foo<string>();
+ foo.Event += new Foo<int>.FooEvent (() => 0);
+ }
+}
TypeParameterSpec[] ITypeDefinition.TypeParameters {
get {
- return PartialContainer.CurrentTypeParameters.Types;
+ var ctp = PartialContainer.CurrentTypeParameters;
+ return ctp == null ? TypeParameterSpec.EmptyTypes : ctp.Types;
}
}
if (conditionalAccess) {
if (!ec.ConditionalAccess.Statement) {
- if (ec.ConditionalAccess.Type.IsNullableType)
- Nullable.LiftedNull.Create (ec.ConditionalAccess.Type, Location.Null).Emit (ec);
- else
+ var t = ec.ConditionalAccess.Type;
+ if (t.IsNullableType)
+ Nullable.LiftedNull.Create (t, Location.Null).Emit (ec);
+ else {
ec.EmitNull ();
+
+ if (t.IsGenericParameter)
+ ec.Emit (OpCodes.Unbox_Any, t);
+ }
}
ec.Emit (OpCodes.Br, ec.ConditionalAccess.EndLabel);
if ($4 == null)
report.Error (1586, GetLocation ($1), "Array creation must have array size or array initializer");
- $$ = new ArrayCreation ((FullNamedExpression) $2, (ComposedTypeSpecifier) $3, (ArrayInitializer) $4, GetLocation ($1));
+ $$ = new ArrayCreation ((FullNamedExpression) $2, (ComposedTypeSpecifier) $3, (ArrayInitializer) $4, GetLocation ($1)) {
+ NoEmptyInterpolation = true
+ };
}
| NEW rank_specifier array_initializer
{
void ResolveConditionalAccessReceiver (ResolveContext rc)
{
- // LAMESPEC: Not sure why this is explicitly disalloed with very odd error message
+ // LAMESPEC: Not sure why this is explicitly disallowed with very odd error message
if (!rc.HasSet (ResolveContext.Options.DontSetConditionalAccessReceiver) && method_group.HasConditionalAccess ()) {
Error_OperatorCannotBeApplied (rc, loc, "?", method_group.Type);
}
return false;
}
- protected static TypeSpec LiftMemberType (ResolveContext rc, TypeSpec type)
+ protected TypeSpec LiftMemberType (ResolveContext rc, TypeSpec type)
{
+ var tps = type as TypeParameterSpec;
+ if (tps != null && !(tps.IsReferenceType || tps.IsValueType)) {
+ Error_OperatorCannotBeApplied (rc, loc, "?", type);
+ }
+
return TypeSpec.IsValueType (type) && !type.IsNullableType ?
Nullable.NullableInfo.MakeType (rc.Module, type) :
type;
{
}
- public ExpressionStatement ResolveStatement (BlockContext ec)
+ public virtual ExpressionStatement ResolveStatement (BlockContext ec)
{
Expression e = Resolve (ec);
if (e == null)
}
}
+ bool statement_resolve;
+ public override ExpressionStatement ResolveStatement (BlockContext bc)
+ {
+ statement_resolve = true;
+ var es = base.ResolveStatement (bc);
+ statement_resolve = false;
+
+ return es;
+ }
+
protected override Expression DoResolve (ResolveContext rc)
{
ResolveConditionalAccessReceiver (rc);
var method = mg.BestCandidate;
type = mg.BestCandidateReturnType;
- if (conditional_access_receiver)
+ if (conditional_access_receiver && !statement_resolve)
type = LiftMemberType (ec, type);
if (arguments == null && method.DeclaringType.BuiltinType == BuiltinTypeSpec.Type.Object && method.Name == Destructor.MetadataName) {
{
}
+ public bool NoEmptyInterpolation { get; set; }
+
public ComposedTypeSpecifier Rank {
get {
return this.rank;
public override void Emit (EmitContext ec)
{
- if (EmitOptimizedEmpty (ec))
+ if (!NoEmptyInterpolation && EmitOptimizedEmpty (ec))
return;
var await_field = EmitToFieldSource (ec);
public string GetSignatureForErrorIncludingAssemblyName ()
{
- return string.Format ("{0} [{1}]", GetSignatureForError (), MemberDefinition.DeclaringAssembly.FullName);
+ var imported = MemberDefinition.DeclaringAssembly as ImportedAssemblyDefinition;
+
+ var location = imported != null ?
+ System.IO.Path.GetFullPath (imported.Location) :
+ ((MemberCore)MemberDefinition).Location.NameFullPath;
+
+ return string.Format ("{0} [{1} -- {2}]", GetSignatureForError (),
+ MemberDefinition.DeclaringAssembly.FullName,
+ location);
}
protected virtual string GetTypeNameSignature ()
--- /dev/null
+class X
+{
+ public static int Main ()
+ {
+ var a = new byte[] { };
+ var b = new byte[] { };
+ if (a.Equals (b))
+ return 1;
+
+ if (ReferenceEquals (a, b))
+ return 2;
+
+ b = new byte[0];
+ if (a.Equals (b))
+ return 3;
+
+ if (ReferenceEquals (a, b))
+ return 4;
+
+ return 0;
+ }
+}
\ No newline at end of file
--- /dev/null
+using System;
+
+interface IFoo<T>
+{
+ T Call ();
+}
+
+class C1
+{
+ public void Foo<T> (IFoo<T> t) where T : class
+ {
+ t?.Call ();
+ var x = t?.Call ();
+ }
+
+ public void Foo2<T> (IFoo<T> t)
+ {
+ t?.Call ();
+ }
+}
+
+class C2<T> where T : class
+{
+ C2<T> i;
+ T field;
+
+ public void Foo ()
+ {
+ var x = i?.field;
+ }
+}
+
+class Program
+{
+ static void Test<T>(Func<T> func) where T : struct
+ {
+ var r = func?.Invoke ();
+ }
+
+ static void Test2<T>(Func<T> func)
+ {
+ func?.Invoke ();
+ }
+
+ static void Main()
+ {
+ new C1 ().Foo<Program> (null);
+ new C1 ().Foo2<Program> (null);
+
+ new C2<string> ().Foo ();
+
+ Test (() => 1);
+ Test (() => 2);
+ }
+}
\ No newline at end of file
</type>
<type name="ExtensibleTester`1[U]">
<method name="Void Direct()" attrs="134">
- <size>24</size>
+ <size>25</size>
</method>
<method name="Void .ctor(U)" attrs="6278">
<size>15</size>
</type>
<type name="TestIssue.Program">
<method name="Int32 Main()" attrs="150">
- <size>31</size>
+ <size>32</size>
</method>
<method name="Void .ctor()" attrs="6278">
<size>7</size>
<size>7</size>
</method>
<method name="Int32 Main()" attrs="150">
- <size>36</size>
+ <size>37</size>
</method>
<method name="Void .ctor()" attrs="6278">
<size>7</size>
<test name="test-555.cs">
<type name="Test">
<method name="Int32 Main()" attrs="150">
- <size>360</size>
+ <size>361</size>
</method>
<method name="Void .ctor()" attrs="6278">
<size>7</size>
</method>
</type>
</test>
+ <test name="test-934.cs">
+ <type name="X">
+ <method name="Int32 Main()" attrs="150">
+ <size>106</size>
+ </method>
+ <method name="Void .ctor()" attrs="6278">
+ <size>7</size>
+ </method>
+ </type>
+ </test>
<test name="test-94.cs">
<type name="Base">
<method name="Int32 IVehicle.Start()" attrs="481">
<size>14</size>
</method>
<method name="Boolean MoveNext()" attrs="486">
- <size>167</size>
+ <size>168</size>
</method>
<method name="Void Dispose()" attrs="486">
<size>15</size>
</method>
</type>
</test>
+ <test name="test-null-operator-04.cs">
+ <type name="C1">
+ <method name="Void Foo[T](IFoo`1[T])" attrs="134">
+ <size>38</size>
+ </method>
+ <method name="Void Foo2[T](IFoo`1[T])" attrs="134">
+ <size>17</size>
+ </method>
+ <method name="Void .ctor()" attrs="6278">
+ <size>7</size>
+ </method>
+ </type>
+ <type name="C2`1[T]">
+ <method name="Void Foo()" attrs="134">
+ <size>33</size>
+ </method>
+ <method name="Void .ctor()" attrs="6278">
+ <size>7</size>
+ </method>
+ </type>
+ <type name="Program">
+ <method name="Void Test[T](System.Func`1[T])" attrs="145">
+ <size>31</size>
+ </method>
+ <method name="Void Test2[T](System.Func`1[T])" attrs="145">
+ <size>17</size>
+ </method>
+ <method name="Void Main()" attrs="145">
+ <size>102</size>
+ </method>
+ <method name="Int32 <Main>m__0()" attrs="145">
+ <size>9</size>
+ </method>
+ <method name="Int32 <Main>m__1()" attrs="145">
+ <size>9</size>
+ </method>
+ <method name="Void .ctor()" attrs="6278">
+ <size>7</size>
+ </method>
+ </type>
+ </test>
<test name="test-null-operator-05.cs">
<type name="CI">
<method name="Void set_Item(System.String, System.String)" attrs="2182">
static bool TryToMatchErrorMessage (string actual, string expected)
{
actual = actual.Replace ("\\", "/");
- var path_mask_start = expected.IndexOf ("*PATH*");
+ var path_mask_start = expected.IndexOf ("*PATH*", StringComparison.Ordinal);
if (path_mask_start > 0 && actual.Length > path_mask_start) {
- var path_mask_continue = expected.Substring (path_mask_start + 6);
- var expected_continue = actual.IndexOf (path_mask_continue, path_mask_start);
- if (expected_continue > 0) {
- var path = actual.Substring (path_mask_start, expected_continue - path_mask_start);
- if (actual == expected.Replace ("*PATH*", path))
- return true;
-
- throw new ApplicationException (expected.Replace ("*PATH*", path));
+ var parts = expected.Split (new [] { "*PATH*" }, StringSplitOptions.None);
+ foreach (var part in parts) {
+ if (!actual.Contains (part))
+ return false;
}
+
+ return true;
}
return false;
<Compile Include="AssemblyComparer.cs" />
<Compile Include="ClassComparer.cs" />
<Compile Include="ApiDiff.cs" />
- <Compile Include="..\..\..\class\Mono.Options\Mono.Options\Options.cs">
+ <Compile Include="..\..\class\Mono.Options\Mono.Options\Options.cs">
<Link>Options.cs</Link>
</Compile>
<Compile Include="ApiChange.cs" />
using System.IO;
using System.Linq;
using System.Text;
-using IKVM.Reflection;
-using System.Diagnostics;
using System.Collections.Generic;
-using Mono.CompilerServices.SymbolWriter;
-using System.Runtime.InteropServices;
+using Mono.Cecil;
+using Mono.Cecil.Cil;
+using Mono.Collections.Generic;
namespace Symbolicate
{
- struct Location {
- public string FileName;
- public int Line;
- }
-
class LocationProvider {
class AssemblyLocationProvider {
- Assembly assembly;
- MonoSymbolFile symbolFile;
+ AssemblyDefinition assembly;
string seqPointDataPath;
- public AssemblyLocationProvider (Assembly assembly, MonoSymbolFile symbolFile, string seqPointDataPath)
+ public AssemblyLocationProvider (AssemblyDefinition assembly, string seqPointDataPath)
{
this.assembly = assembly;
- this.symbolFile = symbolFile;
this.seqPointDataPath = seqPointDataPath;
}
- public bool TryGetLocation (string methodStr, string typeFullName, int offset, bool isOffsetIL, uint methodIndex, out Location location)
+ public SequencePoint TryGetLocation (string typeFullName, string methodSignature, int offset, bool isOffsetIL, uint methodIndex)
{
- location = default (Location);
- if (symbolFile == null)
- return false;
-
- var type = assembly.GetTypes().FirstOrDefault (t => t.FullName == typeFullName);
- if (type == null)
- return false;
+ if (!assembly.MainModule.HasSymbols)
+ return null;
+
+ TypeDefinition type = null;
+ var nested = typeFullName.Split ('+');
+ var types = assembly.MainModule.Types;
+ foreach (var ntype in nested) {
+ type = types.FirstOrDefault (t => t.Name == ntype);
+ if (type == null)
+ return null;
+
+ types = type.NestedTypes;
+ }
- var bindingflags = BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic;
- var method = type.GetMethods(bindingflags).FirstOrDefault (m => GetMethodFullName (m) == methodStr);
+ var parensStart = methodSignature.IndexOf ('(');
+ var methodName = methodSignature.Substring (0, parensStart).TrimEnd ();
+ var methodParameters = methodSignature.Substring (parensStart);
+ var method = type.Methods.FirstOrDefault (m => CompareName (m, methodName) && CompareParameters (m.Parameters, methodParameters));
if (method == null)
- return false;
+ return null;
- int ilOffset = (isOffsetIL)? offset : GetILOffsetFromFile (method.MetadataToken, methodIndex, offset);
+ int ilOffset = isOffsetIL ? offset : GetILOffsetFromFile (method.MetadataToken.ToInt32 (), methodIndex, offset);
if (ilOffset < 0)
- return false;
-
- var methodSymbol = symbolFile.Methods [(method.MetadataToken & 0x00ffffff) - 1];
-
- var lineNumbers = methodSymbol.GetLineNumberTable ().LineNumbers;
- var lineNumber = lineNumbers.FirstOrDefault (l => l.Offset >= ilOffset) ?? lineNumbers.Last ();
+ return null;
+
+ SequencePoint sp = null;
+ foreach (var instr in method.Body.Instructions) {
+ if (instr.SequencePoint != null)
+ sp = instr.SequencePoint;
+
+ if (instr.Offset >= ilOffset) {
+ return sp;
+ }
+ }
- location.FileName = symbolFile.Sources [lineNumber.File-1].FileName;
- location.Line = lineNumber.Row;
- return true;
+ return null;
}
SeqPointInfo seqPointInfo;
return seqPointInfo.GetILOffset (methodToken, methodIndex, nativeOffset);
}
- private string GetMethodFullName (MethodBase m)
+ static bool CompareName (MethodDefinition candidate, string expected)
+ {
+ if (candidate.Name == expected)
+ return true;
+
+ if (!candidate.HasGenericParameters)
+ return false;
+
+ var genStart = expected.IndexOf ('[');
+ if (genStart < 0)
+ return false;
+
+ if (candidate.Name != expected.Substring (0, genStart))
+ return false;
+
+ int arity = 1;
+ for (int pos = genStart; pos < expected.Length; ++pos) {
+ if (expected [pos] == ',')
+ ++arity;
+ }
+
+ return candidate.GenericParameters.Count == arity;
+ }
+
+ static bool CompareParameters (Collection<ParameterDefinition> candidate, string expected)
{
- StringBuilder sb = new StringBuilder ();
+ var builder = new StringBuilder ();
+ builder.Append ("(");
+
+ for (int i = 0; i < candidate.Count; i++) {
+ var parameter = candidate [i];
+ if (i > 0)
+ builder.Append (", ");
+
+ if (parameter.ParameterType.IsSentinel)
+ builder.Append ("...,");
+
+ var pt = parameter.ParameterType;
+ if (!string.IsNullOrEmpty (pt.Namespace)) {
+ builder.Append (pt.Namespace);
+ builder.Append (".");
+ }
+
+ FormatElementType (pt, builder);
- StackTraceHelper.GetFullNameForStackTrace (sb, m);
+ builder.Append (" ");
+ builder.Append (parameter.Name);
+ }
+
+ builder.Append (")");
- return sb.ToString ();
+ return builder.ToString () == expected;
+ }
+
+ static void FormatElementType (TypeReference tr, StringBuilder builder)
+ {
+ var ts = tr as TypeSpecification;
+ if (ts != null) {
+ if (ts.IsByReference) {
+ FormatElementType (ts.ElementType, builder);
+ builder.Append ("&");
+ return;
+ }
+
+ var array = ts as ArrayType;
+ if (array != null) {
+ FormatElementType (ts.ElementType, builder);
+ builder.Append ("[");
+
+ for (int ii = 0; ii < array.Rank - 1; ++ii) {
+ builder.Append (",");
+ }
+
+ builder.Append ("]");
+ return;
+ }
+ }
+
+ builder.Append (tr.Name);
}
}
- static readonly Universe ikvm_reflection = new Universe ();
Dictionary<string, AssemblyLocationProvider> assemblies;
HashSet<string> directories;
if (!File.Exists (assemblyPath))
throw new ArgumentException ("assemblyPath does not exist: "+ assemblyPath);
- var assembly = ikvm_reflection.LoadFile (assemblyPath);
- MonoSymbolFile symbolFile = null;
-
- var symbolPath = assemblyPath + ".mdb";
- if (!File.Exists (symbolPath))
- Debug.WriteLine (".mdb file was not found for " + assemblyPath);
- else
- symbolFile = MonoSymbolFile.ReadSymbolFile (symbolPath);
+ var readerParameters = new ReaderParameters { ReadSymbols = true };
+ var assembly = AssemblyDefinition.ReadAssembly (assemblyPath, readerParameters);
var seqPointDataPath = assemblyPath + ".msym";
if (!File.Exists (seqPointDataPath))
seqPointDataPath = null;
- assemblies.Add (assemblyPath, new AssemblyLocationProvider (assembly, symbolFile, seqPointDataPath));
+ assemblies.Add (assemblyPath, new AssemblyLocationProvider (assembly, seqPointDataPath));
+ // TODO: Should use AssemblyName with .net unification rules
directories.Add (Path.GetDirectoryName (assemblyPath));
- foreach (var assemblyRef in assembly.GetReferencedAssemblies ()) {
+ foreach (var assemblyRef in assembly.MainModule.AssemblyReferences) {
string refPath = null;
foreach (var dir in directories) {
refPath = Path.Combine (dir, assemblyRef.Name);
directories.Add (directory);
}
- public bool TryGetLocation (string method, string typeFullName, int offset, bool isOffsetIL, uint methodIndex, out Location location)
+ public SequencePoint TryGetLocation (string typeFullName, string methodSignature, int offset, bool isOffsetIL, uint methodIndex)
{
- location = default (Location);
foreach (var assembly in assemblies.Values) {
- if (assembly.TryGetLocation (method, typeFullName, offset, isOffsetIL, methodIndex, out location))
- return true;
+ var loc = assembly.TryGetLocation (typeFullName, methodSignature, offset, isOffsetIL, methodIndex);
+ if (loc != null)
+ return loc;
}
- return false;
+ return null;
}
}
}
LOCAL_MCS_FLAGS = \
/D:NO_AUTHENTICODE
-LIB_REFS = Mono.CompilerServices.SymbolWriter System.Xml System.Core System
+LIB_REFS = Mono.Cecil Mono.Cecil.Mdb System.Xml System.Core System
include ../../build/executable.make
test-local: all
$(BUILD_TEST_EXE)
- @echo "Checking $(PROGRAM) without AOT"
+ @echo "Checking $(TEST_EXE) without AOT"
$(CHECK_DIFF)
ifeq ($(AOT_SUPPORTED), 1)
- @echo "Checking $(PROGRAM) with AOT"
+ @echo "Checking $(TEST_EXE) with AOT"
@MONO_DEBUG=gen-compact-seq-points $(MONO) --aot $(TEST_EXE) > /dev/null
$(CHECK_DIFF)
- @echo "Checking $(PROGRAM) with AOT (using .msym)"
+ @echo "Checking $(TEST_EXE) with AOT (using .msym)"
$(BUILD_TEST_EXE)
@MONO_DEBUG=gen-compact-seq-points $(MONO) --aot=gen-seq-points-file $(TEST_EXE) > /dev/null
$(CHECK_DIFF)
symbolicate.cs
LocationProvider.cs
SeqPointInfo.cs
-../../class/corlib/System.Diagnostics/StackTraceHelper.cs
-../../../external/ikvm/reflect/*.cs
-../../../external/ikvm/reflect/Impl/*.cs
-../../../external/ikvm/reflect/Emit/*.cs
-../../../external/ikvm/reflect/Metadata/*.cs
-../../../external/ikvm/reflect/Reader/*.cs
-../../../external/ikvm/reflect/Writer/*.cs
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>\r
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">\r
+ <PropertyGroup>\r
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>\r
+ <Platform Condition=" '$(Platform)' == '' ">x86</Platform>\r
+ <ProjectGuid>{804E854F-E8F5-4E2B-807A-4FAF4BE99C03}</ProjectGuid>\r
+ <OutputType>Exe</OutputType>\r
+ <RootNamespace>monosymbolicate</RootNamespace>\r
+ <AssemblyName>monosymbolicate</AssemblyName>\r
+ <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>\r
+ <ProductVersion>8.0.30703</ProductVersion>\r
+ <SchemaVersion>2.0</SchemaVersion>\r
+ </PropertyGroup>\r
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">\r
+ <DebugSymbols>true</DebugSymbols>\r
+ <DebugType>full</DebugType>\r
+ <Optimize>false</Optimize>\r
+ <OutputPath>bin\Debug</OutputPath>\r
+ <DefineConstants>DEBUG;NO_AUTHENTICODE</DefineConstants>\r
+ <ErrorReport>prompt</ErrorReport>\r
+ <WarningLevel>4</WarningLevel>\r
+ <ExternalConsole>false</ExternalConsole>\r
+ <PlatformTarget>x86</PlatformTarget>\r
+ <Commandlineparameters></Commandlineparameters>\r
+ <ConsolePause>false</ConsolePause>\r
+ </PropertyGroup>\r
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">\r
+ <Optimize>true</Optimize>\r
+ <OutputPath>bin\Release</OutputPath>\r
+ <ErrorReport>prompt</ErrorReport>\r
+ <WarningLevel>4</WarningLevel>\r
+ <ExternalConsole>true</ExternalConsole>\r
+ <PlatformTarget>x86</PlatformTarget>\r
+ </PropertyGroup>\r
+ <ItemGroup>\r
+ <Reference Include="System" />\r
+ <Reference Include="Mono.Cecil">\r
+ <HintPath>..\..\class\lib\net_4_x\Mono.Cecil.dll</HintPath>\r
+ </Reference>\r
+ <Reference Include="Mono.Cecil.Mdb">\r
+ <HintPath>..\..\class\lib\net_4_x\Mono.Cecil.Mdb.dll</HintPath>\r
+ </Reference>\r
+ </ItemGroup>\r
+ <ItemGroup>\r
+ <Compile Include="LocationProvider.cs" />\r
+ <Compile Include="SeqPointInfo.cs" />\r
+ <Compile Include="symbolicate.cs" />\r
+ </ItemGroup>\r
+ <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />\r
+</Project>
\ No newline at end of file
if (!match.Success)
return line;
- string typeFullName;
+ string typeFullName, methodSignature;
var methodStr = match.Groups ["Method"].Value.Trim ();
- if (!TryParseMethodType (methodStr, out typeFullName))
+ if (!ExtractSignatures (methodStr, out typeFullName, out methodSignature))
return line;
var isOffsetIL = !string.IsNullOrEmpty (match.Groups ["IL"].Value);
if (!string.IsNullOrEmpty (match.Groups ["MethodIndex"].Value))
methodIndex = uint.Parse (match.Groups ["MethodIndex"].Value, CultureInfo.InvariantCulture);
- Location location;
- if (!locProvider.TryGetLocation (methodStr, typeFullName, offset, isOffsetIL, methodIndex, out location))
+ var loc = locProvider.TryGetLocation (typeFullName, methodSignature, offset, isOffsetIL, methodIndex);
+ if (loc == null)
return line;
- return line.Replace ("<filename unknown>:0", string.Format ("{0}:{1}", location.FileName, location.Line));
+ return line.Replace ("<filename unknown>:0", string.Format ("{0}:{1}", loc.Document.Url, loc.StartLine));
}
- static bool TryParseMethodType (string str, out string typeFullName)
+ static bool ExtractSignatures (string str, out string typeFullName, out string methodSignature)
{
- typeFullName = null;
-
- var methodNameEnd = str.IndexOf ("(");
- if (methodNameEnd == -1)
+ var methodNameEnd = str.IndexOf ('(');
+ if (methodNameEnd == -1) {
+ typeFullName = methodSignature = null;
return false;
+ }
- // Remove parameters
- str = str.Substring (0, methodNameEnd);
-
- // Remove generic parameters
- str = Regex.Replace (str, @"\[[^\[\]]*\]", "");
-
- var typeNameEnd = str.LastIndexOf (".");
- if (methodNameEnd == -1 || typeNameEnd == -1)
+ var typeNameEnd = str.LastIndexOf ('.', methodNameEnd);
+ if (typeNameEnd == -1) {
+ typeFullName = methodSignature = null;
return false;
+ }
+
+ // Adjustment for Type..ctor ()
+ if (typeNameEnd > 0 && str [typeNameEnd - 1] == '.') {
+ --typeNameEnd;
+ }
- // Remove method name
typeFullName = str.Substring (0, typeNameEnd);
+ // Remove generic parameters
+ typeFullName = Regex.Replace (typeFullName, @"\[[^\[\]]*\]", "");
+ methodSignature = str.Substring (typeNameEnd + 1);
return true;
}
}
SetLastError (ERROR_INVALID_PARAMETER);
return(FALSE);
}
-
+
+ if (sizeof (utbuf.actime) == 4 && ((access_ticks - 116444736000000000ULL) / 10000000) > INT_MAX) {
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: attempt to set write time that is too big for a 32bits time_t",
+ __func__);
+ SetLastError (ERROR_INVALID_PARAMETER);
+ return(FALSE);
+ }
+
utbuf.actime=(access_ticks - 116444736000000000ULL) / 10000000;
} else {
utbuf.actime=statbuf.st_atime;
SetLastError (ERROR_INVALID_PARAMETER);
return(FALSE);
}
+ if (sizeof (utbuf.modtime) == 4 && ((write_ticks - 116444736000000000ULL) / 10000000) > INT_MAX) {
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: attempt to set write time that is too big for a 32bits time_t",
+ __func__);
+ SetLastError (ERROR_INVALID_PARAMETER);
+ return(FALSE);
+ }
utbuf.modtime=(write_ticks - 116444736000000000ULL) / 10000000;
} else {
* Changes which are already detected at runtime, like the addition
* of icalls, do not require an increment.
*/
-#define MONO_CORLIB_VERSION 145
+#define MONO_CORLIB_VERSION 146
typedef struct
{
if (! (field->type->attrs & FIELD_ATTRIBUTE_STATIC))
return -1;
value = mono_field_get_value_object_checked (mono_domain_get (), field, NULL, &error);
- mono_error_raise_exception (&error); /* FIXME don't raise here */
+ mono_error_assert_ok (&error);
return *(gint32*)((gchar*)value + sizeof (MonoObject));
}
klass = mono_class_load_from_name (mono_defaults.corlib, "System", "AppDomainSetup");
setup = (MonoAppDomainSetup *) mono_object_new_checked (mono_domain_get (), klass, &error);
- mono_error_raise_exception (&error); /* FIXME don't raise here */
+ if (!is_ok (&error))
+ goto fail;
setup->configuration_file = configuration_file != NULL ? mono_string_new (mono_domain_get (), configuration_file) : NULL;
ad = mono_domain_create_appdomain_internal (friendly_name, setup, &error);
- mono_error_raise_exception (&error); /* FIXME don't raise here */
+ if (!is_ok (&error))
+ goto fail;
return mono_domain_from_appdomain (ad);
+fail:
+ mono_error_cleanup (&error);
+ return NULL;
}
/**
MonoAppDomain *
ves_icall_System_AppDomain_createDomain (MonoString *friendly_name, MonoAppDomainSetup *setup)
{
+ MonoError error;
+ MonoAppDomain *ad = NULL;
#ifdef DISABLE_APPDOMAINS
- mono_set_pending_exception (mono_get_exception_not_supported ("AppDomain creation is not supported on this runtime."));
- return NULL;
+ mono_error_set_not_supported (&error, "AppDomain creation is not supported on this runtime.");
#else
- MonoError error;
char *fname;
- MonoAppDomain *ad;
fname = mono_string_to_utf8 (friendly_name);
ad = mono_domain_create_appdomain_internal (fname, setup, &error);
g_free (fname);
-
- mono_error_raise_exception (&error);
-
- return ad;
#endif
+ mono_error_set_pending_exception (&error);
+ return ad;
}
MonoArray *
}
mono_domain_assemblies_unlock (domain);
- res = mono_array_new (domain, mono_class_get_assembly_class (), assemblies->len);
+ res = mono_array_new_checked (domain, mono_class_get_assembly_class (), assemblies->len, &error);
+ if (!is_ok (&error))
+ goto leave;
for (i = 0; i < assemblies->len; ++i) {
ass = (MonoAssembly *)g_ptr_array_index (assemblies, i);
MonoReflectionAssembly *ass_obj = mono_assembly_get_object_checked (domain, ass, &error);
/* FIXME: We invoke managed code here, so there is a potential for deadlocks */
str = mono_string_new (domain, aname_str);
+ g_free (aname_str);
if (!str) {
- g_free (aname_str);
return NULL;
}
assembly = mono_try_assembly_resolve (domain, str, requesting, refonly, &error);
- if (!mono_error_ok (&error)) {
- g_free (aname_str);
- mono_error_raise_exception (&error); /* FIXME don't raise here */
- }
-
- g_free (aname_str);
+ mono_error_cleanup (&error);
if (assembly)
return assembly->assembly;
*params = ref_assembly;
mono_runtime_invoke_checked (assembly_load_method, domain->domain, params, &error);
- mono_error_raise_exception (&error); /* FIXME don't raise here */
+ mono_error_cleanup (&error);
}
/*
if (!method)
g_error ("No entry point method found in %s due to %s", image->name, mono_error_get_message (&error));
- if (!args)
- args = (MonoArray *) mono_array_new (ad->data, mono_defaults.string_class, 0);
+ if (!args) {
+ args = (MonoArray *) mono_array_new_checked (ad->data, mono_defaults.string_class, 0, &error);
+ mono_error_assert_ok (&error);
+ }
return mono_runtime_exec_main (method, (MonoArray *)args, NULL);
}
MonoError error;
MonoString *res = NULL;
res = mono_string_new_utf16_checked (mono_domain_get (), process_guid, sizeof(process_guid)/2, &error);
- mono_error_raise_exception (&error);
+ mono_error_set_pending_exception (&error);
return res;
}
memcpy (process_guid, mono_string_chars(newguid), sizeof(process_guid));
/* Have to attach to the runtime so shutdown can wait for this thread */
/* Force it to be attached to avoid racing during shutdown. */
thread = mono_thread_attach_full (mono_get_root_domain (), TRUE, &error);
- mono_error_raise_exception (&error); /* FIXME don't raise here */
+ if (!is_ok (&error)) {
+ data->failure_reason = g_strdup (mono_error_get_message (&error));
+ mono_error_cleanup (&error);
+ goto failure;
+ }
mono_thread_set_name_internal (thread->internal_thread, mono_string_new (mono_get_root_domain (), "Domain unloader"), TRUE, &error);
- mono_error_raise_exception (&error); /* FIXME don't raise here */
+ if (!is_ok (&error)) {
+ data->failure_reason = g_strdup (mono_error_get_message (&error));
+ mono_error_cleanup (&error);
+ goto failure;
+ }
/*
* FIXME: Abort our parent thread last, so we can return a failure
if (!mono_assembly_is_in_gac (fname)) {
MonoError error;
new_fname = mono_make_shadow_copy (fname, &error);
- mono_error_raise_exception (&error); /* FIXME don't raise here */
+ if (!is_ok (&error)) {
+ mono_trace (G_LOG_LEVEL_INFO, MONO_TRACE_ASSEMBLY,
+ "Assembly Loader shadow copy error: %s.", mono_error_get_message (&error));
+ mono_error_cleanup (&error);
+ *status = MONO_IMAGE_IMAGE_INVALID;
+ g_free (fname);
+ return NULL;
+ }
}
if (new_fname && new_fname != fname) {
g_free (fname);
MonoReflectionAssembly *refasm;
refasm = mono_try_assembly_resolve (domain, mono_string_new (domain, name), NULL, FALSE, &error);
- if (!mono_error_ok (&error)) {
+ if (!is_ok (&error)) {
g_free (fullname);
mono_assembly_name_free (aname);
- mono_error_raise_exception (&error); /* FIXME don't raise here */
+ mono_error_cleanup (&error);
+ if (*status == MONO_IMAGE_OK)
+ *status = MONO_IMAGE_IMAGE_INVALID;
}
if (refasm)
return 1;
}
+
+ main_args = (MonoArray*)mono_array_new_checked (domain, mono_defaults.string_class, (args == NULL) ? 0 : 1, &error);
+ if (main_args == NULL) {
+ g_print ("Could not allocate main method args due to %s\n", mono_error_get_message (&error));
+ mono_error_cleanup (&error);
+ g_free (agent);
+ return 1;
+ }
+
if (args) {
- main_args = (MonoArray*)mono_array_new (domain, mono_defaults.string_class, 1);
mono_array_set (main_args, MonoString*, 0, mono_string_new (domain, args));
- } else {
- main_args = (MonoArray*)mono_array_new (domain, mono_defaults.string_class, 0);
}
- g_free (agent);
pa [0] = main_args;
mono_runtime_try_invoke (method, NULL, pa, exc, &error);
- mono_error_raise_exception (&error); /* FIXME don't raise here */
+ if (!is_ok (&error)) {
+ g_print ("The entry point method of assembly '%s' could not be executed due to %s\n", agent, mono_error_get_message (&error));
+ mono_error_cleanup (&error);
+ g_free (agent);
+ return 1;
+ }
+
+ g_free (agent);
return 0;
}
mono_lookup_dynamic_token_class (MonoImage *image, guint32 token, gboolean check_token, MonoClass **handle_class, MonoGenericContext *context, MonoError *error);
gpointer
-mono_runtime_create_jump_trampoline (MonoDomain *domain, MonoMethod *method, gboolean add_sync_wrapper);
+mono_runtime_create_jump_trampoline (MonoDomain *domain, MonoMethod *method, gboolean add_sync_wrapper, MonoError *error);
gpointer
mono_runtime_create_delegate_trampoline (MonoClass *klass);
result->sre_method = FALSE;
result->signature = NULL;
- if (!context->method_inst) {
+ if (iresult->context.method_inst) {
/* Set the generic_container of the result to the generic_container of method */
MonoGenericContainer *generic_container = mono_method_get_generic_container (method);
- if (generic_container) {
+ if (generic_container && iresult->context.method_inst == generic_container->context.method_inst) {
result->is_generic = 1;
mono_method_set_generic_container (result, generic_container);
}
return FALSE;
}
+static gboolean debug_check;
+
MonoClass *
mono_class_get_generic_type_definition (MonoClass *klass)
{
{
int access_level;
+ if (access_klass == member_klass)
+ return TRUE;
+
if (access_klass->image->assembly && access_klass->image->assembly->corlib_internal)
return TRUE;
gboolean
mono_method_can_access_method (MonoMethod *method, MonoMethod *called)
{
- int can = can_access_member (method->klass, called->klass, NULL, called->flags & METHOD_ATTRIBUTE_MEMBER_ACCESS_MASK);
- if (!can) {
- MonoClass *nested = method->klass->nested_in;
- while (nested) {
- can = can_access_member (nested, called->klass, NULL, called->flags & METHOD_ATTRIBUTE_MEMBER_ACCESS_MASK);
- if (can)
- return TRUE;
- nested = nested->nested_in;
- }
+ gboolean res = mono_method_can_access_method_full (method, called, NULL);
+ if (!res) {
+ printf ("FAILED TO VERIFY %s calling %s\n", mono_method_full_name (method, 1), mono_method_full_name (called, 1));
+ debug_check = TRUE;
+ mono_method_can_access_method_full (method, called, NULL);
+ debug_check = FALSE;
}
- /*
- * FIXME:
- * with generics calls to explicit interface implementations can be expressed
- * directly: the method is private, but we must allow it. This may be opening
- * a hole or the generics code should handle this differently.
- * Maybe just ensure the interface type is public.
- */
- if ((called->flags & METHOD_ATTRIBUTE_VIRTUAL) && (called->flags & METHOD_ATTRIBUTE_FINAL))
- return TRUE;
- return can;
+
+ return res;
}
/*
gboolean
mono_method_can_access_method_full (MonoMethod *method, MonoMethod *called, MonoClass *context_klass)
{
+ if (debug_check) printf ("CHECKING %s -> %s (%p)\n", mono_method_full_name (method, 1), mono_method_full_name (called, 1), context_klass);
MonoClass *access_class = method->klass;
MonoClass *member_class = called->klass;
int can = can_access_member (access_class, member_class, context_klass, called->flags & METHOD_ATTRIBUTE_MEMBER_ACCESS_MASK);
if (!can) {
+ if (debug_check) printf ("\tcan_access_member failed\n");
MonoClass *nested = access_class->nested_in;
while (nested) {
can = can_access_member (nested, member_class, context_klass, called->flags & METHOD_ATTRIBUTE_MEMBER_ACCESS_MASK);
break;
nested = nested->nested_in;
}
+ if (!can && debug_check) printf ("\tcan_access_member nest check failed\n");
}
if (!can)
return FALSE;
+ if (debug_check) printf ("\ttype checking %s(%p) -> %s(%p)\n",
+ mono_type_get_full_name (access_class), access_class,
+ mono_type_get_full_name (member_class), member_class);
can = can_access_type (access_class, member_class);
if (!can) {
+ if (debug_check) printf ("\tcan_access_type check failed\n");
MonoClass *nested = access_class->nested_in;
while (nested) {
can = can_access_type (nested, member_class);
break;
nested = nested->nested_in;
}
+ if (!can && debug_check) printf ("\tcan_access_type nest check failed\n");
}
if (!can)
if (called->is_inflated) {
MonoMethodInflated * infl = (MonoMethodInflated*)called;
- if (infl->context.method_inst && !can_access_instantiation (access_class, infl->context.method_inst))
+ if (infl->context.method_inst && !can_access_instantiation (access_class, infl->context.method_inst)) {
+ if (debug_check) printf ("\tginst check failed\n");
return FALSE;
+ }
}
return TRUE;
MonoBoolean
ves_icall_System_ConsoleDriver_TtySetup (MonoString *keypad, MonoString *teardown, MonoArray **control_chars, int **size)
{
+ MonoError error;
+
int dims;
dims = terminal_get_dimensions ();
/* 17 is the number of entries set in set_control_chars() above.
* NCCS is the total size, but, by now, we only care about those 17 values*/
- mono_gc_wbarrier_generic_store (control_chars, (MonoObject*) mono_array_new (mono_domain_get (), mono_defaults.byte_class, 17));
+ MonoArray *control_chars_arr = mono_array_new_checked (mono_domain_get (), mono_defaults.byte_class, 17, &error);
+ if (mono_error_set_pending_exception (&error))
+ return FALSE;
+ mono_gc_wbarrier_generic_store (control_chars, (MonoObject*) control_chars_arr);
if (tcgetattr (STDIN_FILENO, &initial_attr) == -1)
return FALSE;
mono_assembly_load_friends (ass);
- mono_defaults.handleref_class = mono_class_load_from_name (
+ mono_defaults.handleref_class = mono_class_try_load_from_name (
mono_defaults.corlib, "System.Runtime.InteropServices", "HandleRef");
mono_defaults.attribute_class = mono_class_load_from_name (
g_slist_free (domain->domain_assemblies);
domain->domain_assemblies = NULL;
- /*
- * Send this after the assemblies have been unloaded and the domain is still in a
- * usable state.
- */
- mono_profiler_appdomain_event (domain, MONO_PROFILE_END_UNLOAD);
-
if (free_domain_hook)
free_domain_hook (domain);
ves_icall_System_IO_MonoIO_GetFileSystemEntries (MonoString *path,
MonoString *path_with_pattern,
gint attrs, gint mask,
- gint32 *error)
+ gint32 *ioerror)
{
+ MonoError error;
MonoDomain *domain = mono_domain_get ();
MonoArray *result;
int i;
GPtrArray *names;
- *error = ERROR_SUCCESS;
+ *ioerror = ERROR_SUCCESS;
MONO_PREPARE_BLOCKING;
- names = get_filesystem_entries (mono_string_chars (path), mono_string_chars (path_with_pattern), attrs, mask, error);
+ names = get_filesystem_entries (mono_string_chars (path), mono_string_chars (path_with_pattern), attrs, mask, ioerror);
MONO_FINISH_BLOCKING;
if (!names) {
// If there's no array and no error, then return an empty array.
- if (*error == ERROR_SUCCESS)
- return mono_array_new (domain, mono_defaults.string_class, 0);
+ if (*ioerror == ERROR_SUCCESS) {
+ MonoArray *arr = mono_array_new_checked (domain, mono_defaults.string_class, 0, &error);
+ mono_error_set_pending_exception (&error);
+ return arr;
+ }
return NULL;
}
- result = mono_array_new (domain, mono_defaults.string_class, names->len);
+ result = mono_array_new_checked (domain, mono_defaults.string_class, names->len, &error);
+ if (mono_error_set_pending_exception (&error))
+ goto leave;
for (i = 0; i < names->len; i++) {
mono_array_setref (result, i, mono_string_new (domain, (const char *)g_ptr_array_index (names, i)));
g_free (g_ptr_array_index (names, i));
}
+leave:
g_ptr_array_free (names, TRUE);
return result;
}
MonoArray *
ves_icall_System_IO_MonoIO_get_InvalidPathChars ()
{
+ MonoError error;
MonoArray *chars;
MonoDomain *domain;
int i, n;
domain = mono_domain_get ();
n = sizeof (invalid_path_chars) / sizeof (gunichar2);
- chars = mono_array_new (domain, mono_defaults.char_class, n);
+ chars = mono_array_new_checked (domain, mono_defaults.char_class, n, &error);
+ if (mono_error_set_pending_exception (&error))
+ return NULL;
for (i = 0; i < n; ++ i)
mono_array_set (chars, gunichar2, i, invalid_path_chars [i]);
mono_gc_finalize_threadpool_threads ();
}
+ mono_profiler_appdomain_event (domain, MONO_PROFILE_END_UNLOAD);
+
return TRUE;
}
ICALL_TYPE(ARRAY, "System.Array", ARRAY_1)
ICALL(ARRAY_1, "ClearInternal", ves_icall_System_Array_ClearInternal)
-ICALL(ARRAY_2, "Clone", mono_array_clone)
+ICALL(ARRAY_2, "Clone", ves_icall_System_Array_Clone)
ICALL(ARRAY_3, "CreateInstanceImpl", ves_icall_System_Array_CreateInstanceImpl)
ICALL(ARRAY_14, "CreateInstanceImpl64", ves_icall_System_Array_CreateInstanceImpl64)
ICALL(ARRAY_4, "FastCopy", ves_icall_System_Array_FastCopy)
ICALL_TYPE(ENV, "System.Environment", ENV_1)
ICALL(ENV_1, "Exit", ves_icall_System_Environment_Exit)
-ICALL(ENV_2, "GetCommandLineArgs", mono_runtime_get_main_args)
+ICALL(ENV_2, "GetCommandLineArgs", ves_icall_System_Environment_GetCoomandLineArgs)
ICALL(ENV_3, "GetEnvironmentVariableNames", ves_icall_System_Environment_GetEnvironmentVariableNames)
ICALL(ENV_31, "GetIs64BitOperatingSystem", ves_icall_System_Environment_GetIs64BitOperatingSystem)
ICALL(ENV_4, "GetLogicalDrivesInternal", ves_icall_System_Environment_GetLogicalDrives )
mono_gc_bzero_atomic (mono_array_addr_with_size_fast (arr, sz, idx), length * sz);
}
+ICALL_EXPORT MonoArray*
+ves_icall_System_Array_Clone (MonoArray *arr)
+{
+ MonoError error;
+ MonoArray *result = mono_array_clone_checked (arr, &error);
+ mono_error_set_pending_exception (&error);
+ return result;
+}
+
ICALL_EXPORT gboolean
ves_icall_System_Array_FastCopy (MonoArray *source, int source_idx, MonoArray* dest, int dest_idx, int length)
{
if (values) {
int i;
- mono_gc_wbarrier_generic_store (fields, (MonoObject*) mono_array_new (mono_domain_get (), mono_defaults.object_class, count));
+ MonoArray *fields_arr = mono_array_new_checked (mono_domain_get (), mono_defaults.object_class, count, &error);
+ if (mono_error_set_pending_exception (&error))
+ return 0;
+ mono_gc_wbarrier_generic_store (fields, (MonoObject*) fields_arr);
for (i = 0; i < count; ++i)
mono_array_setref (*fields, i, values [i]);
} else {
if (values) {
int i;
- mono_gc_wbarrier_generic_store (fields, (MonoObject*) mono_array_new (mono_domain_get (), mono_defaults.object_class, count));
+ MonoArray *fields_arr = mono_array_new_checked (mono_domain_get (), mono_defaults.object_class, count, &error);
+ if (mono_error_set_pending_exception (&error))
+ return FALSE;
+ mono_gc_wbarrier_generic_store (fields, (MonoObject*) fields_arr);
for (i = 0; i < count; ++i)
mono_array_setref_fast (*fields, i, values [i]);
return FALSE;
int i, n = 0;
while (event->event->other [n])
n++;
- MONO_STRUCT_SETREF (info, other_methods, mono_array_new (domain, mono_defaults.method_info_class, n));
+ MonoArray *info_arr = mono_array_new_checked (domain, mono_defaults.method_info_class, n, &error);
+ if (mono_error_set_pending_exception (&error))
+ return;
+ MONO_STRUCT_SETREF (info, other_methods, info_arr);
for (i = 0; i < n; i++) {
rm = mono_method_get_object_checked (domain, event->event->other [i], NULL, &error);
len = g_hash_table_size (iface_hash);
if (len == 0) {
g_hash_table_destroy (iface_hash);
- if (!data.domain->empty_types)
- data.domain->empty_types = mono_array_new_cached (data.domain, mono_defaults.monotype_class, 0);
+ if (!data.domain->empty_types) {
+ data.domain->empty_types = mono_array_new_cached (data.domain, mono_defaults.monotype_class, 0, &error);
+ if (!is_ok (&error))
+ goto fail;
+ }
return data.domain->empty_types;
}
- data.iface_array = mono_array_new_cached (data.domain, mono_defaults.monotype_class, len);
+ data.iface_array = mono_array_new_cached (data.domain, mono_defaults.monotype_class, len, &error);
+ if (!is_ok (&error))
+ goto fail;
g_hash_table_foreach (iface_hash, fill_iface_array, &data);
if (!mono_error_ok (&error))
goto fail;
len = mono_class_num_methods (iclass);
domain = mono_object_domain (type);
- mono_gc_wbarrier_generic_store (targets, (MonoObject*) mono_array_new (domain, mono_defaults.method_info_class, len));
- mono_gc_wbarrier_generic_store (methods, (MonoObject*) mono_array_new (domain, mono_defaults.method_info_class, len));
+ MonoArray *targets_arr = mono_array_new_checked (domain, mono_defaults.method_info_class, len, &error);
+ if (mono_error_set_pending_exception (&error))
+ return;
+ mono_gc_wbarrier_generic_store (targets, (MonoObject*) targets_arr);
+ MonoArray *methods_arr = mono_array_new_checked (domain, mono_defaults.method_info_class, len, &error);
+ if (mono_error_set_pending_exception (&error))
+ return;
+ mono_gc_wbarrier_generic_store (methods, (MonoObject*) methods_arr);
iter = NULL;
while ((method = mono_class_get_methods (iclass, &iter))) {
member = mono_method_get_object_checked (domain, method, iclass, &error);
}
static MonoArray*
-create_type_array (MonoDomain *domain, MonoBoolean runtimeTypeArray, int count)
+create_type_array (MonoDomain *domain, MonoBoolean runtimeTypeArray, int count, MonoError *error)
{
- MonoArray *res;
- res = mono_array_new (domain, runtimeTypeArray ? mono_defaults.runtimetype_class : mono_defaults.systemtype_class, count);
- return res;
+ return mono_array_new_checked (domain, runtimeTypeArray ? mono_defaults.runtimetype_class : mono_defaults.systemtype_class, count, error);
}
ICALL_EXPORT MonoArray*
if (klass->generic_container) {
MonoGenericContainer *container = klass->generic_container;
- res = create_type_array (domain, runtimeTypeArray, container->type_argc);
+ res = create_type_array (domain, runtimeTypeArray, container->type_argc, &error);
+ if (mono_error_set_pending_exception (&error))
+ return NULL;
for (i = 0; i < container->type_argc; ++i) {
pklass = mono_class_from_generic_parameter_internal (mono_generic_container_get_param (container, i));
}
} else if (klass->generic_class) {
MonoGenericInst *inst = klass->generic_class->context.class_inst;
- res = create_type_array (domain, runtimeTypeArray, inst->type_argc);
+ res = create_type_array (domain, runtimeTypeArray, inst->type_argc, &error);
+ if (mono_error_set_pending_exception (&error))
+ return NULL;
for (i = 0; i < inst->type_argc; ++i) {
rt = mono_type_get_object_checked (domain, inst->type_argv [i], &error);
if (mono_error_set_pending_exception (&error))
for (count = 0, ptr = param_info->constraints; ptr && *ptr; ptr++, count++)
;
- res = mono_array_new (domain, mono_defaults.monotype_class, count);
+ res = mono_array_new_checked (domain, mono_defaults.monotype_class, count, &error);
+ if (mono_error_set_pending_exception (&error))
+ return NULL;
for (i = 0; i < count; i++) {
rt = mono_type_get_object_checked (domain, ¶m_info->constraints [i]->byval_arg, &error);
if (mono_error_set_pending_exception (&error))
if (inst) {
count = inst->type_argc;
- res = mono_array_new (domain, mono_defaults.systemtype_class, count);
+ res = mono_array_new_checked (domain, mono_defaults.systemtype_class, count, &error);
+ if (mono_error_set_pending_exception (&error))
+ return NULL;
for (i = 0; i < count; i++) {
rt = mono_type_get_object_checked (domain, inst->type_argv [i], &error);
}
count = mono_method_signature (method->method)->generic_param_count;
- res = mono_array_new (domain, mono_defaults.systemtype_class, count);
+ res = mono_array_new_checked (domain, mono_defaults.systemtype_class, count, &error);
+ if (mono_error_set_pending_exception (&error))
+ return NULL;
for (i = 0; i < count; i++) {
MonoGenericContainer *container = mono_method_get_generic_container (method->method);
do {
MonoClassField* field = mono_class_get_field_from_name (k, str);
if (field) {
+ g_free (str);
MonoClass *field_klass = mono_class_from_mono_type (field->type);
if (field_klass->valuetype) {
result = mono_value_box_checked (domain, field_klass, (char *)this_arg + field->offset, &error);
- mono_error_set_pending_exception (&error);
- /* fallthru to cleanup */
+ if (mono_error_set_pending_exception (&error))
+ return NULL;
} else
result = (MonoObject *)*((gpointer *)((char *)this_arg + field->offset));
- out_args = mono_array_new (domain, mono_defaults.object_class, 1);
+ out_args = mono_array_new_checked (domain, mono_defaults.object_class, 1, &error);
+ if (mono_error_set_pending_exception (&error))
+ return NULL;
mono_gc_wbarrier_generic_store (outArgs, (MonoObject*) out_args);
mono_array_setref (out_args, 0, result);
- g_free (str);
return NULL;
}
k = k->parent;
do {
MonoClassField* field = mono_class_get_field_from_name (k, str);
if (field) {
+ g_free (str);
MonoClass *field_klass = mono_class_from_mono_type (field->type);
MonoObject *val = (MonoObject *)mono_array_get (params, gpointer, 2);
mono_gc_wbarrier_set_field (this_arg, (char*)this_arg + field->offset, val);
}
- out_args = mono_array_new (domain, mono_defaults.object_class, 0);
+ out_args = mono_array_new_checked (domain, mono_defaults.object_class, 0, &error);
+ if (mono_error_set_pending_exception (&error))
+ return NULL;
mono_gc_wbarrier_generic_store (outArgs, (MonoObject*) out_args);
- g_free (str);
return NULL;
}
outarg_count++;
}
- out_args = mono_array_new (domain, mono_defaults.object_class, outarg_count);
-
+ out_args = mono_array_new_checked (domain, mono_defaults.object_class, outarg_count, &error);
+ if (mono_error_set_pending_exception (&error))
+ return NULL;
+
/* handle constructors only for objects already allocated */
if (!strcmp (method->method->name, ".ctor"))
g_assert (this_arg);
base_type = mono_class_enum_basetype (enumc)->type;
nvalues = mono_class_num_fields (enumc) ? mono_class_num_fields (enumc) - 1 : 0;
- *names = mono_array_new (domain, mono_defaults.string_class, nvalues);
- *values = mono_array_new (domain, mono_defaults.uint64_class, nvalues);
+ *names = mono_array_new_checked (domain, mono_defaults.string_class, nvalues, &error);
+ if (mono_error_set_pending_exception (&error))
+ return FALSE;
+ *values = mono_array_new_checked (domain, mono_defaults.uint64_class, nvalues, &error);
+ if (mono_error_set_pending_exception (&error))
+ return FALSE;
iter = NULL;
while ((field = mono_class_get_fields (enumc, &iter))) {
MonoPtrArray tmp_array;
domain = ((MonoObject *)type)->vtable->domain;
- if (type->type->byref)
- return mono_array_new (domain, mono_defaults.field_info_class, 0);
+ if (type->type->byref) {
+ MonoArray *result = mono_array_new_checked (domain, mono_defaults.field_info_class, 0, &error);
+ mono_error_set_pending_exception (&error);
+ return result;
+ }
klass = startklass = mono_class_from_mono_type (type->type);
refklass = mono_class_from_mono_type (reftype->type);
if (!(bflags & BFLAGS_DeclaredOnly) && (klass = klass->parent))
goto handle_parent;
- res = mono_array_new_cached (domain, mono_defaults.field_info_class, mono_ptr_array_size (tmp_array));
+ res = mono_array_new_cached (domain, mono_defaults.field_info_class, mono_ptr_array_size (tmp_array), &error);
+ if (!is_ok (&error))
+ goto fail;
for (i = 0; i < mono_ptr_array_size (tmp_array); ++i)
mono_array_setref (res, i, mono_ptr_array_get (tmp_array, i));
{
MonoDomain *domain;
MonoClass *startklass, *klass, *refklass;
- MonoArray *res;
+ MonoArray *res = NULL;
MonoMethod *method;
MonoObject *member;
int i, match;
MonoPtrArray tmp_array;
MonoError error;
+ domain = ((MonoObject *)type)->vtable->domain;
+ if (type->type->byref) {
+ res = mono_array_new_cached (domain, mono_defaults.method_info_class, 0, &error);
+ mono_error_set_pending_exception (&error);
+ return res;
+ }
+
mono_ptr_array_init (tmp_array, 4, MONO_ROOT_SOURCE_REFLECTION, "temporary reflection constructors list"); /*FIXME, guestimating*/
- domain = ((MonoObject *)type)->vtable->domain;
- if (type->type->byref)
- return mono_array_new_cached (domain, mono_defaults.method_info_class, 0);
+
klass = startklass = mono_class_from_mono_type (type->type);
refklass = mono_class_from_mono_type (reftype->type);
mono_class_setup_methods (klass);
if (mono_class_has_failure (klass)) {
mono_set_pending_exception (mono_class_get_exception_for_failure (klass));
- return NULL;
+ goto leave;
}
iter = NULL;
if (!match)
continue;
member = (MonoObject*)mono_method_get_object_checked (domain, method, refklass, &error);
- if (!mono_error_ok (&error)) {
- mono_error_set_pending_exception (&error);
- return NULL;
- }
+ if (mono_error_set_pending_exception (&error))
+ goto leave;
mono_ptr_array_append (tmp_array, member);
}
- res = mono_array_new_cached (domain, mono_class_get_constructor_info_class (), mono_ptr_array_size (tmp_array));
+ res = mono_array_new_cached (domain, mono_class_get_constructor_info_class (), mono_ptr_array_size (tmp_array), &error);
+ if (mono_error_set_pending_exception (&error))
+ goto leave;
for (i = 0; i < mono_ptr_array_size (tmp_array); ++i)
mono_array_setref (res, i, mono_ptr_array_get (tmp_array, i));
+leave:
mono_ptr_array_destroy (tmp_array);
return res;
mono_error_init (&error);
+ domain = ((MonoObject *)type)->vtable->domain;
+ if (type->type->byref) {
+ res = mono_array_new_cached (domain, mono_class_get_property_info_class (), 0, &error);
+ mono_error_set_pending_exception (&error);
+ return res;
+ }
+
mono_ptr_array_init (tmp_array, 8, MONO_ROOT_SOURCE_REFLECTION, "temporary reflection properties list"); /*This the average for ASP.NET types*/
- domain = ((MonoObject *)type)->vtable->domain;
- if (type->type->byref)
- return mono_array_new_cached (domain, mono_class_get_property_info_class (), 0);
klass = startklass = mono_class_from_mono_type (type->type);
if (name != NULL) {
g_hash_table_destroy (properties);
g_free (propname);
- res = mono_array_new_cached (domain, mono_class_get_property_info_class (), mono_ptr_array_size (tmp_array));
+ res = mono_array_new_cached (domain, mono_class_get_property_info_class (), mono_ptr_array_size (tmp_array), &error);
+ if (!is_ok (&error))
+ goto failure;
for (i = 0; i < mono_ptr_array_size (tmp_array); ++i)
mono_array_setref (res, i, mono_ptr_array_get (tmp_array, i));
mono_error_init (&error);
+ domain = mono_object_domain (type);
+ if (type->type->byref) {
+ res = mono_array_new_cached (domain, mono_class_get_event_info_class (), 0, &error);
+ mono_error_set_pending_exception (&error);
+ return res;
+ }
+
mono_ptr_array_init (tmp_array, 4, MONO_ROOT_SOURCE_REFLECTION, "temporary reflection events list");
- domain = mono_object_domain (type);
- if (type->type->byref)
- return mono_array_new_cached (domain, mono_class_get_event_info_class (), 0);
klass = startklass = mono_class_from_mono_type (type->type);
events = g_hash_table_new (event_hash, (GEqualFunc)event_equal);
g_hash_table_destroy (events);
- res = mono_array_new_cached (domain, mono_class_get_event_info_class (), mono_ptr_array_size (tmp_array));
+ res = mono_array_new_cached (domain, mono_class_get_event_info_class (), mono_ptr_array_size (tmp_array), &error);
+ if (!is_ok (&error))
+ goto failure;
for (i = 0; i < mono_ptr_array_size (tmp_array); ++i)
mono_array_setref (res, i, mono_ptr_array_get (tmp_array, i));
mono_error_init (&error);
domain = ((MonoObject *)type)->vtable->domain;
- if (type->type->byref)
- return mono_array_new (domain, mono_defaults.monotype_class, 0);
+ if (type->type->byref) {
+ MonoArray *result = mono_array_new_cached (domain, mono_defaults.monotype_class, 0, &error);
+ mono_error_set_pending_exception (&error);
+ return result;
+ }
klass = mono_class_from_mono_type (type->type);
/*
mono_ptr_array_append (tmp_array, (MonoObject*) rt);
}
- res = mono_array_new_cached (domain, mono_defaults.monotype_class, mono_ptr_array_size (tmp_array));
+ res = mono_array_new_cached (domain, mono_defaults.monotype_class, mono_ptr_array_size (tmp_array), &error);
+ if (!is_ok (&error))
+ goto leave;
for (i = 0; i < mono_ptr_array_size (tmp_array); ++i)
mono_array_setref (res, i, mono_ptr_array_get (tmp_array, i));
ICALL_EXPORT MonoArray*
ves_icall_System_Reflection_Assembly_GetManifestResourceNames (MonoReflectionAssembly *assembly)
{
+ MonoError error;
MonoTableInfo *table = &assembly->assembly->image->tables [MONO_TABLE_MANIFESTRESOURCE];
- MonoArray *result = mono_array_new (mono_object_domain (assembly), mono_defaults.string_class, table->rows);
+ MonoArray *result = mono_array_new_checked (mono_object_domain (assembly), mono_defaults.string_class, table->rows, &error);
+ if (mono_error_set_pending_exception (&error))
+ return NULL;
int i;
const char *val;
t = &assembly->assembly->image->tables [MONO_TABLE_ASSEMBLYREF];
count = t->rows;
- result = mono_array_new (domain, mono_class_get_assembly_name_class (), count);
+ result = mono_array_new_checked (domain, mono_class_get_assembly_name_class (), count, &error);
+ if (mono_error_set_pending_exception (&error))
+ return NULL;
+
if (count > 0 && !create_culture) {
MonoMethodDesc *desc = mono_method_desc_new (
if ((cols [MONO_ASSEMBLYREF_FLAGS] & ASSEMBLYREF_FULL_PUBLIC_KEY_FLAG)) {
/* public key token isn't copied - the class library will
automatically generate it from the public key if required */
- MONO_OBJECT_SETREF (aname, publicKey, mono_array_new (domain, mono_defaults.byte_class, pkey_len));
- memcpy (mono_array_addr (aname->publicKey, guint8, 0), pkey_ptr, pkey_len);
+ MonoArray *pkey = mono_array_new_checked (domain, mono_defaults.byte_class, pkey_len, &error);
+ if (mono_error_set_pending_exception (&error))
+ return NULL;
+
+ MONO_OBJECT_SETREF (aname, publicKey, pkey);
+ memcpy (mono_array_addr (pkey, guint8, 0), pkey_ptr, pkey_len);
} else {
- MONO_OBJECT_SETREF (aname, keyToken, mono_array_new (domain, mono_defaults.byte_class, pkey_len));
- memcpy (mono_array_addr (aname->keyToken, guint8, 0), pkey_ptr, pkey_len);
+ MonoArray *keyToken = mono_array_new_checked (domain, mono_defaults.byte_class, pkey_len, &error);
+ if (mono_error_set_pending_exception (&error))
+ return NULL;
+
+ MONO_OBJECT_SETREF (aname, keyToken, keyToken);
+ memcpy (mono_array_addr (keyToken, guint8, 0), pkey_ptr, pkey_len);
}
} else {
- MONO_OBJECT_SETREF (aname, keyToken, mono_array_new (domain, mono_defaults.byte_class, 0));
+ MonoArray *keyToken = mono_array_new_checked (domain, mono_defaults.byte_class, 0, &error);
+ if (mono_error_set_pending_exception (&error))
+ return NULL;
+
+ MONO_OBJECT_SETREF (aname, keyToken, keyToken);
}
/* note: this function doesn't return the codebase on purpose (i.e. it can
ICALL_EXPORT MonoObject*
ves_icall_System_Reflection_Assembly_GetFilesInternal (MonoReflectionAssembly *assembly, MonoString *name, MonoBoolean resource_modules)
{
+ MonoError error;
MonoTableInfo *table = &assembly->assembly->image->tables [MONO_TABLE_FILE];
MonoArray *result = NULL;
int i, count;
count ++;
}
- result = mono_array_new (mono_object_domain (assembly), mono_defaults.string_class, count);
+ result = mono_array_new_checked (mono_object_domain (assembly), mono_defaults.string_class, count, &error);
+ if (mono_error_set_pending_exception (&error))
+ return NULL;
+
count = 0;
for (i = 0; i < table->rows; ++i) {
real_module_count ++;
klass = mono_class_get_module_class ();
- res = mono_array_new (domain, klass, 1 + real_module_count + file_count);
+ res = mono_array_new_checked (domain, klass, 1 + real_module_count + file_count, &error);
+ if (mono_error_set_pending_exception (&error))
+ return NULL;
MonoReflectionModule *image_obj = mono_module_get_object_checked (domain, image, &error);
if (mono_error_set_pending_exception (&error))
pkey_ptr = (char*)name->public_key;
pkey_len = mono_metadata_decode_blob_size (pkey_ptr, &pkey_ptr);
- MONO_OBJECT_SETREF (aname, publicKey, mono_array_new (domain, mono_defaults.byte_class, pkey_len));
+ MonoArray *pkey = mono_array_new_checked (domain, mono_defaults.byte_class, pkey_len, error);
+ return_if_nok (error);
+ MONO_OBJECT_SETREF (aname, publicKey, pkey);
memcpy (mono_array_addr (aname->publicKey, guint8, 0), pkey_ptr, pkey_len);
aname->flags |= ASSEMBLYREF_FULL_PUBLIC_KEY_FLAG;
} else if (default_publickey) {
- MONO_OBJECT_SETREF (aname, publicKey, mono_array_new (domain, mono_defaults.byte_class, 0));
+ MonoArray *pkey = mono_array_new_checked (domain, mono_defaults.byte_class, 0, error);
+ return_if_nok (error);
+ MONO_OBJECT_SETREF (aname, publicKey, pkey);
aname->flags |= ASSEMBLYREF_FULL_PUBLIC_KEY_FLAG;
}
int i, j;
char *p;
- MONO_OBJECT_SETREF (aname, keyToken, mono_array_new (domain, mono_defaults.byte_class, 8));
- p = mono_array_addr (aname->keyToken, char, 0);
+ MonoArray *keyToken = mono_array_new_checked (domain, mono_defaults.byte_class, 8, error);
+ return_if_nok (error);
+
+ MONO_OBJECT_SETREF (aname, keyToken, keyToken);
+ p = mono_array_addr (keyToken, char, 0);
for (i = 0, j = 0; i < 8; i++) {
*p = g_ascii_xdigit_value (name->public_key_token [j++]) << 4;
p++;
}
} else if (default_token) {
- MONO_OBJECT_SETREF (aname, keyToken, mono_array_new (domain, mono_defaults.byte_class, 0));
+ MonoArray *keyToken = mono_array_new_checked (domain, mono_defaults.byte_class, 0, error);
+ return_if_nok (error);
+ MONO_OBJECT_SETREF (aname, keyToken, keyToken);
}
}
} else {
count = tdef->rows - 1;
}
- res = mono_array_new (domain, mono_defaults.monotype_class, count);
- *exceptions = mono_array_new (domain, mono_defaults.exception_class, count);
+ res = mono_array_new_checked (domain, mono_defaults.monotype_class, count, error);
+ return_val_if_nok (error, NULL);
+ *exceptions = mono_array_new_checked (domain, mono_defaults.exception_class, count, error);
+ return_val_if_nok (error, NULL);
count = 0;
for (i = 1; i < tdef->rows; ++i) {
if (!exportedOnly || mono_module_type_is_visible (tdef, image, i + 1)) {
len1 = mono_array_length (res);
len2 = mono_array_length (res2);
- res3 = mono_array_new (domain, mono_defaults.monotype_class, len1 + len2);
+ res3 = mono_array_new_checked (domain, mono_defaults.monotype_class, len1 + len2, &error);
+ if (mono_error_set_pending_exception (&error))
+ return NULL;
mono_array_memcpy_refs (res3, 0, res, 0, len1);
mono_array_memcpy_refs (res3, len1, res2, 0, len2);
res = res3;
- ex3 = mono_array_new (domain, mono_defaults.monotype_class, len1 + len2);
+ ex3 = mono_array_new_checked (domain, mono_defaults.monotype_class, len1 + len2, &error);
+ if (mono_error_set_pending_exception (&error))
+ return NULL;
mono_array_memcpy_refs (ex3, 0, exceptions, 0, len1);
mono_array_memcpy_refs (ex3, len1, ex2, 0, len2);
exceptions = ex3;
MonoArray *exl = NULL;
int j, length = g_list_length (list) + ex_count;
- exl = mono_array_new (domain, mono_defaults.exception_class, length);
+ exl = mono_array_new_checked (domain, mono_defaults.exception_class, length, &error);
+ if (mono_error_set_pending_exception (&error)) {
+ g_list_free (list);
+ return NULL;
+ }
/* Types for which mono_class_get_checked () succeeded */
for (i = 0, tmp = list; tmp; i++, tmp = tmp->next) {
MonoException *exc = mono_class_get_exception_for_failure ((MonoClass *)tmp->data);
MonoArray *exceptions;
int i;
- if (!module->image)
- return mono_array_new (mono_object_domain (module), mono_defaults.monotype_class, 0);
- else {
+ if (!module->image) {
+ MonoArray *arr = mono_array_new_checked (mono_object_domain (module), mono_defaults.monotype_class, 0, &error);
+ mono_error_set_pending_exception (&error);
+ return arr;
+ } else {
MonoArray *res;
res = mono_module_get_types (mono_object_domain (module), module->image, &exceptions, FALSE, &error);
}
ICALL_EXPORT MonoArray*
-ves_icall_System_Reflection_Module_ResolveSignature (MonoImage *image, guint32 token, MonoResolveTokenError *error)
+ves_icall_System_Reflection_Module_ResolveSignature (MonoImage *image, guint32 token, MonoResolveTokenError *resolve_error)
{
+ MonoError error;
int table = mono_metadata_token_table (token);
int idx = mono_metadata_token_index (token);
MonoTableInfo *tables = image->tables;
const char *ptr;
MonoArray *res;
- *error = ResolveTokenError_OutOfRange;
+ *resolve_error = ResolveTokenError_OutOfRange;
/* FIXME: Support other tables ? */
if (table != MONO_TABLE_STANDALONESIG)
ptr = mono_metadata_blob_heap (image, sig);
len = mono_metadata_decode_blob_size (ptr, &ptr);
- res = mono_array_new (mono_domain_get (), mono_defaults.byte_class, len);
+ res = mono_array_new_checked (mono_domain_get (), mono_defaults.byte_class, len, &error);
+ if (mono_error_set_pending_exception (&error))
+ return NULL;
memcpy (mono_array_addr (res, guint8, 0), ptr, len);
return res;
}
} else {
if (target && method->flags & METHOD_ATTRIBUTE_VIRTUAL && method->klass != mono_object_class (target))
method = mono_object_get_virtual_method (target, method);
- func = mono_create_ftnptr (mono_domain_get (),
- mono_runtime_create_jump_trampoline (mono_domain_get (), method, TRUE));
+ gpointer trampoline = mono_runtime_create_jump_trampoline (mono_domain_get (), method, TRUE, &error);
+ if (mono_error_set_pending_exception (&error))
+ return NULL;
+ func = mono_create_ftnptr (mono_domain_get (), trampoline);
}
mono_delegate_ctor_with_method (delegate, target, func, method);
#endif
#endif
+ICALL_EXPORT MonoArray *
+ves_icall_System_Environment_GetCoomandLineArgs (void)
+{
+ MonoError error;
+ MonoArray *result = mono_runtime_get_main_args_checked (&error);
+ mono_error_set_pending_exception (&error);
+ return result;
+}
+
ICALL_EXPORT MonoArray *
ves_icall_System_Environment_GetEnvironmentVariableNames (void)
{
#ifdef HOST_WIN32
+ MonoError error;
MonoArray *names;
MonoDomain *domain;
MonoString *str;
}
domain = mono_domain_get ();
- names = mono_array_new (domain, mono_defaults.string_class, n);
+ names = mono_array_new_checked (domain, mono_defaults.string_class, n, &error);
+ if (mono_error_set_pending_exception (&error))
+ return NULL;
if (env_strings) {
n = 0;
return names;
#else
+ MonoError error;
MonoArray *names;
MonoDomain *domain;
MonoString *str;
++ n;
domain = mono_domain_get ();
- names = mono_array_new (domain, mono_defaults.string_class, n);
+ names = mono_array_new_checked (domain, mono_defaults.string_class, n, &error);
+ if (mono_error_set_pending_exception (&error))
+ return NULL;
n = 0;
for (e = environ; *e != 0; ++ e) {
} while (*dname);
dname = ptr;
- result = mono_array_new (domain, mono_defaults.string_class, ndrives);
+ result = mono_array_new_checked (domain, mono_defaults.string_class, ndrives, &error);
+ if (mono_error_set_pending_exception (&error))
+ goto leave;
+
ndrives = 0;
do {
len = 0;
while (*u16) { u16++; len ++; }
drivestr = mono_string_new_utf16_checked (domain, dname, len, &error);
if (mono_error_set_pending_exception (&error))
- return NULL;
+ goto leave;
mono_array_setref (result, ndrives++, drivestr);
while (*dname++);
} while (*dname);
+leave:
if (ptr != buf)
g_free (ptr);
if (klass->rank >= 1) {
g_assert (klass->rank == 1);
- return (MonoObject *) mono_array_new (domain, klass->element_class, 0);
+ ret = (MonoObject *) mono_array_new_checked (domain, klass->element_class, 0, &error);
+ mono_error_set_pending_exception (&error);
+ return ret;
} else {
MonoVTable *vtable = mono_class_vtable_full (domain, klass, &error);
if (!is_ok (&error)) {
}
if (!count)
return NULL;
- res = mono_array_new (mono_domain_get (), mono_defaults.systemtype_class, count);
+ res = mono_array_new_checked (mono_domain_get (), mono_defaults.systemtype_class, count, error);
+ return_val_if_nok (error, NULL);
count = 0;
for (i = 0; i < type->num_mods; ++i) {
if ((optional && !type->modifiers [i].required) || (!optional && type->modifiers [i].required)) {
}
static MonoArray*
-create_group_sizes_array (const gint *gs, gint ml)
+create_group_sizes_array (const gint *gs, gint ml, MonoError *error)
{
MonoArray *ret;
int i, len = 0;
+ mono_error_init (error);
+
for (i = 0; i < ml; i++) {
if (gs [i] == -1)
break;
}
ret = mono_array_new_cached (mono_domain_get (),
- mono_get_int32_class (), len);
+ mono_get_int32_class (), len, error);
+ return_val_if_nok (error, NULL);
for(i = 0; i < len; i++)
mono_array_set (ret, gint32, i, gs [i]);
}
static MonoArray*
-create_names_array_idx (const guint16 *names, int ml)
+create_names_array_idx (const guint16 *names, int ml, MonoError *error)
{
MonoArray *ret;
MonoDomain *domain;
int i;
+ mono_error_init (error);
+
if (names == NULL)
return NULL;
domain = mono_domain_get ();
- ret = mono_array_new_cached (mono_domain_get (), mono_get_string_class (), ml);
+ ret = mono_array_new_cached (mono_domain_get (), mono_get_string_class (), ml, error);
+ return_val_if_nok (error, NULL);
for(i = 0; i < ml; i++)
mono_array_setref (ret, i, mono_string_new (domain, idx2string (names [i])));
}
static MonoArray*
-create_names_array_idx_dynamic (const guint16 *names, int ml)
+create_names_array_idx_dynamic (const guint16 *names, int ml, MonoError *error)
{
MonoArray *ret;
MonoDomain *domain;
int i, len = 0;
+ mono_error_init (error);
+
if (names == NULL)
return NULL;
len++;
}
- ret = mono_array_new_cached (mono_domain_get (), mono_get_string_class (), len);
+ ret = mono_array_new_cached (mono_domain_get (), mono_get_string_class (), len, error);
+ return_val_if_nok (error, NULL);
for(i = 0; i < len; i++)
mono_array_setref (ret, i, mono_string_new (domain, idx2string (names [i])));
MonoBoolean
ves_icall_System_Globalization_CalendarData_fill_calendar_data (MonoCalendarData *this_obj, MonoString *name, gint32 calendar_index)
{
+ MonoError error;
MonoDomain *domain;
const DateTimeFormatEntry *dfe;
const CultureInfoNameEntry *ne;
domain = mono_domain_get ();
MONO_OBJECT_SETREF (this_obj, NativeName, mono_string_new (domain, idx2string (ci->nativename)));
- MONO_OBJECT_SETREF (this_obj, ShortDatePatterns, create_names_array_idx_dynamic (dfe->short_date_patterns,
- NUM_SHORT_DATE_PATTERNS));
- MONO_OBJECT_SETREF (this_obj, YearMonthPatterns, create_names_array_idx_dynamic (dfe->year_month_patterns,
- NUM_YEAR_MONTH_PATTERNS));
+ MonoArray *short_date_patterns = create_names_array_idx_dynamic (dfe->short_date_patterns,
+ NUM_SHORT_DATE_PATTERNS, &error);
+ return_val_and_set_pending_if_nok (&error, FALSE);
+ MONO_OBJECT_SETREF (this_obj, ShortDatePatterns, short_date_patterns);
+ MonoArray *year_month_patterns =create_names_array_idx_dynamic (dfe->year_month_patterns,
+ NUM_YEAR_MONTH_PATTERNS, &error);
+ return_val_and_set_pending_if_nok (&error, FALSE);
+ MONO_OBJECT_SETREF (this_obj, YearMonthPatterns, year_month_patterns);
+
+ MonoArray *long_date_patterns = create_names_array_idx_dynamic (dfe->long_date_patterns,
+ NUM_LONG_DATE_PATTERNS, &error);
+ return_val_and_set_pending_if_nok (&error, FALSE);
+ MONO_OBJECT_SETREF (this_obj, LongDatePatterns, long_date_patterns);
- MONO_OBJECT_SETREF (this_obj, LongDatePatterns, create_names_array_idx_dynamic (dfe->long_date_patterns,
- NUM_LONG_DATE_PATTERNS));
MONO_OBJECT_SETREF (this_obj, MonthDayPattern, mono_string_new (domain, idx2string (dfe->month_day_pattern)));
- MONO_OBJECT_SETREF (this_obj, DayNames, create_names_array_idx (dfe->day_names, NUM_DAYS));
- MONO_OBJECT_SETREF (this_obj, AbbreviatedDayNames, create_names_array_idx (dfe->abbreviated_day_names,
- NUM_DAYS));
- MONO_OBJECT_SETREF (this_obj, SuperShortDayNames, create_names_array_idx (dfe->shortest_day_names, NUM_DAYS));
- MONO_OBJECT_SETREF (this_obj, MonthNames, create_names_array_idx (dfe->month_names, NUM_MONTHS));
- MONO_OBJECT_SETREF (this_obj, AbbreviatedMonthNames, create_names_array_idx (dfe->abbreviated_month_names,
- NUM_MONTHS));
- MONO_OBJECT_SETREF (this_obj, GenitiveMonthNames, create_names_array_idx (dfe->month_genitive_names, NUM_MONTHS));
- MONO_OBJECT_SETREF (this_obj, GenitiveAbbreviatedMonthNames, create_names_array_idx (dfe->abbreviated_month_genitive_names, NUM_MONTHS));
+ MonoArray *day_names = create_names_array_idx (dfe->day_names, NUM_DAYS, &error);
+ return_val_and_set_pending_if_nok (&error, FALSE);
+ MONO_OBJECT_SETREF (this_obj, DayNames, day_names);
+
+ MonoArray *abbr_day_names = create_names_array_idx (dfe->abbreviated_day_names,
+ NUM_DAYS, &error);
+ return_val_and_set_pending_if_nok (&error, FALSE);
+ MONO_OBJECT_SETREF (this_obj, AbbreviatedDayNames, abbr_day_names);
+
+ MonoArray *ss_day_names = create_names_array_idx (dfe->shortest_day_names, NUM_DAYS, &error);
+ return_val_and_set_pending_if_nok (&error, FALSE);
+ MONO_OBJECT_SETREF (this_obj, SuperShortDayNames, ss_day_names);
+
+ MonoArray *month_names = create_names_array_idx (dfe->month_names, NUM_MONTHS, &error);
+ return_val_and_set_pending_if_nok (&error, FALSE);
+ MONO_OBJECT_SETREF (this_obj, MonthNames, month_names);
+
+ MonoArray *abbr_mon_names = create_names_array_idx (dfe->abbreviated_month_names,
+ NUM_MONTHS, &error);
+ return_val_and_set_pending_if_nok (&error, FALSE);
+ MONO_OBJECT_SETREF (this_obj, AbbreviatedMonthNames, abbr_mon_names);
+
+
+ MonoArray *gen_month_names = create_names_array_idx (dfe->month_genitive_names, NUM_MONTHS, &error);
+ return_val_and_set_pending_if_nok (&error, FALSE);
+ MONO_OBJECT_SETREF (this_obj, GenitiveMonthNames, gen_month_names);
+
+ MonoArray *gen_abbr_mon_names = create_names_array_idx (dfe->abbreviated_month_genitive_names, NUM_MONTHS, &error);
+ return_val_and_set_pending_if_nok (&error, FALSE);
+ MONO_OBJECT_SETREF (this_obj, GenitiveAbbreviatedMonthNames, gen_abbr_mon_names);
return TRUE;
}
void
ves_icall_System_Globalization_CultureData_fill_culture_data (MonoCultureData *this_obj, gint32 datetime_index)
{
+ MonoError error;
MonoDomain *domain;
const DateTimeFormatEntry *dfe;
MONO_OBJECT_SETREF (this_obj, AMDesignator, mono_string_new (domain, idx2string (dfe->am_designator)));
MONO_OBJECT_SETREF (this_obj, PMDesignator, mono_string_new (domain, idx2string (dfe->pm_designator)));
MONO_OBJECT_SETREF (this_obj, TimeSeparator, mono_string_new (domain, idx2string (dfe->time_separator)));
- MONO_OBJECT_SETREF (this_obj, LongTimePatterns, create_names_array_idx_dynamic (dfe->long_time_patterns,
- NUM_LONG_TIME_PATTERNS));
- MONO_OBJECT_SETREF (this_obj, ShortTimePatterns, create_names_array_idx_dynamic (dfe->short_time_patterns,
- NUM_SHORT_TIME_PATTERNS));
+
+ MonoArray *long_time_patterns = create_names_array_idx_dynamic (dfe->long_time_patterns,
+ NUM_LONG_TIME_PATTERNS, &error);
+ if (mono_error_set_pending_exception (&error))
+ return;
+ MONO_OBJECT_SETREF (this_obj, LongTimePatterns, long_time_patterns);
+
+ MonoArray *short_time_patterns = create_names_array_idx_dynamic (dfe->short_time_patterns,
+ NUM_SHORT_TIME_PATTERNS, &error);
+ if (mono_error_set_pending_exception (&error))
+ return;
+ MONO_OBJECT_SETREF (this_obj, ShortTimePatterns, short_time_patterns);
this_obj->FirstDayOfWeek = dfe->first_day_of_week;
this_obj->CalendarWeekRule = dfe->calendar_week_rule;
}
void
ves_icall_System_Globalization_CultureData_fill_number_data (MonoNumberFormatInfo* number, gint32 number_index)
{
+ MonoError error;
MonoDomain *domain;
const NumberFormatEntry *nfe;
idx2string (nfe->currency_decimal_separator)));
MONO_OBJECT_SETREF (number, currencyGroupSeparator, mono_string_new (domain,
idx2string (nfe->currency_group_separator)));
- MONO_OBJECT_SETREF (number, currencyGroupSizes, create_group_sizes_array (nfe->currency_group_sizes,
- GROUP_SIZE));
+ MonoArray *currency_sizes_arr = create_group_sizes_array (nfe->currency_group_sizes,
+ GROUP_SIZE, &error);
+ if (mono_error_set_pending_exception (&error))
+ return;
+ MONO_OBJECT_SETREF (number, currencyGroupSizes, currency_sizes_arr);
number->currencyNegativePattern = nfe->currency_negative_pattern;
number->currencyPositivePattern = nfe->currency_positive_pattern;
MONO_OBJECT_SETREF (number, currencySymbol, mono_string_new (domain, idx2string (nfe->currency_symbol)));
MONO_OBJECT_SETREF (number, numberDecimalSeparator, mono_string_new (domain,
idx2string (nfe->number_decimal_separator)));
MONO_OBJECT_SETREF (number, numberGroupSeparator, mono_string_new (domain, idx2string (nfe->number_group_separator)));
- MONO_OBJECT_SETREF (number, numberGroupSizes, create_group_sizes_array (nfe->number_group_sizes,
- GROUP_SIZE));
+ MonoArray *number_sizes_arr = create_group_sizes_array (nfe->number_group_sizes,
+ GROUP_SIZE, &error);
+ if (mono_error_set_pending_exception (&error))
+ return;
+ MONO_OBJECT_SETREF (number, numberGroupSizes, number_sizes_arr);
number->numberNegativePattern = nfe->number_negative_pattern;
number->percentNegativePattern = nfe->percent_negative_pattern;
number->percentPositivePattern = nfe->percent_positive_pattern;
}
static MonoBoolean
-construct_culture (MonoCultureInfo *this_obj, const CultureInfoEntry *ci)
+construct_culture (MonoCultureInfo *this_obj, const CultureInfoEntry *ci, MonoError *error)
{
MonoDomain *domain = mono_domain_get ();
+ mono_error_init (error);
+
this_obj->lcid = ci->lcid;
MONO_OBJECT_SETREF (this_obj, name, mono_string_new (domain, idx2string (ci->name)));
MONO_OBJECT_SETREF (this_obj, englishname, mono_string_new (domain, idx2string (ci->englishname)));
// It's null for neutral cultures
if (ci->territory > 0)
MONO_OBJECT_SETREF (this_obj, territory, mono_string_new (domain, idx2string (ci->territory)));
- MONO_OBJECT_SETREF (this_obj, native_calendar_names, create_names_array_idx (ci->native_calendar_names, NUM_CALENDARS));
+
+ MonoArray *native_calendar_names = create_names_array_idx (ci->native_calendar_names, NUM_CALENDARS, error);
+ return_val_if_nok (error, FALSE);
+ MONO_OBJECT_SETREF (this_obj, native_calendar_names, native_calendar_names);
this_obj->parent_lcid = ci->parent_lcid;
this_obj->datetime_index = ci->datetime_format_index;
this_obj->number_index = ci->number_format_index;
ves_icall_System_Globalization_CultureInfo_construct_internal_locale_from_lcid (MonoCultureInfo *this_obj,
gint lcid)
{
+ MonoError error;
const CultureInfoEntry *ci;
ci = culture_info_entry_from_lcid (lcid);
if(ci == NULL)
return FALSE;
- return construct_culture (this_obj, ci);
+ if (!construct_culture (this_obj, ci, &error)) {
+ mono_error_set_pending_exception (&error);
+ return FALSE;
+ }
+ return TRUE;
}
MonoBoolean
ves_icall_System_Globalization_CultureInfo_construct_internal_locale_from_name (MonoCultureInfo *this_obj,
MonoString *name)
{
+ MonoError error;
const CultureInfoNameEntry *ne;
char *n;
}
g_free (n);
- return construct_culture (this_obj, &culture_entries [ne->culture_entry_index]);
+ if (!construct_culture (this_obj, &culture_entries [ne->culture_entry_index], &error)) {
+ mono_error_set_pending_exception (&error);
+ return FALSE;
+ }
+ return TRUE;
}
/*
MonoBoolean
if (neutral)
len++;
- ret = mono_array_new (domain, klass, len);
+ ret = mono_array_new_checked (domain, klass, len, &error);
+ if (!is_ok (&error))
+ goto fail;
if (len == 0)
return ret;
if (!is_ok (&error)) goto fail;
mono_runtime_object_init_checked ((MonoObject *) culture, &error);
if (!is_ok (&error)) goto fail;
- construct_culture (culture, ci);
+ if (!construct_culture (culture, ci, &error))
+ goto fail;
culture->use_user_override = TRUE;
mono_array_setref (ret, len++, culture);
}
void ves_icall_System_Globalization_CompareInfo_assign_sortkey (MonoCompareInfo *this_obj, MonoSortKey *key, MonoString *source, gint32 options)
{
+ MonoError error;
MonoArray *arr;
gint32 keylen, i;
keylen=mono_string_length (source);
- arr=mono_array_new (mono_domain_get (), mono_get_byte_class (),
- keylen);
+ arr=mono_array_new_checked (mono_domain_get (), mono_get_byte_class (),
+ keylen, &error);
+ if (mono_error_set_pending_exception (&error))
+ return;
+
for(i=0; i<keylen; i++) {
mono_array_set (arr, guint8, i, mono_string_chars (source)[i]);
}
}
}
+/* This is a JIT icall, it sets the pending exception and returns NULL on error */
static MonoString *
mono_string_from_byvalstr (const char *data, int max_len)
{
+ MonoError error;
MonoDomain *domain = mono_domain_get ();
int len = 0;
while (len < max_len - 1 && data [len])
len++;
- return mono_string_new_len (domain, data, len);
+ MonoString *result = mono_string_new_len_checked (domain, data, len, &error);
+ mono_error_set_pending_exception (&error);
+ return result;
}
/* This is a JIT icall, it sets the pending exception and return NULL on error */
*((gunichar2 *) dst + len) = 0;
}
+/* this is an icall, it sets the pending exception and returns NULL on error */
static MonoString*
mono_string_new_len_wrapper (const char *text, guint length)
{
- return mono_string_new_len (mono_domain_get (), text, length);
+ MonoError error;
+ MonoString *result = mono_string_new_len_checked (mono_domain_get (), text, length, &error);
+ mono_error_set_pending_exception (&error);
+ return result;
}
#ifndef DISABLE_JIT
mono_type_to_stind (MonoType *type)
{
if (type->byref)
- return CEE_STIND_I;
+ return MONO_TYPE_IS_REFERENCE (type) ? CEE_STIND_REF : CEE_STIND_I;
+
handle_enum:
switch (type->type) {
mono_mb_emit_ldloc (mb, 1);
mono_mb_emit_icon (mb, mspec->data.array_data.num_elem);
mono_mb_emit_op (mb, CEE_NEWARR, eklass);
- mono_mb_emit_byte (mb, CEE_STIND_I);
+ mono_mb_emit_byte (mb, CEE_STIND_REF);
if (eklass->blittable) {
/* copy the elements */
}
static gpointer
-conv_to_icall (MonoMarshalConv conv)
+conv_to_icall (MonoMarshalConv conv, int *ind_store_type)
{
+ int dummy;
+ if (!ind_store_type)
+ ind_store_type = &dummy;
+ *ind_store_type = CEE_STIND_I;
switch (conv) {
case MONO_MARSHAL_CONV_STR_LPWSTR:
return mono_marshal_string_to_utf16;
case MONO_MARSHAL_CONV_LPWSTR_STR:
+ *ind_store_type = CEE_STIND_REF;
return mono_string_from_utf16;
case MONO_MARSHAL_CONV_LPTSTR_STR:
+ *ind_store_type = CEE_STIND_REF;
return mono_string_new_wrapper;
case MONO_MARSHAL_CONV_LPSTR_STR:
+ *ind_store_type = CEE_STIND_REF;
return mono_string_new_wrapper;
case MONO_MARSHAL_CONV_STR_LPTSTR:
#ifdef TARGET_WIN32
case MONO_MARSHAL_CONV_STR_BSTR:
return mono_string_to_bstr;
case MONO_MARSHAL_CONV_BSTR_STR:
+ *ind_store_type = CEE_STIND_REF;
return mono_string_from_bstr;
case MONO_MARSHAL_CONV_STR_TBSTR:
case MONO_MARSHAL_CONV_STR_ANSIBSTR:
case MONO_MARSHAL_CONV_DEL_FTN:
return mono_delegate_to_ftnptr;
case MONO_MARSHAL_CONV_FTN_DEL:
+ *ind_store_type = CEE_STIND_REF;
return mono_ftnptr_to_delegate;
case MONO_MARSHAL_CONV_LPSTR_SB:
+ *ind_store_type = CEE_STIND_REF;
return mono_string_utf8_to_builder;
case MONO_MARSHAL_CONV_LPTSTR_SB:
+ *ind_store_type = CEE_STIND_REF;
#ifdef TARGET_WIN32
return mono_string_utf16_to_builder;
#else
return mono_string_utf8_to_builder;
#endif
case MONO_MARSHAL_CONV_LPWSTR_SB:
+ *ind_store_type = CEE_STIND_REF;
return mono_string_utf16_to_builder;
case MONO_MARSHAL_FREE_ARRAY:
return mono_marshal_free_array;
emit_object_to_ptr_conv (MonoMethodBuilder *mb, MonoType *type, MonoMarshalConv conv, MonoMarshalSpec *mspec)
{
int pos;
+ int stind_op;
switch (conv) {
case MONO_MARSHAL_CONV_BOOL_I4:
mono_mb_emit_ldloc (mb, 1);
mono_mb_emit_ldloc (mb, 0);
mono_mb_emit_byte (mb, CEE_LDIND_REF);
- mono_mb_emit_icall (mb, conv_to_icall (conv));
- mono_mb_emit_byte (mb, CEE_STIND_I);
+ mono_mb_emit_icall (mb, conv_to_icall (conv, &stind_op));
+ mono_mb_emit_byte (mb, stind_op);
break;
}
case MONO_MARSHAL_CONV_ARRAY_SAVEARRAY:
mono_mb_emit_ldloc (mb, 1);
mono_mb_emit_ldloc (mb, 0);
mono_mb_emit_byte (mb, CEE_LDIND_REF);
- mono_mb_emit_icall (mb, conv_to_icall (conv));
- mono_mb_emit_byte (mb, CEE_STIND_I);
+ mono_mb_emit_icall (mb, conv_to_icall (conv, &stind_op));
+ mono_mb_emit_byte (mb, stind_op);
break;
case MONO_MARSHAL_CONV_STR_BYVALSTR:
case MONO_MARSHAL_CONV_STR_BYVALWSTR: {
mono_mb_emit_ldloc (mb, 0);
mono_mb_emit_byte (mb, CEE_LDIND_REF); /* src String */
mono_mb_emit_icon (mb, mspec->data.array_data.num_elem);
- mono_mb_emit_icall (mb, conv_to_icall (conv));
+ mono_mb_emit_icall (mb, conv_to_icall (conv, NULL));
break;
}
case MONO_MARSHAL_CONV_ARRAY_BYVALARRAY: {
case MONO_MARSHAL_CONV_NONE: {
int t;
- if (ftype->byref || ftype->type == MONO_TYPE_I ||
- ftype->type == MONO_TYPE_U) {
+ //XXX a byref field!?!? that's not allowed! and worse, it might miss a WB
+ g_assert (!ftype->byref);
+ if (ftype->type == MONO_TYPE_I || ftype->type == MONO_TYPE_U) {
mono_mb_emit_ldloc (mb, 1);
mono_mb_emit_ldloc (mb, 0);
mono_mb_emit_byte (mb, CEE_LDIND_I);
mono_set_pending_exception ((MonoException*)exc);
}
- mono_method_return_message_restore (method, params, out_args);
+ mono_method_return_message_restore (method, params, out_args, &error);
+ mono_error_set_pending_exception (&error);
return res;
}
char *msg = g_strdup_printf ("string marshalling conversion %d not implemented", encoding);
mono_mb_emit_exception_marshal_directive (mb, msg);
} else {
- mono_mb_emit_icall (mb, conv_to_icall (conv));
+ mono_mb_emit_icall (mb, conv_to_icall (conv, NULL));
mono_mb_emit_stloc (mb, conv_arg);
}
mono_mb_emit_icall (mb, mono_string_new_len_wrapper);
mono_mb_emit_byte (mb, CEE_STIND_REF);
} else if (t->byref && (t->attrs & PARAM_ATTRIBUTE_OUT || !(t->attrs & PARAM_ATTRIBUTE_IN))) {
+ int stind_op;
mono_mb_emit_ldarg (mb, argnum);
mono_mb_emit_ldloc (mb, conv_arg);
- mono_mb_emit_icall (mb, conv_to_icall (conv));
- mono_mb_emit_byte (mb, CEE_STIND_REF);
+ mono_mb_emit_icall (mb, conv_to_icall (conv, &stind_op));
+ mono_mb_emit_byte (mb, stind_op);
need_free = TRUE;
}
}
mono_mb_emit_ldloc (mb, 0);
- mono_mb_emit_icall (mb, conv_to_icall (conv));
+ mono_mb_emit_icall (mb, conv_to_icall (conv, NULL));
mono_mb_emit_stloc (mb, 3);
/* free the string */
mono_mb_emit_ldarg (mb, argnum);
if (t->byref)
mono_mb_emit_byte (mb, CEE_LDIND_I);
- mono_mb_emit_icall (mb, conv_to_icall (conv));
+ mono_mb_emit_icall (mb, conv_to_icall (conv, NULL));
mono_mb_emit_stloc (mb, conv_arg);
break;
case MARSHAL_ACTION_MANAGED_CONV_OUT:
if (t->byref) {
if (conv_arg) {
+ int stind_op;
mono_mb_emit_ldarg (mb, argnum);
mono_mb_emit_ldloc (mb, conv_arg);
- mono_mb_emit_icall (mb, conv_to_icall (conv));
- mono_mb_emit_byte (mb, CEE_STIND_I);
+ mono_mb_emit_icall (mb, conv_to_icall (conv, &stind_op));
+ mono_mb_emit_byte (mb, stind_op);
}
}
break;
case MARSHAL_ACTION_MANAGED_CONV_RESULT:
- if (conv_to_icall (conv) == mono_marshal_string_to_utf16)
+ if (conv_to_icall (conv, NULL) == mono_marshal_string_to_utf16)
/* We need to make a copy so the caller is able to free it */
mono_mb_emit_icall (mb, mono_marshal_string_to_utf16_copy);
else
- mono_mb_emit_icall (mb, conv_to_icall (conv));
+ mono_mb_emit_icall (mb, conv_to_icall (conv, NULL));
mono_mb_emit_stloc (mb, 3);
break;
mono_mb_emit_stloc (mb, conv_arg);
} else {
mono_mb_emit_ldarg (mb, argnum);
- mono_mb_emit_icall (mb, conv_to_icall (MONO_MARSHAL_CONV_DEL_FTN));
+ mono_mb_emit_icall (mb, conv_to_icall (MONO_MARSHAL_CONV_DEL_FTN, NULL));
mono_mb_emit_stloc (mb, conv_arg);
}
} else if (klass == mono_defaults.stringbuilder_class) {
if (t->byref)
mono_mb_emit_byte (mb, CEE_LDIND_I);
- mono_mb_emit_icall (mb, conv_to_icall (conv));
+ mono_mb_emit_icall (mb, conv_to_icall (conv, NULL));
mono_mb_emit_stloc (mb, conv_arg);
} else if (klass->blittable) {
mono_mb_emit_byte (mb, CEE_LDNULL);
mono_mb_emit_ldarg (mb, argnum);
mono_mb_emit_ldloc (mb, conv_arg);
- mono_mb_emit_icall (mb, conv_to_icall (conv));
+ mono_mb_emit_icall (mb, conv_to_icall (conv, NULL));
}
if (need_free) {
mono_mb_emit_byte (mb, MONO_CUSTOM_PREFIX);
mono_mb_emit_op (mb, CEE_MONO_CLASSCONST, klass);
mono_mb_emit_ldloc (mb, conv_arg);
- mono_mb_emit_icall (mb, conv_to_icall (MONO_MARSHAL_CONV_FTN_DEL));
+ mono_mb_emit_icall (mb, conv_to_icall (MONO_MARSHAL_CONV_FTN_DEL, NULL));
mono_mb_emit_byte (mb, CEE_STIND_REF);
}
break;
mono_mb_emit_byte (mb, MONO_CUSTOM_PREFIX);
mono_mb_emit_op (mb, CEE_MONO_CLASSCONST, klass);
mono_mb_emit_ldloc (mb, 0);
- mono_mb_emit_icall (mb, conv_to_icall (MONO_MARSHAL_CONV_FTN_DEL));
+ mono_mb_emit_icall (mb, conv_to_icall (MONO_MARSHAL_CONV_FTN_DEL, NULL));
mono_mb_emit_stloc (mb, 3);
} else {
/* set src */
mono_mb_emit_ldarg (mb, argnum);
if (t->byref)
mono_mb_emit_byte (mb, CEE_LDIND_I);
- mono_mb_emit_icall (mb, conv_to_icall (MONO_MARSHAL_CONV_FTN_DEL));
+ mono_mb_emit_icall (mb, conv_to_icall (MONO_MARSHAL_CONV_FTN_DEL, NULL));
mono_mb_emit_stloc (mb, conv_arg);
break;
}
case MARSHAL_ACTION_MANAGED_CONV_OUT:
if (klass->delegate) {
if (t->byref) {
+ int stind_op;
mono_mb_emit_ldarg (mb, argnum);
mono_mb_emit_ldloc (mb, conv_arg);
- mono_mb_emit_icall (mb, conv_to_icall (MONO_MARSHAL_CONV_DEL_FTN));
- mono_mb_emit_byte (mb, CEE_STIND_I);
+ mono_mb_emit_icall (mb, conv_to_icall (MONO_MARSHAL_CONV_DEL_FTN, &stind_op));
+ mono_mb_emit_byte (mb, stind_op);
break;
}
}
case MARSHAL_ACTION_MANAGED_CONV_RESULT:
if (klass->delegate) {
- mono_mb_emit_icall (mb, conv_to_icall (MONO_MARSHAL_CONV_DEL_FTN));
+ mono_mb_emit_icall (mb, conv_to_icall (MONO_MARSHAL_CONV_DEL_FTN, NULL));
mono_mb_emit_stloc (mb, 3);
break;
}
mono_mb_emit_ldarg (mb, argnum);
if (t->byref)
mono_mb_emit_byte (mb, CEE_LDIND_I);
- mono_mb_emit_icall (mb, conv_to_icall (MONO_MARSHAL_CONV_ARRAY_LPARRAY));
+ mono_mb_emit_icall (mb, conv_to_icall (MONO_MARSHAL_CONV_ARRAY_LPARRAY, NULL));
mono_mb_emit_stloc (mb, conv_arg);
} else {
MonoClass *eklass;
/* Emit marshalling code */
if (is_string) {
+ int stind_op;
mono_mb_emit_ldloc (mb, dest_ptr);
mono_mb_emit_ldloc (mb, src_var);
mono_mb_emit_ldloc (mb, index_var);
mono_mb_emit_byte (mb, CEE_LDELEM_REF);
- mono_mb_emit_icall (mb, conv_to_icall (conv));
- mono_mb_emit_byte (mb, CEE_STIND_I);
+ mono_mb_emit_icall (mb, conv_to_icall (conv, &stind_op));
+ mono_mb_emit_byte (mb, stind_op);
} else {
/* set the src_ptr */
mono_mb_emit_ldloc (mb, src_var);
mono_mb_emit_byte (mb, CEE_CONV_OVF_I);
mono_mb_emit_op (mb, CEE_NEWARR, klass->element_class);
/* Store into argument */
- mono_mb_emit_byte (mb, CEE_STIND_I);
+ mono_mb_emit_byte (mb, CEE_STIND_REF);
}
}
mono_mb_emit_ldloc (mb, src_ptr);
mono_mb_emit_byte (mb, CEE_LDIND_I);
- mono_mb_emit_icall (mb, conv_to_icall (conv));
+ mono_mb_emit_icall (mb, conv_to_icall (conv, NULL));
if (need_free) {
/* src */
if (t->byref)
mono_mb_emit_byte (mb, CEE_LDIND_REF);
mono_mb_emit_ldloc (mb, conv_arg);
- mono_mb_emit_icall (mb, conv_to_icall (MONO_MARSHAL_FREE_LPARRAY));
+ mono_mb_emit_icall (mb, conv_to_icall (MONO_MARSHAL_FREE_LPARRAY, NULL));
}
break;
mono_mb_emit_ldloc (mb, src_ptr);
mono_mb_emit_byte (mb, CEE_LDIND_I);
- mono_mb_emit_icall (mb, conv_to_icall (conv));
+ mono_mb_emit_icall (mb, conv_to_icall (conv, NULL));
mono_mb_emit_byte (mb, CEE_STELEM_REF);
}
else {
/* Emit marshalling code */
if (is_string) {
+ int stind_op;
g_assert (conv != MONO_MARSHAL_CONV_INVALID);
/* dest */
mono_mb_emit_byte (mb, CEE_LDELEM_REF);
- mono_mb_emit_icall (mb, conv_to_icall (conv));
- mono_mb_emit_byte (mb, CEE_STIND_I);
+ mono_mb_emit_icall (mb, conv_to_icall (conv, &stind_op));
+ mono_mb_emit_byte (mb, stind_op);
}
else {
char *msg = g_strdup ("Marshalling of non-string and non-blittable arrays to managed code is not implemented.");
/* Emit marshalling code */
if (is_string) {
+ int stind_op;
g_assert (conv != MONO_MARSHAL_CONV_INVALID);
/* dest */
mono_mb_emit_byte (mb, CEE_LDELEM_REF);
- mono_mb_emit_icall (mb, conv_to_icall (conv));
- mono_mb_emit_byte (mb, CEE_STIND_I);
+ mono_mb_emit_icall (mb, conv_to_icall (conv, &stind_op));
+ mono_mb_emit_byte (mb, stind_op);
}
else {
char *msg = g_strdup ("Marshalling of non-string arrays to managed code is not implemented.");
// return obj
mono_mb_patch_branch (mb, positive_cache_hit_pos);
- mono_mb_emit_ldarg (mb, 0);
+ mono_mb_emit_ldarg (mb, obj_arg_position);
mono_mb_emit_byte (mb, CEE_RET);
#endif
MonoString *
ves_icall_System_Runtime_InteropServices_Marshal_PtrToStringAnsi_len (char *ptr, gint32 len)
{
- if (ptr == NULL) {
- mono_set_pending_exception (mono_get_exception_argument_null ("ptr"));
- return NULL;
- } else {
- return mono_string_new_len (mono_domain_get (), ptr, len);
- }
+ MonoError error;
+ MonoString *result = NULL;
+ mono_error_init (&error);
+ if (ptr == NULL)
+ mono_error_set_argument_null (&error, "ptr", "");
+ else
+ result = mono_string_new_len_checked (mono_domain_get (), ptr, len, &error);
+ mono_error_set_pending_exception (&error);
+ return result;
}
MonoString *
MonoArray*
mono_perfcounter_category_names (MonoString *machine)
{
+ MonoError error;
int i;
MonoArray *res;
MonoDomain *domain = mono_domain_get ();
GSList *custom_categories, *tmp;
/* no support for counters on other machines */
- if (mono_string_compare_ascii (machine, "."))
- return mono_array_new (domain, mono_get_string_class (), 0);
+ if (mono_string_compare_ascii (machine, ".")) {
+ res = mono_array_new_checked (domain, mono_get_string_class (), 0, &error);
+ mono_error_set_pending_exception (&error);
+ return res;
+ }
perfctr_lock ();
custom_categories = get_custom_categories ();
- res = mono_array_new (domain, mono_get_string_class (), NUM_CATEGORIES + g_slist_length (custom_categories));
+ res = mono_array_new_checked (domain, mono_get_string_class (), NUM_CATEGORIES + g_slist_length (custom_categories), &error);
+ if (mono_error_set_pending_exception (&error)) {
+ perfctr_unlock ();
+ return NULL;
+ }
+
for (i = 0; i < NUM_CATEGORIES; ++i) {
const CategoryDesc *cdesc = &predef_categories [i];
mono_array_setref (res, i, mono_string_new (domain, cdesc->name));
MonoArray*
mono_perfcounter_counter_names (MonoString *category, MonoString *machine)
{
+ MonoError error;
int i;
SharedCategory *scat;
const CategoryDesc *cdesc;
MonoArray *res;
MonoDomain *domain = mono_domain_get ();
/* no support for counters on other machines */
- if (mono_string_compare_ascii (machine, "."))
- return mono_array_new (domain, mono_get_string_class (), 0);
+ if (mono_string_compare_ascii (machine, ".")) {
+ res = mono_array_new_checked (domain, mono_get_string_class (), 0, &error);
+ mono_error_set_pending_exception (&error);
+ return res;
+ }
cdesc = find_category (category);
if (cdesc) {
- res = mono_array_new (domain, mono_get_string_class (), cdesc [1].first_counter - cdesc->first_counter);
+ res = mono_array_new_checked (domain, mono_get_string_class (), cdesc [1].first_counter - cdesc->first_counter, &error);
+ if (mono_error_set_pending_exception (&error))
+ return NULL;
for (i = cdesc->first_counter; i < cdesc [1].first_counter; ++i) {
const CounterDesc *desc = &predef_counters [i];
mono_array_setref (res, i - cdesc->first_counter, mono_string_new (domain, desc->name));
if (scat) {
char *p = custom_category_counters (scat);
int i;
- res = mono_array_new (domain, mono_get_string_class (), scat->num_counters);
+ res = mono_array_new_checked (domain, mono_get_string_class (), scat->num_counters, &error);
+ if (mono_error_set_pending_exception (&error)) {
+ perfctr_unlock ();
+ return NULL;
+ }
+
for (i = 0; i < scat->num_counters; ++i) {
mono_array_setref (res, i, mono_string_new (domain, p + 1));
p += 2; /* skip counter type */
return res;
}
perfctr_unlock ();
- return mono_array_new (domain, mono_get_string_class (), 0);
+ res = mono_array_new_checked (domain, mono_get_string_class (), 0, &error);
+ mono_error_set_pending_exception (&error);
+ return res;
}
static MonoArray*
-get_string_array (void **array, int count, gboolean is_process)
+get_string_array (void **array, int count, gboolean is_process, MonoError *error)
{
int i;
MonoDomain *domain = mono_domain_get ();
- MonoArray * res = mono_array_new (mono_domain_get (), mono_get_string_class (), count);
+ mono_error_init (error);
+ MonoArray * res = mono_array_new_checked (mono_domain_get (), mono_get_string_class (), count, error);
+ return_val_if_nok (error, NULL);
for (i = 0; i < count; ++i) {
char buf [128];
char *p;
}
static MonoArray*
-get_string_array_of_strings (void **array, int count)
+get_string_array_of_strings (void **array, int count, MonoError *error)
{
int i;
MonoDomain *domain = mono_domain_get ();
- MonoArray * res = mono_array_new (mono_domain_get (), mono_get_string_class (), count);
+ mono_error_init (error);
+ MonoArray * res = mono_array_new_checked (mono_domain_get (), mono_get_string_class (), count, error);
+ return_val_if_nok (error, NULL);
for (i = 0; i < count; ++i) {
char* p = (char *)array[i];
mono_array_setref (res, i, mono_string_new (domain, p));
}
static MonoArray*
-get_mono_instances (void)
+get_mono_instances (MonoError *error)
{
int count = 64;
int res;
void **buf = NULL;
MonoArray *array;
+ mono_error_init (error);
do {
count *= 2;
g_free (buf);
buf = g_new (void*, count);
res = mono_shared_area_instances (buf, count);
} while (res == count);
- array = get_string_array (buf, res, TRUE);
+ array = get_string_array (buf, res, TRUE, error);
g_free (buf);
return array;
}
static MonoArray*
-get_cpu_instances (void)
+get_cpu_instances (MonoError *error)
{
void **buf = NULL;
int i, count;
MonoArray *array;
-
+ mono_error_init (error);
count = mono_cpu_count () + 1; /* +1 for "_Total" */
buf = g_new (void*, count);
for (i = 0; i < count; ++i)
buf [i] = GINT_TO_POINTER (i - 1); /* -1 => _Total */
- array = get_string_array (buf, count, FALSE);
+ array = get_string_array (buf, count, FALSE, error);
g_free (buf);
mono_array_setref (array, 0, mono_string_new (mono_domain_get (), "_Total"));
return array;
}
static MonoArray*
-get_processes_instances (void)
+get_processes_instances (MonoError *error)
{
MonoArray *array;
int count = 0;
void **buf = mono_process_list (&count);
+ mono_error_init (error);
if (!buf)
- return get_string_array (NULL, 0, FALSE);
- array = get_string_array (buf, count, TRUE);
+ return get_string_array (NULL, 0, FALSE, error);
+ array = get_string_array (buf, count, TRUE, error);
g_free (buf);
return array;
}
static MonoArray*
-get_networkinterface_instances (void)
+get_networkinterface_instances (MonoError *error)
{
MonoArray *array;
int count = 0;
+ mono_error_init (error);
void **buf = mono_networkinterface_list (&count);
if (!buf)
- return get_string_array_of_strings (NULL, 0);
- array = get_string_array_of_strings (buf, count);
+ return get_string_array_of_strings (NULL, 0, error);
+ array = get_string_array_of_strings (buf, count, error);
g_strfreev ((char **) buf);
return array;
}
static MonoArray*
-get_custom_instances (MonoString *category)
+get_custom_instances (MonoString *category, MonoError *error)
{
SharedCategory *scat;
+ mono_error_init (error);
scat = find_custom_category (category);
if (scat) {
GSList *list = get_custom_instances_list (scat);
GSList *tmp;
int i = 0;
- MonoArray *array = mono_array_new (mono_domain_get (), mono_get_string_class (), g_slist_length (list));
+ MonoArray *array = mono_array_new_checked (mono_domain_get (), mono_get_string_class (), g_slist_length (list), error);
+ if (!is_ok (error)) {
+ g_slist_free (list);
+ return NULL;
+ }
for (tmp = list; tmp; tmp = tmp->next) {
SharedInstance *inst = (SharedInstance *)tmp->data;
mono_array_setref (array, i, mono_string_new (mono_domain_get (), inst->instance_name));
g_slist_free (list);
return array;
}
- return mono_array_new (mono_domain_get (), mono_get_string_class (), 0);
+ return mono_array_new_checked (mono_domain_get (), mono_get_string_class (), 0, error);
}
MonoArray*
mono_perfcounter_instance_names (MonoString *category, MonoString *machine)
{
+ MonoError error;
const CategoryDesc* cat;
- if (mono_string_compare_ascii (machine, "."))
- return mono_array_new (mono_domain_get (), mono_get_string_class (), 0);
+ MonoArray *result = NULL;
+ if (mono_string_compare_ascii (machine, ".")) {
+ result = mono_array_new_checked (mono_domain_get (), mono_get_string_class (), 0, &error);
+ mono_error_set_pending_exception (&error);
+ return result;
+ }
+
cat = find_category (category);
- if (!cat)
- return get_custom_instances (category);
+ if (!cat) {
+ MonoArray *result = get_custom_instances (category, &error);
+ mono_error_set_pending_exception (&error);
+ return result;
+ }
switch (cat->instance_type) {
case MonoInstance:
- return get_mono_instances ();
+ result = get_mono_instances (&error);
+ break;
case CPUInstance:
- return get_cpu_instances ();
+ result = get_cpu_instances (&error);
+ break;
case ProcessInstance:
- return get_processes_instances ();
+ result = get_processes_instances (&error);
+ break;
case NetworkInterfaceInstance:
- return get_networkinterface_instances ();
+ result = get_networkinterface_instances (&error);
+ break;
case ThreadInstance:
default:
- return mono_array_new (mono_domain_get (), mono_get_string_class (), 0);
+ result = mono_array_new_checked (mono_domain_get (), mono_get_string_class (), 0, &error);
}
+ mono_error_set_pending_exception (&error);
+ return result;
}
typedef struct {
MonoArray*
ves_icall_System_Security_Principal_WindowsIdentity_GetRoles (gpointer token)
{
+ MonoError error;
MonoArray *array = NULL;
MonoDomain *domain = mono_domain_get ();
#ifdef HOST_WIN32
- MonoError error;
gint32 size = 0;
GetTokenInformation (token, TokenGroups, NULL, size, (PDWORD)&size);
int i=0;
int num = tg->GroupCount;
- array = mono_array_new (domain, mono_get_string_class (), num);
+ array = mono_array_new_checked (domain, mono_get_string_class (), num, &error);
+ if (mono_error_set_pending_exception (&error)) {
+ g_free (tg);
+ return NULL;
+ }
for (i=0; i < num; i++) {
gint32 size = 0;
#endif
if (!array) {
/* return empty array of string, i.e. string [0] */
- array = mono_array_new (domain, mono_get_string_class (), 0);
+ array = mono_array_new_checked (domain, mono_get_string_class (), 0, &error);
+ mono_error_set_pending_exception (&error);
}
return array;
}
}; \
tmp_klass; })
/* eclass should be a run-time constant */
-#define mono_array_new_cached(domain, eclass, size) ({ \
- MonoError __error; \
+#define mono_array_new_cached(domain, eclass, size, error) ({ \
MonoVTable *__vtable = mono_class_vtable ((domain), mono_array_class_get_cached ((eclass), 1)); \
- MonoArray *__arr = mono_array_new_specific_checked (__vtable, (size), &__error); \
- mono_error_raise_exception (&__error); /* FIXME don't raise here */ \
+ MonoArray *__arr = mono_array_new_specific_checked (__vtable, (size), (error)); \
__arr; })
#else
#define mono_class_get_field_from_name_cached(klass,name) mono_class_get_field_from_name ((klass), (name))
#define mono_array_class_get_cached(eclass,rank) mono_array_class_get ((eclass), (rank))
-#define mono_array_new_cached(domain, eclass, size) mono_array_new_specific (mono_class_vtable ((domain), mono_array_class_get_cached ((eclass), 1)), (size))
+#define mono_array_new_cached(domain, eclass, size, error) mono_array_new_specific_checked (mono_class_vtable ((domain), mono_array_class_get_cached ((eclass), 1)), (size), (error))
#endif
ves_icall_System_Runtime_Remoting_Messaging_AsyncResult_Invoke (MonoAsyncResult *ares);
MonoWaitHandle *
-mono_wait_handle_new (MonoDomain *domain, HANDLE handle);
+mono_wait_handle_new (MonoDomain *domain, HANDLE handle, MonoError *error);
HANDLE
mono_wait_handle_get_handle (MonoWaitHandle *handle);
MonoDelegate **cb, MonoObject **state);
void
-mono_method_return_message_restore (MonoMethod *method, gpointer *params, MonoArray *out_args);
+mono_method_return_message_restore (MonoMethod *method, gpointer *params, MonoArray *out_args, MonoError *error);
void
mono_delegate_ctor_with_method (MonoObject *this_obj, MonoObject *target, gpointer addr, MonoMethod *method);
MonoArray*
-mono_array_clone_in_domain (MonoDomain *domain, MonoArray *array);
+mono_array_clone_in_domain (MonoDomain *domain, MonoArray *array, MonoError *error);
+
+MonoArray*
+mono_array_clone_checked (MonoArray *array, MonoError *error);
void
mono_array_full_copy (MonoArray *src, MonoArray *dest);
gboolean
mono_array_calc_byte_len (MonoClass *klass, uintptr_t len, uintptr_t *res);
+MonoArray*
+mono_array_new_checked (MonoDomain *domain, MonoClass *eclass, uintptr_t n, MonoError *error);
+
MonoArray*
mono_array_new_full_checked (MonoDomain *domain, MonoClass *array_class, uintptr_t *lengths, intptr_t *lower_bounds, MonoError *error);
MonoArray*
mono_array_new_specific_checked (MonoVTable *vtable, uintptr_t n, MonoError *error);
+MonoArray*
+ves_icall_array_new (MonoDomain *domain, MonoClass *eclass, uintptr_t n);
+
MonoArray*
ves_icall_array_new_specific (MonoVTable *vtable, uintptr_t n);
void
mono_upgrade_remote_class (MonoDomain *domain, MonoObject *tproxy, MonoClass *klass);
+
+void*
+mono_load_remote_field_checked (MonoObject *this_obj, MonoClass *klass, MonoClassField *field, void **res, MonoError *error);
+
+MonoObject *
+mono_load_remote_field_new_icall (MonoObject *this_obj, MonoClass *klass, MonoClassField *field);
+
+MonoObject *
+mono_load_remote_field_new_checked (MonoObject *this_obj, MonoClass *klass, MonoClassField *field, MonoError *error);
+
+gboolean
+mono_store_remote_field_checked (MonoObject *this_obj, MonoClass *klass, MonoClassField *field, void* val, MonoError *error);
+
+void
+mono_store_remote_field_new_icall (MonoObject *this_obj, MonoClass *klass, MonoClassField *field, MonoObject *arg);
+
+gboolean
+mono_store_remote_field_new_checked (MonoObject *this_obj, MonoClass *klass, MonoClassField *field, MonoObject *arg, MonoError *error);
+
+
#endif
gpointer
mono_class_compute_bitmap (MonoClass *klass, gsize *bitmap, int size, int offset, int *max_set, gboolean static_fields);
MonoObject*
-mono_object_xdomain_representation (MonoObject *obj, MonoDomain *target_domain, MonoObject **exc);
+mono_object_xdomain_representation (MonoObject *obj, MonoDomain *target_domain, MonoError *error);
gboolean
mono_class_is_reflection_method_or_constructor (MonoClass *klass);
MonoObject *
mono_field_get_value_object_checked (MonoDomain *domain, MonoClassField *field, MonoObject *obj, MonoError *error);
+gboolean
+mono_property_set_value_checked (MonoProperty *prop, void *obj, void **params, MonoError *error);
+
+MonoObject*
+mono_property_get_value_checked (MonoProperty *prop, void *obj, void **params, MonoError *error);
+
char *
mono_string_to_utf8_ignore (MonoString *s);
mono_error_set_pending_exception (MonoError *error);
MonoArray *
-mono_glist_to_array (GList *list, MonoClass *eclass);
+mono_glist_to_array (GList *list, MonoClass *eclass, MonoError *error);
MonoObject *
mono_object_new_checked (MonoDomain *domain, MonoClass *klass, MonoError *error);
MonoString *
mono_string_new_size_checked (MonoDomain *domain, gint32 len, MonoError *error);
+MonoString*
+mono_string_new_len_checked (MonoDomain *domain, const char *text, guint length, MonoError *error);
+
MonoString*
mono_string_new_checked (MonoDomain *domain, const char *text, MonoError *merror);
mono_runtime_invoke_checked (MonoMethod *method, void *obj, void **params, MonoError *error);
+MonoArray*
+mono_runtime_get_main_args_checked (MonoError *error);
+
#endif /* __MONO_OBJECT_INTERNALS_H__ */
get_default_field_value (MonoDomain* domain, MonoClassField *field, void *value);
static MonoString*
-mono_ldstr_metadata_sig (MonoDomain *domain, const char* sig);
+mono_ldstr_metadata_sig (MonoDomain *domain, const char* sig, MonoError *error);
static void
free_main_args (void);
}
gpointer
-mono_runtime_create_jump_trampoline (MonoDomain *domain, MonoMethod *method, gboolean add_sync_wrapper)
+mono_runtime_create_jump_trampoline (MonoDomain *domain, MonoMethod *method, gboolean add_sync_wrapper, MonoError *error)
{
- MonoError error;
gpointer res;
MONO_REQ_GC_NEUTRAL_MODE;
- res = callbacks.create_jump_trampoline (domain, method, add_sync_wrapper, &error);
- if (!mono_error_ok (&error))
- mono_error_raise_exception (&error); /* FIXME: Don't raise here */
+ mono_error_init (error);
+ res = callbacks.create_jump_trampoline (domain, method, add_sync_wrapper, error);
return res;
}
{
MonoError error;
MonoString *str = mono_string_new_size_checked (mono_domain_get (), length, &error);
- mono_error_raise_exception (&error);
+ mono_error_set_pending_exception (&error);
return str;
}
{
MONO_REQ_GC_UNSAFE_MODE;
+ MonoError error;
int retval = 0;
const char *p = blob;
mono_metadata_decode_blob_size (p, &p);
readr8 (p, (double*) value);
break;
case MONO_TYPE_STRING:
- *(gpointer*) value = mono_ldstr_metadata_sig (domain, blob);
+ *(gpointer*) value = mono_ldstr_metadata_sig (domain, blob, &error);
+ mono_error_raise_exception (&error); /* FIXME don't raise here */
break;
case MONO_TYPE_CLASS:
*(gpointer*) value = NULL;
if (exc && *exc == NULL && !mono_error_ok (&error)) {
*exc = (MonoObject*) mono_error_convert_to_exception (&error);
} else {
- mono_error_raise_exception (&error); /* FIXME don't raise here */
+ mono_error_cleanup (&error);
}
}
+/**
+ * mono_property_set_value_checked:
+ * @prop: MonoProperty to set
+ * @obj: instance object on which to act
+ * @params: parameters to pass to the propery
+ * @error: set on error
+ *
+ * Invokes the property's set method with the given arguments on the
+ * object instance obj (or NULL for static properties).
+ *
+ * Returns: TRUE on success. On failure returns FALSE and sets @error.
+ * If an exception is thrown, it will be caught and returned via @error.
+ */
+gboolean
+mono_property_set_value_checked (MonoProperty *prop, void *obj, void **params, MonoError *error)
+{
+ MONO_REQ_GC_UNSAFE_MODE;
+
+ MonoObject *exc;
+
+ mono_error_init (error);
+ do_runtime_invoke (prop->set, obj, params, &exc, error);
+ if (exc != NULL && is_ok (error))
+ mono_error_set_exception_instance (error, (MonoException*)exc);
+ return is_ok (error);
+}
+
/**
* mono_property_get_value:
* @prop: MonoProperty to fetch
if (exc && *exc == NULL && !mono_error_ok (&error)) {
*exc = (MonoObject*) mono_error_convert_to_exception (&error);
} else {
- mono_error_raise_exception (&error); /* FIXME don't raise here */
+ mono_error_cleanup (&error); /* FIXME don't raise here */
}
return val;
}
+/**
+ * mono_property_get_value_checked:
+ * @prop: MonoProperty to fetch
+ * @obj: instance object on which to act
+ * @params: parameters to pass to the propery
+ * @error: set on error
+ *
+ * Invokes the property's get method with the given arguments on the
+ * object instance obj (or NULL for static properties).
+ *
+ * If an exception is thrown, you can't use the
+ * MonoObject* result from the function. The exception will be propagated via @error.
+ *
+ * Returns: the value from invoking the get method on the property. On
+ * failure returns NULL and sets @error.
+ */
+MonoObject*
+mono_property_get_value_checked (MonoProperty *prop, void *obj, void **params, MonoError *error)
+{
+ MONO_REQ_GC_UNSAFE_MODE;
+
+ MonoObject *exc;
+ MonoObject *val = do_runtime_invoke (prop->get, obj, params, &exc, error);
+ if (exc != NULL && !is_ok (error))
+ mono_error_set_exception_instance (error, (MonoException*) exc);
+ if (!is_ok (error))
+ val = NULL;
+ return val;
+}
+
+
/*
* mono_nullable_init:
* @buf: The nullable structure to initialize.
mono_runtime_get_main_args (void)
{
MONO_REQ_GC_UNSAFE_MODE;
+ MonoError error;
+ MonoArray *result = mono_runtime_get_main_args_checked (&error);
+ mono_error_assert_ok (&error);
+ return result;
+}
+/**
+ * mono_runtime_get_main_args:
+ * @error: set on error
+ *
+ * Returns: a MonoArray with the arguments passed to the main
+ * program. On failure returns NULL and sets @error.
+ */
+MonoArray*
+mono_runtime_get_main_args_checked (MonoError *error)
+{
MonoArray *res;
int i;
MonoDomain *domain = mono_domain_get ();
- res = (MonoArray*)mono_array_new (domain, mono_defaults.string_class, num_main_args);
+ mono_error_init (error);
+
+ res = (MonoArray*)mono_array_new_checked (domain, mono_defaults.string_class, num_main_args, error);
+ return_val_if_nok (error, NULL);
for (i = 0; i < num_main_args; ++i)
mono_array_setref (res, i, mono_string_new (domain, main_args [i]));
{
MONO_REQ_GC_UNSAFE_MODE;
+ MonoError error;
int i;
MonoArray *args = NULL;
MonoDomain *domain = mono_domain_get ();
}
if (sig->param_count) {
- args = (MonoArray*)mono_array_new (domain, mono_defaults.string_class, argc);
+ args = (MonoArray*)mono_array_new_checked (domain, mono_defaults.string_class, argc, &error);
+ mono_error_assert_ok (&error);
for (i = 0; i < argc; ++i) {
/* The encodings should all work, given that
* we've checked all these args for the
g_free (str);
}
} else {
- args = (MonoArray*)mono_array_new (domain, mono_defaults.string_class, 0);
+ args = (MonoArray*)mono_array_new_checked (domain, mono_defaults.string_class, 0, &error);
+ mono_error_assert_ok (&error);
}
mono_assembly_set_main (method->klass->image->assembly);
#ifndef DISABLE_REMOTING
static MonoObject*
-make_transparent_proxy (MonoObject *obj, gboolean *failure, MonoObject **exc)
+make_transparent_proxy (MonoObject *obj, MonoError *error)
{
MONO_REQ_GC_UNSAFE_MODE;
static MonoMethod *get_proxy_method;
- MonoError error;
MonoDomain *domain = mono_domain_get ();
MonoRealProxy *real_proxy;
MonoReflectionType *reflection_type;
MonoTransparentProxy *transparent_proxy;
+ mono_error_init (error);
+
if (!get_proxy_method)
get_proxy_method = mono_class_get_method_from_name (mono_defaults.real_proxy_class, "GetTransparentProxy", 0);
g_assert (mono_class_is_marshalbyref (obj->vtable->klass));
- real_proxy = (MonoRealProxy*) mono_object_new_checked (domain, mono_defaults.real_proxy_class, &error);
- mono_error_raise_exception (&error); /* FIXME don't raise here */
- reflection_type = mono_type_get_object_checked (domain, &obj->vtable->klass->byval_arg, &error);
- mono_error_raise_exception (&error); /* FIXME don't raise here */
+ real_proxy = (MonoRealProxy*) mono_object_new_checked (domain, mono_defaults.real_proxy_class, error);
+ return_val_if_nok (error, NULL);
+ reflection_type = mono_type_get_object_checked (domain, &obj->vtable->klass->byval_arg, error);
+ return_val_if_nok (error, NULL);
MONO_OBJECT_SETREF (real_proxy, class_to_proxy, reflection_type);
MONO_OBJECT_SETREF (real_proxy, unwrapped_server, obj);
- *exc = NULL;
+ MonoObject *exc = NULL;
- transparent_proxy = (MonoTransparentProxy*) mono_runtime_try_invoke (get_proxy_method, real_proxy, NULL, exc, &error);
- if (*exc == NULL && !mono_error_ok (&error))
- *exc = (MonoObject*) mono_error_convert_to_exception (&error); /* FIXME change make_transparent_proxy outarg to MonoError */
- else
- mono_error_cleanup (&error);
- if (*exc)
- *failure = TRUE;
+ transparent_proxy = (MonoTransparentProxy*) mono_runtime_try_invoke (get_proxy_method, real_proxy, NULL, &exc, error);
+ if (exc != NULL && is_ok (error))
+ mono_error_set_exception_instance (error, (MonoException*)exc);
return (MonoObject*) transparent_proxy;
}
* mono_object_xdomain_representation
* @obj: an object
* @target_domain: a domain
- * @exc: pointer to a MonoObject*
+ * @error: set on error.
*
* Creates a representation of obj in the domain target_domain. This
* is either a copy of obj arrived through via serialization and
* serializable or marshal by ref. obj must not be in target_domain.
*
* If the object cannot be represented in target_domain, NULL is
- * returned and *exc is set to an appropriate exception.
+ * returned and @error is set appropriately.
*/
MonoObject*
-mono_object_xdomain_representation (MonoObject *obj, MonoDomain *target_domain, MonoObject **exc)
+mono_object_xdomain_representation (MonoObject *obj, MonoDomain *target_domain, MonoError *error)
{
MONO_REQ_GC_UNSAFE_MODE;
+ mono_error_init (error);
MonoObject *deserialized = NULL;
- gboolean failure = FALSE;
-
- g_assert (exc != NULL);
- *exc = NULL;
#ifndef DISABLE_REMOTING
if (mono_class_is_marshalbyref (mono_object_class (obj))) {
- deserialized = make_transparent_proxy (obj, &failure, exc);
+ deserialized = make_transparent_proxy (obj, error);
}
else
#endif
{
+ gboolean failure = FALSE;
MonoDomain *domain = mono_domain_get ();
MonoObject *serialized;
+ MonoObject *exc = NULL;
mono_domain_set_internal_with_options (mono_object_domain (obj), FALSE);
- serialized = serialize_object (obj, &failure, exc);
+ serialized = serialize_object (obj, &failure, &exc);
mono_domain_set_internal_with_options (target_domain, FALSE);
if (!failure)
- deserialized = deserialize_object (serialized, &failure, exc);
+ deserialized = deserialize_object (serialized, &failure, &exc);
if (domain != target_domain)
mono_domain_set_internal_with_options (domain, FALSE);
+ if (failure)
+ mono_error_set_exception_instance (error, (MonoException*)exc);
}
return deserialized;
g_assert (domain == mono_object_domain (domain->domain));
if (mono_object_domain (exc) != domain) {
- MonoObject *serialization_exc;
+ MonoError error;
- exc = mono_object_xdomain_representation (exc, domain, &serialization_exc);
+ exc = mono_object_xdomain_representation (exc, domain, &error);
if (!exc) {
- if (serialization_exc) {
- MonoObject *dummy;
- exc = mono_object_xdomain_representation (serialization_exc, domain, &dummy);
- g_assert (exc);
+ if (!is_ok (&error)) {
+ MonoError inner_error;
+ MonoException *serialization_exc = mono_error_convert_to_exception (&error);
+ exc = mono_object_xdomain_representation ((MonoObject*)serialization_exc, domain, &inner_error);
+ mono_error_assert_ok (&inner_error);
} else {
exc = (MonoObject*) mono_exception_from_name_msg (mono_get_corlib (),
"System.Runtime.Serialization", "SerializationException",
MonoObject * result = mono_object_new_checked (domain, klass, &error);
- mono_error_raise_exception (&error);
+ mono_error_cleanup (&error);
return result;
}
MonoObject * result = mono_object_new_checked (domain, klass, &error);
- mono_error_raise_exception (&error);
+ mono_error_set_pending_exception (&error);
return result;
}
{
MonoError error;
MonoObject *o = mono_object_new_specific_checked (vtable, &error);
- mono_error_raise_exception (&error);
+ mono_error_cleanup (&error);
return o;
}
{
MonoError error;
MonoObject *o = mono_object_new_specific_checked (vtable, &error);
- mono_error_raise_exception (&error);
+ mono_error_set_pending_exception (&error);
return o;
}
{
MonoError error;
MonoObject *o = mono_object_new_alloc_specific_checked (vtable, &error);
- mono_error_raise_exception (&error);
+ mono_error_cleanup (&error);
return o;
}
{
MonoError error;
MonoObject *o = mono_object_new_fast_checked (vtable, &error);
- mono_error_raise_exception (&error);
+ mono_error_cleanup (&error);
return o;
}
{
MonoError error;
MonoObject *o = mono_object_new_fast_checked (vtable, &error);
- mono_error_raise_exception (&error);
+ mono_error_set_pending_exception (&error);
return o;
}
MonoClass *klass;
klass = mono_class_get_checked (image, token, &error);
- g_assert (mono_error_ok (&error)); /* FIXME don't swallow the error */
+ mono_error_assert_ok (&error);
result = mono_object_new_checked (domain, klass, &error);
- mono_error_raise_exception (&error); /* FIXME don't raise here */
+ mono_error_cleanup (&error);
return result;
}
{
MonoError error;
MonoObject *o = mono_object_clone_checked (obj, &error);
- mono_error_raise_exception (&error);
+ mono_error_cleanup (&error);
return o;
}
size = obj->vtable->klass->instance_size;
if (obj->vtable->klass->rank)
- return (MonoObject*)mono_array_clone ((MonoArray*)obj);
+ return (MonoObject*)mono_array_clone_checked ((MonoArray*)obj, error);
o = (MonoObject *)mono_gc_alloc_obj (obj->vtable, size);
* mono_array_clone_in_domain:
* @domain: the domain in which the array will be cloned into
* @array: the array to clone
+ * @error: set on error
*
* This routine returns a copy of the array that is hosted on the
- * specified MonoDomain.
+ * specified MonoDomain. On failure returns NULL and sets @error.
*/
MonoArray*
-mono_array_clone_in_domain (MonoDomain *domain, MonoArray *array)
+mono_array_clone_in_domain (MonoDomain *domain, MonoArray *array, MonoError *error)
{
MONO_REQ_GC_UNSAFE_MODE;
- MonoError error;
MonoArray *o;
uintptr_t size, i;
uintptr_t *sizes;
MonoClass *klass = array->obj.vtable->klass;
+ mono_error_init (error);
+
if (array->bounds == NULL) {
size = mono_array_length (array);
- o = mono_array_new_full_checked (domain, klass, &size, NULL, &error);
- mono_error_raise_exception (&error); /* FIXME don't raise here */
+ o = mono_array_new_full_checked (domain, klass, &size, NULL, error);
+ return_val_if_nok (error, NULL);
size *= mono_array_element_size (klass);
#ifdef HAVE_SGEN_GC
size *= array->bounds [i].length;
sizes [i + klass->rank] = array->bounds [i].lower_bound;
}
- o = mono_array_new_full_checked (domain, klass, sizes, (intptr_t*)sizes + klass->rank, &error);
- mono_error_raise_exception (&error); /* FIXME don't raise here */
+ o = mono_array_new_full_checked (domain, klass, sizes, (intptr_t*)sizes + klass->rank, error);
+ return_val_if_nok (error, NULL);
#ifdef HAVE_SGEN_GC
if (klass->element_class->valuetype) {
if (klass->element_class->has_references)
{
MONO_REQ_GC_UNSAFE_MODE;
- return mono_array_clone_in_domain (((MonoObject *)array)->vtable->domain, array);
+ MonoError error;
+ MonoArray *result = mono_array_clone_checked (array, &error);
+ mono_error_cleanup (&error);
+ return result;
+}
+
+/**
+ * mono_array_clone_checked:
+ * @array: the array to clone
+ * @error: set on error
+ *
+ * Returns: A newly created array who is a shallow copy of @array. On
+ * failure returns NULL and sets @error.
+ */
+MonoArray*
+mono_array_clone_checked (MonoArray *array, MonoError *error)
+{
+
+ MONO_REQ_GC_UNSAFE_MODE;
+ return mono_array_clone_in_domain (((MonoObject *)array)->vtable->domain, array, error);
}
/* helper macros to check for overflow when calculating the size of arrays */
{
MonoError error;
MonoArray *array = mono_array_new_full_checked (domain, array_class, lengths, lower_bounds, &error);
- mono_error_raise_exception (&error);
+ mono_error_cleanup (&error);
return array;
}
MONO_REQ_GC_UNSAFE_MODE;
MonoError error;
+ MonoArray *result = mono_array_new_checked (domain, eclass, n, &error);
+ mono_error_cleanup (&error);
+ return result;
+}
+
+/**
+ * mono_array_new_checked:
+ * @domain: domain where the object is created
+ * @eclass: element class
+ * @n: number of array elements
+ * @error: set on error
+ *
+ * This routine creates a new szarray with @n elements of type @eclass.
+ * On failure returns NULL and sets @error.
+ */
+MonoArray *
+mono_array_new_checked (MonoDomain *domain, MonoClass *eclass, uintptr_t n, MonoError *error)
+{
MonoClass *ac;
- MonoArray *arr;
+
+ mono_error_init (error);
ac = mono_array_class_get (eclass, 1);
g_assert (ac);
- MonoVTable *vtable = mono_class_vtable_full (domain, ac, &error);
- mono_error_raise_exception (&error); /* FIXME don't raise here */
+ MonoVTable *vtable = mono_class_vtable_full (domain, ac, error);
+ return_val_if_nok (error, NULL);
- arr = mono_array_new_specific_checked (vtable, n, &error);
- mono_error_raise_exception (&error); /* FIXME don't raise here */
+ return mono_array_new_specific_checked (vtable, n, error);
+}
+
+MonoArray*
+ves_icall_array_new (MonoDomain *domain, MonoClass *eclass, uintptr_t n)
+{
+ MonoError error;
+ MonoArray *arr = mono_array_new_checked (domain, eclass, n, &error);
+ mono_error_set_pending_exception (&error);
return arr;
}
{
MonoError error;
MonoArray *arr = mono_array_new_specific_checked (vtable, n, &error);
- mono_error_raise_exception (&error); /* FIXME don't raise here */
+ mono_error_cleanup (&error);
return arr;
}
{
MonoError error;
MonoArray *arr = mono_array_new_specific_checked (vtable, n, &error);
- mono_error_raise_exception (&error);
+ mono_error_set_pending_exception (&error);
return arr;
}
MonoError error;
MonoString *res = NULL;
res = mono_string_new_utf16_checked (domain, text, len, &error);
- mono_error_raise_exception (&error);
+ mono_error_cleanup (&error);
return res;
}
* mono_string_new_utf32:
* @text: a pointer to an utf32 string
* @len: the length of the string
+ * @error: set on failure.
*
- * Returns: A newly created string object which contains @text.
+ * Returns: A newly created string object which contains @text. On failure returns NULL and sets @error.
*/
-MonoString *
-mono_string_new_utf32 (MonoDomain *domain, const mono_unichar4 *text, gint32 len)
+static MonoString *
+mono_string_new_utf32_checked (MonoDomain *domain, const mono_unichar4 *text, gint32 len, MonoError *error)
{
MONO_REQ_GC_UNSAFE_MODE;
- MonoError error;
MonoString *s;
mono_unichar2 *utf16_output = NULL;
gint32 utf16_len = 0;
GError *gerror = NULL;
glong items_written;
+ mono_error_init (error);
utf16_output = g_ucs4_to_utf16 (text, len, NULL, &items_written, &gerror);
if (gerror)
while (utf16_output [utf16_len]) utf16_len++;
- s = mono_string_new_size_checked (domain, utf16_len, &error);
- mono_error_raise_exception (&error); /* FIXME don't raise here */
+ s = mono_string_new_size_checked (domain, utf16_len, error);
+ return_val_if_nok (error, NULL);
memcpy (mono_string_chars (s), utf16_output, utf16_len * 2);
return s;
}
+/**
+ * mono_string_new_utf32:
+ * @text: a pointer to an utf32 string
+ * @len: the length of the string
+ *
+ * Returns: A newly created string object which contains @text.
+ */
+MonoString *
+mono_string_new_utf32 (MonoDomain *domain, const mono_unichar4 *text, gint32 len)
+{
+ MonoError error;
+ MonoString *result = mono_string_new_utf32_checked (domain, text, len, &error);
+ mono_error_cleanup (&error);
+ return result;
+}
+
/**
* mono_string_new_size:
* @text: a pointer to an utf16 string
{
MonoError error;
MonoString *str = mono_string_new_size_checked (domain, len, &error);
- mono_error_raise_exception (&error);
+ mono_error_cleanup (&error);
return str;
}
MONO_REQ_GC_UNSAFE_MODE;
MonoError error;
+ MonoString *result = mono_string_new_len_checked (domain, text, length, &error);
+ mono_error_cleanup (&error);
+ return result;
+}
+
+/**
+ * mono_string_new_len_checked:
+ * @text: a pointer to an utf8 string
+ * @length: number of bytes in @text to consider
+ * @error: set on error
+ *
+ * Returns: A newly created string object which contains @text. On
+ * failure returns NULL and sets @error.
+ */
+MonoString*
+mono_string_new_len_checked (MonoDomain *domain, const char *text, guint length, MonoError *error)
+{
+ MONO_REQ_GC_UNSAFE_MODE;
+
+ mono_error_init (error);
+
GError *eg_error = NULL;
MonoString *o = NULL;
- guint16 *ut;
+ guint16 *ut = NULL;
glong items_written;
- mono_error_init (&error);
-
ut = eg_utf8_to_utf16_with_nuls (text, length, NULL, &items_written, &eg_error);
if (!eg_error)
- o = mono_string_new_utf16_checked (domain, ut, items_written, &error);
+ o = mono_string_new_utf16_checked (domain, ut, items_written, error);
else
g_error_free (eg_error);
g_free (ut);
- mono_error_raise_exception (&error); /* FIXME don't raise here */
return o;
}
g_error_free (eg_error);
g_free (ut);
- mono_error_raise_exception (error);
/*FIXME g_utf8_get_char, g_utf8_next_char and g_utf8_validate are not part of eglib.*/
#if 0
gpointer pa [2];
im = mono_class_get_method_from_name (rpklass, "CanCastTo", -1);
- if (!im)
- mono_raise_exception (mono_get_exception_not_supported ("Linked away."));
+ if (!im) {
+ mono_error_set_not_supported (error, "Linked away.");
+ return NULL;
+ }
im = mono_object_get_virtual_method (rp, im);
g_assert (im);
} else {
if (!mono_verifier_verify_string_signature (image, idx, NULL))
return NULL; /*FIXME we should probably be raising an exception here*/
- return mono_ldstr_metadata_sig (domain, mono_metadata_user_string (image, idx));
+ MonoString *str = mono_ldstr_metadata_sig (domain, mono_metadata_user_string (image, idx), &error);
+ mono_error_raise_exception (&error); /* FIXME don't raise here */
+ return str;
}
}
* mono_ldstr_metadata_sig
* @domain: the domain for the string
* @sig: the signature of a metadata string
+ * @error: set on error
*
- * Returns: a MonoString for a string stored in the metadata
+ * Returns: a MonoString for a string stored in the metadata. On
+ * failure returns NULL and sets @error.
*/
static MonoString*
-mono_ldstr_metadata_sig (MonoDomain *domain, const char* sig)
+mono_ldstr_metadata_sig (MonoDomain *domain, const char* sig, MonoError *error)
{
MONO_REQ_GC_UNSAFE_MODE;
- MonoError error;
+ mono_error_init (error);
const char *str = sig;
MonoString *o, *interned;
size_t len2;
len2 = mono_metadata_decode_blob_size (str, &str);
len2 >>= 1;
- o = mono_string_new_utf16_checked (domain, (guint16*)str, len2, &error);
- mono_error_raise_exception (&error); /* FIXME don't raise here */
+ o = mono_string_new_utf16_checked (domain, (guint16*)str, len2, error);
+ return_val_if_nok (error, NULL);
#if G_BYTE_ORDER != G_LITTLE_ENDIAN
{
int i;
if (interned)
return interned; /* o will get garbage collected */
- o = mono_string_get_pinned (o, &error);
- mono_error_raise_exception (&error); /* FIXME don't raise here */
+ o = mono_string_get_pinned (o, error);
if (o) {
ldstr_lock ();
interned = (MonoString *)mono_g_hash_table_lookup (domain->ldstr_table, o);
* mono_wait_handle_new:
* @domain: Domain where the object will be created
* @handle: Handle for the wait handle
+ * @error: set on error.
*
- * Returns: A new MonoWaitHandle created in the given domain for the given handle
+ * Returns: A new MonoWaitHandle created in the given domain for the
+ * given handle. On failure returns NULL and sets @rror.
*/
MonoWaitHandle *
-mono_wait_handle_new (MonoDomain *domain, HANDLE handle)
+mono_wait_handle_new (MonoDomain *domain, HANDLE handle, MonoError *error)
{
MONO_REQ_GC_UNSAFE_MODE;
- MonoError error;
MonoWaitHandle *res;
gpointer params [1];
static MonoMethod *handle_set;
- res = (MonoWaitHandle *)mono_object_new_checked (domain, mono_defaults.manualresetevent_class, &error);
- mono_error_raise_exception (&error); /* FIXME don't raise here */
+ mono_error_init (error);
+ res = (MonoWaitHandle *)mono_object_new_checked (domain, mono_defaults.manualresetevent_class, error);
+ return_val_if_nok (error, NULL);
/* Even though this method is virtual, it's safe to invoke directly, since the object type matches. */
if (!handle_set)
params [0] = &handle;
- mono_runtime_invoke_checked (handle_set, res, params, &error);
- mono_error_raise_exception (&error); /* FIXME don't raise here */
-
+ mono_runtime_invoke_checked (handle_set, res, params, error);
return res;
}
res->data = (void **)data;
MONO_OBJECT_SETREF (res, object_data, object_data);
MONO_OBJECT_SETREF (res, async_state, state);
+ MonoWaitHandle *wait_handle = mono_wait_handle_new (domain, handle, &error);
+ mono_error_raise_exception (&error); /* FIXME don't raise here */
if (handle != NULL)
- MONO_OBJECT_SETREF (res, handle, (MonoObject *) mono_wait_handle_new (domain, handle));
+ MONO_OBJECT_SETREF (res, handle, (MonoObject *) wait_handle);
res->sync_completed = FALSE;
res->completed = FALSE;
if (ac->cb_method) {
mono_runtime_invoke_checked (ac->cb_method, ac->cb_target, (gpointer*) &ares, &error);
- mono_error_raise_exception (&error);
+ if (mono_error_set_pending_exception (&error))
+ return NULL;
}
}
* Restore results from message based processing back to arguments pointers
*/
void
-mono_method_return_message_restore (MonoMethod *method, gpointer *params, MonoArray *out_args)
+mono_method_return_message_restore (MonoMethod *method, gpointer *params, MonoArray *out_args, MonoError *error)
{
MONO_REQ_GC_UNSAFE_MODE;
+ mono_error_init (error);
+
MonoMethodSignature *sig = mono_method_signature (method);
int i, j, type, size, out_len;
if (pt->byref) {
char *arg;
- if (j >= out_len)
- mono_raise_exception (mono_get_exception_execution_engine ("The proxy call returned an incorrect number of output arguments"));
+ if (j >= out_len) {
+ mono_error_set_execution_engine (error, "The proxy call returned an incorrect number of output arguments");
+ return;
+ }
arg = (char *)mono_array_get (out_args, gpointer, j);
type = pt->type;
gpointer
mono_load_remote_field (MonoObject *this_obj, MonoClass *klass, MonoClassField *field, gpointer *res)
{
- MONO_REQ_GC_UNSAFE_MODE;
-
MonoError error;
+ gpointer result = mono_load_remote_field_checked (this_obj, klass, field, res, &error);
+ mono_error_cleanup (&error);
+ return result;
+}
+
+/**
+ * mono_load_remote_field_checked:
+ * @this: pointer to an object
+ * @klass: klass of the object containing @field
+ * @field: the field to load
+ * @res: a storage to store the result
+ * @error: set on error
+ *
+ * This method is called by the runtime on attempts to load fields of
+ * transparent proxy objects. @this points to such TP, @klass is the class of
+ * the object containing @field. @res is a storage location which can be
+ * used to store the result.
+ *
+ * Returns: an address pointing to the value of field. On failure returns NULL and sets @error.
+ */
+gpointer
+mono_load_remote_field_checked (MonoObject *this_obj, MonoClass *klass, MonoClassField *field, gpointer *res, MonoError *error)
+{
+ MONO_REQ_GC_UNSAFE_MODE;
static MonoMethod *getter = NULL;
+
+ mono_error_init (error);
+
MonoDomain *domain = mono_domain_get ();
MonoTransparentProxy *tp = (MonoTransparentProxy *) this_obj;
MonoClass *field_class;
if (!getter) {
getter = mono_class_get_method_from_name (mono_defaults.object_class, "FieldGetter", -1);
- if (!getter)
- mono_raise_exception (mono_get_exception_not_supported ("Linked away."));
+ if (!getter) {
+ mono_error_set_not_supported (error, "Linked away.");
+ return NULL;
+ }
}
field_class = mono_class_from_mono_type (field->type);
- msg = (MonoMethodMessage *)mono_object_new_checked (domain, mono_defaults.mono_method_message_class, &error);
- mono_error_raise_exception (&error); /* FIXME don't raise here */
- out_args = mono_array_new (domain, mono_defaults.object_class, 1);
- MonoReflectionMethod *rm = mono_method_get_object_checked (domain, getter, NULL, &error);
- mono_error_raise_exception (&error); /* FIXME don't raise here */
+ msg = (MonoMethodMessage *)mono_object_new_checked (domain, mono_defaults.mono_method_message_class, error);
+ return_val_if_nok (error, NULL);
+ out_args = mono_array_new_checked (domain, mono_defaults.object_class, 1, error);
+ return_val_if_nok (error, NULL);
+ MonoReflectionMethod *rm = mono_method_get_object_checked (domain, getter, NULL, error);
+ return_val_if_nok (error, NULL);
mono_message_init (domain, msg, rm, out_args);
full_name = mono_type_get_full_name (klass);
mono_array_setref (msg->args, 1, mono_string_new (domain, mono_field_get_name (field)));
g_free (full_name);
- mono_remoting_invoke ((MonoObject *)(tp->rp), msg, &exc, &out_args, &error);
- mono_error_raise_exception (&error); /* FIXME don't raise here */
+ mono_remoting_invoke ((MonoObject *)(tp->rp), msg, &exc, &out_args, error);
+ return_val_if_nok (error, NULL);
- if (exc) mono_raise_exception ((MonoException *)exc);
+ if (exc) {
+ mono_error_set_exception_instance (error, (MonoException *)exc);
+ return NULL;
+ }
if (mono_array_length (out_args) == 0)
return NULL;
- *res = mono_array_get (out_args, MonoObject *, 0); /* FIXME: GC write abrrier for res */
+ mono_gc_wbarrier_generic_store (res, mono_array_get (out_args, MonoObject *, 0));
if (field_class->valuetype) {
return ((char *)*res) + sizeof (MonoObject);
MonoObject *
mono_load_remote_field_new (MonoObject *this_obj, MonoClass *klass, MonoClassField *field)
{
- MONO_REQ_GC_UNSAFE_MODE;
+ MonoError error;
+
+ MonoObject *result = mono_load_remote_field_new_checked (this_obj, klass, field, &error);
+ mono_error_cleanup (&error);
+ return result;
+}
+/**
+ * mono_load_remote_field_new_icall:
+ * @this: pointer to an object
+ * @klass: klass of the object containing @field
+ * @field: the field to load
+ *
+ * This method is called by the runtime on attempts to load fields of
+ * transparent proxy objects. @this points to such TP, @klass is the class of
+ * the object containing @field.
+ *
+ * Returns: a freshly allocated object containing the value of the
+ * field. On failure returns NULL and throws an exception.
+ */
+MonoObject *
+mono_load_remote_field_new_icall (MonoObject *this_obj, MonoClass *klass, MonoClassField *field)
+{
MonoError error;
+ MonoObject *result = mono_load_remote_field_new_checked (this_obj, klass, field, &error);
+ mono_error_set_pending_exception (&error);
+ return result;
+}
+
+/**
+ * mono_load_remote_field_new_checked:
+ * @this: pointer to an object
+ * @klass: klass of the object containing @field
+ * @field: the field to load
+ * @error: set on error.
+ *
+ * This method is called by the runtime on attempts to load fields of
+ * transparent proxy objects. @this points to such TP, @klass is the class of
+ * the object containing @field.
+ *
+ * Returns: a freshly allocated object containing the value of the field. On failure returns NULL and sets @error.
+ */
+MonoObject *
+mono_load_remote_field_new_checked (MonoObject *this_obj, MonoClass *klass, MonoClassField *field, MonoError *error)
+{
+ MONO_REQ_GC_UNSAFE_MODE;
+
+ mono_error_init (error);
static MonoMethod *getter = NULL;
MonoDomain *domain = mono_domain_get ();
if (mono_class_is_contextbound (tp->remote_class->proxy_class) && tp->rp->context == (MonoObject *) mono_context_get ()) {
gpointer val;
if (field_class->valuetype) {
- res = mono_object_new_checked (domain, field_class, &error);
- mono_error_raise_exception (&error); /* FIXME don't raise here */
+ res = mono_object_new_checked (domain, field_class, error);
+ return_val_if_nok (error, NULL);
val = ((gchar *) res) + sizeof (MonoObject);
} else {
val = &res;
if (!getter) {
getter = mono_class_get_method_from_name (mono_defaults.object_class, "FieldGetter", -1);
- if (!getter)
- mono_raise_exception (mono_get_exception_not_supported ("Linked away."));
+ if (!getter) {
+ mono_error_set_not_supported (error, "Linked away.");
+ return NULL;
+ }
}
- msg = (MonoMethodMessage *)mono_object_new_checked (domain, mono_defaults.mono_method_message_class, &error);
- mono_error_raise_exception (&error); /* FIXME don't raise here */
- out_args = mono_array_new (domain, mono_defaults.object_class, 1);
+ msg = (MonoMethodMessage *)mono_object_new_checked (domain, mono_defaults.mono_method_message_class, error);
+ return_val_if_nok (error, NULL);
+ out_args = mono_array_new_checked (domain, mono_defaults.object_class, 1, error);
+ return_val_if_nok (error, NULL);
- MonoReflectionMethod *rm = mono_method_get_object_checked (domain, getter, NULL, &error);
- mono_error_raise_exception (&error); /* FIXME don't raise here */
+ MonoReflectionMethod *rm = mono_method_get_object_checked (domain, getter, NULL, error);
+ return_val_if_nok (error, NULL);
mono_message_init (domain, msg, rm, out_args);
full_name = mono_type_get_full_name (klass);
mono_array_setref (msg->args, 1, mono_string_new (domain, mono_field_get_name (field)));
g_free (full_name);
- mono_remoting_invoke ((MonoObject *)(tp->rp), msg, &exc, &out_args, &error);
- mono_error_raise_exception (&error); /* FIXME don't raise here */
+ mono_remoting_invoke ((MonoObject *)(tp->rp), msg, &exc, &out_args, error);
+ return_val_if_nok (error, NULL);
- if (exc) mono_raise_exception ((MonoException *)exc);
+ if (exc) {
+ mono_error_set_exception_instance (error, (MonoException *)exc);
+ return NULL;
+ }
if (mono_array_length (out_args) == 0)
res = NULL;
void
mono_store_remote_field (MonoObject *this_obj, MonoClass *klass, MonoClassField *field, gpointer val)
{
- MONO_REQ_GC_UNSAFE_MODE;
-
MonoError error;
+ (void) mono_store_remote_field_checked (this_obj, klass, field, val, &error);
+ mono_error_cleanup (&error);
+}
+
+/**
+ * mono_store_remote_field_checked:
+ * @this_obj: pointer to an object
+ * @klass: klass of the object containing @field
+ * @field: the field to load
+ * @val: the value/object to store
+ * @error: set on error
+ *
+ * This method is called by the runtime on attempts to store fields of
+ * transparent proxy objects. @this_obj points to such TP, @klass is the class of
+ * the object containing @field. @val is the new value to store in @field.
+ *
+ * Returns: on success returns TRUE, on failure returns FALSE and sets @error.
+ */
+gboolean
+mono_store_remote_field_checked (MonoObject *this_obj, MonoClass *klass, MonoClassField *field, gpointer val, MonoError *error)
+{
+
+ MONO_REQ_GC_UNSAFE_MODE;
static MonoMethod *setter = NULL;
+
MonoDomain *domain = mono_domain_get ();
MonoTransparentProxy *tp = (MonoTransparentProxy *) this_obj;
MonoClass *field_class;
MonoObject *arg;
char* full_name;
+ mono_error_init (error);
+
g_assert (mono_object_is_transparent_proxy (this_obj));
field_class = mono_class_from_mono_type (field->type);
if (mono_class_is_contextbound (tp->remote_class->proxy_class) && tp->rp->context == (MonoObject *) mono_context_get ()) {
if (field_class->valuetype) mono_field_set_value (tp->rp->unwrapped_server, field, val);
else mono_field_set_value (tp->rp->unwrapped_server, field, *((MonoObject **)val));
- return;
+ return TRUE;
}
if (!setter) {
setter = mono_class_get_method_from_name (mono_defaults.object_class, "FieldSetter", -1);
- if (!setter)
- mono_raise_exception (mono_get_exception_not_supported ("Linked away."));
+ if (!setter) {
+ mono_error_set_not_supported (error, "Linked away.");
+ return FALSE;
+ }
}
if (field_class->valuetype) {
- arg = mono_value_box_checked (domain, field_class, val, &error);
- mono_error_raise_exception (&error); /* FIXME don't raise here */
+ arg = mono_value_box_checked (domain, field_class, val, error);
+ return_val_if_nok (error, FALSE);
} else
arg = *((MonoObject **)val);
- msg = (MonoMethodMessage *)mono_object_new_checked (domain, mono_defaults.mono_method_message_class, &error);
- mono_error_raise_exception (&error); /* FIXME don't raise here */
- MonoReflectionMethod *rm = mono_method_get_object_checked (domain, setter, NULL, &error);
- mono_error_raise_exception (&error); /* FIXME don't raise here */
+ msg = (MonoMethodMessage *)mono_object_new_checked (domain, mono_defaults.mono_method_message_class, error);
+ return_val_if_nok (error, FALSE);
+ MonoReflectionMethod *rm = mono_method_get_object_checked (domain, setter, NULL, error);
+ return_val_if_nok (error, FALSE);
mono_message_init (domain, msg, rm, NULL);
full_name = mono_type_get_full_name (klass);
mono_array_setref (msg->args, 2, arg);
g_free (full_name);
- mono_remoting_invoke ((MonoObject *)(tp->rp), msg, &exc, &out_args, &error);
- mono_error_raise_exception (&error); /* FIXME don't raise here */
+ mono_remoting_invoke ((MonoObject *)(tp->rp), msg, &exc, &out_args, error);
+ return_val_if_nok (error, FALSE);
- if (exc) mono_raise_exception ((MonoException *)exc);
+ if (exc) {
+ mono_error_set_exception_instance (error, (MonoException *)exc);
+ return FALSE;
+ }
+ return TRUE;
}
/**
void
mono_store_remote_field_new (MonoObject *this_obj, MonoClass *klass, MonoClassField *field, MonoObject *arg)
{
- MONO_REQ_GC_UNSAFE_MODE;
+ MonoError error;
+ (void) mono_store_remote_field_new_checked (this_obj, klass, field, arg, &error);
+ mono_error_cleanup (&error);
+}
+/**
+ * mono_store_remote_field_new_icall:
+ * @this_obj:
+ * @klass:
+ * @field:
+ * @arg:
+ *
+ * Missing documentation
+ */
+void
+mono_store_remote_field_new_icall (MonoObject *this_obj, MonoClass *klass, MonoClassField *field, MonoObject *arg)
+{
MonoError error;
+ (void) mono_store_remote_field_new_checked (this_obj, klass, field, arg, &error);
+ mono_error_set_pending_exception (&error);
+}
+
+/**
+ * mono_store_remote_field_new_checked:
+ * @this_obj:
+ * @klass:
+ * @field:
+ * @arg:
+ * @error:
+ *
+ * Missing documentation
+ */
+gboolean
+mono_store_remote_field_new_checked (MonoObject *this_obj, MonoClass *klass, MonoClassField *field, MonoObject *arg, MonoError *error)
+{
+ MONO_REQ_GC_UNSAFE_MODE;
static MonoMethod *setter = NULL;
MonoDomain *domain = mono_domain_get ();
MonoObject *exc;
char* full_name;
+ mono_error_init (error);
+
g_assert (mono_object_is_transparent_proxy (this_obj));
field_class = mono_class_from_mono_type (field->type);
if (mono_class_is_contextbound (tp->remote_class->proxy_class) && tp->rp->context == (MonoObject *) mono_context_get ()) {
if (field_class->valuetype) mono_field_set_value (tp->rp->unwrapped_server, field, ((gchar *) arg) + sizeof (MonoObject));
else mono_field_set_value (tp->rp->unwrapped_server, field, arg);
- return;
+ return TRUE;
}
if (!setter) {
setter = mono_class_get_method_from_name (mono_defaults.object_class, "FieldSetter", -1);
- if (!setter)
- mono_raise_exception (mono_get_exception_not_supported ("Linked away."));
+ if (!setter) {
+ mono_error_set_not_supported (error, "Linked away.");
+ return FALSE;
+ }
}
- msg = (MonoMethodMessage *)mono_object_new_checked (domain, mono_defaults.mono_method_message_class, &error);
- mono_error_raise_exception (&error); /* FIXME don't raise here */
- MonoReflectionMethod *rm = mono_method_get_object_checked (domain, setter, NULL, &error);
- mono_error_raise_exception (&error); /* FIXME don't raise here */
+ msg = (MonoMethodMessage *)mono_object_new_checked (domain, mono_defaults.mono_method_message_class, error);
+ return_val_if_nok (error, FALSE);
+ MonoReflectionMethod *rm = mono_method_get_object_checked (domain, setter, NULL, error);
+ return_val_if_nok (error, FALSE);
mono_message_init (domain, msg, rm, NULL);
full_name = mono_type_get_full_name (klass);
mono_array_setref (msg->args, 2, arg);
g_free (full_name);
- mono_remoting_invoke ((MonoObject *)(tp->rp), msg, &exc, &out_args, &error);
- mono_error_raise_exception (&error); /* FIXME don't raise here */
+ mono_remoting_invoke ((MonoObject *)(tp->rp), msg, &exc, &out_args, error);
+ return_val_if_nok (error, FALSE);
- if (exc) mono_raise_exception ((MonoException *)exc);
+ if (exc) {
+ mono_error_set_exception_instance (error, (MonoException *)exc);
+ return FALSE;
+ }
+ return TRUE;
}
#endif
MonoArray *
-mono_glist_to_array (GList *list, MonoClass *eclass)
+mono_glist_to_array (GList *list, MonoClass *eclass, MonoError *error)
{
MonoDomain *domain = mono_domain_get ();
MonoArray *res;
int len, i;
+ mono_error_init (error);
if (!list)
return NULL;
len = g_list_length (list);
- res = mono_array_new (domain, eclass, len);
+ res = mono_array_new_checked (domain, eclass, len, error);
+ return_val_if_nok (error, NULL);
for (i = 0; list; list = list->next, i++)
mono_array_set (res, gpointer, i, list->data);
MONO_RT_EXTERNAL_ONLY MONO_API MonoObject *
mono_object_new (MonoDomain *domain, MonoClass *klass);
+MONO_RT_EXTERNAL_ONLY
MONO_API MonoObject *
mono_object_new_specific (MonoVTable *vtable);
/* can be used for classes without finalizer in non-profiling mode */
+MONO_RT_EXTERNAL_ONLY
MONO_API MonoObject *
mono_object_new_fast (MonoVTable *vtable);
+MONO_RT_EXTERNAL_ONLY
MONO_API MonoObject *
mono_object_new_alloc_specific (MonoVTable *vtable);
+MONO_RT_EXTERNAL_ONLY
MONO_API MonoObject *
mono_object_new_from_token (MonoDomain *domain, MonoImage *image, uint32_t token);
+MONO_RT_EXTERNAL_ONLY
MONO_API MonoArray*
mono_array_new (MonoDomain *domain, MonoClass *eclass, uintptr_t n);
+MONO_RT_EXTERNAL_ONLY
MONO_API MonoArray*
mono_array_new_full (MonoDomain *domain, MonoClass *array_class,
uintptr_t *lengths, intptr_t *lower_bounds);
+MONO_RT_EXTERNAL_ONLY
MONO_API MonoArray *
mono_array_new_specific (MonoVTable *vtable, uintptr_t n);
+MONO_RT_EXTERNAL_ONLY
MONO_API MonoArray*
mono_array_clone (MonoArray *array);
MONO_API uintptr_t
mono_array_length (MonoArray *array);
+MONO_RT_EXTERNAL_ONLY
MONO_API MonoString*
mono_string_new_utf16 (MonoDomain *domain, const mono_unichar2 *text, int32_t len);
+MONO_RT_EXTERNAL_ONLY
MONO_API MonoString*
mono_string_new_size (MonoDomain *domain, int32_t len);
MONO_API MonoString*
mono_string_new_wrapper (const char *text);
+MONO_RT_EXTERNAL_ONLY
MONO_API MonoString*
mono_string_new_len (MonoDomain *domain, const char *text, unsigned int length);
+MONO_RT_EXTERNAL_ONLY
MONO_API MonoString*
mono_string_new_utf32 (MonoDomain *domain, const mono_unichar4 *text, int32_t len);
MONO_API void*
mono_object_unbox (MonoObject *obj);
+MONO_RT_EXTERNAL_ONLY
MONO_API MonoObject *
mono_object_clone (MonoObject *obj);
MONO_API void*
mono_method_get_unmanaged_thunk (MonoMethod *method);
+MONO_RT_EXTERNAL_ONLY
MONO_API MonoArray*
mono_runtime_get_main_args (void);
/* The following functions won't be available with mono was configured with remoting disabled. */
/*#ifndef DISABLE_REMOTING */
+MONO_RT_EXTERNAL_ONLY
MONO_API void*
mono_load_remote_field (MonoObject *this_obj, MonoClass *klass, MonoClassField *field, void **res);
+MONO_RT_EXTERNAL_ONLY
MONO_API MonoObject *
mono_load_remote_field_new (MonoObject *this_obj, MonoClass *klass, MonoClassField *field);
+MONO_RT_EXTERNAL_ONLY
MONO_API void
mono_store_remote_field (MonoObject *this_obj, MonoClass *klass, MonoClassField *field, void* val);
+MONO_RT_EXTERNAL_ONLY
MONO_API void
mono_store_remote_field_new (MonoObject *this_obj, MonoClass *klass, MonoClassField *field, MonoObject *arg);
MONO_API MonoObject *
mono_field_get_value_object (MonoDomain *domain, MonoClassField *field, MonoObject *obj);
+MONO_RT_EXTERNAL_ONLY
MONO_API void
mono_property_set_value (MonoProperty *prop, void *obj, void **params, MonoObject **exc);
+MONO_RT_EXTERNAL_ONLY
MONO_API MonoObject*
mono_property_get_value (MonoProperty *prop, void *obj, void **params, MonoObject **exc);
}
count = module_count + assembly_count;
- temp_arr = mono_array_new (mono_domain_get (), mono_class_get_process_module_class (), count);
+ temp_arr = mono_array_new_checked (mono_domain_get (), mono_class_get_process_module_class (), count, &error);
+ if (mono_error_set_pending_exception (&error))
+ return NULL;
for (i = 0; i < module_count; i++) {
if (GetModuleBaseName (process, mods[i], modname, MAX_PATH) &&
arr = temp_arr;
} else {
/* shorter version of the array */
- arr = mono_array_new (mono_domain_get (), mono_class_get_process_module_class (), num_added);
+ arr = mono_array_new_checked (mono_domain_get (), mono_class_get_process_module_class (), num_added, &error);
+ if (mono_error_set_pending_exception (&error))
+ return NULL;
for (i = 0; i < num_added; i++)
mono_array_setref (arr, i, mono_array_get (temp_arr, MonoObject*, i));
ves_icall_System_Diagnostics_Process_GetProcesses_internal (void)
{
#if !defined(HOST_WIN32)
+ MonoError error;
MonoArray *procs;
gpointer *pidarray;
int i, count;
mono_set_pending_exception (mono_get_exception_not_supported ("This system does not support EnumProcesses"));
return NULL;
}
- procs = mono_array_new (mono_domain_get (), mono_get_int32_class (), count);
+ procs = mono_array_new_checked (mono_domain_get (), mono_get_int32_class (), count, &error);
+ if (mono_error_set_pending_exception (&error)) {
+ g_free (pidarray);
+ return NULL;
+ }
if (sizeof (guint32) == sizeof (gpointer)) {
memcpy (mono_array_addr (procs, guint32, 0), pidarray, count * sizeof (gint32));
} else {
return procs;
#else
+ MonoError error;
MonoArray *procs;
gboolean ret;
DWORD needed;
} while (TRUE);
count = needed / sizeof (guint32);
- procs = mono_array_new (mono_domain_get (), mono_get_int32_class (), count);
+ procs = mono_array_new_checked (mono_domain_get (), mono_get_int32_class (), count, &error);
+ if (mono_error_set_pending_exception (&error)) {
+ g_free (pids);
+ return NULL;
+ }
+
memcpy (mono_array_addr (procs, guint32, 0), pids, needed);
g_free (pids);
pids = NULL;
}
static MonoProfileSamplingMode sampling_mode = MONO_PROFILER_STAT_MODE_PROCESS;
-static int64_t sampling_frequency = 1000; //1ms
+static int64_t sampling_frequency = 100; // Hz
/**
* mono_profiler_set_statistical_mode:
* Said that, when using statistical sampling, always assume variable rate sampling as all sort of external factors can interfere.
*/
void
-mono_profiler_set_statistical_mode (MonoProfileSamplingMode mode, int64_t sampling_frequency_is_us)
+mono_profiler_set_statistical_mode (MonoProfileSamplingMode mode, int64_t sampling_frequency_hz)
{
sampling_mode = mode;
- sampling_frequency = sampling_frequency_is_us;
+ sampling_frequency = sampling_frequency_hz;
}
void
MonoDl *pmodule = NULL;
gboolean result;
- pmodule = mono_dl_open (NULL, MONO_DL_LAZY, &err);
+ /*
+ * Some profilers (such as ours) may need to call back into the runtime
+ * from their sampling callback (which is called in async-signal context).
+ * They need to be able to know that all references back to the runtime
+ * have been resolved; otherwise, calling runtime functions may result in
+ * invoking the dynamic linker which is not async-signal-safe. Passing
+ * MONO_DL_EAGER will ask the dynamic linker to resolve everything upfront.
+ */
+ pmodule = mono_dl_open (NULL, MONO_DL_EAGER, &err);
if (!pmodule) {
g_warning ("Could not open main executable (%s)", err);
g_free (err);
iter = NULL;
err = NULL;
while ((path = mono_dl_build_path (directory, libname, &iter))) {
- pmodule = mono_dl_open (path, MONO_DL_LAZY, &err);
+ pmodule = mono_dl_open (path, MONO_DL_EAGER, &err);
mono_trace (G_LOG_LEVEL_INFO, MONO_TRACE_DLLIMPORT, "Attempting to load profiler: %s, %ssuccessful, err: %s", path, pmodule?"":"not ", err);
g_free (path);
g_free (err);
load_profiler_from_mono_installation (const char *libname, const char *desc)
{
char *err = NULL;
- MonoDl *pmodule = mono_dl_open_runtime_lib (libname, MONO_DL_LAZY, &err);
+ MonoDl *pmodule = mono_dl_open_runtime_lib (libname, MONO_DL_EAGER, &err);
mono_trace (G_LOG_LEVEL_INFO, MONO_TRACE_DLLIMPORT, "Attempting to load profiler from runtime libs: %s, %ssuccessful, err: %s", libname, pmodule?"":"not ", err);
g_free (err);
if (pmodule)
MONO_PROFILER_STAT_MODE_REAL = 1,
} MonoProfileSamplingMode;
-MONO_API void mono_profiler_set_statistical_mode (MonoProfileSamplingMode mode, int64_t sampling_frequency_is_us);
+MONO_API void mono_profiler_set_statistical_mode (MonoProfileSamplingMode mode, int64_t sampling_frequency_hz);
MONO_END_DECLS
ret->init_locals = header->init_locals;
ret->max_stack = header->max_stack;
ret->local_var_sig_token = local_var_sig_token;
- MONO_OBJECT_SETREF (ret, il, mono_array_new_cached (domain, mono_defaults.byte_class, header->code_size));
+ MonoArray *il_arr = mono_array_new_cached (domain, mono_defaults.byte_class, header->code_size, error);
+ if (!is_ok (error))
+ goto fail;
+ MONO_OBJECT_SETREF (ret, il, il_arr);
memcpy (mono_array_addr (ret->il, guint8, 0), header->code, header->code_size);
/* Locals */
- MONO_OBJECT_SETREF (ret, locals, mono_array_new_cached (domain, mono_class_get_local_variable_info_class (), header->num_locals));
+ MonoArray *locals_arr = mono_array_new_cached (domain, mono_class_get_local_variable_info_class (), header->num_locals, error);
+ if (!is_ok (error))
+ goto fail;
+ MONO_OBJECT_SETREF (ret, locals, locals_arr);
for (i = 0; i < header->num_locals; ++i) {
MonoReflectionLocalVariableInfo *info = (MonoReflectionLocalVariableInfo*)mono_object_new_checked (domain, mono_class_get_local_variable_info_class (), error);
if (!is_ok (error))
}
/* Exceptions */
- MONO_OBJECT_SETREF (ret, clauses, mono_array_new_cached (domain, mono_class_get_exception_handling_clause_class (), header->num_clauses));
+ MonoArray *exn_clauses = mono_array_new_cached (domain, mono_class_get_exception_handling_clause_class (), header->num_clauses, error);
+ if (!is_ok (error))
+ goto fail;
+ MONO_OBJECT_SETREF (ret, clauses, exn_clauses);
for (i = 0; i < header->num_clauses; ++i) {
MonoReflectionExceptionHandlingClause *info = (MonoReflectionExceptionHandlingClause*)mono_object_new_checked (domain, mono_class_get_exception_handling_clause_class (), error);
if (!is_ok (error))
}
slen = mono_metadata_decode_value (p, &p);
*end = p + slen;
- return mono_string_new_len (mono_domain_get (), p, slen);
+ return mono_string_new_len_checked (mono_domain_get (), p, slen, error);
case MONO_TYPE_CLASS: {
MonoReflectionType *rt;
char *n;
*end = p;
return NULL;
}
- arr = mono_array_new (mono_domain_get(), tklass, alen);
+ arr = mono_array_new_checked (mono_domain_get(), tklass, alen, error);
+ return_val_if_nok (error, NULL);
basetype = tklass->byval_arg.type;
if (basetype == MONO_TYPE_VALUETYPE && tklass->enumtype)
basetype = mono_class_enum_basetype (tklass)->type;
}
- mono_property_set_value (prop, attr, pparams, NULL);
+ mono_property_set_value_checked (prop, attr, pparams, error);
if (!type_is_reference (prop_type))
g_free (pparams [0]);
+ if (!is_ok (error)) {
+ g_free (name);
+ goto fail;
+ }
}
g_free (name);
}
if (len < 2 || read16 (p) != 0x0001) /* Prolog */
return;
- typedargs = mono_array_new (domain, mono_get_object_class (), mono_method_signature (method)->param_count);
-
+ typedargs = mono_array_new_checked (domain, mono_get_object_class (), mono_method_signature (method)->param_count, error);
+ return_if_nok (error);
+
/* skip prolog */
p += 2;
for (i = 0; i < mono_method_signature (method)->param_count; ++i) {
named = p;
num_named = read16 (named);
- namedargs = mono_array_new (domain, mono_get_object_class (), num_named);
+ namedargs = mono_array_new_checked (domain, mono_get_object_class (), num_named, error);
+ return_if_nok (error);
named += 2;
attrklass = method->klass;
n ++;
}
- result = mono_array_new_cached (mono_domain_get (), mono_defaults.attribute_class, n);
+ result = mono_array_new_cached (mono_domain_get (), mono_defaults.attribute_class, n, error);
+ return_val_if_nok (error, NULL);
n = 0;
for (i = 0; i < cinfo->num_attrs; ++i) {
if (!cinfo->attrs [i].ctor) {
int i;
mono_error_init (error);
- result = mono_array_new (mono_domain_get (), mono_defaults.customattribute_data_class, cinfo->num_attrs);
+ result = mono_array_new_checked (mono_domain_get (), mono_defaults.customattribute_data_class, cinfo->num_attrs, error);
+ return_val_if_nok (error, NULL);
for (i = 0; i < cinfo->num_attrs; ++i) {
attr = create_custom_attr_data (cinfo->image, &cinfo->attrs [i], error);
return_val_if_nok (error, NULL);
if (!result)
return NULL;
} else {
- result = mono_array_new_cached (mono_domain_get (), mono_defaults.attribute_class, 0);
+ result = mono_array_new_cached (mono_domain_get (), mono_defaults.attribute_class, 0, error);
}
return result;
if (!cinfo->cached)
mono_custom_attrs_free (cinfo);
return_val_if_nok (error, NULL);
- } else
- result = mono_array_new (mono_domain_get (), mono_defaults.customattribute_data_class, 0);
+ } else
+ result = mono_array_new_checked (mono_domain_get (), mono_defaults.customattribute_data_class, 0, error);
return result;
}
g_assert (p - buffer <= buflen);
buflen = p - buffer;
- result = mono_array_new (mono_domain_get (), mono_defaults.byte_class, buflen);
+ result = mono_array_new_checked (mono_domain_get (), mono_defaults.byte_class, buflen, error);
+ if (!is_ok (error))
+ goto leave;
p = mono_array_addr (result, char, 0);
memcpy (p, buffer, buflen);
leave:
}
buflen = buf.p - buf.buf;
- result = mono_array_new (mono_domain_get (), mono_defaults.byte_class, buflen);
+ result = mono_array_new_checked (mono_domain_get (), mono_defaults.byte_class, buflen, error);
+ if (!is_ok (error)) goto fail;
memcpy (mono_array_addr (result, char, 0), buf.buf, buflen);
sigbuffer_free (&buf);
return result;
}
buflen = buf.p - buf.buf;
- result = mono_array_new (mono_domain_get (), mono_defaults.byte_class, buflen);
+ result = mono_array_new_checked (mono_domain_get (), mono_defaults.byte_class, buflen, error);
+ if (!is_ok (error)) goto fail;
memcpy (mono_array_addr (result, char, 0), buf.buf, buflen);
sigbuffer_free (&buf);
register_icall (mono_marshal_xdomain_copy_out_value, "mono_marshal_xdomain_copy_out_value", "void object object", FALSE);
register_icall (mono_remoting_wrapper, "mono_remoting_wrapper", "object ptr ptr", FALSE);
register_icall (mono_upgrade_remote_class_wrapper, "mono_upgrade_remote_class_wrapper", "void object object", FALSE);
+ /* mono_load_remote_field_new_icall registered by mini-runtime.c */
+ /* mono_store_remote_field_new_icall registered by mini-runtime.c */
+
}
icalls_registered = TRUE;
/* runtime_invoke expects a boxed instance */
if (mono_class_is_nullable (mono_class_from_mono_type (sig->params [i]))) {
mparams[i] = mono_nullable_box ((guint8 *)params [i], klass, &error);
- mono_error_raise_exception (&error); /* FIXME don't raise here */
+ if (!is_ok (&error))
+ goto fail;
} else
mparams[i] = params [i];
}
}
res = mono_runtime_invoke_checked (method, method->klass->valuetype? mono_object_unbox ((MonoObject*)this_obj): this_obj, mparams, &error);
- mono_error_raise_exception (&error); /* FIXME don't raise here */
+ if (!is_ok (&error))
+ goto fail;
return res;
}
msg = mono_method_call_message_new (method, params, NULL, NULL, NULL);
res = mono_remoting_invoke ((MonoObject *)this_obj->rp, msg, &exc, &out_args, &error);
- mono_error_raise_exception (&error); /* FIXME don't raise here */
+ if (!is_ok (&error))
+ goto fail;
- if (exc)
- mono_raise_exception ((MonoException *)exc);
+ if (exc) {
+ mono_error_init (&error);
+ mono_error_set_exception_instance (&error, (MonoException *)exc);
+ goto fail;
+ }
- mono_method_return_message_restore (method, params, out_args);
+ mono_method_return_message_restore (method, params, out_args, &error);
+ if (!is_ok (&error)) goto fail;
return res;
+fail:
+ /* This icall will be called from managed code, and more over
+ * from a protected wrapper so interruptions such as pending
+ * exceptions will not be honored. (See
+ * is_running_protected_wrapper () in threads.c and
+ * mono_marshal_get_remoting_invoke () in remoting.c)
+ */
+ mono_error_raise_exception (&error);
+ return NULL;
}
+
MonoMethod *
mono_marshal_get_remoting_invoke (MonoMethod *method)
{
mono_mb_emit_ptr (mb, method);
mono_mb_emit_ldloc (mb, params_var);
mono_mb_emit_icall (mb, mono_remoting_wrapper);
+ // FIXME: this interrupt checkpoint code is a no-op since 'mb'
+ // is a MONO_WRAPPER_REMOTING_INVOKE, and
+ // mono_thread_interruption_checkpoint_request (FALSE)
+ // considers such wrappers "protected" and always returns
+ // NULL as if there's no pending interruption.
mono_marshal_emit_thread_interrupt_checkpoint (mb);
if (sig->ret->type == MONO_TYPE_VOID) {
MonoDomain *current_domain = mono_domain_get ();
MonoDomain *domain = mono_domain_get_by_id (id);
- if (!domain || !mono_domain_set (domain, FALSE))
- mono_raise_exception (mono_get_exception_appdomain_unloaded ());
+ if (!domain || !mono_domain_set (domain, FALSE)) {
+ mono_set_pending_exception (mono_get_exception_appdomain_unloaded ());
+ return 0;
+ }
if (push)
mono_thread_push_appdomain_ref (domain);
MonoMethod *
mono_marshal_get_ldfld_remote_wrapper (MonoClass *klass)
{
- MonoMethodSignature *sig, *csig;
+ MonoMethodSignature *sig;
MonoMethodBuilder *mb;
MonoMethod *res;
static MonoMethod* cached = NULL;
mono_mb_emit_ldarg (mb, 1);
mono_mb_emit_ldarg (mb, 2);
- csig = mono_metadata_signature_alloc (mono_defaults.corlib, 3);
- csig->params [0] = &mono_defaults.object_class->byval_arg;
- csig->params [1] = &mono_defaults.int_class->byval_arg;
- csig->params [2] = &mono_defaults.int_class->byval_arg;
- csig->ret = &mono_defaults.object_class->byval_arg;
- csig->pinvoke = 1;
-
- mono_mb_emit_native_call (mb, csig, mono_load_remote_field_new);
- mono_marshal_emit_thread_interrupt_checkpoint (mb);
+ mono_mb_emit_icall (mb, mono_load_remote_field_new_icall);
mono_mb_emit_byte (mb, CEE_RET);
#endif
MonoMethod *
mono_marshal_get_stfld_remote_wrapper (MonoClass *klass)
{
- MonoMethodSignature *sig, *csig;
+ MonoMethodSignature *sig;
MonoMethodBuilder *mb;
MonoMethod *res;
static MonoMethod *cached = NULL;
mono_mb_emit_ldarg (mb, 2);
mono_mb_emit_ldarg (mb, 3);
- csig = mono_metadata_signature_alloc (mono_defaults.corlib, 4);
- csig->params [0] = &mono_defaults.object_class->byval_arg;
- csig->params [1] = &mono_defaults.int_class->byval_arg;
- csig->params [2] = &mono_defaults.int_class->byval_arg;
- csig->params [3] = &mono_defaults.object_class->byval_arg;
- csig->ret = &mono_defaults.void_class->byval_arg;
- csig->pinvoke = 1;
-
- mono_mb_emit_native_call (mb, csig, mono_store_remote_field_new);
- mono_marshal_emit_thread_interrupt_checkpoint (mb);
+ mono_mb_emit_icall (mb, mono_store_remote_field_new_icall);
mono_mb_emit_byte (mb, CEE_RET);
#endif
MonoArray *acopy;
MonoXDomainMarshalType mt = mono_get_xdomain_marshal_type (&(mono_object_class (val)->element_class->byval_arg));
if (mt == MONO_MARSHAL_SERIALIZE) return NULL;
- acopy = mono_array_clone_in_domain (domain, (MonoArray *) val);
+ acopy = mono_array_clone_in_domain (domain, (MonoArray *) val, &error);
+ mono_error_raise_exception (&error); /* FIXME don't raise here */
+
if (mt == MONO_MARSHAL_COPY) {
int i, len = mono_array_length (acopy);
for (i = 0; i < len; i++) {
sccs [i]->is_alive = TRUE;
}
+/* This bridge keeps all peers with __test > 0 */
+static void
+bridge_test_positive_status (int num_sccs, MonoGCBridgeSCC **sccs, int num_xrefs, MonoGCBridgeXRef *xrefs)
+{
+ int i;
+
+ if (!mono_bridge_test_field) {
+ mono_bridge_test_field = mono_class_get_field_from_name (mono_object_get_class (sccs[0]->objs [0]), "__test");
+ g_assert (mono_bridge_test_field);
+ }
+
+ /*We mark all objects in a scc with live objects as reachable by scc*/
+ for (i = 0; i < num_sccs; ++i) {
+ int j;
+ for (j = 0; j < sccs [i]->num_objs; ++j) {
+ if (test_scc (sccs [i], j)) {
+ sccs [i]->is_alive = TRUE;
+ break;
+ }
+ }
+ }
+}
+
+
static void
register_test_bridge_callbacks (const char *bridge_class_name)
{
callbacks.bridge_version = SGEN_BRIDGE_VERSION;
callbacks.bridge_class_kind = bridge_test_bridge_class_kind;
callbacks.is_bridge_object = bridge_test_is_bridge_object;
- callbacks.cross_references = bridge_class_name[0] == '2' ? bridge_test_cross_reference2 : bridge_test_cross_reference;
+
+ switch (bridge_class_name [0]) {
+ case '2':
+ bridge_class = bridge_class_name + 1;
+ callbacks.cross_references = bridge_test_cross_reference2;
+ break;
+ case '3':
+ bridge_class = bridge_class_name + 1;
+ callbacks.cross_references = bridge_test_positive_status;
+ break;
+ default:
+ bridge_class = bridge_class_name;
+ callbacks.cross_references = bridge_test_cross_reference;
+ }
mono_gc_register_bridge_callbacks (&callbacks);
- bridge_class = bridge_class_name + (bridge_class_name[0] == '2' ? 1 : 0);
}
gboolean
g_assert_not_reached ();
}
- if (atype != ATYPE_SMALL) {
- /* size += ALLOC_ALIGN - 1; */
- mono_mb_emit_ldloc (mb, size_var);
- mono_mb_emit_icon (mb, SGEN_ALLOC_ALIGN - 1);
- mono_mb_emit_byte (mb, CEE_ADD);
- /* size &= ~(ALLOC_ALIGN - 1); */
- mono_mb_emit_icon (mb, ~(SGEN_ALLOC_ALIGN - 1));
- mono_mb_emit_byte (mb, CEE_AND);
- mono_mb_emit_stloc (mb, size_var);
- }
+ /* size += ALLOC_ALIGN - 1; */
+ mono_mb_emit_ldloc (mb, size_var);
+ mono_mb_emit_icon (mb, SGEN_ALLOC_ALIGN - 1);
+ mono_mb_emit_byte (mb, CEE_ADD);
+ /* size &= ~(ALLOC_ALIGN - 1); */
+ mono_mb_emit_icon (mb, ~(SGEN_ALLOC_ALIGN - 1));
+ mono_mb_emit_byte (mb, CEE_AND);
+ mono_mb_emit_stloc (mb, size_var);
/* if (size > MAX_SMALL_OBJ_SIZE) goto slowpath */
if (atype != ATYPE_SMALL) {
mono_mb_emit_byte (mb, MONO_CEE_ADD);
mono_mb_emit_ldarg (mb, 1);
mono_mb_emit_byte (mb, MONO_CEE_STIND_I4);
- /* s->chars [len] = 0; */
- mono_mb_emit_ldloc (mb, p_var);
- mono_mb_emit_ldloc (mb, size_var);
- mono_mb_emit_icon (mb, 2);
- mono_mb_emit_byte (mb, MONO_CEE_SUB);
- mono_mb_emit_byte (mb, MONO_CEE_ADD);
- mono_mb_emit_icon (mb, 0);
- mono_mb_emit_byte (mb, MONO_CEE_STIND_I2);
}
/*
* the length of the entire sockaddr_in/in6, including
* sizeof (unsigned short) of the family */
/* We can't really avoid the +2 as all code below depends on this size - INCLUDING unix domain sockets.*/
- data = mono_array_new_cached (domain, mono_get_byte_class (), sa_size + 2);
+ data = mono_array_new_cached (domain, mono_get_byte_class (), sa_size + 2, error);
+ return_val_if_nok (error, NULL);
/* The data buffer is laid out as follows:
* bytes 0 and 1 are the address family
}
static MonoObject*
-int_to_object (MonoDomain *domain, int val)
+int_to_object (MonoDomain *domain, int val, MonoError *error)
{
- MonoError error;
- MonoObject *result = mono_value_box_checked (domain, mono_get_int32_class (), &val, &error);
- mono_error_raise_exception (&error); /* FIXME don't raise here */
- return result;
+ return mono_value_box_checked (domain, mono_get_int32_class (), &val, error);
}
void
return;
}
if (ret == -2) {
- *obj_val = int_to_object (domain, 0);
+ *obj_val = int_to_object (domain, 0, &error);
+ mono_error_set_pending_exception (&error);
return;
}
break;
case SocketOptionName_DontLinger:
/* construct a bool int in val - true if linger is off */
- obj = int_to_object (domain, !linger.l_onoff);
+ obj = int_to_object (domain, !linger.l_onoff, &error);
+ mono_error_set_pending_exception (&error);
break;
case SocketOptionName_SendTimeout:
case SocketOptionName_ReceiveTimeout:
- obj = int_to_object (domain, time_ms);
+ obj = int_to_object (domain, time_ms, &error);
+ mono_error_set_pending_exception (&error);
break;
#ifdef SO_PEERCRED
if (level == SocketOptionLevel_Socket && name == SocketOptionName_ExclusiveAddressUse)
val = val ? 0 : 1;
#endif
- obj = int_to_object (domain, val);
+ obj = int_to_object (domain, val, &error);
+ mono_error_set_pending_exception (&error);
}
*obj_val = obj;
}
static gboolean
-addrinfo_to_IPHostEntry(MonoAddressInfo *info, MonoString **h_name, MonoArray **h_aliases, MonoArray **h_addr_list, gboolean add_local_ips)
+addrinfo_to_IPHostEntry (MonoAddressInfo *info, MonoString **h_name, MonoArray **h_aliases, MonoArray **h_addr_list, gboolean add_local_ips, MonoError *error)
{
gint32 count, i;
MonoAddressEntry *ai = NULL;
int addr_index;
MonoDomain *domain = mono_domain_get ();
+ mono_error_init (error);
addr_index = 0;
- *h_aliases = mono_array_new (domain, mono_get_string_class (), 0);
+ *h_aliases = mono_array_new_checked (domain, mono_get_string_class (), 0, error);
+ return_val_if_nok (error, FALSE);
if (add_local_ips) {
local_in = (struct in_addr *) mono_get_local_interfaces (AF_INET, &nlocal_in);
local_in6 = (struct in6_addr *) mono_get_local_interfaces (AF_INET6, &nlocal_in6);
if (nlocal_in || nlocal_in6) {
char addr [INET6_ADDRSTRLEN];
- *h_addr_list = mono_array_new (domain, mono_get_string_class (), nlocal_in + nlocal_in6);
+ *h_addr_list = mono_array_new_checked (domain, mono_get_string_class (), nlocal_in + nlocal_in6, error);
+ if (!is_ok (error))
+ goto leave;
+
if (nlocal_in) {
MonoString *addr_string;
int i;
}
}
+ leave:
g_free (local_in);
g_free (local_in6);
if (info)
mono_free_address_info (info);
- return TRUE;
+ return is_ok (error);;
}
g_free (local_in);
count++;
}
- *h_addr_list = mono_array_new (domain, mono_get_string_class (), count);
+ *h_addr_list = mono_array_new_checked (domain, mono_get_string_class (), count, error);
+ if (!is_ok (error))
+ goto leave2;
for (ai = info->entries, i = 0; ai != NULL; ai = ai->next) {
MonoAddress maddr;
addr_index++;
}
+leave2:
if (info)
mono_free_address_info (info);
- return TRUE;
+ return is_ok (error);
}
static int
g_free(hostname);
- if (add_info_ok)
- return addrinfo_to_IPHostEntry (info, h_name, h_aliases, h_addr_list, add_local_ips);
+ if (add_info_ok) {
+ MonoBoolean result = addrinfo_to_IPHostEntry (info, h_name, h_aliases, h_addr_list, add_local_ips, &error);
+ mono_error_set_pending_exception (&error);
+ return result;
+ }
return FALSE;
}
if (mono_get_address_info (hostname, 0, hint | MONO_HINT_CANONICAL_NAME | MONO_HINT_CONFIGURED_ONLY, &info) != 0)
return FALSE;
- return addrinfo_to_IPHostEntry (info, h_name, h_aliases, h_addr_list, FALSE);
+ MonoBoolean result = addrinfo_to_IPHostEntry (info, h_name, h_aliases, h_addr_list, FALSE, &error);
+ mono_error_set_pending_exception (&error);
+ return result;
}
MonoBoolean
return TRUE;
}
-static void
-epoll_cleanup (void)
-{
- g_free (epoll_events);
- close (epoll_fd);
-}
-
static void
epoll_register_fd (gint fd, gint events, gboolean is_new)
{
static ThreadPoolIOBackend backend_epoll = {
.init = epoll_init,
- .cleanup = epoll_cleanup,
.register_fd = epoll_register_fd,
.remove_fd = epoll_remove_fd,
.event_wait = epoll_event_wait,
return TRUE;
}
-static void
-kqueue_cleanup (void)
-{
- g_free (kqueue_events);
- close (kqueue_fd);
-}
-
static void
kqueue_register_fd (gint fd, gint events, gboolean is_new)
{
static ThreadPoolIOBackend backend_kqueue = {
.init = kqueue_init,
- .cleanup = kqueue_cleanup,
.register_fd = kqueue_register_fd,
.remove_fd = kqueue_remove_fd,
.event_wait = kqueue_event_wait,
return TRUE;
}
-static void
-poll_cleanup (void)
-{
- g_free (poll_fds);
-}
-
static void
poll_register_fd (gint fd, gint events, gboolean is_new)
{
static ThreadPoolIOBackend backend_poll = {
.init = poll_init,
- .cleanup = poll_cleanup,
.register_fd = poll_register_fd,
.remove_fd = poll_remove_fd,
.event_wait = poll_event_wait,
typedef struct {
gboolean (*init) (gint wakeup_pipe_fd);
- void (*cleanup) (void);
void (*register_fd) (gint fd, gint events, gboolean is_new);
void (*remove_fd) (gint fd);
gint (*event_wait) (void (*callback) (gint fd, gint events, gpointer user_data), gpointer user_data);
selector_thread_wakeup ();
while (io_selector_running)
mono_thread_info_usleep (1000);
-
- mono_coop_mutex_destroy (&threadpool_io->updates_lock);
- mono_coop_cond_destroy (&threadpool_io->updates_cond);
-
- threadpool_io->backend.cleanup ();
-
-#if !defined(HOST_WIN32)
- close (threadpool_io->wakeup_pipes [0]);
- close (threadpool_io->wakeup_pipes [1]);
-#else
- closesocket (threadpool_io->wakeup_pipes [0]);
- closesocket (threadpool_io->wakeup_pipes [1]);
-#endif
-
- g_assert (threadpool_io);
- g_free (threadpool_io);
- threadpool_io = NULL;
- g_assert (!threadpool_io);
}
void
MonoObject *
mono_threadpool_ms_end_invoke (MonoAsyncResult *ares, MonoArray **out_args, MonoObject **exc)
{
+ MonoError error;
MonoAsyncCall *ac;
g_assert (exc);
} else {
wait_event = CreateEvent (NULL, TRUE, FALSE, NULL);
g_assert(wait_event);
- MONO_OBJECT_SETREF (ares, handle, (MonoObject*) mono_wait_handle_new (mono_object_domain (ares), wait_event));
+ MonoWaitHandle *wait_handle = mono_wait_handle_new (mono_object_domain (ares), wait_event, &error);
+ mono_error_raise_exception (&error); /* FIXME don't raise here */
+ MONO_OBJECT_SETREF (ares, handle, (MonoObject*) wait_handle);
}
mono_monitor_exit ((MonoObject*) ares);
MONO_PREPARE_BLOCKING;
void ves_icall_System_Threading_Events_CloseEvent_internal (HANDLE handle);
HANDLE ves_icall_System_Threading_Events_OpenEvent_internal (MonoString *name, gint32 rights, gint32 *error);
-gint32 ves_icall_System_Threading_WaitHandle_WaitAll_internal(MonoArray *mono_handles, gint32 ms, gboolean exitContext);
-gint32 ves_icall_System_Threading_WaitHandle_WaitAny_internal(MonoArray *mono_handles, gint32 ms, gboolean exitContext);
-gint32 ves_icall_System_Threading_WaitHandle_WaitOne_internal(HANDLE handle, gint32 ms, gboolean exitContext);
-gint32 ves_icall_System_Threading_WaitHandle_SignalAndWait_Internal (HANDLE toSignal, HANDLE toWait, gint32 ms, gboolean exitContext);
+gint32 ves_icall_System_Threading_WaitHandle_WaitAll_internal(MonoArray *mono_handles, gint32 ms);
+gint32 ves_icall_System_Threading_WaitHandle_WaitAny_internal(MonoArray *mono_handles, gint32 ms);
+gint32 ves_icall_System_Threading_WaitHandle_WaitOne_internal(HANDLE handle, gint32 ms);
+gint32 ves_icall_System_Threading_WaitHandle_SignalAndWait_Internal (HANDLE toSignal, HANDLE toWait, gint32 ms);
MonoArray* ves_icall_System_Threading_Thread_ByteArrayToRootDomain (MonoArray *arr);
MonoArray* ves_icall_System_Threading_Thread_ByteArrayToCurrentDomain (MonoArray *arr);
mono_release_type_locks (thread);
/* Can happen when we attach the profiler helper thread in order to heapshot. */
- if (!mono_thread_info_lookup (thread->tid)->tools_thread)
+ if (!mono_thread_info_lookup (MONO_UINT_TO_NATIVE_THREAD_ID (thread->tid))->tools_thread)
mono_profiler_thread_end (thread->tid);
if (thread == mono_thread_internal_current ()) {
if (internal->name && (internal->flags & MONO_THREAD_FLAG_NAME_SET)) {
char *tname = g_utf16_to_utf8 (internal->name, internal->name_len, NULL, NULL, NULL);
mono_profiler_thread_name (internal->tid, tname);
- mono_thread_info_set_name (internal->tid, tname);
+ mono_thread_info_set_name (MONO_UINT_TO_NATIVE_THREAD_ID (internal->tid), tname);
g_free (tname);
}
/* start_func is set only for unmanaged start functions */
/* If the array is already in the requested domain, we just return it,
otherwise we return a copy in that domain. */
static MonoArray*
-byte_array_to_domain (MonoArray *arr, MonoDomain *domain)
+byte_array_to_domain (MonoArray *arr, MonoDomain *domain, MonoError *error)
{
MonoArray *copy;
+ mono_error_init (error);
if (!arr)
return NULL;
if (mono_object_domain (arr) == domain)
return arr;
- copy = mono_array_new (domain, mono_defaults.byte_class, arr->max_length);
+ copy = mono_array_new_checked (domain, mono_defaults.byte_class, arr->max_length, error);
memmove (mono_array_addr (copy, guint8, 0), mono_array_addr (arr, guint8, 0), arr->max_length);
return copy;
}
MonoArray*
ves_icall_System_Threading_Thread_ByteArrayToRootDomain (MonoArray *arr)
{
- return byte_array_to_domain (arr, mono_get_root_domain ());
+ MonoError error;
+ MonoArray *result = byte_array_to_domain (arr, mono_get_root_domain (), &error);
+ mono_error_set_pending_exception (&error);
+ return result;
}
MonoArray*
ves_icall_System_Threading_Thread_ByteArrayToCurrentDomain (MonoArray *arr)
{
- return byte_array_to_domain (arr, mono_domain_get ());
+ MonoError error;
+ MonoArray *result = byte_array_to_domain (arr, mono_domain_get (), &error);
+ mono_error_set_pending_exception (&error);
+ return result;
}
MonoThread *
return ret;
}
-/* FIXME: exitContext isnt documented */
-gint32 ves_icall_System_Threading_WaitHandle_WaitAll_internal(MonoArray *mono_handles, gint32 ms, gboolean exitContext)
+gint32 ves_icall_System_Threading_WaitHandle_WaitAll_internal(MonoArray *mono_handles, gint32 ms)
{
HANDLE *handles;
guint32 numhandles;
g_free(handles);
- return ret;
+ /* WAIT_FAILED in waithandle.cs is different from WAIT_FAILED in Win32 API */
+ return ret == WAIT_FAILED ? 0x7fffffff : ret;
}
-/* FIXME: exitContext isnt documented */
-gint32 ves_icall_System_Threading_WaitHandle_WaitAny_internal(MonoArray *mono_handles, gint32 ms, gboolean exitContext)
+gint32 ves_icall_System_Threading_WaitHandle_WaitAny_internal(MonoArray *mono_handles, gint32 ms)
{
HANDLE handles [MAXIMUM_WAIT_OBJECTS];
uintptr_t numhandles;
return ret - WAIT_ABANDONED_0;
}
else {
- return ret;
+ /* WAIT_FAILED in waithandle.cs is different from WAIT_FAILED in Win32 API */
+ return ret == WAIT_FAILED ? 0x7fffffff : ret;
}
}
-/* FIXME: exitContext isnt documented */
-gint32 ves_icall_System_Threading_WaitHandle_WaitOne_internal(HANDLE handle, gint32 ms, gboolean exitContext)
+gint32 ves_icall_System_Threading_WaitHandle_WaitOne_internal(HANDLE handle, gint32 ms)
{
guint32 ret;
MonoInternalThread *thread = mono_thread_internal_current ();
mono_thread_clr_state (thread, ThreadState_WaitSleepJoin);
- return ret;
+ /* WAIT_FAILED in waithandle.cs is different from WAIT_FAILED in Win32 API */
+ return ret == WAIT_FAILED ? 0x7fffffff : ret;
}
gint32
-ves_icall_System_Threading_WaitHandle_SignalAndWait_Internal (HANDLE toSignal, HANDLE toWait, gint32 ms, gboolean exitContext)
+ves_icall_System_Threading_WaitHandle_SignalAndWait_Internal (HANDLE toSignal, HANDLE toWait, gint32 ms)
{
guint32 ret;
MonoInternalThread *thread = mono_thread_internal_current ();
mono_thread_clr_state (thread, ThreadState_WaitSleepJoin);
- return ret;
+ /* WAIT_FAILED in waithandle.cs is different from WAIT_FAILED in Win32 API */
+ return ret == WAIT_FAILED ? 0x7fffffff : ret;
}
HANDLE ves_icall_System_Threading_Mutex_CreateMutex_internal (MonoBoolean owned, MonoString *name, MonoBoolean *created)
MonoObject*
ves_icall_System_Threading_Thread_GetAbortExceptionState (MonoThread *this_obj)
{
+ MonoError error;
MonoInternalThread *thread = this_obj->internal_thread;
- MonoObject *state, *deserialized = NULL, *exc;
+ MonoObject *state, *deserialized = NULL;
MonoDomain *domain;
if (!thread->abort_state_handle)
if (mono_object_domain (state) == domain)
return state;
- deserialized = mono_object_xdomain_representation (state, domain, &exc);
+ deserialized = mono_object_xdomain_representation (state, domain, &error);
if (!deserialized) {
MonoException *invalid_op_exc = mono_get_exception_invalid_operation ("Thread.ExceptionState cannot access an ExceptionState from a different AppDomain");
- if (exc)
+ if (!is_ok (&error)) {
+ MonoObject *exc = (MonoObject*)mono_error_convert_to_exception (&error);
MONO_OBJECT_SETREF (invalid_op_exc, inner_ex, exc);
+ }
mono_set_pending_exception (invalid_op_exc);
return NULL;
}
ud.frames = g_new0 (MonoStackFrameInfo, 256);
ud.max_frames = 256;
- *out_threads = mono_array_new (domain, mono_defaults.thread_class, nthreads);
- *out_stack_frames = mono_array_new (domain, mono_defaults.array_class, nthreads);
+ *out_threads = mono_array_new_checked (domain, mono_defaults.thread_class, nthreads, &error);
+ if (!is_ok (&error))
+ goto leave;
+ *out_stack_frames = mono_array_new_checked (domain, mono_defaults.array_class, nthreads, &error);
+ if (!is_ok (&error))
+ goto leave;
for (tindex = 0; tindex < nthreads; ++tindex) {
MonoInternalThread *thread = thread_array [tindex];
mono_array_setref_fast (*out_threads, tindex, mono_thread_current_for_thread (thread));
- thread_frames = mono_array_new (domain, mono_defaults.stack_frame_class, ud.nframes);
+ thread_frames = mono_array_new_checked (domain, mono_defaults.stack_frame_class, ud.nframes, &error);
+ if (!is_ok (&error))
+ goto leave;
mono_array_setref_fast (*out_stack_frames, tindex, thread_frames);
for (i = 0; i < ud.nframes; ++i) {
bb->has_array_access |= first_bb->has_array_access;
/* Delete the links between the original bb and its successors */
- tmp_bblocks = bb->out_bb;
+ tmp_bblocks = mono_mempool_alloc0 (cfg->mempool, sizeof (MonoBasicBlock*) * bb->out_count);
+ memcpy (tmp_bblocks, bb->out_bb, sizeof (MonoBasicBlock*) * bb->out_count);
count = bb->out_count;
for (i = 0; i < count; ++i)
mono_unlink_bblock (cfg, bb, tmp_bblocks [i]);
static ErrorCode
object_commands (int command, guint8 *p, guint8 *end, Buffer *buf)
{
+ MonoError error;
int objid;
ErrorCode err;
MonoObject *obj;
if (remote_obj) {
#ifndef DISABLE_REMOTING
- field_value = mono_load_remote_field(obj, obj_type, f, &field_storage);
+ field_value = mono_load_remote_field_checked(obj, obj_type, f, &field_storage, &error);
+ if (!is_ok (&error)) {
+ mono_error_cleanup (&error); /* FIXME report the error */
+ return ERR_INVALID_OBJECT;
+ }
#else
g_assert_not_reached ();
#endif
MONO_INST_NEW (cfg, iargs [2], OP_MOVE);
iargs [2]->dreg = ins->sreg1;
- dest = mono_emit_jit_icall (cfg, mono_array_new, iargs);
+ dest = mono_emit_jit_icall (cfg, ves_icall_array_new, iargs);
dest->dreg = ins->dreg;
} else {
MonoClass *array_class = mono_array_class_get (ins->inst_newa_class, 1);
method = mono_get_method_checked (image, entry, NULL, NULL, &error);
if (method == NULL){
- g_print ("The entry point method of assembly '%s' could not be loaded due to %s\n", agent, &error);
+ g_print ("The entry point method of assembly '%s' could not be loaded due to %s\n", agent, mono_error_get_message (&error));
mono_error_cleanup (&error);
g_free (agent);
return 1;
mono_thread_set_main (mono_thread_current ());
if (args) {
- main_args = (MonoArray*)mono_array_new (domain, mono_defaults.string_class, 1);
- mono_array_set (main_args, MonoString*, 0, mono_string_new (domain, args));
+ main_args = (MonoArray*)mono_array_new_checked (domain, mono_defaults.string_class, 1, &error);
+ if (main_args)
+ mono_array_set (main_args, MonoString*, 0, mono_string_new (domain, args));
} else {
- main_args = (MonoArray*)mono_array_new (domain, mono_defaults.string_class, 0);
+ main_args = (MonoArray*)mono_array_new_checked (domain, mono_defaults.string_class, 0, &error);
}
-
+ if (!main_args) {
+ g_print ("Could not allocate array for main args of assembly '%s' due to %s\n", agent, mono_error_get_message (&error));
+ mono_error_cleanup (&error);
+ g_free (agent);
+ return 1;
+ }
+
g_free (agent);
pa [0] = main_args;
if (enable_profile) {
mono_profiler_load (profile_options);
- mono_profiler_thread_name (mono_native_thread_id_get (), "Main");
+ mono_profiler_thread_name (MONO_NATIVE_THREAD_ID_TO_UINT (mono_native_thread_id_get ()), "Main");
}
mono_attach_parse_options (attach_options);
if (size < sizeof (MonoObject))
g_error ("Invalid size %d for class %s", size, mono_type_get_full_name (klass));
- EMIT_NEW_ICONST (cfg, iargs [1], mono_gc_get_aligned_size_for_allocator (size));
+ EMIT_NEW_ICONST (cfg, iargs [1], size);
}
return mono_emit_method_call (cfg, managed_alloc, iargs, NULL);
}
g_error ("Invalid size %d for class %s", size, mono_type_get_full_name (klass));
EMIT_NEW_VTABLECONST (cfg, iargs [0], vtable);
- EMIT_NEW_ICONST (cfg, iargs [1], mono_gc_get_aligned_size_for_allocator (size));
+ EMIT_NEW_ICONST (cfg, iargs [1], size);
return mono_emit_method_call (cfg, managed_alloc, iargs, NULL);
}
alloc_ftn = mono_class_get_allocation_ftn (vtable, for_box, &pass_lw);
EMIT_NEW_CLASSCONST (cfg, iargs [1], klass);
iargs [2] = sp [0];
- ins = mono_emit_jit_icall (cfg, mono_array_new, iargs);
+ ins = mono_emit_jit_icall (cfg, ves_icall_array_new, iargs);
} else {
/* Decompose later since it is needed by abcrem */
MonoClass *array_type = mono_array_class_get (klass, 1);
case OP_SEQ_POINT:
g_string_append_printf (sbuf, " il: 0x%x%s", (int)ins->inst_imm, ins->flags & MONO_INST_NONEMPTY_STACK ? ", nonempty-stack" : "");
break;
+ case OP_COND_EXC_EQ:
+ case OP_COND_EXC_GE:
+ case OP_COND_EXC_GT:
+ case OP_COND_EXC_LE:
+ case OP_COND_EXC_LT:
+ case OP_COND_EXC_NE_UN:
+ case OP_COND_EXC_GE_UN:
+ case OP_COND_EXC_GT_UN:
+ case OP_COND_EXC_LE_UN:
+ case OP_COND_EXC_LT_UN:
+ case OP_COND_EXC_OV:
+ case OP_COND_EXC_NO:
+ case OP_COND_EXC_C:
+ case OP_COND_EXC_NC:
+ case OP_COND_EXC_IEQ:
+ case OP_COND_EXC_IGE:
+ case OP_COND_EXC_IGT:
+ case OP_COND_EXC_ILE:
+ case OP_COND_EXC_ILT:
+ case OP_COND_EXC_INE_UN:
+ case OP_COND_EXC_IGE_UN:
+ case OP_COND_EXC_IGT_UN:
+ case OP_COND_EXC_ILE_UN:
+ case OP_COND_EXC_ILT_UN:
+ case OP_COND_EXC_IOV:
+ case OP_COND_EXC_INO:
+ case OP_COND_EXC_IC:
+ case OP_COND_EXC_INC:
+ g_string_append_printf (sbuf, " %s", ins->inst_p1);
+ break;
default:
break;
}
if (ta == NULL) {
/* Exception is not thrown yet */
- return mono_array_new (domain, mono_defaults.stack_frame_class, 0);
+ res = mono_array_new_checked (domain, mono_defaults.stack_frame_class, 0, &error);
+ mono_error_set_pending_exception (&error);
+ return res;
}
len = mono_array_length (ta) >> 1;
- res = mono_array_new (domain, mono_defaults.stack_frame_class, len > skip ? len - skip : 0);
+ res = mono_array_new_checked (domain, mono_defaults.stack_frame_class, len > skip ? len - skip : 0, &error);
+ if (mono_error_set_pending_exception (&error))
+ return NULL;
for (i = skip; i < len; i++) {
MonoJitInfo *ji;
#define MAX_UNMANAGED_BACKTRACE 128
static MonoArray*
-build_native_trace (void)
+build_native_trace (MonoError *error)
{
+ mono_error_init (error);
/* This puppy only makes sense on mobile, IOW, ARM. */
#if defined (HAVE_BACKTRACE_SYMBOLS) && defined (TARGET_ARM)
MonoArray *res;
if (!size)
return NULL;
- res = mono_array_new (mono_domain_get (), mono_defaults.int_class, size);
+ res = mono_array_new_checked (mono_domain_get (), mono_defaults.int_class, size, error);
+ return_val_if_nok (error, NULL);
for (i = 0; i < size; i++)
mono_array_set (res, gpointer, i, native_trace [i]);
{
if (mono_ex && !initial_trace_ips) {
*trace_ips = g_list_reverse (*trace_ips);
- MONO_OBJECT_SETREF (mono_ex, trace_ips, mono_glist_to_array (*trace_ips, mono_defaults.int_class));
- MONO_OBJECT_SETREF (mono_ex, native_trace_ips, build_native_trace ());
+ MonoError error;
+ MonoArray *ips_arr = mono_glist_to_array (*trace_ips, mono_defaults.int_class, &error);
+ mono_error_assert_ok (&error);
+ MONO_OBJECT_SETREF (mono_ex, trace_ips, ips_arr);
+ MONO_OBJECT_SETREF (mono_ex, native_trace_ips, build_native_trace (&error));
+ mono_error_assert_ok (&error);
if (dynamic_methods) {
/* These methods could go away anytime, so save a reference to them in the exception object */
GSList *l;
trace = g_list_append (trace, l->data);
trace = g_list_append (trace, NULL);
}
- MONO_OBJECT_SETREF (mono_ex, trace_ips, mono_glist_to_array (trace, mono_defaults.int_class));
+ MonoArray *ips_arr = mono_glist_to_array (trace, mono_defaults.int_class, &error);
+ mono_error_assert_ok (&error);
+ MONO_OBJECT_SETREF (mono_ex, trace_ips, ips_arr);
g_list_free (l);
g_list_free (trace);
#endif
MonoObject *
mono_llvm_load_exception (void)
{
+ MonoError error;
MonoJitTlsData *jit_tls = mono_get_jit_tls ();
MonoException *mono_ex = (MonoException*)mono_gchandle_get_target (jit_tls->thrown_exc);
// FIXME: Does this work correctly for rethrows?
// We may be discarding useful information
// when this gets GC'ed
- MONO_OBJECT_SETREF (mono_ex, trace_ips, mono_glist_to_array (trace_ips, mono_defaults.int_class));
+ MonoArray *ips_arr = mono_glist_to_array (trace_ips, mono_defaults.int_class, &error);
+ mono_error_assert_ok (&error);
+ MONO_OBJECT_SETREF (mono_ex, trace_ips, ips_arr);
g_list_free (trace_ips);
// FIXME:
//MONO_OBJECT_SETREF (mono_ex, stack_trace, ves_icall_System_Exception_get_trace (mono_ex));
} else {
- MONO_OBJECT_SETREF (mono_ex, trace_ips, mono_array_new (mono_domain_get (), mono_defaults.int_class, 0));
- MONO_OBJECT_SETREF (mono_ex, stack_trace, mono_array_new (mono_domain_get (), mono_defaults.stack_frame_class, 0));
+ MONO_OBJECT_SETREF (mono_ex, trace_ips, mono_array_new_checked (mono_domain_get (), mono_defaults.int_class, 0, &error));
+ mono_error_assert_ok (&error);
+ MONO_OBJECT_SETREF (mono_ex, stack_trace, mono_array_new_checked (mono_domain_get (), mono_defaults.stack_frame_class, 0, &error));
+ mono_error_assert_ok (&error);
}
return &mono_ex->object;
}
}
+static MonoNativeThreadId sampling_thread;
+
+static gint32 profiler_signals_sent;
+static gint32 profiler_signals_received;
+static gint32 profiler_signals_accepted;
+static gint32 profiler_interrupt_signals_received;
+
MONO_SIG_HANDLER_FUNC (static, profiler_signal_handler)
{
int old_errno = errno;
int hp_save_index;
MONO_SIG_HANDLER_GET_CONTEXT;
+ /* See the comment in mono_runtime_shutdown_stat_profiler (). */
+ if (mono_native_thread_id_get () == sampling_thread) {
+#ifdef HAVE_CLOCK_NANOSLEEP
+ if (mono_profiler_get_sampling_mode () == MONO_PROFILER_STAT_MODE_PROCESS) {
+ InterlockedIncrement (&profiler_interrupt_signals_received);
+ return;
+ }
+#endif
+
+ g_error ("%s: Unexpected profiler signal received by the sampler thread", __func__);
+ }
+
+ InterlockedIncrement (&profiler_signals_received);
+
if (mono_thread_info_get_small_id () == -1)
return; //an non-attached thread got the signal
if (!mono_domain_get () || !mono_native_tls_get_value (mono_jit_tls_id))
return; //thread in the process of dettaching
+ InterlockedIncrement (&profiler_signals_accepted);
+
hp_save_index = mono_hazard_pointer_save_for_signal_handler ();
mono_thread_info_set_is_async_context (TRUE);
#ifdef HAVE_PROFILER_SIGNAL
+static volatile gint32 sampling_thread_running;
+
#ifdef PLATFORM_MACOSX
static clock_serv_t sampling_clock_service;
do {
ret = clock_sleep (sampling_clock_service, TIME_ABSOLUTE, then, &remain_unused);
- } while (ret == KERN_ABORTED);
-
- if (ret != KERN_SUCCESS)
- g_error ("%s: clock_sleep () returned %d", __func__, ret);
+ if (ret != KERN_SUCCESS && ret != KERN_ABORTED)
+ g_error ("%s: clock_sleep () returned %d", __func__, ret);
+ } while (ret == KERN_ABORTED && InterlockedRead (&sampling_thread_running));
}
#else
if (ret != 0 && ret != EINTR)
g_error ("%s: clock_nanosleep () returned %d", __func__, ret);
- } while (ret == EINTR);
+ } while (ret == EINTR && InterlockedRead (&sampling_thread_running));
#else
int ret;
gint64 diff;
if ((ret = nanosleep (&req, NULL)) == -1 && errno != EINTR)
g_error ("%s: nanosleep () returned -1, errno = %d", __func__, errno);
- } while (ret == -1);
+ } while (ret == -1 && InterlockedRead (&sampling_thread_running));
#endif
}
#endif
static int profiler_signal;
-static MonoNativeThreadId sampling_thread;
-static volatile gint32 sampling_thread_running;
+static volatile gint32 sampling_thread_exiting;
static mono_native_thread_return_t
sampling_thread_func (void *data)
g_assert (mono_thread_info_get_tid (info) != mono_native_thread_id_get ());
mono_threads_pthread_kill (info, profiler_signal);
+ InterlockedIncrement (&profiler_signals_sent);
} FOREACH_THREAD_SAFE_END
clock_sleep_ns_abs (sleep);
}
+ InterlockedWrite (&sampling_thread_exiting, 1);
+
clock_cleanup ();
pthread_setschedparam (pthread_self (), old_policy, &old_sched);
mono_runtime_shutdown_stat_profiler (void)
{
InterlockedWrite (&sampling_thread_running, 0);
+
+#ifdef HAVE_CLOCK_NANOSLEEP
+ /*
+ * There is a slight problem when we're using CLOCK_PROCESS_CPUTIME_ID: If
+ * we're shutting down and there's largely no activity in the process other
+ * than waiting for the sampler thread to shut down, it can take upwards of
+ * 20 seconds (depending on a lot of factors) for us to shut down because
+ * the sleep progresses very slowly as a result of the low CPU activity.
+ *
+ * We fix this by repeatedly sending the profiler signal to the sampler
+ * thread in order to interrupt the sleep. clock_sleep_ns_abs () will check
+ * sampling_thread_running upon an interrupt and return immediately if it's
+ * zero. profiler_signal_handler () has a special case to ignore the signal
+ * for the sampler thread.
+ *
+ * We do not need to do this on platforms where we use a regular sleep
+ * based on a monotonic clock. The sleep will return in a reasonable amount
+ * of time in those cases.
+ */
+ if (mono_profiler_get_sampling_mode () == MONO_PROFILER_STAT_MODE_PROCESS) {
+ MonoThreadInfo *info;
+
+ // Did it shut down already?
+ if ((info = mono_thread_info_lookup (sampling_thread))) {
+ while (!InterlockedRead (&sampling_thread_exiting)) {
+ mono_threads_pthread_kill (info, profiler_signal);
+ mono_thread_info_usleep (10 * 1000 /* 10ms */);
+ }
+
+ // Make sure info can be freed.
+ mono_hazard_pointer_clear (mono_hazard_pointer_get (), 1);
+ }
+ }
+#endif
+
pthread_join (sampling_thread, NULL);
/*
* tends to result in awful delivery rates when the application is heavily
* loaded.
*
+ * We avoid real-time signals on Android as they're super broken in certain
+ * API levels (too small sigset_t, nonsensical SIGRTMIN/SIGRTMAX values,
+ * etc).
+ *
* TODO: On Mac, we should explore using the Mach thread suspend/resume
* functions and doing the stack walk from the sampling thread. This would
* get us a 100% sampling rate. However, this may interfere with the GC's
* STW logic. Could perhaps be solved by taking the suspend lock.
*/
-#if defined (USE_POSIX_BACKEND) && defined (SIGRTMIN)
+#if defined (USE_POSIX_BACKEND) && defined (SIGRTMIN) && !defined (PLATFORM_ANDROID)
/* Just take the first real-time signal we can get. */
profiler_signal = mono_threads_posix_signal_search_alternative (-1);
#else
add_signal_handler (profiler_signal, profiler_signal_handler, SA_RESTART);
+ mono_counters_register ("Sampling signals sent", MONO_COUNTER_UINT | MONO_COUNTER_PROFILER | MONO_COUNTER_MONOTONIC, &profiler_signals_sent);
+ mono_counters_register ("Sampling signals received", MONO_COUNTER_UINT | MONO_COUNTER_PROFILER | MONO_COUNTER_MONOTONIC, &profiler_signals_received);
+ mono_counters_register ("Sampling signals accepted", MONO_COUNTER_UINT | MONO_COUNTER_PROFILER | MONO_COUNTER_MONOTONIC, &profiler_signals_accepted);
+ mono_counters_register ("Shutdown signals received", MONO_COUNTER_UINT | MONO_COUNTER_PROFILER | MONO_COUNTER_MONOTONIC, &profiler_interrupt_signals_received);
+
InterlockedWrite (&sampling_thread_running, 1);
mono_native_thread_create (&sampling_thread, sampling_thread_func, NULL);
}
thread = mono_thread_info_current_unchecked ();
if (thread)
thread->jit_data = jit_tls;
- if (mono_profiler_get_events () & MONO_PROFILE_STATISTICAL)
- mono_runtime_setup_stat_profiler ();
mono_arch_cpu_init ();
}
mono_thread_attach (domain);
#endif
+ if (mono_profiler_get_events () & MONO_PROFILE_STATISTICAL)
+ mono_runtime_setup_stat_profiler ();
+
mono_profiler_runtime_initialized ();
MONO_VES_INIT_END ();
register_icall (mono_thread_interruption_checkpoint, "mono_thread_interruption_checkpoint", "object", FALSE);
register_icall (mono_thread_force_interruption_checkpoint_noraise, "mono_thread_force_interruption_checkpoint_noraise", "object", FALSE);
#ifndef DISABLE_REMOTING
- register_icall (mono_load_remote_field_new, "mono_load_remote_field_new", "object object ptr ptr", FALSE);
- register_icall (mono_store_remote_field_new, "mono_store_remote_field_new", "void object ptr ptr object", FALSE);
+ register_icall (mono_load_remote_field_new_icall, "mono_load_remote_field_new_icall", "object object ptr ptr", FALSE);
+ register_icall (mono_store_remote_field_new_icall, "mono_store_remote_field_new_icall", "void object ptr ptr object", FALSE);
#endif
#if defined(__native_client__) || defined(__native_client_codegen__)
register_icall (mono_helper_stelem_ref_check, "mono_helper_stelem_ref_check", "void object object", FALSE);
register_icall (ves_icall_object_new, "ves_icall_object_new", "object ptr ptr", FALSE);
register_icall (ves_icall_object_new_specific, "ves_icall_object_new_specific", "object ptr", FALSE);
- register_icall (mono_array_new, "mono_array_new", "object ptr ptr int32", FALSE);
+ register_icall (ves_icall_array_new, "ves_icall_array_new", "object ptr ptr int32", FALSE);
register_icall (ves_icall_array_new_specific, "ves_icall_array_new_specific", "object ptr int32", FALSE);
register_icall (ves_icall_runtime_class_init, "ves_icall_runtime_class_init", "void ptr", FALSE);
register_icall (mono_ldftn, "mono_ldftn", "ptr ptr", FALSE);
endif
libmono_profiler_aot_la_SOURCES = mono-profiler-aot.c
-libmono_profiler_aot_la_LIBADD = $(LIBMONO) $(GLIB_LIBS) $(LIBICONV)
+libmono_profiler_aot_la_LIBADD = $(GLIB_LIBS) $(LIBICONV)
if BITCODE
libmono_profiler_aot_la_LDFLAGS = -no-undefined
endif
libmono_profiler_iomap_la_SOURCES = mono-profiler-iomap.c
-libmono_profiler_iomap_la_LIBADD = $(LIBMONO) $(GLIB_LIBS) $(LIBICONV)
+libmono_profiler_iomap_la_LIBADD = $(GLIB_LIBS) $(LIBICONV)
if BITCODE
libmono_profiler_iomap_la_LDFLAGS = -no-undefined
endif
libmono_profiler_log_la_SOURCES = proflog.c
-libmono_profiler_log_la_LIBADD = $(LIBMONO) $(GLIB_LIBS) $(Z_LIBS)
+libmono_profiler_log_la_LIBADD = $(GLIB_LIBS) $(Z_LIBS)
if HAVE_VTUNE
libmono_profiler_vtune_la_SOURCES = mono-profiler-vtune.c
libmono_profiler_vtune_la_CFLAGS = $(VTUNE_CFLAGS)
-libmono_profiler_vtune_la_LIBADD = $(VTUNE_LIBS) $(LIBMONO) $(GLIB_LIBS) $(LIBICONV)
+libmono_profiler_vtune_la_LIBADD = $(VTUNE_LIBS) $(GLIB_LIBS) $(LIBICONV)
endif
# The log profile uses eglib functions, so it needs to be linked against
case MONO_COUNTER_SECURITY: return "Mono Security";
case MONO_COUNTER_RUNTIME: return "Mono Runtime";
case MONO_COUNTER_SYSTEM: return "Mono System";
+ case MONO_COUNTER_PROFILER: return "Mono Profiler";
default: return "<unknown>";
}
}
#include <mono/metadata/metadata-internals.h>
#include <mono/metadata/class.h>
#include <mono/metadata/class-internals.h>
+#include <mono/metadata/object-internals.h>
#include <mono/metadata/image.h>
#include <mono/metadata/mono-debug.h>
#include <mono/metadata/debug-helpers.h>
static inline void print_report (const gchar *format, ...)
{
+ MonoError error;
MonoClass *klass;
MonoProperty *prop;
MonoString *str;
klass = mono_class_load_from_name (mono_get_corlib (), "System", "Environment");
mono_class_init (klass);
prop = mono_class_get_property_from_name (klass, "StackTrace");
- str = (MonoString*)mono_property_get_value (prop, NULL, NULL, NULL);
+ str = (MonoString*)mono_property_get_value_checked (prop, NULL, NULL, &error);
+ mono_error_assert_ok (&error);
stack_trace = mono_string_to_utf8 (str);
fprintf (stdout, "-= Stack Trace =-\n%s\n\n", stack_trace);
#include <mono/metadata/tabledefs.h>
#include <mono/utils/atomic.h>
#include <mono/utils/mono-membar.h>
+#include <mono/utils/mono-mmap.h>
#include <mono/utils/mono-counters.h>
#include <mono/utils/mono-os-mutex.h>
#include <mono/utils/mono-conc-hashtable.h>
+#include <mono/utils/lock-free-alloc.h>
#include <mono/utils/lock-free-queue.h>
#include <stdlib.h>
#include <string.h>
static int do_coverage = 0;
static gboolean debug_coverage = FALSE;
static MonoProfileSamplingMode sampling_mode = MONO_PROFILER_STAT_MODE_PROCESS;
+static int max_allocated_sample_hits;
+
+static gint32 sample_hits;
+static gint32 sample_flushes;
+static gint32 sample_allocations;
+static gint32 buffer_allocations;
+static gint32 thread_starts;
+static gint32 thread_ends;
+static gint32 domain_loads;
+static gint32 domain_unloads;
+static gint32 context_loads;
+static gint32 context_unloads;
+static gint32 assembly_loads;
+static gint32 assembly_unloads;
+static gint32 image_loads;
+static gint32 image_unloads;
+static gint32 class_loads;
+static gint32 class_unloads;
typedef struct _LogBuffer LogBuffer;
#define ENTER_LOG(lb,str) if ((lb)->locked) {ign_res (write(2, str, strlen(str))); ign_res (write(2, "\n", 1));return;} else {(lb)->locked++;}
#define EXIT_LOG(lb) (lb)->locked--;
-// Shared queue of sample snapshots taken at signal time.
-// The queue is written into by signal handlers for all threads;
-// the helper thread later unqueues and writes into its own LogBuffer.
-typedef struct _StatBuffer StatBuffer;
-struct _StatBuffer {
- // Next (older) StatBuffer in processing queue
- StatBuffer *next;
-
- // Bytes allocated for this StatBuffer
- uintptr_t size;
-
- // Start of currently unused space in buffer
- uintptr_t *cursor;
-
- // Pointer to start-of-structure-plus-size (for convenience)
- uintptr_t *buf_end;
-
- // Start of data in buffer.
- // Data consists of a series of sample packets consisting of:
- // 1 ptrword: Metadata
- // Low 8 bits: COUNT, the count of native stack frames in this sample (currently always 1)
- // Next 8 bits: MBT_COUNT, the count of managed stacks in this sample
- // Next 8 bits: TYPE. See "sampling sources" enum in proflog.h. Usually SAMPLE_CYCLES (1)
- // 1 ptrword: Thread ID
- // 1 ptrword: Timestamp
- // COUNT ptrwords: Native stack frames
- // Each word is an IP (first is IP where the signal did the interruption)
- // MBT_COUNT * 4 ptrwords: Managed stack frames (AsyncFrameInfo, repacked)
- // Word 1: MonoMethod ptr
- // Word 2: MonoDomain ptr
- // Word 3: Base address of method
- // Word 4: Offset within method
- uintptr_t buf [1];
-};
-
typedef struct _BinaryObject BinaryObject;
struct _BinaryObject {
};
struct _MonoProfiler {
- StatBuffer *stat_buffers;
FILE* file;
#if defined (HAVE_SYS_ZLIB)
gzFile gzfile;
#ifndef HOST_WIN32
pthread_t helper_thread;
pthread_t writer_thread;
+ pthread_t dumper_thread;
#endif
volatile gint32 run_writer_thread;
MonoLockFreeQueue writer_queue;
MonoSemType writer_queue_sem;
MonoConcurrentHashTable *method_table;
mono_mutex_t method_table_mutex;
+ volatile gint32 run_dumper_thread;
+ MonoLockFreeQueue dumper_queue;
+ MonoSemType dumper_queue_sem;
+ MonoLockFreeAllocSizeClass sample_size_class;
+ MonoLockFreeAllocator sample_allocator;
+ MonoLockFreeQueue sample_reuse_queue;
BinaryObject *binary_objects;
GPtrArray *coverage_filters;
- GPtrArray *sorted_sample_events;
};
typedef struct _WriterQueueEntry WriterQueueEntry;
return p;
}
-static StatBuffer*
-create_stat_buffer (void)
-{
- StatBuffer* buf = (StatBuffer *)alloc_buffer (BUFFER_SIZE);
- buf->size = BUFFER_SIZE;
- buf->buf_end = (uintptr_t*)((unsigned char*)buf + buf->size);
- buf->cursor = buf->buf;
- return buf;
-}
-
static LogBuffer*
create_buffer (void)
{
LogBuffer* buf = (LogBuffer *)alloc_buffer (BUFFER_SIZE);
+
+ InterlockedIncrement (&buffer_allocations);
+
buf->size = BUFFER_SIZE;
buf->time_base = current_time ();
buf->last_time = buf->time_base;
EXIT_LOG (logbuffer);
}
+// If you alter MAX_FRAMES, you may need to alter SAMPLE_BLOCK_SIZE too.
#define MAX_FRAMES 32
+
typedef struct {
int count;
MonoMethod* methods [MAX_FRAMES];
int32_t il_offsets [MAX_FRAMES];
int32_t native_offsets [MAX_FRAMES];
} FrameData;
+
static int num_frames = MAX_FRAMES;
static mono_bool
if (logbuffer->next)
safe_send (prof, logbuffer);
process_requests (prof);
+
+ InterlockedIncrement (&image_loads);
}
static void
safe_send (prof, logbuffer);
process_requests (prof);
+
+ InterlockedIncrement (&image_unloads);
}
static void
safe_send (prof, logbuffer);
process_requests (prof);
+
+ InterlockedIncrement (&assembly_loads);
}
static void
safe_send (prof, logbuffer);
process_requests (prof);
+
+ InterlockedIncrement (&assembly_unloads);
}
static void
if (logbuffer->next)
safe_send (prof, logbuffer);
process_requests (prof);
+
+ InterlockedIncrement (&class_loads);
}
static void
safe_send (prof, logbuffer);
process_requests (prof);
+
+ InterlockedIncrement (&class_unloads);
}
#ifndef DISABLE_HELPER_THREAD
safe_send (prof, logbuffer);
process_requests (prof);
+
+ InterlockedIncrement (&thread_starts);
}
static void
TLS_SET (tlsbuffer, NULL);
TLS_SET (tlsmethodlist, NULL);
+
+ InterlockedIncrement (&thread_ends);
}
static void
safe_send (prof, logbuffer);
process_requests (prof);
+
+ InterlockedIncrement (&domain_loads);
}
static void
safe_send (prof, logbuffer);
process_requests (prof);
+
+ InterlockedIncrement (&domain_unloads);
}
static void
safe_send (prof, logbuffer);
process_requests (prof);
+
+ InterlockedIncrement (&context_loads);
}
static void
safe_send (prof, logbuffer);
process_requests (prof);
+
+ InterlockedIncrement (&context_unloads);
}
static void
} AsyncFrameInfo;
typedef struct {
+ MonoLockFreeQueueNode node;
+ MonoProfiler *prof;
+ uint64_t elapsed;
+ uintptr_t tid;
+ void *ip;
int count;
- AsyncFrameInfo *data;
-} AsyncFrameData;
+ AsyncFrameInfo frames [MONO_ZERO_LEN_ARRAY];
+} SampleHit;
static mono_bool
async_walk_stack (MonoMethod *method, MonoDomain *domain, void *base_address, int offset, void *data)
{
- AsyncFrameData *frame = (AsyncFrameData *)data;
- if (frame->count < num_frames) {
- frame->data [frame->count].method = method;
- frame->data [frame->count].domain = domain;
- frame->data [frame->count].base_address = base_address;
- frame->data [frame->count].offset = offset;
- // printf ("In %d at %p (dom %p) (native: %p)\n", frame->count, method, domain, base_address);
- frame->count++;
+ SampleHit *sample = (SampleHit *) data;
+
+ if (sample->count < num_frames) {
+ int i = sample->count;
+
+ sample->frames [i].method = method;
+ sample->frames [i].domain = domain;
+ sample->frames [i].base_address = base_address;
+ sample->frames [i].offset = offset;
+
+ sample->count++;
}
- return frame->count == num_frames;
+
+ return sample->count == num_frames;
}
-/*
-(type | frame count), tid, time, ip, [method, domain, base address, offset] * frames
-*/
-#define SAMPLE_EVENT_SIZE_IN_SLOTS(FRAMES) (4 + (FRAMES) * 4)
+#define SAMPLE_SLOT_SIZE(FRAMES) (sizeof (SampleHit) + sizeof (AsyncFrameInfo) * (FRAMES - MONO_ZERO_LEN_ARRAY))
+#define SAMPLE_BLOCK_SIZE (mono_pagesize ())
+
+static void
+enqueue_sample_hit (gpointer p)
+{
+ SampleHit *sample = p;
+
+ mono_lock_free_queue_node_unpoison (&sample->node);
+ mono_lock_free_queue_enqueue (&sample->prof->dumper_queue, &sample->node);
+ mono_os_sem_post (&sample->prof->dumper_queue_sem);
+
+ InterlockedIncrement (&sample_flushes);
+}
static void
mono_sample_hit (MonoProfiler *profiler, unsigned char *ip, void *context)
{
- StatBuffer *sbuf;
- AsyncFrameInfo frames [num_frames];
- AsyncFrameData bt_data = { 0, &frames [0]};
- uint64_t now;
- uintptr_t *data, *new_data, *old_data;
- uintptr_t elapsed;
- int timedout = 0;
- int i;
+ /*
+ * Please note: We rely on the runtime loading the profiler with
+ * MONO_DL_EAGER (RTLD_NOW) so that references to runtime functions within
+ * this function (and its siblings) are resolved when the profiler is
+ * loaded. Otherwise, we would potentially invoke the dynamic linker when
+ * invoking runtime functions, which is not async-signal-safe.
+ */
+
if (in_shutdown)
return;
- now = current_time ();
- mono_stack_walk_async_safe (&async_walk_stack, context, &bt_data);
+ InterlockedIncrement (&sample_hits);
+
+ uint64_t now = current_time ();
+
+ SampleHit *sample = (SampleHit *) mono_lock_free_queue_dequeue (&profiler->sample_reuse_queue);
+
+ if (!sample) {
+ /*
+ * If we're out of reusable sample events and we're not allowed to
+ * allocate more, we have no choice but to drop the event.
+ */
+ if (InterlockedRead (&sample_allocations) >= max_allocated_sample_hits)
+ return;
+
+ sample = mono_lock_free_alloc (&profiler->sample_allocator);
+ sample->prof = profiler;
+ mono_lock_free_queue_node_init (&sample->node, TRUE);
+
+ InterlockedIncrement (&sample_allocations);
+ }
+
+ sample->count = 0;
+ mono_stack_walk_async_safe (&async_walk_stack, context, sample);
+
+ uintptr_t elapsed = (now - profiler->startup_time) / 10000;
+
+ sample->elapsed = elapsed;
+ sample->tid = thread_id ();
+ sample->ip = ip;
- elapsed = (now - profiler->startup_time) / 10000;
if (do_debug) {
int len;
char buf [256];
- snprintf (buf, sizeof (buf), "hit at %p in thread %p after %llu ms\n", ip, (void*)thread_id (), (unsigned long long int)elapsed/100);
+ snprintf (buf, sizeof (buf), "hit at %p in thread %p after %llu ms\n", ip, (void *) thread_id (), (unsigned long long int) elapsed / 100);
len = strlen (buf);
ign_res (write (2, buf, len));
}
- sbuf = profiler->stat_buffers;
- if (!sbuf)
- return;
- /* flush the buffer at 1 second intervals */
- if (sbuf->cursor > sbuf->buf && (elapsed - sbuf->buf [2]) > 100000) {
- timedout = 1;
- }
- /* overflow: 400 slots is a big enough number to reduce the chance of losing this event if many
- * threads hit this same spot at the same time
- */
- if (timedout || (sbuf->cursor + 400 >= sbuf->buf_end)) {
- StatBuffer *oldsb, *foundsb;
- sbuf = create_stat_buffer ();
- do {
- oldsb = profiler->stat_buffers;
- sbuf->next = oldsb;
- foundsb = (StatBuffer *)InterlockedCompareExchangePointer ((void * volatile*)&profiler->stat_buffers, sbuf, oldsb);
- } while (foundsb != oldsb);
- if (do_debug)
- ign_res (write (2, "overflow\n", 9));
- /* notify the helper thread */
- if (sbuf->next->next) {
- char c = 0;
- ign_res (write (profiler->pipes [1], &c, 1));
- if (do_debug)
- ign_res (write (2, "notify\n", 7));
- }
- }
- do {
- old_data = sbuf->cursor;
- new_data = old_data + SAMPLE_EVENT_SIZE_IN_SLOTS (bt_data.count);
- if (new_data > sbuf->buf_end)
- return; /* Not enough room in buf to hold this event-- lost event */
- data = (uintptr_t *)InterlockedCompareExchangePointer ((void * volatile*)&sbuf->cursor, new_data, old_data);
- } while (data != old_data);
-
- old_data [0] = 1 | (sample_type << 16) | (bt_data.count << 8);
- old_data [1] = thread_id ();
- old_data [2] = elapsed;
- old_data [3] = (uintptr_t)ip;
- for (i = 0; i < bt_data.count; ++i) {
- old_data [4 + 4 * i + 0] = (uintptr_t)frames [i].method;
- old_data [4 + 4 * i + 1] = (uintptr_t)frames [i].domain;
- old_data [4 + 4 * i + 2] = (uintptr_t)frames [i].base_address;
- old_data [4 + 4 * i + 3] = (uintptr_t)frames [i].offset;
- }
+
+ mono_thread_hazardous_try_free (sample, enqueue_sample_hit);
}
static uintptr_t *code_pages = 0;
}
}
-static gint
-compare_sample_events (gconstpointer a, gconstpointer b)
-{
- uintptr_t tid1 = (*(uintptr_t **) a) [1];
- uintptr_t tid2 = (*(uintptr_t **) b) [1];
-
- return tid1 > tid2 ? 1 :
- tid1 < tid2 ? -1 :
- 0;
-}
-
-static void
-dump_sample_hits (MonoProfiler *prof, StatBuffer *sbuf)
-{
- LogBuffer *logbuffer;
- if (!sbuf)
- return;
- if (sbuf->next) {
- dump_sample_hits (prof, sbuf->next);
- free_buffer (sbuf->next, sbuf->next->size);
- sbuf->next = NULL;
- }
-
- g_ptr_array_set_size (prof->sorted_sample_events, 0);
-
- for (uintptr_t *sample = sbuf->buf; sample < sbuf->cursor;) {
- int count = sample [0] & 0xff;
- int mbt_count = (sample [0] & 0xff00) >> 8;
-
- if (sample + SAMPLE_EVENT_SIZE_IN_SLOTS (mbt_count) > sbuf->cursor)
- break;
-
- g_ptr_array_add (prof->sorted_sample_events, sample);
-
- sample += count + 3 + 4 * mbt_count;
- }
-
- g_ptr_array_sort (prof->sorted_sample_events, compare_sample_events);
-
- for (guint sidx = 0; sidx < prof->sorted_sample_events->len; sidx++) {
- uintptr_t *sample = (uintptr_t *)g_ptr_array_index (prof->sorted_sample_events, sidx);
- int count = sample [0] & 0xff;
- int mbt_count = (sample [0] & 0xff00) >> 8;
- int type = sample [0] >> 16;
- uintptr_t *managed_sample_base = sample + count + 3;
- uintptr_t thread_id = sample [1];
-
- for (int i = 0; i < mbt_count; ++i) {
- MonoMethod *method = (MonoMethod*)managed_sample_base [i * 4 + 0];
- MonoDomain *domain = (MonoDomain*)managed_sample_base [i * 4 + 1];
- void *address = (void*)managed_sample_base [i * 4 + 2];
-
- if (!method) {
- g_assert (domain);
- MonoJitInfo *ji = mono_jit_info_table_find (domain, (char *)address);
-
- if (ji)
- managed_sample_base [i * 4 + 0] = (uintptr_t)mono_jit_info_get_method (ji);
- }
- }
-
- logbuffer = ensure_logbuf (
- EVENT_SIZE /* event */ +
- LEB128_SIZE /* type */ +
- LEB128_SIZE /* time */ +
- LEB128_SIZE /* tid */ +
- LEB128_SIZE /* count */ +
- count * (
- LEB128_SIZE /* ip */
- ) +
- LEB128_SIZE /* managed count */ +
- mbt_count * (
- LEB128_SIZE /* method */ +
- LEB128_SIZE /* il offset */ +
- LEB128_SIZE /* native offset */
- )
- );
- emit_byte (logbuffer, TYPE_SAMPLE | TYPE_SAMPLE_HIT);
- emit_value (logbuffer, type);
- emit_uvalue (logbuffer, prof->startup_time + (uint64_t)sample [2] * (uint64_t)10000);
- emit_ptr (logbuffer, (void *) thread_id);
- emit_value (logbuffer, count);
- for (int i = 0; i < count; ++i) {
- emit_ptr (logbuffer, (void*)sample [i + 3]);
- add_code_pointer (sample [i + 3]);
- }
-
- sample += count + 3;
- /* new in data version 6 */
- emit_uvalue (logbuffer, mbt_count);
- for (int i = 0; i < mbt_count; ++i) {
- MonoMethod *method = (MonoMethod *) sample [i * 4 + 0];
- uintptr_t native_offset = sample [i * 4 + 3];
-
- emit_method (prof, logbuffer, method);
- emit_svalue (logbuffer, 0); /* il offset will always be 0 from now on */
- emit_svalue (logbuffer, native_offset);
- }
- }
-
- dump_unmanaged_coderefs (prof);
-}
-
-#if USE_PERF_EVENTS
-
static int
mono_cpu_count (void)
{
return 1;
}
+#if USE_PERF_EVENTS
+
typedef struct {
int perf_fd;
unsigned int prev_pos;
mono_assembly_close (assembly);
}
+static void
+free_sample_hit (gpointer p)
+{
+ mono_lock_free_free (p, SAMPLE_BLOCK_SIZE);
+}
+
+static void
+cleanup_reusable_samples (MonoProfiler *prof)
+{
+ SampleHit *sample;
+
+ while ((sample = (SampleHit *) mono_lock_free_queue_dequeue (&prof->sample_reuse_queue)))
+ mono_thread_hazardous_try_free (sample, free_sample_hit);
+}
+
static void
log_shutdown (MonoProfiler *prof)
{
}
#endif
- g_ptr_array_free (prof->sorted_sample_events, TRUE);
-
if (TLS_GET (LogBuffer, tlsbuffer))
send_buffer (prof, TLS_GET (GPtrArray, tlsmethodlist), TLS_GET (LogBuffer, tlsbuffer));
TLS_SET (tlsbuffer, NULL);
TLS_SET (tlsmethodlist, NULL);
+ InterlockedWrite (&prof->run_dumper_thread, 0);
+ mono_os_sem_post (&prof->dumper_queue_sem);
+ pthread_join (prof->dumper_thread, &res);
+ mono_os_sem_destroy (&prof->dumper_queue_sem);
+
InterlockedWrite (&prof->run_writer_thread, 0);
mono_os_sem_post (&prof->writer_queue_sem);
pthread_join (prof->writer_thread, &res);
-
mono_os_sem_destroy (&prof->writer_queue_sem);
+ cleanup_reusable_samples (prof);
+
#if defined (HAVE_SYS_ZLIB)
if (prof->gzfile)
gzclose (prof->gzfile);
if (FD_ISSET (prof->pipes [0], &rfds)) {
char c;
- int r = read (prof->pipes [0], &c, 1);
- if (r == 1 && c == 0) {
- StatBuffer *sbufbase = prof->stat_buffers;
- StatBuffer *sbuf;
- if (!sbufbase->next)
- continue;
- sbuf = sbufbase->next->next;
- sbufbase->next->next = NULL;
- if (do_debug)
- fprintf (stderr, "stat buffer dump\n");
- if (sbuf) {
- dump_sample_hits (prof, sbuf);
- free_buffer (sbuf, sbuf->size);
- safe_send_threadless (prof, ensure_logbuf (0));
- }
- continue;
- }
- /* time to shut down */
- dump_sample_hits (prof, prof->stat_buffers);
+ read (prof->pipes [0], &c, 1);
if (thread)
mono_thread_detach (thread);
if (do_debug)
return !pthread_create (&prof->writer_thread, NULL, writer_thread, prof);
}
+static void
+reuse_sample_hit (gpointer p)
+{
+ SampleHit *sample = p;
+
+ mono_lock_free_queue_node_unpoison (&sample->node);
+ mono_lock_free_queue_enqueue (&sample->prof->sample_reuse_queue, &sample->node);
+}
+
+static gboolean
+handle_dumper_queue_entry (MonoProfiler *prof)
+{
+ SampleHit *sample;
+
+ if ((sample = (SampleHit *) mono_lock_free_queue_dequeue (&prof->dumper_queue))) {
+ for (int i = 0; i < sample->count; ++i) {
+ MonoMethod *method = sample->frames [i].method;
+ MonoDomain *domain = sample->frames [i].domain;
+ void *address = sample->frames [i].base_address;
+
+ if (!method) {
+ g_assert (domain);
+ g_assert (address);
+
+ MonoJitInfo *ji = mono_jit_info_table_find (domain, (char *) address);
+
+ if (ji)
+ sample->frames [i].method = mono_jit_info_get_method (ji);
+ }
+ }
+
+ LogBuffer *logbuffer = ensure_logbuf (
+ EVENT_SIZE /* event */ +
+ LEB128_SIZE /* type */ +
+ LEB128_SIZE /* time */ +
+ LEB128_SIZE /* tid */ +
+ LEB128_SIZE /* count */ +
+ 1 * (
+ LEB128_SIZE /* ip */
+ ) +
+ LEB128_SIZE /* managed count */ +
+ sample->count * (
+ LEB128_SIZE /* method */ +
+ LEB128_SIZE /* il offset */ +
+ LEB128_SIZE /* native offset */
+ )
+ );
+
+ emit_byte (logbuffer, TYPE_SAMPLE | TYPE_SAMPLE_HIT);
+ emit_value (logbuffer, sample_type);
+ emit_uvalue (logbuffer, prof->startup_time + sample->elapsed * 10000);
+ emit_ptr (logbuffer, (void *) sample->tid);
+ emit_value (logbuffer, 1);
+
+ // TODO: Actual native unwinding.
+ for (int i = 0; i < 1; ++i) {
+ emit_ptr (logbuffer, sample->ip);
+ add_code_pointer ((uintptr_t) sample->ip);
+ }
+
+ /* new in data version 6 */
+ emit_uvalue (logbuffer, sample->count);
+
+ for (int i = 0; i < sample->count; ++i) {
+ emit_method (prof, logbuffer, sample->frames [i].method);
+ emit_svalue (logbuffer, 0); /* il offset will always be 0 from now on */
+ emit_svalue (logbuffer, sample->frames [i].offset);
+ }
+
+ mono_thread_hazardous_try_free (sample, reuse_sample_hit);
+
+ dump_unmanaged_coderefs (prof);
+
+ if (logbuffer->next)
+ safe_send_threadless (prof, logbuffer);
+ }
+
+ return FALSE;
+}
+
+static void *
+dumper_thread (void *arg)
+{
+ MonoProfiler *prof = (MonoProfiler *)arg;
+
+ mono_threads_attach_tools_thread ();
+ mono_thread_info_set_name (mono_native_thread_id_get (), "Profiler dumper");
+
+ while (InterlockedRead (&prof->run_dumper_thread)) {
+ mono_os_sem_wait (&prof->dumper_queue_sem, MONO_SEM_FLAGS_NONE);
+ handle_dumper_queue_entry (prof);
+ }
+
+ /* Drain any remaining entries on shutdown. */
+ while (handle_dumper_queue_entry (prof));
+
+ safe_send_threadless (prof, ensure_logbuf (0));
+
+ mono_thread_info_detach ();
+
+ return NULL;
+}
+
+static int
+start_dumper_thread (MonoProfiler* prof)
+{
+ InterlockedWrite (&prof->run_dumper_thread, 1);
+
+ return !pthread_create (&prof->dumper_thread, NULL, dumper_thread, prof);
+}
+
static void
runtime_initialized (MonoProfiler *profiler)
{
#endif
start_writer_thread (profiler);
+ start_dumper_thread (profiler);
InterlockedWrite (&runtime_inited, 1);
#ifndef DISABLE_HELPER_THREAD
}
#endif
if (do_mono_sample) {
- prof->stat_buffers = create_stat_buffer ();
need_helper_thread = 1;
}
if (do_counters && !need_helper_thread) {
need_helper_thread = 1;
}
- prof->sorted_sample_events = g_ptr_array_sized_new (BUFFER_SIZE / SAMPLE_EVENT_SIZE_IN_SLOTS (0));
+ /*
+ * If you hit this assert while increasing MAX_FRAMES, you need to increase
+ * SAMPLE_BLOCK_SIZE as well.
+ */
+ g_assert (SAMPLE_SLOT_SIZE (MAX_FRAMES) * 2 < LOCK_FREE_ALLOC_SB_USABLE_SIZE (SAMPLE_BLOCK_SIZE));
+
+ // FIXME: We should free this stuff too.
+ mono_lock_free_allocator_init_size_class (&prof->sample_size_class, SAMPLE_SLOT_SIZE (num_frames), SAMPLE_BLOCK_SIZE);
+ mono_lock_free_allocator_init_allocator (&prof->sample_allocator, &prof->sample_size_class);
+
+ mono_lock_free_queue_init (&prof->sample_reuse_queue);
#ifdef DISABLE_HELPER_THREAD
if (hs_mode_ondemand)
mono_lock_free_queue_init (&prof->writer_queue);
mono_os_sem_init (&prof->writer_queue_sem, 0);
+ mono_lock_free_queue_init (&prof->dumper_queue);
+ mono_os_sem_init (&prof->dumper_queue_sem, 0);
+
mono_os_mutex_init (&prof->method_table_mutex);
prof->method_table = mono_conc_hashtable_new (NULL, NULL);
printf ("\theapshot[=MODE] record heap shot info (by default at each major collection)\n");
printf ("\t MODE: every XXms milliseconds, every YYgc collections, ondemand\n");
printf ("\tcounters sample counters every 1s\n");
- printf ("\tsample[=TYPE] use statistical sampling mode (by default cycles/1000)\n");
+ printf ("\tsample[=TYPE] use statistical sampling mode (by default cycles/100)\n");
printf ("\t TYPE: cycles,instr,cacherefs,cachemiss,branches,branchmiss\n");
printf ("\t TYPE can be followed by /FREQUENCY\n");
printf ("\ttime=fast use a faster (but more inaccurate) timer\n");
#endif
if (allow_empty && !val) {
sample_type = SAMPLE_CYCLES;
- sample_freq = 1000;
+ sample_freq = 100;
return;
}
if (strcmp (val, "mono") == 0) {
} else if (*maybe_freq != 0) {
usage (1);
} else {
- sample_freq = 1000;
+ sample_freq = 100;
}
free (val);
}
MONO_PROFILE_INS_COVERAGE|MONO_PROFILE_APPDOMAIN_EVENTS|MONO_PROFILE_CONTEXT_EVENTS|
MONO_PROFILE_ASSEMBLY_EVENTS;
+ max_allocated_sample_hits = mono_cpu_count () * 1000;
+
+ mono_counters_register ("Sample hits", MONO_COUNTER_UINT | MONO_COUNTER_PROFILER | MONO_COUNTER_MONOTONIC, &sample_hits);
+ mono_counters_register ("Sample flushes", MONO_COUNTER_UINT | MONO_COUNTER_PROFILER | MONO_COUNTER_MONOTONIC, &sample_flushes);
+ mono_counters_register ("Sample events allocated", MONO_COUNTER_UINT | MONO_COUNTER_PROFILER | MONO_COUNTER_MONOTONIC, &sample_allocations);
+ mono_counters_register ("Log buffers allocated", MONO_COUNTER_UINT | MONO_COUNTER_PROFILER | MONO_COUNTER_MONOTONIC, &buffer_allocations);
+ mono_counters_register ("Thread start events", MONO_COUNTER_UINT | MONO_COUNTER_PROFILER | MONO_COUNTER_MONOTONIC, &thread_starts);
+ mono_counters_register ("Thread stop events", MONO_COUNTER_UINT | MONO_COUNTER_PROFILER | MONO_COUNTER_MONOTONIC, &thread_ends);
+ mono_counters_register ("Domain load events", MONO_COUNTER_UINT | MONO_COUNTER_PROFILER | MONO_COUNTER_MONOTONIC, &domain_loads);
+ mono_counters_register ("Domain unload events", MONO_COUNTER_UINT | MONO_COUNTER_PROFILER | MONO_COUNTER_MONOTONIC, &domain_unloads);
+ mono_counters_register ("Context load events", MONO_COUNTER_UINT | MONO_COUNTER_PROFILER | MONO_COUNTER_MONOTONIC, &context_loads);
+ mono_counters_register ("Context unload events", MONO_COUNTER_UINT | MONO_COUNTER_PROFILER | MONO_COUNTER_MONOTONIC, &context_unloads);
+ mono_counters_register ("Assembly load events", MONO_COUNTER_UINT | MONO_COUNTER_PROFILER | MONO_COUNTER_MONOTONIC, &assembly_loads);
+ mono_counters_register ("Assembly unload events", MONO_COUNTER_UINT | MONO_COUNTER_PROFILER | MONO_COUNTER_MONOTONIC, &assembly_unloads);
+ mono_counters_register ("Image load events", MONO_COUNTER_UINT | MONO_COUNTER_PROFILER | MONO_COUNTER_MONOTONIC, &image_loads);
+ mono_counters_register ("Image unload events", MONO_COUNTER_UINT | MONO_COUNTER_PROFILER | MONO_COUNTER_MONOTONIC, &image_unloads);
+ mono_counters_register ("Class load events", MONO_COUNTER_UINT | MONO_COUNTER_PROFILER | MONO_COUNTER_MONOTONIC, &class_loads);
+ mono_counters_register ("Class unload events", MONO_COUNTER_UINT | MONO_COUNTER_PROFILER | MONO_COUNTER_MONOTONIC, &class_unloads);
+
p = desc;
if (strncmp (p, "log", 3))
usage (1);
notraces = num_frames == 0;
continue;
}
+ if ((opt = match_option (p, "maxsamples", &val)) != p) {
+ char *end;
+ max_allocated_sample_hits = strtoul (val, &end, 10);
+ if (!max_allocated_sample_hits)
+ max_allocated_sample_hits = G_MAXINT32;
+ free (val);
+ continue;
+ }
if ((opt = match_option (p, "calldepth", &val)) != p) {
char *end;
max_call_depth = strtoul (val, &end, 10);
prof = create_profiler (filename, filters);
if (!prof)
return;
+
init_thread ();
mono_profiler_install (prof, log_shutdown);
mono_profiler_install_allocation (gc_alloc);
mono_profiler_install_gc_moves (gc_moves);
mono_profiler_install_gc_roots (gc_handle, gc_roots);
- mono_profiler_install_appdomain (NULL, domain_loaded, NULL, domain_unloaded);
+ mono_profiler_install_appdomain (NULL, domain_loaded, domain_unloaded, NULL);
mono_profiler_install_appdomain_name (domain_name);
mono_profiler_install_context (context_loaded, context_unloaded);
- mono_profiler_install_class (NULL, class_loaded, NULL, class_unloaded);
- mono_profiler_install_module (NULL, image_loaded, NULL, image_unloaded);
+ mono_profiler_install_class (NULL, class_loaded, class_unloaded, NULL);
+ mono_profiler_install_module (NULL, image_loaded, image_unloaded, NULL);
mono_profiler_install_assembly (NULL, assembly_loaded, assembly_unloaded, NULL);
mono_profiler_install_thread (thread_start, thread_end);
mono_profiler_install_thread_name (thread_name);
if (do_mono_sample && sample_type == SAMPLE_CYCLES && !only_counters) {
events |= MONO_PROFILE_STATISTICAL;
- mono_profiler_set_statistical_mode (sampling_mode, 1000000 / sample_freq);
+ mono_profiler_set_statistical_mode (sampling_mode, sample_freq);
mono_profiler_install_statistical (mono_sample_hit);
}
#define LOG_HEADER_ID 0x4D505A01
#define LOG_VERSION_MAJOR 0
#define LOG_VERSION_MINOR 4
-#define LOG_DATA_VERSION 11
+#define LOG_DATA_VERSION 12
/*
* Changes in data versions:
* version 2: added offsets in heap walk
removed TYPE_LOAD_ERR flag (profiler never generated it, now removed from the format itself)
added TYPE_GC_HANDLE_{CREATED,DESTROYED}_BT
TYPE_JIT events are no longer guaranteed to have code start/size info (can be zero)
+ * version 12: added MONO_COUNTER_PROFILER
*/
enum {
}
/* Note: we also handle structs with just ref fields */
if (num_set * sizeof (gpointer) == elem_size) {
- return desc | VECTOR_SUBTYPE_REFS | ((gssize)(-1) << 16);
+ return desc | VECTOR_SUBTYPE_REFS | ((gsize)(-1) << 16);
}
/* FIXME: try run-len first */
/* Note: we can't skip the object header here, because it's not present */
return hidden;
if (closure->predicate (obj, closure->data))
- return NULL;
+ return MONO_GC_HANDLE_METADATA_POINTER (sgen_client_default_metadata (), GC_HANDLE_TYPE_IS_WEAK (handle_type));
return hidden;
}
void
sgen_los_free_object (LOSObject *obj)
{
- SGEN_ASSERT (0, !obj->cardtable_mod_union, "We should never free a LOS object with a mod-union table.");
+ if (obj->cardtable_mod_union)
+ sgen_card_table_free_mod_union (obj->cardtable_mod_union, (char*)obj->data, sgen_los_object_size (obj));
#ifndef LOS_DUMMY
mword size = sgen_los_object_size (obj);
for (bigobj = los_object_list; bigobj;) {
SGEN_ASSERT (0, !SGEN_OBJECT_IS_PINNED (bigobj->data), "Who pinned a LOS object?");
- if (bigobj->cardtable_mod_union) {
- sgen_card_table_free_mod_union (bigobj->cardtable_mod_union, (char*)bigobj->data, sgen_los_object_size (bigobj));
- bigobj->cardtable_mod_union = NULL;
- }
-
if (sgen_los_object_is_pinned (bigobj->data)) {
+ if (bigobj->cardtable_mod_union) {
+ mword obj_size = sgen_los_object_size (bigobj);
+ mword num_cards = sgen_card_table_number_of_cards_in_range ((mword) bigobj->data, obj_size);
+ memset (bigobj->cardtable_mod_union, 0, num_cards);
+ }
+
sgen_los_unpin_object (bigobj->data);
sgen_update_heap_boundaries ((mword)bigobj->data, (mword)bigobj->data + sgen_los_object_size (bigobj));
} else {
* list, where it will either be freed later on, or reused in nursery collections.
*/
static void
-ms_free_block (void *block)
+ms_free_block (MSBlockInfo *info)
{
void *empty;
+ char *block = MS_BLOCK_FOR_BLOCK_INFO (info);
sgen_memgov_release_space (MS_BLOCK_SIZE, SPACE_MAJOR);
+ if (info->cardtable_mod_union)
+ sgen_card_table_free_mod_union (info->cardtable_mod_union, block, MS_BLOCK_SIZE);
memset (block, 0, MS_BLOCK_SIZE);
do {
count = MS_BLOCK_FREE / block->obj_size;
- if (block->cardtable_mod_union) {
- sgen_card_table_free_mod_union (block->cardtable_mod_union, MS_BLOCK_FOR_BLOCK_INFO (block), MS_BLOCK_SIZE);
- block->cardtable_mod_union = NULL;
- }
+ if (block->cardtable_mod_union)
+ memset (block->cardtable_mod_union, 0, CARDS_PER_BLOCK);
/* Count marked objects in the block */
for (i = 0; i < MS_NUM_MARK_WORDS; ++i)
MSBlockInfo *block;
FOREACH_BLOCK_NO_LOCK (block) {
- size_t num_cards;
- guint8 *mod_union = get_cardtable_mod_union_for_block (block, TRUE);
- sgen_card_table_update_mod_union (mod_union, MS_BLOCK_FOR_BLOCK_INFO (block), MS_BLOCK_SIZE, &num_cards);
- SGEN_ASSERT (6, num_cards == CARDS_PER_BLOCK, "Number of cards calculation is wrong");
+ gpointer *card_start = (gpointer*) sgen_card_table_get_card_address ((mword)MS_BLOCK_FOR_BLOCK_INFO (block));
+ gboolean has_dirty_cards = FALSE;
+ int i;
+ for (i = 0; i < CARDS_PER_BLOCK / sizeof(gpointer); i++) {
+ if (card_start [i]) {
+ has_dirty_cards = TRUE;
+ break;
+ }
+ }
+ if (has_dirty_cards) {
+ size_t num_cards;
+ guint8 *mod_union = get_cardtable_mod_union_for_block (block, TRUE);
+ sgen_card_table_update_mod_union (mod_union, MS_BLOCK_FOR_BLOCK_INFO (block), MS_BLOCK_SIZE, &num_cards);
+ SGEN_ASSERT (6, num_cards == CARDS_PER_BLOCK, "Number of cards calculation is wrong");
+ }
} END_FOREACH_BLOCK_NO_LOCK;
}
pinvoke_ppcs.cs \
pinvoke_ppci.cs \
pinvoke_ppcf.cs \
- pinvoke_ppcd.cs
+ pinvoke_ppcd.cs \
+ bug-29585.cs
TEST_CS_SRC_DIST= \
$(BASE_TEST_CS_SRC) \
@$(MCS) -r:TestDriver.dll $(srcdir)/debug-casts.cs
@$(RUNTIME) --debug=casts debug-casts.exe
-EXTRA_DIST += sgen-bridge.cs sgen-descriptors.cs sgen-gshared-vtype.cs sgen-bridge-major-fragmentation.cs sgen-domain-unload.cs sgen-weakref-stress.cs sgen-cementing-stress.cs sgen-case-23400.cs finalizer-wait.cs critical-finalizers.cs sgen-domain-unload-2.cs sgen-suspend.cs sgen-new-threads-dont-join-stw.cs sgen-bridge-xref.cs bug-17590.cs sgen-toggleref.cs
+EXTRA_DIST += sgen-bridge.cs sgen-descriptors.cs sgen-gshared-vtype.cs sgen-bridge-major-fragmentation.cs sgen-domain-unload.cs sgen-weakref-stress.cs sgen-cementing-stress.cs sgen-case-23400.cs finalizer-wait.cs critical-finalizers.cs sgen-domain-unload-2.cs sgen-suspend.cs sgen-new-threads-dont-join-stw.cs sgen-bridge-xref.cs bug-17590.cs sgen-toggleref.cs sgen-bridge-gchandle.cs
sgen-tests:
sgen-bridge2-tests-ms-split-tarjan-bridge: $(SGEN_BRIDGE2_TESTS) test-runner.exe
MONO_ENV_OPTIONS="--gc=sgen" MONO_GC_DEBUG="bridge=2Bridge" MONO_GC_PARAMS="bridge-implementation=tarjan,minor=split" $(RUNTIME) ./test-runner.exe --testsuite-name $@ --timeout 900 $(SGEN_BRIDGE2_TESTS)
+
+SGEN_BRIDGE3_TESTS= \
+ sgen-bridge-gchandle.exe
+
+sgen-bridge3-tests: $(SGEN_BRIDGE3_TESTS)
+ $(MAKE) sgen-bridge3-tests-plain
+ $(MAKE) sgen-bridge3-tests-ms-conc
+ $(MAKE) sgen-bridge3-tests-ms-split
+ $(MAKE) sgen-bridge3-tests-plain-new-bridge
+ $(MAKE) sgen-bridge3-tests-ms-conc-new-bridge
+ $(MAKE) sgen-bridge3-tests-ms-split-new-bridge
+ $(MAKE) sgen-bridge3-tests-plain-tarjan-bridge
+ $(MAKE) sgen-bridge3-tests-ms-split-tarjan-bridge
+
+sgen-bridge3-tests-plain: $(SGEN_bridge3_TESTS) test-runner.exe
+ MONO_ENV_OPTIONS="--gc=sgen" MONO_GC_DEBUG="bridge=3Bridge" MONO_GC_PARAMS="" $(RUNTIME) ./test-runner.exe --testsuite-name $@ --timeout 900 $(SGEN_BRIDGE3_TESTS)
+sgen-bridge3-tests-ms-conc: $(SGEN_BRIDGE3_TESTS) test-runner.exe
+ MONO_ENV_OPTIONS="--gc=sgen" MONO_GC_DEBUG="bridge=3Bridge" MONO_GC_PARAMS="major=marksweep-conc" $(RUNTIME) ./test-runner.exe --testsuite-name $@ --timeout 900 $(SGEN_BRIDGE3_TESTS)
+sgen-bridge3-tests-ms-split: $(SGEN_BRIDGE3_TESTS) test-runner.exe
+ MONO_ENV_OPTIONS="--gc=sgen" MONO_GC_DEBUG="bridge=3Bridge" MONO_GC_PARAMS="minor=split" $(RUNTIME) ./test-runner.exe --testsuite-name $@ --timeout 900 $(SGEN_BRIDGE3_TESTS)
+sgen-bridge3-tests-plain-new-bridge: $(SGEN_BRIDGE3_TESTS) test-runner.exe
+ MONO_ENV_OPTIONS="--gc=sgen" MONO_GC_DEBUG="bridge=3Bridge" MONO_GC_PARAMS="bridge-implementation=new" $(RUNTIME) ./test-runner.exe --testsuite-name $@ --timeout 900 $(SGEN_BRIDGE3_TESTS)
+sgen-bridge3-tests-ms-conc-new-bridge: $(SGEN_BRIDGE3_TESTS) test-runner.exe
+ MONO_ENV_OPTIONS="--gc=sgen" MONO_GC_DEBUG="bridge=3Bridge" MONO_GC_PARAMS="bridge-implementation=new,major=marksweep-conc" $(RUNTIME) ./test-runner.exe --testsuite-name $@ --timeout 900 $(SGEN_BRIDGE3_TESTS)
+sgen-bridge3-tests-ms-split-new-bridge: $(SGEN_BRIDGE3_TESTS) test-runner.exe
+ MONO_ENV_OPTIONS="--gc=sgen" MONO_GC_DEBUG="bridge=3Bridge" MONO_GC_PARAMS="bridge-implementation=new,minor=split" $(RUNTIME) ./test-runner.exe --testsuite-name $@ --timeout 900 $(SGEN_BRIDGE3_TESTS)
+sgen-bridge3-tests-plain-tarjan-bridge: $(SGEN_BRIDGE3_TESTS) test-runner.exe
+ MONO_ENV_OPTIONS="--gc=sgen" MONO_GC_DEBUG="bridge=3Bridge" MONO_GC_PARAMS="bridge-implementation=tarjan" $(RUNTIME) ./test-runner.exe --testsuite-name $@ --timeout 900 $(SGEN_BRIDGE3_TESTS)
+sgen-bridge3-tests-ms-split-tarjan-bridge: $(SGEN_BRIDGE3_TESTS) test-runner.exe
+ MONO_ENV_OPTIONS="--gc=sgen" MONO_GC_DEBUG="bridge=3Bridge" MONO_GC_PARAMS="bridge-implementation=tarjan,minor=split" $(RUNTIME) ./test-runner.exe --testsuite-name $@ --timeout 900 $(SGEN_BRIDGE3_TESTS)
+
+
AOT_CONFIGURATIONS= \
"|regular" \
"--gc=boehm|boehm"
--- /dev/null
+namespace TestCase
+{
+ using System;
+ using System.Linq;
+ using System.Reflection;
+
+
+ public class MainClass
+ {
+ public static int Main()
+ {
+ return new GenericDerived<Param>().FindMethod();
+ }
+ }
+
+
+ interface Param
+ {
+ }
+
+
+ class GenericDerived<T> :
+ Abstract<GenericDerived<T>>
+ {
+ public int FindMethod()
+ {
+ return FindGenericMethod<T>();
+ }
+ }
+
+
+ abstract class Abstract<TDerived>
+ where TDerived : Abstract<TDerived>
+ {
+ protected virtual int FindGenericMethod<T>()
+ {
+ var method = typeof(TDerived)
+ .GetMethods(BindingFlags.Instance | BindingFlags.NonPublic)
+ .FirstOrDefault(x => x.Name == "FindGenericMethod" && x.IsGenericMethod);
+
+ Console.WriteLine("TDerived = {0}", typeof(TDerived));
+ Console.WriteLine("method = {0}", method);
+ Console.WriteLine("method.DeclaringType = {0}", method.DeclaringType);
+ Console.WriteLine("method.IsGenericMethod = {0}", method.IsGenericMethod);
+ Console.WriteLine("method.IsGenericMethodDefinition = {0}", method.IsGenericMethodDefinition);
+
+ if (!method.IsGenericMethod)
+ return 1;
+ if (!method.IsGenericMethodDefinition)
+ return 2;
+ return 0;
+ }
+ }
+}
\ No newline at end of file
--- /dev/null
+using System;
+using System.Collections;
+using System.Threading;
+using System.Runtime.InteropServices;
+
+
+public class Bridge {
+ public int __test;
+ public string id;
+
+ ~Bridge () {
+ try {Console.WriteLine ("bridge {0} gone", id);} catch (Exception) {}
+ }
+}
+
+
+/*
+Test scenario:
+ Alloc a bridge and create a gc handle to it
+ Get it collected.
+ Create another one and see it steal the handle of the previous one.
+
+
+*/
+class Driver {
+ public static GCHandle weak_track_handle;
+ public static GCHandle weak_track_handle2;
+
+ static void CreateFirstBridge () {
+ Bridge b = new Bridge() {
+ __test = 0,
+ id = "first",
+ };
+ weak_track_handle = GCHandle.Alloc (b, GCHandleType.WeakTrackResurrection);
+ }
+
+ static void CreateSecondBridge () {
+ Bridge b = new Bridge() {
+ __test = 1,
+ id = "second",
+ };
+ weak_track_handle2 = GCHandle.Alloc (b, GCHandleType.WeakTrackResurrection);
+ }
+
+ static void DumpHandle (GCHandle h, string name) {
+ Console.WriteLine ("{0}:{1:X} alloc:{2} hasValue:{2}", name, (IntPtr)h, h.IsAllocated, h.Target == null);
+ }
+
+ static int Main () {
+ var t = new Thread (CreateFirstBridge);
+ t.Start ();
+ t.Join ();
+
+ GC.Collect ();
+ GC.WaitForPendingFinalizers ();
+ Console.WriteLine ("GC DONE");
+
+ DumpHandle (weak_track_handle, "weak-track1");
+
+ t = new Thread (CreateSecondBridge);
+ t.Start ();
+ t.Join ();
+
+ GC.Collect ();
+ GC.WaitForPendingFinalizers ();
+ Console.WriteLine ("GC DONE");
+ DumpHandle (weak_track_handle, "weak-track1");
+ DumpHandle (weak_track_handle2, "weak-track2");
+ Console.WriteLine ("DONE");
+
+ if ((IntPtr)weak_track_handle == (IntPtr)weak_track_handle2) {
+ Console.WriteLine ("FIRST HANDLE GOT DEALLOCATED!");
+ return 1;
+ }
+
+ return 0;
+ }
+}
%.exe: %.cil
- ilasm2 -out:$@ $<
+ ilasm -out:$@ $<
BatchCompiler.exe: BatchCompiler.cs
- gmcs -r:../../../mcs/class/lib/net_2_0/ilasm.exe BatchCompiler.cs
+ mcs -r:../../../mcs/class/lib/net_4_x/ilasm.exe BatchCompiler.cs
test_lib.dll: test_lib.cs
- gmcs test_lib.cs -target:library
+ mcs test_lib.cs -target:library
compile-stamp: generate-stamp BatchCompiler.exe test_lib.dll
for i in *.cs; do \
EXE="`echo $$i | cut -d. -f1`.exe"; \
DLL="`echo $$i | cut -d. -f1`.dll"; \
if ! [ -f $$EXE ] && ! [ -f $$DLL ]; then \
- gmcs /unsafe $$i; \
+ mcs /unsafe $$i; \
fi \
done
#MONO_PATH=../../../mcs/class/lib/net_2_0/ mono BatchCompiler.exe
then \
RES=3; \
fi; \
- if [ "$$FIRST" == "unverifiable" ] || [ "$FIRST" == "typeunverifiable" ]; \
+ if [ "$$FIRST" == "unverifiable" ] || [ "$$FIRST" == "typeunverifiable" ]; \
then \
RES=2; \
fi; \
fi; \
if [ "$$FIRST" == "strict" ]; \
then \
- #in strict more it must fail under strict check and pass under non-strict check \
+ echo "#in strict more it must fail under strict check and pass under non-strict check" >/dev/null; \
../../metadata/pedump --verify partial-md,error,warn,cls,code $$TEST.exe >/dev/null 2>/dev/null; \
R1=$$?; \
../../metadata/pedump --verify partial-md,error,warn,cls,code,non-strict $$TEST.exe >/dev/null 2>/dev/null; \
R2=$$?; \
if [ $$R1 != 2 ] && [ $$R1 != 3 ]; then \
echo "$$TEST is strict but did not fail under strict check, got $${R1} but expected 2 or 3"; \
- fi \
- #non-strict result \
+ fi; \
+ echo "#non-strict result" >/dev/null; \
if [ $$R2 != 0 ]; then \
echo "$$TEST is strict but did not pass under non-strict check, got $${R2} but expected 0"; \
- fi \
+ fi; \
elif [ "$$FIRST" == "typeunverifiable" ]; then \
- #in type unverifiable more it must fail under verifiable mode but it's ok under valid mode \
+ echo "#in type unverifiable more it must fail under verifiable mode but it's ok under valid mode" >/dev/null; \
../../metadata/pedump --verify partial-md,error,warn,cls,code $$TEST.exe >/dev/null 2>/dev/null; \
R1=$$?; \
../../metadata/pedump --verify partial-md,error,warn,cls,code,valid-only $$TEST.exe >/dev/null 2>/dev/null; \
R2=$$?; \
if [ $$R1 != 3 ]; then \
echo "$$TEST is type unverifiable but did not fail under verifiable check, got $${R1} but expected 3"; \
- fi \
- #type unverifiable result \
+ fi; \
+ echo "#type unverifiable result" >/dev/null; \
if [ $$R2 != 0 ]; then \
echo "$$TEST is type unverifiable but did not pass under non-strict check, got $${R2} but expected 0"; \
- fi \
+ fi; \
elif [ $$RES != 99 ]; then \
../../metadata/pedump --verify partial-md,error,warn,cls,code $$TEST.exe >/dev/null 2>/dev/null; \
R=$$?; \
if [ $$R != $$RES ]; then \
echo "$$TEST failed expected $$RES but got $$R"; \
- fi \
+ fi; \
fi; \
done
TEST_EXTENDS=$6
TEST_USE_SUB_CLASS=$7
-if [ "$TEST_EXTENDS" == "yes" ]; then
+if [ "$TEST_EXTENDS" = "yes" ]; then
TEST_EXTENDS="extends Class"
TEST_SUPER_TYPE="Class"
else
TEST_SUPER_TYPE="object"
fi
-if [ "$TEST_USE_SUB_CLASS" == "yes" ]; then
+if [ "$TEST_USE_SUB_CLASS" = "yes" ]; then
TEST_VAR_TYPE="ExampleClass"
else
TEST_VAR_TYPE="Class"
ret
}
}
-//EOF
\ No newline at end of file
+//EOF
TEST_BYTE_1=$4
-if [ "$TEST_BYTE_1" == "" ] ; then
+if [ "x$TEST_BYTE_1" = "x" ] ; then
TEST_BYTE_1="0";
fi
TEST_INIT_EXP=$6
TEST_INIT_VAL=$7
-if [ "$TEST_INIT_VAL" == "yes" ]; then
+if [ "$TEST_INIT_VAL" = "yes" ]; then
TEST_INIT="$TEST_INIT_EXP\n\t\stloc.1"
else
TEST_INIT=""
ldc.i4.0
ret
}
-//EOF
\ No newline at end of file
+//EOF
TEST_BEFORE_OP=$4
TEST_CONSTRAINT_TYPE=$5
-if [ "$TEST_CONSTRAINT_TYPE" == "" ]; then
+if [ "x$TEST_CONSTRAINT_TYPE" = "x" ]; then
TEST_CONSTRAINT_TYPE="IFace";
fi
TEST_OP=$4
TEST_FIN=$5
-if [ "$TEST_FIN" == "" ]; then
+if [ "x$TEST_FIN" = "x" ]; then
TEST_FIN="finally";
fi
TEST_INSTANCE_METHOD=$5
TEST_EXTRA_STUFF=$6
-if [ "$TEST_INSTANCE_METHOD" == "instance" ]; then
+if [ "$TEST_INSTANCE_METHOD" = "instance" ]; then
MEMBER_TEST_OP=$TEST_OP
MEMBER_TEST_LOAD_ARGS=$TEST_LOAD_ARGS
MEMBER_TEST_EXTRA_STUFF=$6
echo $TEST_OP | grep unbox > /dev/null;
-if [ "$?" == "0" ]; then
+if [ $? -eq 0 ]; then
TEST_CODE="
ldloc.0
box $TEST_TYPE";
ZZ=`echo $TEST_TYPE1 | grep "\&"`
T1_REF=$?
-if [ "$T1_REF" == "0" ]; then
+if [ $T1_REF -eq 0 ]; then
T1_NO_REF=`echo $TEST_TYPE1 | cut -d '\' -f 1`
INIT_LOCS=", $T1_NO_REF V_2"
INIT_IL="ldloca.s 2\n\tstloc.0"
ZZ=`echo $TEST_TYPE2 | grep "\&"`
T2_REF=$?
-if [ "$T2_REF" == "0" ]; then
+if [ $T2_REF -eq 0 ]; then
T2_NO_REF=`echo $TEST_TYPE2 | cut -d '\' -f 1`
- if [ "$T1_REF" == "0" ]; then
+ if [ $T1_REF -eq 0 ]; then
INIT_LOCS="$INIT_LOCS , $T2_NO_REF V_3"
INIT_IL="$INIT_IL \n\tldloca.s 3\n\tstloc.1"
else
TEST_LOAD_BASE=$7
-if [ "$TEST_EXTENDS" == "yes" ]; then
+if [ "$TEST_EXTENDS" = "yes" ]; then
TEST_EXTENDS="extends Owner\/Nested"
TEST_CONSTRUCTOR="call instance void Owner\/Nested::.ctor()"
else
TEST_CONSTRUCTOR="call instance void object::.ctor()"
fi
-if [ "$TEST_LOAD_BASE" == "yes" ]; then
+if [ "$TEST_LOAD_BASE" = "yes" ]; then
TEST_LOAD_REF="ldarg.0"
else
TEST_LOAD_REF="call class Owner\/Nested Owner::Create ()"
TARGET_TYPE="Test"
TEST_OTHER_CODE="call instance void TestClass::'.ctor'()"
-if [ "$TEST_TARGET_TYPE" == "other" ]; then
+if [ "$TEST_TARGET_TYPE" = "other" ]; then
TARGET_TYPE="TestSubClass"
TEST_OTHER_CODE=$TEST_CODE
TEST_CODE=""
RET_2_LOCAL="$TEST_RET_TYPE2"
RET_2_OP="ldloc 0"
-if [ "$TEST_RET_TYPE2" == "void" ]; then
+if [ "$TEST_RET_TYPE2" = "void" ]; then
RET_2_LOCAL="int32"
RET_2_OP="nop"
fi
}
"
-if [ "$TEST_USE_NATIVE" == "pinvoke" ]; then
+if [ "$TEST_USE_NATIVE" = "pinvoke" ]; then
LDFTN="ldftn $TCONV_2 ${TEST_RET_TYPE2} Driver::NativeMethod(${TEST_PARAM_TYPE2})"
CALLVIRT="nop"
MANAGED_METHOD=""
TEST_LOAD_BASE=$9
-if [ "$TEST_BASE_EXTENDS" == "yes" ]; then
+if [ "$TEST_BASE_EXTENDS" = "yes" ]; then
TEST_BASE_EXTENDS="extends Root"
TEST_BASE_CONSTRUCTOR="call instance void Root::.ctor()"
else
TEST_BASE_CONSTRUCTOR="call instance void object::.ctor()"
fi
-if [ "$TEST_NESTED_EXTENDS" == "yes" ]; then
+if [ "$TEST_NESTED_EXTENDS" = "yes" ]; then
TEST_NESTED_EXTENDS="extends Root\/Nested"
TEST_NESTED_CONSTRUCTOR="call instance void Root\/Nested::.ctor()"
else
TEST_NESTED_CONSTRUCTOR="call instance void object::.ctor()"
fi
-if [ "$TEST_LOAD_BASE" == "yes" ]; then
+if [ "$TEST_LOAD_BASE" = "yes" ]; then
TEST_LOAD_REF="ldarg.0"
else
TEST_LOAD_REF="call class Root\/Nested Root::Create ()"
TEST_WITH_FILTER_BLOCK=$5
TEST_WITH_FINALLY_BLOCK=$6
-if [ "$TEST_WITH_FILTER_BLOCK" == "yes" ]; then
+if [ "$TEST_WITH_FILTER_BLOCK" = "yes" ]; then
FILTER_BLOCK="
FILTER_BLOCK_3:
nop
FILTER_BLOCK="";
fi
-if [ "$TEST_WITH_FINALLY_BLOCK" == "yes" ]; then
+if [ "$TEST_WITH_FINALLY_BLOCK" = "yes" ]; then
FINALLY_BLOCK="
FINALLY_BLOCK_1:
nop
TEST_TYPE1=$4
TEST_TYPE2=$5
TEST_EMIT_CSTOR=$6
-if [ "${TEST_EMIT_CSTOR}" == "yes" ]; then
+if [ "${TEST_EMIT_CSTOR}" = "yes" ]; then
TEST_CSTOR="newobj instance void ${TEST_TYPE2}::.ctor()";
else
TEST_CSTOR="ldloc.0";
T1_REF=$?
LOCAL_INIT="";
-if [ "$T1_REF" == "0" ]; then
+if [ $T1_REF -eq 0 ]; then
T1_NO_REF=`echo $TEST_TYPE1 | cut -d '\' -f 1`
INIT_LOCS=", $T1_NO_REF V_0"
INIT_IL="ldloca.s 1\n\tstloc.0"
T1_REF=$?
LOCAL_INIT="";
-if [ "$T1_REF" == "0" ]; then
+if [ $T1_REF -eq 0 ]; then
T1_NO_REF=`echo $TEST_TYPE1 | cut -d '\' -f 1`
INIT_LOCS=", $T1_NO_REF V_0"
INIT_IL="ldloca.s 1\n\tstloc.0"
leave END
}"
-if [ "$TEST_BLOCK" == "catch" ]; then
+if [ "$TEST_BLOCK" = "catch" ]; then
TRY_MIDDLE="
leave END
} catch [mscorlib]System.NullReferenceException {"
TRY_END="
leave END
}"
-elif [ "$TEST_BLOCK" == "filter" ]; then
+elif [ "$TEST_BLOCK" = "filter" ]; then
TRY_MIDDLE="
leave END
} filter {"
} {
leave END
}"
-elif [ "$TEST_BLOCK" == "handler" ]; then
+elif [ "$TEST_BLOCK" = "handler" ]; then
TRY_MIDDLE="
leave END
} filter {
TRY_END="
leave END
}"
-elif [ "$TEST_BLOCK" == "finally" ]; then
+elif [ "$TEST_BLOCK" = "finally" ]; then
TRY_MIDDLE="
leave END
} finally {"
TRY_END="
endfinally
}"
-elif [ "$TEST_BLOCK" == "fault" ]; then
+elif [ "$TEST_BLOCK" = "fault" ]; then
TRY_MIDDLE="
leave END
} fault {"
TEST_MEMBER_ACCESS=$5
TEST_EXTENDS=$6
-if [ "$TEST_EXTENDS" == "yes" ]; then
+if [ "$TEST_EXTENDS" = "yes" ]; then
TEST_EXTENDS="extends Owner"
TEST_CONSTRUCTOR="call instance void Owner::.ctor()"
else
ldc.i4.0
ret
}
-//EOF
\ No newline at end of file
+//EOF
TEST_TYPE1=`echo $TEST_TYPE1 | $SED -s 's/&/\\\&/'`
TEST_TYPE2=`echo $TEST_TYPE2 | $SED -s 's/&/\\\&/'`
-if [ "$TEST_CREATE_FIELD" == "no" ]; then
+if [ "$TEST_CREATE_FIELD" = "no" ]; then
CLASS_FIELDS="";
else
CLASS_FIELDS=".field public ${TEST_TYPE1} fld\n .field public static ${TEST_TYPE1} sfld";
TEST_POS_2=$5
TEST_TYPE_0=$6
-if [ "$TEST_TYPE_0" == "" ] ; then
+if [ "x$TEST_TYPE_0" = "x" ] ; then
TEST_TYPE_0="int32";
fi
T2_REF=$?
LOCAL_INIT="";
-if [ "$T2_REF" == "0" ]; then
+if [ $T2_REF -eq 0 ]; then
T2_NO_REF=`echo $TEST_TYPE2 | cut -d '\' -f 1`
INIT_LOCS=", $T2_NO_REF V_2"
INIT_IL="ldloca.s 2\n\tstloc.1"
TEST_OP=$5
TEST_FIN=$6
-if [ "$TEST_FIN" == "" ]; then
+if [ "x$TEST_FIN" = "x" ]; then
TEST_FIN="finally";
fi
TEST_TYPE=$5
TEST_RET_TYPE=$6
-if [ "$TEST_RET_TYPE" == "" ]; then
+if [ "x$TEST_RET_TYPE" = "x" ]; then
TEST_RET_TYPE="void"
else
LD_RET_CODE="ldloc.0"
I=1
for OP in add div mul rem sub
do
- if [ "$OP" == "div" ] || [ "$OP" == "rem" ]; then
+ if [ "$OP" = "div" ] || [ "$OP" = "rem" ]; then
INIT="yes";
else
INIT="no";
I=1
for OP in div mul rem
do
- if [ "$OP" == "div" ] || [ "$OP" == "div" ]; then
+ if [ "$OP" = "div" ] || [ "$OP" = "div" ]; then
INIT="yes";
else
INIT="no";
I=1
for OP in div mul rem add
do
- if [ "$OP" == "div" ] || [ "$OP" == "div" ]; then
+ if [ "$OP" = "div" ] || [ "$OP" = "div" ]; then
INIT="yes";
else
INIT="no";
A=$1;
fi
- if [ "$A" == "bool&" ]; then
+ if [ "$A" = "bool&" ]; then
A="int8&";
- elif [ "$A" == "char&" ]; then
+ elif [ "$A" = "char&" ]; then
A="int16&";
fi
do
TA="$(fix $TYPE1)"
TB="$(fix $TYPE2)"
- if [ "$TA" == "$TB" ]; then
+ if [ "$TA" = "$TB" ]; then
./make_store_test.sh ref_coercion_${I} valid "$OP" "$TYPE1" "$TYPE2"
- elif [ "$TA" == "int32&" ] && [ "$TB" == "int&" ]; then
+ elif [ "$TA" = "int32&" ] && [ "$TB" = "int&" ]; then
./make_store_test.sh ref_coercion_${I} valid "$OP" "$TYPE1" "$TYPE2"
- elif [ "$TA" == "int&" ] && [ "$TB" == "int32&" ]; then
+ elif [ "$TA" = "int&" ] && [ "$TB" = "int32&" ]; then
./make_store_test.sh ref_coercion_${I} valid "$OP" "$TYPE1" "$TYPE2"
else
./make_store_test.sh ref_coercion_${I} unverifiable "$OP" "$TYPE1" "$TYPE2"
do
TA="$(fix $TYPE1)"
TB="$(fix $TYPE2)"
- if [ "$TA" == "$TB" ]; then
+ if [ "$TA" = "$TB" ]; then
./make_store_test.sh ref_coercion_${I} valid "$OP" "$TYPE1" "$TYPE2"
else
./make_store_test.sh ref_coercion_${I} unverifiable "$OP" "$TYPE1" "$TYPE2"
do
for TYPE2 in 'class ClassA&' 'class ClassB&' 'class InterfaceA&' 'class InterfaceB&' 'class ValueType&'
do
- if [ "$TYPE1" == "$TYPE2" ]; then
+ if [ "$TYPE1" = "$TYPE2" ]; then
./make_store_test.sh ref_coercion_${I} valid "$OP" "$TYPE1" "$TYPE2"
else
./make_store_test.sh ref_coercion_${I} unverifiable "$OP" "$TYPE1" "$TYPE2"
ZZ=`echo $TYPE2 | grep "*";`
T2_PTR=$?
- if (($T1_PTR == 0 || $T2_PTR == 0)); then
+ if [ $T1_PTR -eq 0 ] || [ $T2_PTR -eq 0 ]; then
./make_stack_merge_test.sh stack_merge_${I} unverifiable "$TYPE1" "$TYPE2"
- elif [ "$TYPE1" == "$TYPE2" ]; then
+ elif [ "$TYPE1" = "$TYPE2" ]; then
./make_stack_merge_test.sh stack_merge_${I} valid "$TYPE1" "$TYPE2"
- elif [ "$TYPE1" == "int32" ] && [ "$TYPE2" == "native int" ]; then
+ elif [ "$TYPE1" = "int32" ] && [ "$TYPE2" = "native int" ]; then
./make_stack_merge_test.sh stack_merge_${I} valid "$TYPE1" "$TYPE2"
- elif [ "$TYPE1" == "native int" ] && [ "$TYPE2" == "int32" ]; then
+ elif [ "$TYPE1" = "native int" ] && [ "$TYPE2" = "int32" ]; then
./make_stack_merge_test.sh stack_merge_${I} valid "$TYPE1" "$TYPE2"
- elif [ "$TYPE1" == "int32&" ] && [ "$TYPE2" == "native int&" ]; then
+ elif [ "$TYPE1" = "int32&" ] && [ "$TYPE2" = "native int&" ]; then
./make_stack_merge_test.sh stack_merge_${I} valid "$TYPE1" "$TYPE2"
- elif [ "$TYPE1" == "native int&" ] && [ "$TYPE2" == "int32&" ]; then
+ elif [ "$TYPE1" = "native int&" ] && [ "$TYPE2" = "int32&" ]; then
./make_stack_merge_test.sh stack_merge_${I} valid "$TYPE1" "$TYPE2"
else
./make_stack_merge_test.sh stack_merge_${I} unverifiable "$TYPE1" "$TYPE2"
MAX_PARAM_RESULT="unverifiable"
POPS="pop\npop\npop\npop\npop\npop\npop\npop\n"
- if [ "$OP" == "ldloc" ]; then
+ if [ "$OP" = "ldloc" ]; then
MAX_PARAM_RESULT="invalid"
LOCALS_1=$ARGS_1
do
for LOAD in yes no
do
- if ! ( [ "$NESTED" == "no" ] && [ "$LOAD" == "yes" ] ) ; then
+ if ! ( [ "$NESTED" = "no" ] && [ "$LOAD" = "yes" ] ) ; then
./make_double_nesting_test.sh double_nesting_access_check_${K}_$I $2 "$OP" $3 $4 $5 "$BASE" "$NESTED" "$LOAD"
K=`expr $K + 1`
fi
do
for LOAD in yes no
do
- if ! ( [ "$NESTED" == "no" ] && [ "$LOAD" == "yes" ] ) ; then
+ if ! ( [ "$NESTED" = "no" ] && [ "$LOAD" = "yes" ] ) ; then
EXPECT=unverifiable
- if [ "$FIRST" == "$K" ]; then
+ if [ "$FIRST" = "$K" ]; then
EXPECT=valid
fi
./make_double_nesting_test.sh double_nesting_access_check_${K}_$I $EXPECT "$OP" $2 $3 $4 "$BASE" "$NESTED" "$LOAD"
for NESTED in yes no
do
EXPECT=unverifiable
- if [ "$NESTED" == "yes" ]; then
+ if [ "$NESTED" = "yes" ]; then
EXPECT=valid
fi
./make_double_nesting_test.sh double_nesting_access_check_${K}_$I $EXPECT "$OP" $2 $3 $4 "$BASE" "$NESTED" yes
A=$1;
fi
- if [ "$A" == "bool" ]; then
+ if [ "$A" = "bool" ]; then
A="int8";
- elif [ "$A" == "char" ]; then
+ elif [ "$A" = "char" ]; then
A="int16";
fi
do
TYPE1="$(fix_ldobj $T1)"
TYPE2="$(fix_ldobj $T2)"
- if [ "$TYPE1" == "$TYPE2" ] ; then
+ if [ "$TYPE1" = "$TYPE2" ] ; then
./make_ldobj_test.sh ldobj_${I} valid "${T1}\&" "${T2}"
else
./make_ldobj_test.sh ldobj_${I} unverifiable "${T1}\&" "${T2}"
for TYPE1 in "int8" "bool" "int16" "char" "int32" "int64" "float64" "native int" "object" "string" "class Class" "valuetype MyStruct" "int32[]" "int32[,]" "int32*" "method int32 *(int32)" "class Template\`1<object>"
do
./make_store_indirect_test.sh indirect_store_bad_addr_r4_${I} unverifiable "stind.r4" "${TYPE1}\&" "float32"
- if [ "$TYPE1" == "float64" ]; then
+ if [ "$TYPE1" = "float64" ]; then
./make_store_indirect_test.sh indirect_store_good_val_r4_${I} valid "stind.r4" "float32\&" "${TYPE1}"
else
./make_store_indirect_test.sh indirect_store_bad_val_r4_${I} unverifiable "stind.r4" "float32\&" "${TYPE1}"
for TYPE1 in "int8" "bool" "int16" "char" "int32" "int64" "float32" "native int" "object" "string" "class Class" "valuetype MyStruct" "int32[]" "int32[,]" "int32*" "method int32 *(int32)" "class Template\`1<object>"
do
./make_store_indirect_test.sh indirect_store_bad_addr_r8_${I} unverifiable "stind.r8" "${TYPE1}\&" "float64"
- if [ "$TYPE1" == "float32" ]; then
+ if [ "$TYPE1" = "float32" ]; then
./make_store_indirect_test.sh indirect_store_good_val_r8_${I} valid "stind.r8" "float64\&" "${TYPE1}";
else
./make_store_indirect_test.sh indirect_store_bad_val_r8_${I} unverifiable "stind.r8" "float64\&" "${TYPE1}";
# Exception block branch tests (see 2.19)
-for I in {1..2};
+I=1; while [ $I -le 2 ]
do
./make_rethrow_test.sh rethrow_from_catch_${I} invalid ${I}
+ I=$((I + 1))
done
-for I in {3..10};
+I=3; while [ $I -le 10 ]
do
./make_rethrow_test.sh rethrow_from_catch_${I} valid ${I}
+ I=$((I + 1))
done
# endfinally / endfault
-for I in {1..7};
+I=1; while [ $I -le 7 ]
do
./make_endfinally_test.sh endfinally_block_${I} invalid finally ${I}
./make_endfinally_test.sh endfault_block_${I} invalid fault ${I}
+ I=$((I + 1))
done
-for I in {8..9};
+I=8; while [ $I -le 9 ]
do
./make_endfinally_test.sh endfinally_block_${I} valid finally ${I}
./make_endfinally_test.sh endfault_block_${I} valid fault ${I}
+ I=$((I + 1))
done
#stack can have stuff and endfinally or endfault will just empty it
./make_endfilter_test.sh endfilter_inside_protected_block_3 invalid 3 "ldc.i4.1\n\t\tendfilter"
./make_endfilter_test.sh endfilter_inside_protected_block_5 strict 5 "ldc.i4.1\n\t\tendfilter"
-for I in {2,4,6};
+for I in 2 4 6;
do
./make_endfilter_test.sh endfilter_inside_protected_block_${I} unverifiable ${I} "ldc.i4.1\n\t\tendfilter"
done
./make_leave_test.sh "filter_block_test_1" valid "1" "leave END" "$EXTRA"
#but not ok to leave finally or filter
-for I in {2..3};
-do
+I=2; while [ $I -le 3 ]; do
./make_leave_test.sh "filter_block_test_${I}" unverifiable "${I}" "leave END" "${EXTRA}_${I}"
+ I=$((I + 1))
done
#neither is to branch to invalid regions of code
# br.X
#valid tests
-for I in {1..6}; do
+I=1; while [ $I -le 6 ]; do
./make_branch_test.sh branch_inside_same_block_${I} valid ${I} "br BLOCK_${I}";
./make_branch_test.sh branch_inside_same_block_${I}_s valid ${I} "br.s BLOCK_${I}";
+ I=$((I + 1))
done
#branching outside of the protected block
-for I in {2..6}; do
+I=2; while [ $I -le 6 ]; do
./make_branch_test.sh branch_outside_protected_block_${I} unverifiable ${I} "br END";
+ I=$((I + 1))
done
#branching to a protected block from the outside
-for I in {2..6}; do
- if [ "$I" == "4" ]; then
+I=2; while [ $I -le 6 ]; do
+ if [ $I -eq 4 ]; then
./make_branch_test.sh branch_inside_protected_block_from_outside_${I}_finally invalid 1 "br BLOCK_${I}" "finally";
./make_branch_test.sh branch_inside_protected_block_from_outside_${I}_fault invalid 1 "br BLOCK_${I}" "fault";
else
./make_branch_test.sh branch_inside_protected_block_from_outside_${I} unverifiable 1 "br BLOCK_${I}";
fi
+ I=$((I + 1))
done
#TODO test the encoding of the switch table
# switch
#valid tests
-for I in {1..6}; do
+I=1; while [ $I -le 6 ]; do
./make_switch_test.sh switch_inside_same_block_${I} valid ${I} "ldloc.0" "switch (BLOCK_${I}, BLOCK_${I}_B)";
+ I=$((I + 1))
done
./make_switch_test.sh switch_with_native_int_on_stack valid 1 "ldloc.1" "switch (BLOCK_1, BLOCK_1_B)";
#branching outside of the protected block
-for I in {2..6}; do
+I=2; while [ $I -le 6 ]; do
./make_switch_test.sh switch_outside_protected_block_${I} unverifiable ${I} "ldloc.0" "switch (END, BLOCK_1, BLOCK_1_B)";
+ I=$((I + 1))
done
#branching to a protected block from the outside
-for I in {2..6}; do
- if [ "$I" == "4" ]; then
+I=2; while [ $I -le 6 ]; do
+ if [ $I -eq 4 ]; then
./make_switch_test.sh switch_inside_protected_block_from_outside_${I}_finally invalid 1 "ldloc.0" "switch (BLOCK_${I}, BLOCK_${I}_B)" "finally";
./make_switch_test.sh switch_inside_protected_block_from_outside_${I}_fault invalid 1 "ldloc.0" "switch (BLOCK_${I}, BLOCK_${I}_B)" "fault";
else
./make_switch_test.sh switch_inside_protected_block_from_outside_${I} unverifiable 1 "ldloc.0" "switch (BLOCK_${I}, BLOCK_${I}_B)";
fi
+ I=$((I + 1))
done
#TODO branching out of range (FIX ilasm first)
./make_overlapped_test.sh ref_only_overlapping_5 invalid 0 0 8 int32
#invalid opcodes
-for I in {166..178}
+I=166; while [ $I -le 178 ]
do
./make_bad_op_test.sh bad_op_$I invalid $I
+ I=$((I + 1))
done
-for I in {187..193}
+I=187; while [ $I -le 193 ]
do
./make_bad_op_test.sh bad_op_$I invalid $I
+ I=$((I + 1))
done
-for I in {196..207}
+I=196; while [ $I -le 207 ]
do
./make_bad_op_test.sh bad_op_$I invalid $I
+ I=$((I + 1))
done
-for I in {225..253}
+I=225; while [ $I -le 253 ]
do
./make_bad_op_test.sh bad_op_$I invalid $I
+ I=$((I + 1))
done
./make_bad_op_test.sh bad_op_xff invalid 255
-for I in {35..255}
+I=35; while [ $I -le 255 ]
do
./make_bad_op_test.sh bad_op_with_prefix_$I invalid 0xFE $I
+ I=$((I + 1))
done
./make_generic_argument_constraints_test.sh type_mixed_3 valid "" "(IfaceA)"
./make_generic_argument_constraints_test.sh type_mixed_4 valid "" "class (IfaceA)"
-
-
TEST_POST_OP=$5
TEST_NO_BOX=$6
TEST_BOX="box ${TEST_TYPE1}";
-if [ "${TEST_NO_BOX}" == "yes" ]; then
+if [ "x${TEST_NO_BOX}" = "xyes" ]; then
TEST_BOX="";
fi
#define LOCK_FREE_ALLOC_SB_HEADER_SIZE (sizeof (MonoLockFreeAllocator))
#define LOCK_FREE_ALLOC_SB_USABLE_SIZE(block_size) ((block_size) - LOCK_FREE_ALLOC_SB_HEADER_SIZE)
-void mono_lock_free_allocator_init_size_class (MonoLockFreeAllocSizeClass *sc, unsigned int slot_size, unsigned int block_size);
-void mono_lock_free_allocator_init_allocator (MonoLockFreeAllocator *heap, MonoLockFreeAllocSizeClass *sc);
+MONO_API void mono_lock_free_allocator_init_size_class (MonoLockFreeAllocSizeClass *sc, unsigned int slot_size, unsigned int block_size);
+MONO_API void mono_lock_free_allocator_init_allocator (MonoLockFreeAllocator *heap, MonoLockFreeAllocSizeClass *sc);
-gpointer mono_lock_free_alloc (MonoLockFreeAllocator *heap);
-void mono_lock_free_free (gpointer ptr, size_t block_size);
+MONO_API gpointer mono_lock_free_alloc (MonoLockFreeAllocator *heap);
+MONO_API void mono_lock_free_free (gpointer ptr, size_t block_size);
-gboolean mono_lock_free_allocator_check_consistency (MonoLockFreeAllocator *heap);
+MONO_API gboolean mono_lock_free_allocator_check_consistency (MonoLockFreeAllocator *heap);
#endif
/*HACK, move this to an eventual mono-signal.c*/
#if defined( __linux__) || defined(__sun) || defined(__APPLE__) || defined(__NetBSD__) || \
defined(__FreeBSD__) || defined(__OpenBSD__)
-#ifdef HAVE_SIGACTION
+#if defined(HAVE_SIGACTION) || defined(__APPLE__) // the __APPLE__ check is required for the tvos simulator, which has ucontext_t but not sigaction
#define MONO_SIGNAL_USE_UCONTEXT_T 1
#endif
#endif
#if !defined( HOST_WIN32 ) && !defined(__native_client__) && !defined(__native_client_codegen__)
-#ifdef HAVE_SIGACTION
+#if defined(HAVE_SIGACTION) || defined(__APPLE__) // the __APPLE__ check is required for the tvos simulator, which has ucontext_t but not sigaction
#define MONO_SIGNAL_USE_UCONTEXT_T 1
#endif
}
static const char
-section_names [][10] = {
+section_names [][12] = {
"JIT",
"GC",
"Metadata",
"Security",
"Runtime",
"System",
+ "", // MONO_COUNTER_PERFCOUNTERS - not used.
+ "Profiler",
};
static void
MONO_COUNTER_RUNTIME = 1 << 13,
MONO_COUNTER_SYSTEM = 1 << 14,
MONO_COUNTER_PERFCOUNTERS = 1 << 15,
+ MONO_COUNTER_PROFILER = 1 << 16,
MONO_COUNTER_LAST_SECTION,
/* Unit, bits 24-27 (4 bits) */
MONO_BEGIN_DECLS
enum {
+ MONO_DL_EAGER = 0,
MONO_DL_LAZY = 1,
MONO_DL_LOCAL = 2,
MONO_DL_MASK = 3
#define return_if_nok(error) do { if (!is_ok ((error))) return; } while (0)
#define return_val_if_nok(error,val) do { if (!is_ok ((error))) return (val); } while (0)
+/* Only use this in icalls */
+#define return_val_and_set_pending_if_nok(error,value) \
+ if (mono_error_set_pending_exception ((error))) \
+ return (value);
+
void
mono_error_assert_ok_pos (MonoError *error, const char* filename, int lineno) MONO_LLVM_INTERNAL;
WINBASEAPI WINBOOL WINAPI InitOnceComplete(LPINIT_ONCE lpInitOnce, DWORD dwFlags, LPVOID lpContext);
WINBASEAPI WINBOOL WINAPI InitOnceExecuteOnce(PINIT_ONCE InitOnce, PINIT_ONCE_FN InitFn, PVOID Parameter, LPVOID *Context);
+/* https://msdn.microsoft.com/en-us/library/windows/desktop/ms683477(v=vs.85).aspx */
+WINBASEAPI BOOL WINAPI InitializeCriticalSectionEx(LPCRITICAL_SECTION lpCriticalSection, DWORD dwSpinCount, DWORD Flags);
+
+#define CRITICAL_SECTION_NO_DEBUG_INFO 0x01000000
+
#endif /* defined __MINGW32__ && !defined __MINGW64_VERSION_MAJOR && (_WIN32_WINNT >= 0x0600) */
typedef CRITICAL_SECTION mono_mutex_t;
static inline int
mono_os_mutex_init (mono_mutex_t *mutex)
{
- InitializeCriticalSection (mutex);
+ InitializeCriticalSectionEx (mutex, 0, CRITICAL_SECTION_NO_DEBUG_INFO);
return 0;
}
static inline int
mono_os_mutex_init_recursive (mono_mutex_t *mutex)
{
- InitializeCriticalSection (mutex);
+ InitializeCriticalSectionEx (mutex, 0, CRITICAL_SECTION_NO_DEBUG_INFO);
return 0;
}
#if defined(_POSIX_VERSION)
#include <sys/errno.h>
#include <sys/param.h>
+#include <errno.h>
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#define UCONTEXT_REG_RSI(ctx) (((ucontext_t*)(ctx))->uc_mcontext.__gregs [_REG_RSI])
#define UCONTEXT_REG_RDI(ctx) (((ucontext_t*)(ctx))->uc_mcontext.__gregs [_REG_RDI])
#define UCONTEXT_REG_RIP(ctx) (((ucontext_t*)(ctx))->uc_mcontext.__gregs [_REG_RIP])
+ #define UCONTEXT_REG_R8(ctx) (((ucontext_t*)(ctx))->uc_mcontext.__gregs [_REG_R8])
+ #define UCONTEXT_REG_R9(ctx) (((ucontext_t*)(ctx))->uc_mcontext.__gregs [_REG_R9])
+ #define UCONTEXT_REG_R10(ctx) (((ucontext_t*)(ctx))->uc_mcontext.__gregs [_REG_R10])
+ #define UCONTEXT_REG_R11(ctx) (((ucontext_t*)(ctx))->uc_mcontext.__gregs [_REG_R11])
#define UCONTEXT_REG_R12(ctx) (((ucontext_t*)(ctx))->uc_mcontext.__gregs [_REG_R12])
#define UCONTEXT_REG_R13(ctx) (((ucontext_t*)(ctx))->uc_mcontext.__gregs [_REG_R13])
#define UCONTEXT_REG_R14(ctx) (((ucontext_t*)(ctx))->uc_mcontext.__gregs [_REG_R14])
#define UCONTEXT_REG_R11(ctx) (((arm_ucontext*)(ctx))->sig_ctx.arm_fp)
#define UCONTEXT_REG_R12(ctx) (((arm_ucontext*)(ctx))->sig_ctx.arm_ip)
#define UCONTEXT_REG_CPSR(ctx) (((arm_ucontext*)(ctx))->sig_ctx.arm_cpsr)
+#elif defined(__NetBSD__)
+ typedef ucontext_t arm_ucontext;
+
+ #define UCONTEXT_REG_PC(ctx) (((ucontext_t*)(ctx))->uc_mcontext.__gregs[_REG_PC])
+ #define UCONTEXT_REG_SP(ctx) (((ucontext_t*)(ctx))->uc_mcontext.__gregs[_REG_SP])
+ #define UCONTEXT_REG_LR(ctx) (((ucontext_t*)(ctx))->uc_mcontext.__gregs[_REG_LR])
+ #define UCONTEXT_REG_R0(ctx) (((ucontext_t*)(ctx))->uc_mcontext.__gregs[_REG_R0])
+ #define UCONTEXT_REG_R1(ctx) (((ucontext_t*)(ctx))->uc_mcontext.__gregs[_REG_R1])
+ #define UCONTEXT_REG_R2(ctx) (((ucontext_t*)(ctx))->uc_mcontext.__gregs[_REG_R2])
+ #define UCONTEXT_REG_R3(ctx) (((ucontext_t*)(ctx))->uc_mcontext.__gregs[_REG_R3])
+ #define UCONTEXT_REG_R4(ctx) (((ucontext_t*)(ctx))->uc_mcontext.__gregs[_REG_R4])
+ #define UCONTEXT_REG_R5(ctx) (((ucontext_t*)(ctx))->uc_mcontext.__gregs[_REG_R5])
+ #define UCONTEXT_REG_R6(ctx) (((ucontext_t*)(ctx))->uc_mcontext.__gregs[_REG_R6])
+ #define UCONTEXT_REG_R7(ctx) (((ucontext_t*)(ctx))->uc_mcontext.__gregs[_REG_R7])
+ #define UCONTEXT_REG_R8(ctx) (((ucontext_t*)(ctx))->uc_mcontext.__gregs[_REG_R8])
+ #define UCONTEXT_REG_R9(ctx) (((ucontext_t*)(ctx))->uc_mcontext.__gregs[_REG_R9])
+ #define UCONTEXT_REG_R10(ctx) (((ucontext_t*)(ctx))->uc_mcontext.__gregs[_REG_R10])
+ #define UCONTEXT_REG_R11(ctx) (((ucontext_t*)(ctx))->uc_mcontext.__gregs[_REG_R11])
+ #define UCONTEXT_REG_R12(ctx) (((ucontext_t*)(ctx))->uc_mcontext.__gregs[_REG_R12])
+ #define UCONTEXT_REG_CPSR(ctx) (((ucontext_t*)(ctx))->uc_mcontext.__gregs[_REG_CPSR])
+ #define UCONTEXT_REG_VFPREGS(ctx) (((ucontext_t*)(ctx))->uc_mcontext.__gregs[_REG_VFPREGS])
#endif
#elif defined(TARGET_ARM64)
n [62] = '\0';
pthread_setname_np (n);
}
+#elif defined (__NetBSD__)
+ if (!name) {
+ pthread_setname_np (tid, "%s", (void*)"");
+ } else {
+ char n [PTHREAD_MAX_NAMELEN_NP];
+
+ strncpy (n, name, PTHREAD_MAX_NAMELEN_NP);
+ n [PTHREAD_MAX_NAMELEN_NP - 1] = '\0';
+ pthread_setname_np (tid, "%s", (void*)n);
+ }
#elif defined (HAVE_PTHREAD_SETNAME_NP)
if (!name) {
pthread_setname_np (tid, "");
# only enable the mobile profiles and mobile_static on the main architectures
fi
+if [ -x "/usr/bin/dpkg-architecture" ];
+ then
+ EXTRA_CONF_FLAGS="$EXTRA_CONF_FLAGS --host=`/usr/bin/dpkg-architecture -qDEB_HOST_GNU_TYPE`"
+ #force build arch = dpkg arch, sometimes misdetected
+fi
+
${TESTCMD} --label=configure --timeout=60m --fatal ./autogen.sh $EXTRA_CONF_FLAGS
if [[ ${label} == w* ]];
then
--- /dev/null
+.stamp-clone
+CppSharp
+*.exe
+*.h
+*.exe.mdb
--- /dev/null
+CPPSHARP_DIR = CppSharp
+
+CPPSHARP_REFS = -r:$(CPPSHARP_DIR)/CppSharp.dll \
+ -r:$(CPPSHARP_DIR)/CppSharp.AST.dll \
+ -r:$(CPPSHARP_DIR)/CppSharp.Parser.CSharp.dll \
+ -r:$(CPPSHARP_DIR)/CppSharp.Generator.dll
+
+SRC_ROOT = ../..
+
+MONO_OPTIONS_SRC = $(SRC_ROOT)/mcs/class/Mono.Options/Mono.Options/Options.cs
+
+.stamp-clone:
+ @if [ ! -d $(CPPSHARP_DIR) ]; then \
+ git clone git@github.com:xamarin/CppSharpBinaries.git $(CPPSHARP_DIR); \
+ touch $@; \
+ fi
+
+MonoAotOffsetsDumper.exe: .stamp-clone MonoAotOffsetsDumper.cs $(MONO_OPTIONS_SRC)
+ mcs MonoAotOffsetsDumper.cs /debug /nowarn:0436 $(MONO_OPTIONS_SRC) $(CPPSHARP_REFS)
+
+.PHONY: clean
+clean:
+ rm MonoAotOffsetsDumper.exe
+
+dump: MonoAotOffsetsDumper.exe
+ MONO_PATH=$(CPPSHARP_DIR) mono MonoAotOffsetsDumper.exe
+
+update:
+ @if [ -f object-offsets.h ]; then rm object-offsets.h; fi;
+ @for f in *.h; do \
+ echo "Processing $$f.."; \
+ echo "#include \"$$f\"" >> object-offsets1.h; \
+ done
+ @cp *.h ../mono/metadata
+
+gen-proj:
+ $(CPPSHARP_DIR)/premake5 vs2012
+
+all: MonoAotOffsetsDumper.exe
\ No newline at end of file
--- /dev/null
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Text.RegularExpressions;
+using CppSharp.AST;
+using CppSharp.AST.Extensions;
+using CppSharp.Parser;
+
+namespace CppSharp
+{
+ /**
+ * This tool dumps the offsets of structures used in the Mono VM needed
+ * by the AOT compiler for cross-compiling code to target platforms
+ * different than the host the compiler is being invoked on.
+ *
+ * It takes two arguments: the path to your clone of the Mono repo and
+ * the path to the root of Android NDK.
+ */
+ static class MonoAotOffsetsDumper
+ {
+ static string MonoDir = @"";
+
+ static List<string> Abis = new List<string> ();
+ static string OutputDir;
+
+ static string MonodroidDir = @"";
+ static string MaccoreDir = @"";
+
+ public enum TargetPlatform
+ {
+ Android,
+ iOS,
+ WatchOS,
+ }
+
+ public class Target
+ {
+ public Target()
+ {
+ Defines = new List<string>();
+ Arguments = new List<string>();
+ }
+
+ public Target(Target target)
+ {
+ Platform = target.Platform;
+ Triple = target.Triple;
+ Build = target.Build;
+ Defines = target.Defines;
+ Arguments = target.Arguments;
+ }
+
+ public TargetPlatform Platform;
+ public string Triple;
+ public string Build;
+ public List<string> Defines;
+ public List<string> Arguments;
+ };
+
+ public static List<Target> Targets = new List<Target>();
+
+ public static IEnumerable<Target> AndroidTargets
+ {
+ get { return Targets.Where ((t) => t.Platform == TargetPlatform.Android); }
+ }
+
+ public static IEnumerable<Target> DarwinTargets
+ {
+ get
+ {
+ return Targets.Where ((t) => t.Platform == TargetPlatform.iOS ||
+ t.Platform == TargetPlatform.WatchOS);
+ }
+ }
+
+ public static IEnumerable<Target> iOSTargets
+ {
+ get
+ {
+ return Targets.Where ((t) => t.Platform == TargetPlatform.iOS);
+ }
+ }
+
+ public static void SetupAndroidTargets()
+ {
+ Targets.Add (new Target {
+ Platform = TargetPlatform.Android,
+ Triple = "i686-none-linux-android",
+ Build = "mono-x86",
+ Defines = { "TARGET_X86" }
+ });
+
+ Targets.Add (new Target {
+ Platform = TargetPlatform.Android,
+ Triple = "x86_64-none-linux-android",
+ Build = "mono-x86_64",
+ Defines = { "TARGET_AMD64" }
+ });
+
+ Targets.Add (new Target {
+ Platform = TargetPlatform.Android,
+ Triple = "armv5-none-linux-androideabi",
+ Build = "mono-armv6",
+ Defines = { "TARGET_ARM", "ARM_FPU_VFP", "HAVE_ARMV5" }
+ });
+
+ Targets.Add (new Target {
+ Platform = TargetPlatform.Android,
+ Triple = "armv7-none-linux-androideabi",
+ Build = "mono-armv7",
+ Defines = { "TARGET_ARM", "ARM_FPU_VFP", "HAVE_ARMV5", "HAVE_ARMV6",
+ "HAVE_ARMV7"
+ }
+ });
+
+ Targets.Add (new Target {
+ Platform = TargetPlatform.Android,
+ Triple = "aarch64-v8a-linux-android",
+ Build = "mono-aarch64",
+ Defines = { "TARGET_ARM64" }
+ });
+
+ /*Targets.Add(new Target {
+ Platform = TargetPlatform.Android,
+ Triple = "mipsel-none-linux-android",
+ Build = "mono-mips",
+ Defines = { "TARGET_MIPS", "__mips__" }
+ });*/
+
+ foreach (var target in AndroidTargets)
+ target.Defines.AddRange (new string[] { "PLATFORM_ANDROID",
+ "TARGET_ANDROID", "MONO_CROSS_COMPILE", "USE_MONO_CTX"
+ });
+ }
+
+ public static void SetupiOSTargets()
+ {
+ Targets.Add(new Target {
+ Platform = TargetPlatform.iOS,
+ Triple = "arm-apple-darwin10",
+ Build = "target7",
+ Defines = { "TARGET_ARM", "ARM_FPU_VFP", "HAVE_ARMV5" }
+ });
+
+ Targets.Add(new Target {
+ Platform = TargetPlatform.iOS,
+ Triple = "aarch64-apple-darwin10",
+ Build = "target64",
+ Defines = { "TARGET_ARM64" }
+ });
+
+ foreach (var target in iOSTargets) {
+ target.Defines.AddRange (new string[] { "PLATFORM_DARWIN",
+ "TARGET_IOS", "TARGET_MACH", "MONO_CROSS_COMPILE", "USE_MONO_CTX",
+ "_XOPEN_SOURCE"
+ });
+ }
+
+ Targets.Add(new Target {
+ Platform = TargetPlatform.WatchOS,
+ Triple = "armv7k-apple-darwin",
+ Build = "targetwatch",
+ Defines = { "TARGET_ARM", "ARM_FPU_VFP", "HAVE_ARMV5" }
+ });
+
+ foreach (var target in DarwinTargets) {
+ target.Defines.AddRange (new string[] { "PLATFORM_DARWIN",
+ "TARGET_IOS", "TARGET_MACH", "MONO_CROSS_COMPILE", "USE_MONO_CTX",
+ "_XOPEN_SOURCE"
+ });
+ }
+ }
+
+ static bool GetParentSubDirectoryPath(string parent, out string subdir)
+ {
+ var directory = Directory.GetParent(Directory.GetCurrentDirectory());
+
+ while (directory != null) {
+ var path = Path.Combine(directory.FullName, parent);
+
+ if (Directory.Exists (path)) {
+ subdir = path;
+ return true;
+ }
+
+ directory = directory.Parent;
+ }
+
+ subdir = null;
+ return false;
+ }
+
+ public static void Main(string[] args)
+ {
+ ParseCommandLineArgs(args);
+
+ string monodroidDir;
+ if (!Directory.Exists (MonodroidDir) &&
+ GetParentSubDirectoryPath ("monodroid", out monodroidDir)) {
+ MonodroidDir = Path.Combine (monodroidDir);
+ }
+
+ if (Directory.Exists (MonodroidDir))
+ SetupAndroidTargets();
+
+ string maccoreDir;
+ if (!Directory.Exists (MaccoreDir) &&
+ GetParentSubDirectoryPath ("maccore", out maccoreDir)) {
+ MaccoreDir = Path.Combine (maccoreDir);
+ }
+
+ if (Directory.Exists(MaccoreDir))
+ SetupiOSTargets();
+
+ foreach (var target in Targets)
+ {
+ if (Abis.Any() && !Abis.Any (target.Triple.Contains))
+ continue;
+
+ Console.WriteLine();
+ Console.WriteLine("Processing triple: {0}", target.Triple);
+
+ var options = new DriverOptions();
+
+ var log = new TextDiagnosticPrinter();
+ var driver = new Driver(options, log);
+
+ Setup(driver, target);
+ driver.Setup();
+
+ BuildParseOptions(driver, target);
+ if (!driver.ParseCode())
+ return;
+
+ Dump(driver.ASTContext, driver.TargetInfo, target);
+ }
+ }
+
+ static void BuildParseOptions(Driver driver, Target target)
+ {
+ foreach (var header in driver.Options.Headers)
+ {
+ var source = driver.Project.AddFile(header);
+ source.Options = driver.BuildParseOptions(source);
+
+ if (header.Contains ("mini"))
+ continue;
+
+ source.Options.addDefines ("HAVE_SGEN_GC");
+ source.Options.addDefines ("HAVE_MOVING_COLLECTOR");
+ }
+ }
+
+ static string GetAndroidNdkPath()
+ {
+ // Find the Android NDK's path from Monodroid's config.
+ var configFile = Path.Combine(MonodroidDir, "env.config");
+ if (!File.Exists(configFile))
+ throw new Exception("Expected a valid Monodroid environment config file at " + configFile);
+
+ var config = File.ReadAllText(configFile);
+ var match = Regex.Match(config, @"ANDROID_NDK_PATH\s*:=\s(.*)");
+ return match.Groups[1].Value.Trim();
+ }
+
+ static void ParseCommandLineArgs(string[] args)
+ {
+ var showHelp = false;
+
+ var options = new Mono.Options.OptionSet () {
+ { "abi=", "ABI triple to generate", v => Abis.Add(v) },
+ { "o|out=", "output directory", v => OutputDir = v },
+ { "maccore=", "include directory", v => MaccoreDir = v },
+ { "monodroid=", "include directory", v => MonodroidDir = v },
+ { "mono=", "include directory", v => MonoDir = v },
+ { "h|help", "show this message and exit", v => showHelp = v != null },
+ };
+
+ try {
+ options.Parse (args);
+ }
+ catch (Mono.Options.OptionException e) {
+ Console.WriteLine (e.Message);
+ Environment.Exit(0);
+ }
+
+ if (showHelp)
+ {
+ // Print usage and exit.
+ Console.WriteLine("{0} [--abi=triple] [--out=dir] "
+ + "[--monodroid/maccore=dir] [--mono=dir]",
+ AppDomain.CurrentDomain.FriendlyName);
+ Environment.Exit(0);
+ }
+ }
+
+ static void Setup(Driver driver, Target target)
+ {
+ var options = driver.Options;
+ options.DryRun = true;
+ options.Verbose = false;
+ options.LibraryName = "Mono";
+ options.MicrosoftMode = false;
+ options.addArguments("-xc");
+ options.addArguments("-std=gnu99");
+ options.addDefines("CPPSHARP");
+
+ foreach (var define in target.Defines)
+ options.addDefines(define);
+
+ SetupToolchainPaths(driver, target);
+
+ SetupMono(options, target);
+ }
+
+ static void SetupMono(DriverOptions options, Target target)
+ {
+ string targetPath;
+ switch (target.Platform) {
+ case TargetPlatform.Android:
+ targetPath = Path.Combine (MonodroidDir, "builds");
+ break;
+ case TargetPlatform.WatchOS:
+ case TargetPlatform.iOS:
+ targetPath = Path.Combine (MaccoreDir, "builds");
+ break;
+ default:
+ throw new ArgumentOutOfRangeException ();
+ }
+
+ if (!Directory.Exists (MonoDir)) {
+ MonoDir = Path.GetFullPath (Path.Combine (targetPath, "../../mono"));
+ }
+
+ var targetBuild = Path.Combine(targetPath, target.Build);
+
+ if (!Directory.Exists(targetBuild))
+ throw new Exception(string.Format("Could not find the target build directory: {0}", targetBuild));
+
+ var includeDirs = new[]
+ {
+ targetBuild,
+ Path.Combine(targetBuild, "eglib", "src"),
+ MonoDir,
+ Path.Combine(MonoDir, "mono"),
+ Path.Combine(MonoDir, "mono", "mini"),
+ Path.Combine(MonoDir, "eglib", "src")
+ };
+
+ foreach (var inc in includeDirs)
+ options.addIncludeDirs(inc);
+
+ var filesToParse = new[]
+ {
+ Path.Combine(MonoDir, "mono", "metadata", "metadata-cross-helpers.c"),
+ Path.Combine(MonoDir, "mono", "mini", "mini-cross-helpers.c"),
+ };
+
+ foreach (var file in filesToParse)
+ options.Headers.Add(file);
+ }
+
+ static void SetupMSVC(Driver driver, string triple)
+ {
+ var options = driver.Options;
+
+ options.Abi = Parser.AST.CppAbi.Microsoft;
+ options.MicrosoftMode = true;
+
+ var systemIncludeDirs = new[]
+ {
+ @"C:\Program Files (x86)\Windows Kits\8.1\Include\um",
+ @"C:\Program Files (x86)\Windows Kits\8.1\Include\shared"
+ };
+
+ foreach (var inc in systemIncludeDirs)
+ options.addSystemIncludeDirs(inc);
+
+ options.addDefines("HOST_WIN32");
+ }
+
+ static void SetupToolchainPaths(Driver driver, Target target)
+ {
+ switch (target.Platform) {
+ case TargetPlatform.Android:
+ SetupAndroidNDK(driver, target);
+ break;
+ case TargetPlatform.iOS:
+ case TargetPlatform.WatchOS:
+ SetupXcode(driver, target);
+ break;
+ default:
+ throw new ArgumentOutOfRangeException ();
+ }
+ }
+
+ static string GetArchFromTriple(string triple)
+ {
+ if (triple.Contains("mips"))
+ return "mips";
+
+ if (triple.Contains("arm64") || triple.Contains("aarch64"))
+ return "arm64";
+
+ if (triple.Contains("arm"))
+ return "arm";
+
+ if (triple.Contains("i686"))
+ return "x86";
+
+ if (triple.Contains("x86_64"))
+ return "x86_64";
+
+ throw new Exception("Unknown architecture from triple: " + triple);
+ }
+
+ static string GetXcodeToolchainPath()
+ {
+ var toolchains = Directory.EnumerateDirectories("/Applications", "Xcode*")
+ .ToList();
+ toolchains.Sort();
+
+ var toolchainPath = toolchains.LastOrDefault();
+ if (toolchainPath == null)
+ throw new Exception("Could not find a valid Xcode SDK");
+
+ return toolchainPath;
+ }
+
+ static string GetXcodeBuiltinIncludesFolder()
+ {
+ var toolchainPath = GetXcodeToolchainPath();
+
+ var toolchains = Directory.EnumerateDirectories(Path.Combine(toolchainPath,
+ "Contents/Developer/Toolchains")).ToList();
+ toolchains.Sort();
+
+ toolchainPath = toolchains.LastOrDefault();
+ if (toolchainPath == null)
+ throw new Exception("Could not find a valid Xcode toolchain");
+
+ var includePaths = Directory.EnumerateDirectories(Path.Combine(toolchainPath,
+ "usr/lib/clang")).ToList();
+ var includePath = includePaths.LastOrDefault();
+
+ if (includePath == null)
+ throw new Exception("Could not find a valid Clang include folder");
+
+ return Path.Combine(includePath, "include");
+ }
+
+ static string GetXcodeiOSIncludesFolder()
+ {
+ var toolchainPath = GetXcodeToolchainPath();
+
+ var sdkPaths = Directory.EnumerateDirectories(Path.Combine(toolchainPath,
+ "Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs")).ToList();
+ var sdkPath = sdkPaths.LastOrDefault();
+
+ if (sdkPath == null)
+ throw new Exception("Could not find a valid iPhone SDK");
+
+ return Path.Combine(sdkPath, "usr/include");
+ }
+
+ static string GetXcodeWatchOSIncludesFolder()
+ {
+ var toolchainPath = GetXcodeToolchainPath();
+
+ var sdkPaths = Directory.EnumerateDirectories(Path.Combine(toolchainPath,
+ "Contents/Developer/Platforms/WatchOS.platform/Developer/SDKs")).ToList();
+ var sdkPath = sdkPaths.LastOrDefault();
+
+ if (sdkPath == null)
+ throw new Exception("Could not find a valid WatchOS SDK");
+
+ return Path.Combine(sdkPath, "usr/include");
+ }
+
+ static void SetupXcode(Driver driver, Target target)
+ {
+ var options = driver.Options;
+
+ var builtinsPath = GetXcodeBuiltinIncludesFolder();
+ string includePath;
+
+ switch (target.Platform) {
+ case TargetPlatform.iOS:
+ includePath = GetXcodeiOSIncludesFolder();
+ break;
+ case TargetPlatform.WatchOS:
+ includePath = GetXcodeWatchOSIncludesFolder();
+ break;
+ default:
+ throw new ArgumentOutOfRangeException ();
+ }
+
+ options.addSystemIncludeDirs(builtinsPath);
+ options.addSystemIncludeDirs(includePath);
+
+ options.NoBuiltinIncludes = true;
+ options.NoStandardIncludes = true;
+ options.TargetTriple = target.Triple;
+ }
+
+ static string GetAndroidHostToolchainPath()
+ {
+ var androidNdkPath = GetAndroidNdkPath ();
+ var toolchains = Directory.EnumerateDirectories(
+ Path.Combine(androidNdkPath, "toolchains"), "llvm*").ToList();
+ toolchains.Sort();
+
+ var toolchainPath = toolchains.LastOrDefault();
+ if (toolchainPath == null)
+ throw new Exception("Could not find a valid NDK host toolchain");
+
+ toolchains = Directory.EnumerateDirectories(Path.Combine(toolchainPath,
+ "prebuilt")).ToList();
+ toolchains.Sort();
+
+ toolchainPath = toolchains.LastOrDefault();
+ if (toolchainPath == null)
+ throw new Exception("Could not find a valid NDK host toolchain");
+
+ return toolchainPath;
+ }
+
+ static string GetAndroidBuiltinIncludesFolder()
+ {
+ var toolchainPath = GetAndroidHostToolchainPath();
+
+ string clangToolchainPath = Path.Combine(toolchainPath, "lib64", "clang");
+ if (!Directory.Exists (clangToolchainPath))
+ clangToolchainPath = Path.Combine(toolchainPath, "lib", "clang");
+
+ string includePath = null;
+ if (Directory.Exists (clangToolchainPath)) {
+ var includePaths = Directory.EnumerateDirectories(clangToolchainPath).ToList();
+ includePath = includePaths.LastOrDefault();
+ }
+ if (includePath == null)
+ throw new Exception("Could not find a valid Clang include folder");
+
+ return Path.Combine(includePath, "include");
+ }
+
+ static void SetupAndroidNDK(Driver driver, Target target)
+ {
+ var options = driver.Options;
+
+ var builtinsPath = GetAndroidBuiltinIncludesFolder();
+ options.addSystemIncludeDirs(builtinsPath);
+
+ var androidNdkRoot = GetAndroidNdkPath ();
+ const int androidNdkApiLevel = 21;
+
+ var toolchainPath = Path.Combine(androidNdkRoot, "platforms",
+ "android-" + androidNdkApiLevel, "arch-" + GetArchFromTriple(target.Triple),
+ "usr", "include");
+ options.addSystemIncludeDirs(toolchainPath);
+
+ options.NoBuiltinIncludes = true;
+ options.NoStandardIncludes = true;
+ options.TargetTriple = target.Triple;
+ }
+
+ static uint GetTypeAlign(ParserTargetInfo target, ParserIntType type)
+ {
+ switch (type)
+ {
+ case ParserIntType.SignedChar:
+ case ParserIntType.UnsignedChar:
+ return target.CharAlign;
+ case ParserIntType.SignedShort:
+ case ParserIntType.UnsignedShort:
+ return target.ShortAlign;
+ case ParserIntType.SignedInt:
+ case ParserIntType.UnsignedInt:
+ return target.IntAlign;
+ case ParserIntType.SignedLong:
+ case ParserIntType.UnsignedLong:
+ return target.LongAlign;
+ case ParserIntType.SignedLongLong:
+ case ParserIntType.UnsignedLongLong:
+ return target.LongLongAlign;
+ default:
+ throw new Exception("Type has no alignment");
+ }
+ }
+
+ static uint GetTypeSize(ParserTargetInfo target, ParserIntType type)
+ {
+ switch (type)
+ {
+ case ParserIntType.SignedChar:
+ case ParserIntType.UnsignedChar:
+ return target.CharWidth;
+ case ParserIntType.SignedShort:
+ case ParserIntType.UnsignedShort:
+ return target.ShortWidth;
+ case ParserIntType.SignedInt:
+ case ParserIntType.UnsignedInt:
+ return target.IntWidth;
+ case ParserIntType.SignedLong:
+ case ParserIntType.UnsignedLong:
+ return target.LongWidth;
+ case ParserIntType.SignedLongLong:
+ case ParserIntType.UnsignedLongLong:
+ return target.LongLongWidth;
+ default:
+ throw new Exception("Type has no size");
+ }
+ }
+
+ static string GetTargetPlatformDefine(TargetPlatform target)
+ {
+ switch (target) {
+ case TargetPlatform.Android:
+ return "TARGET_ANDROID";
+ case TargetPlatform.iOS:
+ return "TARGET_IOS";
+ case TargetPlatform.WatchOS:
+ return "TARGET_WATCHOS";
+ default:
+ throw new ArgumentOutOfRangeException ();
+ }
+ }
+
+ static void Dump(ASTContext ctx, ParserTargetInfo targetInfo, Target target)
+ {
+ var targetFile = target.Triple;
+
+ if (!string.IsNullOrEmpty (OutputDir))
+ targetFile = Path.Combine (OutputDir, targetFile);
+
+ targetFile += ".h";
+
+ using (var writer = new StreamWriter(targetFile))
+ //using (var writer = Console.Out)
+ {
+ writer.WriteLine("#ifndef USED_CROSS_COMPILER_OFFSETS");
+ writer.WriteLine("#ifdef {0}", target.Defines[0]);
+ writer.WriteLine ("#ifdef {0}", GetTargetPlatformDefine (target.Platform));
+ writer.WriteLine("#ifndef HAVE_BOEHM_GC");
+ writer.WriteLine("#define HAS_CROSS_COMPILER_OFFSETS");
+ writer.WriteLine("#if defined (USE_CROSS_COMPILE_OFFSETS) || defined (MONO_CROSS_COMPILE)");
+ writer.WriteLine("#if !defined (DISABLE_METADATA_OFFSETS)");
+ writer.WriteLine("#define USED_CROSS_COMPILER_OFFSETS");
+
+ DumpAligns(writer, targetInfo);
+ DumpSizes(writer, targetInfo);
+ DumpMetadataOffsets(writer, ctx, target);
+
+ writer.WriteLine("#endif //disable metadata check");
+
+ DumpJITOffsets(writer, ctx);
+
+ writer.WriteLine("#endif //cross compiler checks");
+ writer.WriteLine("#endif //gc check");
+ writer.WriteLine("#endif //os check");
+ writer.WriteLine("#endif //arch check");
+ writer.WriteLine("#endif //USED_CROSS_COMPILER_OFFSETS check");
+ }
+
+ Console.WriteLine("Generated offsets file: {0}", targetFile);
+ }
+
+ static void DumpAligns(TextWriter writer, ParserTargetInfo target)
+ {
+ var aligns = new[]
+ {
+ new { Name = "gint8", Align = target.CharAlign},
+ new { Name = "gint16", Align = target.ShortAlign},
+ new { Name = "gint32", Align = target.IntAlign},
+ new { Name = "gint64", Align = GetTypeAlign(target, target.Int64Type)},
+ new { Name = "float", Align = target.FloatAlign},
+ new { Name = "double", Align = target.DoubleAlign},
+ new { Name = "gpointer", Align = GetTypeAlign(target, target.IntPtrType)},
+ };
+
+ // Write the alignment info for the basic types.
+ foreach (var align in aligns)
+ writer.WriteLine("DECL_ALIGN2({0},{1})", align.Name, align.Align / 8);
+ }
+
+ static void DumpSizes(TextWriter writer, ParserTargetInfo target)
+ {
+ var sizes = new[]
+ {
+ new { Name = "gint8", Size = target.CharWidth},
+ new { Name = "gint16", Size = target.ShortWidth},
+ new { Name = "gint32", Size = target.IntWidth},
+ new { Name = "gint64", Size = GetTypeSize(target, target.Int64Type)},
+ new { Name = "float", Size = target.FloatWidth},
+ new { Name = "double", Size = target.DoubleWidth},
+ new { Name = "gpointer", Size = GetTypeSize(target, target.IntPtrType)},
+ };
+
+ // Write the size info for the basic types.
+ foreach (var size in sizes)
+ writer.WriteLine("DECL_SIZE2({0},{1})", size.Name, size.Size / 8);
+ }
+
+ static Class GetClassFromTypedef(ITypedDecl typedef)
+ {
+ var type = typedef.Type.Desugar() as TagType;
+ if (type == null)
+ return null;
+
+ var @class = type.Declaration as Class;
+
+ return @class.IsIncomplete ?
+ (@class.CompleteDeclaration as Class) : @class;
+ }
+
+ static void DumpClasses(TextWriter writer, ASTContext ctx, IEnumerable<string> types,
+ bool optional = false)
+ {
+ foreach (var @struct in types)
+ {
+ var @class = ctx.FindCompleteClass(@struct);
+ if (@class == null)
+ @class = ctx.FindCompleteClass("_" + @struct);
+
+ if (@class == null)
+ {
+ var typedef = ctx.FindTypedef(@struct).FirstOrDefault(
+ decl => !decl.IsIncomplete);
+
+ if (typedef != null)
+ @class = GetClassFromTypedef(typedef);
+ }
+
+ if (@class == null && optional)
+ continue;
+
+ if (@class == null)
+ throw new Exception("Expected to find struct definition for " + @struct);
+
+ DumpStruct(writer, @class);
+ }
+ }
+
+ static void DumpMetadataOffsets(TextWriter writer, ASTContext ctx, Target target)
+ {
+ var types = new List<string>
+ {
+ "MonoObject",
+ "MonoClass",
+ "MonoVTable",
+ "MonoDelegate",
+ "MonoInternalThread",
+ "MonoMulticastDelegate",
+ "MonoTransparentProxy",
+ "MonoRealProxy",
+ "MonoRemoteClass",
+ "MonoArray",
+ "MonoArrayBounds",
+ "MonoSafeHandle",
+ "MonoHandleRef",
+ "MonoComInteropProxy",
+ "MonoString",
+ "MonoException",
+ "MonoTypedRef",
+ "MonoThreadsSync",
+ "SgenThreadInfo"
+ };
+
+ DumpClasses(writer, ctx, types);
+ }
+
+ static void DumpJITOffsets(TextWriter writer, ASTContext ctx)
+ {
+ writer.WriteLine("#ifndef DISABLE_JIT_OFFSETS");
+ writer.WriteLine("#define USED_CROSS_COMPILER_OFFSETS");
+
+ var types = new[]
+ {
+ "MonoLMF",
+ "MonoMethodRuntimeGenericContext",
+ "MonoJitTlsData",
+ "MonoGSharedVtMethodRuntimeInfo",
+ "MonoContinuation",
+ "MonoContext",
+ "MonoDelegateTrampInfo",
+ };
+
+ DumpClasses(writer, ctx, types);
+
+ var optionalTypes = new[]
+ {
+ "GSharedVtCallInfo",
+ "SeqPointInfo",
+ "DynCallArgs",
+ "MonoLMFTramp",
+ };
+
+ DumpClasses(writer, ctx, optionalTypes, optional: true);
+
+ writer.WriteLine("#endif //disable jit check");
+ }
+
+ static void DumpStruct(TextWriter writer, Class @class)
+ {
+ var name = @class.Name;
+ if (name.StartsWith ("_", StringComparison.Ordinal))
+ name = name.Substring (1);
+
+ foreach (var field in @class.Fields)
+ {
+ if (field.IsBitField) continue;
+
+ if (name == "SgenThreadInfo" && field.Name == "regs")
+ continue;
+
+ writer.WriteLine("DECL_OFFSET2({0},{1},{2})", name, field.Name,
+ field.Offset / 8);
+ }
+ }
+ }
+}