Skip to content
This repository was archived by the owner on Mar 2, 2019. It is now read-only.

Commit c03a501

Browse files
author
iignatyev
committed
8160673: Jittester: investigate bytecode generation hangs during bytecode tests generation
Reviewed-by: iveresov
1 parent 3d7b273 commit c03a501

File tree

1 file changed

+20
-26
lines changed

1 file changed

+20
-26
lines changed

test/hotspot/jtreg/testlibrary/jittester/src/jdk/test/lib/jittester/visitors/ByteCodeVisitor.java

Lines changed: 20 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1011,7 +1011,7 @@ private void emitDup(Type type) {
10111011
@Override
10121012
public byte[] visit(Interface node) {
10131013
String name = node.getName();
1014-
ContextDependedClassWriter classWriter = new ContextDependedClassWriter(context, CLASS_WRITER_FLAGS);
1014+
ContextDependedClassWriter classWriter = new ContextDependedClassWriter(CLASS_WRITER_FLAGS);
10151015
classWriters.put(name, classWriter);
10161016
TypeKlass parentKlass = node.getParentKlass();
10171017
classWriter.visit(Opcodes.V1_8,
@@ -1036,7 +1036,7 @@ public byte[] visit(Klass node) {
10361036
String name = node.getName();
10371037
TypeKlass prevClass = currentClass;
10381038
currentClass = node.getThisKlass();
1039-
ContextDependedClassWriter classWriter = new ContextDependedClassWriter(context, CLASS_WRITER_FLAGS);
1039+
ContextDependedClassWriter classWriter = new ContextDependedClassWriter(CLASS_WRITER_FLAGS);
10401040
classWriters.put(name, classWriter);
10411041
TypeKlass thisClass = node.getThisKlass();
10421042
TypeKlass parentClass = node.getParentKlass();
@@ -1233,7 +1233,7 @@ public byte[] visit(MainKlass node) {
12331233
TypeKlass prevClass = currentClass;
12341234
currentClass = node.getThisKlass();
12351235
String name = node.getName();
1236-
ContextDependedClassWriter mainClassWriter = new ContextDependedClassWriter(context, CLASS_WRITER_FLAGS);
1236+
ContextDependedClassWriter mainClassWriter = new ContextDependedClassWriter(CLASS_WRITER_FLAGS);
12371237
classWriters.put(name, mainClassWriter);
12381238

12391239
TypeKlass thisClass = node.getThisKlass();
@@ -1780,11 +1780,10 @@ private void initArguments(TypeKlass owner, FunctionInfo info) {
17801780
}
17811781
}
17821782

1783-
private static class GeneratedClassesContext extends java.lang.ClassLoader {
1783+
private static class GeneratedClassesContext {
17841784
private final HashMap<String, byte[]> byteCodes = new HashMap<>();
17851785

17861786
public void register(String name, byte[] bytecode) {
1787-
defineClass(name, bytecode, 0, bytecode.length);
17881787
byteCodes.put(name, bytecode);
17891788
}
17901789

@@ -1795,37 +1794,32 @@ public byte[] get(String name) {
17951794

17961795

17971796
private static class ContextDependedClassWriter extends ClassWriter {
1798-
private final GeneratedClassesContext context;
1799-
1800-
public ContextDependedClassWriter(GeneratedClassesContext context, int flags) {
1797+
public ContextDependedClassWriter(int flags) {
18011798
super(flags);
1802-
this.context = context;
18031799
}
18041800

18051801
protected String getCommonSuperClass(String className1, String className2) {
1806-
Class<?> klass1;
1807-
Class<?> klass2;
1808-
try {
1809-
klass1 = Class.forName(className1.replace('/', '.'), false, context);
1810-
klass2 = Class.forName(className2.replace('/', '.'), false, context);
1811-
} catch (ClassNotFoundException e) {
1812-
throw new Error("can not get common supper for " + className1
1813-
+ " and " + className2, e);
1802+
TypeKlass type1 = (TypeKlass) TypeList.find(className1.replace('/', '.'));
1803+
TypeKlass type2 = (TypeKlass) TypeList.find(className2.replace('/', '.'));
1804+
if (type1 == null || type2 == null) {
1805+
return super.getCommonSuperClass(className1, className2);
18141806
}
18151807

1816-
if (klass1.isAssignableFrom(klass2)) {
1808+
if (type2.canImplicitlyCastTo(type1)) {
18171809
return className1;
1818-
} else if (klass2.isAssignableFrom(klass1)) {
1810+
}
1811+
if (type1.canImplicitlyCastTo(type2)) {
18191812
return className2;
1820-
} else if (!klass1.isInterface() && !klass2.isInterface()) {
1821-
do {
1822-
klass1 = klass1.getSuperclass();
1823-
} while (!klass1.isAssignableFrom(klass2));
1824-
1825-
return asInternalName(className1);
1826-
} else {
1813+
}
1814+
if (type1.isInterface() || type2.isInterface()) {
18271815
return "java/lang/Object";
18281816
}
1817+
1818+
do {
1819+
type1 = type1.getParent();
1820+
} while (!type2.canImplicitlyCastTo(type1));
1821+
1822+
return asInternalName(type1.getName());
18291823
}
18301824
}
18311825
}

0 commit comments

Comments
 (0)