Skip to content

Commit

Permalink
8346984: Remove ASM-based benchmarks from Class-File API benchmarks
Browse files Browse the repository at this point in the history
Reviewed-by: liach, redestad, erikj
  • Loading branch information
asotona committed Jan 6, 2025
1 parent c027f2e commit 594e519
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 555 deletions.
4 changes: 1 addition & 3 deletions make/test/BuildMicrobenchmark.gmk
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -96,8 +96,6 @@ $(eval $(call SetupJavaCompilation, BUILD_JDK_MICROBENCHMARK, \
--add-exports java.base/jdk.internal.foreign=ALL-UNNAMED \
--add-exports java.base/jdk.internal.misc=ALL-UNNAMED \
--add-exports java.base/jdk.internal.util=ALL-UNNAMED \
--add-exports java.base/jdk.internal.org.objectweb.asm.tree=ALL-UNNAMED \
--add-exports java.base/jdk.internal.org.objectweb.asm=ALL-UNNAMED \
--add-exports java.base/jdk.internal.vm=ALL-UNNAMED \
--add-exports java.base/sun.invoke.util=ALL-UNNAMED \
--add-exports java.base/sun.security.util=ALL-UNNAMED \
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -44,8 +44,6 @@
@Warmup(iterations = 2)
@Measurement(iterations = 4)
@Fork(value = 1, jvmArgs = {
"--add-exports", "java.base/jdk.internal.org.objectweb.asm=ALL-UNNAMED",
"--add-exports", "java.base/jdk.internal.org.objectweb.asm.tree=ALL-UNNAMED",
"--add-exports", "java.base/jdk.internal.classfile.components=ALL-UNNAMED",
"--add-exports", "java.base/jdk.internal.classfile.impl=ALL-UNNAMED"})
@State(Scope.Benchmark)
Expand Down
6 changes: 1 addition & 5 deletions test/micro/org/openjdk/bench/jdk/classfile/AdaptNull.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -35,10 +35,6 @@ public class AdaptNull extends AbstractCorpusBenchmark {

@Param({
// "ARRAYCOPY",
"ASM_1",
"ASM_3",
"ASM_UNSHARED_3",
// "ASM_TREE",
"SHARED_1",
"SHARED_2",
"SHARED_3",
Expand Down
57 changes: 1 addition & 56 deletions test/micro/org/openjdk/bench/jdk/classfile/ReadDeep.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -29,12 +29,6 @@
import java.lang.classfile.CompoundElement;
import java.lang.classfile.MethodModel;
import java.lang.classfile.instruction.LoadInstruction;
import jdk.internal.org.objectweb.asm.ClassReader;
import jdk.internal.org.objectweb.asm.ClassVisitor;
import jdk.internal.org.objectweb.asm.MethodVisitor;
import jdk.internal.org.objectweb.asm.Opcodes;
import jdk.internal.org.objectweb.asm.tree.ClassNode;
import jdk.internal.org.objectweb.asm.tree.MethodNode;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.BenchmarkMode;
import org.openjdk.jmh.annotations.Mode;
Expand All @@ -45,55 +39,6 @@
*/
public class ReadDeep extends AbstractCorpusBenchmark {

@Benchmark
@BenchmarkMode(Mode.Throughput)
public void asmStreamCountLoads(Blackhole bh) {
for (byte[] bytes : classes) {
ClassReader cr = new ClassReader(bytes);

var mv = new MethodVisitor(Opcodes.ASM9) {
int count = 0;

@Override
public void visitVarInsn(int opcode, int var) {
++count;
}
};

var visitor = new ClassVisitor(Opcodes.ASM9) {
@Override
public MethodVisitor visitMethod(int access, String name, String descriptor, String signature, String[] exceptions) {
return mv;
}
};
cr.accept(visitor, 0);
bh.consume(mv.count);
}
}

@Benchmark
@BenchmarkMode(Mode.Throughput)
public void asmTreeCountLoads(Blackhole bh) {
for (byte[] bytes : classes) {
var mv = new MethodVisitor(Opcodes.ASM9) {
int count = 0;

@Override
public void visitVarInsn(int opcode, int var) {
++count;
}
};

ClassNode node = new ClassNode();
ClassReader cr = new ClassReader(bytes);
cr.accept(node, 0);
for (MethodNode mn : node.methods) {
mn.accept(mv);
}
bh.consume(mv.count);
}
}

@Benchmark
@BenchmarkMode(Mode.Throughput)
public void jdkElementsCountLoads(Blackhole bh) {
Expand Down
70 changes: 1 addition & 69 deletions test/micro/org/openjdk/bench/jdk/classfile/ReadMetadata.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -27,42 +27,11 @@
import java.lang.classfile.ClassModel;
import java.lang.classfile.ClassFile;
import java.lang.classfile.FieldModel;
import jdk.internal.org.objectweb.asm.*;
import jdk.internal.org.objectweb.asm.tree.*;
import org.openjdk.jmh.annotations.*;
import org.openjdk.jmh.infra.Blackhole;

public class ReadMetadata extends AbstractCorpusBenchmark {

@Benchmark
@BenchmarkMode(Mode.Throughput)
public void asmStreamReadName(Blackhole bh) {
for (byte[] bytes : classes) {
ClassReader cr = new ClassReader(bytes);
var visitor = new ClassVisitor(Opcodes.ASM9) {
String theName;

@Override
public void visit(int version, int access, String name, String signature, String superName, String[] interfaces) {
theName = name;
}
};
cr.accept(visitor, 0);
bh.consume(visitor.theName);
}
}

@Benchmark
@BenchmarkMode(Mode.Throughput)
public void asmTreeReadName(Blackhole bh) {
for (byte[] bytes : classes) {
ClassNode node = new ClassNode();
ClassReader cr = new ClassReader(bytes);
cr.accept(node, 0);
bh.consume(node.name);
}
}

@Benchmark
@BenchmarkMode(Mode.Throughput)
public void jdkReadName(Blackhole bh) {
Expand Down Expand Up @@ -90,43 +59,6 @@ public void jdkReadMemberNames(Blackhole bh) {
}
}

@Benchmark
@BenchmarkMode(Mode.Throughput)
public void asmStreamCountFields(Blackhole bh) {
for (byte[] bytes : classes) {
ClassReader cr = new ClassReader(bytes);
var visitor = new ClassVisitor(Opcodes.ASM9) {
int count;

@Override
public FieldVisitor visitField(int access, String name, String descriptor, String signature, Object value) {
if ((access & Opcodes.ACC_PUBLIC) != 1) {
++count;
}
return null;
}
};
cr.accept(visitor, 0);
bh.consume(visitor.count);
}
}

@Benchmark
@BenchmarkMode(Mode.Throughput)
public void asmTreeCountFields(Blackhole bh) {
for (byte[] bytes : classes) {
int count = 0;
ClassNode node = new ClassNode();
ClassReader cr = new ClassReader(bytes);
cr.accept(node, 0);
for (FieldNode fn : node.fields)
if ((fn.access & Opcodes.ACC_PUBLIC) != 1) {
++count;
}
bh.consume(count);
}
}

@Benchmark
@BenchmarkMode(Mode.Throughput)
public void jdkTreeCountFields(Blackhole bh) {
Expand Down
Loading

1 comment on commit 594e519

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.