src/share/vm/ci/ciMetadata.hpp

changeset 0
f90c822e73f8
child 6876
710a3c8b516e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/share/vm/ci/ciMetadata.hpp	Wed Apr 27 01:25:04 2016 +0800
     1.3 @@ -0,0 +1,121 @@
     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 +  virtual void dump_replay_data(outputStream* st) { /* do nothing */ }
    1.68 +
    1.69 +  ciMethod*                as_method() {
    1.70 +    assert(is_method(), "bad cast");
    1.71 +    return (ciMethod*)this;
    1.72 +  }
    1.73 +  ciMethodData*            as_method_data() {
    1.74 +    assert(is_method_data(), "bad cast");
    1.75 +    return (ciMethodData*)this;
    1.76 +  }
    1.77 +  ciSymbol*                as_symbol() {
    1.78 +    assert(is_symbol(), "bad cast");
    1.79 +    return (ciSymbol*)this;
    1.80 +  }
    1.81 +  ciType*                  as_type() {
    1.82 +    assert(is_type(), "bad cast");
    1.83 +    return (ciType*)this;
    1.84 +  }
    1.85 +  ciReturnAddress*         as_return_address() {
    1.86 +    assert(is_return_address(), "bad cast");
    1.87 +    return (ciReturnAddress*)this;
    1.88 +  }
    1.89 +  ciKlass*                 as_klass() {
    1.90 +    assert(is_klass(), "bad cast");
    1.91 +    return (ciKlass*)this;
    1.92 +  }
    1.93 +  ciInstanceKlass*         as_instance_klass() {
    1.94 +    assert(is_instance_klass(), "bad cast");
    1.95 +    return (ciInstanceKlass*)this;
    1.96 +  }
    1.97 +  ciArrayKlass*            as_array_klass() {
    1.98 +    assert(is_array_klass(), "bad cast");
    1.99 +    return (ciArrayKlass*)this;
   1.100 +  }
   1.101 +  ciObjArrayKlass*         as_obj_array_klass() {
   1.102 +    assert(is_obj_array_klass(), "bad cast");
   1.103 +    return (ciObjArrayKlass*)this;
   1.104 +  }
   1.105 +  ciTypeArrayKlass*        as_type_array_klass() {
   1.106 +    assert(is_type_array_klass(), "bad cast");
   1.107 +    return (ciTypeArrayKlass*)this;
   1.108 +  }
   1.109 +
   1.110 +  Metadata* constant_encoding() { return _metadata; }
   1.111 +
   1.112 +  bool equals(ciMetadata* obj) const { return (this == obj); }
   1.113 +
   1.114 +  int hash() { return ident() * 31; } // ???
   1.115 +
   1.116 +  void print(outputStream* st);
   1.117 +  virtual void print_impl(outputStream* st) {}
   1.118 +  virtual const char* type_string() { return "ciMetadata"; }
   1.119 +
   1.120 +  void print()  { print(tty); }
   1.121 +  void print_metadata(outputStream* st = tty);
   1.122 +
   1.123 +};
   1.124 +#endif // SHARE_VM_CI_CIMETADATA_HPP

mercurial