hotspot/src/share/vm/c1/c1_ValueType.cpp
author jprovino
Mon, 04 Apr 2016 12:57:48 -0400
changeset 37248 11a660dbbb8e
parent 31957 ed3e3cb35041
child 46630 75aa3e39d02c
permissions -rw-r--r--
8132524: Missing includes to resourceArea.hpp Summary: Files that use ResourceMark are missing the include of resourceArea.hpp Reviewed-by: tschatzl, jwilhelm
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
37248
11a660dbbb8e 8132524: Missing includes to resourceArea.hpp
jprovino
parents: 31957
diff changeset
     2
 * Copyright (c) 1999, 2016, 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: 3908
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 3908
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: 3908
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: 5707
diff changeset
    25
#include "precompiled.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5707
diff changeset
    26
#include "c1/c1_ValueType.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5707
diff changeset
    27
#include "ci/ciArray.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5707
diff changeset
    28
#include "ci/ciInstance.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5707
diff changeset
    29
#include "ci/ciNullObject.hpp"
37248
11a660dbbb8e 8132524: Missing includes to resourceArea.hpp
jprovino
parents: 31957
diff changeset
    30
#include "memory/resourceArea.hpp"
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
// predefined types
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
VoidType*       voidType     = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
IntType*        intType      = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
LongType*       longType     = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
FloatType*      floatType    = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
DoubleType*     doubleType   = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
ObjectType*     objectType   = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
ArrayType*      arrayType    = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
InstanceType*   instanceType = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
ClassType*      classType    = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
AddressType*    addressType  = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
IllegalType*    illegalType  = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
// predefined constants
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
IntConstant*    intZero      = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
IntConstant*    intOne       = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
ObjectConstant* objectNull   = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
5707
6c66849ed24e 6958292: C1: Enable parallel compilation
iveresov
parents: 5547
diff changeset
    53
void ValueType::initialize(Arena* arena) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
  // Note: Must initialize all types for each compilation
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
  //       as they are allocated within a ResourceMark!
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
  // types
5707
6c66849ed24e 6958292: C1: Enable parallel compilation
iveresov
parents: 5547
diff changeset
    58
  voidType     = new (arena) VoidType();
6c66849ed24e 6958292: C1: Enable parallel compilation
iveresov
parents: 5547
diff changeset
    59
  intType      = new (arena) IntType();
6c66849ed24e 6958292: C1: Enable parallel compilation
iveresov
parents: 5547
diff changeset
    60
  longType     = new (arena) LongType();
6c66849ed24e 6958292: C1: Enable parallel compilation
iveresov
parents: 5547
diff changeset
    61
  floatType    = new (arena) FloatType();
6c66849ed24e 6958292: C1: Enable parallel compilation
iveresov
parents: 5547
diff changeset
    62
  doubleType   = new (arena) DoubleType();
6c66849ed24e 6958292: C1: Enable parallel compilation
iveresov
parents: 5547
diff changeset
    63
  objectType   = new (arena) ObjectType();
6c66849ed24e 6958292: C1: Enable parallel compilation
iveresov
parents: 5547
diff changeset
    64
  arrayType    = new (arena) ArrayType();
6c66849ed24e 6958292: C1: Enable parallel compilation
iveresov
parents: 5547
diff changeset
    65
  instanceType = new (arena) InstanceType();
6c66849ed24e 6958292: C1: Enable parallel compilation
iveresov
parents: 5547
diff changeset
    66
  classType    = new (arena) ClassType();
6c66849ed24e 6958292: C1: Enable parallel compilation
iveresov
parents: 5547
diff changeset
    67
  addressType  = new (arena) AddressType();
6c66849ed24e 6958292: C1: Enable parallel compilation
iveresov
parents: 5547
diff changeset
    68
  illegalType  = new (arena) IllegalType();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
5707
6c66849ed24e 6958292: C1: Enable parallel compilation
iveresov
parents: 5547
diff changeset
    70
  intZero     = new (arena) IntConstant(0);
6c66849ed24e 6958292: C1: Enable parallel compilation
iveresov
parents: 5547
diff changeset
    71
  intOne      = new (arena) IntConstant(1);
6c66849ed24e 6958292: C1: Enable parallel compilation
iveresov
parents: 5547
diff changeset
    72
  objectNull  = new (arena) ObjectConstant(ciNullObject::make());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
ValueType* ValueType::meet(ValueType* y) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
  // incomplete & conservative solution for now - fix this!
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
  assert(tag() == y->tag(), "types must match");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
  return base();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
ValueType* ValueType::join(ValueType* y) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
  Unimplemented();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
  return NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
13391
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 7397
diff changeset
    89
ciType* ObjectConstant::exact_type() const {
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 7397
diff changeset
    90
  ciObject* c = constant_value();
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 7397
diff changeset
    91
  return (c != NULL && !c->is_null_object()) ? c->klass() : NULL;
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 7397
diff changeset
    92
}
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 7397
diff changeset
    93
ciType* ArrayConstant::exact_type() const {
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 7397
diff changeset
    94
  ciObject* c = constant_value();
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 7397
diff changeset
    95
  return (c != NULL && !c->is_null_object()) ? c->klass() : NULL;
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 7397
diff changeset
    96
}
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 7397
diff changeset
    97
ciType* InstanceConstant::exact_type() const {
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 7397
diff changeset
    98
  ciObject* c = constant_value();
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 7397
diff changeset
    99
  return (c != NULL && !c->is_null_object()) ? c->klass() : NULL;
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 7397
diff changeset
   100
}
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 7397
diff changeset
   101
ciType* ClassConstant::exact_type() const {
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
   102
  return Compilation::current()->env()->Class_klass();
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
   103
}
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
   104
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
   105
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
   106
jobject ObjectType::encoding() const {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
   107
  assert(is_constant(), "must be");
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
   108
  return constant_value()->constant_encoding();
13391
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 7397
diff changeset
   109
}
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 7397
diff changeset
   110
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
   111
bool ObjectType::is_loaded() const {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
   112
  assert(is_constant(), "must be");
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
   113
  return constant_value()->is_loaded();
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
   114
}
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
   115
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
   116
bool MetadataType::is_loaded() const {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
   117
  assert(is_constant(), "must be");
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
   118
  return constant_value()->is_loaded();
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
   119
}
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
   120
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
   121
ciObject* ObjectConstant::constant_value() const                   { return _value; }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
   122
ciObject* ArrayConstant::constant_value() const                    { return _value; }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
   123
ciObject* InstanceConstant::constant_value() const                 { return _value; }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
ValueType* as_ValueType(BasicType type) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
  switch (type) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
    case T_VOID   : return voidType;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
    case T_BYTE   : // fall through
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
    case T_CHAR   : // fall through
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
    case T_SHORT  : // fall through
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
    case T_BOOLEAN: // fall through
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
    case T_INT    : return intType;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
    case T_LONG   : return longType;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
    case T_FLOAT  : return floatType;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
    case T_DOUBLE : return doubleType;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
    case T_ARRAY  : return arrayType;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
    case T_OBJECT : return objectType;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
    case T_ADDRESS: return addressType;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
    case T_ILLEGAL: return illegalType;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
  ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
  return illegalType;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
ValueType* as_ValueType(ciConstant value) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
  switch (value.basic_type()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
    case T_BYTE   : // fall through
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
    case T_CHAR   : // fall through
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
    case T_SHORT  : // fall through
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
    case T_BOOLEAN: // fall through
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
    case T_INT    : return new IntConstant   (value.as_int   ());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
    case T_LONG   : return new LongConstant  (value.as_long  ());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
    case T_FLOAT  : return new FloatConstant (value.as_float ());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
    case T_DOUBLE : return new DoubleConstant(value.as_double());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
    case T_ARRAY  : // fall through (ciConstant doesn't have an array accessor)
31957
ed3e3cb35041 8131782: C1 Class.cast optimization breaks when Class is loaded from static final
shade
parents: 13742
diff changeset
   157
    case T_OBJECT : {
ed3e3cb35041 8131782: C1 Class.cast optimization breaks when Class is loaded from static final
shade
parents: 13742
diff changeset
   158
      // TODO: Common the code with GraphBuilder::load_constant?
ed3e3cb35041 8131782: C1 Class.cast optimization breaks when Class is loaded from static final
shade
parents: 13742
diff changeset
   159
      ciObject* obj = value.as_object();
ed3e3cb35041 8131782: C1 Class.cast optimization breaks when Class is loaded from static final
shade
parents: 13742
diff changeset
   160
      if (obj->is_null_object())
ed3e3cb35041 8131782: C1 Class.cast optimization breaks when Class is loaded from static final
shade
parents: 13742
diff changeset
   161
        return objectNull;
ed3e3cb35041 8131782: C1 Class.cast optimization breaks when Class is loaded from static final
shade
parents: 13742
diff changeset
   162
      if (obj->is_loaded()) {
ed3e3cb35041 8131782: C1 Class.cast optimization breaks when Class is loaded from static final
shade
parents: 13742
diff changeset
   163
        if (obj->is_array())
ed3e3cb35041 8131782: C1 Class.cast optimization breaks when Class is loaded from static final
shade
parents: 13742
diff changeset
   164
          return new ArrayConstant(obj->as_array());
ed3e3cb35041 8131782: C1 Class.cast optimization breaks when Class is loaded from static final
shade
parents: 13742
diff changeset
   165
        else if (obj->is_instance())
ed3e3cb35041 8131782: C1 Class.cast optimization breaks when Class is loaded from static final
shade
parents: 13742
diff changeset
   166
          return new InstanceConstant(obj->as_instance());
ed3e3cb35041 8131782: C1 Class.cast optimization breaks when Class is loaded from static final
shade
parents: 13742
diff changeset
   167
      }
ed3e3cb35041 8131782: C1 Class.cast optimization breaks when Class is loaded from static final
shade
parents: 13742
diff changeset
   168
      return new ObjectConstant(obj);
ed3e3cb35041 8131782: C1 Class.cast optimization breaks when Class is loaded from static final
shade
parents: 13742
diff changeset
   169
    }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
  ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
  return illegalType;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
BasicType as_BasicType(ValueType* type) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
  switch (type->tag()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
    case voidTag:    return T_VOID;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
    case intTag:     return T_INT;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
    case longTag:    return T_LONG;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   181
    case floatTag:   return T_FLOAT;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   182
    case doubleTag:  return T_DOUBLE;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   183
    case objectTag:  return T_OBJECT;
13742
9180987e305d 7195816: NPG: Crash in c1_ValueType - ShouldNotReachHere
roland
parents: 13728
diff changeset
   184
    case metaDataTag:return T_METADATA;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
    case addressTag: return T_ADDRESS;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   186
    case illegalTag: return T_ILLEGAL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   187
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   188
  ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   189
  return T_ILLEGAL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   190
}