1 /* 2 * Copyright Amazon.com Inc. 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 #include "precompiled.hpp" 25 #include "oops/objArrayOop.hpp" 26 #include "unittest.hpp" 27 #include "utilities/globalDefinitions.hpp" 28 29 TEST_VM(objArrayOop, osize) { 30 static const struct { 31 int objal; bool ccp; bool coops; bool coh; int result; 32 } x[] = { 33 // ObjAligInB, UseCCP, UseCoops, UseCOH, object size in heap words 34 #ifdef _LP64 35 { 8, false, false, false, 4 }, // 20 byte header, 8 byte oops 36 { 8, false, true, false, 3 }, // 20 byte header, 4 byte oops 37 { 8, true, false, false, 3 }, // 16 byte header, 8 byte oops 38 { 8, true, true, false, 3 }, // 16 byte header, 4 byte oops 39 { 8, true, false, true, 3 }, // 12 byte header, 8 byte oops 40 { 8, true, true, true, 2 }, // 12 byte header, 4 byte oops 41 { 16, false, false, false, 4 }, // 20 byte header, 8 byte oops, 16-byte align 42 { 16, false, true, false, 4 }, // 20 byte header, 4 byte oops, 16-byte align 43 { 16, true, false, false, 4 }, // 16 byte header, 8 byte oops, 16-byte align 44 { 16, true, true, false, 4 }, // 16 byte header, 4 byte oops, 16-byte align 45 { 16, true, false, true, 4 }, // 12 byte header, 8 byte oops, 16-byte align 46 { 16, true, true, true, 2 }, // 12 byte header, 4 byte oops, 16-byte align 47 { 256, false, false, false, 32 }, // 20 byte header, 8 byte oops, 256-byte align 48 { 256, false, true, false, 32 }, // 20 byte header, 4 byte oops, 256-byte align 49 { 256, true, false, false, 32 }, // 16 byte header, 8 byte oops, 256-byte align 50 { 256, true, true, false, 32 }, // 16 byte header, 4 byte oops, 256-byte align 51 { 256, true, false, true, 32 }, // 12 byte header, 8 byte oops, 256-byte align 52 { 256, true, true, true, 32 }, // 12 byte header, 4 byte oops, 256-byte align 53 #else 54 { 8, false, false, false, 4 }, // 12 byte header, 4 byte oops, wordsize 4 55 #endif 56 { -1, false, false, false, -1 } 57 }; 58 for (int i = 0; x[i].result != -1; i++) { 59 if (x[i].objal == (int)ObjectAlignmentInBytes && x[i].ccp == UseCompressedClassPointers && x[i].coops == UseCompressedOops && 60 x[i].coh == UseCompactObjectHeaders) { 61 EXPECT_EQ(objArrayOopDesc::object_size(1), (size_t)x[i].result); 62 } 63 } 64 }