asm merge requestshttps://gitlab.ow2.org/asm/asm/-/merge_requests2017-11-01T08:34:45Zhttps://gitlab.ow2.org/asm/asm/-/merge_requests/50Switch to JUnit 5.2017-11-01T08:34:45ZEric BrunetonSwitch to JUnit 5.Remi ForaxRemi Foraxhttps://gitlab.ow2.org/asm/asm/-/merge_requests/68Improve the code quality of SignatureReader and SignatureWriter.2017-11-14T18:57:50ZEric BrunetonImprove the code quality of SignatureReader and SignatureWriter.Remi ForaxRemi Foraxhttps://gitlab.ow2.org/asm/asm/-/merge_requests/69Rename the *UnitTest classes to *Test, and merge them in existing *Test class...2017-11-14T19:45:57ZEric BrunetonRename the *UnitTest classes to *Test, and merge them in existing *Test class if needed.Remi ForaxRemi Foraxhttps://gitlab.ow2.org/asm/asm/-/merge_requests/67Improve the code quality of ModuleWriter.2017-11-19T08:44:29ZEric BrunetonImprove the code quality of ModuleWriter.Remi ForaxRemi Foraxhttps://gitlab.ow2.org/asm/asm/-/merge_requests/66Improve the code quality of Item and of related code in ClassWriter and Class...2017-11-25T07:07:40ZEric BrunetonImprove the code quality of Item and of related code in ClassWriter and ClassReader.- Item was a mutable class with many set* methods, used to set predefined Item key instances in ClassWriter, to perform lookups (while avoiding the creation of new instances for this). These preallocated keys were error prone, due to the...- Item was a mutable class with many set* methods, used to set predefined Item key instances in ClassWriter, to perform lookups (while avoiding the creation of new instances for this). These preallocated keys were error prone, due to the nested calls (a nested call could inadvertently modify the key used by a caller).
- The Javadoc was largely obsolete, refering mostly to the constant pool, while Item was also used for bootstrap methods and for the ASM specific type table.
- The number of elements in ClassWriter#items was poorly tracked, for instance bootstrap methods were not taken into account in ClassWriter#put.
- The threshold to limit hash collisions was not always respected (for instance in copyPool, items was created with a size equal to the constant pool count, without margin).
- Lookups in ClassWriter#get were not optimal: a check on hashcode could be used before calling the expensive isEqualTo method.
Now Item is replaced with Symbol, which is immutable (except for the lazily computed info field). Also the hashCode and next fields are hidden in a private subclass (they are only used inside SymbolTable).
The preallocated Item key, key2, ... fields are removed, while keeping the zero allocation property for lookups.
The number of elements in entries is now explicitely tracked with entryCount, and the threshold is correctly used.
Lookups are now optimized to do a quick hashcode comparison before slow equality tests.
All Symbol management is now done is a separate SymbolTable class, allowing a cleaner implementation for the copyPool option (more private fields, less exposure of internal details to other classes).
According to performance tests using benchmarks/read-write, this new code is slightly faster than before (e.g. ~1.05 speedup for R+W with or without copyPool).
The jar size is now 99581 bytes vs 95209 for ASM 6.0.
This is a large refactor, please review carefully.
PS: I spent several days on this, and considered several designs before choosing this one. For instance, I also considered splitting SymbolTable in 3 (e.g. ConstantPoolWriter, BootstrapMethodsWriter and TypeTable, all delegating to a shared (custom) HashSet), and/or splitting Symbol using one class per type of symbol, to get something even more clean from an Object Oriented design point of view. But I rejected this as "going too far" from the current design.Remi ForaxRemi Foraxhttps://gitlab.ow2.org/asm/asm/-/merge_requests/70Improve the code quality of ClassWriter.2017-11-25T07:56:49ZEric BrunetonImprove the code quality of ClassWriter.Also fix a bug in toByteArray() if(hasAsmInsns) ...: type annotations were not reset to null.Also fix a bug in toByteArray() if(hasAsmInsns) ...: type annotations were not reset to null.Remi ForaxRemi Foraxhttps://gitlab.ow2.org/asm/asm/-/merge_requests/71Improve the code quality of MethodWriter.2017-11-25T09:09:12ZEric BrunetonImprove the code quality of MethodWriter.Remi ForaxRemi Foraxhttps://gitlab.ow2.org/asm/asm/-/merge_requests/72Improve the code quality of Frame.2017-11-25T09:34:33ZEric BrunetonImprove the code quality of Frame.Remi ForaxRemi Foraxhttps://gitlab.ow2.org/asm/asm/-/merge_requests/73Improve the code quality of ClassReader.2017-11-26T12:38:25ZEric BrunetonImprove the code quality of ClassReader.Remi ForaxRemi Foraxhttps://gitlab.ow2.org/asm/asm/-/merge_requests/74Update to be able to generate JDK 10 compatible classfile (54).2017-12-10T12:01:11ZRemi ForaxUpdate to be able to generate JDK 10 compatible classfile (54).There is no new feature, the number is just incremented so the
association between a JDK version and a classfile version is monotonic.
see http://mail.openjdk.java.net/pipermail/jdk-dev/2017-December/000309.html for more info.There is no new feature, the number is just incremented so the
association between a JDK version and a classfile version is monotonic.
see http://mail.openjdk.java.net/pipermail/jdk-dev/2017-December/000309.html for more info.Eric BrunetonEric Brunetonhttps://gitlab.ow2.org/asm/asm/-/merge_requests/75Improve the code quality of Label and add a Constants interface for internal ...2017-12-10T13:40:43ZEric BrunetonImprove the code quality of Label and add a Constants interface for internal constantsIn more details:
- add a Constants interface to avoid some magic constants in the code
- remove the INSTRUCTION_TYPES indirection in ClassReader, and use (table)switch statements on raw opcode values instead
- remove unnecessary flags BA...In more details:
- add a Constants interface to avoid some magic constants in the code
- remove the INSTRUCTION_TYPES indirection in ClassReader, and use (table)switch statements on raw opcode values instead
- remove unnecessary flags BASIC_BLOCK_CHANGED, VISITED and VISITED2 in Label (replaced with a simpler algorithm using an EMPTY_LIST sentinel), as well as the redundant STORE flag
- add an otherLineNumbers field in Label to store line numbers in a cleaner way than with nextChangedBlock
- remove the inputStackTop field in Label, which was used to store different values depending on the compute options or basic block types. Replace it with new inputStackSize and outputStackSize fields in Label, and a new (private) outputStackStart field in Frame.
- use 'short' fields when possible in Frame and Label. Object size in memory with OpenJDK 1.8.0, measured with https://www.javaworld.com/article/2077496/testing-debugging/java-tip-130--do-you-know-your-data-size-.html, decreased from 64 to 56 bytes for Label (despite the added fields), and stayed unchanged (48 bytes) for Frame (despite the added field outputStackStart).
- split the large visitMaxs method in two smaller methods.
- performance is unchanged or improved: 1.02-1.04 speedup for ClassReader, no change for ClassReader+ClassWriter, 1.11 speedup for CR+CW with compute maxs, 1.05 speedup for CR+CW with compute frames.Remi ForaxRemi Foraxhttps://gitlab.ow2.org/asm/asm/-/merge_requests/76Improve the code quality of Type and add more tests.2017-12-10T13:42:03ZEric BrunetonImprove the code quality of Type and add more tests.Also optimize the implementation with a new internal sort value, to avoid some String and StringBuilder manipulations.Also optimize the implementation with a new internal sort value, to avoid some String and StringBuilder manipulations.Remi ForaxRemi Foraxhttps://gitlab.ow2.org/asm/asm/-/merge_requests/77Small code quality improvements, hopefully the last ones for the core package.2017-12-10T14:05:29ZEric BrunetonSmall code quality improvements, hopefully the last ones for the core package.Remi ForaxRemi Foraxhttps://gitlab.ow2.org/asm/asm/-/merge_requests/80Update the package Javadoc.2017-12-30T13:51:08ZEric BrunetonUpdate the package Javadoc.Remi ForaxRemi Foraxhttps://gitlab.ow2.org/asm/asm/-/merge_requests/85Fix a regression in ClassReader, for the SKIP_CODE option2017-12-30T13:52:22ZEric BrunetonFix a regression in ClassReader, for the SKIP_CODE optionThis regression was introduced by https://gitlab.ow2.org/asm/asm/commit/f08474649b4e94cc7deda21bdf4c11af383eace9.This regression was introduced by https://gitlab.ow2.org/asm/asm/commit/f08474649b4e94cc7deda21bdf4c11af383eace9.Remi ForaxRemi Foraxhttps://gitlab.ow2.org/asm/asm/-/merge_requests/81Fix the build for JDK9. Also switch to Gradle 4.4.1 and source 1.6 (retrofitt...2017-12-30T14:08:22ZEric BrunetonFix the build for JDK9. Also switch to Gradle 4.4.1 and source 1.6 (retrofitted to 1.5).Remi ForaxRemi Foraxhttps://gitlab.ow2.org/asm/asm/-/merge_requests/79Replace the use of 'new Integer' with 'Integer.valueOf'.2017-12-30T14:24:41ZEric BrunetonReplace the use of 'new Integer' with 'Integer.valueOf'.Remi ForaxRemi Foraxhttps://gitlab.ow2.org/asm/asm/-/merge_requests/82Improve the class generation benchmark by using the JMH framework.2017-12-30T14:48:33ZEric BrunetonImprove the class generation benchmark by using the JMH framework.Results:
```
Benchmark Mode Cnt Score Error Units
GeneratorBenchmark.asm4_0 thrpt 20 753119,277 ± 1890,328 ops/s
GeneratorBenchmark.asm5_0 thrpt 20 729869,073 ± 23...Results:
```
Benchmark Mode Cnt Score Error Units
GeneratorBenchmark.asm4_0 thrpt 20 753119,277 ± 1890,328 ops/s
GeneratorBenchmark.asm5_0 thrpt 20 729869,073 ± 2328,108 ops/s
GeneratorBenchmark.asm6_0 thrpt 20 728330,694 ± 2244,506 ops/s
GeneratorBenchmark.asm6_1 thrpt 20 847886,985 ± 2767,943 ops/s
GeneratorBenchmark.aspectJBcel thrpt 20 274363,976 ± 1171,862 ops/s
GeneratorBenchmark.bcel thrpt 20 196715,573 ± 797,970 ops/s
GeneratorBenchmark.cojen thrpt 20 191329,604 ± 898,662 ops/s
GeneratorBenchmark.csgBytecode thrpt 20 325157,840 ± 1065,897 ops/s
GeneratorBenchmark.gnuByteCode thrpt 20 245634,219 ± 1061,192 ops/s
GeneratorBenchmark.jclassLib thrpt 20 280383,253 ± 973,727 ops/s
GeneratorBenchmark.jiapi thrpt 20 75012,298 ± 325,473 ops/s
GeneratorBenchmark.mozillaClassFile thrpt 20 303011,386 ± 1629,259 ops/s
```Remi ForaxRemi Foraxhttps://gitlab.ow2.org/asm/asm/-/merge_requests/83Improve the read-write performance test by using the JMH framework.2017-12-30T15:15:10ZEric BrunetonImprove the read-write performance test by using the JMH framework.Results:
```
AdapterBenchmark.getClassInfo_asm4_0 thrpt 20 12964,540 ± 100,411 ops/s
AdapterBenchmark.getClassInfo_asm5_0 thrpt 20 12410,599 ± 64,511 ops/s
AdapterBenchmark.getClassInfo_...Results:
```
AdapterBenchmark.getClassInfo_asm4_0 thrpt 20 12964,540 ± 100,411 ops/s
AdapterBenchmark.getClassInfo_asm5_0 thrpt 20 12410,599 ± 64,511 ops/s
AdapterBenchmark.getClassInfo_asm6_0 thrpt 20 12538,801 ± 67,891 ops/s
AdapterBenchmark.getClassInfo_asm6_1 thrpt 20 15744,919 ± 54,819 ops/s
AdapterBenchmark.getClassObjectModel_asm4_0 thrpt 20 536,993 ± 2,805 ops/s
AdapterBenchmark.getClassObjectModel_asm5_0 thrpt 20 539,811 ± 2,934 ops/s
AdapterBenchmark.getClassObjectModel_asm6_0 thrpt 20 529,741 ± 1,942 ops/s
AdapterBenchmark.getClassObjectModel_asm6_1 thrpt 20 553,037 ± 3,225 ops/s
AdapterBenchmark.readAndWriteWithComputeFrames_asm4_0 thrpt 20 167,452 ± 0,664 ops/s
AdapterBenchmark.readAndWriteWithComputeFrames_asm5_0 thrpt 20 164,215 ± 0,689 ops/s
AdapterBenchmark.readAndWriteWithComputeFrames_asm6_0 thrpt 20 165,821 ± 0,688 ops/s
AdapterBenchmark.readAndWriteWithComputeFrames_asm6_1 thrpt 20 174,736 ± 0,673 ops/s
AdapterBenchmark.readAndWriteWithComputeMaxs_asm4_0 thrpt 20 301,145 ± 1,328 ops/s
AdapterBenchmark.readAndWriteWithComputeMaxs_asm5_0 thrpt 20 303,352 ± 1,269 ops/s
AdapterBenchmark.readAndWriteWithComputeMaxs_asm6_0 thrpt 20 317,626 ± 1,079 ops/s
AdapterBenchmark.readAndWriteWithComputeMaxs_asm6_1 thrpt 20 321,737 ± 1,544 ops/s
AdapterBenchmark.readAndWriteWithComputeMaxs_aspectJBcel thrpt 20 82,308 ± 0,389 ops/s
AdapterBenchmark.readAndWriteWithComputeMaxs_bcel thrpt 20 65,963 ± 0,261 ops/s
AdapterBenchmark.readAndWriteWithComputeMaxs_serp thrpt 20 33,711 ± 0,090 ops/s
AdapterBenchmark.readAndWriteWithCopyPool_asm4_0 thrpt 20 1144,297 ± 4,976 ops/s
AdapterBenchmark.readAndWriteWithCopyPool_asm5_0 thrpt 20 1142,265 ± 5,866 ops/s
AdapterBenchmark.readAndWriteWithCopyPool_asm6_0 thrpt 20 1128,241 ± 5,340 ops/s
AdapterBenchmark.readAndWriteWithCopyPool_asm6_1 thrpt 20 1235,521 ± 4,344 ops/s
AdapterBenchmark.readAndWriteWithObjectModel_asm4_0 thrpt 20 252,227 ± 1,036 ops/s
AdapterBenchmark.readAndWriteWithObjectModel_asm5_0 thrpt 20 248,238 ± 1,110 ops/s
AdapterBenchmark.readAndWriteWithObjectModel_asm6_0 thrpt 20 246,449 ± 1,103 ops/s
AdapterBenchmark.readAndWriteWithObjectModel_asm6_1 thrpt 20 261,525 ± 1,003 ops/s
AdapterBenchmark.readAndWrite_asm4_0 thrpt 20 313,583 ± 1,429 ops/s
AdapterBenchmark.readAndWrite_asm5_0 thrpt 20 319,958 ± 2,057 ops/s
AdapterBenchmark.readAndWrite_asm6_0 thrpt 20 316,718 ± 1,316 ops/s
AdapterBenchmark.readAndWrite_asm6_1 thrpt 20 319,508 ± 0,990 ops/s
AdapterBenchmark.readAndWrite_aspectJBcel thrpt 20 100,253 ± 0,353 ops/s
AdapterBenchmark.readAndWrite_bcel thrpt 20 79,329 ± 0,235 ops/s
AdapterBenchmark.readAndWrite_javassist thrpt 20 531,673 ± 1,894 ops/s
AdapterBenchmark.readAndWrite_serp thrpt 20 37,049 ± 0,102 ops/s
AdapterBenchmark.read_asm4_0 thrpt 20 642,491 ± 2,536 ops/s
AdapterBenchmark.read_asm5_0 thrpt 20 682,731 ± 5,122 ops/s
AdapterBenchmark.read_asm6_0 thrpt 20 671,490 ± 3,581 ops/s
AdapterBenchmark.read_asm6_1 thrpt 20 665,407 ± 2,716 ops/s
```Remi ForaxRemi Foraxhttps://gitlab.ow2.org/asm/asm/-/merge_requests/84Improve the memory benchmarks by using the JMH framework.2017-12-30T15:40:06ZEric BrunetonImprove the memory benchmarks by using the JMH framework.Results:
```
Benchmark Mode Cnt Score Error Units
MemoryBenchmark.newClassNode_asm4_0 thrpt 5 196,689 ± 123,711 ops/s
MemoryBenchmark.newClassNode_asm4_0:+mem...Results:
```
Benchmark Mode Cnt Score Error Units
MemoryBenchmark.newClassNode_asm4_0 thrpt 5 196,689 ± 123,711 ops/s
MemoryBenchmark.newClassNode_asm4_0:+memory.used thrpt 5 2798238,715 ± 3602,377 bytes
MemoryBenchmark.newClassNode_asm5_0 thrpt 5 158,445 ± 111,103 ops/s
MemoryBenchmark.newClassNode_asm5_0:+memory.used thrpt 5 2693396,799 ± 4985,178 bytes
MemoryBenchmark.newClassNode_asm6_0 thrpt 5 140,053 ± 95,105 ops/s
MemoryBenchmark.newClassNode_asm6_0:+memory.used thrpt 5 2688716,368 ± 5513,428 bytes
MemoryBenchmark.newClassNode_asm6_1 thrpt 5 165,112 ± 94,423 ops/s
MemoryBenchmark.newClassNode_asm6_1:+memory.used thrpt 5 2690737,112 ± 4993,252 bytes
MemoryBenchmark.newClass_asm4_0 thrpt 5 236,938 ± 183,190 ops/s
MemoryBenchmark.newClass_asm4_0:+memory.used thrpt 5 1823050,423 ± 2051,755 bytes
MemoryBenchmark.newClass_asm5_0 thrpt 5 266,850 ± 3,303 ops/s
MemoryBenchmark.newClass_asm5_0:+memory.used thrpt 5 1847376,794 ± 1919,159 bytes
MemoryBenchmark.newClass_asm6_0 thrpt 5 238,714 ± 197,099 ops/s
MemoryBenchmark.newClass_asm6_0:+memory.used thrpt 5 1848268,051 ± 2092,874 bytes
MemoryBenchmark.newClass_asm6_1 thrpt 5 245,291 ± 163,061 ops/s
MemoryBenchmark.newClass_asm6_1:+memory.used thrpt 5 1844124,244 ± 2064,886 bytes
```Remi ForaxRemi Forax