423 utf16r.registerMethodSubstitution(StringUTF16Substitutions.class, "toBytes", char[].class, int.class, int.class); 424 utf16r.registerMethodSubstitution(StringUTF16Substitutions.class, "getChars", byte[].class, int.class, int.class, char[].class, int.class); 425 } 426 } 427 428 private static void registerThreadPlugins(InvocationPlugins plugins, MetaAccessProvider metaAccess, WordTypes wordTypes, GraalHotSpotVMConfig config, BytecodeProvider bytecodeProvider) { 429 Registration r = new Registration(plugins, Thread.class, bytecodeProvider); 430 r.register0("currentThread", new InvocationPlugin() { 431 @Override 432 public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver) { 433 CurrentJavaThreadNode thread = b.add(new CurrentJavaThreadNode(wordTypes.getWordKind())); 434 ValueNode offset = b.add(ConstantNode.forLong(config.threadObjectOffset)); 435 AddressNode address = b.add(new OffsetAddressNode(thread, offset)); 436 // JavaThread::_threadObj is never compressed 437 ObjectStamp stamp = StampFactory.objectNonNull(TypeReference.create(b.getAssumptions(), metaAccess.lookupJavaType(Thread.class))); 438 b.addPush(JavaKind.Object, new ReadNode(address, JAVA_THREAD_THREAD_OBJECT_LOCATION, stamp, BarrierType.NONE)); 439 return true; 440 } 441 }); 442 443 r.registerMethodSubstitution(ThreadSubstitutions.class, "isInterrupted", Receiver.class, boolean.class); 444 } 445 446 public static final String aesEncryptName; 447 public static final String aesDecryptName; 448 449 public static final String reflectionClass; 450 public static final String constantPoolClass; 451 452 static { 453 if (JavaVersionUtil.JAVA_SPEC <= 8) { 454 aesEncryptName = "encryptBlock"; 455 aesDecryptName = "decryptBlock"; 456 reflectionClass = "sun.reflect.Reflection"; 457 constantPoolClass = "sun.reflect.ConstantPool"; 458 } else { 459 aesEncryptName = "implEncryptBlock"; 460 aesDecryptName = "implDecryptBlock"; 461 reflectionClass = "jdk.internal.reflect.Reflection"; 462 constantPoolClass = "jdk.internal.reflect.ConstantPool"; 463 } | 423 utf16r.registerMethodSubstitution(StringUTF16Substitutions.class, "toBytes", char[].class, int.class, int.class); 424 utf16r.registerMethodSubstitution(StringUTF16Substitutions.class, "getChars", byte[].class, int.class, int.class, char[].class, int.class); 425 } 426 } 427 428 private static void registerThreadPlugins(InvocationPlugins plugins, MetaAccessProvider metaAccess, WordTypes wordTypes, GraalHotSpotVMConfig config, BytecodeProvider bytecodeProvider) { 429 Registration r = new Registration(plugins, Thread.class, bytecodeProvider); 430 r.register0("currentThread", new InvocationPlugin() { 431 @Override 432 public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver) { 433 CurrentJavaThreadNode thread = b.add(new CurrentJavaThreadNode(wordTypes.getWordKind())); 434 ValueNode offset = b.add(ConstantNode.forLong(config.threadObjectOffset)); 435 AddressNode address = b.add(new OffsetAddressNode(thread, offset)); 436 // JavaThread::_threadObj is never compressed 437 ObjectStamp stamp = StampFactory.objectNonNull(TypeReference.create(b.getAssumptions(), metaAccess.lookupJavaType(Thread.class))); 438 b.addPush(JavaKind.Object, new ReadNode(address, JAVA_THREAD_THREAD_OBJECT_LOCATION, stamp, BarrierType.NONE)); 439 return true; 440 } 441 }); 442 443 if (config.osThreadInterruptedOffset != Integer.MAX_VALUE) { 444 r.registerMethodSubstitution(ThreadSubstitutions.class, "isInterrupted", Receiver.class, boolean.class); 445 } 446 447 } 448 449 public static final String aesEncryptName; 450 public static final String aesDecryptName; 451 452 public static final String reflectionClass; 453 public static final String constantPoolClass; 454 455 static { 456 if (JavaVersionUtil.JAVA_SPEC <= 8) { 457 aesEncryptName = "encryptBlock"; 458 aesDecryptName = "decryptBlock"; 459 reflectionClass = "sun.reflect.Reflection"; 460 constantPoolClass = "sun.reflect.ConstantPool"; 461 } else { 462 aesEncryptName = "implEncryptBlock"; 463 aesDecryptName = "implDecryptBlock"; 464 reflectionClass = "jdk.internal.reflect.Reflection"; 465 constantPoolClass = "jdk.internal.reflect.ConstantPool"; 466 } |