Bug Summary

File:jdk/src/hotspot/share/utilities/chunkedList.hpp
Warning:line 77, column 5
Undefined or garbage value returned to caller

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -triple x86_64-pc-linux-gnu -analyze -disable-free -disable-llvm-verifier -discard-value-names -main-file-name test_chunkedList.cpp -analyzer-store=region -analyzer-opt-analyze-nested-blocks -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 2 -mthread-model posix -fno-delete-null-pointer-checks -mframe-pointer=all -relaxed-aliasing -fmath-errno -fno-rounding-math -masm-verbose -mconstructor-aliases -munwind-tables -target-cpu x86-64 -dwarf-column-info -fno-split-dwarf-inlining -debugger-tuning=gdb -resource-dir /usr/lib/llvm-10/lib/clang/10.0.0 -I /home/daniel/Projects/java/jdk/build/linux-x86_64-server-fastdebug/hotspot/variant-server/libjvm/gtest/objs/precompiled -D __STDC_FORMAT_MACROS -D __STDC_LIMIT_MACROS -D __STDC_CONSTANT_MACROS -D _GNU_SOURCE -D _REENTRANT -D LIBC=gnu -D LINUX -D VM_LITTLE_ENDIAN -D _LP64=1 -D ASSERT -D CHECK_UNHANDLED_OOPS -D TARGET_ARCH_x86 -D INCLUDE_SUFFIX_OS=_linux -D INCLUDE_SUFFIX_CPU=_x86 -D INCLUDE_SUFFIX_COMPILER=_gcc -D TARGET_COMPILER_gcc -D AMD64 -D HOTSPOT_LIB_ARCH="amd64" -D COMPILER1 -D COMPILER2 -I /home/daniel/Projects/java/jdk/build/linux-x86_64-server-fastdebug/hotspot/variant-server/gensrc/adfiles -I /home/daniel/Projects/java/jdk/src/hotspot/share -I /home/daniel/Projects/java/jdk/src/hotspot/os/linux -I /home/daniel/Projects/java/jdk/src/hotspot/os/posix -I /home/daniel/Projects/java/jdk/src/hotspot/cpu/x86 -I /home/daniel/Projects/java/jdk/src/hotspot/os_cpu/linux_x86 -I /home/daniel/Projects/java/jdk/build/linux-x86_64-server-fastdebug/hotspot/variant-server/gensrc -I /home/daniel/Projects/java/jdk/src/hotspot/share/precompiled -I /home/daniel/Projects/java/jdk/src/hotspot/share/include -I /home/daniel/Projects/java/jdk/src/hotspot/os/posix/include -I /home/daniel/Projects/java/jdk/build/linux-x86_64-server-fastdebug/support/modules_include/java.base -I /home/daniel/Projects/java/jdk/build/linux-x86_64-server-fastdebug/support/modules_include/java.base/linux -I /home/daniel/Projects/java/jdk/src/java.base/share/native/libjimage -I /home/daniel/Projects/java/googletest/googletest/include -I /home/daniel/Projects/java/googletest/googlemock/include -I /home/daniel/Projects/java/jdk/test/hotspot/gtest -I /home/daniel/Projects/java/jdk/test/hotspot/gtest -D _FORTIFY_SOURCE=2 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/7.5.0/../../../../include/c++/7.5.0 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/7.5.0/../../../../include/x86_64-linux-gnu/c++/7.5.0 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/7.5.0/../../../../include/x86_64-linux-gnu/c++/7.5.0 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/7.5.0/../../../../include/c++/7.5.0/backward -internal-isystem /usr/local/include -internal-isystem /usr/lib/llvm-10/lib/clang/10.0.0/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -O3 -Wno-format-zero-length -Wno-unused-parameter -Wno-unused -Wno-parentheses -Wno-comment -Wno-unknown-pragmas -Wno-address -Wno-delete-non-virtual-dtor -Wno-char-subscripts -Wno-array-bounds -Wno-int-in-bool-context -Wno-ignored-qualifiers -Wno-missing-field-initializers -Wno-implicit-fallthrough -Wno-empty-body -Wno-strict-overflow -Wno-sequence-point -Wno-maybe-uninitialized -Wno-misleading-indentation -Wno-cast-function-type -Wno-shift-negative-value -Wno-undef -Wno-stringop-overflow -std=c++14 -fdeprecated-macro -fdebug-compilation-dir /home/daniel/Projects/java/jdk/make/hotspot -ferror-limit 19 -fmessage-length 0 -fvisibility hidden -stack-protector 1 -fno-rtti -fgnuc-version=4.2.1 -fobjc-runtime=gcc -fdiagnostics-show-option -vectorize-loops -vectorize-slp -analyzer-output=html -faddrsig -o /home/daniel/Projects/java/scan/2021-12-21-193737-8510-1 -x c++ /home/daniel/Projects/java/jdk/test/hotspot/gtest/utilities/test_chunkedList.cpp

/home/daniel/Projects/java/jdk/test/hotspot/gtest/utilities/test_chunkedList.cpp

1/*
2 * Copyright (c) 2014, 2016, 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#include "precompiled.hpp"
25#include "unittest.hpp"
26#include "utilities/chunkedList.hpp"
27
28class Metadata;
29
30template <typename T>
31class TestChunkedList {
32 typedef ChunkedList<T, mtOther> ChunkedListT;
33
34 public:
35
36 static void testEmpty() {
37 ChunkedListT buffer;
38 ASSERT_EQ((size_t) 0, buffer.size())switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing
::internal::IsNullLiteralHelper((size_t) 0)) == 1)>::Compare
("(size_t) 0", "buffer.size()", (size_t) 0, buffer.size()))) ;
else return ::testing::internal::AssertHelper(::testing::TestPartResult
::kFatalFailure, "/home/daniel/Projects/java/jdk/test/hotspot/gtest/utilities/test_chunkedList.cpp"
, 38, gtest_ar.failure_message()) = ::testing::Message()
;
39 }
40
41 static void testFull() {
42 ChunkedListT buffer;
43 for (uintptr_t i = 0; i < ChunkedListT::BufferSize; i++) {
44 buffer.push((T) i);
45 }
46 ASSERT_EQ((size_t) ChunkedListT::BufferSize, buffer.size())switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing
::internal::IsNullLiteralHelper((size_t) ChunkedListT::BufferSize
)) == 1)>::Compare("(size_t) ChunkedListT::BufferSize", "buffer.size()"
, (size_t) ChunkedListT::BufferSize, buffer.size()))) ; else return
::testing::internal::AssertHelper(::testing::TestPartResult::
kFatalFailure, "/home/daniel/Projects/java/jdk/test/hotspot/gtest/utilities/test_chunkedList.cpp"
, 46, gtest_ar.failure_message()) = ::testing::Message()
;
47 ASSERT_TRUE(buffer.is_full())switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar_ = ::testing::AssertionResult(buffer.is_full())) ; else
return ::testing::internal::AssertHelper(::testing::TestPartResult
::kFatalFailure, "/home/daniel/Projects/java/jdk/test/hotspot/gtest/utilities/test_chunkedList.cpp"
, 47, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_
, "buffer.is_full()", "false", "true").c_str()) = ::testing::
Message()
;
48 }
49
50 static void testSize() {
51 ChunkedListT buffer;
52 for (uintptr_t i = 0; i < ChunkedListT::BufferSize; i++) {
53 ASSERT_EQ((size_t) i, buffer.size())switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing
::internal::IsNullLiteralHelper((size_t) i)) == 1)>::Compare
("(size_t) i", "buffer.size()", (size_t) i, buffer.size()))) ;
else return ::testing::internal::AssertHelper(::testing::TestPartResult
::kFatalFailure, "/home/daniel/Projects/java/jdk/test/hotspot/gtest/utilities/test_chunkedList.cpp"
, 53, gtest_ar.failure_message()) = ::testing::Message()
;
54 buffer.push((T) i);
55 ASSERT_EQ((size_t) (i + 1), buffer.size())switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing
::internal::IsNullLiteralHelper((size_t) (i + 1))) == 1)>::
Compare("(size_t) (i + 1)", "buffer.size()", (size_t) (i + 1)
, buffer.size()))) ; else return ::testing::internal::AssertHelper
(::testing::TestPartResult::kFatalFailure, "/home/daniel/Projects/java/jdk/test/hotspot/gtest/utilities/test_chunkedList.cpp"
, 55, gtest_ar.failure_message()) = ::testing::Message()
;
56 }
57 }
58
59 static void testClear() {
60 ChunkedListT buffer;
61
62 buffer.clear();
63 ASSERT_EQ((size_t) 0, buffer.size())switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing
::internal::IsNullLiteralHelper((size_t) 0)) == 1)>::Compare
("(size_t) 0", "buffer.size()", (size_t) 0, buffer.size()))) ;
else return ::testing::internal::AssertHelper(::testing::TestPartResult
::kFatalFailure, "/home/daniel/Projects/java/jdk/test/hotspot/gtest/utilities/test_chunkedList.cpp"
, 63, gtest_ar.failure_message()) = ::testing::Message()
;
64
65 for (uintptr_t i = 0; i < ChunkedListT::BufferSize / 2; i++) {
66 buffer.push((T) i);
67 }
68 buffer.clear();
69 ASSERT_EQ((size_t) 0, buffer.size())switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing
::internal::IsNullLiteralHelper((size_t) 0)) == 1)>::Compare
("(size_t) 0", "buffer.size()", (size_t) 0, buffer.size()))) ;
else return ::testing::internal::AssertHelper(::testing::TestPartResult
::kFatalFailure, "/home/daniel/Projects/java/jdk/test/hotspot/gtest/utilities/test_chunkedList.cpp"
, 69, gtest_ar.failure_message()) = ::testing::Message()
;
70
71 for (uintptr_t i = 0; i < ChunkedListT::BufferSize; i++) {
72 buffer.push((T) i);
73 }
74 buffer.clear();
75 ASSERT_EQ((size_t) 0, buffer.size())switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing
::internal::IsNullLiteralHelper((size_t) 0)) == 1)>::Compare
("(size_t) 0", "buffer.size()", (size_t) 0, buffer.size()))) ;
else return ::testing::internal::AssertHelper(::testing::TestPartResult
::kFatalFailure, "/home/daniel/Projects/java/jdk/test/hotspot/gtest/utilities/test_chunkedList.cpp"
, 75, gtest_ar.failure_message()) = ::testing::Message()
;
76 }
77
78 static void testAt() {
79 ChunkedListT buffer;
80
81 for (uintptr_t i = 0; i < ChunkedListT::BufferSize; i++) {
2
'i' initialized to 0
3
Loop condition is true. Entering loop body
82 buffer.push((T) i);
83 ASSERT_EQ((T) i, buffer.at(i))switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing
::internal::IsNullLiteralHelper((T) i)) == 1)>::Compare("(T) i"
, "buffer.at(i)", (T) i, buffer.at(i)))) ; else return ::testing
::internal::AssertHelper(::testing::TestPartResult::kFatalFailure
, "/home/daniel/Projects/java/jdk/test/hotspot/gtest/utilities/test_chunkedList.cpp"
, 83, gtest_ar.failure_message()) = ::testing::Message()
;
4
Control jumps to 'case 0:' at line 83
5
Passing the value 0 via 1st parameter 'i'
6
Calling 'ChunkedList::at'
84 }
85
86 for (uintptr_t i = 0; i < ChunkedListT::BufferSize; i++) {
87 ASSERT_EQ((T) i, buffer.at(i))switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing
::internal::IsNullLiteralHelper((T) i)) == 1)>::Compare("(T) i"
, "buffer.at(i)", (T) i, buffer.at(i)))) ; else return ::testing
::internal::AssertHelper(::testing::TestPartResult::kFatalFailure
, "/home/daniel/Projects/java/jdk/test/hotspot/gtest/utilities/test_chunkedList.cpp"
, 87, gtest_ar.failure_message()) = ::testing::Message()
;
88 }
89 }
90};
91
92TEST(ChunkedList, metadata_empty)class ChunkedList_metadata_empty_Test : public ::testing::Test
{ public: ChunkedList_metadata_empty_Test() {} private: virtual
void TestBody(); static ::testing::TestInfo* const test_info_
__attribute__ ((unused)); ChunkedList_metadata_empty_Test(ChunkedList_metadata_empty_Test
const &) = delete; void operator=(ChunkedList_metadata_empty_Test
const &) = delete;};::testing::TestInfo* const ChunkedList_metadata_empty_Test
::test_info_ = ::testing::internal::MakeAndRegisterTestInfo(
"ChunkedList", "metadata_empty", __null, __null, ::testing::
internal::CodeLocation("/home/daniel/Projects/java/jdk/test/hotspot/gtest/utilities/test_chunkedList.cpp"
, 92), (::testing::internal::GetTestTypeId()), ::testing::Test
::SetUpTestCase, ::testing::Test::TearDownTestCase, new ::testing
::internal::TestFactoryImpl< ChunkedList_metadata_empty_Test
>);void ChunkedList_metadata_empty_Test::TestBody()
{
93 TestChunkedList<Metadata*>::testEmpty();
94}
95
96TEST(ChunkedList, metadata_full)class ChunkedList_metadata_full_Test : public ::testing::Test
{ public: ChunkedList_metadata_full_Test() {} private: virtual
void TestBody(); static ::testing::TestInfo* const test_info_
__attribute__ ((unused)); ChunkedList_metadata_full_Test(ChunkedList_metadata_full_Test
const &) = delete; void operator=(ChunkedList_metadata_full_Test
const &) = delete;};::testing::TestInfo* const ChunkedList_metadata_full_Test
::test_info_ = ::testing::internal::MakeAndRegisterTestInfo(
"ChunkedList", "metadata_full", __null, __null, ::testing::internal
::CodeLocation("/home/daniel/Projects/java/jdk/test/hotspot/gtest/utilities/test_chunkedList.cpp"
, 96), (::testing::internal::GetTestTypeId()), ::testing::Test
::SetUpTestCase, ::testing::Test::TearDownTestCase, new ::testing
::internal::TestFactoryImpl< ChunkedList_metadata_full_Test
>);void ChunkedList_metadata_full_Test::TestBody()
{
97 TestChunkedList<Metadata*>::testFull();
98}
99
100TEST(ChunkedList, metadata_size)class ChunkedList_metadata_size_Test : public ::testing::Test
{ public: ChunkedList_metadata_size_Test() {} private: virtual
void TestBody(); static ::testing::TestInfo* const test_info_
__attribute__ ((unused)); ChunkedList_metadata_size_Test(ChunkedList_metadata_size_Test
const &) = delete; void operator=(ChunkedList_metadata_size_Test
const &) = delete;};::testing::TestInfo* const ChunkedList_metadata_size_Test
::test_info_ = ::testing::internal::MakeAndRegisterTestInfo(
"ChunkedList", "metadata_size", __null, __null, ::testing::internal
::CodeLocation("/home/daniel/Projects/java/jdk/test/hotspot/gtest/utilities/test_chunkedList.cpp"
, 100), (::testing::internal::GetTestTypeId()), ::testing::Test
::SetUpTestCase, ::testing::Test::TearDownTestCase, new ::testing
::internal::TestFactoryImpl< ChunkedList_metadata_size_Test
>);void ChunkedList_metadata_size_Test::TestBody()
{
101 TestChunkedList<Metadata*>::testSize();
102}
103
104TEST(ChunkedList, metadata_clear)class ChunkedList_metadata_clear_Test : public ::testing::Test
{ public: ChunkedList_metadata_clear_Test() {} private: virtual
void TestBody(); static ::testing::TestInfo* const test_info_
__attribute__ ((unused)); ChunkedList_metadata_clear_Test(ChunkedList_metadata_clear_Test
const &) = delete; void operator=(ChunkedList_metadata_clear_Test
const &) = delete;};::testing::TestInfo* const ChunkedList_metadata_clear_Test
::test_info_ = ::testing::internal::MakeAndRegisterTestInfo(
"ChunkedList", "metadata_clear", __null, __null, ::testing::
internal::CodeLocation("/home/daniel/Projects/java/jdk/test/hotspot/gtest/utilities/test_chunkedList.cpp"
, 104), (::testing::internal::GetTestTypeId()), ::testing::Test
::SetUpTestCase, ::testing::Test::TearDownTestCase, new ::testing
::internal::TestFactoryImpl< ChunkedList_metadata_clear_Test
>);void ChunkedList_metadata_clear_Test::TestBody()
{
105 TestChunkedList<Metadata*>::testSize();
106}
107
108TEST(ChunkedList, metadata_at)class ChunkedList_metadata_at_Test : public ::testing::Test {
public: ChunkedList_metadata_at_Test() {} private: virtual void
TestBody(); static ::testing::TestInfo* const test_info_ __attribute__
((unused)); ChunkedList_metadata_at_Test(ChunkedList_metadata_at_Test
const &) = delete; void operator=(ChunkedList_metadata_at_Test
const &) = delete;};::testing::TestInfo* const ChunkedList_metadata_at_Test
::test_info_ = ::testing::internal::MakeAndRegisterTestInfo(
"ChunkedList", "metadata_at", __null, __null, ::testing::internal
::CodeLocation("/home/daniel/Projects/java/jdk/test/hotspot/gtest/utilities/test_chunkedList.cpp"
, 108), (::testing::internal::GetTestTypeId()), ::testing::Test
::SetUpTestCase, ::testing::Test::TearDownTestCase, new ::testing
::internal::TestFactoryImpl< ChunkedList_metadata_at_Test>
);void ChunkedList_metadata_at_Test::TestBody()
{
109 TestChunkedList<Metadata*>::testAt();
110}
111
112TEST(ChunkedList, size_t_empty)class ChunkedList_size_t_empty_Test : public ::testing::Test {
public: ChunkedList_size_t_empty_Test() {} private: virtual void
TestBody(); static ::testing::TestInfo* const test_info_ __attribute__
((unused)); ChunkedList_size_t_empty_Test(ChunkedList_size_t_empty_Test
const &) = delete; void operator=(ChunkedList_size_t_empty_Test
const &) = delete;};::testing::TestInfo* const ChunkedList_size_t_empty_Test
::test_info_ = ::testing::internal::MakeAndRegisterTestInfo(
"ChunkedList", "size_t_empty", __null, __null, ::testing::internal
::CodeLocation("/home/daniel/Projects/java/jdk/test/hotspot/gtest/utilities/test_chunkedList.cpp"
, 112), (::testing::internal::GetTestTypeId()), ::testing::Test
::SetUpTestCase, ::testing::Test::TearDownTestCase, new ::testing
::internal::TestFactoryImpl< ChunkedList_size_t_empty_Test
>);void ChunkedList_size_t_empty_Test::TestBody()
{
113 TestChunkedList<size_t>::testEmpty();
114}
115
116TEST(ChunkedList, size_t_full)class ChunkedList_size_t_full_Test : public ::testing::Test {
public: ChunkedList_size_t_full_Test() {} private: virtual void
TestBody(); static ::testing::TestInfo* const test_info_ __attribute__
((unused)); ChunkedList_size_t_full_Test(ChunkedList_size_t_full_Test
const &) = delete; void operator=(ChunkedList_size_t_full_Test
const &) = delete;};::testing::TestInfo* const ChunkedList_size_t_full_Test
::test_info_ = ::testing::internal::MakeAndRegisterTestInfo(
"ChunkedList", "size_t_full", __null, __null, ::testing::internal
::CodeLocation("/home/daniel/Projects/java/jdk/test/hotspot/gtest/utilities/test_chunkedList.cpp"
, 116), (::testing::internal::GetTestTypeId()), ::testing::Test
::SetUpTestCase, ::testing::Test::TearDownTestCase, new ::testing
::internal::TestFactoryImpl< ChunkedList_size_t_full_Test>
);void ChunkedList_size_t_full_Test::TestBody()
{
117 TestChunkedList<size_t>::testFull();
118}
119
120TEST(ChunkedList, size_t_size)class ChunkedList_size_t_size_Test : public ::testing::Test {
public: ChunkedList_size_t_size_Test() {} private: virtual void
TestBody(); static ::testing::TestInfo* const test_info_ __attribute__
((unused)); ChunkedList_size_t_size_Test(ChunkedList_size_t_size_Test
const &) = delete; void operator=(ChunkedList_size_t_size_Test
const &) = delete;};::testing::TestInfo* const ChunkedList_size_t_size_Test
::test_info_ = ::testing::internal::MakeAndRegisterTestInfo(
"ChunkedList", "size_t_size", __null, __null, ::testing::internal
::CodeLocation("/home/daniel/Projects/java/jdk/test/hotspot/gtest/utilities/test_chunkedList.cpp"
, 120), (::testing::internal::GetTestTypeId()), ::testing::Test
::SetUpTestCase, ::testing::Test::TearDownTestCase, new ::testing
::internal::TestFactoryImpl< ChunkedList_size_t_size_Test>
);void ChunkedList_size_t_size_Test::TestBody()
{
121 TestChunkedList<size_t>::testSize();
122}
123
124TEST(ChunkedList, size_t_clear)class ChunkedList_size_t_clear_Test : public ::testing::Test {
public: ChunkedList_size_t_clear_Test() {} private: virtual void
TestBody(); static ::testing::TestInfo* const test_info_ __attribute__
((unused)); ChunkedList_size_t_clear_Test(ChunkedList_size_t_clear_Test
const &) = delete; void operator=(ChunkedList_size_t_clear_Test
const &) = delete;};::testing::TestInfo* const ChunkedList_size_t_clear_Test
::test_info_ = ::testing::internal::MakeAndRegisterTestInfo(
"ChunkedList", "size_t_clear", __null, __null, ::testing::internal
::CodeLocation("/home/daniel/Projects/java/jdk/test/hotspot/gtest/utilities/test_chunkedList.cpp"
, 124), (::testing::internal::GetTestTypeId()), ::testing::Test
::SetUpTestCase, ::testing::Test::TearDownTestCase, new ::testing
::internal::TestFactoryImpl< ChunkedList_size_t_clear_Test
>);void ChunkedList_size_t_clear_Test::TestBody()
{
125 TestChunkedList<size_t>::testSize();
126}
127
128TEST(ChunkedList, size_t_at)class ChunkedList_size_t_at_Test : public ::testing::Test { public
: ChunkedList_size_t_at_Test() {} private: virtual void TestBody
(); static ::testing::TestInfo* const test_info_ __attribute__
((unused)); ChunkedList_size_t_at_Test(ChunkedList_size_t_at_Test
const &) = delete; void operator=(ChunkedList_size_t_at_Test
const &) = delete;};::testing::TestInfo* const ChunkedList_size_t_at_Test
::test_info_ = ::testing::internal::MakeAndRegisterTestInfo(
"ChunkedList", "size_t_at", __null, __null, ::testing::internal
::CodeLocation("/home/daniel/Projects/java/jdk/test/hotspot/gtest/utilities/test_chunkedList.cpp"
, 128), (::testing::internal::GetTestTypeId()), ::testing::Test
::SetUpTestCase, ::testing::Test::TearDownTestCase, new ::testing
::internal::TestFactoryImpl< ChunkedList_size_t_at_Test>
);void ChunkedList_size_t_at_Test::TestBody()
{
129 TestChunkedList<size_t>::testAt();
1
Calling 'TestChunkedList::testAt'
130}

/home/daniel/Projects/java/jdk/src/hotspot/share/utilities/chunkedList.hpp

1/*
2 * Copyright (c) 2014, 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
25#ifndef SHARE_UTILITIES_CHUNKEDLIST_HPP
26#define SHARE_UTILITIES_CHUNKEDLIST_HPP
27
28#include "memory/allocation.hpp"
29#include "utilities/debug.hpp"
30
31template <class T, MEMFLAGS F> class ChunkedList : public CHeapObj<F> {
32 template <class U> friend class TestChunkedList;
33
34 static const size_t BufferSize = 64;
35
36 T _values[BufferSize];
37 T* _top;
38
39 ChunkedList<T, F>* _next_used;
40 ChunkedList<T, F>* _next_free;
41
42 T const * end() const {
43 return &_values[BufferSize];
44 }
45
46 public:
47 ChunkedList<T, F>() : _top(_values), _next_used(NULL__null), _next_free(NULL__null) {}
48
49 bool is_full() const {
50 return _top == end();
51 }
52
53 void clear() {
54 _top = _values;
55 // Don't clear the next pointers since that would interfere
56 // with other threads trying to iterate through the lists.
57 }
58
59 void push(T m) {
60 assert(!is_full(), "Buffer is full")do { if (!(!is_full())) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/utilities/chunkedList.hpp"
, 60, "assert(" "!is_full()" ") failed", "Buffer is full"); ::
breakpoint(); } } while (0)
;
61 *_top = m;
62 _top++;
63 }
64
65 void set_next_used(ChunkedList<T, F>* buffer) { _next_used = buffer; }
66 void set_next_free(ChunkedList<T, F>* buffer) { _next_free = buffer; }
67
68 ChunkedList<T, F>* next_used() const { return _next_used; }
69 ChunkedList<T, F>* next_free() const { return _next_free; }
70
71 size_t size() const {
72 return pointer_delta(_top, _values, sizeof(T));
73 }
74
75 T at(size_t i) {
76 assert(i < size(), "IOOBE i: " SIZE_FORMAT " size(): " SIZE_FORMAT, i, size())do { if (!(i < size())) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/utilities/chunkedList.hpp"
, 76, "assert(" "i < size()" ") failed", "IOOBE i: " "%" "l"
"u" " size(): " "%" "l" "u", i, size()); ::breakpoint(); } }
while (0)
;
7
Assuming the condition is false
8
Taking false branch
9
Loop condition is false. Exiting loop
77 return _values[i];
10
Undefined or garbage value returned to caller
78 }
79};
80
81#endif // SHARE_UTILITIES_CHUNKEDLIST_HPP