Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/src/share/vm/ci/ciField.hpp
32285 views
/*1* Copyright (c) 1999, 2013, 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_VM_CI_CIFIELD_HPP25#define SHARE_VM_CI_CIFIELD_HPP2627#include "ci/ciClassList.hpp"28#include "ci/ciConstant.hpp"29#include "ci/ciFlags.hpp"30#include "ci/ciInstance.hpp"3132// ciField33//34// This class represents the result of a field lookup in the VM.35// The lookup may not succeed, in which case the information in36// the ciField will be incomplete.37class ciField : public ResourceObj {38CI_PACKAGE_ACCESS39friend class ciEnv;40friend class ciInstanceKlass;41friend class NonStaticFieldFiller;4243private:44ciFlags _flags;45ciInstanceKlass* _holder;46ciSymbol* _name;47ciSymbol* _signature;48ciType* _type;49int _offset;50bool _is_constant;51ciInstanceKlass* _known_to_link_with_put;52ciInstanceKlass* _known_to_link_with_get;53ciConstant _constant_value;5455ciType* compute_type();56ciType* compute_type_impl();5758ciField(ciInstanceKlass* klass, int index);59ciField(fieldDescriptor* fd);6061// shared constructor code62void initialize_from(fieldDescriptor* fd);6364public:65ciFlags flags() { return _flags; }6667// Of which klass is this field a member?68//69// Usage note: the declared holder of a field is the class70// referenced by name in the bytecodes. The canonical holder71// is the most general class which holds the field. This72// method returns the canonical holder. The declared holder73// can be accessed via a method in ciBytecodeStream.74//75// Ex.76// class A {77// public int f = 7;78// }79// class B extends A {80// public void test() {81// System.out.println(f);82// }83// }84//85// A java compiler is permitted to compile the access to86// field f as:87//88// getfield B.f89//90// In that case the declared holder of f would be B and91// the canonical holder of f would be A.92ciInstanceKlass* holder() { return _holder; }9394// Name of this field?95ciSymbol* name() { return _name; }9697// Signature of this field?98ciSymbol* signature() { return _signature; }99100// Of what type is this field?101ciType* type() { return (_type == NULL) ? compute_type() : _type; }102103// How is this field actually stored in memory?104BasicType layout_type() { return type2field[(_type == NULL) ? T_OBJECT : _type->basic_type()]; }105106// How big is this field in memory?107int size_in_bytes() { return type2aelembytes(layout_type()); }108109// What is the offset of this field?110int offset() {111assert(_offset >= 1, "illegal call to offset()");112return _offset;113}114115// Same question, explicit units. (Fields are aligned to the byte level.)116int offset_in_bytes() {117return offset();118}119120// Is this field shared?121bool is_shared() {122// non-static fields of shared holders are cached123return _holder->is_shared() && !is_static();124}125126// Is this field a constant? See ciField::initialize_from() for details127// about how a field is determined to be constant.128bool is_constant() { return _is_constant; }129130// Get the constant value of this field.131ciConstant constant_value() {132assert(is_static() && is_constant(), "illegal call to constant_value()");133return _constant_value;134}135136// Get the constant value of non-static final field in the given137// object.138ciConstant constant_value_of(ciObject* object) {139assert(!is_static() && is_constant(), "only if field is non-static constant");140assert(object->is_instance(), "must be instance");141return object->as_instance()->field_value(this);142}143144// Check for link time errors. Accessing a field from a145// certain class via a certain bytecode may or may not be legal.146// This call checks to see if an exception may be raised by147// an access of this field.148//149// Usage note: if the same field is accessed multiple times150// in the same compilation, will_link will need to be checked151// at each point of access.152bool will_link(ciInstanceKlass* accessing_klass,153Bytecodes::Code bc);154155// Java access flags156bool is_public () { return flags().is_public(); }157bool is_private () { return flags().is_private(); }158bool is_protected () { return flags().is_protected(); }159bool is_static () { return flags().is_static(); }160bool is_final () { return flags().is_final(); }161bool is_stable () { return flags().is_stable(); }162bool is_volatile () { return flags().is_volatile(); }163bool is_transient () { return flags().is_transient(); }164// The field is modified outside of instance initializer methods165// (or class/initializer methods if the field is static).166bool has_initialized_final_update() { return flags().has_initialized_final_update(); }167168bool is_call_site_target() {169ciInstanceKlass* callsite_klass = CURRENT_ENV->CallSite_klass();170if (callsite_klass == NULL)171return false;172return (holder()->is_subclass_of(callsite_klass) && (name() == ciSymbol::target_name()));173}174175// Debugging output176void print();177void print_name_on(outputStream* st);178};179180#endif // SHARE_VM_CI_CIFIELD_HPP181182183