hotspot/src/share/vm/opto/countbitsnode.cpp
author thartmann
Fri, 20 Nov 2015 10:09:42 +0100
changeset 34204 5ad1ba3afecc
parent 23528 8f1a7f5e8066
child 35551 36ef3841fb34
permissions -rw-r--r--
8140390: Char stores/loads accessing byte arrays must be marked as unmatched Summary: Mark unmatched char stores/loads emitted by CompactStrings. Reviewed-by: roland, vlivanov, jrose
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
23528
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
     1
/*
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
     2
 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
     4
 *
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
     7
 * published by the Free Software Foundation.
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
     8
 *
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    13
 * accompanied this code).
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    14
 *
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    18
 *
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    21
 * questions.
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    22
 *
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    23
 */
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    24
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    25
#include "precompiled.hpp"
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    26
#include "opto/countbitsnode.hpp"
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    27
#include "opto/opcodes.hpp"
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    28
#include "opto/phaseX.hpp"
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    29
#include "opto/type.hpp"
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    30
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    31
//------------------------------Value------------------------------------------
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    32
const Type* CountLeadingZerosINode::Value(PhaseTransform* phase) const {
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    33
  const Type* t = phase->type(in(1));
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    34
  if (t == Type::TOP) return Type::TOP;
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    35
  const TypeInt* ti = t->isa_int();
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    36
  if (ti && ti->is_con()) {
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    37
    jint i = ti->get_con();
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    38
    // HD, Figure 5-6
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    39
    if (i == 0)
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    40
    return TypeInt::make(BitsPerInt);
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    41
    int n = 1;
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    42
    unsigned int x = i;
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    43
    if (x >> 16 == 0) { n += 16; x <<= 16; }
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    44
    if (x >> 24 == 0) { n +=  8; x <<=  8; }
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    45
    if (x >> 28 == 0) { n +=  4; x <<=  4; }
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    46
    if (x >> 30 == 0) { n +=  2; x <<=  2; }
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    47
    n -= x >> 31;
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    48
    return TypeInt::make(n);
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    49
  }
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    50
  return TypeInt::INT;
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    51
}
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    52
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    53
//------------------------------Value------------------------------------------
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    54
const Type* CountLeadingZerosLNode::Value(PhaseTransform* phase) const {
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    55
  const Type* t = phase->type(in(1));
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    56
  if (t == Type::TOP) return Type::TOP;
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    57
  const TypeLong* tl = t->isa_long();
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    58
  if (tl && tl->is_con()) {
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    59
    jlong l = tl->get_con();
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    60
    // HD, Figure 5-6
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    61
    if (l == 0)
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    62
    return TypeInt::make(BitsPerLong);
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    63
    int n = 1;
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    64
    unsigned int x = (((julong) l) >> 32);
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    65
    if (x == 0) { n += 32; x = (int) l; }
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    66
    if (x >> 16 == 0) { n += 16; x <<= 16; }
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    67
    if (x >> 24 == 0) { n +=  8; x <<=  8; }
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    68
    if (x >> 28 == 0) { n +=  4; x <<=  4; }
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    69
    if (x >> 30 == 0) { n +=  2; x <<=  2; }
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    70
    n -= x >> 31;
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    71
    return TypeInt::make(n);
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    72
  }
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    73
  return TypeInt::INT;
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    74
}
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    75
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    76
//------------------------------Value------------------------------------------
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    77
const Type* CountTrailingZerosINode::Value(PhaseTransform* phase) const {
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    78
  const Type* t = phase->type(in(1));
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    79
  if (t == Type::TOP) return Type::TOP;
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    80
  const TypeInt* ti = t->isa_int();
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    81
  if (ti && ti->is_con()) {
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    82
    jint i = ti->get_con();
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    83
    // HD, Figure 5-14
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    84
    int y;
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    85
    if (i == 0)
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    86
    return TypeInt::make(BitsPerInt);
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    87
    int n = 31;
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    88
    y = i << 16; if (y != 0) { n = n - 16; i = y; }
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    89
    y = i <<  8; if (y != 0) { n = n -  8; i = y; }
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    90
    y = i <<  4; if (y != 0) { n = n -  4; i = y; }
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    91
    y = i <<  2; if (y != 0) { n = n -  2; i = y; }
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    92
    y = i <<  1; if (y != 0) { n = n -  1; }
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    93
    return TypeInt::make(n);
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    94
  }
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    95
  return TypeInt::INT;
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    96
}
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    97
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    98
//------------------------------Value------------------------------------------
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    99
const Type* CountTrailingZerosLNode::Value(PhaseTransform* phase) const {
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   100
  const Type* t = phase->type(in(1));
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   101
  if (t == Type::TOP) return Type::TOP;
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   102
  const TypeLong* tl = t->isa_long();
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   103
  if (tl && tl->is_con()) {
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   104
    jlong l = tl->get_con();
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   105
    // HD, Figure 5-14
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   106
    int x, y;
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   107
    if (l == 0)
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   108
    return TypeInt::make(BitsPerLong);
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   109
    int n = 63;
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   110
    y = (int) l; if (y != 0) { n = n - 32; x = y; } else x = (((julong) l) >> 32);
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   111
    y = x << 16; if (y != 0) { n = n - 16; x = y; }
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   112
    y = x <<  8; if (y != 0) { n = n -  8; x = y; }
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   113
    y = x <<  4; if (y != 0) { n = n -  4; x = y; }
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   114
    y = x <<  2; if (y != 0) { n = n -  2; x = y; }
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   115
    y = x <<  1; if (y != 0) { n = n -  1; }
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   116
    return TypeInt::make(n);
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   117
  }
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   118
  return TypeInt::INT;
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   119
}