1 /*
2 * Copyright (c) 1999, 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 *
1651 bool LibraryCallKit::inline_string_char_access(bool is_store) {
1652 Node* value = argument(0);
1653 Node* index = argument(1);
1654 Node* ch = is_store ? argument(2) : NULL;
1655
1656 // This intrinsic accesses byte[] array as char[] array. Computing the offsets
1657 // correctly requires matched array shapes.
1658 assert (arrayOopDesc::base_offset_in_bytes(T_CHAR) == arrayOopDesc::base_offset_in_bytes(T_BYTE),
1659 "sanity: byte[] and char[] bases agree");
1660 assert (type2aelembytes(T_CHAR) == type2aelembytes(T_BYTE)*2,
1661 "sanity: byte[] and char[] scales agree");
1662
1663 // Bail when getChar over constants is requested: constant folding would
1664 // reject folding mismatched char access over byte[]. A normal inlining for getChar
1665 // Java method would constant fold nicely instead.
1666 if (!is_store && value->is_Con() && index->is_Con()) {
1667 return false;
1668 }
1669
1670 Node* adr = array_element_address(value, index, T_CHAR);
1671 if (is_store) {
1672 (void) store_to_memory(control(), adr, ch, T_CHAR, TypeAryPtr::BYTES, MemNode::unordered,
1673 false, false, true /* mismatched */);
1674 } else {
1675 ch = make_load(control(), adr, TypeInt::CHAR, T_CHAR, TypeAryPtr::BYTES, MemNode::unordered,
1676 LoadNode::DependsOnlyOnTest, false, false, true /* mismatched */);
1677 set_result(ch);
1678 }
1679 return true;
1680 }
1681
1682 //--------------------------round_double_node--------------------------------
1683 // Round a double node if necessary.
1684 Node* LibraryCallKit::round_double_node(Node* n) {
1685 if (Matcher::strict_fp_requires_explicit_rounding && UseSSE <= 1)
1686 n = _gvn.transform(new RoundDoubleNode(0, n));
1687 return n;
1688 }
1689
1690 //------------------------------inline_math-----------------------------------
|
1 /*
2 * Copyright (c) 1999, 2017, 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 *
1651 bool LibraryCallKit::inline_string_char_access(bool is_store) {
1652 Node* value = argument(0);
1653 Node* index = argument(1);
1654 Node* ch = is_store ? argument(2) : NULL;
1655
1656 // This intrinsic accesses byte[] array as char[] array. Computing the offsets
1657 // correctly requires matched array shapes.
1658 assert (arrayOopDesc::base_offset_in_bytes(T_CHAR) == arrayOopDesc::base_offset_in_bytes(T_BYTE),
1659 "sanity: byte[] and char[] bases agree");
1660 assert (type2aelembytes(T_CHAR) == type2aelembytes(T_BYTE)*2,
1661 "sanity: byte[] and char[] scales agree");
1662
1663 // Bail when getChar over constants is requested: constant folding would
1664 // reject folding mismatched char access over byte[]. A normal inlining for getChar
1665 // Java method would constant fold nicely instead.
1666 if (!is_store && value->is_Con() && index->is_Con()) {
1667 return false;
1668 }
1669
1670 Node* adr = array_element_address(value, index, T_CHAR);
1671 if (adr->is_top()) {
1672 return false;
1673 }
1674 if (is_store) {
1675 (void) store_to_memory(control(), adr, ch, T_CHAR, TypeAryPtr::BYTES, MemNode::unordered,
1676 false, false, true /* mismatched */);
1677 } else {
1678 ch = make_load(control(), adr, TypeInt::CHAR, T_CHAR, TypeAryPtr::BYTES, MemNode::unordered,
1679 LoadNode::DependsOnlyOnTest, false, false, true /* mismatched */);
1680 set_result(ch);
1681 }
1682 return true;
1683 }
1684
1685 //--------------------------round_double_node--------------------------------
1686 // Round a double node if necessary.
1687 Node* LibraryCallKit::round_double_node(Node* n) {
1688 if (Matcher::strict_fp_requires_explicit_rounding && UseSSE <= 1)
1689 n = _gvn.transform(new RoundDoubleNode(0, n));
1690 return n;
1691 }
1692
1693 //------------------------------inline_math-----------------------------------
|