Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8231500: [lworld] Merge the experimental bytecode API #279

Closed
wants to merge 5 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -182,7 +182,7 @@ public static MethodHandle loadCode(MethodHandles.Lookup lookup, String classNam
}


protected static <Z, C extends CodeBuilder<Class<?>, String, byte[], ?>> Z loadCode(
private static <Z, C extends CodeBuilder<Class<?>, String, byte[], ?>> Z loadCode(
MethodHandles.Lookup lookup, String className, String methodName, String type,
Function<MethodBuilder<Class<?>, String, byte[]>, ? extends C> builderFunc,
Function<Class<?>, Z> resFunc, Consumer<? super C> builder) {
@@ -206,11 +206,11 @@ public static MethodHandle loadCode(MethodHandles.Lookup lookup, String classNam
}
}

public static class IsolatedMethodBuilder extends ClassBuilder<Class<?>, String, IsolatedMethodBuilder> {
private static class IsolatedMethodBuilder extends ClassBuilder<Class<?>, String, IsolatedMethodBuilder> {

private static final Class<?> THIS_CLASS = new Object() { }.getClass();

public IsolatedMethodBuilder(String clazz, MethodHandles.Lookup lookup) {
private IsolatedMethodBuilder(String clazz, MethodHandles.Lookup lookup) {
super(new IsolatedMethodPoolHelper(clazz),
new IsolatedMethodTypeHelper(lookup));
withThisClass(THIS_CLASS);
@@ -224,12 +224,12 @@ static String classToInternalName(Class<?> c) {
return c.getName().replace('.', '/');
}

static class IsolatedMethodTypeHelper implements TypeHelper<Class<?>, String> {
private static class IsolatedMethodTypeHelper implements TypeHelper<Class<?>, String> {

BasicTypeHelper basicTypeHelper = new BasicTypeHelper();
MethodHandles.Lookup lookup;

IsolatedMethodTypeHelper(MethodHandles.Lookup lookup) {
private IsolatedMethodTypeHelper(MethodHandles.Lookup lookup) {
this.lookup = lookup;
}

@@ -268,7 +268,7 @@ public String type(Class<?> aClass) {
}

@Override
public boolean isValue(String desc) {
public boolean isInlineClass(String desc) {
Class<?> aClass = symbol(desc);
return aClass != null && aClass.isInlineClass();
}
@@ -307,18 +307,14 @@ public String nullType() {
}
}

static class IsolatedMethodPoolHelper extends BytePoolHelper<Class<?>, String> {
private static class IsolatedMethodPoolHelper extends BytePoolHelper<Class<?>, String> {
final String clazz;

IsolatedMethodPoolHelper(String clazz) {
private IsolatedMethodPoolHelper(String clazz) {
super(c -> from(c, clazz), s->s);
this.clazz = clazz;
}

Object[] patches() {
return null;
}

static String from(Class<?> c, String clazz) {
return c == THIS_CLASS ? clazz.replace('.', '/')
: classToInternalName(c);
@@ -46,7 +46,7 @@ public String arrayOf(String s) {
}

@Override
public boolean isValue(String t) {
public boolean isInlineClass(String t) {
return t.charAt(0) == 'Q' && t.endsWith(";");
}

@@ -338,7 +338,7 @@ public int putClass(S symbol) {
}

@Override
public int putValueClass(S symbol) {
public int putInlineClass(S symbol) {
return putClassInternal("Q" + symbolToString.apply(symbol) + ";");
}

@@ -1156,8 +1156,8 @@ private void writeStackMapType(T t) {
} else {
//TODO: uninit this, top?
stackmaps.writeByte(7);
stackmaps.writeChar(typeHelper.isValue(t) ?
poolHelper.putValueClass(typeHelper.symbol(t)) : poolHelper.putClass(typeHelper.symbol(t)));
stackmaps.writeChar(typeHelper.isInlineClass(t) ?
poolHelper.putInlineClass(typeHelper.symbol(t)) : poolHelper.putClass(typeHelper.symbol(t)));
}
break;
default:
@@ -54,7 +54,7 @@ public int putClass(Class<?> symbol) {
}

@Override
public int putValueClass(Class<?> symbol) {
public int putInlineClass(Class<?> symbol) {
return putIfAbsent(symbol);
}

@@ -36,7 +36,7 @@
public interface PoolHelper<S, T, E> {
int putClass(S symbol);

int putValueClass(S symbol);
int putInlineClass(S symbol);

int putFieldRef(S owner, CharSequence name, T type);

@@ -89,7 +89,7 @@
* @param t the type descreiptor
* @return true if the given type is a value type
*/
boolean isValue(T t);
boolean isInlineClass(T t);

/**
* For a symbol that corresponds to a value type, return the type descriptor.
@@ -872,7 +872,7 @@ public int putClass(S symbol) {
}

@Override
public int putValueClass(S symbol) {
public int putInlineClass(S symbol) {
throw new IllegalStateException();
}