Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/corert.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichal Strehovský <michals@microsoft.com>2015-11-18 22:03:26 +0300
committerMichal Strehovský <michals@microsoft.com>2015-11-19 05:49:09 +0300
commitd86875fe2a2d33db094c9828a1af84c78573e075 (patch)
tree3e0ab1f933bc8d19596023e0c26a25acebdb8fcb /src/ILCompiler.Compiler
parent8928dfd66d98f40017ec7435df1fbada113656a8 (diff)
Enable range check code in MDArray accessors
The code was already there, but ILEmitter didn't support labels at the time it was written. We now emit IL to check the bounds of multidimensional arrays in Get/Set/Address methods and throw an IndexOutOfRangeException if an out of bounds access was made. Fixes half of what's in scope for issue #89.
Diffstat (limited to 'src/ILCompiler.Compiler')
-rw-r--r--src/ILCompiler.Compiler/src/IL/HelperExtensions.cs38
-rw-r--r--src/ILCompiler.Compiler/src/ILCompiler.Compiler.csproj1
2 files changed, 39 insertions, 0 deletions
diff --git a/src/ILCompiler.Compiler/src/IL/HelperExtensions.cs b/src/ILCompiler.Compiler/src/IL/HelperExtensions.cs
new file mode 100644
index 000000000..a16595f0b
--- /dev/null
+++ b/src/ILCompiler.Compiler/src/IL/HelperExtensions.cs
@@ -0,0 +1,38 @@
+// Copyright (c) Microsoft. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+
+using System;
+
+using ILCompiler;
+using Internal.TypeSystem;
+
+namespace Internal.IL
+{
+ static class HelperExtensions
+ {
+ public static MetadataType GetHelperType(this TypeSystemContext context, string name)
+ {
+ MetadataType helperType = ((CompilerTypeSystemContext)context).SystemModule.GetType("Internal.Runtime.CompilerHelpers", name, false);
+ if (helperType == null)
+ {
+ // TODO: throw the exception that means 'Core Library doesn't have a required thing in it'
+ throw new NotImplementedException();
+ }
+
+ return helperType;
+ }
+
+ public static MethodDesc GetHelperEntryPoint(this TypeSystemContext context, string typeName, string methodName)
+ {
+ MetadataType helperType = context.GetHelperType(typeName);
+ MethodDesc helperMethod = helperType.GetMethod(methodName, null);
+ if (helperMethod == null)
+ {
+ // TODO: throw the exception that means 'Core Library doesn't have a required thing in it'
+ throw new NotImplementedException();
+ }
+
+ return helperMethod;
+ }
+ }
+} \ No newline at end of file
diff --git a/src/ILCompiler.Compiler/src/ILCompiler.Compiler.csproj b/src/ILCompiler.Compiler/src/ILCompiler.Compiler.csproj
index 7213aa62e..01a1404fe 100644
--- a/src/ILCompiler.Compiler/src/ILCompiler.Compiler.csproj
+++ b/src/ILCompiler.Compiler/src/ILCompiler.Compiler.csproj
@@ -81,6 +81,7 @@
<Compile Include="Compiler\RvaFieldData.cs" />
<Compile Include="Compiler\IntrinsicMethods.cs" />
<Compile Include="CppCodeGen\CppWriter.cs" />
+ <Compile Include="IL\HelperExtensions.cs" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\..\Common\src\System\Collections\Generic\ArrayBuilder.cs">