1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/share/vm/ci/ciMetadata.hpp Sat Sep 01 13:25:18 2012 -0400 1.3 @@ -0,0 +1,120 @@ 1.4 +/* 1.5 + * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. 1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.7 + * 1.8 + * This code is free software; you can redistribute it and/or modify it 1.9 + * under the terms of the GNU General Public License version 2 only, as 1.10 + * published by the Free Software Foundation. 1.11 + * 1.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 1.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1.15 + * version 2 for more details (a copy is included in the LICENSE file that 1.16 + * accompanied this code). 1.17 + * 1.18 + * You should have received a copy of the GNU General Public License version 1.19 + * 2 along with this work; if not, write to the Free Software Foundation, 1.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1.21 + * 1.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 1.23 + * or visit www.oracle.com if you need additional information or have any 1.24 + * questions. 1.25 + * 1.26 + */ 1.27 + 1.28 +#ifndef SHARE_VM_CI_CIMETADATA_HPP 1.29 +#define SHARE_VM_CI_CIMETADATA_HPP 1.30 + 1.31 +#include "ci/ciBaseObject.hpp" 1.32 +#include "ci/ciClassList.hpp" 1.33 +#include "memory/allocation.hpp" 1.34 +#include "runtime/handles.hpp" 1.35 +#include "runtime/jniHandles.hpp" 1.36 + 1.37 +// ciMetadata 1.38 +// 1.39 +// Compiler interface to metadata object in the VM, not Java object. 1.40 + 1.41 +class ciMetadata: public ciBaseObject { 1.42 + CI_PACKAGE_ACCESS 1.43 + friend class ciEnv; 1.44 + 1.45 + protected: 1.46 + Metadata* _metadata; 1.47 + 1.48 + ciMetadata(): _metadata(NULL) {} 1.49 + ciMetadata(Metadata* o): _metadata(o) {} 1.50 + 1.51 + virtual bool is_classless() const { return false; } 1.52 + public: 1.53 + bool is_loaded() const { return _metadata != NULL || is_classless(); } 1.54 + 1.55 + virtual bool is_metadata() const { return true; } 1.56 + 1.57 + virtual bool is_type() const { return false; } 1.58 + virtual bool is_cpcache() const { return false; } 1.59 + virtual bool is_return_address() const { return false; } 1.60 + virtual bool is_method() const { return false; } 1.61 + virtual bool is_method_data() const { return false; } 1.62 + virtual bool is_klass() const { return false; } 1.63 + virtual bool is_instance_klass() const { return false; } 1.64 + virtual bool is_array_klass() const { return false; } 1.65 + virtual bool is_obj_array_klass() const { return false; } 1.66 + virtual bool is_type_array_klass() const { return false; } 1.67 + 1.68 + ciMethod* as_method() { 1.69 + assert(is_method(), "bad cast"); 1.70 + return (ciMethod*)this; 1.71 + } 1.72 + ciMethodData* as_method_data() { 1.73 + assert(is_method_data(), "bad cast"); 1.74 + return (ciMethodData*)this; 1.75 + } 1.76 + ciSymbol* as_symbol() { 1.77 + assert(is_symbol(), "bad cast"); 1.78 + return (ciSymbol*)this; 1.79 + } 1.80 + ciType* as_type() { 1.81 + assert(is_type(), "bad cast"); 1.82 + return (ciType*)this; 1.83 + } 1.84 + ciReturnAddress* as_return_address() { 1.85 + assert(is_return_address(), "bad cast"); 1.86 + return (ciReturnAddress*)this; 1.87 + } 1.88 + ciKlass* as_klass() { 1.89 + assert(is_klass(), "bad cast"); 1.90 + return (ciKlass*)this; 1.91 + } 1.92 + ciInstanceKlass* as_instance_klass() { 1.93 + assert(is_instance_klass(), "bad cast"); 1.94 + return (ciInstanceKlass*)this; 1.95 + } 1.96 + ciArrayKlass* as_array_klass() { 1.97 + assert(is_array_klass(), "bad cast"); 1.98 + return (ciArrayKlass*)this; 1.99 + } 1.100 + ciObjArrayKlass* as_obj_array_klass() { 1.101 + assert(is_obj_array_klass(), "bad cast"); 1.102 + return (ciObjArrayKlass*)this; 1.103 + } 1.104 + ciTypeArrayKlass* as_type_array_klass() { 1.105 + assert(is_type_array_klass(), "bad cast"); 1.106 + return (ciTypeArrayKlass*)this; 1.107 + } 1.108 + 1.109 + Metadata* constant_encoding() { return _metadata; } 1.110 + 1.111 + bool equals(ciMetadata* obj) const { return (this == obj); } 1.112 + 1.113 + int hash() { return ident() * 31; } // ??? 1.114 + 1.115 + void print(outputStream* st); 1.116 + virtual void print_impl(outputStream* st) {} 1.117 + virtual const char* type_string() { return "ciMetadata"; } 1.118 + 1.119 + void print() { print(tty); } 1.120 + void print_metadata(outputStream* st = tty); 1.121 + 1.122 +}; 1.123 +#endif // SHARE_VM_CI_CIMETADATA_HPP