hotspot/src/share/vm/shark/sharkValue.cpp
author jlaskey
Tue, 23 Jul 2013 12:00:29 -0300
changeset 19089 51cfdcf21d35
parent 14622 8e94e4186d35
permissions -rw-r--r--
8021130: Comments need to be tokens Reviewed-by: lagergren, attila Contributed-by: james.laskey@oracle.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
6187
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
     1
/*
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6187
diff changeset
     2
 * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
6187
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
     3
 * Copyright 2008, 2009 Red Hat, Inc.
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
     4
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
     5
 *
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
     6
 * This code is free software; you can redistribute it and/or modify it
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
     7
 * under the terms of the GNU General Public License version 2 only, as
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
     8
 * published by the Free Software Foundation.
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
     9
 *
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    10
 * This code is distributed in the hope that it will be useful, but WITHOUT
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    11
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    12
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    13
 * version 2 for more details (a copy is included in the LICENSE file that
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    14
 * accompanied this code).
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    15
 *
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    16
 * You should have received a copy of the GNU General Public License version
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    17
 * 2 along with this work; if not, write to the Free Software Foundation,
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    18
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    19
 *
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    20
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    21
 * or visit www.oracle.com if you need additional information or have any
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    22
 * questions.
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    23
 *
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    24
 */
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    25
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6187
diff changeset
    26
#include "precompiled.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6187
diff changeset
    27
#include "ci/ciType.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6187
diff changeset
    28
#include "shark/llvmHeaders.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6187
diff changeset
    29
#include "shark/llvmValue.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6187
diff changeset
    30
#include "shark/sharkBuilder.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6187
diff changeset
    31
#include "shark/sharkValue.hpp"
6187
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    32
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    33
using namespace llvm;
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    34
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    35
// Cloning
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    36
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    37
SharkValue* SharkNormalValue::clone() const {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    38
  return SharkValue::create_generic(type(), generic_value(), zero_checked());
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    39
}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    40
SharkValue* SharkPHIValue::clone() const {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    41
  return SharkValue::create_phi(type(), (PHINode *) generic_value(), this);
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    42
}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    43
SharkValue* SharkAddressValue::clone() const {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    44
  return SharkValue::address_constant(address_value());
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    45
}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    46
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    47
// Casting
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    48
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    49
bool SharkValue::is_phi() const {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    50
  return false;
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    51
}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    52
bool SharkPHIValue::is_phi() const {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    53
  return true;
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    54
}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    55
SharkPHIValue* SharkValue::as_phi() {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    56
  ShouldNotCallThis();
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    57
}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    58
SharkPHIValue* SharkPHIValue::as_phi() {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    59
  return this;
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    60
}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    61
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    62
// Comparison
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    63
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    64
bool SharkNormalValue::equal_to(SharkValue *other) const {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    65
  return (this->type()          == other->type() &&
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    66
          this->generic_value() == other->generic_value() &&
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    67
          this->zero_checked()  == other->zero_checked());
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    68
}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    69
bool SharkAddressValue::equal_to(SharkValue *other) const {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    70
  return (this->address_value() == other->address_value());
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    71
}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    72
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    73
// Type access
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    74
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    75
ciType* SharkValue::type() const {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    76
  ShouldNotCallThis();
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    77
}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    78
ciType* SharkNormalValue::type() const {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    79
  return _type;
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    80
}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    81
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    82
BasicType SharkNormalValue::basic_type() const {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    83
  return type()->basic_type();
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    84
}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    85
BasicType SharkAddressValue::basic_type() const {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    86
  return T_ADDRESS;
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    87
}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    88
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    89
int SharkNormalValue::size() const {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    90
  return type()->size();
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    91
}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    92
int SharkAddressValue::size() const {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    93
  return 1;
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    94
}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    95
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    96
bool SharkValue::is_jint() const {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    97
  return false;
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    98
}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    99
bool SharkValue::is_jlong() const {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   100
  return false;
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   101
}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   102
bool SharkValue::is_jfloat() const {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   103
  return false;
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   104
}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   105
bool SharkValue::is_jdouble() const {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   106
  return false;
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   107
}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   108
bool SharkValue::is_jobject() const {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   109
  return false;
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   110
}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   111
bool SharkValue::is_jarray() const {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   112
  return false;
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   113
}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   114
bool SharkValue::is_address() const {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   115
  return false;
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   116
}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   117
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   118
bool SharkNormalValue::is_jint() const {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   119
  return llvm_value()->getType() == SharkType::jint_type();
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   120
}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   121
bool SharkNormalValue::is_jlong() const {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   122
  return llvm_value()->getType() == SharkType::jlong_type();
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   123
}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   124
bool SharkNormalValue::is_jfloat() const {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   125
  return llvm_value()->getType() == SharkType::jfloat_type();
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   126
}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   127
bool SharkNormalValue::is_jdouble() const {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   128
  return llvm_value()->getType() == SharkType::jdouble_type();
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   129
}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   130
bool SharkNormalValue::is_jobject() const {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   131
  return llvm_value()->getType() == SharkType::oop_type();
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   132
}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   133
bool SharkNormalValue::is_jarray() const {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   134
  return basic_type() == T_ARRAY;
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   135
}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   136
bool SharkAddressValue::is_address() const {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   137
  return true;
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   138
}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   139
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   140
// Typed conversions from SharkValues
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   141
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   142
Value* SharkValue::jint_value() const {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   143
  ShouldNotCallThis();
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   144
}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   145
Value* SharkValue::jlong_value() const {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   146
  ShouldNotCallThis();
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   147
}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   148
Value* SharkValue::jfloat_value() const {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   149
  ShouldNotCallThis();
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   150
}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   151
Value* SharkValue::jdouble_value() const {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   152
  ShouldNotCallThis();
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   153
}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   154
Value* SharkValue::jobject_value() const {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   155
  ShouldNotCallThis();
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   156
}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   157
Value* SharkValue::jarray_value() const {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   158
  ShouldNotCallThis();
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   159
}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   160
int SharkValue::address_value() const {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   161
  ShouldNotCallThis();
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   162
}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   163
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   164
Value* SharkNormalValue::jint_value() const {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   165
  assert(is_jint(), "should be");
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   166
  return llvm_value();
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   167
}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   168
Value* SharkNormalValue::jlong_value() const {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   169
  assert(is_jlong(), "should be");
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   170
  return llvm_value();
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   171
}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   172
Value* SharkNormalValue::jfloat_value() const {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   173
  assert(is_jfloat(), "should be");
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   174
  return llvm_value();
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   175
}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   176
Value* SharkNormalValue::jdouble_value() const {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   177
  assert(is_jdouble(), "should be");
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   178
  return llvm_value();
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   179
}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   180
Value* SharkNormalValue::jobject_value() const {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   181
  assert(is_jobject(), "should be");
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   182
  return llvm_value();
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   183
}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   184
Value* SharkNormalValue::jarray_value() const {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   185
  // XXX assert(is_jarray(), "should be");
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   186
  // XXX http://icedtea.classpath.org/bugzilla/show_bug.cgi?id=324
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   187
  assert(is_jobject(), "should be");
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   188
  return llvm_value();
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   189
}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   190
int SharkAddressValue::address_value() const {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   191
  return _bci;
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   192
}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   193
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   194
// Type-losing conversions -- use with care!
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   195
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   196
Value* SharkNormalValue::generic_value() const {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   197
  return llvm_value();
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   198
}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   199
Value* SharkAddressValue::generic_value() const {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   200
  return LLVMValue::intptr_constant(address_value());
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   201
}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   202
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   203
Value* SharkValue::intptr_value(SharkBuilder* builder) const {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   204
  ShouldNotCallThis();
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   205
}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   206
Value* SharkNormalValue::intptr_value(SharkBuilder* builder) const {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   207
  return builder->CreatePtrToInt(jobject_value(), SharkType::intptr_type());
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   208
}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   209
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   210
// Phi-style stuff for SharkPHIState::add_incoming
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   211
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   212
void SharkValue::addIncoming(SharkValue *value, BasicBlock* block) {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   213
  ShouldNotCallThis();
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   214
}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   215
void SharkPHIValue::addIncoming(SharkValue *value, BasicBlock* block) {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   216
  assert(!is_clone(), "shouldn't be");
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   217
  ((llvm::PHINode *) generic_value())->addIncoming(
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   218
      value->generic_value(), block);
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   219
  if (!value->zero_checked())
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   220
    _all_incomers_zero_checked = false;
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   221
}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   222
void SharkAddressValue::addIncoming(SharkValue *value, BasicBlock* block) {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   223
  assert(this->equal_to(value), "should be");
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   224
}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   225
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   226
// Phi-style stuff for SharkState::merge
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   227
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   228
SharkValue* SharkNormalValue::merge(SharkBuilder* builder,
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   229
                                    SharkValue*   other,
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   230
                                    BasicBlock*   other_block,
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   231
                                    BasicBlock*   this_block,
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   232
                                    const char*   name) {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   233
  assert(type() == other->type(), "should be");
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   234
  assert(zero_checked() == other->zero_checked(), "should be");
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   235
14622
8e94e4186d35 8003868: fix shark for latest HotSpot and LLVM
twisti
parents: 7397
diff changeset
   236
  PHINode *phi = builder->CreatePHI(SharkType::to_stackType(type()), 0, name);
6187
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   237
  phi->addIncoming(this->generic_value(), this_block);
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   238
  phi->addIncoming(other->generic_value(), other_block);
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   239
  return SharkValue::create_generic(type(), phi, zero_checked());
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   240
}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   241
SharkValue* SharkAddressValue::merge(SharkBuilder* builder,
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   242
                                     SharkValue*   other,
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   243
                                     BasicBlock*   other_block,
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   244
                                     BasicBlock*   this_block,
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   245
                                     const char*   name) {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   246
  assert(this->equal_to(other), "should be");
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   247
  return this;
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   248
}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   249
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   250
// Repeated null and divide-by-zero check removal
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   251
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   252
bool SharkValue::zero_checked() const {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   253
  ShouldNotCallThis();
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   254
}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   255
void SharkValue::set_zero_checked(bool zero_checked) {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   256
  ShouldNotCallThis();
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   257
}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   258
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   259
bool SharkNormalValue::zero_checked() const {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   260
  return _zero_checked;
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   261
}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   262
void SharkNormalValue::set_zero_checked(bool zero_checked) {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   263
  _zero_checked = zero_checked;
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   264
}