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 #ifdef _LP64
40   if (UseCompactObjectHeaders) {
41     o->set_mark(Universe::boolArrayKlassObj()->prototype_header());
42   } else
43 #endif
44   {
45     o->set_klass(Universe::boolArrayKlassObj());
46   }
47   o->set_length(10);
48 
49 
50   ASSERT_EQ((jboolean)0, o->bool_at(0));
51   ASSERT_EQ((jboolean)0, o->bool_at(1));
52   ASSERT_EQ((jboolean)0, o->bool_at(2));
53   ASSERT_EQ((jboolean)0, o->bool_at(3));
54   ASSERT_EQ((jboolean)0, o->bool_at(4));
55   ASSERT_EQ((jboolean)0, o->bool_at(5));
56   ASSERT_EQ((jboolean)0, o->bool_at(6));
57   ASSERT_EQ((jboolean)0, o->bool_at(7));
58 
59   o->bool_at_put(3, 255); // Check for masking store.
60   o->bool_at_put(2, 1);
61   o->bool_at_put(1, 1);
62   o->bool_at_put(0, 1);
63 
64   ASSERT_EQ((jboolean)1, o->bool_at(0));
65   ASSERT_EQ((jboolean)1, o->bool_at(1));
66   ASSERT_EQ((jboolean)1, o->bool_at(2));
67   ASSERT_EQ((jboolean)1, o->bool_at(3));
68   ASSERT_EQ((jboolean)0, o->bool_at(4));
69   ASSERT_EQ((jboolean)0, o->bool_at(5));
70   ASSERT_EQ((jboolean)0, o->bool_at(6));
71   ASSERT_EQ((jboolean)0, o->bool_at(7));
72 }