[linker] Provide better error message when an error occurs while processing xml descriptions
mono-*.tar.*
tmpinst-dir.stamp
msvc/scripts/inputs/
+extensions-config.h
You can run the mono and mcs test suites with the command: `make check`.
Expect to find a few test suite failures. As a sanity check, you
-can compare the failures you got with [https://wrench.mono-project.com/Wrench/](https://wrench.mono-project.com/Wrench/)
-and [http://jenkins.mono-project.com/](http://jenkins.mono-project.com/).
+can compare the failures you got with [https://jenkins.mono-project.com/](https://jenkins.mono-project.com/).
You can now install mono with: `make install`
check-ms-test-suite:
@if $(MAKE) validate-ms-test-suite RESET_VERSIONS=1; then \
$(MAKE) -C $(MSTESTSUITE_PATH)/conformance build MCS="$(MCS) -t:library -warn:1 -r:nunit.framework"; \
- $(MAKE) -C $(MSTESTSUITE_PATH)/conformance run NUNIT-CONSOLE="$(RUNTIME) $(CLASS)/nunit-console.exe -nologo -exclude=MonoBug,BadTest"; \
+ $(MAKE) -C $(MSTESTSUITE_PATH)/conformance run NUNIT-CONSOLE="$(RUNTIME) $(CLASS)/nunit-console.exe -nologo -exclude=MonoBug,BadTest" NUNIT_XML_RESULT=$(abs_top_builddir)/acceptance-tests/TestResult-ms-test-suite-conformance.xml; \
$(MAKE) -C $(MSTESTSUITE_PATH)/systemruntimebringup build MCS="$(MCS) -debug -warn:1"; \
$(MAKE) -C $(MSTESTSUITE_PATH)/systemruntimebringup run MONO="$(RUNTIME)"; \
else \
echo "*** [ms-test-suite] Getting the repository failed, you probably don't have access to this Xamarin-internal resource. Skipping."; \
fi
-# Roslyn require some aditional files in the mono installation to build.
-# Those files can be copied from roslyn mono toolset archive that is downloaded by cibuild.sh
check-roslyn:
@$(MAKE) validate-roslyn RESET_VERSIONS=1
@if [ -z $$PREFIX ]; then echo "You need to set PREFIX to the prefix of the Mono installation that should be used for testing Roslyn." && exit 1; fi
export MSBuildExtensionsPath=$$PREFIX/lib/mono/xbuild; \
- MONO_TOOLSET_NAME=mono.mac.3; \
- MONO_NUGET_DIR=$$PREFIX/lib/mono/xbuild/Microsoft/NuGet; \
MONO_DOTNET_PORTABLE_DIR=$$PREFIX/lib/mono/xbuild-frameworks/.NETPortable/; \
- pushd /tmp; \
- if [ ! -d "$$MONO_NUGET_DIR" ]; then \
- echo "Mono installation is missing $$MONO_NUGET_DIR"; \
- ROSLYN_MONO_TOOLSET_REQUIRED=yes; \
+ MONO_NUGET_TARGETS_DIR=$$PREFIX/lib/mono/xbuild/Microsoft/NuGet/; \
+ MONO_PORTABLE_TARGETS_DIR=$$PREFIX/lib/mono/xbuild/Microsoft/Portable/v5.0; \
+ if [ ! -d "$$MONO_DOTNET_PORTABLE_DIR/v5.0" ]; then \
+ mkdir -p $$MONO_DOTNET_PORTABLE_DIR; \
+ mkdir -p $$MONO_NUGET_TARGETS_DIR; \
+ mkdir -p $$MONO_PORTABLE_TARGETS_DIR; \
+ curl -SL "http://storage.bos.internalx.com/bot-provisioning/RoslynBuildDependencies.zip" > /tmp/RoslynBuildDependencies.zip; \
+ unzip -o /tmp/RoslynBuildDependencies.zip -d /tmp/RoslynBuildDependencies; \
+ cp -r /tmp/RoslynBuildDependencies/PortableReferenceAssemblies/* $$MONO_DOTNET_PORTABLE_DIR; \
+ cp /tmp/RoslynBuildDependencies/NuGetTargets/* $$MONO_NUGET_TARGETS_DIR; \
+ cp /tmp/RoslynBuildDependencies/PortableTargets/* $$MONO_PORTABLE_TARGETS_DIR; \
fi; \
- if [ ! -d "$$MONO_DOTNET_PORTABLE_DIR" ]; then \
- echo "Mono installation is missing $$MONO_DOTNET_PORTABLE_DIR"; \
- ROSLYN_MONO_TOOLSET_REQUIRED=yes; \
- fi; \
- if [[ $$ROSLYN_MONO_TOOLSET_REQUIRED ]]; then \
- if [ ! -d "$$MONO_TOOLSET_NAME" ]; then \
- echo "Downloading roslyn mono tool set"; \
- curl -O https://dotnetci.blob.core.windows.net/roslyn/$$MONO_TOOLSET_NAME.tar.bz2; \
- tar -jxf $$MONO_TOOLSET_NAME.tar.bz2; \
- fi; \
- fi; \
- if [ ! -d "$$MONO_NUGET_DIR" ]; then \
- mkdir $$MONO_NUGET_DIR; \
- cp -r $$MONO_TOOLSET_NAME/lib/mono/xbuild/Microsoft/NuGet/* $$MONO_NUGET_DIR; \
- fi; \
- if [ ! -d "$$MONO_DOTNET_PORTABLE_DIR" ]; then \
- mkdir $$MONO_DOTNET_PORTABLE_DIR; \
- cp -r $$MONO_TOOLSET_NAME/lib/mono/xbuild-frameworks/.NETPortable/* $$MONO_DOTNET_PORTABLE_DIR; \
- fi; \
- popd; \
- cd $(ROSLYN_PATH) && ./cibuild.sh --mono-path $$PREFIX/bin
+ cd $(ROSLYN_PATH); \
+ sed -i -e 'N; s/bootstrapArg=".*\n.*"/bootstrapArg=""/g' cibuild.sh; \
+ sed -i -e 's#-xml Binaries/\$$BUILD_CONFIGURATION/xUnitResults/#-nunit $(abs_top_builddir)/acceptance-tests/TestResult-#g' cibuild.sh; \
+ ./cibuild.sh --mono-path $$PREFIX/bin
coreclr-validate:
$(MAKE) validate-coreclr RESET_VERSIONS=1
coreclr-compile-tests: coreclr-validate
- $(MAKE) -j4 $(CORECLR_TESTSI_CS) $(CORECLR_COREMANGLIB_TESTSI_CS) $(CORECLR_TESTSI_IL)
+ $(MAKE) -j4 $(CORECLR_TESTSI_CS)
+ $(MAKE) -j4 $(CORECLR_COREMANGLIB_TESTSI_CS)
+ $(MAKE) -j4 $(CORECLR_TESTSI_IL)
# the CoreCLR IL tests use the System.Console facade, we need to copy it to the test directory
# all the other tests rely on the coreclr-testlibrary.dll
check-coreclr: coreclr-compile-tests coreclr-runtest-basic coreclr-runtest-coremanglib
coreclr-gcstress: coreclr-validate GCStressTests.exe $(CORECLR_STRESSTESTSI_CS)
- BVT_ROOT=$(realpath $(CORECLR_PATH)/tests/src/GC/Stress/Tests) $(RUNTIME) GCStressTests.exe $(CORECLR_PATH)/tests/src/GC/Stress/testmix_gc.config
+ BVT_ROOT=$(realpath $(CORECLR_PATH)/tests/src/GC/Stress/Tests) $(RUNTIME) GCStressTests.exe $(CORECLR_PATH)/tests/src/GC/Stress/testmix_gc.config; if [ $$? -ne 100 ]; then exit 1; fi
# Output a variable in $(2) to the file $(1), separated by newline characters
# we need to do it in groups of 100 entries to make sure we don't exceed shell char limits
$(CORECLR_PATH)/tests/src/JIT/Directed/coverage/oldtests/lclfldmul.cs \
$(CORECLR_PATH)/tests/src/JIT/Directed/coverage/oldtests/lclfldrem.cs \
$(CORECLR_PATH)/tests/src/JIT/Directed/coverage/oldtests/lclfldsub.cs \
+ $(CORECLR_PATH)/tests/src/JIT/Directed/gettypetypeof/gettypetypeofmatrix.cs \
$(CORECLR_PATH)/tests/src/JIT/Directed/intrinsic/interlocked/IntrinsicTest_Overflow.cs \
$(CORECLR_PATH)/tests/src/JIT/Directed/intrinsic/interlocked/cmpxchg.cs \
$(CORECLR_PATH)/tests/src/JIT/Directed/intrinsic/interlocked/cse_cmpxchg.cs \
CORECLR_DISABLED_TEST_CS_SRC += \
$(CORECLR_PATH)/tests/src/Regressions/assemblyref/assem.cs \
$(CORECLR_PATH)/tests/src/Regressions/assemblyref/test.cs \
- $(CORECLR_PATH)/tests/src/Interop/ReversePInvoke/Marshalling/MarshalBoolArray.cs
+ $(CORECLR_PATH)/tests/src/Interop/ReversePInvoke/Marshalling/MarshalBoolArray.cs \
+ $(CORECLR_PATH)/tests/src/Interop/NativeCallable/NativeCallableTest.cs \
+ $(CORECLR_PATH)/tests/src/JIT/Directed/StructABI/StructABI.OSX.cs \
+ $(CORECLR_PATH)/tests/src/JIT/Directed/StructABI/StructABI.Windows.cs \
+ $(CORECLR_PATH)/tests/src/JIT/Directed/StructABI/StructABI.Unix.cs \
+ $(CORECLR_PATH)/tests/src/JIT/Directed/StructABI/StructABI.cs
# relies on a define:
CORECLR_DISABLED_TEST_CS_SRC += $(CORECLR_PATH)/tests/src/Exceptions/Finalization/Finalizer.cs
$(CORECLR_PATH)/tests/src/CoreMangLib/cti/system/resources/resourcemanager/customculture.cs \
$(CORECLR_PATH)/tests/src/CoreMangLib/system/resources/resourcemanager/customculture.cs
+# Mono doesn't support ICastable
+CORECLR_DISABLED_TEST_CS_SRC += $(CORECLR_PATH)/tests/src/Interop/ICastable/Castable.cs
+
# throws IndexOutOfRange exception even on .NET
CORECLR_DISABLED_TEST_CS_SRC += \
$(CORECLR_PATH)/tests/src/baseservices/threading/interlocked/compareexchange/compareexchangetclass.cs \
GCStressTests.exe: $(CORECLR_STRESSTEST_RUNNER_CS_SRC)
$(MCS) -out:$@ -debug -d:PROJECTK_BUILD $(CORECLR_STRESSTEST_RUNNER_CS_SRC)
-CLEANFILES = $(CORECLR_TESTSI_CS) $(CORECLR_COREMANGLIB_TESTSI_CS) $(CORECLR_TESTSI_IL) *.dll *.exe *.mdb $(CORECLR_STRESSTESTSI_CS) GCStressTests.exe coreclr-testlibrary.dll
+CLEANFILES = *.dll *.exe *.mdb $(CORECLR_STRESSTESTSI_CS) GCStressTests.exe coreclr-testlibrary.dll
+
+clean-local:
+ -rm -f $(CORECLR_TESTSI_CS)
+ -rm -f $(CORECLR_COREMANGLIB_TESTSI_CS)
+ -rm -f $(CORECLR_TESTSI_IL)
\ No newline at end of file
{
"name": "roslyn",
"url": "git://github.com/dotnet/roslyn.git",
- "rev": "2e68ae5e6ec51762296c681aadf57a6f33f2f34f",
+ "rev": "322bd5b2bbf07df6a67de35cbcb2365484412f70",
"remote-branch": "origin/master",
"branch": "master",
"directory": "roslyn"
{
"name": "coreclr",
"url": "git://github.com/mono/coreclr.git",
- "rev": "65b122151adb6b5ef7c27d8e0c268ef479fbe8b4",
+ "rev": "ffe6263398591cfbd8100070ac8a191ff2080fbb",
"remote-branch": "origin/mono",
"branch": "mono",
"directory": "coreclr"
{
"name": "ms-test-suite",
"url": "git@github.com:xamarin/ms-test-suite.git",
- "rev": "4caab98ae449836c2aaacb9748fe0c796b71517f",
+ "rev": "19f2a7dd44a2bfcf6006fd38033222383e8b81bf",
"remote-branch": "origin/master",
"branch": "master",
"directory": "ms-test-suite"
-Subproject commit d69f20d81d23e8e924e9339552336a2d0252864a
+Subproject commit 8c73c45821dfbaf20fb303db1a73f8de96c0a515
heap corruption issues.
.TP
-\fBdo-not-finalize\fR
+\fBdo-not-finalize(=\fIclasses\fB)\fR
If enabled, finalizers will not be run. Everything else will be
unaffected: finalizable objects will still be put into the
finalization queue where they survive until they're scheduled to
finalize. Once they're not in the queue anymore they will be
-collected regularly.
+collected regularly. If a list of comma-separated class names is
+given, only objects from those classes will not be finalized.
.TP
\fBlog-finalizers\fR
monotouch_watch_SUBDIRS := build class
monotouch_tv_SUBDIRS := build class
monotouch_runtime_SUBDIRS := build class
+monotouch_watch_runtime_SUBDIRS := build class
+monotouch_tv_runtime_SUBDIRS := build class
xammac_SUBDIRS := build class
mobile_SUBDIRS := build class
mobile_static_SUBDIRS := build class
$(_boot_:%=profile-do--monotouch_watch--%): profile-do--monotouch_watch--%: profile-do--build--%
$(_boot_:%=profile-do--monotouch_tv--%): profile-do--monotouch_tv--%: profile-do--build--%
$(_boot_:%=profile-do--monotouch_runtime--%): profile-do--monotouch_runtime--%: profile-do--build--%
+$(_boot_:%=profile-do--monotouch_watch_runtime--%): profile-do--monotouch_watch_runtime--%: profile-do--build--%
+$(_boot_:%=profile-do--monotouch_tv_runtime--%): profile-do--monotouch_tv_runtime--%: profile-do--build--%
$(_boot_:%=profile-do--xammac--%): profile-do--xammac--%: profile-do--build--%
$(_boot_:%=profile-do--xammac_net_4_5--%): profile-do--xammac_net_4_5--%: profile-do--build--%
$(_boot_:%=profile-do--mobile--%): profile-do--mobile--%: profile-do--build--%
-#! -*- makefile -*-
+include $(topdir)/build/profiles/monotouch_runtime.make
-BOOTSTRAP_PROFILE = build
-
-BOOTSTRAP_MCS = MONO_PATH="$(topdir)/class/lib/$(BOOTSTRAP_PROFILE)$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH" $(INTERNAL_GMCS)
-MCS = MONO_PATH="$(topdir)/class/lib/$(BOOTSTRAP_PROFILE)$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH" $(INTERNAL_GMCS)
-
-# Use system resgen as we don't want local System.Windows.Forms dependency
-RESGEN := $(dir $(shell which $(EXTERNAL_MCS)))resgen2
-
-profile-check:
- @:
-
-DEFAULT_REFERENCES = -r:mscorlib.dll
-
-PROFILE_MCS_FLAGS = \
- -d:NET_1_1 \
- -d:NET_2_0 \
- -d:NET_2_1 \
- -d:NET_3_5 \
- -d:NET_4_0 \
- -d:NET_4_5 \
- -d:MOBILE,MOBILE_LEGACY \
- -d:MONO \
- -d:DISABLE_CAS_USE \
- -d:MONOTOUCH \
- -d:DISABLE_REMOTING \
- -d:DISABLE_COM \
- -d:FULL_AOT_RUNTIME \
- -nowarn:1699 \
- -nostdlib \
- -lib:$(topdir)/class/lib/$(PROFILE) \
- $(DEFAULT_REFERENCES) \
- $(PLATFORM_DEBUG_FLAGS)
-
-FRAMEWORK_VERSION = 2.1
-NO_TEST = yes
-
-# the tuner takes care of the install
-NO_INSTALL = yes
-MOBILE_STATIC = yes
-MOBILE_PROFILE = yes
+PROFILE_MCS_FLAGS += \
+ -d:FULL_AOT_RUNTIME
@:
DEFAULT_REFERENCES = -r:mscorlib.dll
-PROFILE_MCS_FLAGS = -d:NET_1_1 -d:NET_2_0 -d:NET_2_1 -d:NET_3_5 -d:NET_4_0 -d:NET_4_5 -d:MONO -d:DISABLE_CAS_USE -d:MOBILE,MOBILE_LEGACY -d:MONOTOUCH -D:DISABLE_REMOTING -d:DISABLE_COM -nowarn:1699 -nostdlib -lib:$(topdir)/class/lib/$(PROFILE) $(DEFAULT_REFERENCES) $(PLATFORM_DEBUG_FLAGS)
+PROFILE_MCS_FLAGS = \
+ -d:NET_1_1 \
+ -d:NET_2_0 \
+ -d:NET_2_1 \
+ -d:NET_3_5 \
+ -d:NET_4_0 \
+ -d:NET_4_5 \
+ -d:MOBILE,MOBILE_LEGACY \
+ -d:MONO \
+ -d:DISABLE_CAS_USE \
+ -d:MONOTOUCH \
+ -d:DISABLE_REMOTING \
+ -d:DISABLE_COM \
+ -nowarn:1699 \
+ -nostdlib \
+ -lib:$(topdir)/class/lib/$(PROFILE) \
+ $(DEFAULT_REFERENCES) \
+ $(PLATFORM_DEBUG_FLAGS)
FRAMEWORK_VERSION = 2.1
--- /dev/null
+include $(topdir)/build/profiles/monotouch_runtime.make
+
+PROFILE_MCS_FLAGS += \
+ -d:MONOTOUCH_TV
--- /dev/null
+include $(topdir)/build/profiles/monotouch_runtime.make
+
+PROFILE_MCS_FLAGS += \
+ -d:MONOTOUCH_WATCH
thisdir = class/Facades
-monotouch_PARALLEL_SUBDIRS = System.Collections.Concurrent System.Collections System.ComponentModel.Annotations System.ComponentModel.EventBasedAsync System.ComponentModel \
- System.Diagnostics.Contracts System.Diagnostics.Debug System.Diagnostics.Tracing System.Diagnostics.Tools System.Dynamic.Runtime System.Globalization System.IO System.Linq.Expressions \
- System.Linq.Parallel System.Linq.Queryable System.Linq System.Net.NetworkInformation System.Net.Primitives System.Net.Requests System.ObjectModel \
- System.Reflection.Extensions System.Reflection.Primitives System.Reflection System.Resources.ResourceManager System.Runtime.Extensions \
- System.Runtime.InteropServices System.Runtime.InteropServices.WindowsRuntime System.Runtime.Numerics System.Runtime.Serialization.Json \
- System.Runtime.Serialization.Primitives System.Runtime.Serialization.Xml System.Runtime System.Security.Principal System.ServiceModel.Http \
- System.ServiceModel.Primitives System.ServiceModel.Security System.Text.Encoding.Extensions System.Text.Encoding System.Text.RegularExpressions System.Threading.Tasks.Parallel \
- System.Threading.Tasks System.Threading.Timer System.Threading System.Xml.ReaderWriter System.Xml.XDocument System.Xml.XmlSerializer \
- System.Runtime.Handles System.ServiceModel.Duplex System.ServiceModel.NetTcp \
- Microsoft.Win32.Primitives Microsoft.Win32.Registry System.AppContext System.Collections.NonGeneric System.Collections.Specialized System.ComponentModel.Primitives \
- System.ComponentModel.TypeConverter System.Console System.Data.Common System.Data.SqlClient System.Diagnostics.FileVersionInfo \
- System.Diagnostics.Process System.Diagnostics.TextWriterTraceListener System.Diagnostics.TraceEvent System.Diagnostics.TraceSource System.Globalization.Calendars \
- System.IO.Compression.ZipFile System.IO.FileSystem System.IO.FileSystem.DriveInfo System.IO.FileSystem.Primitives \
- System.IO.IsolatedStorage System.IO.MemoryMappedFiles System.IO.UnmanagedMemoryStream System.Net.AuthenticationManager System.Net.Cache \
- System.Net.HttpListener System.Net.Mail System.Net.NameResolution System.Net.Security System.Net.ServicePoint System.Net.Sockets \
- System.Net.Utilities System.Net.WebHeaderCollection System.Net.WebSockets System.Net.WebSockets.Client System.Resources.ReaderWriter System.Runtime.CompilerServices.VisualC \
- System.Security.AccessControl System.Security.Claims System.Security.Cryptography.DeriveBytes System.Security.Cryptography.Encoding System.Security.Cryptography.Encryption \
- System.Security.Cryptography.Encryption.Aes System.Security.Cryptography.Encryption.ECDiffieHellman System.Security.Cryptography.Encryption.ECDsa System.Security.Cryptography.Hashing \
- System.Security.Cryptography.Hashing.Algorithms System.Security.Cryptography.RSA System.Security.Cryptography.RandomNumberGenerator \
- System.Security.Cryptography.X509Certificates System.Security.Principal.Windows System.Threading.Thread System.Threading.ThreadPool \
- System.Xml.XPath System.Xml.XmlDocument System.Xml.Xsl.Primitives Microsoft.Win32.Registry.AccessControl System.Diagnostics.StackTrace System.Globalization.Extensions \
- System.IO.FileSystem.AccessControl System.Private.CoreLib.InteropServices System.Private.CoreLib.Threading System.Reflection.TypeExtensions \
- System.Security.SecureString System.Threading.AccessControl System.Threading.Overlapped System.Xml.XPath.XDocument
-
-reflection_PARALLEL_SUBDIRS = System.Reflection.Emit.ILGeneration System.Reflection.Emit.Lightweight System.Reflection.Emit
-
-mobile_static_PARALLEL_SUBDIRS = $(monotouch_PARALLEL_SUBDIRS)
-
-net_4_x_PARALLEL_SUBDIRS = $(monotouch_PARALLEL_SUBDIRS) $(reflection_PARALLEL_SUBDIRS) System.Diagnostics.PerformanceCounter \
- System.IO.FileSystem.Watcher System.IO.Pipes System.Security.Cryptography.ProtectedData System.ServiceProcess.ServiceController System.Net.Http.WebRequestHandler
-
-monodroid_PARALLEL_SUBDIRS = $(monotouch_PARALLEL_SUBDIRS) $(reflection_PARALLEL_SUBDIRS)
-
-xammac_PARALLEL_SUBDIRS = $(monotouch_PARALLEL_SUBDIRS) $(reflection_PARALLEL_SUBDIRS)
-xammac_net_4_5_PARALLEL_SUBDIRS = $(monotouch_PARALLEL_SUBDIRS) $(reflection_PARALLEL_SUBDIRS)
-
-monotouch_watch_PARALLEL_SUBDIRS = $(monotouch_PARALLEL_SUBDIRS)
-monotouch_tv_PARALLEL_SUBDIRS = $(monotouch_PARALLEL_SUBDIRS)
-
-PROFILE_PARALLEL_SUBDIRS = $(net_4_x_PARALLEL_SUBDIRS)
+include subdirs.make
#OVERRIDE_TARGET_ALL = yes
dist-local: dist-default
DIST_SUBDIRS = $(net_4_x_PARALLEL_SUBDIRS)
+DISTFILES=subdirs.make
doc-update-local:
@echo "not doing docs"
--- /dev/null
+
+# This file should only contain SUBDIRS variables
+# Caution while renaming SUBDIRS variables as those are used outside mono repository.
+# ie: macccore/builds/Makefile
+
+monotouch_PARALLEL_SUBDIRS = System.Collections.Concurrent System.Collections System.ComponentModel.Annotations System.ComponentModel.EventBasedAsync System.ComponentModel \
+System.Diagnostics.Contracts System.Diagnostics.Debug System.Diagnostics.Tracing System.Diagnostics.Tools System.Dynamic.Runtime System.Globalization System.IO System.Linq.Expressions \
+System.Linq.Parallel System.Linq.Queryable System.Linq System.Net.NetworkInformation System.Net.Primitives System.Net.Requests System.ObjectModel \
+System.Reflection.Extensions System.Reflection.Primitives System.Reflection System.Resources.ResourceManager System.Runtime.Extensions \
+System.Runtime.InteropServices System.Runtime.InteropServices.WindowsRuntime System.Runtime.Numerics System.Runtime.Serialization.Json \
+System.Runtime.Serialization.Primitives System.Runtime.Serialization.Xml System.Runtime System.Security.Principal System.ServiceModel.Http \
+System.ServiceModel.Primitives System.ServiceModel.Security System.Text.Encoding.Extensions System.Text.Encoding System.Text.RegularExpressions System.Threading.Tasks.Parallel \
+System.Threading.Tasks System.Threading.Timer System.Threading System.Xml.ReaderWriter System.Xml.XDocument System.Xml.XmlSerializer \
+System.Runtime.Handles System.ServiceModel.Duplex System.ServiceModel.NetTcp \
+Microsoft.Win32.Primitives Microsoft.Win32.Registry System.AppContext System.Collections.NonGeneric System.Collections.Specialized System.ComponentModel.Primitives \
+System.ComponentModel.TypeConverter System.Console System.Data.Common System.Data.SqlClient System.Diagnostics.FileVersionInfo \
+System.Diagnostics.Process System.Diagnostics.TextWriterTraceListener System.Diagnostics.TraceEvent System.Diagnostics.TraceSource System.Globalization.Calendars \
+System.IO.Compression.ZipFile System.IO.FileSystem System.IO.FileSystem.DriveInfo System.IO.FileSystem.Primitives \
+System.IO.IsolatedStorage System.IO.MemoryMappedFiles System.IO.UnmanagedMemoryStream System.Net.AuthenticationManager System.Net.Cache \
+System.Net.HttpListener System.Net.Mail System.Net.NameResolution System.Net.Security System.Net.ServicePoint System.Net.Sockets \
+System.Net.Utilities System.Net.WebHeaderCollection System.Net.WebSockets System.Net.WebSockets.Client System.Resources.ReaderWriter System.Runtime.CompilerServices.VisualC \
+System.Security.AccessControl System.Security.Claims System.Security.Cryptography.DeriveBytes System.Security.Cryptography.Encoding System.Security.Cryptography.Encryption \
+System.Security.Cryptography.Encryption.Aes System.Security.Cryptography.Encryption.ECDiffieHellman System.Security.Cryptography.Encryption.ECDsa System.Security.Cryptography.Hashing \
+System.Security.Cryptography.Hashing.Algorithms System.Security.Cryptography.RSA System.Security.Cryptography.RandomNumberGenerator \
+System.Security.Cryptography.X509Certificates System.Security.Principal.Windows System.Threading.Thread System.Threading.ThreadPool \
+System.Xml.XPath System.Xml.XmlDocument System.Xml.Xsl.Primitives Microsoft.Win32.Registry.AccessControl System.Diagnostics.StackTrace System.Globalization.Extensions \
+System.IO.FileSystem.AccessControl System.Private.CoreLib.InteropServices System.Private.CoreLib.Threading System.Reflection.TypeExtensions \
+System.Security.SecureString System.Threading.AccessControl System.Threading.Overlapped System.Xml.XPath.XDocument
+
+reflection_PARALLEL_SUBDIRS = System.Reflection.Emit.ILGeneration System.Reflection.Emit.Lightweight System.Reflection.Emit
+
+mobile_static_PARALLEL_SUBDIRS = $(monotouch_PARALLEL_SUBDIRS)
+
+net_4_x_PARALLEL_SUBDIRS = $(monotouch_PARALLEL_SUBDIRS) $(reflection_PARALLEL_SUBDIRS) System.Diagnostics.PerformanceCounter \
+System.IO.FileSystem.Watcher System.IO.Pipes System.Security.Cryptography.ProtectedData System.ServiceProcess.ServiceController System.Net.Http.WebRequestHandler
+
+monodroid_PARALLEL_SUBDIRS = $(monotouch_PARALLEL_SUBDIRS) $(reflection_PARALLEL_SUBDIRS)
+
+xammac_PARALLEL_SUBDIRS = $(monotouch_PARALLEL_SUBDIRS) $(reflection_PARALLEL_SUBDIRS)
+xammac_net_4_5_PARALLEL_SUBDIRS = $(monotouch_PARALLEL_SUBDIRS) $(reflection_PARALLEL_SUBDIRS)
+
+monotouch_watch_PARALLEL_SUBDIRS = $(monotouch_PARALLEL_SUBDIRS)
+monotouch_tv_PARALLEL_SUBDIRS = $(monotouch_PARALLEL_SUBDIRS)
+
+PROFILE_PARALLEL_SUBDIRS = $(net_4_x_PARALLEL_SUBDIRS)
System.XML \
Mono.CSharp
+monotouch_watch_runtime_dirs := $(monotouch_runtime_dirs)
+monotouch_tv_runtime_dirs := $(monotouch_runtime_dirs)
+
xammac_4_5_dirs := \
corlib \
System \
monotouch_watch_SUBDIRS := $(monotouch_watch_dirs)
monotouch_tv_SUBDIRS := $(monotouch_tv_dirs)
monotouch_runtime_SUBDIRS := $(monotouch_runtime_dirs)
+monotouch_watch_runtime_SUBDIRS := $(monotouch_watch_runtime_dirs)
+monotouch_tv_runtime_SUBDIRS := $(monotouch_tv_runtime_dirs)
mobile_static_SUBDIRS := $(mobile_static_dirs)
mobile_SUBDIRS := $(mobile_dynamic_dirs)
xammac_SUBDIRS := $(xammac_dirs)
Test/resources/*.*proj \
Test/resources/*.csproj
-Test/resources/TestTasks.dll: Test/resources/TestTasks.cs
- $(CSCOMPILE) Test/resources/TestTasks.cs /r:$(XBUILD_FRAMEWORK) /r:$(XBUILD_UTILITIES) /target:library
+Test/resources/TestTasks-$(PROFILE).dll: Test/resources/TestTasks.cs
+ $(CSCOMPILE) /out:$@ Test/resources/TestTasks.cs /r:$(XBUILD_FRAMEWORK) /r:$(XBUILD_UTILITIES) /target:library
clean-test-resources:
- rm -f Test/resources/TestTasks.dll
+ rm -f Test/resources/TestTasks*.dll Test/resources/TestTasks*.dll.mdb
-test-local: Test/resources/TestTasks.dll
+test-local: compile-resources
+
+compile-resources: Test/resources/TestTasks-$(PROFILE).dll
+ cp Test/resources/TestTasks-$(PROFILE).dll Test/resources/TestTasks.dll
+ cp Test/resources/TestTasks-$(PROFILE).dll.mdb Test/resources/TestTasks.dll.mdb
clean-local: clean-test-resources
Evaluator.Evaluate ("File.Exists (\"/etc/passwd\");");
}
+ [Test]
+ public void UsingWithError ()
+ {
+ try {
+ Evaluator.Run ("using System.DateTime;");
+ Assert.Fail ("#1");
+ } catch {
+ }
+
+ Evaluator.Evaluate ("1+1");
+ }
+
+ [Test]
+ public void UsingAlias ()
+ {
+ Evaluator.Run("using System;");
+ Evaluator.Run("using MyConsole = System.Console;");
+ Evaluator.Run("Console.WriteLine(\"Hello World\")");
+ }
+
[Test]
public void WithTypeBuilders ()
{
NativeMethods.cairo_set_dash (handle, dashes, dashes.Length, offset);
}
- [Obsolete("Use GetSource/GetSource")]
+ [Obsolete("Use GetSource/SetSource")]
public Pattern Pattern {
set {
SetSource (value);
}
//This is obsolete because it wasn't obvious it needed to be disposed
- [Obsolete("Use GetSource/GetSource")]
+ [Obsolete("Use GetSource/SetSource")]
public Pattern Source {
set {
SetSource (value);
public void SockOpt ()
{
WithSockets (UnixAddressFamily.AF_UNIX, UnixSocketType.SOCK_STREAM, 0, (so1, so2) => {
+ int value;
if (Syscall.getsockopt (so1, UnixSocketProtocol.SOL_SOCKET, UnixSocketOptionName.SO_REUSEADDR, out value) < 0)
UnixMarshal.ThrowExceptionForLastError ();
Assert.AreEqual (0, value);
UnixMarshal.ThrowExceptionForLastError ();
// Get and check SO_REUSEADDR
- int value;
if (Syscall.getsockopt (so1, UnixSocketProtocol.SOL_SOCKET, UnixSocketOptionName.SO_REUSEADDR, out value) < 0)
UnixMarshal.ThrowExceptionForLastError ();
Assert.AreNotEqual (0, value);
Stream innerStream, bool leaveInnerStreamOpen,
MonoTlsSettings settings = null)
{
- var impl = new LegacySslStream (innerStream, leaveInnerStreamOpen, settings);
+ var impl = new LegacySslStream (innerStream, leaveInnerStreamOpen, this, settings);
return new MonoSslStreamImpl (impl);
}
get;
}
- X509Certificate SelectClientCertificate (
+ /*
+ * Returns `true` if a client certificate has been selected (which could be `null`).
+ */
+ bool SelectClientCertificate (
string targetHost, X509CertificateCollection localCertificates, X509Certificate remoteCertificate,
- string[] acceptableIssuers);
+ string[] acceptableIssuers, out X509Certificate clientCertificate);
- ValidationResult ValidateChain (string targetHost, X509CertificateCollection certificates);
+ /*
+ * If @serverMode is true, then we're a server and want to validate a certificate that we received from a client.
+ */
+ ValidationResult ValidateCertificate (string targetHost, bool serverMode, X509CertificateCollection certificates);
- ValidationResult ValidateClientCertificate (X509CertificateCollection certificates);
+ bool InvokeSystemValidator (
+ string targetHost, bool serverMode, X509CertificateCollection certificates,
+ ref MonoSslPolicyErrors errors, ref int status11);
}
public static class CertificateValidationHelper
get { return supportsTrustAnchors; }
}
- internal static ICertificateValidator GetDefaultValidator (MonoTlsSettings settings)
+ static ICertificateValidator GetDefaultValidator (MonoTlsProvider provider, MonoTlsSettings settings)
{
- return (ICertificateValidator)NoReflectionHelper.GetDefaultCertificateValidator (settings);
+ return (ICertificateValidator)NoReflectionHelper.GetDefaultCertificateValidator (provider, settings);
}
+ /*
+ * Internal API, intended to be used by MonoTlsProvider implementations.
+ */
+ public static ICertificateValidator GetValidator (MonoTlsProvider provider, MonoTlsSettings settings)
+ {
+ return GetDefaultValidator (provider, settings);
+ }
+
+ /*
+ * Use this overloaded version in user code.
+ */
public static ICertificateValidator GetValidator (MonoTlsSettings settings)
{
- return GetDefaultValidator (settings);
+ return GetDefaultValidator (null, settings);
}
}
#endif
namespace Mono.Security.Interface
{
- public abstract class MonoSslStream
+ public abstract class MonoSslStream : IDisposable
{
public abstract void AuthenticateAsClient (string targetHost);
protected virtual void Dispose (bool disposing)
{
}
+
+ ~MonoSslStream ()
+ {
+ Dispose (false);
+ }
}
}
#endregion
+#region Certificate Validation
+
+ /*
+ * Allows a TLS provider to provide a custom system certificiate validator.
+ */
+ public virtual bool HasCustomSystemCertificateValidator {
+ get { return false; }
+ }
+
+ /*
+ * If @serverMode is true, then we're a server and want to validate a certificate
+ * that we received from a client.
+ *
+ * Returns `true` if certificate validation has been performed and `false` to invoke the
+ * default system validator.
+ */
+ public virtual bool InvokeSystemCertificateValidator (
+ ICertificateValidator validator, string targetHost, bool serverMode,
+ X509CertificateCollection certificates, out bool success,
+ ref MonoSslPolicyErrors errors, ref int status11)
+ {
+ success = false;
+ return false;
+ }
+
+#endregion
+
#region Manged SSPI
/*
return NoReflectionHelper.CreateHttpsRequest (requestUri, provider, settings);
}
- public static HttpListener CreateHttpListener (X509Certificate2 certificate, MonoTlsProvider provider = null, MonoTlsSettings settings = null)
+ public static HttpListener CreateHttpListener (X509Certificate certificate, MonoTlsProvider provider = null, MonoTlsSettings settings = null)
{
return (HttpListener)NoReflectionHelper.CreateHttpListener (certificate, provider, settings);
}
bool callbackNeedsChain = true;
ICertificateValidator certificateValidator;
+ public MonoTlsSettings ()
+ {
+ }
+
#region Private APIs
/*
[Obsolete ("Do not use outside System.dll!")]
public ICertificateValidator CertificateValidator {
get { return certificateValidator; }
- set { certificateValidator = value; }
}
[Obsolete ("Do not use outside System.dll!")]
return this;
}
- var copy = new MonoTlsSettings ();
- copy.RemoteCertificateValidationCallback = RemoteCertificateValidationCallback;
- copy.ClientCertificateSelectionCallback = ClientCertificateSelectionCallback;
- copy.checkCertName = checkCertName;
- copy.checkCertRevocationStatus = checkCertRevocationStatus;
- copy.UseServicePointManagerCallback = useServicePointManagerCallback;
- copy.skipSystemValidators = skipSystemValidators;
- copy.callbackNeedsChain = callbackNeedsChain;
- copy.UserSettings = UserSettings;
+ var copy = new MonoTlsSettings (this);
copy.certificateValidator = validator;
- copy.EnabledProtocols = EnabledProtocols;
- copy.TrustAnchors = TrustAnchors;
- copy.cloned = true;
return copy;
}
+ MonoTlsSettings (MonoTlsSettings other)
+ {
+ RemoteCertificateValidationCallback = other.RemoteCertificateValidationCallback;
+ ClientCertificateSelectionCallback = other.ClientCertificateSelectionCallback;
+ checkCertName = other.checkCertName;
+ checkCertRevocationStatus = other.checkCertRevocationStatus;
+ UseServicePointManagerCallback = other.useServicePointManagerCallback;
+ skipSystemValidators = other.skipSystemValidators;
+ callbackNeedsChain = other.callbackNeedsChain;
+ UserSettings = other.UserSettings;
+ EnabledProtocols = other.EnabledProtocols;
+ TrustAnchors = other.TrustAnchors;
+ cloned = true;
+ }
+
#endregion
}
}
--- /dev/null
+#include monotouch_System.Core.dll.sources
--- /dev/null
+#include monotouch_System.Core.dll.sources
public static Color FromHtml (string htmlColor)
{
- if ((htmlColor == null) || (htmlColor.Length == 0))
- return Color.Empty;
+ if (string.IsNullOrEmpty (htmlColor)) return Color.Empty;
switch (htmlColor.ToLowerInvariant ()) {
case "buttonface":
- case "threedface":
+ case "threedface":
return SystemColors.Control;
case "buttonhighlight":
case "threedlightshadow":
case "lightgrey":
return Color.LightGray;
}
-
+
+ if (htmlColor[0] == '#' && htmlColor.Length == 4)
+ {
+ char r = htmlColor[1], g = htmlColor[2], b = htmlColor[3];
+ htmlColor = new string ( new char [] { '#', r, r, g, g, b, b } );
+ }
+
TypeConverter converter = TypeDescriptor.GetConverter (typeof (Color));
return (Color) converter.ConvertFromString (htmlColor);
}
Assert.AreEqual (0, ColorTranslator.FromHtml ("#0").ToArgb (), "#0");
Assert.AreEqual (1, ColorTranslator.FromHtml ("#1").ToArgb (), "#1");
Assert.AreEqual (255, ColorTranslator.FromHtml ("#FF").ToArgb (), "#FF");
+ Assert.AreEqual (-15654349, ColorTranslator.FromHtml ("#123").ToArgb (), "#123");
+ Assert.AreEqual (-1, ColorTranslator.FromHtml ("#FFF").ToArgb (), "#FFF");
Assert.AreEqual (65535, ColorTranslator.FromHtml ("#FFFF").ToArgb (), "#FFFF");
Assert.AreEqual (-15584170, ColorTranslator.FromHtml ("#123456").ToArgb (), "#123456");
Assert.AreEqual (-1, ColorTranslator.FromHtml ("#FFFFFF").ToArgb (), "#FFFFFF");
for (int i = 0; i < array.Length; ++i)
Assert.IsTrue (block.Post (i), "Not accepted");
- Assert.IsTrue (evt.Wait (500));
+ Assert.IsTrue (evt.Wait (1000));
Assert.IsTrue (array.All (b => b), "Some false");
}
block.Complete ();
- Assert.IsTrue (block.Completion.Wait (100));
+ Assert.IsTrue (block.Completion.Wait (1000));
}
[Test]
scheduler.ExecuteAll ();
- Assert.IsTrue (block.Completion.Wait (100));
+ Assert.IsTrue (block.Completion.Wait (1000));
}
[Test]
block.Complete ();
CollectionAssert.AreEqual (new[] { 1 },
- block.Receive (TimeSpan.FromMilliseconds (200)));
+ block.Receive (TimeSpan.FromMilliseconds (2000)));
- Assert.IsTrue (block.Completion.Wait (100));
+ Assert.IsTrue (block.Completion.Wait (1000));
}
[Test]
block.Complete ();
CollectionAssert.AreEqual (new[] { 1, 2 },
- block.Receive (TimeSpan.FromMilliseconds (200)));
+ block.Receive (TimeSpan.FromMilliseconds (2000)));
- Assert.IsTrue (block.Completion.Wait (100));
+ Assert.IsTrue (block.Completion.Wait (1000));
}
[Test]
block.Complete ();
CollectionAssert.AreEqual (new[] { 1 },
- block.Receive (TimeSpan.FromMilliseconds (200)));
+ block.Receive (TimeSpan.FromMilliseconds (2000)));
- Assert.IsTrue (block.Completion.Wait (100));
+ Assert.IsTrue (block.Completion.Wait (1000));
}
[Test]
int[] batch;
Assert.IsFalse (block.TryReceive (out batch));
- Assert.IsTrue (block.Completion.Wait (100));
+ Assert.IsTrue (block.Completion.Wait (1000));
}
[Test]
Assert.IsTrue (block.TryReceive (out batch));
CollectionAssert.AreEquivalent (new[] { 11, 21 }, batch);
- Assert.IsTrue (block.Completion.Wait (100));
+ Assert.IsTrue (block.Completion.Wait (1000));
}
}
}
\ No newline at end of file
Assert.IsTrue (block.Target2.Post (2));
- Assert.IsTrue (evt.Wait (100));
+ Assert.IsTrue (evt.Wait (1000));
Assert.IsNotNull (result);
CollectionAssert.AreEqual (new[] { 1 }, result.Item1);
Assert.IsNull (result);
Assert.IsTrue (block.Target1.Post (4));
- Assert.IsTrue (evt.Wait (100));
+ Assert.IsTrue (evt.Wait (1000));
Assert.IsNotNull (result);
CollectionAssert.AreEqual (new[] { 3, 4 }, result.Item1);
Assert.IsNull (result);
Assert.IsTrue (block.Target2.Post (6));
- Assert.IsTrue (evt.Wait (100));
+ Assert.IsTrue (evt.Wait (1000));
Assert.IsNotNull (result);
CollectionAssert.IsEmpty (result.Item1);
CollectionAssert.AreEqual (new[] { 1 }, batch.Item1);
CollectionAssert.IsEmpty (batch.Item2);
- Assert.IsTrue (block.Completion.Wait (100));
+ Assert.IsTrue (block.Completion.Wait (1000));
}
[Test]
scheduler.ExecuteAll ();
- Assert.IsTrue (block.Completion.Wait (100));
+ Assert.IsTrue (block.Completion.Wait (1000));
}
}
}
\ No newline at end of file
Assert.IsTrue (block.Target3.Post ("foo"));
- Assert.IsTrue (evt.Wait (100));
+ Assert.IsTrue (evt.Wait (1000));
Assert.IsNotNull (result);
CollectionAssert.AreEqual (new[] { 1 }, result.Item1);
CollectionAssert.IsEmpty (batch.Item2);
CollectionAssert.IsEmpty (batch.Item3);
- Assert.IsTrue (block.Completion.Wait (100));
+ Assert.IsTrue (block.Completion.Wait (1000));
}
[Test]
scheduler.ExecuteAll ();
- Assert.IsTrue (block.Completion.Wait (100));
+ Assert.IsTrue (block.Completion.Wait (1000));
}
}
}
\ No newline at end of file
Assert.AreEqual (DataflowMessageStatus.Postponed,
target.OfferMessage (header, 43, source, false));
- Assert.AreEqual (42, block.Receive (TimeSpan.FromMilliseconds (100)));
+ Assert.AreEqual (42, block.Receive (TimeSpan.FromMilliseconds (1000)));
Assert.IsFalse (block.Completion.Wait (100));
Assert.IsTrue (source.WasConsumed (header));
- Assert.AreEqual (43, block.Receive (TimeSpan.FromMilliseconds (100)));
+ Assert.AreEqual (43, block.Receive (TimeSpan.FromMilliseconds (1000)));
Assert.AreEqual (DataflowMessageStatus.Accepted,
target.OfferMessage (new DataflowMessageHeader (3), 44, source, false));
Assert.IsTrue (broadcast.Post (42));
- Assert.IsTrue (evt.Wait (100));
+ Assert.IsTrue (evt.Wait (1000));
Assert.IsTrue (act1);
Assert.IsTrue (act2);
broadcast.LinkTo (action);
- Assert.IsTrue (evt.Wait (100));
+ Assert.IsTrue (evt.Wait (1000));
Assert.IsTrue (act);
}
Assert.IsTrue (broadcast.Post (2));
Assert.AreEqual (1, target.Receive (TimeSpan.FromMilliseconds (0)));
- Assert.AreEqual (2, target.Receive (TimeSpan.FromMilliseconds (100)));
+ Assert.AreEqual (2, target.Receive (TimeSpan.FromMilliseconds (1000)));
}
[Test]
Assert.IsTrue (broadcast.Post (2));
AssertEx.Throws<TimeoutException> (
- () => target.Receive (TimeSpan.FromMilliseconds (100)));
+ () => target.Receive (TimeSpan.FromMilliseconds (1000)));
scheduler.ExecuteAll ();
Assert.IsTrue (broadcast.Post (source));
- Assert.IsTrue (evt.Wait (100));
+ Assert.IsTrue (evt.Wait (1000));
Assert.IsNotNull (act1);
Assert.IsNotNull (act2);
source1.Post (42);
- Assert.IsTrue (completion.Wait (500));
+ Assert.IsTrue (completion.Wait (1000));
Assert.AreEqual (0, completion.Result);
Assert.IsTrue (action1);
Assert.IsFalse (action2);
source1.Post (42);
source1.Post (43);
- Assert.IsTrue (completion.Wait (500));
+ Assert.IsTrue (completion.Wait (1000));
Assert.AreEqual (0, completion.Result);
Assert.AreEqual (1, action1);
Assert.AreEqual (0, action2);
Task.WaitAll (t1, t2);
- Assert.IsTrue (completion.Wait (500));
+ Assert.IsTrue (completion.Wait (1000));
Assert.AreEqual (1, action1 + action2);
int item;
source1.Post (10);
- Assert.IsTrue (completion.Wait (500));
+ Assert.IsTrue (completion.Wait (1000));
Assert.AreEqual (0, completion.Result);
Assert.AreEqual (42, action1);
Assert.AreEqual (0, action2);
source1.Post (42);
- var ae = AssertEx.Throws<AggregateException> (() => completion.Wait (500));
+ var ae = AssertEx.Throws<AggregateException> (() => completion.Wait (1000));
Assert.AreEqual (1, ae.InnerExceptions.Count);
Assert.AreSame (exception, ae.InnerException);
}
source3.Post (new object ());
- Assert.IsTrue (completion.Wait (500));
+ Assert.IsTrue (completion.Wait (1000));
Assert.AreEqual (2, completion.Result);
Assert.IsFalse (action1);
Assert.IsFalse (action2);
Assert.AreEqual (42, block.Receive ());
- Assert.IsTrue (block.Completion.Wait (100));
+ Assert.IsTrue (block.Completion.Wait (1000));
Assert.IsTrue (block.Completion.IsCompleted);
Assert.AreEqual (TaskStatus.RanToCompletion, block.Completion.Status);
}
Assert.IsTrue (block.Post (42));
((IDataflowBlock)block).Fault (new Exception ());
- AssertEx.Throws<AggregateException> (() => block.Completion.Wait (100));
+ AssertEx.Throws<AggregateException> (() => block.Completion.Wait (1000));
Assert.IsTrue (block.Completion.IsCompleted);
Assert.AreEqual (TaskStatus.Faulted, block.Completion.Status);
Assert.IsFalse (block.Post (43));
tokenSource.Cancel ();
var ae = AssertEx.Throws<AggregateException> (
- () => block.Completion.Wait (100));
+ () => block.Completion.Wait (1000));
Assert.AreEqual (1, ae.InnerExceptions.Count);
Assert.AreEqual (typeof(TaskCanceledException), ae.InnerException.GetType ());
((IDataflowBlock)block).Fault (new Exception ("fault"));
var exception =
- AssertEx.Throws<AggregateException> (() => block.Completion.Wait (100));
+ AssertEx.Throws<AggregateException> (() => block.Completion.Wait (1000));
Assert.AreEqual (1, exception.InnerExceptions.Count);
Assert.AreEqual ("action", exception.InnerException.Message);
tokenSource.Cancel ();
var exception =
- AssertEx.Throws<AggregateException> (() => block.Completion.Wait (100));
+ AssertEx.Throws<AggregateException> (() => block.Completion.Wait (1000));
Assert.AreEqual (1, exception.InnerExceptions.Count);
Assert.AreEqual ("action", exception.InnerException.Message);
evt.Set ();
var exception =
- AssertEx.Throws<AggregateException> (() => block.Completion.Wait (100));
+ AssertEx.Throws<AggregateException> (() => block.Completion.Wait (1000));
Assert.AreEqual (1, exception.InnerExceptions.Count);
Assert.AreEqual ("action", exception.InnerException.Message);
((IDataflowBlock)block).Fault (new Exception ("fault"));
var exception =
- AssertEx.Throws<AggregateException> (() => block.Completion.Wait (100));
+ AssertEx.Throws<AggregateException> (() => block.Completion.Wait (1000));
Assert.AreEqual (1, exception.InnerExceptions.Count);
Assert.AreEqual (typeof(TaskCanceledException),
Thread.Sleep (100);
var exception =
- AssertEx.Throws<AggregateException> (() => block.Completion.Wait (100));
+ AssertEx.Throws<AggregateException> (() => block.Completion.Wait (1000));
Assert.AreEqual (1, exception.InnerExceptions.Count);
Assert.AreEqual (typeof(TaskCanceledException),
Thread.Sleep (100);
var exception =
- AssertEx.Throws<AggregateException> (() => block.Completion.Wait (100));
+ AssertEx.Throws<AggregateException> (() => block.Completion.Wait (1000));
Assert.AreEqual (1, exception.InnerExceptions.Count);
Assert.AreEqual ("fault", exception.InnerException.Message);
var block = new BufferBlock<int> ();
block.Complete ();
AssertEx.Throws<InvalidOperationException> (
- () => block.Receive (TimeSpan.FromMilliseconds (100)));
+ () => block.Receive (TimeSpan.FromMilliseconds (1000)));
}
[Test]
{
var block = new BufferBlock<int> ();
AssertEx.Throws<TimeoutException> (
- () => block.Receive (TimeSpan.FromMilliseconds (100)));
+ () => block.Receive (TimeSpan.FromMilliseconds (1000)));
}
[Test]
Assert.AreEqual (1, target.Receive ());
- Assert.IsTrue (task.Wait (100));
+ Assert.IsTrue (task.Wait (1000));
Assert.IsTrue (task.Result);
}
target.Complete ();
- Assert.IsTrue (task.Wait (100));
+ Assert.IsTrue (task.Wait (1000));
Assert.IsFalse (task.Result);
}
block.Post (1);
var ae =
- AssertEx.Throws<AggregateException> (() => block.Completion.Wait (100));
+ AssertEx.Throws<AggregateException> (() => block.Completion.Wait (1000));
Assert.AreEqual (1, ae.InnerExceptions.Count);
Assert.AreSame (exception, ae.InnerException);
}
shouldRun = 0;
evt.Set ();
- AssertEx.Throws<AggregateException> (() => block.Completion.Wait (100));
+ AssertEx.Throws<AggregateException> (() => block.Completion.Wait (1000));
Thread.Sleep (100);
scheduler.ExecuteAll ();
var ae =
- AssertEx.Throws<AggregateException> (() => block.Completion.Wait (100)).
+ AssertEx.Throws<AggregateException> (() => block.Completion.Wait (1000)).
Flatten ();
Assert.AreEqual (1, ae.InnerExceptions.Count);
Task.Factory.StartNew (() => block.Target1.Post (42));
Task.Factory.StartNew (() => block.Target2.Post (24));
- Assert.IsTrue (evt.Wait (500));
+ Assert.IsTrue (evt.Wait (1000));
Assert.IsNotNull (tuple);
Assert.AreEqual (42, tuple.Item1);
Assert.AreEqual (24, tuple.Item2);
Tuple<int, int> tuple;
Assert.IsFalse (block.TryReceive (out tuple));
- Assert.IsTrue (block.Completion.Wait (100));
+ Assert.IsTrue (block.Completion.Wait (1000));
}
[Test]
scheduler.ExecuteAll ();
- Assert.IsTrue (block.Completion.Wait (100));
+ Assert.IsTrue (block.Completion.Wait (1000));
}
[Test]
Assert.IsTrue (block.TryReceive (out tuple));
Assert.AreEqual (Tuple.Create (11, 21), tuple);
- Assert.IsTrue (block.Completion.Wait (100));
+ Assert.IsTrue (block.Completion.Wait (1000));
}
}
}
\ No newline at end of file
block.Target1.Post (42);
- evt.Wait (500);
+ evt.Wait (1000);
Assert.IsNull (tuple);
block.Target2.Post (24);
- evt.Wait (500);
+ evt.Wait (1000);
Assert.IsNull (tuple);
block.Target3.Post (44);
Tuple<int, int, int> tuple;
Assert.IsFalse (block.TryReceive (out tuple));
- Assert.IsTrue (block.Completion.Wait (100));
+ Assert.IsTrue (block.Completion.Wait (1000));
}
[Test]
scheduler.ExecuteAll ();
- Assert.IsTrue (block.Completion.Wait (100));
+ Assert.IsTrue (block.Completion.Wait (1000));
}
[Test]
Assert.IsTrue (block.TryReceive (out tuple));
Assert.AreEqual (Tuple.Create (11, 21, 31), tuple);
- Assert.IsTrue (block.Completion.Wait (100));
+ Assert.IsTrue (block.Completion.Wait (1000));
}
}
}
\ No newline at end of file
foreach (var block in blocks) {
var ae =
- AssertEx.Throws<AggregateException> (() => block.Completion.Wait (100));
+ AssertEx.Throws<AggregateException> (() => block.Completion.Wait (1000));
Assert.AreEqual (1, ae.InnerExceptions.Count);
Assert.IsInstanceOfType (typeof(TaskCanceledException), ae.InnerExceptions [0]);
Assert.IsTrue (block.Completion.IsCanceled);
source.LinkTo (new BufferBlock<int> ());
}
- Assert.IsTrue (block.Completion.Wait (500));
+ Assert.IsTrue (block.Completion.Wait (1000));
CollectionAssert.AreEquivalent (
Enumerable.Range (0, 100), queue.Select (t => t.Item1));
Assert.IsNotNull (action);
- Assert.IsTrue (action.Completion.Wait (100));
+ Assert.IsTrue (action.Completion.Wait (1000));
Assert.IsTrue (task.Wait (0));
}
evt.Set ();
- Assert.IsTrue (Task.WaitAll (new Task[] { task1, task2 }, 100));
+ Assert.IsTrue (Task.WaitAll (new Task[] { task1, task2 }, 1000));
CollectionAssert.AreEquivalent (
new[]
Assert.IsTrue(source.Post(1));
- Assert.IsTrue(task.Wait(100));
+ Assert.IsTrue(task.Wait(1000));
Assert.IsTrue(task.Result);
}
var task = source.OutputAvailableAsync();
- Assert.IsTrue(task.Wait(100));
+ Assert.IsTrue(task.Wait(1000));
Assert.IsFalse(task.Result);
}
source.Complete();
- Assert.IsTrue(task.Wait(100));
+ Assert.IsTrue(task.Wait(1000));
Assert.IsFalse(task.Result);
}
var task = source.OutputAvailableAsync();
- Assert.IsTrue(task.Wait(100));
+ Assert.IsTrue(task.Wait(1000));
Assert.IsFalse(task.Result);
}
((IDataflowBlock)source).Fault(new Exception());
- Assert.IsTrue(task.Wait(100));
+ Assert.IsTrue(task.Wait(1000));
Assert.IsFalse(task.Result);
}
Assert.IsTrue(source.Post(1));
- Assert.IsTrue(task.Wait(100));
+ Assert.IsTrue(task.Wait(1000));
Assert.IsTrue(task.Result);
}
tokenSource.Cancel();
- AssertEx.Throws<AggregateException>(() => task.Wait(100));
+ AssertEx.Throws<AggregateException>(() => task.Wait(1000));
Assert.IsTrue(task.IsCanceled);
}
}
Assert.IsFalse (target.Completion.Wait (100));
source.Complete ();
- Assert.IsTrue (target.Completion.Wait (100));
+ Assert.IsTrue (target.Completion.Wait (1000));
}
[Test]
source.Fault (exception);
var ae =
- AssertEx.Throws<AggregateException> (() => source.Completion.Wait (100));
+ AssertEx.Throws<AggregateException> (() => source.Completion.Wait (1000));
Assert.AreEqual (exception, ae.Flatten ().InnerException);
- ae = AssertEx.Throws<AggregateException> (() => target.Completion.Wait (100));
+ ae = AssertEx.Throws<AggregateException> (() => target.Completion.Wait (1000));
Assert.AreEqual (exception, ae.Flatten ().InnerException);
}
tokenSource.Cancel ();
var ae =
- AssertEx.Throws<AggregateException> (() => source.Completion.Wait (100));
+ AssertEx.Throws<AggregateException> (() => source.Completion.Wait (1000));
Assert.IsInstanceOfType (
typeof(TaskCanceledException), ae.Flatten ().InnerException);
- Assert.IsTrue (target.Completion.Wait (100));
+ Assert.IsTrue (target.Completion.Wait (1000));
}
[Test]
Assert.IsFalse (target.Completion.Wait (100));
Assert.AreEqual (42, target.Receive ());
- Assert.IsTrue (target.Completion.Wait (100));
+ Assert.IsTrue (target.Completion.Wait (1000));
}
[Test]
scheduler.ExecuteAll ();
Assert.AreEqual (default(int), target.DirectlyAccepted);
- Assert.AreEqual (42, source.Receive (TimeSpan.FromMilliseconds (100)));
+ Assert.AreEqual (42, source.Receive (TimeSpan.FromMilliseconds (1000)));
scheduler.ExecuteAll ();
Assert.AreEqual (43, target.DirectlyAccepted);
}
new BufferBlock<int> (new DataflowBlockOptions { TaskScheduler = scheduler });
AssertEx.Throws<TimeoutException> (
- () => block.Receive (TimeSpan.FromMilliseconds (100)));
+ () => block.Receive (TimeSpan.FromMilliseconds (1000)));
block.Post (1);
block.Complete ();
- Assert.IsTrue (block.Completion.Wait (100));
+ Assert.IsTrue (block.Completion.Wait (1000));
}
[Test]
Assert.IsTrue (transformMany.Post (1), "#1");
transformMany.Complete ();
- Assert.IsTrue (transformMany.Completion.Wait (100), "#2");
+ Assert.IsTrue (transformMany.Completion.Wait (1000), "#2");
Assert.IsFalse (received, "#3");
}
block.Complete ();
- Assert.IsTrue (block.Completion.Wait (100));
+ Assert.IsTrue (block.Completion.Wait (1000));
}
[Test]
Assert.IsTrue (block.Post (42), "#1");
Assert.IsFalse (block.Post (43), "#2");
- Assert.IsTrue (evt.Wait (100), "#3");
+ Assert.IsTrue (evt.Wait (1000), "#3");
Assert.IsTrue (act1, "#4");
Assert.IsTrue (act2, "#5");
block.LinkTo (action);
- Assert.IsTrue (evt.Wait (100));
+ Assert.IsTrue (evt.Wait (1000));
Assert.IsTrue (act);
}
Assert.IsTrue (block.Post (2));
- Assert.AreEqual (1, target.Receive (TimeSpan.FromMilliseconds (100)));
- Assert.AreEqual (2, target.Receive (TimeSpan.FromMilliseconds (100)));
+ Assert.AreEqual (1, target.Receive (TimeSpan.FromMilliseconds (1000)));
+ Assert.AreEqual (2, target.Receive (TimeSpan.FromMilliseconds (1000)));
}
[Test]
Assert.IsTrue (block.Post (1));
AssertEx.Throws<TimeoutException> (
- () => target.Receive (TimeSpan.FromMilliseconds (100)));
+ () => target.Receive (TimeSpan.FromMilliseconds (1000)));
scheduler.ExecuteAll ();
Assert.IsTrue (block.Post (source));
- Assert.IsTrue (evt.Wait (100));
+ Assert.IsTrue (evt.Wait (1000));
Assert.IsNotNull (act1);
Assert.IsNotNull (act2);
Assert.IsTrue (broadcast.Post (42));
- Assert.IsTrue (evt.Wait (100));
+ Assert.IsTrue (evt.Wait (1000));
Assert.IsTrue (act1);
Assert.IsTrue (act2);
+++ /dev/null
-// 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.
-//
-// Copyright (c) 2005 Novell, Inc. (http://www.novell.com)
-//
-// Authors:
-// Peter Bartok (pbartok@novell.com)
-// Marek Safar (marek.safar@gmail.com)
-//
-//
-
-using System.Collections;
-using System.Drawing;
-using System.Globalization;
-using System.ComponentModel;
-using System.Security.Permissions;
-using System.Web.Util;
-
-namespace System.Web.UI.WebControls {
-
- // CAS
- [AspNetHostingPermission (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
- [AspNetHostingPermission (SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
- public class WebColorConverter : ColorConverter
- {
- // Converts from string to Color
- public override object ConvertFrom (ITypeDescriptorContext context, CultureInfo culture, object value)
- {
- if (value is string) {
- string s = ((string)value).Trim();
- return ColorTranslator.FromHtml (s);
- }
-
- return base.ConvertFrom (context, culture, value);
- }
-
- // Converts from Color to string
- public override object ConvertTo (ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
- {
- if (!(value is Color) || destinationType != typeof (string))
- return base.ConvertTo (context, culture, value, destinationType);
-
- Color c = (Color) value;
-
- if (culture == null)
- culture = Helpers.InvariantCulture;
-
- string s = c.ToKnownColor ().ToString ();
- if (s != "0")
- return s;
-
- return String.Concat ("#", c.R.ToString ("X2"), c.G.ToString ("X2"), c.B.ToString ("X2"));
- }
- }
-}
../../../external/referencesource/System.Web/UI/WebControls/VerticalAlign.cs
System.Web.UI.WebControls/ViewCollection.cs
System.Web.UI.WebControls/View.cs
-System.Web.UI.WebControls/WebColorConverter.cs
+../../../external/referencesource/System.Web/UI/WebControls/WebColorConverter.cs
System.Web.UI.WebControls/WebControl.cs
System.Web.UI.WebControls.WebParts/ConnectionConsumerCallback.cs
System.Web.UI.WebControls.WebParts/ConnectionInterfaceCollection.cs
System.Web.Util/HttpEncoder.cs
System.Web.Util/ICalls.cs
../../../external/referencesource/System.Web/Util/IObjectFactory.cs
+../../../external/referencesource/System.Web/Util/StringUtil.cs
System.Web.Util/IWebPropertyAccessor.cs
System.Web.Util/MachineKeySectionUtils.cs
System.Web.Util/RuntimeHelpers.cs
}
internal void Initialize () {
+ if (Marshal.SizeOf<IntPtr> () == 8){
+ Console.Error.WriteLine ("WARNING: The Carbon driver has not been ported to 64bits, and very few parts of Windows.Forms will work properly, or at all");
+ }
// Initialize the event handlers
Carbon.EventHandler.Driver = this;
ApplicationHandler = new Carbon.ApplicationHandler (this);
--- /dev/null
+#include mobile_System.Xml.dll.sources
--- /dev/null
+#include mobile_System.Xml.dll.sources
{
readonly object sender;
readonly MonoTlsSettings settings;
+ readonly MonoTlsProvider provider;
readonly ServerCertValidationCallback certValidationCallback;
readonly LocalCertSelectionCallback certSelectionCallback;
readonly ServerCertValidationCallbackWrapper callbackWrapper;
#endif
}
- internal static ICertificateValidator GetDefaultValidator (MonoTlsSettings settings)
+ internal static ICertificateValidator GetDefaultValidator (MonoTlsProvider provider, MonoTlsSettings settings)
{
if (settings == null)
- return new ChainValidationHelper (null, false, null, null);
- if (settings.CertificateValidator == null)
- settings.CertificateValidator = new ChainValidationHelper (settings, false, null, null);
- return settings.CertificateValidator;
+ return new ChainValidationHelper (provider, null, false, null, null);
+ if (settings.CertificateValidator != null)
+ return settings.CertificateValidator;
+ return new ChainValidationHelper (provider, settings, false, null, null);
}
#region SslStream support
/*
* This is a hack which is used in SslStream - see ReferenceSources/SslStream.cs for details.
*/
- internal static ChainValidationHelper CloneWithCallbackWrapper (ref MonoTlsSettings settings, ServerCertValidationCallbackWrapper wrapper)
+ internal static ChainValidationHelper CloneWithCallbackWrapper (MonoTlsProvider provider, ref MonoTlsSettings settings, ServerCertValidationCallbackWrapper wrapper)
{
var helper = (ChainValidationHelper)settings.CertificateValidator;
if (helper == null)
- helper = new ChainValidationHelper (settings, true, null, wrapper);
+ helper = new ChainValidationHelper (provider, settings, true, null, wrapper);
else
- helper = new ChainValidationHelper (helper, settings, wrapper);
+ helper = new ChainValidationHelper (helper, provider, settings, wrapper);
settings = helper.settings;
return helper;
}
#endregion
- ChainValidationHelper (ChainValidationHelper other, MonoTlsSettings settings, ServerCertValidationCallbackWrapper callbackWrapper = null)
+ ChainValidationHelper (ChainValidationHelper other, MonoTlsProvider provider, MonoTlsSettings settings, ServerCertValidationCallbackWrapper callbackWrapper = null)
{
sender = other.sender;
certValidationCallback = other.certValidationCallback;
tlsStream = other.tlsStream;
request = other.request;
+ this.provider = provider;
this.settings = settings = settings.CloneWithValidator (this);
this.callbackWrapper = callbackWrapper;
}
- internal static ChainValidationHelper Create (ref MonoTlsSettings settings, MonoTlsStream stream)
+ internal static ChainValidationHelper Create (MonoTlsProvider provider, ref MonoTlsSettings settings, MonoTlsStream stream)
{
- var helper = new ChainValidationHelper (settings, true, stream, null);
+ var helper = new ChainValidationHelper (provider, settings, true, stream, null);
settings = helper.settings;
return helper;
}
- ChainValidationHelper (MonoTlsSettings settings, bool cloneSettings, MonoTlsStream stream, ServerCertValidationCallbackWrapper callbackWrapper)
+ ChainValidationHelper (MonoTlsProvider provider, MonoTlsSettings settings, bool cloneSettings, MonoTlsStream stream, ServerCertValidationCallbackWrapper callbackWrapper)
{
if (cloneSettings)
settings = settings.CloneWithValidator (this);
+ this.provider = provider;
this.settings = settings;
this.tlsStream = stream;
this.callbackWrapper = callbackWrapper;
return clientCertificate;
}
+ public MonoTlsProvider Provider {
+ get { return provider; }
+ }
+
public MonoTlsSettings Settings {
get { return settings; }
}
get { return certSelectionCallback != null; }
}
- public X509Certificate SelectClientCertificate (
+ public bool SelectClientCertificate (
+ string targetHost, XX509CertificateCollection localCertificates, X509Certificate remoteCertificate,
+ string[] acceptableIssuers, out X509Certificate clientCertificate)
+ {
+ if (certSelectionCallback == null) {
+ clientCertificate = null;
+ return false;
+ }
+ clientCertificate = certSelectionCallback (targetHost, localCertificates, remoteCertificate, acceptableIssuers);
+ return true;
+ }
+
+ internal X509Certificate SelectClientCertificate (
string targetHost, XX509CertificateCollection localCertificates, X509Certificate remoteCertificate,
string[] acceptableIssuers)
{
var certs = new XX509CertificateCollection ();
certs.Add (new X509Certificate2 (certificate.GetRawCertData ()));
- var result = ValidateChain (null, certs, (SslPolicyErrors)errors);
+ var result = ValidateChain (string.Empty, true, certs, (SslPolicyErrors)errors);
if (result == null)
return false;
return result.Trusted && !result.UserDenied;
}
- internal static SystemCertificateValidator GetSystemCertificateValidator ()
- {
- return new SystemCertificateValidator ();
- }
-
- public ValidationResult ValidateClientCertificate (XX509CertificateCollection certs)
- {
- return ValidateChain (string.Empty, certs, 0);
- }
-
- public ValidationResult ValidateChain (string host, XX509CertificateCollection certs)
+ public ValidationResult ValidateCertificate (string host, bool serverMode, XX509CertificateCollection certs)
{
try {
- var result = ValidateChain (host, certs, 0);
+ var result = ValidateChain (host, serverMode, certs, 0);
if (tlsStream != null)
tlsStream.CertificateValidationFailed = result == null || !result.Trusted || result.UserDenied;
return result;
}
}
- ValidationResult ValidateChain (string host, XX509CertificateCollection certs, SslPolicyErrors errors)
+ ValidationResult ValidateChain (string host, bool server, XX509CertificateCollection certs, SslPolicyErrors errors)
{
// user_denied is true if the user callback is called and returns false
bool user_denied = false;
bool result = false;
var hasCallback = certValidationCallback != null || callbackWrapper != null;
- var anchors = settings != null ? settings.TrustAnchors : null;
-
- var systemValidator = GetSystemCertificateValidator ();
X509Certificate leaf;
if (certs == null || certs.Count == 0)
return new ValidationResult (result, user_denied, 0, (MonoSslPolicyErrors)errors);
}
- bool needsChain;
- bool skipSystemValidators = false;
- if (!CertificateValidationHelper.SupportsX509Chain || is_mobile || is_macosx) {
- needsChain = false;
- } else if (settings != null) {
- skipSystemValidators = settings.SkipSystemValidators;
- needsChain = !settings.SkipSystemValidators || settings.CallbackNeedsCertificateChain;
- } else {
- needsChain = true;
- }
-
ICertificatePolicy policy = ServicePointManager.GetLegacyCertificatePolicy ();
int status11 = 0; // Error code passed to the obsolete ICertificatePolicy callback
X509Chain chain = null;
-#if !MOBILE
- if (needsChain)
- chain = systemValidator.ComputeX509Chain (certs, ref errors, ref status11);
-#endif
-
- systemValidator.CheckUsage (certs, host, ref errors, ref status11);
+ bool providerValidated = false;
+ if (provider != null && provider.HasCustomSystemCertificateValidator) {
+ if (SystemCertificateValidator.NeedsChain (settings))
+ throw new NotSupportedException ("Cannot use MonoTlsProvider.InvokeSystemCertificateValidator() when the X509Chain is required.");
+ var xerrors = (MonoSslPolicyErrors)errors;
+ providerValidated = provider.InvokeSystemCertificateValidator (this, host, server, certs, out result, ref xerrors, ref status11);
+ errors = (SslPolicyErrors)xerrors;
+ }
- if (!skipSystemValidators)
- result = systemValidator.EvaluateSystem (certs, anchors, host, chain, ref errors, ref status11);
+ if (!providerValidated)
+ result = SystemCertificateValidator.Evaluate (settings, host, certs, ref chain, ref errors, ref status11);
if (policy != null && (!(policy is DefaultCertificatePolicy) || certValidationCallback == null)) {
ServicePoint sp = null;
}
return new ValidationResult (result, user_denied, status11, (MonoSslPolicyErrors)errors);
}
+
+ public bool InvokeSystemValidator (string targetHost, bool serverMode, XX509CertificateCollection certificates, ref MonoSslPolicyErrors xerrors, ref int status11)
+ {
+ if (SystemCertificateValidator.NeedsChain (settings))
+ throw new NotSupportedException ("Cannot use ICertificateValidator.InvokeSystemValidator() when the X509Chain is required.");
+
+ X509Chain chain = null;
+ var errors = (SslPolicyErrors)xerrors;
+ var result = SystemCertificateValidator.Evaluate (settings, targetHost, certificates, ref chain, ref errors, ref status11);
+ xerrors = (MonoSslPolicyErrors)errors;
+ return result;
+ }
}
}
#endif
#region Fields
SslStreamBase ssl_stream;
+ MonoTlsProvider provider;
MonoTlsSettings settings;
ICertificateValidator certificateValidator;
#region Constructors
- public LegacySslStream (Stream innerStream)
- : this (innerStream, false)
- {
- }
-
- public LegacySslStream (Stream innerStream, bool leaveInnerStreamOpen)
- : this (innerStream, leaveInnerStreamOpen, null)
- {
- }
-
- public LegacySslStream (Stream innerStream, bool leaveInnerStreamOpen, MonoTlsSettings settings)
+ public LegacySslStream (Stream innerStream, bool leaveInnerStreamOpen, MonoTlsProvider provider, MonoTlsSettings settings)
: base (innerStream, leaveInnerStreamOpen)
{
+ this.provider = provider;
this.settings = settings;
- this.certificateValidator = ChainValidationHelper.GetDefaultValidator (settings);
+ this.certificateValidator = ChainValidationHelper.GetDefaultValidator (provider, settings);
}
#endregion // Constructors
string [] acceptableIssuers = new string [serverRequestedCerts != null ? serverRequestedCerts.Count : 0];
for (int i = 0; i < acceptableIssuers.Length; i++)
acceptableIssuers [i] = serverRequestedCerts [i].GetIssuerName ();
- return certificateValidator.SelectClientCertificate (targetHost, clientCerts, serverCert, acceptableIssuers);
+ X509Certificate clientCertificate;
+ certificateValidator.SelectClientCertificate (targetHost, clientCerts, serverCert, acceptableIssuers, out clientCertificate);
+ return clientCertificate;
}
public virtual IAsyncResult BeginAuthenticateAsClient (string targetHost, AsyncCallback asyncCallback, object asyncState)
for (int i = 0; i < mcerts.Count; i++)
certs.Add (new X509Certificate2 (mcerts [i].RawData));
}
- return ((ChainValidationHelper)certificateValidator).ValidateChain (targetHost, certs);
+ return ((ChainValidationHelper)certificateValidator).ValidateCertificate (targetHost, false, certs);
};
s.ClientCertSelectionDelegate = OnCertificateSelection;
Stream innerStream, bool leaveInnerStreamOpen,
MonoTlsSettings settings)
{
- return new LegacySslStream (innerStream, leaveInnerStreamOpen, settings);
+ return new LegacySslStream (innerStream, leaveInnerStreamOpen, this, settings);
}
protected override IMonoTlsContext CreateTlsContextImpl (
}
}
- internal static HttpListener CreateHttpListener (X509Certificate2 certificate, MSI.MonoTlsProvider provider, MSI.MonoTlsSettings settings)
+ internal static HttpListener CreateHttpListener (X509Certificate certificate, MSI.MonoTlsProvider provider, MSI.MonoTlsSettings settings)
{
lock (locker) {
var internalProvider = provider != null ? new Private.MonoTlsProviderWrapper (provider) : null;
if (settings == null)
settings = new MonoTlsSettings ();
- validationHelper = ChainValidationHelper.Create (ref settings, this);
+ validationHelper = ChainValidationHelper.Create (provider.Provider, ref settings, this);
}
internal Stream CreateStream (byte[] buffer)
//
internal static class NoReflectionHelper
{
- internal static object GetDefaultCertificateValidator (object settings)
+ internal static object GetDefaultCertificateValidator (object provider, object settings)
{
#if SECURITY_DEP
- return ChainValidationHelper.GetDefaultValidator ((MSI.MonoTlsSettings)settings);
+ return ChainValidationHelper.GetDefaultValidator ((MSI.MonoTlsProvider)provider, (MSI.MonoTlsSettings)settings);
#else
throw new NotSupportedException ();
#endif
internal static object CreateHttpListener (object certificate, object provider, object settings)
{
#if SECURITY_DEP
- return MonoTlsProviderFactory.CreateHttpListener ((X509Certificate2)certificate, (MSI.MonoTlsProvider)provider, (MSI.MonoTlsSettings)settings);
+ return MonoTlsProviderFactory.CreateHttpListener ((X509Certificate)certificate, (MSI.MonoTlsProvider)provider, (MSI.MonoTlsSettings)settings);
#else
throw new NotSupportedException ();
#endif
namespace Mono.Net.Security
{
- internal class SystemCertificateValidator
+ internal static class SystemCertificateValidator
{
static bool is_macosx;
static bool is_mobile;
#endif
}
- public virtual X509Chain ComputeX509Chain (XX509CertificateCollection certs, ref SslPolicyErrors errors, ref int status11)
+ static X509Chain ComputeX509Chain (XX509CertificateCollection certs, ref SslPolicyErrors errors, ref int status11)
{
#if MOBILE
return null;
#endif
}
- public virtual void CheckUsage (XX509CertificateCollection certs, string host, ref SslPolicyErrors errors, ref int status11)
+ static void CheckUsage (XX509CertificateCollection certs, string host, ref SslPolicyErrors errors, ref int status11)
{
#if !MONOTOUCH
var leaf = (X509Certificate2)certs[0];
#endif
}
- public virtual bool EvaluateSystem (XX509CertificateCollection certs, XX509CertificateCollection anchors, string host, X509Chain chain, ref SslPolicyErrors errors, ref int status11)
+ static bool EvaluateSystem (XX509CertificateCollection certs, XX509CertificateCollection anchors, string host, X509Chain chain, ref SslPolicyErrors errors, ref int status11)
{
var leaf = certs [0];
var result = false;
return result;
}
+ public static bool Evaluate (
+ MonoTlsSettings settings, string host, XX509CertificateCollection certs,
+ ref X509Chain chain, ref SslPolicyErrors errors, ref int status11)
+ {
+#if !MOBILE
+ if (NeedsChain (settings) && chain == null)
+ chain = ComputeX509Chain (certs, ref errors, ref status11);
+#endif
+
+ CheckUsage (certs, host, ref errors, ref status11);
+
+ if (settings != null && settings.SkipSystemValidators)
+ return false;
+
+ var anchors = settings != null ? settings.TrustAnchors : null;
+ return EvaluateSystem (certs, anchors, host, chain, ref errors, ref status11);
+ }
+
+ internal static bool NeedsChain (MonoTlsSettings settings)
+ {
+#if MOBILE
+ return false;
+#else
+ if (!CertificateValidationHelper.SupportsX509Chain)
+ return false;
+ if (settings != null)
+ return !settings.SkipSystemValidators || settings.CallbackNeedsCertificateChain;
+ else
+ return true;
+#endif
+ }
+
#if !MOBILE
static int GetStatusFromChain (X509Chain chain)
{
if (encryptionPolicy != EncryptionPolicy.RequireEncryption && encryptionPolicy != EncryptionPolicy.AllowNoEncryption && encryptionPolicy != EncryptionPolicy.NoEncryption)
throw new ArgumentException (SR.GetString (SR.net_invalid_enum, "EncryptionPolicy"), "encryptionPolicy");
- var validationHelper = MNS.ChainValidationHelper.CloneWithCallbackWrapper (ref settings, myUserCertValidationCallbackWrapper);
+ var validationHelper = MNS.ChainValidationHelper.CloneWithCallbackWrapper (provider, ref settings, myUserCertValidationCallbackWrapper);
LocalCertSelectionCallback selectionCallback = null;
if (validationHelper.HasCertificateSelectionCallback)
static MonoTlsProvider GetProvider ()
{
- return new MNS.Private.MonoDefaultTlsProvider ();
+ return MonoTlsProviderFactory.GetDefaultProvider ();
}
public SslStream (Stream innerStream)
Hashtable prefixes; // Dictionary <ListenerPrefix, HttpListener>
ArrayList unhandled; // List<ListenerPrefix> unhandled; host = '*'
ArrayList all; // List<ListenerPrefix> all; host = '+'
- X509Certificate2 cert;
+ X509Certificate cert;
bool secure;
Dictionary<HttpConnection, HttpConnection> unregistered;
if (accepted == null)
return;
- if (epl.secure && (epl.cert == null || !epl.cert.HasPrivateKey)) {
+ if (epl.secure && epl.cert == null) {
accepted.Close ();
return;
}
int reuses;
bool context_bound;
bool secure;
- X509Certificate2 cert;
+ X509Certificate cert;
int s_timeout = 90000; // 90k ms for first request, 15k ms from then on
Timer timer;
IPEndPoint local_ep;
X509Certificate2 client_cert;
IMonoSslStream ssl_stream;
- public HttpConnection (Socket sock, EndPointListener epl, bool secure, X509Certificate2 cert)
+ public HttpConnection (Socket sock, EndPointListener epl, bool secure, X509Certificate cert)
{
this.sock = sock;
this.epl = epl;
int used = 0;
string line;
- try {
- line = ReadLine (buffer, position, len - position, ref used);
- position += used;
- } catch {
- context.ErrorMessage = "Bad request";
- context.ErrorStatus = 400;
- return true;
- }
+ while (true) {
+ if (context.HaveError)
+ return true;
+
+ if (position >= len)
+ break;
+
+ try {
+ line = ReadLine (buffer, position, len - position, ref used);
+ position += used;
+ } catch {
+ context.ErrorMessage = "Bad request";
+ context.ErrorStatus = 400;
+ return true;
+ }
- do {
if (line == null)
break;
+
if (line == "") {
if (input_state == InputState.RequestLine)
continue;
return true;
}
}
-
- if (context.HaveError)
- return true;
-
- if (position >= len)
- break;
- try {
- line = ReadLine (buffer, position, len - position, ref used);
- position += used;
- } catch {
- context.ErrorMessage = "Bad request";
- context.ErrorStatus = 400;
- return true;
- }
- } while (line != null);
+ }
if (used == len) {
ms.SetLength (0);
IMonoTlsProvider tlsProvider;
MSI.MonoTlsSettings tlsSettings;
- X509Certificate2 certificate;
+ X509Certificate certificate;
Hashtable registry; // Dictionary<HttpListenerContext,HttpListenerContext>
ArrayList ctx_queue; // List<HttpListenerContext> ctx_queue;
auth_schemes = AuthenticationSchemes.Anonymous;
}
- internal HttpListener (X509Certificate2 certificate, IMonoTlsProvider tlsProvider, MSI.MonoTlsSettings tlsSettings)
+ internal HttpListener (X509Certificate certificate, IMonoTlsProvider tlsProvider, MSI.MonoTlsSettings tlsSettings)
: this ()
{
this.certificate = certificate;
this.tlsSettings = tlsSettings;
}
- internal X509Certificate2 LoadCertificateAndKey (IPAddress addr, int port)
+ internal X509Certificate LoadCertificateAndKey (IPAddress addr, int port)
{
lock (registry) {
if (certificate != null)
string pvk_file = Path.Combine (path, String.Format ("{0}.pvk", port));
if (!File.Exists (pvk_file))
return null;
- certificate = new X509Certificate2 (cert_file);
- certificate.PrivateKey = PrivateKey.CreateFromFile (pvk_file).RSA;
+ var cert = new X509Certificate2 (cert_file);
+ cert.PrivateKey = PrivateKey.CreateFromFile (pvk_file).RSA;
+ certificate = cert;
return certificate;
} catch {
// ignore errors
var c = new TcpClient ("localhost", port);
h.Stop ();
}
+
+ // Test case for bug #31209
+ [Test]
+ public void Test_EmptyLineAtStart ()
+ {
+ var listener = HttpListener2Test.CreateAndStartListener ("http://127.0.0.1:9124/");
+ var ns = HttpListener2Test.CreateNS (9124);
+
+ HttpListener2Test.Send (ns, "\r\nGET / HTTP/1.1\r\nHost: 127.0.0.1\r\n\r\n");
+
+ bool timedout;
+ HttpListener2Test.GetContextWithTimeout (listener, 1000, out timedout);
+
+ Assert.IsFalse (timedout, "timed out");
+
+ ns.Close ();
+ listener.Close ();
+ }
}
}
--- /dev/null
+#include monotouch_System.dll.sources
--- /dev/null
+#include monotouch_System.dll.sources
public static readonly IntPtr
InvalidHandle = (IntPtr)(-1L);
+ static bool dump_handles = Environment.GetEnvironmentVariable ("MONO_DUMP_HANDLES_ON_ERROR_TOO_MANY_OPEN_FILES") != null;
+
// error methods
public static Exception GetException (MonoIOError error)
{
return new FileNotFoundException (message, path);
case MonoIOError.ERROR_TOO_MANY_OPEN_FILES:
+ if (dump_handles)
+ DumpHandles ();
return new IOException ("Too many open files", unchecked((int)0x80070000) | (int)error);
case MonoIOError.ERROR_PATH_NOT_FOUND:
[MethodImplAttribute (MethodImplOptions.InternalCall)]
get;
}
+
+ [MethodImplAttribute (MethodImplOptions.InternalCall)]
+ extern static void DumpHandles ();
}
}
if (keys == null)
throw new ArgumentNullException ("keys");
-
- if (keys.Length != items.Length)
- throw new ArgumentException ("Length of keys and items does not match.");
-
+
+ if (keys.Length > items.Length)
+ throw new ArgumentException ("Length of keys is larger than length of items.");
+
SortImpl<TKey, TValue> (keys, items, 0, keys.Length, comparer);
}
//
// Moved value from instance into target of different type with no checks (JIT intristics)
//
+ // Restrictions:
+ //
+ // S and R must either:
+ // both be blitable valuetypes
+ // both be reference types (IOW, an unsafe cast)
+ // S and R cannot be float or double
+ // S and R must either:
+ // both be a struct
+ // both be a scalar
+ // S and R must either:
+ // be of same size
+ // both be a scalar of size <= 4
+ //
internal static R UnsafeMov<S,R> (S instance) {
return (R)(object) instance;
}
else {
abbrevs.Add (abbrev_index, sb.ToString ());
//Adding all the substrings too, as it seems to be used, at least for Africa/Windhoek
- for (int j = 1; j < sb.Length; j++)
+ //j == sb.Length empty substring also needs to be added #31432
+ for (int j = 1; j <= sb.Length; j++)
abbrevs.Add (abbrev_index + j, sb.ToString (j, sb.Length - j));
abbrev_index = i + 1;
sb = new StringBuilder ();
Assert.AreSame (expected, t.BaseType, "#1");
}
+
+ [Test]
+ public void GenericClassFromStaleTypeBuilderDoesNotClassInit ()
+ {
+ // interface JJJ<T> {
+ // abstract void W (x : T)
+ // }
+ MethodInfo winfo = null;
+ TypeBuilder ib = null;
+ Type ic = null;
+ Type icreated = null;
+ {
+ ib = module.DefineType ("Foo.JJJ`1",
+ TypeAttributes.Public
+ | TypeAttributes.Interface
+ | TypeAttributes.Abstract);
+ String[] gens = { "T" };
+ GenericTypeParameterBuilder[] gbs = ib.DefineGenericParameters (gens);
+ var gb = gbs[0];
+ winfo = ib.DefineMethod ("W",
+ MethodAttributes.Public |
+ MethodAttributes.Abstract |
+ MethodAttributes.Virtual,
+ CallingConventions.HasThis,
+ typeof(void),
+ new Type[] { gb });
+ icreated = ib.CreateType();
+
+ }
+
+ // class SSS : JJJ<char> {
+ // bool wasCalled;
+ // void JJJ.W (x : T) { wasCalled = true; return; }
+ // }
+ TypeBuilder tb = null;
+ MethodBuilder mb = null;
+ {
+ tb = module.DefineType ("Foo.SSS",
+ TypeAttributes.Public,
+ null,
+ new Type[]{ icreated.MakeGenericType(typeof(char)) });
+ var wasCalledField = tb.DefineField ("wasCalled",
+ typeof(bool),
+ FieldAttributes.Public);
+ mb = tb.DefineMethod ("W_impl",
+ MethodAttributes.Public | MethodAttributes.Virtual,
+ CallingConventions.HasThis,
+ typeof (void),
+ new Type[] { typeof (char) });
+ {
+ var il = mb.GetILGenerator ();
+ il.Emit (OpCodes.Ldarg_0); // this
+ il.Emit (OpCodes.Ldc_I4_1);
+ il.Emit (OpCodes.Stfld, wasCalledField); // this.wasCalled = true
+ il.Emit (OpCodes.Ret);
+ }
+ }
+
+ ic = ib.MakeGenericType(typeof (char)); // this is a MonoGenericMethod
+ var mintf = TypeBuilder.GetMethod(ic, winfo);
+ // the next line causes mono_class_init() to
+ // be called on JJJ<char> when we try to setup
+ // the vtable for SSS
+ tb.DefineMethodOverride(mb, mintf);
+
+ var result = tb.CreateType();
+
+ // o = new SSS()
+ object o = Activator.CreateInstance(result);
+ Assert.IsNotNull(o, "#1");
+
+ // ((JJJ<char>)o).W('a');
+ var m = icreated.MakeGenericType(typeof(char)).GetMethod("W", BindingFlags.Public | BindingFlags.Instance);
+ Assert.IsNotNull(m, "#2");
+ m.Invoke(o, new object[] {'a'});
+
+ var f = result.GetField("wasCalled", BindingFlags.Public | BindingFlags.Instance);
+ Assert.IsNotNull(f, "#3");
+ var wasCalledVal = f.GetValue(o);
+ Assert.IsNotNull(wasCalledVal, "#4");
+ Assert.AreEqual (wasCalledVal.GetType(), typeof(Boolean), "#5");
+ Assert.AreEqual (wasCalledVal, true, "#6");
+ }
}
}
Assert.AreSame (Thread.GetNamedDataSlot ("te#st"), Thread.GetNamedDataSlot ("te#st"), "#2");
}
+ class DomainClass : MarshalByRefObject {
+ Thread m_thread;
+ bool success;
+
+ public bool Run () {
+ m_thread = new Thread(ThreadProc);
+ m_thread.Start(Thread.CurrentThread);
+ m_thread.Join();
+ return success;
+ }
+
+ public void ThreadProc (object arg) {
+ success = m_thread == Thread.CurrentThread;
+ }
+ }
+
+ [Test]
+ public void CurrentThread_Domains ()
+ {
+ AppDomain ad = AppDomain.CreateDomain ("foo");
+ ad.Load (typeof (DomainClass).Assembly.GetName ());
+ var o = (DomainClass)ad.CreateInstanceAndUnwrap (typeof (DomainClass).Assembly.FullName, typeof (DomainClass).FullName);
+ Assert.IsTrue (o.Run ());
+ AppDomain.Unload (ad);
+ }
+
void CheckIsRunning (string s, Thread t)
{
int c = counter;
Assert.AreEqual (4, indices [0]);
}
+ [Test]
+ public void TestSortComparable()
+ {
+ int[] source = { 1, 2, 3, 4, 5, 6, 7, 8, 9 };
+ int[] expected = { 6, 5, 4, 3, 2, 1, 7, 8, 9 };
+ Comp[] c = { new Comp (100), new Comp (16), new Comp (11), new Comp (9), new Comp (0), new Comp (-100) };
+ IComparer<Comp> comp = null;
+ Array.Sort<Comp, int> (c, source, comp);
+
+ Assert.AreEqual (expected, source);
+ }
+
+ class Comp : IComparable
+ {
+ readonly int val;
+
+ public Comp (int a)
+ {
+ val = a;
+ }
+
+ int IComparable.CompareTo (object obj)
+ {
+ return val.CompareTo ((obj as Comp).val);
+ }
+ }
+
[Test]
public void TestInitializeEmpty()
{
{
long expectedMilliseconds = test.UnixTimeMilliseconds;
long actualMilliseconds = test.DateTimeOffset.ToUnixTimeMilliseconds();
- Assert.Equals(expectedMilliseconds, actualMilliseconds);
+ Assert.AreEqual(expectedMilliseconds, actualMilliseconds);
}
private static void TestToUnixTimeSeconds(TestTime test)
{
long expectedSeconds = test.UnixTimeSeconds;
long actualSeconds = test.DateTimeOffset.ToUnixTimeSeconds();
- Assert.Equals(expectedSeconds, actualSeconds);
+ Assert.AreEqual(expectedSeconds, actualSeconds);
}
[Test]
// Only assert that expected == actual up to millisecond precision for conversion from milliseconds
long expectedTicks = (test.DateTimeOffset.UtcTicks / TimeSpan.TicksPerMillisecond) * TimeSpan.TicksPerMillisecond;
long actualTicks = DateTimeOffset.FromUnixTimeMilliseconds(test.UnixTimeMilliseconds).UtcTicks;
- Assert.Equals(expectedTicks, actualTicks);
+ Assert.AreEqual(expectedTicks, actualTicks);
}
private static void TestFromUnixTimeSeconds(TestTime test)
// Only assert that expected == actual up to second precision for conversion from seconds
long expectedTicks = (test.DateTimeOffset.UtcTicks / TimeSpan.TicksPerSecond) * TimeSpan.TicksPerSecond;
long actualTicks = DateTimeOffset.FromUnixTimeSeconds(test.UnixTimeSeconds).UtcTicks;
- Assert.Equals(expectedTicks, actualTicks);
+ Assert.AreEqual(expectedTicks, actualTicks);
}
[Test]
public void GetHashCode_ShouldBeEqualToUnderlyingType ()
{
- Assert.AreEqual (EnInt8.A.GetHashCode(), SByte.MinValue, "i8#0");
- Assert.AreEqual (EnInt8.B.GetHashCode(), 44, "i8#1");
- Assert.AreEqual (EnInt8.C.GetHashCode(), SByte.MaxValue, "i8#2");
+ Assert.AreEqual (EnInt8.A.GetHashCode(), SByte.MinValue.GetHashCode (), "i8#0");
+ Assert.AreEqual (EnInt8.B.GetHashCode(), ((sbyte)44).GetHashCode (), "i8#1");
+ Assert.AreEqual (EnInt8.C.GetHashCode(), SByte.MaxValue.GetHashCode (), "i8#2");
- Assert.AreEqual (EnUInt8.A.GetHashCode(), Byte.MinValue, "u8#0");
- Assert.AreEqual (EnUInt8.B.GetHashCode(), 55, "u8#1");
- Assert.AreEqual (EnUInt8.C.GetHashCode(), Byte.MaxValue, "u8#2");
+ Assert.AreEqual (EnUInt8.A.GetHashCode(), Byte.MinValue.GetHashCode (), "u8#0");
+ Assert.AreEqual (EnUInt8.B.GetHashCode(), ((byte)55).GetHashCode (), "u8#1");
+ Assert.AreEqual (EnUInt8.C.GetHashCode(), Byte.MaxValue.GetHashCode (), "u8#2");
- Assert.AreEqual (EnInt16.A.GetHashCode(), Int16.MinValue, "i16#0");
- Assert.AreEqual (EnInt16.B.GetHashCode(), 66, "i16#1");
- Assert.AreEqual (EnInt16.C.GetHashCode(), Int16.MaxValue, "i16#2");
+ Assert.AreEqual (EnInt16.A.GetHashCode(), Int16.MinValue.GetHashCode (), "i16#0");
+ Assert.AreEqual (EnInt16.B.GetHashCode(), ((short)66).GetHashCode (), "i16#1");
+ Assert.AreEqual (EnInt16.C.GetHashCode(), Int16.MaxValue.GetHashCode (), "i16#2");
- Assert.AreEqual (EnUInt16.A.GetHashCode(), UInt16.MinValue, "u16#0");
- Assert.AreEqual (EnUInt16.B.GetHashCode(), 77, "u16#1");
- Assert.AreEqual (EnUInt16.C.GetHashCode(), UInt16.MaxValue, "u16#2");
+ Assert.AreEqual (EnUInt16.A.GetHashCode(), UInt16.MinValue.GetHashCode (), "u16#0");
+ Assert.AreEqual (EnUInt16.B.GetHashCode(), ((ushort)77).GetHashCode (), "u16#1");
+ Assert.AreEqual (EnUInt16.C.GetHashCode(), UInt16.MaxValue.GetHashCode (), "u16#2");
- Assert.AreEqual (EnInt32.A.GetHashCode(), Int32.MinValue, "i32#0");
- Assert.AreEqual (EnInt32.B.GetHashCode(), 88, "i32#1");
- Assert.AreEqual (EnInt32.C.GetHashCode(), Int32.MaxValue, "i32#2");
+ Assert.AreEqual (EnInt32.A.GetHashCode(), Int32.MinValue.GetHashCode (), "i32#0");
+ Assert.AreEqual (EnInt32.B.GetHashCode(), ((int)88).GetHashCode (), "i32#1");
+ Assert.AreEqual (EnInt32.C.GetHashCode(), Int32.MaxValue.GetHashCode (), "i32#2");
- Assert.AreEqual (EnUInt32.A.GetHashCode(), UInt32.MinValue, "u32#0");
- Assert.AreEqual (EnUInt32.B.GetHashCode(), 99, "u32#1");
+ Assert.AreEqual (EnUInt32.A.GetHashCode(), UInt32.MinValue.GetHashCode (), "u32#0");
+ Assert.AreEqual (EnUInt32.B.GetHashCode(), ((uint)99).GetHashCode (), "u32#1");
Assert.AreEqual (EnUInt32.C.GetHashCode(), UInt32.MaxValue.GetHashCode (), "u32#2");
Assert.AreEqual (EnInt64.A.GetHashCode(), Int64.MinValue.GetHashCode (), "i64#0");
Assert.AreEqual (EnInt64.C.GetHashCode(), Int64.MaxValue.GetHashCode (), "i64#2");
Assert.AreEqual (EnUInt64.A.GetHashCode(), UInt64.MinValue.GetHashCode (), "u64#0");
- Assert.AreEqual (EnUInt64.B.GetHashCode(), 3488924689489L.GetHashCode (), "u64#1");
+ Assert.AreEqual (EnUInt64.B.GetHashCode(), ((ulong)3488924689489L).GetHashCode (), "u64#1");
Assert.AreEqual (EnUInt64.C.GetHashCode(), UInt64.MaxValue.GetHashCode (), "u64#2");
}
}
}
}
+
+ [TestFixture]
+ public class ParseTZBuffer
+ {
+ MethodInfo parseTZBuffer;
+
+ [SetUp]
+ public void Setup()
+ {
+ var flags = BindingFlags.Static | BindingFlags.NonPublic;
+ parseTZBuffer = typeof (TimeZoneInfo).GetMethod ("ParseTZBuffer", flags);
+ }
+
+ [Test]
+ public void Bug31432 ()
+ {
+ // Europe/Moscow from failing device
+ var base64Data = "VFppZjIAAAAAAAAAAAAAAAAAAAAAAAAPAAAADwAAAAAAAABNAAAADwAAACKbXx7HnT7yeZ4q7vme9zlpn4RX+aDYbOmhABYJoTymQKQQbcCkPTKwpRVosKU9A8CnHkVQtaQZYBUnp9AWGNxAFwjbUBf6D8AY6g7QGdtDQBrMk9AbvKDwHKyR8B2cgvAejHPwH3xk8CBsVfAhXEbwIkw38CM8KPAkLBnwJRwK8CYL+/AnBSdwJ/UYcCjlF4ApeL+AKdTQQCrEszArtNxwLKTNcC2UvnAuhK9wL3SgcDBkkXAxXbzwMnKX8DM9nvA0UnnwNR2A8DYyW/A2/WLwOBt4cDjdRPA5+1pwOr0m8DvbPHA8pkNwPbsecD6GJXA/mwBwQGYHcEGEHPBCRelwQ2P+8EQly3BFQ+DwRgWtcEcjwvBH7snwSQOk8EnOq/BK44bwS66N8EzMo3BNjm/wVEwdYAIBAgMBAwUEBQYFBwgHCQcJBwkHCQoLCgsKCwoLCgsKCwoMDQoJBwsKCwoLCgsKCwoLCgsKCwoLCgsKCwoLCgsKCwoLCgsKCwoLCg4KAAAjOQAAAAAxhwEEAAAjdwAAAAA/lwEIAAAqMAADAAA4QAENAABGUAEPAAAqMAARAAAcIAAVAAA4QAEZAAAqMAARAAA4QAEZAAAqMAEdAAAcIAAVAAA4QAARTU1UAE1TVABNRFNUAFMATQBNU0sARUVUAE1TRABFRVNUAAAAAAAAAAAAAAABAQEBAQAAAAAAAAAAAAAAAAAAAFRaaWYyAAAAAAAAAAAAAAAAAAAAAAAAEAAAABAAAAAAAAAATgAAABAAAAAm/////1a2wMf/////m18ex/////+dPvJ5/////54q7vn/////nvc5af////+fhFf5/////6DYbOn/////oQAWCf////+hPKZA/////6QQbcD/////pD0ysP////+lFWiw/////6U9A8D/////px5FUP////+1pBlgAAAAABUnp9AAAAAAFhjcQAAAAAAXCNtQAAAAABf6D8AAAAAAGOoO0AAAAAAZ20NAAAAAABrMk9AAAAAAG7yg8AAAAAAcrJHwAAAAAB2cgvAAAAAAHoxz8AAAAAAffGTwAAAAACBsVfAAAAAAIVxG8AAAAAAiTDfwAAAAACM8KPAAAAAAJCwZ8AAAAAAlHArwAAAAACYL+/AAAAAAJwUncAAAAAAn9RhwAAAAACjlF4AAAAAAKXi/gAAAAAAp1NBAAAAAACrEszAAAAAAK7TccAAAAAAspM1wAAAAAC2UvnAAAAAALoSvcAAAAAAvdKBwAAAAADBkkXAAAAAAMV288AAAAAAycpfwAAAAADM9nvAAAAAANFJ58AAAAAA1HYDwAAAAADYyW/AAAAAANv1i8AAAAAA4G3hwAAAAADjdRPAAAAAAOftacAAAAAA6vSbwAAAAADvbPHAAAAAAPKZDcAAAAAA9ux5wAAAAAD6GJXAAAAAAP5sAcAAAAABAZgdwAAAAAEGEHPAAAAAAQkXpcAAAAABDY/7wAAAAAEQly3AAAAAARUPg8AAAAABGBa1wAAAAAEcjwvAAAAAAR+7J8AAAAABJA6TwAAAAAEnOq/AAAAAASuOG8AAAAABLro3wAAAAAEzMo3AAAAAATY5v8AAAAABUTB1gAQMCAwQCBAYFBgcGCAkICggKCAoICgsMCwwLDAsMCwwLDAsNDgsKCAwLDAsMCwwLDAsMCwwLDAsMCwwLDAsMCwwLDAsMCwwLDAsMCw8LAAAjOQAAAAAjOQAEAAAxhwEIAAAjdwAEAAA/lwEMAAAqMAADAAA4QAERAABGUAETAAAqMAAVAAAcIAAZAAA4QAEdAAAqMAAVAAA4QAEdAAAqMAEhAAAcIAAZAAA4QAAVTE1UAE1NVABNU1QATURTVABTAE0ATVNLAEVFVABNU0QARUVTVAAAAAAAAAAAAAAAAAEBAQEBAAAAAAAAAAAAAAAAAAAAAApNU0stMwo=";
+
+ var data = Convert.FromBase64String (base64Data);
+
+ var tz = parseTZBuffer.Invoke (null, new object[] { "Test", data, data.Length});
+ Assert.IsTrue (tz != null);
+ }
+ }
}
}
#if !MONOTOUCH
[Test]
+ [Category ("AndroidNotWorking")] // requires symbol writer
public void FullNameGetTypeParseEscapeRoundtrip () // bug #26384
{
var nm = new AssemblyName ("asm");
--- /dev/null
+#include corlib.dll.sources
\ No newline at end of file
--- /dev/null
+#include corlib.dll.sources
\ No newline at end of file
--- /dev/null
+// CS0841: A local variable `n' cannot be used before it is declared
+// Line: 17
+
+class MainClass
+{
+ public delegate void Fn (MainClass o);
+
+ public static void Call (Fn f)
+ {
+ f(null);
+ }
+
+ public static void Main ()
+ {
+ Call (delegate (MainClass o) {
+ n = o;
+ MainClass n = new MainClass ();
+ });
+ }
+}
\ No newline at end of file
prev = null;
}
- var body = CompatibleMethodBody (ec, tic, null, delegate_type);
+ HashSet<LocalVariable> undeclaredVariables = null;
+ var body = CompatibleMethodBody (ec, tic, null, delegate_type, ref undeclaredVariables);
if (body != null) {
am = body.Compatible (ec, body);
} else {
if (TypeInferenceReportPrinter != null) {
ec.Report.SetPrinter (prev);
}
+
+ if (undeclaredVariables != null) {
+ body.Block.TopBlock.SetUndeclaredVariables (undeclaredVariables);
+ }
}
if (am == null)
// we satisfy the rule by setting the return type on the EmitContext
// to be the delegate type return type.
//
-
- var body = CompatibleMethodBody (ec, null, return_type, delegate_type);
+ HashSet<LocalVariable> undeclaredVariables = null;
+ var body = CompatibleMethodBody (ec, null, return_type, delegate_type, ref undeclaredVariables);
if (body == null)
return null;
throw;
} catch (Exception e) {
throw new InternalErrorException (e, loc);
+ } finally {
+ //
+ // LocalVariable is not stateless and it's not easy to clone because it's
+ // cached in toplevel block. Unsetting any initialized variables should
+ // be enough
+ //
+ if (undeclaredVariables != null) {
+ body.Block.TopBlock.SetUndeclaredVariables (undeclaredVariables);
+ }
}
if (!ec.IsInProbingMode && !etree_conversion) {
return ExprClassName;
}
- AnonymousMethodBody CompatibleMethodBody (ResolveContext ec, TypeInferenceContext tic, TypeSpec return_type, TypeSpec delegate_type)
+ AnonymousMethodBody CompatibleMethodBody (ResolveContext ec, TypeInferenceContext tic, TypeSpec return_type, TypeSpec delegate_type, ref HashSet<LocalVariable> undeclaredVariables)
{
ParametersCompiled p = ResolveParameters (ec, tic, delegate_type);
if (p == null)
return null;
- ParametersBlock b = ec.IsInProbingMode ? (ParametersBlock) Block.PerformClone () : Block;
+ ParametersBlock b = ec.IsInProbingMode ? (ParametersBlock) Block.PerformClone (ref undeclaredVariables) : Block;
if (b.IsAsync) {
var rt = return_type;
//
// Iterate over inflated interfaces
//
- foreach (var iface in Interfaces) {
+ foreach (var iface in InterfacesDefined) {
found = false;
if (other.InterfacesDefined != null) {
foreach (var oiface in other.Interfaces) {
//
// Iterate over inflated interfaces
//
- foreach (var oiface in other.Interfaces) {
+ foreach (var oiface in other.InterfacesDefined) {
found = false;
if (InterfacesDefined != null) {
continue;
}
- entry.Define (this);
+ try {
+ entry.Define (this);
+ } finally {
+ //
+ // It's needed for repl only, when using clause cannot be resolved don't hold it in
+ // global list which is resolved for every evaluation
+ //
+ if (entry.ResolvedExpression == null) {
+ clauses.RemoveAt (i--);
+ }
+ }
- //
- // It's needed for repl only, when using clause cannot be resolved don't hold it in
- // global list which is resolved for each evaluation
- //
- if (entry.ResolvedExpression == null) {
- clauses.RemoveAt (i--);
+ if (entry.ResolvedExpression == null)
continue;
- }
var using_ns = entry.ResolvedExpression as NamespaceExpression;
if (using_ns == null) {
for (int i = 0; i < clauses.Count; ++i) {
var entry = clauses[i];
if (entry.Alias != null) {
- aliases.Add (entry.Alias.Value, (UsingAliasNamespace) entry);
+ aliases[entry.Alias.Value] = (UsingAliasNamespace) entry;
}
}
}
if (resolved != null) {
var compiler = ctx.Module.Compiler;
var type = resolved.Type;
+ resolved = null;
compiler.Report.SymbolRelatedToPreviousError (type);
compiler.Report.Error (138, Location,
return new ParameterReference (parameter_info[index], loc);
}
- public Statement PerformClone ()
+ public Statement PerformClone (ref HashSet<LocalVariable> undeclaredVariables)
{
+ undeclaredVariables = TopBlock.GetUndeclaredVariables ();
+
CloneContext clonectx = new CloneContext ();
return Clone (clonectx);
}
base.CheckControlExit (fc, dat);
}
+ public HashSet<LocalVariable> GetUndeclaredVariables ()
+ {
+ if (names == null)
+ return null;
+
+ HashSet<LocalVariable> variables = null;
+
+ foreach (var entry in names) {
+ var complex = entry.Value as List<INamedBlockVariable>;
+ if (complex != null) {
+ foreach (var centry in complex) {
+ if (IsUndeclaredVariable (centry)) {
+ if (variables == null)
+ variables = new HashSet<LocalVariable> ();
+
+ variables.Add ((LocalVariable) centry);
+ }
+ }
+ } else if (IsUndeclaredVariable ((INamedBlockVariable)entry.Value)) {
+ if (variables == null)
+ variables = new HashSet<LocalVariable> ();
+
+ variables.Add ((LocalVariable)entry.Value);
+ }
+ }
+
+ return variables;
+ }
+
+ static bool IsUndeclaredVariable (INamedBlockVariable namedBlockVariable)
+ {
+ var lv = namedBlockVariable as LocalVariable;
+ return lv != null && !lv.IsDeclared;
+ }
+
+ public void SetUndeclaredVariables (HashSet<LocalVariable> undeclaredVariables)
+ {
+ if (names == null)
+ return;
+
+ foreach (var entry in names) {
+ var complex = entry.Value as List<INamedBlockVariable>;
+ if (complex != null) {
+ foreach (var centry in complex) {
+ var lv = centry as LocalVariable;
+ if (lv != null && undeclaredVariables.Contains (lv)) {
+ lv.Type = null;
+ }
+ }
+ } else {
+ var lv = entry.Value as LocalVariable;
+ if (lv != null && undeclaredVariables.Contains (lv))
+ lv.Type = null;
+ }
+ }
+ }
+
public override void Emit (EmitContext ec)
{
if (Report.Errors > 0)
--- /dev/null
+public interface I<T>
+{
+ T Clone();
+ T1 Clone<T1>() where T1 : T;
+}
+
+public interface I2 : I<I2>
+{
+}
+
+public class TestClass : I2
+{
+ public I2 Clone ()
+ {
+ return null;
+ }
+
+ public T1 Clone<T1> () where T1 : I2
+ {
+ return (T1) Clone();
+ }
+
+ public static void Main ()
+ {
+ new TestClass ();
+ }
+}
\ No newline at end of file
</method>
</type>
</test>
+ <test name="gtest-635.cs">
+ <type name="TestClass">
+ <method name="I2 Clone()" attrs="486">
+ <size>10</size>
+ </method>
+ <method name="T1 Clone[T1]()" attrs="486">
+ <size>20</size>
+ </method>
+ <method name="Void Main()" attrs="150">
+ <size>8</size>
+ </method>
+ <method name="Void .ctor()" attrs="6278">
+ <size>7</size>
+ </method>
+ </type>
+ </test>
<test name="gtest-anontype-01.cs">
<type name="Test">
<method name="Int32 Main()" attrs="150">
PROGRAM_INSTALL_DIR = $(mono_libdir)/mono/$(FRAMEWORK_VERSION)
-APIINFO_SOURCES = mono-api-info.cs $(COMMON_SOURCES)
+APIINFO_SOURCES = \
+ mono-api-info.cs \
+ ../../class/Mono.Options/Mono.Options/Options.cs \
+ $(COMMON_SOURCES)
DISTFILES= $(COMMON_SOURCES) $(APIINFO_SOURCES)
{
public static int Main (string [] args)
{
- if (args.Length == 0)
- return 1;
-
+ bool showHelp = false;
AbiMode = false;
-
- AssemblyCollection acoll = new AssemblyCollection ();
+ FollowForwarders = false;
+
+ var acoll = new AssemblyCollection ();
+
+ var options = new Mono.Options.OptionSet {
+ { "h|help", "Show this help", v => showHelp = true },
+ { "abi", _ => AbiMode = true},
+ { "f|follow-forwarders", _ => FollowForwarders = true },
+ { "d|search-directory=", v => TypeHelper.Resolver.AddSearchDirectory (v) },
+ };
+
+ var asms = options.Parse (args);
+
+ if (showHelp || asms.Count == 0) {
+ Console.WriteLine (@"Usage: mono-api-info [options] <assemblies>");
+ Console.WriteLine ();
+ Console.WriteLine ("Available options:");
+ options.WriteOptionDescriptions (Console.Out);
+ Console.WriteLine ();
+ return showHelp? 0 :1;
+ }
string windir = Environment.GetFolderPath(Environment.SpecialFolder.Windows);
string pf = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles);
TypeHelper.Resolver.AddSearchDirectory (Path.Combine (windir, @"assembly\GAC\MSDATASRC\7.0.3300.0__b03f5f7f11d50a3a"));
- foreach (string arg in args) {
- if (arg == "--abi") {
- AbiMode = true;
- } else {
- acoll.Add (arg);
-
- if (arg.Contains ("v3.0")) {
- TypeHelper.Resolver.AddSearchDirectory (Path.Combine (windir, @"Microsoft.NET\Framework\v2.0.50727"));
- } else if (arg.Contains ("v3.5")) {
- TypeHelper.Resolver.AddSearchDirectory (Path.Combine (windir, @"Microsoft.NET\Framework\v2.0.50727"));
- TypeHelper.Resolver.AddSearchDirectory (Path.Combine (windir, @"Microsoft.NET\Framework\v3.0\Windows Communication Foundation"));
- } else if (arg.Contains ("v4.0")) {
- if (arg.Contains ("Silverlight")) {
- TypeHelper.Resolver.AddSearchDirectory (Path.Combine (pf, @"Microsoft Silverlight\4.0.51204.0"));
- } else {
- TypeHelper.Resolver.AddSearchDirectory (Path.Combine (windir, @"Microsoft.NET\Framework\v4.0.30319"));
- TypeHelper.Resolver.AddSearchDirectory (Path.Combine (windir, @"Microsoft.NET\Framework\v4.0.30319\WPF"));
- }
+ foreach (string arg in asms) {
+ acoll.Add (arg);
+
+ if (arg.Contains ("v3.0")) {
+ TypeHelper.Resolver.AddSearchDirectory (Path.Combine (windir, @"Microsoft.NET\Framework\v2.0.50727"));
+ } else if (arg.Contains ("v3.5")) {
+ TypeHelper.Resolver.AddSearchDirectory (Path.Combine (windir, @"Microsoft.NET\Framework\v2.0.50727"));
+ TypeHelper.Resolver.AddSearchDirectory (Path.Combine (windir, @"Microsoft.NET\Framework\v3.0\Windows Communication Foundation"));
+ } else if (arg.Contains ("v4.0")) {
+ if (arg.Contains ("Silverlight")) {
+ TypeHelper.Resolver.AddSearchDirectory (Path.Combine (pf, @"Microsoft Silverlight\4.0.51204.0"));
} else {
- TypeHelper.Resolver.AddSearchDirectory (Path.GetDirectoryName (arg));
+ TypeHelper.Resolver.AddSearchDirectory (Path.Combine (windir, @"Microsoft.NET\Framework\v4.0.30319"));
+ TypeHelper.Resolver.AddSearchDirectory (Path.Combine (windir, @"Microsoft.NET\Framework\v4.0.30319\WPF"));
}
+ } else {
+ TypeHelper.Resolver.AddSearchDirectory (Path.GetDirectoryName (arg));
}
}
}
internal static bool AbiMode { get; private set; }
+ internal static bool FollowForwarders { get; private set; }
}
public class Utils {
AddAttribute (nassembly, "name", aname.Name);
AddAttribute (nassembly, "version", aname.Version.ToString ());
parent.AppendChild (nassembly);
- TypeForwardedToData.OutputForwarders (document, nassembly, ass);
+
+ if (!Driver.FollowForwarders) {
+ TypeForwardedToData.OutputForwarders (document, nassembly, ass);
+ }
+
AttributeData.OutputAttributes (document, nassembly, ass);
- var typesCollection = ass.MainModule.Types;
- if (typesCollection == null || typesCollection.Count == 0)
+
+ var types = new List<TypeDefinition> ();
+ if (ass.MainModule.Types != null) {
+ types.AddRange (ass.MainModule.Types);
+ }
+
+ if (Driver.FollowForwarders && ass.MainModule.ExportedTypes != null) {
+ foreach (var t in ass.MainModule.ExportedTypes) {
+ var forwarded = t.Resolve ();
+ if (forwarded == null) {
+ throw new Exception ("Could not resolve forwarded type " + t.FullName + " in " + ass.Name);
+ }
+ types.Add (forwarded);
+ }
+ }
+
+ if (types.Count == 0) {
return;
- var typesArray = new TypeDefinition [typesCollection.Count];
- for (int i = 0; i < typesCollection.Count; i++) {
- typesArray [i] = typesCollection [i];
}
- Array.Sort (typesArray, TypeReferenceComparer.Default);
+
+ types.Sort (TypeReferenceComparer.Default);
XmlNode nss = document.CreateElement ("namespaces", null);
nassembly.AppendChild (nss);
string current_namespace = "$%&$&";
XmlNode ns = null;
XmlNode classes = null;
- foreach (TypeDefinition t in typesArray) {
+ foreach (TypeDefinition t in types) {
if (string.IsNullOrEmpty (t.Namespace))
continue;
}
- class TypeReferenceComparer : IComparer
+ class TypeReferenceComparer : IComparer<TypeReference>
{
public static TypeReferenceComparer Default = new TypeReferenceComparer ();
- public int Compare (object a, object b)
+ public int Compare (TypeReference a, TypeReference b)
{
- TypeReference ta = (TypeReference) a;
- TypeReference tb = (TypeReference) b;
- int result = String.Compare (ta.Namespace, tb.Namespace);
+ int result = String.Compare (a.Namespace, b.Namespace, StringComparison.Ordinal);
if (result != 0)
return result;
- return String.Compare (ta.Name, tb.Name);
+ return String.Compare (a.Name, b.Name, StringComparison.Ordinal);
}
}
{
MemberReference ma = (MemberReference) a;
MemberReference mb = (MemberReference) b;
- return String.Compare (ma.Name, mb.Name);
+ return String.Compare (ma.Name, mb.Name, StringComparison.Ordinal);
}
}
<PropertyGroup>\r
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>\r
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>\r
- <ProductVersion>9.0.30729</ProductVersion>\r
+ <ProductVersion>8.0.30703</ProductVersion>\r
<SchemaVersion>2.0</SchemaVersion>\r
<ProjectGuid>{6446D5E1-8F4E-4692-8EF3-B1D4CA290ECF}</ProjectGuid>\r
<OutputType>Exe</OutputType>\r
</PropertyGroup>\r
<ItemGroup>\r
<Reference Include="System" />\r
- <Reference Include="System.Core">\r
- <RequiredTargetFramework>3.5</RequiredTargetFramework>\r
- </Reference>\r
+ <Reference Include="System.Core" />\r
<Reference Include="System.Xml" />\r
</ItemGroup>\r
<ItemGroup>\r
<Compile Include="mono-api-info.cs" />\r
<Compile Include="Util.cs" />\r
<Compile Include="WellFormedXmlWriter.cs" />\r
+ <Compile Include="..\..\class\Mono.Options\Mono.Options\Options.cs">\r
+ <Link>Options.cs</Link>\r
+ </Compile>\r
</ItemGroup>\r
<ItemGroup>\r
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">\r
<type fullname="System.Threading.ExecutionContext" />
<type fullname="System.Threading.Interlocked">
<method name="CompareExchange" />
+ <method name="Exchange" />
</type>
<type fullname="System.Threading.Monitor">
<method name="Enter" />
return;
MarkType (et);
+ if (argument.Value == null)
+ return;
+
foreach (var cac in (CustomAttributeArgument[]) argument.Value)
MarkWithResolvedScope ((TypeReference) cac.Value);
} else if (at.Namespace == "System" && at.Name == "Type") {
if [ "$X11_MODE" -eq "1" ]; then
open-x11 "$APP_NAME"
+
+# rcruzs00
+# El Capitan FIX: `which` wont work (system-integrity-protection)
+# elif: Keep compatibility with previous code
+elif [ -f /usr/local/bin/mono ]; then
+ DIR=$(cd "$(dirname "$0")"; pwd)
+ /usr/local/bin/mono $DIR/../Resources/"$ASSEMBLY"
+
else
if [ ! -d "./bin" ]; then mkdir bin ; fi
if [ -f "./bin/$APP_NAME" ]; then rm -f "./bin/$APP_NAME" ; fi
OPDEF(CEE_MONO_LDPTR_INT_REQ_FLAG, "mono_ldptr_int_req_flag", Pop0, PushI, InlineNone, X, 2, 0xF0, 0x14, NEXT)
OPDEF(CEE_MONO_LDPTR_CARD_TABLE, "mono_ldptr_card_table", Pop0, PushI, InlineNone, X, 2, 0xF0, 0x15, NEXT)
OPDEF(CEE_MONO_LDPTR_NURSERY_START, "mono_ldptr_nursery_start", Pop0, PushI, InlineNone, X, 2, 0xF0, 0x16, NEXT)
+OPDEF(CEE_MONO_LDPTR_NURSERY_BITS, "mono_ldptr_nursery_bits", Pop0, PushI, InlineNone, X, 2, 0xF0, 0x17, NEXT)
#ifndef OPALIAS
#define _MONO_CIL_OPALIAS_DEFINED_
#define OPALIAS(a,s,r)
file-io.h \
filewatcher.c \
filewatcher.h \
- gc-internal.h \
+ gc-internals.h \
icall.c \
icall-def.h \
image.c \
sgen-os-coop.c \
sgen-bridge.c \
sgen-bridge.h \
- sgen-bridge-internal.h \
+ sgen-bridge-internals.h \
sgen-old-bridge.c \
sgen-new-bridge.c \
sgen-tarjan-bridge.c \
#endif
#endif
-#include <mono/metadata/gc-internal.h>
+#include <mono/metadata/gc-internals.h>
#include <mono/metadata/object.h>
#include <mono/metadata/domain-internals.h>
#include "mono/metadata/metadata-internals.h"
#include <mono/metadata/threadpool-ms.h>
#include <mono/metadata/socket-io.h>
#include <mono/metadata/tabledefs.h>
-#include <mono/metadata/gc-internal.h>
+#include <mono/metadata/gc-internals.h>
#include <mono/metadata/mono-gc.h>
#include <mono/metadata/marshal.h>
#include <mono/metadata/monitor.h>
#include <mono/metadata/tokentype.h>
#include <mono/metadata/profiler-private.h>
#include <mono/utils/mono-uri.h>
-#include <mono/utils/mono-logger-internal.h>
+#include <mono/utils/mono-logger-internals.h>
#include <mono/utils/mono-path.h>
#include <mono/utils/mono-stdlib.h>
#include <mono/utils/mono-io-portability.h>
{
MonoAppDomainSetup *setup;
MonoAppDomain *ad;
- MonoClass *class;
+ MonoClass *klass;
mono_portability_helpers_init ();
mono_thread_init (start_cb, attach_cb);
- class = mono_class_from_name (mono_defaults.corlib, "System", "AppDomainSetup");
- setup = (MonoAppDomainSetup *) mono_object_new_pinned (domain, class);
+ klass = mono_class_from_name (mono_defaults.corlib, "System", "AppDomainSetup");
+ setup = (MonoAppDomainSetup *) mono_object_new_pinned (domain, klass);
- class = mono_class_from_name (mono_defaults.corlib, "System", "AppDomain");
- ad = (MonoAppDomain *) mono_object_new_pinned (domain, class);
+ klass = mono_class_from_name (mono_defaults.corlib, "System", "AppDomain");
+ ad = (MonoAppDomain *) mono_object_new_pinned (domain, klass);
ad->data = domain;
domain->domain = ad;
domain->setup = setup;
void
mono_context_init (MonoDomain *domain)
{
- MonoClass *class;
+ MonoClass *klass;
MonoAppContext *context;
- class = mono_class_from_name (mono_defaults.corlib, "System.Runtime.Remoting.Contexts", "Context");
- context = (MonoAppContext *) mono_object_new_pinned (domain, class);
+ klass = mono_class_from_name (mono_defaults.corlib, "System.Runtime.Remoting.Contexts", "Context");
+ context = (MonoAppContext *) mono_object_new_pinned (domain, klass);
context->domain_id = domain->domain_id;
context->context_id = 0;
ves_icall_System_Runtime_Remoting_Contexts_Context_RegisterContext (context);
{
MonoAppDomain *ad;
MonoAppDomainSetup *setup;
- MonoClass *class;
+ MonoClass *klass;
- class = mono_class_from_name (mono_defaults.corlib, "System", "AppDomainSetup");
- setup = (MonoAppDomainSetup *) mono_object_new (mono_domain_get (), class);
+ klass = mono_class_from_name (mono_defaults.corlib, "System", "AppDomainSetup");
+ setup = (MonoAppDomainSetup *) mono_object_new (mono_domain_get (), klass);
setup->configuration_file = configuration_file != NULL ? mono_string_new (mono_domain_get (), configuration_file) : NULL;
ad = mono_domain_create_appdomain_internal (friendly_name, setup);
GSList *list = image->reflection_info_unregister_classes;
while (list) {
- MonoClass *class = list->data;
+ MonoClass *klass = list->data;
- mono_class_free_ref_info (class);
+ mono_class_free_ref_info (klass);
list = list->next;
}
#include <mono/metadata/mono-config.h>
#include <mono/metadata/mono-config-dirs.h>
#include <mono/utils/mono-digest.h>
-#include <mono/utils/mono-logger-internal.h>
+#include <mono/utils/mono-logger-internals.h>
#include <mono/utils/mono-path.h>
#include <mono/metadata/reflection.h>
#include <mono/metadata/coree.h>
#include <mono/metadata/class-internals.h>
#include <mono/metadata/object-internals.h>
#include <mono/metadata/threads-types.h>
-#include <mono/metadata/gc-internal.h>
+#include <mono/metadata/gc-internals.h>
#include <mono/utils/mono-threads.h>
#include "attach.h"
#include <string.h>
#define GC_I_HIDE_POINTERS
-#include <mono/metadata/gc-internal.h>
+#include <mono/metadata/gc-internals.h>
#include <mono/metadata/mono-gc.h>
#include <mono/metadata/profiler-private.h>
#include <mono/metadata/class-internals.h>
#include <mono/metadata/runtime.h>
#include <mono/metadata/sgen-toggleref.h>
#include <mono/utils/atomic.h>
-#include <mono/utils/mono-logger-internal.h>
+#include <mono/utils/mono-logger-internals.h>
#include <mono/utils/mono-memory-model.h>
#include <mono/utils/mono-time.h>
#include <mono/utils/mono-threads.h>
for (char **ptr = opts; ptr && *ptr; ptr ++) {
char *opt = *ptr;
if (!strcmp (opt, "do-not-finalize")) {
- do_not_finalize = 1;
+ mono_do_not_finalize = 1;
} else if (!strcmp (opt, "log-finalizers")) {
log_finalizers = 1;
}
MonoMethod *res;
MonoMethodSignature *csig;
const char *name = NULL;
- AllocatorWrapperInfo *info;
+ WrapperInfo *info;
if (atype == ATYPE_FREEPTR) {
name = slowpath ? "SlowAllocPtrfree" : "AllocPtrfree";
mono_mb_emit_byte (mb, MONO_CEE_RET);
- res = mono_mb_create_method (mb, csig, 8);
+ info = mono_wrapper_info_create (mb, WRAPPER_SUBTYPE_NONE);
+ info->d.alloc.gc_name = "boehm";
+ info->d.alloc.alloc_type = atype;
+
+ res = mono_mb_create (mb, csig, 8, info);
mono_mb_free (mb);
mono_method_get_header (res)->init_locals = FALSE;
- info = mono_image_alloc0 (mono_defaults.corlib, sizeof (AllocatorWrapperInfo));
- info->gc_name = "boehm";
- info->alloc_type = atype;
- mono_marshal_set_wrapper_info (res, info);
-
return res;
}
#endif
guint
-mono_gc_get_vtable_bits (MonoClass *class)
+mono_gc_get_vtable_bits (MonoClass *klass)
{
if (fin_callbacks.is_class_finalization_aware) {
- if (fin_callbacks.is_class_finalization_aware (class))
+ if (fin_callbacks.is_class_finalization_aware (klass))
return BOEHM_GC_BIT_FINALIZER_AWARE;
}
return 0;
/*
* Copyright 2012 Xamarin Inc
*/
-#ifndef __MONO_METADATA_CLASS_INTERBALS_H__
-#define __MONO_METADATA_CLASS_INTERBALS_H__
+#ifndef __MONO_METADATA_CLASS_INTERNALS_H__
+#define __MONO_METADATA_CLASS_INTERNALS_H__
#include <mono/metadata/class.h>
#include <mono/metadata/object.h>
mono_class_get_##shortname##_class (void) \
{ \
static MonoClass *tmp_class; \
- MonoClass *class = tmp_class; \
- if (!class) { \
- class = mono_class_from_name (mono_defaults.corlib, #namespace, #name); \
- g_assert (class); \
+ MonoClass *klass = tmp_class; \
+ if (!klass) { \
+ klass = mono_class_from_name (mono_defaults.corlib, #namespace, #name); \
+ g_assert (klass); \
mono_memory_barrier (); \
- tmp_class = class; \
+ tmp_class = klass; \
} \
- return class; \
+ return klass; \
}
#define GENERATE_STATIC_GET_CLASS_WITH_CACHE(shortname,namespace,name) \
gpointer
mono_ldtoken_checked (MonoImage *image, guint32 token, MonoClass **handle_class, MonoGenericContext *context, MonoError *error);
-#endif /* __MONO_METADATA_CLASS_INTERBALS_H__ */
+#endif /* __MONO_METADATA_CLASS_INTERNALS_H__ */
#include <mono/metadata/security-manager.h>
#include <mono/metadata/security-core-clr.h>
#include <mono/metadata/attrdefs.h>
-#include <mono/metadata/gc-internal.h>
+#include <mono/metadata/gc-internals.h>
#include <mono/metadata/verify-internals.h>
#include <mono/metadata/mono-debug.h>
#include <mono/utils/mono-counters.h>
#include <mono/utils/mono-string.h>
#include <mono/utils/mono-error-internals.h>
-#include <mono/utils/mono-logger-internal.h>
+#include <mono/utils/mono-logger-internals.h>
#include <mono/utils/mono-memory-model.h>
#include <mono/utils/atomic.h>
#include <mono/utils/bsearch.h>
static gboolean mono_class_get_cached_class_info (MonoClass *klass, MonoCachedClassInfo *res);
static gboolean can_access_type (MonoClass *access_klass, MonoClass *member_klass);
static MonoMethod* find_method_in_metadata (MonoClass *klass, const char *name, int param_count, int flags);
-static int generic_array_methods (MonoClass *class);
-static void setup_generic_array_ifaces (MonoClass *class, MonoClass *iface, MonoMethod **methods, int pos);
+static int generic_array_methods (MonoClass *klass);
+static void setup_generic_array_ifaces (MonoClass *klass, MonoClass *iface, MonoMethod **methods, int pos);
static MonoMethod* mono_class_get_virtual_methods (MonoClass* klass, gpointer *iter);
static char* mono_assembly_name_from_token (MonoImage *image, guint32 type_token);
static void mono_field_resolve_type (MonoClassField *field, MonoError *error);
static guint32 mono_field_resolve_flags (MonoClassField *field);
-static void mono_class_setup_vtable_full (MonoClass *class, GList *in_setup);
+static void mono_class_setup_vtable_full (MonoClass *klass, GList *in_setup);
static void mono_generic_class_setup_parent (MonoClass *klass, MonoClass *gklass);
/*
mono_class_from_typeref (MonoImage *image, guint32 type_token)
{
MonoError error;
- MonoClass *class = mono_class_from_typeref_checked (image, type_token, &error);
+ MonoClass *klass = mono_class_from_typeref_checked (image, type_token, &error);
g_assert (mono_error_ok (&error)); /*FIXME proper error handling*/
- return class;
+ return klass;
}
MonoClass *
* The inverse of mono_reflection_parse_type ().
*/
char *
-mono_type_get_full_name (MonoClass *class)
+mono_type_get_full_name (MonoClass *klass)
{
- return mono_type_get_name_full (mono_class_get_type (class), MONO_TYPE_NAME_FORMAT_REFLECTION);
+ return mono_type_get_name_full (mono_class_get_type (klass), MONO_TYPE_NAME_FORMAT_REFLECTION);
}
/**
}
MonoGenericContext *
-mono_class_get_context (MonoClass *class)
+mono_class_get_context (MonoClass *klass)
{
- return class->generic_class ? mono_generic_class_get_context (class->generic_class) : NULL;
+ return klass->generic_class ? mono_generic_class_get_context (klass->generic_class) : NULL;
}
/*
* in a separate function since it is cheaper than calling mono_class_setup_fields.
*/
static MonoType*
-mono_class_find_enum_basetype (MonoClass *class, MonoError *error)
+mono_class_find_enum_basetype (MonoClass *klass, MonoError *error)
{
MonoGenericContainer *container = NULL;
- MonoImage *m = class->image;
- const int top = class->field.count;
+ MonoImage *m = klass->image;
+ const int top = klass->field.count;
int i;
- g_assert (class->enumtype);
+ g_assert (klass->enumtype);
mono_error_init (error);
- if (class->generic_container)
- container = class->generic_container;
- else if (class->generic_class) {
- MonoClass *gklass = class->generic_class->container_class;
+ if (klass->generic_container)
+ container = klass->generic_container;
+ else if (klass->generic_class) {
+ MonoClass *gklass = klass->generic_class->container_class;
container = gklass->generic_container;
g_assert (container);
for (i = 0; i < top; i++){
const char *sig;
guint32 cols [MONO_FIELD_SIZE];
- int idx = class->field.first + i;
+ int idx = klass->field.first + i;
MonoType *ftype;
- /* class->field.first and idx points into the fieldptr table */
+ /* klass->field.first and idx points into the fieldptr table */
mono_metadata_decode_table_row (m, MONO_TABLE_FIELD, idx, cols, MONO_FIELD_SIZE);
if (cols [MONO_FIELD_FLAGS] & FIELD_ATTRIBUTE_STATIC) //no need to decode static fields
continue;
- if (!mono_verifier_verify_field_signature (class->image, cols [MONO_FIELD_SIGNATURE], NULL)) {
- mono_error_set_bad_image (error, class->image, "Invalid field signature %x", cols [MONO_FIELD_SIGNATURE]);
+ if (!mono_verifier_verify_field_signature (klass->image, cols [MONO_FIELD_SIGNATURE], NULL)) {
+ mono_error_set_bad_image (error, klass->image, "Invalid field signature %x", cols [MONO_FIELD_SIGNATURE]);
goto fail;
}
mono_metadata_decode_value (sig, &sig);
/* FIELD signature == 0x06 */
if (*sig != 0x06) {
- mono_error_set_bad_image (error, class->image, "Invalid field signature %x, expected 0x6 but got %x", cols [MONO_FIELD_SIGNATURE], *sig);
+ mono_error_set_bad_image (error, klass->image, "Invalid field signature %x, expected 0x6 but got %x", cols [MONO_FIELD_SIGNATURE], *sig);
goto fail;
}
if (mono_loader_get_last_error ()) /*FIXME plug the above to not leak errors*/
mono_error_set_from_loader_error (error);
else
- mono_error_set_bad_image (error, class->image, "Could not parse type for field signature %x", cols [MONO_FIELD_SIGNATURE]);
+ mono_error_set_bad_image (error, klass->image, "Could not parse type for field signature %x", cols [MONO_FIELD_SIGNATURE]);
goto fail;
}
- if (class->generic_class) {
+ if (klass->generic_class) {
//FIXME do we leak here?
- ftype = mono_class_inflate_generic_type_checked (ftype, mono_class_get_context (class), error);
+ ftype = mono_class_inflate_generic_type_checked (ftype, mono_class_get_context (klass), error);
if (!mono_error_ok (error))
goto fail;
ftype->attrs = cols [MONO_FIELD_FLAGS];
return ftype;
}
- mono_error_set_type_load_class (error, class, "Could not find base type");
+ mono_error_set_type_load_class (error, klass, "Could not find base type");
fail:
mono_loader_assert_no_error ();
* or from the heap.
*/
static gpointer
-mono_class_alloc (MonoClass *class, int size)
+mono_class_alloc (MonoClass *klass, int size)
{
- if (class->generic_class)
- return mono_image_set_alloc (class->generic_class->owner, size);
+ if (klass->generic_class)
+ return mono_image_set_alloc (klass->generic_class->owner, size);
else
- return mono_image_alloc (class->image, size);
+ return mono_image_alloc (klass->image, size);
}
static gpointer
-mono_class_alloc0 (MonoClass *class, int size)
+mono_class_alloc0 (MonoClass *klass, int size)
{
gpointer res;
- res = mono_class_alloc (class, size);
+ res = mono_class_alloc (klass, size);
memset (res, 0, size);
return res;
}
-#define mono_class_new0(class,struct_type, n_structs) \
- ((struct_type *) mono_class_alloc0 ((class), ((gsize) sizeof (struct_type)) * ((gsize) (n_structs))))
+#define mono_class_new0(klass,struct_type, n_structs) \
+ ((struct_type *) mono_class_alloc0 ((klass), ((gsize) sizeof (struct_type)) * ((gsize) (n_structs))))
/**
* mono_class_setup_basic_field_info:
* @class: The class to initialize
*
- * Initializes the class->fields.
+ * Initializes the klass->fields.
* LOCKING: Assumes the loader lock is held.
*/
static void
-mono_class_setup_basic_field_info (MonoClass *class)
+mono_class_setup_basic_field_info (MonoClass *klass)
{
MonoClassField *field;
MonoClass *gtd;
MonoImage *image;
int i, top;
- if (class->fields)
+ if (klass->fields)
return;
- gtd = class->generic_class ? mono_class_get_generic_type_definition (class) : NULL;
- image = class->image;
- top = class->field.count;
+ gtd = klass->generic_class ? mono_class_get_generic_type_definition (klass) : NULL;
+ image = klass->image;
+ top = klass->field.count;
- if (class->generic_class && image_is_dynamic (class->generic_class->container_class->image) && !class->generic_class->container_class->wastypebuilder) {
+ if (klass->generic_class && image_is_dynamic (klass->generic_class->container_class->image) && !klass->generic_class->container_class->wastypebuilder) {
/*
* This happens when a generic instance of an unfinished generic typebuilder
* is used as an element type for creating an array type. We can't initialize
mono_class_setup_basic_field_info (gtd);
top = gtd->field.count;
- class->field.first = gtd->field.first;
- class->field.count = gtd->field.count;
+ klass->field.first = gtd->field.first;
+ klass->field.count = gtd->field.count;
}
- class->fields = mono_class_alloc0 (class, sizeof (MonoClassField) * top);
+ klass->fields = mono_class_alloc0 (klass, sizeof (MonoClassField) * top);
/*
* Fetch all the field information.
*/
for (i = 0; i < top; i++){
- field = &class->fields [i];
- field->parent = class;
+ field = &klass->fields [i];
+ field->parent = klass;
if (gtd) {
field->name = mono_field_get_name (>d->fields [i]);
} else {
- int idx = class->field.first + i;
- /* class->field.first and idx points into the fieldptr table */
+ int idx = klass->field.first + i;
+ /* klass->field.first and idx points into the fieldptr table */
guint32 name_idx = mono_metadata_decode_table_row_col (image, MONO_TABLE_FIELD, idx, MONO_FIELD_NAME);
/* The name is needed for fieldrefs */
field->name = mono_metadata_string_heap (image, name_idx);
* mono_class_setup_fields:
* @class: The class to initialize
*
- * Initializes the class->fields.
+ * Initializes the klass->fields.
* LOCKING: Assumes the loader lock is held.
*/
static void
-mono_class_setup_fields (MonoClass *class)
+mono_class_setup_fields (MonoClass *klass)
{
MonoError error;
- MonoImage *m = class->image;
+ MonoImage *m = klass->image;
int top;
- guint32 layout = class->flags & TYPE_ATTRIBUTE_LAYOUT_MASK;
+ guint32 layout = klass->flags & TYPE_ATTRIBUTE_LAYOUT_MASK;
int i, blittable = TRUE;
guint32 real_size = 0;
guint32 packing_size = 0;
gboolean explicit_size;
MonoClassField *field;
MonoGenericContainer *container = NULL;
- MonoClass *gtd = class->generic_class ? mono_class_get_generic_type_definition (class) : NULL;
+ MonoClass *gtd = klass->generic_class ? mono_class_get_generic_type_definition (klass) : NULL;
/*
* FIXME: We have a race condition here. It's possible that this function returns
* This function is called for a class whenever one of its subclasses is inited.
* For example, it's called for every subclass of Object. What it does is this:
*
- * if (class->setup_fields_called)
+ * if (klass->setup_fields_called)
* return;
* ...
- * class->instance_size = 0;
+ * klass->instance_size = 0;
* ...
- * class->setup_fields_called = 1;
+ * klass->setup_fields_called = 1;
* ... critical point
- * class->instance_size = actual_instance_size;
+ * klass->instance_size = actual_instance_size;
*
* The last two steps are sometimes reversed, but that only changes the way in which
* the race condition works.
*
* The other case looks like this:
*
- * if (class->setup_fields_called)
+ * if (klass->setup_fields_called)
* return;
* ... critical point X
- * class->instance_size = 0;
+ * klass->instance_size = 0;
* ... critical point Y
- * class->instance_size = actual_instance_size;
+ * klass->instance_size = actual_instance_size;
* ...
- * class->setup_fields_called = 1;
+ * klass->setup_fields_called = 1;
*
* Assume thread A goes through the function and makes it to critical point X. Now
* thread B runs through the whole of the function, returning, assuming
* critical point Y, at which time `instance_size` is `0` again, invalidating thread
* B's assumption.
*/
- if (class->setup_fields_called)
+ if (klass->setup_fields_called)
return;
- if (class->generic_class && image_is_dynamic (class->generic_class->container_class->image) && !class->generic_class->container_class->wastypebuilder) {
+ if (klass->generic_class && image_is_dynamic (klass->generic_class->container_class->image) && !klass->generic_class->container_class->wastypebuilder) {
/*
* This happens when a generic instance of an unfinished generic typebuilder
* is used as an element type for creating an array type. We can't initialize
return;
}
- mono_class_setup_basic_field_info (class);
- top = class->field.count;
+ mono_class_setup_basic_field_info (klass);
+ top = klass->field.count;
if (gtd) {
mono_class_setup_fields (gtd);
if (gtd->exception_type) {
- mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, NULL);
+ mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, NULL);
return;
}
}
- class->instance_size = 0;
- if (!class->rank)
- class->sizes.class_size = 0;
+ klass->instance_size = 0;
+ if (!klass->rank)
+ klass->sizes.class_size = 0;
- if (class->parent) {
- /* For generic instances, class->parent might not have been initialized */
- mono_class_init (class->parent);
- if (!class->parent->size_inited) {
- mono_class_setup_fields (class->parent);
- if (class->parent->exception_type) {
- mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, NULL);
+ if (klass->parent) {
+ /* For generic instances, klass->parent might not have been initialized */
+ mono_class_init (klass->parent);
+ if (!klass->parent->size_inited) {
+ mono_class_setup_fields (klass->parent);
+ if (klass->parent->exception_type) {
+ mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, NULL);
return;
}
}
- class->instance_size += class->parent->instance_size;
- class->min_align = class->parent->min_align;
+ klass->instance_size += klass->parent->instance_size;
+ klass->min_align = klass->parent->min_align;
/* we use |= since it may have been set already */
- class->has_references |= class->parent->has_references;
- blittable = class->parent->blittable;
+ klass->has_references |= klass->parent->has_references;
+ blittable = klass->parent->blittable;
} else {
- class->instance_size = sizeof (MonoObject);
- class->min_align = 1;
+ klass->instance_size = sizeof (MonoObject);
+ klass->min_align = 1;
}
/* We can't really enable 16 bytes alignment until the GC supports it.
boxed instance, which leads to unexplainable holes at the beginning of an object embedding a simd type.
Bug #506144 is an example of this issue.
- if (class->simd_type)
- class->min_align = 16;
+ if (klass->simd_type)
+ klass->min_align = 16;
*/
/* Get the real size */
- explicit_size = mono_metadata_packing_from_typedef (class->image, class->type_token, &packing_size, &real_size);
+ explicit_size = mono_metadata_packing_from_typedef (klass->image, klass->type_token, &packing_size, &real_size);
if (explicit_size) {
if ((packing_size & 0xffffff00) != 0) {
- char *err_msg = g_strdup_printf ("Could not load struct '%s' with packing size %d >= 256", class->name, packing_size);
- mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, err_msg);
+ char *err_msg = g_strdup_printf ("Could not load struct '%s' with packing size %d >= 256", klass->name, packing_size);
+ mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, err_msg);
return;
}
- class->packing_size = packing_size;
- real_size += class->instance_size;
+ klass->packing_size = packing_size;
+ real_size += klass->instance_size;
}
if (!top) {
if (explicit_size && real_size) {
- class->instance_size = MAX (real_size, class->instance_size);
+ klass->instance_size = MAX (real_size, klass->instance_size);
}
- class->blittable = blittable;
+ klass->blittable = blittable;
mono_memory_barrier ();
- class->size_inited = 1;
- class->fields_inited = 1;
- class->setup_fields_called = 1;
+ klass->size_inited = 1;
+ klass->fields_inited = 1;
+ klass->setup_fields_called = 1;
return;
}
- if (layout == TYPE_ATTRIBUTE_AUTO_LAYOUT && !(mono_is_corlib_image (class->image) && !strcmp (class->name_space, "System") && !strcmp (class->name, "ValueType")))
+ if (layout == TYPE_ATTRIBUTE_AUTO_LAYOUT && !(mono_is_corlib_image (klass->image) && !strcmp (klass->name_space, "System") && !strcmp (klass->name, "ValueType")))
blittable = FALSE;
/* Prevent infinite loops if the class references itself */
- class->setup_fields_called = 1;
+ klass->setup_fields_called = 1;
- if (class->generic_container) {
- container = class->generic_container;
+ if (klass->generic_container) {
+ container = klass->generic_container;
} else if (gtd) {
container = gtd->generic_container;
g_assert (container);
* Fetch all the field information.
*/
for (i = 0; i < top; i++){
- int idx = class->field.first + i;
- field = &class->fields [i];
+ int idx = klass->field.first + i;
+ field = &klass->fields [i];
- field->parent = class;
+ field->parent = klass;
if (!field->type) {
mono_field_resolve_type (field, &error);
return;
}
if (!field->type)
- g_error ("could not resolve %s:%s\n", mono_type_get_full_name(class), field->name);
+ g_error ("could not resolve %s:%s\n", mono_type_get_full_name(klass), field->name);
g_assert (field->type);
}
field->offset = offset;
if (field->offset == (guint32)-1 && !(field->type->attrs & FIELD_ATTRIBUTE_STATIC)) {
- mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, g_strdup_printf ("Missing field layout info for %s", field->name));
+ mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, g_strdup_printf ("Missing field layout info for %s", field->name));
break;
}
if (field->offset < -1) { /*-1 is used to encode special static fields */
- mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, g_strdup_printf ("Invalid negative field offset %d for %s", field->offset, field->name));
+ mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, g_strdup_printf ("Invalid negative field offset %d for %s", field->offset, field->name));
break;
}
- if (class->generic_container) {
- mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, g_strdup_printf ("Generic class cannot have explicit layout."));
+ if (klass->generic_container) {
+ mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, g_strdup_printf ("Generic class cannot have explicit layout."));
break;
}
}
if (field_class) {
mono_class_setup_fields (field_class);
if (field_class->exception_type) {
- mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, NULL);
+ mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, NULL);
break;
}
}
}
}
- if (class->enumtype && !(field->type->attrs & FIELD_ATTRIBUTE_STATIC)) {
- class->cast_class = class->element_class = mono_class_from_mono_type (field->type);
- blittable = class->element_class->blittable;
+ if (klass->enumtype && !(field->type->attrs & FIELD_ATTRIBUTE_STATIC)) {
+ klass->cast_class = klass->element_class = mono_class_from_mono_type (field->type);
+ blittable = klass->element_class->blittable;
}
if (mono_type_has_exceptions (field->type)) {
- char *class_name = mono_type_get_full_name (class);
+ char *class_name = mono_type_get_full_name (klass);
char *type_name = mono_type_full_name (field->type);
- mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, NULL);
+ mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, NULL);
g_warning ("Invalid type %s for instance field %s:%s", type_name, class_name, field->name);
g_free (class_name);
g_free (type_name);
/* The def_value of fields is compute lazily during vtable creation */
}
- if (class == mono_defaults.string_class)
+ if (klass == mono_defaults.string_class)
blittable = FALSE;
- class->blittable = blittable;
+ klass->blittable = blittable;
- if (class->enumtype && !mono_class_enum_basetype (class)) {
- mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, NULL);
+ if (klass->enumtype && !mono_class_enum_basetype (klass)) {
+ mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, NULL);
return;
}
if (explicit_size && real_size) {
- class->instance_size = MAX (real_size, class->instance_size);
+ klass->instance_size = MAX (real_size, klass->instance_size);
}
- if (class->exception_type)
+ if (klass->exception_type)
return;
- mono_class_layout_fields (class);
+ mono_class_layout_fields (klass);
/*valuetypes can't be neither bigger than 1Mb or empty. */
- if (class->valuetype && (class->instance_size <= 0 || class->instance_size > (0x100000 + sizeof (MonoObject))))
- mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, NULL);
+ if (klass->valuetype && (klass->instance_size <= 0 || klass->instance_size > (0x100000 + sizeof (MonoObject))))
+ mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, NULL);
mono_memory_barrier ();
- class->fields_inited = 1;
+ klass->fields_inited = 1;
}
/**
* mono_class_setup_fields_locking:
* @class: The class to initialize
*
- * Initializes the class->fields array of fields.
+ * Initializes the klass->fields array of fields.
* Aquires the loader lock.
*/
void
-mono_class_setup_fields_locking (MonoClass *class)
+mono_class_setup_fields_locking (MonoClass *klass)
{
/* This can be checked without locks */
- if (class->fields_inited)
+ if (klass->fields_inited)
return;
mono_loader_lock ();
- mono_class_setup_fields (class);
+ mono_class_setup_fields (klass);
mono_loader_unlock ();
}
* LOCKING: this is supposed to be called with the loader lock held.
*/
void
-mono_class_layout_fields (MonoClass *class)
+mono_class_layout_fields (MonoClass *klass)
{
int i;
- const int top = class->field.count;
- guint32 layout = class->flags & TYPE_ATTRIBUTE_LAYOUT_MASK;
+ const int top = klass->field.count;
+ guint32 layout = klass->flags & TYPE_ATTRIBUTE_LAYOUT_MASK;
guint32 pass, passes, real_size;
gboolean gc_aware_layout = FALSE;
gboolean has_static_fields = FALSE;
*/
/* corlib is missing [StructLayout] directives in many places */
if (layout == TYPE_ATTRIBUTE_AUTO_LAYOUT) {
- if (!class->valuetype)
+ if (!klass->valuetype)
gc_aware_layout = TRUE;
}
for (i = 0; i < top; i++) {
MonoType *ftype;
- field = &class->fields [i];
+ field = &klass->fields [i];
if (!(field->type->attrs & FIELD_ATTRIBUTE_STATIC)) {
ftype = mono_type_get_underlying_type (field->type);
ftype = mono_type_get_basic_type_from_generic (ftype);
- if (type_has_references (class, ftype))
- class->has_references = TRUE;
+ if (type_has_references (klass, ftype))
+ klass->has_references = TRUE;
}
}
for (i = 0; i < top; i++) {
MonoType *ftype;
- field = &class->fields [i];
+ field = &klass->fields [i];
if (field->type->attrs & FIELD_ATTRIBUTE_STATIC) {
ftype = mono_type_get_underlying_type (field->type);
ftype = mono_type_get_basic_type_from_generic (ftype);
- if (type_has_references (class, ftype))
- class->has_static_refs = TRUE;
+ if (type_has_references (klass, ftype))
+ klass->has_static_refs = TRUE;
}
}
for (i = 0; i < top; i++) {
MonoType *ftype;
- field = &class->fields [i];
+ field = &klass->fields [i];
ftype = mono_type_get_underlying_type (field->type);
ftype = mono_type_get_basic_type_from_generic (ftype);
- if (type_has_references (class, ftype)) {
+ if (type_has_references (klass, ftype)) {
if (field->type->attrs & FIELD_ATTRIBUTE_STATIC)
- class->has_static_refs = TRUE;
+ klass->has_static_refs = TRUE;
else
- class->has_references = TRUE;
+ klass->has_references = TRUE;
}
}
if (layout != TYPE_ATTRIBUTE_AUTO_LAYOUT)
passes = 1;
- if (class->parent) {
- mono_class_setup_fields (class->parent);
- if (class->parent->exception_type) {
- mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, NULL);
+ if (klass->parent) {
+ mono_class_setup_fields (klass->parent);
+ if (klass->parent->exception_type) {
+ mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, NULL);
return;
}
- real_size = class->parent->instance_size;
+ real_size = klass->parent->instance_size;
} else {
real_size = sizeof (MonoObject);
}
guint32 size;
MonoType *ftype;
- field = &class->fields [i];
+ field = &klass->fields [i];
if (mono_field_is_deleted (field))
continue;
ftype = mono_type_get_underlying_type (field->type);
ftype = mono_type_get_basic_type_from_generic (ftype);
if (gc_aware_layout) {
- if (type_has_references (class, ftype)) {
+ if (type_has_references (klass, ftype)) {
if (pass == 1)
continue;
} else {
}
}
- if ((top == 1) && (class->instance_size == sizeof (MonoObject)) &&
+ if ((top == 1) && (klass->instance_size == sizeof (MonoObject)) &&
(strcmp (mono_field_get_name (field), "$PRIVATE$") == 0)) {
/* This field is a hack inserted by MCS to empty structures */
continue;
size = mono_type_size (field->type, &align);
/* FIXME (LAMESPEC): should we also change the min alignment according to pack? */
- align = class->packing_size ? MIN (class->packing_size, align): align;
+ align = klass->packing_size ? MIN (klass->packing_size, align): align;
/* if the field has managed references, we need to force-align it
* see bug #77788
*/
- if (type_has_references (class, ftype))
+ if (type_has_references (klass, ftype))
align = MAX (align, sizeof (gpointer));
- class->min_align = MAX (align, class->min_align);
+ klass->min_align = MAX (align, klass->min_align);
field->offset = real_size;
if (align) {
field->offset += align - 1;
field->offset &= ~(align - 1);
}
/*TypeBuilders produce all sort of weird things*/
- g_assert (image_is_dynamic (class->image) || field->offset > 0);
+ g_assert (image_is_dynamic (klass->image) || field->offset > 0);
real_size = field->offset + size;
}
- class->instance_size = MAX (real_size, class->instance_size);
+ klass->instance_size = MAX (real_size, klass->instance_size);
- if (class->instance_size & (class->min_align - 1)) {
- class->instance_size += class->min_align - 1;
- class->instance_size &= ~(class->min_align - 1);
+ if (klass->instance_size & (klass->min_align - 1)) {
+ klass->instance_size += klass->min_align - 1;
+ klass->instance_size &= ~(klass->min_align - 1);
}
}
break;
guint32 size;
MonoType *ftype;
- field = &class->fields [i];
+ field = &klass->fields [i];
/*
* There must be info about all the fields in a type if it
continue;
size = mono_type_size (field->type, &align);
- align = class->packing_size ? MIN (class->packing_size, align): align;
- class->min_align = MAX (align, class->min_align);
+ align = klass->packing_size ? MIN (klass->packing_size, align): align;
+ klass->min_align = MAX (align, klass->min_align);
/*
* When we get here, field->offset is already set by the
field->offset += sizeof (MonoObject);
ftype = mono_type_get_underlying_type (field->type);
ftype = mono_type_get_basic_type_from_generic (ftype);
- if (type_has_references (class, ftype)) {
+ if (type_has_references (klass, ftype)) {
if (field->offset % sizeof (gpointer)) {
- mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, NULL);
+ mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, NULL);
}
}
real_size = MAX (real_size, size + field->offset);
}
- if (class->has_references) {
+ if (klass->has_references) {
ref_bitmap = g_new0 (guint8, real_size / sizeof (gpointer));
/* Check for overlapping reference and non-reference fields */
for (i = 0; i < top; i++) {
MonoType *ftype;
- field = &class->fields [i];
+ field = &klass->fields [i];
if (mono_field_is_deleted (field))
continue;
ref_bitmap [field->offset / sizeof (gpointer)] = 1;
}
for (i = 0; i < top; i++) {
- field = &class->fields [i];
+ field = &klass->fields [i];
if (mono_field_is_deleted (field))
continue;
// FIXME: Too much code does this
#if 0
if (!MONO_TYPE_IS_REFERENCE (field->type) && ref_bitmap [field->offset / sizeof (gpointer)]) {
- char *err_msg = g_strdup_printf ("Could not load type '%s' because it contains an object field at offset %d that is incorrectly aligned or overlapped by a non-object field.", class->name, field->offset);
- mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, err_msg);
+ char *err_msg = g_strdup_printf ("Could not load type '%s' because it contains an object field at offset %d that is incorrectly aligned or overlapped by a non-object field.", klass->name, field->offset);
+ mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, err_msg);
}
#endif
}
g_free (ref_bitmap);
}
- class->instance_size = MAX (real_size, class->instance_size);
- if (class->instance_size & (class->min_align - 1)) {
- class->instance_size += class->min_align - 1;
- class->instance_size &= ~(class->min_align - 1);
+ klass->instance_size = MAX (real_size, klass->instance_size);
+ if (klass->instance_size & (klass->min_align - 1)) {
+ klass->instance_size += klass->min_align - 1;
+ klass->instance_size &= ~(klass->min_align - 1);
}
break;
}
* unaligned accesses otherwise. See #78990 for a testcase.
*/
if (mono_align_small_structs) {
- if (class->instance_size <= sizeof (MonoObject) + sizeof (gpointer))
- class->min_align = MAX (class->min_align, class->instance_size - sizeof (MonoObject));
+ if (klass->instance_size <= sizeof (MonoObject) + sizeof (gpointer))
+ klass->min_align = MAX (klass->min_align, klass->instance_size - sizeof (MonoObject));
}
}
mono_memory_barrier ();
- class->size_inited = 1;
+ klass->size_inited = 1;
/*
* Compute static field layout and size
gint32 align;
guint32 size;
- field = &class->fields [i];
+ field = &klass->fields [i];
if (!(field->type->attrs & FIELD_ATTRIBUTE_STATIC) || field->type->attrs & FIELD_ATTRIBUTE_LITERAL)
continue;
continue;
if (mono_type_has_exceptions (field->type)) {
- mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, NULL);
+ mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, NULL);
break;
}
has_static_fields = TRUE;
size = mono_type_size (field->type, &align);
- field->offset = class->sizes.class_size;
+ field->offset = klass->sizes.class_size;
/*align is always non-zero here*/
field->offset += align - 1;
field->offset &= ~(align - 1);
- class->sizes.class_size = field->offset + size;
+ klass->sizes.class_size = field->offset + size;
}
- if (has_static_fields && class->sizes.class_size == 0)
+ if (has_static_fields && klass->sizes.class_size == 0)
/* Simplify code which depends on class_size != 0 if the class has static fields */
- class->sizes.class_size = 8;
+ klass->sizes.class_size = 8;
}
static MonoMethod*
-create_array_method (MonoClass *class, const char *name, MonoMethodSignature *sig)
+create_array_method (MonoClass *klass, const char *name, MonoMethodSignature *sig)
{
MonoMethod *method;
- method = (MonoMethod *) mono_image_alloc0 (class->image, sizeof (MonoMethodPInvoke));
- method->klass = class;
+ method = (MonoMethod *) mono_image_alloc0 (klass->image, sizeof (MonoMethodPInvoke));
+ method->klass = klass;
method->flags = METHOD_ATTRIBUTE_PUBLIC;
method->iflags = METHOD_IMPL_ATTRIBUTE_INTERNAL_CALL;
method->signature = sig;
* Methods belonging to an interface are assigned a sequential slot starting
* from 0.
*
- * On failure this function sets class->exception_type
+ * On failure this function sets klass->exception_type
*/
void
-mono_class_setup_methods (MonoClass *class)
+mono_class_setup_methods (MonoClass *klass)
{
int i, count;
MonoMethod **methods;
- if (class->methods)
+ if (klass->methods)
return;
- if (class->generic_class) {
+ if (klass->generic_class) {
MonoError error;
- MonoClass *gklass = class->generic_class->container_class;
+ MonoClass *gklass = klass->generic_class->container_class;
mono_class_init (gklass);
if (!gklass->exception_type)
mono_class_setup_methods (gklass);
if (gklass->exception_type) {
/* FIXME make exception_data less opaque so it's possible to dup it here */
- mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, g_strdup ("Generic type definition failed to load"));
+ mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, g_strdup ("Generic type definition failed to load"));
return;
}
/* The + 1 makes this always non-NULL to pass the check in mono_class_setup_methods () */
count = gklass->method.count;
- methods = mono_class_alloc0 (class, sizeof (MonoMethod*) * (count + 1));
+ methods = mono_class_alloc0 (klass, sizeof (MonoMethod*) * (count + 1));
for (i = 0; i < count; i++) {
methods [i] = mono_class_inflate_generic_method_full_checked (
- gklass->methods [i], class, mono_class_get_context (class), &error);
+ gklass->methods [i], klass, mono_class_get_context (klass), &error);
if (!mono_error_ok (&error)) {
char *method = mono_method_full_name (gklass->methods [i], TRUE);
- mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, g_strdup_printf ("Could not inflate method %s due to %s", method, mono_error_get_message (&error)));
+ mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, g_strdup_printf ("Could not inflate method %s due to %s", method, mono_error_get_message (&error)));
g_free (method);
mono_error_cleanup (&error);
return;
}
}
- } else if (class->rank) {
+ } else if (klass->rank) {
MonoError error;
MonoMethod *amethod;
MonoMethodSignature *sig;
int method_num = 0;
gboolean jagged_ctor = FALSE;
- count = 3 + (class->rank > 1? 2: 1);
+ count = 3 + (klass->rank > 1? 2: 1);
- mono_class_setup_interfaces (class, &error);
+ mono_class_setup_interfaces (klass, &error);
g_assert (mono_error_ok (&error)); /*FIXME can this fail for array types?*/
- if (class->rank == 1 && class->element_class->rank) {
+ if (klass->rank == 1 && klass->element_class->rank) {
jagged_ctor = TRUE;
- class->method.count ++;
+ klass->method.count ++;
}
- if (class->interface_count) {
- count_generic = generic_array_methods (class);
+ if (klass->interface_count) {
+ count_generic = generic_array_methods (klass);
first_generic = count;
- count += class->interface_count * count_generic;
+ count += klass->interface_count * count_generic;
}
- methods = mono_class_alloc0 (class, sizeof (MonoMethod*) * count);
+ methods = mono_class_alloc0 (klass, sizeof (MonoMethod*) * count);
- sig = mono_metadata_signature_alloc (class->image, class->rank);
+ sig = mono_metadata_signature_alloc (klass->image, klass->rank);
sig->ret = &mono_defaults.void_class->byval_arg;
sig->pinvoke = TRUE;
sig->hasthis = TRUE;
- for (i = 0; i < class->rank; ++i)
+ for (i = 0; i < klass->rank; ++i)
sig->params [i] = &mono_defaults.int32_class->byval_arg;
- amethod = create_array_method (class, ".ctor", sig);
+ amethod = create_array_method (klass, ".ctor", sig);
methods [method_num++] = amethod;
- if (class->rank > 1) {
- sig = mono_metadata_signature_alloc (class->image, class->rank * 2);
+ if (klass->rank > 1) {
+ sig = mono_metadata_signature_alloc (klass->image, klass->rank * 2);
sig->ret = &mono_defaults.void_class->byval_arg;
sig->pinvoke = TRUE;
sig->hasthis = TRUE;
- for (i = 0; i < class->rank * 2; ++i)
+ for (i = 0; i < klass->rank * 2; ++i)
sig->params [i] = &mono_defaults.int32_class->byval_arg;
- amethod = create_array_method (class, ".ctor", sig);
+ amethod = create_array_method (klass, ".ctor", sig);
methods [method_num++] = amethod;
}
if (jagged_ctor) {
/* Jagged arrays have an extra ctor in .net which creates an array of arrays */
- sig = mono_metadata_signature_alloc (class->image, class->rank + 1);
+ sig = mono_metadata_signature_alloc (klass->image, klass->rank + 1);
sig->ret = &mono_defaults.void_class->byval_arg;
sig->pinvoke = TRUE;
sig->hasthis = TRUE;
- for (i = 0; i < class->rank + 1; ++i)
+ for (i = 0; i < klass->rank + 1; ++i)
sig->params [i] = &mono_defaults.int32_class->byval_arg;
- amethod = create_array_method (class, ".ctor", sig);
+ amethod = create_array_method (klass, ".ctor", sig);
methods [method_num++] = amethod;
}
/* element Get (idx11, [idx2, ...]) */
- sig = mono_metadata_signature_alloc (class->image, class->rank);
- sig->ret = &class->element_class->byval_arg;
+ sig = mono_metadata_signature_alloc (klass->image, klass->rank);
+ sig->ret = &klass->element_class->byval_arg;
sig->pinvoke = TRUE;
sig->hasthis = TRUE;
- for (i = 0; i < class->rank; ++i)
+ for (i = 0; i < klass->rank; ++i)
sig->params [i] = &mono_defaults.int32_class->byval_arg;
- amethod = create_array_method (class, "Get", sig);
+ amethod = create_array_method (klass, "Get", sig);
methods [method_num++] = amethod;
/* element& Address (idx11, [idx2, ...]) */
- sig = mono_metadata_signature_alloc (class->image, class->rank);
- sig->ret = &class->element_class->this_arg;
+ sig = mono_metadata_signature_alloc (klass->image, klass->rank);
+ sig->ret = &klass->element_class->this_arg;
sig->pinvoke = TRUE;
sig->hasthis = TRUE;
- for (i = 0; i < class->rank; ++i)
+ for (i = 0; i < klass->rank; ++i)
sig->params [i] = &mono_defaults.int32_class->byval_arg;
- amethod = create_array_method (class, "Address", sig);
+ amethod = create_array_method (klass, "Address", sig);
methods [method_num++] = amethod;
/* void Set (idx11, [idx2, ...], element) */
- sig = mono_metadata_signature_alloc (class->image, class->rank + 1);
+ sig = mono_metadata_signature_alloc (klass->image, klass->rank + 1);
sig->ret = &mono_defaults.void_class->byval_arg;
sig->pinvoke = TRUE;
sig->hasthis = TRUE;
- for (i = 0; i < class->rank; ++i)
+ for (i = 0; i < klass->rank; ++i)
sig->params [i] = &mono_defaults.int32_class->byval_arg;
- sig->params [i] = &class->element_class->byval_arg;
- amethod = create_array_method (class, "Set", sig);
+ sig->params [i] = &klass->element_class->byval_arg;
+ amethod = create_array_method (klass, "Set", sig);
methods [method_num++] = amethod;
- for (i = 0; i < class->interface_count; i++)
- setup_generic_array_ifaces (class, class->interfaces [i], methods, first_generic + i * count_generic);
+ for (i = 0; i < klass->interface_count; i++)
+ setup_generic_array_ifaces (klass, klass->interfaces [i], methods, first_generic + i * count_generic);
} else {
MonoError error;
- count = class->method.count;
- methods = mono_class_alloc (class, sizeof (MonoMethod*) * count);
+ count = klass->method.count;
+ methods = mono_class_alloc (klass, sizeof (MonoMethod*) * count);
for (i = 0; i < count; ++i) {
- int idx = mono_metadata_translate_token_index (class->image, MONO_TABLE_METHOD, class->method.first + i + 1);
- methods [i] = mono_get_method_checked (class->image, MONO_TOKEN_METHOD_DEF | idx, class, NULL, &error);
+ int idx = mono_metadata_translate_token_index (klass->image, MONO_TABLE_METHOD, klass->method.first + i + 1);
+ methods [i] = mono_get_method_checked (klass->image, MONO_TOKEN_METHOD_DEF | idx, klass, NULL, &error);
if (!methods [i]) {
- mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, g_strdup_printf ("Could not load method %d due to %s", i, mono_error_get_message (&error)));
+ mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, g_strdup_printf ("Could not load method %d due to %s", i, mono_error_get_message (&error)));
mono_error_cleanup (&error);
}
}
}
- if (MONO_CLASS_IS_INTERFACE (class)) {
+ if (MONO_CLASS_IS_INTERFACE (klass)) {
int slot = 0;
/*Only assign slots to virtual methods as interfaces are allowed to have static methods.*/
for (i = 0; i < count; ++i) {
}
}
- mono_image_lock (class->image);
+ mono_image_lock (klass->image);
- if (!class->methods) {
- class->method.count = count;
+ if (!klass->methods) {
+ klass->method.count = count;
/* Needed because of the double-checking locking pattern */
mono_memory_barrier ();
- class->methods = methods;
+ klass->methods = methods;
}
- mono_image_unlock (class->image);
+ mono_image_unlock (klass->image);
}
/*
* mono_class_get_method_by_index:
*
- * Returns class->methods [index], initializing class->methods if neccesary.
+ * Returns klass->methods [index], initializing klass->methods if neccesary.
*
* LOCKING: Acquires the loader lock.
*/
MonoMethod*
-mono_class_get_method_by_index (MonoClass *class, int index)
+mono_class_get_method_by_index (MonoClass *klass, int index)
{
MonoError error;
/* Avoid calling setup_methods () if possible */
- if (class->generic_class && !class->methods) {
- MonoClass *gklass = class->generic_class->container_class;
+ if (klass->generic_class && !klass->methods) {
+ MonoClass *gklass = klass->generic_class->container_class;
MonoMethod *m;
m = mono_class_inflate_generic_method_full_checked (
- gklass->methods [index], class, mono_class_get_context (class), &error);
+ gklass->methods [index], klass, mono_class_get_context (klass), &error);
g_assert (mono_error_ok (&error)); /* FIXME don't swallow the error */
/*
* If setup_methods () is called later for this class, no duplicates are created,
* is created for each context.
*/
/*
- mono_class_setup_methods (class);
- g_assert (m == class->methods [index]);
+ mono_class_setup_methods (klass);
+ g_assert (m == klass->methods [index]);
*/
return m;
} else {
- mono_class_setup_methods (class);
- if (class->exception_type) /*FIXME do proper error handling*/
+ mono_class_setup_methods (klass);
+ if (klass->exception_type) /*FIXME do proper error handling*/
return NULL;
- g_assert (index >= 0 && index < class->method.count);
- return class->methods [index];
+ g_assert (index >= 0 && index < klass->method.count);
+ return klass->methods [index];
}
}
* CLASS's generic definition, return the inflated method corresponding to METHOD.
*/
MonoMethod*
-mono_class_get_inflated_method (MonoClass *class, MonoMethod *method)
+mono_class_get_inflated_method (MonoClass *klass, MonoMethod *method)
{
- MonoClass *gklass = class->generic_class->container_class;
+ MonoClass *gklass = klass->generic_class->container_class;
int i;
g_assert (method->klass == gklass);
for (i = 0; i < gklass->method.count; ++i) {
if (gklass->methods [i] == method) {
- if (class->methods) {
- return class->methods [i];
+ if (klass->methods) {
+ return klass->methods [i];
} else {
MonoError error;
- MonoMethod *result = mono_class_inflate_generic_method_full_checked (gklass->methods [i], class, mono_class_get_context (class), &error);
+ MonoMethod *result = mono_class_inflate_generic_method_full_checked (gklass->methods [i], klass, mono_class_get_context (klass), &error);
g_assert (mono_error_ok (&error)); /* FIXME don't swallow this error */
return result;
}
/*
* mono_class_get_vtable_entry:
*
- * Returns class->vtable [offset], computing it if neccesary. Returns NULL on failure.
+ * Returns klass->vtable [offset], computing it if neccesary. Returns NULL on failure.
* LOCKING: Acquires the loader lock.
*/
MonoMethod*
-mono_class_get_vtable_entry (MonoClass *class, int offset)
+mono_class_get_vtable_entry (MonoClass *klass, int offset)
{
MonoMethod *m;
- if (class->rank == 1) {
+ if (klass->rank == 1) {
/*
* szarrays do not overwrite any methods of Array, so we can avoid
* initializing their vtables in some cases.
*/
- mono_class_setup_vtable (class->parent);
- if (offset < class->parent->vtable_size)
- return class->parent->vtable [offset];
+ mono_class_setup_vtable (klass->parent);
+ if (offset < klass->parent->vtable_size)
+ return klass->parent->vtable [offset];
}
- if (class->generic_class) {
+ if (klass->generic_class) {
MonoError error;
- MonoClass *gklass = class->generic_class->container_class;
+ MonoClass *gklass = klass->generic_class->container_class;
mono_class_setup_vtable (gklass);
m = gklass->vtable [offset];
- m = mono_class_inflate_generic_method_full_checked (m, class, mono_class_get_context (class), &error);
+ m = mono_class_inflate_generic_method_full_checked (m, klass, mono_class_get_context (klass), &error);
g_assert (mono_error_ok (&error)); /* FIXME don't swallow this error */
} else {
- mono_class_setup_vtable (class);
- if (class->exception_type)
+ mono_class_setup_vtable (klass);
+ if (klass->exception_type)
return NULL;
- m = class->vtable [offset];
+ m = klass->vtable [offset];
}
return m;
/*
* mono_class_setup_properties:
*
- * Initialize class->ext.property and class->ext.properties.
+ * Initialize klass->ext.property and klass->ext.properties.
*
* This method can fail the class.
*/
static void
-mono_class_setup_properties (MonoClass *class)
+mono_class_setup_properties (MonoClass *klass)
{
guint startm, endm, i, j;
guint32 cols [MONO_PROPERTY_SIZE];
- MonoTableInfo *msemt = &class->image->tables [MONO_TABLE_METHODSEMANTICS];
+ MonoTableInfo *msemt = &klass->image->tables [MONO_TABLE_METHODSEMANTICS];
MonoProperty *properties;
guint32 last;
int first, count;
- if (class->ext && class->ext->properties)
+ if (klass->ext && klass->ext->properties)
return;
- if (class->generic_class) {
- MonoClass *gklass = class->generic_class->container_class;
+ if (klass->generic_class) {
+ MonoClass *gklass = klass->generic_class->container_class;
mono_class_init (gklass);
mono_class_setup_properties (gklass);
if (gklass->exception_type) {
- mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, g_strdup ("Generic type definition failed to load"));
+ mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, g_strdup ("Generic type definition failed to load"));
return;
}
- properties = mono_class_new0 (class, MonoProperty, gklass->ext->property.count + 1);
+ properties = mono_class_new0 (klass, MonoProperty, gklass->ext->property.count + 1);
for (i = 0; i < gklass->ext->property.count; i++) {
MonoError error;
if (prop->get)
prop->get = mono_class_inflate_generic_method_full_checked (
- prop->get, class, mono_class_get_context (class), &error);
+ prop->get, klass, mono_class_get_context (klass), &error);
if (prop->set)
prop->set = mono_class_inflate_generic_method_full_checked (
- prop->set, class, mono_class_get_context (class), &error);
+ prop->set, klass, mono_class_get_context (klass), &error);
g_assert (mono_error_ok (&error)); /*FIXME proper error handling*/
- prop->parent = class;
+ prop->parent = klass;
}
first = gklass->ext->property.first;
count = gklass->ext->property.count;
} else {
- first = mono_metadata_properties_from_typedef (class->image, mono_metadata_token_index (class->type_token) - 1, &last);
+ first = mono_metadata_properties_from_typedef (klass->image, mono_metadata_token_index (klass->type_token) - 1, &last);
count = last - first;
if (count) {
- mono_class_setup_methods (class);
- if (class->exception_type)
+ mono_class_setup_methods (klass);
+ if (klass->exception_type)
return;
}
- properties = mono_class_alloc0 (class, sizeof (MonoProperty) * count);
+ properties = mono_class_alloc0 (klass, sizeof (MonoProperty) * count);
for (i = first; i < last; ++i) {
- mono_metadata_decode_table_row (class->image, MONO_TABLE_PROPERTY, i, cols, MONO_PROPERTY_SIZE);
- properties [i - first].parent = class;
+ mono_metadata_decode_table_row (klass->image, MONO_TABLE_PROPERTY, i, cols, MONO_PROPERTY_SIZE);
+ properties [i - first].parent = klass;
properties [i - first].attrs = cols [MONO_PROPERTY_FLAGS];
- properties [i - first].name = mono_metadata_string_heap (class->image, cols [MONO_PROPERTY_NAME]);
+ properties [i - first].name = mono_metadata_string_heap (klass->image, cols [MONO_PROPERTY_NAME]);
- startm = mono_metadata_methods_from_property (class->image, i, &endm);
+ startm = mono_metadata_methods_from_property (klass->image, i, &endm);
for (j = startm; j < endm; ++j) {
MonoMethod *method;
mono_metadata_decode_row (msemt, j, cols, MONO_METHOD_SEMA_SIZE);
- if (class->image->uncompressed_metadata) {
+ if (klass->image->uncompressed_metadata) {
MonoError error;
/* It seems like the MONO_METHOD_SEMA_METHOD column needs no remapping */
- method = mono_get_method_checked (class->image, MONO_TOKEN_METHOD_DEF | cols [MONO_METHOD_SEMA_METHOD], class, NULL, &error);
+ method = mono_get_method_checked (klass->image, MONO_TOKEN_METHOD_DEF | cols [MONO_METHOD_SEMA_METHOD], klass, NULL, &error);
mono_error_cleanup (&error); /* FIXME don't swallow this error */
} else {
- method = class->methods [cols [MONO_METHOD_SEMA_METHOD] - 1 - class->method.first];
+ method = klass->methods [cols [MONO_METHOD_SEMA_METHOD] - 1 - klass->method.first];
}
switch (cols [MONO_METHOD_SEMA_SEMANTICS]) {
}
}
- mono_class_alloc_ext (class);
+ mono_class_alloc_ext (klass);
- mono_image_lock (class->image);
+ mono_image_lock (klass->image);
- if (class->ext->properties) {
+ if (klass->ext->properties) {
/* We leak 'properties' which was allocated from the image mempool */
- mono_image_unlock (class->image);
+ mono_image_unlock (klass->image);
return;
}
- class->ext->property.first = first;
- class->ext->property.count = count;
+ klass->ext->property.first = first;
+ klass->ext->property.count = count;
- /* Flush any pending writes as we do double checked locking on class->ext->properties */
+ /* Flush any pending writes as we do double checked locking on klass->ext->properties */
mono_memory_barrier ();
/* Leave this assignment as the last op in the function */
- class->ext->properties = properties;
+ klass->ext->properties = properties;
- mono_image_unlock (class->image);
+ mono_image_unlock (klass->image);
}
static MonoMethod**
-inflate_method_listz (MonoMethod **methods, MonoClass *class, MonoGenericContext *context)
+inflate_method_listz (MonoMethod **methods, MonoClass *klass, MonoGenericContext *context)
{
MonoMethod **om, **retval;
int count;
count = 0;
for (om = methods, count = 0; *om; ++om, ++count) {
MonoError error;
- retval [count] = mono_class_inflate_generic_method_full_checked (*om, class, context, &error);
+ retval [count] = mono_class_inflate_generic_method_full_checked (*om, klass, context, &error);
g_assert (mono_error_ok (&error)); /*FIXME proper error handling*/
}
/*This method can fail the class.*/
static void
-mono_class_setup_events (MonoClass *class)
+mono_class_setup_events (MonoClass *klass)
{
int first, count;
guint startm, endm, i, j;
guint32 cols [MONO_EVENT_SIZE];
- MonoTableInfo *msemt = &class->image->tables [MONO_TABLE_METHODSEMANTICS];
+ MonoTableInfo *msemt = &klass->image->tables [MONO_TABLE_METHODSEMANTICS];
guint32 last;
MonoEvent *events;
- if (class->ext && class->ext->events)
+ if (klass->ext && klass->ext->events)
return;
- if (class->generic_class) {
- MonoClass *gklass = class->generic_class->container_class;
+ if (klass->generic_class) {
+ MonoClass *gklass = klass->generic_class->container_class;
MonoGenericContext *context = NULL;
mono_class_setup_events (gklass);
if (gklass->exception_type) {
- mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, g_strdup ("Generic type definition failed to load"));
+ mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, g_strdup ("Generic type definition failed to load"));
return;
}
first = gklass->ext->event.first;
count = gklass->ext->event.count;
- events = mono_class_new0 (class, MonoEvent, count);
+ events = mono_class_new0 (klass, MonoEvent, count);
if (count)
- context = mono_class_get_context (class);
+ context = mono_class_get_context (klass);
for (i = 0; i < count; i++) {
MonoError error;
mono_error_init (&error); //since we do conditional calls, we must ensure the default value is ok
- event->parent = class;
+ event->parent = klass;
event->name = gevent->name;
- event->add = gevent->add ? mono_class_inflate_generic_method_full_checked (gevent->add, class, context, &error) : NULL;
+ event->add = gevent->add ? mono_class_inflate_generic_method_full_checked (gevent->add, klass, context, &error) : NULL;
g_assert (mono_error_ok (&error)); /*FIXME proper error handling*/
- event->remove = gevent->remove ? mono_class_inflate_generic_method_full_checked (gevent->remove, class, context, &error) : NULL;
+ event->remove = gevent->remove ? mono_class_inflate_generic_method_full_checked (gevent->remove, klass, context, &error) : NULL;
g_assert (mono_error_ok (&error)); /*FIXME proper error handling*/
- event->raise = gevent->raise ? mono_class_inflate_generic_method_full_checked (gevent->raise, class, context, &error) : NULL;
+ event->raise = gevent->raise ? mono_class_inflate_generic_method_full_checked (gevent->raise, klass, context, &error) : NULL;
g_assert (mono_error_ok (&error)); /*FIXME proper error handling*/
#ifndef MONO_SMALL_CONFIG
- event->other = gevent->other ? inflate_method_listz (gevent->other, class, context) : NULL;
+ event->other = gevent->other ? inflate_method_listz (gevent->other, klass, context) : NULL;
#endif
event->attrs = gevent->attrs;
}
} else {
- first = mono_metadata_events_from_typedef (class->image, mono_metadata_token_index (class->type_token) - 1, &last);
+ first = mono_metadata_events_from_typedef (klass->image, mono_metadata_token_index (klass->type_token) - 1, &last);
count = last - first;
if (count) {
- mono_class_setup_methods (class);
- if (class->exception_type) {
- mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, g_strdup ("Generic type definition failed to load"));
+ mono_class_setup_methods (klass);
+ if (klass->exception_type) {
+ mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, g_strdup ("Generic type definition failed to load"));
return;
}
}
- events = mono_class_alloc0 (class, sizeof (MonoEvent) * count);
+ events = mono_class_alloc0 (klass, sizeof (MonoEvent) * count);
for (i = first; i < last; ++i) {
MonoEvent *event = &events [i - first];
- mono_metadata_decode_table_row (class->image, MONO_TABLE_EVENT, i, cols, MONO_EVENT_SIZE);
- event->parent = class;
+ mono_metadata_decode_table_row (klass->image, MONO_TABLE_EVENT, i, cols, MONO_EVENT_SIZE);
+ event->parent = klass;
event->attrs = cols [MONO_EVENT_FLAGS];
- event->name = mono_metadata_string_heap (class->image, cols [MONO_EVENT_NAME]);
+ event->name = mono_metadata_string_heap (klass->image, cols [MONO_EVENT_NAME]);
- startm = mono_metadata_methods_from_event (class->image, i, &endm);
+ startm = mono_metadata_methods_from_event (klass->image, i, &endm);
for (j = startm; j < endm; ++j) {
MonoMethod *method;
mono_metadata_decode_row (msemt, j, cols, MONO_METHOD_SEMA_SIZE);
- if (class->image->uncompressed_metadata) {
+ if (klass->image->uncompressed_metadata) {
MonoError error;
/* It seems like the MONO_METHOD_SEMA_METHOD column needs no remapping */
- method = mono_get_method_checked (class->image, MONO_TOKEN_METHOD_DEF | cols [MONO_METHOD_SEMA_METHOD], class, NULL, &error);
+ method = mono_get_method_checked (klass->image, MONO_TOKEN_METHOD_DEF | cols [MONO_METHOD_SEMA_METHOD], klass, NULL, &error);
mono_error_cleanup (&error); /* FIXME don't swallow this error */
} else {
- method = class->methods [cols [MONO_METHOD_SEMA_METHOD] - 1 - class->method.first];
+ method = klass->methods [cols [MONO_METHOD_SEMA_METHOD] - 1 - klass->method.first];
}
switch (cols [MONO_METHOD_SEMA_SEMANTICS]) {
}
}
- mono_class_alloc_ext (class);
+ mono_class_alloc_ext (klass);
- mono_image_lock (class->image);
+ mono_image_lock (klass->image);
- if (class->ext->events) {
- mono_image_unlock (class->image);
+ if (klass->ext->events) {
+ mono_image_unlock (klass->image);
return;
}
- class->ext->event.first = first;
- class->ext->event.count = count;
+ klass->ext->event.first = first;
+ klass->ext->event.count = count;
- /* Flush any pending writes as we do double checked locking on class->ext.events */
+ /* Flush any pending writes as we do double checked locking on klass->ext.events */
mono_memory_barrier ();
/* Leave this assignment as the last op in the function */
- class->ext->events = events;
+ klass->ext->events = events;
- mono_image_unlock (class->image);
+ mono_image_unlock (klass->image);
}
/*
}
void
-mono_unload_interface_id (MonoClass *class)
+mono_unload_interface_id (MonoClass *klass)
{
- if (global_interface_bitset && class->interface_id) {
+ if (global_interface_bitset && klass->interface_id) {
classes_lock ();
- mono_bitset_clear (global_interface_bitset, class->interface_id);
+ mono_bitset_clear (global_interface_bitset, klass->interface_id);
classes_unlock ();
}
}
* Returns: the new ID.
*/
static guint
-mono_get_unique_iid (MonoClass *class)
+mono_get_unique_iid (MonoClass *klass)
{
int iid;
- g_assert (MONO_CLASS_IS_INTERFACE (class));
+ g_assert (MONO_CLASS_IS_INTERFACE (klass));
classes_lock ();
}
mono_bitset_set (global_interface_bitset, iid);
/* set the bit also in the per-image set */
- if (!class->generic_class) {
- if (class->image->interface_bitset) {
- if (iid >= mono_bitset_size (class->image->interface_bitset)) {
- MonoBitSet *new_set = mono_bitset_clone (class->image->interface_bitset, iid + 1);
- mono_bitset_free (class->image->interface_bitset);
- class->image->interface_bitset = new_set;
+ if (!klass->generic_class) {
+ if (klass->image->interface_bitset) {
+ if (iid >= mono_bitset_size (klass->image->interface_bitset)) {
+ MonoBitSet *new_set = mono_bitset_clone (klass->image->interface_bitset, iid + 1);
+ mono_bitset_free (klass->image->interface_bitset);
+ klass->image->interface_bitset = new_set;
}
} else {
- class->image->interface_bitset = mono_bitset_new (iid + 1, 0);
+ klass->image->interface_bitset = mono_bitset_new (iid + 1, 0);
}
- mono_bitset_set (class->image->interface_bitset, iid);
+ mono_bitset_set (klass->image->interface_bitset, iid);
}
classes_unlock ();
#ifndef MONO_SMALL_CONFIG
if (mono_print_vtable) {
int generic_id;
- char *type_name = mono_type_full_name (&class->byval_arg);
- if (class->generic_class && !class->generic_class->context.class_inst->is_open) {
- generic_id = class->generic_class->context.class_inst->id;
+ char *type_name = mono_type_full_name (&klass->byval_arg);
+ if (klass->generic_class && !klass->generic_class->context.class_inst->is_open) {
+ generic_id = klass->generic_class->context.class_inst->id;
g_assert (generic_id != 0);
} else {
generic_id = 0;
}
- printf ("Interface: assigned id %d to %s|%s|%d\n", iid, class->image->name, type_name, generic_id);
+ printf ("Interface: assigned id %d to %s|%s|%d\n", iid, klass->image->name, type_name, generic_id);
g_free (type_name);
}
#endif
}
static MonoClass*
-array_class_get_if_rank (MonoClass *class, guint rank)
+array_class_get_if_rank (MonoClass *klass, guint rank)
{
- return rank ? mono_array_class_get (class, rank) : class;
+ return rank ? mono_array_class_get (klass, rank) : klass;
}
static void
* Fixing this should kill quite some code, save some bits and improve compatibility.
*/
static MonoClass**
-get_implicit_generic_array_interfaces (MonoClass *class, int *num, int *is_enumerator)
+get_implicit_generic_array_interfaces (MonoClass *klass, int *num, int *is_enumerator)
{
- MonoClass *eclass = class->element_class;
+ MonoClass *eclass = klass->element_class;
static MonoClass* generic_icollection_class = NULL;
static MonoClass* generic_ienumerable_class = NULL;
static MonoClass* generic_ienumerator_class = NULL;
internal_enumerator = FALSE;
eclass_is_valuetype = FALSE;
original_rank = eclass->rank;
- if (class->byval_arg.type != MONO_TYPE_SZARRAY) {
- if (class->generic_class && class->nested_in == mono_defaults.array_class && strcmp (class->name, "InternalEnumerator`1") == 0) {
+ if (klass->byval_arg.type != MONO_TYPE_SZARRAY) {
+ if (klass->generic_class && klass->nested_in == mono_defaults.array_class && strcmp (klass->name, "InternalEnumerator`1") == 0) {
/*
* For a Enumerator<T[]> we need to get the list of interfaces for T.
*/
- eclass = mono_class_from_mono_type (class->generic_class->context.class_inst->type_argv [0]);
+ eclass = mono_class_from_mono_type (klass->generic_class->context.class_inst->type_argv [0]);
original_rank = eclass->rank;
if (!eclass->rank)
eclass = eclass->element_class;
}
#if 0
{
- char *type_name = mono_type_get_name_full (&class->byval_arg, 0);
+ char *type_name = mono_type_get_name_full (&klass->byval_arg, 0);
for (i = 0; i < real_count; ++i) {
char *name = mono_type_get_name_full (&interfaces [i]->byval_arg, 0);
g_print ("%s implements %s\n", type_name, name);
* FIXME It would be nice if this information could be cached somewhere.
*/
static int
-count_virtual_methods (MonoClass *class)
+count_virtual_methods (MonoClass *klass)
{
int i, count = 0;
guint32 flags;
- class = mono_class_get_generic_type_definition (class); /*We can find this information by looking at the GTD*/
+ klass = mono_class_get_generic_type_definition (klass); /*We can find this information by looking at the GTD*/
- if (class->methods || !MONO_CLASS_HAS_STATIC_METADATA (class)) {
- mono_class_setup_methods (class);
- if (class->exception_type)
+ if (klass->methods || !MONO_CLASS_HAS_STATIC_METADATA (klass)) {
+ mono_class_setup_methods (klass);
+ if (klass->exception_type)
return -1;
- for (i = 0; i < class->method.count; ++i) {
- flags = class->methods [i]->flags;
+ for (i = 0; i < klass->method.count; ++i) {
+ flags = klass->methods [i]->flags;
if (flags & METHOD_ATTRIBUTE_VIRTUAL)
++count;
}
} else {
- for (i = 0; i < class->method.count; ++i) {
- flags = mono_metadata_decode_table_row_col (class->image, MONO_TABLE_METHOD, class->method.first + i, MONO_METHOD_FLAGS);
+ for (i = 0; i < klass->method.count; ++i) {
+ flags = mono_metadata_decode_table_row_col (klass->image, MONO_TABLE_METHOD, klass->method.first + i, MONO_METHOD_FLAGS);
if (flags & METHOD_ATTRIBUTE_VIRTUAL)
++count;
* Return -1 on failure and set exception_type
*/
static int
-setup_interface_offsets (MonoClass *class, int cur_slot, gboolean overwrite)
+setup_interface_offsets (MonoClass *klass, int cur_slot, gboolean overwrite)
{
MonoError error;
MonoClass *k, *ic;
int num_array_interfaces;
int is_enumerator = FALSE;
- mono_class_setup_supertypes (class);
+ mono_class_setup_supertypes (klass);
/*
* get the implicit generic interfaces for either the arrays or for System.Array/InternalEnumerator<T>
* implicit interfaces have the property that they are assigned the same slot in the
* vtables for compatible interfaces
*/
- array_interfaces = get_implicit_generic_array_interfaces (class, &num_array_interfaces, &is_enumerator);
+ array_interfaces = get_implicit_generic_array_interfaces (klass, &num_array_interfaces, &is_enumerator);
/* compute maximum number of slots and maximum interface id */
max_iid = 0;
num_ifaces = num_array_interfaces; /* this can include duplicated ones */
- ifaces_array = g_new0 (GPtrArray *, class->idepth);
- for (j = 0; j < class->idepth; j++) {
- k = class->supertypes [j];
+ ifaces_array = g_new0 (GPtrArray *, klass->idepth);
+ for (j = 0; j < klass->idepth; j++) {
+ k = klass->supertypes [j];
num_ifaces += k->interface_count;
for (i = 0; i < k->interface_count; i++) {
ic = k->interfaces [i];
ifaces = mono_class_get_implemented_interfaces (k, &error);
if (!mono_error_ok (&error)) {
char *name = mono_type_get_full_name (k);
- mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, g_strdup_printf ("Error getting the interfaces of %s due to %s", name, mono_error_get_message (&error)));
+ mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, g_strdup_printf ("Error getting the interfaces of %s due to %s", name, mono_error_get_message (&error)));
g_free (name);
mono_error_cleanup (&error);
cur_slot = -1;
max_iid = ic->interface_id;
}
- if (MONO_CLASS_IS_INTERFACE (class)) {
+ if (MONO_CLASS_IS_INTERFACE (klass)) {
num_ifaces++;
- if (max_iid < class->interface_id)
- max_iid = class->interface_id;
+ if (max_iid < klass->interface_id)
+ max_iid = klass->interface_id;
}
- class->max_interface_id = max_iid;
+ klass->max_interface_id = max_iid;
/* compute vtable offset for interfaces */
interfaces_full = g_malloc0 (sizeof (MonoClass*) * num_ifaces);
interface_offsets_full = g_malloc (sizeof (int) * num_ifaces);
}
/* skip the current class */
- for (j = 0; j < class->idepth - 1; j++) {
- k = class->supertypes [j];
+ for (j = 0; j < klass->idepth - 1; j++) {
+ k = klass->supertypes [j];
ifaces = ifaces_array [j];
if (ifaces) {
}
}
- g_assert (class == class->supertypes [class->idepth - 1]);
- ifaces = ifaces_array [class->idepth - 1];
+ g_assert (klass == klass->supertypes [klass->idepth - 1]);
+ ifaces = ifaces_array [klass->idepth - 1];
if (ifaces) {
for (i = 0; i < ifaces->len; ++i) {
int count;
count = count_virtual_methods (ic);
if (count == -1) {
char *name = mono_type_get_full_name (ic);
- mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, g_strdup_printf ("Error calculating interface offset of %s", name));
+ mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, g_strdup_printf ("Error calculating interface offset of %s", name));
g_free (name);
cur_slot = -1;
goto end;
}
}
- if (MONO_CLASS_IS_INTERFACE (class))
- set_interface_and_offset (num_ifaces, interfaces_full, interface_offsets_full, class, cur_slot, TRUE);
+ if (MONO_CLASS_IS_INTERFACE (klass))
+ set_interface_and_offset (num_ifaces, interfaces_full, interface_offsets_full, klass, cur_slot, TRUE);
if (num_array_interfaces) {
if (is_enumerator) {
- int ienumerator_idx = find_array_interface (class, "IEnumerator`1");
- int ienumerator_offset = find_interface_offset (num_ifaces, interfaces_full, interface_offsets_full, class->interfaces [ienumerator_idx]);
+ int ienumerator_idx = find_array_interface (klass, "IEnumerator`1");
+ int ienumerator_offset = find_interface_offset (num_ifaces, interfaces_full, interface_offsets_full, klass->interfaces [ienumerator_idx]);
g_assert (ienumerator_offset >= 0);
for (i = 0; i < num_array_interfaces; ++i) {
ic = array_interfaces [i];
set_interface_and_offset (num_ifaces, interfaces_full, interface_offsets_full, ic, ienumerator_offset, TRUE);
else
g_assert_not_reached ();
- /*g_print ("type %s has %s offset at %d (%s)\n", class->name, ic->name, interface_offsets_full [ic->interface_id], class->interfaces [0]->name);*/
+ /*g_print ("type %s has %s offset at %d (%s)\n", klass->name, ic->name, interface_offsets_full [ic->interface_id], klass->interfaces [0]->name);*/
}
} else {
int ilist_offset, icollection_offset, ienumerable_offset, ireadonlylist_offset, ireadonlycollection_offset;
- int ilist_iface_idx = find_array_interface (class, "IList`1");
- MonoClass* ilist_class = class->interfaces [ilist_iface_idx];
- int ireadonlylist_iface_idx = find_array_interface (class, "IReadOnlyList`1");
- MonoClass* ireadonlylist_class = ireadonlylist_iface_idx != -1 ? class->interfaces [ireadonlylist_iface_idx] : NULL;
+ int ilist_iface_idx = find_array_interface (klass, "IList`1");
+ MonoClass* ilist_class = klass->interfaces [ilist_iface_idx];
+ int ireadonlylist_iface_idx = find_array_interface (klass, "IReadOnlyList`1");
+ MonoClass* ireadonlylist_class = ireadonlylist_iface_idx != -1 ? klass->interfaces [ireadonlylist_iface_idx] : NULL;
int icollection_iface_idx = find_array_interface (ilist_class, "ICollection`1");
int ienumerable_iface_idx = find_array_interface (ilist_class, "IEnumerable`1");
int ireadonlycollection_iface_idx = ireadonlylist_iface_idx != -1 ? find_array_interface (ireadonlylist_class, "IReadOnlyCollection`1") : -1;
- ilist_offset = find_interface_offset (num_ifaces, interfaces_full, interface_offsets_full, class->interfaces [ilist_iface_idx]);
+ ilist_offset = find_interface_offset (num_ifaces, interfaces_full, interface_offsets_full, klass->interfaces [ilist_iface_idx]);
icollection_offset = find_interface_offset (num_ifaces, interfaces_full, interface_offsets_full, ilist_class->interfaces [icollection_iface_idx]);
ienumerable_offset = find_interface_offset (num_ifaces, interfaces_full, interface_offsets_full, ilist_class->interfaces [ienumerable_iface_idx]);
- ireadonlylist_offset = ireadonlylist_iface_idx != -1 ? find_interface_offset (num_ifaces, interfaces_full, interface_offsets_full, class->interfaces [ireadonlylist_iface_idx]) : -1;
+ ireadonlylist_offset = ireadonlylist_iface_idx != -1 ? find_interface_offset (num_ifaces, interfaces_full, interface_offsets_full, klass->interfaces [ireadonlylist_iface_idx]) : -1;
ireadonlycollection_offset = ireadonlycollection_iface_idx != -1 ? find_interface_offset (num_ifaces, interfaces_full, interface_offsets_full, ireadonlylist_class->interfaces [ireadonlycollection_iface_idx]) : -1;
g_assert (ilist_offset >= 0 && icollection_offset >= 0 && ienumerable_offset >= 0);
for (i = 0; i < num_array_interfaces; ++i) {
else
g_assert_not_reached ();
set_interface_and_offset (num_ifaces, interfaces_full, interface_offsets_full, ic, offset, TRUE);
- /*g_print ("type %s has %s offset at %d (%s)\n", class->name, ic->name, offset, class->interfaces [0]->name);*/
+ /*g_print ("type %s has %s offset at %d (%s)\n", klass->name, ic->name, offset, klass->interfaces [0]->name);*/
}
}
}
* mono_class_setup_interface_offsets () passes 0 as CUR_SLOT, so the computed interface offsets will be invalid. This
* means we have to overwrite those when called from other places (#4440).
*/
- if (class->interfaces_packed) {
+ if (klass->interfaces_packed) {
if (!overwrite)
- g_assert (class->interface_offsets_count == interface_offsets_count);
+ g_assert (klass->interface_offsets_count == interface_offsets_count);
} else {
uint8_t *bitmap;
int bsize;
- class->interface_offsets_count = interface_offsets_count;
- class->interfaces_packed = mono_class_alloc (class, sizeof (MonoClass*) * interface_offsets_count);
- class->interface_offsets_packed = mono_class_alloc (class, sizeof (guint16) * interface_offsets_count);
+ klass->interface_offsets_count = interface_offsets_count;
+ klass->interfaces_packed = mono_class_alloc (klass, sizeof (MonoClass*) * interface_offsets_count);
+ klass->interface_offsets_packed = mono_class_alloc (klass, sizeof (guint16) * interface_offsets_count);
bsize = (sizeof (guint8) * ((max_iid + 1) >> 3)) + (((max_iid + 1) & 7)? 1 :0);
#ifdef COMPRESSED_INTERFACE_BITMAP
bitmap = g_malloc0 (bsize);
#else
- bitmap = mono_class_alloc0 (class, bsize);
+ bitmap = mono_class_alloc0 (klass, bsize);
#endif
for (i = 0; i < interface_offsets_count; i++) {
int id = interfaces_full [i]->interface_id;
bitmap [id >> 3] |= (1 << (id & 7));
- class->interfaces_packed [i] = interfaces_full [i];
- class->interface_offsets_packed [i] = interface_offsets_full [i];
+ klass->interfaces_packed [i] = interfaces_full [i];
+ klass->interface_offsets_packed [i] = interface_offsets_full [i];
/*if (num_array_interfaces)
- g_print ("type %s has %s offset at %d\n", mono_type_get_name_full (&class->byval_arg, 0), mono_type_get_name_full (&interfaces_full [i]->byval_arg, 0), interface_offsets_full [i]);*/
+ g_print ("type %s has %s offset at %d\n", mono_type_get_name_full (&klass->byval_arg, 0), mono_type_get_name_full (&interfaces_full [i]->byval_arg, 0), interface_offsets_full [i]);*/
}
#ifdef COMPRESSED_INTERFACE_BITMAP
i = mono_compress_bitmap (NULL, bitmap, bsize);
- class->interface_bitmap = mono_class_alloc0 (class, i);
- mono_compress_bitmap (class->interface_bitmap, bitmap, bsize);
+ klass->interface_bitmap = mono_class_alloc0 (klass, i);
+ mono_compress_bitmap (klass->interface_bitmap, bitmap, bsize);
g_free (bitmap);
#else
- class->interface_bitmap = bitmap;
+ klass->interface_bitmap = bitmap;
#endif
}
g_free (interfaces_full);
g_free (interface_offsets_full);
g_free (array_interfaces);
- for (i = 0; i < class->idepth; i++) {
+ for (i = 0; i < klass->idepth; i++) {
ifaces = ifaces_array [i];
if (ifaces)
g_ptr_array_free (ifaces, TRUE);
g_free (ifaces_array);
//printf ("JUST DONE: ");
- //print_implemented_interfaces (class);
+ //print_implemented_interfaces (klass);
return cur_slot;
}
/*
* Setup interface offsets for interfaces.
* Initializes:
- * - class->max_interface_id
- * - class->interface_offsets_count
- * - class->interfaces_packed
- * - class->interface_offsets_packed
- * - class->interface_bitmap
+ * - klass->max_interface_id
+ * - klass->interface_offsets_count
+ * - klass->interfaces_packed
+ * - klass->interface_offsets_packed
+ * - klass->interface_bitmap
*
* This function can fail @class.
*/
void
-mono_class_setup_interface_offsets (MonoClass *class)
+mono_class_setup_interface_offsets (MonoClass *klass)
{
mono_loader_lock ();
- setup_interface_offsets (class, 0, FALSE);
+ setup_interface_offsets (klass, 0, FALSE);
mono_loader_unlock ();
}
}
gboolean
-mono_class_check_vtable_constraints (MonoClass *class, GList *in_setup)
+mono_class_check_vtable_constraints (MonoClass *klass, GList *in_setup)
{
MonoGenericInst *ginst;
int i;
- if (!class->generic_class) {
- mono_class_setup_vtable_full (class, in_setup);
- return class->exception_type == 0;
+ if (!klass->generic_class) {
+ mono_class_setup_vtable_full (klass, in_setup);
+ return klass->exception_type == 0;
}
- mono_class_setup_vtable_full (mono_class_get_generic_type_definition (class), in_setup);
- if (class->generic_class->container_class->exception_type) {
- mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, g_strdup ("Failed to load generic definition vtable"));
+ mono_class_setup_vtable_full (mono_class_get_generic_type_definition (klass), in_setup);
+ if (klass->generic_class->container_class->exception_type) {
+ mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, g_strdup ("Failed to load generic definition vtable"));
return FALSE;
}
- ginst = class->generic_class->context.class_inst;
+ ginst = klass->generic_class->context.class_inst;
for (i = 0; i < ginst->type_argc; ++i) {
MonoClass *arg;
if (ginst->type_argv [i]->type != MONO_TYPE_GENERICINST)
continue;
arg = mono_class_from_mono_type (ginst->type_argv [i]);
/*Those 2 will be checked by mono_class_setup_vtable itself*/
- if (mono_class_has_gtd_parent (class, arg) || mono_class_has_gtd_parent (arg, class))
+ if (mono_class_has_gtd_parent (klass, arg) || mono_class_has_gtd_parent (arg, klass))
continue;
if (!mono_class_check_vtable_constraints (arg, in_setup)) {
- mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, g_strdup_printf ("Failed to load generic parameter %d", i));
+ mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, g_strdup_printf ("Failed to load generic parameter %d", i));
return FALSE;
}
}
* - vtable
* - vtable_size
* Plus all the fields initialized by setup_interface_offsets ().
- * If there is an error during vtable construction, class->exception_type is set.
+ * If there is an error during vtable construction, klass->exception_type is set.
*
* LOCKING: Acquires the loader lock.
*/
void
-mono_class_setup_vtable (MonoClass *class)
+mono_class_setup_vtable (MonoClass *klass)
{
- mono_class_setup_vtable_full (class, NULL);
+ mono_class_setup_vtable_full (klass, NULL);
}
static void
-mono_class_setup_vtable_full (MonoClass *class, GList *in_setup)
+mono_class_setup_vtable_full (MonoClass *klass, GList *in_setup)
{
MonoMethod **overrides;
MonoGenericContext *context;
int onum = 0;
gboolean ok = TRUE;
- if (class->vtable)
+ if (klass->vtable)
return;
- if (MONO_CLASS_IS_INTERFACE (class)) {
+ if (MONO_CLASS_IS_INTERFACE (klass)) {
/* This sets method->slot for all methods if this is an interface */
- mono_class_setup_methods (class);
+ mono_class_setup_methods (klass);
return;
}
- if (class->exception_type)
+ if (klass->exception_type)
return;
- if (g_list_find (in_setup, class))
+ if (g_list_find (in_setup, klass))
return;
mono_loader_lock ();
- if (class->vtable) {
+ if (klass->vtable) {
mono_loader_unlock ();
return;
}
mono_stats.generic_vtable_count ++;
- in_setup = g_list_prepend (in_setup, class);
+ in_setup = g_list_prepend (in_setup, klass);
- if (class->generic_class) {
- if (!mono_class_check_vtable_constraints (class, in_setup)) {
+ if (klass->generic_class) {
+ if (!mono_class_check_vtable_constraints (klass, in_setup)) {
mono_loader_unlock ();
- g_list_remove (in_setup, class);
+ g_list_remove (in_setup, klass);
return;
}
- context = mono_class_get_context (class);
- type_token = class->generic_class->container_class->type_token;
+ context = mono_class_get_context (klass);
+ type_token = klass->generic_class->container_class->type_token;
} else {
- context = (MonoGenericContext *) class->generic_container;
- type_token = class->type_token;
+ context = (MonoGenericContext *) klass->generic_container;
+ type_token = klass->type_token;
}
- if (image_is_dynamic (class->image)) {
+ if (image_is_dynamic (klass->image)) {
/* Generic instances can have zero method overrides without causing any harm.
* This is true since we don't do layout all over again for them, we simply inflate
* the layout of the parent.
*/
- mono_reflection_get_dynamic_overrides (class, &overrides, &onum);
+ mono_reflection_get_dynamic_overrides (klass, &overrides, &onum);
} else {
/* The following call fails if there are missing methods in the type */
/* FIXME it's probably a good idea to avoid this for generic instances. */
- ok = mono_class_get_overrides_full (class->image, type_token, &overrides, &onum, context);
+ ok = mono_class_get_overrides_full (klass->image, type_token, &overrides, &onum, context);
}
if (ok)
- mono_class_setup_vtable_general (class, overrides, onum, in_setup);
+ mono_class_setup_vtable_general (klass, overrides, onum, in_setup);
else
- mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, g_strdup ("Could not load list of method overrides"));
+ mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, g_strdup ("Could not load list of method overrides"));
g_free (overrides);
mono_loader_unlock ();
- g_list_remove (in_setup, class);
+ g_list_remove (in_setup, klass);
return;
}
}
static gboolean
-check_interface_method_override (MonoClass *class, MonoMethod *im, MonoMethod *cm, gboolean require_newslot, gboolean interface_is_explicitly_implemented_by_class, gboolean slot_is_empty)
+check_interface_method_override (MonoClass *klass, MonoMethod *im, MonoMethod *cm, gboolean require_newslot, gboolean interface_is_explicitly_implemented_by_class, gboolean slot_is_empty)
{
MonoMethodSignature *cmsig, *imsig;
if (strcmp (im->name, cm->name) == 0) {
cmsig = mono_method_signature (cm);
imsig = mono_method_signature (im);
if (!cmsig || !imsig) {
- mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, g_strdup ("Could not resolve the signature of a virtual method"));
+ mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, g_strdup ("Could not resolve the signature of a virtual method"));
return FALSE;
}
}
TRACE_INTERFACE_VTABLE (printf ("[SECURITY CHECKS]"));
if (mono_security_core_clr_enabled ())
- mono_security_core_clr_check_override (class, cm, im);
+ mono_security_core_clr_check_override (klass, cm, im);
TRACE_INTERFACE_VTABLE (printf ("[NAME CHECK OK]"));
if (is_wcf_hack_disabled () && !mono_method_can_access_method_full (cm, im, NULL)) {
char *body_name = mono_method_full_name (cm, TRUE);
char *decl_name = mono_method_full_name (im, TRUE);
- mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, g_strdup_printf ("Method %s overrides method '%s' which is not accessible", body_name, decl_name));
+ mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, g_strdup_printf ("Method %s overrides method '%s' which is not accessible", body_name, decl_name));
g_free (body_name);
g_free (decl_name);
return FALSE;
cmsig = mono_method_signature (cm);
imsig = mono_method_signature (im);
if (!cmsig || !imsig) {
- mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, g_strdup ("Could not resolve the signature of a virtual method"));
+ mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, g_strdup ("Could not resolve the signature of a virtual method"));
return FALSE;
}
TRACE_INTERFACE_VTABLE (printf ("[SECURITY CHECKS (INJECTED CASE)]"));
if (mono_security_core_clr_enabled ())
- mono_security_core_clr_check_override (class, cm, im);
+ mono_security_core_clr_check_override (klass, cm, im);
TRACE_INTERFACE_VTABLE (printf ("[INJECTED INTERFACE CHECK OK]"));
if (is_wcf_hack_disabled () && !mono_method_can_access_method_full (cm, im, NULL)) {
char *body_name = mono_method_full_name (cm, TRUE);
char *decl_name = mono_method_full_name (im, TRUE);
- mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, g_strdup_printf ("Method %s overrides method '%s' which is not accessible", body_name, decl_name));
+ mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, g_strdup_printf ("Method %s overrides method '%s' which is not accessible", body_name, decl_name));
g_free (body_name);
g_free (decl_name);
return FALSE;
}
}
static void
-print_vtable_full (MonoClass *class, MonoMethod** vtable, int size, int first_non_interface_slot, const char *message, gboolean print_interfaces) {
- char *full_name = mono_type_full_name (&class->byval_arg);
+print_vtable_full (MonoClass *klass, MonoMethod** vtable, int size, int first_non_interface_slot, const char *message, gboolean print_interfaces) {
+ char *full_name = mono_type_full_name (&klass->byval_arg);
int i;
int parent_size;
printf ("*** Vtable for class '%s' at \"%s\" (size %d)\n", full_name, message, size);
if (print_interfaces) {
- print_implemented_interfaces (class);
+ print_implemented_interfaces (klass);
printf ("* Interfaces for class '%s' done.\nStarting vtable (size %d):\n", full_name, size);
}
- if (class->parent) {
- parent_size = class->parent->vtable_size;
+ if (klass->parent) {
+ parent_size = klass->parent->vtable_size;
} else {
parent_size = 0;
}
}
static void
-mono_class_verify_vtable (MonoClass *class)
+mono_class_verify_vtable (MonoClass *klass)
{
int i;
- char *full_name = mono_type_full_name (&class->byval_arg);
+ char *full_name = mono_type_full_name (&klass->byval_arg);
printf ("*** Verifying VTable of class '%s' \n", full_name);
g_free (full_name);
full_name = NULL;
- if (!class->methods)
+ if (!klass->methods)
return;
- for (i = 0; i < class->method.count; ++i) {
- MonoMethod *cm = class->methods [i];
+ for (i = 0; i < klass->method.count; ++i) {
+ MonoMethod *cm = klass->methods [i];
int slot;
if (!(cm->flags & METHOD_ATTRIBUTE_VIRTUAL))
slot = mono_method_try_get_vtable_index (cm);
if (slot >= 0) {
- if (slot >= class->vtable_size) {
- printf ("\tInvalid method %s at index %d with vtable of length %d\n", full_name, slot, class->vtable_size);
+ if (slot >= klass->vtable_size) {
+ printf ("\tInvalid method %s at index %d with vtable of length %d\n", full_name, slot, klass->vtable_size);
continue;
}
- if (slot >= 0 && class->vtable [slot] != cm && (class->vtable [slot])) {
- char *other_name = class->vtable [slot] ? mono_method_full_name (class->vtable [slot], TRUE) : g_strdup ("[null value]");
+ if (slot >= 0 && klass->vtable [slot] != cm && (klass->vtable [slot])) {
+ char *other_name = klass->vtable [slot] ? mono_method_full_name (klass->vtable [slot], TRUE) : g_strdup ("[null value]");
printf ("\tMethod %s has slot %d but vtable has %s on it\n", full_name, slot, other_name);
g_free (other_name);
}
#endif
static void
-print_unimplemented_interface_method_info (MonoClass *class, MonoClass *ic, MonoMethod *im, int im_slot, MonoMethod **overrides, int onum) {
+print_unimplemented_interface_method_info (MonoClass *klass, MonoClass *ic, MonoMethod *im, int im_slot, MonoMethod **overrides, int onum) {
int index;
char *method_signature;
char *type_name;
overrides [index*2+1]->slot, overrides [index*2]->name, overrides [index*2]->slot);
}
method_signature = mono_signature_get_desc (mono_method_signature (im), FALSE);
- type_name = mono_type_full_name (&class->byval_arg);
+ type_name = mono_type_full_name (&klass->byval_arg);
mono_trace_warning (MONO_TRACE_TYPE, "no implementation for interface method %s::%s(%s) in class %s\n",
mono_type_get_name (&ic->byval_arg), im->name, method_signature, type_name);
g_free (method_signature);
g_free (type_name);
- mono_class_setup_methods (class);
- if (class->exception_type) {
- char *name = mono_type_get_full_name (class);
+ mono_class_setup_methods (klass);
+ if (klass->exception_type) {
+ char *name = mono_type_get_full_name (klass);
mono_trace_warning (MONO_TRACE_TYPE, "CLASS %s failed to resolve methods\n", name);
g_free (name);
return;
}
- for (index = 0; index < class->method.count; ++index) {
- MonoMethod *cm = class->methods [index];
+ for (index = 0; index < klass->method.count; ++index) {
+ MonoMethod *cm = klass->methods [index];
method_signature = mono_signature_get_desc (mono_method_signature (cm), TRUE);
mono_trace_warning (MONO_TRACE_TYPE, "METHOD %s(%s)\n", cm->name, method_signature);
}
static gboolean
-verify_class_overrides (MonoClass *class, MonoMethod **overrides, int onum)
+verify_class_overrides (MonoClass *klass, MonoMethod **overrides, int onum)
{
int i;
MonoMethod *decl = overrides [i * 2];
MonoMethod *body = overrides [i * 2 + 1];
- if (mono_class_get_generic_type_definition (body->klass) != mono_class_get_generic_type_definition (class)) {
- mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, g_strdup ("Method belongs to a different class than the declared one"));
+ if (mono_class_get_generic_type_definition (body->klass) != mono_class_get_generic_type_definition (klass)) {
+ mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, g_strdup ("Method belongs to a different class than the declared one"));
return FALSE;
}
if (!(body->flags & METHOD_ATTRIBUTE_VIRTUAL) || (body->flags & METHOD_ATTRIBUTE_STATIC)) {
if (body->flags & METHOD_ATTRIBUTE_STATIC)
- mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, g_strdup ("Method must not be static to override a base type"));
+ mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, g_strdup ("Method must not be static to override a base type"));
else
- mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, g_strdup ("Method must be virtual to override a base type"));
+ mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, g_strdup ("Method must be virtual to override a base type"));
return FALSE;
}
if (!(decl->flags & METHOD_ATTRIBUTE_VIRTUAL) || (decl->flags & METHOD_ATTRIBUTE_STATIC)) {
if (body->flags & METHOD_ATTRIBUTE_STATIC)
- mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, g_strdup ("Cannot override a static method in a base type"));
+ mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, g_strdup ("Cannot override a static method in a base type"));
else
- mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, g_strdup ("Cannot override a non virtual method in a base type"));
+ mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, g_strdup ("Cannot override a non virtual method in a base type"));
return FALSE;
}
- if (!mono_class_is_assignable_from_slow (decl->klass, class)) {
- mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, g_strdup ("Method overrides a class or interface that extended or implemented by this type"));
+ if (!mono_class_is_assignable_from_slow (decl->klass, klass)) {
+ mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, g_strdup ("Method overrides a class or interface that extended or implemented by this type"));
return FALSE;
}
if (is_wcf_hack_disabled () && !mono_method_can_access_method_full (body, decl, NULL)) {
char *body_name = mono_method_full_name (body, TRUE);
char *decl_name = mono_method_full_name (decl, TRUE);
- mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, g_strdup_printf ("Method %s overrides method '%s' which is not accessible", body_name, decl_name));
+ mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, g_strdup_printf ("Method %s overrides method '%s' which is not accessible", body_name, decl_name));
g_free (body_name);
g_free (decl_name);
return FALSE;
}
static gboolean
-mono_class_need_stelemref_method (MonoClass *class)
+mono_class_need_stelemref_method (MonoClass *klass)
{
- return class->rank == 1 && MONO_TYPE_IS_REFERENCE (&class->element_class->byval_arg);
+ return klass->rank == 1 && MONO_TYPE_IS_REFERENCE (&klass->element_class->byval_arg);
}
/*
* LOCKING: this is supposed to be called with the loader lock held.
*/
void
-mono_class_setup_vtable_general (MonoClass *class, MonoMethod **overrides, int onum, GList *in_setup)
+mono_class_setup_vtable_general (MonoClass *klass, MonoMethod **overrides, int onum, GList *in_setup)
{
MonoError error;
MonoClass *k, *ic;
GSList *virt_methods = NULL, *l;
int stelemref_slot = 0;
- if (class->vtable)
+ if (klass->vtable)
return;
- if (overrides && !verify_class_overrides (class, overrides, onum))
+ if (overrides && !verify_class_overrides (klass, overrides, onum))
return;
- ifaces = mono_class_get_implemented_interfaces (class, &error);
+ ifaces = mono_class_get_implemented_interfaces (klass, &error);
if (!mono_error_ok (&error)) {
- char *name = mono_type_get_full_name (class);
- mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, g_strdup_printf ("Could not resolve %s interfaces due to %s", name, mono_error_get_message (&error)));
+ char *name = mono_type_get_full_name (klass);
+ mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, g_strdup_printf ("Could not resolve %s interfaces due to %s", name, mono_error_get_message (&error)));
g_free (name);
mono_error_cleanup (&error);
return;
ifaces = NULL;
}
- if (class->parent) {
- mono_class_init (class->parent);
- mono_class_setup_vtable_full (class->parent, in_setup);
+ if (klass->parent) {
+ mono_class_init (klass->parent);
+ mono_class_setup_vtable_full (klass->parent, in_setup);
- if (class->parent->exception_type) {
- char *name = mono_type_get_full_name (class->parent);
- mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, g_strdup_printf ("Parent %s failed to load", name));
+ if (klass->parent->exception_type) {
+ char *name = mono_type_get_full_name (klass->parent);
+ mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, g_strdup_printf ("Parent %s failed to load", name));
g_free (name);
return;
}
- max_vtsize += class->parent->vtable_size;
- cur_slot = class->parent->vtable_size;
+ max_vtsize += klass->parent->vtable_size;
+ cur_slot = klass->parent->vtable_size;
}
- max_vtsize += class->method.count;
+ max_vtsize += klass->method.count;
/*Array have a slot for stelemref*/
- if (mono_class_need_stelemref_method (class)) {
+ if (mono_class_need_stelemref_method (klass)) {
stelemref_slot = cur_slot;
++max_vtsize;
++cur_slot;
vtable = alloca (sizeof (gpointer) * max_vtsize);
memset (vtable, 0, sizeof (gpointer) * max_vtsize);
- /* printf ("METAINIT %s.%s\n", class->name_space, class->name); */
+ /* printf ("METAINIT %s.%s\n", klass->name_space, klass->name); */
- cur_slot = setup_interface_offsets (class, cur_slot, TRUE);
+ cur_slot = setup_interface_offsets (klass, cur_slot, TRUE);
if (cur_slot == -1) /*setup_interface_offsets fails the type.*/
return;
- max_iid = class->max_interface_id;
+ max_iid = klass->max_interface_id;
DEBUG_INTERFACE_VTABLE (first_non_interface_slot = cur_slot);
/* Optimized version for generic instances */
- if (class->generic_class) {
+ if (klass->generic_class) {
MonoError error;
- MonoClass *gklass = class->generic_class->container_class;
+ MonoClass *gklass = klass->generic_class->container_class;
MonoMethod **tmp;
mono_class_setup_vtable_full (gklass, in_setup);
if (gklass->exception_type != MONO_EXCEPTION_NONE) {
- mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, NULL);
+ mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, NULL);
return;
}
- tmp = mono_class_alloc0 (class, sizeof (gpointer) * gklass->vtable_size);
- class->vtable_size = gklass->vtable_size;
+ tmp = mono_class_alloc0 (klass, sizeof (gpointer) * gklass->vtable_size);
+ klass->vtable_size = gklass->vtable_size;
for (i = 0; i < gklass->vtable_size; ++i)
if (gklass->vtable [i]) {
- MonoMethod *inflated = mono_class_inflate_generic_method_full_checked (gklass->vtable [i], class, mono_class_get_context (class), &error);
+ MonoMethod *inflated = mono_class_inflate_generic_method_full_checked (gklass->vtable [i], klass, mono_class_get_context (klass), &error);
if (!mono_error_ok (&error)) {
char *err_msg = g_strdup_printf ("Could not inflate method due to %s", mono_error_get_message (&error));
- mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, err_msg);
+ mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, err_msg);
g_free (err_msg);
mono_error_cleanup (&error);
return;
tmp [i]->slot = gklass->vtable [i]->slot;
}
mono_memory_barrier ();
- class->vtable = tmp;
+ klass->vtable = tmp;
/* Have to set method->slot for abstract virtual methods */
- if (class->methods && gklass->methods) {
- for (i = 0; i < class->method.count; ++i)
- if (class->methods [i]->slot == -1)
- class->methods [i]->slot = gklass->methods [i]->slot;
+ if (klass->methods && gklass->methods) {
+ for (i = 0; i < klass->method.count; ++i)
+ if (klass->methods [i]->slot == -1)
+ klass->methods [i]->slot = gklass->methods [i]->slot;
}
return;
}
- if (class->parent && class->parent->vtable_size) {
- MonoClass *parent = class->parent;
+ if (klass->parent && klass->parent->vtable_size) {
+ MonoClass *parent = klass->parent;
int i;
memcpy (vtable, parent->vtable, sizeof (gpointer) * parent->vtable_size);
// classes the ".override" information is not used anymore.
for (i = 0; i < parent->interface_offsets_count; i++) {
MonoClass *parent_interface = parent->interfaces_packed [i];
- int interface_offset = mono_class_interface_offset (class, parent_interface);
+ int interface_offset = mono_class_interface_offset (klass, parent_interface);
/*FIXME this is now dead code as this condition will never hold true.
Since interface offsets are inherited then the offset of an interface implemented
by a parent will never be the out of it's vtable boundary.
mono_class_setup_methods (parent_interface); /*FIXME Just kill this whole chunk of dead code*/
TRACE_INTERFACE_VTABLE (printf (" +++ Inheriting interface %s.%s\n", parent_interface->name_space, parent_interface->name));
- for (j = 0; j < parent_interface->method.count && !class->exception_type; j++) {
+ for (j = 0; j < parent_interface->method.count && !klass->exception_type; j++) {
vtable [interface_offset + j] = parent->vtable [parent_interface_offset + j];
TRACE_INTERFACE_VTABLE (printf (" --- Inheriting: [%03d][(%03d)+(%03d)] => [%03d][(%03d)+(%03d)]\n",
parent_interface_offset + j, parent_interface_offset, j,
}
/*Array have a slot for stelemref*/
- if (mono_class_need_stelemref_method (class)) {
- MonoMethod *method = mono_marshal_get_virtual_stelemref (class);
+ if (mono_class_need_stelemref_method (klass)) {
+ MonoMethod *method = mono_marshal_get_virtual_stelemref (klass);
if (!method->slot)
method->slot = stelemref_slot;
else
vtable [stelemref_slot] = method;
}
- TRACE_INTERFACE_VTABLE (print_vtable_full (class, vtable, cur_slot, first_non_interface_slot, "AFTER INHERITING PARENT VTABLE", TRUE));
+ TRACE_INTERFACE_VTABLE (print_vtable_full (klass, vtable, cur_slot, first_non_interface_slot, "AFTER INHERITING PARENT VTABLE", TRUE));
/* override interface methods */
for (i = 0; i < onum; i++) {
MonoMethod *decl = overrides [i*2];
int dslot;
dslot = mono_method_get_vtable_slot (decl);
if (dslot == -1) {
- mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, NULL);
+ mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, NULL);
return;
}
- dslot += mono_class_interface_offset (class, decl->klass);
+ dslot += mono_class_interface_offset (klass, decl->klass);
vtable [dslot] = overrides [i*2 + 1];
vtable [dslot]->slot = dslot;
if (!override_map)
g_hash_table_insert (override_map, overrides [i * 2], overrides [i * 2 + 1]);
if (mono_security_core_clr_enabled ())
- mono_security_core_clr_check_override (class, vtable [dslot], decl);
+ mono_security_core_clr_check_override (klass, vtable [dslot], decl);
}
}
TRACE_INTERFACE_VTABLE (print_overrides (override_map, "AFTER OVERRIDING INTERFACE METHODS"));
- TRACE_INTERFACE_VTABLE (print_vtable_full (class, vtable, cur_slot, first_non_interface_slot, "AFTER OVERRIDING INTERFACE METHODS", FALSE));
+ TRACE_INTERFACE_VTABLE (print_vtable_full (klass, vtable, cur_slot, first_non_interface_slot, "AFTER OVERRIDING INTERFACE METHODS", FALSE));
/*
* Create a list of virtual methods to avoid calling
MonoMethod *cm;
virt_methods = NULL;
- while ((cm = mono_class_get_virtual_methods (class, &iter))) {
+ while ((cm = mono_class_get_virtual_methods (klass, &iter))) {
virt_methods = g_slist_prepend (virt_methods, cm);
}
- if (class->exception_type)
+ if (klass->exception_type)
goto fail;
}
// Loop on all implemented interfaces...
- for (i = 0; i < class->interface_offsets_count; i++) {
- MonoClass *parent = class->parent;
+ for (i = 0; i < klass->interface_offsets_count; i++) {
+ MonoClass *parent = klass->parent;
int ic_offset;
gboolean interface_is_explicitly_implemented_by_class;
int im_index;
- ic = class->interfaces_packed [i];
- ic_offset = mono_class_interface_offset (class, ic);
+ ic = klass->interfaces_packed [i];
+ ic_offset = mono_class_interface_offset (klass, ic);
mono_class_setup_methods (ic);
if (ic->exception_type)
if (parent != NULL) {
int implemented_interfaces_index;
interface_is_explicitly_implemented_by_class = FALSE;
- for (implemented_interfaces_index = 0; implemented_interfaces_index < class->interface_count; implemented_interfaces_index++) {
- if (ic == class->interfaces [implemented_interfaces_index]) {
+ for (implemented_interfaces_index = 0; implemented_interfaces_index < klass->interface_count; implemented_interfaces_index++) {
+ if (ic == klass->interfaces [implemented_interfaces_index]) {
interface_is_explicitly_implemented_by_class = TRUE;
break;
}
for (l = virt_methods; l; l = l->next) {
cm = l->data;
TRACE_INTERFACE_VTABLE (printf (" For slot %d ('%s'.'%s':'%s'), trying method '%s'.'%s':'%s'... [EXPLICIT IMPLEMENTATION = %d][SLOT IS NULL = %d]", im_slot, ic->name_space, ic->name, im->name, cm->klass->name_space, cm->klass->name, cm->name, interface_is_explicitly_implemented_by_class, (vtable [im_slot] == NULL)));
- if (check_interface_method_override (class, im, cm, TRUE, interface_is_explicitly_implemented_by_class, (vtable [im_slot] == NULL))) {
+ if (check_interface_method_override (klass, im, cm, TRUE, interface_is_explicitly_implemented_by_class, (vtable [im_slot] == NULL))) {
TRACE_INTERFACE_VTABLE (printf ("[check ok]: ASSIGNING"));
vtable [im_slot] = cm;
/* Why do we need this? */
}
}
TRACE_INTERFACE_VTABLE (printf ("\n"));
- if (class->exception_type) /*Might be set by check_interface_method_override*/
+ if (klass->exception_type) /*Might be set by check_interface_method_override*/
goto fail;
}
// If the slot is still empty, look in all the inherited virtual methods...
- if ((vtable [im_slot] == NULL) && class->parent != NULL) {
- MonoClass *parent = class->parent;
+ if ((vtable [im_slot] == NULL) && klass->parent != NULL) {
+ MonoClass *parent = klass->parent;
// Reverse order, so that last added methods are preferred
for (cm_index = parent->vtable_size - 1; cm_index >= 0; cm_index--) {
MonoMethod *cm = parent->vtable [cm_index];
TRACE_INTERFACE_VTABLE ((cm != NULL) && printf (" For slot %d ('%s'.'%s':'%s'), trying (ancestor) method '%s'.'%s':'%s'... ", im_slot, ic->name_space, ic->name, im->name, cm->klass->name_space, cm->klass->name, cm->name));
- if ((cm != NULL) && check_interface_method_override (class, im, cm, FALSE, FALSE, TRUE)) {
+ if ((cm != NULL) && check_interface_method_override (klass, im, cm, FALSE, FALSE, TRUE)) {
TRACE_INTERFACE_VTABLE (printf ("[everything ok]: ASSIGNING"));
vtable [im_slot] = cm;
/* Why do we need this? */
}
break;
}
- if (class->exception_type) /*Might be set by check_interface_method_override*/
+ if (klass->exception_type) /*Might be set by check_interface_method_override*/
goto fail;
TRACE_INTERFACE_VTABLE ((cm != NULL) && printf ("\n"));
}
// it can happen (for injected generic array interfaces) that the same slot is
// processed multiple times (those interfaces have overlapping slots), and it
// will not always be the first pass the one that fills the slot.
- if (! (class->flags & TYPE_ATTRIBUTE_ABSTRACT)) {
- for (i = 0; i < class->interface_offsets_count; i++) {
+ if (! (klass->flags & TYPE_ATTRIBUTE_ABSTRACT)) {
+ for (i = 0; i < klass->interface_offsets_count; i++) {
int ic_offset;
int im_index;
- ic = class->interfaces_packed [i];
- ic_offset = mono_class_interface_offset (class, ic);
+ ic = klass->interfaces_packed [i];
+ ic_offset = mono_class_interface_offset (klass, ic);
for (im_index = 0; im_index < ic->method.count; im_index++) {
MonoMethod *im = ic->methods [im_index];
TRACE_INTERFACE_VTABLE (printf (" [class is not abstract, checking slot %d for interface '%s'.'%s', method %s, slot check is %d]\n",
im_slot, ic->name_space, ic->name, im->name, (vtable [im_slot] == NULL)));
if (vtable [im_slot] == NULL) {
- print_unimplemented_interface_method_info (class, ic, im, im_slot, overrides, onum);
+ print_unimplemented_interface_method_info (klass, ic, im, im_slot, overrides, onum);
goto fail;
}
}
}
}
- TRACE_INTERFACE_VTABLE (print_vtable_full (class, vtable, cur_slot, first_non_interface_slot, "AFTER SETTING UP INTERFACE METHODS", FALSE));
+ TRACE_INTERFACE_VTABLE (print_vtable_full (klass, vtable, cur_slot, first_non_interface_slot, "AFTER SETTING UP INTERFACE METHODS", FALSE));
for (l = virt_methods; l; l = l->next) {
cm = l->data;
/*
*/
if (!(cm->flags & METHOD_ATTRIBUTE_NEW_SLOT)) {
int slot = -1;
- for (k = class->parent; k ; k = k->parent) {
+ for (k = klass->parent; k ; k = k->parent) {
gpointer k_iter;
MonoMethod *m1;
m1sig = mono_method_signature (m1);
if (!cmsig || !m1sig) {
- mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, NULL);
+ mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, NULL);
return;
}
mono_metadata_signature_equal (cmsig, m1sig)) {
if (mono_security_core_clr_enabled ())
- mono_security_core_clr_check_override (class, cm, m1);
+ mono_security_core_clr_check_override (klass, cm, m1);
slot = mono_method_get_vtable_slot (m1);
if (slot == -1)
if (is_wcf_hack_disabled () && !mono_method_can_access_method_full (cm, m1, NULL)) {
char *body_name = mono_method_full_name (cm, TRUE);
char *decl_name = mono_method_full_name (m1, TRUE);
- mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, g_strdup_printf ("Method %s overrides method '%s' which is not accessible", body_name, decl_name));
+ mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, g_strdup_printf ("Method %s overrides method '%s' which is not accessible", body_name, decl_name));
g_free (body_name);
g_free (decl_name);
goto fail;
g_hash_table_insert (override_map, decl, overrides [i * 2 + 1]);
if (mono_security_core_clr_enabled ())
- mono_security_core_clr_check_override (class, vtable [decl->slot], decl);
+ mono_security_core_clr_check_override (klass, vtable [decl->slot], decl);
}
}
virt_methods = NULL;
/* Ensure that all vtable slots are filled with concrete instance methods */
- if (!(class->flags & TYPE_ATTRIBUTE_ABSTRACT)) {
+ if (!(klass->flags & TYPE_ATTRIBUTE_ABSTRACT)) {
for (i = 0; i < cur_slot; ++i) {
if (vtable [i] == NULL || (vtable [i]->flags & (METHOD_ATTRIBUTE_ABSTRACT | METHOD_ATTRIBUTE_STATIC))) {
- char *type_name = mono_type_get_full_name (class);
+ char *type_name = mono_type_get_full_name (klass);
char *method_name = vtable [i] ? mono_method_full_name (vtable [i], TRUE) : g_strdup ("none");
- mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, g_strdup_printf ("Type %s has invalid vtable method slot %d with method %s", type_name, i, method_name));
+ mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, g_strdup_printf ("Type %s has invalid vtable method slot %d with method %s", type_name, i, method_name));
g_free (type_name);
g_free (method_name);
return;
}
}
- if (class->generic_class) {
- MonoClass *gklass = class->generic_class->container_class;
+ if (klass->generic_class) {
+ MonoClass *gklass = klass->generic_class->container_class;
mono_class_init (gklass);
- class->vtable_size = MAX (gklass->vtable_size, cur_slot);
+ klass->vtable_size = MAX (gklass->vtable_size, cur_slot);
} else {
/* Check that the vtable_size value computed in mono_class_init () is correct */
- if (class->vtable_size)
- g_assert (cur_slot == class->vtable_size);
- class->vtable_size = cur_slot;
+ if (klass->vtable_size)
+ g_assert (cur_slot == klass->vtable_size);
+ klass->vtable_size = cur_slot;
}
/* Try to share the vtable with our parent. */
- if (class->parent && (class->parent->vtable_size == class->vtable_size) && (memcmp (class->parent->vtable, vtable, sizeof (gpointer) * class->vtable_size) == 0)) {
+ if (klass->parent && (klass->parent->vtable_size == klass->vtable_size) && (memcmp (klass->parent->vtable, vtable, sizeof (gpointer) * klass->vtable_size) == 0)) {
mono_memory_barrier ();
- class->vtable = class->parent->vtable;
+ klass->vtable = klass->parent->vtable;
} else {
- MonoMethod **tmp = mono_class_alloc0 (class, sizeof (gpointer) * class->vtable_size);
- memcpy (tmp, vtable, sizeof (gpointer) * class->vtable_size);
+ MonoMethod **tmp = mono_class_alloc0 (klass, sizeof (gpointer) * klass->vtable_size);
+ memcpy (tmp, vtable, sizeof (gpointer) * klass->vtable_size);
mono_memory_barrier ();
- class->vtable = tmp;
+ klass->vtable = tmp;
}
- DEBUG_INTERFACE_VTABLE (print_vtable_full (class, class->vtable, class->vtable_size, first_non_interface_slot, "FINALLY", FALSE));
+ DEBUG_INTERFACE_VTABLE (print_vtable_full (klass, klass->vtable, klass->vtable_size, first_non_interface_slot, "FINALLY", FALSE));
if (mono_print_vtable) {
int icount = 0;
- print_implemented_interfaces (class);
+ print_implemented_interfaces (klass);
for (i = 0; i <= max_iid; i++)
- if (MONO_CLASS_IMPLEMENTS_INTERFACE (class, i))
+ if (MONO_CLASS_IMPLEMENTS_INTERFACE (klass, i))
icount++;
- printf ("VTable %s (vtable entries = %d, interfaces = %d)\n", mono_type_full_name (&class->byval_arg),
- class->vtable_size, icount);
+ printf ("VTable %s (vtable entries = %d, interfaces = %d)\n", mono_type_full_name (&klass->byval_arg),
+ klass->vtable_size, icount);
for (i = 0; i < cur_slot; ++i) {
MonoMethod *cm;
if (icount) {
- printf ("Interfaces %s.%s (max_iid = %d)\n", class->name_space,
- class->name, max_iid);
+ printf ("Interfaces %s.%s (max_iid = %d)\n", klass->name_space,
+ klass->name, max_iid);
- for (i = 0; i < class->interface_count; i++) {
- ic = class->interfaces [i];
+ for (i = 0; i < klass->interface_count; i++) {
+ ic = klass->interfaces [i];
printf (" slot offset: %03d, method count: %03d, iid: %03d %s\n",
- mono_class_interface_offset (class, ic),
+ mono_class_interface_offset (klass, ic),
count_virtual_methods (ic), ic->interface_id, mono_type_full_name (&ic->byval_arg));
}
- for (k = class->parent; k ; k = k->parent) {
+ for (k = klass->parent; k ; k = k->parent) {
for (i = 0; i < k->interface_count; i++) {
ic = k->interfaces [i];
printf (" parent slot offset: %03d, method count: %03d, iid: %03d %s\n",
- mono_class_interface_offset (class, ic),
+ mono_class_interface_offset (klass, ic),
count_virtual_methods (ic), ic->interface_id, mono_type_full_name (&ic->byval_arg));
}
}
}
}
- VERIFY_INTERFACE_VTABLE (mono_class_verify_vtable (class));
+ VERIFY_INTERFACE_VTABLE (mono_class_verify_vtable (klass));
return;
fail:
{
- char *name = mono_type_get_full_name (class);
- mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, g_strdup_printf ("VTable setup of type %s failed", name));
+ char *name = mono_type_get_full_name (klass);
+ mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, g_strdup_printf ("VTable setup of type %s failed", name));
g_free (name);
if (override_map)
g_hash_table_destroy (override_map);
static int ghc_slot = -1;
static void
-initialize_object_slots (MonoClass *class)
+initialize_object_slots (MonoClass *klass)
{
int i;
if (default_ghc)
return;
- if (class == mono_defaults.object_class) {
- mono_class_setup_vtable (class);
- for (i = 0; i < class->vtable_size; ++i) {
- MonoMethod *cm = class->vtable [i];
+ if (klass == mono_defaults.object_class) {
+ mono_class_setup_vtable (klass);
+ for (i = 0; i < klass->vtable_size; ++i) {
+ MonoMethod *cm = klass->vtable [i];
if (!strcmp (cm->name, "GetHashCode"))
ghc_slot = i;
}
g_assert (ghc_slot > 0);
- default_ghc = class->vtable [ghc_slot];
+ default_ghc = klass->vtable [ghc_slot];
g_assert (finalize_slot > 0);
- default_finalize = class->vtable [finalize_slot];
+ default_finalize = klass->vtable [finalize_slot];
}
}
static GenericArrayMethodInfo *generic_array_method_info = NULL;
static int
-generic_array_methods (MonoClass *class)
+generic_array_methods (MonoClass *klass)
{
int i, count_generic = 0;
GList *list = NULL, *tmp;
if (generic_array_method_num)
return generic_array_method_num;
- mono_class_setup_methods (class->parent); /*This is setting up System.Array*/
- g_assert (!class->parent->exception_type); /*So hitting this assert is a huge problem*/
- for (i = 0; i < class->parent->method.count; i++) {
- MonoMethod *m = class->parent->methods [i];
+ mono_class_setup_methods (klass->parent); /*This is setting up System.Array*/
+ g_assert (!klass->parent->exception_type); /*So hitting this assert is a huge problem*/
+ for (i = 0; i < klass->parent->method.count; i++) {
+ MonoMethod *m = klass->parent->methods [i];
if (!strncmp (m->name, "InternalArray__", 15)) {
count_generic++;
list = g_list_prepend (list, m);
}
static void
-setup_generic_array_ifaces (MonoClass *class, MonoClass *iface, MonoMethod **methods, int pos)
+setup_generic_array_ifaces (MonoClass *klass, MonoClass *iface, MonoMethod **methods, int pos)
{
MonoGenericContext tmp_context;
int i;
inflated = mono_class_inflate_generic_method_checked (m, &tmp_context, &error);
g_assert (mono_error_ok (&error)); /*FIXME proper error handling*/
- methods [pos++] = mono_marshal_get_generic_array_helper (class, iface, generic_array_method_info [i].name, inflated);
+ methods [pos++] = mono_marshal_get_generic_array_helper (klass, iface, generic_array_method_info [i].name, inflated);
}
}
}
static void
-set_failure_from_loader_error (MonoClass *class, MonoLoaderError *error)
+set_failure_from_loader_error (MonoClass *klass, MonoLoaderError *error)
{
gpointer exception_data = NULL;
switch (error->exception_type) {
case MONO_EXCEPTION_TYPE_LOAD:
- exception_data = concat_two_strings_with_zero (class->image, error->class_name, error->assembly_name);
+ exception_data = concat_two_strings_with_zero (klass->image, error->class_name, error->assembly_name);
break;
case MONO_EXCEPTION_MISSING_METHOD:
- exception_data = concat_two_strings_with_zero (class->image, error->class_name, error->member_name);
+ exception_data = concat_two_strings_with_zero (klass->image, error->class_name, error->member_name);
break;
case MONO_EXCEPTION_MISSING_FIELD: {
else
class_name = error->klass->name;
- exception_data = concat_two_strings_with_zero (class->image, class_name, error->member_name);
+ exception_data = concat_two_strings_with_zero (klass->image, class_name, error->member_name);
if (name_space)
g_free ((void*)class_name);
else
msg = "Could not load file or assembly '%s' or one of its dependencies.";
- exception_data = concat_two_strings_with_zero (class->image, msg, error->assembly_name);
+ exception_data = concat_two_strings_with_zero (klass->image, msg, error->assembly_name);
break;
}
g_assert_not_reached ();
}
- mono_class_set_failure (class, error->exception_type, exception_data);
+ mono_class_set_failure (klass, error->exception_type, exception_data);
}
/**
* LOCKING: Acquires the loader lock.
*/
gboolean
-mono_class_init (MonoClass *class)
+mono_class_init (MonoClass *klass)
{
int i;
MonoCachedClassInfo cached_info;
gboolean has_cached_info;
- g_assert (class);
+ g_assert (klass);
/* Double-checking locking pattern */
- if (class->inited || class->exception_type)
- return class->exception_type == MONO_EXCEPTION_NONE;
+ if (klass->inited || klass->exception_type)
+ return klass->exception_type == MONO_EXCEPTION_NONE;
- /*g_print ("Init class %s\n", mono_type_get_full_name (class));*/
+ /*g_print ("Init class %s\n", mono_type_get_full_name (klass));*/
/* We do everything inside the lock to prevent races */
mono_loader_lock ();
- if (class->inited || class->exception_type) {
+ if (klass->inited || klass->exception_type) {
mono_loader_unlock ();
/* Somebody might have gotten in before us */
- return class->exception_type == MONO_EXCEPTION_NONE;
+ return klass->exception_type == MONO_EXCEPTION_NONE;
}
- if (class->init_pending) {
- mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, g_strdup ("Recursive type definition detected"));
+ if (klass->init_pending) {
+ mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, g_strdup ("Recursive type definition detected"));
goto leave;
}
- class->init_pending = 1;
+ klass->init_pending = 1;
- if (mono_verifier_is_enabled_for_class (class) && !mono_verifier_verify_class (class)) {
- mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, concat_two_strings_with_zero (class->image, class->name, class->image->assembly_name));
+ if (mono_verifier_is_enabled_for_class (klass) && !mono_verifier_verify_class (klass)) {
+ mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, concat_two_strings_with_zero (klass->image, klass->name, klass->image->assembly_name));
goto leave;
}
- if (class->byval_arg.type == MONO_TYPE_ARRAY || class->byval_arg.type == MONO_TYPE_SZARRAY) {
- MonoClass *element_class = class->element_class;
+ if (klass->byval_arg.type == MONO_TYPE_ARRAY || klass->byval_arg.type == MONO_TYPE_SZARRAY) {
+ MonoClass *element_class = klass->element_class;
if (!element_class->inited)
mono_class_init (element_class);
if (element_class->exception_type != MONO_EXCEPTION_NONE) {
- mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, NULL);
+ mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, NULL);
goto leave;
}
}
mono_stats.initialized_class_count++;
- if (class->generic_class && !class->generic_class->is_dynamic) {
- MonoClass *gklass = class->generic_class->container_class;
+ if (klass->generic_class && !klass->generic_class->is_dynamic) {
+ MonoClass *gklass = klass->generic_class->container_class;
mono_stats.generic_class_count++;
- class->method = gklass->method;
- class->field = gklass->field;
+ klass->method = gklass->method;
+ klass->field = gklass->field;
mono_class_init (gklass);
// FIXME: Why is this needed ?
if (!gklass->exception_type)
mono_class_setup_methods (gklass);
if (gklass->exception_type) {
- mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, g_strdup_printf ("Generic Type Defintion failed to init"));
+ mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, g_strdup_printf ("Generic Type Defintion failed to init"));
goto leave;
}
- if (MONO_CLASS_IS_INTERFACE (class))
- class->interface_id = mono_get_unique_iid (class);
+ if (MONO_CLASS_IS_INTERFACE (klass))
+ klass->interface_id = mono_get_unique_iid (klass);
}
- if (class->parent && !class->parent->inited)
- mono_class_init (class->parent);
+ if (klass->parent && !klass->parent->inited)
+ mono_class_init (klass->parent);
- has_cached_info = mono_class_get_cached_class_info (class, &cached_info);
+ has_cached_info = mono_class_get_cached_class_info (klass, &cached_info);
- if (class->generic_class || image_is_dynamic (class->image) || !class->type_token || (has_cached_info && !cached_info.has_nested_classes))
- class->nested_classes_inited = TRUE;
+ if (klass->generic_class || image_is_dynamic (klass->image) || !klass->type_token || (has_cached_info && !cached_info.has_nested_classes))
+ klass->nested_classes_inited = TRUE;
/*
* Computes the size used by the fields, and their locations
*/
if (has_cached_info) {
- class->instance_size = cached_info.instance_size;
- class->sizes.class_size = cached_info.class_size;
- class->packing_size = cached_info.packing_size;
- class->min_align = cached_info.min_align;
- class->blittable = cached_info.blittable;
- class->has_references = cached_info.has_references;
- class->has_static_refs = cached_info.has_static_refs;
- class->no_special_static_fields = cached_info.no_special_static_fields;
+ klass->instance_size = cached_info.instance_size;
+ klass->sizes.class_size = cached_info.class_size;
+ klass->packing_size = cached_info.packing_size;
+ klass->min_align = cached_info.min_align;
+ klass->blittable = cached_info.blittable;
+ klass->has_references = cached_info.has_references;
+ klass->has_static_refs = cached_info.has_static_refs;
+ klass->no_special_static_fields = cached_info.no_special_static_fields;
}
else
- if (!class->size_inited){
- mono_class_setup_fields (class);
- if (class->exception_type || mono_loader_get_last_error ())
+ if (!klass->size_inited){
+ mono_class_setup_fields (klass);
+ if (klass->exception_type || mono_loader_get_last_error ())
goto leave;
}
/* Initialize arrays */
- if (class->rank) {
- class->method.count = 3 + (class->rank > 1? 2: 1);
+ if (klass->rank) {
+ klass->method.count = 3 + (klass->rank > 1? 2: 1);
- if (class->interface_count) {
- int count_generic = generic_array_methods (class);
- class->method.count += class->interface_count * count_generic;
+ if (klass->interface_count) {
+ int count_generic = generic_array_methods (klass);
+ klass->method.count += klass->interface_count * count_generic;
}
}
- mono_class_setup_supertypes (class);
+ mono_class_setup_supertypes (klass);
if (!default_ghc)
- initialize_object_slots (class);
+ initialize_object_slots (klass);
/*
* Initialize the rest of the data without creating a generic vtable if possible.
*/
if (has_cached_info) {
/* AOT case */
- class->vtable_size = cached_info.vtable_size;
- class->has_finalize = cached_info.has_finalize;
- class->has_finalize_inited = TRUE;
- class->ghcimpl = cached_info.ghcimpl;
- class->has_cctor = cached_info.has_cctor;
- } else if (class->rank == 1 && class->byval_arg.type == MONO_TYPE_SZARRAY) {
+ klass->vtable_size = cached_info.vtable_size;
+ klass->has_finalize = cached_info.has_finalize;
+ klass->has_finalize_inited = TRUE;
+ klass->ghcimpl = cached_info.ghcimpl;
+ klass->has_cctor = cached_info.has_cctor;
+ } else if (klass->rank == 1 && klass->byval_arg.type == MONO_TYPE_SZARRAY) {
/* SZARRAY can have 2 vtable layouts, with and without the stelemref method.
* The first slot if for array with.
*/
static int szarray_vtable_size[2] = { 0 };
- int slot = MONO_TYPE_IS_REFERENCE (&class->element_class->byval_arg) ? 0 : 1;
+ int slot = MONO_TYPE_IS_REFERENCE (&klass->element_class->byval_arg) ? 0 : 1;
/* SZARRAY case */
if (!szarray_vtable_size [slot]) {
- mono_class_setup_vtable (class);
- szarray_vtable_size [slot] = class->vtable_size;
+ mono_class_setup_vtable (klass);
+ szarray_vtable_size [slot] = klass->vtable_size;
} else {
- class->vtable_size = szarray_vtable_size[slot];
+ klass->vtable_size = szarray_vtable_size[slot];
}
- } else if (class->generic_class && !MONO_CLASS_IS_INTERFACE (class)) {
- MonoClass *gklass = class->generic_class->container_class;
+ } else if (klass->generic_class && !MONO_CLASS_IS_INTERFACE (klass)) {
+ MonoClass *gklass = klass->generic_class->container_class;
/* Generic instance case */
- class->ghcimpl = gklass->ghcimpl;
- class->has_cctor = gklass->has_cctor;
+ klass->ghcimpl = gklass->ghcimpl;
+ klass->has_cctor = gklass->has_cctor;
mono_class_setup_vtable (gklass);
if (gklass->exception_type) {
- mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, NULL);
+ mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, NULL);
goto leave;
}
- class->vtable_size = gklass->vtable_size;
+ klass->vtable_size = gklass->vtable_size;
} else {
/* General case */
/* ghcimpl is not currently used
- class->ghcimpl = 1;
- if (class->parent) {
- MonoMethod *cmethod = class->vtable [ghc_slot];
+ klass->ghcimpl = 1;
+ if (klass->parent) {
+ MonoMethod *cmethod = klass->vtable [ghc_slot];
if (cmethod->is_inflated)
cmethod = ((MonoMethodInflated*)cmethod)->declaring;
if (cmethod == default_ghc) {
- class->ghcimpl = 0;
+ klass->ghcimpl = 0;
}
}
*/
/* C# doesn't allow interfaces to have cctors */
- if (!MONO_CLASS_IS_INTERFACE (class) || class->image != mono_defaults.corlib) {
+ if (!MONO_CLASS_IS_INTERFACE (klass) || klass->image != mono_defaults.corlib) {
MonoMethod *cmethod = NULL;
- if (class->type_token) {
- cmethod = find_method_in_metadata (class, ".cctor", 0, METHOD_ATTRIBUTE_SPECIAL_NAME);
+ if (klass->type_token && !image_is_dynamic(klass->image)) {
+ cmethod = find_method_in_metadata (klass, ".cctor", 0, METHOD_ATTRIBUTE_SPECIAL_NAME);
/* The find_method function ignores the 'flags' argument */
if (cmethod && (cmethod->flags & METHOD_ATTRIBUTE_SPECIAL_NAME))
- class->has_cctor = 1;
+ klass->has_cctor = 1;
} else {
- mono_class_setup_methods (class);
- if (class->exception_type)
+ mono_class_setup_methods (klass);
+ if (klass->exception_type)
goto leave;
- for (i = 0; i < class->method.count; ++i) {
- MonoMethod *method = class->methods [i];
+ for (i = 0; i < klass->method.count; ++i) {
+ MonoMethod *method = klass->methods [i];
if ((method->flags & METHOD_ATTRIBUTE_SPECIAL_NAME) &&
(strcmp (".cctor", method->name) == 0)) {
- class->has_cctor = 1;
+ klass->has_cctor = 1;
break;
}
}
}
}
- if (class->parent) {
+ if (klass->parent) {
int first_iface_slot;
- /* This will compute class->parent->vtable_size for some classes */
- mono_class_init (class->parent);
- if (class->parent->exception_type) {
- mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, NULL);
+ /* This will compute klass->parent->vtable_size for some classes */
+ mono_class_init (klass->parent);
+ if (klass->parent->exception_type) {
+ mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, NULL);
goto leave;
}
if (mono_loader_get_last_error ())
goto leave;
- if (!class->parent->vtable_size) {
+ if (!klass->parent->vtable_size) {
/* FIXME: Get rid of this somehow */
- mono_class_setup_vtable (class->parent);
- if (class->parent->exception_type) {
- mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, NULL);
+ mono_class_setup_vtable (klass->parent);
+ if (klass->parent->exception_type) {
+ mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, NULL);
goto leave;
}
if (mono_loader_get_last_error ())
goto leave;
}
- first_iface_slot = class->parent->vtable_size;
- if (mono_class_need_stelemref_method (class))
+ first_iface_slot = klass->parent->vtable_size;
+ if (mono_class_need_stelemref_method (klass))
++first_iface_slot;
- setup_interface_offsets (class, first_iface_slot, TRUE);
+ setup_interface_offsets (klass, first_iface_slot, TRUE);
} else {
- setup_interface_offsets (class, 0, TRUE);
+ setup_interface_offsets (klass, 0, TRUE);
}
if (mono_security_core_clr_enabled ())
- mono_security_core_clr_check_inheritance (class);
+ mono_security_core_clr_check_inheritance (klass);
if (mono_loader_get_last_error ()) {
- if (class->exception_type == MONO_EXCEPTION_NONE) {
- set_failure_from_loader_error (class, mono_loader_get_last_error ());
+ if (klass->exception_type == MONO_EXCEPTION_NONE) {
+ set_failure_from_loader_error (klass, mono_loader_get_last_error ());
}
mono_loader_clear_error ();
}
- if (class->generic_class && !mono_verifier_class_is_valid_generic_instantiation (class))
- mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, g_strdup ("Invalid generic instantiation"));
+ if (klass->generic_class && !mono_verifier_class_is_valid_generic_instantiation (klass))
+ mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, g_strdup ("Invalid generic instantiation"));
goto leave;
leave:
/* Because of the double-checking locking pattern */
mono_memory_barrier ();
- class->inited = 1;
- class->init_pending = 0;
+ klass->inited = 1;
+ klass->init_pending = 0;
mono_loader_unlock ();
- return class->exception_type == MONO_EXCEPTION_NONE;
+ return klass->exception_type == MONO_EXCEPTION_NONE;
}
/*
gboolean
mono_class_has_finalizer (MonoClass *klass)
{
- MonoClass *class = klass;
gboolean has_finalize = FALSE;
if (klass->has_finalize_inited)
return klass->has_finalize;
/* Interfaces and valuetypes are not supposed to have finalizers */
- if (!(MONO_CLASS_IS_INTERFACE (class) || class->valuetype)) {
+ if (!(MONO_CLASS_IS_INTERFACE (klass) || klass->valuetype)) {
MonoMethod *cmethod = NULL;
- if (class->rank == 1 && class->byval_arg.type == MONO_TYPE_SZARRAY) {
- } else if (class->generic_class) {
- MonoClass *gklass = class->generic_class->container_class;
+ if (klass->rank == 1 && klass->byval_arg.type == MONO_TYPE_SZARRAY) {
+ } else if (klass->generic_class) {
+ MonoClass *gklass = klass->generic_class->container_class;
has_finalize = mono_class_has_finalizer (gklass);
- } else if (class->parent && class->parent->has_finalize) {
+ } else if (klass->parent && klass->parent->has_finalize) {
has_finalize = TRUE;
} else {
- if (class->parent) {
+ if (klass->parent) {
/*
* Can't search in metadata for a method named Finalize, because that
* ignores overrides.
*/
- mono_class_setup_vtable (class);
- if (class->exception_type || mono_loader_get_last_error ())
+ mono_class_setup_vtable (klass);
+ if (klass->exception_type || mono_loader_get_last_error ())
cmethod = NULL;
else
- cmethod = class->vtable [finalize_slot];
+ cmethod = klass->vtable [finalize_slot];
}
if (cmethod) {
- g_assert (class->vtable_size > finalize_slot);
+ g_assert (klass->vtable_size > finalize_slot);
- if (class->parent) {
+ if (klass->parent) {
if (cmethod->is_inflated)
cmethod = ((MonoMethodInflated*)cmethod)->declaring;
if (cmethod != default_finalize)
* LOCKING: this assumes the loader lock is held
*/
void
-mono_class_setup_mono_type (MonoClass *class)
+mono_class_setup_mono_type (MonoClass *klass)
{
- const char *name = class->name;
- const char *nspace = class->name_space;
- gboolean is_corlib = mono_is_corlib_image (class->image);
+ const char *name = klass->name;
+ const char *nspace = klass->name_space;
+ gboolean is_corlib = mono_is_corlib_image (klass->image);
- class->this_arg.byref = 1;
- class->this_arg.data.klass = class;
- class->this_arg.type = MONO_TYPE_CLASS;
- class->byval_arg.data.klass = class;
- class->byval_arg.type = MONO_TYPE_CLASS;
+ klass->this_arg.byref = 1;
+ klass->this_arg.data.klass = klass;
+ klass->this_arg.type = MONO_TYPE_CLASS;
+ klass->byval_arg.data.klass = klass;
+ klass->byval_arg.type = MONO_TYPE_CLASS;
if (is_corlib && !strcmp (nspace, "System")) {
if (!strcmp (name, "ValueType")) {
/*
* do not set the valuetype bit for System.ValueType.
- * class->valuetype = 1;
+ * klass->valuetype = 1;
*/
- class->blittable = TRUE;
+ klass->blittable = TRUE;
} else if (!strcmp (name, "Enum")) {
/*
* do not set the valuetype bit for System.Enum.
- * class->valuetype = 1;
+ * klass->valuetype = 1;
*/
- class->valuetype = 0;
- class->enumtype = 0;
+ klass->valuetype = 0;
+ klass->enumtype = 0;
} else if (!strcmp (name, "Object")) {
- class->this_arg.type = class->byval_arg.type = MONO_TYPE_OBJECT;
+ klass->this_arg.type = klass->byval_arg.type = MONO_TYPE_OBJECT;
} else if (!strcmp (name, "String")) {
- class->this_arg.type = class->byval_arg.type = MONO_TYPE_STRING;
+ klass->this_arg.type = klass->byval_arg.type = MONO_TYPE_STRING;
} else if (!strcmp (name, "TypedReference")) {
- class->this_arg.type = class->byval_arg.type = MONO_TYPE_TYPEDBYREF;
+ klass->this_arg.type = klass->byval_arg.type = MONO_TYPE_TYPEDBYREF;
}
}
- if (class->valuetype) {
+ if (klass->valuetype) {
int t = MONO_TYPE_VALUETYPE;
if (is_corlib && !strcmp (nspace, "System")) {
t = MONO_TYPE_BOOLEAN;
} else if (!strcmp(name, "Byte")) {
t = MONO_TYPE_U1;
- class->blittable = TRUE;
+ klass->blittable = TRUE;
}
break;
case 'C':
case 'D':
if (!strcmp (name, "Double")) {
t = MONO_TYPE_R8;
- class->blittable = TRUE;
+ klass->blittable = TRUE;
}
break;
case 'I':
if (!strcmp (name, "Int32")) {
t = MONO_TYPE_I4;
- class->blittable = TRUE;
+ klass->blittable = TRUE;
} else if (!strcmp(name, "Int16")) {
t = MONO_TYPE_I2;
- class->blittable = TRUE;
+ klass->blittable = TRUE;
} else if (!strcmp(name, "Int64")) {
t = MONO_TYPE_I8;
- class->blittable = TRUE;
+ klass->blittable = TRUE;
} else if (!strcmp(name, "IntPtr")) {
t = MONO_TYPE_I;
- class->blittable = TRUE;
+ klass->blittable = TRUE;
}
break;
case 'S':
if (!strcmp (name, "Single")) {
t = MONO_TYPE_R4;
- class->blittable = TRUE;
+ klass->blittable = TRUE;
} else if (!strcmp(name, "SByte")) {
t = MONO_TYPE_I1;
- class->blittable = TRUE;
+ klass->blittable = TRUE;
}
break;
case 'U':
if (!strcmp (name, "UInt32")) {
t = MONO_TYPE_U4;
- class->blittable = TRUE;
+ klass->blittable = TRUE;
} else if (!strcmp(name, "UInt16")) {
t = MONO_TYPE_U2;
- class->blittable = TRUE;
+ klass->blittable = TRUE;
} else if (!strcmp(name, "UInt64")) {
t = MONO_TYPE_U8;
- class->blittable = TRUE;
+ klass->blittable = TRUE;
} else if (!strcmp(name, "UIntPtr")) {
t = MONO_TYPE_U;
- class->blittable = TRUE;
+ klass->blittable = TRUE;
}
break;
case 'T':
if (!strcmp (name, "TypedReference")) {
t = MONO_TYPE_TYPEDBYREF;
- class->blittable = TRUE;
+ klass->blittable = TRUE;
}
break;
case 'V':
break;
}
}
- class->this_arg.type = class->byval_arg.type = t;
+ klass->this_arg.type = klass->byval_arg.type = t;
}
- if (MONO_CLASS_IS_INTERFACE (class))
- class->interface_id = mono_get_unique_iid (class);
+ if (MONO_CLASS_IS_INTERFACE (klass))
+ klass->interface_id = mono_get_unique_iid (klass);
}
* lacks the types that COM depends on (e.g. Variant on Silverlight).
*/
static void
-init_com_from_comimport (MonoClass *class)
+init_com_from_comimport (MonoClass *klass)
{
/* we don't always allow COM initialization under the CoreCLR (e.g. Moonlight does not require it) */
if (mono_security_core_clr_enabled ()) {
/* but some other CoreCLR user could requires it for their platform (i.e. trusted) code */
- if (!mono_security_core_clr_determine_platform_image (class->image)) {
+ if (!mono_security_core_clr_determine_platform_image (klass->image)) {
/* but it can not be made available for application (i.e. user code) since all COM calls
* are considered native calls. In this case we fail with a TypeLoadException (just like
* Silverlight 2 does */
- mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, NULL);
+ mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, NULL);
return;
}
}
* LOCKING: this assumes the loader lock is held
*/
void
-mono_class_setup_parent (MonoClass *class, MonoClass *parent)
+mono_class_setup_parent (MonoClass *klass, MonoClass *parent)
{
gboolean system_namespace;
- gboolean is_corlib = mono_is_corlib_image (class->image);
+ gboolean is_corlib = mono_is_corlib_image (klass->image);
- system_namespace = !strcmp (class->name_space, "System") && is_corlib;
+ system_namespace = !strcmp (klass->name_space, "System") && is_corlib;
/* if root of the hierarchy */
- if (system_namespace && !strcmp (class->name, "Object")) {
- class->parent = NULL;
- class->instance_size = sizeof (MonoObject);
+ if (system_namespace && !strcmp (klass->name, "Object")) {
+ klass->parent = NULL;
+ klass->instance_size = sizeof (MonoObject);
return;
}
- if (!strcmp (class->name, "<Module>")) {
- class->parent = NULL;
- class->instance_size = 0;
+ if (!strcmp (klass->name, "<Module>")) {
+ klass->parent = NULL;
+ klass->instance_size = 0;
return;
}
- if (!MONO_CLASS_IS_INTERFACE (class)) {
+ if (!MONO_CLASS_IS_INTERFACE (klass)) {
/* Imported COM Objects always derive from __ComObject. */
#ifndef DISABLE_COM
- if (MONO_CLASS_IS_IMPORT (class)) {
- init_com_from_comimport (class);
+ if (MONO_CLASS_IS_IMPORT (klass)) {
+ init_com_from_comimport (klass);
if (parent == mono_defaults.object_class)
parent = mono_class_get_com_object_class ();
}
if (!parent) {
/* set the parent to something useful and safe, but mark the type as broken */
parent = mono_defaults.object_class;
- mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, NULL);
+ mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, NULL);
}
- class->parent = parent;
+ klass->parent = parent;
if (parent->generic_class && !parent->name) {
/*
}
#ifndef DISABLE_REMOTING
- class->marshalbyref = parent->marshalbyref;
- class->contextbound = parent->contextbound;
+ klass->marshalbyref = parent->marshalbyref;
+ klass->contextbound = parent->contextbound;
#endif
- class->delegate = parent->delegate;
+ klass->delegate = parent->delegate;
- if (MONO_CLASS_IS_IMPORT (class) || mono_class_is_com_object (parent))
- mono_class_set_is_com_object (class);
+ if (MONO_CLASS_IS_IMPORT (klass) || mono_class_is_com_object (parent))
+ mono_class_set_is_com_object (klass);
if (system_namespace) {
#ifndef DISABLE_REMOTING
- if (*class->name == 'M' && !strcmp (class->name, "MarshalByRefObject"))
- class->marshalbyref = 1;
+ if (klass->name [0] == 'M' && !strcmp (klass->name, "MarshalByRefObject"))
+ klass->marshalbyref = 1;
- if (*class->name == 'C' && !strcmp (class->name, "ContextBoundObject"))
- class->contextbound = 1;
+ if (klass->name [0] == 'C' && !strcmp (klass->name, "ContextBoundObject"))
+ klass->contextbound = 1;
#endif
- if (*class->name == 'D' && !strcmp (class->name, "Delegate"))
- class->delegate = 1;
+ if (klass->name [0] == 'D' && !strcmp (klass->name, "Delegate"))
+ klass->delegate = 1;
}
- if (class->parent->enumtype || (mono_is_corlib_image (class->parent->image) && (strcmp (class->parent->name, "ValueType") == 0) &&
- (strcmp (class->parent->name_space, "System") == 0)))
- class->valuetype = 1;
- if (mono_is_corlib_image (class->parent->image) && ((strcmp (class->parent->name, "Enum") == 0) && (strcmp (class->parent->name_space, "System") == 0))) {
- class->valuetype = class->enumtype = 1;
+ if (klass->parent->enumtype || (mono_is_corlib_image (klass->parent->image) && (strcmp (klass->parent->name, "ValueType") == 0) &&
+ (strcmp (klass->parent->name_space, "System") == 0)))
+ klass->valuetype = 1;
+ if (mono_is_corlib_image (klass->parent->image) && ((strcmp (klass->parent->name, "Enum") == 0) && (strcmp (klass->parent->name_space, "System") == 0))) {
+ klass->valuetype = klass->enumtype = 1;
}
- /*class->enumtype = class->parent->enumtype; */
+ /*klass->enumtype = klass->parent->enumtype; */
} else {
/* initialize com types if COM interfaces are present */
#ifndef DISABLE_COM
- if (MONO_CLASS_IS_IMPORT (class))
- init_com_from_comimport (class);
+ if (MONO_CLASS_IS_IMPORT (klass))
+ init_com_from_comimport (klass);
#endif
- class->parent = NULL;
+ klass->parent = NULL;
}
}
* LOCKING: This function is atomic, in case of contention we waste memory.
*/
void
-mono_class_setup_supertypes (MonoClass *class)
+mono_class_setup_supertypes (MonoClass *klass)
{
int ms;
MonoClass **supertypes;
- mono_atomic_load_acquire (supertypes, void*, &class->supertypes);
+ mono_atomic_load_acquire (supertypes, void*, &klass->supertypes);
if (supertypes)
return;
- if (class->parent && !class->parent->supertypes)
- mono_class_setup_supertypes (class->parent);
- if (class->parent)
- class->idepth = class->parent->idepth + 1;
+ if (klass->parent && !klass->parent->supertypes)
+ mono_class_setup_supertypes (klass->parent);
+ if (klass->parent)
+ klass->idepth = klass->parent->idepth + 1;
else
- class->idepth = 1;
+ klass->idepth = 1;
- ms = MAX (MONO_DEFAULT_SUPERTABLE_SIZE, class->idepth);
- supertypes = mono_class_alloc0 (class, sizeof (MonoClass *) * ms);
+ ms = MAX (MONO_DEFAULT_SUPERTABLE_SIZE, klass->idepth);
+ supertypes = mono_class_alloc0 (klass, sizeof (MonoClass *) * ms);
- if (class->parent) {
- supertypes [class->idepth - 1] = class;
- memcpy (supertypes, class->parent->supertypes, class->parent->idepth * sizeof (gpointer));
+ if (klass->parent) {
+ supertypes [klass->idepth - 1] = klass;
+ memcpy (supertypes, klass->parent->supertypes, klass->parent->idepth * sizeof (gpointer));
} else {
- supertypes [0] = class;
+ supertypes [0] = klass;
}
- mono_atomic_store_release (&class->supertypes, supertypes);
+ mono_atomic_store_release (&klass->supertypes, supertypes);
}
static gboolean
}
static void
-mono_class_set_failure_and_error (MonoClass *class, MonoError *error, const char *msg)
+mono_class_set_failure_and_error (MonoClass *klass, MonoError *error, const char *msg)
{
- mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, g_strdup (msg));
- mono_error_set_type_load_class (error, class, msg);
+ mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, g_strdup (msg));
+ mono_error_set_type_load_class (error, klass, msg);
}
static void
-mono_class_set_failure_from_loader_error (MonoClass *class, MonoError *error, char *msg)
+mono_class_set_failure_from_loader_error (MonoClass *klass, MonoError *error, char *msg)
{
MonoLoaderError *lerror = mono_loader_get_last_error ();
if (lerror) {
- set_failure_from_loader_error (class, lerror);
+ set_failure_from_loader_error (klass, lerror);
mono_error_set_from_loader_error (error);
if (msg)
g_free (msg);
} else {
- mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, msg);
- mono_error_set_type_load_class (error, class, msg);
+ mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, msg);
+ mono_error_set_type_load_class (error, klass, msg);
}
}
mono_class_create_from_typedef (MonoImage *image, guint32 type_token, MonoError *error)
{
MonoTableInfo *tt = &image->tables [MONO_TABLE_TYPEDEF];
- MonoClass *class, *parent = NULL;
+ MonoClass *klass, *parent = NULL;
guint32 cols [MONO_TYPEDEF_SIZE];
guint32 cols_next [MONO_TYPEDEF_SIZE];
guint tidx = mono_metadata_token_index (type_token);
mono_loader_lock ();
- if ((class = mono_internal_hash_table_lookup (&image->class_cache, GUINT_TO_POINTER (type_token)))) {
+ if ((klass = mono_internal_hash_table_lookup (&image->class_cache, GUINT_TO_POINTER (type_token)))) {
mono_loader_unlock ();
mono_loader_assert_no_error ();
- return class;
+ return klass;
}
mono_metadata_decode_row (tt, tidx - 1, cols, MONO_TYPEDEF_SIZE);
name = mono_metadata_string_heap (image, cols [MONO_TYPEDEF_NAME]);
nspace = mono_metadata_string_heap (image, cols [MONO_TYPEDEF_NAMESPACE]);
- class = mono_image_alloc0 (image, sizeof (MonoClass));
+ klass = mono_image_alloc0 (image, sizeof (MonoClass));
- class->name = name;
- class->name_space = nspace;
+ klass->name = name;
+ klass->name_space = nspace;
- mono_profiler_class_event (class, MONO_PROFILE_START_LOAD);
+ mono_profiler_class_event (klass, MONO_PROFILE_START_LOAD);
- class->image = image;
- class->type_token = type_token;
- class->flags = cols [MONO_TYPEDEF_FLAGS];
+ klass->image = image;
+ klass->type_token = type_token;
+ klass->flags = cols [MONO_TYPEDEF_FLAGS];
- mono_internal_hash_table_insert (&image->class_cache, GUINT_TO_POINTER (type_token), class);
+ mono_internal_hash_table_insert (&image->class_cache, GUINT_TO_POINTER (type_token), klass);
classes_size += sizeof (MonoClass);
/*
* Check whether we're a generic type definition.
*/
- class->generic_container = mono_metadata_load_generic_params (image, class->type_token, NULL);
- if (class->generic_container) {
- class->is_generic = 1;
- class->generic_container->owner.klass = class;
- context = &class->generic_container->context;
+ klass->generic_container = mono_metadata_load_generic_params (image, klass->type_token, NULL);
+ if (klass->generic_container) {
+ klass->is_generic = 1;
+ klass->generic_container->owner.klass = klass;
+ context = &klass->generic_container->context;
}
- if (class->generic_container)
+ if (klass->generic_container)
enable_gclass_recording ();
if (cols [MONO_TYPEDEF_EXTENDS]) {
if (mono_metadata_token_table (parent_token) == MONO_TABLE_TYPESPEC) {
/*WARNING: this must satisfy mono_metadata_type_hash*/
- class->this_arg.byref = 1;
- class->this_arg.data.klass = class;
- class->this_arg.type = MONO_TYPE_CLASS;
- class->byval_arg.data.klass = class;
- class->byval_arg.type = MONO_TYPE_CLASS;
+ klass->this_arg.byref = 1;
+ klass->this_arg.data.klass = klass;
+ klass->this_arg.type = MONO_TYPE_CLASS;
+ klass->byval_arg.data.klass = klass;
+ klass->byval_arg.type = MONO_TYPE_CLASS;
}
parent = mono_class_get_checked (image, parent_token, error);
if (parent && context) /* Always inflate */
parent = mono_class_inflate_generic_class_checked (parent, context, error);
if (parent == NULL) {
- mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, g_strdup (mono_error_get_message (error)));
+ mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, g_strdup (mono_error_get_message (error)));
goto parent_failure;
}
for (tmp = parent; tmp; tmp = tmp->parent) {
- if (tmp == class) {
- mono_class_set_failure_and_error (class, error, "Cycle found while resolving parent");
+ if (tmp == klass) {
+ mono_class_set_failure_and_error (klass, error, "Cycle found while resolving parent");
goto parent_failure;
}
- if (class->generic_container && tmp->generic_class && tmp->generic_class->container_class == class) {
- mono_class_set_failure_and_error (class, error, "Parent extends generic instance of this type");
+ if (klass->generic_container && tmp->generic_class && tmp->generic_class->container_class == klass) {
+ mono_class_set_failure_and_error (klass, error, "Parent extends generic instance of this type");
goto parent_failure;
}
}
}
- mono_class_setup_parent (class, parent);
+ mono_class_setup_parent (klass, parent);
/* uses ->valuetype, which is initialized by mono_class_setup_parent above */
- mono_class_setup_mono_type (class);
+ mono_class_setup_mono_type (klass);
- if (class->generic_container)
- disable_gclass_recording (fix_gclass_incomplete_instantiation, class);
+ if (klass->generic_container)
+ disable_gclass_recording (fix_gclass_incomplete_instantiation, klass);
/*
- * This might access class->byval_arg for recursion generated by generic constraints,
+ * This might access klass->byval_arg for recursion generated by generic constraints,
* so it has to come after setup_mono_type ().
*/
if ((nesting_tokeen = mono_metadata_nested_in_typedef (image, type_token))) {
- class->nested_in = mono_class_create_from_typedef (image, nesting_tokeen, error);
+ klass->nested_in = mono_class_create_from_typedef (image, nesting_tokeen, error);
if (!mono_error_ok (error)) {
/*FIXME implement a mono_class_set_failure_from_mono_error */
- mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, g_strdup (mono_error_get_message (error)));
+ mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, g_strdup (mono_error_get_message (error)));
mono_loader_unlock ();
- mono_profiler_class_loaded (class, MONO_PROFILE_FAILED);
+ mono_profiler_class_loaded (klass, MONO_PROFILE_FAILED);
mono_loader_assert_no_error ();
return NULL;
}
}
- if ((class->flags & TYPE_ATTRIBUTE_STRING_FORMAT_MASK) == TYPE_ATTRIBUTE_UNICODE_CLASS)
- class->unicode = 1;
+ if ((klass->flags & TYPE_ATTRIBUTE_STRING_FORMAT_MASK) == TYPE_ATTRIBUTE_UNICODE_CLASS)
+ klass->unicode = 1;
#ifdef HOST_WIN32
- if ((class->flags & TYPE_ATTRIBUTE_STRING_FORMAT_MASK) == TYPE_ATTRIBUTE_AUTO_CLASS)
- class->unicode = 1;
+ if ((klass->flags & TYPE_ATTRIBUTE_STRING_FORMAT_MASK) == TYPE_ATTRIBUTE_AUTO_CLASS)
+ klass->unicode = 1;
#endif
- class->cast_class = class->element_class = class;
+ klass->cast_class = klass->element_class = klass;
- if (!class->enumtype) {
+ if (!klass->enumtype) {
if (!mono_metadata_interfaces_from_typedef_full (
image, type_token, &interfaces, &icount, FALSE, context, error)){
- mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, g_strdup (mono_error_get_message (error)));
+ mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, g_strdup (mono_error_get_message (error)));
mono_loader_unlock ();
- mono_profiler_class_loaded (class, MONO_PROFILE_FAILED);
+ mono_profiler_class_loaded (klass, MONO_PROFILE_FAILED);
return NULL;
}
- class->interfaces = interfaces;
- class->interface_count = icount;
- class->interfaces_inited = 1;
+ klass->interfaces = interfaces;
+ klass->interface_count = icount;
+ klass->interfaces_inited = 1;
}
/*g_print ("Load class %s\n", name);*/
/*
* Compute the field and method lists
*/
- class->field.first = cols [MONO_TYPEDEF_FIELD_LIST] - 1;
- class->method.first = cols [MONO_TYPEDEF_METHOD_LIST] - 1;
+ klass->field.first = cols [MONO_TYPEDEF_FIELD_LIST] - 1;
+ klass->method.first = cols [MONO_TYPEDEF_METHOD_LIST] - 1;
if (tt->rows > tidx){
mono_metadata_decode_row (tt, tidx, cols_next, MONO_TYPEDEF_SIZE);
if (cols [MONO_TYPEDEF_FIELD_LIST] &&
cols [MONO_TYPEDEF_FIELD_LIST] <= image->tables [MONO_TABLE_FIELD].rows)
- class->field.count = field_last - class->field.first;
+ klass->field.count = field_last - klass->field.first;
else
- class->field.count = 0;
+ klass->field.count = 0;
if (cols [MONO_TYPEDEF_METHOD_LIST] <= image->tables [MONO_TABLE_METHOD].rows)
- class->method.count = method_last - class->method.first;
+ klass->method.count = method_last - klass->method.first;
else
- class->method.count = 0;
+ klass->method.count = 0;
/* reserve space to store vector pointer in arrays */
if (mono_is_corlib_image (image) && !strcmp (nspace, "System") && !strcmp (name, "Array")) {
- class->instance_size += 2 * sizeof (gpointer);
- g_assert (class->field.count == 0);
+ klass->instance_size += 2 * sizeof (gpointer);
+ g_assert (klass->field.count == 0);
}
- if (class->enumtype) {
- MonoType *enum_basetype = mono_class_find_enum_basetype (class, error);
+ if (klass->enumtype) {
+ MonoType *enum_basetype = mono_class_find_enum_basetype (klass, error);
if (!enum_basetype) {
/*set it to a default value as the whole runtime can't handle this to be null*/
- class->cast_class = class->element_class = mono_defaults.int32_class;
- mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, g_strdup (mono_error_get_message (error)));
+ klass->cast_class = klass->element_class = mono_defaults.int32_class;
+ mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, g_strdup (mono_error_get_message (error)));
mono_loader_unlock ();
- mono_profiler_class_loaded (class, MONO_PROFILE_FAILED);
+ mono_profiler_class_loaded (klass, MONO_PROFILE_FAILED);
mono_loader_assert_no_error ();
return NULL;
}
- class->cast_class = class->element_class = mono_class_from_mono_type (enum_basetype);
+ klass->cast_class = klass->element_class = mono_class_from_mono_type (enum_basetype);
}
/*
* We must do this after the class has been constructed to make certain recursive scenarios
* work.
*/
- if (class->generic_container && !mono_metadata_load_generic_param_constraints_checked (image, type_token, class->generic_container, error)) {
- mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, g_strdup_printf ("Could not load generic parameter constrains due to %s", mono_error_get_message (error)));
+ if (klass->generic_container && !mono_metadata_load_generic_param_constraints_checked (image, type_token, klass->generic_container, error)) {
+ mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, g_strdup_printf ("Could not load generic parameter constrains due to %s", mono_error_get_message (error)));
mono_loader_unlock ();
- mono_profiler_class_loaded (class, MONO_PROFILE_FAILED);
+ mono_profiler_class_loaded (klass, MONO_PROFILE_FAILED);
mono_loader_assert_no_error ();
return NULL;
}
- if (class->image->assembly_name && !strcmp (class->image->assembly_name, "Mono.Simd") && !strcmp (nspace, "Mono.Simd")) {
+ if (klass->image->assembly_name && !strcmp (klass->image->assembly_name, "Mono.Simd") && !strcmp (nspace, "Mono.Simd")) {
if (!strncmp (name, "Vector", 6))
- class->simd_type = !strcmp (name + 6, "2d") || !strcmp (name + 6, "2ul") || !strcmp (name + 6, "2l") || !strcmp (name + 6, "4f") || !strcmp (name + 6, "4ui") || !strcmp (name + 6, "4i") || !strcmp (name + 6, "8s") || !strcmp (name + 6, "8us") || !strcmp (name + 6, "16b") || !strcmp (name + 6, "16sb");
+ klass->simd_type = !strcmp (name + 6, "2d") || !strcmp (name + 6, "2ul") || !strcmp (name + 6, "2l") || !strcmp (name + 6, "4f") || !strcmp (name + 6, "4ui") || !strcmp (name + 6, "4i") || !strcmp (name + 6, "8s") || !strcmp (name + 6, "8us") || !strcmp (name + 6, "16b") || !strcmp (name + 6, "16sb");
}
mono_loader_unlock ();
- mono_profiler_class_loaded (class, MONO_PROFILE_OK);
+ mono_profiler_class_loaded (klass, MONO_PROFILE_OK);
mono_loader_assert_no_error ();
- return class;
+ return klass;
parent_failure:
- mono_class_setup_mono_type (class);
+ mono_class_setup_mono_type (klass);
mono_loader_unlock ();
- mono_profiler_class_loaded (class, MONO_PROFILE_FAILED);
+ mono_profiler_class_loaded (klass, MONO_PROFILE_FAILED);
mono_loader_assert_no_error ();
return NULL;
}
mono_bounded_array_class_get (MonoClass *eclass, guint32 rank, gboolean bounded)
{
MonoImage *image;
- MonoClass *class;
+ MonoClass *klass;
MonoClass *parent = NULL;
GSList *list, *rootlist = NULL;
int nsize;
mono_mutex_lock (&image->szarray_cache_lock);
if (!image->szarray_cache)
image->szarray_cache = g_hash_table_new (mono_aligned_addr_hash, NULL);
- class = g_hash_table_lookup (image->szarray_cache, eclass);
+ klass = g_hash_table_lookup (image->szarray_cache, eclass);
mono_mutex_unlock (&image->szarray_cache_lock);
- if (class)
- return class;
+ if (klass)
+ return klass;
mono_loader_lock ();
} else {
if ((rootlist = list = g_hash_table_lookup (image->array_cache, eclass))) {
for (; list; list = list->next) {
- class = list->data;
- if ((class->rank == rank) && (class->byval_arg.type == (((rank > 1) || bounded) ? MONO_TYPE_ARRAY : MONO_TYPE_SZARRAY))) {
+ klass = list->data;
+ if ((klass->rank == rank) && (klass->byval_arg.type == (((rank > 1) || bounded) ? MONO_TYPE_ARRAY : MONO_TYPE_SZARRAY))) {
mono_loader_unlock ();
- return class;
+ return klass;
}
}
}
mono_class_init (parent);
}
- class = mono_image_alloc0 (image, sizeof (MonoClass));
+ klass = mono_image_alloc0 (image, sizeof (MonoClass));
- class->image = image;
- class->name_space = eclass->name_space;
+ klass->image = image;
+ klass->name_space = eclass->name_space;
nsize = strlen (eclass->name);
name = g_malloc (nsize + 2 + rank + 1);
memcpy (name, eclass->name, nsize);
name [nsize + rank] = '*';
name [nsize + rank + bounded] = ']';
name [nsize + rank + bounded + 1] = 0;
- class->name = mono_image_strdup (image, name);
+ klass->name = mono_image_strdup (image, name);
g_free (name);
- mono_profiler_class_event (class, MONO_PROFILE_START_LOAD);
+ mono_profiler_class_event (klass, MONO_PROFILE_START_LOAD);
classes_size += sizeof (MonoClass);
- class->type_token = 0;
+ klass->type_token = 0;
/* all arrays are marked serializable and sealed, bug #42779 */
- class->flags = TYPE_ATTRIBUTE_CLASS | TYPE_ATTRIBUTE_SERIALIZABLE | TYPE_ATTRIBUTE_SEALED | TYPE_ATTRIBUTE_PUBLIC;
- class->parent = parent;
- class->instance_size = mono_class_instance_size (class->parent);
+ klass->flags = TYPE_ATTRIBUTE_CLASS | TYPE_ATTRIBUTE_SERIALIZABLE | TYPE_ATTRIBUTE_SEALED | TYPE_ATTRIBUTE_PUBLIC;
+ klass->parent = parent;
+ klass->instance_size = mono_class_instance_size (klass->parent);
if (eclass->byval_arg.type == MONO_TYPE_TYPEDBYREF || eclass->byval_arg.type == MONO_TYPE_VOID) {
/*Arrays of those two types are invalid.*/
- mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, NULL);
+ mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, NULL);
} else if (eclass->enumtype && !mono_class_enum_basetype (eclass)) {
if (!eclass->ref_info_handle || eclass->wastypebuilder) {
g_warning ("Only incomplete TypeBuilder objects are allowed to be an enum without base_type");
g_assert (eclass->ref_info_handle && !eclass->wastypebuilder);
}
/* element_size -1 is ok as this is not an instantitable type*/
- class->sizes.element_size = -1;
+ klass->sizes.element_size = -1;
} else
- class->sizes.element_size = mono_class_array_element_size (eclass);
+ klass->sizes.element_size = mono_class_array_element_size (eclass);
- mono_class_setup_supertypes (class);
+ mono_class_setup_supertypes (klass);
if (eclass->generic_class)
mono_class_init (eclass);
if (!eclass->size_inited)
mono_class_setup_fields (eclass);
if (eclass->exception_type) /*FIXME we fail the array type, but we have to let other fields be set.*/
- mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, NULL);
+ mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, NULL);
- class->has_references = MONO_TYPE_IS_REFERENCE (&eclass->byval_arg) || eclass->has_references? TRUE: FALSE;
+ klass->has_references = MONO_TYPE_IS_REFERENCE (&eclass->byval_arg) || eclass->has_references? TRUE: FALSE;
- class->rank = rank;
+ klass->rank = rank;
if (eclass->enumtype)
- class->cast_class = eclass->element_class;
+ klass->cast_class = eclass->element_class;
else
- class->cast_class = eclass;
+ klass->cast_class = eclass;
- switch (class->cast_class->byval_arg.type) {
+ switch (klass->cast_class->byval_arg.type) {
case MONO_TYPE_I1:
- class->cast_class = mono_defaults.byte_class;
+ klass->cast_class = mono_defaults.byte_class;
break;
case MONO_TYPE_U2:
- class->cast_class = mono_defaults.int16_class;
+ klass->cast_class = mono_defaults.int16_class;
break;
case MONO_TYPE_U4:
#if SIZEOF_VOID_P == 4
case MONO_TYPE_I:
case MONO_TYPE_U:
#endif
- class->cast_class = mono_defaults.int32_class;
+ klass->cast_class = mono_defaults.int32_class;
break;
case MONO_TYPE_U8:
#if SIZEOF_VOID_P == 8
case MONO_TYPE_I:
case MONO_TYPE_U:
#endif
- class->cast_class = mono_defaults.int64_class;
+ klass->cast_class = mono_defaults.int64_class;
break;
default:
break;
}
- class->element_class = eclass;
+ klass->element_class = eclass;
if ((rank > 1) || bounded) {
MonoArrayType *at = mono_image_alloc0 (image, sizeof (MonoArrayType));
- class->byval_arg.type = MONO_TYPE_ARRAY;
- class->byval_arg.data.array = at;
+ klass->byval_arg.type = MONO_TYPE_ARRAY;
+ klass->byval_arg.data.array = at;
at->eklass = eclass;
at->rank = rank;
/* FIXME: complete.... */
} else {
- class->byval_arg.type = MONO_TYPE_SZARRAY;
- class->byval_arg.data.klass = eclass;
+ klass->byval_arg.type = MONO_TYPE_SZARRAY;
+ klass->byval_arg.data.klass = eclass;
}
- class->this_arg = class->byval_arg;
- class->this_arg.byref = 1;
+ klass->this_arg = klass->byval_arg;
+ klass->this_arg.byref = 1;
if (corlib_type) {
- class->inited = 1;
+ klass->inited = 1;
}
- class->generic_container = eclass->generic_container;
+ klass->generic_container = eclass->generic_container;
if (rank == 1 && !bounded) {
MonoClass *prev_class;
prev_class = g_hash_table_lookup (image->szarray_cache, eclass);
if (prev_class)
/* Someone got in before us */
- class = prev_class;
+ klass = prev_class;
else
- g_hash_table_insert (image->szarray_cache, eclass, class);
+ g_hash_table_insert (image->szarray_cache, eclass, klass);
mono_mutex_unlock (&image->szarray_cache_lock);
} else {
- list = g_slist_append (rootlist, class);
+ list = g_slist_append (rootlist, klass);
g_hash_table_insert (image->array_cache, eclass, list);
}
mono_loader_unlock ();
- mono_profiler_class_loaded (class, MONO_PROFILE_OK);
+ mono_profiler_class_loaded (klass, MONO_PROFILE_OK);
- return class;
+ return klass;
}
/**
* Takes a field index instead of a field token.
*/
static MonoClassField *
-mono_class_get_field_idx (MonoClass *class, int idx)
+mono_class_get_field_idx (MonoClass *klass, int idx)
{
- mono_class_setup_fields_locking (class);
- if (class->exception_type)
+ mono_class_setup_fields_locking (klass);
+ if (klass->exception_type)
return NULL;
- while (class) {
- if (class->image->uncompressed_metadata) {
+ while (klass) {
+ if (klass->image->uncompressed_metadata) {
/*
- * class->field.first points to the FieldPtr table, while idx points into the
+ * klass->field.first points to the FieldPtr table, while idx points into the
* Field table, so we have to do a search.
*/
/*FIXME this is broken for types with multiple fields with the same name.*/
- const char *name = mono_metadata_string_heap (class->image, mono_metadata_decode_row_col (&class->image->tables [MONO_TABLE_FIELD], idx, MONO_FIELD_NAME));
+ const char *name = mono_metadata_string_heap (klass->image, mono_metadata_decode_row_col (&klass->image->tables [MONO_TABLE_FIELD], idx, MONO_FIELD_NAME));
int i;
- for (i = 0; i < class->field.count; ++i)
- if (mono_field_get_name (&class->fields [i]) == name)
- return &class->fields [i];
+ for (i = 0; i < klass->field.count; ++i)
+ if (mono_field_get_name (&klass->fields [i]) == name)
+ return &klass->fields [i];
g_assert_not_reached ();
} else {
- if (class->field.count) {
- if ((idx >= class->field.first) && (idx < class->field.first + class->field.count)){
- return &class->fields [idx - class->field.first];
+ if (klass->field.count) {
+ if ((idx >= klass->field.first) && (idx < klass->field.first + klass->field.count)){
+ return &klass->fields [idx - klass->field.first];
}
}
}
- class = class->parent;
+ klass = klass->parent;
}
return NULL;
}
* class.
*/
MonoClassField *
-mono_class_get_field (MonoClass *class, guint32 field_token)
+mono_class_get_field (MonoClass *klass, guint32 field_token)
{
int idx = mono_metadata_token_index (field_token);
g_assert (mono_metadata_token_code (field_token) == MONO_TOKEN_FIELD_DEF);
- return mono_class_get_field_idx (class, idx - 1);
+ return mono_class_get_field_idx (klass, idx - 1);
}
/**
mono_class_get_full (MonoImage *image, guint32 type_token, MonoGenericContext *context)
{
MonoError error;
- MonoClass *class;
- class = mono_class_get_checked (image, type_token, &error);
+ MonoClass *klass;
+ klass = mono_class_get_checked (image, type_token, &error);
- if (class && context && mono_metadata_token_table (type_token) == MONO_TABLE_TYPESPEC)
- class = mono_class_inflate_generic_class_checked (class, context, &error);
+ if (klass && context && mono_metadata_token_table (type_token) == MONO_TABLE_TYPESPEC)
+ klass = mono_class_inflate_generic_class_checked (klass, context, &error);
g_assert (mono_error_ok (&error)); /* FIXME deprecate this function and forbit the runtime from using it. */
- return class;
+ return klass;
}
MonoClass *
mono_class_get_and_inflate_typespec_checked (MonoImage *image, guint32 type_token, MonoGenericContext *context, MonoError *error)
{
- MonoClass *class;
+ MonoClass *klass;
mono_error_init (error);
- class = mono_class_get_checked (image, type_token, error);
+ klass = mono_class_get_checked (image, type_token, error);
- if (class && context && mono_metadata_token_table (type_token) == MONO_TABLE_TYPESPEC)
- class = mono_class_inflate_generic_class_checked (class, context, error);
+ if (klass && context && mono_metadata_token_table (type_token) == MONO_TABLE_TYPESPEC)
+ klass = mono_class_inflate_generic_class_checked (klass, context, error);
- return class;
+ return klass;
}
/**
* mono_class_get_checked:
MonoClass *
mono_class_get_checked (MonoImage *image, guint32 type_token, MonoError *error)
{
- MonoClass *class = NULL;
+ MonoClass *klass = NULL;
mono_error_init (error);
mono_error_set_bad_image (error, image,"Bad token table for dynamic image: %x", table);
return NULL;
}
- class = mono_lookup_dynamic_token (image, type_token, NULL); /*FIXME proper error handling*/
+ klass = mono_lookup_dynamic_token (image, type_token, NULL); /*FIXME proper error handling*/
goto done;
}
switch (type_token & 0xff000000){
case MONO_TOKEN_TYPE_DEF:
- class = mono_class_create_from_typedef (image, type_token, error);
+ klass = mono_class_create_from_typedef (image, type_token, error);
break;
case MONO_TOKEN_TYPE_REF:
- class = mono_class_from_typeref_checked (image, type_token, error);
+ klass = mono_class_from_typeref_checked (image, type_token, error);
break;
case MONO_TOKEN_TYPE_SPEC:
- class = mono_class_create_from_typespec (image, type_token, NULL, error);
+ klass = mono_class_create_from_typespec (image, type_token, NULL, error);
break;
default:
mono_error_set_bad_image (error, image, "Unknown type token %x", type_token & 0xff000000);
done:
/* Generic case, should be avoided for when a better error is possible. */
- if (!class && mono_error_ok (error)) {
+ if (!klass && mono_error_ok (error)) {
char *name = mono_class_name_from_token (image, type_token);
char *assembly = mono_assembly_name_from_token (image, type_token);
mono_error_set_type_load_name (error, name, assembly, "Could not resolve type with token %08x", type_token);
}
- return class;
+ return klass;
}
return mono_class_get_type (mono_lookup_dynamic_token (image, type_token, context));
if ((type_token & 0xff000000) != MONO_TOKEN_TYPE_SPEC) {
- MonoClass *class = mono_class_get_checked (image, type_token, error);
+ MonoClass *klass = mono_class_get_checked (image, type_token, error);
- if (!class) {
+ if (!klass) {
mono_loader_assert_no_error ();
return NULL;
}
- g_assert (class);
- return mono_class_get_type (class);
+ g_assert (klass);
+ return mono_class_get_type (klass);
}
type = mono_type_retrieve_from_typespec (image, type_token, context, &inflated, error);
}
static MonoClass*
-return_nested_in (MonoClass *class, char *nested)
+return_nested_in (MonoClass *klass, char *nested)
{
MonoClass *found;
char *s = strchr (nested, '/');
s++;
}
- while ((found = mono_class_get_nested_types (class, &iter))) {
+ while ((found = mono_class_get_nested_types (klass, &iter))) {
if (strcmp (found->name, nested) == 0) {
if (s)
return return_nested_in (found, s);
{
MonoTableInfo *file_table = &image->tables [MONO_TABLE_FILE];
MonoImage *file_image;
- MonoClass *class;
+ MonoClass *klass;
int i;
/*
file_image = mono_image_load_file_for_image (image, i + 1);
if (file_image) {
- class = mono_class_from_name (file_image, name_space, name);
- if (class)
- return class;
+ klass = mono_class_from_name (file_image, name_space, name);
+ if (klass)
+ return klass;
}
}
MonoImage *loaded_image;
guint32 token = 0;
int i;
- MonoClass *class;
+ MonoClass *klass;
char *nested;
char buf [1024];
/* FIXME: get_class_from_name () can't handle types in the EXPORTEDTYPE table */
if (get_class_from_name && image->tables [MONO_TABLE_EXPORTEDTYPE].rows == 0) {
- gboolean res = get_class_from_name (image, name_space, name, &class);
+ gboolean res = get_class_from_name (image, name_space, name, &klass);
if (res) {
- if (!class)
- class = search_modules (image, name_space, name);
+ if (!klass)
+ klass = search_modules (image, name_space, name);
if (nested)
- return class ? return_nested_in (class, nested) : NULL;
+ return klass ? return_nested_in (klass, nested) : NULL;
else
- return class;
+ return klass;
}
}
for (i = 0; i < image->module_count; ++i) {
MonoImage *module = image->modules [i];
- class = mono_class_from_name (module, name_space, name);
- if (class)
- return class;
+ klass = mono_class_from_name (module, name_space, name);
+ if (klass)
+ return klass;
}
}
if (!token) {
- class = search_modules (image, name_space, name);
- if (class)
- return class;
+ klass = search_modules (image, name_space, name);
+ if (klass)
+ return klass;
}
if (!token)
loaded_image = mono_assembly_load_module (image->assembly, impl >> MONO_IMPLEMENTATION_BITS);
if (!loaded_image)
return NULL;
- class = mono_class_from_name_checked_aux (loaded_image, name_space, name, error, visited_images);
+ klass = mono_class_from_name_checked_aux (loaded_image, name_space, name, error, visited_images);
if (nested)
- return return_nested_in (class, nested);
- return class;
+ return return_nested_in (klass, nested);
+ return klass;
} else if ((impl & MONO_IMPLEMENTATION_MASK) == MONO_IMPLEMENTATION_ASSEMBLYREF) {
guint32 assembly_idx;
token = MONO_TOKEN_TYPE_DEF | token;
- class = mono_class_get_checked (image, token, error);
+ klass = mono_class_get_checked (image, token, error);
if (nested)
- return return_nested_in (class, nested);
- return class;
+ return return_nested_in (klass, nested);
+ return klass;
}
MonoClass *
return type;
}
case MONO_TOKEN_FIELD_DEF: {
- MonoClass *class;
+ MonoClass *klass;
guint32 type = mono_metadata_typedef_from_field (image, mono_metadata_token_index (token));
if (!type) {
mono_error_set_bad_image (error, image, "Bad ldtoken %x", token);
}
if (handle_class)
*handle_class = mono_defaults.fieldhandle_class;
- class = mono_class_get_and_inflate_typespec_checked (image, MONO_TOKEN_TYPE_DEF | type, context, error);
- if (!class)
+ klass = mono_class_get_and_inflate_typespec_checked (image, MONO_TOKEN_TYPE_DEF | type, context, error);
+ if (!klass)
return NULL;
- mono_class_init (class);
- return mono_class_get_field (class, token);
+ mono_class_init (klass);
+ return mono_class_get_field (klass, token);
}
case MONO_TOKEN_METHOD_DEF:
case MONO_TOKEN_METHOD_SPEC: {
for (i = start_index; i < klass->method.count; ++i) {
guint32 flags;
- /* class->method.first points into the methodptr table */
+ /* klass->method.first points into the methodptr table */
flags = mono_metadata_decode_table_row_col (klass->image, MONO_TABLE_METHOD, klass->method.first + i, MONO_METHOD_FLAGS);
if (flags & METHOD_ATTRIBUTE_VIRTUAL)
MonoMethod *method;
MonoMethodSignature *sig;
- /* class->method.first points into the methodptr table */
+ /* klass->method.first points into the methodptr table */
mono_metadata_decode_table_row (klass->image, MONO_TABLE_METHOD, klass->method.first + i, cols, MONO_METHOD_SIZE);
if (!strcmp (mono_metadata_string_heap (klass->image, cols [MONO_METHOD_NAME]), name)) {
if (res) {
MonoError error;
res = mono_class_inflate_generic_method_full_checked (res, klass, mono_class_get_context (klass), &error);
- g_assert (mono_error_ok (&error)); /*FIXME proper error handling*/
+ if (!mono_error_ok (&error))
+ mono_error_cleanup (&error); /*FIXME don't swallow the error */
}
return res;
}
* LOCKING: Acquires the loader lock.
*/
void
-mono_class_setup_interface_id (MonoClass *class)
+mono_class_setup_interface_id (MonoClass *klass)
{
mono_loader_lock ();
- if (MONO_CLASS_IS_INTERFACE (class) && !class->interface_id)
- class->interface_id = mono_get_unique_iid (class);
+ if (MONO_CLASS_IS_INTERFACE (klass) && !klass->interface_id)
+ klass->interface_id = mono_get_unique_iid (klass);
mono_loader_unlock ();
}
/*
* mono_class_setup_interfaces:
*
- * Initialize class->interfaces/interfaces_count.
+ * Initialize klass->interfaces/interfaces_count.
* LOCKING: Acquires the loader lock.
* This function can fail the type.
*/
static void
mono_field_resolve_type (MonoClassField *field, MonoError *error)
{
- MonoClass *class = field->parent;
- MonoImage *image = class->image;
- MonoClass *gtd = class->generic_class ? mono_class_get_generic_type_definition (class) : NULL;
- int field_idx = field - class->fields;
+ MonoClass *klass = field->parent;
+ MonoImage *image = klass->image;
+ MonoClass *gtd = klass->generic_class ? mono_class_get_generic_type_definition (klass) : NULL;
+ int field_idx = field - klass->fields;
mono_error_init (error);
MonoType *gtype = mono_field_get_type_checked (gfield, error);
if (!mono_error_ok (error)) {
char *err_msg = g_strdup_printf ("Could not load field %d type due to: %s", field_idx, mono_error_get_message (error));
- mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, err_msg);
+ mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, err_msg);
g_free (err_msg);
}
- field->type = mono_class_inflate_generic_type_no_copy (image, gtype, mono_class_get_context (class), error);
+ field->type = mono_class_inflate_generic_type_no_copy (image, gtype, mono_class_get_context (klass), error);
if (!mono_error_ok (error)) {
char *err_msg = g_strdup_printf ("Could not load field %d type due to: %s", field_idx, mono_error_get_message (error));
- mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, err_msg);
+ mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, err_msg);
g_free (err_msg);
}
} else {
const char *sig;
guint32 cols [MONO_FIELD_SIZE];
MonoGenericContainer *container = NULL;
- int idx = class->field.first + field_idx;
+ int idx = klass->field.first + field_idx;
/*FIXME, in theory we do not lazy load SRE fields*/
g_assert (!image_is_dynamic (image));
- if (class->generic_container) {
- container = class->generic_container;
+ if (klass->generic_container) {
+ container = klass->generic_container;
} else if (gtd) {
container = gtd->generic_container;
g_assert (container);
}
- /* class->field.first and idx points into the fieldptr table */
+ /* klass->field.first and idx points into the fieldptr table */
mono_metadata_decode_table_row (image, MONO_TABLE_FIELD, idx, cols, MONO_FIELD_SIZE);
if (!mono_verifier_verify_field_signature (image, cols [MONO_FIELD_SIGNATURE], NULL)) {
- mono_error_set_type_load_class (error, class, "Could not verify field %s signature", field->name);
- mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, NULL);
+ mono_error_set_type_load_class (error, klass, "Could not verify field %s signature", field->name);
+ mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, NULL);
return;
}
g_assert (*sig == 0x06);
field->type = mono_metadata_parse_type_full (image, container, cols [MONO_FIELD_FLAGS], sig + 1, &sig);
if (!field->type)
- mono_class_set_failure_from_loader_error (class, error, g_strdup_printf ("Could not load field %s type", field->name));
+ mono_class_set_failure_from_loader_error (klass, error, g_strdup_printf ("Could not load field %s type", field->name));
}
}
static guint32
mono_field_resolve_flags (MonoClassField *field)
{
- MonoClass *class = field->parent;
- MonoImage *image = class->image;
- MonoClass *gtd = class->generic_class ? mono_class_get_generic_type_definition (class) : NULL;
- int field_idx = field - class->fields;
+ MonoClass *klass = field->parent;
+ MonoImage *image = klass->image;
+ MonoClass *gtd = klass->generic_class ? mono_class_get_generic_type_definition (klass) : NULL;
+ int field_idx = field - klass->fields;
if (gtd) {
MonoClassField *gfield = >d->fields [field_idx];
return mono_field_get_flags (gfield);
} else {
- int idx = class->field.first + field_idx;
+ int idx = klass->field.first + field_idx;
/*FIXME, in theory we do not lazy load SRE fields*/
g_assert (!image_is_dynamic (image));
* mono_class_setup_basic_field_info:
* @class: The class to initialize
*
- * Initializes the class->fields array of fields.
+ * Initializes the klass->fields array of fields.
* Aquires the loader lock.
*/
static void
-mono_class_setup_basic_field_info_locking (MonoClass *class)
+mono_class_setup_basic_field_info_locking (MonoClass *klass)
{
mono_loader_lock ();
- mono_class_setup_basic_field_info (class);
+ mono_class_setup_basic_field_info (klass);
mono_loader_unlock ();
}
#include "mono/metadata/monitor.h"
#include "mono/metadata/metadata-internals.h"
#include "mono/metadata/domain-internals.h"
-#include "mono/metadata/gc-internal.h"
+#include "mono/metadata/gc-internals.h"
#include "mono/metadata/threads-types.h"
#include "mono/metadata/string-icalls.h"
#include "mono/metadata/attrdefs.h"
-#include "mono/metadata/gc-internal.h"
+#include "mono/metadata/gc-internals.h"
#include "mono/utils/mono-counters.h"
#include "mono/utils/strenc.h"
#include "mono/utils/atomic.h"
ves_icall_System_ComObject_GetInterfaceInternal (MonoComObject* obj, MonoReflectionType* type, MonoBoolean throw_exception)
{
#ifndef DISABLE_COM
- MonoClass *class = mono_type_get_class (type->type);
- if (!mono_class_init (class)) {
- mono_set_pending_exception (mono_class_get_exception_for_failure (class));
+ MonoClass *klass = mono_type_get_class (type->type);
+ if (!mono_class_init (klass)) {
+ mono_set_pending_exception (mono_class_get_exception_for_failure (klass));
return NULL;
}
- return cominterop_get_interface (obj, class, (gboolean)throw_exception);
+ return cominterop_get_interface (obj, klass, (gboolean)throw_exception);
#else
g_assert_not_reached ();
#endif
#include <mono/metadata/object-internals.h>
#include <mono/metadata/class-internals.h>
#include <mono/metadata/domain-internals.h>
-#include <mono/metadata/gc-internal.h>
+#include <mono/metadata/gc-internals.h>
#include <mono/metadata/console-io.h>
#include <mono/metadata/exception.h>
#include <mono/metadata/object-internals.h>
#include <mono/metadata/class-internals.h>
#include <mono/metadata/domain-internals.h>
-#include <mono/metadata/gc-internal.h>
+#include <mono/metadata/gc-internals.h>
#include <mono/metadata/metadata.h>
#include <mono/metadata/threadpool-ms.h>
#include <mono/utils/mono-signal-handler.h>
#include <mono/metadata/object-internals.h>
#include <mono/metadata/class-internals.h>
#include <mono/metadata/domain-internals.h>
-#include <mono/metadata/gc-internal.h>
+#include <mono/metadata/gc-internals.h>
#include <mono/metadata/metadata.h>
#include <mono/metadata/console-io.h>
#endif
static void
-append_class_name (GString *res, MonoClass *class, gboolean include_namespace)
+append_class_name (GString *res, MonoClass *klass, gboolean include_namespace)
{
- if (!class) {
+ if (!klass) {
g_string_append (res, "Unknown");
return;
}
- if (class->nested_in) {
- append_class_name (res, class->nested_in, include_namespace);
+ if (klass->nested_in) {
+ append_class_name (res, klass->nested_in, include_namespace);
g_string_append_c (res, '/');
}
- if (include_namespace && *(class->name_space)) {
- g_string_append (res, class->name_space);
+ if (include_namespace && *(klass->name_space)) {
+ g_string_append (res, klass->name_space);
g_string_append_c (res, '.');
}
- g_string_append (res, class->name);
+ g_string_append (res, klass->name);
}
static MonoClass*
}
static void
-objval_describe (MonoClass *class, const char *addr)
+objval_describe (MonoClass *klass, const char *addr)
{
MonoClassField *field;
MonoClass *p;
const char *field_ptr;
gssize type_offset = 0;
- if (class->valuetype)
+
+ if (klass->valuetype)
type_offset = -sizeof (MonoObject);
- for (p = class; p != NULL; p = p->parent) {
+ for (p = klass; p != NULL; p = p->parent) {
gpointer iter = NULL;
int printed_header = FALSE;
while ((field = mono_class_get_fields (p, &iter))) {
if (field->type->attrs & (FIELD_ATTRIBUTE_STATIC | FIELD_ATTRIBUTE_HAS_FIELD_RVA))
continue;
- if (p != class && !printed_header) {
+ if (p != klass && !printed_header) {
const char *sep;
g_print ("In class ");
sep = print_name_space (p);
void
mono_object_describe_fields (MonoObject *obj)
{
- MonoClass *class = mono_object_class (obj);
- objval_describe (class, (char*)obj);
+ MonoClass *klass = mono_object_class (obj);
+ objval_describe (klass, (char*)obj);
}
/**
#include <string.h>
#include <sys/stat.h>
-#include <mono/metadata/gc-internal.h>
+#include <mono/metadata/gc-internals.h>
#include <mono/utils/atomic.h>
#include <mono/utils/mono-compiler.h>
-#include <mono/utils/mono-logger-internal.h>
+#include <mono/utils/mono-logger-internals.h>
#include <mono/utils/mono-membar.h>
#include <mono/utils/mono-counters.h>
#include <mono/utils/hazard-pointer.h>
#include <mono/metadata/assembly.h>
#include <mono/metadata/exception.h>
#include <mono/metadata/metadata-internals.h>
-#include <mono/metadata/gc-internal.h>
+#include <mono/metadata/gc-internals.h>
#include <mono/metadata/appdomain.h>
#include <mono/metadata/mono-debug-debugger.h>
#include <mono/metadata/mono-config.h>
}
#endif
+
+void _wapi_handle_dump (void);
+
+void ves_icall_System_IO_MonoIO_DumpHandles (void)
+{
+#ifndef HOST_WIN32
+ _wapi_handle_dump ();
+#endif
+}
extern gint64
mono_filesize_from_fd (int fd);
+void
+ves_icall_System_IO_MonoIO_DumpHandles (void);
+
G_END_DECLS
#endif /* _MONO_METADATA_FILEIO_H_ */
+++ /dev/null
-/*
- * metadata/gc-internal.h: Internal GC interface
- *
- * Author: Paolo Molaro <lupus@ximian.com>
- *
- * (C) 2002 Ximian, Inc.
- * Copyright 2012 Xamarin Inc (http://www.xamarin.com)
- */
-
-#ifndef __MONO_METADATA_GC_INTERNAL_H__
-#define __MONO_METADATA_GC_INTERNAL_H__
-
-#include <glib.h>
-#include <mono/utils/gc_wrapper.h>
-#include <mono/metadata/object-internals.h>
-#include <mono/metadata/threads-types.h>
-#include <mono/sgen/gc-internal-agnostic.h>
-#include <mono/utils/gc_wrapper.h>
-
-#define mono_domain_finalizers_lock(domain) mono_mutex_lock (&(domain)->finalizable_objects_hash_lock);
-#define mono_domain_finalizers_unlock(domain) mono_mutex_unlock (&(domain)->finalizable_objects_hash_lock);
-
-/* Register a memory area as a conservatively scanned GC root */
-#define MONO_GC_REGISTER_ROOT_PINNING(x,src,msg) mono_gc_register_root ((char*)&(x), sizeof(x), MONO_GC_DESCRIPTOR_NULL, (src), (msg))
-
-#define MONO_GC_UNREGISTER_ROOT(x) mono_gc_deregister_root ((char*)&(x))
-
-/*
- * Register a memory location as a root pointing to memory allocated using
- * mono_gc_alloc_fixed (). This includes MonoGHashTable.
- */
-/* The result of alloc_fixed () is not GC tracked memory */
-#define MONO_GC_REGISTER_ROOT_FIXED(x,src,msg) do { \
- if (!mono_gc_is_moving ()) \
- MONO_GC_REGISTER_ROOT_PINNING ((x),(src),(msg)); \
- } while (0)
-
-/*
- * Return a GC descriptor for an array containing N pointers to memory allocated
- * by mono_gc_alloc_fixed ().
- */
-/* For SGEN, the result of alloc_fixed () is not GC tracked memory */
-#define MONO_GC_ROOT_DESCR_FOR_FIXED(n) (mono_gc_is_moving () ? mono_gc_make_root_descr_all_refs (0) : MONO_GC_DESCRIPTOR_NULL)
-
-/* Register a memory location holding a single object reference as a GC root */
-#define MONO_GC_REGISTER_ROOT_SINGLE(x,src,msg) do { \
- g_assert (sizeof (x) == sizeof (MonoObject*)); \
- mono_gc_register_root ((char*)&(x), sizeof(MonoObject*), mono_gc_make_root_descr_all_refs (1), (src), (msg)); \
- } while (0)
-
-/*
- * This is used for fields which point to objects which are kept alive by other references
- * when using Boehm.
- */
-#define MONO_GC_REGISTER_ROOT_IF_MOVING(x,src,msg) do { \
- if (mono_gc_is_moving ()) \
- MONO_GC_REGISTER_ROOT_SINGLE(x,src,msg); \
-} while (0)
-
-#define MONO_GC_UNREGISTER_ROOT_IF_MOVING(x) do { \
- if (mono_gc_is_moving ()) \
- MONO_GC_UNREGISTER_ROOT (x); \
-} while (0)
-
-/* useful until we keep track of gc-references in corlib etc. */
-#define IS_GC_REFERENCE(class,t) (mono_gc_is_moving () ? FALSE : ((t)->type == MONO_TYPE_U && (class)->image == mono_defaults.corlib))
-
-void mono_object_register_finalizer (MonoObject *obj);
-void ves_icall_System_GC_InternalCollect (int generation);
-gint64 ves_icall_System_GC_GetTotalMemory (MonoBoolean forceCollection);
-void ves_icall_System_GC_KeepAlive (MonoObject *obj);
-void ves_icall_System_GC_ReRegisterForFinalize (MonoObject *obj);
-void ves_icall_System_GC_SuppressFinalize (MonoObject *obj);
-void ves_icall_System_GC_WaitForPendingFinalizers (void);
-
-MonoObject *ves_icall_System_GCHandle_GetTarget (guint32 handle);
-guint32 ves_icall_System_GCHandle_GetTargetHandle (MonoObject *obj, guint32 handle, gint32 type);
-void ves_icall_System_GCHandle_FreeHandle (guint32 handle);
-gpointer ves_icall_System_GCHandle_GetAddrOfPinnedObject (guint32 handle);
-void ves_icall_System_GC_register_ephemeron_array (MonoObject *array);
-MonoObject *ves_icall_System_GC_get_ephemeron_tombstone (void);
-
-MonoBoolean ves_icall_Mono_Runtime_SetGCAllowSynchronousMajor (MonoBoolean flag);
-
-extern void mono_gc_init (void);
-extern void mono_gc_base_init (void);
-extern void mono_gc_cleanup (void);
-extern void mono_gc_base_cleanup (void);
-
-/*
- * Return whenever the current thread is registered with the GC (i.e. started
- * by the GC pthread wrappers on unix.
- */
-extern gboolean mono_gc_is_gc_thread (void);
-
-extern gboolean mono_gc_is_finalizer_internal_thread (MonoInternalThread *thread);
-
-extern void mono_gc_set_stack_end (void *stack_end);
-
-/* only valid after the RECLAIM_START GC event and before RECLAIM_END
- * Not exported in public headers, but can be linked to (unsupported).
- */
-gboolean mono_object_is_alive (MonoObject* obj);
-gboolean mono_gc_is_finalizer_thread (MonoThread *thread);
-gpointer mono_gc_out_of_memory (size_t size);
-void mono_gc_enable_events (void);
-void mono_gc_enable_alloc_events (void);
-
-void mono_gchandle_set_target (guint32 gchandle, MonoObject *obj);
-
-/*Ephemeron functionality. Sgen only*/
-gboolean mono_gc_ephemeron_array_add (MonoObject *obj);
-
-/* To disable synchronous, evacuating collections - concurrent SGen only */
-gboolean mono_gc_set_allow_synchronous_major (gboolean flag);
-
-MonoBoolean
-mono_gc_GCHandle_CheckCurrentDomain (guint32 gchandle);
-
-/* User defined marking function */
-/* It should work like this:
- * foreach (ref in GC references in the are structure pointed to by ADDR)
- * mark_func (ref)
- */
-typedef void (*MonoGCMarkFunc) (MonoObject **addr, void *gc_data);
-typedef void (*MonoGCRootMarkFunc) (void *addr, MonoGCMarkFunc mark_func, void *gc_data);
-
-/* Create a descriptor with a user defined marking function */
-MonoGCDescriptor mono_gc_make_root_descr_user (MonoGCRootMarkFunc marker);
-
-/* Return whenever user defined marking functions are supported */
-gboolean mono_gc_user_markers_supported (void);
-
-/* desc is the result from mono_gc_make_descr*. A NULL value means
- * all the words might contain GC pointers.
- * The memory is non-moving and it will be explicitly deallocated.
- * size bytes will be available from the returned address (ie, descr
- * must not be stored in the returned memory)
- * NOTE: Under Boehm, this returns memory allocated using GC_malloc, so the result should
- * be stored into a location registered using MONO_GC_REGISTER_ROOT_FIXED ().
- */
-void* mono_gc_alloc_fixed (size_t size, MonoGCDescriptor descr, MonoGCRootSource source, const char *msg);
-void mono_gc_free_fixed (void* addr);
-
-/* make sure the gchandle was allocated for an object in domain */
-gboolean mono_gchandle_is_in_domain (guint32 gchandle, MonoDomain *domain);
-void mono_gchandle_free_domain (MonoDomain *domain);
-
-typedef void (*FinalizerThreadCallback) (gpointer user_data);
-
-/* if there are finalizers to run, run them. Returns the number of finalizers run */
-gboolean mono_gc_pending_finalizers (void);
-void mono_gc_finalize_notify (void);
-
-void* mono_gc_alloc_pinned_obj (MonoVTable *vtable, size_t size);
-void* mono_gc_alloc_obj (MonoVTable *vtable, size_t size);
-void* mono_gc_alloc_vector (MonoVTable *vtable, size_t size, uintptr_t max_length);
-void* mono_gc_alloc_array (MonoVTable *vtable, size_t size, uintptr_t max_length, uintptr_t bounds_size);
-void* mono_gc_alloc_string (MonoVTable *vtable, size_t size, gint32 len);
-MonoGCDescriptor mono_gc_make_descr_for_string (gsize *bitmap, int numbits);
-
-void mono_gc_register_for_finalization (MonoObject *obj, void *user_data);
-void mono_gc_add_memory_pressure (gint64 value);
-MONO_API int mono_gc_register_root (char *start, size_t size, MonoGCDescriptor descr, MonoGCRootSource source, const char *msg);
-void mono_gc_deregister_root (char* addr);
-int mono_gc_finalizers_for_domain (MonoDomain *domain, MonoObject **out_array, int out_size);
-void mono_gc_run_finalize (void *obj, void *data);
-void mono_gc_clear_domain (MonoDomain * domain);
-void* mono_gc_alloc_mature (MonoVTable *vtable);
-
-/*
- * Register a root which can only be written using a write barrier.
- * Writes to the root must be done using a write barrier (MONO_ROOT_SETREF).
- * If the root uses an user defined mark routine, the writes are not required to be
- * to the area between START and START+SIZE.
- * The write barrier allows the GC to avoid scanning this root at each collection, so it
- * is more efficient.
- * FIXME: Add an API for clearing remset entries if a root with a user defined
- * mark routine is deleted.
- */
-int mono_gc_register_root_wbarrier (char *start, size_t size, MonoGCDescriptor descr, MonoGCRootSource source, const char *msg);
-
-void mono_gc_wbarrier_set_root (gpointer ptr, MonoObject *value);
-
-/* Set a field of a root registered using mono_gc_register_root_wbarrier () */
-#define MONO_ROOT_SETREF(s,fieldname,value) do { \
- mono_gc_wbarrier_set_root (&((s)->fieldname), (MonoObject*)value); \
-} while (0)
-
-void mono_gc_finalize_threadpool_threads (void);
-
-/* fast allocation support */
-
-/* Accessible using mono_marshal_wrapper_info_from_wrapper () */
-typedef struct {
- const char *gc_name;
- int alloc_type;
-} AllocatorWrapperInfo;
-
-int mono_gc_get_aligned_size_for_allocator (int size);
-MonoMethod* mono_gc_get_managed_allocator (MonoClass *klass, gboolean for_box, gboolean known_instance_size);
-MonoMethod* mono_gc_get_managed_array_allocator (MonoClass *klass);
-MonoMethod *mono_gc_get_managed_allocator_by_type (int atype, gboolean slowpath);
-
-guint32 mono_gc_get_managed_allocator_types (void);
-
-/* Return a short string identifying the GC, indented to be saved in AOT images */
-const char *mono_gc_get_gc_name (void);
-
-/* Fast write barriers */
-MonoMethod* mono_gc_get_specific_write_barrier (gboolean is_concurrent);
-MonoMethod* mono_gc_get_write_barrier (void);
-
-/* Fast valuetype copy */
-void mono_gc_wbarrier_value_copy_bitmap (gpointer dest, gpointer src, int size, unsigned bitmap);
-
-/* helper for the managed alloc support */
-MonoString *mono_string_alloc (int length);
-
-/*
- * Functions supplied by the runtime and called by the GC. Currently only used
- * by SGEN.
- */
-typedef struct {
- /*
- * Function called during thread startup/attach to allocate thread-local data
- * needed by the other functions.
- */
- gpointer (*thread_attach_func) (void);
- /*
- * Function called during thread deatch to free the data allocated by
- * thread_attach_func.
- */
- void (*thread_detach_func) (gpointer user_data);
- /*
- * Function called from every thread when suspending for GC. It can save
- * data needed for marking from thread stacks. user_data is the data returned
- * by attach_func. This might called with GC locks held and the word stopped,
- * so it shouldn't do any synchronization etc.
- */
- void (*thread_suspend_func) (gpointer user_data, void *sigcontext, MonoContext *ctx);
- /*
- * Function called to mark from thread stacks. user_data is the data returned
- * by attach_func. This is called twice, with the word stopped:
- * - in the first pass, it should mark areas of the stack using
- * conservative marking by calling mono_gc_conservatively_scan_area ().
- * - in the second pass, it should mark the remaining areas of the stack
- * using precise marking by calling mono_gc_scan_object ().
- */
- void (*thread_mark_func) (gpointer user_data, guint8 *stack_start, guint8 *stack_end, gboolean precise, void *gc_data);
- /*
- * Function called for debugging to get the current managed method for
- * tracking the provenances of objects.
- */
- gpointer (*get_provenance_func) (void);
-} MonoGCCallbacks;
-
-/* Set the callback functions callable by the GC */
-void mono_gc_set_gc_callbacks (MonoGCCallbacks *callbacks);
-MonoGCCallbacks *mono_gc_get_gc_callbacks (void);
-
-/* Functions callable from the thread mark func */
-
-/* Scan the memory area between START and END conservatively */
-void mono_gc_conservatively_scan_area (void *start, void *end);
-
-/* Scan OBJ, returning its new address */
-void *mono_gc_scan_object (void *obj, void *gc_data);
-
-/* Return the suspend signal number used by the GC to suspend threads,
- or -1 if not applicable. */
-int mono_gc_get_suspend_signal (void);
-
-/* Return the suspend signal number used by the GC to suspend threads,
- or -1 if not applicable. */
-int mono_gc_get_restart_signal (void);
-
-/*
- * Return a human readable description of the GC in malloc-ed memory.
- */
-char* mono_gc_get_description (void);
-
-/*
- * Configure the GC to desktop mode
- */
-void mono_gc_set_desktop_mode (void);
-
-/*
- * Return whenever this GC can move objects
- */
-gboolean mono_gc_is_moving (void);
-
-typedef void* (*MonoGCLockedCallbackFunc) (void *data);
-
-void* mono_gc_invoke_with_gc_lock (MonoGCLockedCallbackFunc func, void *data);
-
-int mono_gc_get_los_limit (void);
-
-guint8* mono_gc_get_card_table (int *shift_bits, gpointer *card_mask);
-gboolean mono_gc_card_table_nursery_check (void);
-
-void* mono_gc_get_nursery (int *shift_bits, size_t *size);
-
-void mono_gc_set_current_thread_appdomain (MonoDomain *domain);
-
-void mono_gc_set_skip_thread (gboolean skip);
-
-#ifndef HOST_WIN32
-int mono_gc_pthread_create (pthread_t *new_thread, const pthread_attr_t *attr, void *(*start_routine)(void *), void *arg);
-#endif
-
-/*
- * Return whenever GC is disabled
- */
-gboolean mono_gc_is_disabled (void);
-
-/*
- * Return whenever this is the null GC
- */
-gboolean mono_gc_is_null (void);
-
-void mono_gc_set_string_length (MonoString *str, gint32 new_length);
-
-#if defined(__MACH__)
-void mono_gc_register_mach_exception_thread (pthread_t thread);
-pthread_t mono_gc_get_mach_exception_thread (void);
-#endif
-
-gboolean mono_gc_precise_stack_mark_enabled (void);
-
-typedef struct _RefQueueEntry RefQueueEntry;
-
-struct _RefQueueEntry {
- void *dis_link;
- guint32 gchandle;
- MonoDomain *domain;
- void *user_data;
- RefQueueEntry *next;
-};
-
-struct _MonoReferenceQueue {
- RefQueueEntry *queue;
- mono_reference_queue_callback callback;
- MonoReferenceQueue *next;
- gboolean should_be_deleted;
-};
-
-enum {
- MONO_GC_FINALIZER_EXTENSION_VERSION = 1,
-};
-
-typedef struct {
- int version;
- gboolean (*is_class_finalization_aware) (MonoClass *klass);
- void (*object_queued_for_finalization) (MonoObject *object);
-} MonoGCFinalizerCallbacks;
-
-MONO_API void mono_gc_register_finalizer_callbacks (MonoGCFinalizerCallbacks *callbacks);
-
-
-#ifdef HOST_WIN32
-BOOL APIENTRY mono_gc_dllmain (HMODULE module_handle, DWORD reason, LPVOID reserved);
-#endif
-
-guint mono_gc_get_vtable_bits (MonoClass *klass);
-
-void mono_gc_register_altstack (gpointer stack, gint32 stack_size, gpointer altstack, gint32 altstack_size);
-
-/* If set, print debugging messages around finalizers. */
-extern gboolean log_finalizers;
-
-/* If set, do not run finalizers. */
-extern gboolean do_not_finalize;
-
-#endif /* __MONO_METADATA_GC_INTERNAL_H__ */
-
--- /dev/null
+/*
+ * metadata/gc-internals.h: Internal GC interface
+ *
+ * Author: Paolo Molaro <lupus@ximian.com>
+ *
+ * (C) 2002 Ximian, Inc.
+ * Copyright 2012 Xamarin Inc (http://www.xamarin.com)
+ */
+
+#ifndef __MONO_METADATA_GC_INTERNAL_H__
+#define __MONO_METADATA_GC_INTERNAL_H__
+
+#include <glib.h>
+#include <mono/utils/gc_wrapper.h>
+#include <mono/metadata/object-internals.h>
+#include <mono/metadata/threads-types.h>
+#include <mono/sgen/gc-internal-agnostic.h>
+#include <mono/utils/gc_wrapper.h>
+
+#define mono_domain_finalizers_lock(domain) mono_mutex_lock (&(domain)->finalizable_objects_hash_lock);
+#define mono_domain_finalizers_unlock(domain) mono_mutex_unlock (&(domain)->finalizable_objects_hash_lock);
+
+/* Register a memory area as a conservatively scanned GC root */
+#define MONO_GC_REGISTER_ROOT_PINNING(x,src,msg) mono_gc_register_root ((char*)&(x), sizeof(x), MONO_GC_DESCRIPTOR_NULL, (src), (msg))
+
+#define MONO_GC_UNREGISTER_ROOT(x) mono_gc_deregister_root ((char*)&(x))
+
+/*
+ * Register a memory location as a root pointing to memory allocated using
+ * mono_gc_alloc_fixed (). This includes MonoGHashTable.
+ */
+/* The result of alloc_fixed () is not GC tracked memory */
+#define MONO_GC_REGISTER_ROOT_FIXED(x,src,msg) do { \
+ if (!mono_gc_is_moving ()) \
+ MONO_GC_REGISTER_ROOT_PINNING ((x),(src),(msg)); \
+ } while (0)
+
+/*
+ * Return a GC descriptor for an array containing N pointers to memory allocated
+ * by mono_gc_alloc_fixed ().
+ */
+/* For SGEN, the result of alloc_fixed () is not GC tracked memory */
+#define MONO_GC_ROOT_DESCR_FOR_FIXED(n) (mono_gc_is_moving () ? mono_gc_make_root_descr_all_refs (0) : MONO_GC_DESCRIPTOR_NULL)
+
+/* Register a memory location holding a single object reference as a GC root */
+#define MONO_GC_REGISTER_ROOT_SINGLE(x,src,msg) do { \
+ g_assert (sizeof (x) == sizeof (MonoObject*)); \
+ mono_gc_register_root ((char*)&(x), sizeof(MonoObject*), mono_gc_make_root_descr_all_refs (1), (src), (msg)); \
+ } while (0)
+
+/*
+ * This is used for fields which point to objects which are kept alive by other references
+ * when using Boehm.
+ */
+#define MONO_GC_REGISTER_ROOT_IF_MOVING(x,src,msg) do { \
+ if (mono_gc_is_moving ()) \
+ MONO_GC_REGISTER_ROOT_SINGLE(x,src,msg); \
+} while (0)
+
+#define MONO_GC_UNREGISTER_ROOT_IF_MOVING(x) do { \
+ if (mono_gc_is_moving ()) \
+ MONO_GC_UNREGISTER_ROOT (x); \
+} while (0)
+
+/* useful until we keep track of gc-references in corlib etc. */
+#define IS_GC_REFERENCE(class,t) (mono_gc_is_moving () ? FALSE : ((t)->type == MONO_TYPE_U && (class)->image == mono_defaults.corlib))
+
+void mono_object_register_finalizer (MonoObject *obj);
+void ves_icall_System_GC_InternalCollect (int generation);
+gint64 ves_icall_System_GC_GetTotalMemory (MonoBoolean forceCollection);
+void ves_icall_System_GC_KeepAlive (MonoObject *obj);
+void ves_icall_System_GC_ReRegisterForFinalize (MonoObject *obj);
+void ves_icall_System_GC_SuppressFinalize (MonoObject *obj);
+void ves_icall_System_GC_WaitForPendingFinalizers (void);
+
+MonoObject *ves_icall_System_GCHandle_GetTarget (guint32 handle);
+guint32 ves_icall_System_GCHandle_GetTargetHandle (MonoObject *obj, guint32 handle, gint32 type);
+void ves_icall_System_GCHandle_FreeHandle (guint32 handle);
+gpointer ves_icall_System_GCHandle_GetAddrOfPinnedObject (guint32 handle);
+void ves_icall_System_GC_register_ephemeron_array (MonoObject *array);
+MonoObject *ves_icall_System_GC_get_ephemeron_tombstone (void);
+
+MonoBoolean ves_icall_Mono_Runtime_SetGCAllowSynchronousMajor (MonoBoolean flag);
+
+extern void mono_gc_init (void);
+extern void mono_gc_base_init (void);
+extern void mono_gc_cleanup (void);
+extern void mono_gc_base_cleanup (void);
+
+/*
+ * Return whenever the current thread is registered with the GC (i.e. started
+ * by the GC pthread wrappers on unix.
+ */
+extern gboolean mono_gc_is_gc_thread (void);
+
+extern gboolean mono_gc_is_finalizer_internal_thread (MonoInternalThread *thread);
+
+extern void mono_gc_set_stack_end (void *stack_end);
+
+/* only valid after the RECLAIM_START GC event and before RECLAIM_END
+ * Not exported in public headers, but can be linked to (unsupported).
+ */
+gboolean mono_object_is_alive (MonoObject* obj);
+gboolean mono_gc_is_finalizer_thread (MonoThread *thread);
+gpointer mono_gc_out_of_memory (size_t size);
+void mono_gc_enable_events (void);
+void mono_gc_enable_alloc_events (void);
+
+void mono_gchandle_set_target (guint32 gchandle, MonoObject *obj);
+
+/*Ephemeron functionality. Sgen only*/
+gboolean mono_gc_ephemeron_array_add (MonoObject *obj);
+
+/* To disable synchronous, evacuating collections - concurrent SGen only */
+gboolean mono_gc_set_allow_synchronous_major (gboolean flag);
+
+MonoBoolean
+mono_gc_GCHandle_CheckCurrentDomain (guint32 gchandle);
+
+/* User defined marking function */
+/* It should work like this:
+ * foreach (ref in GC references in the are structure pointed to by ADDR)
+ * mark_func (ref)
+ */
+typedef void (*MonoGCMarkFunc) (MonoObject **addr, void *gc_data);
+typedef void (*MonoGCRootMarkFunc) (void *addr, MonoGCMarkFunc mark_func, void *gc_data);
+
+/* Create a descriptor with a user defined marking function */
+MonoGCDescriptor mono_gc_make_root_descr_user (MonoGCRootMarkFunc marker);
+
+/* Return whenever user defined marking functions are supported */
+gboolean mono_gc_user_markers_supported (void);
+
+/* desc is the result from mono_gc_make_descr*. A NULL value means
+ * all the words might contain GC pointers.
+ * The memory is non-moving and it will be explicitly deallocated.
+ * size bytes will be available from the returned address (ie, descr
+ * must not be stored in the returned memory)
+ * NOTE: Under Boehm, this returns memory allocated using GC_malloc, so the result should
+ * be stored into a location registered using MONO_GC_REGISTER_ROOT_FIXED ().
+ */
+void* mono_gc_alloc_fixed (size_t size, MonoGCDescriptor descr, MonoGCRootSource source, const char *msg);
+void mono_gc_free_fixed (void* addr);
+
+/* make sure the gchandle was allocated for an object in domain */
+gboolean mono_gchandle_is_in_domain (guint32 gchandle, MonoDomain *domain);
+void mono_gchandle_free_domain (MonoDomain *domain);
+
+typedef void (*FinalizerThreadCallback) (gpointer user_data);
+
+/* if there are finalizers to run, run them. Returns the number of finalizers run */
+gboolean mono_gc_pending_finalizers (void);
+void mono_gc_finalize_notify (void);
+
+void* mono_gc_alloc_pinned_obj (MonoVTable *vtable, size_t size);
+void* mono_gc_alloc_obj (MonoVTable *vtable, size_t size);
+void* mono_gc_alloc_vector (MonoVTable *vtable, size_t size, uintptr_t max_length);
+void* mono_gc_alloc_array (MonoVTable *vtable, size_t size, uintptr_t max_length, uintptr_t bounds_size);
+void* mono_gc_alloc_string (MonoVTable *vtable, size_t size, gint32 len);
+MonoGCDescriptor mono_gc_make_descr_for_string (gsize *bitmap, int numbits);
+
+void mono_gc_register_for_finalization (MonoObject *obj, void *user_data);
+void mono_gc_add_memory_pressure (gint64 value);
+MONO_API int mono_gc_register_root (char *start, size_t size, MonoGCDescriptor descr, MonoGCRootSource source, const char *msg);
+void mono_gc_deregister_root (char* addr);
+int mono_gc_finalizers_for_domain (MonoDomain *domain, MonoObject **out_array, int out_size);
+void mono_gc_run_finalize (void *obj, void *data);
+void mono_gc_clear_domain (MonoDomain * domain);
+void* mono_gc_alloc_mature (MonoVTable *vtable);
+
+/*
+ * Register a root which can only be written using a write barrier.
+ * Writes to the root must be done using a write barrier (MONO_ROOT_SETREF).
+ * If the root uses an user defined mark routine, the writes are not required to be
+ * to the area between START and START+SIZE.
+ * The write barrier allows the GC to avoid scanning this root at each collection, so it
+ * is more efficient.
+ * FIXME: Add an API for clearing remset entries if a root with a user defined
+ * mark routine is deleted.
+ */
+int mono_gc_register_root_wbarrier (char *start, size_t size, MonoGCDescriptor descr, MonoGCRootSource source, const char *msg);
+
+void mono_gc_wbarrier_set_root (gpointer ptr, MonoObject *value);
+
+/* Set a field of a root registered using mono_gc_register_root_wbarrier () */
+#define MONO_ROOT_SETREF(s,fieldname,value) do { \
+ mono_gc_wbarrier_set_root (&((s)->fieldname), (MonoObject*)value); \
+} while (0)
+
+void mono_gc_finalize_threadpool_threads (void);
+
+/* fast allocation support */
+
+int mono_gc_get_aligned_size_for_allocator (int size);
+MonoMethod* mono_gc_get_managed_allocator (MonoClass *klass, gboolean for_box, gboolean known_instance_size);
+MonoMethod* mono_gc_get_managed_array_allocator (MonoClass *klass);
+MonoMethod *mono_gc_get_managed_allocator_by_type (int atype, gboolean slowpath);
+
+guint32 mono_gc_get_managed_allocator_types (void);
+
+/* Return a short string identifying the GC, indented to be saved in AOT images */
+const char *mono_gc_get_gc_name (void);
+
+/* Fast write barriers */
+MonoMethod* mono_gc_get_specific_write_barrier (gboolean is_concurrent);
+MonoMethod* mono_gc_get_write_barrier (void);
+
+/* Fast valuetype copy */
+void mono_gc_wbarrier_value_copy_bitmap (gpointer dest, gpointer src, int size, unsigned bitmap);
+
+/* helper for the managed alloc support */
+MonoString *mono_string_alloc (int length);
+
+/*
+ * Functions supplied by the runtime and called by the GC. Currently only used
+ * by SGEN.
+ */
+typedef struct {
+ /*
+ * Function called during thread startup/attach to allocate thread-local data
+ * needed by the other functions.
+ */
+ gpointer (*thread_attach_func) (void);
+ /*
+ * Function called during thread deatch to free the data allocated by
+ * thread_attach_func.
+ */
+ void (*thread_detach_func) (gpointer user_data);
+ /*
+ * Function called from every thread when suspending for GC. It can save
+ * data needed for marking from thread stacks. user_data is the data returned
+ * by attach_func. This might called with GC locks held and the word stopped,
+ * so it shouldn't do any synchronization etc.
+ */
+ void (*thread_suspend_func) (gpointer user_data, void *sigcontext, MonoContext *ctx);
+ /*
+ * Function called to mark from thread stacks. user_data is the data returned
+ * by attach_func. This is called twice, with the word stopped:
+ * - in the first pass, it should mark areas of the stack using
+ * conservative marking by calling mono_gc_conservatively_scan_area ().
+ * - in the second pass, it should mark the remaining areas of the stack
+ * using precise marking by calling mono_gc_scan_object ().
+ */
+ void (*thread_mark_func) (gpointer user_data, guint8 *stack_start, guint8 *stack_end, gboolean precise, void *gc_data);
+ /*
+ * Function called for debugging to get the current managed method for
+ * tracking the provenances of objects.
+ */
+ gpointer (*get_provenance_func) (void);
+} MonoGCCallbacks;
+
+/* Set the callback functions callable by the GC */
+void mono_gc_set_gc_callbacks (MonoGCCallbacks *callbacks);
+MonoGCCallbacks *mono_gc_get_gc_callbacks (void);
+
+/* Functions callable from the thread mark func */
+
+/* Scan the memory area between START and END conservatively */
+void mono_gc_conservatively_scan_area (void *start, void *end);
+
+/* Scan OBJ, returning its new address */
+void *mono_gc_scan_object (void *obj, void *gc_data);
+
+/* Return the suspend signal number used by the GC to suspend threads,
+ or -1 if not applicable. */
+int mono_gc_get_suspend_signal (void);
+
+/* Return the suspend signal number used by the GC to suspend threads,
+ or -1 if not applicable. */
+int mono_gc_get_restart_signal (void);
+
+/*
+ * Return a human readable description of the GC in malloc-ed memory.
+ */
+char* mono_gc_get_description (void);
+
+/*
+ * Configure the GC to desktop mode
+ */
+void mono_gc_set_desktop_mode (void);
+
+/*
+ * Return whenever this GC can move objects
+ */
+gboolean mono_gc_is_moving (void);
+
+typedef void* (*MonoGCLockedCallbackFunc) (void *data);
+
+void* mono_gc_invoke_with_gc_lock (MonoGCLockedCallbackFunc func, void *data);
+
+int mono_gc_get_los_limit (void);
+
+guint8* mono_gc_get_card_table (int *shift_bits, gpointer *card_mask);
+gboolean mono_gc_card_table_nursery_check (void);
+
+void* mono_gc_get_nursery (int *shift_bits, size_t *size);
+
+void mono_gc_set_current_thread_appdomain (MonoDomain *domain);
+
+void mono_gc_set_skip_thread (gboolean skip);
+
+#ifndef HOST_WIN32
+int mono_gc_pthread_create (pthread_t *new_thread, const pthread_attr_t *attr, void *(*start_routine)(void *), void *arg);
+#endif
+
+/*
+ * Return whenever GC is disabled
+ */
+gboolean mono_gc_is_disabled (void);
+
+/*
+ * Return whenever this is the null GC
+ */
+gboolean mono_gc_is_null (void);
+
+void mono_gc_set_string_length (MonoString *str, gint32 new_length);
+
+#if defined(__MACH__)
+void mono_gc_register_mach_exception_thread (pthread_t thread);
+pthread_t mono_gc_get_mach_exception_thread (void);
+#endif
+
+gboolean mono_gc_precise_stack_mark_enabled (void);
+
+typedef struct _RefQueueEntry RefQueueEntry;
+
+struct _RefQueueEntry {
+ void *dis_link;
+ guint32 gchandle;
+ MonoDomain *domain;
+ void *user_data;
+ RefQueueEntry *next;
+};
+
+struct _MonoReferenceQueue {
+ RefQueueEntry *queue;
+ mono_reference_queue_callback callback;
+ MonoReferenceQueue *next;
+ gboolean should_be_deleted;
+};
+
+enum {
+ MONO_GC_FINALIZER_EXTENSION_VERSION = 1,
+};
+
+typedef struct {
+ int version;
+ gboolean (*is_class_finalization_aware) (MonoClass *klass);
+ void (*object_queued_for_finalization) (MonoObject *object);
+} MonoGCFinalizerCallbacks;
+
+MONO_API void mono_gc_register_finalizer_callbacks (MonoGCFinalizerCallbacks *callbacks);
+
+
+#ifdef HOST_WIN32
+BOOL APIENTRY mono_gc_dllmain (HMODULE module_handle, DWORD reason, LPVOID reserved);
+#endif
+
+guint mono_gc_get_vtable_bits (MonoClass *klass);
+
+void mono_gc_register_altstack (gpointer stack, gint32 stack_size, gpointer altstack, gint32 altstack_size);
+
+/* If set, print debugging messages around finalizers. */
+extern gboolean log_finalizers;
+
+/* If set, do not run finalizers. */
+extern gboolean mono_do_not_finalize;
+/* List of names of classes not to finalize. */
+extern gchar **mono_do_not_finalize_class_names;
+
+#endif /* __MONO_METADATA_GC_INTERNAL_H__ */
+
#include <glib.h>
#include <string.h>
-#include <mono/metadata/gc-internal.h>
+#include <mono/metadata/gc-internals.h>
#include <mono/metadata/mono-gc.h>
#include <mono/metadata/threads.h>
#include <mono/metadata/tabledefs.h>
#include <mono/metadata/threadpool-ms.h>
#include <mono/sgen/sgen-conf.h>
#include <mono/sgen/sgen-gc.h>
-#include <mono/utils/mono-logger-internal.h>
-#include <mono/metadata/gc-internal.h>
+#include <mono/utils/mono-logger-internals.h>
+#include <mono/metadata/gc-internals.h>
#include <mono/metadata/marshal.h> /* for mono_delegate_free_ftnptr () */
#include <mono/metadata/attach.h>
#include <mono/metadata/console-io.h>
static gboolean finalizing_root_domain = FALSE;
gboolean log_finalizers = FALSE;
-gboolean do_not_finalize = FALSE;
+gboolean mono_do_not_finalize = FALSE;
+gchar **mono_do_not_finalize_class_names = NULL;
#define mono_finalizer_lock() mono_mutex_lock (&finalizer_mutex)
#define mono_finalizer_unlock() mono_mutex_unlock (&finalizer_mutex)
void
mono_gc_run_finalize (void *obj, void *data)
{
- if (do_not_finalize)
- return;
-
MonoObject *exc = NULL;
MonoObject *o;
#ifndef HAVE_SGEN_GC
o = (MonoObject*)((char*)obj + GPOINTER_TO_UINT (data));
+ if (mono_do_not_finalize) {
+ if (!mono_do_not_finalize_class_names)
+ return;
+
+ size_t namespace_len = strlen (o->vtable->klass->name_space);
+ for (int i = 0; mono_do_not_finalize_class_names [i]; ++i) {
+ const char *name = mono_do_not_finalize_class_names [i];
+ if (strncmp (name, o->vtable->klass->name_space, namespace_len))
+ break;
+ if (name [namespace_len] != '.')
+ break;
+ if (strcmp (name + namespace_len + 1, o->vtable->klass->name))
+ break;
+ return;
+ }
+ }
+
if (log_finalizers)
g_log ("mono-gc-finalizers", G_LOG_LEVEL_DEBUG, "<%s at %p> Starting finalizer checks.", o->vtable->klass->name, o);
ICALL(MONOIO_4, "CreatePipe", ves_icall_System_IO_MonoIO_CreatePipe)
ICALL(MONOIO_5, "DeleteFile(string,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_DeleteFile)
#endif /* !PLATFORM_RO_FS */
+ICALL(MONOIO_38, "DumpHandles", ves_icall_System_IO_MonoIO_DumpHandles)
ICALL(MONOIO_34, "DuplicateHandle", ves_icall_System_IO_MonoIO_DuplicateHandle)
ICALL(MONOIO_37, "FindClose", ves_icall_System_IO_MonoIO_FindClose)
ICALL(MONOIO_35, "FindFirst", ves_icall_System_IO_MonoIO_FindFirst)
#include <mono/metadata/class-internals.h>
#include <mono/metadata/reflection-internals.h>
#include <mono/metadata/marshal.h>
-#include <mono/metadata/gc-internal.h>
+#include <mono/metadata/gc-internals.h>
#include <mono/metadata/mono-gc.h>
#include <mono/metadata/rand.h>
#include <mono/metadata/sysmath.h>
ves_icall_Type_GetInterfaces (MonoReflectionType* type)
{
MonoError error;
- MonoClass *class = mono_class_from_mono_type (type->type);
+ MonoClass *klass = mono_class_from_mono_type (type->type);
MonoClass *parent;
FillIfaceArrayData data = { 0 };
int len;
GHashTable *iface_hash = g_hash_table_new (get_interfaces_hash, NULL);
- if (class->generic_class && class->generic_class->context.class_inst->is_open) {
- data.context = mono_class_get_context (class);
- class = class->generic_class->container_class;
+ if (klass->generic_class && klass->generic_class->context.class_inst->is_open) {
+ data.context = mono_class_get_context (klass);
+ klass = klass->generic_class->container_class;
}
- for (parent = class; parent; parent = parent->parent) {
+ for (parent = klass; parent; parent = parent->parent) {
mono_class_setup_interfaces (parent, &error);
if (!mono_error_ok (&error))
goto fail;
ves_icall_Type_GetInterfaceMapData (MonoReflectionType *type, MonoReflectionType *iface, MonoArray **targets, MonoArray **methods)
{
gboolean variance_used;
- MonoClass *class = mono_class_from_mono_type (type->type);
+ MonoClass *klass = mono_class_from_mono_type (type->type);
MonoClass *iclass = mono_class_from_mono_type (iface->type);
MonoReflectionMethod *member;
MonoMethod* method;
int i = 0, len, ioffset;
MonoDomain *domain;
- mono_class_init_or_throw (class);
+ mono_class_init_or_throw (klass);
mono_class_init_or_throw (iclass);
- mono_class_setup_vtable (class);
+ mono_class_setup_vtable (klass);
- ioffset = mono_class_interface_offset_with_variance (class, iclass, &variance_used);
+ ioffset = mono_class_interface_offset_with_variance (klass, iclass, &variance_used);
if (ioffset == -1)
return;
while ((method = mono_class_get_methods (iclass, &iter))) {
member = mono_method_get_object (domain, method, iclass);
mono_array_setref (*methods, i, member);
- member = mono_method_get_object (domain, class->vtable [i + ioffset], class);
+ member = mono_method_get_object (domain, klass->vtable [i + ioffset], klass);
mono_array_setref (*targets, i, member);
i ++;
ICALL_EXPORT MonoReflectionType*
ves_icall_MonoType_GetElementType (MonoReflectionType *type)
{
- MonoClass *class;
+ MonoClass *klass;
if (!type->type->byref && type->type->type == MONO_TYPE_SZARRAY)
return mono_type_get_object (mono_object_domain (type), &type->type->data.klass->byval_arg);
- class = mono_class_from_mono_type (type->type);
- mono_class_init_or_throw (class);
+ klass = mono_class_from_mono_type (type->type);
+ mono_class_init_or_throw (klass);
// GetElementType should only return a type for:
// Array Pointer PassedByRef
if (type->type->byref)
- return mono_type_get_object (mono_object_domain (type), &class->byval_arg);
- else if (class->element_class && MONO_CLASS_IS_ARRAY (class))
- return mono_type_get_object (mono_object_domain (type), &class->element_class->byval_arg);
- else if (class->element_class && type->type->type == MONO_TYPE_PTR)
- return mono_type_get_object (mono_object_domain (type), &class->element_class->byval_arg);
+ return mono_type_get_object (mono_object_domain (type), &klass->byval_arg);
+ else if (klass->element_class && MONO_CLASS_IS_ARRAY (klass))
+ return mono_type_get_object (mono_object_domain (type), &klass->element_class->byval_arg);
+ else if (klass->element_class && type->type->type == MONO_TYPE_PTR)
+ return mono_type_get_object (mono_object_domain (type), &klass->element_class->byval_arg);
else
return NULL;
}
if (type->type->byref)
return NULL;
- MonoClass *class = mono_class_from_mono_type (type->type);
- return class->parent ? mono_type_get_object (mono_object_domain (type), &class->parent->byval_arg): NULL;
+ MonoClass *klass = mono_class_from_mono_type (type->type);
+ return klass->parent ? mono_type_get_object (mono_object_domain (type), &klass->parent->byval_arg): NULL;
}
ICALL_EXPORT MonoBoolean
ICALL_EXPORT MonoReflectionModule*
ves_icall_MonoType_get_Module (MonoReflectionType *type)
{
- MonoClass *class = mono_class_from_mono_type (type->type);
- return mono_module_get_object (mono_object_domain (type), class->image);
+ MonoClass *klass = mono_class_from_mono_type (type->type);
+ return mono_module_get_object (mono_object_domain (type), klass->image);
}
ICALL_EXPORT MonoReflectionAssembly*
ves_icall_MonoType_get_Assembly (MonoReflectionType *type)
{
MonoDomain *domain = mono_domain_get ();
- MonoClass *class = mono_class_from_mono_type (type->type);
- return mono_assembly_get_object (domain, class->image->assembly);
+ MonoClass *klass = mono_class_from_mono_type (type->type);
+ return mono_assembly_get_object (domain, klass->image->assembly);
}
ICALL_EXPORT MonoReflectionType*
ves_icall_MonoType_get_DeclaringType (MonoReflectionType *type)
{
MonoDomain *domain = mono_domain_get ();
- MonoClass *class;
+ MonoClass *klass;
if (type->type->byref)
return NULL;
if (type->type->type == MONO_TYPE_VAR) {
MonoGenericContainer *param = mono_type_get_generic_param_owner (type->type);
- class = param ? param->owner.klass : NULL;
+ klass = param ? param->owner.klass : NULL;
} else if (type->type->type == MONO_TYPE_MVAR) {
MonoGenericContainer *param = mono_type_get_generic_param_owner (type->type);
- class = param ? param->owner.method->klass : NULL;
+ klass = param ? param->owner.method->klass : NULL;
} else {
- class = mono_class_from_mono_type (type->type)->nested_in;
+ klass = mono_class_from_mono_type (type->type)->nested_in;
}
- return class ? mono_type_get_object (domain, &class->byval_arg) : NULL;
+ return klass ? mono_type_get_object (domain, &klass->byval_arg) : NULL;
}
ICALL_EXPORT MonoString*
ves_icall_MonoType_get_Name (MonoReflectionType *type)
{
MonoDomain *domain = mono_domain_get ();
- MonoClass *class = mono_class_from_mono_type (type->type);
+ MonoClass *klass = mono_class_from_mono_type (type->type);
if (type->type->byref) {
- char *n = g_strdup_printf ("%s&", class->name);
+ char *n = g_strdup_printf ("%s&", klass->name);
MonoString *res = mono_string_new (domain, n);
g_free (n);
return res;
} else {
- return mono_string_new (domain, class->name);
+ return mono_string_new (domain, klass->name);
}
}
ves_icall_MonoType_get_Namespace (MonoReflectionType *type)
{
MonoDomain *domain = mono_domain_get ();
- MonoClass *class = mono_class_from_mono_type (type->type);
+ MonoClass *klass = mono_class_from_mono_type (type->type);
- while (class->nested_in)
- class = class->nested_in;
+ while (klass->nested_in)
+ klass = klass->nested_in;
- if (class->name_space [0] == '\0')
+ if (klass->name_space [0] == '\0')
return NULL;
else
- return mono_string_new (domain, class->name_space);
+ return mono_string_new (domain, klass->name_space);
}
ICALL_EXPORT gint32
ves_icall_MonoType_GetArrayRank (MonoReflectionType *type)
{
- MonoClass *class;
+ MonoClass *klass;
if (type->type->type != MONO_TYPE_ARRAY && type->type->type != MONO_TYPE_SZARRAY) {
mono_set_pending_exception (mono_get_exception_argument ("type", "Type must be an array type"));
return 0;
}
- class = mono_class_from_mono_type (type->type);
+ klass = mono_class_from_mono_type (type->type);
- return class->rank;
+ return klass->rank;
}
static MonoArray*
ICALL_EXPORT MonoReflectionType*
ves_icall_Type_MakeGenericType (MonoReflectionType *type, MonoArray *type_array)
{
- MonoClass *class;
+ MonoClass *klass;
MonoType *geninst, **types;
int i, count;
if (!geninst)
return NULL;
- class = mono_class_from_mono_type (geninst);
+ klass = mono_class_from_mono_type (geninst);
/*we might inflate to the GTD*/
- if (class->generic_class && !mono_verifier_class_is_valid_generic_instantiation (class)) {
+ if (klass->generic_class && !mono_verifier_class_is_valid_generic_instantiation (klass)) {
mono_set_pending_exception (mono_get_exception_argument ("typeArguments", "Invalid generic arguments"));
return NULL;
}
g_assert (basetype);
switch (basetype->type) {
- case MONO_TYPE_I1:
- return *((gint8*)data);
+ case MONO_TYPE_I1: {
+ gint8 value = *((gint8*)data);
+ return ((int)value ^ (int)value << 8);
+ }
case MONO_TYPE_U1:
return *((guint8*)data);
case MONO_TYPE_CHAR:
case MONO_TYPE_U2:
return *((guint16*)data);
- case MONO_TYPE_I2:
- return *((gint16*)data);
+ case MONO_TYPE_I2: {
+ gint16 value = *((gint16*)data);
+ return ((int)(guint16)value | (((int)value) << 16));
+ }
case MONO_TYPE_U4:
return *((guint32*)data);
case MONO_TYPE_I4:
#include "marshal.h"
#include "coree.h"
#include <mono/io-layer/io-layer.h>
-#include <mono/utils/mono-logger-internal.h>
+#include <mono/utils/mono-logger-internals.h>
#include <mono/utils/mono-path.h>
#include <mono/utils/mono-mmap.h>
#include <mono/utils/mono-io-portability.h>
static gpointer
class_key_extract (gpointer value)
{
- MonoClass *class = value;
+ MonoClass *klass = value;
- return GUINT_TO_POINTER (class->type_token);
+ return GUINT_TO_POINTER (klass->type_token);
}
static gpointer*
class_next_value (gpointer value)
{
- MonoClass *class = value;
+ MonoClass *klass = value;
- return (gpointer*)&class->next_class_cache;
+ return (gpointer*)&klass->next_class_cache;
}
void
}
void
-mono_image_append_class_to_reflection_info_set (MonoClass *class)
+mono_image_append_class_to_reflection_info_set (MonoClass *klass)
{
- MonoImage *image = class->image;
+ MonoImage *image = klass->image;
g_assert (image_is_dynamic (image));
mono_image_lock (image);
- image->reflection_info_unregister_classes = g_slist_prepend_mempool (image->mempool, image->reflection_info_unregister_classes, class);
+ image->reflection_info_unregister_classes = g_slist_prepend_mempool (image->mempool, image->reflection_info_unregister_classes, klass);
mono_image_unlock (image);
}
gboolean searching = TRUE;
// Iterate over both by-path image hashes
- const int hash_count = 2;
- const int hash_candidates[hash_count] = {IMAGES_HASH_PATH, IMAGES_HASH_PATH_REFONLY};
+ const int hash_candidates[] = {IMAGES_HASH_PATH, IMAGES_HASH_PATH_REFONLY};
int hash_idx;
- for (hash_idx = 0; searching && hash_idx < IMAGES_HASH_COUNT; hash_idx++)
+ for (hash_idx = 0; searching && hash_idx < G_N_ELEMENTS (hash_candidates); hash_idx++)
{
GHashTable *target = loaded_images_hashes [hash_candidates [hash_idx]];
GHashTableIter iter;
return owner;
}
-#endif
\ No newline at end of file
+#endif
#include <string.h>
#include <sys/stat.h>
-#include <mono/metadata/gc-internal.h>
+#include <mono/metadata/gc-internals.h>
#include <mono/utils/atomic.h>
#include <mono/utils/mono-compiler.h>
-#include <mono/utils/mono-logger-internal.h>
+#include <mono/utils/mono-logger-internals.h>
#include <mono/utils/mono-membar.h>
#include <mono/utils/mono-counters.h>
#include <mono/utils/hazard-pointer.h>
#include <mono/metadata/assembly.h>
#include <mono/metadata/exception.h>
#include <mono/metadata/metadata-internals.h>
-#include <mono/metadata/gc-internal.h>
+#include <mono/metadata/gc-internals.h>
#include <mono/metadata/appdomain.h>
#include <mono/metadata/mono-debug-debugger.h>
#include <mono/metadata/mono-config.h>
g_assert (chunk->num_elements <= MONO_JIT_INFO_TABLE_CHUNK_SIZE);
for (j = 0; j < chunk->num_elements; ++j) {
- MonoJitInfo *this = chunk->data [j];
+ MonoJitInfo *this_ji = chunk->data [j];
MonoJitInfo *next;
- g_assert ((gint8*)this->code_start + this->code_size <= chunk->last_code_end);
+ g_assert ((gint8*)this_ji->code_start + this_ji->code_size <= chunk->last_code_end);
if (j < chunk->num_elements - 1)
next = chunk->data [j + 1];
} else
return;
- g_assert ((gint8*)this->code_start + this->code_size <= (gint8*)next->code_start + next->code_size);
+ g_assert ((gint8*)this_ji->code_start + this_ji->code_size <= (gint8*)next->code_start + next->code_size);
}
}
}
#include <mono/metadata/marshal.h>
#include <mono/metadata/lock-tracer.h>
#include <mono/metadata/verify-internals.h>
-#include <mono/utils/mono-logger-internal.h>
+#include <mono/utils/mono-logger-internals.h>
#include <mono/utils/mono-dl.h>
#include <mono/utils/mono-membar.h>
#include <mono/utils/mono-counters.h>
MonoBoolean specific, MonoBoolean installed)
{
MonoArray *ret;
- MonoClass *class;
+ MonoClass *klass;
MonoCultureInfo *culture;
MonoDomain *domain;
const CultureInfoEntry *ci;
len++;
}
- class = mono_class_from_name (mono_get_corlib (),
+ klass = mono_class_from_name (mono_get_corlib (),
"System.Globalization", "CultureInfo");
/* The InvariantCulture is not in culture_entries */
if (neutral)
len++;
- ret = mono_array_new (domain, class, len);
+ ret = mono_array_new (domain, klass, len);
if (len == 0)
return ret;
ci = &culture_entries [i];
is_neutral = ci->territory == 0;
if ((neutral && is_neutral) || (specific && !is_neutral)) {
- culture = (MonoCultureInfo *) mono_object_new (domain, class);
+ culture = (MonoCultureInfo *) mono_object_new (domain, klass);
mono_runtime_object_init ((MonoObject *) culture);
construct_culture (culture, ci);
culture->use_user_override = TRUE;
#include "mono/metadata/class-internals.h"
#include "mono/metadata/metadata-internals.h"
#include "mono/metadata/domain-internals.h"
-#include "mono/metadata/gc-internal.h"
+#include "mono/metadata/gc-internals.h"
#include "mono/metadata/threads-types.h"
#include "mono/metadata/string-icalls.h"
#include "mono/metadata/attrdefs.h"
-#include "mono/metadata/gc-internal.h"
+#include "mono/metadata/gc-internals.h"
#include "mono/metadata/cominterop.h"
#include "mono/metadata/remoting.h"
#include "mono/metadata/reflection-internals.h"
if (!res) {
res = newm;
g_hash_table_insert (cache, key, res);
- if (info)
- mono_marshal_set_wrapper_info (res, info);
- else
- mono_marshal_set_wrapper_info (res, key);
+ mono_marshal_set_wrapper_info (res, info);
mono_marshal_unlock ();
} else {
if (out_found)
MonoMethod *
mono_marshal_method_from_wrapper (MonoMethod *wrapper)
{
- gpointer res;
+ MonoMethod *m;
int wrapper_type = wrapper->wrapper_type;
WrapperInfo *info;
if (wrapper_type == MONO_WRAPPER_NONE || wrapper_type == MONO_WRAPPER_DYNAMIC_METHOD)
return wrapper;
+ info = mono_marshal_get_wrapper_info (wrapper);
+
switch (wrapper_type) {
case MONO_WRAPPER_REMOTING_INVOKE:
case MONO_WRAPPER_REMOTING_INVOKE_WITH_CHECK:
case MONO_WRAPPER_XDOMAIN_INVOKE:
- case MONO_WRAPPER_SYNCHRONIZED:
- case MONO_WRAPPER_UNBOX:
- res = mono_marshal_get_wrapper_info (wrapper);
- if (res == NULL)
- return wrapper;
+ m = info->d.remoting.method;
if (wrapper->is_inflated) {
MonoError error;
MonoMethod *result;
* A method cannot be inflated and a wrapper at the same time, so the wrapper info
* contains an uninflated method.
*/
- result = mono_class_inflate_generic_method_checked (res, mono_method_get_context (wrapper), &error);
+ result = mono_class_inflate_generic_method_checked (m, mono_method_get_context (wrapper), &error);
g_assert (mono_error_ok (&error)); /* FIXME don't swallow the error */
return result;
}
- return res;
+ return m;
+ case MONO_WRAPPER_SYNCHRONIZED:
+ return info->d.synchronized.method;
+ case MONO_WRAPPER_UNBOX:
+ return info->d.unbox.method;
case MONO_WRAPPER_MANAGED_TO_NATIVE:
- info = mono_marshal_get_wrapper_info (wrapper);
if (info && (info->subtype == WRAPPER_SUBTYPE_NONE || info->subtype == WRAPPER_SUBTYPE_NATIVE_FUNC_AOT || info->subtype == WRAPPER_SUBTYPE_PINVOKE))
return info->d.managed_to_native.method;
else
return NULL;
case MONO_WRAPPER_RUNTIME_INVOKE:
- info = mono_marshal_get_wrapper_info (wrapper);
if (info && (info->subtype == WRAPPER_SUBTYPE_RUNTIME_INVOKE_DIRECT || info->subtype == WRAPPER_SUBTYPE_RUNTIME_INVOKE_VIRTUAL))
return info->d.runtime_invoke.method;
else
/*
* mono_marshal_get_wrapper_info:
*
- * Retrieve the pointer stored by mono_marshal_set_wrapper_info. The type of data
- * returned depends on the wrapper type. It is usually a method, a class, or a
- * WrapperInfo structure.
+ * Retrieve the WrapperInfo structure associated with WRAPPER.
*/
-gpointer
+WrapperInfo*
mono_marshal_get_wrapper_info (MonoMethod *wrapper)
{
g_assert (wrapper->wrapper_type);
/*
* mono_marshal_set_wrapper_info:
*
- * Store an arbitrary pointer inside the wrapper which is retrievable by
- * mono_marshal_get_wrapper_info. The format of the data depends on the type of the
- * wrapper (method->wrapper_type).
+ * Set the WrapperInfo structure associated with the wrapper
+ * method METHOD to INFO.
*/
void
-mono_marshal_set_wrapper_info (MonoMethod *method, gpointer data)
+mono_marshal_set_wrapper_info (MonoMethod *method, WrapperInfo *info)
{
void **datav;
/* assert */
return;
datav = ((MonoMethodWrapper *)method)->method_data;
- datav [1] = data;
+ datav [1] = info;
}
WrapperInfo*
/*
* generates IL code for the runtime invoke function
- * MonoObject *runtime_invoke (MonoObject *this, void **params, MonoObject **exc, void* method)
+ * MonoObject *runtime_invoke (MonoObject *this_obj, void **params, MonoObject **exc, void* method)
*
* we also catch exceptions if exc != null
* If VIRTUAL is TRUE, then METHOD is invoked virtually on THIS. This is useful since
MonoMethodBuilder *mb;
MonoMethod *res;
GHashTable *cache;
+ WrapperInfo *info;
int i, pos, pos2, this_local, taken_local, ret_local = 0;
MonoGenericContext *ctx = NULL;
MonoMethod *orig_method = NULL;
mb = mono_mb_new (method->klass, method->name, MONO_WRAPPER_SYNCHRONIZED);
+ info = mono_wrapper_info_create (mb, WRAPPER_SUBTYPE_NONE);
+ info->d.synchronized.method = method;
+
#ifndef DISABLE_JIT
mb->skip_visibility = 1;
/* result */
mono_mb_emit_byte (mb, CEE_RET);
#endif
- res = mono_mb_create_and_cache (cache, method,
- mb, sig, sig->param_count + 16);
+ res = mono_mb_create_and_cache_full (cache, method,
+ mb, sig, sig->param_count + 16, info, NULL);
mono_mb_free (mb);
return res;
if (ctx) {
MonoMethod *def;
- def = mono_mb_create_and_cache (cache, method, mb, sig, sig->param_count + 16);
+ def = mono_mb_create_and_cache_full (cache, method, mb, sig, sig->param_count + 16, info, NULL);
res = cache_generic_wrapper (cache, orig_method, def, ctx, orig_method);
} else {
- res = mono_mb_create_and_cache (cache, method,
- mb, sig, sig->param_count + 16);
+ res = mono_mb_create_and_cache_full (cache, method,
+ mb, sig, sig->param_count + 16, info, NULL);
}
mono_mb_free (mb);
MonoMethodBuilder *mb;
MonoMethod *res;
GHashTable *cache;
+ WrapperInfo *info;
cache = get_cache (&mono_method_get_wrapper_cache (method)->unbox_wrapper_cache, mono_aligned_addr_hash, NULL);
mono_mb_emit_byte (mb, CEE_RET);
#endif
- res = mono_mb_create_and_cache (cache, method,
- mb, sig, sig->param_count + 16);
+ info = mono_wrapper_info_create (mb, WRAPPER_SUBTYPE_NONE);
+ info->d.unbox.method = method;
+
+ res = mono_mb_create_and_cache_full (cache, method,
+ mb, sig, sig->param_count + 16, info, NULL);
mono_mb_free (mb);
/* mono_method_print_code (res); */
mono_mb_emit_byte (mb, CEE_RET);
#endif
+ info = mono_wrapper_info_create (mb, WRAPPER_SUBTYPE_ARRAY_ACCESSOR);
+ info->d.array_accessor.method = method;
+
if (ctx) {
MonoMethod *def;
- def = mono_mb_create_and_cache (cache, method, mb, sig, sig->param_count + 16);
+ def = mono_mb_create_and_cache_full (cache, method, mb, sig, sig->param_count + 16, info, NULL);
res = cache_generic_wrapper (cache, orig_method, def, ctx, orig_method);
} else {
- info = mono_wrapper_info_create (mb, WRAPPER_SUBTYPE_ARRAY_ACCESSOR);
- info->d.array_accessor.method = method;
-
res = mono_mb_create_and_cache_full (cache, method,
mb, sig, sig->param_count + 16,
info, NULL);
}
MonoMethod *
-mono_marshal_get_generic_array_helper (MonoClass *class, MonoClass *iface, gchar *name, MonoMethod *method)
+mono_marshal_get_generic_array_helper (MonoClass *klass, MonoClass *iface, gchar *name, MonoMethod *method)
{
MonoMethodSignature *sig, *csig;
MonoMethodBuilder *mb;
WrapperInfo *info;
int i;
- mb = mono_mb_new_no_dup_name (class, name, MONO_WRAPPER_MANAGED_TO_MANAGED);
+ mb = mono_mb_new_no_dup_name (klass, name, MONO_WRAPPER_MANAGED_TO_MANAGED);
mb->method->slot = -1;
mb->method->flags = METHOD_ATTRIBUTE_PRIVATE | METHOD_ATTRIBUTE_VIRTUAL |
cache = get_cache (&mono_method_get_wrapper_cache (method)->thunk_invoke_cache, mono_aligned_addr_hash, NULL);
-
if ((res = mono_marshal_find_in_cache (cache, method)))
return res;
MonoMethod *method;
} ManagedToNativeWrapperInfo;
+typedef struct {
+ MonoMethod *method;
+} SynchronizedWrapperInfo;
+
typedef struct {
MonoMethod *method;
} SynchronizedInnerWrapperInfo;
MonoClass *klass;
} ProxyWrapperInfo;
+typedef struct {
+} WriteBarrierWrapperInfo;
+
+typedef struct {
+ const char *gc_name;
+ int alloc_type;
+} AllocatorWrapperInfo;
+
+typedef struct {
+ MonoMethod *method;
+} UnboxWrapperInfo;
+
+typedef struct {
+ MonoMethod *method;
+} RemotingWrapperInfo;
+
/*
* This structure contains additional information to uniquely identify a given wrapper
* method. It can be retrieved by mono_marshal_get_wrapper_info () for certain types
NativeToManagedWrapperInfo native_to_managed;
/* MONO_WRAPPER_MANAGED_TO_NATIVE */
ManagedToNativeWrapperInfo managed_to_native;
+ /* SYNCHRONIZED */
+ SynchronizedWrapperInfo synchronized;
/* SYNCHRONIZED_INNER */
SynchronizedInnerWrapperInfo synchronized_inner;
/* GENERIC_ARRAY_HELPER */
ArrayAccessorWrapperInfo array_accessor;
/* PROXY_ISINST etc. */
ProxyWrapperInfo proxy;
+ /* WRITE_BARRIER */
+ WriteBarrierWrapperInfo wbarrier;
+ /* ALLOC */
+ AllocatorWrapperInfo alloc;
+ /* UNBOX */
+ UnboxWrapperInfo unbox;
+ /* MONO_WRAPPER_REMOTING_INVOKE/MONO_WRAPPER_REMOTING_INVOKE_WITH_CHECK/MONO_WRAPPER_XDOMAIN_INVOKE */
+ RemotingWrapperInfo remoting;
} d;
} WrapperInfo;
mono_wrapper_info_create (MonoMethodBuilder *mb, WrapperSubtype subtype);
void
-mono_marshal_set_wrapper_info (MonoMethod *method, gpointer data);
+mono_marshal_set_wrapper_info (MonoMethod *method, WrapperInfo *info);
-gpointer
+WrapperInfo*
mono_marshal_get_wrapper_info (MonoMethod *wrapper);
MonoMethod *
case MONO_TYPE_VALUETYPE:
case MONO_TYPE_CLASS: {
guint32 token;
- MonoClass *class;
+ MonoClass *klass;
token = mono_metadata_parse_typedef_or_ref (m, ptr, &ptr);
- class = mono_class_get_checked (m, token, error);
- type->data.klass = class;
- if (!class)
+ klass = mono_class_get_checked (m, token, error);
+ type->data.klass = klass;
+ if (!klass)
return FALSE;
- if (!compare_type_literals (m, class->byval_arg.type, type->type, error))
+ if (!compare_type_literals (m, klass->byval_arg.type, type->type, error))
return FALSE;
break;
case MONO_TYPE_VALUETYPE:
case MONO_TYPE_CLASS:
case MONO_TYPE_SZARRAY: {
- MonoClass *class = t1->data.klass;
+ MonoClass *klass = t1->data.klass;
/*
* Dynamic classes must not be hashed on their type since it can change
* during runtime. For example, if we hash a reference type that is
* This is specially problematic with generic instances since they are
* inserted in a bunch of hash tables before been finished.
*/
- if (image_is_dynamic (class->image))
- return (t1->byref << 6) | mono_metadata_str_hash (class->name);
- return ((hash << 5) - hash) ^ mono_metadata_str_hash (class->name);
+ if (image_is_dynamic (klass->image))
+ return (t1->byref << 6) | mono_metadata_str_hash (klass->name);
+ return ((hash << 5) - hash) ^ mono_metadata_str_hash (klass->name);
}
case MONO_TYPE_PTR:
return ((hash << 5) - hash) ^ mono_metadata_type_hash (t1->data.type);
#include <mono/io-layer/io-layer.h>
#include <mono/metadata/object-internals.h>
#include <mono/metadata/class-internals.h>
-#include <mono/metadata/gc-internal.h>
+#include <mono/metadata/gc-internals.h>
#include <mono/metadata/method-builder.h>
#include <mono/metadata/debug-helpers.h>
#include <mono/metadata/tabledefs.h>
#include "mono/metadata/mono-config.h"
#include "mono/metadata/metadata-internals.h"
#include "mono/metadata/object-internals.h"
-#include "mono/utils/mono-logger-internal.h"
+#include "mono/utils/mono-logger-internals.h"
#if defined(TARGET_PS3)
#define CONFIG_OS "CellOS"
#include <mono/metadata/mono-debug.h>
#include <mono/metadata/mono-debug-debugger.h>
#include <mono/metadata/mono-endian.h>
-#include <mono/metadata/gc-internal.h>
+#include <mono/metadata/gc-internals.h>
#include <mono/metadata/mempool.h>
#include <mono/metadata/debug-mono-ppdb.h>
#include <string.h>
#include <math.h>
#include <glib.h>
#include "mono-hash.h"
-#include "metadata/gc-internal.h"
+#include "metadata/gc-internals.h"
#include <mono/utils/checked-build.h>
#ifdef HAVE_BOEHM_GC
#include <glib.h>
-#include "mono/metadata/gc-internal.h"
+#include "mono/metadata/gc-internals.h"
/* This is an implementation of a growable pointer array that avoids doing memory allocations for small sizes.
* It works by allocating an initial small array on stack and only going to gc tracked memory if needed.
#include "config.h"
#include <glib.h>
#include <mono/metadata/mono-gc.h>
-#include <mono/metadata/gc-internal.h>
+#include <mono/metadata/gc-internals.h>
#include <mono/metadata/runtime.h>
#include <mono/utils/atomic.h>
#include <mono/utils/mono-threads.h>
#endif
guint
-mono_gc_get_vtable_bits (MonoClass *class)
+mono_gc_get_vtable_bits (MonoClass *klass)
{
return 0;
}
guint16 *src;
gint exp, remaining, total, count, scale, absscale, index;
- g_assert (number->digits);
-
total = 0;
src = number->digits;
while (*src++) total ++;
#include <mono/metadata/tokentype.h>
#include <mono/metadata/loader.h>
#include <mono/metadata/object.h>
-#include <mono/metadata/gc-internal.h>
+#include <mono/metadata/gc-internals.h>
#include <mono/metadata/exception.h>
#include <mono/metadata/domain-internals.h>
#include "mono/metadata/metadata-internals.h"
#include "mono/metadata/profiler-private.h"
#include "mono/metadata/security-manager.h"
#include "mono/metadata/mono-debug-debugger.h"
-#include <mono/metadata/gc-internal.h>
+#include <mono/metadata/gc-internals.h>
#include <mono/metadata/verify-internals.h>
#include <mono/utils/strenc.h>
#include <mono/utils/mono-counters.h>
static mono_mutex_t ldstr_section;
void
-mono_runtime_object_init (MonoObject *this)
+mono_runtime_object_init (MonoObject *this_obj)
{
MONO_REQ_GC_UNSAFE_MODE;
MonoMethod *method = NULL;
- MonoClass *klass = this->vtable->klass;
+ MonoClass *klass = this_obj->vtable->klass;
method = mono_class_get_method_from_name (klass, ".ctor", 0);
if (!method)
g_error ("Could not lookup zero argument constructor for class %s", mono_type_get_full_name (klass));
if (method->klass->valuetype)
- this = mono_object_unbox (this);
- mono_runtime_invoke (method, this, NULL, NULL);
+ this_obj = mono_object_unbox (this_obj);
+ mono_runtime_invoke (method, this_obj, NULL, NULL);
}
/* The pseudo algorithm for type initialization from the spec
#define BITMAP_EL_SIZE (sizeof (gsize) * 8)
static gsize*
-compute_class_bitmap (MonoClass *class, gsize *bitmap, int size, int offset, int *max_set, gboolean static_fields)
+compute_class_bitmap (MonoClass *klass, gsize *bitmap, int size, int offset, int *max_set, gboolean static_fields)
{
MONO_REQ_GC_NEUTRAL_MODE;
int max_size;
if (static_fields)
- max_size = mono_class_data_size (class) / sizeof (gpointer);
+ max_size = mono_class_data_size (klass) / sizeof (gpointer);
else
- max_size = class->instance_size / sizeof (gpointer);
+ max_size = klass->instance_size / sizeof (gpointer);
if (max_size > size) {
g_assert (offset <= 0);
bitmap = g_malloc0 ((max_size + BITMAP_EL_SIZE - 1) / BITMAP_EL_SIZE * sizeof (gsize));
#ifdef HAVE_SGEN_GC
/*An Ephemeron cannot be marked by sgen*/
- if (!static_fields && class->image == mono_defaults.corlib && !strcmp ("Ephemeron", class->name)) {
+ if (!static_fields && klass->image == mono_defaults.corlib && !strcmp ("Ephemeron", klass->name)) {
*max_set = 0;
memset (bitmap, 0, size / 8);
return bitmap;
}
#endif
- for (p = class; p != NULL; p = p->parent) {
+ for (p = klass; p != NULL; p = p->parent) {
gpointer iter = NULL;
while ((field = mono_class_get_fields (p, &iter))) {
MonoType *type;
#ifdef HAVE_SGEN_GC
break;
#else
- if (class->image != mono_defaults.corlib)
+ if (klass->image != mono_defaults.corlib)
break;
#endif
case MONO_TYPE_STRING:
* Mono internal function to compute a bitmap of reference fields in a class.
*/
gsize*
-mono_class_compute_bitmap (MonoClass *class, gsize *bitmap, int size, int offset, int *max_set, gboolean static_fields)
+mono_class_compute_bitmap (MonoClass *klass, gsize *bitmap, int size, int offset, int *max_set, gboolean static_fields)
{
MONO_REQ_GC_NEUTRAL_MODE;
- return compute_class_bitmap (class, bitmap, size, offset, max_set, static_fields);
+ return compute_class_bitmap (klass, bitmap, size, offset, max_set, static_fields);
}
#if 0
* and ignores static fields
*/
static gsize*
-compute_class_non_ref_bitmap (MonoClass *class, gsize *bitmap, int size, int offset)
+compute_class_non_ref_bitmap (MonoClass *klass, gsize *bitmap, int size, int offset)
{
MonoClassField *field;
MonoClass *p;
}
void
-mono_class_compute_gc_descriptor (MonoClass *class)
+mono_class_compute_gc_descriptor (MonoClass *klass)
{
MONO_REQ_GC_NEUTRAL_MODE;
mono_loader_unlock ();
}
- if (!class->inited)
- mono_class_init (class);
+ if (!klass->inited)
+ mono_class_init (klass);
- if (class->gc_descr_inited)
+ if (klass->gc_descr_inited)
return;
- class->gc_descr_inited = TRUE;
- class->gc_descr = MONO_GC_DESCRIPTOR_NULL;
+ klass->gc_descr_inited = TRUE;
+ klass->gc_descr = MONO_GC_DESCRIPTOR_NULL;
bitmap = default_bitmap;
- if (class == mono_defaults.string_class) {
- class->gc_descr = mono_gc_make_descr_for_string (bitmap, 2);
- } else if (class->rank) {
- mono_class_compute_gc_descriptor (class->element_class);
- if (MONO_TYPE_IS_REFERENCE (&class->element_class->byval_arg)) {
+ if (klass == mono_defaults.string_class) {
+ klass->gc_descr = mono_gc_make_descr_for_string (bitmap, 2);
+ } else if (klass->rank) {
+ mono_class_compute_gc_descriptor (klass->element_class);
+ if (MONO_TYPE_IS_REFERENCE (&klass->element_class->byval_arg)) {
gsize abm = 1;
- class->gc_descr = mono_gc_make_descr_for_array (class->byval_arg.type == MONO_TYPE_SZARRAY, &abm, 1, sizeof (gpointer));
+ klass->gc_descr = mono_gc_make_descr_for_array (klass->byval_arg.type == MONO_TYPE_SZARRAY, &abm, 1, sizeof (gpointer));
/*printf ("new array descriptor: 0x%x for %s.%s\n", class->gc_descr,
class->name_space, class->name);*/
} else {
/* remove the object header */
- bitmap = compute_class_bitmap (class->element_class, default_bitmap, sizeof (default_bitmap) * 8, - (int)(sizeof (MonoObject) / sizeof (gpointer)), &max_set, FALSE);
- class->gc_descr = mono_gc_make_descr_for_array (class->byval_arg.type == MONO_TYPE_SZARRAY, bitmap, mono_array_element_size (class) / sizeof (gpointer), mono_array_element_size (class));
+ bitmap = compute_class_bitmap (klass->element_class, default_bitmap, sizeof (default_bitmap) * 8, - (int)(sizeof (MonoObject) / sizeof (gpointer)), &max_set, FALSE);
+ klass->gc_descr = mono_gc_make_descr_for_array (klass->byval_arg.type == MONO_TYPE_SZARRAY, bitmap, mono_array_element_size (klass) / sizeof (gpointer), mono_array_element_size (klass));
/*printf ("new vt array descriptor: 0x%x for %s.%s\n", class->gc_descr,
class->name_space, class->name);*/
if (bitmap != default_bitmap)
/*static int count = 0;
if (count++ > 58)
return;*/
- bitmap = compute_class_bitmap (class, default_bitmap, sizeof (default_bitmap) * 8, 0, &max_set, FALSE);
- class->gc_descr = mono_gc_make_descr_for_object (bitmap, max_set + 1, class->instance_size);
+ bitmap = compute_class_bitmap (klass, default_bitmap, sizeof (default_bitmap) * 8, 0, &max_set, FALSE);
+ klass->gc_descr = mono_gc_make_descr_for_object (bitmap, max_set + 1, klass->instance_size);
/*
if (class->gc_descr == MONO_GC_DESCRIPTOR_NULL)
g_print ("disabling typed alloc (%d) for %s.%s\n", max_set, class->name_space, class->name);
mono_domain_unlock (domain);
}
-static MonoVTable *mono_class_create_runtime_vtable (MonoDomain *domain, MonoClass *class, gboolean raise_on_error);
+static MonoVTable *mono_class_create_runtime_vtable (MonoDomain *domain, MonoClass *klass, gboolean raise_on_error);
/**
* mono_class_vtable:
* On failure, NULL is returned, and class->exception_type is set.
*/
MonoVTable *
-mono_class_vtable (MonoDomain *domain, MonoClass *class)
+mono_class_vtable (MonoDomain *domain, MonoClass *klass)
{
- return mono_class_vtable_full (domain, class, FALSE);
+ return mono_class_vtable_full (domain, klass, FALSE);
}
/**
* they contain the domain specific static class data.
*/
MonoVTable *
-mono_class_vtable_full (MonoDomain *domain, MonoClass *class, gboolean raise_on_error)
+mono_class_vtable_full (MonoDomain *domain, MonoClass *klass, gboolean raise_on_error)
{
MONO_REQ_GC_UNSAFE_MODE;
MonoClassRuntimeInfo *runtime_info;
- g_assert (class);
+ g_assert (klass);
- if (class->exception_type) {
+ if (klass->exception_type) {
if (raise_on_error)
- mono_raise_exception (mono_class_get_exception_for_failure (class));
+ mono_raise_exception (mono_class_get_exception_for_failure (klass));
return NULL;
}
/* this check can be inlined in jitted code, too */
- runtime_info = class->runtime_info;
+ runtime_info = klass->runtime_info;
if (runtime_info && runtime_info->max_domain >= domain->domain_id && runtime_info->domain_vtables [domain->domain_id])
return runtime_info->domain_vtables [domain->domain_id];
- return mono_class_create_runtime_vtable (domain, class, raise_on_error);
+ return mono_class_create_runtime_vtable (domain, klass, raise_on_error);
}
/**
* it was already created.
*/
MonoVTable *
-mono_class_try_get_vtable (MonoDomain *domain, MonoClass *class)
+mono_class_try_get_vtable (MonoDomain *domain, MonoClass *klass)
{
MONO_REQ_GC_NEUTRAL_MODE;
MonoClassRuntimeInfo *runtime_info;
- g_assert (class);
+ g_assert (klass);
- runtime_info = class->runtime_info;
+ runtime_info = klass->runtime_info;
if (runtime_info && runtime_info->max_domain >= domain->domain_id && runtime_info->domain_vtables [domain->domain_id])
return runtime_info->domain_vtables [domain->domain_id];
return NULL;
}
static MonoVTable *
-mono_class_create_runtime_vtable (MonoDomain *domain, MonoClass *class, gboolean raise_on_error)
+mono_class_create_runtime_vtable (MonoDomain *domain, MonoClass *klass, gboolean raise_on_error)
{
MONO_REQ_GC_UNSAFE_MODE;
mono_loader_lock (); /*FIXME mono_class_init acquires it*/
mono_domain_lock (domain);
- runtime_info = class->runtime_info;
+ runtime_info = klass->runtime_info;
if (runtime_info && runtime_info->max_domain >= domain->domain_id && runtime_info->domain_vtables [domain->domain_id]) {
mono_domain_unlock (domain);
mono_loader_unlock ();
return runtime_info->domain_vtables [domain->domain_id];
}
- if (!class->inited || class->exception_type) {
- if (!mono_class_init (class) || class->exception_type) {
+ if (!klass->inited || klass->exception_type) {
+ if (!mono_class_init (klass) || klass->exception_type) {
mono_domain_unlock (domain);
mono_loader_unlock ();
if (raise_on_error)
- mono_raise_exception (mono_class_get_exception_for_failure (class));
+ mono_raise_exception (mono_class_get_exception_for_failure (klass));
return NULL;
}
}
/* Array types require that their element type be valid*/
- if (class->byval_arg.type == MONO_TYPE_ARRAY || class->byval_arg.type == MONO_TYPE_SZARRAY) {
- MonoClass *element_class = class->element_class;
+ if (klass->byval_arg.type == MONO_TYPE_ARRAY || klass->byval_arg.type == MONO_TYPE_SZARRAY) {
+ MonoClass *element_class = klass->element_class;
if (!element_class->inited)
mono_class_init (element_class);
if (element_class->exception_type != MONO_EXCEPTION_NONE) {
/*Can happen if element_class only got bad after mono_class_setup_vtable*/
- if (class->exception_type == MONO_EXCEPTION_NONE)
- mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, NULL);
+ if (klass->exception_type == MONO_EXCEPTION_NONE)
+ mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, NULL);
mono_domain_unlock (domain);
mono_loader_unlock ();
if (raise_on_error)
- mono_raise_exception (mono_class_get_exception_for_failure (class));
+ mono_raise_exception (mono_class_get_exception_for_failure (klass));
return NULL;
}
}
/*
- * For some classes, mono_class_init () already computed class->vtable_size, and
+ * For some classes, mono_class_init () already computed klass->vtable_size, and
* that is all that is needed because of the vtable trampolines.
*/
- if (!class->vtable_size)
- mono_class_setup_vtable (class);
+ if (!klass->vtable_size)
+ mono_class_setup_vtable (klass);
- if (class->generic_class && !class->vtable)
- mono_class_check_vtable_constraints (class, NULL);
+ if (klass->generic_class && !klass->vtable)
+ mono_class_check_vtable_constraints (klass, NULL);
/* Initialize klass->has_finalize */
- mono_class_has_finalizer (class);
+ mono_class_has_finalizer (klass);
- if (class->exception_type) {
+ if (klass->exception_type) {
mono_domain_unlock (domain);
mono_loader_unlock ();
if (raise_on_error)
- mono_raise_exception (mono_class_get_exception_for_failure (class));
+ mono_raise_exception (mono_class_get_exception_for_failure (klass));
return NULL;
}
- vtable_slots = class->vtable_size;
+ vtable_slots = klass->vtable_size;
/* we add an additional vtable slot to store the pointer to static field data only when needed */
- class_size = mono_class_data_size (class);
+ class_size = mono_class_data_size (klass);
if (class_size)
vtable_slots++;
- if (class->interface_offsets_count) {
+ if (klass->interface_offsets_count) {
imt_table_bytes = sizeof (gpointer) * (MONO_IMT_SIZE);
mono_stats.imt_number_of_tables++;
mono_stats.imt_tables_size += imt_table_bytes;
vt = (MonoVTable*) ((char*)interface_offsets + imt_table_bytes);
g_assert (!((gsize)vt & 7));
- vt->klass = class;
- vt->rank = class->rank;
+ vt->klass = klass;
+ vt->rank = klass->rank;
vt->domain = domain;
- mono_class_compute_gc_descriptor (class);
+ mono_class_compute_gc_descriptor (klass);
/*
* We can't use typed allocation in the non-root domains, since the
* collector needs the GC descriptor stored in the vtable even after
vt->gc_descr = MONO_GC_DESCRIPTOR_NULL;
else
#endif
- vt->gc_descr = class->gc_descr;
+ vt->gc_descr = klass->gc_descr;
- gc_bits = mono_gc_get_vtable_bits (class);
+ gc_bits = mono_gc_get_vtable_bits (klass);
g_assert (!(gc_bits & ~((1 << MONO_VTABLE_AVAILABLE_GC_BITS) - 1)));
vt->gc_bits = gc_bits;
if (class_size) {
/* we store the static field pointer at the end of the vtable: vt->vtable [class->vtable_size] */
- if (class->has_static_refs) {
+ if (klass->has_static_refs) {
MonoGCDescriptor statics_gc_descr;
int max_set = 0;
gsize default_bitmap [4] = {0};
gsize *bitmap;
- bitmap = compute_class_bitmap (class, default_bitmap, sizeof (default_bitmap) * 8, 0, &max_set, TRUE);
- /*g_print ("bitmap 0x%x for %s.%s (size: %d)\n", bitmap [0], class->name_space, class->name, class_size);*/
+ bitmap = compute_class_bitmap (klass, default_bitmap, sizeof (default_bitmap) * 8, 0, &max_set, TRUE);
+ /*g_print ("bitmap 0x%x for %s.%s (size: %d)\n", bitmap [0], klass->name_space, klass->name, class_size);*/
statics_gc_descr = mono_gc_make_descr_from_bitmap (bitmap, max_set + 1);
- vt->vtable [class->vtable_size] = mono_gc_alloc_fixed (class_size, statics_gc_descr, MONO_ROOT_SOURCE_STATIC, "managed static variables");
- mono_domain_add_class_static_data (domain, class, vt->vtable [class->vtable_size], NULL);
+ vt->vtable [klass->vtable_size] = mono_gc_alloc_fixed (class_size, statics_gc_descr, MONO_ROOT_SOURCE_STATIC, "managed static variables");
+ mono_domain_add_class_static_data (domain, klass, vt->vtable [klass->vtable_size], NULL);
if (bitmap != default_bitmap)
g_free (bitmap);
} else {
- vt->vtable [class->vtable_size] = mono_domain_alloc0 (domain, class_size);
+ vt->vtable [klass->vtable_size] = mono_domain_alloc0 (domain, class_size);
}
vt->has_static_fields = TRUE;
mono_stats.class_static_data_size += class_size;
}
iter = NULL;
- while ((field = mono_class_get_fields (class, &iter))) {
+ while ((field = mono_class_get_fields (klass, &iter))) {
if (!(field->type->attrs & FIELD_ATTRIBUTE_STATIC))
continue;
if (mono_field_is_deleted (field))
continue;
if (!(field->type->attrs & FIELD_ATTRIBUTE_LITERAL)) {
- gint32 special_static = class->no_special_static_fields ? SPECIAL_STATIC_NONE : field_is_special_static (class, field);
+ gint32 special_static = klass->no_special_static_fields ? SPECIAL_STATIC_NONE : field_is_special_static (klass, field);
if (special_static != SPECIAL_STATIC_NONE) {
guint32 size, offset;
gint32 align;
}
}
- vt->max_interface_id = class->max_interface_id;
- vt->interface_bitmap = class->interface_bitmap;
+ vt->max_interface_id = klass->max_interface_id;
+ vt->interface_bitmap = klass->interface_bitmap;
//printf ("Initializing VT for class %s (interface_offsets_count = %d)\n",
- // class->name, class->interface_offsets_count);
+ // class->name, klass->interface_offsets_count);
/* Initialize vtable */
if (callbacks.get_vtable_trampoline) {
// This also covers the AOT case
- for (i = 0; i < class->vtable_size; ++i) {
+ for (i = 0; i < klass->vtable_size; ++i) {
vt->vtable [i] = callbacks.get_vtable_trampoline (i);
}
} else {
- mono_class_setup_vtable (class);
+ mono_class_setup_vtable (klass);
- for (i = 0; i < class->vtable_size; ++i) {
+ for (i = 0; i < klass->vtable_size; ++i) {
MonoMethod *cm;
- if ((cm = class->vtable [i]))
+ if ((cm = klass->vtable [i]))
vt->vtable [i] = arch_create_jit_trampoline (cm);
}
}
* re-acquire them and check if another thread has created the vtable in the meantime.
*/
/* Special case System.MonoType to avoid infinite recursion */
- if (class != mono_defaults.monotype_class) {
+ if (klass != mono_defaults.monotype_class) {
/*FIXME check for OOM*/
- vt->type = mono_type_get_object (domain, &class->byval_arg);
+ vt->type = mono_type_get_object (domain, &klass->byval_arg);
if (mono_object_get_class (vt->type) != mono_defaults.monotype_class)
/* This is unregistered in
unregister_vtable_reflection_type() in
MONO_GC_REGISTER_ROOT_IF_MOVING(vt->type, MONO_ROOT_SOURCE_REFLECTION, "vtable reflection type");
}
- mono_vtable_set_is_remote (vt, mono_class_is_contextbound (class));
+ mono_vtable_set_is_remote (vt, mono_class_is_contextbound (klass));
/* class_vtable_array keeps an array of created vtables
*/
g_ptr_array_add (domain->class_vtable_array, vt);
- /* class->runtime_info is protected by the loader lock, both when
+ /* klass->runtime_info is protected by the loader lock, both when
* it it enlarged and when it is stored info.
*/
/*
- * Store the vtable in class->runtime_info.
- * class->runtime_info is accessed without locking, so this do this last after the vtable has been constructed.
+ * Store the vtable in klass->runtime_info.
+ * klass->runtime_info is accessed without locking, so this do this last after the vtable has been constructed.
*/
mono_memory_barrier ();
- old_info = class->runtime_info;
+ old_info = klass->runtime_info;
if (old_info && old_info->max_domain >= domain->domain_id) {
/* someone already created a large enough runtime info */
old_info->domain_vtables [domain->domain_id] = vt;
/* this is a bounded memory retention issue: may want to
* handle it differently when we'll have a rcu-like system.
*/
- runtime_info = mono_image_alloc0 (class->image, MONO_SIZEOF_CLASS_RUNTIME_INFO + new_size * sizeof (gpointer));
+ runtime_info = mono_image_alloc0 (klass->image, MONO_SIZEOF_CLASS_RUNTIME_INFO + new_size * sizeof (gpointer));
runtime_info->max_domain = new_size - 1;
/* copy the stuff from the older info */
if (old_info) {
runtime_info->domain_vtables [domain->domain_id] = vt;
/* keep this last*/
mono_memory_barrier ();
- class->runtime_info = runtime_info;
+ klass->runtime_info = runtime_info;
}
- if (class == mono_defaults.monotype_class) {
+ if (klass == mono_defaults.monotype_class) {
/*FIXME check for OOM*/
- vt->type = mono_type_get_object (domain, &class->byval_arg);
+ vt->type = mono_type_get_object (domain, &klass->byval_arg);
if (mono_object_get_class (vt->type) != mono_defaults.monotype_class)
/* This is unregistered in
unregister_vtable_reflection_type() in
/* make sure the parent is initialized */
/*FIXME shouldn't this fail the current type?*/
- if (class->parent)
- mono_class_vtable_full (domain, class->parent, raise_on_error);
+ if (klass->parent)
+ mono_class_vtable_full (domain, klass->parent, raise_on_error);
return vt;
}
int i, j, vtsize, max_interface_id, extra_interface_vtsize = 0;
MonoClass *k;
GSList *extra_interfaces = NULL;
- MonoClass *class = remote_class->proxy_class;
+ MonoClass *klass = remote_class->proxy_class;
gpointer *interface_offsets;
uint8_t *bitmap;
int bsize;
int bcsize;
#endif
- vt = mono_class_vtable (domain, class);
+ vt = mono_class_vtable (domain, klass);
g_assert (vt); /*FIXME property handle failure*/
max_interface_id = vt->max_interface_id;
int method_count;
/*FIXME test for interfaces with variant generic arguments*/
- if (MONO_CLASS_IMPLEMENTS_INTERFACE (class, iclass->interface_id))
+ if (MONO_CLASS_IMPLEMENTS_INTERFACE (klass, iclass->interface_id))
continue; /* interface implemented by the class */
if (g_slist_find (extra_interfaces, iclass))
continue;
for (i = 0; i < ifaces->len; ++i) {
MonoClass *ic = g_ptr_array_index (ifaces, i);
/*FIXME test for interfaces with variant generic arguments*/
- if (MONO_CLASS_IMPLEMENTS_INTERFACE (class, ic->interface_id))
+ if (MONO_CLASS_IMPLEMENTS_INTERFACE (klass, ic->interface_id))
continue; /* interface implemented by the class */
if (g_slist_find (extra_interfaces, ic))
continue;
mono_stats.imt_number_of_tables++;
mono_stats.imt_tables_size += imt_table_bytes;
- vtsize = imt_table_bytes + MONO_SIZEOF_VTABLE + class->vtable_size * sizeof (gpointer);
+ vtsize = imt_table_bytes + MONO_SIZEOF_VTABLE + klass->vtable_size * sizeof (gpointer);
mono_stats.class_vtable_size += vtsize + extra_interface_vtsize;
pvt = (MonoVTable*) ((char*)interface_offsets + imt_table_bytes);
g_assert (!((gsize)pvt & 7));
- memcpy (pvt, vt, MONO_SIZEOF_VTABLE + class->vtable_size * sizeof (gpointer));
+ memcpy (pvt, vt, MONO_SIZEOF_VTABLE + klass->vtable_size * sizeof (gpointer));
pvt->klass = mono_defaults.transparent_proxy_class;
/* we need to keep the GC descriptor for a transparent proxy or we confuse the precise GC */
pvt->gc_descr = mono_defaults.transparent_proxy_class->gc_descr;
/* initialize vtable */
- mono_class_setup_vtable (class);
- for (i = 0; i < class->vtable_size; ++i) {
+ mono_class_setup_vtable (klass);
+ for (i = 0; i < klass->vtable_size; ++i) {
MonoMethod *cm;
- if ((cm = class->vtable [i]))
+ if ((cm = klass->vtable [i]))
pvt->vtable [i] = arch_create_remoting_trampoline (domain, cm, target_type);
else
pvt->vtable [i] = NULL;
}
- if (class->flags & TYPE_ATTRIBUTE_ABSTRACT) {
+ if (klass->flags & TYPE_ATTRIBUTE_ABSTRACT) {
/* create trampolines for abstract methods */
- for (k = class; k; k = k->parent) {
+ for (k = klass; k; k = k->parent) {
MonoMethod* m;
gpointer iter = NULL;
while ((m = mono_class_get_methods (k, &iter)))
bitmap = mono_domain_alloc0 (domain, bsize);
#endif
- for (i = 0; i < class->interface_offsets_count; ++i) {
- int interface_id = class->interfaces_packed [i]->interface_id;
+ for (i = 0; i < klass->interface_offsets_count; ++i) {
+ int interface_id = klass->interfaces_packed [i]->interface_id;
bitmap [interface_id >> 3] |= (1 << (interface_id & 7));
}
if (extra_interfaces) {
- int slot = class->vtable_size;
+ int slot = klass->vtable_size;
MonoClass* interf;
gpointer iter;
MonoMethod* cm;
}
/* Now that the vtable is full, we can actually fill up the IMT */
- build_imt (class, pvt, domain, interface_offsets, extra_interfaces);
+ build_imt (klass, pvt, domain, interface_offsets, extra_interfaces);
if (extra_interfaces) {
g_slist_free (extra_interfaces);
}
t = mono_class_enum_basetype (type->data.klass)->type;
goto handle_enum;
} else {
- MonoClass *class = mono_class_from_mono_type (type);
- int size = mono_class_value_size (class, NULL);
+ MonoClass *klass = mono_class_from_mono_type (type);
+ int size = mono_class_value_size (klass, NULL);
if (value == NULL)
mono_gc_bzero_atomic (dest, size);
else
- mono_gc_wbarrier_value_copy (dest, value, 1, class);
+ mono_gc_wbarrier_value_copy (dest, value, 1, klass);
}
return;
case MONO_TYPE_GENERICINST:
MONO_REQ_GC_UNSAFE_MODE;
MonoError error;
- MonoClass *class;
+ MonoClass *klass;
- class = mono_class_get_checked (image, token, &error);
+ klass = mono_class_get_checked (image, token, &error);
g_assert (mono_error_ok (&error)); /* FIXME don't swallow the error */
- return mono_object_new (domain, class);
+ return mono_object_new (domain, klass);
}
#endif
gboolean
-mono_array_calc_byte_len (MonoClass *class, uintptr_t len, uintptr_t *res)
+mono_array_calc_byte_len (MonoClass *klass, uintptr_t len, uintptr_t *res)
{
MONO_REQ_GC_NEUTRAL_MODE;
uintptr_t byte_len;
- byte_len = mono_array_element_size (class);
+ byte_len = mono_array_element_size (klass);
if (CHECK_MUL_OVERFLOW_UN (byte_len, len))
return FALSE;
byte_len *= len;
* Returns: A newly created object which contains @value.
*/
MonoObject *
-mono_value_box (MonoDomain *domain, MonoClass *class, gpointer value)
+mono_value_box (MonoDomain *domain, MonoClass *klass, gpointer value)
{
MONO_REQ_GC_UNSAFE_MODE;
int size;
MonoVTable *vtable;
- g_assert (class->valuetype);
- if (mono_class_is_nullable (class))
- return mono_nullable_box (value, class);
+ g_assert (klass->valuetype);
+ if (mono_class_is_nullable (klass))
+ return mono_nullable_box (value, klass);
- vtable = mono_class_vtable (domain, class);
+ vtable = mono_class_vtable (domain, klass);
if (!vtable)
return NULL;
- size = mono_class_instance_size (class);
+ size = mono_class_instance_size (klass);
res = mono_object_new_alloc_specific (vtable);
size = size - sizeof (MonoObject);
#ifdef HAVE_SGEN_GC
- g_assert (size == mono_class_value_size (class, NULL));
- mono_gc_wbarrier_value_copy ((char *)res + sizeof (MonoObject), value, 1, class);
+ g_assert (size == mono_class_value_size (klass, NULL));
+ mono_gc_wbarrier_value_copy ((char *)res + sizeof (MonoObject), value, 1, klass);
#else
#if NO_UNALIGNED_ACCESS
mono_gc_memmove_atomic ((char *)res + sizeof (MonoObject), value, size);
}
#endif
#endif
- if (class->has_finalize)
+ if (klass->has_finalize)
mono_object_register_finalizer (res);
return res;
}
for (i = 0; i < count; i++) {
gpointer vpos;
- MonoClass *class;
+ MonoClass *klass;
MonoObject *arg;
if (sig->params [i]->byref)
else
vpos = params [i];
- class = mono_class_from_mono_type (sig->params [i]);
+ klass = mono_class_from_mono_type (sig->params [i]);
- if (class->valuetype)
- arg = mono_value_box (domain, class, vpos);
+ if (klass->valuetype)
+ arg = mono_value_box (domain, klass, vpos);
else
arg = *((MonoObject **)vpos);
mono_gc_wbarrier_generic_store (*((MonoObject ***)params [i]), (MonoObject *)arg);
} else {
if (arg) {
- MonoClass *class = ((MonoObject*)arg)->vtable->klass;
- size = mono_class_value_size (class, NULL);
- if (class->has_references)
- mono_gc_wbarrier_value_copy (*((gpointer *)params [i]), arg + sizeof (MonoObject), 1, class);
+ MonoClass *klass = ((MonoObject*)arg)->vtable->klass;
+ size = mono_class_value_size (klass, NULL);
+ if (klass->has_references)
+ mono_gc_wbarrier_value_copy (*((gpointer *)params [i]), arg + sizeof (MonoObject), 1, klass);
else
mono_gc_memmove_atomic (*((gpointer *)params [i]), arg + sizeof (MonoObject), size);
} else {
for (i = 1; i <= table->rows; ++i) {
MonoError error;
guint32 token = i | MONO_TOKEN_TYPE_DEF;
- MonoClass *class = mono_class_get_checked (image, token, &error);
- if (!class) {
+ MonoClass *klass = mono_class_get_checked (image, token, &error);
+ if (!klass) {
printf ("Could not load class with token %x due to %s\n", token, mono_error_get_message (&error));
mono_error_cleanup (&error);
continue;
}
- mono_class_init (class);
- if (class->exception_type != MONO_EXCEPTION_NONE || mono_loader_get_last_error ()) {
- printf ("Error verifying class(0x%08x) %s.%s a type load error happened\n", token, class->name_space, class->name);
+ mono_class_init (klass);
+ if (klass->exception_type != MONO_EXCEPTION_NONE || mono_loader_get_last_error ()) {
+ printf ("Error verifying class(0x%08x) %s.%s a type load error happened\n", token, klass->name_space, klass->name);
mono_loader_clear_error ();
++count;
}
- mono_class_setup_vtable (class);
- if (class->exception_type != MONO_EXCEPTION_NONE || mono_loader_get_last_error ()) {
- printf ("Error verifying class(0x%08x) %s.%s a type load error happened\n", token, class->name_space, class->name);
+ mono_class_setup_vtable (klass);
+ if (klass->exception_type != MONO_EXCEPTION_NONE || mono_loader_get_last_error ()) {
+ printf ("Error verifying class(0x%08x) %s.%s a type load error happened\n", token, klass->name_space, klass->name);
mono_loader_clear_error ();
++count;
}
#include "mono/metadata/metadata-internals.h"
#include "mono/metadata/class-internals.h"
#include "mono/metadata/domain-internals.h"
-#include "mono/metadata/gc-internal.h"
+#include "mono/metadata/gc-internals.h"
#include "mono/metadata/mono-config-dirs.h"
#include "mono/io-layer/io-layer.h"
#include "mono/utils/mono-dl.h"
/*
* Copyright 2014 Xamarin Inc
*/
-#ifndef __MONO_METADATA_REFLECTION_INTERBALS_H__
-#define __MONO_METADATA_REFLECTION_INTERBALS_H__
+#ifndef __MONO_METADATA_REFLECTION_INTERNALS_H__
+#define __MONO_METADATA_REFLECTION_INTERNALS_H__
#include <mono/metadata/reflection.h>
#include <mono/utils/mono-compiler.h>
char*
mono_identifier_unescape_type_name_chars (char* identifier);
-#endif
+#endif /* __MONO_METADATA_REFLECTION_INTERNALS_H__ */
#include "mono/metadata/metadata-internals.h"
#include <mono/metadata/profiler-private.h>
#include "mono/metadata/class-internals.h"
-#include "mono/metadata/gc-internal.h"
+#include "mono/metadata/gc-internals.h"
#include "mono/metadata/tokentype.h"
#include "mono/metadata/domain-internals.h"
#include "mono/metadata/opcodes.h"
#include "image.h"
#include "cil-coff.h"
#include "mono-endian.h"
-#include <mono/metadata/gc-internal.h>
+#include <mono/metadata/gc-internals.h>
#include <mono/metadata/mempool-internals.h>
#include <mono/metadata/security-core-clr.h>
#include <mono/metadata/debug-helpers.h>
static MonoReflectionType *mono_reflection_type_get_underlying_system_type (MonoReflectionType* t);
static MonoType* mono_reflection_get_type_with_rootimage (MonoImage *rootimage, MonoImage* image, MonoTypeNameParse *info, gboolean ignorecase, gboolean *type_resolve);
static MonoReflectionType* mono_reflection_type_resolve_user_types (MonoReflectionType *type);
-static gboolean is_sre_array (MonoClass *class);
-static gboolean is_sre_byref (MonoClass *class);
-static gboolean is_sre_pointer (MonoClass *class);
-static gboolean is_sre_type_builder (MonoClass *class);
-static gboolean is_sre_method_builder (MonoClass *class);
-static gboolean is_sre_ctor_builder (MonoClass *class);
-static gboolean is_sre_field_builder (MonoClass *class);
-static gboolean is_sr_mono_method (MonoClass *class);
-static gboolean is_sr_mono_cmethod (MonoClass *class);
-static gboolean is_sr_mono_generic_method (MonoClass *class);
-static gboolean is_sr_mono_generic_cmethod (MonoClass *class);
-static gboolean is_sr_mono_field (MonoClass *class);
-static gboolean is_sr_mono_property (MonoClass *class);
-static gboolean is_sre_method_on_tb_inst (MonoClass *class);
-static gboolean is_sre_ctor_on_tb_inst (MonoClass *class);
+static gboolean is_sre_array (MonoClass *klass);
+static gboolean is_sre_byref (MonoClass *klass);
+static gboolean is_sre_pointer (MonoClass *klass);
+static gboolean is_sre_type_builder (MonoClass *klass);
+static gboolean is_sre_method_builder (MonoClass *klass);
+static gboolean is_sre_ctor_builder (MonoClass *klass);
+static gboolean is_sre_field_builder (MonoClass *klass);
+static gboolean is_sr_mono_method (MonoClass *klass);
+static gboolean is_sr_mono_cmethod (MonoClass *klass);
+static gboolean is_sr_mono_generic_method (MonoClass *klass);
+static gboolean is_sr_mono_generic_cmethod (MonoClass *klass);
+static gboolean is_sr_mono_field (MonoClass *klass);
+static gboolean is_sr_mono_property (MonoClass *klass);
+static gboolean is_sre_method_on_tb_inst (MonoClass *klass);
+static gboolean is_sre_ctor_on_tb_inst (MonoClass *klass);
static guint32 mono_image_get_methodspec_token (MonoDynamicImage *assembly, MonoMethod *method);
static guint32 mono_image_get_inflated_method_token (MonoDynamicImage *assembly, MonoMethod *m);
for (i = 0; i < type->num_mods; ++i) {
if (field_image) {
MonoError error;
- MonoClass *class = mono_class_get_checked (field_image, type->modifiers [i].token, &error);
+ MonoClass *klass = mono_class_get_checked (field_image, type->modifiers [i].token, &error);
g_assert (mono_error_ok (&error)); /* FIXME don't swallow the error */
- token = mono_image_typedef_or_ref (assembly, &class->byval_arg);
+ token = mono_image_typedef_or_ref (assembly, &klass->byval_arg);
} else {
token = type->modifiers [i].token;
}
guint32 idx;
guint32 typespec = 0;
MonoType *type;
- MonoClass *class;
+ MonoClass *klass;
init_type_builder_generics (fb->type);
type = mono_reflection_type_get_handle ((MonoReflectionType*)fb->type);
- class = mono_class_from_mono_type (type);
+ klass = mono_class_from_mono_type (type);
sigbuffer_init (&buf, 32);
encode_custom_modifiers (assembly, fb->modreq, fb->modopt, &buf);
/* encode custom attributes before the type */
- if (class->generic_container)
+ if (klass->generic_container)
typespec = create_typespec (assembly, type);
if (typespec) {
MonoGenericClass *gclass;
- gclass = mono_metadata_lookup_generic_class (class, class->generic_container->context.class_inst, TRUE);
+ gclass = mono_metadata_lookup_generic_class (klass, klass->generic_container->context.class_inst, TRUE);
encode_generic_class (assembly, gclass, &buf);
} else {
encode_type (assembly, type, &buf);
static MonoType*
get_field_on_inst_generic_type (MonoClassField *field)
{
- MonoClass *class, *gtd;
+ MonoClass *klass, *gtd;
MonoDynamicGenericClass *dgclass;
int field_index;
return dgclass->field_generic_types [field_index];
}
- class = field->parent;
- gtd = class->generic_class->container_class;
+ klass = field->parent;
+ gtd = klass->generic_class->container_class;
- if (field >= class->fields && field - class->fields < class->field.count) {
- field_index = field - class->fields;
+ if (field >= klass->fields && field - klass->fields < klass->field.count) {
+ field_index = field - klass->fields;
return gtd->fields [field_index].type;
}
CHECK_OBJECT (MonoReflectionAssembly *, assembly, NULL);
if (!assembly_type) {
- MonoClass *class = mono_class_from_name (mono_defaults.corlib, "System.Reflection", "MonoAssembly");
- if (class == NULL)
- class = mono_class_from_name (mono_defaults.corlib, "System.Reflection", "Assembly");
- g_assert (class);
- assembly_type = class;
+ MonoClass *klass = mono_class_from_name (mono_defaults.corlib, "System.Reflection", "MonoAssembly");
+ if (klass == NULL)
+ klass = mono_class_from_name (mono_defaults.corlib, "System.Reflection", "Assembly");
+ g_assert (klass);
+ assembly_type = klass;
}
res = (MonoReflectionAssembly *)mono_object_new (domain, assembly_type);
res->assembly = assembly;
CHECK_OBJECT (MonoReflectionModule *, image, NULL);
if (!module_type) {
- MonoClass *class = mono_class_from_name (mono_defaults.corlib, "System.Reflection", "MonoModule");
- if (class == NULL)
- class = mono_class_from_name (mono_defaults.corlib, "System.Reflection", "Module");
- g_assert (class);
- module_type = class;
+ MonoClass *klass = mono_class_from_name (mono_defaults.corlib, "System.Reflection", "MonoModule");
+ if (klass == NULL)
+ klass = mono_class_from_name (mono_defaults.corlib, "System.Reflection", "Module");
+ g_assert (klass);
+ module_type = klass;
}
res = (MonoReflectionModule *)mono_object_new (domain, module_type);
const char *val;
if (!module_type) {
- MonoClass *class = mono_class_from_name (mono_defaults.corlib, "System.Reflection", "MonoModule");
- if (class == NULL)
- class = mono_class_from_name (mono_defaults.corlib, "System.Reflection", "Module");
- g_assert (class);
- module_type = class;
+ MonoClass *klass = mono_class_from_name (mono_defaults.corlib, "System.Reflection", "MonoModule");
+ if (klass == NULL)
+ klass = mono_class_from_name (mono_defaults.corlib, "System.Reflection", "Module");
+ g_assert (klass);
+ module_type = klass;
}
res = (MonoReflectionModule *)mono_object_new (domain, module_type);
static gboolean
-is_corlib_type (MonoClass *class)
+is_corlib_type (MonoClass *klass)
{
- return class->image == mono_defaults.corlib;
+ return klass->image == mono_defaults.corlib;
}
#define check_corlib_type_cached(_class, _namespace, _name) do { \
#ifndef DISABLE_REFLECTION_EMIT
static gboolean
-is_sre_array (MonoClass *class)
+is_sre_array (MonoClass *klass)
{
- check_corlib_type_cached (class, "System.Reflection.Emit", "ArrayType");
+ check_corlib_type_cached (klass, "System.Reflection.Emit", "ArrayType");
}
static gboolean
-is_sre_byref (MonoClass *class)
+is_sre_byref (MonoClass *klass)
{
- check_corlib_type_cached (class, "System.Reflection.Emit", "ByRefType");
+ check_corlib_type_cached (klass, "System.Reflection.Emit", "ByRefType");
}
static gboolean
-is_sre_pointer (MonoClass *class)
+is_sre_pointer (MonoClass *klass)
{
- check_corlib_type_cached (class, "System.Reflection.Emit", "PointerType");
+ check_corlib_type_cached (klass, "System.Reflection.Emit", "PointerType");
}
static gboolean
-is_sre_generic_instance (MonoClass *class)
+is_sre_generic_instance (MonoClass *klass)
{
- check_corlib_type_cached (class, "System.Reflection", "MonoGenericClass");
+ check_corlib_type_cached (klass, "System.Reflection", "MonoGenericClass");
}
static gboolean
-is_sre_type_builder (MonoClass *class)
+is_sre_type_builder (MonoClass *klass)
{
- check_corlib_type_cached (class, "System.Reflection.Emit", "TypeBuilder");
+ check_corlib_type_cached (klass, "System.Reflection.Emit", "TypeBuilder");
}
static gboolean
-is_sre_method_builder (MonoClass *class)
+is_sre_method_builder (MonoClass *klass)
{
- check_corlib_type_cached (class, "System.Reflection.Emit", "MethodBuilder");
+ check_corlib_type_cached (klass, "System.Reflection.Emit", "MethodBuilder");
}
static gboolean
-is_sre_ctor_builder (MonoClass *class)
+is_sre_ctor_builder (MonoClass *klass)
{
- check_corlib_type_cached (class, "System.Reflection.Emit", "ConstructorBuilder");
+ check_corlib_type_cached (klass, "System.Reflection.Emit", "ConstructorBuilder");
}
static gboolean
-is_sre_field_builder (MonoClass *class)
+is_sre_field_builder (MonoClass *klass)
{
- check_corlib_type_cached (class, "System.Reflection.Emit", "FieldBuilder");
+ check_corlib_type_cached (klass, "System.Reflection.Emit", "FieldBuilder");
}
static gboolean
-is_sre_method_on_tb_inst (MonoClass *class)
+is_sre_method_on_tb_inst (MonoClass *klass)
{
- check_corlib_type_cached (class, "System.Reflection.Emit", "MethodOnTypeBuilderInst");
+ check_corlib_type_cached (klass, "System.Reflection.Emit", "MethodOnTypeBuilderInst");
}
static gboolean
-is_sre_ctor_on_tb_inst (MonoClass *class)
+is_sre_ctor_on_tb_inst (MonoClass *klass)
{
- check_corlib_type_cached (class, "System.Reflection.Emit", "ConstructorOnTypeBuilderInst");
+ check_corlib_type_cached (klass, "System.Reflection.Emit", "ConstructorOnTypeBuilderInst");
}
MonoType*
mono_reflection_type_get_handle (MonoReflectionType* ref)
{
- MonoClass *class;
+ MonoClass *klass;
if (!ref)
return NULL;
if (ref->type)
return ref->type;
}
- class = mono_object_class (ref);
+ klass = mono_object_class (ref);
- if (is_sre_array (class)) {
+ if (is_sre_array (klass)) {
MonoType *res;
MonoReflectionArrayType *sre_array = (MonoReflectionArrayType*)ref;
MonoType *base = mono_reflection_type_get_handle (sre_array->element_type);
res = &mono_bounded_array_class_get (mono_class_from_mono_type (base), sre_array->rank, TRUE)->byval_arg;
sre_array->type.type = res;
return res;
- } else if (is_sre_byref (class)) {
+ } else if (is_sre_byref (klass)) {
MonoType *res;
MonoReflectionDerivedType *sre_byref = (MonoReflectionDerivedType*)ref;
MonoType *base = mono_reflection_type_get_handle (sre_byref->element_type);
res = &mono_class_from_mono_type (base)->this_arg;
sre_byref->type.type = res;
return res;
- } else if (is_sre_pointer (class)) {
+ } else if (is_sre_pointer (klass)) {
MonoType *res;
MonoReflectionDerivedType *sre_pointer = (MonoReflectionDerivedType*)ref;
MonoType *base = mono_reflection_type_get_handle (sre_pointer->element_type);
res = &mono_ptr_class_get (base)->byval_arg;
sre_pointer->type.type = res;
return res;
- } else if (is_sre_generic_instance (class)) {
+ } else if (is_sre_generic_instance (klass)) {
MonoType *res, **types;
MonoReflectionGenericClass *gclass = (MonoReflectionGenericClass*)ref;
int i, count;
{
MonoType *res = mono_reflection_type_get_handle (type);
MonoDomain *domain = mono_object_domain ((MonoObject*)type);
- MonoClass *class;
+ MonoClass *klass;
if (!res)
mono_raise_exception (mono_get_exception_argument (NULL, "Invalid generic instantiation, one or more arguments are not proper user types"));
- class = mono_class_from_mono_type (res);
+ klass = mono_class_from_mono_type (res);
mono_loader_lock (); /*same locking as mono_type_get_object*/
mono_domain_lock (domain);
- if (!image_is_dynamic (class->image)) {
- mono_class_setup_supertypes (class);
+ if (!image_is_dynamic (klass->image)) {
+ mono_class_setup_supertypes (klass);
} else {
if (!domain->type_hash)
domain->type_hash = mono_g_hash_table_new_type ((GHashFunc)mono_metadata_type_hash,
}
static gboolean
-is_sre_type_builder (MonoClass *class)
+is_sre_type_builder (MonoClass *klass)
{
return FALSE;
}
static gboolean
-is_sre_generic_instance (MonoClass *class)
+is_sre_generic_instance (MonoClass *klass)
{
return FALSE;
}
static gboolean
-is_sr_mono_field (MonoClass *class)
+is_sr_mono_field (MonoClass *klass)
{
- check_corlib_type_cached (class, "System.Reflection", "MonoField");
+ check_corlib_type_cached (klass, "System.Reflection", "MonoField");
}
static gboolean
-is_sr_mono_property (MonoClass *class)
+is_sr_mono_property (MonoClass *klass)
{
- check_corlib_type_cached (class, "System.Reflection", "MonoProperty");
+ check_corlib_type_cached (klass, "System.Reflection", "MonoProperty");
}
static gboolean
-is_sr_mono_method (MonoClass *class)
+is_sr_mono_method (MonoClass *klass)
{
- check_corlib_type_cached (class, "System.Reflection", "MonoMethod");
+ check_corlib_type_cached (klass, "System.Reflection", "MonoMethod");
}
static gboolean
-is_sr_mono_cmethod (MonoClass *class)
+is_sr_mono_cmethod (MonoClass *klass)
{
- check_corlib_type_cached (class, "System.Reflection", "MonoCMethod");
+ check_corlib_type_cached (klass, "System.Reflection", "MonoCMethod");
}
static gboolean
-is_sr_mono_generic_method (MonoClass *class)
+is_sr_mono_generic_method (MonoClass *klass)
{
- check_corlib_type_cached (class, "System.Reflection", "MonoGenericMethod");
+ check_corlib_type_cached (klass, "System.Reflection", "MonoGenericMethod");
}
static gboolean
-is_sr_mono_generic_cmethod (MonoClass *class)
+is_sr_mono_generic_cmethod (MonoClass *klass)
{
- check_corlib_type_cached (class, "System.Reflection", "MonoGenericCMethod");
+ check_corlib_type_cached (klass, "System.Reflection", "MonoGenericCMethod");
}
gboolean
-mono_class_is_reflection_method_or_constructor (MonoClass *class)
+mono_class_is_reflection_method_or_constructor (MonoClass *klass)
{
- return is_sr_mono_method (class) || is_sr_mono_cmethod (class) || is_sr_mono_generic_method (class) || is_sr_mono_generic_cmethod (class);
+ return is_sr_mono_method (klass) || is_sr_mono_cmethod (klass) || is_sr_mono_generic_method (klass) || is_sr_mono_generic_cmethod (klass);
}
static gboolean
is_usertype (MonoReflectionType *ref)
{
- MonoClass *class = mono_object_class (ref);
- return class->image != mono_defaults.corlib || strcmp ("TypeDelegator", class->name) == 0;
+ MonoClass *klass = mono_object_class (ref);
+ return klass->image != mono_defaults.corlib || strcmp ("TypeDelegator", klass->name) == 0;
}
static MonoReflectionType*
static MonoMethod*
mono_reflection_method_get_handle (MonoObject *method)
{
- MonoClass *class = mono_object_class (method);
- if (is_sr_mono_method (class) || is_sr_mono_generic_method (class)) {
+ MonoClass *klass = mono_object_class (method);
+ if (is_sr_mono_method (klass) || is_sr_mono_generic_method (klass)) {
MonoReflectionMethod *sr_method = (MonoReflectionMethod*)method;
return sr_method->method;
}
- if (is_sre_method_builder (class)) {
+ if (is_sre_method_builder (klass)) {
MonoReflectionMethodBuilder *mb = (MonoReflectionMethodBuilder*)method;
return mb->mhandle;
}
- if (is_sre_method_on_tb_inst (class)) {
+ if (is_sre_method_on_tb_inst (klass)) {
MonoReflectionMethodOnTypeBuilderInst *m = (MonoReflectionMethodOnTypeBuilderInst*)method;
MonoMethod *result;
/*FIXME move this to a proper method and unify with resolve_object*/
return result;
}
- g_error ("Can't handle methods of type %s:%s", class->name_space, class->name);
+ g_error ("Can't handle methods of type %s:%s", klass->name_space, klass->name);
return NULL;
}
ensure_complete_type (field->parent);
if (context) {
MonoType *inflated = mono_class_inflate_generic_type (&field->parent->byval_arg, context);
- MonoClass *class = mono_class_from_mono_type (inflated);
+ MonoClass *klass = mono_class_from_mono_type (inflated);
MonoClassField *inflated_field;
gpointer iter = NULL;
mono_metadata_free_type (inflated);
- while ((inflated_field = mono_class_get_fields (class, &iter))) {
+ while ((inflated_field = mono_class_get_fields (klass, &iter))) {
if (!strcmp (field->name, inflated_field->name))
break;
}
/* Create the method from the builder and place it in the cache */
static inline MonoMethod*
mono_remoting_mb_create_and_cache (MonoMethod *key, MonoMethodBuilder *mb,
- MonoMethodSignature *sig, int max_stack)
+ MonoMethodSignature *sig, int max_stack, WrapperInfo *info)
{
MonoMethod **res = NULL;
MonoRemotingMethods *wrps;
mono_marshal_lock_internal ();
if (!*res) {
*res = newm;
- mono_marshal_set_wrapper_info (*res, key);
+ mono_marshal_set_wrapper_info (*res, info);
mono_marshal_unlock_internal ();
} else {
mono_marshal_unlock_internal ();
gpointer* mparams = (gpointer*) alloca(count*sizeof(gpointer));
for (i=0; i<count; i++) {
- MonoClass *class = mono_class_from_mono_type (sig->params [i]);
- if (class->valuetype) {
+ MonoClass *klass = mono_class_from_mono_type (sig->params [i]);
+ if (klass->valuetype) {
if (sig->params [i]->byref) {
mparams[i] = *((gpointer *)params [i]);
} else {
/* runtime_invoke expects a boxed instance */
if (mono_class_is_nullable (mono_class_from_mono_type (sig->params [i])))
- mparams[i] = mono_nullable_box (params [i], class);
+ mparams[i] = mono_nullable_box (params [i], klass);
else
mparams[i] = params [i];
}
MonoMethodBuilder *mb;
MonoMethod *res;
int params_var;
+ WrapperInfo *info;
g_assert (method);
}
#endif
- res = mono_remoting_mb_create_and_cache (method, mb, sig, sig->param_count + 16);
+ info = mono_wrapper_info_create (mb, WRAPPER_SUBTYPE_NONE);
+ info->d.remoting.method = method;
+ res = mono_remoting_mb_create_and_cache (method, mb, sig, sig->param_count + 16, info);
mono_mb_free (mb);
return res;
MonoExceptionClause *main_clause;
int pos, pos_leave;
gboolean copy_return;
+ WrapperInfo *info;
if ((res = mono_marshal_remoting_find_in_cache (method, MONO_WRAPPER_XDOMAIN_DISPATCH)))
return res;
mono_mb_set_clauses (mb, 1, main_clause);
#endif
- res = mono_remoting_mb_create_and_cache (method, mb, csig, csig->param_count + 16);
+ info = mono_wrapper_info_create (mb, WRAPPER_SUBTYPE_NONE);
+ info->d.remoting.method = method;
+ res = mono_remoting_mb_create_and_cache (method, mb, csig, csig->param_count + 16, info);
mono_mb_free (mb);
return res;
int loc_old_domainid, loc_domainid, loc_return=0, loc_serialized_exc=0, loc_context;
int pos, pos_dispatch, pos_noex;
gboolean copy_return = FALSE;
+ WrapperInfo *info;
g_assert (method);
mono_mb_emit_byte (mb, CEE_RET);
#endif /* DISABLE_JIT */
- res = mono_remoting_mb_create_and_cache (method, mb, sig, sig->param_count + 16);
+ info = mono_wrapper_info_create (mb, WRAPPER_SUBTYPE_NONE);
+ info->d.remoting.method = method;
+ res = mono_remoting_mb_create_and_cache (method, mb, sig, sig->param_count + 16, info);
mono_mb_free (mb);
return res;
MonoMethodSignature *sig;
MonoMethodBuilder *mb;
MonoMethod *res, *native;
+ WrapperInfo *info;
int i, pos, pos_rem;
g_assert (method);
mono_mb_emit_byte (mb, CEE_RET);
#endif
- res = mono_remoting_mb_create_and_cache (method, mb, sig, sig->param_count + 16);
+ info = mono_wrapper_info_create (mb, WRAPPER_SUBTYPE_NONE);
+ info->d.remoting.method = method;
+ res = mono_remoting_mb_create_and_cache (method, mb, sig, sig->param_count + 16, info);
mono_mb_free (mb);
return res;
*
* This method generates a function which can be use to load a field with type
* @type from an object. The generated function has the following signature:
- * <@type> ldfld_wrapper (MonoObject *this, MonoClass *class, MonoClassField *field, int offset)
+ * <@type> ldfld_wrapper (MonoObject *this_obj, MonoClass *klass, MonoClassField *field, int offset)
*/
MonoMethod *
mono_marshal_get_ldfld_wrapper (MonoType *type)
*
* This method generates a function which can be used to load a field address
* from an object. The generated function has the following signature:
- * gpointer ldflda_wrapper (MonoObject *this, MonoClass *class, MonoClassField *field, int offset);
+ * gpointer ldflda_wrapper (MonoObject *this_obj, MonoClass *klass, MonoClassField *field, int offset);
*/
MonoMethod *
mono_marshal_get_ldflda_wrapper (MonoType *type)
*
* This method generates a function which can be use to store a field with type
* @type. The generated function has the following signature:
- * void stfld_wrapper (MonoObject *this, MonoClass *class, MonoClassField *field, int offset, <@type> val)
+ * void stfld_wrapper (MonoObject *this_obj, MonoClass *klass, MonoClassField *field, int offset, <@type> val)
*/
MonoMethod *
mono_marshal_get_stfld_wrapper (MonoType *type)
#include <mono/metadata/object.h>
#include <mono/metadata/exception.h>
#include <mono/metadata/debug-helpers.h>
-#include <mono/utils/mono-logger-internal.h>
+#include <mono/utils/mono-logger-internals.h>
#include "security-core-clr.h"
static MonoClass*
security_critical_attribute (void)
{
- static MonoClass *class = NULL;
+ static MonoClass *klass = NULL;
- if (!class) {
- class = mono_class_from_name (mono_defaults.corlib, "System.Security",
+ if (!klass) {
+ klass = mono_class_from_name (mono_defaults.corlib, "System.Security",
"SecurityCriticalAttribute");
}
- g_assert (class);
- return class;
+ g_assert (klass);
+ return klass;
}
static MonoClass*
security_safe_critical_attribute (void)
{
- static MonoClass *class = NULL;
+ static MonoClass *klass = NULL;
- if (!class) {
- class = mono_class_from_name (mono_defaults.corlib, "System.Security",
+ if (!klass) {
+ klass = mono_class_from_name (mono_defaults.corlib, "System.Security",
"SecuritySafeCriticalAttribute");
}
- g_assert (class);
- return class;
+ g_assert (klass);
+ return klass;
}
/* sometime we get a NULL (not found) caller (e.g. get_reflection_caller) */
* debugging purposes.
*/
static void
-set_type_load_exception_type (const char *format, MonoClass *class)
+set_type_load_exception_type (const char *format, MonoClass *klass)
{
- char *type_name = mono_type_get_full_name (class);
- char *parent_name = mono_type_get_full_name (class->parent);
+ char *type_name = mono_type_get_full_name (klass);
+ char *parent_name = mono_type_get_full_name (klass->parent);
char *message = g_strdup_printf (format, type_name, parent_name);
g_free (parent_name);
g_free (type_name);
mono_trace (G_LOG_LEVEL_WARNING, MONO_TRACE_SECURITY, message);
- mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, message);
+ mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, message);
// note: do not free string given to mono_class_set_failure
}
* Reference: fxcop CA2132 rule
*/
void
-mono_security_core_clr_check_inheritance (MonoClass *class)
+mono_security_core_clr_check_inheritance (MonoClass *klass)
{
MonoSecurityCoreCLRLevel class_level, parent_level;
- MonoClass *parent = class->parent;
+ MonoClass *parent = klass->parent;
if (!parent)
return;
- class_level = mono_security_core_clr_class_level (class);
+ class_level = mono_security_core_clr_class_level (klass);
parent_level = mono_security_core_clr_class_level (parent);
if (class_level < parent_level) {
set_type_load_exception_type (
"Inheritance failure for type %s. Parent class %s is more restricted.",
- class);
+ klass);
} else {
MonoMethod *parent_ctor = get_default_ctor (parent);
if (parent_ctor && ((parent_ctor->flags & METHOD_ATTRIBUTE_PUBLIC) != 0)) {
- class_level = mono_security_core_clr_method_level (get_default_ctor (class), FALSE);
+ class_level = mono_security_core_clr_method_level (get_default_ctor (klass), FALSE);
parent_level = mono_security_core_clr_method_level (parent_ctor, FALSE);
if (class_level < parent_level) {
set_type_load_exception_type (
"Inheritance failure for type %s. Default constructor security mismatch with %s.",
- class);
+ klass);
}
}
}
* Reference: http://msdn.microsoft.com/en-us/magazine/cc765416.aspx#id0190030
*/
void
-mono_security_core_clr_check_override (MonoClass *class, MonoMethod *override, MonoMethod *base)
+mono_security_core_clr_check_override (MonoClass *klass, MonoMethod *override, MonoMethod *base)
{
MonoSecurityCoreCLRLevel base_level = mono_security_core_clr_method_level (base, FALSE);
MonoSecurityCoreCLRLevel override_level = mono_security_core_clr_method_level (override, FALSE);
* - a check for the class and outer class(es) ...
*/
static MonoSecurityCoreCLRLevel
-mono_security_core_clr_class_level_no_platform_check (MonoClass *class)
+mono_security_core_clr_class_level_no_platform_check (MonoClass *klass)
{
MonoSecurityCoreCLRLevel level = MONO_SECURITY_CORE_CLR_TRANSPARENT;
- MonoCustomAttrInfo *cinfo = mono_custom_attrs_from_class (class);
+ MonoCustomAttrInfo *cinfo = mono_custom_attrs_from_class (klass);
if (cinfo) {
- level = mono_security_core_clr_level_from_cinfo (cinfo, class->image);
+ level = mono_security_core_clr_level_from_cinfo (cinfo, klass->image);
mono_custom_attrs_free (cinfo);
}
- if (level == MONO_SECURITY_CORE_CLR_TRANSPARENT && class->nested_in)
- level = mono_security_core_clr_class_level_no_platform_check (class->nested_in);
+ if (level == MONO_SECURITY_CORE_CLR_TRANSPARENT && klass->nested_in)
+ level = mono_security_core_clr_class_level_no_platform_check (klass->nested_in);
return level;
}
* Return the MonoSecurityCoreCLRLevel for the specified class.
*/
MonoSecurityCoreCLRLevel
-mono_security_core_clr_class_level (MonoClass *class)
+mono_security_core_clr_class_level (MonoClass *klass)
{
/* non-platform code is always Transparent - whatever the attributes says */
- if (!mono_security_core_clr_test && !mono_security_core_clr_is_platform_image (class->image))
+ if (!mono_security_core_clr_test && !mono_security_core_clr_is_platform_image (klass->image))
return MONO_SECURITY_CORE_CLR_TRANSPARENT;
- return mono_security_core_clr_class_level_no_platform_check (class);
+ return mono_security_core_clr_class_level_no_platform_check (klass);
}
/*
#else
void
-mono_security_core_clr_check_inheritance (MonoClass *class)
+mono_security_core_clr_check_inheritance (MonoClass *klass)
{
}
void
-mono_security_core_clr_check_override (MonoClass *class, MonoMethod *override, MonoMethod *base)
+mono_security_core_clr_check_override (MonoClass *klass, MonoMethod *override, MonoMethod *base)
{
}
}
MonoSecurityCoreCLRLevel
-mono_security_core_clr_class_level (MonoClass *class)
+mono_security_core_clr_class_level (MonoClass *klass)
{
return MONO_SECURITY_CORE_CLR_TRANSPARENT;
}
+++ /dev/null
-/*
- * sgen-bridge-internal.h: The cross-GC bridge.
- *
- * Copyright (C) 2015 Xamarin Inc
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License 2.0 as published by the Free Software Foundation;
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License 2.0 along with this library; if not, write to the Free
- * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-#ifndef __MONO_SGENBRIDGEINTERNAL_H__
-#define __MONO_SGENBRIDGEINTERNAL_H__
-
-#include "config.h"
-
-#ifdef HAVE_SGEN_GC
-
-#include "mono/utils/mono-compiler.h"
-
-#include "mono/sgen/sgen-gc.h"
-#include "mono/metadata/sgen-bridge.h"
-
-extern volatile gboolean bridge_processing_in_progress;
-extern MonoGCBridgeCallbacks bridge_callbacks;
-
-gboolean sgen_need_bridge_processing (void);
-void sgen_bridge_reset_data (void);
-void sgen_bridge_processing_stw_step (void);
-void sgen_bridge_processing_finish (int generation);
-gboolean sgen_is_bridge_object (GCObject *obj);
-MonoGCBridgeObjectKind sgen_bridge_class_kind (MonoClass *klass);
-void sgen_bridge_register_finalized_object (GCObject *object);
-void sgen_bridge_describe_pointer (GCObject *object);
-
-gboolean sgen_is_bridge_object (GCObject *obj);
-void sgen_mark_bridge_object (GCObject *obj);
-
-gboolean sgen_bridge_handle_gc_debug (const char *opt);
-void sgen_bridge_print_gc_debug_usage (void);
-
-typedef struct {
- void (*reset_data) (void);
- void (*processing_stw_step) (void);
- void (*processing_build_callback_data) (int generation);
- void (*processing_after_callback) (int generation);
- MonoGCBridgeObjectKind (*class_kind) (MonoClass *class);
- void (*register_finalized_object) (GCObject *object);
- void (*describe_pointer) (GCObject *object);
- void (*enable_accounting) (void);
- void (*set_dump_prefix) (const char *prefix);
-
- /*
- * These are set by processing_build_callback_data().
- */
- int num_sccs;
- MonoGCBridgeSCC **api_sccs;
-
- int num_xrefs;
- MonoGCBridgeXRef *api_xrefs;
-} SgenBridgeProcessor;
-
-void sgen_old_bridge_init (SgenBridgeProcessor *collector);
-void sgen_new_bridge_init (SgenBridgeProcessor *collector);
-void sgen_tarjan_bridge_init (SgenBridgeProcessor *collector);
-void sgen_set_bridge_implementation (const char *name);
-void sgen_bridge_set_dump_prefix (const char *prefix);
-
-#endif
-
-#endif
--- /dev/null
+/*
+ * sgen-bridge-internals.h: The cross-GC bridge.
+ *
+ * Copyright (C) 2015 Xamarin Inc
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License 2.0 as published by the Free Software Foundation;
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License 2.0 along with this library; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#ifndef __MONO_SGENBRIDGEINTERNAL_H__
+#define __MONO_SGENBRIDGEINTERNAL_H__
+
+#include "config.h"
+
+#ifdef HAVE_SGEN_GC
+
+#include "mono/utils/mono-compiler.h"
+
+#include "mono/sgen/sgen-gc.h"
+#include "mono/metadata/sgen-bridge.h"
+
+extern volatile gboolean bridge_processing_in_progress;
+extern MonoGCBridgeCallbacks bridge_callbacks;
+
+gboolean sgen_need_bridge_processing (void);
+void sgen_bridge_reset_data (void);
+void sgen_bridge_processing_stw_step (void);
+void sgen_bridge_processing_finish (int generation);
+gboolean sgen_is_bridge_object (GCObject *obj);
+MonoGCBridgeObjectKind sgen_bridge_class_kind (MonoClass *klass);
+void sgen_bridge_register_finalized_object (GCObject *object);
+void sgen_bridge_describe_pointer (GCObject *object);
+
+gboolean sgen_is_bridge_object (GCObject *obj);
+void sgen_mark_bridge_object (GCObject *obj);
+
+gboolean sgen_bridge_handle_gc_debug (const char *opt);
+void sgen_bridge_print_gc_debug_usage (void);
+
+typedef struct {
+ void (*reset_data) (void);
+ void (*processing_stw_step) (void);
+ void (*processing_build_callback_data) (int generation);
+ void (*processing_after_callback) (int generation);
+ MonoGCBridgeObjectKind (*class_kind) (MonoClass *klass);
+ void (*register_finalized_object) (GCObject *object);
+ void (*describe_pointer) (GCObject *object);
+ void (*enable_accounting) (void);
+ void (*set_dump_prefix) (const char *prefix);
+
+ /*
+ * These are set by processing_build_callback_data().
+ */
+ int num_sccs;
+ MonoGCBridgeSCC **api_sccs;
+
+ int num_xrefs;
+ MonoGCBridgeXRef *api_xrefs;
+} SgenBridgeProcessor;
+
+void sgen_old_bridge_init (SgenBridgeProcessor *collector);
+void sgen_new_bridge_init (SgenBridgeProcessor *collector);
+void sgen_tarjan_bridge_init (SgenBridgeProcessor *collector);
+void sgen_set_bridge_implementation (const char *name);
+void sgen_bridge_set_dump_prefix (const char *prefix);
+
+#endif
+
+#endif
#include <stdlib.h>
#include "sgen/sgen-gc.h"
-#include "sgen-bridge-internal.h"
+#include "sgen-bridge-internals.h"
#include "sgen/sgen-hash-table.h"
#include "sgen/sgen-qsort.h"
-#include "utils/mono-logger-internal.h"
+#include "utils/mono-logger-internals.h"
MonoGCBridgeCallbacks bridge_callbacks;
static SgenBridgeProcessor bridge_processor;
}
MonoGCBridgeObjectKind
-sgen_bridge_class_kind (MonoClass *class)
+sgen_bridge_class_kind (MonoClass *klass)
{
- return bridge_processor.class_kind (class);
+ return bridge_processor.class_kind (klass);
}
void
static const char *bridge_class;
static MonoGCBridgeObjectKind
-bridge_test_bridge_class_kind (MonoClass *class)
+bridge_test_bridge_class_kind (MonoClass *klass)
{
- if (!strcmp (bridge_class, class->name))
+ if (!strcmp (bridge_class, klass->name))
return GC_BRIDGE_TRANSPARENT_BRIDGE_CLASS;
return GC_BRIDGE_TRANSPARENT_CLASS;
}
#include "metadata/profiler-private.h"
#include "utils/dtrace.h"
#include "utils/mono-counters.h"
-#include "utils/mono-logger-internal.h"
+#include "utils/mono-logger-internals.h"
#include "utils/mono-time.h"
#include "utils/mono-semaphore.h"
-#include "metadata/sgen-bridge-internal.h"
+#include "metadata/sgen-bridge-internals.h"
extern void mono_sgen_register_moved_object (void *obj, void *destination);
extern void mono_sgen_gc_event_moves (void);
static gboolean G_GNUC_UNUSED
sgen_client_object_has_critical_finalizer (GCObject *obj)
{
- MonoClass *class;
+ MonoClass *klass;
if (!mono_defaults.critical_finalizer_object)
return FALSE;
- class = SGEN_LOAD_VTABLE (obj)->klass;
+ klass = SGEN_LOAD_VTABLE (obj)->klass;
- return mono_class_has_parent_fast (class, mono_defaults.critical_finalizer_object);
+ return mono_class_has_parent_fast (klass, mono_defaults.critical_finalizer_object);
}
const char* sgen_client_vtable_get_namespace (GCVTable vtable);
#include "metadata/abi-details.h"
#include "metadata/mono-gc.h"
#include "metadata/runtime.h"
-#include "metadata/sgen-bridge-internal.h"
-#include "metadata/gc-internal.h"
+#include "metadata/sgen-bridge-internals.h"
+#include "metadata/gc-internals.h"
#include "utils/mono-memory-model.h"
-#include "utils/mono-logger-internal.h"
+#include "utils/mono-logger-internals.h"
#ifdef HEAVY_STATISTICS
static guint64 stat_wbarrier_set_arrayref = 0;
*/
mono_mb_emit_byte (mb, MONO_CUSTOM_PREFIX);
mono_mb_emit_byte (mb, CEE_MONO_LDPTR_NURSERY_START);
- mono_mb_emit_icon (mb, DEFAULT_NURSERY_BITS);
+ mono_mb_emit_byte (mb, MONO_CUSTOM_PREFIX);
+ mono_mb_emit_byte (mb, CEE_MONO_LDPTR_NURSERY_BITS);
mono_mb_emit_byte (mb, CEE_SHR_UN);
mono_mb_emit_stloc (mb, shifted_nursery_start);
mono_mb_emit_ldarg (mb, 0);
- mono_mb_emit_icon (mb, DEFAULT_NURSERY_BITS);
+ mono_mb_emit_byte (mb, MONO_CUSTOM_PREFIX);
+ mono_mb_emit_byte (mb, CEE_MONO_LDPTR_NURSERY_BITS);
mono_mb_emit_byte (mb, CEE_SHR_UN);
mono_mb_emit_ldloc (mb, shifted_nursery_start);
nursery_check_return_labels [0] = mono_mb_emit_branch (mb, CEE_BEQ);
// if (!ptr_in_nursery (*ptr)) return;
mono_mb_emit_ldarg (mb, 0);
mono_mb_emit_byte (mb, CEE_LDIND_I);
- mono_mb_emit_icon (mb, DEFAULT_NURSERY_BITS);
+ mono_mb_emit_byte (mb, MONO_CUSTOM_PREFIX);
+ mono_mb_emit_byte (mb, CEE_MONO_LDPTR_NURSERY_BITS);
mono_mb_emit_byte (mb, CEE_SHR_UN);
mono_mb_emit_ldloc (mb, shifted_nursery_start);
nursery_check_return_labels [1] = mono_mb_emit_branch (mb, CEE_BNE_UN);
MonoMethodBuilder *mb;
MonoMethodSignature *sig;
MonoMethod **write_barrier_method_addr;
+ WrapperInfo *info;
#ifdef MANAGED_WBARRIER
int i, nursery_check_labels [2];
#endif
#endif
#endif
res = mono_mb_create_method (mb, sig, 16);
+ info = mono_wrapper_info_create (mb, WRAPPER_SUBTYPE_NONE);
+ mono_marshal_set_wrapper_info (res, info);
mono_mb_free (mb);
LOCK_GC;
static MonoGCFinalizerCallbacks fin_callbacks;
guint
-mono_gc_get_vtable_bits (MonoClass *class)
+mono_gc_get_vtable_bits (MonoClass *klass)
{
guint res = 0;
/* FIXME move this to the bridge code */
if (sgen_need_bridge_processing ()) {
- switch (sgen_bridge_class_kind (class)) {
+ switch (sgen_bridge_class_kind (klass)) {
case GC_BRIDGE_TRANSPARENT_BRIDGE_CLASS:
case GC_BRIDGE_OPAQUE_BRIDGE_CLASS:
res = SGEN_GC_BIT_BRIDGE_OBJECT;
}
}
if (fin_callbacks.is_class_finalization_aware) {
- if (fin_callbacks.is_class_finalization_aware (class))
+ if (fin_callbacks.is_class_finalization_aware (klass))
res |= SGEN_GC_BIT_FINALIZER_AWARE;
}
return res;
static gboolean registered = FALSE;
int tlab_next_addr_var, new_next_var;
const char *name = NULL;
- AllocatorWrapperInfo *info;
+ WrapperInfo *info;
int num_params, i;
if (!registered) {
mono_mb_emit_byte (mb, CEE_RET);
#endif
- res = mono_mb_create_method (mb, csig, 8);
+ info = mono_wrapper_info_create (mb, WRAPPER_SUBTYPE_NONE);
+ info->d.alloc.gc_name = "sgen";
+ info->d.alloc.alloc_type = atype;
+
+ res = mono_mb_create (mb, csig, 8, info);
mono_mb_free (mb);
#ifndef DISABLE_JIT
mono_method_get_header (res)->init_locals = FALSE;
#endif
- info = mono_image_alloc0 (mono_defaults.corlib, sizeof (AllocatorWrapperInfo));
- info->gc_name = "sgen";
- info->alloc_type = atype;
- mono_marshal_set_wrapper_info (res, info);
return res;
}
if (!strcmp (opt, "xdomain-checks")) {
sgen_mono_xdomain_checks = TRUE;
} else if (!strcmp (opt, "do-not-finalize")) {
- do_not_finalize = TRUE;
+ mono_do_not_finalize = TRUE;
+ } else if (g_str_has_prefix (opt, "do-not-finalize=")) {
+ opt = strchr (opt, '=') + 1;
+ mono_do_not_finalize = TRUE;
+ mono_do_not_finalize_class_names = g_strsplit (opt, ",", 0);
} else if (!strcmp (opt, "log-finalizers")) {
log_finalizers = TRUE;
} else if (!strcmp (opt, "no-managed-allocator")) {
#include <errno.h>
#include "sgen/sgen-gc.h"
-#include "sgen-bridge-internal.h"
+#include "sgen-bridge-internals.h"
#include "sgen/sgen-hash-table.h"
#include "sgen/sgen-qsort.h"
#include "sgen/sgen-client.h"
#include "tabledefs.h"
-#include "utils/mono-logger-internal.h"
+#include "utils/mono-logger-internals.h"
//#define NEW_XREFS
#ifdef NEW_XREFS
}
static MonoGCBridgeObjectKind
-class_kind (MonoClass *class)
+class_kind (MonoClass *klass)
{
- MonoGCBridgeObjectKind res = bridge_callbacks.bridge_class_kind (class);
+ MonoGCBridgeObjectKind res = bridge_callbacks.bridge_class_kind (klass);
/* If it's a bridge, nothing we can do about it. */
if (res == GC_BRIDGE_TRANSPARENT_BRIDGE_CLASS || res == GC_BRIDGE_OPAQUE_BRIDGE_CLASS)
return res;
/* Non bridge classes with no pointers will never point to a bridge, so we can savely ignore them. */
- if (!class->has_references) {
- SGEN_LOG (6, "class %s is opaque\n", class->name);
+ if (!klass->has_references) {
+ SGEN_LOG (6, "class %s is opaque\n", klass->name);
return GC_BRIDGE_OPAQUE_CLASS;
}
/* Some arrays can be ignored */
- if (class->rank == 1) {
- MonoClass *elem_class = class->element_class;
+ if (klass->rank == 1) {
+ MonoClass *elem_class = klass->element_class;
/* FIXME the bridge check can be quite expensive, cache it at the class level. */
/* An array of a sealed type that is not a bridge will never get to a bridge */
if ((elem_class->flags & TYPE_ATTRIBUTE_SEALED) && !elem_class->has_references && !bridge_callbacks.bridge_class_kind (elem_class)) {
- SGEN_LOG (6, "class %s is opaque\n", class->name);
+ SGEN_LOG (6, "class %s is opaque\n", klass->name);
return GC_BRIDGE_OPAQUE_CLASS;
}
}
#include <stdlib.h>
#include "sgen/sgen-gc.h"
-#include "sgen-bridge-internal.h"
+#include "sgen-bridge-internals.h"
#include "sgen/sgen-hash-table.h"
#include "sgen/sgen-qsort.h"
#include "sgen/sgen-client.h"
-#include "utils/mono-logger-internal.h"
+#include "utils/mono-logger-internals.h"
typedef struct {
int size;
}
static MonoGCBridgeObjectKind
-class_kind (MonoClass *class)
+class_kind (MonoClass *klass)
{
- return bridge_callbacks.bridge_class_kind (class);
+ return bridge_callbacks.bridge_class_kind (klass);
}
static HashEntry*
#include "sgen/sgen-archdep.h"
#include "sgen/sgen-protocol.h"
#include "metadata/object-internals.h"
-#include "metadata/gc-internal.h"
+#include "metadata/gc-internals.h"
#if defined(USE_COOP_GC)
#include "sgen/sgen-protocol.h"
#include "sgen/sgen-thread-pool.h"
#include "metadata/object-internals.h"
-#include "metadata/gc-internal.h"
+#include "metadata/gc-internals.h"
#if defined(__MACH__)
#include "utils/mach-support.h"
#include <errno.h>
#include <glib.h>
#include "sgen/sgen-gc.h"
-#include "metadata/gc-internal.h"
+#include "metadata/gc-internals.h"
#include "sgen/sgen-archdep.h"
#include "metadata/object-internals.h"
#include "utils/mono-signal-handler.h"
#include "io-layer/io-layer.h"
#include "sgen/sgen-gc.h"
-#include "metadata/gc-internal.h"
+#include "metadata/gc-internals.h"
gboolean
sgen_resume_thread (SgenThreadInfo *info)
#include "sgen/sgen-thread-pool.h"
#include "metadata/profiler-private.h"
#include "sgen/sgen-client.h"
-#include "metadata/sgen-bridge-internal.h"
-#include "metadata/gc-internal.h"
+#include "metadata/sgen-bridge-internals.h"
+#include "metadata/gc-internals.h"
#define TV_DECLARE SGEN_TV_DECLARE
#define TV_GETTIME SGEN_TV_GETTIME
#include <stdlib.h>
#include "sgen/sgen-gc.h"
-#include "sgen-bridge-internal.h"
+#include "sgen-bridge-internals.h"
#include "sgen/sgen-hash-table.h"
#include "sgen/sgen-qsort.h"
#include "tabledefs.h"
-#include "utils/mono-logger-internal.h"
+#include "utils/mono-logger-internals.h"
typedef struct {
int size;
}
static MonoGCBridgeObjectKind
-class_kind (MonoClass *class)
+class_kind (MonoClass *klass)
{
- MonoGCBridgeObjectKind res = bridge_callbacks.bridge_class_kind (class);
+ MonoGCBridgeObjectKind res = bridge_callbacks.bridge_class_kind (klass);
/* If it's a bridge, nothing we can do about it. */
if (res == GC_BRIDGE_TRANSPARENT_BRIDGE_CLASS || res == GC_BRIDGE_OPAQUE_BRIDGE_CLASS)
return res;
/* Non bridge classes with no pointers will never point to a bridge, so we can savely ignore them. */
- if (!class->has_references) {
- SGEN_LOG (6, "class %s is opaque\n", class->name);
+ if (!klass->has_references) {
+ SGEN_LOG (6, "class %s is opaque\n", klass->name);
return GC_BRIDGE_OPAQUE_CLASS;
}
/* Some arrays can be ignored */
- if (class->rank == 1) {
- MonoClass *elem_class = class->element_class;
+ if (klass->rank == 1) {
+ MonoClass *elem_class = klass->element_class;
/* FIXME the bridge check can be quite expensive, cache it at the class level. */
/* An array of a sealed type that is not a bridge will never get to a bridge */
if ((elem_class->flags & TYPE_ATTRIBUTE_SEALED) && !elem_class->has_references && !bridge_callbacks.bridge_class_kind (elem_class)) {
- SGEN_LOG (6, "class %s is opaque\n", class->name);
+ SGEN_LOG (6, "class %s is opaque\n", klass->name);
return GC_BRIDGE_OPAQUE_CLASS;
}
}
#include <mono/metadata/debug-helpers.h>
#include <mono/metadata/profiler.h>
#include <mono/metadata/profiler-private.h>
-#include <mono/metadata/gc-internal.h>
+#include <mono/metadata/gc-internals.h>
/* This function is redirected to String.CreateString ()
by mono_marshal_get_native_wrapper () */
#include <fcntl.h>
#endif
-#include <mono/metadata/gc-internal.h>
+#include <mono/metadata/gc-internals.h>
#include <mono/metadata/mono-mlist.h>
#include <mono/metadata/threadpool-ms.h>
#include <mono/metadata/threadpool-ms-io.h>
#include <mono/utils/atomic.h>
#include <mono/utils/mono-threads.h>
#include <mono/utils/mono-lazy-init.h>
-#include <mono/utils/mono-logger-internal.h>
+#include <mono/utils/mono-logger-internals.h>
typedef struct {
gboolean (*init) (gint wakeup_pipe_fd);
#include <mono/metadata/class-internals.h>
#include <mono/metadata/exception.h>
-#include <mono/metadata/gc-internal.h>
+#include <mono/metadata/gc-internals.h>
#include <mono/metadata/object.h>
#include <mono/metadata/object-internals.h>
#include <mono/metadata/threadpool-ms.h>
#include <mono/utils/mono-complex.h>
#include <mono/utils/mono-lazy-init.h>
#include <mono/utils/mono-logger.h>
-#include <mono/utils/mono-logger-internal.h>
+#include <mono/utils/mono-logger-internals.h>
#include <mono/utils/mono-proclib.h>
#include <mono/utils/mono-threads.h>
#include <mono/utils/mono-time.h>
#include <mono/metadata/exception.h>
#include <mono/metadata/environment.h>
#include <mono/metadata/monitor.h>
-#include <mono/metadata/gc-internal.h>
+#include <mono/metadata/gc-internals.h>
#include <mono/metadata/marshal.h>
#include <mono/metadata/runtime.h>
#include <mono/io-layer/io-layer.h>
#include <mono/utils/atomic.h>
#include <mono/utils/mono-memory-model.h>
-#include <mono/metadata/gc-internal.h>
+#include <mono/metadata/gc-internals.h>
#ifdef HAVE_SIGNAL_H
#include <signal.h>
*/
mono_thread_new_init (tid, &tid, start_func);
internal->stack_ptr = &tid;
+ if (domain != mono_get_root_domain ())
+ set_current_thread_for_domain (domain, internal, start_info->obj);
LIBGC_DEBUG (g_message ("%s: (%"G_GSIZE_FORMAT",%d) Setting thread stack to %p", __func__, mono_native_thread_id_get (), getpid (), thread->stack_ptr));
}
int
-ves_icall_System_Threading_Thread_GetPriority (MonoThread *this)
+ves_icall_System_Threading_Thread_GetPriority (MonoThread *this_obj)
{
return ThreadPriority_Lowest;
}
MonoType* type;
if (ctx->method->wrapper_type != MONO_WRAPPER_NONE) {
- MonoClass *class = mono_method_get_wrapper_data (ctx->method, (guint32)token);
- type = class ? &class->byval_arg : NULL;
+ MonoClass *klass = mono_method_get_wrapper_data (ctx->method, (guint32)token);
+ type = klass ? &klass->byval_arg : NULL;
} else {
MonoError error;
if (!IS_TYPE_DEF_OR_REF_OR_SPEC (token) || !token_bounds_check (ctx->image, token)) {
get_boxable_mono_type (VerifyContext* ctx, int token, const char *opcode)
{
MonoType *type;
- MonoClass *class;
+ MonoClass *klass;
if (!(type = verifier_load_type (ctx, token, opcode)))
return NULL;
if (type->type == MONO_TYPE_TYPEDBYREF)
CODE_NOT_VERIFIABLE (ctx, g_strdup_printf ("Invalid use of typedbyref for %s at 0x%04x", opcode, ctx->ip_offset));
- if (!(class = mono_class_from_mono_type (type)))
+ if (!(klass = mono_class_from_mono_type (type)))
ADD_VERIFY_ERROR (ctx, g_strdup_printf ("Could not retrieve type token for %s at 0x%04x", opcode, ctx->ip_offset));
- if (class->generic_container && type->type != MONO_TYPE_GENERICINST)
+ if (klass->generic_container && type->type != MONO_TYPE_GENERICINST)
CODE_NOT_VERIFIABLE (ctx, g_strdup_printf ("Cannot use the generic type definition in a boxable type position for %s at 0x%04x", opcode, ctx->ip_offset));
check_unverifiable_type (ctx, type);
}
static gboolean
-verify_class_for_overlapping_reference_fields (MonoClass *class)
+verify_class_for_overlapping_reference_fields (MonoClass *klass)
{
int i = 0, j;
gpointer iter = NULL;
MonoClassField *field;
- gboolean is_fulltrust = mono_verifier_is_class_full_trust (class);
+ gboolean is_fulltrust = mono_verifier_is_class_full_trust (klass);
/*We can't skip types with !has_references since this is calculated after we have run.*/
- if (!((class->flags & TYPE_ATTRIBUTE_LAYOUT_MASK) == TYPE_ATTRIBUTE_EXPLICIT_LAYOUT))
+ if (!((klass->flags & TYPE_ATTRIBUTE_LAYOUT_MASK) == TYPE_ATTRIBUTE_EXPLICIT_LAYOUT))
return TRUE;
/*We must check for stuff overlapping reference fields.
The outer loop uses mono_class_get_fields to ensure that MonoClass:fields get inited.
*/
- while ((field = mono_class_get_fields (class, &iter))) {
+ while ((field = mono_class_get_fields (klass, &iter))) {
int fieldEnd = get_field_end (field);
gboolean is_valuetype = !MONO_TYPE_IS_REFERENCE (field->type);
++i;
if (mono_field_is_deleted (field) || (field->type->attrs & FIELD_ATTRIBUTE_STATIC))
continue;
- for (j = i; j < class->field.count; ++j) {
- MonoClassField *other = &class->fields [j];
+ for (j = i; j < klass->field.count; ++j) {
+ MonoClassField *other = &klass->fields [j];
int otherEnd = get_field_end (other);
if (mono_field_is_deleted (other) || (is_valuetype && !MONO_TYPE_IS_REFERENCE (other->type)) || (other->type->attrs & FIELD_ATTRIBUTE_STATIC))
continue;
static gboolean
-verify_class_fields (MonoClass *class)
+verify_class_fields (MonoClass *klass)
{
gpointer iter = NULL;
MonoClassField *field;
- MonoGenericContext *context = mono_class_get_context (class);
+ MonoGenericContext *context = mono_class_get_context (klass);
GHashTable *unique_fields = g_hash_table_new_full (&field_hash, &field_equals, NULL, NULL);
- if (class->generic_container)
- context = &class->generic_container->context;
+ if (klass->generic_container)
+ context = &klass->generic_container->context;
- while ((field = mono_class_get_fields (class, &iter)) != NULL) {
+ while ((field = mono_class_get_fields (klass, &iter)) != NULL) {
if (!mono_type_is_valid_type_in_context (field->type, context)) {
g_hash_table_destroy (unique_fields);
return FALSE;
}
static gboolean
-verify_interfaces (MonoClass *class)
+verify_interfaces (MonoClass *klass)
{
int i;
- for (i = 0; i < class->interface_count; ++i) {
- MonoClass *iface = class->interfaces [i];
+ for (i = 0; i < klass->interface_count; ++i) {
+ MonoClass *iface = klass->interfaces [i];
if (!(iface->flags & TYPE_ATTRIBUTE_INTERFACE))
return FALSE;
}
}
static gboolean
-verify_valuetype_layout_with_target (MonoClass *class, MonoClass *target_class)
+verify_valuetype_layout_with_target (MonoClass *klass, MonoClass *target_class)
{
int type;
gpointer iter = NULL;
MonoClassField *field;
MonoClass *field_class;
- if (!class->valuetype)
+ if (!klass->valuetype)
return TRUE;
- type = class->byval_arg.type;
+ type = klass->byval_arg.type;
/*primitive type fields are not properly decoded*/
if ((type >= MONO_TYPE_BOOLEAN && type <= MONO_TYPE_R8) || (type >= MONO_TYPE_I && type <= MONO_TYPE_U))
return TRUE;
- while ((field = mono_class_get_fields (class, &iter)) != NULL) {
+ while ((field = mono_class_get_fields (klass, &iter)) != NULL) {
if (!field->type)
return FALSE;
field_class = mono_class_get_generic_type_definition (mono_class_from_mono_type (field->type));
- if (field_class == target_class || class == field_class || !verify_valuetype_layout_with_target (field_class, target_class))
+ if (field_class == target_class || klass == field_class || !verify_valuetype_layout_with_target (field_class, target_class))
return FALSE;
}
}
static gboolean
-verify_valuetype_layout (MonoClass *class)
+verify_valuetype_layout (MonoClass *klass)
{
gboolean res;
- res = verify_valuetype_layout_with_target (class, class);
+ res = verify_valuetype_layout_with_target (klass, klass);
return res;
}
}
static gboolean
-verify_generic_parameters (MonoClass *class)
+verify_generic_parameters (MonoClass *klass)
{
int i;
- MonoGenericContainer *gc = class->generic_container;
+ MonoGenericContainer *gc = klass->generic_container;
MonoBitSet *used_args = mono_bitset_new (gc->type_argc, 0);
for (i = 0; i < gc->type_argc; ++i) {
MonoClass *ctr = *constraints;
MonoType *constraint_type = &ctr->byval_arg;
- if (!mono_class_can_access_class (class, ctr))
+ if (!mono_class_can_access_class (klass, ctr))
goto fail;
if (!mono_type_is_valid_type_in_context (constraint_type, &gc->context))
*
*/
gboolean
-mono_verifier_verify_class (MonoClass *class)
+mono_verifier_verify_class (MonoClass *klass)
{
/*Neither <Module>, object or ifaces have parent.*/
- if (!class->parent &&
- class != mono_defaults.object_class &&
- !MONO_CLASS_IS_INTERFACE (class) &&
- (!image_is_dynamic (class->image) && class->type_token != 0x2000001)) /*<Module> is the first type in the assembly*/
+ if (!klass->parent &&
+ klass != mono_defaults.object_class &&
+ !MONO_CLASS_IS_INTERFACE (klass) &&
+ (!image_is_dynamic (klass->image) && klass->type_token != 0x2000001)) /*<Module> is the first type in the assembly*/
return FALSE;
- if (class->parent) {
- if (MONO_CLASS_IS_INTERFACE (class->parent))
+ if (klass->parent) {
+ if (MONO_CLASS_IS_INTERFACE (klass->parent))
return FALSE;
- if (!class->generic_class && class->parent->generic_container)
+ if (!klass->generic_class && klass->parent->generic_container)
return FALSE;
- if (class->parent->generic_class && !class->generic_class) {
- MonoGenericContext *context = mono_class_get_context (class);
- if (class->generic_container)
- context = &class->generic_container->context;
- if (!mono_type_is_valid_type_in_context (&class->parent->byval_arg, context))
+ if (klass->parent->generic_class && !klass->generic_class) {
+ MonoGenericContext *context = mono_class_get_context (klass);
+ if (klass->generic_container)
+ context = &klass->generic_container->context;
+ if (!mono_type_is_valid_type_in_context (&klass->parent->byval_arg, context))
return FALSE;
}
}
- if (class->generic_container && (class->flags & TYPE_ATTRIBUTE_LAYOUT_MASK) == TYPE_ATTRIBUTE_EXPLICIT_LAYOUT)
+ if (klass->generic_container && (klass->flags & TYPE_ATTRIBUTE_LAYOUT_MASK) == TYPE_ATTRIBUTE_EXPLICIT_LAYOUT)
return FALSE;
- if (class->generic_container && !verify_generic_parameters (class))
+ if (klass->generic_container && !verify_generic_parameters (klass))
return FALSE;
- if (!verify_class_for_overlapping_reference_fields (class))
+ if (!verify_class_for_overlapping_reference_fields (klass))
return FALSE;
- if (class->generic_class && !mono_class_is_valid_generic_instantiation (NULL, class))
+ if (klass->generic_class && !mono_class_is_valid_generic_instantiation (NULL, klass))
return FALSE;
- if (class->generic_class == NULL && !verify_class_fields (class))
+ if (klass->generic_class == NULL && !verify_class_fields (klass))
return FALSE;
- if (class->valuetype && !verify_valuetype_layout (class))
+ if (klass->valuetype && !verify_valuetype_layout (klass))
return FALSE;
- if (!verify_interfaces (class))
+ if (!verify_interfaces (klass))
return FALSE;
return TRUE;
}
gboolean
-mono_verifier_class_is_valid_generic_instantiation (MonoClass *class)
+mono_verifier_class_is_valid_generic_instantiation (MonoClass *klass)
{
- return mono_class_is_valid_generic_instantiation (NULL, class);
+ return mono_class_is_valid_generic_instantiation (NULL, klass);
}
gboolean
#else
gboolean
-mono_verifier_verify_class (MonoClass *class)
+mono_verifier_verify_class (MonoClass *klass)
{
/* The verifier was disabled at compile time */
return TRUE;
}
gboolean
-mono_verifier_class_is_valid_generic_instantiation (MonoClass *class)
+mono_verifier_class_is_valid_generic_instantiation (MonoClass *klass)
{
return TRUE;
}
driver.c \
debug-mini.c \
linear-scan.c \
+ aot-compiler.h \
aot-compiler.c \
aot-runtime.c \
graph.c \
basic.cs \
exceptions.cs \
devirtualization.cs \
- iltests.il.in \
+ iltests.il \
test.cs \
generics.cs \
generics-variant-types.il\
%.exe: %.cs TestDriver.dll
$(MCS) -out:$@ $(CSFLAGS) $< -r:TestDriver.dll
-iltests.il: iltests.il.in Makefile.am
- echo '// DO NOT EDIT: This file has been generated from iltests.il.in' > iltests.il
- cpp -Darch=$(arch_define) < $(srcdir)/iltests.il.in | sed 's/^#.*//' >> iltests.il
-
%.exe: %.il
$(ILASM) -output=$@ $<
}
}
+/// Provide tests with the ability to find out how much time they have to run before being timed out.
+public class TestTimeout {
+ const string ENV_TIMEOUT = "TEST_DRIVER_TIMEOUT_SEC";
+ private readonly TimeSpan availableTime;
+ private TimeSpan slack;
+ private DateTime startTime;
+
+ /// <summary>
+ /// How much time the test runner provided for us or TimeSpan.Zero if there is no bound.
+ /// </summary>
+ public TimeSpan AvailableTime { get { return availableTime; } }
+
+ public DateTime StartTime { get { return startTime; } }
+
+ /// <summary> Extra time to add when deciding if there
+ /// is still time to run. Bigger slack means less
+ /// time left.
+ /// </summary>
+ public TimeSpan Slack {
+ get { return slack; }
+ set { slack = value; }
+ }
+
+ public TestTimeout () {
+ availableTime = initializeAvailableTime ();
+ slack = defaultSlack ();
+ }
+
+ /// <summary>
+ /// Consider the test started.
+ /// </summary>
+ public void Start ()
+ {
+ startTime = DateTime.UtcNow;
+ }
+
+ public bool HaveTimeLeft ()
+ {
+ if (availableTime == TimeSpan.Zero)
+ return true;
+ var t = DateTime.UtcNow;
+ var finishTime = startTime + availableTime - slack;
+ return (t < finishTime);
+ }
+
+ private TimeSpan defaultSlack ()
+ {
+ return TimeSpan.FromSeconds (5);
+ }
+
+ private TimeSpan initializeAvailableTime ()
+ {
+ var e = System.Environment.GetEnvironmentVariable(ENV_TIMEOUT);
+ double d;
+ if (Double.TryParse(e, out d)) {
+ return TimeSpan.FromSeconds(d);
+ } else {
+ return TimeSpan.Zero;
+ }
+ }
+
+}
#include <mono/metadata/assembly.h>
#include <mono/metadata/metadata-internals.h>
#include <mono/metadata/marshal.h>
-#include <mono/metadata/gc-internal.h>
+#include <mono/metadata/gc-internals.h>
#include <mono/metadata/mempool-internals.h>
#include <mono/metadata/mono-endian.h>
#include <mono/metadata/threads-types.h>
-#include <mono/utils/mono-logger-internal.h>
+#include <mono/utils/mono-logger-internals.h>
#include <mono/utils/mono-compiler.h>
#include <mono/utils/mono-time.h>
#include <mono/utils/mono-mmap.h>
#include <mono/utils/json.h>
-#include "mini.h"
+#include "aot-compiler.h"
#include "seq-points.h"
#include "image-writer.h"
#include "dwarfwriter.h"
encode_value ((MONO_AOT_METHODREF_NO_AOT_TRAMPOLINE << 24), p, &p);
if (method->wrapper_type) {
+ WrapperInfo *info = mono_marshal_get_wrapper_info (method);
+
encode_value ((MONO_AOT_METHODREF_WRAPPER << 24), p, &p);
encode_value (method->wrapper_type, p, &p);
case MONO_WRAPPER_LDFLDA:
case MONO_WRAPPER_STFLD:
case MONO_WRAPPER_ISINST: {
- WrapperInfo *info = mono_marshal_get_wrapper_info (method);
-
g_assert (info);
encode_klass_ref (acfg, info->d.proxy.klass, p, &p);
break;
case MONO_WRAPPER_STFLD_REMOTE:
break;
case MONO_WRAPPER_ALLOC: {
- AllocatorWrapperInfo *info = mono_marshal_get_wrapper_info (method);
-
/* The GC name is saved once in MonoAotFileInfo */
- g_assert (info->alloc_type != -1);
- encode_value (info->alloc_type, p, &p);
+ g_assert (info->d.alloc.alloc_type != -1);
+ encode_value (info->d.alloc.alloc_type, p, &p);
break;
}
- case MONO_WRAPPER_WRITE_BARRIER:
+ case MONO_WRAPPER_WRITE_BARRIER: {
+ g_assert (info);
break;
+ }
case MONO_WRAPPER_STELEMREF: {
- WrapperInfo *info = mono_marshal_get_wrapper_info (method);
-
g_assert (info);
encode_value (info->subtype, p, &p);
if (info->subtype == WRAPPER_SUBTYPE_VIRTUAL_STELEMREF)
break;
}
case MONO_WRAPPER_UNKNOWN: {
- WrapperInfo *info = mono_marshal_get_wrapper_info (method);
-
g_assert (info);
encode_value (info->subtype, p, &p);
if (info->subtype == WRAPPER_SUBTYPE_PTR_TO_STRUCTURE ||
break;
}
case MONO_WRAPPER_MANAGED_TO_NATIVE: {
- WrapperInfo *info = mono_marshal_get_wrapper_info (method);
-
g_assert (info);
encode_value (info->subtype, p, &p);
if (info->subtype == WRAPPER_SUBTYPE_ICALL_WRAPPER) {
break;
}
case MONO_WRAPPER_MANAGED_TO_MANAGED: {
- WrapperInfo *info = mono_marshal_get_wrapper_info (method);
-
g_assert (info);
encode_value (info->subtype, p, &p);
break;
}
case MONO_WRAPPER_CASTCLASS: {
- WrapperInfo *info = mono_marshal_get_wrapper_info (method);
-
g_assert (info);
encode_value (info->subtype, p, &p);
break;
}
case MONO_WRAPPER_RUNTIME_INVOKE: {
- WrapperInfo *info = mono_marshal_get_wrapper_info (method);
-
g_assert (info);
encode_value (info->subtype, p, &p);
encode_value (info->d.runtime_invoke.pass_rgctx, p, &p);
break;
}
case MONO_WRAPPER_NATIVE_TO_MANAGED: {
- WrapperInfo *info = mono_marshal_get_wrapper_info (method);
-
g_assert (info);
encode_method_ref (acfg, info->d.native_to_managed.method, p, &p);
encode_klass_ref (acfg, info->d.native_to_managed.klass, p, &p);
case MONO_PATCH_INFO_JIT_TLS_ID:
case MONO_PATCH_INFO_GC_CARD_TABLE_ADDR:
case MONO_PATCH_INFO_GC_NURSERY_START:
+ case MONO_PATCH_INFO_GC_NURSERY_BITS:
break;
case MONO_PATCH_INFO_CASTCLASS_CACHE:
encode_value (patch_info->data.index, p, &p);
if (patch_info->type == MONO_PATCH_INFO_GC_CARD_TABLE_ADDR ||
patch_info->type == MONO_PATCH_INFO_GC_NURSERY_START ||
+ patch_info->type == MONO_PATCH_INFO_GC_NURSERY_BITS ||
patch_info->type == MONO_PATCH_INFO_AOT_MODULE) {
/* Stored in a GOT slot initialized at module load time */
patch_info->type = MONO_PATCH_INFO_NONE;
case MONO_PATCH_INFO_NONE:
case MONO_PATCH_INFO_GC_CARD_TABLE_ADDR:
case MONO_PATCH_INFO_GC_NURSERY_START:
+ case MONO_PATCH_INFO_GC_NURSERY_BITS:
break;
case MONO_PATCH_INFO_IMAGE:
/* The assembly is stored in GOT slot 0 */
get_got_offset (acfg, FALSE, ji);
get_got_offset (acfg, TRUE, ji);
+ ji = mono_mempool_alloc0 (acfg->mempool, sizeof (MonoJumpInfo));
+ ji->type = MONO_PATCH_INFO_GC_NURSERY_BITS;
+ get_got_offset (acfg, FALSE, ji);
+ get_got_offset (acfg, TRUE, ji);
+
for (i = 0; i < sizeof (preinited_jit_icalls) / sizeof (char*); ++i) {
ji = mono_mempool_alloc0 (acfg->mempool, sizeof (MonoAotCompile));
ji->type = MONO_PATCH_INFO_INTERNAL_METHOD;
--- /dev/null
+#ifndef __MONO_AOT_COMPILER_H__
+#define __MONO_AOT_COMPILER_H__
+
+#include "mini.h"
+
+int mono_compile_assembly (MonoAssembly *ass, guint32 opts, const char *aot_options);
+void* mono_aot_readonly_field_override (MonoClassField *field);
+gboolean mono_aot_is_shared_got_offset (int offset) MONO_LLVM_INTERNAL;
+
+guint32 mono_aot_get_got_offset (MonoJumpInfo *ji) MONO_LLVM_INTERNAL;
+char* mono_aot_get_method_name (MonoCompile *cfg) MONO_LLVM_INTERNAL;
+gboolean mono_aot_is_direct_callable (MonoJumpInfo *patch_info) MONO_LLVM_INTERNAL;
+void mono_aot_mark_unused_llvm_plt_entry(MonoJumpInfo *patch_info) MONO_LLVM_INTERNAL;
+char* mono_aot_get_plt_symbol (MonoJumpInfoType type, gconstpointer data) MONO_LLVM_INTERNAL;
+char* mono_aot_get_direct_call_symbol (MonoJumpInfoType type, gconstpointer data);
+int mono_aot_get_method_index (MonoMethod *method) MONO_LLVM_INTERNAL;
+MonoJumpInfo* mono_aot_patch_info_dup (MonoJumpInfo* ji) MONO_LLVM_INTERNAL;
+
+#endif
+
+
+
+
#include <mono/metadata/assembly.h>
#include <mono/metadata/metadata-internals.h>
#include <mono/metadata/marshal.h>
-#include <mono/metadata/gc-internal.h>
+#include <mono/metadata/gc-internals.h>
#include <mono/metadata/threads-types.h>
#include <mono/metadata/mono-endian.h>
-#include <mono/utils/mono-logger-internal.h>
+#include <mono/utils/mono-logger-internals.h>
#include <mono/utils/mono-mmap.h>
#include <mono/utils/mono-compiler.h>
#include <mono/utils/mono-counters.h>
#include "seq-points.h"
#include "version.h"
#include "debugger-agent.h"
+#include "aot-compiler.h"
#ifndef DISABLE_AOT
}
if (image_index == MONO_AOT_METHODREF_WRAPPER) {
+ WrapperInfo *info;
guint32 wrapper_type;
wrapper_type = decode_value (p, &p);
g_error ("Error: No managed allocator, but we need one for AOT.\nAre you using non-standard GC options?\n");
break;
}
- case MONO_WRAPPER_WRITE_BARRIER:
+ case MONO_WRAPPER_WRITE_BARRIER: {
ref->method = mono_gc_get_write_barrier ();
break;
+ }
case MONO_WRAPPER_STELEMREF: {
int subtype = decode_value (p, &p);
ref->method = mono_marshal_get_stelemref ();
} else if (subtype == WRAPPER_SUBTYPE_VIRTUAL_STELEMREF) {
int kind;
- WrapperInfo *info;
kind = decode_value (p, &p);
ref->method = mono_marshal_get_array_address (rank, elem_size);
} else if (subtype == WRAPPER_SUBTYPE_STRING_CTOR) {
- WrapperInfo *info;
MonoMethod *m;
m = decode_resolve_method_ref (module, p, &p);
ref->method = mono_marshal_get_runtime_invoke (m, TRUE, pass_rgctx);
} else {
MonoMethodSignature *sig;
- WrapperInfo *info;
sig = decode_signature_with_target (module, NULL, p, &p);
info = mono_marshal_get_wrapper_info (target);
return FALSE;
if (wrapper_type == MONO_WRAPPER_DELEGATE_INVOKE) {
- WrapperInfo *info;
-
subtype = decode_value (p, &p);
info = mono_marshal_get_wrapper_info (target);
if (info) {
amodule->shared_got [i] = NULL;
} else if (ji->type == MONO_PATCH_INFO_GC_NURSERY_START && !mono_gc_is_moving ()) {
amodule->shared_got [i] = NULL;
+ } else if (ji->type == MONO_PATCH_INFO_GC_NURSERY_BITS && !mono_gc_is_moving ()) {
+ amodule->shared_got [i] = NULL;
} else if (ji->type == MONO_PATCH_INFO_IMAGE) {
amodule->shared_got [i] = amodule->assembly->image;
} else if (ji->type == MONO_PATCH_INFO_MSCORLIB_GOT_ADDR) {
mono_trace (G_LOG_LEVEL_INFO, MONO_TRACE_AOT, "AOT: loaded AOT Module for %s.\n", assembly->image->name);
}
-/*
- * mono_aot_register_globals:
- *
- * This is called by the ctor function in AOT images compiled with the
- * 'no-dlsym' option.
- */
-void
-mono_aot_register_globals (gpointer *globals)
-{
- g_assert_not_reached ();
-}
-
/*
* mono_aot_register_module:
*
case MONO_PATCH_INFO_INTERRUPTION_REQUEST_FLAG:
case MONO_PATCH_INFO_GC_CARD_TABLE_ADDR:
case MONO_PATCH_INFO_GC_NURSERY_START:
+ case MONO_PATCH_INFO_GC_NURSERY_BITS:
case MONO_PATCH_INFO_JIT_TLS_ID:
break;
case MONO_PATCH_INFO_CASTCLASS_CACHE:
gboolean
mono_arch_opcode_needs_emulation (MonoCompile *cfg, int opcode)
{
- return FALSE;
+ return TRUE;
}
#endif
#include <mono/metadata/mono-debug.h>
#include <mono/metadata/mono-debug-debugger.h>
#include <mono/metadata/debug-mono-symfile.h>
-#include <mono/metadata/gc-internal.h>
+#include <mono/metadata/gc-internals.h>
#include <mono/metadata/environment.h>
#include <mono/metadata/threads-types.h>
#include <mono/metadata/threadpool-ms.h>
#include "ir-emit.h"
#include "jit-icalls.h"
-#include <mono/metadata/gc-internal.h>
+#include <mono/metadata/gc-internals.h>
#include <mono/metadata/abi-details.h>
#ifndef DISABLE_JIT
case OP_IREM:
case OP_IDIV_UN:
case OP_IREM_UN:
- if (cfg->backend->emulate_div && !mono_arch_opcode_needs_emulation (cfg, ins->opcode)) {
+ if (cfg->backend->emulate_div && mono_arch_opcode_needs_emulation (cfg, ins->opcode))
+ emulate = TRUE;
+ if (!emulate) {
if (cfg->backend->need_div_check) {
int reg1 = alloc_ireg (cfg);
int reg2 = alloc_ireg (cfg);
}
MONO_EMIT_NEW_BIALU (cfg, ins->opcode, ins->dreg, ins->sreg1, ins->sreg2);
NULLIFY_INS (ins);
- } else {
- emulate = TRUE;
}
break;
#include <mono/metadata/mono-debug.h>
#include <mono/metadata/security-manager.h>
#include <mono/metadata/security-core-clr.h>
-#include <mono/metadata/gc-internal.h>
+#include <mono/metadata/gc-internals.h>
#include <mono/metadata/coree.h>
#include <mono/metadata/attach.h>
#include "mono/utils/mono-counters.h"
#include "mini.h"
#include "jit.h"
+#include "aot-compiler.h"
+
#include <string.h>
#include <ctype.h>
#include <locale.h>
mono_jit_set_aot_only (gboolean val)
{
mono_aot_only = val;
- if (mono_aot_only)
- mono_llvm_only = TRUE;
}
void
mono_jit_set_aot_mode (MonoAotMode mode)
{
mono_aot_mode = mode;
+ if (mono_aot_mode == MONO_AOT_MODE_LLVMONLY)
+ mono_llvm_only = TRUE;
}
/**
#include <mono/metadata/threads-types.h>
#include <mono/metadata/debug-helpers.h>
#include <mono/metadata/exception.h>
-#include <mono/metadata/gc-internal.h>
+#include <mono/metadata/gc-internals.h>
#include <mono/metadata/mono-debug.h>
#include <mono/utils/mono-mmap.h>
#include <mono/metadata/threads.h>
#include <mono/metadata/debug-helpers.h>
#include <mono/metadata/exception.h>
-#include <mono/metadata/gc-internal.h>
+#include <mono/metadata/gc-internals.h>
#include <mono/metadata/mono-debug.h>
#include "mini.h"
#include <mono/metadata/debug-helpers.h>
#include <mono/metadata/exception.h>
#include <mono/metadata/mono-debug.h>
-#include <mono/metadata/gc-internal.h>
+#include <mono/metadata/gc-internals.h>
#include <mono/metadata/tokentype.h>
#include "mini.h"
#include <mono/metadata/threads.h>
#include <mono/metadata/debug-helpers.h>
#include <mono/metadata/exception.h>
-#include <mono/metadata/gc-internal.h>
+#include <mono/metadata/gc-internals.h>
#include <mono/metadata/mono-debug.h>
#include <mono/utils/mono-mmap.h>
--- /dev/null
+.assembly iltests {
+ .custom instance void class [mscorlib]System.Runtime.CompilerServices.RuntimeCompatibilityAttribute::'.ctor'() = (
+ 01 00 01 00 54 02 16 57 72 61 70 4E 6F 6E 45 78 // ....T..WrapNonEx
+ 63 65 70 74 69 6F 6E 54 68 72 6F 77 73 01 ) // ceptionThrows.
+}
+.assembly extern TestDriver {}
+.assembly extern mscorlib {}
+
+.class public auto ansi sealed beforefieldinit Tests {
+
+ .method static public int32 Main(string[] args) il managed {
+ .entrypoint
+
+ ldtoken Tests
+ call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)
+ ldarg.0
+ call int32 [TestDriver]TestDriver::RunTests(class [mscorlib]System.Type, string[])
+ ret
+ }
+
+ // make sure the register allocator works when the return value of
+ // 'div' is discarded
+ .method static public int32 test_0_div_regalloc () il managed {
+ .locals init (
+ int32 i
+ )
+
+ ldloc 0
+ ldc.i4.s 0xa
+ div
+ pop
+ ldc.i4.0
+ ret
+ }
+
+
+ .method static public int32 test_1_ceq_to_i4 () il managed {
+ .locals init (
+ int32 foo
+ )
+ ldc.i4 500
+ stloc foo
+ ldloc foo
+ ldc.i4 500
+ ceq
+ stloc foo
+ ldloc foo
+ ret
+ }
+
+ .method static public int32 test_3_shl_regvars () il managed {
+ .locals init (
+ int32 a,
+ int32 b,
+ int32 r1,
+ int32 r2,
+ int32 r3
+ )
+
+ ldc.i4.2
+ stloc a
+ ldc.i4.1
+ stloc b
+
+ ldloc a
+ ldloc b
+ shl
+ stloc r1
+
+ ldloc a
+ ldloc b
+ shl
+ stloc r2
+
+ ldloc a
+ ldloc b
+ shl
+ stloc r3
+
+ ldloc r1
+ ldc.i4.4
+ ceq
+
+ ldloc r2
+ ldc.i4.4
+ ceq
+
+ ldloc r3
+ ldc.i4.4
+ ceq
+
+ add
+ add
+
+ ret
+ }
+
+ .method static public int32 test_1_fceq_to_i4 () il managed {
+
+ .locals init (
+ float64 foo,
+ int32 val
+ )
+
+ ldc.r8 2
+ stloc foo
+
+ ldloc foo
+ ldc.r8 2
+ ceq
+ stloc val
+
+ ldloc val
+ ret
+ }
+
+ //
+ // This should be manually checked. Basically under -O=linears,
+ // you should not see tons of register spilling.
+ //
+ .method static public int32 test_1_bytedreg_free () il managed {
+ .locals init (
+ int32 foo
+ )
+ ldc.i4 500
+ stloc foo
+ ldloc foo
+ ldc.i4 500
+ ceq
+ stloc foo
+
+ ldloc foo
+ ldc.i4 1
+ ceq
+ stloc foo
+
+ ldloc foo
+ ldc.i4 1
+ ceq
+ stloc foo
+
+ ldloc foo
+ ldc.i4 1
+ ceq
+ stloc foo
+
+ ldloc foo
+ ldc.i4 1
+ ceq
+ stloc foo
+
+ ldloc foo
+ ret
+ }
+
+ //
+ // This should be manually checked. Basically under -O=linears,
+ // you should not see tons of register spilling.
+ //
+ .method static public int32 test_0_bytesreg1_free () il managed {
+ .locals init (
+ unsigned int8 dest,
+ int32 src,
+ unsigned int8& pdest
+ )
+
+ ldloca dest
+ stloc pdest
+
+ ldloc pdest
+ ldloc src
+ stind.i1
+
+ ldloc pdest
+ ldloc src
+ stind.i1
+
+ ldloc pdest
+ ldloc src
+ stind.i1
+
+ ldloc pdest
+ ldloc src
+ stind.i1
+
+ ldloc pdest
+ ldloc src
+ stind.i1
+
+ ldloc pdest
+ ldloc src
+ stind.i1
+
+ ldloc pdest
+ ldind.i1
+ ret
+ }
+
+ .method static public int32 test_1_shift_regvar () il managed {
+
+ .locals init (
+ int32 v7FFFFFFF,
+ int32 v1
+ )
+
+ ldc.i4 0x7FFFFFFF
+ stloc v7FFFFFFF
+
+ ldc.i4.1
+ stloc v1
+
+ ldloc v7FFFFFFF
+ ldloc v1
+ shl
+ ldc.i4 0xFFFFFFFE
+ ceq
+ ret
+ }
+
+ // this only happens with the managed pointer, not an unmanaged one.
+ .method static public int32 test_0_foo () il managed {
+
+ .locals init (
+ int32& buf
+ )
+
+ ldc.i4.5
+ localloc
+
+ stloc buf
+ ldloc buf
+
+ ldind.i4
+
+ ret
+ }
+
+ .method static public int32 test_0_localloc () cil managed {
+ .locals init (native int, native int, native int, native int, int32)
+
+ ldc.i4 6
+ localloc
+ conv.i
+ stloc.0
+
+ ldc.i4 6
+ localloc
+ conv.i
+ stloc.1
+
+ ldc.i4 6
+ localloc
+ conv.i
+ stloc.2
+
+ // Variable length
+ ldc.i4 128
+ stloc.s 4
+ ldloc.s 4
+ localloc
+ conv.i
+ stloc.3
+
+ // Check zero initialized
+ ldloc.0
+ ldind.i4
+ ldc.i4.0
+ beq OK1
+ ldc.i4.1
+ br FAIL
+
+OK1:
+ ldloc.3
+ ldind.i4
+ ldc.i4.0
+ beq OK2
+ ldc.i4.2
+ br FAIL
+
+OK2:
+ ldloc.3
+ ldc.i4.s 124
+ add
+ ldind.i4
+ ldc.i4.0
+ beq OK3
+ ldc.i4.3
+ br FAIL
+
+OK3:
+ ldloc.1
+ ldc.i4 999999
+ stind.i4
+ ldloc.1
+ ldind.i4
+ ldc.i4 999999
+ beq OK4
+ ldc.i4.4
+ br FAIL
+
+OK4:
+ ldloc.0
+ ldc.i4 999999
+ stind.i4
+ ldloc.0
+ ldind.i4
+ ldc.i4 999999
+ beq OK5
+ ldc.i4.5
+ br FAIL
+
+OK5:
+ // Try allocations bigger than one page
+ ldc.i4 8196
+ localloc
+ conv.i
+ stloc.3
+ ldloc.3
+ ldc.i4 8192
+ add
+ ldc.i4 99
+ stind.i4
+ ldloc.3
+ ldc.i4 8192
+ add
+ ldind.i4
+ ldc.i4 99
+ beq PASS
+ ldc.i4.6
+ br FAIL
+
+FAIL:
+ ret
+
+PASS: ldc.i4.0
+ ret
+ }
+
+ .method private static void do_localloc () cil managed {
+ .maxstack 3
+ .locals init (
+ unsigned int8* V_0)
+ IL_0000: ldc.i4.1
+ IL_0001: ldc.i4 131072
+ IL_0006: mul
+ IL_0007: localloc
+ IL_0009: stloc.0
+ IL_000a: ret
+ }
+
+ // Check that localloc cannot be inlined
+ .method static public int32 test_0_localloc_inline () cil managed {
+ .maxstack 16
+ .locals init (
+ int32 i
+ )
+
+ ldc.i4.0
+ stloc.0
+ br COND
+
+START: call void class Tests::do_localloc()
+ ldloc.0
+ ldc.i4.1
+ add
+ stloc.0
+COND: ldloc.0
+ ldc.i4 1000
+ blt START
+
+ ldc.i4.0
+ ret
+ }
+
+ .method static public int32 test_3_copy_used_bug () il managed {
+
+ .locals init (
+ int32 size,
+ int32 res
+ )
+
+ ldc.i4 0
+ stloc res
+
+ ldc.i4 1
+ stloc size
+
+ ldloc size
+ ldloc size
+ ldloc size
+ add
+ stloc size
+ ldloc size
+ add
+ stloc res
+
+ ldloc res
+ ret
+ }
+
+ // demonstrate that the copy_used_var is not a fix for the above bug
+ .method static public int32 test_3_copy_used_indir_bug () il managed {
+
+ .locals init (
+ int32 size,
+ int32 res
+ )
+
+ ldc.i4 0
+ stloc res
+
+ ldc.i4 1
+ stloc size
+
+ ldloc size
+ ldloca size
+ ldloc size
+ ldloc size
+ add
+ stind.i4
+ ldloc size
+ add
+ stloc res
+
+ ldloc res
+ ret
+ }
+
+ .method static public void do_nothing (int32 a) il managed {
+ ret
+ }
+
+ // demonstrate the block_split failure: needs -O=inline
+ // mini -O=inline --compile Tests:test_0_split_block_bug iltests.exe
+ .method static public int32 test_0_split_block_bug () il managed {
+
+ .locals init (
+ int32 i1
+ )
+
+ ldc.i4 1
+ stloc i1
+ test_label:
+ ldloc i1
+ call void class Tests::do_nothing (int32)
+ ldc.i4 0
+ brtrue test_label
+
+ ldc.i4 0
+ ret
+ }
+
+ .method public void inline_do_nothing () il managed {
+ ret
+ }
+ .method static public int32 test_1_checkthis_inlining () il managed {
+ ldnull
+ call instance void class Tests::inline_do_nothing ()
+ ldc.i4 1
+ ret
+ }
+
+ .class nested private auto ansi sealed beforefieldinit TailCallStruct
+ extends [mscorlib]System.ValueType {
+ .field public int32 a
+ .field public int32 b
+ }
+
+ .method static valuetype Tests/TailCallStruct tail1 (valuetype Tests/TailCallStruct arg) {
+ ldarga 0
+ ldarga 0
+ ldfld int32 Tests/TailCallStruct::a
+ ldc.i4.1
+ add
+ stfld int32 Tests/TailCallStruct::a
+ ldarga 0
+ ldarga 0
+ ldfld int32 Tests/TailCallStruct::a
+ ldc.i4.2
+ add
+ stfld int32 Tests/TailCallStruct::a
+ ldarg.0
+ ret
+ }
+
+ .method static valuetype Tests/TailCallStruct tail2 (valuetype Tests/TailCallStruct arg) {
+ ldarg.0
+ tail.
+ call valuetype Tests/TailCallStruct Tests::tail1 (valuetype Tests/TailCallStruct)
+ ret
+ }
+
+ .class nested private auto ansi sealed beforefieldinit TailCallStructBig
+ extends [mscorlib]System.ValueType {
+ .field public int32 a
+ .field public int32 b
+ .field public int32 c
+ .field public int32 d
+ .field public int32 e
+ }
+
+ .method static valuetype Tests/TailCallStructBig tail_vret_by_addr_inner (valuetype Tests/TailCallStructBig arg) {
+ ldarga 0
+ ldarga 0
+ ldfld int32 Tests/TailCallStructBig::a
+ ldc.i4.1
+ add
+ stfld int32 Tests/TailCallStructBig::a
+ ldarg.0
+ ret
+ }
+
+ .method static valuetype Tests/TailCallStructBig tail_vret_by_addr (valuetype Tests/TailCallStructBig arg) {
+ ldarg.0
+ tail.
+ call valuetype Tests/TailCallStructBig Tests::tail_vret_by_addr_inner (valuetype Tests/TailCallStructBig)
+ ret
+ }
+
+ .method static public int32 test_3_tail_call_vret_by_addr () il managed {
+ .maxstack 16
+ .locals init (
+ valuetype Tests/TailCallStructBig arg2
+ )
+
+ ldloca 0
+ ldc.i4.2
+ stfld int32 Tests/TailCallStructBig::a
+ ldloc.0
+ call valuetype Tests/TailCallStructBig Tests::tail_vret_by_addr (valuetype Tests/TailCallStructBig)
+ stloc.0
+
+ ldloca 0
+ ldfld int32 Tests/TailCallStructBig::a
+ ret
+ }
+
+ .method static public int32 test_9_tail_call_vret_by_val () il managed {
+ .maxstack 16
+ .locals init (
+ valuetype Tests/TailCallStruct arg
+ )
+ ldloca 0
+ ldc.i4.2
+ stfld int32 Tests/TailCallStruct::a
+ ldloca 0
+ ldc.i4.4
+ stfld int32 Tests/TailCallStruct::b
+ ldloc.0
+ call valuetype Tests/TailCallStruct Tests::tail2 (valuetype Tests/TailCallStruct)
+ stloc.0
+
+ ldloca 0
+ ldfld int32 Tests/TailCallStruct::a
+ ldloca 0
+ ldfld int32 Tests/TailCallStruct::b
+ add
+ ret
+ }
+
+ .method static public int32 tail3 (int32 i, int32 j) il managed {
+ ldarg.0
+ ldarg.1
+ add
+ ret
+ }
+
+ .method static public int32 tail4 (int32 i, int32 j) il managed {
+ .maxstack 16
+ .locals init (
+ int32 k)
+
+ // Test arg0 allocated to a register
+ ldarg.0
+ ldarg.0
+ ldarg.0
+ ldarg.0
+ add
+ add
+ add
+ starg 0
+
+ // Test switched up argument variables as the actual arguments
+ ldarg.1
+ ldarg.0
+ tail.
+ call int32 Tests::tail3 (int32, int32)
+ ret
+ }
+
+ .method static public int32 test_24_tail_calls2 () il managed {
+ // Some platforms might not be able to AOT tail calls
+ .custom instance void class [TestDriver]CategoryAttribute::'.ctor'(string) = (01 00 08 21 46 55 4C 4C 41 4F 54 00 00 ) // ...!FULLAOT..
+
+ .maxstack 16
+ .locals init (
+ int32 i,
+ int32 j)
+
+ ldc.i4.4
+ stloc.0
+ ldc.i4.8
+ stloc.1
+
+ ldloc.0
+ ldloc.1
+ call int32 Tests::tail4 (int32, int32)
+ ret
+ }
+
+ .method public static int32 test_5_jmp () cil managed {
+ // Some platforms might not be able to AOT tail calls
+ .custom instance void class [TestDriver]CategoryAttribute::'.ctor'(string) = (01 00 08 21 46 55 4C 4C 41 4F 54 00 00 ) // ...!FULLAOT..
+
+ ldc.i4.1
+ ldc.i4.2
+ call int32 Tests::jmp2 (int32, int32)
+ ret
+ }
+
+ .method public static int32 jmp2 (int32, int32) cil managed {
+ ldarg.0
+ ldc.i4.1
+ add
+ starg.s 0
+ ldarg.1
+ ldc.i4.1
+ add
+ starg.s 1
+ jmp int32 Tests::jmp3 (int32, int32)
+ ldc.i4.0
+ ret
+ }
+
+ .method public static int32 jmp3 (int32 i, int32 j) cil managed {
+ ldarg.0
+ ldarg.1
+ add
+ ret
+ }
+
+ .method static public int32 test_11_switch_with_nonempty_stack () il managed {
+ .maxstack 16
+
+ ldc.i4.5
+ ldc.i4.6
+ ldc.i4.1
+ switch (L0, L1)
+ L0:
+ add
+ ret
+ L1:
+ add
+ ret
+ }
+
+ .method public static int32 test_5_endfinally_with_nonempty_stack () il managed {
+ .maxstack 16
+
+ .try {
+ leave IL_0
+ }
+ finally {
+ ldc.i4.0
+ endfinally
+ }
+ IL_0: ldc.i4.5
+ ret
+ }
+
+ .method public static int32 test_0_conv_ovf_i8_neg () il managed {
+ .maxstack 16
+
+ ldc.i4.m1
+ conv.ovf.i8
+ conv.i4
+ ldc.i4.m1
+ beq L_OK
+ ldc.i4.1
+ ret
+ L_OK:
+ ldc.i4.0
+ ret
+ }
+
+ .method public static int32 test_1234_conv_u4 () cil managed {
+ .maxstack 16
+
+ ldc.i4 1234
+ conv.u4
+ conv.i4
+ ret
+ }
+
+ .method public static int32 test_0_conv_ovf_i_un () cil managed {
+ .maxstack 16
+
+ ldc.i4 1234
+ conv.ovf.i.un
+ conv.i4
+ ldc.i4 1234
+ beq L1
+ ldc.i4.1
+ ret
+ L1:
+ ldc.i4 0x7fffffff
+ conv.ovf.i.un
+ conv.i4
+ ldc.i4 0x7fffffff
+ beq L2
+ ldc.i4.2
+ ret
+ L2:
+ sizeof [mscorlib]System.IntPtr
+ ldc.i4 8
+ beq L5
+ .try {
+ ldc.i4 0x80000000
+ conv.ovf.i.un
+ leave L4
+ } catch [mscorlib]System.OverflowException {
+ pop
+ leave L5
+ }
+ L4:
+ ldc.i4.3
+ ret
+ L5:
+ ldc.i4.0
+ ret
+ }
+
+ .method public static int32 test_0_conv_ovf_u_un () cil managed {
+ .maxstack 16
+
+ ldc.i4 1234
+ conv.ovf.u.un
+ conv.i4
+ ldc.i4 1234
+ beq L1
+ ldc.i4.1
+ ret
+ L1:
+ ldc.i4.0
+ ret
+ }
+
+ .method public static int32 test_0_conv_ovf_i () cil managed {
+ .maxstack 16
+
+ ldc.i4 1234
+ conv.ovf.i
+ conv.i4
+ ldc.i4 1234
+ beq L1
+ ldc.i4.1
+ ret
+ L1:
+ ldc.i4.0
+ ret
+ }
+
+ .method public static int32 test_0_conv_ovf_u () cil managed {
+ .maxstack 16
+
+ ldc.i4 1234
+ conv.ovf.u
+ conv.i4
+ ldc.i4 1234
+ beq L1
+ ldc.i4.1
+ ret
+ L1:
+ ldc.i4.0
+ ret
+ }
+
+ .method public static int32 test_1234_conv_ovf_i8_un () cil managed {
+ .maxstack 16
+
+ ldc.i4 1234
+ conv.ovf.i8.un
+ conv.i4
+ ret
+ }
+
+ .method public static int32 test_0_lconv_ovf_i () cil managed {
+ .maxstack 16
+
+ ldc.i4 1234
+ conv.i8
+ conv.ovf.i
+ conv.i4
+ ldc.i4 1234
+ beq L1
+ ldc.i4.1
+ ret
+ L1:
+ ldc.i4.0
+ ret
+ }
+
+ .method public static int32 test_0_lconv_ovf_u () cil managed {
+ .maxstack 16
+
+ ldc.i4 1234
+ conv.i8
+ conv.ovf.u
+ conv.i4
+ ldc.i4 1234
+ beq L1
+ ldc.i4.1
+ ret
+ L1:
+ ldc.i4.0
+ ret
+ }
+
+ .method public static int32 test_0_lconv_ovf_i_un () cil managed {
+ .maxstack 16
+
+ ldc.i4 1234
+ conv.i8
+ conv.ovf.i.un
+ conv.i4
+ ldc.i4 1234
+ beq L1
+ ldc.i4.1
+ ret
+ L1:
+ ldc.i4.0
+ ret
+ }
+
+ .method public static int32 test_0_lconv_ovf_u_un () cil managed {
+ .maxstack 16
+
+ ldc.i4 1234
+ conv.i8
+ conv.ovf.u.un
+ conv.i4
+ ldc.i4 1234
+ beq L1
+ ldc.i4.1
+ ret
+ L1:
+ ldc.i4.0
+ ret
+ }
+
+ .method public static int32 test_0_lconv_to_ovf_i8 () cil managed {
+ .maxstack 16
+
+ ldc.i4 1234
+ conv.i8
+ conv.ovf.i8
+ conv.i4
+ ldc.i4 1234
+ beq L1
+ ldc.i4.1
+ ret
+ L1:
+ ldc.i4.0
+ ret
+ }
+
+ .method public static int32 test_0_lconv_to_ovf_u8_un () cil managed {
+ .maxstack 16
+
+ ldc.i4 1234
+ conv.i8
+ conv.ovf.u8.un
+ conv.i4
+ ldc.i4 1234
+ beq L1
+ ldc.i4.1
+ ret
+ L1:
+ ldc.i4.0
+ ret
+ }
+
+ .method public static int32 test_2_lconv_to_ovf_i4_un () cil managed {
+ .maxstack 16
+ .locals init (int32 res)
+
+ ldc.i4 0x7fffffff
+ conv.u8
+ conv.ovf.i4.un
+ pop
+
+ ldc.i4.2
+ stloc res
+
+ .try {
+ ldc.i8 0x80000000
+ conv.ovf.i4.un
+ pop
+ ldc.i4.0
+ stloc res
+ leave RET
+ } catch [mscorlib]System.OverflowException {
+ pop
+ leave IL_0
+ }
+
+ IL_0:
+
+ .try {
+ ldc.i8 0xffffffff80000000
+ conv.ovf.i4.un
+ pop
+ ldc.i4.1
+ stloc res
+ leave RET
+ } catch [mscorlib]System.OverflowException {
+ pop
+ leave RET
+ }
+
+ RET:
+ ldloc res
+ ret
+ }
+
+ .method public static int32 test_1_lconv_to_ovf_i_un () cil managed {
+ .maxstack 16
+ .locals init (int32 res)
+
+ ldc.i4 0x7fffffff
+ conv.u8
+ conv.ovf.i.un
+ conv.i4
+ pop
+
+ ldc.i4.1
+ ret
+ }
+
+ .method public static int32 test_32_lconv_to_u8 () cil managed
+ {
+ .maxstack 16
+
+ ldc.i4 32
+ conv.i8
+ conv.u8
+ conv.i4
+ ret
+ }
+
+ .method public static int32 test_32_lconv_to_i8 () cil managed
+ {
+ .maxstack 16
+
+ ldc.i4 32
+ conv.i8
+ conv.i8
+ conv.i4
+ ret
+ }
+
+ .method public static int32 test_15_lconv_to_u () cil managed
+ {
+ ldc.i8 0x10000000f
+ conv.u
+ conv.i4
+ ret
+ }
+
+ .method public static int32 test_1234_fconv_u () cil managed {
+ .maxstack 16
+
+ ldc.r8 1234.0
+ conv.u
+ conv.i4
+ ret
+ }
+
+ .method public static int32 test_0_get_type_from_handle_on_bblock_boundary () cil managed
+ {
+ .maxstack 16
+
+ ldc.i4.1
+ brfalse OBJECT
+
+ ldtoken [mscorlib]System.String
+ br AFTER
+ OBJECT:
+ ldtoken [mscorlib]System.Object
+ AFTER:
+ call class [mscorlib]'System.Type' class [mscorlib]'System.Type'::'GetTypeFromHandle'(valuetype [mscorlib]'System.RuntimeTypeHandle')
+ callvirt instance string class [mscorlib]System.Type::get_FullName ()
+ ldstr "System.String"
+ callvirt instance bool class [mscorlib]System.Object::Equals(object)
+ ldc.i4.0
+ ceq
+ ret
+ }
+
+ .method public static int32 test_0_bug59580 ()
+ {
+ ldc.r4 float32(0x7FC00000)
+ ldc.r4 float32(0x7FC00000)
+ bge.un pass
+ br fail
+ pass:
+ ldc.i4.0
+ ret
+ fail:
+ ldc.i4.1
+ ret
+ }
+
+ .method public static int32 test_1_bug60056 () {
+ .locals init (int32 m5)
+
+ ldc.i4.m1
+ stloc.0
+
+ ldc.i4.1
+ conv.u8
+
+ ldloc.0
+ conv.i8
+ mul
+
+ ldc.i4.m1
+ conv.i8
+ ceq
+ ret
+ }
+
+ .method public static int32 test_1_conv_u8_cfold () {
+ ldc.i4.m1
+ conv.u8
+
+ ldc.i8 0x00000000ffffffff
+
+ ceq
+ ret
+ }
+
+ .method public static int32 test_1_array_type_mismatch_ldelema () {
+ .locals init (int32 r)
+
+ ldc.i4.1
+ newarr string
+ ldc.i4.0
+ ldelema string
+ pop
+
+ .try {
+ ldc.i4.1
+ newarr string
+ ldc.i4.0
+ ldelema object
+ pop
+
+ leave end
+ } catch [mscorlib]System.ArrayTypeMismatchException {
+ pop
+ ldc.i4.1
+ stloc.0
+ leave end
+ }
+ end:
+ ldloc.0
+ ret
+ }
+
+ .method public static int32 test_1_conv_ovf_i8_with_i4 () {
+ ldc.i4.m1
+ conv.ovf.i8
+ conv.ovf.i4
+ neg
+ ret
+ }
+
+ // bug #72148
+ .method public static int32 test_0_initlocals_float_ptr () {
+ .maxstack 3
+ .locals init (
+ float32[] V_0,
+ float32& pinned V_1,
+ unsigned int32 V_2)
+ ldc.i4.s 0x0f
+ newarr [mscorlib]System.Single
+ stloc.0
+ ldloc.0
+ ldc.i4.0
+ ldc.r4 1.13
+ stelem.r4
+ ldloc.0
+ ldc.i4.0
+ ldelema [mscorlib]System.Single
+ stloc.1
+ ldloc.1
+ conv.i
+ ldind.u4
+ stloc.2
+ ldc.i4.0
+ ret
+ }
+
+ .method public static int32 test_7_conv_ovf_u8_un () {
+ .maxstack 2
+ .locals init (unsigned int64)
+
+ ldc.i4.7
+ conv.ovf.u8.un
+ stloc.0
+ ldloc.0
+ conv.i4
+ ret
+ }
+
+ .method public static int32 test_7_conv_ovf_u4_un () {
+ .maxstack 2
+ .locals init (unsigned int32)
+
+ ldc.i4.7
+ conv.ovf.u4.un
+ stloc.0
+ ldloc.0
+ conv.i4
+ ret
+ }
+
+ .method public static int32 test_1_bug_74591 () {
+ .maxstack 16
+ .locals init (int32)
+
+ ldc.i4.m1
+ stloc.0
+ ldloc.0
+ conv.ovf.i8
+ ldc.i4.m1
+ conv.ovf.i8
+ mul.ovf
+ conv.i4
+ ret
+ }
+
+ .class nested public auto ansi Integer
+ extends [mscorlib]System.Object {
+
+ .field public bool n
+
+ .method public hidebysig specialname rtspecialname
+ instance default void .ctor (unsigned int64 i, bool n) cil managed
+ {
+ .maxstack 8
+ ldarg.0
+ call instance void class [mscorlib]System.Object::.ctor()
+ ldarg.0
+ ldarg.2
+ stfld bool Tests/Integer::n
+ ret
+ }
+ }
+
+ .method public static int32 test_1_bug_74726 () {
+ .maxstack 16
+
+ ldc.i4.2
+ conv.ovf.u8
+ ldc.i4.1
+ conv.ovf.u8
+ mul.ovf.un
+ ldc.i4.1
+ newobj instance void class Tests/Integer::.ctor(unsigned int64, bool)
+ ldfld bool Tests/Integer::n
+ ldc.i4.1
+ ceq
+ ret
+ }
+
+ .class nested private auto ansi sealed xxx
+ extends [mscorlib]System.ValueType
+ {
+ .field public object a
+
+ .method public hidebysig specialname rtspecialname
+ instance default void .ctor () cil managed
+ {
+ .maxstack 8
+ ret
+ }
+ } // end of class xxx
+
+ .method public static int32 test_0_newobj_vtype () {
+ .maxstack 6
+ .locals init (
+ valuetype Tests/xxx V_0
+ )
+
+ newobj instance void valuetype Tests/xxx::.ctor ()
+ stloc.0
+ ldloca.s 0
+ ldfld object Tests/xxx::a
+ brfalse OK
+ ldc.i4.s 1
+ ret
+ OK:
+ ldc.i4.s 0
+ ret
+ }
+
+ .method public static int32 test_0_newobj_vtype_primitive () {
+ .maxstack 6
+ .locals init (
+ native int V_0
+ )
+
+ ldc.i4.s 10
+ newobj instance void native int::'.ctor'(int32)
+ stloc.0
+ ldloc.0
+ ldc.i4.s 10
+ beq OK
+ ldc.i4.s 1
+ ret
+ OK:
+ ldc.i4.s 0
+ ret
+ }
+
+ .method public static int32 test_1_filters () {
+ .custom instance void [TestDriver]CategoryAttribute::.ctor(string) = ( 01 00 08 21 42 49 54 43 4F 44 45 00 00 ) // ...!BITCODE..
+ .maxstack 16
+ .locals init (
+ int32 res
+ )
+
+ .try { // 0
+ .try {
+ ldstr "OnErrorSub test Exception"
+ newobj instance void class [mscorlib]System.Exception::.ctor(string)
+ throw
+ leave.s IL_0033
+ }
+ filter {
+ pop
+ ldc.i4.0
+ endfilter
+ } {
+ pop
+ // Should not be called
+ ldc.i4.2
+ stloc res
+ leave.s IL_0033
+ }
+ }
+ filter {
+ pop
+ ldc.i4.1
+ endfilter
+ } {
+ pop
+ ldc.i4.1
+ stloc res
+ leave.s IL_0033
+
+ }
+ IL_0033:
+ ldloc res
+ ret
+ }
+
+ .class nested private auto ansi sealed beforefieldinit TheStruct
+ extends [mscorlib]System.ValueType {
+ .field public int32 a
+ .field public int32 b
+ }
+
+ .method public static int32 test_5_cpobj () {
+ .maxstack 8
+ .locals init (
+ valuetype Tests/TheStruct v_0,
+ valuetype Tests/TheStruct v_1
+ )
+
+ ldloca v_0
+ ldc.i4.2
+ stfld int32 Tests/TheStruct::a
+
+ ldloca v_0
+ ldc.i4.3
+ stfld int32 Tests/TheStruct::b
+
+ ldloca v_1
+ ldloca v_0
+ cpobj Tests/TheStruct
+
+ ldloca v_1
+ ldfld int32 Tests/TheStruct::a
+ ldloca v_1
+ ldfld int32 Tests/TheStruct::b
+ add
+
+ ret
+ }
+
+ .method public static int32 test_5_ldobj_stloc_optimization () {
+ .maxstack 8
+ .locals init (
+ valuetype Tests/TheStruct v_0,
+ valuetype Tests/TheStruct v_1
+ )
+
+ ldloca v_0
+ ldc.i4.2
+ stfld int32 Tests/TheStruct::a
+
+ ldloca v_0
+ ldc.i4.3
+ stfld int32 Tests/TheStruct::b
+
+ ldloca v_0
+ ldobj valuetype Tests/TheStruct
+ stloc.s v_1
+
+ ldloca v_1
+ ldfld int32 Tests/TheStruct::a
+ ldloca v_1
+ ldfld int32 Tests/TheStruct::b
+ add
+
+ ret
+ }
+
+ .method public static int32 test_1_cpobj_reference () {
+ .maxstack 8
+ .locals init (
+ object v_0,
+ object v_1
+ )
+
+ newobj instance void object::.ctor()
+ stloc v_0
+
+ ldloca v_1
+ ldloca v_0
+ cpobj object
+
+ ldloc v_0
+ ldloc v_1
+ ceq
+ ret
+ }
+
+ .method public static int32 test_1_initobj_reference () {
+ .maxstack 8
+ .locals init (
+ object v_0
+ )
+
+ newobj instance void object::.ctor()
+ stloc v_0
+
+ ldloca v_0
+ initobj object
+
+ ldloc v_0
+ ldnull
+ ceq
+ ret
+ }
+
+ .method public static int32 test_1_ldobj_reference () {
+ .maxstack 8
+ .locals init (
+ object v_0
+ )
+
+ newobj instance void object::.ctor()
+ stloc v_0
+
+ ldloc v_0
+ ldloca v_0
+ ldobj object
+ ceq
+ ret
+ }
+
+ .method public static int32 test_5_vtype_on_bb_boundary () {
+ .maxstack 8
+ .locals init (
+ valuetype Tests/TheStruct v_0,
+ valuetype Tests/TheStruct v_1
+ )
+
+ ldloca v_0
+ ldc.i4.2
+ stfld int32 Tests/TheStruct::a
+
+ ldloca v_0
+ ldc.i4.3
+ stfld int32 Tests/TheStruct::b
+
+ ldloc v_0
+ br L_0
+ L_0: stloc v_1
+
+ ldloca v_1
+ ldfld int32 Tests/TheStruct::a
+ ldloca v_1
+ ldfld int32 Tests/TheStruct::b
+ add
+ ret
+ }
+
+ .method public static int32 test_5_different_in_stacks () cil managed {
+ .maxstack 16
+
+ ldc.i4.1
+ ldc.i4.1
+ beq L_0
+
+ ldc.i4.3
+ ldc.i4.3
+ br L_1
+ ldc.i4.3
+ ldc.i4.3
+ br L_2
+ L_0: ldc.i4.2
+ ldc.i4.3
+ ldc.i4.1
+ ldc.i4.1
+ beq L_2
+ L_1: add
+ ret
+ L_2: add
+ ret
+ }
+
+ .method public static int32 test_3_larray_get_set () {
+ .locals init (
+ int32[2] V_0)
+
+ ldc.i4.2
+ newobj instance void int32[0...]::.ctor(int32)
+ stloc.0
+ ldloc.0
+ ldc.i4.0
+ ldc.i4 1
+ call instance void int32[0...]::Set(int32, int32)
+ ldloc.0
+ ldc.i4.1
+ ldc.i4 2
+ call instance void int32[0...]::Set(int32, int32)
+
+ ldloc.0
+ ldc.i4.0
+ call instance int32 int32[0...]::Get(int32)
+ ldloc.0
+ ldc.i4.1
+ call instance int32 int32[0...]::Get(int32)
+ add
+ ret
+ }
+
+ .method public static int32 test_0_pop_side_effects () {
+ .try {
+ ldc.r8 1
+ ldc.r8 0
+ div
+ ckfinite
+ pop
+ leave FAIL
+ }
+ catch [mscorlib]System.ArithmeticException {
+ pop
+ leave L_0
+ }
+ L_0:
+ ldc.i4.0
+ ret
+ FAIL:
+ ldc.i4.1
+ ret
+ }
+
+ .method public static void regalloc_regress_78314_helper (object o) cil managed
+ {
+ ret
+ }
+
+ .method public static int32 test_1_regalloc_regress_78314 () cil managed
+ {
+ // Code size 68 (0x44)
+ .maxstack 6
+ .locals init (int32 V_0, bool V_1)
+ IL_0000: ldc.i4.0
+ IL_0001: stloc.0
+ IL_0002: br.s IL_003b
+
+ IL_0004:
+ IL_001e: ldc.i4.s 10
+ IL_0020: ldloc.0
+ IL_0021: shl
+ IL_0022: ldc.i4.s 10
+ IL_0024: ldloc.0
+ IL_0025: shl
+ IL_0026: ceq
+ IL_0028: box [mscorlib]System.Boolean
+ IL_0032: call void Tests::regalloc_regress_78314_helper(object)
+ IL_0037: ldloc.0
+ IL_0038: ldc.i4.1
+ IL_0039: add
+ IL_003a: stloc.0
+ IL_003b: ldloc.0
+ IL_003c: ldc.i4.8
+ IL_003f: blt.s IL_0004
+
+ ldloc.0
+ ldc.i4.8
+ ceq
+ conv.i4
+ ret
+ }
+
+ .method public static void try_block_end_remove_if_useless () cil managed {
+ .maxstack 8
+
+ T_START:
+ ldstr "Start"
+ pop
+ leave.s COMPLETE
+ T1_END:
+
+ COMPLETE:
+ ret
+
+ F1_START:
+ ldstr "Finally1"
+ pop
+ endfinally
+ F1_END:
+
+ .try T_START to T1_END finally handler F1_START to F1_END
+ }
+
+ .method public static int32 test_0_try_block_end_remove_if_useless () cil managed {
+ call void class Tests::try_block_end_remove_if_useless ()
+ ldc.i4.0
+ ret
+ }
+
+ .method private static int32 test_0_regress_78629_switch_next_ins_target () cil managed
+ {
+ ldc.i4.0
+ switch (target)
+ target: ldstr "bar"
+ pop
+ ldc.i4.0
+ ret
+ }
+
+ // This belongs to basic-float.cs, but its hard to tell mcs/csc to
+ // generate the non .un version of the opcodes
+ .method private static hidebysig
+ default int32 test_4_float_branch_nan () cil managed
+ {
+ // Method begins at RVA 0x27a4
+ // Code size 74 (0x4a)
+ .maxstack 2
+ .locals init (
+ float64 V_0,
+ float64 V_1,
+ int32 V_2)
+ IL_0000: ldc.r8 (00 00 00 00 00 00 f8 ff)
+ IL_0009: stloc.0
+ IL_000a: ldc.r8 1.
+ IL_0013: stloc.1
+ IL_0014: ldc.i4.0
+ IL_0015: stloc.2
+ IL_0016: ldloc.0
+ IL_0017: ldloc.1
+ IL_0018: bge.s IL_001a
+
+ br L1
+ IL_001a: ldloc.2
+ IL_001b: ret
+ L1:
+ IL_001c: ldloc.2
+ IL_001d: ldc.i4.1
+ IL_001e: add
+ IL_001f: stloc.2
+ IL_0020: ldloc.0
+ IL_0021: ldloc.1
+ IL_0022: ble.s IL_002e
+ br L2
+ IL_002e: ldloc.2
+ IL_002f: ret
+ L2:
+ IL_0030: ldloc.2
+ IL_0031: ldc.i4.1
+ IL_0032: add
+ IL_0033: stloc.2
+ IL_0034: ldloc.0
+ IL_0035: ldloc.1
+ IL_0036: blt.s IL_0038
+ br L3
+ IL_0038: ldloc.2
+ IL_0039: ret
+ L3:
+ IL_003a: ldloc.2
+ IL_003b: ldc.i4.1
+ IL_003c: add
+ IL_003d: stloc.2
+ IL_003e: ldloc.0
+ IL_003f: ldloc.1
+ IL_0040: bgt.s IL_0042
+ br L4
+ IL_0042: ldloc.2
+ IL_0043: ret
+ L4:
+ IL_0044: ldloc.2
+ IL_0045: ldc.i4.1
+ IL_0046: add
+ IL_0047: stloc.2
+ IL_0048: ldloc.2
+ IL_0049: ret
+ } // end of method Tests::test_5_float_branch_nan
+
+ .method private static hidebysig
+ default void regress_80622_inner (object x) cil managed
+ {
+ .locals init (unsigned int8 i)
+ // Method begins at RVA 0x2050
+ // Code size 14 (0xe)
+ .maxstack 8
+ IL_1000: ldarg.0
+ IL_1001: unbox unsigned int8
+ IL_1006: ldobj unsigned int8
+ IL_000b: conv.ovf.i4.un
+ IL_000c: pop
+ IL_000d: ret
+ }
+
+ // method line 2
+ .method private static hidebysig
+ default int32 test_0_regress_80622 () cil managed
+ {
+ .maxstack 8
+ IL_0000: ldc.i4 255
+ IL_0005: box unsigned int8
+ IL_000a: call void class Tests::regress_80622_inner (object)
+ ldc.i4.0
+ IL_000f: ret
+ }
+
+ .method private static default int32 test_0_regresss_80190 () cil managed
+ {
+ .maxstack 2
+ .locals init (int32 V_0,
+ int32* V_1)
+ IL_0000: nop
+ IL_0001: nop
+ IL_0002: ldloca.s V_0
+ IL_0004: conv.u
+ IL_0005: stloc.1
+ IL_0006: ldloc.1
+ IL_0007: ldc.i4.3
+ IL_0008: stind.i4
+ IL_0009: nop
+ ldc.i4.0
+ ret
+ }
+
+ .class interface nested public auto ansi abstract IFaceWithStaticMethod
+ {
+ .method public static specialname
+ default void foo () cil managed noinlining
+ {
+ .maxstack 0
+ IL_0000: ret
+ }
+ }
+
+ .class nested public auto ansi AClass extends [mscorlib]System.Object implements Tests/IFaceWithStaticMethod
+ {
+ .method public hidebysig specialname rtspecialname
+ instance default void .ctor () cil managed
+ {
+ .maxstack 8
+ ret
+ }
+
+ }
+
+ // Test that static methods in interfaces are ignored during vtable construction
+ .method private static default int32 test_0_ifaces_with_static_methods () cil managed
+ {
+ .maxstack 16
+
+ newobj instance void class Tests/AClass::.ctor()
+ pop
+ ldc.i4.0
+ ret
+ }
+
+ .method private static hidebysig default int32 Foo<T> (!!T n) cil managed {
+ ldarg.0
+ box !!0
+ brtrue HAS_VALUE
+ ldc.i4.0
+ ret
+HAS_VALUE: ldc.i4.1
+ ret
+ }
+
+ // bug 78019
+ .method static public int32 test_0_nullable_box_brtrue () cil managed {
+
+ .locals init (valuetype [mscorlib]System.Nullable`1<int32> V_0)
+
+ ldloc.0
+ call int32 class Tests::Foo<valuetype [mscorlib]System.Nullable`1<int32>> (!!0)
+ ret
+ }
+
+ //Bug 372410
+ .method static public int32 test_0_ldelema_type_check () cil managed {
+ .maxstack 16
+ .locals init (object[] V_0,
+ object[,] V_1)
+
+ ldc.i4.1
+ newarr object
+ stloc.0
+
+ .try {
+ ldloc.0
+ ldc.i4.0
+ ldelema object
+ leave L1
+ } catch [mscorlib]System.ArrayTypeMismatchException {
+ leave ERROR1
+ }
+
+ L1:
+ ldc.i4.1
+ newarr string
+ stloc.0
+
+ .try {
+ ldloc.0
+ ldc.i4.0
+ ldelema object
+ leave ERROR2
+ } catch [mscorlib]System.ArrayTypeMismatchException {
+ leave L2
+ }
+
+ L2:
+ ldc.i4.1
+ newarr string
+ stloc.0
+
+ .try {
+ ldloc.0
+ ldc.i4.0
+ readonly. ldelema object
+ leave L3
+ } catch [mscorlib]System.ArrayTypeMismatchException {
+ leave ERROR3
+ }
+
+ L3:
+ ldc.i4.0
+ ret
+
+
+ ERROR1:
+ ldc.i4.1
+ ret
+
+ ERROR2:
+ ldc.i4.2
+ ret
+
+ ERROR3:
+ ldc.i4.3
+ ret
+ }
+
+
+ //Bug 372410
+ .method static public int32 test_0_array_address_type_check () cil managed {
+ .maxstack 16
+ .locals init (object[] V_0,
+ object[,] V_1)
+
+ ldc.i4.1
+ ldc.i4.1
+ newobj instance void object[,]::.ctor(int32, int32)
+ stloc.1
+
+ .try {
+ ldloc.1
+ ldc.i4.0
+ ldc.i4.0
+ call instance object& object[,]::Address(int32, int32)
+ leave L4
+ } catch [mscorlib]System.ArrayTypeMismatchException {
+ leave ERROR4
+ }
+
+ L4:
+ ldc.i4.1
+ ldc.i4.1
+ newobj instance void string[,]::.ctor(int32, int32)
+ stloc.1
+
+ .try {
+ ldloc.1
+ ldc.i4.0
+ ldc.i4.0
+ call instance object& object[,]::Address(int32, int32)
+ leave ERROR5
+ } catch [mscorlib]System.ArrayTypeMismatchException {
+ leave L5
+ }
+
+ L5:
+ ldc.i4.1
+ ldc.i4.1
+ newobj instance void string[,]::.ctor(int32, int32)
+ stloc.1
+
+ .try {
+ ldloc.1
+ ldc.i4.0
+ ldc.i4.0
+ readonly. call instance object& object[,]::Address(int32, int32)
+ leave L6
+ } catch [mscorlib]System.ArrayTypeMismatchException {
+ leave ERROR6
+ }
+
+ L6:
+ ldc.i4.0
+ ret
+ ERROR4:
+ ldc.i4.4
+ ret
+
+ ERROR5:
+ ldc.i4.5
+ ret
+
+ ERROR6:
+ ldc.i4.6
+ ret
+ }
+
+ .field public static unsigned int64 'ull'
+
+ .field public static int32 'shift2'
+
+ .method public static int32 test_0_long_shift_regalloc () cil managed
+ {
+ .locals init (unsigned int32 'cilsimp.28', unsigned int64 'cilsimp.27', int32 'cilsimp.26')
+
+ .maxstack 4
+
+ ldc.i8 81985529234382576
+ stsfld unsigned int64 Tests::ull
+ ldc.i4 60
+ stsfld int32 Tests::shift2
+
+ ldsfld unsigned int64 Tests::ull
+ stloc 'cilsimp.27'
+ ldsfld int32 Tests::shift2
+ stloc 'cilsimp.28'
+ ldloc 'cilsimp.27'
+ ldloc 'cilsimp.28'
+ shr.un
+ ldloc 'cilsimp.27'
+ ldc.i4 64
+ ldloc 'cilsimp.28'
+ sub
+ shl
+ or
+ ldc.i8 1311768467750121216
+ ceq
+ ldc.i4.1
+ xor
+ conv.u4
+ ret
+ }
+
+ // Test calling ldfld directly on a vtype instead of a vtype address
+ .method public static int32 test_5_call_ldfld_vtype () cil managed
+ {
+ .maxstack 16
+ .locals init (
+ valuetype Tests/TailCallStruct arg
+ )
+ ldloca 0
+ ldc.i4.2
+ stfld int32 Tests/TailCallStruct::a
+ ldloca 0
+ ldc.i4.4
+ stfld int32 Tests/TailCallStruct::b
+ ldloc.0
+ call valuetype Tests/TailCallStruct Tests::tail2 (valuetype Tests/TailCallStruct)
+ ldfld int32 Tests/TailCallStruct::a
+ ret
+ }
+
+ .method public static int32 throw_ret () cil managed
+ {
+ ldstr "FOO"
+ newobj instance void class [mscorlib]System.OverflowException::.ctor(string)
+ throw
+ ldc.i4.4
+ ret
+ }
+
+ .method public static int32 throw2_ret () cil managed
+ {
+ // Disable inlining
+ ldc.i4.5
+ localloc
+ pop
+
+ call int32 Tests::throw_ret ()
+ ret
+ }
+
+ // Test inlining a method which contains just a throw
+ .method public static int32 test_0_inline_throw () cil managed
+ {
+ .maxstack 16
+ .locals init (
+ int32 v_0
+ )
+
+ .try {
+ call int32 Tests::throw2_ret ()
+ stloc.0
+ leave L0
+ } catch [mscorlib]System.OverflowException {
+ pop
+ leave L1
+ }
+
+ L0:
+ ldc.i4.1
+ ret
+ L1:
+ ldc.i4.0
+ ret
+ }
+
+ .method public static int32 test_0_stelem_any_null_opt () cil managed
+ {
+ .maxstack 16
+ .locals init (
+ object[] V_0,
+ int32 V_1)
+
+ ldc.i4.s 10
+ newarr [mscorlib]System.Object
+ stloc.0
+
+ ldc.i4.0
+ stloc.1
+ br L0
+
+ L1:
+ ldloc.0
+ ldloc.1
+ ldnull
+ stelem.any [mscorlib]System.Object
+ ldloc.1
+ ldc.i4.1
+ add
+ stloc.1
+ L0:
+ ldloc.1
+ ldc.i4.s 10
+ blt L1
+
+ ldc.i4.0
+ ret
+ }
+
+ // method line 2
+ .method public static hidebysig
+ default int32 manyargs_callee (int32 a, int32 b, int32 c, int32 d, int32 e, int32 f, int32 g, int32 h, int32 i, int32 j, int32 k, int32 l, int32 m, int32 n, int32 o, int32 p) cil managed
+ {
+ // Method begins at RVA 0x20f4
+ // Code size 44 (0x2c)
+ .maxstack 8
+ IL_0000: ldarg.0
+ IL_0001: ldarg.1
+ IL_0002: add
+ IL_0003: ldarg.2
+ IL_0004: add
+ IL_0005: ldarg.3
+ IL_0006: add
+ IL_0007: ldarg.s 4
+ IL_0009: add
+ IL_000a: ldarg.s 5
+ IL_000c: add
+ IL_000d: ldarg.s 6
+ IL_000f: add
+ IL_0010: ldarg.s 7
+ IL_0012: add
+ IL_0013: ldarg.s 8
+ IL_0015: add
+ IL_0016: ldarg.s 9
+ IL_0018: add
+ IL_0019: ldarg.s 10
+ IL_001b: add
+ IL_001c: ldarg.s 11
+ IL_001e: add
+ IL_001f: ldarg.s 12
+ IL_0021: add
+ IL_0022: ldarg.s 13
+ IL_0024: add
+ IL_0025: ldarg.s 14
+ IL_0027: add
+ IL_0028: ldarg.s 15
+ IL_002a: add
+ IL_002b: ret
+ } // end of method main::callee
+
+ // method line 3
+ .method public static hidebysig
+ default int32 manyargs_tail_caller (int32 a, int32 b, int32 c, int32 d, int32 e, int32 f, int32 g, int32 h, int32 i, int32 j, int32 k, int32 l, int32 m, int32 n, int32 o, int32 p) cil managed
+ {
+ // Method begins at RVA 0x2124
+ // Code size 34 (0x22)
+ .maxstack 17
+ IL_0000: ldarg.0
+ ldc.i4.1
+ add
+ IL_0001: ldarg.1
+ IL_0002: ldarg.2
+ IL_0003: ldarg.3
+ IL_0004: ldarg.s 4
+ IL_0006: ldarg.s 5
+ IL_0008: ldarg.s 6
+ IL_000a: ldarg.s 7
+ IL_000c: ldarg.s 8
+ IL_000e: ldarg.s 9
+ IL_0010: ldarg.s 10
+ IL_0012: ldarg.s 11
+ IL_0014: ldarg.s 12
+ IL_0016: ldarg.s 13
+ IL_0018: ldarg.s 14
+ ldc.i4.1
+ add
+ IL_001a: ldarg.s 15
+ ldc.i4.1
+ add
+ tail.
+ IL_001c: call int32 class Tests::manyargs_callee(int32, int32, int32, int32, int32, int32, int32, int32, int32, int32, int32, int32, int32, int32, int32, int32)
+ IL_0021: ret
+ } // end of method main::caller
+
+ // method line 4
+ .method public static hidebysig
+ default int32 test_139_many_args_tail_call () cil managed
+ {
+ // Some platforms might not be able to AOT tail calls
+ .custom instance void class [TestDriver]CategoryAttribute::'.ctor'(string) = (01 00 08 21 46 55 4C 4C 41 4F 54 00 00 ) // ...!FULLAOT..
+
+ // Method begins at RVA 0x2154
+ // Code size 43 (0x2b)
+ .maxstack 17
+ IL_0000: ldc.i4.1
+ IL_0001: ldc.i4.2
+ IL_0002: ldc.i4.3
+ IL_0003: ldc.i4.4
+ IL_0004: ldc.i4.5
+ IL_0005: ldc.i4.6
+ IL_0006: ldc.i4.7
+ IL_0007: ldc.i4.8
+ IL_0008: ldc.i4.s 0x09
+ IL_000a: ldc.i4.s 0x0a
+ IL_000c: ldc.i4.s 0x0b
+ IL_000e: ldc.i4.s 0x0c
+ IL_0010: ldc.i4.s 0x0d
+ IL_0012: ldc.i4.s 0x0e
+ IL_0014: ldc.i4.s 0x0f
+ IL_0016: ldc.i4.s 0x10
+ IL_0018: call int32 class Tests::manyargs_tail_caller(int32, int32, int32, int32, int32, int32, int32, int32, int32, int32, int32, int32, int32, int32, int32, int32)
+ IL_0028: ret
+ } // end of method main::Main
+
+ .class nested private auto ansi beforefieldinit R1
+ extends [mscorlib]System.MarshalByRefObject
+ {
+ .field public int32 test_field
+
+ .method public hidebysig specialname rtspecialname
+ instance default void '.ctor' () cil managed
+ {
+ ret
+ }
+ }
+
+ .method public static hidebysig
+ default int32 return_0 () cil managed
+ {
+ ldc.i4.0
+ ret
+ }
+
+ .method public static hidebysig
+ default int32 test_1_volatile_marshalbyref_bug_432673 () cil managed
+ {
+ .locals init (
+ class Tests/R1 v_0
+ )
+
+ newobj instance void class Tests/R1::.ctor ()
+ stloc.0
+ ldloc.0
+ ldc.i4.0
+ volatile.
+ stfld int32 Tests/R1::test_field
+ call int32 class Tests::return_0 ()
+ ldc.i4.1
+ add
+ ret
+ }
+
+ .method public static default int32 return_2 () cil managed
+ {
+ // Prevent inlining
+ ldc.i4.s 16
+ localloc
+ pop
+ ldc.i4.s 2
+ ret
+ }
+
+ .method public static hidebysig
+ default int32 test_1_cmov_opt_regress_463357 () cil managed
+ {
+ call int32 class Tests::return_2 ()
+ ldc.i4.0
+ ceq
+ brfalse L1
+ ldc.i4.0
+ ret
+ br L2
+ L1: nop
+ L2: nop
+ ldc.i4.1
+ ret
+ }
+
+ .method public static hidebysig default int32 cmov_opt_regress_474718_inner (int32 A_1) cil managed
+ {
+ .maxstack 3
+ .locals init (int32 V_0, bool V_1, bool V_2)
+
+ ldc.i4.0
+ IL_000b: stloc.1
+ IL_000d: br IL_002f
+
+ ldc.i4.1
+ stloc.2
+ IL_001e: ldloc.2
+ IL_001f: brfalse IL_0036
+
+ IL_0024:
+ IL_002a: br IL_0041
+
+ IL_002f: ldloc.1
+ IL_0030: stloc.2
+ IL_0031: br IL_001e
+
+ IL_0036: ldc.i4 0
+ IL_003b: stloc.0
+ IL_003c: br IL_0041
+
+ IL_0041: ldloc.0
+ IL_0042: ret
+ }
+
+ .method public static default int32 test_0_cmov_opt_regress_474718 () cil managed
+ {
+ .maxstack 16
+ ldc.i4.1
+ call int32 Tests::cmov_opt_regress_474718_inner (int32)
+ ret
+ }
+
+ .method public static default int32 test_5_createarr_newobj () cil managed
+ {
+ .maxstack 16
+
+ ldc.i4 5
+ newobj void char[]::.ctor(int32)
+ ldlen
+ ret
+ }
+
+ .method public static default int32 test_0_initblk_3_regress_481458 () cil managed
+ {
+ .maxstack 16
+ .locals init (native int)
+
+ ldc.i4.s 10
+ localloc
+ stloc.0
+
+ // Set the first value to 3
+ ldloc.0
+ ldc.i4.0
+ add //addr
+ ldc.i4.3 //value
+ stind.i1
+
+ // Zero out the first 3 values
+ ldloc.0 //addr
+ ldc.i4.0 //value
+ ldc.i4.s 3 //size
+ initblk
+
+ // Load the first value
+ ldloc.0
+ ldc.i4.0
+ add
+ ldind.u1
+ conv.i4
+ ret
+ }
+
+ .method public static float32 GetFloat32() cil managed noinlining
+ {
+ .maxstack 8
+ ldc.r8 0.19975845134874831
+ ret
+ }
+
+/* Disabled until they can be fixed to run on amd64
+ .method public static default int32 test_0_implicit_float_to_double_conversion () cil managed
+ {
+ .maxstack 16
+
+ call float32 Tests::GetFloat32()
+ ldc.r8 0.19975845134874831
+ beq OK
+
+ ldc.i4.1
+ ret
+OK:
+ ldc.i4.0
+ ret
+ }
+*/
+
+ .method public static default int32 test_0_long_to_r8_un_overflow () cil managed
+ {
+ .maxstack 16
+ ldc.i8 0x00FFFFFFFFFFFFFF
+ conv.r.un
+ conv.i8
+ ldc.i8 0x100000000000000
+ beq OK_1
+
+ ldc.i4.1
+ ret
+OK_1:
+ ldc.i8 0x00FFFFFFFFFFFFFF
+ conv.r.un
+ conv.r8
+ conv.i8
+ ldc.i8 0x100000000000000
+ beq OK_2
+
+ ldc.i4.2
+ ret
+OK_2:
+ ldc.i4.0
+ ret
+ }
+
+ .field public static int32 shift1
+
+ .method public static int32 regress_497271_helper (int32 i) cil managed
+ {
+ ldarg.0
+ ret
+ }
+
+ .method public static int32 test_0_regalloc_regress_497271 () cil managed
+ {
+ .locals init (int32 var)
+
+ ldc.i4 4
+ stsfld int32 Tests::shift1
+ ldsfld int32 Tests::shift1
+ stloc var
+ ldc.i4 4660
+ ldloc var
+ shr.un
+ ldc.i4 4660
+ ldc.i4 32
+ ldloc var
+ sub
+ shl
+ or
+ ldc.i4 1073742115
+ beq ?L10
+?L9:
+ ldc.i4 1
+ call int32 Tests::regress_497271_helper (int32)
+ ret
+?L10:
+ ldc.i4 0
+ call int32 Tests::regress_497271_helper (int32)
+ ret
+ }
+
+ .field private static int32 Value
+
+ .method public static hidebysig specialname
+ default int32 regress_513931_inner () cil managed
+ {
+ // Method begins at RVA 0x225c
+ // Code size 52 (0x34)
+ .maxstack 2
+ .locals init (
+ int32 V_0,
+ int32 V_1,
+ bool V_2)
+
+ ldc.i4 999
+ stsfld int32 Tests::Value
+
+ IL_0000: nop
+ IL_0001: ldsfld int32 Tests::Value
+ IL_0006: stloc.0
+ IL_0007: ldloc.0
+ IL_0008: ldc.i4.0
+ IL_0009: cgt
+ IL_000b: ldc.i4.0
+ IL_000c: ceq
+ IL_000e: stloc.2
+ IL_000f: ldloc.2
+ IL_0010: brtrue.s IL_0027
+
+ IL_0012: nop
+ IL_0013: ldloc.0
+ IL_0014: ldc.i4.s 0x7b
+ IL_0016: ceq
+ IL_0018: ldc.i4.0
+ IL_0019: ceq
+ IL_001b: stloc.2
+ IL_001c: ldloc.2
+ IL_001d: brtrue.s IL_0023
+
+ IL_001f: ldc.i4.m1
+ IL_0020: stloc.1
+ IL_0021: br.s IL_0032
+
+ IL_0023: ldc.i4.1
+ IL_0024: stloc.1
+ IL_0025: br.s IL_0032
+
+ IL_0027:
+ IL_002c: newobj instance void class [mscorlib]System.Exception::'.ctor'()
+ IL_0031: throw
+ IL_0032: ldloc.1
+ IL_0033: ret
+ }
+
+ .method public static hidebysig specialname
+ default int32 test_0_regress_513931 () cil managed
+ {
+ call int32 Tests::regress_513931_inner ()
+ pop
+ ldc.i4.0
+ ret
+ }
+
+ .method public static default int32 test_0_newarr_i8 () cil managed
+ {
+ ldc.i4 1000
+ conv.i8
+ newarr [mscorlib]System.Boolean
+ pop
+ ldc.i4 0
+ ret
+ }
+
+ .method public static specialname
+ default int32 return_1_noinline () cil managed noinlining
+ {
+ .maxstack 0
+
+ ldc.i4.1
+ ret
+ }
+
+ // Only happens with -O=-deadce,cmov
+ .method public static default int32 test_0_cmov_unused_582322 () cil managed
+ {
+ .maxstack 2
+ .locals init (
+ int32 V_0
+ )
+ call int32 Tests::return_1_noinline ()
+ ldc.i4.1
+ bne.un L0
+ ldloc.s 0
+ pop
+ L0:
+ ldc.i4.0
+ ret
+ }
+
+ .method public static hidebysig
+ default int32 test_0_regress_586664 () cil managed
+ {
+ // Method begins at RVA 0x20f4
+ // Code size 76 (0x4c)
+ .maxstack 6
+ .locals init (
+ float64 V_0,
+ float64[] V_1)
+ IL_0000: ldc.r8 1.
+ IL_0009: ldc.r8 2.
+ IL_0012: ldc.r8 1.
+ IL_001b: call float64 class [mscorlib]System.Math::Pow(float64, float64)
+ IL_0020: div
+ IL_0021: stloc.0
+ IL_0022: ldc.i4.2
+ IL_0023: newarr [mscorlib]System.Double
+ IL_0028: dup
+ IL_0029: ldc.i4.0
+ IL_002a: ldloc.0
+ IL_002b: neg
+ IL_002c: stelem.r8
+ IL_002d: dup
+ IL_002e: ldc.i4.1
+ IL_002f: ldloc.0
+ IL_0030: neg
+ IL_0031: stelem.r8
+ IL_0032: stloc.1
+ IL_0033: ldloc.1
+ IL_0034: ldc.i4.0
+ IL_0035: ldelem.r8
+ IL_0036: ldc.r8 -0.5
+ IL_003f: bne.un IL_004a
+
+ IL_0044: ldc.i4.0
+ IL_0045: br IL_004b
+
+ IL_004a: ldc.i4.1
+ IL_004b: ret
+ }
+
+ .method public static int32 test_2_leave_multiple_blocks_from_end ()
+ {
+ .locals init (int32 V_0)
+
+ .try {
+ .try {
+ nop
+ nop
+ leave END
+ } finally {
+ ldloc.0
+ ldc.i4.1
+ add
+ stloc.0
+ endfinally
+ }
+ nop
+ leave END
+ } finally {
+ ldloc.0
+ ldc.i4.1
+ add
+ stloc.0
+ endfinally
+ }
+END:
+ ldloc.0
+ ret
+ }
+
+ .method public static int32 test_3_leave_multiple_blocks_from_hole ()
+ {
+ .locals init (int32 V_0)
+
+ .try {
+ .try {
+ ldloc.0
+ brtrue REST
+ leave BEFORE_END
+REST:
+ nop
+ nop
+ leave END
+ } finally {
+ ldloc.0
+ ldc.i4.1
+ add
+ stloc.0
+ endfinally
+ }
+ nop
+ leave END
+ } finally {
+ ldloc.0
+ ldc.i4.1
+ add
+ stloc.0
+ endfinally
+ }
+BEFORE_END:
+ ldloc.0
+ ldc.i4.1
+ add
+ stloc.0
+END:
+ ldloc.0
+ ret
+ }
+
+ .class nested private auto ansi sealed beforefieldinit Pair`2<TKey,TValue>
+ extends [mscorlib]System.ValueType
+ {
+ .field public !0 key
+ .field public !1 'value'
+ }
+
+ .method private static hidebysig
+ default bool ContentEquals<TKey,TValue> (valuetype Tests/Pair`2<!!TKey, !!TValue> v) cil managed
+ {
+ .maxstack 8
+ IL_0000: ldarga.s 0
+ IL_0006: ldnull
+ constrained. valuetype Tests/Pair`2<!!0,!!1>
+ IL_0007: callvirt instance bool class [mscorlib]System.Object::Equals(object)
+ ret
+ }
+
+ .method public static hidebysig default int32 test_0_constrained_gshared_595863 () cil managed
+ {
+ .locals init (
+ valuetype Tests/Pair`2<string, string> V_0,
+ valuetype Tests/Pair`2<string, string> V_1)
+ IL_0000: ldloca.s 0
+ IL_0002: initobj valuetype Tests/Pair`2<string,string>
+ IL_0008: ldloc.0
+ IL_0009: stloc.1
+ IL_000a: ldloca.s 1
+ IL_000c: ldstr "A"
+ IL_0011: stfld !0 valuetype Tests/Pair`2<string,string>::key
+ IL_0016: ldloca.s 1
+ IL_0018: ldstr "B"
+ IL_001d: stfld !1 valuetype Tests/Pair`2<string,string>::'value'
+ IL_0022: ldloc.1
+ IL_0023: stloc.0
+ IL_0024: ldloc.0
+ IL_0025: call bool class Tests::ContentEquals<string, string> (valuetype Tests/Pair`2<!!0,!!1>)
+ brfalse SUCCESS
+ ldc.i4.1
+ ret
+ SUCCESS:
+ ldc.i4.0
+ ret
+ }
+
+ .method public static default int32 test_0_wrap_non_exception_throws () cil managed
+ {
+ .try {
+ newobj instance void class [mscorlib]System.Object::'.ctor'()
+ throw
+ leave IL_0
+ } catch class [mscorlib]System.Runtime.CompilerServices.RuntimeWrappedException {
+ leave IL_0
+ }
+ IL_0:
+ ldc.i4.0
+ ret
+ }
+
+ .method public static default int32 test_0_typespec_modopt () cil managed {
+ ldtoken class Tests modopt (Tests)
+ pop
+ ldc.i4.0
+ ret
+ }
+
+ .method public hidebysig static int32 SizeOfT<T>() cil managed
+ {
+ .maxstack 8
+
+ sizeof !!0
+ ret
+ }
+
+ .method public static default int32 test_1_sizeof_gshared () cil managed {
+ call int32 Tests::SizeOfT<int8>()
+ ldc.i4.1
+ ceq
+ ret
+ }
+
+ .method public static default int32 test_1_sizeof_ref () cil managed {
+ call int32 Tests::SizeOfT<object>()
+ sizeof [mscorlib]System.IntPtr
+ ceq
+ ret
+ }
+
+ .field static public int32 volatile_int
+
+ .method public static default int32 test_5_volatile_load_store () cil managed {
+ ldsflda int32 class Tests::volatile_int
+ ldc.i4 5
+ volatile.
+ stind.i4
+ ldsflda int32 class Tests::volatile_int
+ volatile.
+ ldind.i4
+ ret
+ }
+
+ .method public static
+ default int32 regress_693905_inner (int32 x, int32 acc) cil managed
+ {
+ // Method begins at RVA 0x2050
+ // Code size 17 (0x11)
+ .maxstack 5
+ IL_0000: ldarg.0
+ IL_0001: brtrue.s IL_0005
+
+ IL_0003: ldarg.1
+ IL_0004: ret
+ IL_0005: ldarg.0
+ IL_0006: ldc.i4.1
+ IL_0007: sub
+ IL_0008: ldarg.1
+ IL_0009: ldc.i4.1
+ IL_000a: add
+ IL_000b: starg.s 1
+ IL_000d: starg.s 0
+ IL_000f: br.s IL_0000
+
+ } // end of method Test::f
+
+ .method public static
+ default int32 test_10_regress_693905 () cil managed
+ {
+ ldc.i4.s 0x0a
+ ldc.i4.0
+ call int32 class Tests::regress_693905_inner(int32, int32)
+ ret
+ }
+
+ .method public static
+ default int32 test_0_llvm_regress_171 () cil managed
+ {
+ .locals init (
+ int32 i
+ )
+
+ call int32 Tests::return_1_noinline ()
+ ldc.i4.1
+ beq L1
+ ldc.i4.1
+ stloc.s 0
+ call int32 Tests::return_1_noinline ()
+ ldc.i4.0
+ beq L1
+ L1:
+ ldloc.s 0
+ ret
+ }
+
+ .field public static int32 static_a
+
+ .method public static
+ default int32 test_4_ldfld_stfld_static () cil managed
+ {
+ ldnull
+ ldc.i4 2
+ stfld int32 Tests::static_a
+ ldnull
+ ldfld int32 Tests::static_a
+ ldnull
+ ldflda int32 Tests::static_a
+ ldind.i4
+ add
+ ret
+ }
+
+ .method public static default int32 no_initlocals_inner () cil managed
+ {
+ .locals (
+ int32 V_0,
+ float32 V_1,
+ float64 V_2,
+ valuetype Tests/TailCallStruct V_3)
+ ldloc V_0
+ ret
+ }
+
+ .method public static default int32 test_0_no_initlocals () cil managed
+ {
+ call int32 Tests::no_initlocals_inner()
+ pop
+ ldc.i4.0
+ ret
+ }
+
+ .method public hidebysig static int32 test_5_r4_fadd_mixed() cil managed
+ {
+ // Code size 17 (0x11)
+ .maxstack 2
+ .locals init (float32 V_0,
+ float64 V_1)
+ IL_0000: ldc.r4 3
+ IL_0005: stloc.0
+ IL_0006: ldc.r8 2
+ IL_000b: stloc.1
+ IL_000c: ldloc.0
+ IL_000d: ldloc.1
+ IL_000e: add
+ IL_000f: conv.i4
+ IL_0010: ret
+ }
+
+ .method public hidebysig static int32 test_0_fcmp_eq_r4_mixed() cil managed
+ {
+ // Code size 32 (0x20)
+ .maxstack 2
+ .locals init (float32 V_0,
+ float64 V_1)
+ IL_0000: ldc.r4 1
+ IL_0005: stloc.0
+ IL_0006: ldc.r8 1
+ IL_000f: stloc.1
+ IL_0010: ldloc.0
+ IL_0012: ldloc.1
+ IL_0013: bne.un IL_001e
+
+ IL_0018: ldc.i4.0
+ IL_0019: br IL_001f
+
+ IL_001e: ldc.i4.1
+ IL_001f: ret
+ } // end of method Tests::test_0_fcmp_eq_r4_mixed
+
+ .method public hidebysig static int32 test_0_fceq_r4_mixed() cil managed
+ {
+ // Code size 31 (0x1f)
+ .maxstack 2
+ .locals init (float32 V_0,
+ float64 V_1,
+ bool V_2)
+ IL_0000: ldc.r4 1
+ IL_0005: stloc.0
+ IL_0006: ldc.r8 1
+ IL_000b: stloc.1
+ IL_000c: ldloc.0
+ IL_000d: ldloc.1
+ IL_000e: ceq
+ IL_0010: stloc.2
+ IL_0011: ldloc.2
+ IL_0012: brfalse IL_001d
+
+ IL_0017: ldc.i4.0
+ IL_0018: br IL_001e
+
+ IL_001d: ldc.i4.1
+ IL_001e: ret
+ } // end of method Tests::test_0_fceq_r4
+
+ .method public static int32 test_0_switch_loop () cil managed
+ {
+ .maxstack 16
+ .locals init (valuetype Tests/TailCallStruct V_0, int32 V_1)
+ ldc.i4.0
+ ldloc.0
+ ldloc.1
+ brtrue L_1
+ L_0:
+ ldc.i4.4
+ switch (L_0)
+ L_1:
+ pop
+ ret
+ }
+}
+++ /dev/null
-.assembly iltests {
- .custom instance void class [mscorlib]System.Runtime.CompilerServices.RuntimeCompatibilityAttribute::'.ctor'() = (
- 01 00 01 00 54 02 16 57 72 61 70 4E 6F 6E 45 78 // ....T..WrapNonEx
- 63 65 70 74 69 6F 6E 54 68 72 6F 77 73 01 ) // ceptionThrows.
-}
-.assembly extern TestDriver {}
-.assembly extern mscorlib {}
-
-.class public auto ansi sealed beforefieldinit Tests {
-
- .method static public int32 Main(string[] args) il managed {
- .entrypoint
-
- ldtoken Tests
- call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)
- ldarg.0
- call int32 [TestDriver]TestDriver::RunTests(class [mscorlib]System.Type, string[])
- ret
- }
-
- // make sure the register allocator works when the return value of
- // 'div' is discarded
- .method static public int32 test_0_div_regalloc () il managed {
- .locals init (
- int32 i
- )
-
- ldloc 0
- ldc.i4.s 0xa
- div
- pop
- ldc.i4.0
- ret
- }
-
-
- .method static public int32 test_1_ceq_to_i4 () il managed {
- .locals init (
- int32 foo
- )
- ldc.i4 500
- stloc foo
- ldloc foo
- ldc.i4 500
- ceq
- stloc foo
- ldloc foo
- ret
- }
-
- .method static public int32 test_3_shl_regvars () il managed {
- .locals init (
- int32 a,
- int32 b,
- int32 r1,
- int32 r2,
- int32 r3
- )
-
- ldc.i4.2
- stloc a
- ldc.i4.1
- stloc b
-
- ldloc a
- ldloc b
- shl
- stloc r1
-
- ldloc a
- ldloc b
- shl
- stloc r2
-
- ldloc a
- ldloc b
- shl
- stloc r3
-
- ldloc r1
- ldc.i4.4
- ceq
-
- ldloc r2
- ldc.i4.4
- ceq
-
- ldloc r3
- ldc.i4.4
- ceq
-
- add
- add
-
- ret
- }
-
- .method static public int32 test_1_fceq_to_i4 () il managed {
-
- .locals init (
- float64 foo,
- int32 val
- )
-
- ldc.r8 2
- stloc foo
-
- ldloc foo
- ldc.r8 2
- ceq
- stloc val
-
- ldloc val
- ret
- }
-
- //
- // This should be manually checked. Basically under -O=linears,
- // you should not see tons of register spilling.
- //
- .method static public int32 test_1_bytedreg_free () il managed {
- .locals init (
- int32 foo
- )
- ldc.i4 500
- stloc foo
- ldloc foo
- ldc.i4 500
- ceq
- stloc foo
-
- ldloc foo
- ldc.i4 1
- ceq
- stloc foo
-
- ldloc foo
- ldc.i4 1
- ceq
- stloc foo
-
- ldloc foo
- ldc.i4 1
- ceq
- stloc foo
-
- ldloc foo
- ldc.i4 1
- ceq
- stloc foo
-
- ldloc foo
- ret
- }
-
- //
- // This should be manually checked. Basically under -O=linears,
- // you should not see tons of register spilling.
- //
- .method static public int32 test_0_bytesreg1_free () il managed {
- .locals init (
- unsigned int8 dest,
- int32 src,
- unsigned int8& pdest
- )
-
- ldloca dest
- stloc pdest
-
- ldloc pdest
- ldloc src
- stind.i1
-
- ldloc pdest
- ldloc src
- stind.i1
-
- ldloc pdest
- ldloc src
- stind.i1
-
- ldloc pdest
- ldloc src
- stind.i1
-
- ldloc pdest
- ldloc src
- stind.i1
-
- ldloc pdest
- ldloc src
- stind.i1
-
- ldloc pdest
- ldind.i1
- ret
- }
-
- .method static public int32 test_1_shift_regvar () il managed {
-
- .locals init (
- int32 v7FFFFFFF,
- int32 v1
- )
-
- ldc.i4 0x7FFFFFFF
- stloc v7FFFFFFF
-
- ldc.i4.1
- stloc v1
-
- ldloc v7FFFFFFF
- ldloc v1
- shl
- ldc.i4 0xFFFFFFFE
- ceq
- ret
- }
-
- // this only happens with the managed pointer, not an unmanaged one.
- .method static public int32 test_0_foo () il managed {
-
- .locals init (
- int32& buf
- )
-
- ldc.i4.5
- localloc
-
- stloc buf
- ldloc buf
-
- ldind.i4
-
- ret
- }
-
- .method static public int32 test_0_localloc () cil managed {
- .locals init (native int, native int, native int, native int, int32)
-
- ldc.i4 6
- localloc
- conv.i
- stloc.0
-
- ldc.i4 6
- localloc
- conv.i
- stloc.1
-
- ldc.i4 6
- localloc
- conv.i
- stloc.2
-
- // Variable length
- ldc.i4 128
- stloc.s 4
- ldloc.s 4
- localloc
- conv.i
- stloc.3
-
- // Check zero initialized
- ldloc.0
- ldind.i4
- ldc.i4.0
- beq OK1
- ldc.i4.1
- br FAIL
-
-OK1:
- ldloc.3
- ldind.i4
- ldc.i4.0
- beq OK2
- ldc.i4.2
- br FAIL
-
-OK2:
- ldloc.3
- ldc.i4.s 124
- add
- ldind.i4
- ldc.i4.0
- beq OK3
- ldc.i4.3
- br FAIL
-
-OK3:
- ldloc.1
- ldc.i4 999999
- stind.i4
- ldloc.1
- ldind.i4
- ldc.i4 999999
- beq OK4
- ldc.i4.4
- br FAIL
-
-OK4:
- ldloc.0
- ldc.i4 999999
- stind.i4
- ldloc.0
- ldind.i4
- ldc.i4 999999
- beq OK5
- ldc.i4.5
- br FAIL
-
-OK5:
- // Try allocations bigger than one page
- ldc.i4 8196
- localloc
- conv.i
- stloc.3
- ldloc.3
- ldc.i4 8192
- add
- ldc.i4 99
- stind.i4
- ldloc.3
- ldc.i4 8192
- add
- ldind.i4
- ldc.i4 99
- beq PASS
- ldc.i4.6
- br FAIL
-
-FAIL:
- ret
-
-PASS: ldc.i4.0
- ret
- }
-
- .method private static void do_localloc () cil managed {
- .maxstack 3
- .locals init (
- unsigned int8* V_0)
- IL_0000: ldc.i4.1
- IL_0001: ldc.i4 131072
- IL_0006: mul
- IL_0007: localloc
- IL_0009: stloc.0
- IL_000a: ret
- }
-
- // Check that localloc cannot be inlined
- .method static public int32 test_0_localloc_inline () cil managed {
- .maxstack 16
- .locals init (
- int32 i
- )
-
- ldc.i4.0
- stloc.0
- br COND
-
-START: call void class Tests::do_localloc()
- ldloc.0
- ldc.i4.1
- add
- stloc.0
-COND: ldloc.0
- ldc.i4 1000
- blt START
-
- ldc.i4.0
- ret
- }
-
- .method static public int32 test_3_copy_used_bug () il managed {
-
- .locals init (
- int32 size,
- int32 res
- )
-
- ldc.i4 0
- stloc res
-
- ldc.i4 1
- stloc size
-
- ldloc size
- ldloc size
- ldloc size
- add
- stloc size
- ldloc size
- add
- stloc res
-
- ldloc res
- ret
- }
-
- // demonstrate that the copy_used_var is not a fix for the above bug
- .method static public int32 test_3_copy_used_indir_bug () il managed {
-
- .locals init (
- int32 size,
- int32 res
- )
-
- ldc.i4 0
- stloc res
-
- ldc.i4 1
- stloc size
-
- ldloc size
- ldloca size
- ldloc size
- ldloc size
- add
- stind.i4
- ldloc size
- add
- stloc res
-
- ldloc res
- ret
- }
-
- .method static public void do_nothing (int32 a) il managed {
- ret
- }
-
- // demonstrate the block_split failure: needs -O=inline
- // mini -O=inline --compile Tests:test_0_split_block_bug iltests.exe
- .method static public int32 test_0_split_block_bug () il managed {
-
- .locals init (
- int32 i1
- )
-
- ldc.i4 1
- stloc i1
- test_label:
- ldloc i1
- call void class Tests::do_nothing (int32)
- ldc.i4 0
- brtrue test_label
-
- ldc.i4 0
- ret
- }
-
- .method public void inline_do_nothing () il managed {
- ret
- }
- .method static public int32 test_1_checkthis_inlining () il managed {
- ldnull
- call instance void class Tests::inline_do_nothing ()
- ldc.i4 1
- ret
- }
-
- .class nested private auto ansi sealed beforefieldinit TailCallStruct
- extends [mscorlib]System.ValueType {
- .field public int32 a
- .field public int32 b
- }
-
- .method static valuetype Tests/TailCallStruct tail1 (valuetype Tests/TailCallStruct arg) {
- ldarga 0
- ldarga 0
- ldfld int32 Tests/TailCallStruct::a
- ldc.i4.1
- add
- stfld int32 Tests/TailCallStruct::a
- ldarga 0
- ldarga 0
- ldfld int32 Tests/TailCallStruct::a
- ldc.i4.2
- add
- stfld int32 Tests/TailCallStruct::a
- ldarg.0
- ret
- }
-
- .method static valuetype Tests/TailCallStruct tail2 (valuetype Tests/TailCallStruct arg) {
- ldarg.0
- tail.
- call valuetype Tests/TailCallStruct Tests::tail1 (valuetype Tests/TailCallStruct)
- ret
- }
-
- .class nested private auto ansi sealed beforefieldinit TailCallStructBig
- extends [mscorlib]System.ValueType {
- .field public int32 a
- .field public int32 b
- .field public int32 c
- .field public int32 d
- .field public int32 e
- }
-
- .method static valuetype Tests/TailCallStructBig tail_vret_by_addr_inner (valuetype Tests/TailCallStructBig arg) {
- ldarga 0
- ldarga 0
- ldfld int32 Tests/TailCallStructBig::a
- ldc.i4.1
- add
- stfld int32 Tests/TailCallStructBig::a
- ldarg.0
- ret
- }
-
- .method static valuetype Tests/TailCallStructBig tail_vret_by_addr (valuetype Tests/TailCallStructBig arg) {
- ldarg.0
- tail.
- call valuetype Tests/TailCallStructBig Tests::tail_vret_by_addr_inner (valuetype Tests/TailCallStructBig)
- ret
- }
-
- .method static public int32 test_3_tail_call_vret_by_addr () il managed {
- .maxstack 16
- .locals init (
- valuetype Tests/TailCallStructBig arg2
- )
-
- ldloca 0
- ldc.i4.2
- stfld int32 Tests/TailCallStructBig::a
- ldloc.0
- call valuetype Tests/TailCallStructBig Tests::tail_vret_by_addr (valuetype Tests/TailCallStructBig)
- stloc.0
-
- ldloca 0
- ldfld int32 Tests/TailCallStructBig::a
- ret
- }
-
- .method static public int32 test_9_tail_call_vret_by_val () il managed {
- .maxstack 16
- .locals init (
- valuetype Tests/TailCallStruct arg
- )
- ldloca 0
- ldc.i4.2
- stfld int32 Tests/TailCallStruct::a
- ldloca 0
- ldc.i4.4
- stfld int32 Tests/TailCallStruct::b
- ldloc.0
- call valuetype Tests/TailCallStruct Tests::tail2 (valuetype Tests/TailCallStruct)
- stloc.0
-
- ldloca 0
- ldfld int32 Tests/TailCallStruct::a
- ldloca 0
- ldfld int32 Tests/TailCallStruct::b
- add
- ret
- }
-
- .method static public int32 tail3 (int32 i, int32 j) il managed {
- ldarg.0
- ldarg.1
- add
- ret
- }
-
- .method static public int32 tail4 (int32 i, int32 j) il managed {
- .maxstack 16
- .locals init (
- int32 k)
-
- // Test arg0 allocated to a register
- ldarg.0
- ldarg.0
- ldarg.0
- ldarg.0
- add
- add
- add
- starg 0
-
- // Test switched up argument variables as the actual arguments
- ldarg.1
- ldarg.0
- tail.
- call int32 Tests::tail3 (int32, int32)
- ret
- }
-
- .method static public int32 test_24_tail_calls2 () il managed {
- // Some platforms might not be able to AOT tail calls
- .custom instance void class [TestDriver]CategoryAttribute::'.ctor'(string) = (01 00 08 21 46 55 4C 4C 41 4F 54 00 00 ) // ...!FULLAOT..
-
- .maxstack 16
- .locals init (
- int32 i,
- int32 j)
-
- ldc.i4.4
- stloc.0
- ldc.i4.8
- stloc.1
-
- ldloc.0
- ldloc.1
- call int32 Tests::tail4 (int32, int32)
- ret
- }
-
- .method public static int32 test_5_jmp () cil managed {
- // Some platforms might not be able to AOT tail calls
- .custom instance void class [TestDriver]CategoryAttribute::'.ctor'(string) = (01 00 08 21 46 55 4C 4C 41 4F 54 00 00 ) // ...!FULLAOT..
-
- ldc.i4.1
- ldc.i4.2
- call int32 Tests::jmp2 (int32, int32)
- ret
- }
-
- .method public static int32 jmp2 (int32, int32) cil managed {
- ldarg.0
- ldc.i4.1
- add
- starg.s 0
- ldarg.1
- ldc.i4.1
- add
- starg.s 1
- jmp int32 Tests::jmp3 (int32, int32)
- ldc.i4.0
- ret
- }
-
- .method public static int32 jmp3 (int32 i, int32 j) cil managed {
- ldarg.0
- ldarg.1
- add
- ret
- }
-
- .method static public int32 test_11_switch_with_nonempty_stack () il managed {
- .maxstack 16
-
- ldc.i4.5
- ldc.i4.6
- ldc.i4.1
- switch (L0, L1)
- L0:
- add
- ret
- L1:
- add
- ret
- }
-
- .method public static int32 test_5_endfinally_with_nonempty_stack () il managed {
- .maxstack 16
-
- .try {
- leave IL_0
- }
- finally {
- ldc.i4.0
- endfinally
- }
- IL_0: ldc.i4.5
- ret
- }
-
- .method public static int32 test_0_conv_ovf_i8_neg () il managed {
- .maxstack 16
-
- ldc.i4.m1
- conv.ovf.i8
- conv.i4
- ldc.i4.m1
- beq L_OK
- ldc.i4.1
- ret
- L_OK:
- ldc.i4.0
- ret
- }
-
- .method public static int32 test_1234_conv_u4 () cil managed {
- .maxstack 16
-
- ldc.i4 1234
- conv.u4
- conv.i4
- ret
- }
-
- .method public static int32 test_0_conv_ovf_i_un () cil managed {
- .maxstack 16
-
- ldc.i4 1234
- conv.ovf.i.un
- conv.i4
- ldc.i4 1234
- beq L1
- ldc.i4.1
- ret
- L1:
- ldc.i4 0x7fffffff
- conv.ovf.i.un
- conv.i4
- ldc.i4 0x7fffffff
- beq L2
- ldc.i4.2
- ret
- L2:
- sizeof [mscorlib]System.IntPtr
- ldc.i4 8
- beq L5
- .try {
- ldc.i4 0x80000000
- conv.ovf.i.un
- leave L4
- } catch [mscorlib]System.OverflowException {
- pop
- leave L5
- }
- L4:
- ldc.i4.3
- ret
- L5:
- ldc.i4.0
- ret
- }
-
- .method public static int32 test_0_conv_ovf_u_un () cil managed {
- .maxstack 16
-
- ldc.i4 1234
- conv.ovf.u.un
- conv.i4
- ldc.i4 1234
- beq L1
- ldc.i4.1
- ret
- L1:
- ldc.i4.0
- ret
- }
-
- .method public static int32 test_0_conv_ovf_i () cil managed {
- .maxstack 16
-
- ldc.i4 1234
- conv.ovf.i
- conv.i4
- ldc.i4 1234
- beq L1
- ldc.i4.1
- ret
- L1:
- ldc.i4.0
- ret
- }
-
- .method public static int32 test_0_conv_ovf_u () cil managed {
- .maxstack 16
-
- ldc.i4 1234
- conv.ovf.u
- conv.i4
- ldc.i4 1234
- beq L1
- ldc.i4.1
- ret
- L1:
- ldc.i4.0
- ret
- }
-
- .method public static int32 test_1234_conv_ovf_i8_un () cil managed {
- .maxstack 16
-
- ldc.i4 1234
- conv.ovf.i8.un
- conv.i4
- ret
- }
-
- .method public static int32 test_0_lconv_ovf_i () cil managed {
- .maxstack 16
-
- ldc.i4 1234
- conv.i8
- conv.ovf.i
- conv.i4
- ldc.i4 1234
- beq L1
- ldc.i4.1
- ret
- L1:
- ldc.i4.0
- ret
- }
-
- .method public static int32 test_0_lconv_ovf_u () cil managed {
- .maxstack 16
-
- ldc.i4 1234
- conv.i8
- conv.ovf.u
- conv.i4
- ldc.i4 1234
- beq L1
- ldc.i4.1
- ret
- L1:
- ldc.i4.0
- ret
- }
-
- .method public static int32 test_0_lconv_ovf_i_un () cil managed {
- .maxstack 16
-
- ldc.i4 1234
- conv.i8
- conv.ovf.i.un
- conv.i4
- ldc.i4 1234
- beq L1
- ldc.i4.1
- ret
- L1:
- ldc.i4.0
- ret
- }
-
- .method public static int32 test_0_lconv_ovf_u_un () cil managed {
- .maxstack 16
-
- ldc.i4 1234
- conv.i8
- conv.ovf.u.un
- conv.i4
- ldc.i4 1234
- beq L1
- ldc.i4.1
- ret
- L1:
- ldc.i4.0
- ret
- }
-
- .method public static int32 test_0_lconv_to_ovf_i8 () cil managed {
- .maxstack 16
-
- ldc.i4 1234
- conv.i8
- conv.ovf.i8
- conv.i4
- ldc.i4 1234
- beq L1
- ldc.i4.1
- ret
- L1:
- ldc.i4.0
- ret
- }
-
- .method public static int32 test_0_lconv_to_ovf_u8_un () cil managed {
- .maxstack 16
-
- ldc.i4 1234
- conv.i8
- conv.ovf.u8.un
- conv.i4
- ldc.i4 1234
- beq L1
- ldc.i4.1
- ret
- L1:
- ldc.i4.0
- ret
- }
-
- .method public static int32 test_2_lconv_to_ovf_i4_un () cil managed {
- .maxstack 16
- .locals init (int32 res)
-
- ldc.i4 0x7fffffff
- conv.u8
- conv.ovf.i4.un
- pop
-
- ldc.i4.2
- stloc res
-
- .try {
- ldc.i8 0x80000000
- conv.ovf.i4.un
- pop
- ldc.i4.0
- stloc res
- leave RET
- } catch [mscorlib]System.OverflowException {
- pop
- leave IL_0
- }
-
- IL_0:
-
- .try {
- ldc.i8 0xffffffff80000000
- conv.ovf.i4.un
- pop
- ldc.i4.1
- stloc res
- leave RET
- } catch [mscorlib]System.OverflowException {
- pop
- leave RET
- }
-
- RET:
- ldloc res
- ret
- }
-
- .method public static int32 test_1_lconv_to_ovf_i_un () cil managed {
- .maxstack 16
- .locals init (int32 res)
-
- ldc.i4 0x7fffffff
- conv.u8
- conv.ovf.i.un
- conv.i4
- pop
-
- ldc.i4.1
- ret
- }
-
- .method public static int32 test_32_lconv_to_u8 () cil managed
- {
- .maxstack 16
-
- ldc.i4 32
- conv.i8
- conv.u8
- conv.i4
- ret
- }
-
- .method public static int32 test_32_lconv_to_i8 () cil managed
- {
- .maxstack 16
-
- ldc.i4 32
- conv.i8
- conv.i8
- conv.i4
- ret
- }
-
- .method public static int32 test_15_lconv_to_u () cil managed
- {
- ldc.i8 0x10000000f
- conv.u
- conv.i4
- ret
- }
-
- .method public static int32 test_1234_fconv_u () cil managed {
- .maxstack 16
-
- ldc.r8 1234.0
- conv.u
- conv.i4
- ret
- }
-
- .method public static int32 test_0_get_type_from_handle_on_bblock_boundary () cil managed
- {
- .maxstack 16
-
- ldc.i4.1
- brfalse OBJECT
-
- ldtoken [mscorlib]System.String
- br AFTER
- OBJECT:
- ldtoken [mscorlib]System.Object
- AFTER:
- call class [mscorlib]'System.Type' class [mscorlib]'System.Type'::'GetTypeFromHandle'(valuetype [mscorlib]'System.RuntimeTypeHandle')
- callvirt instance string class [mscorlib]System.Type::get_FullName ()
- ldstr "System.String"
- callvirt instance bool class [mscorlib]System.Object::Equals(object)
- ldc.i4.0
- ceq
- ret
- }
-
- .method public static int32 test_0_bug59580 ()
- {
- ldc.r4 float32(0x7FC00000)
- ldc.r4 float32(0x7FC00000)
- bge.un pass
- br fail
- pass:
- ldc.i4.0
- ret
- fail:
- ldc.i4.1
- ret
- }
-
- .method public static int32 test_1_bug60056 () {
- .locals init (int32 m5)
-
- ldc.i4.m1
- stloc.0
-
- ldc.i4.1
- conv.u8
-
- ldloc.0
- conv.i8
- mul
-
- ldc.i4.m1
- conv.i8
- ceq
- ret
- }
-
- .method public static int32 test_1_conv_u8_cfold () {
- ldc.i4.m1
- conv.u8
-
- ldc.i8 0x00000000ffffffff
-
- ceq
- ret
- }
-
- .method public static int32 test_1_array_type_mismatch_ldelema () {
- .locals init (int32 r)
-
- ldc.i4.1
- newarr string
- ldc.i4.0
- ldelema string
- pop
-
- .try {
- ldc.i4.1
- newarr string
- ldc.i4.0
- ldelema object
- pop
-
- leave end
- } catch [mscorlib]System.ArrayTypeMismatchException {
- pop
- ldc.i4.1
- stloc.0
- leave end
- }
- end:
- ldloc.0
- ret
- }
-
- .method public static int32 test_1_conv_ovf_i8_with_i4 () {
- ldc.i4.m1
- conv.ovf.i8
- conv.ovf.i4
- neg
- ret
- }
-
- // bug #72148
- .method public static int32 test_0_initlocals_float_ptr () {
- .maxstack 3
- .locals init (
- float32[] V_0,
- float32& pinned V_1,
- unsigned int32 V_2)
- ldc.i4.s 0x0f
- newarr [mscorlib]System.Single
- stloc.0
- ldloc.0
- ldc.i4.0
- ldc.r4 1.13
- stelem.r4
- ldloc.0
- ldc.i4.0
- ldelema [mscorlib]System.Single
- stloc.1
- ldloc.1
- conv.i
- ldind.u4
- stloc.2
- ldc.i4.0
- ret
- }
-
- .method public static int32 test_7_conv_ovf_u8_un () {
- .maxstack 2
- .locals init (unsigned int64)
-
- ldc.i4.7
- conv.ovf.u8.un
- stloc.0
- ldloc.0
- conv.i4
- ret
- }
-
- .method public static int32 test_7_conv_ovf_u4_un () {
- .maxstack 2
- .locals init (unsigned int32)
-
- ldc.i4.7
- conv.ovf.u4.un
- stloc.0
- ldloc.0
- conv.i4
- ret
- }
-
- .method public static int32 test_1_bug_74591 () {
- .maxstack 16
- .locals init (int32)
-
- ldc.i4.m1
- stloc.0
- ldloc.0
- conv.ovf.i8
- ldc.i4.m1
- conv.ovf.i8
- mul.ovf
- conv.i4
- ret
- }
-
- .class nested public auto ansi Integer
- extends [mscorlib]System.Object {
-
- .field public bool n
-
- .method public hidebysig specialname rtspecialname
- instance default void .ctor (unsigned int64 i, bool n) cil managed
- {
- .maxstack 8
- ldarg.0
- call instance void class [mscorlib]System.Object::.ctor()
- ldarg.0
- ldarg.2
- stfld bool Tests/Integer::n
- ret
- }
- }
-
- .method public static int32 test_1_bug_74726 () {
- .maxstack 16
-
- ldc.i4.2
- conv.ovf.u8
- ldc.i4.1
- conv.ovf.u8
- mul.ovf.un
- ldc.i4.1
- newobj instance void class Tests/Integer::.ctor(unsigned int64, bool)
- ldfld bool Tests/Integer::n
- ldc.i4.1
- ceq
- ret
- }
-
- .class nested private auto ansi sealed xxx
- extends [mscorlib]System.ValueType
- {
- .field public object a
-
- .method public hidebysig specialname rtspecialname
- instance default void .ctor () cil managed
- {
- .maxstack 8
- ret
- }
- } // end of class xxx
-
- .method public static int32 test_0_newobj_vtype () {
- .maxstack 6
- .locals init (
- valuetype Tests/xxx V_0
- )
-
- newobj instance void valuetype Tests/xxx::.ctor ()
- stloc.0
- ldloca.s 0
- ldfld object Tests/xxx::a
- brfalse OK
- ldc.i4.s 1
- ret
- OK:
- ldc.i4.s 0
- ret
- }
-
- .method public static int32 test_0_newobj_vtype_primitive () {
- .maxstack 6
- .locals init (
- native int V_0
- )
-
- ldc.i4.s 10
- newobj instance void native int::'.ctor'(int32)
- stloc.0
- ldloc.0
- ldc.i4.s 10
- beq OK
- ldc.i4.s 1
- ret
- OK:
- ldc.i4.s 0
- ret
- }
-
- .method public static int32 test_1_filters () {
- .custom instance void [TestDriver]CategoryAttribute::.ctor(string) = ( 01 00 08 21 42 49 54 43 4F 44 45 00 00 ) // ...!BITCODE..
- .maxstack 16
- .locals init (
- int32 res
- )
-
- .try { // 0
- .try {
- ldstr "OnErrorSub test Exception"
- newobj instance void class [mscorlib]System.Exception::.ctor(string)
- throw
- leave.s IL_0033
- }
- filter {
- pop
- ldc.i4.0
- endfilter
- } {
- pop
- // Should not be called
- ldc.i4.2
- stloc res
- leave.s IL_0033
- }
- }
- filter {
- pop
- ldc.i4.1
- endfilter
- } {
- pop
- ldc.i4.1
- stloc res
- leave.s IL_0033
-
- }
- IL_0033:
- ldloc res
- ret
- }
-
- .class nested private auto ansi sealed beforefieldinit TheStruct
- extends [mscorlib]System.ValueType {
- .field public int32 a
- .field public int32 b
- }
-
- .method public static int32 test_5_cpobj () {
- .maxstack 8
- .locals init (
- valuetype Tests/TheStruct v_0,
- valuetype Tests/TheStruct v_1
- )
-
- ldloca v_0
- ldc.i4.2
- stfld int32 Tests/TheStruct::a
-
- ldloca v_0
- ldc.i4.3
- stfld int32 Tests/TheStruct::b
-
- ldloca v_1
- ldloca v_0
- cpobj Tests/TheStruct
-
- ldloca v_1
- ldfld int32 Tests/TheStruct::a
- ldloca v_1
- ldfld int32 Tests/TheStruct::b
- add
-
- ret
- }
-
- .method public static int32 test_5_ldobj_stloc_optimization () {
- .maxstack 8
- .locals init (
- valuetype Tests/TheStruct v_0,
- valuetype Tests/TheStruct v_1
- )
-
- ldloca v_0
- ldc.i4.2
- stfld int32 Tests/TheStruct::a
-
- ldloca v_0
- ldc.i4.3
- stfld int32 Tests/TheStruct::b
-
- ldloca v_0
- ldobj valuetype Tests/TheStruct
- stloc.s v_1
-
- ldloca v_1
- ldfld int32 Tests/TheStruct::a
- ldloca v_1
- ldfld int32 Tests/TheStruct::b
- add
-
- ret
- }
-
- .method public static int32 test_1_cpobj_reference () {
- .maxstack 8
- .locals init (
- object v_0,
- object v_1
- )
-
- newobj instance void object::.ctor()
- stloc v_0
-
- ldloca v_1
- ldloca v_0
- cpobj object
-
- ldloc v_0
- ldloc v_1
- ceq
- ret
- }
-
- .method public static int32 test_1_initobj_reference () {
- .maxstack 8
- .locals init (
- object v_0
- )
-
- newobj instance void object::.ctor()
- stloc v_0
-
- ldloca v_0
- initobj object
-
- ldloc v_0
- ldnull
- ceq
- ret
- }
-
- .method public static int32 test_1_ldobj_reference () {
- .maxstack 8
- .locals init (
- object v_0
- )
-
- newobj instance void object::.ctor()
- stloc v_0
-
- ldloc v_0
- ldloca v_0
- ldobj object
- ceq
- ret
- }
-
- .method public static int32 test_5_vtype_on_bb_boundary () {
- .maxstack 8
- .locals init (
- valuetype Tests/TheStruct v_0,
- valuetype Tests/TheStruct v_1
- )
-
- ldloca v_0
- ldc.i4.2
- stfld int32 Tests/TheStruct::a
-
- ldloca v_0
- ldc.i4.3
- stfld int32 Tests/TheStruct::b
-
- ldloc v_0
- br L_0
- L_0: stloc v_1
-
- ldloca v_1
- ldfld int32 Tests/TheStruct::a
- ldloca v_1
- ldfld int32 Tests/TheStruct::b
- add
- ret
- }
-
- .method public static int32 test_5_different_in_stacks () cil managed {
- .maxstack 16
-
- ldc.i4.1
- ldc.i4.1
- beq L_0
-
- ldc.i4.3
- ldc.i4.3
- br L_1
- ldc.i4.3
- ldc.i4.3
- br L_2
- L_0: ldc.i4.2
- ldc.i4.3
- ldc.i4.1
- ldc.i4.1
- beq L_2
- L_1: add
- ret
- L_2: add
- ret
- }
-
- .method public static int32 test_3_larray_get_set () {
- .locals init (
- int32[2] V_0)
-
- ldc.i4.2
- newobj instance void int32[0...]::.ctor(int32)
- stloc.0
- ldloc.0
- ldc.i4.0
- ldc.i4 1
- call instance void int32[0...]::Set(int32, int32)
- ldloc.0
- ldc.i4.1
- ldc.i4 2
- call instance void int32[0...]::Set(int32, int32)
-
- ldloc.0
- ldc.i4.0
- call instance int32 int32[0...]::Get(int32)
- ldloc.0
- ldc.i4.1
- call instance int32 int32[0...]::Get(int32)
- add
- ret
- }
-
- .method public static int32 test_0_pop_side_effects () {
- .try {
- ldc.r8 1
- ldc.r8 0
- div
- ckfinite
- pop
- leave FAIL
- }
- catch [mscorlib]System.ArithmeticException {
- pop
- leave L_0
- }
- L_0:
- ldc.i4.0
- ret
- FAIL:
- ldc.i4.1
- ret
- }
-
- .method public static void regalloc_regress_78314_helper (object o) cil managed
- {
- ret
- }
-
- .method public static int32 test_1_regalloc_regress_78314 () cil managed
- {
- // Code size 68 (0x44)
- .maxstack 6
- .locals init (int32 V_0, bool V_1)
- IL_0000: ldc.i4.0
- IL_0001: stloc.0
- IL_0002: br.s IL_003b
-
- IL_0004:
- IL_001e: ldc.i4.s 10
- IL_0020: ldloc.0
- IL_0021: shl
- IL_0022: ldc.i4.s 10
- IL_0024: ldloc.0
- IL_0025: shl
- IL_0026: ceq
- IL_0028: box [mscorlib]System.Boolean
- IL_0032: call void Tests::regalloc_regress_78314_helper(object)
- IL_0037: ldloc.0
- IL_0038: ldc.i4.1
- IL_0039: add
- IL_003a: stloc.0
- IL_003b: ldloc.0
- IL_003c: ldc.i4.8
- IL_003f: blt.s IL_0004
-
- ldloc.0
- ldc.i4.8
- ceq
- conv.i4
- ret
- }
-
- .method public static void try_block_end_remove_if_useless () cil managed {
- .maxstack 8
-
- T_START:
- ldstr "Start"
- pop
- leave.s COMPLETE
- T1_END:
-
- COMPLETE:
- ret
-
- F1_START:
- ldstr "Finally1"
- pop
- endfinally
- F1_END:
-
- .try T_START to T1_END finally handler F1_START to F1_END
- }
-
- .method public static int32 test_0_try_block_end_remove_if_useless () cil managed {
- call void class Tests::try_block_end_remove_if_useless ()
- ldc.i4.0
- ret
- }
-
- .method private static int32 test_0_regress_78629_switch_next_ins_target () cil managed
- {
- ldc.i4.0
- switch (target)
- target: ldstr "bar"
- pop
- ldc.i4.0
- ret
- }
-
- // This belongs to basic-float.cs, but its hard to tell mcs/csc to
- // generate the non .un version of the opcodes
- .method private static hidebysig
- default int32 test_4_float_branch_nan () cil managed
- {
- // Method begins at RVA 0x27a4
- // Code size 74 (0x4a)
- .maxstack 2
- .locals init (
- float64 V_0,
- float64 V_1,
- int32 V_2)
- IL_0000: ldc.r8 (00 00 00 00 00 00 f8 ff)
- IL_0009: stloc.0
- IL_000a: ldc.r8 1.
- IL_0013: stloc.1
- IL_0014: ldc.i4.0
- IL_0015: stloc.2
- IL_0016: ldloc.0
- IL_0017: ldloc.1
- IL_0018: bge.s IL_001a
-
- br L1
- IL_001a: ldloc.2
- IL_001b: ret
- L1:
- IL_001c: ldloc.2
- IL_001d: ldc.i4.1
- IL_001e: add
- IL_001f: stloc.2
- IL_0020: ldloc.0
- IL_0021: ldloc.1
- IL_0022: ble.s IL_002e
- br L2
- IL_002e: ldloc.2
- IL_002f: ret
- L2:
- IL_0030: ldloc.2
- IL_0031: ldc.i4.1
- IL_0032: add
- IL_0033: stloc.2
- IL_0034: ldloc.0
- IL_0035: ldloc.1
- IL_0036: blt.s IL_0038
- br L3
- IL_0038: ldloc.2
- IL_0039: ret
- L3:
- IL_003a: ldloc.2
- IL_003b: ldc.i4.1
- IL_003c: add
- IL_003d: stloc.2
- IL_003e: ldloc.0
- IL_003f: ldloc.1
- IL_0040: bgt.s IL_0042
- br L4
- IL_0042: ldloc.2
- IL_0043: ret
- L4:
- IL_0044: ldloc.2
- IL_0045: ldc.i4.1
- IL_0046: add
- IL_0047: stloc.2
- IL_0048: ldloc.2
- IL_0049: ret
- } // end of method Tests::test_5_float_branch_nan
-
- .method private static hidebysig
- default void regress_80622_inner (object x) cil managed
- {
- .locals init (unsigned int8 i)
- // Method begins at RVA 0x2050
- // Code size 14 (0xe)
- .maxstack 8
- IL_1000: ldarg.0
- IL_1001: unbox unsigned int8
- IL_1006: ldobj unsigned int8
- IL_000b: conv.ovf.i4.un
- IL_000c: pop
- IL_000d: ret
- }
-
- // method line 2
- .method private static hidebysig
- default int32 test_0_regress_80622 () cil managed
- {
- .maxstack 8
- IL_0000: ldc.i4 255
- IL_0005: box unsigned int8
- IL_000a: call void class Tests::regress_80622_inner (object)
- ldc.i4.0
- IL_000f: ret
- }
-
- .method private static default int32 test_0_regresss_80190 () cil managed
- {
- .maxstack 2
- .locals init (int32 V_0,
- int32* V_1)
- IL_0000: nop
- IL_0001: nop
- IL_0002: ldloca.s V_0
- IL_0004: conv.u
- IL_0005: stloc.1
- IL_0006: ldloc.1
- IL_0007: ldc.i4.3
- IL_0008: stind.i4
- IL_0009: nop
- ldc.i4.0
- ret
- }
-
- .class interface nested public auto ansi abstract IFaceWithStaticMethod
- {
- .method public static specialname
- default void foo () cil managed noinlining
- {
- .maxstack 0
- IL_0000: ret
- }
- }
-
- .class nested public auto ansi AClass extends [mscorlib]System.Object implements Tests/IFaceWithStaticMethod
- {
- .method public hidebysig specialname rtspecialname
- instance default void .ctor () cil managed
- {
- .maxstack 8
- ret
- }
-
- }
-
- // Test that static methods in interfaces are ignored during vtable construction
- .method private static default int32 test_0_ifaces_with_static_methods () cil managed
- {
- .maxstack 16
-
- newobj instance void class Tests/AClass::.ctor()
- pop
- ldc.i4.0
- ret
- }
-
- .method private static hidebysig default int32 Foo<T> (!!T n) cil managed {
- ldarg.0
- box !!0
- brtrue HAS_VALUE
- ldc.i4.0
- ret
-HAS_VALUE: ldc.i4.1
- ret
- }
-
- // bug 78019
- .method static public int32 test_0_nullable_box_brtrue () cil managed {
-
- .locals init (valuetype [mscorlib]System.Nullable`1<int32> V_0)
-
- ldloc.0
- call int32 class Tests::Foo<valuetype [mscorlib]System.Nullable`1<int32>> (!!0)
- ret
- }
-
- //Bug 372410
- .method static public int32 test_0_ldelema_type_check () cil managed {
- .maxstack 16
- .locals init (object[] V_0,
- object[,] V_1)
-
- ldc.i4.1
- newarr object
- stloc.0
-
- .try {
- ldloc.0
- ldc.i4.0
- ldelema object
- leave L1
- } catch [mscorlib]System.ArrayTypeMismatchException {
- leave ERROR1
- }
-
- L1:
- ldc.i4.1
- newarr string
- stloc.0
-
- .try {
- ldloc.0
- ldc.i4.0
- ldelema object
- leave ERROR2
- } catch [mscorlib]System.ArrayTypeMismatchException {
- leave L2
- }
-
- L2:
- ldc.i4.1
- newarr string
- stloc.0
-
- .try {
- ldloc.0
- ldc.i4.0
- readonly. ldelema object
- leave L3
- } catch [mscorlib]System.ArrayTypeMismatchException {
- leave ERROR3
- }
-
- L3:
- ldc.i4.0
- ret
-
-
- ERROR1:
- ldc.i4.1
- ret
-
- ERROR2:
- ldc.i4.2
- ret
-
- ERROR3:
- ldc.i4.3
- ret
- }
-
-
- //Bug 372410
- .method static public int32 test_0_array_address_type_check () cil managed {
- .maxstack 16
- .locals init (object[] V_0,
- object[,] V_1)
-
- ldc.i4.1
- ldc.i4.1
- newobj instance void object[,]::.ctor(int32, int32)
- stloc.1
-
- .try {
- ldloc.1
- ldc.i4.0
- ldc.i4.0
- call instance object& object[,]::Address(int32, int32)
- leave L4
- } catch [mscorlib]System.ArrayTypeMismatchException {
- leave ERROR4
- }
-
- L4:
- ldc.i4.1
- ldc.i4.1
- newobj instance void string[,]::.ctor(int32, int32)
- stloc.1
-
- .try {
- ldloc.1
- ldc.i4.0
- ldc.i4.0
- call instance object& object[,]::Address(int32, int32)
- leave ERROR5
- } catch [mscorlib]System.ArrayTypeMismatchException {
- leave L5
- }
-
- L5:
- ldc.i4.1
- ldc.i4.1
- newobj instance void string[,]::.ctor(int32, int32)
- stloc.1
-
- .try {
- ldloc.1
- ldc.i4.0
- ldc.i4.0
- readonly. call instance object& object[,]::Address(int32, int32)
- leave L6
- } catch [mscorlib]System.ArrayTypeMismatchException {
- leave ERROR6
- }
-
- L6:
- ldc.i4.0
- ret
- ERROR4:
- ldc.i4.4
- ret
-
- ERROR5:
- ldc.i4.5
- ret
-
- ERROR6:
- ldc.i4.6
- ret
- }
-
- .field public static unsigned int64 'ull'
-
- .field public static int32 'shift2'
-
- .method public static int32 test_0_long_shift_regalloc () cil managed
- {
- .locals init (unsigned int32 'cilsimp.28', unsigned int64 'cilsimp.27', int32 'cilsimp.26')
-
- .maxstack 4
-
- ldc.i8 81985529234382576
- stsfld unsigned int64 Tests::ull
- ldc.i4 60
- stsfld int32 Tests::shift2
-
- ldsfld unsigned int64 Tests::ull
- stloc 'cilsimp.27'
- ldsfld int32 Tests::shift2
- stloc 'cilsimp.28'
- ldloc 'cilsimp.27'
- ldloc 'cilsimp.28'
- shr.un
- ldloc 'cilsimp.27'
- ldc.i4 64
- ldloc 'cilsimp.28'
- sub
- shl
- or
- ldc.i8 1311768467750121216
- ceq
- ldc.i4.1
- xor
- conv.u4
- ret
- }
-
- // Test calling ldfld directly on a vtype instead of a vtype address
- .method public static int32 test_5_call_ldfld_vtype () cil managed
- {
- .maxstack 16
- .locals init (
- valuetype Tests/TailCallStruct arg
- )
- ldloca 0
- ldc.i4.2
- stfld int32 Tests/TailCallStruct::a
- ldloca 0
- ldc.i4.4
- stfld int32 Tests/TailCallStruct::b
- ldloc.0
- call valuetype Tests/TailCallStruct Tests::tail2 (valuetype Tests/TailCallStruct)
- ldfld int32 Tests/TailCallStruct::a
- ret
- }
-
- .method public static int32 throw_ret () cil managed
- {
- ldstr "FOO"
- newobj instance void class [mscorlib]System.OverflowException::.ctor(string)
- throw
- ldc.i4.4
- ret
- }
-
- .method public static int32 throw2_ret () cil managed
- {
- // Disable inlining
- ldc.i4.5
- localloc
- pop
-
- call int32 Tests::throw_ret ()
- ret
- }
-
- // Test inlining a method which contains just a throw
- .method public static int32 test_0_inline_throw () cil managed
- {
- .maxstack 16
- .locals init (
- int32 v_0
- )
-
- .try {
- call int32 Tests::throw2_ret ()
- stloc.0
- leave L0
- } catch [mscorlib]System.OverflowException {
- pop
- leave L1
- }
-
- L0:
- ldc.i4.1
- ret
- L1:
- ldc.i4.0
- ret
- }
-
- .method public static int32 test_0_stelem_any_null_opt () cil managed
- {
- .maxstack 16
- .locals init (
- object[] V_0,
- int32 V_1)
-
- ldc.i4.s 10
- newarr [mscorlib]System.Object
- stloc.0
-
- ldc.i4.0
- stloc.1
- br L0
-
- L1:
- ldloc.0
- ldloc.1
- ldnull
- stelem.any [mscorlib]System.Object
- ldloc.1
- ldc.i4.1
- add
- stloc.1
- L0:
- ldloc.1
- ldc.i4.s 10
- blt L1
-
- ldc.i4.0
- ret
- }
-
- // method line 2
- .method public static hidebysig
- default int32 manyargs_callee (int32 a, int32 b, int32 c, int32 d, int32 e, int32 f, int32 g, int32 h, int32 i, int32 j, int32 k, int32 l, int32 m, int32 n, int32 o, int32 p) cil managed
- {
- // Method begins at RVA 0x20f4
- // Code size 44 (0x2c)
- .maxstack 8
- IL_0000: ldarg.0
- IL_0001: ldarg.1
- IL_0002: add
- IL_0003: ldarg.2
- IL_0004: add
- IL_0005: ldarg.3
- IL_0006: add
- IL_0007: ldarg.s 4
- IL_0009: add
- IL_000a: ldarg.s 5
- IL_000c: add
- IL_000d: ldarg.s 6
- IL_000f: add
- IL_0010: ldarg.s 7
- IL_0012: add
- IL_0013: ldarg.s 8
- IL_0015: add
- IL_0016: ldarg.s 9
- IL_0018: add
- IL_0019: ldarg.s 10
- IL_001b: add
- IL_001c: ldarg.s 11
- IL_001e: add
- IL_001f: ldarg.s 12
- IL_0021: add
- IL_0022: ldarg.s 13
- IL_0024: add
- IL_0025: ldarg.s 14
- IL_0027: add
- IL_0028: ldarg.s 15
- IL_002a: add
- IL_002b: ret
- } // end of method main::callee
-
- // method line 3
- .method public static hidebysig
- default int32 manyargs_tail_caller (int32 a, int32 b, int32 c, int32 d, int32 e, int32 f, int32 g, int32 h, int32 i, int32 j, int32 k, int32 l, int32 m, int32 n, int32 o, int32 p) cil managed
- {
- // Method begins at RVA 0x2124
- // Code size 34 (0x22)
- .maxstack 17
- IL_0000: ldarg.0
- ldc.i4.1
- add
- IL_0001: ldarg.1
- IL_0002: ldarg.2
- IL_0003: ldarg.3
- IL_0004: ldarg.s 4
- IL_0006: ldarg.s 5
- IL_0008: ldarg.s 6
- IL_000a: ldarg.s 7
- IL_000c: ldarg.s 8
- IL_000e: ldarg.s 9
- IL_0010: ldarg.s 10
- IL_0012: ldarg.s 11
- IL_0014: ldarg.s 12
- IL_0016: ldarg.s 13
- IL_0018: ldarg.s 14
- ldc.i4.1
- add
- IL_001a: ldarg.s 15
- ldc.i4.1
- add
- tail.
- IL_001c: call int32 class Tests::manyargs_callee(int32, int32, int32, int32, int32, int32, int32, int32, int32, int32, int32, int32, int32, int32, int32, int32)
- IL_0021: ret
- } // end of method main::caller
-
- // method line 4
- .method public static hidebysig
- default int32 test_139_many_args_tail_call () cil managed
- {
- // Some platforms might not be able to AOT tail calls
- .custom instance void class [TestDriver]CategoryAttribute::'.ctor'(string) = (01 00 08 21 46 55 4C 4C 41 4F 54 00 00 ) // ...!FULLAOT..
-
- // Method begins at RVA 0x2154
- // Code size 43 (0x2b)
- .maxstack 17
- IL_0000: ldc.i4.1
- IL_0001: ldc.i4.2
- IL_0002: ldc.i4.3
- IL_0003: ldc.i4.4
- IL_0004: ldc.i4.5
- IL_0005: ldc.i4.6
- IL_0006: ldc.i4.7
- IL_0007: ldc.i4.8
- IL_0008: ldc.i4.s 0x09
- IL_000a: ldc.i4.s 0x0a
- IL_000c: ldc.i4.s 0x0b
- IL_000e: ldc.i4.s 0x0c
- IL_0010: ldc.i4.s 0x0d
- IL_0012: ldc.i4.s 0x0e
- IL_0014: ldc.i4.s 0x0f
- IL_0016: ldc.i4.s 0x10
- IL_0018: call int32 class Tests::manyargs_tail_caller(int32, int32, int32, int32, int32, int32, int32, int32, int32, int32, int32, int32, int32, int32, int32, int32)
- IL_0028: ret
- } // end of method main::Main
-
- .class nested private auto ansi beforefieldinit R1
- extends [mscorlib]System.MarshalByRefObject
- {
- .field public int32 test_field
-
- .method public hidebysig specialname rtspecialname
- instance default void '.ctor' () cil managed
- {
- ret
- }
- }
-
- .method public static hidebysig
- default int32 return_0 () cil managed
- {
- ldc.i4.0
- ret
- }
-
- .method public static hidebysig
- default int32 test_1_volatile_marshalbyref_bug_432673 () cil managed
- {
- .locals init (
- class Tests/R1 v_0
- )
-
- newobj instance void class Tests/R1::.ctor ()
- stloc.0
- ldloc.0
- ldc.i4.0
- volatile.
- stfld int32 Tests/R1::test_field
- call int32 class Tests::return_0 ()
- ldc.i4.1
- add
- ret
- }
-
- .method public static default int32 return_2 () cil managed
- {
- // Prevent inlining
- ldc.i4.s 16
- localloc
- pop
- ldc.i4.s 2
- ret
- }
-
- .method public static hidebysig
- default int32 test_1_cmov_opt_regress_463357 () cil managed
- {
- call int32 class Tests::return_2 ()
- ldc.i4.0
- ceq
- brfalse L1
- ldc.i4.0
- ret
- br L2
- L1: nop
- L2: nop
- ldc.i4.1
- ret
- }
-
- .method public static hidebysig default int32 cmov_opt_regress_474718_inner (int32 A_1) cil managed
- {
- .maxstack 3
- .locals init (int32 V_0, bool V_1, bool V_2)
-
- ldc.i4.0
- IL_000b: stloc.1
- IL_000d: br IL_002f
-
- ldc.i4.1
- stloc.2
- IL_001e: ldloc.2
- IL_001f: brfalse IL_0036
-
- IL_0024:
- IL_002a: br IL_0041
-
- IL_002f: ldloc.1
- IL_0030: stloc.2
- IL_0031: br IL_001e
-
- IL_0036: ldc.i4 0
- IL_003b: stloc.0
- IL_003c: br IL_0041
-
- IL_0041: ldloc.0
- IL_0042: ret
- }
-
- .method public static default int32 test_0_cmov_opt_regress_474718 () cil managed
- {
- .maxstack 16
- ldc.i4.1
- call int32 Tests::cmov_opt_regress_474718_inner (int32)
- ret
- }
-
- .method public static default int32 test_5_createarr_newobj () cil managed
- {
- .maxstack 16
-
- ldc.i4 5
- newobj void char[]::.ctor(int32)
- ldlen
- ret
- }
-
- .method public static default int32 test_0_initblk_3_regress_481458 () cil managed
- {
- .maxstack 16
- .locals init (native int)
-
- ldc.i4.s 10
- localloc
- stloc.0
-
- // Set the first value to 3
- ldloc.0
- ldc.i4.0
- add //addr
- ldc.i4.3 //value
- stind.i1
-
- // Zero out the first 3 values
- ldloc.0 //addr
- ldc.i4.0 //value
- ldc.i4.s 3 //size
- initblk
-
- // Load the first value
- ldloc.0
- ldc.i4.0
- add
- ldind.u1
- conv.i4
- ret
- }
-
- .method public static float32 GetFloat32() cil managed noinlining
- {
- .maxstack 8
- ldc.r8 0.19975845134874831
- ret
- }
-
-/* Disabled until they can be fixed to run on amd64
- .method public static default int32 test_0_implicit_float_to_double_conversion () cil managed
- {
- .maxstack 16
-
- call float32 Tests::GetFloat32()
- ldc.r8 0.19975845134874831
- beq OK
-
- ldc.i4.1
- ret
-OK:
- ldc.i4.0
- ret
- }
-*/
-
- .method public static default int32 test_0_long_to_r8_un_overflow () cil managed
- {
- .maxstack 16
- ldc.i8 0x00FFFFFFFFFFFFFF
- conv.r.un
- conv.i8
- ldc.i8 0x100000000000000
- beq OK_1
-
- ldc.i4.1
- ret
-OK_1:
- ldc.i8 0x00FFFFFFFFFFFFFF
- conv.r.un
- conv.r8
- conv.i8
- ldc.i8 0x100000000000000
- beq OK_2
-
- ldc.i4.2
- ret
-OK_2:
- ldc.i4.0
- ret
- }
-
- .field public static int32 shift1
-
- .method public static int32 regress_497271_helper (int32 i) cil managed
- {
- ldarg.0
- ret
- }
-
- .method public static int32 test_0_regalloc_regress_497271 () cil managed
- {
- .locals init (int32 var)
-
- ldc.i4 4
- stsfld int32 Tests::shift1
- ldsfld int32 Tests::shift1
- stloc var
- ldc.i4 4660
- ldloc var
- shr.un
- ldc.i4 4660
- ldc.i4 32
- ldloc var
- sub
- shl
- or
- ldc.i4 1073742115
- beq ?L10
-?L9:
- ldc.i4 1
- call int32 Tests::regress_497271_helper (int32)
- ret
-?L10:
- ldc.i4 0
- call int32 Tests::regress_497271_helper (int32)
- ret
- }
-
- .field private static int32 Value
-
- .method public static hidebysig specialname
- default int32 regress_513931_inner () cil managed
- {
- // Method begins at RVA 0x225c
- // Code size 52 (0x34)
- .maxstack 2
- .locals init (
- int32 V_0,
- int32 V_1,
- bool V_2)
-
- ldc.i4 999
- stsfld int32 Tests::Value
-
- IL_0000: nop
- IL_0001: ldsfld int32 Tests::Value
- IL_0006: stloc.0
- IL_0007: ldloc.0
- IL_0008: ldc.i4.0
- IL_0009: cgt
- IL_000b: ldc.i4.0
- IL_000c: ceq
- IL_000e: stloc.2
- IL_000f: ldloc.2
- IL_0010: brtrue.s IL_0027
-
- IL_0012: nop
- IL_0013: ldloc.0
- IL_0014: ldc.i4.s 0x7b
- IL_0016: ceq
- IL_0018: ldc.i4.0
- IL_0019: ceq
- IL_001b: stloc.2
- IL_001c: ldloc.2
- IL_001d: brtrue.s IL_0023
-
- IL_001f: ldc.i4.m1
- IL_0020: stloc.1
- IL_0021: br.s IL_0032
-
- IL_0023: ldc.i4.1
- IL_0024: stloc.1
- IL_0025: br.s IL_0032
-
- IL_0027:
- IL_002c: newobj instance void class [mscorlib]System.Exception::'.ctor'()
- IL_0031: throw
- IL_0032: ldloc.1
- IL_0033: ret
- }
-
- .method public static hidebysig specialname
- default int32 test_0_regress_513931 () cil managed
- {
- call int32 Tests::regress_513931_inner ()
- pop
- ldc.i4.0
- ret
- }
-
- .method public static default int32 test_0_newarr_i8 () cil managed
- {
- ldc.i4 1000
- conv.i8
- newarr [mscorlib]System.Boolean
- pop
- ldc.i4 0
- ret
- }
-
- .method public static specialname
- default int32 return_1_noinline () cil managed noinlining
- {
- .maxstack 0
-
- ldc.i4.1
- ret
- }
-
- // Only happens with -O=-deadce,cmov
- .method public static default int32 test_0_cmov_unused_582322 () cil managed
- {
- .maxstack 2
- .locals init (
- int32 V_0
- )
- call int32 Tests::return_1_noinline ()
- ldc.i4.1
- bne.un L0
- ldloc.s 0
- pop
- L0:
- ldc.i4.0
- ret
- }
-
- .method public static hidebysig
- default int32 test_0_regress_586664 () cil managed
- {
- // Method begins at RVA 0x20f4
- // Code size 76 (0x4c)
- .maxstack 6
- .locals init (
- float64 V_0,
- float64[] V_1)
- IL_0000: ldc.r8 1.
- IL_0009: ldc.r8 2.
- IL_0012: ldc.r8 1.
- IL_001b: call float64 class [mscorlib]System.Math::Pow(float64, float64)
- IL_0020: div
- IL_0021: stloc.0
- IL_0022: ldc.i4.2
- IL_0023: newarr [mscorlib]System.Double
- IL_0028: dup
- IL_0029: ldc.i4.0
- IL_002a: ldloc.0
- IL_002b: neg
- IL_002c: stelem.r8
- IL_002d: dup
- IL_002e: ldc.i4.1
- IL_002f: ldloc.0
- IL_0030: neg
- IL_0031: stelem.r8
- IL_0032: stloc.1
- IL_0033: ldloc.1
- IL_0034: ldc.i4.0
- IL_0035: ldelem.r8
- IL_0036: ldc.r8 -0.5
- IL_003f: bne.un IL_004a
-
- IL_0044: ldc.i4.0
- IL_0045: br IL_004b
-
- IL_004a: ldc.i4.1
- IL_004b: ret
- }
-
- .method public static int32 test_2_leave_multiple_blocks_from_end ()
- {
- .locals init (int32 V_0)
-
- .try {
- .try {
- nop
- nop
- leave END
- } finally {
- ldloc.0
- ldc.i4.1
- add
- stloc.0
- endfinally
- }
- nop
- leave END
- } finally {
- ldloc.0
- ldc.i4.1
- add
- stloc.0
- endfinally
- }
-END:
- ldloc.0
- ret
- }
-
- .method public static int32 test_3_leave_multiple_blocks_from_hole ()
- {
- .locals init (int32 V_0)
-
- .try {
- .try {
- ldloc.0
- brtrue REST
- leave BEFORE_END
-REST:
- nop
- nop
- leave END
- } finally {
- ldloc.0
- ldc.i4.1
- add
- stloc.0
- endfinally
- }
- nop
- leave END
- } finally {
- ldloc.0
- ldc.i4.1
- add
- stloc.0
- endfinally
- }
-BEFORE_END:
- ldloc.0
- ldc.i4.1
- add
- stloc.0
-END:
- ldloc.0
- ret
- }
-
- .class nested private auto ansi sealed beforefieldinit Pair`2<TKey,TValue>
- extends [mscorlib]System.ValueType
- {
- .field public !0 key
- .field public !1 'value'
- }
-
- .method private static hidebysig
- default bool ContentEquals<TKey,TValue> (valuetype Tests/Pair`2<!!TKey, !!TValue> v) cil managed
- {
- .maxstack 8
- IL_0000: ldarga.s 0
- IL_0006: ldnull
- constrained. valuetype Tests/Pair`2<!!0,!!1>
- IL_0007: callvirt instance bool class [mscorlib]System.Object::Equals(object)
- ret
- }
-
- .method public static hidebysig default int32 test_0_constrained_gshared_595863 () cil managed
- {
- .locals init (
- valuetype Tests/Pair`2<string, string> V_0,
- valuetype Tests/Pair`2<string, string> V_1)
- IL_0000: ldloca.s 0
- IL_0002: initobj valuetype Tests/Pair`2<string,string>
- IL_0008: ldloc.0
- IL_0009: stloc.1
- IL_000a: ldloca.s 1
- IL_000c: ldstr "A"
- IL_0011: stfld !0 valuetype Tests/Pair`2<string,string>::key
- IL_0016: ldloca.s 1
- IL_0018: ldstr "B"
- IL_001d: stfld !1 valuetype Tests/Pair`2<string,string>::'value'
- IL_0022: ldloc.1
- IL_0023: stloc.0
- IL_0024: ldloc.0
- IL_0025: call bool class Tests::ContentEquals<string, string> (valuetype Tests/Pair`2<!!0,!!1>)
- brfalse SUCCESS
- ldc.i4.1
- ret
- SUCCESS:
- ldc.i4.0
- ret
- }
-
- .method public static default int32 test_0_wrap_non_exception_throws () cil managed
- {
- .try {
- newobj instance void class [mscorlib]System.Object::'.ctor'()
- throw
- leave IL_0
- } catch class [mscorlib]System.Runtime.CompilerServices.RuntimeWrappedException {
- leave IL_0
- }
- IL_0:
- ldc.i4.0
- ret
- }
-
- .method public static default int32 test_0_typespec_modopt () cil managed {
- ldtoken class Tests modopt (Tests)
- pop
- ldc.i4.0
- ret
- }
-
- .method public hidebysig static int32 SizeOfT<T>() cil managed
- {
- .maxstack 8
-
- sizeof !!0
- ret
- }
-
- .method public static default int32 test_1_sizeof_gshared () cil managed {
- call int32 Tests::SizeOfT<int8>()
- ldc.i4.1
- ceq
- ret
- }
-
- .method public static default int32 test_1_sizeof_ref () cil managed {
- call int32 Tests::SizeOfT<object>()
- sizeof [mscorlib]System.IntPtr
- ceq
- ret
- }
-
- .field static public int32 volatile_int
-
- .method public static default int32 test_5_volatile_load_store () cil managed {
- ldsflda int32 class Tests::volatile_int
- ldc.i4 5
- volatile.
- stind.i4
- ldsflda int32 class Tests::volatile_int
- volatile.
- ldind.i4
- ret
- }
-
- .method public static
- default int32 regress_693905_inner (int32 x, int32 acc) cil managed
- {
- // Method begins at RVA 0x2050
- // Code size 17 (0x11)
- .maxstack 5
- IL_0000: ldarg.0
- IL_0001: brtrue.s IL_0005
-
- IL_0003: ldarg.1
- IL_0004: ret
- IL_0005: ldarg.0
- IL_0006: ldc.i4.1
- IL_0007: sub
- IL_0008: ldarg.1
- IL_0009: ldc.i4.1
- IL_000a: add
- IL_000b: starg.s 1
- IL_000d: starg.s 0
- IL_000f: br.s IL_0000
-
- } // end of method Test::f
-
- .method public static
- default int32 test_10_regress_693905 () cil managed
- {
- ldc.i4.s 0x0a
- ldc.i4.0
- call int32 class Tests::regress_693905_inner(int32, int32)
- ret
- }
-
- .method public static
- default int32 test_0_llvm_regress_171 () cil managed
- {
- .locals init (
- int32 i
- )
-
- call int32 Tests::return_1_noinline ()
- ldc.i4.1
- beq L1
- ldc.i4.1
- stloc.s 0
- call int32 Tests::return_1_noinline ()
- ldc.i4.0
- beq L1
- L1:
- ldloc.s 0
- ret
- }
-
- .field public static int32 static_a
-
- .method public static
- default int32 test_4_ldfld_stfld_static () cil managed
- {
- ldnull
- ldc.i4 2
- stfld int32 Tests::static_a
- ldnull
- ldfld int32 Tests::static_a
- ldnull
- ldflda int32 Tests::static_a
- ldind.i4
- add
- ret
- }
-
- .method public static default int32 no_initlocals_inner () cil managed
- {
- .locals (
- int32 V_0,
- float32 V_1,
- float64 V_2,
- valuetype Tests/TailCallStruct V_3)
- ldloc V_0
- ret
- }
-
- .method public static default int32 test_0_no_initlocals () cil managed
- {
- call int32 Tests::no_initlocals_inner()
- pop
- ldc.i4.0
- ret
- }
-
- .method public hidebysig static int32 test_5_r4_fadd_mixed() cil managed
- {
- // Code size 17 (0x11)
- .maxstack 2
- .locals init (float32 V_0,
- float64 V_1)
- IL_0000: ldc.r4 3
- IL_0005: stloc.0
- IL_0006: ldc.r8 2
- IL_000b: stloc.1
- IL_000c: ldloc.0
- IL_000d: ldloc.1
- IL_000e: add
- IL_000f: conv.i4
- IL_0010: ret
- }
-
- .method public hidebysig static int32 test_0_fcmp_eq_r4_mixed() cil managed
- {
- // Code size 32 (0x20)
- .maxstack 2
- .locals init (float32 V_0,
- float64 V_1)
- IL_0000: ldc.r4 1
- IL_0005: stloc.0
- IL_0006: ldc.r8 1
- IL_000f: stloc.1
- IL_0010: ldloc.0
- IL_0012: ldloc.1
- IL_0013: bne.un IL_001e
-
- IL_0018: ldc.i4.0
- IL_0019: br IL_001f
-
- IL_001e: ldc.i4.1
- IL_001f: ret
- } // end of method Tests::test_0_fcmp_eq_r4_mixed
-
- .method public hidebysig static int32 test_0_fceq_r4_mixed() cil managed
- {
- // Code size 31 (0x1f)
- .maxstack 2
- .locals init (float32 V_0,
- float64 V_1,
- bool V_2)
- IL_0000: ldc.r4 1
- IL_0005: stloc.0
- IL_0006: ldc.r8 1
- IL_000b: stloc.1
- IL_000c: ldloc.0
- IL_000d: ldloc.1
- IL_000e: ceq
- IL_0010: stloc.2
- IL_0011: ldloc.2
- IL_0012: brfalse IL_001d
-
- IL_0017: ldc.i4.0
- IL_0018: br IL_001e
-
- IL_001d: ldc.i4.1
- IL_001e: ret
- } // end of method Tests::test_0_fceq_r4
-
- .method public static int32 test_0_switch_loop () cil managed
- {
- .maxstack 16
- .locals init (valuetype Tests/TailCallStruct V_0, int32 V_1)
- ldc.i4.0
- ldloc.0
- ldloc.1
- brtrue L_1
- L_0:
- ldc.i4.4
- switch (L_0)
- L_1:
- pop
- ret
- }
-}
* Return the executable code for the iface method IMT_METHOD called on THIS.
*/
gpointer
-mono_resolve_iface_call (MonoObject *this, int imt_slot, MonoMethod *imt_method, gpointer *out_rgctx_arg)
+mono_resolve_iface_call (MonoObject *this_obj, int imt_slot, MonoMethod *imt_method, gpointer *out_rgctx_arg)
{
MonoVTable *vt;
gpointer *imt, *vtable_slot;
// FIXME: Optimize this
- if (!this)
+ if (!this_obj)
/* The caller will handle it */
return NULL;
- vt = this->vtable;
+ vt = this_obj->vtable;
imt = (gpointer*)vt - MONO_IMT_SIZE;
vtable_slot = mini_resolve_imt_method (vt, imt + imt_slot, imt_method, &impl_method, &aot_addr, &need_rgctx_tramp, &variant_iface);
/*
* mono_resolve_vcall:
*
- * Return the executable code for calling this->vtable [slot].
+ * Return the executable code for calling this_obj->vtable [slot].
*/
gpointer
-mono_resolve_vcall (MonoObject *this, int slot, MonoMethod *imt_method)
+mono_resolve_vcall (MonoObject *this_obj, int slot, MonoMethod *imt_method)
{
MonoVTable *vt;
MonoMethod *m, *generic_virtual = NULL;
// FIXME: Optimize this
- if (!this)
+ if (!this_obj)
/* The caller will handle it */
return NULL;
- vt = this->vtable;
+ vt = this_obj->vtable;
vtable_slot = &(vt->vtable [slot]);
MONO_AOT_MODE_NONE,
/* Enables normal AOT mode, equivalent to mono_jit_set_aot_only (false) */
MONO_AOT_MODE_NORMAL,
- /* Enables hyrbid AOT mode, JIT can still be used for wrappers */
+ /* Enables hybrid AOT mode, JIT can still be used for wrappers */
MONO_AOT_MODE_HYBRID,
/* Enables full AOT mode, JIT is disabled and not allowed,
* equivalent to mono_jit_set_aot_only (true) */
- MONO_AOT_MODE_FULL
+ MONO_AOT_MODE_FULL,
+ /* Same as full, but use only llvm compiled code */
+ MONO_AOT_MODE_LLVMONLY
} MonoAotMode;
MONO_API void
#include <mono/metadata/debug-helpers.h>
#include <mono/metadata/mono-debug.h>
#include <mono/metadata/mono-debug-debugger.h>
-#include <mono/metadata/gc-internal.h>
+#include <mono/metadata/gc-internals.h>
#include <mono/metadata/security-manager.h>
#include <mono/metadata/threads-types.h>
#include <mono/metadata/security-core-clr.h>
#include "jit.h"
#include "debugger-agent.h"
#include "seq-points.h"
+#include "aot-compiler.h"
#define BRANCH_COST 10
#define INLINE_LENGTH_LIMIT 20
}
}
+static MonoInst*
+emit_runtime_constant (MonoCompile *cfg, MonoJumpInfoType patch_type, gpointer data)
+{
+ MonoInst *ins;
+
+ if (cfg->compile_aot) {
+ EMIT_NEW_AOTCONST (cfg, ins, patch_type, data);
+ } else {
+ MonoJumpInfo ji;
+ gpointer target;
+
+ ji.type = patch_type;
+ ji.data.target = data;
+ target = mono_resolve_patch_target (NULL, cfg->domain, NULL, &ji, FALSE);
+
+ EMIT_NEW_PCONST (cfg, ins, target);
+ }
+ return ins;
+}
+
static void
mini_emit_interface_bitmap_check (MonoCompile *cfg, int intf_bit_reg, int base_reg, int offset, MonoClass *klass)
{
NEW_LOAD_MEMBASE (cfg, ins, OP_LOAD_MEMBASE, ibitmap_reg, base_reg, offset);
MONO_ADD_INS (cfg->cbb, ins);
args [0] = ins;
- if (cfg->compile_aot)
- EMIT_NEW_AOTCONST (cfg, args [1], MONO_PATCH_INFO_IID, klass);
- else
- EMIT_NEW_ICONST (cfg, args [1], klass->interface_id);
+ args [1] = emit_runtime_constant (cfg, MONO_PATCH_INFO_IID, klass);
res = mono_emit_jit_icall (cfg, mono_class_interface_match, args);
MONO_EMIT_NEW_UNALU (cfg, OP_MOVE, intf_bit_reg, res->dreg);
#else
{
if (klass_inst) {
MONO_EMIT_NEW_BIALU (cfg, OP_COMPARE, -1, klass_reg, klass_inst->dreg);
- } else if (cfg->compile_aot) {
- int const_reg = alloc_preg (cfg);
- MONO_EMIT_NEW_CLASSCONST (cfg, const_reg, klass);
- MONO_EMIT_NEW_BIALU (cfg, OP_COMPARE, -1, klass_reg, const_reg);
} else {
- MONO_EMIT_NEW_BIALU_IMM (cfg, OP_COMPARE_IMM, -1, klass_reg, klass);
+ MonoInst *ins = emit_runtime_constant (cfg, MONO_PATCH_INFO_CLASS, klass);
+ MONO_EMIT_NEW_BIALU (cfg, OP_COMPARE, -1, klass_reg, ins->dreg);
}
MONO_EMIT_NEW_COND_EXC (cfg, NE_UN, "InvalidCastException");
}
int method_reg;
if (COMPILE_LLVM (cfg)) {
- method_reg = alloc_preg (cfg);
-
if (imt_arg) {
+ method_reg = alloc_preg (cfg);
MONO_EMIT_NEW_UNALU (cfg, OP_MOVE, method_reg, imt_arg->dreg);
- } else if (cfg->compile_aot) {
- MONO_EMIT_NEW_AOTCONST (cfg, method_reg, method, MONO_PATCH_INFO_METHODCONST);
} else {
- MonoInst *ins;
- MONO_INST_NEW (cfg, ins, OP_PCONST);
- ins->inst_p0 = method;
- ins->dreg = method_reg;
- MONO_ADD_INS (cfg->cbb, ins);
+ MonoInst *ins = emit_runtime_constant (cfg, MONO_PATCH_INFO_METHODCONST, method);
+ method_reg = ins->dreg;
}
#ifdef ENABLE_LLVM
return;
}
- method_reg = alloc_preg (cfg);
-
if (imt_arg) {
+ method_reg = alloc_preg (cfg);
MONO_EMIT_NEW_UNALU (cfg, OP_MOVE, method_reg, imt_arg->dreg);
- } else if (cfg->compile_aot) {
- MONO_EMIT_NEW_AOTCONST (cfg, method_reg, method, MONO_PATCH_INFO_METHODCONST);
} else {
- MonoInst *ins;
- MONO_INST_NEW (cfg, ins, OP_PCONST);
- ins->inst_p0 = method;
- ins->dreg = method_reg;
- MONO_ADD_INS (cfg->cbb, ins);
+ MonoInst *ins = emit_runtime_constant (cfg, MONO_PATCH_INFO_METHODCONST, method);
+ method_reg = ins->dreg;
}
mono_call_inst_add_outarg_reg (cfg, call, method_reg, MONO_ARCH_IMT_REG, FALSE);
MONO_ADD_INS (cfg->cbb, wbarrier);
} else if (card_table && !cfg->compile_aot && !mono_gc_card_table_nursery_check ()) {
int offset_reg = alloc_preg (cfg);
- int card_reg = alloc_preg (cfg);
+ int card_reg;
MonoInst *ins;
MONO_EMIT_NEW_BIALU_IMM (cfg, OP_SHR_UN_IMM, offset_reg, ptr->dreg, card_table_shift_bits);
/*We can't use PADD_IMM since the cardtable might end up in high addresses and amd64 doesn't support
* IMM's larger than 32bits.
*/
- if (cfg->compile_aot) {
- MONO_EMIT_NEW_AOTCONST (cfg, card_reg, NULL, MONO_PATCH_INFO_GC_CARD_TABLE_ADDR);
- } else {
- MONO_INST_NEW (cfg, ins, OP_PCONST);
- ins->inst_p0 = card_table;
- ins->dreg = card_reg;
- MONO_ADD_INS (cfg->cbb, ins);
- }
+ ins = emit_runtime_constant (cfg, MONO_PATCH_INFO_GC_CARD_TABLE_ADDR, NULL);
+ card_reg = ins->dreg;
MONO_EMIT_NEW_BIALU (cfg, OP_PADD, offset_reg, offset_reg, card_reg);
MONO_EMIT_NEW_STORE_MEMBASE_IMM (cfg, OP_STOREI1_MEMBASE_IMM, offset_reg, 0, 1);
} else if (context_used) {
iargs [2] = emit_get_rgctx_klass (cfg, context_used, klass, MONO_RGCTX_INFO_KLASS);
} else {
- if (cfg->compile_aot) {
- EMIT_NEW_CLASSCONST (cfg, iargs [2], klass);
- } else {
- EMIT_NEW_PCONST (cfg, iargs [2], klass);
+ iargs [2] = emit_runtime_constant (cfg, MONO_PATCH_INFO_CLASS, klass);
+ if (!cfg->compile_aot)
mono_class_compute_gc_descriptor (klass);
- }
}
if (size_ins)
if (cfg->opt & MONO_OPT_SHARED) {
int class_reg = alloc_preg (cfg);
+ MonoInst *ins;
+
MONO_EMIT_NEW_LOAD_MEMBASE (cfg, class_reg, vtable_reg, MONO_STRUCT_OFFSET (MonoVTable, klass));
- if (cfg->compile_aot) {
- int klass_reg = alloc_preg (cfg);
- MONO_EMIT_NEW_CLASSCONST (cfg, klass_reg, array_class);
- MONO_EMIT_NEW_BIALU (cfg, OP_COMPARE, -1, class_reg, klass_reg);
- } else {
- MONO_EMIT_NEW_BIALU_IMM (cfg, OP_COMPARE_IMM, -1, class_reg, array_class);
- }
+ ins = emit_runtime_constant (cfg, MONO_PATCH_INFO_CLASS, array_class);
+ MONO_EMIT_NEW_BIALU (cfg, OP_COMPARE, -1, class_reg, ins->dreg);
} else if (context_used) {
MonoInst *vtable_ins;
EMIT_NEW_CLASSCONST (cfg, args [1], klass);
/* inline cache*/
- if (cfg->compile_aot) {
- idx = get_castclass_cache_idx (cfg);
- EMIT_NEW_AOTCONST (cfg, args [2], MONO_PATCH_INFO_CASTCLASS_CACHE, GINT_TO_POINTER (idx));
- } else {
- EMIT_NEW_PCONST (cfg, args [2], mono_domain_alloc0 (cfg->domain, sizeof (gpointer)));
- }
+ idx = get_castclass_cache_idx (cfg);
+ args [2] = emit_runtime_constant (cfg, MONO_PATCH_INFO_CASTCLASS_CACHE, GINT_TO_POINTER (idx));
/*The wrapper doesn't inline well so the bloat of inlining doesn't pay off.*/
return emit_castclass_with_cache (cfg, klass, args);
}
mono_domain_unlock (domain);
- if (cfg->compile_aot)
- EMIT_NEW_AOTCONST (cfg, code_slot_ins, MONO_PATCH_INFO_METHOD_CODE_SLOT, method);
- else
- EMIT_NEW_PCONST (cfg, code_slot_ins, code_slot);
+ code_slot_ins = emit_runtime_constant (cfg, MONO_PATCH_INFO_METHOD_CODE_SLOT, method);
}
MONO_EMIT_NEW_STORE_MEMBASE (cfg, OP_STORE_MEMBASE_REG, obj->dreg, MONO_STRUCT_OFFSET (MonoDelegate, method_code), code_slot_ins->dreg);
}
is_unsafe_mov_compatible (MonoCompile *cfg, MonoClass *param_klass, MonoClass *return_klass)
{
uint32_t align;
+ int param_size, return_size;
param_klass = mono_class_from_mono_type (mini_get_underlying_type (¶m_klass->byval_arg));
+ return_klass = mono_class_from_mono_type (mini_get_underlying_type (&return_klass->byval_arg));
+
+ if (cfg->verbose_level > 3)
+ printf ("[UNSAFE-MOV-INTRISIC] %s <- %s\n", return_klass->name, param_klass->name);
- //Only allow for valuetypes
- if (!param_klass->valuetype || !return_klass->valuetype)
+ //Don't allow mixing reference types with value types
+ if (param_klass->valuetype != return_klass->valuetype) {
+ if (cfg->verbose_level > 3)
+ printf ("[UNSAFE-MOV-INTRISIC]\tone of the args is a valuetype and the other is not\n");
return FALSE;
+ }
+
+ if (!param_klass->valuetype) {
+ if (cfg->verbose_level > 3)
+ printf ("[UNSAFE-MOV-INTRISIC]\targs are reference types\n");
+ return TRUE;
+ }
//That are blitable
if (param_klass->has_references || return_klass->has_references)
/* Avoid mixing structs and primitive types/enums, they need to be handled differently in the JIT */
if ((MONO_TYPE_ISSTRUCT (¶m_klass->byval_arg) && !MONO_TYPE_ISSTRUCT (&return_klass->byval_arg)) ||
- (!MONO_TYPE_ISSTRUCT (¶m_klass->byval_arg) && MONO_TYPE_ISSTRUCT (&return_klass->byval_arg)))
+ (!MONO_TYPE_ISSTRUCT (¶m_klass->byval_arg) && MONO_TYPE_ISSTRUCT (&return_klass->byval_arg))) {
+ if (cfg->verbose_level > 3)
+ printf ("[UNSAFE-MOV-INTRISIC]\tmixing structs and scalars\n");
return FALSE;
+ }
if (param_klass->byval_arg.type == MONO_TYPE_R4 || param_klass->byval_arg.type == MONO_TYPE_R8 ||
- return_klass->byval_arg.type == MONO_TYPE_R4 || return_klass->byval_arg.type == MONO_TYPE_R8)
+ return_klass->byval_arg.type == MONO_TYPE_R4 || return_klass->byval_arg.type == MONO_TYPE_R8) {
+ if (cfg->verbose_level > 3)
+ printf ("[UNSAFE-MOV-INTRISIC]\tfloat or double are not supported\n");
return FALSE;
+ }
+
+ param_size = mono_class_value_size (param_klass, &align);
+ return_size = mono_class_value_size (return_klass, &align);
- //And have the same size
- if (mono_class_value_size (param_klass, &align) != mono_class_value_size (return_klass, &align))
+ //We can do it if sizes match
+ if (param_size == return_size) {
+ if (cfg->verbose_level > 3)
+ printf ("[UNSAFE-MOV-INTRISIC]\tsame size\n");
+ return TRUE;
+ }
+
+ //No simple way to handle struct if sizes don't match
+ if (MONO_TYPE_ISSTRUCT (¶m_klass->byval_arg)) {
+ if (cfg->verbose_level > 3)
+ printf ("[UNSAFE-MOV-INTRISIC]\tsize mismatch and type is a struct\n");
return FALSE;
- return TRUE;
+ }
+
+ /*
+ * Same reg size category.
+ * A quick note on why we don't require widening here.
+ * The intrinsic is "R Array.UnsafeMov<S,R> (S s)".
+ *
+ * Since the source value comes from a function argument, the JIT will already have
+ * the value in a VREG and performed any widening needed before (say, when loading from a field).
+ */
+ if (param_size <= 4 && return_size <= 4) {
+ if (cfg->verbose_level > 3)
+ printf ("[UNSAFE-MOV-INTRISIC]\tsize mismatch but both are of the same reg class\n");
+ return TRUE;
+ }
+
+ return FALSE;
}
static MonoInst*
MonoClass *param_klass = mono_class_from_mono_type (fsig->params [0]);
MonoClass *return_klass = mono_class_from_mono_type (fsig->ret);
- //Valuetypes that are semantically equivalent
+ //Valuetypes that are semantically equivalent or numbers than can be widened to
if (is_unsafe_mov_compatible (cfg, param_klass, return_klass))
return args [0];
EMIT_NEW_CLASSCONST (cfg, args [1], klass);
/* inline cache*/
- if (cfg->compile_aot) {
- idx = get_castclass_cache_idx (cfg);
- EMIT_NEW_AOTCONST (cfg, args [2], MONO_PATCH_INFO_CASTCLASS_CACHE, GINT_TO_POINTER (idx));
- } else {
- EMIT_NEW_PCONST (cfg, args [2], mono_domain_alloc0 (cfg->domain, sizeof (gpointer)));
- }
+ idx = get_castclass_cache_idx (cfg);
+ args [2] = emit_runtime_constant (cfg, MONO_PATCH_INFO_CASTCLASS_CACHE, GINT_TO_POINTER (idx));
*sp++ = mono_emit_method_call (cfg, mono_isinst, args, NULL);
ip += 5;
break;
}
- case CEE_MONO_LDPTR_CARD_TABLE: {
- int shift_bits;
- gpointer card_mask;
- CHECK_STACK_OVF (1);
-
- if (cfg->compile_aot)
- EMIT_NEW_AOTCONST (cfg, ins, MONO_PATCH_INFO_GC_CARD_TABLE_ADDR, NULL);
- else
- EMIT_NEW_PCONST (cfg, ins, mono_gc_get_card_table (&shift_bits, &card_mask));
-
- *sp++ = ins;
- ip += 2;
- inline_costs += 10 * num_calls++;
- break;
- }
- case CEE_MONO_LDPTR_NURSERY_START: {
- int shift_bits;
- size_t size;
- CHECK_STACK_OVF (1);
-
- if (cfg->compile_aot)
- EMIT_NEW_AOTCONST (cfg, ins, MONO_PATCH_INFO_GC_NURSERY_START, NULL);
- else
- EMIT_NEW_PCONST (cfg, ins, mono_gc_get_nursery (&shift_bits, &size));
-
- *sp++ = ins;
- ip += 2;
- inline_costs += 10 * num_calls++;
- break;
- }
+ case CEE_MONO_LDPTR_CARD_TABLE:
+ case CEE_MONO_LDPTR_NURSERY_START:
+ case CEE_MONO_LDPTR_NURSERY_BITS:
case CEE_MONO_LDPTR_INT_REQ_FLAG: {
CHECK_STACK_OVF (1);
- if (cfg->compile_aot)
- EMIT_NEW_AOTCONST (cfg, ins, MONO_PATCH_INFO_INTERRUPTION_REQUEST_FLAG, NULL);
- else
- EMIT_NEW_PCONST (cfg, ins, mono_thread_interruption_request_flag ());
+ switch (ip [1]) {
+ case CEE_MONO_LDPTR_CARD_TABLE:
+ ins = emit_runtime_constant (cfg, MONO_PATCH_INFO_GC_CARD_TABLE_ADDR, NULL);
+ break;
+ case CEE_MONO_LDPTR_NURSERY_START:
+ ins = emit_runtime_constant (cfg, MONO_PATCH_INFO_GC_NURSERY_START, NULL);
+ break;
+ case CEE_MONO_LDPTR_NURSERY_BITS:
+ ins = emit_runtime_constant (cfg, MONO_PATCH_INFO_GC_NURSERY_BITS, NULL);
+ break;
+ case CEE_MONO_LDPTR_INT_REQ_FLAG:
+ ins = emit_runtime_constant (cfg, MONO_PATCH_INFO_INTERRUPTION_REQUEST_FLAG, NULL);
+ break;
+ }
*sp++ = ins;
ip += 2;
#include <mono/metadata/threads.h>
#include <mono/metadata/profiler-private.h>
#include <mono/metadata/mono-debug.h>
-#include <mono/metadata/gc-internal.h>
+#include <mono/metadata/gc-internals.h>
#include <mono/utils/mono-math.h>
#include <mono/utils/mono-mmap.h>
#include <mono/utils/mono-memory-model.h>
#endif /*__native_client_codegen__*/
-static inline void
+static void
amd64_patch (unsigned char* code, gpointer target)
{
guint8 rex = 0;
switch (ainfo->storage) {
case ArgInIReg:
- linfo->args [i].storage = LLVMArgInIReg;
+ linfo->args [i].storage = LLVMArgNormal;
break;
case ArgInDoubleSSEReg:
case ArgInFloatSSEReg:
- linfo->args [i].storage = LLVMArgInFPReg;
+ linfo->args [i].storage = LLVMArgNormal;
break;
case ArgOnStack:
- if (MONO_TYPE_ISSTRUCT (t)) {
+ if (MONO_TYPE_ISSTRUCT (t))
linfo->args [i].storage = LLVMArgVtypeByVal;
- } else {
- linfo->args [i].storage = LLVMArgInIReg;
- if (!t->byref) {
- if (t->type == MONO_TYPE_R4)
- linfo->args [i].storage = LLVMArgInFPReg;
- else if (t->type == MONO_TYPE_R8)
- linfo->args [i].storage = LLVMArgInFPReg;
- }
- }
+ else
+ linfo->args [i].storage = LLVMArgNormal;
break;
case ArgValuetypeInReg:
if (sig->pinvoke) {
#define MONO_ARCH_HAVE_TLS_GET_REG 1
#endif
+#if defined(TARGET_APPLETVOS)
+/* No signals */
+#define MONO_ARCH_NEED_DIV_CHECK 1
+#endif
+
/* Used for optimization, not complete */
#define MONO_ARCH_IS_OP_MEMBASE(opcode) ((opcode) == OP_X86_PUSH_MEMBASE)
static int i8_align;
-static volatile int ss_trigger_var = 0;
-
static gpointer single_step_tramp, breakpoint_tramp;
/*
gboolean
mono_arm_have_tls_get (void)
{
+ return FALSE;
#ifdef HAVE_FAST_TLS
return TRUE;
#else
mono_mutex_init_recursive (&mini_arch_mutex);
if (mini_get_debug_options ()->soft_breakpoints) {
- single_step_tramp = mini_get_single_step_trampoline ();
breakpoint_tramp = mini_get_breakpoint_trampoline ();
} else {
ss_trigger_page = mono_valloc (NULL, mono_pagesize (), MONO_MMAP_READ|MONO_MMAP_32BIT);
ainfo->reg = fpr;
ainfo->nregs = nfields;
ainfo->esize = esize;
- fpr += nfields;
+ if (esize == 4)
+ fpr += nfields;
+ else
+ fpr += nfields * 2;
break;
} else {
fpr = ARM_VFP_F16;
offset += size;
}
- if (cfg->arch.seq_point_read_var) {
+ if (cfg->arch.seq_point_ss_method_var) {
MonoInst *ins;
- ins = cfg->arch.seq_point_read_var;
-
- size = 4;
- align = 4;
- offset += align - 1;
- offset &= ~(align - 1);
- ins->opcode = OP_REGOFFSET;
- ins->inst_basereg = cfg->frame_reg;
- ins->inst_offset = offset;
- offset += size;
-
ins = cfg->arch.seq_point_ss_method_var;
size = 4;
align = 4;
if (cfg->gen_sdb_seq_points) {
if (cfg->soft_breakpoints) {
- MonoInst *ins = mono_compile_create_var (cfg, &mono_defaults.int_class->byval_arg, OP_LOCAL);
- ins->flags |= MONO_INST_VOLATILE;
- cfg->arch.seq_point_read_var = ins;
+ MonoInst *ins;
ins = mono_compile_create_var (cfg, &mono_defaults.int_class->byval_arg, OP_LOCAL);
ins->flags |= MONO_INST_VOLATILE;
case RegTypeIRegPair:
case RegTypeBase:
case RegTypeBaseGen:
- linfo->args [i].storage = LLVMArgInIReg;
+ linfo->args [i].storage = LLVMArgNormal;
break;
case RegTypeStructByVal:
linfo->args [i].storage = LLVMArgAsIArgs;
call->float_args = g_slist_append_mempool (cfg->mempool, call->float_args, fad);
} else {
- add_outarg_reg (cfg, call, RegTypeFP, ainfo->reg + i, load);
+ add_outarg_reg (cfg, call, RegTypeFP, ainfo->reg + (i * 2), load);
}
}
break;
int i;
MonoInst *info_var = cfg->arch.seq_point_info_var;
MonoInst *ss_trigger_page_var = cfg->arch.ss_trigger_page_var;
- MonoInst *ss_read_var = cfg->arch.seq_point_read_var;
MonoInst *ss_method_var = cfg->arch.seq_point_ss_method_var;
MonoInst *bp_method_var = cfg->arch.seq_point_bp_method_var;
MonoInst *var;
if (ins->flags & MONO_INST_SINGLE_STEP_LOC) {
if (cfg->soft_breakpoints) {
- /* Load the address of the sequence point trigger variable. */
- var = ss_read_var;
+ /* Load the address of the sequence point method variable. */
+ var = ss_method_var;
g_assert (var);
g_assert (var->opcode == OP_REGOFFSET);
g_assert (arm_is_imm12 (var->inst_offset));
/* Read the value and check whether it is non-zero. */
ARM_LDR_IMM (code, dreg, dreg, 0);
ARM_CMP_REG_IMM (code, dreg, 0, 0);
-
- /* Load the address of the sequence point method. */
- var = ss_method_var;
- g_assert (var);
- g_assert (var->opcode == OP_REGOFFSET);
- g_assert (arm_is_imm12 (var->inst_offset));
- ARM_LDR_IMM (code, dreg, var->inst_basereg, var->inst_offset);
-
/* Call it conditionally. */
ARM_BLX_REG_COND (code, ARMCOND_NE, dreg);
} else {
}
}
- if (cfg->arch.seq_point_read_var) {
- MonoInst *read_ins = cfg->arch.seq_point_read_var;
+ if (cfg->arch.seq_point_ss_method_var) {
MonoInst *ss_method_ins = cfg->arch.seq_point_ss_method_var;
MonoInst *bp_method_ins = cfg->arch.seq_point_bp_method_var;
#ifdef USE_JUMP_TABLES
gpointer *jte;
#endif
- g_assert (read_ins->opcode == OP_REGOFFSET);
- g_assert (arm_is_imm12 (read_ins->inst_offset));
g_assert (ss_method_ins->opcode == OP_REGOFFSET);
g_assert (arm_is_imm12 (ss_method_ins->inst_offset));
g_assert (bp_method_ins->opcode == OP_REGOFFSET);
#ifdef USE_JUMP_TABLES
jte = mono_jumptable_add_entries (3);
- jte [0] = (gpointer)&ss_trigger_var;
- jte [1] = single_step_tramp;
- jte [2] = breakpoint_tramp;
+ jte [0] = &single_step_tramp;
+ jte [1] = breakpoint_tramp;
code = mono_arm_load_jumptable_entry_addr (code, jte, ARMREG_LR);
#else
ARM_MOV_REG_REG (code, ARMREG_LR, ARMREG_PC);
ARM_B (code, 2);
- *(volatile int **)code = &ss_trigger_var;
- code += 4;
- *(gpointer*)code = single_step_tramp;
+ *(gpointer*)code = &single_step_tramp;
code += 4;
*(gpointer*)code = breakpoint_tramp;
code += 4;
#endif
ARM_LDR_IMM (code, ARMREG_IP, ARMREG_LR, 0);
- ARM_STR_IMM (code, ARMREG_IP, read_ins->inst_basereg, read_ins->inst_offset);
- ARM_LDR_IMM (code, ARMREG_IP, ARMREG_LR, 4);
ARM_STR_IMM (code, ARMREG_IP, ss_method_ins->inst_basereg, ss_method_ins->inst_offset);
- ARM_LDR_IMM (code, ARMREG_IP, ARMREG_LR, 8);
+ ARM_LDR_IMM (code, ARMREG_IP, ARMREG_LR, 4);
ARM_STR_IMM (code, ARMREG_IP, bp_method_ins->inst_basereg, bp_method_ins->inst_offset);
}
if (ss_trigger_page)
mono_mprotect (ss_trigger_page, mono_pagesize (), 0);
else
- ss_trigger_var = 1;
+ single_step_tramp = mini_get_single_step_trampoline ();
}
/*
if (ss_trigger_page)
mono_mprotect (ss_trigger_page, mono_pagesize (), MONO_MMAP_READ);
else
- ss_trigger_var = 0;
+ single_step_tramp = NULL;
}
#if __APPLE__
typedef struct MonoCompileArch {
gpointer seq_point_info_var, ss_trigger_page_var;
- gpointer seq_point_read_var, seq_point_ss_method_var;
+ gpointer seq_point_ss_method_var;
gpointer seq_point_bp_method_var;
gpointer vret_addr_loc;
gboolean omit_fp, omit_fp_computed;
#endif
#define MONO_ARCH_HAVE_TLS_GET (mono_arm_have_tls_get ())
-#define MONO_ARCH_HAVE_TLS_GET_REG 1
+// #define MONO_ARCH_HAVE_TLS_GET_REG 1
/* ARM doesn't have too many registers, so we have to use a callee saved one */
#define MONO_ARCH_RGCTX_REG ARMREG_V5
#include <mono/metadata/verify-internals.h>
#include <mono/metadata/mempool-internals.h>
#include <mono/metadata/attach.h>
-#include <mono/metadata/gc-internal.h>
+#include <mono/metadata/gc-internals.h>
#include <mono/utils/mono-math.h>
#include <mono/utils/mono-compiler.h>
#include <mono/utils/mono-counters.h>
-#include <mono/utils/mono-logger-internal.h>
+#include <mono/utils/mono-logger-internals.h>
#include <mono/utils/mono-mmap.h>
#include <mono/utils/dtrace.h>
#include <mono/metadata/debug-helpers.h>
#include <mono/metadata/exception.h>
#include <mono/metadata/object-internals.h>
-#include <mono/metadata/gc-internal.h>
+#include <mono/metadata/gc-internals.h>
#include <mono/metadata/mono-debug.h>
#include <mono/metadata/profiler.h>
#include <mono/metadata/mono-endian.h>
#include <mono/metadata/environment.h>
#include <mono/metadata/mono-mlist.h>
#include <mono/utils/mono-mmap.h>
-#include <mono/utils/mono-logger-internal.h>
+#include <mono/utils/mono-logger-internals.h>
#include "mini.h"
#include "trace.h"
{
g_assert_not_reached ();
}
+#else
+void
+mono_debug_personality (void)
+{
+ g_assert_not_reached ();
+}
#endif
#include "config.h"
#include "mini-gc.h"
-#include <mono/metadata/gc-internal.h>
+#include <mono/metadata/gc-internals.h>
static gboolean
get_provenance (StackFrameInfo *frame, MonoContext *ctx, gpointer data)
//#if defined(MONO_ARCH_GC_MAPS_SUPPORTED)
#include <mono/metadata/sgen-conf.h>
-#include <mono/metadata/gc-internal.h>
+#include <mono/metadata/gc-internals.h>
#include <mono/utils/mono-counters.h>
#define SIZEOF_SLOT ((int)sizeof (mgreg_t))
#include "llvm-c/Analysis.h"
#include "mini-llvm-cpp.h"
+#include "aot-compiler.h"
#ifdef __MINGW32__
}
break;
case LLVMArgVtypeByVal:
- param_types [pindex] = type_to_llvm_arg_type (ctx, sig->params [i]);
+ param_types [pindex] = type_to_llvm_arg_type (ctx, ainfo->type);
CHECK_FAILURE (ctx);
param_types [pindex] = LLVMPointerType (param_types [pindex], 0);
pindex ++;
break;
case LLVMArgVtypeByRef:
case LLVMArgScalarByRef:
- param_types [pindex] = type_to_llvm_arg_type (ctx, sig->params [i]);
+ param_types [pindex] = type_to_llvm_arg_type (ctx, ainfo->type);
CHECK_FAILURE (ctx);
param_types [pindex] = LLVMPointerType (param_types [pindex], 0);
pindex ++;
g_assert_not_reached ();
break;
default:
- param_types [pindex ++] = type_to_llvm_arg_type (ctx, sig->params [i]);
+ param_types [pindex ++] = type_to_llvm_arg_type (ctx, ainfo->type);
break;
}
}
for (j = 0; j < ainfo->nslots; ++j)
args [j] = LLVMGetParam (ctx->lmethod, pindex + j);
}
- ctx->addresses [reg] = build_alloca (ctx, sig->params [i]);
+ ctx->addresses [reg] = build_alloca (ctx, ainfo->type);
- emit_args_to_vtype (ctx, builder, sig->params [i], ctx->addresses [reg], ainfo, args);
+ emit_args_to_vtype (ctx, builder, ainfo->type, ctx->addresses [reg], ainfo, args);
- if (ainfo->storage == LLVMArgVtypeInReg && MONO_CLASS_IS_SIMD (ctx->cfg, mono_class_from_mono_type (sig->params [i]))) {
+ if (ainfo->storage == LLVMArgVtypeInReg && MONO_CLASS_IS_SIMD (ctx->cfg, mono_class_from_mono_type (ainfo->type))) {
/* Treat these as normal values */
ctx->values [reg] = LLVMBuildLoad (builder, ctx->addresses [reg], "");
}
case LLVMArgVtypeByVal: {
ctx->addresses [reg] = LLVMGetParam (ctx->lmethod, pindex);
- if (MONO_CLASS_IS_SIMD (ctx->cfg, mono_class_from_mono_type (sig->params [i]))) {
+ if (MONO_CLASS_IS_SIMD (ctx->cfg, mono_class_from_mono_type (ainfo->type))) {
/* Treat these as normal values */
ctx->values [reg] = LLVMBuildLoad (builder, ctx->addresses [reg], "");
}
case LLVMArgAsIArgs: {
LLVMValueRef arg = LLVMGetParam (ctx->lmethod, pindex);
- ctx->addresses [reg] = build_alloca (ctx, sig->params [i]);
+ ctx->addresses [reg] = build_alloca (ctx, ainfo->type);
/* The argument is received as an array of ints, store it into the real argument */
LLVMBuildStore (ctx->builder, arg, convert (ctx, ctx->addresses [reg], LLVMPointerType (LLVMTypeOf (arg), 0)));
g_assert_not_reached ();
break;
default:
- ctx->values [reg] = convert_full (ctx, ctx->values [reg], llvm_type_to_stack_type (cfg, type_to_llvm_type (ctx, sig->params [i])), type_is_unsigned (ctx, sig->params [i]));
+ ctx->values [reg] = convert_full (ctx, ctx->values [reg], llvm_type_to_stack_type (cfg, type_to_llvm_type (ctx, ainfo->type)), type_is_unsigned (ctx, ainfo->type));
break;
}
}
guint32 nargs;
g_assert (addresses [reg]);
- emit_vtype_to_args (ctx, builder, sig->params [i - sig->hasthis], addresses [reg], ainfo, args + pindex, &nargs);
+ emit_vtype_to_args (ctx, builder, ainfo->type, addresses [reg], ainfo, args + pindex, &nargs);
pindex += nargs;
// FIXME: alignment
case LLVMArgVtypeByRef:
case LLVMArgScalarByRef: {
g_assert (addresses [reg]);
- args [pindex] = convert (ctx, addresses [reg], LLVMPointerType (type_to_llvm_arg_type (ctx, sig->params [i - sig->hasthis]), 0));
+ args [pindex] = convert (ctx, addresses [reg], LLVMPointerType (type_to_llvm_arg_type (ctx, ainfo->type), 0));
break;
}
case LLVMArgAsIArgs:
if (i == 0 && sig->hasthis)
args [pindex] = convert (ctx, args [pindex], ThisType ());
else
- args [pindex] = convert (ctx, args [pindex], type_to_llvm_arg_type (ctx, sig->params [i - sig->hasthis]));
+ args [pindex] = convert (ctx, args [pindex], type_to_llvm_arg_type (ctx, ainfo->type));
break;
}
g_assert (pindex <= nargs);
return;
}
+static LLVMCallInfo*
+get_llvm_call_info (MonoCompile *cfg, MonoMethodSignature *sig)
+{
+ LLVMCallInfo *linfo;
+ int i;
+
+ linfo = mono_arch_get_llvm_call_info (cfg, sig);
+ for (i = 0; i < sig->param_count; ++i)
+ linfo->args [i + sig->hasthis].type = sig->params [i];
+
+ return linfo;
+}
+
/*
* mono_llvm_emit_method:
*
sig = mono_method_signature (cfg->method);
ctx->sig = sig;
- linfo = mono_arch_get_llvm_call_info (cfg, sig);
+ linfo = get_llvm_call_info (cfg, sig);
ctx->linfo = linfo;
CHECK_FAILURE (ctx);
sig = call->signature;
n = sig->param_count + sig->hasthis;
- call->cinfo = mono_arch_get_llvm_call_info (cfg, sig);
+ call->cinfo = get_llvm_call_info (cfg, sig);
if (cfg->disable_llvm)
return;
/* Simply remember the arguments */
switch (ainfo->storage) {
- case LLVMArgInIReg:
- case LLVMArgInFPReg: {
- MonoType *t = (sig->hasthis && i == 0) ? &mono_get_intptr_class ()->byval_arg : sig->params [i - sig->hasthis];
+ case LLVMArgNormal: {
+ MonoType *t = (sig->hasthis && i == 0) ? &mono_get_intptr_class ()->byval_arg : ainfo->type;
int opcode;
opcode = mono_type_to_regmove (cfg, t);
ins->sreg1 = in->dreg;
ins->inst_p0 = mono_mempool_alloc0 (cfg->mempool, sizeof (LLVMArgInfo));
memcpy (ins->inst_p0, ainfo, sizeof (LLVMArgInfo));
- ins->inst_vtype = sig->params [i - sig->hasthis];
- ins->klass = mono_class_from_mono_type (sig->params [i - sig->hasthis]);
+ ins->inst_vtype = ainfo->type;
+ ins->klass = mono_class_from_mono_type (ainfo->type);
break;
default:
- call->cinfo = mono_arch_get_llvm_call_info (cfg, sig);
cfg->exception_message = g_strdup ("ainfo->storage");
cfg->disable_llvm = TRUE;
return;
#include <mono/metadata/mono-config.h>
#include <mono/metadata/environment.h>
#include <mono/metadata/mono-debug.h>
-#include <mono/metadata/gc-internal.h>
+#include <mono/metadata/gc-internals.h>
#include <mono/metadata/threads-types.h>
#include <mono/metadata/verify.h>
#include <mono/metadata/verify-internals.h>
#include <mono/utils/mono-math.h>
#include <mono/utils/mono-compiler.h>
#include <mono/utils/mono-counters.h>
-#include <mono/utils/mono-logger-internal.h>
+#include <mono/utils/mono-logger-internals.h>
#include <mono/utils/mono-mmap.h>
#include <mono/utils/dtrace.h>
#include <mono/utils/mono-signal-handler.h>
#include <mono/metadata/mono-config.h>
#include <mono/metadata/environment.h>
#include <mono/metadata/mono-debug.h>
-#include <mono/metadata/gc-internal.h>
+#include <mono/metadata/gc-internals.h>
#include <mono/metadata/threads-types.h>
#include <mono/metadata/mempool-internals.h>
#include <mono/metadata/attach.h>
#include <mono/utils/mono-compiler.h>
#include <mono/utils/mono-counters.h>
#include <mono/utils/mono-error-internals.h>
-#include <mono/utils/mono-logger-internal.h>
+#include <mono/utils/mono-logger-internals.h>
#include <mono/utils/mono-mmap.h>
#include <mono/utils/mono-path.h>
#include <mono/utils/mono-tls.h>
case MONO_PATCH_INFO_MSCORLIB_GOT_ADDR:
case MONO_PATCH_INFO_GC_CARD_TABLE_ADDR:
case MONO_PATCH_INFO_GC_NURSERY_START:
+ case MONO_PATCH_INFO_GC_NURSERY_BITS:
case MONO_PATCH_INFO_JIT_TLS_ID:
case MONO_PATCH_INFO_GOT_OFFSET:
case MONO_PATCH_INFO_GC_SAFE_POINT_FLAG:
target = mono_gc_get_nursery (&shift_bits, &size);
break;
}
+ case MONO_PATCH_INFO_GC_NURSERY_BITS: {
+ int shift_bits;
+ size_t size;
+
+ mono_gc_get_nursery (&shift_bits, &size);
+
+ target = (gpointer)(mgreg_t)shift_bits;
+ break;
+ }
case MONO_PATCH_INFO_CASTCLASS_CACHE: {
target = mono_domain_alloc0 (domain, sizeof (gpointer));
break;
mono_jit_runtime_invoke (MonoMethod *method, void *obj, void **params, MonoObject **exc)
{
MonoMethod *invoke, *callee;
- MonoObject *(*runtime_invoke) (MonoObject *this, void **params, MonoObject **exc, void* compiled_method);
+ MonoObject *(*runtime_invoke) (MonoObject *this_obj, void **params, MonoObject **exc, void* compiled_method);
MonoDomain *domain = mono_domain_get ();
MonoJitDomainInfo *domain_info;
RuntimeInvokeInfo *info, *info2;
#include <mono/metadata/mono-config.h>
#include <mono/metadata/environment.h>
#include <mono/metadata/mono-debug.h>
-#include <mono/metadata/gc-internal.h>
+#include <mono/metadata/gc-internals.h>
#include <mono/metadata/threads-types.h>
#include <mono/metadata/verify.h>
#include <mono/metadata/verify-internals.h>
#include <mono/utils/mono-math.h>
#include <mono/utils/mono-compiler.h>
#include <mono/utils/mono-counters.h>
-#include <mono/utils/mono-logger-internal.h>
+#include <mono/utils/mono-logger-internals.h>
#include <mono/utils/mono-mmap.h>
#include <mono/utils/dtrace.h>
#include <mono/metadata/threads.h>
#include <mono/metadata/profiler-private.h>
#include <mono/metadata/mono-debug.h>
-#include <mono/metadata/gc-internal.h>
+#include <mono/metadata/gc-internals.h>
#include <mono/utils/mono-math.h>
#include <mono/utils/mono-counters.h>
#include <mono/utils/mono-mmap.h>
switch (ainfo->storage) {
case ArgInIReg:
- linfo->args [i].storage = LLVMArgInIReg;
+ linfo->args [i].storage = LLVMArgNormal;
break;
case ArgInDoubleSSEReg:
case ArgInFloatSSEReg:
- linfo->args [i].storage = LLVMArgInFPReg;
+ linfo->args [i].storage = LLVMArgNormal;
break;
case ArgOnStack:
if (mini_type_is_vtype (t)) {
else
linfo->args [i].storage = LLVMArgVtypeByVal;
} else {
- linfo->args [i].storage = LLVMArgInIReg;
- if (t->byref) {
- if (t->type == MONO_TYPE_R4)
- linfo->args [i].storage = LLVMArgInFPReg;
- else if (t->type == MONO_TYPE_R8)
- linfo->args [i].storage = LLVMArgInFPReg;
- }
+ linfo->args [i].storage = LLVMArgNormal;
}
break;
case ArgValuetypeInReg:
#include <mono/metadata/mono-config.h>
#include <mono/metadata/environment.h>
#include <mono/metadata/mono-debug.h>
-#include <mono/metadata/gc-internal.h>
+#include <mono/metadata/gc-internals.h>
#include <mono/metadata/threads-types.h>
#include <mono/metadata/verify.h>
#include <mono/metadata/verify-internals.h>
#include <mono/utils/mono-compiler.h>
#include <mono/utils/mono-counters.h>
#include <mono/utils/mono-error-internals.h>
-#include <mono/utils/mono-logger-internal.h>
+#include <mono/utils/mono-logger-internals.h>
#include <mono/utils/mono-mmap.h>
#include <mono/utils/mono-path.h>
#include <mono/utils/mono-tls.h>
#include "mini-gc.h"
#include "debugger-agent.h"
+#include "llvm-runtime.h"
MonoTraceSpec *mono_jit_trace_calls;
MonoMethodDesc *mono_inject_async_exc_method;
#endif
/* Version number of the AOT file format */
-#define MONO_AOT_FILE_VERSION 124
+#define MONO_AOT_FILE_VERSION 126
//TODO: This is x86/amd64 specific.
#define mono_simd_shuffle_mask(a,b,c,d) ((a) | ((b) << 2) | ((c) << 4) | ((d) << 6))
typedef enum {
LLVMArgNone,
+ /* Scalar argument passed by value */
LLVMArgNormal,
+ /* Only in ainfo->pair_storage */
LLVMArgInIReg,
+ /* Only in ainfo->pair_storage */
LLVMArgInFPReg,
LLVMArgVtypeInReg,
LLVMArgVtypeByVal,
int esize;
/* Parameter index in the LLVM signature */
int pindex;
+ MonoType *type;
} LLVMArgInfo;
typedef struct {
void mono_linear_scan (MonoCompile *cfg, GList *vars, GList *regs, regmask_t *used_mask);
void mono_global_regalloc (MonoCompile *cfg);
void mono_create_jump_table (MonoCompile *cfg, MonoInst *label, MonoBasicBlock **bbs, int num_blocks);
-int mono_compile_assembly (MonoAssembly *ass, guint32 opts, const char *aot_options);
MonoCompile *mini_method_compile (MonoMethod *method, guint32 opts, MonoDomain *domain, JitFlags flags, int parts, int aot_method_index);
void mono_destroy_compile (MonoCompile *cfg);
MonoJitICallInfo *mono_find_jit_opcode_emulation (int opcode);
guint8* mono_aot_get_unwind_info (MonoJitInfo *ji, guint32 *unwind_info_len);
guint32 mono_aot_method_hash (MonoMethod *method);
MonoMethod* mono_aot_get_array_helper_from_wrapper (MonoMethod *method);
-guint32 mono_aot_get_got_offset (MonoJumpInfo *ji) MONO_LLVM_INTERNAL;
-gboolean mono_aot_is_shared_got_offset (int offset) MONO_LLVM_INTERNAL;
-char* mono_aot_get_method_name (MonoCompile *cfg) MONO_LLVM_INTERNAL;
-gboolean mono_aot_is_direct_callable (MonoJumpInfo *patch_info) MONO_LLVM_INTERNAL;
-void mono_aot_mark_unused_llvm_plt_entry(MonoJumpInfo *patch_info) MONO_LLVM_INTERNAL;
-char* mono_aot_get_plt_symbol (MonoJumpInfoType type, gconstpointer data) MONO_LLVM_INTERNAL;
-char* mono_aot_get_direct_call_symbol (MonoJumpInfoType type, gconstpointer data);
-int mono_aot_get_method_index (MonoMethod *method) MONO_LLVM_INTERNAL;
-MonoJumpInfo* mono_aot_patch_info_dup (MonoJumpInfo* ji) MONO_LLVM_INTERNAL;
void mono_aot_set_make_unreadable (gboolean unreadable);
gboolean mono_aot_is_pagefault (void *ptr);
void mono_aot_handle_pagefault (void *ptr);
void mono_aot_register_jit_icall (const char *name, gpointer addr);
-void* mono_aot_readonly_field_override (MonoClassField *field);
guint32 mono_aot_find_method_index (MonoMethod *method);
void mono_aot_init_llvm_method (gpointer aot_module, guint32 method_index);
void mono_aot_init_gshared_method_this (gpointer aot_module, guint32 method_index, MonoObject *this_ins);
void mono_aot_init_gshared_method_rgctx (gpointer aot_module, guint32 method_index, MonoMethodRuntimeGenericContext *rgctx);
/* This is an exported function */
-MONO_API void mono_aot_register_globals (gpointer *globals);
-/* This too */
MONO_API void mono_aot_register_module (gpointer *aot_info);
void mono_xdebug_init (const char *xdebug_opts);
PATCH_INFO(NONE, "none")
PATCH_INFO(AOT_MODULE, "aot_module")
PATCH_INFO(AOT_JIT_INFO, "aot_jit_info")
+PATCH_INFO(GC_NURSERY_BITS, "gc_nursery_bits")
#include "config.h"
#include "tasklets.h"
#include "mono/metadata/exception.h"
-#include "mono/metadata/gc-internal.h"
+#include "mono/metadata/gc-internals.h"
#include "mini.h"
#if defined(MONO_SUPPORT_TASKLETS)
#include <mono/metadata/tabledefs.h>
#include <mono/metadata/mono-debug-debugger.h>
#include <mono/metadata/profiler-private.h>
-#include <mono/metadata/gc-internal.h>
+#include <mono/metadata/gc-internals.h>
#include <mono/arch/amd64/amd64-codegen.h>
#include <mono/utils/memcheck.h>
#include <mono/metadata/abi-details.h>
#include <mono/metadata/appdomain.h>
-#include <mono/metadata/gc-internal.h>
+#include <mono/metadata/gc-internals.h>
#include <mono/metadata/marshal.h>
#include <mono/metadata/profiler-private.h>
#include <mono/metadata/tabledefs.h>
#include <mono/metadata/mono-debug.h>
#include <mono/metadata/mono-debug-debugger.h>
#include <mono/metadata/profiler-private.h>
-#include <mono/metadata/gc-internal.h>
+#include <mono/metadata/gc-internals.h>
#include <mono/arch/x86/x86-codegen.h>
#include <mono/utils/memcheck.h>
#define SGEN_MIN_ALLOWANCE_NURSERY_SIZE_RATIO 1.0
#define SGEN_MAX_ALLOWANCE_NURSERY_SIZE_RATIO 10.0
+/*
+ * How much more we allow the heap to grow before triggering another major collection
+ */
+#define SGEN_DEFAULT_ALLOWANCE_HEAP_SIZE_RATIO 0.33
+
+/*
+ * How much more we allow the heap to grow, relative to the allowance, while doing
+ * a concurrent collection, before forcing its finish.
+ */
+#define SGEN_DEFAULT_CONCURRENT_HEAP_ALLOWANCE_RATIO 0.25
+
/*
* Default ratio of memory we want to release in a major collection in relation to the the current heap size.
*
}
static void
-init_gray_queue (void)
+init_gray_queue (gboolean use_workers)
{
- if (sgen_collection_is_concurrent ())
+ if (use_workers)
sgen_workers_init_distribute_gray_queue ();
sgen_gray_object_queue_init (&gray_queue, NULL);
}
sgen_memgov_minor_collection_start ();
- init_gray_queue ();
+ init_gray_queue (FALSE);
gc_stats.minor_gc_count ++;
sgen_nursery_alloc_prepare_for_major ();
}
- init_gray_queue ();
+ init_gray_queue (mode == COPY_OR_MARK_FROM_ROOTS_START_CONCURRENT);
TV_GETTIME (atv);
SGEN_ASSERT (0, sgen_workers_all_done (), "Why are the workers not done when we start or finish a major collection?");
sgen_workers_start_all_workers (object_ops);
gray_queue_enable_redirect (WORKERS_DISTRIBUTE_GRAY_QUEUE);
+ } else if (mode == COPY_OR_MARK_FROM_ROOTS_FINISH_CONCURRENT) {
+ if (sgen_workers_have_idle_work ()) {
+ sgen_workers_start_all_workers (object_ops);
+ sgen_workers_join ();
+ }
}
#ifdef SGEN_DEBUG_INTERNAL_ALLOC
object_ops = &major_collector.major_ops_serial;
}
- /*
- * The workers have stopped so we need to finish gray queue
- * work that might result from finalization in the main GC
- * thread. Redirection must therefore be turned off.
- */
- sgen_gray_object_queue_disable_alloc_prepare (&gray_queue);
g_assert (sgen_section_gray_queue_is_empty (sgen_workers_get_distribute_section_gray_queue ()));
/* all the objects in the heap */
binary_protocol_concurrent_finish ();
/*
- * The major collector can add global remsets which are processed in the finishing
- * nursery collection, below. That implies that the workers must have finished
- * marking before the nursery collection is allowed to run, otherwise we might miss
- * some remsets.
+ * We need to stop all workers since we're updating the cardtable below.
+ * The workers will be resumed with a finishing pause context to avoid
+ * additional cardtable and object scanning.
*/
- sgen_workers_wait ();
+ sgen_workers_stop_all_workers ();
SGEN_TV_GETTIME (time_major_conc_collection_end);
gc_stats.major_gc_time_concurrent += SGEN_TV_ELAPSED (time_major_conc_collection_start, time_major_conc_collection_end);
generation_to_collect = GENERATION_OLD;
}
} else if (sgen_need_major_collection (size)) {
- reason = "Minor allowance";
+ reason = concurrent_collection_in_progress ? "Forced finish concurrent collection" : "Minor allowance";
generation_to_collect = GENERATION_OLD;
} else {
generation_to_collect = GENERATION_NURSERY;
if (concurrent_collection_in_progress) {
/*
- * We update the concurrent collection. If it finished, we're done. If
- * not, and we've been asked to do a nursery collection, we do that.
+ * If the concurrent worker is finished or we are asked to do a major collection
+ * then we finish the concurrent collection.
*/
- gboolean finish = major_should_finish_concurrent_collection () || (wait_to_finish && generation_to_collect == GENERATION_OLD);
+ gboolean finish = major_should_finish_concurrent_collection () || generation_to_collect == GENERATION_OLD;
if (finish) {
major_finish_concurrent_collection (wait_to_finish);
oldest_generation_collected = GENERATION_OLD;
} else {
+ SGEN_ASSERT (0, generation_to_collect == GENERATION_NURSERY, "Why aren't we finishing the concurrent collection?");
major_update_concurrent_collection ();
- if (generation_to_collect == GENERATION_NURSERY)
- collect_nursery (NULL, FALSE);
+ collect_nursery (NULL, FALSE);
}
goto done;
* We allow the heap to grow by one third its current size before we start the next
* major collection.
*/
- allowance_target = new_heap_size / 3;
+ allowance_target = new_heap_size * SGEN_DEFAULT_ALLOWANCE_HEAP_SIZE_RATIO;
allowance = MAX (allowance_target, MIN_MINOR_COLLECTION_ALLOWANCE);
}
}
+static inline size_t
+get_heap_size (void)
+{
+ return major_collector.get_num_major_sections () * major_collector.section_size + los_memory_usage;
+}
+
gboolean
sgen_need_major_collection (mword space_needed)
{
size_t heap_size;
- if (sgen_concurrent_collection_in_progress ())
+ if (sgen_concurrent_collection_in_progress ()) {
+ heap_size = get_heap_size ();
+
+ if (heap_size <= major_collection_trigger_size)
+ return FALSE;
+
+ /* We allow the heap to grow an additional third of the allowance during a concurrent collection */
+ if ((heap_size - major_collection_trigger_size) >
+ (major_collection_trigger_size
+ * (SGEN_DEFAULT_ALLOWANCE_HEAP_SIZE_RATIO / (SGEN_DEFAULT_ALLOWANCE_HEAP_SIZE_RATIO + 1))
+ * SGEN_DEFAULT_CONCURRENT_HEAP_ALLOWANCE_RATIO)) {
+ return TRUE;
+ }
return FALSE;
+ }
/* FIXME: This is a cop-out. We should have some way of figuring this out. */
if (!major_collector.have_swept ())
sgen_memgov_calculate_minor_collection_allowance ();
- heap_size = major_collector.get_num_major_sections () * major_collector.section_size + los_memory_usage;
+ heap_size = get_heap_size ();
return heap_size > major_collection_trigger_size;
}
need_calculate_minor_collection_allowance = TRUE;
if (debug_print_allowance) {
- SGEN_LOG (0, "Starting collection with heap size %ld bytes", (long)(major_collector.get_num_major_sections () * major_collector.section_size + los_memory_usage));
+ SGEN_LOG (0, "Starting collection with heap size %ld bytes", (long)get_heap_size ());
}
}
#include "mono/sgen/sgen-client.h"
static int workers_num;
+static volatile gboolean forced_stop;
static WorkerData *workers_data;
static SgenSectionGrayQueue workers_distribute_gray_queue;
SGEN_ASSERT (0, workers_state != STATE_NOT_WORKING, "How did we get from WORK ENQUEUED to NOT WORKING?");
}
- if (!sgen_gray_object_queue_is_empty (&data->private_gray_queue) || workers_get_work (data)) {
+ if (!forced_stop && (!sgen_gray_object_queue_is_empty (&data->private_gray_queue) || workers_get_work (data))) {
ScanCopyContext ctx = CONTEXT_FROM_OBJECT_OPERATIONS (idle_func_object_ops, &data->private_gray_queue);
SGEN_ASSERT (0, !sgen_gray_object_queue_is_empty (&data->private_gray_queue), "How is our gray queue empty if we just got work?");
mono_counters_register ("# workers finished", MONO_COUNTER_GC | MONO_COUNTER_ULONG, &stat_workers_num_finished);
}
+void
+sgen_workers_stop_all_workers (void)
+{
+ forced_stop = TRUE;
+
+ sgen_thread_pool_wait_for_all_jobs ();
+ sgen_thread_pool_idle_wait ();
+ SGEN_ASSERT (0, workers_state == STATE_NOT_WORKING, "Can only signal enqueue work when in no work state");
+}
+
void
sgen_workers_start_all_workers (SgenObjectOperations *object_ops)
{
+ forced_stop = FALSE;
idle_func_object_ops = object_ops;
mono_memory_write_barrier ();
SGEN_ASSERT (0, sgen_gray_object_queue_is_empty (&workers_data [i].private_gray_queue), "Why is there still work left to do?");
}
+/*
+ * Can only be called if the workers are stopped.
+ * If we're stopped, there are also no pending jobs.
+ */
+gboolean
+sgen_workers_have_idle_work (void)
+{
+ int i;
+
+ SGEN_ASSERT (0, forced_stop && sgen_workers_all_done (), "Checking for idle work should only happen if the workers are stopped.");
+
+ if (!sgen_section_gray_queue_is_empty (&workers_distribute_gray_queue))
+ return TRUE;
+
+ for (i = 0; i < workers_num; ++i) {
+ if (!sgen_gray_object_queue_is_empty (&workers_data [i].private_gray_queue))
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
gboolean
sgen_workers_all_done (void)
{
return state_is_working_or_enqueued (workers_state);
}
-void
-sgen_workers_wait (void)
-{
- sgen_thread_pool_idle_wait ();
- SGEN_ASSERT (0, sgen_workers_all_done (), "Why are the workers not done after we wait for them?");
-}
-
SgenSectionGrayQueue*
sgen_workers_get_distribute_section_gray_queue (void)
{
};
void sgen_workers_init (int num_workers);
+void sgen_workers_stop_all_workers (void);
void sgen_workers_start_all_workers (SgenObjectOperations *object_ops);
void sgen_workers_ensure_awake (void);
void sgen_workers_init_distribute_gray_queue (void);
void sgen_workers_distribute_gray_queue_sections (void);
void sgen_workers_reset_data (void);
void sgen_workers_join (void);
+gboolean sgen_workers_have_idle_work (void);
gboolean sgen_workers_all_done (void);
gboolean sgen_workers_are_working (void);
-void sgen_workers_wait (void);
SgenSectionGrayQueue* sgen_workers_get_distribute_section_gray_queue (void);
#endif
+using System;
+using System.Collections.Generic;
+
namespace Test {
-public enum YaddaYadda {
- buba,
- birba,
- dadoom,
-};
-
-public enum byteenum : byte {
- zero,
- one,
- two,
- three
-}
+ enum ByteEnum : byte {
+ A = 10
+ }
-public enum longenum: long {
- s0 = 0,
- s1 = 1
-}
+ enum SByteEnum : sbyte {
+ A = -11
+ }
-public enum sbyteenum : sbyte {
- d0,
- d1
-}
+ enum ShortEnum : short {
+ A = -12
+ }
+
+ enum UShortEnum : ushort {
+ A = 13
+ }
+
+ enum IntEnum : int {
+ A = -15
+ }
+
+ enum UIntEnum : uint {
+ A = 16
+ }
+
+ enum LongEnum : long {
+ A = -153453525432334L
+ }
+
+ enum ULongEnum : ulong {
+ A = 164923797563459L
+ }
+
+ public enum YaddaYadda {
+ buba,
+ birba,
+ dadoom,
+ };
+
+ public enum byteenum : byte {
+ zero,
+ one,
+ two,
+ three
+ }
+
+ public enum longenum: long {
+ s0 = 0,
+ s1 = 1
+ }
+
+ public enum sbyteenum : sbyte {
+ d0,
+ d1
+ }
+
+ public class Tests {
+ public static int test_0_basic_enum_vals ()
+ {
+ YaddaYadda val = YaddaYadda.dadoom;
+ byteenum be = byteenum.one;
+ if (val != YaddaYadda.dadoom)
+ return 1;
+ if (be != (byteenum)1)
+ return 2;
+ return 0;
+ }
+
+ public static int test_0_byte_enum_hashcode ()
+ {
+ if (ByteEnum.A.GetHashCode () != EqualityComparer<ByteEnum>.Default.GetHashCode (ByteEnum.A))
+ return 1;
+ if (ByteEnum.A.GetHashCode () != ((byte)ByteEnum.A).GetHashCode () )
+ return 2;
+ return 0;
+ }
+
+ public static int test_0_sbyte_enum_hashcode ()
+ {
+ if (SByteEnum.A.GetHashCode () != EqualityComparer<SByteEnum>.Default.GetHashCode (SByteEnum.A))
+ return 1;
+ if (SByteEnum.A.GetHashCode () != ((sbyte)SByteEnum.A).GetHashCode () )
+ return 2;
+ return 0;
+ }
+
+ public static int test_0_short_enum_hashcode ()
+ {
+ if (ShortEnum.A.GetHashCode () != EqualityComparer<ShortEnum>.Default.GetHashCode (ShortEnum.A))
+ return 1;
+ if (ShortEnum.A.GetHashCode () != ((short)ShortEnum.A).GetHashCode () )
+ return 2;
+ return 0;
+ }
+
+ public static int test_0_ushort_enum_hashcode ()
+ {
+ if (UShortEnum.A.GetHashCode () != EqualityComparer<UShortEnum>.Default.GetHashCode (UShortEnum.A))
+ return 1;
+ if (UShortEnum.A.GetHashCode () != ((ushort)UShortEnum.A).GetHashCode () )
+ return 2;
+ return 0;
+ }
+
+ public static int test_0_int_enum_hashcode ()
+ {
+ if (IntEnum.A.GetHashCode () != EqualityComparer<IntEnum>.Default.GetHashCode (IntEnum.A))
+ return 1;
+ if (IntEnum.A.GetHashCode () != ((int)IntEnum.A).GetHashCode () )
+ return 2;
+ return 0;
+ }
+
+ public static int test_0_uint_enum_hashcode ()
+ {
+ if (UIntEnum.A.GetHashCode () != EqualityComparer<UIntEnum>.Default.GetHashCode (UIntEnum.A))
+ return 1;
+ if (UIntEnum.A.GetHashCode () != ((uint)UIntEnum.A).GetHashCode () )
+ return 2;
+ return 0;
+ }
+
+ public static int test_0_long_enum_hashcode ()
+ {
+ if (LongEnum.A.GetHashCode () != EqualityComparer<LongEnum>.Default.GetHashCode (LongEnum.A))
+ return 1;
+ if (LongEnum.A.GetHashCode () != ((long)LongEnum.A).GetHashCode () )
+ return 2;
+ return 0;
+ }
+
+ public static int test_0_ulong_enum_hashcode ()
+ {
+ if (ULongEnum.A.GetHashCode () != EqualityComparer<ULongEnum>.Default.GetHashCode (ULongEnum.A))
+ return 1;
+ if (ULongEnum.A.GetHashCode () != ((ulong)ULongEnum.A).GetHashCode () )
+ return 2;
+ return 0;
+ }
+
+ public static int Main (String[] args) {
+ return TestDriver.RunTests (typeof (Tests), args);
+ }
-public class test {
- public static int Main () {
- YaddaYadda val = YaddaYadda.dadoom;
- byteenum be = byteenum.one;
- if (val != YaddaYadda.dadoom)
- return 1;
- if (be != (byteenum)1)
- return 2;
- return 0;
}
-}
}
stop-the-world before walking the heap.
*/
class Driver {
-
static void AllocStuff ()
{
var x = new object ();
}
static void Main () {
+ var testTimeout = new TestTimeout ();
+ testTimeout.Start ();
for (int i = 0; i < Math.Max (1, Environment.ProcessorCount / 2); ++i) {
// for (int i = 0; i < 4; ++i) {
var t = new Thread (BackgroundNoise);
t.Start ();
}
- for (int i = 0; i < 100; ++i) {
+ const int TOTAL_ITERATIONS = 100;
+ for (int i = 0; i < TOTAL_ITERATIONS; ++i) {
var ad = AppDomain.CreateDomain ("domain_" + i);
ad.DoCallBack (new CrossAppDomainDelegate (AllocStuff));
AppDomain.Unload (ad);
+
Console.Write (".");
if (i > 0 && i % 20 == 0) Console.WriteLine ();
+
+ if (!testTimeout.HaveTimeLeft ()) {
+ var finishTime = DateTime.UtcNow;
+ var ranFor = finishTime - testTimeout.StartTime;
+ Console.WriteLine ("Will run out of time soon. ran for {0}, finished {1}/{2} iterations", ranFor, i+1, TOTAL_ITERATIONS);
+ }
}
Console.WriteLine ("\ndone");
}
-}
\ No newline at end of file
+}
}
static void Main (string[] args) {
-
- for (int j = 0; j < 2; j++)
+ var testTimeout = new TestTimeout ();
+ testTimeout.Start ();
+
+ const int TOTAL_ITERATIONS = 2;
+ for (int j = 0; j < TOTAL_ITERATIONS; j++)
{
count = 0;
{
while (count < num_threads)
{
+ Console.Write (".");
Monitor.Wait(count_lock);
}
}
{
t.Join();
}
+
+ Console.WriteLine ();
+ if (!testTimeout.HaveTimeLeft ()) {
+ var finishTime = DateTime.UtcNow;
+ var ranFor = finishTime - testTimeout.StartTime;
+ Console.WriteLine ("Will run out of time soon. ran for {0}, finished {1}/{2} iterations", ranFor, j+1, TOTAL_ITERATIONS);
+ }
}
+
+ Console.WriteLine ("done");
}
}
$output = $test;
#This is a silly workaround, but all tests that use extra parameters need a larger timeout.
- $timeout_in_minutes = 5;
+ $timeout_in_minutes = 9;
}
+$ENV{'TEST_DRIVER_TIMEOUT_SEC'} = $timeout_in_minutes * 60;
$| = 0;
print "Testing $test... ";
public class TestRunner
{
const string TEST_TIME_FORMAT = "mm\\:ss\\.fff";
+ const string ENV_TIMEOUT = "TEST_DRIVER_TIMEOUT_SEC";
class ProcessData {
public string test;
info.UseShellExecute = false;
info.RedirectStandardOutput = true;
info.RedirectStandardError = true;
+ info.EnvironmentVariables[ENV_TIMEOUT] = timeout.ToString();
Process p = new Process ();
p.StartInfo = info;
mono-md5.c \
mono-sha1.c \
mono-logger.c \
- mono-logger-internal.h \
+ mono-logger-internals.h \
mono-codeman.c \
dlmalloc.h \
dlmalloc.c \
mono-math.c \
mono-mmap.c \
mono-mmap.h \
- mono-mmap-internal.h \
+ mono-mmap-internals.h \
mono-mutex.c \
mono-mutex.h \
mono-lazy-init.h \
+++ /dev/null
-#ifndef __MONO_LOGGER_INTERNAL_H__
-#define __MONO_LOGGER_INTERNAL_H__
-
-#include <glib.h>
-#include "mono-logger.h"
-
-G_BEGIN_DECLS
-
-typedef enum {
- MONO_TRACE_ASSEMBLY = (1<<0),
- MONO_TRACE_TYPE = (1<<1),
- MONO_TRACE_DLLIMPORT = (1<<2),
- MONO_TRACE_GC = (1<<3),
- MONO_TRACE_CONFIG = (1<<4),
- MONO_TRACE_AOT = (1<<5),
- MONO_TRACE_SECURITY = (1<<6),
- MONO_TRACE_THREADPOOL = (1<<7),
- MONO_TRACE_IO_THREADPOOL = (1<<8),
- MONO_TRACE_ALL = MONO_TRACE_ASSEMBLY |
- MONO_TRACE_TYPE |
- MONO_TRACE_DLLIMPORT |
- MONO_TRACE_GC |
- MONO_TRACE_CONFIG |
- MONO_TRACE_AOT |
- MONO_TRACE_SECURITY |
- MONO_TRACE_THREADPOOL |
- MONO_TRACE_IO_THREADPOOL
-} MonoTraceMask;
-
-void
-mono_trace_cleanup (void);
-
-void
-mono_trace (GLogLevelFlags level, MonoTraceMask mask, const char *format, ...);
-
-void
-mono_tracev (GLogLevelFlags level, MonoTraceMask mask, const char *format, va_list args);
-
-void
-mono_trace_set_level (GLogLevelFlags level);
-
-void
-mono_trace_set_mask (MonoTraceMask mask);
-
-void
-mono_trace_push (GLogLevelFlags level, MonoTraceMask mask);
-
-void
-mono_trace_pop (void);
-
-gboolean
-mono_trace_is_traced (GLogLevelFlags level, MonoTraceMask mask);
-
-#ifdef G_HAVE_ISO_VARARGS
-#define mono_trace_error(...) mono_trace(G_LOG_LEVEL_ERROR, \
- __VA_ARGS__)
-#define mono_trace_warning(...) mono_trace(G_LOG_LEVEL_WARNING, \
- __VA_ARGS__)
-#define mono_trace_message(...) mono_trace(G_LOG_LEVEL_MESSAGE, \
- __VA_ARGS__)
-#elif defined(G_HAVE_GNUC_VARARGS)
-#define mono_trace_error(format...) mono_trace(G_LOG_LEVEL_ERROR, \
- format)
-#define mono_trace_warning(format...) mono_trace(G_LOG_LEVEL_WARNING, \
- format)
-#define mono_trace_message(format...) mono_trace(G_LOG_LEVEL_MESSAGE, \
- format)
-#else /* no varargs macros */
-G_GNUC_UNUSED static void
-mono_trace_error(MonoTraceMask mask, const char *format, ...)
-{
- va_list args;
- va_start (args, format);
- mono_tracev(G_LOG_LEVEL_ERROR, mask, format, args);
- va_end (args);
-}
-
-G_GNUC_UNUSED static void
-mono_trace_warning(MonoTraceMask mask, const char *format, ...)
-{
- va_list args;
- va_start (args, format);
- mono_tracev(G_LOG_LEVEL_WARNING, mask, format, args);
- va_end (args);
-}
-
-G_GNUC_UNUSED static void
-mono_trace_message(MonoTraceMask mask, const char *format, ...)
-{
- va_list args;
- va_start (args, format);
- mono_tracev(G_LOG_LEVEL_MESSAGE, mask, format, args);
- va_end (args);
-}
-
-#endif /* !__GNUC__ */
-
-#if defined (PLATFORM_ANDROID) || (defined (TARGET_IOS) && defined (TARGET_IOS))
-
-#define mono_gc_printf(gc_log_file, format, ...) g_log ("mono-gc", G_LOG_LEVEL_MESSAGE, format, ##__VA_ARGS__)
-#define mono_runtime_printf(format, ...) g_log ("mono-rt", G_LOG_LEVEL_MESSAGE, format "\n", ##__VA_ARGS__)
-#define mono_runtime_printf_err(format, ...) g_log ("mono-rt", G_LOG_LEVEL_CRITICAL, format "\n", ##__VA_ARGS__)
-#define mono_runtime_stdout_fflush() do { } while (0)
-
-#else
-
-#define mono_gc_printf(gc_log_file, format, ...) do { \
- fprintf (gc_log_file, format, ##__VA_ARGS__); \
- fflush (gc_log_file); \
-} while (0)
-
-#define mono_runtime_printf(format, ...) fprintf (stdout, format "\n", ##__VA_ARGS__)
-#define mono_runtime_printf_err(format, ...) fprintf (stderr, format "\n", ##__VA_ARGS__)
-#define mono_runtime_stdout_fflush() do { fflush (stdout); } while (0)
-
-#endif
-
-
-G_END_DECLS
-
-#endif /* __MONO_LOGGER_INTERNAL_H__ */
--- /dev/null
+#ifndef __MONO_LOGGER_INTERNAL_H__
+#define __MONO_LOGGER_INTERNAL_H__
+
+#include <glib.h>
+#include "mono-logger.h"
+
+G_BEGIN_DECLS
+
+typedef enum {
+ MONO_TRACE_ASSEMBLY = (1<<0),
+ MONO_TRACE_TYPE = (1<<1),
+ MONO_TRACE_DLLIMPORT = (1<<2),
+ MONO_TRACE_GC = (1<<3),
+ MONO_TRACE_CONFIG = (1<<4),
+ MONO_TRACE_AOT = (1<<5),
+ MONO_TRACE_SECURITY = (1<<6),
+ MONO_TRACE_THREADPOOL = (1<<7),
+ MONO_TRACE_IO_THREADPOOL = (1<<8),
+ MONO_TRACE_ALL = MONO_TRACE_ASSEMBLY |
+ MONO_TRACE_TYPE |
+ MONO_TRACE_DLLIMPORT |
+ MONO_TRACE_GC |
+ MONO_TRACE_CONFIG |
+ MONO_TRACE_AOT |
+ MONO_TRACE_SECURITY |
+ MONO_TRACE_THREADPOOL |
+ MONO_TRACE_IO_THREADPOOL
+} MonoTraceMask;
+
+void
+mono_trace_cleanup (void);
+
+void
+mono_trace (GLogLevelFlags level, MonoTraceMask mask, const char *format, ...);
+
+void
+mono_tracev (GLogLevelFlags level, MonoTraceMask mask, const char *format, va_list args);
+
+void
+mono_trace_set_level (GLogLevelFlags level);
+
+void
+mono_trace_set_mask (MonoTraceMask mask);
+
+void
+mono_trace_push (GLogLevelFlags level, MonoTraceMask mask);
+
+void
+mono_trace_pop (void);
+
+gboolean
+mono_trace_is_traced (GLogLevelFlags level, MonoTraceMask mask);
+
+#ifdef G_HAVE_ISO_VARARGS
+#define mono_trace_error(...) mono_trace(G_LOG_LEVEL_ERROR, \
+ __VA_ARGS__)
+#define mono_trace_warning(...) mono_trace(G_LOG_LEVEL_WARNING, \
+ __VA_ARGS__)
+#define mono_trace_message(...) mono_trace(G_LOG_LEVEL_MESSAGE, \
+ __VA_ARGS__)
+#elif defined(G_HAVE_GNUC_VARARGS)
+#define mono_trace_error(format...) mono_trace(G_LOG_LEVEL_ERROR, \
+ format)
+#define mono_trace_warning(format...) mono_trace(G_LOG_LEVEL_WARNING, \
+ format)
+#define mono_trace_message(format...) mono_trace(G_LOG_LEVEL_MESSAGE, \
+ format)
+#else /* no varargs macros */
+G_GNUC_UNUSED static void
+mono_trace_error(MonoTraceMask mask, const char *format, ...)
+{
+ va_list args;
+ va_start (args, format);
+ mono_tracev(G_LOG_LEVEL_ERROR, mask, format, args);
+ va_end (args);
+}
+
+G_GNUC_UNUSED static void
+mono_trace_warning(MonoTraceMask mask, const char *format, ...)
+{
+ va_list args;
+ va_start (args, format);
+ mono_tracev(G_LOG_LEVEL_WARNING, mask, format, args);
+ va_end (args);
+}
+
+G_GNUC_UNUSED static void
+mono_trace_message(MonoTraceMask mask, const char *format, ...)
+{
+ va_list args;
+ va_start (args, format);
+ mono_tracev(G_LOG_LEVEL_MESSAGE, mask, format, args);
+ va_end (args);
+}
+
+#endif /* !__GNUC__ */
+
+#if defined (PLATFORM_ANDROID) || (defined (TARGET_IOS) && defined (TARGET_IOS))
+
+#define mono_gc_printf(gc_log_file, format, ...) g_log ("mono-gc", G_LOG_LEVEL_MESSAGE, format, ##__VA_ARGS__)
+#define mono_runtime_printf(format, ...) g_log ("mono-rt", G_LOG_LEVEL_MESSAGE, format "\n", ##__VA_ARGS__)
+#define mono_runtime_printf_err(format, ...) g_log ("mono-rt", G_LOG_LEVEL_CRITICAL, format "\n", ##__VA_ARGS__)
+#define mono_runtime_stdout_fflush() do { } while (0)
+
+#else
+
+#define mono_gc_printf(gc_log_file, format, ...) do { \
+ fprintf (gc_log_file, format, ##__VA_ARGS__); \
+ fflush (gc_log_file); \
+} while (0)
+
+#define mono_runtime_printf(format, ...) fprintf (stdout, format "\n", ##__VA_ARGS__)
+#define mono_runtime_printf_err(format, ...) fprintf (stderr, format "\n", ##__VA_ARGS__)
+#define mono_runtime_stdout_fflush() do { fflush (stdout); } while (0)
+
+#endif
+
+
+G_END_DECLS
+
+#endif /* __MONO_LOGGER_INTERNAL_H__ */
#include <glib.h>
#include "mono-compiler.h"
-#include "mono-logger-internal.h"
+#include "mono-logger-internals.h"
typedef struct {
GLogLevelFlags level;
+++ /dev/null
-/*
- * mono-mmap-internal.h: Internal virtual memory stuff.
- *
- * Copyright (C) 2014 Xamarin Inc
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License 2.0 as published by the Free Software Foundation;
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License 2.0 along with this library; if not, write to the Free
- * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-#ifndef __MONO_UTILS_MMAP_INTERNAL_H__
-#define __MONO_UTILS_MMAP_INTERNAL_H__
-
-#include "mono-compiler.h"
-
-int mono_pages_not_faulted (void *addr, size_t length);
-
-#endif /* __MONO_UTILS_MMAP_INTERNAL_H__ */
-
--- /dev/null
+/*
+ * mono-mmap-internals.h: Internal virtual memory stuff.
+ *
+ * Copyright (C) 2014 Xamarin Inc
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License 2.0 as published by the Free Software Foundation;
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License 2.0 along with this library; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#ifndef __MONO_UTILS_MMAP_INTERNAL_H__
+#define __MONO_UTILS_MMAP_INTERNAL_H__
+
+#include "mono-compiler.h"
+
+int mono_pages_not_faulted (void *addr, size_t length);
+
+#endif /* __MONO_UTILS_MMAP_INTERNAL_H__ */
+
#endif
#include "mono-mmap.h"
-#include "mono-mmap-internal.h"
+#include "mono-mmap-internals.h"
#include "mono-proclib.h"
#include <mono/utils/mono-threads.h>
#define UCONTEXT_REG_R13(ctx) (((ucontext_t*)(ctx))->sc_r13)
#define UCONTEXT_REG_R14(ctx) (((ucontext_t*)(ctx))->sc_r14)
#define UCONTEXT_REG_R15(ctx) (((ucontext_t*)(ctx))->sc_r15)
-#else
+#elif !defined(HOST_WIN32)
#define UCONTEXT_GREGS(ctx) ((guint64*)&(((ucontext_t*)(ctx))->uc_mcontext.gregs))
#endif
#include <mono/utils/mono-threads.h>
#include <mono/utils/mono-threads-posix-signals.h>
-#include <mono/metadata/gc-internal.h>
+#include <mono/metadata/gc-internals.h>
#include <errno.h>
<ClInclude Include="..\mono\metadata\exception.h" />\r
<ClInclude Include="..\mono\metadata\file-io.h" />\r
<ClInclude Include="..\mono\metadata\filewatcher.h" />\r
- <ClInclude Include="..\mono\metadata\gc-internal.h" />\r
+ <ClInclude Include="..\mono\metadata\gc-internals.h" />\r
<ClInclude Include="..\mono\metadata\number-ms.h" />\r
<ClInclude Include="..\mono\metadata\seq-points-data.h" />\r
<ClInclude Include="..\mono\metadata\threadpool-ms-io.h" />\r
<ClInclude Include="..\mono\utils\mono-internal-hash.h" />\r
<ClInclude Include="..\mono\utils\mono-io-portability.h" />\r
<ClInclude Include="..\mono\utils\mono-linked-list-set.h" />\r
- <ClInclude Include="..\mono\utils\mono-logger-internal.h" />\r
+ <ClInclude Include="..\mono\utils\mono-logger-internals.h" />\r
<ClInclude Include="..\mono\utils\mono-logger.h" />\r
<ClInclude Include="..\mono\utils\mono-machine.h" />\r
<ClInclude Include="..\mono\utils\mono-math.h" />\r
endif
if INSTALL_MONOTOUCH_WATCH
-build_profiles += monotouch_watch
+build_profiles += monotouch_watch monotouch_watch_runtime
endif
if INSTALL_MONOTOUCH_TV
-build_profiles += monotouch_tv
+build_profiles += monotouch_tv monotouch_tv_runtime
endif
if INSTALL_XAMMAC
+++ /dev/null
-#include <mono/interpreter/embed.h>
-#include <mono/metadata/environment.h>
-
-/*
- * Very simple mint embedding example.
- * Compile with:
- * gcc -o testi testi.c `pkg-config --cflags --libs mint` -lm
- * mcs test.cs
- * Run with:
- * ./testi test.exe
- */
-
-static MonoString*
-gimme () {
- return mono_string_new (mono_domain_get (), "All your monos are belong to us!");
-}
-
-typedef struct
-{
- MonoDomain *domain;
- const char *file;
- int argc;
- char **argv;
-} MainThreadArgs;
-
-static void main_thread_handler (gpointer user_data)
-{
- MainThreadArgs *main_args=(MainThreadArgs *)user_data;
- MonoAssembly *assembly;
-
- assembly = mono_domain_assembly_open (main_args->domain,
- main_args->file);
- if (!assembly)
- exit (2);
- /*
- * mono_jit_exec() will run the Main() method in the assembly.
- * The return value needs to be looked up from
- * System.Environment.ExitCode.
- */
- mono_interp_exec (main_args->domain, assembly, main_args->argc,
- main_args->argv);
-}
-
-
-int
-main(int argc, char* argv[]) {
- MonoDomain *domain;
- const char *file;
- int retval;
- MainThreadArgs main_args;
-
- if (argc < 2){
- fprintf (stderr, "Please provide an assembly to load\n");
- return 1;
- }
- file = argv [1];
- /*
- * mono_jit_init() creates a domain: each assembly is
- * loaded and run in a MonoDomain.
- */
- domain = mono_interp_init (file);
- /*
- * We add our special internal call, so that C# code
- * can call us back.
- */
- mono_add_internal_call ("MonoEmbed::gimme", gimme);
-
- main_args.domain=domain;
- main_args.file=file;
- main_args.argc=argc-1;
- main_args.argv=argv+1;
-
- mono_runtime_exec_managed_code (domain, main_thread_handler,
- &main_args);
-
- retval=mono_environment_exitcode_get ();
-
- mono_interp_cleanup (domain);
- return retval;
-}
-