Path: blob/master/src/hotspot/share/ci/ciBaseObject.hpp
40930 views
/*1* Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*22*/2324#ifndef SHARE_CI_CIBASEOBJECT_HPP25#define SHARE_CI_CIBASEOBJECT_HPP2627#include "ci/ciClassList.hpp"28#include "memory/allocation.hpp"2930// ciBaseObject31//32// This class represents an oop in the HotSpot virtual machine.33// Its subclasses are structured in a hierarchy which mirrors34// an aggregate of the VM's oop and klass hierarchies (see35// oopHierarchy.hpp). Each instance of ciBaseObject holds a handle36// to a corresponding oop on the VM side and provides routines37// for accessing the information in its oop. By using the ciBaseObject38// hierarchy for accessing oops in the VM, the compiler ensures39// that it is safe with respect to garbage collection; that is,40// GC and compilation can proceed independently without41// interference.42//43// Within the VM, the oop and klass hierarchies are separate.44// The compiler interface does not preserve this separation --45// the distinction between `Klass*' and `Klass' are not46// reflected in the interface and instead the Klass hierarchy47// is directly modeled as the subclasses of ciKlass.48class ciBaseObject : public ResourceObj {49CI_PACKAGE_ACCESS50friend class ciEnv;5152protected:53uint _ident;5455protected:56ciBaseObject(): _ident(0) {}5758virtual const char* type_string() { return "ciBaseObject"; }5960void set_ident(uint id);6162public:63// A number unique to this object.64uint ident();6566// What kind of ciBaseObject is this?67virtual bool is_symbol() const { return false; }68virtual bool is_object() const { return false; }69virtual bool is_metadata() const { return false; }7071ciSymbol* as_symbol() {72assert(is_symbol(), "must be");73return (ciSymbol*)this;74}75ciObject* as_object() {76assert(is_object(), "must be");77return (ciObject*)this;78}79ciMetadata* as_metadata() {80assert(is_metadata(), "must be");81return (ciMetadata*)this;82}83};84#endif // SHARE_CI_CIBASEOBJECT_HPP858687