Skip to content

Commit 0e0823e

Browse files
author
duke
committedNov 23, 2021
Automatic merge of jdk:master into master
2 parents 8ba75a0 + 7b67a49 commit 0e0823e

File tree

3 files changed

+433
-34
lines changed

3 files changed

+433
-34
lines changed
 

‎src/java.base/share/classes/java/lang/runtime/ObjectMethods.java

+104-34
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,11 @@
2929
import java.lang.invoke.MethodHandle;
3030
import java.lang.invoke.MethodHandles;
3131
import java.lang.invoke.MethodType;
32+
import java.lang.invoke.StringConcatFactory;
3233
import java.lang.invoke.TypeDescriptor;
3334
import java.security.AccessController;
3435
import java.security.PrivilegedAction;
36+
import java.util.ArrayList;
3537
import java.util.Arrays;
3638
import java.util.HashMap;
3739
import java.util.List;
@@ -52,6 +54,8 @@ public class ObjectMethods {
5254

5355
private ObjectMethods() { }
5456

57+
private static final int MAX_STRING_CONCAT_SLOTS = 20;
58+
5559
private static final MethodType DESCRIPTOR_MT = MethodType.methodType(MethodType.class);
5660
private static final MethodType NAMES_MT = MethodType.methodType(List.class);
5761
private static final MethodHandle FALSE = MethodHandles.constant(boolean.class, false);
@@ -251,44 +255,110 @@ private static MethodHandle makeHashCode(Class<?> receiverClass,
251255
* @param names the names
252256
* @return the method handle
253257
*/
254-
private static MethodHandle makeToString(Class<?> receiverClass,
255-
List<MethodHandle> getters,
258+
private static MethodHandle makeToString(MethodHandles.Lookup lookup,
259+
Class<?> receiverClass,
260+
MethodHandle[] getters,
256261
List<String> names) {
257-
// This is a pretty lousy algorithm; we spread the receiver over N places,
258-
// apply the N getters, apply N toString operations, and concat the result with String.format
259-
// Better to use String.format directly, or delegate to StringConcatFactory
260-
// Also probably want some quoting around String components
261-
262-
assert getters.size() == names.size();
263-
264-
int[] invArgs = new int[getters.size()];
265-
Arrays.fill(invArgs, 0);
266-
MethodHandle[] filters = new MethodHandle[getters.size()];
267-
StringBuilder sb = new StringBuilder();
268-
sb.append(receiverClass.getSimpleName()).append("[");
269-
for (int i=0; i<getters.size(); i++) {
270-
MethodHandle getter = getters.get(i); // (R)T
271-
MethodHandle stringify = stringifier(getter.type().returnType()); // (T)String
272-
MethodHandle stringifyThisField = MethodHandles.filterArguments(stringify, 0, getter); // (R)String
273-
filters[i] = stringifyThisField;
274-
sb.append(names.get(i)).append("=%s");
275-
if (i != getters.size() - 1)
276-
sb.append(", ");
262+
assert getters.length == names.size();
263+
if (getters.length == 0) {
264+
// special case
265+
MethodHandle emptyRecordCase = MethodHandles.constant(String.class, receiverClass.getSimpleName() + "[]");
266+
emptyRecordCase = MethodHandles.dropArguments(emptyRecordCase, 0, receiverClass); // (R)S
267+
return emptyRecordCase;
277268
}
278-
sb.append(']');
279-
String formatString = sb.toString();
280-
MethodHandle formatter = MethodHandles.insertArguments(STRING_FORMAT, 0, formatString)
281-
.asCollector(String[].class, getters.size()); // (R*)String
282-
if (getters.size() == 0) {
283-
// Add back extra R
284-
formatter = MethodHandles.dropArguments(formatter, 0, receiverClass);
269+
270+
boolean firstTime = true;
271+
MethodHandle[] mhs;
272+
List<List<MethodHandle>> splits;
273+
MethodHandle[] toSplit = getters;
274+
int namesIndex = 0;
275+
do {
276+
/* StringConcatFactory::makeConcatWithConstants can only deal with 200 slots, longs and double occupy two
277+
* the rest 1 slot, we need to chop the current `getters` into chunks, it could be that for records with
278+
* a lot of components that we need to do a couple of iterations. The main difference between the first
279+
* iteration and the rest would be on the recipe
280+
*/
281+
splits = split(toSplit);
282+
mhs = new MethodHandle[splits.size()];
283+
for (int splitIndex = 0; splitIndex < splits.size(); splitIndex++) {
284+
String recipe = "";
285+
if (firstTime && splitIndex == 0) {
286+
recipe = receiverClass.getSimpleName() + "[";
287+
}
288+
for (int i = 0; i < splits.get(splitIndex).size(); i++) {
289+
recipe += firstTime ? names.get(namesIndex) + "=" + "\1" : "\1";
290+
if (firstTime && namesIndex != names.size() - 1) {
291+
recipe += ", ";
292+
}
293+
namesIndex++;
294+
}
295+
if (firstTime && splitIndex == splits.size() - 1) {
296+
recipe += "]";
297+
}
298+
Class<?>[] concatTypeArgs = new Class<?>[splits.get(splitIndex).size()];
299+
// special case: no need to create another getters if there is only one split
300+
MethodHandle[] currentSplitGetters = new MethodHandle[splits.get(splitIndex).size()];
301+
for (int j = 0; j < splits.get(splitIndex).size(); j++) {
302+
concatTypeArgs[j] = splits.get(splitIndex).get(j).type().returnType();
303+
currentSplitGetters[j] = splits.get(splitIndex).get(j);
304+
}
305+
MethodType concatMT = MethodType.methodType(String.class, concatTypeArgs);
306+
try {
307+
mhs[splitIndex] = StringConcatFactory.makeConcatWithConstants(
308+
lookup, "",
309+
concatMT,
310+
recipe,
311+
new Object[0]
312+
).getTarget();
313+
mhs[splitIndex] = MethodHandles.filterArguments(mhs[splitIndex], 0, currentSplitGetters);
314+
// this will spread the receiver class across all the getters
315+
mhs[splitIndex] = MethodHandles.permuteArguments(
316+
mhs[splitIndex],
317+
MethodType.methodType(String.class, receiverClass),
318+
new int[splits.get(splitIndex).size()]
319+
);
320+
} catch (Throwable t) {
321+
throw new RuntimeException(t);
322+
}
323+
}
324+
toSplit = mhs;
325+
firstTime = false;
326+
} while (splits.size() > 1);
327+
return mhs[0];
328+
}
329+
330+
/**
331+
* Chops the getters into smaller chunks according to the maximum number of slots
332+
* StringConcatFactory::makeConcatWithConstants can chew
333+
* @param getters the current getters
334+
* @return chunks that wont surpass the maximum number of slots StringConcatFactory::makeConcatWithConstants can chew
335+
*/
336+
private static List<List<MethodHandle>> split(MethodHandle[] getters) {
337+
List<List<MethodHandle>> splits = new ArrayList<>();
338+
339+
int slots = 0;
340+
341+
// Need to peel, so that neither call has more than acceptable number
342+
// of slots for the arguments.
343+
List<MethodHandle> cArgs = new ArrayList<>();
344+
for (MethodHandle methodHandle : getters) {
345+
Class<?> returnType = methodHandle.type().returnType();
346+
int needSlots = (returnType == long.class || returnType == double.class) ? 2 : 1;
347+
if (slots + needSlots > MAX_STRING_CONCAT_SLOTS) {
348+
splits.add(cArgs);
349+
cArgs = new ArrayList<>();
350+
slots = 0;
351+
}
352+
cArgs.add(methodHandle);
353+
slots += needSlots;
285354
}
286-
else {
287-
MethodHandle filtered = MethodHandles.filterArguments(formatter, 0, filters);
288-
formatter = MethodHandles.permuteArguments(filtered, MethodType.methodType(String.class, receiverClass), invArgs);
355+
356+
// Flush the tail slice
357+
if (!cArgs.isEmpty()) {
358+
splits.add(cArgs);
289359
}
290360

291-
return formatter;
361+
return splits;
292362
}
293363

294364
/**
@@ -367,7 +437,7 @@ public static Object bootstrap(MethodHandles.Lookup lookup, String methodName, T
367437
List<String> nameList = "".equals(names) ? List.of() : List.of(names.split(";"));
368438
if (nameList.size() != getterList.size())
369439
throw new IllegalArgumentException("Name list and accessor list do not match");
370-
yield makeToString(recordClass, getterList, nameList);
440+
yield makeToString(lookup, recordClass, getters, nameList);
371441
}
372442
default -> throw new IllegalArgumentException(methodName);
373443
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
1+
/*
2+
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
5+
* This code is free software; you can redistribute it and/or modify it
6+
* under the terms of the GNU General Public License version 2 only, as
7+
* published by the Free Software Foundation.
8+
*
9+
* This code is distributed in the hope that it will be useful, but WITHOUT
10+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12+
* version 2 for more details (a copy is included in the LICENSE file that
13+
* accompanied this code).
14+
*
15+
* You should have received a copy of the GNU General Public License version
16+
* 2 along with this work; if not, write to the Free Software Foundation,
17+
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18+
*
19+
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20+
* or visit www.oracle.com if you need additional information or have any
21+
* questions.
22+
*/
23+
24+
/**
25+
* @test
26+
* @bug 8261847
27+
* @summary test the output of the toString method of records with a large number of components
28+
* @run testng BigRecordsToStringTest
29+
*/
30+
31+
import java.lang.reflect.Constructor;
32+
import java.lang.reflect.Field;
33+
import java.lang.reflect.Method;
34+
import java.lang.reflect.Modifier;
35+
import java.lang.reflect.Parameter;
36+
import java.util.List;
37+
import java.util.function.Supplier;
38+
39+
import org.testng.annotations.*;
40+
import static org.testng.Assert.*;
41+
42+
@Test
43+
public class BigRecordsToStringTest {
44+
record BigInt(
45+
int i1,int i2,int i3,int i4,int i5,int i6,int i7,int i8,int i9,int i10,
46+
int i11,int i12,int i13,int i14,int i15,int i16,int i17,int i18,int i19,int i20,
47+
int i21,int i22,int i23,int i24,int i25,int i26,int i27,int i28,int i29,int i30,
48+
int i31,int i32,int i33,int i34,int i35,int i36,int i37,int i38,int i39,int i40,
49+
int i41,int i42,int i43,int i44,int i45,int i46,int i47,int i48,int i49,int i50,
50+
int i51,int i52,int i53,int i54,int i55,int i56,int i57,int i58,int i59,int i60,
51+
int i61,int i62,int i63,int i64,int i65,int i66,int i67,int i68,int i69,int i70,
52+
int i71,int i72,int i73,int i74,int i75,int i76,int i77,int i78,int i79,int i80,
53+
int i81,int i82,int i83,int i84,int i85,int i86,int i87,int i88,int i89,int i90,
54+
int i91,int i92,int i93,int i94,int i95,int i96,int i97,int i98,int i99,int i100,
55+
int i101,int i102,int i103,int i104,int i105,int i106,int i107,int i108,int i109,int i110,
56+
int i111,int i112,int i113,int i114,int i115,int i116,int i117,int i118,int i119,int i120,
57+
int i121,int i122,int i123,int i124,int i125,int i126,int i127,int i128,int i129,int i130,
58+
int i131,int i132,int i133,int i134,int i135,int i136,int i137,int i138,int i139,int i140,
59+
int i141,int i142,int i143,int i144,int i145,int i146,int i147,int i148,int i149,int i150,
60+
int i151,int i152,int i153,int i154,int i155,int i156,int i157,int i158,int i159,int i160,
61+
int i161,int i162,int i163,int i164,int i165,int i166,int i167,int i168,int i169,int i170,
62+
int i171,int i172,int i173,int i174,int i175,int i176,int i177,int i178,int i179,int i180,
63+
int i181,int i182,int i183,int i184,int i185,int i186,int i187,int i188,int i189,int i190,
64+
int i191,int i192,int i193,int i194,int i195,int i196,int i197,int i198,int i199, int i200,
65+
int i201,int i202,int i203,int i204,int i205,int i206,int i207,int i208,int i209,int i210,
66+
int i211,int i212,int i213,int i214,int i215,int i216,int i217,int i218,int i219,int i220,
67+
int i221,int i222,int i223,int i224,int i225,int i226,int i227,int i228,int i229,int i230,
68+
int i231,int i232,int i233,int i234,int i235,int i236,int i237,int i238,int i239,int i240,
69+
int i241,int i242,int i243,int i244,int i245,int i246,int i247,int i248,int i249,int i250,
70+
int i251,int i252,int i253,int i254
71+
) {}
72+
73+
BigInt bigInt= new BigInt(
74+
1,2,3,4,5,6,7,8,9,10,
75+
11,12,13,14,15,16,17,18,19,20,
76+
21,22,23,24,25,26,27,28,29,30,
77+
31,32,33,34,35,36,37,38,39,40,
78+
41,42,43,44,45,46,47,48,49,50,
79+
51,52,53,54,55,56,57,58,59,60,
80+
61,62,63,64,65,66,67,68,69,70,
81+
71,72,73,74,75,76,77,78,79,80,
82+
81,82,83,84,85,86,87,88,89,90,
83+
91,92,93,94,95,96,97,98,99,100,
84+
101,102,103,104,105,106,107,108,109,110,
85+
111,112,113,114,115,116,117,118,119,120,
86+
121,122,123,124,125,126,127,128,129,130,
87+
131,132,133,134,135,136,137,138,139,140,
88+
141,142,143,144,145,146,147,148,149,150,
89+
151,152,153,154,155,156,157,158,159,160,
90+
161,162,163,164,165,166,167,168,169,170,
91+
171,172,173,174,175,176,177,178,179,180,
92+
181,182,183,184,185,186,187,188,189,190,
93+
191,192,193,194,195,196,197,198,199, 200,
94+
201,202,203,204,205,206,207,208,209,210,
95+
211,212,213,214,215,216,217,218,219,220,
96+
221,222,223,224,225,226,227,228,229,230,
97+
231,232,233,234,235,236,237,238,239,240,
98+
241,242,243,244,245,246,247,248,249,250,
99+
251,252,253,254
100+
);
101+
102+
record BigLong(
103+
long i1,long i2,long i3,long i4,long i5,long i6,long i7,long i8,long i9,long i10,
104+
long i11,long i12,long i13,long i14,long i15,long i16,long i17,long i18,long i19,long i20,
105+
long i21,long i22,long i23,long i24,long i25,long i26,long i27,long i28,long i29,long i30,
106+
long i31,long i32,long i33,long i34,long i35,long i36,long i37,long i38,long i39,long i40,
107+
long i41,long i42,long i43,long i44,long i45,long i46,long i47,long i48,long i49,long i50,
108+
long i51,long i52,long i53,long i54,long i55,long i56,long i57,long i58,long i59,long i60,
109+
long i61,long i62,long i63,long i64,long i65,long i66,long i67,long i68,long i69,long i70,
110+
long i71,long i72,long i73,long i74,long i75,long i76,long i77,long i78,long i79,long i80,
111+
long i81,long i82,long i83,long i84,long i85,long i86,long i87,long i88,long i89,long i90,
112+
long i91,long i92,long i93,long i94,long i95,long i96,long i97,long i98,long i99,long i100,
113+
long i101,long i102,long i103,long i104,long i105,long i106,long i107,long i108,long i109,long i110,
114+
long i111,long i112,long i113,long i114,long i115,long i116,long i117,long i118,long i119,long i120,
115+
long i121,long i122,long i123,long i124,long i125,long i126,long i127
116+
) {}
117+
118+
BigLong bigLong = new BigLong(
119+
1,2,3,4,5,6,7,8,9,10,
120+
11,12,13,14,15,16,17,18,19,20,
121+
21,22,23,24,25,26,27,28,29,30,
122+
31,32,33,34,35,36,37,38,39,40,
123+
41,42,43,44,45,46,47,48,49,50,
124+
51,52,53,54,55,56,57,58,59,60,
125+
61,62,63,64,65,66,67,68,69,70,
126+
71,72,73,74,75,76,77,78,79,80,
127+
81,82,83,84,85,86,87,88,89,90,
128+
91,92,93,94,95,96,97,98,99,100,
129+
101,102,103,104,105,106,107,108,109,110,
130+
111,112,113,114,115,116,117,118,119,120,
131+
121,122,123,124,125,126,127
132+
);
133+
134+
private static final String BIG_INT_TO_STRING_OUTPUT =
135+
"BigInt[i1=1, i2=2, i3=3, i4=4, i5=5, i6=6, i7=7, i8=8, i9=9, i10=10, i11=11, i12=12, i13=13, i14=14, i15=15, i16=16, " +
136+
"i17=17, i18=18, i19=19, i20=20, i21=21, i22=22, i23=23, i24=24, i25=25, i26=26, i27=27, i28=28, i29=29, i30=30, " +
137+
"i31=31, i32=32, i33=33, i34=34, i35=35, i36=36, i37=37, i38=38, i39=39, i40=40, i41=41, i42=42, i43=43, i44=44, " +
138+
"i45=45, i46=46, i47=47, i48=48, i49=49, i50=50, i51=51, i52=52, i53=53, i54=54, i55=55, i56=56, i57=57, i58=58, " +
139+
"i59=59, i60=60, i61=61, i62=62, i63=63, i64=64, i65=65, i66=66, i67=67, i68=68, i69=69, i70=70, i71=71, i72=72, " +
140+
"i73=73, i74=74, i75=75, i76=76, i77=77, i78=78, i79=79, i80=80, i81=81, i82=82, i83=83, i84=84, i85=85, i86=86, " +
141+
"i87=87, i88=88, i89=89, i90=90, i91=91, i92=92, i93=93, i94=94, i95=95, i96=96, i97=97, i98=98, i99=99, i100=100, " +
142+
"i101=101, i102=102, i103=103, i104=104, i105=105, i106=106, i107=107, i108=108, i109=109, i110=110, i111=111, i112=112, " +
143+
"i113=113, i114=114, i115=115, i116=116, i117=117, i118=118, i119=119, i120=120, i121=121, i122=122, i123=123, i124=124, " +
144+
"i125=125, i126=126, i127=127, i128=128, i129=129, i130=130, i131=131, i132=132, i133=133, i134=134, i135=135, i136=136, " +
145+
"i137=137, i138=138, i139=139, i140=140, i141=141, i142=142, i143=143, i144=144, i145=145, i146=146, i147=147, i148=148, " +
146+
"i149=149, i150=150, i151=151, i152=152, i153=153, i154=154, i155=155, i156=156, i157=157, i158=158, i159=159, i160=160, " +
147+
"i161=161, i162=162, i163=163, i164=164, i165=165, i166=166, i167=167, i168=168, i169=169, i170=170, i171=171, i172=172, " +
148+
"i173=173, i174=174, i175=175, i176=176, i177=177, i178=178, i179=179, i180=180, i181=181, i182=182, i183=183, i184=184, " +
149+
"i185=185, i186=186, i187=187, i188=188, i189=189, i190=190, i191=191, i192=192, i193=193, i194=194, i195=195, i196=196, " +
150+
"i197=197, i198=198, i199=199, i200=200, i201=201, i202=202, i203=203, i204=204, i205=205, i206=206, i207=207, i208=208, " +
151+
"i209=209, i210=210, i211=211, i212=212, i213=213, i214=214, i215=215, i216=216, i217=217, i218=218, i219=219, i220=220, " +
152+
"i221=221, i222=222, i223=223, i224=224, i225=225, i226=226, i227=227, i228=228, i229=229, i230=230, i231=231, i232=232, " +
153+
"i233=233, i234=234, i235=235, i236=236, i237=237, i238=238, i239=239, i240=240, i241=241, i242=242, i243=243, i244=244, " +
154+
"i245=245, i246=246, i247=247, i248=248, i249=249, i250=250, i251=251, i252=252, i253=253, i254=254]";
155+
156+
private static final String BIG_LONG_TO_STRING_OUTPUT =
157+
"BigLong[i1=1, i2=2, i3=3, i4=4, i5=5, i6=6, i7=7, i8=8, i9=9, i10=10, i11=11, i12=12, i13=13, i14=14, i15=15, i16=16, i17=17, " +
158+
"i18=18, i19=19, i20=20, i21=21, i22=22, i23=23, i24=24, i25=25, i26=26, i27=27, i28=28, i29=29, i30=30, i31=31, i32=32, i33=33, " +
159+
"i34=34, i35=35, i36=36, i37=37, i38=38, i39=39, i40=40, i41=41, i42=42, i43=43, i44=44, i45=45, i46=46, i47=47, i48=48, i49=49, " +
160+
"i50=50, i51=51, i52=52, i53=53, i54=54, i55=55, i56=56, i57=57, i58=58, i59=59, i60=60, i61=61, i62=62, i63=63, i64=64, i65=65, " +
161+
"i66=66, i67=67, i68=68, i69=69, i70=70, i71=71, i72=72, i73=73, i74=74, i75=75, i76=76, i77=77, i78=78, i79=79, i80=80, i81=81, " +
162+
"i82=82, i83=83, i84=84, i85=85, i86=86, i87=87, i88=88, i89=89, i90=90, i91=91, i92=92, i93=93, i94=94, i95=95, i96=96, i97=97, " +
163+
"i98=98, i99=99, i100=100, i101=101, i102=102, i103=103, i104=104, i105=105, i106=106, i107=107, i108=108, i109=109, i110=110, " +
164+
"i111=111, i112=112, i113=113, i114=114, i115=115, i116=116, i117=117, i118=118, i119=119, i120=120, i121=121, i122=122, i123=123, " +
165+
"i124=124, i125=125, i126=126, i127=127]";
166+
167+
public void testToStringOutput() {
168+
assertTrue(bigInt.toString().equals(BIG_INT_TO_STRING_OUTPUT));
169+
assertTrue(bigLong.toString().equals(BIG_LONG_TO_STRING_OUTPUT));
170+
}
171+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
/*
2+
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
5+
* This code is free software; you can redistribute it and/or modify it
6+
* under the terms of the GNU General Public License version 2 only, as
7+
* published by the Free Software Foundation.
8+
*
9+
* This code is distributed in the hope that it will be useful, but WITHOUT
10+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12+
* version 2 for more details (a copy is included in the LICENSE file that
13+
* accompanied this code).
14+
*
15+
* You should have received a copy of the GNU General Public License version
16+
* 2 along with this work; if not, write to the Free Software Foundation,
17+
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18+
*
19+
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20+
* or visit www.oracle.com if you need additional information or have any
21+
* questions.
22+
*/
23+
package org.openjdk.bench.java.lang.runtime;
24+
25+
import org.openjdk.jmh.annotations.Benchmark;
26+
import org.openjdk.jmh.annotations.BenchmarkMode;
27+
import org.openjdk.jmh.annotations.Mode;
28+
import org.openjdk.jmh.annotations.OutputTimeUnit;
29+
import org.openjdk.jmh.annotations.Scope;
30+
import org.openjdk.jmh.annotations.Setup;
31+
import org.openjdk.jmh.annotations.State;
32+
33+
import java.lang.invoke.MethodHandle;
34+
import java.lang.invoke.MethodHandles;
35+
import java.lang.invoke.MethodType;
36+
import java.util.concurrent.TimeUnit;
37+
38+
/**
39+
* Benchmark assesses Record.toString which is implemented by ObjectMethods::makeToString
40+
*/
41+
@BenchmarkMode(Mode.AverageTime)
42+
@OutputTimeUnit(TimeUnit.NANOSECONDS)
43+
@State(Scope.Thread)
44+
public class ObjectMethods {
45+
record R0() {}
46+
record R1(int i) {}
47+
record R10(int i1,int i2,int i3,int i4,int i5,int i6,int i7,int i8,int i9,int i10) {}
48+
record R100(int i1,int i2,int i3,int i4,int i5,int i6,int i7,int i8,int i9,int i10,
49+
int i11,int i12,int i13,int i14,int i15,int i16,int i17,int i18,int i19,int i20,
50+
int i21,int i22,int i23,int i24,int i25,int i26,int i27,int i28,int i29,int i30,
51+
int i31,int i32,int i33,int i34,int i35,int i36,int i37,int i38,int i39,int i40,
52+
int i41,int i42,int i43,int i44,int i45,int i46,int i47,int i48,int i49,int i50,
53+
int i51,int i52,int i53,int i54,int i55,int i56,int i57,int i58,int i59,int i60,
54+
int i61,int i62,int i63,int i64,int i65,int i66,int i67,int i68,int i69,int i70,
55+
int i71,int i72,int i73,int i74,int i75,int i76,int i77,int i78,int i79,int i80,
56+
int i81,int i82,int i83,int i84,int i85,int i86,int i87,int i88,int i89,int i90,
57+
int i91,int i92,int i93,int i94,int i95,int i96,int i97,int i98,int i99,int i100) {}
58+
record R254(int i1,int i2,int i3,int i4,int i5,int i6,int i7,int i8,int i9,int i10,
59+
int i11,int i12,int i13,int i14,int i15,int i16,int i17,int i18,int i19,int i20,
60+
int i21,int i22,int i23,int i24,int i25,int i26,int i27,int i28,int i29,int i30,
61+
int i31,int i32,int i33,int i34,int i35,int i36,int i37,int i38,int i39,int i40,
62+
int i41,int i42,int i43,int i44,int i45,int i46,int i47,int i48,int i49,int i50,
63+
int i51,int i52,int i53,int i54,int i55,int i56,int i57,int i58,int i59,int i60,
64+
int i61,int i62,int i63,int i64,int i65,int i66,int i67,int i68,int i69,int i70,
65+
int i71,int i72,int i73,int i74,int i75,int i76,int i77,int i78,int i79,int i80,
66+
int i81,int i82,int i83,int i84,int i85,int i86,int i87,int i88,int i89,int i90,
67+
int i91,int i92,int i93,int i94,int i95,int i96,int i97,int i98,int i99,int i100,
68+
int i101,int i102,int i103,int i104,int i105,int i106,int i107,int i108,int i109,int i110,
69+
int i111,int i112,int i113,int i114,int i115,int i116,int i117,int i118,int i119,int i120,
70+
int i121,int i122,int i123,int i124,int i125,int i126,int i127,int i128,int i129,int i130,
71+
int i131,int i132,int i133,int i134,int i135,int i136,int i137,int i138,int i139,int i140,
72+
int i141,int i142,int i143,int i144,int i145,int i146,int i147,int i148,int i149,int i150,
73+
int i151,int i152,int i153,int i154,int i155,int i156,int i157,int i158,int i159,int i160,
74+
int i161,int i162,int i163,int i164,int i165,int i166,int i167,int i168,int i169,int i170,
75+
int i171,int i172,int i173,int i174,int i175,int i176,int i177,int i178,int i179,int i180,
76+
int i181,int i182,int i183,int i184,int i185,int i186,int i187,int i188,int i189,int i190,
77+
int i191,int i192,int i193,int i194,int i195,int i196,int i197,int i198,int i199, int i200,
78+
int i201,int i202,int i203,int i204,int i205,int i206,int i207,int i208,int i209,int i210,
79+
int i211,int i212,int i213,int i214,int i215,int i216,int i217,int i218,int i219,int i220,
80+
int i221,int i222,int i223,int i224,int i225,int i226,int i227,int i228,int i229,int i230,
81+
int i231,int i232,int i233,int i234,int i235,int i236,int i237,int i238,int i239,int i240,
82+
int i241,int i242,int i243,int i244,int i245,int i246,int i247,int i248,int i249,int i250,
83+
int i251,int i252,int i253,int i254) {}
84+
85+
R0 r0;
86+
R1 r1;
87+
R10 r10;
88+
R100 r100;
89+
R254 r254;
90+
91+
@Setup
92+
public void prepare() {
93+
r0 = new R0();
94+
r1 = new R1(1);
95+
r10 = new R10(1,2,3,4,5,6,7,8,9,10);
96+
r100 = new R100(1,2,3,4,5,6,7,8,9,10,
97+
11,12,13,14,15,16,17,18,19,20,
98+
21,22,23,24,25,26,27,28,29,30,
99+
31,32,33,34,35,36,37,38,39,40,
100+
41,42,43,44,45,46,47,48,49,50,
101+
51,52,53,54,55,56,57,58,59,60,
102+
61,62,63,64,65,66,67,68,69,70,
103+
71,72,73,74,75,76,77,78,79,80,
104+
81,82,83,84,85,86,87,88,89,90,
105+
91,92,93,94,95,96,97,98,99,100);
106+
r254 = new R254(1,2,3,4,5,6,7,8,9,10,
107+
11,12,13,14,15,16,17,18,19,20,
108+
21,22,23,24,25,26,27,28,29,30,
109+
31,32,33,34,35,36,37,38,39,40,
110+
41,42,43,44,45,46,47,48,49,50,
111+
51,52,53,54,55,56,57,58,59,60,
112+
61,62,63,64,65,66,67,68,69,70,
113+
71,72,73,74,75,76,77,78,79,80,
114+
81,82,83,84,85,86,87,88,89,90,
115+
91,92,93,94,95,96,97,98,99,100,
116+
101,102,103,104,105,106,107,108,109,110,
117+
111,112,113,114,115,116,117,118,119,120,
118+
121,122,123,124,125,126,127,128,129,130,
119+
131,132,133,134,135,136,137,138,139,140,
120+
141,142,143,144,145,146,147,148,149,150,
121+
151,152,153,154,155,156,157,158,159,160,
122+
161,162,163,164,165,166,167,168,169,170,
123+
171,172,173,174,175,176,177,178,179,180,
124+
181,182,183,184,185,186,187,188,189,190,
125+
191,192,193,194,195,196,197,198,199, 200,
126+
201,202,203,204,205,206,207,208,209,210,
127+
211,212,213,214,215,216,217,218,219,220,
128+
221,222,223,224,225,226,227,228,229,230,
129+
231,232,233,234,235,236,237,238,239,240,
130+
241,242,243,244,245,246,247,248,249,250,
131+
251,252,253,254);
132+
}
133+
134+
@Benchmark
135+
public String toString0() {
136+
return r0.toString();
137+
}
138+
139+
@Benchmark
140+
public String toString1() {
141+
return r1.toString();
142+
}
143+
144+
@Benchmark
145+
public String toString10() {
146+
return r10.toString();
147+
}
148+
149+
@Benchmark
150+
public String toString100() {
151+
return r100.toString();
152+
}
153+
154+
@Benchmark
155+
public String toString254() {
156+
return r254.toString();
157+
}
158+
}

0 commit comments

Comments
 (0)
Please sign in to comment.