mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-26 14:24:46 +02:00
8339876: Move constant symbol caches to Utf8EntryImpl
Reviewed-by: redestad
This commit is contained in:
parent
0765917dea
commit
4d65c3efca
19 changed files with 87 additions and 113 deletions
|
@ -34,6 +34,8 @@ import jdk.internal.classfile.impl.TemporaryConstantPool;
|
|||
|
||||
import java.lang.constant.ClassDesc;
|
||||
import java.util.List;
|
||||
|
||||
import jdk.internal.classfile.impl.Util;
|
||||
import jdk.internal.javac.PreviewFeature;
|
||||
|
||||
/**
|
||||
|
@ -78,7 +80,7 @@ public sealed interface Annotation
|
|||
* {@return the annotation interface, as a symbolic descriptor}
|
||||
*/
|
||||
default ClassDesc classSymbol() {
|
||||
return ClassDesc.ofDescriptor(className().stringValue());
|
||||
return Util.fieldTypeSymbol(className());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -115,7 +117,7 @@ public sealed interface Annotation
|
|||
*/
|
||||
static Annotation of(ClassDesc annotationClass,
|
||||
List<AnnotationElement> elements) {
|
||||
return of(TemporaryConstantPool.INSTANCE.utf8Entry(annotationClass.descriptorString()), elements);
|
||||
return of(TemporaryConstantPool.INSTANCE.utf8Entry(annotationClass), elements);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -125,6 +127,6 @@ public sealed interface Annotation
|
|||
*/
|
||||
static Annotation of(ClassDesc annotationClass,
|
||||
AnnotationElement... elements) {
|
||||
return of(TemporaryConstantPool.INSTANCE.utf8Entry(annotationClass.descriptorString()), elements);
|
||||
return of(TemporaryConstantPool.INSTANCE.utf8Entry(annotationClass), elements);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,6 +38,8 @@ import java.lang.constant.ClassDesc;
|
|||
import java.lang.constant.Constable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import jdk.internal.classfile.impl.Util;
|
||||
import jdk.internal.javac.PreviewFeature;
|
||||
|
||||
/**
|
||||
|
@ -405,7 +407,7 @@ public sealed interface AnnotationValue {
|
|||
|
||||
/** {@return the class descriptor} */
|
||||
default ClassDesc classSymbol() {
|
||||
return ClassDesc.ofDescriptor(className().stringValue());
|
||||
return Util.fieldTypeSymbol(className());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -423,7 +425,7 @@ public sealed interface AnnotationValue {
|
|||
|
||||
/** {@return the enum class descriptor} */
|
||||
default ClassDesc classSymbol() {
|
||||
return ClassDesc.ofDescriptor(className().stringValue());
|
||||
return Util.fieldTypeSymbol(className());
|
||||
}
|
||||
|
||||
/** {@return the enum constant name} */
|
||||
|
@ -452,7 +454,7 @@ public sealed interface AnnotationValue {
|
|||
* @param constantName the name of the enum constant
|
||||
*/
|
||||
static OfEnum ofEnum(ClassDesc className, String constantName) {
|
||||
return ofEnum(TemporaryConstantPool.INSTANCE.utf8Entry(className.descriptorString()),
|
||||
return ofEnum(TemporaryConstantPool.INSTANCE.utf8Entry(className),
|
||||
TemporaryConstantPool.INSTANCE.utf8Entry(constantName));
|
||||
}
|
||||
|
||||
|
@ -469,7 +471,7 @@ public sealed interface AnnotationValue {
|
|||
* @param className the descriptor of the class
|
||||
*/
|
||||
static OfClass ofClass(ClassDesc className) {
|
||||
return ofClass(TemporaryConstantPool.INSTANCE.utf8Entry(className.descriptorString()));
|
||||
return ofClass(TemporaryConstantPool.INSTANCE.utf8Entry(className));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -194,7 +194,9 @@ public sealed interface ClassBuilder
|
|||
default ClassBuilder withField(String name,
|
||||
ClassDesc descriptor,
|
||||
int flags) {
|
||||
return withField(name, descriptor, Util.buildingFlags(flags));
|
||||
return withField(constantPool().utf8Entry(name),
|
||||
constantPool().utf8Entry(descriptor),
|
||||
flags);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -769,7 +769,7 @@ public sealed interface CodeBuilder
|
|||
default CodeBuilder localVariable(int slot, String name, ClassDesc descriptor, Label startScope, Label endScope) {
|
||||
return localVariable(slot,
|
||||
constantPool().utf8Entry(name),
|
||||
constantPool().utf8Entry(descriptor.descriptorString()),
|
||||
constantPool().utf8Entry(descriptor),
|
||||
startScope, endScope);
|
||||
}
|
||||
|
||||
|
|
|
@ -31,6 +31,7 @@ import java.util.Optional;
|
|||
import java.lang.classfile.constantpool.Utf8Entry;
|
||||
import jdk.internal.classfile.impl.BufferedFieldBuilder;
|
||||
import jdk.internal.classfile.impl.FieldImpl;
|
||||
import jdk.internal.classfile.impl.Util;
|
||||
import jdk.internal.javac.PreviewFeature;
|
||||
|
||||
/**
|
||||
|
@ -59,6 +60,6 @@ public sealed interface FieldModel
|
|||
|
||||
/** {@return the field descriptor of this field, as a symbolic descriptor} */
|
||||
default ClassDesc fieldTypeSymbol() {
|
||||
return ClassDesc.ofDescriptor(fieldType().stringValue());
|
||||
return Util.fieldTypeSymbol(fieldType());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,6 +31,7 @@ import java.util.Optional;
|
|||
import java.lang.classfile.constantpool.Utf8Entry;
|
||||
import jdk.internal.classfile.impl.BufferedMethodBuilder;
|
||||
import jdk.internal.classfile.impl.MethodImpl;
|
||||
import jdk.internal.classfile.impl.Util;
|
||||
import jdk.internal.javac.PreviewFeature;
|
||||
|
||||
/**
|
||||
|
@ -59,7 +60,7 @@ public sealed interface MethodModel
|
|||
|
||||
/** {@return the method descriptor of this method, as a symbolic descriptor} */
|
||||
default MethodTypeDesc methodTypeSymbol() {
|
||||
return MethodTypeDesc.ofDescriptor(methodType().stringValue());
|
||||
return Util.methodTypeSymbol(methodType());
|
||||
}
|
||||
|
||||
/** {@return the body of this method, if there is one} */
|
||||
|
|
|
@ -28,6 +28,7 @@ import java.lang.constant.ClassDesc;
|
|||
import java.lang.classfile.constantpool.Utf8Entry;
|
||||
import jdk.internal.classfile.impl.BoundLocalVariable;
|
||||
import jdk.internal.classfile.impl.UnboundAttribute;
|
||||
import jdk.internal.classfile.impl.Util;
|
||||
import jdk.internal.javac.PreviewFeature;
|
||||
|
||||
/**
|
||||
|
@ -65,7 +66,7 @@ public sealed interface LocalVariableInfo
|
|||
* {@return the field descriptor of the local variable}
|
||||
*/
|
||||
default ClassDesc typeSymbol() {
|
||||
return ClassDesc.ofDescriptor(type().stringValue());
|
||||
return Util.fieldTypeSymbol(type());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -33,6 +33,7 @@ import java.lang.classfile.constantpool.Utf8Entry;
|
|||
import jdk.internal.classfile.impl.BoundRecordComponentInfo;
|
||||
import jdk.internal.classfile.impl.TemporaryConstantPool;
|
||||
import jdk.internal.classfile.impl.UnboundAttribute;
|
||||
import jdk.internal.classfile.impl.Util;
|
||||
import jdk.internal.javac.PreviewFeature;
|
||||
|
||||
/**
|
||||
|
@ -58,7 +59,7 @@ public sealed interface RecordComponentInfo
|
|||
* {@return the field descriptor of this component, as a {@linkplain ClassDesc}}
|
||||
*/
|
||||
default ClassDesc descriptorSymbol() {
|
||||
return ClassDesc.ofDescriptor(descriptor().stringValue());
|
||||
return Util.fieldTypeSymbol(descriptor());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -95,7 +96,7 @@ public sealed interface RecordComponentInfo
|
|||
ClassDesc descriptor,
|
||||
List<Attribute<?>> attributes) {
|
||||
return new UnboundAttribute.UnboundRecordComponentInfo(TemporaryConstantPool.INSTANCE.utf8Entry(name),
|
||||
TemporaryConstantPool.INSTANCE.utf8Entry(descriptor.descriptorString()),
|
||||
TemporaryConstantPool.INSTANCE.utf8Entry(descriptor),
|
||||
attributes);
|
||||
}
|
||||
|
||||
|
|
|
@ -223,9 +223,7 @@ public sealed interface ConstantPoolBuilder
|
|||
* @param type the symbolic descriptor for a field type
|
||||
*/
|
||||
default NameAndTypeEntry nameAndTypeEntry(String name, ClassDesc type) {
|
||||
var ret = (NameAndTypeEntryImpl)nameAndTypeEntry(utf8Entry(name), utf8Entry(type.descriptorString()));
|
||||
ret.typeSym = type;
|
||||
return ret;
|
||||
return nameAndTypeEntry(utf8Entry(name), utf8Entry(type));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -238,9 +236,7 @@ public sealed interface ConstantPoolBuilder
|
|||
* @param type the symbolic descriptor for a method type
|
||||
*/
|
||||
default NameAndTypeEntry nameAndTypeEntry(String name, MethodTypeDesc type) {
|
||||
var ret = (NameAndTypeEntryImpl)nameAndTypeEntry(utf8Entry(name), utf8Entry(type.descriptorString()));
|
||||
ret.typeSym = type;
|
||||
return ret;
|
||||
return nameAndTypeEntry(utf8Entry(name), utf8Entry(type));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -36,6 +36,7 @@ import java.lang.constant.ClassDesc;
|
|||
import jdk.internal.classfile.impl.AbstractPseudoInstruction;
|
||||
import jdk.internal.classfile.impl.BoundLocalVariable;
|
||||
import jdk.internal.classfile.impl.TemporaryConstantPool;
|
||||
import jdk.internal.classfile.impl.Util;
|
||||
import jdk.internal.javac.PreviewFeature;
|
||||
|
||||
/**
|
||||
|
@ -70,7 +71,7 @@ public sealed interface LocalVariable extends PseudoInstruction
|
|||
* {@return the local variable type, as a symbolic descriptor}
|
||||
*/
|
||||
default ClassDesc typeSymbol() {
|
||||
return ClassDesc.ofDescriptor(type().stringValue());
|
||||
return Util.fieldTypeSymbol(type());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -109,7 +110,7 @@ public sealed interface LocalVariable extends PseudoInstruction
|
|||
static LocalVariable of(int slot, String name, ClassDesc descriptor, Label startScope, Label endScope) {
|
||||
return of(slot,
|
||||
TemporaryConstantPool.INSTANCE.utf8Entry(name),
|
||||
TemporaryConstantPool.INSTANCE.utf8Entry(descriptor.descriptorString()),
|
||||
TemporaryConstantPool.INSTANCE.utf8Entry(descriptor),
|
||||
startScope, endScope);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue