/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/
#ifndef SHARE_VM_CI_CIFIELD_HPP
#define SHARE_VM_CI_CIFIELD_HPP
#include "ci/ciClassList.hpp"
#include "ci/ciConstant.hpp"
#include "ci/ciFlags.hpp"
#include "ci/ciInstance.hpp"
// ciField
//
// This class represents the result of a field lookup in the VM.
// The lookup may not succeed, in which case the information in
// the ciField will be incomplete.
friend class ciEnv;
friend class ciInstanceKlass;
friend class NonStaticFieldFiller;
private:
int _offset;
bool _is_constant;
// Used for will_link
int _cp_index;
ciType* compute_type();
// shared constructor code
public:
// Of which klass is this field a member?
//
// Usage note: the declared holder of a field is the class
// referenced by name in the bytecodes. The canonical holder
// is the most general class which holds the field. This
// method returns the canonical holder. The declared holder
// can be accessed via a method in ciBytecodeStream.
//
// Ex.
// class A {
// public int f = 7;
// }
// class B extends A {
// public void test() {
// System.out.println(f);
// }
// }
//
// A java compiler is permitted to compile the access to
// field f as:
//
// getfield B.f
//
// In that case the declared holder of f would be B and
// the canonical holder of f would be A.
// Name of this field?
// Signature of this field?
// Of what type is this field?
// How is this field actually stored in memory?
// How big is this field in memory?
// What is the offset of this field?
int offset() {
return _offset;
}
// Same question, explicit units. (Fields are aligned to the byte level.)
int offset_in_bytes() {
return offset();
}
// Is this field shared?
bool is_shared() {
// non-static fields of shared holders are cached
}
// Is this field a constant?
//
// Clarification: A field is considered constant if:
// 1. The field is both static and final
// 2. The canonical holder of the field has undergone
// static initialization.
// 3. If the field is an object or array, then the oop
// in question is allocated in perm space.
// non-constant fields. These are java.lang.System.in
// and java.lang.System.out. Abomination.
//
// Note: the check for case 4 is not yet implemented.
// Get the constant value of this field.
return _constant_value;
}
// Get the constant value of non-static final field in the given
// object.
}
// Check for link time errors. Accessing a field from a
// certain class via a certain bytecode may or may not be legal.
// This call checks to see if an exception may be raised by
// an access of this field.
//
// Usage note: if the same field is accessed multiple times
// in the same compilation, will_link will need to be checked
// at each point of access.
// Java access flags
bool is_call_site_target() {
if (callsite_klass == NULL)
return false;
}
// Debugging output
void print();
};
#endif // SHARE_VM_CI_CIFIELD_HPP