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
32TEST_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) addr;
39 o->set_klass(Universe::boolArrayKlassObj());
40 o->set_length(10);
41
42
43 ASSERT_EQ((jboolean)0, o->bool_at(0));
44 ASSERT_EQ((jboolean)0, o->bool_at(1));
45 ASSERT_EQ((jboolean)0, o->bool_at(2));
46 ASSERT_EQ((jboolean)0, o->bool_at(3));
47 ASSERT_EQ((jboolean)0, o->bool_at(4));
48 ASSERT_EQ((jboolean)0, o->bool_at(5));
49 ASSERT_EQ((jboolean)0, o->bool_at(6));
50 ASSERT_EQ((jboolean)0, o->bool_at(7));
51
52 o->bool_at_put(3, 255); // Check for masking store.
53 o->bool_at_put(2, 1);
54 o->bool_at_put(1, 1);
55 o->bool_at_put(0, 1);
56
57 ASSERT_EQ((jboolean)1, o->bool_at(0));
58 ASSERT_EQ((jboolean)1, o->bool_at(1));
59 ASSERT_EQ((jboolean)1, o->bool_at(2));
60 ASSERT_EQ((jboolean)1, o->bool_at(3));
61 ASSERT_EQ((jboolean)0, o->bool_at(4));
62 ASSERT_EQ((jboolean)0, o->bool_at(5));
63 ASSERT_EQ((jboolean)0, o->bool_at(6));
64 ASSERT_EQ((jboolean)0, o->bool_at(7));
65}
66