src/share/vm/shark/sharkValue.cpp

Wed, 11 Aug 2010 05:51:21 -0700

author
twisti
date
Wed, 11 Aug 2010 05:51:21 -0700
changeset 2047
d2ede61b7a12
child 2314
f95d63e2154a
permissions
-rw-r--r--

6976186: integrate Shark HotSpot changes
Summary: Shark is a JIT compiler for Zero that uses the LLVM compiler infrastructure.
Reviewed-by: kvn, twisti
Contributed-by: Gary Benson <gbenson@redhat.com>

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

mercurial