author | dlong |
Thu, 14 Nov 2019 12:21:00 -0800 | |
changeset 59095 | 03fbcd06b4c0 |
parent 58901 | 2700c409ff10 |
permissions | -rw-r--r-- |
43972 | 1 |
/* |
53425
312880c38a7f
8215375: [Graal] jck:vm/jvmti/Exception/excp001/excp00101 fails in Graal as JIT mode and -Xcomp mode
dnsimon
parents:
52956
diff
changeset
|
2 |
* Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved. |
43972 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. |
|
8 |
* |
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
13 |
* accompanied this code). |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License version |
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 |
* |
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
20 |
* or visit www.oracle.com if you need additional information or have any |
|
21 |
* questions. |
|
22 |
*/ |
|
50858 | 23 |
|
24 |
||
43972 | 25 |
package org.graalvm.compiler.hotspot.meta; |
26 |
||
46344 | 27 |
import static org.graalvm.compiler.core.common.GraalOptions.GeneratePIC; |
54601 | 28 |
import static org.graalvm.compiler.hotspot.HotSpotBackend.BASE64_ENCODE_BLOCK; |
54084 | 29 |
import static org.graalvm.compiler.hotspot.HotSpotBackend.GHASH_PROCESS_BLOCKS; |
43972 | 30 |
import static org.graalvm.compiler.hotspot.meta.HotSpotAOTProfilingPlugin.Options.TieredAOT; |
31 |
import static org.graalvm.compiler.hotspot.replacements.HotSpotReplacementsUtil.JAVA_THREAD_THREAD_OBJECT_LOCATION; |
|
32 |
import static org.graalvm.compiler.java.BytecodeParserOptions.InlineDuringParsing; |
|
46459 | 33 |
|
43972 | 34 |
import java.lang.invoke.ConstantCallSite; |
35 |
import java.lang.invoke.MutableCallSite; |
|
36 |
import java.lang.invoke.VolatileCallSite; |
|
48861 | 37 |
import java.lang.reflect.Array; |
59095 | 38 |
import java.lang.reflect.Type; |
43972 | 39 |
import java.math.BigInteger; |
40 |
import java.util.zip.CRC32; |
|
41 |
||
59095 | 42 |
import jdk.internal.vm.compiler.collections.Pair; |
43972 | 43 |
import org.graalvm.compiler.api.replacements.SnippetReflectionProvider; |
44 |
import org.graalvm.compiler.core.common.spi.ForeignCallsProvider; |
|
48861 | 45 |
import org.graalvm.compiler.core.common.type.ObjectStamp; |
47798 | 46 |
import org.graalvm.compiler.core.common.type.StampFactory; |
48861 | 47 |
import org.graalvm.compiler.core.common.type.TypeReference; |
57537 | 48 |
import org.graalvm.compiler.debug.GraalError; |
43972 | 49 |
import org.graalvm.compiler.hotspot.GraalHotSpotVMConfig; |
58299 | 50 |
import org.graalvm.compiler.hotspot.HotSpotGraalRuntimeProvider; |
43972 | 51 |
import org.graalvm.compiler.hotspot.nodes.CurrentJavaThreadNode; |
52 |
import org.graalvm.compiler.hotspot.replacements.AESCryptSubstitutions; |
|
54084 | 53 |
import org.graalvm.compiler.hotspot.replacements.ArraysSupportSubstitutions; |
43972 | 54 |
import org.graalvm.compiler.hotspot.replacements.BigIntegerSubstitutions; |
48861 | 55 |
import org.graalvm.compiler.hotspot.replacements.CRC32CSubstitutions; |
43972 | 56 |
import org.graalvm.compiler.hotspot.replacements.CRC32Substitutions; |
57 |
import org.graalvm.compiler.hotspot.replacements.CallSiteTargetNode; |
|
58 |
import org.graalvm.compiler.hotspot.replacements.CipherBlockChainingSubstitutions; |
|
59 |
import org.graalvm.compiler.hotspot.replacements.ClassGetHubNode; |
|
54084 | 60 |
import org.graalvm.compiler.hotspot.replacements.CounterModeSubstitutions; |
61 |
import org.graalvm.compiler.hotspot.replacements.DigestBaseSubstitutions; |
|
48861 | 62 |
import org.graalvm.compiler.hotspot.replacements.HotSpotArraySubstitutions; |
46344 | 63 |
import org.graalvm.compiler.hotspot.replacements.HotSpotClassSubstitutions; |
43972 | 64 |
import org.graalvm.compiler.hotspot.replacements.IdentityHashCodeNode; |
65 |
import org.graalvm.compiler.hotspot.replacements.ObjectCloneNode; |
|
66 |
import org.graalvm.compiler.hotspot.replacements.ObjectSubstitutions; |
|
67 |
import org.graalvm.compiler.hotspot.replacements.ReflectionGetCallerClassNode; |
|
68 |
import org.graalvm.compiler.hotspot.replacements.ReflectionSubstitutions; |
|
69 |
import org.graalvm.compiler.hotspot.replacements.SHA2Substitutions; |
|
70 |
import org.graalvm.compiler.hotspot.replacements.SHA5Substitutions; |
|
71 |
import org.graalvm.compiler.hotspot.replacements.SHASubstitutions; |
|
54084 | 72 |
import org.graalvm.compiler.hotspot.replacements.StringUTF16Substitutions; |
43972 | 73 |
import org.graalvm.compiler.hotspot.replacements.ThreadSubstitutions; |
74 |
import org.graalvm.compiler.hotspot.word.HotSpotWordTypes; |
|
54084 | 75 |
import org.graalvm.compiler.nodes.ComputeObjectAddressNode; |
43972 | 76 |
import org.graalvm.compiler.nodes.ConstantNode; |
77 |
import org.graalvm.compiler.nodes.NamedLocationIdentity; |
|
48190 | 78 |
import org.graalvm.compiler.nodes.NodeView; |
43972 | 79 |
import org.graalvm.compiler.nodes.ValueNode; |
80 |
import org.graalvm.compiler.nodes.calc.AddNode; |
|
47798 | 81 |
import org.graalvm.compiler.nodes.calc.IntegerConvertNode; |
43972 | 82 |
import org.graalvm.compiler.nodes.calc.LeftShiftNode; |
54084 | 83 |
import org.graalvm.compiler.nodes.extended.ForeignCallNode; |
43972 | 84 |
import org.graalvm.compiler.nodes.graphbuilderconf.ForeignCallPlugin; |
85 |
import org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderConfiguration.Plugins; |
|
86 |
import org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext; |
|
87 |
import org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin; |
|
88 |
import org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin.Receiver; |
|
89 |
import org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins; |
|
90 |
import org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.Registration; |
|
91 |
import org.graalvm.compiler.nodes.graphbuilderconf.NodeIntrinsicPluginFactory; |
|
92 |
import org.graalvm.compiler.nodes.memory.HeapAccess.BarrierType; |
|
48861 | 93 |
import org.graalvm.compiler.nodes.memory.ReadNode; |
43972 | 94 |
import org.graalvm.compiler.nodes.memory.address.AddressNode; |
95 |
import org.graalvm.compiler.nodes.memory.address.OffsetAddressNode; |
|
58877 | 96 |
import org.graalvm.compiler.nodes.spi.Replacements; |
43972 | 97 |
import org.graalvm.compiler.nodes.util.GraphUtil; |
46344 | 98 |
import org.graalvm.compiler.options.OptionValues; |
46459 | 99 |
import org.graalvm.compiler.phases.tiers.CompilerConfiguration; |
43972 | 100 |
import org.graalvm.compiler.replacements.InlineDuringParsingPlugin; |
101 |
import org.graalvm.compiler.replacements.MethodHandlePlugin; |
|
102 |
import org.graalvm.compiler.replacements.NodeIntrinsificationProvider; |
|
103 |
import org.graalvm.compiler.replacements.ReplacementsImpl; |
|
104 |
import org.graalvm.compiler.replacements.StandardGraphBuilderPlugins; |
|
52956 | 105 |
import org.graalvm.compiler.replacements.arraycopy.ArrayCopyNode; |
43972 | 106 |
import org.graalvm.compiler.serviceprovider.GraalServices; |
55509 | 107 |
import org.graalvm.compiler.serviceprovider.JavaVersionUtil; |
46459 | 108 |
import org.graalvm.compiler.word.WordOperationPlugin; |
43972 | 109 |
import org.graalvm.compiler.word.WordTypes; |
49873 | 110 |
import jdk.internal.vm.compiler.word.LocationIdentity; |
43972 | 111 |
|
112 |
import jdk.vm.ci.code.CodeUtil; |
|
58877 | 113 |
import jdk.vm.ci.code.TargetDescription; |
57537 | 114 |
import jdk.vm.ci.hotspot.VMIntrinsicMethod; |
43972 | 115 |
import jdk.vm.ci.meta.ConstantReflectionProvider; |
116 |
import jdk.vm.ci.meta.DeoptimizationAction; |
|
117 |
import jdk.vm.ci.meta.JavaKind; |
|
118 |
import jdk.vm.ci.meta.MetaAccessProvider; |
|
119 |
import jdk.vm.ci.meta.ResolvedJavaMethod; |
|
59095 | 120 |
import jdk.vm.ci.services.Services; |
47084 | 121 |
import sun.misc.Unsafe; |
43972 | 122 |
|
123 |
/** |
|
124 |
* Defines the {@link Plugins} used when running on HotSpot. |
|
125 |
*/ |
|
126 |
public class HotSpotGraphBuilderPlugins { |
|
127 |
||
128 |
/** |
|
129 |
* Creates a {@link Plugins} object that should be used when running on HotSpot. |
|
130 |
* |
|
131 |
* @param constantReflection |
|
132 |
* @param snippetReflection |
|
133 |
* @param foreignCalls |
|
54601 | 134 |
* @param options |
58877 | 135 |
* @param target |
43972 | 136 |
*/ |
58299 | 137 |
public static Plugins create(HotSpotGraalRuntimeProvider graalRuntime, |
138 |
CompilerConfiguration compilerConfiguration, |
|
139 |
GraalHotSpotVMConfig config, |
|
140 |
HotSpotWordTypes wordTypes, |
|
141 |
MetaAccessProvider metaAccess, |
|
142 |
ConstantReflectionProvider constantReflection, |
|
143 |
SnippetReflectionProvider snippetReflection, |
|
144 |
ForeignCallsProvider foreignCalls, |
|
145 |
ReplacementsImpl replacements, |
|
58877 | 146 |
OptionValues options, TargetDescription target) { |
58299 | 147 |
InvocationPlugins invocationPlugins = new HotSpotInvocationPlugins(graalRuntime, config, compilerConfiguration); |
43972 | 148 |
|
149 |
Plugins plugins = new Plugins(invocationPlugins); |
|
58877 | 150 |
NodeIntrinsificationProvider nodeIntrinsificationProvider = new NodeIntrinsificationProvider(metaAccess, snippetReflection, foreignCalls, wordTypes, target); |
43972 | 151 |
HotSpotWordOperationPlugin wordOperationPlugin = new HotSpotWordOperationPlugin(snippetReflection, wordTypes); |
53425
312880c38a7f
8215375: [Graal] jck:vm/jvmti/Exception/excp001/excp00101 fails in Graal as JIT mode and -Xcomp mode
dnsimon
parents:
52956
diff
changeset
|
152 |
HotSpotNodePlugin nodePlugin = new HotSpotNodePlugin(wordOperationPlugin, config, wordTypes); |
43972 | 153 |
|
154 |
plugins.appendTypePlugin(nodePlugin); |
|
155 |
plugins.appendNodePlugin(nodePlugin); |
|
47667 | 156 |
if (!GeneratePIC.getValue(options)) { |
157 |
plugins.appendNodePlugin(new MethodHandlePlugin(constantReflection.getMethodHandleAccess(), true)); |
|
43972 | 158 |
} |
159 |
plugins.appendInlineInvokePlugin(replacements); |
|
46344 | 160 |
if (InlineDuringParsing.getValue(options)) { |
43972 | 161 |
plugins.appendInlineInvokePlugin(new InlineDuringParsingPlugin()); |
162 |
} |
|
163 |
||
46344 | 164 |
if (GeneratePIC.getValue(options)) { |
58299 | 165 |
plugins.setClassInitializationPlugin(new HotSpotAOTClassInitializationPlugin()); |
46344 | 166 |
if (TieredAOT.getValue(options)) { |
43972 | 167 |
plugins.setProfilingPlugin(new HotSpotAOTProfilingPlugin()); |
168 |
} |
|
58299 | 169 |
} else { |
170 |
if (config.instanceKlassInitThreadOffset != -1) { |
|
171 |
plugins.setClassInitializationPlugin(new HotSpotJITClassInitializationPlugin()); |
|
172 |
} |
|
43972 | 173 |
} |
174 |
||
175 |
invocationPlugins.defer(new Runnable() { |
|
176 |
||
177 |
@Override |
|
178 |
public void run() { |
|
58877 | 179 |
registerObjectPlugins(invocationPlugins, options, config, replacements); |
180 |
registerClassPlugins(plugins, config, replacements); |
|
43972 | 181 |
registerSystemPlugins(invocationPlugins, foreignCalls); |
58877 | 182 |
registerThreadPlugins(invocationPlugins, metaAccess, wordTypes, config, replacements); |
47667 | 183 |
if (!GeneratePIC.getValue(options)) { |
184 |
registerCallSitePlugins(invocationPlugins); |
|
185 |
} |
|
58877 | 186 |
registerReflectionPlugins(invocationPlugins, replacements); |
187 |
registerConstantPoolPlugins(invocationPlugins, wordTypes, config, replacements); |
|
188 |
registerAESPlugins(invocationPlugins, config, replacements); |
|
189 |
registerCRC32Plugins(invocationPlugins, config, replacements); |
|
190 |
registerCRC32CPlugins(invocationPlugins, config, replacements); |
|
191 |
registerBigIntegerPlugins(invocationPlugins, config, replacements); |
|
192 |
registerSHAPlugins(invocationPlugins, config, replacements); |
|
54084 | 193 |
registerGHASHPlugins(invocationPlugins, config, metaAccess, foreignCalls); |
58877 | 194 |
registerCounterModePlugins(invocationPlugins, config, replacements); |
54601 | 195 |
registerBase64Plugins(invocationPlugins, config, metaAccess, foreignCalls); |
58877 | 196 |
registerUnsafePlugins(invocationPlugins, config, replacements); |
197 |
StandardGraphBuilderPlugins.registerInvocationPlugins(metaAccess, snippetReflection, invocationPlugins, replacements, true, false); |
|
198 |
registerArrayPlugins(invocationPlugins, replacements); |
|
199 |
registerStringPlugins(invocationPlugins, replacements); |
|
200 |
registerArraysSupportPlugins(invocationPlugins, config, replacements); |
|
43972 | 201 |
|
202 |
for (NodeIntrinsicPluginFactory factory : GraalServices.load(NodeIntrinsicPluginFactory.class)) { |
|
203 |
factory.registerPlugins(invocationPlugins, nodeIntrinsificationProvider); |
|
204 |
} |
|
205 |
} |
|
206 |
}); |
|
207 |
return plugins; |
|
208 |
} |
|
209 |
||
58877 | 210 |
private static void registerObjectPlugins(InvocationPlugins plugins, OptionValues options, GraalHotSpotVMConfig config, Replacements replacements) { |
211 |
Registration r = new Registration(plugins, Object.class, replacements); |
|
46344 | 212 |
if (!GeneratePIC.getValue(options)) { |
43972 | 213 |
// FIXME: clone() requires speculation and requires a fix in here (to check that |
214 |
// b.getAssumptions() != null), and in ReplacementImpl.getSubstitution() where there is |
|
215 |
// an instantiation of IntrinsicGraphBuilder using a constructor that sets |
|
216 |
// AllowAssumptions to YES automatically. The former has to inherit the assumptions |
|
217 |
// settings from the root compile instead. So, for now, I'm disabling it for |
|
218 |
// GeneratePIC. |
|
219 |
r.register1("clone", Receiver.class, new InvocationPlugin() { |
|
220 |
@Override |
|
221 |
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver) { |
|
222 |
ValueNode object = receiver.get(); |
|
223 |
b.addPush(JavaKind.Object, new ObjectCloneNode(b.getInvokeKind(), targetMethod, b.bci(), b.getInvokeReturnStamp(b.getAssumptions()), object)); |
|
224 |
return true; |
|
225 |
} |
|
226 |
||
227 |
@Override |
|
228 |
public boolean inlineOnly() { |
|
229 |
return true; |
|
230 |
} |
|
231 |
}); |
|
232 |
} |
|
233 |
r.registerMethodSubstitution(ObjectSubstitutions.class, "hashCode", Receiver.class); |
|
49873 | 234 |
if (config.inlineNotify()) { |
235 |
r.registerMethodSubstitution(ObjectSubstitutions.class, "notify", Receiver.class); |
|
236 |
} |
|
237 |
if (config.inlineNotifyAll()) { |
|
238 |
r.registerMethodSubstitution(ObjectSubstitutions.class, "notifyAll", Receiver.class); |
|
239 |
} |
|
43972 | 240 |
} |
241 |
||
58877 | 242 |
private static void registerClassPlugins(Plugins plugins, GraalHotSpotVMConfig config, Replacements replacements) { |
243 |
Registration r = new Registration(plugins.getInvocationPlugins(), Class.class, replacements); |
|
43972 | 244 |
|
245 |
r.registerMethodSubstitution(HotSpotClassSubstitutions.class, "getModifiers", Receiver.class); |
|
246 |
r.registerMethodSubstitution(HotSpotClassSubstitutions.class, "isInterface", Receiver.class); |
|
247 |
r.registerMethodSubstitution(HotSpotClassSubstitutions.class, "isArray", Receiver.class); |
|
248 |
r.registerMethodSubstitution(HotSpotClassSubstitutions.class, "isPrimitive", Receiver.class); |
|
249 |
r.registerMethodSubstitution(HotSpotClassSubstitutions.class, "getSuperclass", Receiver.class); |
|
250 |
||
251 |
if (config.getFieldOffset("ArrayKlass::_component_mirror", Integer.class, "oop", Integer.MAX_VALUE) != Integer.MAX_VALUE) { |
|
252 |
r.registerMethodSubstitution(HotSpotClassSubstitutions.class, "getComponentType", Receiver.class); |
|
253 |
} |
|
254 |
} |
|
255 |
||
256 |
private static void registerCallSitePlugins(InvocationPlugins plugins) { |
|
257 |
InvocationPlugin plugin = new InvocationPlugin() { |
|
258 |
@Override |
|
259 |
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver) { |
|
260 |
ValueNode callSite = receiver.get(); |
|
58533 | 261 |
ValueNode folded = CallSiteTargetNode.tryFold(GraphUtil.originalValue(callSite, true), b.getMetaAccess(), b.getAssumptions()); |
43972 | 262 |
if (folded != null) { |
263 |
b.addPush(JavaKind.Object, folded); |
|
264 |
} else { |
|
265 |
b.addPush(JavaKind.Object, new CallSiteTargetNode(b.getInvokeKind(), targetMethod, b.bci(), b.getInvokeReturnStamp(b.getAssumptions()), callSite)); |
|
266 |
} |
|
267 |
return true; |
|
268 |
} |
|
269 |
||
270 |
@Override |
|
271 |
public boolean inlineOnly() { |
|
272 |
return true; |
|
273 |
} |
|
274 |
}; |
|
275 |
plugins.register(plugin, ConstantCallSite.class, "getTarget", Receiver.class); |
|
276 |
plugins.register(plugin, MutableCallSite.class, "getTarget", Receiver.class); |
|
277 |
plugins.register(plugin, VolatileCallSite.class, "getTarget", Receiver.class); |
|
278 |
} |
|
279 |
||
58877 | 280 |
private static void registerReflectionPlugins(InvocationPlugins plugins, Replacements replacements) { |
281 |
Registration r = new Registration(plugins, reflectionClass, replacements); |
|
43972 | 282 |
r.register0("getCallerClass", new InvocationPlugin() { |
283 |
@Override |
|
284 |
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver) { |
|
285 |
b.addPush(JavaKind.Object, new ReflectionGetCallerClassNode(b.getInvokeKind(), targetMethod, b.bci(), b.getInvokeReturnStamp(b.getAssumptions()))); |
|
286 |
return true; |
|
287 |
} |
|
288 |
||
289 |
@Override |
|
290 |
public boolean inlineOnly() { |
|
291 |
return true; |
|
292 |
} |
|
293 |
}); |
|
294 |
r.registerMethodSubstitution(ReflectionSubstitutions.class, "getClassAccessFlags", Class.class); |
|
295 |
} |
|
296 |
||
58877 | 297 |
private static void registerUnsafePlugins(InvocationPlugins plugins, GraalHotSpotVMConfig config, Replacements replacements) { |
47084 | 298 |
Registration r; |
55509 | 299 |
if (JavaVersionUtil.JAVA_SPEC <= 8) { |
58877 | 300 |
r = new Registration(plugins, Unsafe.class, replacements); |
47084 | 301 |
} else { |
58877 | 302 |
r = new Registration(plugins, "jdk.internal.misc.Unsafe", replacements); |
47084 | 303 |
} |
55674
ff76baab1c90
8227068: [Graal] MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents:
55509
diff
changeset
|
304 |
String substituteMethodName = config.doingUnsafeAccessOffset != Integer.MAX_VALUE ? "copyMemoryGuarded" : "copyMemory"; |
ff76baab1c90
8227068: [Graal] MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents:
55509
diff
changeset
|
305 |
r.registerMethodSubstitution(HotSpotUnsafeSubstitutions.class, HotSpotUnsafeSubstitutions.copyMemoryName, substituteMethodName, Receiver.class, Object.class, long.class, Object.class, |
ff76baab1c90
8227068: [Graal] MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents:
55509
diff
changeset
|
306 |
long.class, long.class); |
47084 | 307 |
} |
308 |
||
43972 | 309 |
private static final LocationIdentity INSTANCE_KLASS_CONSTANTS = NamedLocationIdentity.immutable("InstanceKlass::_constants"); |
310 |
private static final LocationIdentity CONSTANT_POOL_LENGTH = NamedLocationIdentity.immutable("ConstantPool::_length"); |
|
311 |
||
312 |
/** |
|
313 |
* Emits a node to get the metaspace {@code ConstantPool} pointer given the value of the |
|
314 |
* {@code constantPoolOop} field in a ConstantPool value. |
|
315 |
* |
|
316 |
* @param constantPoolOop value of the {@code constantPoolOop} field in a ConstantPool value |
|
317 |
* @return a node representing the metaspace {@code ConstantPool} pointer associated with |
|
318 |
* {@code constantPoolOop} |
|
319 |
*/ |
|
320 |
private static ValueNode getMetaspaceConstantPool(GraphBuilderContext b, ValueNode constantPoolOop, WordTypes wordTypes, GraalHotSpotVMConfig config) { |
|
321 |
// ConstantPool.constantPoolOop is in fact the holder class. |
|
46371 | 322 |
ValueNode value = b.nullCheckedValue(constantPoolOop, DeoptimizationAction.None); |
323 |
ValueNode klass = b.add(ClassGetHubNode.create(value, b.getMetaAccess(), b.getConstantReflection(), false)); |
|
43972 | 324 |
|
325 |
boolean notCompressible = false; |
|
326 |
AddressNode constantsAddress = b.add(new OffsetAddressNode(klass, b.add(ConstantNode.forLong(config.instanceKlassConstantsOffset)))); |
|
327 |
return WordOperationPlugin.readOp(b, wordTypes.getWordKind(), constantsAddress, INSTANCE_KLASS_CONSTANTS, BarrierType.NONE, notCompressible); |
|
328 |
} |
|
329 |
||
330 |
/** |
|
331 |
* Emits a node representing an element in a metaspace {@code ConstantPool}. |
|
332 |
* |
|
333 |
* @param constantPoolOop value of the {@code constantPoolOop} field in a ConstantPool value |
|
334 |
*/ |
|
335 |
private static boolean readMetaspaceConstantPoolElement(GraphBuilderContext b, ValueNode constantPoolOop, ValueNode index, JavaKind elementKind, WordTypes wordTypes, GraalHotSpotVMConfig config) { |
|
336 |
ValueNode constants = getMetaspaceConstantPool(b, constantPoolOop, wordTypes, config); |
|
337 |
int shift = CodeUtil.log2(wordTypes.getWordKind().getByteCount()); |
|
48190 | 338 |
ValueNode scaledIndex = b.add(new LeftShiftNode(IntegerConvertNode.convert(index, StampFactory.forKind(JavaKind.Long), NodeView.DEFAULT), b.add(ConstantNode.forInt(shift)))); |
47798 | 339 |
ValueNode offset = b.add(new AddNode(scaledIndex, b.add(ConstantNode.forLong(config.constantPoolSize)))); |
43972 | 340 |
AddressNode elementAddress = b.add(new OffsetAddressNode(constants, offset)); |
341 |
boolean notCompressible = false; |
|
342 |
ValueNode elementValue = WordOperationPlugin.readOp(b, elementKind, elementAddress, NamedLocationIdentity.getArrayLocation(elementKind), BarrierType.NONE, notCompressible); |
|
343 |
b.addPush(elementKind, elementValue); |
|
344 |
return true; |
|
345 |
} |
|
346 |
||
58877 | 347 |
private static void registerConstantPoolPlugins(InvocationPlugins plugins, WordTypes wordTypes, GraalHotSpotVMConfig config, Replacements replacements) { |
348 |
Registration r = new Registration(plugins, constantPoolClass, replacements); |
|
43972 | 349 |
|
350 |
r.register2("getSize0", Receiver.class, Object.class, new InvocationPlugin() { |
|
351 |
@Override |
|
352 |
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode constantPoolOop) { |
|
353 |
boolean notCompressible = false; |
|
354 |
ValueNode constants = getMetaspaceConstantPool(b, constantPoolOop, wordTypes, config); |
|
355 |
AddressNode lengthAddress = b.add(new OffsetAddressNode(constants, b.add(ConstantNode.forLong(config.constantPoolLengthOffset)))); |
|
356 |
ValueNode length = WordOperationPlugin.readOp(b, JavaKind.Int, lengthAddress, CONSTANT_POOL_LENGTH, BarrierType.NONE, notCompressible); |
|
357 |
b.addPush(JavaKind.Int, length); |
|
358 |
return true; |
|
359 |
} |
|
360 |
}); |
|
361 |
||
362 |
r.register3("getIntAt0", Receiver.class, Object.class, int.class, new InvocationPlugin() { |
|
363 |
@Override |
|
364 |
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode constantPoolOop, ValueNode index) { |
|
365 |
return readMetaspaceConstantPoolElement(b, constantPoolOop, index, JavaKind.Int, wordTypes, config); |
|
366 |
} |
|
367 |
}); |
|
368 |
r.register3("getLongAt0", Receiver.class, Object.class, int.class, new InvocationPlugin() { |
|
369 |
@Override |
|
370 |
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode constantPoolOop, ValueNode index) { |
|
371 |
return readMetaspaceConstantPoolElement(b, constantPoolOop, index, JavaKind.Long, wordTypes, config); |
|
372 |
} |
|
373 |
}); |
|
374 |
r.register3("getFloatAt0", Receiver.class, Object.class, int.class, new InvocationPlugin() { |
|
375 |
@Override |
|
376 |
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode constantPoolOop, ValueNode index) { |
|
377 |
return readMetaspaceConstantPoolElement(b, constantPoolOop, index, JavaKind.Float, wordTypes, config); |
|
378 |
} |
|
379 |
}); |
|
380 |
r.register3("getDoubleAt0", Receiver.class, Object.class, int.class, new InvocationPlugin() { |
|
381 |
@Override |
|
382 |
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode constantPoolOop, ValueNode index) { |
|
383 |
return readMetaspaceConstantPoolElement(b, constantPoolOop, index, JavaKind.Double, wordTypes, config); |
|
384 |
} |
|
385 |
}); |
|
386 |
} |
|
387 |
||
388 |
private static void registerSystemPlugins(InvocationPlugins plugins, ForeignCallsProvider foreignCalls) { |
|
389 |
Registration r = new Registration(plugins, System.class); |
|
390 |
r.register0("currentTimeMillis", new ForeignCallPlugin(foreignCalls, HotSpotHostForeignCallsProvider.JAVA_TIME_MILLIS)); |
|
391 |
r.register0("nanoTime", new ForeignCallPlugin(foreignCalls, HotSpotHostForeignCallsProvider.JAVA_TIME_NANOS)); |
|
392 |
r.register1("identityHashCode", Object.class, new InvocationPlugin() { |
|
393 |
@Override |
|
394 |
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode object) { |
|
395 |
b.addPush(JavaKind.Int, new IdentityHashCodeNode(object)); |
|
396 |
return true; |
|
397 |
} |
|
398 |
||
399 |
@Override |
|
400 |
public boolean inlineOnly() { |
|
401 |
return true; |
|
402 |
} |
|
403 |
}); |
|
404 |
r.register5("arraycopy", Object.class, int.class, Object.class, int.class, int.class, new InvocationPlugin() { |
|
405 |
@Override |
|
406 |
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode src, ValueNode srcPos, ValueNode dst, ValueNode dstPos, ValueNode length) { |
|
407 |
b.add(new ArrayCopyNode(b.bci(), src, srcPos, dst, dstPos, length)); |
|
408 |
return true; |
|
409 |
} |
|
410 |
||
411 |
@Override |
|
412 |
public boolean inlineOnly() { |
|
413 |
return true; |
|
414 |
} |
|
415 |
}); |
|
416 |
} |
|
417 |
||
58877 | 418 |
private static void registerArrayPlugins(InvocationPlugins plugins, Replacements replacements) { |
419 |
Registration r = new Registration(plugins, Array.class, replacements); |
|
48861 | 420 |
r.setAllowOverwrite(true); |
421 |
r.registerMethodSubstitution(HotSpotArraySubstitutions.class, "newInstance", Class.class, int.class); |
|
422 |
} |
|
423 |
||
58877 | 424 |
private static void registerStringPlugins(InvocationPlugins plugins, Replacements replacements) { |
55509 | 425 |
if (JavaVersionUtil.JAVA_SPEC > 8) { |
58877 | 426 |
final Registration utf16r = new Registration(plugins, "java.lang.StringUTF16", replacements); |
54084 | 427 |
utf16r.registerMethodSubstitution(StringUTF16Substitutions.class, "toBytes", char[].class, int.class, int.class); |
428 |
utf16r.registerMethodSubstitution(StringUTF16Substitutions.class, "getChars", byte[].class, int.class, int.class, char[].class, int.class); |
|
429 |
} |
|
430 |
} |
|
431 |
||
58877 | 432 |
private static void registerThreadPlugins(InvocationPlugins plugins, MetaAccessProvider metaAccess, WordTypes wordTypes, GraalHotSpotVMConfig config, Replacements replacements) { |
433 |
Registration r = new Registration(plugins, Thread.class, replacements); |
|
43972 | 434 |
r.register0("currentThread", new InvocationPlugin() { |
435 |
@Override |
|
436 |
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver) { |
|
437 |
CurrentJavaThreadNode thread = b.add(new CurrentJavaThreadNode(wordTypes.getWordKind())); |
|
438 |
ValueNode offset = b.add(ConstantNode.forLong(config.threadObjectOffset)); |
|
439 |
AddressNode address = b.add(new OffsetAddressNode(thread, offset)); |
|
48861 | 440 |
// JavaThread::_threadObj is never compressed |
441 |
ObjectStamp stamp = StampFactory.objectNonNull(TypeReference.create(b.getAssumptions(), metaAccess.lookupJavaType(Thread.class))); |
|
442 |
b.addPush(JavaKind.Object, new ReadNode(address, JAVA_THREAD_THREAD_OBJECT_LOCATION, stamp, BarrierType.NONE)); |
|
43972 | 443 |
return true; |
444 |
} |
|
445 |
}); |
|
446 |
||
58901
2700c409ff10
8229516: Thread.isInterrupted() always returns false after thread termination
dholmes
parents:
58877
diff
changeset
|
447 |
if (config.osThreadInterruptedOffset != Integer.MAX_VALUE) { |
2700c409ff10
8229516: Thread.isInterrupted() always returns false after thread termination
dholmes
parents:
58877
diff
changeset
|
448 |
r.registerMethodSubstitution(ThreadSubstitutions.class, "isInterrupted", Receiver.class, boolean.class); |
2700c409ff10
8229516: Thread.isInterrupted() always returns false after thread termination
dholmes
parents:
58877
diff
changeset
|
449 |
} |
2700c409ff10
8229516: Thread.isInterrupted() always returns false after thread termination
dholmes
parents:
58877
diff
changeset
|
450 |
|
43972 | 451 |
} |
452 |
||
453 |
public static final String reflectionClass; |
|
454 |
public static final String constantPoolClass; |
|
455 |
||
456 |
static { |
|
55509 | 457 |
if (JavaVersionUtil.JAVA_SPEC <= 8) { |
43972 | 458 |
reflectionClass = "sun.reflect.Reflection"; |
459 |
constantPoolClass = "sun.reflect.ConstantPool"; |
|
460 |
} else { |
|
461 |
reflectionClass = "jdk.internal.reflect.Reflection"; |
|
462 |
constantPoolClass = "jdk.internal.reflect.ConstantPool"; |
|
463 |
} |
|
464 |
} |
|
465 |
||
58877 | 466 |
public static String lookupIntrinsicName(GraalHotSpotVMConfig config, String className, String name1, String name2) { |
59095 | 467 |
return selectIntrinsicName(config, className, name1, name2).getLeft(); |
468 |
} |
|
469 |
||
470 |
/** |
|
471 |
* Returns a pair of Strings where the left one represents the matched intrinsic name and the |
|
472 |
* right one represents the mismatched intrinsic name. |
|
473 |
*/ |
|
474 |
public static Pair<String, String> selectIntrinsicName(GraalHotSpotVMConfig config, String className, String name1, String name2) { |
|
58877 | 475 |
boolean foundName1 = false; |
476 |
boolean foundName2 = false; |
|
57537 | 477 |
for (VMIntrinsicMethod intrinsic : config.getStore().getIntrinsics()) { |
58877 | 478 |
if (className.equals(intrinsic.declaringClass)) { |
479 |
if (name1.equals(intrinsic.name)) { |
|
480 |
foundName1 = true; |
|
481 |
} else if (name2.equals(intrinsic.name)) { |
|
482 |
foundName2 = true; |
|
483 |
} |
|
484 |
} |
|
485 |
} |
|
59095 | 486 |
if (foundName1 && !foundName2) { |
487 |
return Pair.create(name1, name2); |
|
488 |
} else if (foundName2 && !foundName1) { |
|
489 |
return Pair.create(name2, name1); |
|
58877 | 490 |
} |
491 |
throw GraalError.shouldNotReachHere(); |
|
492 |
} |
|
493 |
||
494 |
public static boolean isIntrinsicName(GraalHotSpotVMConfig config, String className, String name) { |
|
495 |
for (VMIntrinsicMethod intrinsic : config.getStore().getIntrinsics()) { |
|
496 |
if (className.equals(intrinsic.declaringClass)) { |
|
497 |
if (name.equals(intrinsic.name)) { |
|
57537 | 498 |
return true; |
499 |
} |
|
500 |
} |
|
501 |
} |
|
58877 | 502 |
return false; |
57537 | 503 |
} |
504 |
||
58877 | 505 |
private static void registerAESPlugins(InvocationPlugins plugins, GraalHotSpotVMConfig config, Replacements replacements) { |
43972 | 506 |
if (config.useAESIntrinsics) { |
507 |
assert config.aescryptEncryptBlockStub != 0L; |
|
508 |
assert config.aescryptDecryptBlockStub != 0L; |
|
509 |
assert config.cipherBlockChainingEncryptAESCryptStub != 0L; |
|
510 |
assert config.cipherBlockChainingDecryptAESCryptStub != 0L; |
|
511 |
String arch = config.osArch; |
|
512 |
String decryptSuffix = arch.equals("sparc") ? "WithOriginalKey" : ""; |
|
57537 | 513 |
|
58877 | 514 |
Registration r = new Registration(plugins, "com.sun.crypto.provider.CipherBlockChaining", replacements); |
57537 | 515 |
|
59095 | 516 |
Pair<String, String> cbcEncryptName = selectIntrinsicName(config, "com/sun/crypto/provider/CipherBlockChaining", "implEncrypt", "encrypt"); |
517 |
registerAndCheckMismatch(r, CipherBlockChainingSubstitutions.class, cbcEncryptName, Receiver.class, byte[].class, int.class, int.class, |
|
518 |
byte[].class, int.class); |
|
519 |
||
520 |
Pair<String, String> cbcDecryptName = selectIntrinsicName(config, "com/sun/crypto/provider/CipherBlockChaining", "implDecrypt", "decrypt"); |
|
521 |
registerAndCheckMismatch(r, CipherBlockChainingSubstitutions.class, cbcDecryptName, cbcDecryptName.getLeft() + decryptSuffix, Receiver.class, byte[].class, int.class, int.class, |
|
522 |
byte[].class, int.class); |
|
58877 | 523 |
|
524 |
r = new Registration(plugins, "com.sun.crypto.provider.AESCrypt", replacements); |
|
59095 | 525 |
|
526 |
Pair<String, String> aesEncryptName = selectIntrinsicName(config, "com/sun/crypto/provider/AESCrypt", "implEncryptBlock", "encryptBlock"); |
|
527 |
registerAndCheckMismatch(r, AESCryptSubstitutions.class, aesEncryptName, Receiver.class, byte[].class, int.class, byte[].class, int.class); |
|
528 |
||
529 |
Pair<String, String> aesDecryptName = selectIntrinsicName(config, "com/sun/crypto/provider/AESCrypt", "implDecryptBlock", "decryptBlock"); |
|
530 |
registerAndCheckMismatch(r, AESCryptSubstitutions.class, aesDecryptName, aesDecryptName.getLeft() + decryptSuffix, Receiver.class, byte[].class, int.class, byte[].class, int.class); |
|
531 |
} |
|
532 |
} |
|
533 |
||
534 |
private static void registerAndCheckMismatch(Registration r, Class<?> substitutionClass, Pair<String, String> intrinsicNames, Type... argumentTypes) { |
|
535 |
try { |
|
536 |
r.registerMethodSubstitution(substitutionClass, intrinsicNames.getLeft(), argumentTypes); |
|
537 |
} catch (NoSuchMethodError e) { |
|
538 |
throw new GraalError(e, "Found method named '%s' instead of '%s' in class '%s'. This is most likely because the JVMCI JDK in %s was built on an incompatible base JDK.", |
|
539 |
intrinsicNames.getRight(), intrinsicNames.getLeft(), r.getDeclaringType().getTypeName(), Services.getSavedProperties().get("java.home")); |
|
540 |
} |
|
541 |
} |
|
542 |
||
543 |
private static void registerAndCheckMismatch(Registration r, Class<?> substitutionClass, Pair<String, String> intrinsicNames, String substituteName, Type... argumentTypes) { |
|
544 |
try { |
|
545 |
r.registerMethodSubstitution(substitutionClass, intrinsicNames.getLeft(), substituteName, argumentTypes); |
|
546 |
} catch (NoSuchMethodError e) { |
|
547 |
throw new GraalError(e, "Found method named '%s' instead of '%s' in class '%s'. This is most likely because the JVMCI JDK in %s was built on an incompatible base JDK.", |
|
548 |
intrinsicNames.getRight(), intrinsicNames.getLeft(), r.getDeclaringType().getTypeName(), Services.getSavedProperties().get("java.home")); |
|
43972 | 549 |
} |
550 |
} |
|
551 |
||
58877 | 552 |
private static void registerBigIntegerPlugins(InvocationPlugins plugins, GraalHotSpotVMConfig config, Replacements replacements) { |
553 |
Registration r = new Registration(plugins, BigInteger.class, replacements); |
|
554 |
assert !config.useMultiplyToLenIntrinsic() || config.multiplyToLen != 0L; |
|
555 |
if (JavaVersionUtil.JAVA_SPEC <= 8) { |
|
556 |
r.registerConditionalMethodSubstitution(config.useMultiplyToLenIntrinsic(), BigIntegerSubstitutions.class, "multiplyToLen", "multiplyToLenStatic", int[].class, int.class, int[].class, |
|
557 |
int.class, int[].class); |
|
558 |
} else { |
|
559 |
r.registerConditionalMethodSubstitution(config.useMultiplyToLenIntrinsic(), BigIntegerSubstitutions.class, "implMultiplyToLen", "multiplyToLenStatic", int[].class, int.class, int[].class, |
|
560 |
int.class, int[].class); |
|
43972 | 561 |
} |
58877 | 562 |
r.registerConditionalMethodSubstitution(config.useMulAddIntrinsic(), BigIntegerSubstitutions.class, "implMulAdd", int[].class, int[].class, int.class, int.class, int.class); |
563 |
r.registerConditionalMethodSubstitution(config.useMontgomeryMultiplyIntrinsic(), BigIntegerSubstitutions.class, "implMontgomeryMultiply", int[].class, int[].class, int[].class, int.class, |
|
564 |
long.class, int[].class); |
|
565 |
r.registerConditionalMethodSubstitution(config.useMontgomerySquareIntrinsic(), BigIntegerSubstitutions.class, "implMontgomerySquare", int[].class, int[].class, int.class, long.class, |
|
566 |
int[].class); |
|
567 |
r.registerConditionalMethodSubstitution(config.useSquareToLenIntrinsic(), BigIntegerSubstitutions.class, "implSquareToLen", int[].class, int.class, int[].class, int.class); |
|
43972 | 568 |
} |
569 |
||
58877 | 570 |
private static void registerSHAPlugins(InvocationPlugins plugins, GraalHotSpotVMConfig config, Replacements replacements) { |
54084 | 571 |
boolean useSha1 = config.useSHA1Intrinsics(); |
572 |
boolean useSha256 = config.useSHA256Intrinsics(); |
|
573 |
boolean useSha512 = config.useSHA512Intrinsics(); |
|
574 |
||
58877 | 575 |
if (isIntrinsicName(config, "sun/security/provider/DigestBase", "implCompressMultiBlock0") && (useSha1 || useSha256 || useSha512)) { |
576 |
Registration r = new Registration(plugins, "sun.security.provider.DigestBase", replacements); |
|
54084 | 577 |
r.registerMethodSubstitution(DigestBaseSubstitutions.class, "implCompressMultiBlock0", Receiver.class, byte[].class, int.class, int.class); |
578 |
} |
|
579 |
||
59095 | 580 |
Pair<String, String> implCompressName = selectIntrinsicName(config, "sun/security/provider/SHA", "implCompress", "implCompress0"); |
54084 | 581 |
if (useSha1) { |
43972 | 582 |
assert config.sha1ImplCompress != 0L; |
58877 | 583 |
Registration r = new Registration(plugins, "sun.security.provider.SHA", replacements); |
59095 | 584 |
registerAndCheckMismatch(r, SHASubstitutions.class, implCompressName, "implCompress0", Receiver.class, byte[].class, int.class); |
43972 | 585 |
} |
54084 | 586 |
if (useSha256) { |
43972 | 587 |
assert config.sha256ImplCompress != 0L; |
58877 | 588 |
Registration r = new Registration(plugins, "sun.security.provider.SHA2", replacements); |
59095 | 589 |
registerAndCheckMismatch(r, SHA2Substitutions.class, implCompressName, "implCompress0", Receiver.class, byte[].class, int.class); |
43972 | 590 |
} |
54084 | 591 |
if (useSha512) { |
43972 | 592 |
assert config.sha512ImplCompress != 0L; |
58877 | 593 |
Registration r = new Registration(plugins, "sun.security.provider.SHA5", replacements); |
59095 | 594 |
registerAndCheckMismatch(r, SHA5Substitutions.class, implCompressName, "implCompress0", Receiver.class, byte[].class, int.class); |
43972 | 595 |
} |
596 |
} |
|
597 |
||
54084 | 598 |
private static void registerGHASHPlugins(InvocationPlugins plugins, GraalHotSpotVMConfig config, MetaAccessProvider metaAccess, ForeignCallsProvider foreignCalls) { |
599 |
if (config.useGHASHIntrinsics()) { |
|
600 |
assert config.ghashProcessBlocks != 0L; |
|
601 |
Registration r = new Registration(plugins, "com.sun.crypto.provider.GHASH"); |
|
602 |
r.register5("processBlocks", |
|
603 |
byte[].class, |
|
604 |
int.class, |
|
605 |
int.class, |
|
606 |
long[].class, |
|
607 |
long[].class, |
|
608 |
new InvocationPlugin() { |
|
609 |
@Override |
|
610 |
public boolean apply(GraphBuilderContext b, |
|
611 |
ResolvedJavaMethod targetMethod, |
|
612 |
Receiver receiver, |
|
613 |
ValueNode data, |
|
614 |
ValueNode inOffset, |
|
615 |
ValueNode blocks, |
|
616 |
ValueNode state, |
|
617 |
ValueNode hashSubkey) { |
|
618 |
int longArrayBaseOffset = metaAccess.getArrayBaseOffset(JavaKind.Long); |
|
619 |
int byteArrayBaseOffset = metaAccess.getArrayBaseOffset(JavaKind.Byte); |
|
620 |
ValueNode dataOffset = AddNode.create(ConstantNode.forInt(byteArrayBaseOffset), inOffset, NodeView.DEFAULT); |
|
621 |
ComputeObjectAddressNode dataAddress = b.add(new ComputeObjectAddressNode(data, dataOffset)); |
|
622 |
ComputeObjectAddressNode stateAddress = b.add(new ComputeObjectAddressNode(state, ConstantNode.forInt(longArrayBaseOffset))); |
|
623 |
ComputeObjectAddressNode hashSubkeyAddress = b.add(new ComputeObjectAddressNode(hashSubkey, ConstantNode.forInt(longArrayBaseOffset))); |
|
624 |
b.add(new ForeignCallNode(foreignCalls, GHASH_PROCESS_BLOCKS, stateAddress, hashSubkeyAddress, dataAddress, blocks)); |
|
625 |
return true; |
|
626 |
} |
|
627 |
}); |
|
628 |
} |
|
629 |
} |
|
630 |
||
58877 | 631 |
private static void registerCounterModePlugins(InvocationPlugins plugins, GraalHotSpotVMConfig config, Replacements replacements) { |
632 |
if (JavaVersionUtil.JAVA_SPEC > 8) { |
|
633 |
assert !config.useAESCTRIntrinsics || config.counterModeAESCrypt != 0L; |
|
634 |
Registration r = new Registration(plugins, "com.sun.crypto.provider.CounterMode", replacements); |
|
635 |
r.registerConditionalMethodSubstitution(config.useAESCTRIntrinsics, CounterModeSubstitutions.class, "implCrypt", Receiver.class, byte[].class, int.class, int.class, byte[].class, |
|
636 |
int.class); |
|
54084 | 637 |
} |
638 |
} |
|
639 |
||
54601 | 640 |
private static void registerBase64Plugins(InvocationPlugins plugins, GraalHotSpotVMConfig config, MetaAccessProvider metaAccess, ForeignCallsProvider foreignCalls) { |
641 |
if (config.useBase64Intrinsics()) { |
|
642 |
Registration r = new Registration(plugins, "java.util.Base64$Encoder"); |
|
643 |
r.register7("encodeBlock", |
|
644 |
Receiver.class, |
|
645 |
byte[].class, |
|
646 |
int.class, |
|
647 |
int.class, |
|
648 |
byte[].class, |
|
649 |
int.class, |
|
650 |
boolean.class, |
|
651 |
new InvocationPlugin() { |
|
652 |
@Override |
|
653 |
public boolean apply(GraphBuilderContext b, |
|
654 |
ResolvedJavaMethod targetMethod, |
|
655 |
Receiver receiver, |
|
656 |
ValueNode src, |
|
657 |
ValueNode sp, |
|
658 |
ValueNode sl, |
|
659 |
ValueNode dst, |
|
660 |
ValueNode dp, |
|
661 |
ValueNode isURL) { |
|
662 |
int byteArrayBaseOffset = metaAccess.getArrayBaseOffset(JavaKind.Byte); |
|
663 |
ComputeObjectAddressNode srcAddress = b.add(new ComputeObjectAddressNode(src, ConstantNode.forInt(byteArrayBaseOffset))); |
|
664 |
ComputeObjectAddressNode dstAddress = b.add(new ComputeObjectAddressNode(dst, ConstantNode.forInt(byteArrayBaseOffset))); |
|
665 |
b.add(new ForeignCallNode(foreignCalls, BASE64_ENCODE_BLOCK, srcAddress, sp, sl, dstAddress, dp, isURL)); |
|
666 |
return true; |
|
667 |
} |
|
668 |
}); |
|
669 |
} |
|
670 |
} |
|
671 |
||
58877 | 672 |
private static void registerCRC32Plugins(InvocationPlugins plugins, GraalHotSpotVMConfig config, Replacements replacements) { |
673 |
Registration r = new Registration(plugins, CRC32.class, replacements); |
|
674 |
r.registerConditionalMethodSubstitution(config.useCRC32Intrinsics, CRC32Substitutions.class, "update", int.class, int.class); |
|
675 |
if (JavaVersionUtil.JAVA_SPEC <= 8) { |
|
676 |
r.registerConditionalMethodSubstitution(config.useCRC32Intrinsics, CRC32Substitutions.class, "updateBytes", int.class, byte[].class, int.class, int.class); |
|
677 |
r.registerConditionalMethodSubstitution(config.useCRC32Intrinsics, CRC32Substitutions.class, "updateByteBuffer", int.class, long.class, int.class, int.class); |
|
678 |
} else { |
|
679 |
r.registerConditionalMethodSubstitution(config.useCRC32Intrinsics, CRC32Substitutions.class, "updateBytes0", int.class, byte[].class, int.class, int.class); |
|
680 |
r.registerConditionalMethodSubstitution(config.useCRC32Intrinsics, CRC32Substitutions.class, "updateByteBuffer0", int.class, long.class, int.class, int.class); |
|
43972 | 681 |
} |
682 |
} |
|
48398 | 683 |
|
58877 | 684 |
private static void registerCRC32CPlugins(InvocationPlugins plugins, GraalHotSpotVMConfig config, Replacements replacements) { |
685 |
if (JavaVersionUtil.JAVA_SPEC > 8) { |
|
686 |
Registration r = new Registration(plugins, "java.util.zip.CRC32C", replacements); |
|
687 |
r.registerConditionalMethodSubstitution(config.useCRC32CIntrinsics, CRC32CSubstitutions.class, "updateBytes", int.class, byte[].class, int.class, int.class); |
|
688 |
r.registerConditionalMethodSubstitution(config.useCRC32CIntrinsics, CRC32CSubstitutions.class, "updateDirectByteBuffer", int.class, long.class, int.class, int.class); |
|
48398 | 689 |
} |
690 |
} |
|
54084 | 691 |
|
58877 | 692 |
private static void registerArraysSupportPlugins(InvocationPlugins plugins, GraalHotSpotVMConfig config, Replacements replacements) { |
693 |
if (JavaVersionUtil.JAVA_SPEC > 8) { |
|
694 |
Registration r = new Registration(plugins, "jdk.internal.util.ArraysSupport", replacements); |
|
695 |
r.registerConditionalMethodSubstitution(config.useVectorizedMismatchIntrinsic, ArraysSupportSubstitutions.class, "vectorizedMismatch", Object.class, long.class, Object.class, long.class, |
|
696 |
int.class, int.class); |
|
54084 | 697 |
} |
698 |
} |
|
43972 | 699 |
} |