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; int result; 32 } x[] = { 33 // ObjAligInB, UseCCP, UseCoops, object size in heap words 34 #ifdef _LP64 35 { 8, false, false, 4 }, // 20 byte header, 8 byte oops 36 { 8, false, true, 3 }, // 20 byte header, 4 byte oops 37 { 8, true, false, 3 }, // 16 byte header, 8 byte oops 38 { 8, true, true, 3 }, // 16 byte header, 4 byte oops 39 { 16, false, false, 4 }, // 20 byte header, 8 byte oops, 16-byte align 40 { 16, false, true, 4 }, // 20 byte header, 4 byte oops, 16-byte align 41 { 16, true, false, 4 }, // 16 byte header, 8 byte oops, 16-byte align 42 { 16, true, true, 4 }, // 16 byte header, 4 byte oops, 16-byte align 43 { 256, false, false, 32 }, // 20 byte header, 8 byte oops, 256-byte align 44 { 256, false, true, 32 }, // 20 byte header, 4 byte oops, 256-byte align 45 { 256, true, false, 32 }, // 16 byte header, 8 byte oops, 256-byte align 46 { 256, true, true, 32 }, // 16 byte header, 4 byte oops, 256-byte align 47 #else 48 { 8, false, false, 4 }, // 12 byte header, 4 byte oops, wordsize 4 49 #endif 50 { -1, false, false, -1 } 51 }; 52 for (int i = 0; x[i].result != -1; i++) { 53 if (x[i].objal == (int)ObjectAlignmentInBytes && x[i].ccp == UseCompressedClassPointers && x[i].coops == UseCompressedOops) { 54 EXPECT_EQ(objArrayOopDesc::object_size(1), (size_t)x[i].result); 55 } 56 } 57 }