jdk.jfr.internal.EventInstrumentation.SettingInfo Java Examples

The following examples show how to use jdk.jfr.internal.EventInstrumentation.SettingInfo. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: EventHandlerCreator.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
public EventHandlerCreator(long id, List<SettingInfo> settingInfos, List<FieldInfo> fields) {
    this.classWriter = new ClassWriter(ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS);
    this.className = makeEventHandlerName(id);
    this.internalClassName = ASMToolkit.getInternalName(className);
    this.settingInfos = settingInfos;
    this.fields = fields;
}
 
Example #2
Source File: EventHandlerCreator.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
private void buildConstructor() {
    MethodVisitor mv = classWriter.visitMethod(Opcodes.ACC_PRIVATE, METHOD_EVENT_HANDLER_CONSTRUCTOR.getName(), makeConstructorDescriptor(settingInfos), null, null);
    mv.visitVarInsn(Opcodes.ALOAD, 0); // this
    mv.visitVarInsn(Opcodes.ILOAD, 1); // registered
    mv.visitVarInsn(Opcodes.ALOAD, 2); // event type
    mv.visitVarInsn(Opcodes.ALOAD, 3); // event control
    mv.visitMethodInsn(Opcodes.INVOKESPECIAL, Type.getInternalName(EventHandler.class), METHOD_EVENT_HANDLER_CONSTRUCTOR.getName(), METHOD_EVENT_HANDLER_CONSTRUCTOR.getDescriptor(), false);
    for (SettingInfo si : settingInfos) {
        mv.visitVarInsn(Opcodes.ALOAD, 0); // this
        mv.visitVarInsn(Opcodes.ALOAD, si.index + 4); // Setting Control
        mv.visitFieldInsn(Opcodes.PUTFIELD, internalClassName, si.fieldName, TYPE_SETTING_CONTROL.getDescriptor());
    }
    // initialized string field writers
    int fieldIndex = 0;
    for (FieldInfo field : fields) {
        if (field.isString()) {
            mv.visitVarInsn(Opcodes.ALOAD, 0);
            mv.visitVarInsn(Opcodes.ALOAD, 0);
            mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, Type.getInternalName(EventHandler.class), "createStringFieldWriter", "()" + TYPE_STRING_POOL.getDescriptor(), false);
            mv.visitFieldInsn(Opcodes.PUTFIELD, internalClassName, FIELD_PREFIX_STRING_POOL + fieldIndex, TYPE_STRING_POOL.getDescriptor());
        }
        fieldIndex++;
    }
    mv.visitInsn(Opcodes.RETURN);
    mv.visitMaxs(0, 0);
    mv.visitEnd();
}
 
Example #3
Source File: EventHandlerCreator.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
private void buildClassInfo() {
    String internalSuperName = ASMToolkit.getInternalName(EventHandler.class.getName());
    classWriter.visit(CLASS_VERSION, Opcodes.ACC_PUBLIC + Opcodes.ACC_FINAL + Opcodes.ACC_SUPER, internalClassName, null, internalSuperName, null);
    for (SettingInfo si : settingInfos) {
        classWriter.visitField(Opcodes.ACC_PUBLIC + Opcodes.ACC_FINAL, si.fieldName, TYPE_SETTING_CONTROL.getDescriptor(), null, null);
    }
    int fieldIndex = 0;
    for (FieldInfo field : fields) {
        if (field.isString()) {
            classWriter.visitField(Opcodes.ACC_PRIVATE | Opcodes.ACC_FINAL, FIELD_PREFIX_STRING_POOL+ fieldIndex, TYPE_STRING_POOL.getDescriptor(), null, null);
        }
        fieldIndex++;
    }
}
 
Example #4
Source File: EventHandlerCreator.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
private static String makeConstructorDescriptor(List<SettingInfo> settingsInfos) {
    StringJoiner constructordescriptor = new StringJoiner("", "(", ")V");
    constructordescriptor.add(Type.BOOLEAN_TYPE.getDescriptor());
    constructordescriptor.add(Type.getType(EventType.class).getDescriptor());
    constructordescriptor.add(Type.getType(EventControl.class).getDescriptor());
    for (int i = 0; i < settingsInfos.size(); i++) {
        constructordescriptor.add(TYPE_SETTING_CONTROL.getDescriptor());
    }
    return constructordescriptor.toString();
}
 
Example #5
Source File: EventHandlerCreator.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private static String makeConstructorDescriptor(List<SettingInfo> settingsInfos) {
    StringJoiner constructordescriptor = new StringJoiner("", "(", ")V");
    constructordescriptor.add(Type.BOOLEAN_TYPE.getDescriptor());
    constructordescriptor.add(Type.getType(EventType.class).getDescriptor());
    constructordescriptor.add(Type.getType(EventControl.class).getDescriptor());
    for (int i = 0; i < settingsInfos.size(); i++) {
        constructordescriptor.add(TYPE_SETTING_CONTROL.getDescriptor());
    }
    return constructordescriptor.toString();
}
 
Example #6
Source File: EventHandlerCreator.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public EventHandlerCreator(long id, List<SettingInfo> settingInfos, List<FieldInfo> fields) {
    this.classWriter = new ClassWriter(ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS);
    this.className = makeEventHandlerName(id);
    this.internalClassName = ASMToolkit.getInternalName(className);
    this.settingInfos = settingInfos;
    this.fields = fields;
}
 
Example #7
Source File: EventHandlerCreator.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private void buildClassInfo() {
    String internalSuperName = ASMToolkit.getInternalName(eventHandlerProxy.getName());
    classWriter.visit(CLASS_VERSION, Opcodes.ACC_PUBLIC + Opcodes.ACC_FINAL + Opcodes.ACC_SUPER, internalClassName, null, internalSuperName, null);
    for (SettingInfo si : settingInfos) {
        classWriter.visitField(Opcodes.ACC_PUBLIC + Opcodes.ACC_FINAL, si.fieldName, TYPE_SETTING_CONTROL.getDescriptor(), null, null);
    }
    int fieldIndex = 0;
    for (FieldInfo field : fields) {
        if (field.isString()) {
            classWriter.visitField(Opcodes.ACC_PRIVATE | Opcodes.ACC_FINAL, FIELD_PREFIX_STRING_POOL+ fieldIndex, TYPE_STRING_POOL.getDescriptor(), null, null);
        }
        fieldIndex++;
    }
}
 
Example #8
Source File: EventHandlerCreator.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private void buildConstructor() {
    MethodVisitor mv = classWriter.visitMethod(Opcodes.ACC_PRIVATE, METHOD_EVENT_HANDLER_CONSTRUCTOR.getName(), makeConstructorDescriptor(settingInfos), null, null);
    mv.visitVarInsn(Opcodes.ALOAD, 0); // this
    mv.visitVarInsn(Opcodes.ILOAD, 1); // registered
    mv.visitVarInsn(Opcodes.ALOAD, 2); // event type
    mv.visitVarInsn(Opcodes.ALOAD, 3); // event control
    mv.visitMethodInsn(Opcodes.INVOKESPECIAL, Type.getInternalName(eventHandlerProxy), METHOD_EVENT_HANDLER_CONSTRUCTOR.getName(), METHOD_EVENT_HANDLER_CONSTRUCTOR.getDescriptor(), false);
    for (SettingInfo si : settingInfos) {
        mv.visitVarInsn(Opcodes.ALOAD, 0); // this
        mv.visitVarInsn(Opcodes.ALOAD, si.index + 4); // Setting Control
        mv.visitFieldInsn(Opcodes.PUTFIELD, internalClassName, si.fieldName, TYPE_SETTING_CONTROL.getDescriptor());
    }
    // initialized string field writers
    int fieldIndex = 0;
    for (FieldInfo field : fields) {
        if (field.isString()) {
            mv.visitVarInsn(Opcodes.ALOAD, 0);
            mv.visitVarInsn(Opcodes.ALOAD, 0);
            mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, Type.getInternalName(eventHandlerProxy), "createStringFieldWriter", "()" + TYPE_STRING_POOL.getDescriptor(), false);
            mv.visitFieldInsn(Opcodes.PUTFIELD, internalClassName, FIELD_PREFIX_STRING_POOL + fieldIndex, TYPE_STRING_POOL.getDescriptor());
        }
        fieldIndex++;
    }
    mv.visitInsn(Opcodes.RETURN);
    mv.visitMaxs(0, 0);
    mv.visitEnd();
}
 
Example #9
Source File: EventHandlerCreator.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private void buildClassInfo() {
    String internalSuperName = ASMToolkit.getInternalName(eventHandlerProxy.getName());
    classWriter.visit(CLASS_VERSION, Opcodes.ACC_PUBLIC + Opcodes.ACC_FINAL + Opcodes.ACC_SUPER, internalClassName, null, internalSuperName, null);
    for (SettingInfo si : settingInfos) {
        classWriter.visitField(Opcodes.ACC_PUBLIC + Opcodes.ACC_FINAL, si.fieldName, TYPE_SETTING_CONTROL.getDescriptor(), null, null);
    }
    int fieldIndex = 0;
    for (FieldInfo field : fields) {
        if (field.isString()) {
            classWriter.visitField(Opcodes.ACC_PRIVATE | Opcodes.ACC_FINAL, FIELD_PREFIX_STRING_POOL+ fieldIndex, TYPE_STRING_POOL.getDescriptor(), null, null);
        }
        fieldIndex++;
    }
}
 
Example #10
Source File: EventHandlerCreator.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private static String makeConstructorDescriptor(List<SettingInfo> settingsInfos) {
    StringJoiner constructordescriptor = new StringJoiner("", "(", ")V");
    constructordescriptor.add(Type.BOOLEAN_TYPE.getDescriptor());
    constructordescriptor.add(Type.getType(EventType.class).getDescriptor());
    constructordescriptor.add(Type.getType(EventControl.class).getDescriptor());
    for (int i = 0; i < settingsInfos.size(); i++) {
        constructordescriptor.add(TYPE_SETTING_CONTROL.getDescriptor());
    }
    return constructordescriptor.toString();
}
 
Example #11
Source File: EventHandlerCreator.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private void buildConstructor() {
    MethodVisitor mv = classWriter.visitMethod(Opcodes.ACC_PRIVATE, METHOD_EVENT_HANDLER_CONSTRUCTOR.getName(), makeConstructorDescriptor(settingInfos), null, null);
    mv.visitVarInsn(Opcodes.ALOAD, 0); // this
    mv.visitVarInsn(Opcodes.ILOAD, 1); // registered
    mv.visitVarInsn(Opcodes.ALOAD, 2); // event type
    mv.visitVarInsn(Opcodes.ALOAD, 3); // event control
    mv.visitMethodInsn(Opcodes.INVOKESPECIAL, Type.getInternalName(eventHandlerProxy), METHOD_EVENT_HANDLER_CONSTRUCTOR.getName(), METHOD_EVENT_HANDLER_CONSTRUCTOR.getDescriptor(), false);
    for (SettingInfo si : settingInfos) {
        mv.visitVarInsn(Opcodes.ALOAD, 0); // this
        mv.visitVarInsn(Opcodes.ALOAD, si.index + 4); // Setting Control
        mv.visitFieldInsn(Opcodes.PUTFIELD, internalClassName, si.fieldName, TYPE_SETTING_CONTROL.getDescriptor());
    }
    // initialized string field writers
    int fieldIndex = 0;
    for (FieldInfo field : fields) {
        if (field.isString()) {
            mv.visitVarInsn(Opcodes.ALOAD, 0);
            mv.visitVarInsn(Opcodes.ALOAD, 0);
            mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, Type.getInternalName(eventHandlerProxy), "createStringFieldWriter", "()" + TYPE_STRING_POOL.getDescriptor(), false);
            mv.visitFieldInsn(Opcodes.PUTFIELD, internalClassName, FIELD_PREFIX_STRING_POOL + fieldIndex, TYPE_STRING_POOL.getDescriptor());
        }
        fieldIndex++;
    }
    mv.visitInsn(Opcodes.RETURN);
    mv.visitMaxs(0, 0);
    mv.visitEnd();
}
 
Example #12
Source File: EventHandlerCreator.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public EventHandlerCreator(long id, List<SettingInfo> settingInfos, List<FieldInfo> fields) {
    this.classWriter = new ClassWriter(ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS);
    this.className = makeEventHandlerName(id);
    this.internalClassName = ASMToolkit.getInternalName(className);
    this.settingInfos = settingInfos;
    this.fields = fields;
}
 
Example #13
Source File: EventControl.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
public List<SettingInfo> getSettingInfos() {
    return settingInfos;
}
 
Example #14
Source File: EventHandlerCreator.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
public EventHandlerCreator(long id, List<SettingInfo> settingInfos, EventType type, Class<? extends Event> eventClass) {
    this(id, settingInfos, createFieldInfos(eventClass, type));
}
 
Example #15
Source File: EventControl.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
public List<SettingInfo> getSettingInfos() {
    return settingInfos;
}
 
Example #16
Source File: EventHandlerCreator.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
public EventHandlerCreator(long id, List<SettingInfo> settingInfos, EventType type, Class<? extends Event> eventClass) {
    this(id, settingInfos, createFieldInfos(eventClass, type));
}
 
Example #17
Source File: EventControl.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
public List<SettingInfo> getSettingInfos() {
    return settingInfos;
}
 
Example #18
Source File: EventHandlerCreator.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
public EventHandlerCreator(long id, List<SettingInfo> settingInfos, EventType type, Class<? extends Event> eventClass) {
    this(id, settingInfos, createFieldInfos(eventClass, type));
}