提交 e70e7796 编写于 作者: C coleenp

8031820: NPG: Fix remaining references to metadata as oops in comments

8012125: Comments for ConstantPoolCache should reflect the addition of resolved_references in ConstantPool
Summary: Updated comments in metadata header files, and renamed this_oop variables to this_cp or this_k when referring to constant pool or classes.
Reviewed-by: stefank, jmasa
上级 e7e83a08
/*
* Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -32,8 +32,8 @@
// header: dump of archive instance plus versioning info, datestamp, etc.
// [magic # = 0xF00BABA2]
// ... padding to align on page-boundary
// read-write space from CompactingPermGenGen
// read-only space from CompactingPermGenGen
// read-write space
// read-only space
// misc data (block offset table, string table, symbols, dictionary, etc.)
// tag(666)
......
/*
* Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -27,68 +27,61 @@
#include "oops/oop.hpp"
// An ConstMethod* represents portions of a Java method which
// do not vary.
// An ConstMethod represents portions of a Java method which are not written to after
// the classfile is parsed(*see below). This part of the method can be shared across
// processes in a read-only section with Class Data Sharing (CDS). It's important
// that this class doesn't have virtual functions because the vptr cannot be shared
// with CDS.
// (*)RewriteByteCodes and RewriteFrequentPairs is an exception but turned off in CDS
//
// Memory layout (each line represents a word). Note that most
// applications load thousands of methods, so keeping the size of this
// Note that most applications load thousands of methods, so keeping the size of this
// structure small has a big impact on footprint.
// The actual bytecodes are inlined after the end of the ConstMethod struct.
//
// The line number table is compressed and inlined following the byte codes. It is
// found as the first byte following the byte codes. Note that accessing the line
// number and local variable tables is not performance critical at all.
//
// The checked exceptions table and the local variable table are inlined after the
// line number table, and indexed from the end of the method. We do not compress the
// checked exceptions table since the average length is less than 2, and it is used
// by reflection so access should be fast. We do not bother to compress the local
// variable table either since it is mostly absent.
//
//
// |------------------------------------------------------|
// | header |
// | klass |
// |------------------------------------------------------|
// | fingerprint 1 |
// | fingerprint 2 |
// | constants (oop) |
// | stackmap_data (oop) |
// | constMethod_size |
// | interp_kind | flags | code_size |
// | name index | signature index |
// | method_idnum | max_stack |
// | max_locals | size_of_parameters |
// |------------------------------------------------------|
// | |
// | byte codes |
// | |
// |------------------------------------------------------|
// | compressed linenumber table |
// | (see class CompressedLineNumberReadStream) |
// | (note that length is unknown until decompressed) |
// | (access flags bit tells whether table is present) |
// | (indexed from start of ConstMethod*) |
// | (elements not necessarily sorted!) |
// |------------------------------------------------------|
// | localvariable table elements + length (length last) |
// | (length is u2, elements are 6-tuples of u2) |
// | (see class LocalVariableTableElement) |
// | (access flags bit tells whether table is present) |
// | (indexed from end of ConstMethod*) |
// |------------------------------------------------------|
// | exception table + length (length last) |
// | (length is u2, elements are 4-tuples of u2) |
// | (see class ExceptionTableElement) |
// | (access flags bit tells whether table is present) |
// | (indexed from end of ConstMethod*) |
// |------------------------------------------------------|
// | checked exceptions elements + length (length last) |
// | (length is u2, elements are u2) |
// | (see class CheckedExceptionElement) |
// | (access flags bit tells whether table is present) |
// | (indexed from end of ConstMethod*) |
// |------------------------------------------------------|
// | method parameters elements + length (length last) |
// | (length is u2, elements are u2, u4 structures) |
// | (see class MethodParametersElement) |
// | (access flags bit tells whether table is present) |
// | (indexed from end of ConstMethod*) |
// |------------------------------------------------------|
// | generic signature index (u2) |
// | (indexed from start of constMethodOop) |
// |------------------------------------------------------|
// | annotations arrays - method, parameter, type, default|
// | pointer to Array<u1> if annotation is present |
// |------------------------------------------------------|
// ConstMethod embedded field layout (after declared fields):
// [EMBEDDED byte codes]
// [EMBEDDED compressed linenumber table]
// (see class CompressedLineNumberReadStream)
// (note that length is unknown until decompressed)
// (access flags bit tells whether table is present)
// (indexed from start of ConstMethod)
// (elements not necessarily sorted!)
// [EMBEDDED localvariable table elements + length (length last)]
// (length is u2, elements are 6-tuples of u2)
// (see class LocalVariableTableElement)
// (access flags bit tells whether table is present)
// (indexed from end of ConstMethod*)
// [EMBEDDED exception table + length (length last)]
// (length is u2, elements are 4-tuples of u2)
// (see class ExceptionTableElement)
// (access flags bit tells whether table is present)
// (indexed from end of ConstMethod*)
// [EMBEDDED checked exceptions elements + length (length last)]
// (length is u2, elements are u2)
// (see class CheckedExceptionElement)
// (access flags bit tells whether table is present)
// (indexed from end of ConstMethod*)
// [EMBEDDED method parameters elements + length (length last)]
// (length is u2, elements are u2, u4 structures)
// (see class MethodParametersElement)
// (access flags bit tells whether table is present)
// (indexed from end of ConstMethod*)
// [EMBEDDED generic signature index (u2)]
// (indexed from end of constMethodOop)
// [EMBEDDED annotations arrays - method, parameter, type, default]
// pointer to Array<u1> if annotation is present
//
// IMPORTANT: If anything gets added here, there need to be changes to
// ensure that ServicabilityAgent doesn't get broken as a result!
......
/*
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -48,7 +48,7 @@
# include "bytes_ppc.hpp"
#endif
// A constantPool is an array containing class constants as described in the
// A ConstantPool is an array containing class constants as described in the
// class file.
//
// Most of the constant pool entries are written during class parsing, which
......@@ -81,9 +81,10 @@ class CPSlot VALUE_OBJ_CLASS_SPEC {
};
class KlassSizeStats;
class ConstantPool : public Metadata {
friend class VMStructs;
friend class BytecodeInterpreter; // Directly extracts an oop in the pool for fast instanceof/checkcast
friend class BytecodeInterpreter; // Directly extracts a klass in the pool for fast instanceof/checkcast
friend class Universe; // For null constructor
private:
Array<u1>* _tags; // the tag array describing the constant pool's contents
......@@ -747,13 +748,13 @@ class ConstantPool : public Metadata {
friend class SystemDictionary;
// Used by compiler to prevent classloading.
static Method* method_at_if_loaded (constantPoolHandle this_oop, int which);
static bool has_appendix_at_if_loaded (constantPoolHandle this_oop, int which);
static oop appendix_at_if_loaded (constantPoolHandle this_oop, int which);
static bool has_method_type_at_if_loaded (constantPoolHandle this_oop, int which);
static oop method_type_at_if_loaded (constantPoolHandle this_oop, int which);
static Klass* klass_at_if_loaded (constantPoolHandle this_oop, int which);
static Klass* klass_ref_at_if_loaded (constantPoolHandle this_oop, int which);
static Method* method_at_if_loaded (constantPoolHandle this_cp, int which);
static bool has_appendix_at_if_loaded (constantPoolHandle this_cp, int which);
static oop appendix_at_if_loaded (constantPoolHandle this_cp, int which);
static bool has_method_type_at_if_loaded (constantPoolHandle this_cp, int which);
static oop method_type_at_if_loaded (constantPoolHandle this_cp, int which);
static Klass* klass_at_if_loaded (constantPoolHandle this_cp, int which);
static Klass* klass_ref_at_if_loaded (constantPoolHandle this_cp, int which);
// Routines currently used for annotations (only called by jvm.cpp) but which might be used in the
// future by other Java code. These take constant pool indices rather than
......@@ -811,19 +812,19 @@ class ConstantPool : public Metadata {
}
// Performs the LinkResolver checks
static void verify_constant_pool_resolve(constantPoolHandle this_oop, KlassHandle klass, TRAPS);
static void verify_constant_pool_resolve(constantPoolHandle this_cp, KlassHandle klass, TRAPS);
// Implementation of methods that needs an exposed 'this' pointer, in order to
// handle GC while executing the method
static Klass* klass_at_impl(constantPoolHandle this_oop, int which, TRAPS);
static oop string_at_impl(constantPoolHandle this_oop, int which, int obj_index, TRAPS);
static Klass* klass_at_impl(constantPoolHandle this_cp, int which, TRAPS);
static oop string_at_impl(constantPoolHandle this_cp, int which, int obj_index, TRAPS);
// Resolve string constants (to prevent allocation during compilation)
static void resolve_string_constants_impl(constantPoolHandle this_oop, TRAPS);
static void resolve_string_constants_impl(constantPoolHandle this_cp, TRAPS);
static oop resolve_constant_at_impl(constantPoolHandle this_oop, int index, int cache_index, TRAPS);
static void save_and_throw_exception(constantPoolHandle this_oop, int which, int tag_value, TRAPS);
static oop resolve_bootstrap_specifier_at_impl(constantPoolHandle this_oop, int index, TRAPS);
static oop resolve_constant_at_impl(constantPoolHandle this_cp, int index, int cache_index, TRAPS);
static void save_and_throw_exception(constantPoolHandle this_cp, int which, int tag_value, TRAPS);
static oop resolve_bootstrap_specifier_at_impl(constantPoolHandle this_cp, int index, TRAPS);
public:
// Merging ConstantPool* support:
......
/*
* Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -328,7 +328,7 @@ void ConstantPoolCacheEntry::set_method_handle_common(constantPoolHandle cpool,
// the f1 method has signature '(Ljl/Object;Ljl/invoke/MethodType;)Ljl/Object;',
// not '(Ljava/lang/String;)Ljava/util/List;'.
// The fact that String and List are involved is encoded in the MethodType in refs[f2].
// This allows us to create fewer method oops, while keeping type safety.
// This allows us to create fewer Methods, while keeping type safety.
//
objArrayHandle resolved_references = cpool->resolved_references();
......
/*
* Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -102,8 +102,9 @@ class PSPromotionManager;
// _f1 = Method* for non-virtual calls, unused by virtual calls.
// for interface calls, which are essentially virtual but need a klass,
// contains Klass* for the corresponding interface.
// for invokedynamic, f1 contains a site-specific CallSite object (as an appendix)
// for invokehandle, f1 contains a site-specific MethodType object (as an appendix)
// for invokedynamic and invokehandle, f1 contains the adapter method which
// manages the actual call. The appendix is stored in the ConstantPool
// resolved_references array.
// (upcoming metadata changes will move the appendix to a separate array)
// _f2 = vtable/itable index (or final Method*) for virtual calls only,
// unused by non-virtual. The is_vfinal flag indicates this is a
......
......@@ -43,35 +43,7 @@
// An InstanceKlass is the VM level representation of a Java class.
// It contains all information needed for at class at execution runtime.
// InstanceKlass layout:
// [C++ vtbl pointer ] Klass
// [subtype cache ] Klass
// [instance size ] Klass
// [java mirror ] Klass
// [super ] Klass
// [access_flags ] Klass
// [name ] Klass
// [first subklass ] Klass
// [next sibling ] Klass
// [array klasses ]
// [methods ]
// [local interfaces ]
// [transitive interfaces ]
// [fields ]
// [constants ]
// [class loader ]
// [source file name ]
// [inner classes ]
// [static field size ]
// [nonstatic field size ]
// [static oop fields size ]
// [nonstatic oop maps size ]
// [has finalize method ]
// [deoptimization mark bit ]
// [initialization state ]
// [initializing thread ]
// [Java vtable length ]
// [oop map cache (stack maps) ]
// InstanceKlass embedded field layout (after declared fields):
// [EMBEDDED Java vtable ] size in words = vtable_len
// [EMBEDDED nonstatic oop-map blocks] size in words = nonstatic_oop_map_size
// The embedded nonstatic oop-map blocks are short pairs (offset, length)
......@@ -1031,16 +1003,16 @@ private:
// Static methods that are used to implement member methods where an exposed this pointer
// is needed due to possible GCs
static bool link_class_impl (instanceKlassHandle this_oop, bool throw_verifyerror, TRAPS);
static bool verify_code (instanceKlassHandle this_oop, bool throw_verifyerror, TRAPS);
static void initialize_impl (instanceKlassHandle this_oop, TRAPS);
static void eager_initialize_impl (instanceKlassHandle this_oop);
static void set_initialization_state_and_notify_impl (instanceKlassHandle this_oop, ClassState state, TRAPS);
static void call_class_initializer_impl (instanceKlassHandle this_oop, TRAPS);
static Klass* array_klass_impl (instanceKlassHandle this_oop, bool or_null, int n, TRAPS);
static void do_local_static_fields_impl (instanceKlassHandle this_oop, void f(fieldDescriptor* fd, TRAPS), TRAPS);
static bool link_class_impl (instanceKlassHandle this_k, bool throw_verifyerror, TRAPS);
static bool verify_code (instanceKlassHandle this_k, bool throw_verifyerror, TRAPS);
static void initialize_impl (instanceKlassHandle this_k, TRAPS);
static void eager_initialize_impl (instanceKlassHandle this_k);
static void set_initialization_state_and_notify_impl (instanceKlassHandle this_k, ClassState state, TRAPS);
static void call_class_initializer_impl (instanceKlassHandle this_k, TRAPS);
static Klass* array_klass_impl (instanceKlassHandle this_k, bool or_null, int n, TRAPS);
static void do_local_static_fields_impl (instanceKlassHandle this_k, void f(fieldDescriptor* fd, TRAPS), TRAPS);
/* jni_id_for_impl for jfieldID only */
static JNIid* jni_id_for_impl (instanceKlassHandle this_oop, int offset);
static JNIid* jni_id_for_impl (instanceKlassHandle this_k, int offset);
// Returns the array class for the n'th dimension
Klass* array_klass_impl(bool or_null, int n, TRAPS);
......
......@@ -334,19 +334,11 @@ GrowableArray<Klass*>* Klass::compute_secondary_supers(int num_extra_slots) {
}
Klass* Klass::subklass() const {
return _subklass == NULL ? NULL : _subklass;
}
InstanceKlass* Klass::superklass() const {
assert(super() == NULL || super()->oop_is_instance(), "must be instance klass");
return _super == NULL ? NULL : InstanceKlass::cast(_super);
}
Klass* Klass::next_sibling() const {
return _next_sibling == NULL ? NULL : _next_sibling;
}
void Klass::set_subklass(Klass* s) {
assert(s != this, "sanity check");
_subklass = s;
......@@ -365,7 +357,7 @@ void Klass::append_to_sibling_list() {
assert((!super->is_interface() // interfaces cannot be supers
&& (super->superklass() == NULL || !is_interface())),
"an interface can only be a subklass of Object");
Klass* prev_first_subklass = super->subklass_oop();
Klass* prev_first_subklass = super->subklass();
if (prev_first_subklass != NULL) {
// set our sibling to be the superklass' previous first subklass
set_next_sibling(prev_first_subklass);
......@@ -405,7 +397,7 @@ void Klass::clean_weak_klass_links(BoolObjectClosure* is_alive) {
assert(current->is_loader_alive(is_alive), "just checking, this should be live");
// Find and set the first alive subklass
Klass* sub = current->subklass_oop();
Klass* sub = current->subklass();
while (sub != NULL && !sub->is_loader_alive(is_alive)) {
#ifndef PRODUCT
if (TraceClassUnloading && WizardMode) {
......@@ -413,7 +405,7 @@ void Klass::clean_weak_klass_links(BoolObjectClosure* is_alive) {
tty->print_cr("[Unlinking class (subclass) %s]", sub->external_name());
}
#endif
sub = sub->next_sibling_oop();
sub = sub->next_sibling();
}
current->set_subklass(sub);
if (sub != NULL) {
......@@ -421,13 +413,13 @@ void Klass::clean_weak_klass_links(BoolObjectClosure* is_alive) {
}
// Find and set the first alive sibling
Klass* sibling = current->next_sibling_oop();
Klass* sibling = current->next_sibling();
while (sibling != NULL && !sibling->is_loader_alive(is_alive)) {
if (TraceClassUnloading && WizardMode) {
ResourceMark rm;
tty->print_cr("[Unlinking class (sibling) %s]", sibling->external_name());
}
sibling = sibling->next_sibling_oop();
sibling = sibling->next_sibling();
}
current->set_next_sibling(sibling);
if (sibling != NULL) {
......
......@@ -56,34 +56,6 @@
// actual type. (See oop.inline.hpp for some of the forwarding code.)
// ALL FUNCTIONS IMPLEMENTING THIS DISPATCH ARE PREFIXED WITH "oop_"!
// Klass layout:
// [C++ vtbl ptr ] (contained in Metadata)
// [layout_helper ]
// [super_check_offset ] for fast subtype checks
// [name ]
// [secondary_super_cache] for fast subtype checks
// [secondary_supers ] array of 2ndary supertypes
// [primary_supers 0]
// [primary_supers 1]
// [primary_supers 2]
// ...
// [primary_supers 7]
// [java_mirror ]
// [super ]
// [subklass ] first subclass
// [next_sibling ] link to chain additional subklasses
// [next_link ]
// [class_loader_data]
// [modifier_flags]
// [access_flags ]
// [last_biased_lock_bulk_revocation_time] (64 bits)
// [prototype_header]
// [biased_lock_revocation_count]
// [_modified_oops]
// [_accumulated_modified_oops]
// [trace_id]
// Forward declarations.
template <class T> class Array;
template <class T> class GrowableArray;
......@@ -257,9 +229,9 @@ class Klass : public Metadata {
// Use InstanceKlass::contains_field_offset to classify field offsets.
// sub/superklass links
Klass* subklass() const { return _subklass; }
Klass* next_sibling() const { return _next_sibling; }
InstanceKlass* superklass() const;
Klass* subklass() const;
Klass* next_sibling() const;
void append_to_sibling_list(); // add newly created receiver to superklass' subklass list
void set_next_link(Klass* k) { _next_link = k; }
......@@ -281,8 +253,6 @@ class Klass : public Metadata {
bool has_accumulated_modified_oops() { return _accumulated_modified_oops == 1; }
protected: // internal accessors
Klass* subklass_oop() const { return _subklass; }
Klass* next_sibling_oop() const { return _next_sibling; }
void set_subklass(Klass* s);
void set_next_sibling(Klass* s);
......
/*
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -577,12 +577,12 @@ bool Method::is_static_initializer() const {
}
objArrayHandle Method::resolved_checked_exceptions_impl(Method* this_oop, TRAPS) {
int length = this_oop->checked_exceptions_length();
objArrayHandle Method::resolved_checked_exceptions_impl(Method* method, TRAPS) {
int length = method->checked_exceptions_length();
if (length == 0) { // common case
return objArrayHandle(THREAD, Universe::the_empty_class_klass_array());
} else {
methodHandle h_this(THREAD, this_oop);
methodHandle h_this(THREAD, method);
objArrayOop m_oop = oopFactory::new_objArray(SystemDictionary::Class_klass(), length, CHECK_(objArrayHandle()));
objArrayHandle mirrors (THREAD, m_oop);
for (int i = 0; i < length; i++) {
......
/*
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -40,50 +40,15 @@
// A Method represents a Java method.
//
// Memory layout (each line represents a word). Note that most applications load thousands of methods,
// so keeping the size of this structure small has a big impact on footprint.
// Note that most applications load thousands of methods, so keeping the size of this
// class small has a big impact on footprint.
//
// The actual bytecodes are inlined after the end of the Method struct.
// Note that native_function and signature_handler have to be at fixed offsets
// (required by the interpreter)
//
// There are bits in the access_flags telling whether inlined tables are present.
// Note that accessing the line number and local variable tables is not performance critical at all.
// Accessing the checked exceptions table is used by reflection, so we put that last to make access
// to it fast.
//
// The line number table is compressed and inlined following the byte codes. It is found as the first
// byte following the byte codes. The checked exceptions table and the local variable table are inlined
// after the line number table, and indexed from the end of the method. We do not compress the checked
// exceptions table since the average length is less than 2, and do not bother to compress the local
// variable table either since it is mostly absent.
//
// Note that native_function and signature_handler has to be at fixed offsets (required by the interpreter)
//
// |------------------------------------------------------|
// | header |
// | klass |
// |------------------------------------------------------|
// | ConstMethod* (metadata) |
// |------------------------------------------------------|
// | MethodData* (metadata) |
// | MethodCounters |
// |------------------------------------------------------|
// | access_flags |
// | vtable_index |
// |------------------------------------------------------|
// | result_index (C++ interpreter only) |
// |------------------------------------------------------|
// | method_size | intrinsic_id | flags |
// |------------------------------------------------------|
// | code (pointer) |
// | i2i (pointer) |
// | adapter (pointer) |
// | from_compiled_entry (pointer) |
// | from_interpreted_entry (pointer) |
// |------------------------------------------------------|
// | native_function (present only if native) |
// | signature_handler (present only if native) |
// |------------------------------------------------------|
// Method embedded field layout (after declared fields):
// [EMBEDDED native_function (present only if native) ]
// [EMBEDDED signature_handler (present only if native) ]
class CheckedExceptionElement;
class LocalVariableTableElement;
......@@ -661,7 +626,7 @@ class Method : public Metadata {
// Static methods that are used to implement member methods where an exposed this pointer
// is needed due to possible GCs
static objArrayHandle resolved_checked_exceptions_impl(Method* this_oop, TRAPS);
static objArrayHandle resolved_checked_exceptions_impl(Method* method, TRAPS);
// Returns the byte code index from the byte code pointer
int bci_from(address bcp) const;
......
/*
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -243,7 +243,6 @@ template <> struct StaticAssert<true> {};
// out of shared space reporting
enum SharedSpaceType {
SharedPermGen,
SharedReadOnly,
SharedReadWrite,
SharedMiscData
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册