# HG changeset patch # User Gary Benson # Date 1236935225 14400 # Node ID 4d70fcddd403ee68d11dd3a61abb08def1aaef5b # Parent 1caf618d2b4cf5fc2a58d3754526fa5db09b10ab 2009-03-13 Gary Benson * ports/hotspot/src/share/vm/shark/sharkValue.hpp (SharkValue): Moved virtual method bodies to sharkValue.cpp. (SharkValue::is_address): Renamed from is_returnAddress. (SharkValue::address_value): Renamed from returnAddress_value. (SharkValue::address_constant): Renamed from create_returnAddress. (SharkNormalValue): Renamed from SharkComputableValue, and moved virtual method bodies to sharkValue.cpp. (SharkAddressValue): Renamed from SharkReturnAddressValue, and moved virtual method bodies to sharkValue.cpp. (SharkAddressValue::is_address): Renamed from is_returnAddress. (SharkAddressValue::address_value): Renamed from returnAddress_value. * ports/hotspot/src/share/vm/shark/sharkValue.cpp: New file. * ports/hotspot/src/share/vm/shark/sharkTopLevelBlock.cpp (SharkPHIState::SharkPHIState): s/create_returnAddress/address_constant/ (SharkTopLevelBlock::do_jsr): Likewise. (SharkTopLevelBlock::do_ret): s/returnAddress_value/address_value/ * ports/hotspot/src/share/vm/includeDB_shark: Updated. diff -r 1caf618d2b4c -r 4d70fcddd403 ChangeLog --- a/ChangeLog Thu Mar 12 10:23:39 2009 -0400 +++ b/ChangeLog Fri Mar 13 05:07:05 2009 -0400 @@ -1,3 +1,25 @@ +2009-03-13 Gary Benson + + * ports/hotspot/src/share/vm/shark/sharkValue.hpp + (SharkValue): Moved virtual method bodies to sharkValue.cpp. + (SharkValue::is_address): Renamed from is_returnAddress. + (SharkValue::address_value): Renamed from returnAddress_value. + (SharkValue::address_constant): Renamed from create_returnAddress. + (SharkNormalValue): Renamed from SharkComputableValue, and moved + virtual method bodies to sharkValue.cpp. + (SharkAddressValue): Renamed from SharkReturnAddressValue, and + moved virtual method bodies to sharkValue.cpp. + (SharkAddressValue::is_address): Renamed from is_returnAddress. + (SharkAddressValue::address_value): Renamed from returnAddress_value. + * ports/hotspot/src/share/vm/shark/sharkValue.cpp: New file. + + * ports/hotspot/src/share/vm/shark/sharkTopLevelBlock.cpp + (SharkPHIState::SharkPHIState): s/create_returnAddress/address_constant/ + (SharkTopLevelBlock::do_jsr): Likewise. + (SharkTopLevelBlock::do_ret): s/returnAddress_value/address_value/ + + * ports/hotspot/src/share/vm/includeDB_shark: Updated. + 2009-03-12 Gary Benson * ports/hotspot/src/share/vm/shark/sharkValue.hpp diff -r 1caf618d2b4c -r 4d70fcddd403 ports/hotspot/src/share/vm/includeDB_shark --- a/ports/hotspot/src/share/vm/includeDB_shark Thu Mar 12 10:23:39 2009 -0400 +++ b/ports/hotspot/src/share/vm/includeDB_shark Fri Mar 13 05:07:05 2009 -0400 @@ -329,6 +329,12 @@ sharkType.hpp globalDefinitions.hpp sharkType.hpp llvmHeaders.hpp +sharkValue.cpp ciType.hpp +sharkValue.cpp llvmHeaders.hpp +sharkValue.cpp llvmValue.hpp +sharkValue.cpp sharkBuilder.hpp +sharkValue.cpp sharkValue.hpp + sharkValue.hpp allocation.hpp sharkValue.hpp ciType.hpp sharkValue.hpp llvmHeaders.hpp diff -r 1caf618d2b4c -r 4d70fcddd403 ports/hotspot/src/share/vm/shark/sharkTopLevelBlock.cpp --- a/ports/hotspot/src/share/vm/shark/sharkTopLevelBlock.cpp Thu Mar 12 10:23:39 2009 -0400 +++ b/ports/hotspot/src/share/vm/shark/sharkTopLevelBlock.cpp Fri Mar 13 05:07:05 2009 -0400 @@ -62,8 +62,7 @@ break; case T_ADDRESS: - value = SharkValue::create_returnAddress( - type->as_return_address()->bci()); + value = SharkValue::address_constant(type->as_return_address()->bci()); break; case ciTypeFlow::StateVector::T_BOTTOM: @@ -101,8 +100,7 @@ break; case T_ADDRESS: - value = SharkValue::create_returnAddress( - type->as_return_address()->bci()); + value = SharkValue::address_constant(type->as_return_address()->bci()); break; case ciTypeFlow::StateVector::T_LONG2: @@ -888,13 +886,13 @@ void SharkTopLevelBlock::do_jsr() { - push(SharkValue::create_returnAddress(iter()->next_bci())); + push(SharkValue::address_constant(iter()->next_bci())); builder()->CreateBr(successor(ciTypeFlow::GOTO_TARGET)->entry_block()); } void SharkTopLevelBlock::do_ret() { - assert(local(iter()->get_index())->returnAddress_value() == + assert(local(iter()->get_index())->address_value() == successor(ciTypeFlow::GOTO_TARGET)->start(), "should be"); builder()->CreateBr(successor(ciTypeFlow::GOTO_TARGET)->entry_block()); } diff -r 1caf618d2b4c -r 4d70fcddd403 ports/hotspot/src/share/vm/shark/sharkValue.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ports/hotspot/src/share/vm/shark/sharkValue.cpp Fri Mar 13 05:07:05 2009 -0400 @@ -0,0 +1,235 @@ +/* + * Copyright 1999-2007 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2008, 2009 Red Hat, Inc. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + * + */ + +#include "incls/_precompiled.incl" +#include "incls/_sharkValue.cpp.incl" + +using namespace llvm; + +// Type access + +ciType* SharkValue::type() const +{ + ShouldNotCallThis(); +} +ciType* SharkNormalValue::type() const +{ + return _type; +} + +BasicType SharkNormalValue::basic_type() const +{ + return type()->basic_type(); +} +BasicType SharkAddressValue::basic_type() const +{ + return T_ADDRESS; +} + +int SharkNormalValue::size() const +{ + return type()->size(); +} +int SharkAddressValue::size() const +{ + return 1; +} + +bool SharkValue::is_jint() const +{ + return false; +} +bool SharkValue::is_jlong() const +{ + return false; +} +bool SharkValue::is_jfloat() const +{ + return false; +} +bool SharkValue::is_jdouble() const +{ + return false; +} +bool SharkValue::is_jobject() const +{ + return false; +} +bool SharkValue::is_jarray() const +{ + return false; +} +bool SharkValue::is_address() const +{ + return false; +} + +bool SharkNormalValue::is_jint() const +{ + return llvm_value()->getType() == SharkType::jint_type(); +} +bool SharkNormalValue::is_jlong() const +{ + return llvm_value()->getType() == SharkType::jlong_type(); +} +bool SharkNormalValue::is_jfloat() const +{ + return llvm_value()->getType() == SharkType::jfloat_type(); +} +bool SharkNormalValue::is_jdouble() const +{ + return llvm_value()->getType() == SharkType::jdouble_type(); +} +bool SharkNormalValue::is_jobject() const +{ + return llvm_value()->getType() == SharkType::jobject_type(); +} +bool SharkNormalValue::is_jarray() const +{ + return basic_type() == T_ARRAY; +} +bool SharkAddressValue::is_address() const +{ + return true; +} + +// Typed conversions from SharkValues + +Value* SharkValue::jint_value() const +{ + ShouldNotCallThis(); +} +Value* SharkValue::jlong_value() const +{ + ShouldNotCallThis(); +} +Value* SharkValue::jfloat_value() const +{ + ShouldNotCallThis(); +} +Value* SharkValue::jdouble_value() const +{ + ShouldNotCallThis(); +} +Value* SharkValue::jobject_value() const +{ + ShouldNotCallThis(); +} +Value* SharkValue::jarray_value() const +{ + ShouldNotCallThis(); +} +int SharkValue::address_value() const +{ + ShouldNotCallThis(); +} + +Value* SharkNormalValue::jint_value() const +{ + assert(is_jint(), "should be"); + return llvm_value(); +} +Value* SharkNormalValue::jlong_value() const +{ + assert(is_jlong(), "should be"); + return llvm_value(); +} +Value* SharkNormalValue::jfloat_value() const +{ + assert(is_jfloat(), "should be"); + return llvm_value(); +} +Value* SharkNormalValue::jdouble_value() const +{ + assert(is_jdouble(), "should be"); + return llvm_value(); +} +Value* SharkNormalValue::jobject_value() const +{ + assert(is_jobject(), "should be"); + return llvm_value(); +} +Value* SharkNormalValue::jarray_value() const +{ + assert(is_jarray(), "should be"); + return llvm_value(); +} +int SharkAddressValue::address_value() const +{ + return _bci; +} + +// Type-losing conversions -- use with care! + +Value* SharkNormalValue::generic_value() const +{ + return llvm_value(); +} +Value* SharkAddressValue::generic_value() const +{ + return LLVMValue::intptr_constant(_bci); +} + +Value* SharkValue::intptr_value(SharkBuilder* builder) const +{ + ShouldNotCallThis(); +} +Value* SharkNormalValue::intptr_value(SharkBuilder* builder) const +{ + return builder->CreatePtrToInt(jobject_value(), SharkType::intptr_type()); +} + +// Phi-style stuff + +void SharkNormalValue::addIncoming(SharkValue *value, BasicBlock* block) +{ + assert(llvm::isa(generic_value()), "should be"); + ((llvm::PHINode *) generic_value())->addIncoming( + value->generic_value(), block); +} +void SharkAddressValue::addIncoming(SharkValue *value, BasicBlock* block) +{ + assert(_bci == value->address_value(), "should be"); +} + +// Repeated null and divide-by-zero check removal + +bool SharkValue::zero_checked() const +{ + ShouldNotCallThis(); +} +void SharkValue::set_zero_checked(bool zero_checked) +{ + ShouldNotCallThis(); +} + +bool SharkNormalValue::zero_checked() const +{ + return _zero_checked; +} +void SharkNormalValue::set_zero_checked(bool zero_checked) +{ + _zero_checked = zero_checked; +} diff -r 1caf618d2b4c -r 4d70fcddd403 ports/hotspot/src/share/vm/shark/sharkValue.hpp --- a/ports/hotspot/src/share/vm/shark/sharkValue.hpp Thu Mar 12 10:23:39 2009 -0400 +++ b/ports/hotspot/src/share/vm/shark/sharkValue.hpp Fri Mar 13 05:07:05 2009 -0400 @@ -1,6 +1,6 @@ /* * Copyright 1999-2007 Sun Microsystems, Inc. All Rights Reserved. - * Copyright 2008 Red Hat, Inc. + * Copyright 2008, 2009 Red Hat, Inc. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,25 +23,37 @@ * */ +// Items on the stack and in local variables are tracked using +// SharkValue objects. There are two types, SharkNormalValue +// and SharkAddressValue, but no code outside this file should +// ever refer to those directly. The split is because of the +// way JSRs are handled: the typeflow pass expands them into +// multiple copies, so the return addresses pushed by jsr and +// popped by ret only exist at compile time. Having separate +// classes for these allows us to check that our jsr handling +// is correct, via assertions. + +class SharkBuilder; + class SharkValue : public ResourceObj { protected: SharkValue() {} // Type access public: - virtual ciType* type() const - { - ShouldNotCallThis(); - } + virtual BasicType basic_type() const = 0; + virtual ciType* type() const; - virtual BasicType basic_type() const - { - ShouldNotCallThis(); - } - virtual int size() const - { - ShouldNotCallThis(); - } + virtual bool is_jint() const; + virtual bool is_jlong() const; + virtual bool is_jfloat() const; + virtual bool is_jdouble() const; + virtual bool is_jobject() const; + virtual bool is_jarray() const; + virtual bool is_address() const; + + virtual int size() const = 0; + bool is_one_word() const { return size() == 1; @@ -51,67 +63,45 @@ return size() == 2; } - virtual bool is_jint() const - { - return false; - } - virtual bool is_jlong() const - { - return false; - } - virtual bool is_jfloat() const - { - return false; - } - virtual bool is_jdouble() const + // Typed conversion from SharkValues + public: + virtual llvm::Value* jint_value() const; + virtual llvm::Value* jlong_value() const; + virtual llvm::Value* jfloat_value() const; + virtual llvm::Value* jdouble_value() const; + virtual llvm::Value* jobject_value() const; + virtual llvm::Value* jarray_value() const; + virtual int address_value() const; + + // Typed conversion to SharkValues + public: + static SharkValue* create_jint(llvm::Value* value) { - return false; + assert(value->getType() == SharkType::jint_type(), "should be"); + return create_generic(ciType::make(T_INT), value); } - virtual bool is_jobject() const + static SharkValue* create_jlong(llvm::Value* value) { - return false; + assert(value->getType() == SharkType::jlong_type(), "should be"); + return create_generic(ciType::make(T_LONG), value); } - virtual bool is_jarray() const + static SharkValue* create_jfloat(llvm::Value* value) { - return false; + assert(value->getType() == SharkType::jfloat_type(), "should be"); + return create_generic(ciType::make(T_FLOAT), value); } - virtual bool is_returnAddress() const + static SharkValue* create_jdouble(llvm::Value* value) { - return false; + assert(value->getType() == SharkType::jdouble_type(), "should be"); + return create_generic(ciType::make(T_DOUBLE), value); + } + static SharkValue* create_jobject(llvm::Value* value) + { + assert(value->getType() == SharkType::jobject_type(), "should be"); + return create_generic(ciType::make(T_OBJECT), value); } - // Typed conversions to LLVM values - public: - virtual llvm::Value* jint_value() const - { - ShouldNotCallThis(); - } - virtual llvm::Value* jlong_value() const - { - ShouldNotCallThis(); - } - virtual llvm::Value* jfloat_value() const - { - ShouldNotCallThis(); - } - virtual llvm::Value* jdouble_value() const - { - ShouldNotCallThis(); - } - virtual llvm::Value* jobject_value() const - { - ShouldNotCallThis(); - } - virtual llvm::Value* jarray_value() const - { - ShouldNotCallThis(); - } - virtual int returnAddress_value() const - { - ShouldNotCallThis(); - } - - // Constants of various types + // Typed conversion from constants of various types public: static SharkValue* jint_constant(jint value) { @@ -139,34 +129,7 @@ { return create_jobject(LLVMValue::null()); } - - // Typed conversion from LLVM values - public: - static SharkValue* create_jint(llvm::Value* value) - { - assert(value->getType() == SharkType::jint_type(), "should be"); - return create_generic(ciType::make(T_INT), value); - } - static SharkValue* create_jlong(llvm::Value* value) - { - assert(value->getType() == SharkType::jlong_type(), "should be"); - return create_generic(ciType::make(T_LONG), value); - } - static SharkValue* create_jfloat(llvm::Value* value) - { - assert(value->getType() == SharkType::jfloat_type(), "should be"); - return create_generic(ciType::make(T_FLOAT), value); - } - static SharkValue* create_jdouble(llvm::Value* value) - { - assert(value->getType() == SharkType::jdouble_type(), "should be"); - return create_generic(ciType::make(T_DOUBLE), value); - } - static SharkValue* create_jobject(llvm::Value* value) - { - assert(value->getType() == SharkType::jobject_type(), "should be"); - return create_generic(ciType::make(T_OBJECT), value); - } + static inline SharkValue* address_constant(int bci); // Typed conversion from HotSpot ciConstants public: @@ -203,50 +166,32 @@ default: tty->print_cr("Unhandled type %s", type2name(value.basic_type())); + ShouldNotReachHere(); } - ShouldNotReachHere(); } - // Typed "conversion" from return address + // Type-losing conversions -- use with care! public: - static inline SharkValue* create_returnAddress(int bci); + virtual llvm::Value* generic_value() const = 0; + virtual llvm::Value* intptr_value(SharkBuilder* builder) const; - // Type-losing conversions, use with care - public: static inline SharkValue* create_generic(ciType* type, llvm::Value* value); - virtual llvm::Value* generic_value() const - { - ShouldNotCallThis(); - } - virtual llvm::Value* intptr_value(llvm::IRBuilder<>* builder) const - { - ShouldNotCallThis(); - } // Phi-style stuff public: - virtual void addIncoming(SharkValue *value, llvm::BasicBlock* block) - { - ShouldNotCallThis(); - } + virtual void addIncoming(SharkValue *value, llvm::BasicBlock* block) = 0; // Repeated null and divide-by-zero check removal public: - virtual bool zero_checked() const - { - ShouldNotCallThis(); - } - virtual void set_zero_checked(bool zero_checked) - { - ShouldNotCallThis(); - } + virtual bool zero_checked() const; + virtual void set_zero_checked(bool zero_checked); }; -class SharkComputableValue : public SharkValue { +class SharkNormalValue : public SharkValue { friend class SharkValue; protected: - SharkComputableValue(ciType* type, llvm::Value* value) + SharkNormalValue(ciType* type, llvm::Value* value) : _type(type), _llvm_value(value), _zero_checked(false) {} private: @@ -262,123 +207,52 @@ // Type access public: - ciType* type() const - { - return _type; - } - - public: - BasicType basic_type() const - { - return type()->basic_type(); - } - int size() const - { - return type()->size(); - } + ciType* type() const; + BasicType basic_type() const; + int size() const; public: - bool is_jint() const - { - return llvm_value()->getType() == SharkType::jint_type(); - } - bool is_jlong() const - { - return llvm_value()->getType() == SharkType::jlong_type(); - } - bool is_jfloat() const - { - return llvm_value()->getType() == SharkType::jfloat_type(); - } - bool is_jdouble() const - { - return llvm_value()->getType() == SharkType::jdouble_type(); - } - bool is_jobject() const - { - return llvm_value()->getType() == SharkType::jobject_type(); - } - bool is_jarray() const - { - return basic_type() == T_ARRAY; - } + bool is_jint() const; + bool is_jlong() const; + bool is_jfloat() const; + bool is_jdouble() const; + bool is_jobject() const; + bool is_jarray() const; // Typed conversions to LLVM values public: - llvm::Value* jint_value() const - { - assert(is_jint(), "should be"); - return llvm_value(); - } - llvm::Value* jlong_value() const - { - assert(is_jlong(), "should be"); - return llvm_value(); - } - llvm::Value* jfloat_value() const - { - assert(is_jfloat(), "should be"); - return llvm_value(); - } - llvm::Value* jdouble_value() const - { - assert(is_jdouble(), "should be"); - return llvm_value(); - } - llvm::Value* jobject_value() const - { - assert(is_jobject(), "should be"); - return llvm_value(); - } - llvm::Value* jarray_value() const - { - assert(is_jarray(), "should be"); - return llvm_value(); - } + llvm::Value* jint_value() const; + llvm::Value* jlong_value() const; + llvm::Value* jfloat_value() const; + llvm::Value* jdouble_value() const; + llvm::Value* jobject_value() const; + llvm::Value* jarray_value() const; // Type-losing conversions, use with care public: - llvm::Value* generic_value() const - { - return llvm_value(); - } - llvm::Value* intptr_value(llvm::IRBuilder<>* builder) const - { - assert(is_jobject(), "should be"); - return builder->CreatePtrToInt(llvm_value(), SharkType::intptr_type()); - } + llvm::Value* generic_value() const; + llvm::Value* intptr_value(SharkBuilder* builder) const; // Wrapped PHINodes public: - void addIncoming(SharkValue *value, llvm::BasicBlock* block) - { - assert(llvm::isa(generic_value()), "should be"); - ((llvm::PHINode *) generic_value())->addIncoming( - value->generic_value(), block); - } + void addIncoming(SharkValue *value, llvm::BasicBlock* block); // Repeated null and divide-by-zero check removal public: - bool zero_checked() const - { - return _zero_checked; - } - void set_zero_checked(bool zero_checked) - { - _zero_checked = zero_checked; - } + bool zero_checked() const; + void set_zero_checked(bool zero_checked); }; inline SharkValue* SharkValue::create_generic(ciType* type, llvm::Value* value) { - return new SharkComputableValue(type, value); + return new SharkNormalValue(type, value); } -class SharkReturnAddressValue : public SharkValue { +class SharkAddressValue : public SharkValue { friend class SharkValue; protected: - SharkReturnAddressValue(int bci) + SharkAddressValue(int bci) : _bci(bci) {} private: @@ -386,44 +260,24 @@ // Type access public: - BasicType basic_type() const - { - return T_ADDRESS; - } - int size() const - { - return 1; - } + BasicType basic_type() const; + int size() const; + bool is_address() const; + // Typed conversion from SharkValues public: - bool is_returnAddress() const - { - return true; - } + int address_value() const; - // Typed "conversion" + // Type-losing conversion -- use with care! public: - int returnAddress_value() const - { - return _bci; - } - - // Type-losing "conversion", use with care - public: - llvm::Value* generic_value() const - { - return LLVMValue::intptr_constant(_bci); - } + llvm::Value* generic_value() const; // Phi-style stuff public: - void addIncoming(SharkValue *value, llvm::BasicBlock* block) - { - assert(_bci == value->returnAddress_value(), "should be"); - } + void addIncoming(SharkValue *value, llvm::BasicBlock* block); }; -inline SharkValue* SharkValue::create_returnAddress(int bci) +inline SharkValue* SharkValue::address_constant(int bci) { - return new SharkReturnAddressValue(bci); + return new SharkAddressValue(bci); }