hotspot/src/share/vm/ci/ciConstant.hpp
author never
Wed, 31 Aug 2011 16:46:11 -0700
changeset 10508 233d2e7c462d
parent 7397 5b173b4ca846
child 10547 ea4a2ec31ae2
permissions -rw-r--r--
7083786: dead various dead chunks of code Reviewed-by: iveresov, kvn
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
     2
 * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     4
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
489c9b5090e2 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
489c9b5090e2 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     8
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
489c9b5090e2 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
489c9b5090e2 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    14
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
489c9b5090e2 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    18
 *
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1
diff changeset
    21
 * questions.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    25
#ifndef SHARE_VM_CI_CICONSTANT_HPP
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    26
#define SHARE_VM_CI_CICONSTANT_HPP
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    27
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    28
#include "ci/ciClassList.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    29
#include "ci/ciNullObject.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    30
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
// ciConstant
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
// This class represents a constant value.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
class ciConstant VALUE_OBJ_CLASS_SPEC {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
  friend class ciEnv;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
  friend class ciField;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
  BasicType _type;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
  union {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
    jint      _int;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
    jlong     _long;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
    jint      _long_half[2];
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
    jfloat    _float;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
    jdouble   _double;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
    ciObject* _object;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
  } _value;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
  ciConstant() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
    _type = T_ILLEGAL; _value._long = -1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
  ciConstant(BasicType type, jint value) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
    assert(type != T_LONG && type != T_DOUBLE && type != T_FLOAT,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
           "using the wrong ciConstant constructor");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
    _type = type; _value._int = value;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
  ciConstant(jlong value) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
    _type = T_LONG; _value._long = value;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
  ciConstant(jfloat value) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
    _type = T_FLOAT; _value._float = value;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
  ciConstant(jdouble value) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
    _type = T_DOUBLE; _value._double = value;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
  ciConstant(BasicType type, ciObject* p) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
    _type = type; _value._object = p;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
  BasicType basic_type() const { return _type; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
  jboolean  as_boolean() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
    assert(basic_type() == T_BOOLEAN, "wrong type");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
    return (jboolean)_value._int;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
  jchar     as_char() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
    assert(basic_type() == T_CHAR, "wrong type");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
    return (jchar)_value._int;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
  jbyte     as_byte() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
    assert(basic_type() == T_BYTE, "wrong type");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
    return (jbyte)_value._int;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
  jshort    as_short() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
    assert(basic_type() == T_SHORT, "wrong type");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
    return (jshort)_value._int;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
  jint      as_int() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
    assert(basic_type() == T_BOOLEAN || basic_type() == T_CHAR  ||
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
           basic_type() == T_BYTE    || basic_type() == T_SHORT ||
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
           basic_type() == T_INT, "wrong type");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
    return _value._int;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
  jlong     as_long() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
    assert(basic_type() == T_LONG, "wrong type");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
    return _value._long;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
  jfloat    as_float() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
    assert(basic_type() == T_FLOAT, "wrong type");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
    return _value._float;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
  jdouble   as_double() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
    assert(basic_type() == T_DOUBLE, "wrong type");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
    return _value._double;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
  ciObject* as_object() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
    assert(basic_type() == T_OBJECT || basic_type() == T_ARRAY, "wrong type");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
    return _value._object;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
  // Debugging output
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
  void print();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
};
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   116
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   117
#endif // SHARE_VM_CI_CICONSTANT_HPP