1 /*
   2  * Copyright (c) 2016, 2019, 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 package gc;
  25 
  26 import jdk.internal.vm.annotation.Contended;
  27 
  28 /*
  29  * @test TestHumongousReferenceObjectParallel
  30  * @summary Test that verifies that iteration over large, plain Java objects, that potentially cross region boundaries, with references in them works.
  31  * @requires vm.gc.Parallel
  32  * @bug 8151499 8153734
  33  * @modules java.base/jdk.internal.vm.annotation
  34  * @run main/othervm -XX:+EnableContended -XX:-RestrictContended -Xmx128m -XX:+UseParallelGC -XX:ContendedPaddingWidth=8192 gc.TestHumongousReferenceObject
  35  */
  36 
  37 /*
  38  * @test TestHumongousReferenceObjectG1
  39  * @summary Test that verifies that iteration over large, plain Java objects, that potentially cross region boundaries on G1, with references in them works.
  40  * @requires vm.gc.G1
  41  * @bug 8151499 8153734
  42  * @modules java.base/jdk.internal.vm.annotation
  43  * @run main/othervm -XX:+EnableContended -XX:-RestrictContended -Xmx128m -XX:+UseG1GC -XX:G1HeapRegionSize=1M -XX:ContendedPaddingWidth=8192 gc.TestHumongousReferenceObject
  44  * @run main/othervm -XX:+EnableContended -XX:-RestrictContended -Xmx128m -XX:+UseG1GC -XX:G1HeapRegionSize=2M -XX:ContendedPaddingWidth=8192 gc.TestHumongousReferenceObject
  45  * @run main/othervm -XX:+EnableContended -XX:-RestrictContended -Xmx128m -XX:+UseG1GC -XX:G1HeapRegionSize=4M -XX:ContendedPaddingWidth=8192 gc.TestHumongousReferenceObject
  46  * @run main/othervm -XX:+EnableContended -XX:-RestrictContended -Xmx128m -XX:+UseG1GC -XX:G1HeapRegionSize=8M -XX:ContendedPaddingWidth=8192 gc.TestHumongousReferenceObject
  47  */
  48 
  49 /*
  50  * @test TestHumongousReferenceObjectShenandoah
  51  * @summary Test that verifies that iteration over large, plain Java objects, that potentially cross region boundaries, with references in them works.
  52  * @requires vm.gc.Shenandoah & !vm.graal.enabled
  53  * @bug 8151499 8153734
  54  * @modules java.base/jdk.internal.vm.annotation
  55  * @run main/othervm -XX:+EnableContended -XX:-RestrictContended -Xms128m -Xmx128m -XX:+UnlockExperimentalVMOptions -XX:+UseShenandoahGC -XX:ShenandoahHeapRegionSize=8M -XX:ContendedPaddingWidth=8192 gc.TestHumongousReferenceObject
  56  * @run main/othervm -XX:+EnableContended -XX:-RestrictContended -Xms128m -Xmx128m -XX:+UnlockExperimentalVMOptions -XX:+UseShenandoahGC -XX:ShenandoahHeapRegionSize=8M -XX:ContendedPaddingWidth=8192 -XX:+UnlockDiagnosticVMOptions -XX:+ShenandoahVerify gc.TestHumongousReferenceObject
  57  */
  58 public class TestHumongousReferenceObject {
  59 
  60     /*
  61       Due to 300 fields with 8K @Contended padding around each field, it takes 2.4M bytes per instance.
  62       With small G1 regions, it is bound to cross regions. G1 should properly (card) mark the object nevertheless.
  63       With 128M heap, it is enough to allocate ~100 of these objects to provoke at least one GC.
  64      */
  65 
  66     static volatile Object instance;
  67 
  68     public static void main(String[] args) {
  69         for (int c = 0; c < 100; c++) {
  70             instance = new TestHumongousReferenceObject();
  71         }
  72     }
  73 
  74     @Contended Integer int_1 = new Integer(1);
  75     @Contended Integer int_2 = new Integer(2);
  76     @Contended Integer int_3 = new Integer(3);
  77     @Contended Integer int_4 = new Integer(4);
  78     @Contended Integer int_5 = new Integer(5);
  79     @Contended Integer int_6 = new Integer(6);
  80     @Contended Integer int_7 = new Integer(7);
  81     @Contended Integer int_8 = new Integer(8);
  82     @Contended Integer int_9 = new Integer(9);
  83     @Contended Integer int_10 = new Integer(10);
  84     @Contended Integer int_11 = new Integer(11);
  85     @Contended Integer int_12 = new Integer(12);
  86     @Contended Integer int_13 = new Integer(13);
  87     @Contended Integer int_14 = new Integer(14);
  88     @Contended Integer int_15 = new Integer(15);
  89     @Contended Integer int_16 = new Integer(16);
  90     @Contended Integer int_17 = new Integer(17);
  91     @Contended Integer int_18 = new Integer(18);
  92     @Contended Integer int_19 = new Integer(19);
  93     @Contended Integer int_20 = new Integer(20);
  94     @Contended Integer int_21 = new Integer(21);
  95     @Contended Integer int_22 = new Integer(22);
  96     @Contended Integer int_23 = new Integer(23);
  97     @Contended Integer int_24 = new Integer(24);
  98     @Contended Integer int_25 = new Integer(25);
  99     @Contended Integer int_26 = new Integer(26);
 100     @Contended Integer int_27 = new Integer(27);
 101     @Contended Integer int_28 = new Integer(28);
 102     @Contended Integer int_29 = new Integer(29);
 103     @Contended Integer int_30 = new Integer(30);
 104     @Contended Integer int_31 = new Integer(31);
 105     @Contended Integer int_32 = new Integer(32);
 106     @Contended Integer int_33 = new Integer(33);
 107     @Contended Integer int_34 = new Integer(34);
 108     @Contended Integer int_35 = new Integer(35);
 109     @Contended Integer int_36 = new Integer(36);
 110     @Contended Integer int_37 = new Integer(37);
 111     @Contended Integer int_38 = new Integer(38);
 112     @Contended Integer int_39 = new Integer(39);
 113     @Contended Integer int_40 = new Integer(40);
 114     @Contended Integer int_41 = new Integer(41);
 115     @Contended Integer int_42 = new Integer(42);
 116     @Contended Integer int_43 = new Integer(43);
 117     @Contended Integer int_44 = new Integer(44);
 118     @Contended Integer int_45 = new Integer(45);
 119     @Contended Integer int_46 = new Integer(46);
 120     @Contended Integer int_47 = new Integer(47);
 121     @Contended Integer int_48 = new Integer(48);
 122     @Contended Integer int_49 = new Integer(49);
 123     @Contended Integer int_50 = new Integer(50);
 124     @Contended Integer int_51 = new Integer(51);
 125     @Contended Integer int_52 = new Integer(52);
 126     @Contended Integer int_53 = new Integer(53);
 127     @Contended Integer int_54 = new Integer(54);
 128     @Contended Integer int_55 = new Integer(55);
 129     @Contended Integer int_56 = new Integer(56);
 130     @Contended Integer int_57 = new Integer(57);
 131     @Contended Integer int_58 = new Integer(58);
 132     @Contended Integer int_59 = new Integer(59);
 133     @Contended Integer int_60 = new Integer(60);
 134     @Contended Integer int_61 = new Integer(61);
 135     @Contended Integer int_62 = new Integer(62);
 136     @Contended Integer int_63 = new Integer(63);
 137     @Contended Integer int_64 = new Integer(64);
 138     @Contended Integer int_65 = new Integer(65);
 139     @Contended Integer int_66 = new Integer(66);
 140     @Contended Integer int_67 = new Integer(67);
 141     @Contended Integer int_68 = new Integer(68);
 142     @Contended Integer int_69 = new Integer(69);
 143     @Contended Integer int_70 = new Integer(70);
 144     @Contended Integer int_71 = new Integer(71);
 145     @Contended Integer int_72 = new Integer(72);
 146     @Contended Integer int_73 = new Integer(73);
 147     @Contended Integer int_74 = new Integer(74);
 148     @Contended Integer int_75 = new Integer(75);
 149     @Contended Integer int_76 = new Integer(76);
 150     @Contended Integer int_77 = new Integer(77);
 151     @Contended Integer int_78 = new Integer(78);
 152     @Contended Integer int_79 = new Integer(79);
 153     @Contended Integer int_80 = new Integer(80);
 154     @Contended Integer int_81 = new Integer(81);
 155     @Contended Integer int_82 = new Integer(82);
 156     @Contended Integer int_83 = new Integer(83);
 157     @Contended Integer int_84 = new Integer(84);
 158     @Contended Integer int_85 = new Integer(85);
 159     @Contended Integer int_86 = new Integer(86);
 160     @Contended Integer int_87 = new Integer(87);
 161     @Contended Integer int_88 = new Integer(88);
 162     @Contended Integer int_89 = new Integer(89);
 163     @Contended Integer int_90 = new Integer(90);
 164     @Contended Integer int_91 = new Integer(91);
 165     @Contended Integer int_92 = new Integer(92);
 166     @Contended Integer int_93 = new Integer(93);
 167     @Contended Integer int_94 = new Integer(94);
 168     @Contended Integer int_95 = new Integer(95);
 169     @Contended Integer int_96 = new Integer(96);
 170     @Contended Integer int_97 = new Integer(97);
 171     @Contended Integer int_98 = new Integer(98);
 172     @Contended Integer int_99 = new Integer(99);
 173     @Contended Integer int_100 = new Integer(100);
 174     @Contended Integer int_101 = new Integer(101);
 175     @Contended Integer int_102 = new Integer(102);
 176     @Contended Integer int_103 = new Integer(103);
 177     @Contended Integer int_104 = new Integer(104);
 178     @Contended Integer int_105 = new Integer(105);
 179     @Contended Integer int_106 = new Integer(106);
 180     @Contended Integer int_107 = new Integer(107);
 181     @Contended Integer int_108 = new Integer(108);
 182     @Contended Integer int_109 = new Integer(109);
 183     @Contended Integer int_110 = new Integer(110);
 184     @Contended Integer int_111 = new Integer(111);
 185     @Contended Integer int_112 = new Integer(112);
 186     @Contended Integer int_113 = new Integer(113);
 187     @Contended Integer int_114 = new Integer(114);
 188     @Contended Integer int_115 = new Integer(115);
 189     @Contended Integer int_116 = new Integer(116);
 190     @Contended Integer int_117 = new Integer(117);
 191     @Contended Integer int_118 = new Integer(118);
 192     @Contended Integer int_119 = new Integer(119);
 193     @Contended Integer int_120 = new Integer(120);
 194     @Contended Integer int_121 = new Integer(121);
 195     @Contended Integer int_122 = new Integer(122);
 196     @Contended Integer int_123 = new Integer(123);
 197     @Contended Integer int_124 = new Integer(124);
 198     @Contended Integer int_125 = new Integer(125);
 199     @Contended Integer int_126 = new Integer(126);
 200     @Contended Integer int_127 = new Integer(127);
 201     @Contended Integer int_128 = new Integer(128);
 202     @Contended Integer int_129 = new Integer(129);
 203     @Contended Integer int_130 = new Integer(130);
 204     @Contended Integer int_131 = new Integer(131);
 205     @Contended Integer int_132 = new Integer(132);
 206     @Contended Integer int_133 = new Integer(133);
 207     @Contended Integer int_134 = new Integer(134);
 208     @Contended Integer int_135 = new Integer(135);
 209     @Contended Integer int_136 = new Integer(136);
 210     @Contended Integer int_137 = new Integer(137);
 211     @Contended Integer int_138 = new Integer(138);
 212     @Contended Integer int_139 = new Integer(139);
 213     @Contended Integer int_140 = new Integer(140);
 214     @Contended Integer int_141 = new Integer(141);
 215     @Contended Integer int_142 = new Integer(142);
 216     @Contended Integer int_143 = new Integer(143);
 217     @Contended Integer int_144 = new Integer(144);
 218     @Contended Integer int_145 = new Integer(145);
 219     @Contended Integer int_146 = new Integer(146);
 220     @Contended Integer int_147 = new Integer(147);
 221     @Contended Integer int_148 = new Integer(148);
 222     @Contended Integer int_149 = new Integer(149);
 223     @Contended Integer int_150 = new Integer(150);
 224     @Contended Integer int_151 = new Integer(151);
 225     @Contended Integer int_152 = new Integer(152);
 226     @Contended Integer int_153 = new Integer(153);
 227     @Contended Integer int_154 = new Integer(154);
 228     @Contended Integer int_155 = new Integer(155);
 229     @Contended Integer int_156 = new Integer(156);
 230     @Contended Integer int_157 = new Integer(157);
 231     @Contended Integer int_158 = new Integer(158);
 232     @Contended Integer int_159 = new Integer(159);
 233     @Contended Integer int_160 = new Integer(160);
 234     @Contended Integer int_161 = new Integer(161);
 235     @Contended Integer int_162 = new Integer(162);
 236     @Contended Integer int_163 = new Integer(163);
 237     @Contended Integer int_164 = new Integer(164);
 238     @Contended Integer int_165 = new Integer(165);
 239     @Contended Integer int_166 = new Integer(166);
 240     @Contended Integer int_167 = new Integer(167);
 241     @Contended Integer int_168 = new Integer(168);
 242     @Contended Integer int_169 = new Integer(169);
 243     @Contended Integer int_170 = new Integer(170);
 244     @Contended Integer int_171 = new Integer(171);
 245     @Contended Integer int_172 = new Integer(172);
 246     @Contended Integer int_173 = new Integer(173);
 247     @Contended Integer int_174 = new Integer(174);
 248     @Contended Integer int_175 = new Integer(175);
 249     @Contended Integer int_176 = new Integer(176);
 250     @Contended Integer int_177 = new Integer(177);
 251     @Contended Integer int_178 = new Integer(178);
 252     @Contended Integer int_179 = new Integer(179);
 253     @Contended Integer int_180 = new Integer(180);
 254     @Contended Integer int_181 = new Integer(181);
 255     @Contended Integer int_182 = new Integer(182);
 256     @Contended Integer int_183 = new Integer(183);
 257     @Contended Integer int_184 = new Integer(184);
 258     @Contended Integer int_185 = new Integer(185);
 259     @Contended Integer int_186 = new Integer(186);
 260     @Contended Integer int_187 = new Integer(187);
 261     @Contended Integer int_188 = new Integer(188);
 262     @Contended Integer int_189 = new Integer(189);
 263     @Contended Integer int_190 = new Integer(190);
 264     @Contended Integer int_191 = new Integer(191);
 265     @Contended Integer int_192 = new Integer(192);
 266     @Contended Integer int_193 = new Integer(193);
 267     @Contended Integer int_194 = new Integer(194);
 268     @Contended Integer int_195 = new Integer(195);
 269     @Contended Integer int_196 = new Integer(196);
 270     @Contended Integer int_197 = new Integer(197);
 271     @Contended Integer int_198 = new Integer(198);
 272     @Contended Integer int_199 = new Integer(199);
 273     @Contended Integer int_200 = new Integer(200);
 274     @Contended Integer int_201 = new Integer(201);
 275     @Contended Integer int_202 = new Integer(202);
 276     @Contended Integer int_203 = new Integer(203);
 277     @Contended Integer int_204 = new Integer(204);
 278     @Contended Integer int_205 = new Integer(205);
 279     @Contended Integer int_206 = new Integer(206);
 280     @Contended Integer int_207 = new Integer(207);
 281     @Contended Integer int_208 = new Integer(208);
 282     @Contended Integer int_209 = new Integer(209);
 283     @Contended Integer int_210 = new Integer(210);
 284     @Contended Integer int_211 = new Integer(211);
 285     @Contended Integer int_212 = new Integer(212);
 286     @Contended Integer int_213 = new Integer(213);
 287     @Contended Integer int_214 = new Integer(214);
 288     @Contended Integer int_215 = new Integer(215);
 289     @Contended Integer int_216 = new Integer(216);
 290     @Contended Integer int_217 = new Integer(217);
 291     @Contended Integer int_218 = new Integer(218);
 292     @Contended Integer int_219 = new Integer(219);
 293     @Contended Integer int_220 = new Integer(220);
 294     @Contended Integer int_221 = new Integer(221);
 295     @Contended Integer int_222 = new Integer(222);
 296     @Contended Integer int_223 = new Integer(223);
 297     @Contended Integer int_224 = new Integer(224);
 298     @Contended Integer int_225 = new Integer(225);
 299     @Contended Integer int_226 = new Integer(226);
 300     @Contended Integer int_227 = new Integer(227);
 301     @Contended Integer int_228 = new Integer(228);
 302     @Contended Integer int_229 = new Integer(229);
 303     @Contended Integer int_230 = new Integer(230);
 304     @Contended Integer int_231 = new Integer(231);
 305     @Contended Integer int_232 = new Integer(232);
 306     @Contended Integer int_233 = new Integer(233);
 307     @Contended Integer int_234 = new Integer(234);
 308     @Contended Integer int_235 = new Integer(235);
 309     @Contended Integer int_236 = new Integer(236);
 310     @Contended Integer int_237 = new Integer(237);
 311     @Contended Integer int_238 = new Integer(238);
 312     @Contended Integer int_239 = new Integer(239);
 313     @Contended Integer int_240 = new Integer(240);
 314     @Contended Integer int_241 = new Integer(241);
 315     @Contended Integer int_242 = new Integer(242);
 316     @Contended Integer int_243 = new Integer(243);
 317     @Contended Integer int_244 = new Integer(244);
 318     @Contended Integer int_245 = new Integer(245);
 319     @Contended Integer int_246 = new Integer(246);
 320     @Contended Integer int_247 = new Integer(247);
 321     @Contended Integer int_248 = new Integer(248);
 322     @Contended Integer int_249 = new Integer(249);
 323     @Contended Integer int_250 = new Integer(250);
 324     @Contended Integer int_251 = new Integer(251);
 325     @Contended Integer int_252 = new Integer(252);
 326     @Contended Integer int_253 = new Integer(253);
 327     @Contended Integer int_254 = new Integer(254);
 328     @Contended Integer int_255 = new Integer(255);
 329     @Contended Integer int_256 = new Integer(256);
 330     @Contended Integer int_257 = new Integer(257);
 331     @Contended Integer int_258 = new Integer(258);
 332     @Contended Integer int_259 = new Integer(259);
 333     @Contended Integer int_260 = new Integer(260);
 334     @Contended Integer int_261 = new Integer(261);
 335     @Contended Integer int_262 = new Integer(262);
 336     @Contended Integer int_263 = new Integer(263);
 337     @Contended Integer int_264 = new Integer(264);
 338     @Contended Integer int_265 = new Integer(265);
 339     @Contended Integer int_266 = new Integer(266);
 340     @Contended Integer int_267 = new Integer(267);
 341     @Contended Integer int_268 = new Integer(268);
 342     @Contended Integer int_269 = new Integer(269);
 343     @Contended Integer int_270 = new Integer(270);
 344     @Contended Integer int_271 = new Integer(271);
 345     @Contended Integer int_272 = new Integer(272);
 346     @Contended Integer int_273 = new Integer(273);
 347     @Contended Integer int_274 = new Integer(274);
 348     @Contended Integer int_275 = new Integer(275);
 349     @Contended Integer int_276 = new Integer(276);
 350     @Contended Integer int_277 = new Integer(277);
 351     @Contended Integer int_278 = new Integer(278);
 352     @Contended Integer int_279 = new Integer(279);
 353     @Contended Integer int_280 = new Integer(280);
 354     @Contended Integer int_281 = new Integer(281);
 355     @Contended Integer int_282 = new Integer(282);
 356     @Contended Integer int_283 = new Integer(283);
 357     @Contended Integer int_284 = new Integer(284);
 358     @Contended Integer int_285 = new Integer(285);
 359     @Contended Integer int_286 = new Integer(286);
 360     @Contended Integer int_287 = new Integer(287);
 361     @Contended Integer int_288 = new Integer(288);
 362     @Contended Integer int_289 = new Integer(289);
 363     @Contended Integer int_290 = new Integer(290);
 364     @Contended Integer int_291 = new Integer(291);
 365     @Contended Integer int_292 = new Integer(292);
 366     @Contended Integer int_293 = new Integer(293);
 367     @Contended Integer int_294 = new Integer(294);
 368     @Contended Integer int_295 = new Integer(295);
 369     @Contended Integer int_296 = new Integer(296);
 370     @Contended Integer int_297 = new Integer(297);
 371     @Contended Integer int_298 = new Integer(298);
 372     @Contended Integer int_299 = new Integer(299);
 373     @Contended Integer int_300 = new Integer(300);
 374 }