Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/src/share/vm/shark/sharkValue.cpp
32285 views
/*1* Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.2* Copyright 2008, 2009 Red Hat, Inc.3* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.4*5* This code is free software; you can redistribute it and/or modify it6* under the terms of the GNU General Public License version 2 only, as7* published by the Free Software Foundation.8*9* This code is distributed in the hope that it will be useful, but WITHOUT10* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or11* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License12* version 2 for more details (a copy is included in the LICENSE file that13* accompanied this code).14*15* You should have received a copy of the GNU General Public License version16* 2 along with this work; if not, write to the Free Software Foundation,17* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.18*19* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA20* or visit www.oracle.com if you need additional information or have any21* questions.22*23*/2425#include "precompiled.hpp"26#include "ci/ciType.hpp"27#include "shark/llvmHeaders.hpp"28#include "shark/llvmValue.hpp"29#include "shark/sharkBuilder.hpp"30#include "shark/sharkValue.hpp"3132using namespace llvm;3334// Cloning3536SharkValue* SharkNormalValue::clone() const {37return SharkValue::create_generic(type(), generic_value(), zero_checked());38}39SharkValue* SharkPHIValue::clone() const {40return SharkValue::create_phi(type(), (PHINode *) generic_value(), this);41}42SharkValue* SharkAddressValue::clone() const {43return SharkValue::address_constant(address_value());44}4546// Casting4748bool SharkValue::is_phi() const {49return false;50}51bool SharkPHIValue::is_phi() const {52return true;53}54SharkPHIValue* SharkValue::as_phi() {55ShouldNotCallThis();56}57SharkPHIValue* SharkPHIValue::as_phi() {58return this;59}6061// Comparison6263bool SharkNormalValue::equal_to(SharkValue *other) const {64return (this->type() == other->type() &&65this->generic_value() == other->generic_value() &&66this->zero_checked() == other->zero_checked());67}68bool SharkAddressValue::equal_to(SharkValue *other) const {69return (this->address_value() == other->address_value());70}7172// Type access7374ciType* SharkValue::type() const {75ShouldNotCallThis();76}77ciType* SharkNormalValue::type() const {78return _type;79}8081BasicType SharkNormalValue::basic_type() const {82return type()->basic_type();83}84BasicType SharkAddressValue::basic_type() const {85return T_ADDRESS;86}8788int SharkNormalValue::size() const {89return type()->size();90}91int SharkAddressValue::size() const {92return 1;93}9495bool SharkValue::is_jint() const {96return false;97}98bool SharkValue::is_jlong() const {99return false;100}101bool SharkValue::is_jfloat() const {102return false;103}104bool SharkValue::is_jdouble() const {105return false;106}107bool SharkValue::is_jobject() const {108return false;109}110bool SharkValue::is_jarray() const {111return false;112}113bool SharkValue::is_address() const {114return false;115}116117bool SharkNormalValue::is_jint() const {118return llvm_value()->getType() == SharkType::jint_type();119}120bool SharkNormalValue::is_jlong() const {121return llvm_value()->getType() == SharkType::jlong_type();122}123bool SharkNormalValue::is_jfloat() const {124return llvm_value()->getType() == SharkType::jfloat_type();125}126bool SharkNormalValue::is_jdouble() const {127return llvm_value()->getType() == SharkType::jdouble_type();128}129bool SharkNormalValue::is_jobject() const {130return llvm_value()->getType() == SharkType::oop_type();131}132bool SharkNormalValue::is_jarray() const {133return basic_type() == T_ARRAY;134}135bool SharkAddressValue::is_address() const {136return true;137}138139// Typed conversions from SharkValues140141Value* SharkValue::jint_value() const {142ShouldNotCallThis();143}144Value* SharkValue::jlong_value() const {145ShouldNotCallThis();146}147Value* SharkValue::jfloat_value() const {148ShouldNotCallThis();149}150Value* SharkValue::jdouble_value() const {151ShouldNotCallThis();152}153Value* SharkValue::jobject_value() const {154ShouldNotCallThis();155}156Value* SharkValue::jarray_value() const {157ShouldNotCallThis();158}159int SharkValue::address_value() const {160ShouldNotCallThis();161}162163Value* SharkNormalValue::jint_value() const {164assert(is_jint(), "should be");165return llvm_value();166}167Value* SharkNormalValue::jlong_value() const {168assert(is_jlong(), "should be");169return llvm_value();170}171Value* SharkNormalValue::jfloat_value() const {172assert(is_jfloat(), "should be");173return llvm_value();174}175Value* SharkNormalValue::jdouble_value() const {176assert(is_jdouble(), "should be");177return llvm_value();178}179Value* SharkNormalValue::jobject_value() const {180assert(is_jobject(), "should be");181return llvm_value();182}183Value* SharkNormalValue::jarray_value() const {184// XXX assert(is_jarray(), "should be");185// XXX http://icedtea.classpath.org/bugzilla/show_bug.cgi?id=324186assert(is_jobject(), "should be");187return llvm_value();188}189int SharkAddressValue::address_value() const {190return _bci;191}192193// Type-losing conversions -- use with care!194195Value* SharkNormalValue::generic_value() const {196return llvm_value();197}198Value* SharkAddressValue::generic_value() const {199return LLVMValue::intptr_constant(address_value());200}201202Value* SharkValue::intptr_value(SharkBuilder* builder) const {203ShouldNotCallThis();204}205Value* SharkNormalValue::intptr_value(SharkBuilder* builder) const {206return builder->CreatePtrToInt(jobject_value(), SharkType::intptr_type());207}208209// Phi-style stuff for SharkPHIState::add_incoming210211void SharkValue::addIncoming(SharkValue *value, BasicBlock* block) {212ShouldNotCallThis();213}214void SharkPHIValue::addIncoming(SharkValue *value, BasicBlock* block) {215assert(!is_clone(), "shouldn't be");216((llvm::PHINode *) generic_value())->addIncoming(217value->generic_value(), block);218if (!value->zero_checked())219_all_incomers_zero_checked = false;220}221void SharkAddressValue::addIncoming(SharkValue *value, BasicBlock* block) {222assert(this->equal_to(value), "should be");223}224225// Phi-style stuff for SharkState::merge226227SharkValue* SharkNormalValue::merge(SharkBuilder* builder,228SharkValue* other,229BasicBlock* other_block,230BasicBlock* this_block,231const char* name) {232assert(type() == other->type(), "should be");233assert(zero_checked() == other->zero_checked(), "should be");234235PHINode *phi = builder->CreatePHI(SharkType::to_stackType(type()), 0, name);236phi->addIncoming(this->generic_value(), this_block);237phi->addIncoming(other->generic_value(), other_block);238return SharkValue::create_generic(type(), phi, zero_checked());239}240SharkValue* SharkAddressValue::merge(SharkBuilder* builder,241SharkValue* other,242BasicBlock* other_block,243BasicBlock* this_block,244const char* name) {245assert(this->equal_to(other), "should be");246return this;247}248249// Repeated null and divide-by-zero check removal250251bool SharkValue::zero_checked() const {252ShouldNotCallThis();253}254void SharkValue::set_zero_checked(bool zero_checked) {255ShouldNotCallThis();256}257258bool SharkNormalValue::zero_checked() const {259return _zero_checked;260}261void SharkNormalValue::set_zero_checked(bool zero_checked) {262_zero_checked = zero_checked;263}264265266