coleenp@4037: /* coleenp@4037: * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. coleenp@4037: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. coleenp@4037: * coleenp@4037: * This code is free software; you can redistribute it and/or modify it coleenp@4037: * under the terms of the GNU General Public License version 2 only, as coleenp@4037: * published by the Free Software Foundation. coleenp@4037: * coleenp@4037: * This code is distributed in the hope that it will be useful, but WITHOUT coleenp@4037: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or coleenp@4037: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License coleenp@4037: * version 2 for more details (a copy is included in the LICENSE file that coleenp@4037: * accompanied this code). coleenp@4037: * coleenp@4037: * You should have received a copy of the GNU General Public License version coleenp@4037: * 2 along with this work; if not, write to the Free Software Foundation, coleenp@4037: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. coleenp@4037: * coleenp@4037: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA coleenp@4037: * or visit www.oracle.com if you need additional information or have any coleenp@4037: * questions. coleenp@4037: * coleenp@4037: */ coleenp@4037: coleenp@4037: #ifndef SHARE_VM_CI_CIMETADATA_HPP coleenp@4037: #define SHARE_VM_CI_CIMETADATA_HPP coleenp@4037: coleenp@4037: #include "ci/ciBaseObject.hpp" coleenp@4037: #include "ci/ciClassList.hpp" coleenp@4037: #include "memory/allocation.hpp" coleenp@4037: #include "runtime/handles.hpp" coleenp@4037: #include "runtime/jniHandles.hpp" coleenp@4037: coleenp@4037: // ciMetadata coleenp@4037: // coleenp@4037: // Compiler interface to metadata object in the VM, not Java object. coleenp@4037: coleenp@4037: class ciMetadata: public ciBaseObject { coleenp@4037: CI_PACKAGE_ACCESS coleenp@4037: friend class ciEnv; coleenp@4037: coleenp@4037: protected: coleenp@4037: Metadata* _metadata; coleenp@4037: coleenp@4037: ciMetadata(): _metadata(NULL) {} coleenp@4037: ciMetadata(Metadata* o): _metadata(o) {} coleenp@4037: coleenp@4037: virtual bool is_classless() const { return false; } coleenp@4037: public: coleenp@4037: bool is_loaded() const { return _metadata != NULL || is_classless(); } coleenp@4037: coleenp@4037: virtual bool is_metadata() const { return true; } coleenp@4037: coleenp@4037: virtual bool is_type() const { return false; } coleenp@4037: virtual bool is_cpcache() const { return false; } coleenp@4037: virtual bool is_return_address() const { return false; } coleenp@4037: virtual bool is_method() const { return false; } coleenp@4037: virtual bool is_method_data() const { return false; } coleenp@4037: virtual bool is_klass() const { return false; } coleenp@4037: virtual bool is_instance_klass() const { return false; } coleenp@4037: virtual bool is_array_klass() const { return false; } coleenp@4037: virtual bool is_obj_array_klass() const { return false; } coleenp@4037: virtual bool is_type_array_klass() const { return false; } minqi@4267: virtual void dump_replay_data(outputStream* st) { /* do nothing */ } coleenp@4037: coleenp@4037: ciMethod* as_method() { coleenp@4037: assert(is_method(), "bad cast"); coleenp@4037: return (ciMethod*)this; coleenp@4037: } coleenp@4037: ciMethodData* as_method_data() { coleenp@4037: assert(is_method_data(), "bad cast"); coleenp@4037: return (ciMethodData*)this; coleenp@4037: } coleenp@4037: ciSymbol* as_symbol() { coleenp@4037: assert(is_symbol(), "bad cast"); coleenp@4037: return (ciSymbol*)this; coleenp@4037: } coleenp@4037: ciType* as_type() { coleenp@4037: assert(is_type(), "bad cast"); coleenp@4037: return (ciType*)this; coleenp@4037: } coleenp@4037: ciReturnAddress* as_return_address() { coleenp@4037: assert(is_return_address(), "bad cast"); coleenp@4037: return (ciReturnAddress*)this; coleenp@4037: } coleenp@4037: ciKlass* as_klass() { coleenp@4037: assert(is_klass(), "bad cast"); coleenp@4037: return (ciKlass*)this; coleenp@4037: } coleenp@4037: ciInstanceKlass* as_instance_klass() { coleenp@4037: assert(is_instance_klass(), "bad cast"); coleenp@4037: return (ciInstanceKlass*)this; coleenp@4037: } coleenp@4037: ciArrayKlass* as_array_klass() { coleenp@4037: assert(is_array_klass(), "bad cast"); coleenp@4037: return (ciArrayKlass*)this; coleenp@4037: } coleenp@4037: ciObjArrayKlass* as_obj_array_klass() { coleenp@4037: assert(is_obj_array_klass(), "bad cast"); coleenp@4037: return (ciObjArrayKlass*)this; coleenp@4037: } coleenp@4037: ciTypeArrayKlass* as_type_array_klass() { coleenp@4037: assert(is_type_array_klass(), "bad cast"); coleenp@4037: return (ciTypeArrayKlass*)this; coleenp@4037: } coleenp@4037: coleenp@4037: Metadata* constant_encoding() { return _metadata; } coleenp@4037: coleenp@4037: bool equals(ciMetadata* obj) const { return (this == obj); } coleenp@4037: coleenp@4037: int hash() { return ident() * 31; } // ??? coleenp@4037: coleenp@4037: void print(outputStream* st); coleenp@4037: virtual void print_impl(outputStream* st) {} coleenp@4037: virtual const char* type_string() { return "ciMetadata"; } coleenp@4037: coleenp@4037: void print() { print(tty); } coleenp@4037: void print_metadata(outputStream* st = tty); coleenp@4037: coleenp@4037: }; coleenp@4037: #endif // SHARE_VM_CI_CIMETADATA_HPP