undefect. CWE-407 — 63 sites patched across 27 ecosystems
Authors: russell@unturf.com · brackishbert@gmail.com · foxhop.net · TimeHexOn.com Patches, unit tests, benchmarks, whitepaper, and outreach briefs. Public domain — no copyright claimed. Use freely.
This commit is contained in:
commit
0a580b313d
70422 changed files with 17213626 additions and 0 deletions
63
test/hotspot/gtest/oops/test_objArrayOop.cpp
Normal file
63
test/hotspot/gtest/oops/test_objArrayOop.cpp
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
/*
|
||||
* Copyright Amazon.com Inc. or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
#include "oops/objArrayOop.hpp"
|
||||
#include "unittest.hpp"
|
||||
#include "utilities/globalDefinitions.hpp"
|
||||
|
||||
TEST_VM(objArrayOop, osize) {
|
||||
static const struct {
|
||||
int objal; bool ccp; bool coops; bool coh; int result;
|
||||
} x[] = {
|
||||
// ObjAligInB, UseCCP, UseCoops, UseCOH, object size in heap words
|
||||
#ifdef _LP64
|
||||
{ 8, false, false, false, 4 }, // 20 byte header, 8 byte oops
|
||||
{ 8, false, true, false, 3 }, // 20 byte header, 4 byte oops
|
||||
{ 8, true, false, false, 3 }, // 16 byte header, 8 byte oops
|
||||
{ 8, true, true, false, 3 }, // 16 byte header, 4 byte oops
|
||||
{ 8, true, false, true, 3 }, // 12 byte header, 8 byte oops
|
||||
{ 8, true, true, true, 2 }, // 12 byte header, 4 byte oops
|
||||
{ 16, false, false, false, 4 }, // 20 byte header, 8 byte oops, 16-byte align
|
||||
{ 16, false, true, false, 4 }, // 20 byte header, 4 byte oops, 16-byte align
|
||||
{ 16, true, false, false, 4 }, // 16 byte header, 8 byte oops, 16-byte align
|
||||
{ 16, true, true, false, 4 }, // 16 byte header, 4 byte oops, 16-byte align
|
||||
{ 16, true, false, true, 4 }, // 12 byte header, 8 byte oops, 16-byte align
|
||||
{ 16, true, true, true, 2 }, // 12 byte header, 4 byte oops, 16-byte align
|
||||
{ 256, false, false, false, 32 }, // 20 byte header, 8 byte oops, 256-byte align
|
||||
{ 256, false, true, false, 32 }, // 20 byte header, 4 byte oops, 256-byte align
|
||||
{ 256, true, false, false, 32 }, // 16 byte header, 8 byte oops, 256-byte align
|
||||
{ 256, true, true, false, 32 }, // 16 byte header, 4 byte oops, 256-byte align
|
||||
{ 256, true, false, true, 32 }, // 12 byte header, 8 byte oops, 256-byte align
|
||||
{ 256, true, true, true, 32 }, // 12 byte header, 4 byte oops, 256-byte align
|
||||
#else
|
||||
{ 8, false, false, false, 4 }, // 12 byte header, 4 byte oops, wordsize 4
|
||||
#endif
|
||||
{ -1, false, false, false, -1 }
|
||||
};
|
||||
for (int i = 0; x[i].result != -1; i++) {
|
||||
if (x[i].objal == (int)ObjectAlignmentInBytes && x[i].ccp == UseCompressedClassPointers && x[i].coops == UseCompressedOops &&
|
||||
x[i].coh == UseCompactObjectHeaders) {
|
||||
EXPECT_EQ(objArrayOopDesc::object_size(1), (size_t)x[i].result);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue