IKVM11  11
Java SE 11 Virtual Machine for .NET
Loading...
Searching...
No Matches
ByteCodeHelperMethods.cs
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2015 Jeroen Frijters
3
4 This software is provided 'as-is', without any express or implied
5 warranty. In no event will the authors be held liable for any damages
6 arising from the use of this software.
7
8 Permission is granted to anyone to use this software for any purpose,
9 including commercial applications, and to alter it and redistribute it
10 freely, subject to the following restrictions:
11
12 1. The origin of this software must not be misrepresented; you must not
13 claim that you wrote the original software. If you use this software
14 in a product, an acknowledgment in the product documentation would be
15 appreciated but is not required.
16 2. Altered source versions must be plainly marked as such, and must not be
17 misrepresented as being the original software.
18 3. This notice may not be removed or altered from any source distribution.
19
20 Jeroen Frijters
21 jeroen@frijters.net
22
23*/
24using System;
25
29
30#if IMPORTER
31using IKVM.Reflection;
34
35using Type = IKVM.Reflection.Type;
36#else
37using System.Reflection;
38#endif
39
40namespace IKVM.Runtime
41{
42
43#if EXPORTER == FALSE
44
46 {
47
48 internal readonly MethodInfo multianewarray;
49 internal readonly MethodInfo multianewarray_ghost;
50 internal readonly MethodInfo anewarray_ghost;
51 internal readonly MethodInfo f2i;
52 internal readonly MethodInfo d2i;
53 internal readonly MethodInfo f2l;
54 internal readonly MethodInfo d2l;
55 internal readonly MethodInfo arraycopy_fast;
56 internal readonly MethodInfo arraycopy_primitive_8;
57 internal readonly MethodInfo arraycopy_primitive_4;
58 internal readonly MethodInfo arraycopy_primitive_2;
59 internal readonly MethodInfo arraycopy_primitive_1;
60 internal readonly MethodInfo arraycopy;
61 internal readonly MethodInfo DynamicCast;
62 internal readonly MethodInfo DynamicAaload;
63 internal readonly MethodInfo DynamicAastore;
64 internal readonly MethodInfo DynamicClassLiteral;
65 internal readonly MethodInfo DynamicMultianewarray;
66 internal readonly MethodInfo DynamicNewarray;
67 internal readonly MethodInfo DynamicNewCheckOnly;
68 internal readonly MethodInfo DynamicCreateDelegate;
69 internal readonly MethodInfo DynamicLoadMethodType;
70 internal readonly MethodInfo DynamicLoadMethodHandle;
71 internal readonly MethodInfo DynamicBinderMemberLookup;
72 internal readonly MethodInfo DynamicMapException;
73 internal readonly MethodInfo DynamicCallerID;
74 internal readonly MethodInfo DynamicLinkIndyCallSite;
75 internal readonly MethodInfo DynamicEraseInvokeExact;
76 internal readonly MethodInfo VerboseCastFailure;
77 internal readonly MethodInfo SkipFinalizer;
78 internal readonly MethodInfo SkipFinalizerOf;
79 internal readonly MethodInfo DynamicInstanceOf;
80 internal readonly MethodInfo VolatileReadBoolean;
81 internal readonly MethodInfo VolatileReadByte;
82 internal readonly MethodInfo VolatileReadChar;
83 internal readonly MethodInfo VolatileReadShort;
84 internal readonly MethodInfo VolatileReadInt;
85 internal readonly MethodInfo VolatileReadLong;
86 internal readonly MethodInfo VolatileReadFloat;
87 internal readonly MethodInfo VolatileReadDouble;
88 internal readonly MethodInfo VolatileWriteBoolean;
89 internal readonly MethodInfo VolatileWriteByte;
90 internal readonly MethodInfo VolatileWriteChar;
91 internal readonly MethodInfo VolatileWriteShort;
92 internal readonly MethodInfo VolatileWriteInt;
93 internal readonly MethodInfo VolatileWriteLong;
94 internal readonly MethodInfo VolatileWriteFloat;
95 internal readonly MethodInfo VolatileWriteDouble;
96 internal readonly MethodInfo CompareAndSwapObject;
97 internal readonly MethodInfo CompareAndSwapInt;
98 internal readonly MethodInfo CompareAndSwapLong;
99 internal readonly MethodInfo CompareAndSwapDouble;
100 internal readonly MethodInfo MapException;
101 internal readonly MethodInfo GetDelegateForInvokeExact;
102 internal readonly MethodInfo GetDelegateForInvoke;
103 internal readonly MethodInfo GetDelegateForInvokeBasic;
104 internal readonly MethodInfo LoadMethodType;
105 internal readonly MethodInfo LinkIndyCallSite;
106
112 {
113#if IMPORTER || EXPORTER
114 var typeofByteCodeHelper = ((IkvmReflectionTypeSymbol)context.Resolver.ResolveRuntimeType("IKVM.Runtime.ByteCodeHelper")).UnderlyingType;
115#else
116 var typeofByteCodeHelper = ((ReflectionTypeSymbol)context.Resolver.ResolveRuntimeType("IKVM.Runtime.ByteCodeHelper")).UnderlyingType;
117#endif
118 multianewarray = GetHelper(typeofByteCodeHelper, "multianewarray");
119 multianewarray_ghost = GetHelper(typeofByteCodeHelper, "multianewarray_ghost");
120 anewarray_ghost = GetHelper(typeofByteCodeHelper, "anewarray_ghost");
121 f2i = GetHelper(typeofByteCodeHelper, "f2i");
122 d2i = GetHelper(typeofByteCodeHelper, "d2i");
123 f2l = GetHelper(typeofByteCodeHelper, "f2l");
124 d2l = GetHelper(typeofByteCodeHelper, "d2l");
125 arraycopy_fast = GetHelper(typeofByteCodeHelper, "arraycopy_fast");
126 arraycopy_primitive_8 = GetHelper(typeofByteCodeHelper, "arraycopy_primitive_8");
127 arraycopy_primitive_4 = GetHelper(typeofByteCodeHelper, "arraycopy_primitive_4");
128 arraycopy_primitive_2 = GetHelper(typeofByteCodeHelper, "arraycopy_primitive_2");
129 arraycopy_primitive_1 = GetHelper(typeofByteCodeHelper, "arraycopy_primitive_1");
130 arraycopy = GetHelper(typeofByteCodeHelper, "arraycopy");
131 DynamicCast = GetHelper(typeofByteCodeHelper, "DynamicCast");
132 DynamicAaload = GetHelper(typeofByteCodeHelper, "DynamicAaload");
133 DynamicAastore = GetHelper(typeofByteCodeHelper, "DynamicAastore");
134 DynamicClassLiteral = GetHelper(typeofByteCodeHelper, "DynamicClassLiteral");
135 DynamicMultianewarray = GetHelper(typeofByteCodeHelper, "DynamicMultianewarray");
136 DynamicNewarray = GetHelper(typeofByteCodeHelper, "DynamicNewarray");
137 DynamicNewCheckOnly = GetHelper(typeofByteCodeHelper, "DynamicNewCheckOnly");
138 DynamicCreateDelegate = GetHelper(typeofByteCodeHelper, "DynamicCreateDelegate");
139 DynamicLoadMethodType = GetHelper(typeofByteCodeHelper, "DynamicLoadMethodType");
140 DynamicLoadMethodHandle = GetHelper(typeofByteCodeHelper, "DynamicLoadMethodHandle");
141 DynamicBinderMemberLookup = GetHelper(typeofByteCodeHelper, "DynamicBinderMemberLookup");
142 DynamicMapException = GetHelper(typeofByteCodeHelper, "DynamicMapException");
143 DynamicCallerID = GetHelper(typeofByteCodeHelper, "DynamicCallerID");
144 DynamicLinkIndyCallSite = GetHelper(typeofByteCodeHelper, "DynamicLinkIndyCallSite");
145 DynamicEraseInvokeExact = GetHelper(typeofByteCodeHelper, "DynamicEraseInvokeExact");
146 VerboseCastFailure = GetHelper(typeofByteCodeHelper, "VerboseCastFailure");
147 SkipFinalizer = GetHelper(typeofByteCodeHelper, "SkipFinalizer", new Type[] { });
148 SkipFinalizerOf = GetHelper(typeofByteCodeHelper, "SkipFinalizer", new Type[] { context.Types.Object });
149 DynamicInstanceOf = GetHelper(typeofByteCodeHelper, "DynamicInstanceOf");
150 VolatileReadBoolean = GetHelper(typeofByteCodeHelper, "VolatileRead", new Type[] { context.Types.Boolean.MakeByRefType() });
151 VolatileReadByte = GetHelper(typeofByteCodeHelper, "VolatileRead", new Type[] { context.Types.Byte.MakeByRefType() });
152 VolatileReadChar = GetHelper(typeofByteCodeHelper, "VolatileRead", new Type[] { context.Types.Char.MakeByRefType() });
153 VolatileReadShort = GetHelper(typeofByteCodeHelper, "VolatileRead", new Type[] { context.Types.Int16.MakeByRefType() });
154 VolatileReadInt = GetHelper(typeofByteCodeHelper, "VolatileRead", new Type[] { context.Types.Int32.MakeByRefType() });
155 VolatileReadLong = GetHelper(typeofByteCodeHelper, "VolatileRead", new Type[] { context.Types.Int64.MakeByRefType() });
156 VolatileReadFloat = GetHelper(typeofByteCodeHelper, "VolatileRead", new Type[] { context.Types.Single.MakeByRefType() });
157 VolatileReadDouble = GetHelper(typeofByteCodeHelper, "VolatileRead", new Type[] { context.Types.Double.MakeByRefType() });
158 VolatileWriteBoolean = GetHelper(typeofByteCodeHelper, "VolatileWrite", new Type[] { context.Types.Boolean.MakeByRefType(), context.Types.Boolean });
159 VolatileWriteByte = GetHelper(typeofByteCodeHelper, "VolatileWrite", new Type[] { context.Types.Byte.MakeByRefType(), context.Types.Byte });
160 VolatileWriteChar = GetHelper(typeofByteCodeHelper, "VolatileWrite", new Type[] { context.Types.Char.MakeByRefType(), context.Types.Char });
161 VolatileWriteShort = GetHelper(typeofByteCodeHelper, "VolatileWrite", new Type[] { context.Types.Int16.MakeByRefType(), context.Types.Int16 });
162 VolatileWriteInt = GetHelper(typeofByteCodeHelper, "VolatileWrite", new Type[] { context.Types.Int32.MakeByRefType(), context.Types.Int32 });
163 VolatileWriteLong = GetHelper(typeofByteCodeHelper, "VolatileWrite", new Type[] { context.Types.Int64.MakeByRefType(), context.Types.Int64 });
164 VolatileWriteFloat = GetHelper(typeofByteCodeHelper, "VolatileWrite", new Type[] { context.Types.Single.MakeByRefType(), context.Types.Single });
165 VolatileWriteDouble = GetHelper(typeofByteCodeHelper, "VolatileWrite", new Type[] { context.Types.Double.MakeByRefType(), context.Types.Double });
166 CompareAndSwapObject = GetHelper(typeofByteCodeHelper, "CompareAndSwap", new[] { context.Types.Object.MakeByRefType(), context.Types.Object, context.Types.Object });
167 CompareAndSwapInt = GetHelper(typeofByteCodeHelper, "CompareAndSwap", new[] { context.Types.Int32.MakeByRefType(), context.Types.Int32, context.Types.Int32 });
168 CompareAndSwapLong = GetHelper(typeofByteCodeHelper, "CompareAndSwap", new[] { context.Types.Int64.MakeByRefType(), context.Types.Int64, context.Types.Int64 });
169 CompareAndSwapDouble = GetHelper(typeofByteCodeHelper, "CompareAndSwap", new[] { context.Types.Double.MakeByRefType(), context.Types.Double, context.Types.Double });
170 MapException = GetHelper(typeofByteCodeHelper, "MapException");
171 GetDelegateForInvokeExact = GetHelper(typeofByteCodeHelper, "GetDelegateForInvokeExact");
172 GetDelegateForInvoke = GetHelper(typeofByteCodeHelper, "GetDelegateForInvoke");
173 GetDelegateForInvokeBasic = GetHelper(typeofByteCodeHelper, "GetDelegateForInvokeBasic");
174 LoadMethodType = GetHelper(typeofByteCodeHelper, "LoadMethodType");
175 LinkIndyCallSite = GetHelper(typeofByteCodeHelper, "LinkIndyCallSite");
176 }
177
178 static MethodInfo GetHelper(Type type, string method)
179 {
180 return GetHelper(type, method, null);
181 }
182
183 static MethodInfo GetHelper(Type type, string method, Type[] parameters)
184 {
185 var mi = parameters == null ? type.GetMethod(method) : type.GetMethod(method, parameters);
186 if (mi == null)
187#if IMPORTER
189#else
190 throw new InternalException("Missing ByteCodeHelper method in runtime.");
191#endif
192
193 return mi;
194 }
195
196 }
197
198#endif
199
200}
IKVM.Reflection.Type Type
IKVM.Reflection.MethodInfo MethodInfo
ByteCodeHelperMethods(RuntimeContext context)
Initializes a new instance.
Maintains services relevant to an instane of the IKVM runtime.
Types Types
Gets the Types associated with this instance of the runtime.
ISymbolResolver Resolver
Gets the ISymbolResolver associated with this instance of the runtime.
static DiagnosticEvent RuntimeMethodMissing(string arg0, Exception? exception=null, DiagnosticLocation location=default)
The 'RuntimeMethodMissing' diagnostic.