1 /*
 2  * Copyright (c) 2017, Red Hat, Inc. and/or its affiliates.
 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 #include "precompiled.hpp"
26 #include "memory/universe.hpp"
27 #include "oops/oop.inline.hpp"
28 #include "oops/typeArrayOop.inline.hpp"
29 #include "unittest.hpp"
30 #include "utilities/globalDefinitions.hpp"
31 
32 TEST_VM(typeArrayOopDesc, bool_at_put) {
33   char mem[100];
34   memset(mem, 0, ARRAY_SIZE(mem));
35 
36   char* addr = align_up(mem, 16);
37 
38   typeArrayOop o = (typeArrayOop) cast_to_oop(addr);
39   if (UseCompactObjectHeaders) {
40     o->set_mark(Universe::boolArrayKlass()->prototype_header());
41   } else {
42     o->set_klass(Universe::boolArrayKlass());
43   }
44   o->set_length(10);
45 
46 
47   ASSERT_EQ((jboolean)0, o->bool_at(0));
48   ASSERT_EQ((jboolean)0, o->bool_at(1));
49   ASSERT_EQ((jboolean)0, o->bool_at(2));
50   ASSERT_EQ((jboolean)0, o->bool_at(3));
51   ASSERT_EQ((jboolean)0, o->bool_at(4));
52   ASSERT_EQ((jboolean)0, o->bool_at(5));
53   ASSERT_EQ((jboolean)0, o->bool_at(6));
54   ASSERT_EQ((jboolean)0, o->bool_at(7));
55 
56   o->bool_at_put(3, 255); // Check for masking store.
57   o->bool_at_put(2, 1);
58   o->bool_at_put(1, 1);
59   o->bool_at_put(0, 1);
60 
61   ASSERT_EQ((jboolean)1, o->bool_at(0));
62   ASSERT_EQ((jboolean)1, o->bool_at(1));
63   ASSERT_EQ((jboolean)1, o->bool_at(2));
64   ASSERT_EQ((jboolean)1, o->bool_at(3));
65   ASSERT_EQ((jboolean)0, o->bool_at(4));
66   ASSERT_EQ((jboolean)0, o->bool_at(5));
67   ASSERT_EQ((jboolean)0, o->bool_at(6));
68   ASSERT_EQ((jboolean)0, o->bool_at(7));
69 }