oopsHierarchy.hpp revision 2223
0N/A/*
2223N/A * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
0N/A * published by the Free Software Foundation.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
1472N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
1472N/A * or visit www.oracle.com if you need additional information or have any
1472N/A * questions.
0N/A *
0N/A */
0N/A
1879N/A#ifndef SHARE_VM_OOPS_OOPSHIERARCHY_HPP
1879N/A#define SHARE_VM_OOPS_OOPSHIERARCHY_HPP
1879N/A
1879N/A#include "runtime/globals.hpp"
1879N/A#include "utilities/globalDefinitions.hpp"
1879N/A
0N/A// OBJECT hierarchy
0N/A// This hierarchy is a representation hierarchy, i.e. if A is a superclass
0N/A// of B, A's representation is a prefix of B's representation.
0N/A
113N/Atypedef juint narrowOop; // Offset instead of address for an oop within a java object
113N/Atypedef class klassOopDesc* wideKlassOop; // to keep SA happy and unhandled oop
113N/A // detector happy.
845N/Atypedef void* OopOrNarrowOopStar;
113N/A
0N/A#ifndef CHECK_UNHANDLED_OOPS
0N/A
113N/Atypedef class oopDesc* oop;
0N/Atypedef class instanceOopDesc* instanceOop;
113N/Atypedef class methodOopDesc* methodOop;
113N/Atypedef class constMethodOopDesc* constMethodOop;
113N/Atypedef class methodDataOopDesc* methodDataOop;
113N/Atypedef class arrayOopDesc* arrayOop;
113N/Atypedef class objArrayOopDesc* objArrayOop;
113N/Atypedef class typeArrayOopDesc* typeArrayOop;
113N/Atypedef class constantPoolOopDesc* constantPoolOop;
113N/Atypedef class constantPoolCacheOopDesc* constantPoolCacheOop;
113N/Atypedef class klassOopDesc* klassOop;
113N/Atypedef class markOopDesc* markOop;
0N/Atypedef class compiledICHolderOopDesc* compiledICHolderOop;
0N/A
0N/A#else
0N/A
0N/A
0N/A// When CHECK_UNHANDLED_OOPS is defined, an "oop" is a class with a
0N/A// carefully chosen set of constructors and conversion operators to go
0N/A// to and from the underlying oopDesc pointer type.
0N/A//
0N/A// Because oop and its subclasses <type>Oop are class types, arbitrary
0N/A// conversions are not accepted by the compiler, and you may get a message
0N/A// about overloading ambiguity (between long and int is common when converting
0N/A// from a constant in 64 bit mode), or unable to convert from type to 'oop'.
0N/A// Applying a cast to one of these conversion operators first will get to the
0N/A// underlying oopDesc* type if appropriate.
0N/A// Converting NULL to oop to Handle implicit is no longer accepted by the
0N/A// compiler because there are too many steps in the conversion. Use Handle()
0N/A// instead, which generates less code anyway.
0N/A
0N/Aclass Thread;
0N/Atypedef class markOopDesc* markOop;
0N/Aclass PromotedObject;
0N/A
0N/A
0N/Aclass oop {
0N/A oopDesc* _o;
0N/A
0N/A void register_oop();
0N/A void unregister_oop();
0N/A
0N/A // friend class markOop;
0N/Apublic:
0N/A void set_obj(const void* p) {
0N/A raw_set_obj(p);
0N/A if (CheckUnhandledOops) register_oop();
0N/A }
0N/A void raw_set_obj(const void* p) { _o = (oopDesc*)p; }
0N/A
0N/A oop() { set_obj(NULL); }
0N/A oop(const volatile oop& o) { set_obj(o.obj()); }
0N/A oop(const void* p) { set_obj(p); }
0N/A oop(intptr_t i) { set_obj((void *)i); }
0N/A#ifdef _LP64
0N/A oop(int i) { set_obj((void *)i); }
0N/A#endif
0N/A ~oop() {
0N/A if (CheckUnhandledOops) unregister_oop();
0N/A }
0N/A
0N/A oopDesc* obj() const volatile { return _o; }
0N/A
0N/A // General access
0N/A oopDesc* operator->() const { return obj(); }
0N/A bool operator==(const oop o) const { return obj() == o.obj(); }
0N/A bool operator==(void *p) const { return obj() == p; }
0N/A bool operator!=(const oop o) const { return obj() != o.obj(); }
0N/A bool operator!=(void *p) const { return obj() != p; }
0N/A bool operator==(intptr_t p) const { return obj() == (oopDesc*)p; }
0N/A bool operator!=(intptr_t p) const { return obj() != (oopDesc*)p; }
0N/A
0N/A bool operator<(oop o) const { return obj() < o.obj(); }
0N/A bool operator>(oop o) const { return obj() > o.obj(); }
0N/A bool operator<=(oop o) const { return obj() <= o.obj(); }
0N/A bool operator>=(oop o) const { return obj() >= o.obj(); }
0N/A bool operator!() const { return !obj(); }
0N/A
0N/A // Cast
0N/A operator void* () const { return (void *)obj(); }
0N/A operator HeapWord* () const { return (HeapWord*)obj(); }
0N/A operator oopDesc* () const { return obj(); }
0N/A operator intptr_t* () const { return (intptr_t*)obj(); }
0N/A operator PromotedObject* () const { return (PromotedObject*)obj(); }
0N/A operator markOop () const { return markOop(obj()); }
0N/A
0N/A operator address () const { return (address)obj(); }
0N/A operator intptr_t () const { return (intptr_t)obj(); }
0N/A
0N/A // from javaCalls.cpp
0N/A operator jobject () const { return (jobject)obj(); }
0N/A // from javaClasses.cpp
0N/A operator JavaThread* () const { return (JavaThread*)obj(); }
513N/A
513N/A#ifndef _LP64
0N/A // from jvm.cpp
0N/A operator jlong* () const { return (jlong*)obj(); }
513N/A#endif
0N/A
0N/A // from parNewGeneration and other things that want to get to the end of
0N/A // an oop for stuff (like constMethodKlass.cpp, objArrayKlass.cpp)
0N/A operator oop* () const { return (oop *)obj(); }
0N/A};
0N/A
0N/A#define DEF_OOP(type) \
0N/A class type##OopDesc; \
0N/A class type##Oop : public oop { \
0N/A public: \
0N/A type##Oop() : oop() {} \
0N/A type##Oop(const volatile oop& o) : oop(o) {} \
0N/A type##Oop(const void* p) : oop(p) {} \
0N/A operator type##OopDesc* () const { return (type##OopDesc*)obj(); } \
0N/A type##OopDesc* operator->() const { \
0N/A return (type##OopDesc*)obj(); \
0N/A } \
0N/A }; \
0N/A
0N/ADEF_OOP(instance);
0N/ADEF_OOP(method);
0N/ADEF_OOP(methodData);
0N/ADEF_OOP(array);
0N/ADEF_OOP(constMethod);
0N/ADEF_OOP(constantPool);
0N/ADEF_OOP(constantPoolCache);
0N/ADEF_OOP(objArray);
0N/ADEF_OOP(typeArray);
0N/ADEF_OOP(klass);
0N/ADEF_OOP(compiledICHolder);
0N/A
0N/A#endif // CHECK_UNHANDLED_OOPS
0N/A
0N/A// The klass hierarchy is separate from the oop hierarchy.
0N/A
0N/Aclass Klass;
0N/Aclass instanceKlass;
2223N/Aclass instanceMirrorKlass;
0N/Aclass instanceRefKlass;
0N/Aclass methodKlass;
0N/Aclass constMethodKlass;
0N/Aclass methodDataKlass;
0N/Aclass klassKlass;
0N/Aclass instanceKlassKlass;
0N/Aclass arrayKlassKlass;
0N/Aclass objArrayKlassKlass;
0N/Aclass typeArrayKlassKlass;
0N/Aclass arrayKlass;
0N/Aclass objArrayKlass;
0N/Aclass typeArrayKlass;
113N/Aclass constantPoolKlass;
113N/Aclass constantPoolCacheKlass;
0N/Aclass compiledICHolderKlass;
1879N/A
1879N/A#endif // SHARE_VM_OOPS_OOPSHIERARCHY_HPP