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