提交 8ecb3802 编写于 作者: C coleenp

7117052: instanceKlass::_init_state can be u1 type

Summary: Change instanceKlass::_init_state field to u1 type.
Reviewed-by: bdelsart, coleenp, dholmes, phh, never
Contributed-by: NJiangli Zhou <jiangli.zhou@oracle.com>
上级 d17c0dfc
...@@ -2455,7 +2455,7 @@ void LIR_Assembler::emit_alloc_obj(LIR_OpAllocObj* op) { ...@@ -2455,7 +2455,7 @@ void LIR_Assembler::emit_alloc_obj(LIR_OpAllocObj* op) {
op->obj()->as_register() == O0 && op->obj()->as_register() == O0 &&
op->klass()->as_register() == G5, "must be"); op->klass()->as_register() == G5, "must be");
if (op->init_check()) { if (op->init_check()) {
__ ld(op->klass()->as_register(), __ ldub(op->klass()->as_register(),
instanceKlass::init_state_offset_in_bytes() + sizeof(oopDesc), instanceKlass::init_state_offset_in_bytes() + sizeof(oopDesc),
op->tmp1()->as_register()); op->tmp1()->as_register());
add_debug_info_for_null_check_here(op->stub()->info()); add_debug_info_for_null_check_here(op->stub()->info());
......
...@@ -398,7 +398,7 @@ OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) { ...@@ -398,7 +398,7 @@ OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) {
if (id == fast_new_instance_init_check_id) { if (id == fast_new_instance_init_check_id) {
// make sure the klass is initialized // make sure the klass is initialized
__ ld(G5_klass, instanceKlass::init_state_offset_in_bytes() + sizeof(oopDesc), G3_t1); __ ldub(G5_klass, instanceKlass::init_state_offset_in_bytes() + sizeof(oopDesc), G3_t1);
__ cmp_and_br_short(G3_t1, instanceKlass::fully_initialized, Assembler::notEqual, Assembler::pn, slow_path); __ cmp_and_br_short(G3_t1, instanceKlass::fully_initialized, Assembler::notEqual, Assembler::pn, slow_path);
} }
#ifdef ASSERT #ifdef ASSERT
......
...@@ -3350,7 +3350,7 @@ void TemplateTable::_new() { ...@@ -3350,7 +3350,7 @@ void TemplateTable::_new() {
__ ld_ptr(Rscratch, Roffset, RinstanceKlass); __ ld_ptr(Rscratch, Roffset, RinstanceKlass);
// make sure klass is fully initialized: // make sure klass is fully initialized:
__ ld(RinstanceKlass, instanceKlass::init_state_offset_in_bytes() + sizeof(oopDesc), G3_scratch); __ ldub(RinstanceKlass, instanceKlass::init_state_offset_in_bytes() + sizeof(oopDesc), G3_scratch);
__ cmp(G3_scratch, instanceKlass::fully_initialized); __ cmp(G3_scratch, instanceKlass::fully_initialized);
__ br(Assembler::notEqual, false, Assembler::pn, slow_case); __ br(Assembler::notEqual, false, Assembler::pn, slow_case);
__ delayed()->ld(RinstanceKlass, Klass::layout_helper_offset_in_bytes() + sizeof(oopDesc), Roffset); __ delayed()->ld(RinstanceKlass, Klass::layout_helper_offset_in_bytes() + sizeof(oopDesc), Roffset);
......
...@@ -1557,7 +1557,7 @@ void LIR_Assembler::emit_opConvert(LIR_OpConvert* op) { ...@@ -1557,7 +1557,7 @@ void LIR_Assembler::emit_opConvert(LIR_OpConvert* op) {
void LIR_Assembler::emit_alloc_obj(LIR_OpAllocObj* op) { void LIR_Assembler::emit_alloc_obj(LIR_OpAllocObj* op) {
if (op->init_check()) { if (op->init_check()) {
__ cmpl(Address(op->klass()->as_register(), __ cmpb(Address(op->klass()->as_register(),
instanceKlass::init_state_offset_in_bytes() + sizeof(oopDesc)), instanceKlass::init_state_offset_in_bytes() + sizeof(oopDesc)),
instanceKlass::fully_initialized); instanceKlass::fully_initialized);
add_debug_info_for_null_check_here(op->stub()->info()); add_debug_info_for_null_check_here(op->stub()->info());
......
...@@ -1011,7 +1011,7 @@ OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) { ...@@ -1011,7 +1011,7 @@ OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) {
if (id == fast_new_instance_init_check_id) { if (id == fast_new_instance_init_check_id) {
// make sure the klass is initialized // make sure the klass is initialized
__ cmpl(Address(klass, instanceKlass::init_state_offset_in_bytes() + sizeof(oopDesc)), instanceKlass::fully_initialized); __ cmpb(Address(klass, instanceKlass::init_state_offset_in_bytes() + sizeof(oopDesc)), instanceKlass::fully_initialized);
__ jcc(Assembler::notEqual, slow_path); __ jcc(Assembler::notEqual, slow_path);
} }
......
...@@ -3188,7 +3188,7 @@ void TemplateTable::_new() { ...@@ -3188,7 +3188,7 @@ void TemplateTable::_new() {
// make sure klass is initialized & doesn't have finalizer // make sure klass is initialized & doesn't have finalizer
// make sure klass is fully initialized // make sure klass is fully initialized
__ cmpl(Address(rcx, instanceKlass::init_state_offset_in_bytes() + sizeof(oopDesc)), instanceKlass::fully_initialized); __ cmpb(Address(rcx, instanceKlass::init_state_offset_in_bytes() + sizeof(oopDesc)), instanceKlass::fully_initialized);
__ jcc(Assembler::notEqual, slow_case); __ jcc(Assembler::notEqual, slow_case);
// get instance_size in instanceKlass (scaled to a count of bytes) // get instance_size in instanceKlass (scaled to a count of bytes)
......
...@@ -3235,7 +3235,7 @@ void TemplateTable::_new() { ...@@ -3235,7 +3235,7 @@ void TemplateTable::_new() {
// make sure klass is initialized & doesn't have finalizer // make sure klass is initialized & doesn't have finalizer
// make sure klass is fully initialized // make sure klass is fully initialized
__ cmpl(Address(rsi, __ cmpb(Address(rsi,
instanceKlass::init_state_offset_in_bytes() + instanceKlass::init_state_offset_in_bytes() +
sizeof(oopDesc)), sizeof(oopDesc)),
instanceKlass::fully_initialized); instanceKlass::fully_initialized);
......
...@@ -54,7 +54,7 @@ ciInstanceKlass::ciInstanceKlass(KlassHandle h_k) : ...@@ -54,7 +54,7 @@ ciInstanceKlass::ciInstanceKlass(KlassHandle h_k) :
_flags = ciFlags(access_flags); _flags = ciFlags(access_flags);
_has_finalizer = access_flags.has_finalizer(); _has_finalizer = access_flags.has_finalizer();
_has_subklass = ik->subklass() != NULL; _has_subklass = ik->subklass() != NULL;
_init_state = (instanceKlass::ClassState)ik->get_init_state(); _init_state = ik->init_state();
_nonstatic_field_size = ik->nonstatic_field_size(); _nonstatic_field_size = ik->nonstatic_field_size();
_has_nonstatic_fields = ik->has_nonstatic_fields(); _has_nonstatic_fields = ik->has_nonstatic_fields();
_nonstatic_fields = NULL; // initialized lazily by compute_nonstatic_fields: _nonstatic_fields = NULL; // initialized lazily by compute_nonstatic_fields:
...@@ -118,7 +118,7 @@ ciInstanceKlass::ciInstanceKlass(ciSymbol* name, ...@@ -118,7 +118,7 @@ ciInstanceKlass::ciInstanceKlass(ciSymbol* name,
void ciInstanceKlass::compute_shared_init_state() { void ciInstanceKlass::compute_shared_init_state() {
GUARDED_VM_ENTRY( GUARDED_VM_ENTRY(
instanceKlass* ik = get_instanceKlass(); instanceKlass* ik = get_instanceKlass();
_init_state = (instanceKlass::ClassState)ik->get_init_state(); _init_state = ik->init_state();
) )
} }
......
...@@ -1402,7 +1402,7 @@ class LinkClassesClosure : public ObjectClosure { ...@@ -1402,7 +1402,7 @@ class LinkClassesClosure : public ObjectClosure {
instanceKlass* ik = (instanceKlass*) k; instanceKlass* ik = (instanceKlass*) k;
// Link the class to cause the bytecodes to be rewritten and the // Link the class to cause the bytecodes to be rewritten and the
// cpcache to be created. // cpcache to be created.
if (ik->get_init_state() < instanceKlass::linked) { if (ik->init_state() < instanceKlass::linked) {
ik->link_class(THREAD); ik->link_class(THREAD);
guarantee(!HAS_PENDING_EXCEPTION, "exception in class rewriting"); guarantee(!HAS_PENDING_EXCEPTION, "exception in class rewriting");
} }
...@@ -1535,7 +1535,7 @@ void GenCollectedHeap::preload_and_dump(TRAPS) { ...@@ -1535,7 +1535,7 @@ void GenCollectedHeap::preload_and_dump(TRAPS) {
// are loaded in order that the related data structures (klass, // are loaded in order that the related data structures (klass,
// cpCache, Sting constants) are located together. // cpCache, Sting constants) are located together.
if (ik->get_init_state() < instanceKlass::linked) { if (ik->init_state() < instanceKlass::linked) {
ik->link_class(THREAD); ik->link_class(THREAD);
guarantee(!(HAS_PENDING_EXCEPTION), "exception in class rewriting"); guarantee(!(HAS_PENDING_EXCEPTION), "exception in class rewriting");
} }
......
...@@ -208,7 +208,7 @@ void instanceKlass::eager_initialize_impl(instanceKlassHandle this_oop) { ...@@ -208,7 +208,7 @@ void instanceKlass::eager_initialize_impl(instanceKlassHandle this_oop) {
// abort if someone beat us to the initialization // abort if someone beat us to the initialization
if (!this_oop->is_not_initialized()) return; // note: not equivalent to is_initialized() if (!this_oop->is_not_initialized()) return; // note: not equivalent to is_initialized()
ClassState old_state = this_oop->_init_state; ClassState old_state = this_oop->init_state();
link_class_impl(this_oop, true, THREAD); link_class_impl(this_oop, true, THREAD);
if (HAS_PENDING_EXCEPTION) { if (HAS_PENDING_EXCEPTION) {
CLEAR_PENDING_EXCEPTION; CLEAR_PENDING_EXCEPTION;
...@@ -2479,7 +2479,7 @@ void instanceKlass::set_init_state(ClassState state) { ...@@ -2479,7 +2479,7 @@ void instanceKlass::set_init_state(ClassState state) {
bool good_state = as_klassOop()->is_shared() ? (_init_state <= state) bool good_state = as_klassOop()->is_shared() ? (_init_state <= state)
: (_init_state < state); : (_init_state < state);
assert(good_state || state == allocated, "illegal state transition"); assert(good_state || state == allocated, "illegal state transition");
_init_state = state; _init_state = (u1)state;
} }
#endif #endif
......
...@@ -233,7 +233,6 @@ class instanceKlass: public Klass { ...@@ -233,7 +233,6 @@ class instanceKlass: public Klass {
u2 _minor_version; // minor version number of class file u2 _minor_version; // minor version number of class file
u2 _major_version; // major version number of class file u2 _major_version; // major version number of class file
ClassState _init_state; // state of class
Thread* _init_thread; // Pointer to current thread doing initialization (to handle recusive initialization) Thread* _init_thread; // Pointer to current thread doing initialization (to handle recusive initialization)
int _vtable_len; // length of Java vtable (in words) int _vtable_len; // length of Java vtable (in words)
int _itable_len; // length of Java itable (in words) int _itable_len; // length of Java itable (in words)
...@@ -257,6 +256,11 @@ class instanceKlass: public Klass { ...@@ -257,6 +256,11 @@ class instanceKlass: public Klass {
JvmtiCachedClassFieldMap* _jvmti_cached_class_field_map; // JVMTI: used during heap iteration JvmtiCachedClassFieldMap* _jvmti_cached_class_field_map; // JVMTI: used during heap iteration
volatile u2 _idnum_allocated_count; // JNI/JVMTI: increments with the addition of methods, old ids don't change volatile u2 _idnum_allocated_count; // JNI/JVMTI: increments with the addition of methods, old ids don't change
// Class states are defined as ClassState (see above).
// Place the _init_state here to utilize the unused 2-byte after
// _idnum_allocated_count.
u1 _init_state; // state of class
// Compact the following four boolean flags into 1-bit each. These four flags // Compact the following four boolean flags into 1-bit each. These four flags
// were defined as separate boolean fields and each was 1-byte before. Since // were defined as separate boolean fields and each was 1-byte before. Since
// there are 2 bytes unused after the _idnum_allocated_count field, place the // there are 2 bytes unused after the _idnum_allocated_count field, place the
...@@ -393,7 +397,7 @@ class instanceKlass: public Klass { ...@@ -393,7 +397,7 @@ class instanceKlass: public Klass {
bool is_being_initialized() const { return _init_state == being_initialized; } bool is_being_initialized() const { return _init_state == being_initialized; }
bool is_in_error_state() const { return _init_state == initialization_error; } bool is_in_error_state() const { return _init_state == initialization_error; }
bool is_reentrant_initialization(Thread *thread) { return thread == _init_thread; } bool is_reentrant_initialization(Thread *thread) { return thread == _init_thread; }
int get_init_state() { return _init_state; } // Useful for debugging ClassState init_state() { return (ClassState)_init_state; }
bool is_rewritten() const { return (_misc_flags & REWRITTEN) != 0; } bool is_rewritten() const { return (_misc_flags & REWRITTEN) != 0; }
// defineClass specified verification // defineClass specified verification
...@@ -778,7 +782,7 @@ private: ...@@ -778,7 +782,7 @@ private:
#ifdef ASSERT #ifdef ASSERT
void set_init_state(ClassState state); void set_init_state(ClassState state);
#else #else
void set_init_state(ClassState state) { _init_state = state; } void set_init_state(ClassState state) { _init_state = (u1)state; }
#endif #endif
void set_rewritten() { _misc_flags |= REWRITTEN; } void set_rewritten() { _misc_flags |= REWRITTEN; }
void set_init_thread(Thread *thread) { _init_thread = thread; } void set_init_thread(Thread *thread) { _init_thread = thread; }
......
...@@ -2807,7 +2807,9 @@ bool LibraryCallKit::inline_unsafe_allocate() { ...@@ -2807,7 +2807,9 @@ bool LibraryCallKit::inline_unsafe_allocate() {
// Serializable.class or Object[].class. The runtime will handle it. // Serializable.class or Object[].class. The runtime will handle it.
// But we must make an explicit check for initialization. // But we must make an explicit check for initialization.
Node* insp = basic_plus_adr(kls, instanceKlass::init_state_offset_in_bytes() + sizeof(oopDesc)); Node* insp = basic_plus_adr(kls, instanceKlass::init_state_offset_in_bytes() + sizeof(oopDesc));
Node* inst = make_load(NULL, insp, TypeInt::INT, T_INT); // Use T_BOOLEAN for instanceKlass::_init_state so the compiler
// can generate code to load it as unsigned byte.
Node* inst = make_load(NULL, insp, TypeInt::UBYTE, T_BOOLEAN);
Node* bits = intcon(instanceKlass::fully_initialized); Node* bits = intcon(instanceKlass::fully_initialized);
Node* test = _gvn.transform( new (C, 3) SubINode(inst, bits) ); Node* test = _gvn.transform( new (C, 3) SubINode(inst, bits) );
// The 'test' is non-zero if we need to take a slow path. // The 'test' is non-zero if we need to take a slow path.
......
...@@ -230,7 +230,9 @@ void Parse::emit_guard_for_new(ciInstanceKlass* klass) { ...@@ -230,7 +230,9 @@ void Parse::emit_guard_for_new(ciInstanceKlass* klass) {
Node* init_state_offset = _gvn.MakeConX(instanceKlass::init_state_offset_in_bytes() + klassOopDesc::klass_part_offset_in_bytes()); Node* init_state_offset = _gvn.MakeConX(instanceKlass::init_state_offset_in_bytes() + klassOopDesc::klass_part_offset_in_bytes());
adr_node = basic_plus_adr(kls, kls, init_state_offset); adr_node = basic_plus_adr(kls, kls, init_state_offset);
Node* init_state = make_load(NULL, adr_node, TypeInt::INT, T_INT); // Use T_BOOLEAN for instanceKlass::_init_state so the compiler
// can generate code to load it as unsigned byte.
Node* init_state = make_load(NULL, adr_node, TypeInt::UBYTE, T_BOOLEAN);
Node* being_init = _gvn.intcon(instanceKlass::being_initialized); Node* being_init = _gvn.intcon(instanceKlass::being_initialized);
tst = Bool( CmpI( init_state, being_init), BoolTest::eq); tst = Bool( CmpI( init_state, being_init), BoolTest::eq);
iff = create_and_map_if(control(), tst, PROB_ALWAYS, COUNT_UNKNOWN); iff = create_and_map_if(control(), tst, PROB_ALWAYS, COUNT_UNKNOWN);
......
...@@ -310,7 +310,7 @@ static inline uint64_t cast_uint64_t(size_t x) ...@@ -310,7 +310,7 @@ static inline uint64_t cast_uint64_t(size_t x)
nonstatic_field(instanceKlass, _misc_flags, u1) \ nonstatic_field(instanceKlass, _misc_flags, u1) \
nonstatic_field(instanceKlass, _minor_version, u2) \ nonstatic_field(instanceKlass, _minor_version, u2) \
nonstatic_field(instanceKlass, _major_version, u2) \ nonstatic_field(instanceKlass, _major_version, u2) \
nonstatic_field(instanceKlass, _init_state, instanceKlass::ClassState) \ nonstatic_field(instanceKlass, _init_state, u1) \
nonstatic_field(instanceKlass, _init_thread, Thread*) \ nonstatic_field(instanceKlass, _init_thread, Thread*) \
nonstatic_field(instanceKlass, _vtable_len, int) \ nonstatic_field(instanceKlass, _vtable_len, int) \
nonstatic_field(instanceKlass, _itable_len, int) \ nonstatic_field(instanceKlass, _itable_len, int) \
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册