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