OpenJDK / amber / amber
changeset 46329:53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
Summary: Summary: Use unhandled pointers for Klass and InstanceKlass, remove handles with no implementation.
Reviewed-by: dholmes, lfoltan, vlivanov, sspitsyn
line wrap: on
line diff
--- a/hotspot/src/cpu/aarch64/vm/methodHandles_aarch64.cpp Wed Mar 15 11:44:46 2017 +0100 +++ b/hotspot/src/cpu/aarch64/vm/methodHandles_aarch64.cpp Wed Mar 15 10:25:37 2017 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2014, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -63,7 +63,7 @@ Register obj, SystemDictionary::WKID klass_id, const char* error_message) { InstanceKlass** klass_addr = SystemDictionary::well_known_klass_addr(klass_id); - KlassHandle klass = SystemDictionary::well_known_klass(klass_id); + Klass* klass = SystemDictionary::well_known_klass(klass_id); Register temp = rscratch2; Register temp2 = rscratch1; // used by MacroAssembler::cmpptr Label L_ok, L_bad;
--- a/hotspot/src/cpu/arm/vm/methodHandles_arm.cpp Wed Mar 15 11:44:46 2017 +0100 +++ b/hotspot/src/cpu/arm/vm/methodHandles_arm.cpp Wed Mar 15 10:25:37 2017 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2017, 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 @@ -67,7 +67,7 @@ Register obj, Register temp1, Register temp2, SystemDictionary::WKID klass_id, const char* error_message) { InstanceKlass** klass_addr = SystemDictionary::well_known_klass_addr(klass_id); - KlassHandle klass = SystemDictionary::well_known_klass(klass_id); + Klass* klass = SystemDictionary::well_known_klass(klass_id); Label L_ok, L_bad; BLOCK_COMMENT("verify_klass {"); __ verify_oop(obj);
--- a/hotspot/src/cpu/ppc/vm/methodHandles_ppc.cpp Wed Mar 15 11:44:46 2017 +0100 +++ b/hotspot/src/cpu/ppc/vm/methodHandles_ppc.cpp Wed Mar 15 10:25:37 2017 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2012, 2015 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -71,7 +71,7 @@ Register temp_reg, Register temp2_reg, const char* error_message) { InstanceKlass** klass_addr = SystemDictionary::well_known_klass_addr(klass_id); - KlassHandle klass = SystemDictionary::well_known_klass(klass_id); + Klass* klass = SystemDictionary::well_known_klass(klass_id); Label L_ok, L_bad; BLOCK_COMMENT("verify_klass {"); __ verify_oop(obj_reg);
--- a/hotspot/src/cpu/s390/vm/methodHandles_s390.cpp Wed Mar 15 11:44:46 2017 +0100 +++ b/hotspot/src/cpu/s390/vm/methodHandles_s390.cpp Wed Mar 15 10:25:37 2017 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2016 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -73,7 +73,7 @@ const char* error_message) { InstanceKlass** klass_addr = SystemDictionary::well_known_klass_addr(klass_id); - KlassHandle klass = SystemDictionary::well_known_klass(klass_id); + KLass* klass = SystemDictionary::well_known_klass(klass_id); assert(temp_reg != Z_R0 && // Is used as base register! temp_reg != noreg && temp2_reg != noreg, "need valid registers!");
--- a/hotspot/src/cpu/sparc/vm/methodHandles_sparc.cpp Wed Mar 15 11:44:46 2017 +0100 +++ b/hotspot/src/cpu/sparc/vm/methodHandles_sparc.cpp Wed Mar 15 10:25:37 2017 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2017, 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 @@ -71,7 +71,7 @@ Register temp_reg, Register temp2_reg, const char* error_message) { InstanceKlass** klass_addr = SystemDictionary::well_known_klass_addr(klass_id); - KlassHandle klass = SystemDictionary::well_known_klass(klass_id); + Klass* klass = SystemDictionary::well_known_klass(klass_id); bool did_save = false; if (temp_reg == noreg || temp2_reg == noreg) { temp_reg = L1;
--- a/hotspot/src/cpu/x86/vm/methodHandles_x86.cpp Wed Mar 15 11:44:46 2017 +0100 +++ b/hotspot/src/cpu/x86/vm/methodHandles_x86.cpp Wed Mar 15 10:25:37 2017 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2017, 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 @@ -65,7 +65,7 @@ Register obj, SystemDictionary::WKID klass_id, const char* error_message) { InstanceKlass** klass_addr = SystemDictionary::well_known_klass_addr(klass_id); - KlassHandle klass = SystemDictionary::well_known_klass(klass_id); + Klass* klass = SystemDictionary::well_known_klass(klass_id); Register temp = rdi; Register temp2 = noreg; LP64_ONLY(temp2 = rscratch1); // used by MacroAssembler::cmpptr
--- a/hotspot/src/share/vm/aot/aotCodeHeap.cpp Wed Mar 15 11:44:46 2017 +0100 +++ b/hotspot/src/share/vm/aot/aotCodeHeap.cpp Wed Mar 15 10:25:37 2017 -0400 @@ -560,7 +560,7 @@ } #endif -Method* AOTCodeHeap::find_method(KlassHandle klass, Thread* thread, const char* method_name) { +Method* AOTCodeHeap::find_method(Klass* klass, Thread* thread, const char* method_name) { int method_name_len = build_u2_from((address)method_name); method_name += 2; const char* signature_name = method_name + method_name_len; @@ -578,14 +578,14 @@ name == vmSymbols::class_initializer_name()) { // Never search superclasses for constructors if (klass->is_instance_klass()) { - m = InstanceKlass::cast(klass())->find_method(name, signature); + m = InstanceKlass::cast(klass)->find_method(name, signature); } else { m = NULL; } } else { m = klass->lookup_method(name, signature); if (m == NULL && klass->is_instance_klass()) { - m = InstanceKlass::cast(klass())->lookup_method_in_ordered_interfaces(name, signature); + m = InstanceKlass::cast(klass)->lookup_method_in_ordered_interfaces(name, signature); } } if (m == NULL) { @@ -669,28 +669,28 @@ } } -bool AOTCodeHeap::load_klass_data(instanceKlassHandle kh, Thread* thread) { +bool AOTCodeHeap::load_klass_data(InstanceKlass* ik, Thread* thread) { ResourceMark rm; NOT_PRODUCT( klasses_seen++; ) - AOTKlassData* klass_data = find_klass(kh()); + AOTKlassData* klass_data = find_klass(ik); if (klass_data == NULL) { return false; } - if (!kh->has_passed_fingerprint_check()) { + if (!ik->has_passed_fingerprint_check()) { NOT_PRODUCT( aot_klasses_fp_miss++; ) log_trace(aot, class, fingerprint)("class %s%s has bad fingerprint in %s tid=" INTPTR_FORMAT, - kh->internal_name(), kh->is_shared() ? " (shared)" : "", + ik->internal_name(), ik->is_shared() ? " (shared)" : "", _lib->name(), p2i(thread)); sweep_dependent_methods(klass_data); return false; } - if (kh->has_been_redefined()) { + if (ik->has_been_redefined()) { log_trace(aot, class, load)("class %s%s in %s has been redefined tid=" INTPTR_FORMAT, - kh->internal_name(), kh->is_shared() ? " (shared)" : "", + ik->internal_name(), ik->is_shared() ? " (shared)" : "", _lib->name(), p2i(thread)); sweep_dependent_methods(klass_data); return false; @@ -698,26 +698,26 @@ assert(klass_data->_class_id < _class_count, "invalid class id"); AOTClass* aot_class = &_classes[klass_data->_class_id]; - if (aot_class->_classloader != NULL && aot_class->_classloader != kh->class_loader_data()) { + if (aot_class->_classloader != NULL && aot_class->_classloader != ik->class_loader_data()) { log_trace(aot, class, load)("class %s in %s already loaded for classloader %p vs %p tid=" INTPTR_FORMAT, - kh->internal_name(), _lib->name(), aot_class->_classloader, kh->class_loader_data(), p2i(thread)); + ik->internal_name(), _lib->name(), aot_class->_classloader, ik->class_loader_data(), p2i(thread)); NOT_PRODUCT( aot_klasses_cl_miss++; ) return false; } - if (_lib->config()->_omitAssertions && JavaAssertions::enabled(kh->name()->as_C_string(), kh->class_loader() == NULL)) { - log_trace(aot, class, load)("class %s in %s does not have java assertions in compiled code, but assertions are enabled for this execution.", kh->internal_name(), _lib->name()); + if (_lib->config()->_omitAssertions && JavaAssertions::enabled(ik->name()->as_C_string(), ik->class_loader() == NULL)) { + log_trace(aot, class, load)("class %s in %s does not have java assertions in compiled code, but assertions are enabled for this execution.", ik->internal_name(), _lib->name()); sweep_dependent_methods(klass_data); return false; } NOT_PRODUCT( aot_klasses_found++; ) - log_trace(aot, class, load)("found %s in %s for classloader %p tid=" INTPTR_FORMAT, kh->internal_name(), _lib->name(), kh->class_loader_data(), p2i(thread)); + log_trace(aot, class, load)("found %s in %s for classloader %p tid=" INTPTR_FORMAT, ik->internal_name(), _lib->name(), ik->class_loader_data(), p2i(thread)); - aot_class->_classloader = kh->class_loader_data(); + aot_class->_classloader = ik->class_loader_data(); // Set klass's Resolve (second) got cell. - _metaspace_got[klass_data->_got_index] = kh(); + _metaspace_got[klass_data->_got_index] = ik; // Initialize global symbols of the DSO to the corresponding VM symbol values. link_global_lib_symbols(); @@ -745,7 +745,7 @@ // aot_name format: "<u2_size>Ljava/lang/ThreadGroup;<u2_size>addUnstarted<u2_size>()V" int klass_len = build_u2_from((address)aot_name); const char* method_name = aot_name + 2 + klass_len; - Method* m = AOTCodeHeap::find_method(kh, thread, method_name); + Method* m = AOTCodeHeap::find_method(ik, thread, method_name); methodHandle mh(thread, m); if (mh->code() != NULL) { // Does it have already compiled code? continue; // Don't overwrite @@ -866,7 +866,7 @@ } #endif -void AOTCodeHeap::flush_evol_dependents_on(instanceKlassHandle dependee) { +void AOTCodeHeap::flush_evol_dependents_on(InstanceKlass* dependee) { for (int index = 0; index < _method_count; index++) { if (_code_to_aot[index]._state != in_use) { continue; // Skip uninitialized entries.
--- a/hotspot/src/share/vm/aot/aotCodeHeap.hpp Wed Mar 15 11:44:46 2017 +0100 +++ b/hotspot/src/share/vm/aot/aotCodeHeap.hpp Wed Mar 15 10:25:37 2017 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2017, 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 @@ -253,7 +253,7 @@ virtual void* next(void *p) const; AOTKlassData* find_klass(InstanceKlass* ik); - bool load_klass_data(instanceKlassHandle kh, Thread* thread); + bool load_klass_data(InstanceKlass* ik, Thread* thread); Klass* get_klass_from_got(const char* klass_name, int klass_len, const Method* method); void sweep_dependent_methods(AOTKlassData* klass_data); bool is_dependent_method(Klass* dependee, AOTCompiledMethod* aot); @@ -289,13 +289,13 @@ return NULL; } - static Method* find_method(KlassHandle klass, Thread* thread, const char* method_name); + static Method* find_method(Klass* klass, Thread* thread, const char* method_name); void cleanup_inline_caches(); DEBUG_ONLY( int verify_icholder_relocations(); ) - void flush_evol_dependents_on(instanceKlassHandle dependee); + void flush_evol_dependents_on(InstanceKlass* dependee); void alive_methods_do(void f(CompiledMethod* nm));
--- a/hotspot/src/share/vm/aot/aotCompiledMethod.cpp Wed Mar 15 11:44:46 2017 +0100 +++ b/hotspot/src/share/vm/aot/aotCompiledMethod.cpp Wed Mar 15 10:25:37 2017 -0400 @@ -143,9 +143,8 @@ int full_len = 2 + klass_len + 2 + method_name_len + 2 + signature_len; if (!klass_matched || memcmp(_name, meta_name, full_len) != 0) { // Does not match? Thread* thread = Thread::current(); - KlassHandle klass = KlassHandle(thread, k); const char* method_name = klass_name + klass_len; - m = AOTCodeHeap::find_method(klass, thread, method_name); + m = AOTCodeHeap::find_method(k, thread, method_name); } meta = ((intptr_t)m) | 1; *entry = (Metadata*)meta; // Should be atomic on x64 @@ -239,7 +238,7 @@ // We don't have full dependencies for AOT methods, so flushing is // more conservative than for nmethods. -void AOTCompiledMethod::flush_evol_dependents_on(instanceKlassHandle dependee) { +void AOTCompiledMethod::flush_evol_dependents_on(InstanceKlass* dependee) { if (is_java_method()) { cleanup_inline_caches(); mark_for_deoptimization();
--- a/hotspot/src/share/vm/aot/aotCompiledMethod.hpp Wed Mar 15 11:44:46 2017 +0100 +++ b/hotspot/src/share/vm/aot/aotCompiledMethod.hpp Wed Mar 15 10:25:37 2017 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2017, 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 @@ -240,7 +240,7 @@ #ifdef HOTSWAP // Flushing and deoptimization in case of evolution - void flush_evol_dependents_on(instanceKlassHandle dependee); + void flush_evol_dependents_on(InstanceKlass* dependee); #endif // HOTSWAP virtual void metadata_do(void f(Metadata*));
--- a/hotspot/src/share/vm/aot/aotLoader.cpp Wed Mar 15 11:44:46 2017 +0100 +++ b/hotspot/src/share/vm/aot/aotLoader.cpp Wed Mar 15 10:25:37 2017 -0400 @@ -37,10 +37,10 @@ // Iterate over all AOT Libraries #define FOR_ALL_AOT_LIBRARIES(lib) for (GrowableArrayIterator<AOTLib*> lib = libraries()->begin(); lib != libraries()->end(); ++lib) -void AOTLoader::load_for_klass(instanceKlassHandle kh, Thread* thread) { +void AOTLoader::load_for_klass(InstanceKlass* ik, Thread* thread) { if (UseAOT) { FOR_ALL_AOT_HEAPS(heap) { - (*heap)->load_klass_data(kh, thread); + (*heap)->load_klass_data(ik, thread); } } } @@ -98,7 +98,7 @@ } // Flushing and deoptimization in case of evolution -void AOTLoader::flush_evol_dependents_on(instanceKlassHandle dependee) { +void AOTLoader::flush_evol_dependents_on(InstanceKlass* dependee) { // make non entrant and mark for deoptimization FOR_ALL_AOT_HEAPS(heap) { (*heap)->flush_evol_dependents_on(dependee);
--- a/hotspot/src/share/vm/aot/aotLoader.hpp Wed Mar 15 11:44:46 2017 +0100 +++ b/hotspot/src/share/vm/aot/aotLoader.hpp Wed Mar 15 10:25:37 2017 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2017, 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 @@ -58,7 +58,7 @@ static void universe_init() NOT_AOT_RETURN; static void set_narrow_klass_shift() NOT_AOT_RETURN; static bool contains(address p) NOT_AOT({ return false; }); - static void load_for_klass(instanceKlassHandle, Thread* thread) NOT_AOT_RETURN; + static void load_for_klass(InstanceKlass* ik, Thread* thread) NOT_AOT_RETURN; static bool find_klass(InstanceKlass* ik) NOT_AOT({ return false; }); static uint64_t get_saved_fingerprint(InstanceKlass* ik) NOT_AOT({ return 0; }); static void oops_do(OopClosure* f) NOT_AOT_RETURN; @@ -69,7 +69,7 @@ #ifdef HOTSWAP // Flushing and deoptimization in case of evolution - static void flush_evol_dependents_on(instanceKlassHandle dependee) NOT_AOT_RETURN; + static void flush_evol_dependents_on(InstanceKlass* dependee) NOT_AOT_RETURN; #endif // HOTSWAP };
--- a/hotspot/src/share/vm/c1/c1_Runtime1.cpp Wed Mar 15 11:44:46 2017 +0100 +++ b/hotspot/src/share/vm/c1/c1_Runtime1.cpp Wed Mar 15 10:25:37 2017 -0400 @@ -331,7 +331,7 @@ assert(klass->is_klass(), "not a class"); Handle holder(THREAD, klass->klass_holder()); // keep the klass alive - instanceKlassHandle h(thread, klass); + InstanceKlass* h = InstanceKlass::cast(klass); h->check_valid_for_instantiation(true, CHECK); // make sure klass is initialized h->initialize(CHECK); @@ -857,8 +857,8 @@ bool deoptimize_for_volatile = false; bool deoptimize_for_atomic = false; int patch_field_offset = -1; - KlassHandle init_klass(THREAD, NULL); // klass needed by load_klass_patching code - KlassHandle load_klass(THREAD, NULL); // klass needed by load_klass_patching code + Klass* init_klass = NULL; // klass needed by load_klass_patching code + Klass* load_klass = NULL; // klass needed by load_klass_patching code Handle mirror(THREAD, NULL); // oop needed by load_mirror_patching code Handle appendix(THREAD, NULL); // oop needed by appendix_patching code bool load_klass_or_mirror_patch_id = @@ -905,7 +905,7 @@ case Bytecodes::_putstatic: case Bytecodes::_getstatic: { Klass* klass = resolve_field_return_klass(caller_method, bci, CHECK); - init_klass = KlassHandle(THREAD, klass); + init_klass = klass; mirror = Handle(THREAD, klass->java_mirror()); } break; @@ -945,8 +945,7 @@ break; default: fatal("unexpected bytecode for load_klass_or_mirror_patch_id"); } - // convert to handle - load_klass = KlassHandle(THREAD, k); + load_klass = k; } else if (stub_id == load_appendix_patching_id) { Bytecode_invoke bytecode(caller_method, bci); Bytecodes::Code bc = bytecode.invoke_code(); @@ -1067,7 +1066,7 @@ // initializing thread are forced to come into the VM and // block. do_patch = (code != Bytecodes::_getstatic && code != Bytecodes::_putstatic) || - InstanceKlass::cast(init_klass())->is_initialized(); + InstanceKlass::cast(init_klass)->is_initialized(); NativeGeneralJump* jump = nativeGeneralJump_at(instr_pc); if (jump->jump_destination() == being_initialized_entry) { assert(do_patch == true, "initialization must be complete at this point"); @@ -1079,8 +1078,8 @@ n_copy->data() == (intptr_t)Universe::non_oop_word(), "illegal init value"); if (stub_id == Runtime1::load_klass_patching_id) { - assert(load_klass() != NULL, "klass not set"); - n_copy->set_data((intx) (load_klass())); + assert(load_klass != NULL, "klass not set"); + n_copy->set_data((intx) (load_klass)); } else { assert(mirror() != NULL, "klass not set"); // Don't need a G1 pre-barrier here since we assert above that data isn't an oop. @@ -1131,7 +1130,7 @@ assert(stub_id == Runtime1::load_klass_patching_id, "wrong stub id"); metadata_Relocation* r = mds.metadata_reloc(); Metadata** metadata_adr = r->metadata_addr(); - *metadata_adr = load_klass(); + *metadata_adr = load_klass; r->fix_metadata_relocation(); found = true; }
--- a/hotspot/src/share/vm/ci/ciArrayKlass.cpp Wed Mar 15 11:44:46 2017 +0100 +++ b/hotspot/src/share/vm/ci/ciArrayKlass.cpp Wed Mar 15 10:25:37 2017 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2017, 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 @@ -37,7 +37,7 @@ // ciArrayKlass::ciArrayKlass // // Loaded array klass. -ciArrayKlass::ciArrayKlass(KlassHandle h_k) : ciKlass(h_k) { +ciArrayKlass::ciArrayKlass(Klass* k) : ciKlass(k) { assert(get_Klass()->is_array_klass(), "wrong type"); _dimension = get_ArrayKlass()->dimension(); }
--- a/hotspot/src/share/vm/ci/ciArrayKlass.hpp Wed Mar 15 11:44:46 2017 +0100 +++ b/hotspot/src/share/vm/ci/ciArrayKlass.hpp Wed Mar 15 10:25:37 2017 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2017, 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 @@ -37,7 +37,7 @@ jint _dimension; protected: - ciArrayKlass(KlassHandle h_k); + ciArrayKlass(Klass* k); ciArrayKlass(ciSymbol* name, int dimension, BasicType bt); ArrayKlass* get_ArrayKlass() {
--- a/hotspot/src/share/vm/ci/ciEnv.cpp Wed Mar 15 11:44:46 2017 +0100 +++ b/hotspot/src/share/vm/ci/ciEnv.cpp Wed Mar 15 10:25:37 2017 -0400 @@ -426,7 +426,7 @@ } else { fail_type = _unloaded_ciinstance_klass; } - KlassHandle found_klass; + Klass* found_klass; { ttyUnlocker ttyul; // release tty lock to avoid ordering problems MutexLocker ml(Compile_lock); @@ -438,7 +438,7 @@ kls = SystemDictionary::find_instance_or_array_klass(sym, loader, domain, KILL_COMPILE_ON_FATAL_(fail_type)); } - found_klass = KlassHandle(THREAD, kls); + found_klass = kls; } // If we fail to find an array klass, look again for its element type. @@ -467,22 +467,22 @@ } } - if (found_klass() == NULL && !cpool.is_null() && cpool->has_preresolution()) { + if (found_klass == NULL && !cpool.is_null() && cpool->has_preresolution()) { // Look inside the constant pool for pre-resolved class entries. for (int i = cpool->length() - 1; i >= 1; i--) { if (cpool->tag_at(i).is_klass()) { Klass* kls = cpool->resolved_klass_at(i); if (kls->name() == sym) { - found_klass = KlassHandle(THREAD, kls); + found_klass = kls; break; } } } } - if (found_klass() != NULL) { + if (found_klass != NULL) { // Found it. Build a CI handle. - return get_klass(found_klass()); + return get_klass(found_klass); } if (require_local) return NULL; @@ -512,21 +512,21 @@ bool& is_accessible, ciInstanceKlass* accessor) { EXCEPTION_CONTEXT; - KlassHandle klass; // = NULL; + Klass* klass = NULL; Symbol* klass_name = NULL; if (cpool->tag_at(index).is_symbol()) { klass_name = cpool->symbol_at(index); } else { // Check if it's resolved if it's not a symbol constant pool entry. - klass = KlassHandle(THREAD, ConstantPool::klass_at_if_loaded(cpool, index)); + klass = ConstantPool::klass_at_if_loaded(cpool, index); // Try to look it up by name. - if (klass.is_null()) { + if (klass == NULL) { klass_name = cpool->klass_name_at(index); - } + } } - if (klass.is_null()) { + if (klass == NULL) { // Not found in constant pool. Use the name to do the lookup. ciKlass* k = get_klass_by_name_impl(accessor, cpool, @@ -548,7 +548,7 @@ // Check for prior unloaded klass. The SystemDictionary's answers // can vary over time but the compiler needs consistency. - ciSymbol* name = get_symbol(klass()->name()); + ciSymbol* name = get_symbol(klass->name()); ciKlass* unloaded_klass = check_get_unloaded_klass(accessor, name); if (unloaded_klass != NULL) { is_accessible = false; @@ -557,7 +557,7 @@ // It is known to be accessible, since it was found in the constant pool. is_accessible = true; - return get_klass(klass()); + return get_klass(klass); } // ------------------------------------------------------------------ @@ -713,10 +713,10 @@ // Accessibility checks are performed in ciEnv::get_method_by_index_impl. assert(check_klass_accessibility(accessor, holder->get_Klass()), "holder not accessible"); - KlassHandle h_accessor(accessor->get_instanceKlass()); - KlassHandle h_holder(holder->get_Klass()); + InstanceKlass* accessor_klass = accessor->get_instanceKlass(); + Klass* holder_klass = holder->get_Klass(); methodHandle dest_method; - LinkInfo link_info(h_holder, name, sig, h_accessor, LinkInfo::needs_access_check, tag); + LinkInfo link_info(holder_klass, name, sig, accessor_klass, LinkInfo::needs_access_check, tag); switch (bc) { case Bytecodes::_invokestatic: dest_method =
--- a/hotspot/src/share/vm/ci/ciInstanceKlass.cpp Wed Mar 15 11:44:46 2017 +0100 +++ b/hotspot/src/share/vm/ci/ciInstanceKlass.cpp Wed Mar 15 10:25:37 2017 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2017, 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 @@ -44,8 +44,8 @@ // ciInstanceKlass::ciInstanceKlass // // Loaded instance klass. -ciInstanceKlass::ciInstanceKlass(KlassHandle h_k) : - ciKlass(h_k) +ciInstanceKlass::ciInstanceKlass(Klass* k) : + ciKlass(k) { assert(get_Klass()->is_instance_klass(), "wrong type"); assert(get_instanceKlass()->is_loaded(), "must be at least loaded"); @@ -83,7 +83,7 @@ _java_mirror = NULL; if (is_shared()) { - if (h_k() != SystemDictionary::Object_klass()) { + if (k != SystemDictionary::Object_klass()) { super(); } //compute_nonstatic_fields(); // done outside of constructor
--- a/hotspot/src/share/vm/ci/ciInstanceKlass.hpp Wed Mar 15 11:44:46 2017 +0100 +++ b/hotspot/src/share/vm/ci/ciInstanceKlass.hpp Wed Mar 15 10:25:37 2017 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2017, 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 @@ -77,7 +77,7 @@ bool compute_injected_fields_helper(); protected: - ciInstanceKlass(KlassHandle h_k); + ciInstanceKlass(Klass* k); ciInstanceKlass(ciSymbol* name, jobject loader, jobject protection_domain); InstanceKlass* get_instanceKlass() const {
--- a/hotspot/src/share/vm/ci/ciKlass.cpp Wed Mar 15 11:44:46 2017 +0100 +++ b/hotspot/src/share/vm/ci/ciKlass.cpp Wed Mar 15 10:25:37 2017 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2017, 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 @@ -35,11 +35,11 @@ // ------------------------------------------------------------------ // ciKlass::ciKlass -ciKlass::ciKlass(KlassHandle h_k) : ciType(h_k) { +ciKlass::ciKlass(Klass* k) : ciType(k) { assert(get_Klass()->is_klass(), "wrong type"); - Klass* k = get_Klass(); - _layout_helper = k->layout_helper(); - Symbol* klass_name = k->name(); + Klass* klass = get_Klass(); + _layout_helper = klass->layout_helper(); + Symbol* klass_name = klass->name(); assert(klass_name != NULL, "wrong ciKlass constructor"); _name = CURRENT_ENV->get_symbol(klass_name); } @@ -48,7 +48,7 @@ // ciKlass::ciKlass // // Nameless klass variant. -ciKlass::ciKlass(KlassHandle h_k, ciSymbol* name) : ciType(h_k) { +ciKlass::ciKlass(Klass* k, ciSymbol* name) : ciType(k) { assert(get_Klass()->is_klass(), "wrong type"); _name = name; _layout_helper = Klass::_lh_neutral_value;
--- a/hotspot/src/share/vm/ci/ciKlass.hpp Wed Mar 15 11:44:46 2017 +0100 +++ b/hotspot/src/share/vm/ci/ciKlass.hpp Wed Mar 15 10:25:37 2017 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2017, 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 @@ -51,7 +51,7 @@ jint _layout_helper; protected: - ciKlass(KlassHandle k_h, ciSymbol* name); + ciKlass(Klass* k, ciSymbol* name); ciKlass(ciSymbol* name, BasicType bt); Klass* get_Klass() const { @@ -72,7 +72,7 @@ void print_impl(outputStream* st); public: - ciKlass(KlassHandle k_h); + ciKlass(Klass* k); // What is the name of this klass? ciSymbol* name() const { return _name; }
--- a/hotspot/src/share/vm/ci/ciMethod.cpp Wed Mar 15 11:44:46 2017 +0100 +++ b/hotspot/src/share/vm/ci/ciMethod.cpp Wed Mar 15 10:25:37 2017 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2017, 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 @@ -783,24 +783,24 @@ check_is_loaded(); VM_ENTRY_MARK; - KlassHandle caller_klass (THREAD, caller->get_Klass()); - KlassHandle h_recv (THREAD, exact_receiver->get_Klass()); - KlassHandle h_resolved (THREAD, holder()->get_Klass()); + Klass* caller_klass = caller->get_Klass(); + Klass* recv = exact_receiver->get_Klass(); + Klass* resolved = holder()->get_Klass(); Symbol* h_name = name()->get_symbol(); Symbol* h_signature = signature()->get_symbol(); - LinkInfo link_info(h_resolved, h_name, h_signature, caller_klass, + LinkInfo link_info(resolved, h_name, h_signature, caller_klass, check_access ? LinkInfo::needs_access_check : LinkInfo::skip_access_check); methodHandle m; // Only do exact lookup if receiver klass has been linked. Otherwise, // the vtable has not been setup, and the LinkResolver will fail. - if (h_recv->is_array_klass() + if (recv->is_array_klass() || - InstanceKlass::cast(h_recv())->is_linked() && !exact_receiver->is_interface()) { + InstanceKlass::cast(recv)->is_linked() && !exact_receiver->is_interface()) { if (holder()->is_interface()) { - m = LinkResolver::resolve_interface_call_or_null(h_recv, link_info); + m = LinkResolver::resolve_interface_call_or_null(recv, link_info); } else { - m = LinkResolver::resolve_virtual_call_or_null(h_recv, link_info); + m = LinkResolver::resolve_virtual_call_or_null(recv, link_info); } } @@ -839,13 +839,13 @@ receiver->as_instance_klass()->is_linked())) { VM_ENTRY_MARK; - KlassHandle caller_klass (THREAD, caller->get_Klass()); - KlassHandle h_recv (THREAD, receiver->get_Klass()); + Klass* caller_klass = caller->get_Klass(); + Klass* recv = receiver->get_Klass(); Symbol* h_name = name()->get_symbol(); Symbol* h_signature = signature()->get_symbol(); - LinkInfo link_info(h_recv, h_name, h_signature, caller_klass); - vtable_index = LinkResolver::resolve_virtual_vtable_index(h_recv, link_info); + LinkInfo link_info(recv, h_name, h_signature, caller_klass); + vtable_index = LinkResolver::resolve_virtual_vtable_index(recv, link_info); if (vtable_index == Method::nonvirtual_vtable_index) { // A statically bound method. Return "no such index". vtable_index = Method::invalid_vtable_index;
--- a/hotspot/src/share/vm/ci/ciObjArrayKlass.cpp Wed Mar 15 11:44:46 2017 +0100 +++ b/hotspot/src/share/vm/ci/ciObjArrayKlass.cpp Wed Mar 15 10:25:37 2017 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2017, 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 @@ -38,7 +38,7 @@ // ciObjArrayKlass::ciObjArrayKlass // // Constructor for loaded object array klasses. -ciObjArrayKlass::ciObjArrayKlass(KlassHandle h_k) : ciArrayKlass(h_k) { +ciObjArrayKlass::ciObjArrayKlass(Klass* k) : ciArrayKlass(k) { assert(get_Klass()->is_objArray_klass(), "wrong type"); Klass* element_Klass = get_ObjArrayKlass()->bottom_klass(); _base_element_klass = CURRENT_ENV->get_klass(element_Klass);
--- a/hotspot/src/share/vm/ci/ciObjArrayKlass.hpp Wed Mar 15 11:44:46 2017 +0100 +++ b/hotspot/src/share/vm/ci/ciObjArrayKlass.hpp Wed Mar 15 10:25:37 2017 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2017, 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,7 +40,7 @@ ciKlass* _base_element_klass; protected: - ciObjArrayKlass(KlassHandle h_k); + ciObjArrayKlass(Klass* k); ciObjArrayKlass(ciSymbol* array_name, ciKlass* base_element_klass, int dimension);
--- a/hotspot/src/share/vm/ci/ciObjectFactory.cpp Wed Mar 15 11:44:46 2017 +0100 +++ b/hotspot/src/share/vm/ci/ciObjectFactory.cpp Wed Mar 15 10:25:37 2017 -0400 @@ -377,14 +377,13 @@ } if (o->is_klass()) { - KlassHandle h_k(THREAD, (Klass*)o); Klass* k = (Klass*)o; if (k->is_instance_klass()) { - return new (arena()) ciInstanceKlass(h_k); + return new (arena()) ciInstanceKlass(k); } else if (k->is_objArray_klass()) { - return new (arena()) ciObjArrayKlass(h_k); + return new (arena()) ciObjArrayKlass(k); } else if (k->is_typeArray_klass()) { - return new (arena()) ciTypeArrayKlass(h_k); + return new (arena()) ciTypeArrayKlass(k); } } else if (o->is_method()) { methodHandle h_m(THREAD, (Method*)o);
--- a/hotspot/src/share/vm/ci/ciReplay.cpp Wed Mar 15 11:44:46 2017 +0100 +++ b/hotspot/src/share/vm/ci/ciReplay.cpp Wed Mar 15 10:25:37 2017 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2017, 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 @@ -799,8 +799,8 @@ } else if (strcmp(field_signature, "[J") == 0) { value = oopFactory::new_longArray(length, CHECK); } else if (field_signature[0] == '[' && field_signature[1] == 'L') { - KlassHandle kelem = resolve_klass(field_signature + 1, CHECK); - value = oopFactory::new_objArray(kelem(), length, CHECK); + Klass* kelem = resolve_klass(field_signature + 1, CHECK); + value = oopFactory::new_objArray(kelem, length, CHECK); } else { report_error("unhandled array staticfield"); } @@ -840,8 +840,8 @@ Handle value = java_lang_String::create_from_str(string_value, CHECK); java_mirror->obj_field_put(fd.offset(), value()); } else if (field_signature[0] == 'L') { - KlassHandle k = resolve_klass(string_value, CHECK); - oop value = InstanceKlass::cast(k())->allocate_instance(CHECK); + Klass* k = resolve_klass(string_value, CHECK); + oop value = InstanceKlass::cast(k)->allocate_instance(CHECK); java_mirror->obj_field_put(fd.offset(), value); } else { report_error("unhandled staticfield");
--- a/hotspot/src/share/vm/ci/ciType.cpp Wed Mar 15 11:44:46 2017 +0100 +++ b/hotspot/src/share/vm/ci/ciType.cpp Wed Mar 15 10:25:37 2017 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2017, 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 @@ -45,8 +45,8 @@ _basic_type = basic_type; } -ciType::ciType(KlassHandle k) : ciMetadata(k()) { - _basic_type = k()->is_array_klass() ? T_ARRAY : T_OBJECT; +ciType::ciType(Klass* k) : ciMetadata(k) { + _basic_type = k->is_array_klass() ? T_ARRAY : T_OBJECT; }
--- a/hotspot/src/share/vm/ci/ciType.hpp Wed Mar 15 11:44:46 2017 +0100 +++ b/hotspot/src/share/vm/ci/ciType.hpp Wed Mar 15 10:25:37 2017 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2017, 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,7 +40,7 @@ BasicType _basic_type; ciType(BasicType t); // for primitive and unloaded types - ciType(KlassHandle k); // for subclasses (reference types) + ciType(Klass* k); // for subclasses (reference types) const char* type_string() { return "ciType"; }
--- a/hotspot/src/share/vm/ci/ciTypeArrayKlass.cpp Wed Mar 15 11:44:46 2017 +0100 +++ b/hotspot/src/share/vm/ci/ciTypeArrayKlass.cpp Wed Mar 15 10:25:37 2017 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2017, 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 @@ -33,7 +33,7 @@ // ------------------------------------------------------------------ // ciTypeArrayKlass::ciTypeArrayKlass -ciTypeArrayKlass::ciTypeArrayKlass(KlassHandle h_k) : ciArrayKlass(h_k) { +ciTypeArrayKlass::ciTypeArrayKlass(Klass* k) : ciArrayKlass(k) { assert(get_Klass()->is_typeArray_klass(), "wrong type"); assert(element_type() == get_TypeArrayKlass()->element_type(), ""); }
--- a/hotspot/src/share/vm/ci/ciTypeArrayKlass.hpp Wed Mar 15 11:44:46 2017 +0100 +++ b/hotspot/src/share/vm/ci/ciTypeArrayKlass.hpp Wed Mar 15 10:25:37 2017 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2017, 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 @@ -35,7 +35,7 @@ CI_PACKAGE_ACCESS protected: - ciTypeArrayKlass(KlassHandle h_k); + ciTypeArrayKlass(Klass* k); TypeArrayKlass* get_TypeArrayKlass() { return (TypeArrayKlass*)get_Klass();
--- a/hotspot/src/share/vm/classfile/classFileParser.cpp Wed Mar 15 11:44:46 2017 +0100 +++ b/hotspot/src/share/vm/classfile/classFileParser.cpp Wed Mar 15 10:25:37 2017 -0400 @@ -815,13 +815,13 @@ int index; for (index = 0; index < itfs_len; index++) { const u2 interface_index = stream->get_u2(CHECK); - KlassHandle interf; + Klass* interf; check_property( valid_klass_reference_at(interface_index), "Interface name has bad constant pool index %u in class file %s", interface_index, CHECK); if (cp->tag_at(interface_index).is_klass()) { - interf = KlassHandle(THREAD, cp->resolved_klass_at(interface_index)); + interf = cp->resolved_klass_at(interface_index); } else { Symbol* const unresolved_klass = cp->klass_name_at(interface_index); @@ -831,25 +831,24 @@ "Bad interface name in class file %s", CHECK); // Call resolve_super so classcircularity is checked - const Klass* const k = - SystemDictionary::resolve_super_or_fail(_class_name, + interf = SystemDictionary::resolve_super_or_fail( + _class_name, unresolved_klass, Handle(THREAD, _loader_data->class_loader()), _protection_domain, false, CHECK); - interf = KlassHandle(THREAD, k); } - if (!interf()->is_interface()) { + if (!interf->is_interface()) { THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(), "Implementing class"); } - if (InstanceKlass::cast(interf())->has_nonstatic_concrete_methods()) { + if (InstanceKlass::cast(interf)->has_nonstatic_concrete_methods()) { *has_nonstatic_concrete_methods = true; } - _local_interfaces->at_put(index, interf()); + _local_interfaces->at_put(index, interf); } if (!_need_verify || itfs_len <= 1) {
--- a/hotspot/src/share/vm/classfile/classLoader.cpp Wed Mar 15 11:44:46 2017 +0100 +++ b/hotspot/src/share/vm/classfile/classLoader.cpp Wed Mar 15 10:25:37 2017 -0400 @@ -1405,7 +1405,7 @@ return NULL; } -instanceKlassHandle ClassLoader::load_class(Symbol* name, bool search_append_only, TRAPS) { +InstanceKlass* ClassLoader::load_class(Symbol* name, bool search_append_only, TRAPS) { assert(name != NULL, "invariant"); assert(THREAD->is_Java_thread(), "must be a JavaThread"); @@ -1512,13 +1512,13 @@ ClassLoaderData* loader_data = ClassLoaderData::the_null_class_loader_data(); Handle protection_domain; - instanceKlassHandle result = KlassFactory::create_from_stream(stream, - name, - loader_data, - protection_domain, - NULL, // host_klass - NULL, // cp_patches - THREAD); + InstanceKlass* result = KlassFactory::create_from_stream(stream, + name, + loader_data, + protection_domain, + NULL, // host_klass + NULL, // cp_patches + THREAD); if (HAS_PENDING_EXCEPTION) { if (DumpSharedSpaces) { tty->print_cr("Preload Error: Failed to load %s", class_name); @@ -1891,15 +1891,15 @@ // Construct name without extension TempNewSymbol sym = SymbolTable::new_symbol(buffer, CHECK); // Use loader to load and initialize class - Klass* ik = SystemDictionary::resolve_or_null(sym, loader, Handle(), THREAD); - instanceKlassHandle k (THREAD, ik); - if (k.not_null() && !HAS_PENDING_EXCEPTION) { + Klass* k = SystemDictionary::resolve_or_null(sym, loader, Handle(), THREAD); + if (k != NULL && !HAS_PENDING_EXCEPTION) { k->initialize(THREAD); } bool exception_occurred = HAS_PENDING_EXCEPTION; clear_pending_exception_if_not_oom(CHECK); - if (CompileTheWorldPreloadClasses && k.not_null()) { - ConstantPool::preload_and_initialize_all_classes(k->constants(), THREAD); + if (CompileTheWorldPreloadClasses && k != NULL) { + InstanceKlass* ik = InstanceKlass::cast(k); + ConstantPool::preload_and_initialize_all_classes(ik->constants(), THREAD); if (HAS_PENDING_EXCEPTION) { // If something went wrong in preloading we just ignore it clear_pending_exception_if_not_oom(CHECK); @@ -1908,7 +1908,7 @@ } if (_compile_the_world_class_counter >= CompileTheWorldStartAt) { - if (k.is_null() || exception_occurred) { + if (k == NULL || exception_occurred) { // If something went wrong (e.g. ExceptionInInitializerError) we skip this class tty->print_cr("CompileTheWorld (%d) : Skipping %s", _compile_the_world_class_counter, buffer); } else { @@ -1916,8 +1916,9 @@ // Preload all classes to get around uncommon traps // Iterate over all methods in class int comp_level = CompilationPolicy::policy()->initial_compile_level(); - for (int n = 0; n < k->methods()->length(); n++) { - methodHandle m (THREAD, k->methods()->at(n)); + InstanceKlass* ik = InstanceKlass::cast(k); + for (int n = 0; n < ik->methods()->length(); n++) { + methodHandle m (THREAD, ik->methods()->at(n)); if (can_be_compiled(m, comp_level)) { if (++_codecache_sweep_counter == CompileTheWorldSafepointInterval) { // Give sweeper a chance to keep up with CTW
--- a/hotspot/src/share/vm/classfile/classLoader.hpp Wed Mar 15 11:44:46 2017 +0100 +++ b/hotspot/src/share/vm/classfile/classLoader.hpp Wed Mar 15 10:25:37 2017 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2017, 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 @@ -371,7 +371,7 @@ const char* const file_name, TRAPS); // Load individual .class file - static instanceKlassHandle load_class(Symbol* class_name, bool search_append_only, TRAPS); + static InstanceKlass* load_class(Symbol* class_name, bool search_append_only, TRAPS); // If the specified package has been loaded by the system, then returns // the name of the directory or ZIP file that the package was loaded from.
--- a/hotspot/src/share/vm/classfile/classLoaderData.cpp Wed Mar 15 11:44:46 2017 +0100 +++ b/hotspot/src/share/vm/classfile/classLoaderData.cpp Wed Mar 15 10:25:37 2017 -0400 @@ -760,7 +760,7 @@ // Include the result of loader.toString() in the output. This allows // the user of the log to identify the class loader instance. JavaValue result(T_OBJECT); - KlassHandle spec_klass(THREAD, SystemDictionary::ClassLoader_klass()); + Klass* spec_klass = SystemDictionary::ClassLoader_klass(); JavaCalls::call_virtual(&result, loader, spec_klass,
--- a/hotspot/src/share/vm/classfile/classLoaderExt.hpp Wed Mar 15 11:44:46 2017 +0100 +++ b/hotspot/src/share/vm/classfile/classLoaderExt.hpp Wed Mar 15 10:25:37 2017 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2017, 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 @@ -49,10 +49,10 @@ return false; } - instanceKlassHandle record_result(Symbol* class_name, - ClassPathEntry* e, - const s2 classpath_index, - instanceKlassHandle result, TRAPS) { + InstanceKlass* record_result(Symbol* class_name, + ClassPathEntry* e, + const s2 classpath_index, + InstanceKlass* result, TRAPS) { if (ClassLoader::add_package(_file_name, classpath_index, THREAD)) { #if INCLUDE_CDS if (DumpSharedSpaces) { @@ -64,7 +64,7 @@ #endif return result; } else { - return instanceKlassHandle(); // NULL + return NULL; } } };
--- a/hotspot/src/share/vm/classfile/dictionary.cpp Wed Mar 15 11:44:46 2017 +0100 +++ b/hotspot/src/share/vm/classfile/dictionary.cpp Wed Mar 15 10:25:37 2017 -0400 @@ -46,7 +46,7 @@ } Dictionary::Dictionary(int table_size) - : TwoOopHashtable<Klass*, mtClass>(table_size, (int)entry_size()) { + : TwoOopHashtable<InstanceKlass*, mtClass>(table_size, (int)entry_size()) { _current_class_index = 0; _current_class_entry = NULL; _pd_cache_table = new ProtectionDomainCacheTable(defaultProtectionDomainCacheSize); @@ -55,7 +55,7 @@ Dictionary::Dictionary(int table_size, HashtableBucket<mtClass>* t, int number_of_entries) - : TwoOopHashtable<Klass*, mtClass>(table_size, (int)entry_size(), t, number_of_entries) { + : TwoOopHashtable<InstanceKlass*, mtClass>(table_size, (int)entry_size(), t, number_of_entries) { _current_class_index = 0; _current_class_entry = NULL; _pd_cache_table = new ProtectionDomainCacheTable(defaultProtectionDomainCacheSize); @@ -65,9 +65,9 @@ return _pd_cache_table->get(protection_domain); } -DictionaryEntry* Dictionary::new_entry(unsigned int hash, Klass* klass, +DictionaryEntry* Dictionary::new_entry(unsigned int hash, InstanceKlass* klass, ClassLoaderData* loader_data) { - DictionaryEntry* entry = (DictionaryEntry*)Hashtable<Klass*, mtClass>::new_entry(hash, klass); + DictionaryEntry* entry = (DictionaryEntry*)Hashtable<InstanceKlass*, mtClass>::new_entry(hash, klass); entry->set_loader_data(loader_data); entry->set_pd_set(NULL); assert(klass->is_instance_klass(), "Must be"); @@ -85,7 +85,7 @@ entry->set_pd_set(to_delete->next()); delete to_delete; } - Hashtable<Klass*, mtClass>::free_entry(entry); + Hashtable<InstanceKlass*, mtClass>::free_entry(entry); } @@ -351,10 +351,10 @@ _pd_cache_table->unlink(is_alive); } -Klass* Dictionary::try_get_next_class() { +InstanceKlass* Dictionary::try_get_next_class() { while (true) { if (_current_class_entry != NULL) { - Klass* k = _current_class_entry->klass(); + InstanceKlass* k = _current_class_entry->klass(); _current_class_entry = _current_class_entry->next(); return k; } @@ -371,15 +371,15 @@ // by the compilers. void Dictionary::add_klass(Symbol* class_name, ClassLoaderData* loader_data, - KlassHandle obj) { + InstanceKlass* obj) { assert_locked_or_safepoint(SystemDictionary_lock); - assert(obj() != NULL, "adding NULL obj"); - assert(obj()->name() == class_name, "sanity check on name"); + assert(obj != NULL, "adding NULL obj"); + assert(obj->name() == class_name, "sanity check on name"); assert(loader_data != NULL, "Must be non-NULL"); unsigned int hash = compute_hash(class_name, loader_data); int index = hash_to_index(hash); - DictionaryEntry* entry = new_entry(hash, obj(), loader_data); + DictionaryEntry* entry = new_entry(hash, obj, loader_data); add_entry(index, entry); } @@ -410,8 +410,8 @@ } -Klass* Dictionary::find(int index, unsigned int hash, Symbol* name, - ClassLoaderData* loader_data, Handle protection_domain, TRAPS) { +InstanceKlass* Dictionary::find(int index, unsigned int hash, Symbol* name, + ClassLoaderData* loader_data, Handle protection_domain, TRAPS) { DictionaryEntry* entry = get_entry(index, hash, name, loader_data); if (entry != NULL && entry->is_valid_protection_domain(protection_domain)) { return entry->klass(); @@ -421,30 +421,30 @@ } -Klass* Dictionary::find_class(int index, unsigned int hash, - Symbol* name, ClassLoaderData* loader_data) { +InstanceKlass* Dictionary::find_class(int index, unsigned int hash, + Symbol* name, ClassLoaderData* loader_data) { assert_locked_or_safepoint(SystemDictionary_lock); assert (index == index_for(name, loader_data), "incorrect index?"); DictionaryEntry* entry = get_entry(index, hash, name, loader_data); - return (entry != NULL) ? entry->klass() : (Klass*)NULL; + return (entry != NULL) ? entry->klass() : NULL; } // Variant of find_class for shared classes. No locking required, as // that table is static. -Klass* Dictionary::find_shared_class(int index, unsigned int hash, - Symbol* name) { +InstanceKlass* Dictionary::find_shared_class(int index, unsigned int hash, + Symbol* name) { assert (index == index_for(name, NULL), "incorrect index?"); DictionaryEntry* entry = get_entry(index, hash, name, NULL); - return (entry != NULL) ? entry->klass() : (Klass*)NULL; + return (entry != NULL) ? entry->klass() : NULL; } void Dictionary::add_protection_domain(int index, unsigned int hash, - instanceKlassHandle klass, + InstanceKlass* klass, ClassLoaderData* loader_data, Handle protection_domain, TRAPS) { Symbol* klass_name = klass->name();
--- a/hotspot/src/share/vm/classfile/dictionary.hpp Wed Mar 15 11:44:46 2017 +0100 +++ b/hotspot/src/share/vm/classfile/dictionary.hpp Wed Mar 15 10:25:37 2017 -0400 @@ -41,7 +41,7 @@ // The data structure for the system dictionary (and the shared system // dictionary). -class Dictionary : public TwoOopHashtable<Klass*, mtClass> { +class Dictionary : public TwoOopHashtable<InstanceKlass*, mtClass> { friend class VMStructs; private: // current iteration index. @@ -56,16 +56,16 @@ protected: DictionaryEntry* bucket(int i) const { - return (DictionaryEntry*)Hashtable<Klass*, mtClass>::bucket(i); + return (DictionaryEntry*)Hashtable<InstanceKlass*, mtClass>::bucket(i); } // The following method is not MT-safe and must be done under lock. DictionaryEntry** bucket_addr(int i) { - return (DictionaryEntry**)Hashtable<Klass*, mtClass>::bucket_addr(i); + return (DictionaryEntry**)Hashtable<InstanceKlass*, mtClass>::bucket_addr(i); } void add_entry(int index, DictionaryEntry* new_entry) { - Hashtable<Klass*, mtClass>::add_entry(index, (HashtableEntry<Klass*, mtClass>*)new_entry); + Hashtable<InstanceKlass*, mtClass>::add_entry(index, (HashtableEntry<InstanceKlass*, mtClass>*)new_entry); } static size_t entry_size(); @@ -73,21 +73,21 @@ Dictionary(int table_size); Dictionary(int table_size, HashtableBucket<mtClass>* t, int number_of_entries); - DictionaryEntry* new_entry(unsigned int hash, Klass* klass, ClassLoaderData* loader_data); + DictionaryEntry* new_entry(unsigned int hash, InstanceKlass* klass, ClassLoaderData* loader_data); DictionaryEntry* new_entry(); void free_entry(DictionaryEntry* entry); - void add_klass(Symbol* class_name, ClassLoaderData* loader_data,KlassHandle obj); + void add_klass(Symbol* class_name, ClassLoaderData* loader_data, InstanceKlass* obj); - Klass* find_class(int index, unsigned int hash, - Symbol* name, ClassLoaderData* loader_data); + InstanceKlass* find_class(int index, unsigned int hash, + Symbol* name, ClassLoaderData* loader_data); - Klass* find_shared_class(int index, unsigned int hash, Symbol* name); + InstanceKlass* find_shared_class(int index, unsigned int hash, Symbol* name); // Compiler support - Klass* try_get_next_class(); + InstanceKlass* try_get_next_class(); // GC support void oops_do(OopClosure* f); @@ -116,13 +116,13 @@ void do_unloading(); // Protection domains - Klass* find(int index, unsigned int hash, Symbol* name, - ClassLoaderData* loader_data, Handle protection_domain, TRAPS); + InstanceKlass* find(int index, unsigned int hash, Symbol* name, + ClassLoaderData* loader_data, Handle protection_domain, TRAPS); bool is_valid_protection_domain(int index, unsigned int hash, Symbol* name, ClassLoaderData* loader_data, Handle protection_domain); void add_protection_domain(int index, unsigned int hash, - instanceKlassHandle klass, ClassLoaderData* loader_data, + InstanceKlass* klass, ClassLoaderData* loader_data, Handle protection_domain, TRAPS); // Sharing support @@ -243,9 +243,9 @@ }; // An entry in the system dictionary, this describes a class as -// { Klass*, loader, protection_domain }. +// { InstanceKlass*, loader, protection_domain }. -class DictionaryEntry : public HashtableEntry<Klass*, mtClass> { +class DictionaryEntry : public HashtableEntry<InstanceKlass*, mtClass> { friend class VMStructs; private: // Contains the set of approved protection domains that can access @@ -277,15 +277,15 @@ // Adds a protection domain to the approved set. void add_protection_domain(Dictionary* dict, Handle protection_domain); - Klass* klass() const { return (Klass*)literal(); } - Klass** klass_addr() { return (Klass**)literal_addr(); } + InstanceKlass* klass() const { return (InstanceKlass*)literal(); } + InstanceKlass** klass_addr() { return (InstanceKlass**)literal_addr(); } DictionaryEntry* next() const { - return (DictionaryEntry*)HashtableEntry<Klass*, mtClass>::next(); + return (DictionaryEntry*)HashtableEntry<InstanceKlass*, mtClass>::next(); } DictionaryEntry** next_addr() { - return (DictionaryEntry**)HashtableEntry<Klass*, mtClass>::next_addr(); + return (DictionaryEntry**)HashtableEntry<InstanceKlass*, mtClass>::next_addr(); } ClassLoaderData* loader_data() const { return _loader_data; } @@ -323,7 +323,7 @@ } bool equals(const Symbol* class_name, ClassLoaderData* loader_data) const { - Klass* klass = (Klass*)literal(); + InstanceKlass* klass = (InstanceKlass*)literal(); return (klass->name() == class_name && _loader_data == loader_data); }
--- a/hotspot/src/share/vm/classfile/javaAssertions.cpp Wed Mar 15 11:44:46 2017 +0100 +++ b/hotspot/src/share/vm/classfile/javaAssertions.cpp Wed Mar 15 10:25:37 2017 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2017, 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 @@ -96,7 +96,7 @@ oop JavaAssertions::createAssertionStatusDirectives(TRAPS) { Symbol* asd_sym = vmSymbols::java_lang_AssertionStatusDirectives(); Klass* k = SystemDictionary::resolve_or_fail(asd_sym, true, CHECK_NULL); - instanceKlassHandle asd_klass (THREAD, k); + InstanceKlass* asd_klass = InstanceKlass::cast(k); asd_klass->initialize(CHECK_NULL); Handle h = asd_klass->allocate_instance_handle(CHECK_NULL);
--- a/hotspot/src/share/vm/classfile/javaClasses.cpp Wed Mar 15 11:44:46 2017 +0100 +++ b/hotspot/src/share/vm/classfile/javaClasses.cpp Wed Mar 15 10:25:37 2017 -0400 @@ -735,7 +735,7 @@ } -void java_lang_Class::fixup_mirror(KlassHandle k, TRAPS) { +void java_lang_Class::fixup_mirror(Klass* k, TRAPS) { assert(InstanceMirrorKlass::offset_of_static_fields() != 0, "must have been computed already"); // If the offset was read from the shared archive, it was fixed up already @@ -744,7 +744,7 @@ // During bootstrap, java.lang.Class wasn't loaded so static field // offsets were computed without the size added it. Go back and // update all the static field offsets to included the size. - for (JavaFieldStream fs(InstanceKlass::cast(k())); !fs.done(); fs.next()) { + for (JavaFieldStream fs(InstanceKlass::cast(k)); !fs.done(); fs.next()) { if (fs.access_flags().is_static()) { int real_offset = fs.offset() + InstanceMirrorKlass::offset_of_static_fields(); fs.set_offset(real_offset); @@ -755,7 +755,7 @@ create_mirror(k, Handle(), Handle(), Handle(), CHECK); } -void java_lang_Class::initialize_mirror_fields(KlassHandle k, +void java_lang_Class::initialize_mirror_fields(Klass* k, Handle mirror, Handle protection_domain, TRAPS) { @@ -769,11 +769,11 @@ set_protection_domain(mirror(), protection_domain()); // Initialize static fields - InstanceKlass::cast(k())->do_local_static_fields(&initialize_static_field, mirror, CHECK); + InstanceKlass::cast(k)->do_local_static_fields(&initialize_static_field, mirror, CHECK); } // Set the java.lang.reflect.Module module field in the java_lang_Class mirror -void java_lang_Class::set_mirror_module_field(KlassHandle k, Handle mirror, Handle module, TRAPS) { +void java_lang_Class::set_mirror_module_field(Klass* k, Handle mirror, Handle module, TRAPS) { if (module.is_null()) { // During startup, the module may be NULL only if java.base has not been defined yet. // Put the class on the fixup_module_list to patch later when the java.lang.reflect.Module @@ -791,7 +791,7 @@ set_fixup_module_field_list(list); } k->class_loader_data()->inc_keep_alive(); - fixup_module_field_list()->push(k()); + fixup_module_field_list()->push(k); } else { javabase_was_defined = true; } @@ -814,7 +814,7 @@ } } -void java_lang_Class::create_mirror(KlassHandle k, Handle class_loader, +void java_lang_Class::create_mirror(Klass* k, Handle class_loader, Handle module, Handle protection_domain, TRAPS) { assert(k->java_mirror() == NULL, "should only assign mirror once"); // Use this moment of initialization to cache modifier_flags also, @@ -831,8 +831,8 @@ Handle mirror(THREAD, mirror_oop); // Setup indirection from mirror->klass - if (!k.is_null()) { - java_lang_Class::set_klass(mirror(), k()); + if (k != NULL) { + java_lang_Class::set_klass(mirror(), k); } InstanceMirrorKlass* mk = InstanceMirrorKlass::cast(mirror->klass()); @@ -844,11 +844,11 @@ if (k->is_array_klass()) { oop comp_mirror; if (k->is_typeArray_klass()) { - BasicType type = TypeArrayKlass::cast(k())->element_type(); + BasicType type = TypeArrayKlass::cast(k)->element_type(); comp_mirror = Universe::java_mirror(type); } else { assert(k->is_objArray_klass(), "Must be"); - Klass* element_klass = ObjArrayKlass::cast(k())->element_klass(); + Klass* element_klass = ObjArrayKlass::cast(k)->element_klass(); assert(element_klass != NULL, "Must have an element klass"); comp_mirror = element_klass->java_mirror(); } @@ -857,7 +857,7 @@ // Two-way link between the array klass and its component mirror: // (array_klass) k -> mirror -> component_mirror -> array_klass -> k set_component_mirror(mirror(), comp_mirror); - set_array_klass(comp_mirror, k()); + set_array_klass(comp_mirror, k); } else { assert(k->is_instance_klass(), "Must be"); @@ -881,7 +881,7 @@ // Setup indirection from klass->mirror last // after any exceptions can happen during allocations. - if (!k.is_null()) { + if (k != NULL) { k->set_java_mirror(mirror()); } } else { @@ -890,11 +890,11 @@ new (ResourceObj::C_HEAP, mtClass) GrowableArray<Klass*>(40, true); set_fixup_mirror_list(list); } - fixup_mirror_list()->push(k()); + fixup_mirror_list()->push(k); } } -void java_lang_Class::fixup_module_field(KlassHandle k, Handle module) { +void java_lang_Class::fixup_module_field(Klass* k, Handle module) { assert(_module_offset != 0, "must have been computed already"); java_lang_Class::set_module(k->java_mirror(), module()); } @@ -1876,7 +1876,7 @@ JavaValue cause(T_OBJECT); JavaCalls::call_virtual(&cause, throwable, - KlassHandle(THREAD, throwable->klass()), + throwable->klass(), vmSymbols::getCause_name(), vmSymbols::void_throwable_signature(), THREAD); @@ -1904,7 +1904,7 @@ JavaValue result(T_VOID); JavaCalls::call_virtual(&result, throwable, - KlassHandle(THREAD, SystemDictionary::Throwable_klass()), + SystemDictionary::Throwable_klass(), vmSymbols::printStackTrace_name(), vmSymbols::void_method_signature(), THREAD); @@ -2153,14 +2153,13 @@ oop java_lang_StackTraceElement::create(const methodHandle& method, int bci, TRAPS) { // Allocate java.lang.StackTraceElement instance - Klass* k = SystemDictionary::StackTraceElement_klass(); + InstanceKlass* k = SystemDictionary::StackTraceElement_klass(); assert(k != NULL, "must be loaded in 1.4+"); - instanceKlassHandle ik (THREAD, k); - if (ik->should_be_initialized()) { - ik->initialize(CHECK_0); + if (k->should_be_initialized()) { + k->initialize(CHECK_0); } - Handle element = ik->allocate_instance_handle(CHECK_0); + Handle element = k->allocate_instance_handle(CHECK_0); int version = method->constants()->version(); fill_in(element, method->method_holder(), method, version, bci, method->name(), CHECK_0); @@ -2489,10 +2488,10 @@ assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem"); Symbol* name = vmSymbols::java_lang_reflect_Constructor(); Klass* k = SystemDictionary::resolve_or_fail(name, true, CHECK_NH); - instanceKlassHandle klass (THREAD, k); + InstanceKlass* ik = InstanceKlass::cast(k); // Ensure it is initialized - klass->initialize(CHECK_NH); - return klass->allocate_instance_handle(THREAD); + ik->initialize(CHECK_NH); + return ik->allocate_instance_handle(THREAD); } oop java_lang_reflect_Constructor::clazz(oop reflect) { @@ -2629,10 +2628,10 @@ assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem"); Symbol* name = vmSymbols::java_lang_reflect_Field(); Klass* k = SystemDictionary::resolve_or_fail(name, true, CHECK_NH); - instanceKlassHandle klass (THREAD, k); + InstanceKlass* ik = InstanceKlass::cast(k); // Ensure it is initialized - klass->initialize(CHECK_NH); - return klass->allocate_instance_handle(THREAD); + ik->initialize(CHECK_NH); + return ik->allocate_instance_handle(THREAD); } oop java_lang_reflect_Field::clazz(oop reflect) { @@ -2756,10 +2755,10 @@ assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem"); Symbol* name = vmSymbols::java_lang_reflect_Parameter(); Klass* k = SystemDictionary::resolve_or_fail(name, true, CHECK_NH); - instanceKlassHandle klass (THREAD, k); + InstanceKlass* ik = InstanceKlass::cast(k); // Ensure it is initialized - klass->initialize(CHECK_NH); - return klass->allocate_instance_handle(THREAD); + ik->initialize(CHECK_NH); + return ik->allocate_instance_handle(THREAD); } oop java_lang_reflect_Parameter::name(oop param) { @@ -2812,11 +2811,10 @@ Symbol* name = vmSymbols::java_lang_reflect_Module(); Klass* k = SystemDictionary::resolve_or_fail(name, true, CHECK_NH); - instanceKlassHandle klass (THREAD, k); - - Handle jlrmh = klass->allocate_instance_handle(CHECK_NH); + InstanceKlass* ik = InstanceKlass::cast(k); + Handle jlrmh = ik->allocate_instance_handle(CHECK_NH); JavaValue result(T_VOID); - JavaCalls::call_special(&result, jlrmh, KlassHandle(THREAD, klass()), + JavaCalls::call_special(&result, jlrmh, ik, vmSymbols::object_initializer_name(), vmSymbols::java_lang_reflect_module_init_signature(), loader, module_name, CHECK_NH); @@ -2879,11 +2877,10 @@ Handle reflect_ConstantPool::create(TRAPS) { assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem"); - Klass* k = SystemDictionary::reflect_ConstantPool_klass(); - instanceKlassHandle klass (THREAD, k); + InstanceKlass* k = SystemDictionary::reflect_ConstantPool_klass(); // Ensure it is initialized - klass->initialize(CHECK_NH); - return klass->allocate_instance_handle(THREAD); + k->initialize(CHECK_NH); + return k->allocate_instance_handle(THREAD); } @@ -2921,9 +2918,9 @@ oop java_lang_boxing_object::initialize_and_allocate(BasicType type, TRAPS) { Klass* k = SystemDictionary::box_klass(type); if (k == NULL) return NULL; - instanceKlassHandle h (THREAD, k); - if (!h->is_initialized()) h->initialize(CHECK_0); - return h->allocate_instance(THREAD); + InstanceKlass* ik = InstanceKlass::cast(k); + if (!ik->is_initialized()) ik->initialize(CHECK_0); + return ik->allocate_instance(THREAD); } @@ -3894,10 +3891,10 @@ fieldDescriptor fd; TempNewSymbol klass_sym = SymbolTable::new_symbol(klass_name, CATCH); Klass* k = SystemDictionary::resolve_or_fail(klass_sym, true, CATCH); - instanceKlassHandle h_klass (THREAD, k); + InstanceKlass* ik = InstanceKlass::cast(k); TempNewSymbol f_name = SymbolTable::new_symbol(field_name, CATCH); TempNewSymbol f_sig = SymbolTable::new_symbol(field_sig, CATCH); - if (!h_klass->find_local_field(f_name, f_sig, &fd)) { + if (!ik->find_local_field(f_name, f_sig, &fd)) { tty->print_cr("Nonstatic field %s.%s not found", klass_name, field_name); return false; } @@ -3920,10 +3917,10 @@ fieldDescriptor fd; TempNewSymbol klass_sym = SymbolTable::new_symbol(klass_name, CATCH); Klass* k = SystemDictionary::resolve_or_fail(klass_sym, true, CATCH); - instanceKlassHandle h_klass (THREAD, k); + InstanceKlass* ik = InstanceKlass::cast(k); TempNewSymbol f_name = SymbolTable::new_symbol(field_name, CATCH); TempNewSymbol f_sig = SymbolTable::new_symbol(field_sig, CATCH); - if (!h_klass->find_local_field(f_name, f_sig, &fd)) { + if (!ik->find_local_field(f_name, f_sig, &fd)) { tty->print_cr("Static field %s.%s not found", klass_name, field_name); return false; } @@ -3945,10 +3942,10 @@ fieldDescriptor fd; TempNewSymbol klass_sym = SymbolTable::new_symbol(klass_name, CATCH); Klass* k = SystemDictionary::resolve_or_fail(klass_sym, true, CATCH); - instanceKlassHandle h_klass (THREAD, k); + InstanceKlass* ik = InstanceKlass::cast(k); TempNewSymbol f_name = SymbolTable::new_symbol(field_name, CATCH); TempNewSymbol f_sig = SymbolTable::new_symbol(field_sig, CATCH); - if (!h_klass->find_local_field(f_name, f_sig, &fd)) { + if (!ik->find_local_field(f_name, f_sig, &fd)) { tty->print_cr("Static field %s.%s not found", klass_name, field_name); return false; }
--- a/hotspot/src/share/vm/classfile/javaClasses.hpp Wed Mar 15 11:44:46 2017 +0100 +++ b/hotspot/src/share/vm/classfile/javaClasses.hpp Wed Mar 15 10:25:37 2017 -0400 @@ -209,29 +209,23 @@ static void set_protection_domain(oop java_class, oop protection_domain); static void set_class_loader(oop java_class, oop class_loader); static void set_component_mirror(oop java_class, oop comp_mirror); - static void initialize_mirror_fields(KlassHandle k, Handle mirror, Handle protection_domain, TRAPS); - static void set_mirror_module_field(KlassHandle K, Handle mirror, Handle module, TRAPS); + static void initialize_mirror_fields(Klass* k, Handle mirror, Handle protection_domain, TRAPS); + static void set_mirror_module_field(Klass* K, Handle mirror, Handle module, TRAPS); public: static void compute_offsets(); // Instance creation - static void create_mirror(KlassHandle k, Handle class_loader, Handle module, + static void create_mirror(Klass* k, Handle class_loader, Handle module, Handle protection_domain, TRAPS); - static void fixup_mirror(KlassHandle k, TRAPS); + static void fixup_mirror(Klass* k, TRAPS); static oop create_basic_type_mirror(const char* basic_type_name, BasicType type, TRAPS); - static void fixup_module_field(KlassHandle k, Handle module); + static void fixup_module_field(Klass* k, Handle module); // Conversion static Klass* as_Klass(oop java_class); static void set_klass(oop java_class, Klass* klass); static BasicType as_BasicType(oop java_class, Klass** reference_klass = NULL); - static BasicType as_BasicType(oop java_class, KlassHandle* reference_klass) { - Klass* refk_oop = NULL; - BasicType result = as_BasicType(java_class, &refk_oop); - (*reference_klass) = KlassHandle(refk_oop); - return result; - } static Symbol* as_signature(oop java_class, bool intern_if_not_found, TRAPS); static void print_signature(oop java_class, outputStream *st); static const char* as_external_name(oop java_class);
--- a/hotspot/src/share/vm/classfile/klassFactory.cpp Wed Mar 15 11:44:46 2017 +0100 +++ b/hotspot/src/share/vm/classfile/klassFactory.cpp Wed Mar 15 10:25:37 2017 -0400 @@ -1,5 +1,5 @@ /* -* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. +* Copyright (c) 2015, 2017, 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 @@ -37,14 +37,14 @@ #include "trace/traceMacros.hpp" // called during initial loading of a shared class -instanceKlassHandle KlassFactory::check_shared_class_file_load_hook( - instanceKlassHandle ik, +InstanceKlass* KlassFactory::check_shared_class_file_load_hook( + InstanceKlass* ik, Symbol* class_name, Handle class_loader, Handle protection_domain, TRAPS) { #if INCLUDE_CDS && INCLUDE_JVMTI - assert(ik.not_null(), "sanity"); - assert(ik()->is_shared(), "expecting a shared class"); + assert(ik != NULL, "sanity"); + assert(ik->is_shared(), "expecting a shared class"); if (JvmtiExport::should_post_class_file_load_hook()) { assert(THREAD->is_Java_thread(), "must be JavaThread"); @@ -84,8 +84,8 @@ NULL, ClassFileParser::BROADCAST, // publicity level CHECK_NULL); - instanceKlassHandle new_ik = parser.create_instance_klass(true /* changed_by_loadhook */, - CHECK_NULL); + InstanceKlass* new_ik = parser.create_instance_klass(true /* changed_by_loadhook */, + CHECK_NULL); if (cached_class_file != NULL) { new_ik->set_cached_class_file(cached_class_file); } @@ -128,14 +128,11 @@ JvmtiThreadState* state = jt->jvmti_thread_state(); if (state != NULL) { - KlassHandle* h_class_being_redefined = - state->get_class_being_redefined(); + Klass* k = state->get_class_being_redefined(); - if (h_class_being_redefined != NULL) { - instanceKlassHandle ikh_class_being_redefined = - instanceKlassHandle(THREAD, (*h_class_being_redefined)()); - - *cached_class_file = ikh_class_being_redefined->get_cached_class_file(); + if (k != NULL) { + InstanceKlass* class_being_redefined = InstanceKlass::cast(k); + *cached_class_file = class_being_redefined->get_cached_class_file(); } } @@ -163,13 +160,13 @@ } -instanceKlassHandle KlassFactory::create_from_stream(ClassFileStream* stream, - Symbol* name, - ClassLoaderData* loader_data, - Handle protection_domain, - const InstanceKlass* host_klass, - GrowableArray<Handle>* cp_patches, - TRAPS) { +InstanceKlass* KlassFactory::create_from_stream(ClassFileStream* stream, + Symbol* name, + ClassLoaderData* loader_data, + Handle protection_domain, + const InstanceKlass* host_klass, + GrowableArray<Handle>* cp_patches, + TRAPS) { assert(stream != NULL, "invariant"); assert(loader_data != NULL, "invariant"); assert(THREAD->is_Java_thread(), "must be a JavaThread"); @@ -200,10 +197,10 @@ ClassFileParser::BROADCAST, // publicity level CHECK_NULL); - instanceKlassHandle result = parser.create_instance_klass(old_stream != stream, CHECK_NULL); + InstanceKlass* result = parser.create_instance_klass(old_stream != stream, CHECK_NULL); assert(result == parser.create_instance_klass(old_stream != stream, THREAD), "invariant"); - if (result.is_null()) { + if (result == NULL) { return NULL; }
--- a/hotspot/src/share/vm/classfile/klassFactory.hpp Wed Mar 15 11:44:46 2017 +0100 +++ b/hotspot/src/share/vm/classfile/klassFactory.hpp Wed Mar 15 10:25:37 2017 -0400 @@ -1,5 +1,5 @@ /* -* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. +* Copyright (c) 2015, 2017, 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 @@ -68,16 +68,16 @@ friend class SystemDictionary; private: - static instanceKlassHandle create_from_stream(ClassFileStream* stream, - Symbol* name, - ClassLoaderData* loader_data, - Handle protection_domain, - const InstanceKlass* host_klass, - GrowableArray<Handle>* cp_patches, - TRAPS); + static InstanceKlass* create_from_stream(ClassFileStream* stream, + Symbol* name, + ClassLoaderData* loader_data, + Handle protection_domain, + const InstanceKlass* host_klass, + GrowableArray<Handle>* cp_patches, + TRAPS); public: - static instanceKlassHandle check_shared_class_file_load_hook( - instanceKlassHandle ik, + static InstanceKlass* check_shared_class_file_load_hook( + InstanceKlass* ik, Symbol* class_name, Handle class_loader, Handle protection_domain, TRAPS);
--- a/hotspot/src/share/vm/classfile/loaderConstraints.cpp Wed Mar 15 11:44:46 2017 +0100 +++ b/hotspot/src/share/vm/classfile/loaderConstraints.cpp Wed Mar 15 10:25:37 2017 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2017, 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 @@ -36,15 +36,15 @@ } LoaderConstraintTable::LoaderConstraintTable(int nof_buckets) - : Hashtable<Klass*, mtClass>(nof_buckets, sizeof(LoaderConstraintEntry)) {}; + : Hashtable<InstanceKlass*, mtClass>(nof_buckets, sizeof(LoaderConstraintEntry)) {}; LoaderConstraintEntry* LoaderConstraintTable::new_entry( unsigned int hash, Symbol* name, - Klass* klass, int num_loaders, + InstanceKlass* klass, int num_loaders, int max_loaders) { LoaderConstraintEntry* entry; - entry = (LoaderConstraintEntry*)Hashtable<Klass*, mtClass>::new_entry(hash, klass); + entry = (LoaderConstraintEntry*)Hashtable<InstanceKlass*, mtClass>::new_entry(hash, klass); entry->set_name(name); entry->set_num_loaders(num_loaders); entry->set_max_loaders(max_loaders); @@ -54,7 +54,7 @@ void LoaderConstraintTable::free_entry(LoaderConstraintEntry *entry) { // decrement name refcount before freeing entry->name()->decrement_refcount(); - Hashtable<Klass*, mtClass>::free_entry(entry); + Hashtable<InstanceKlass*, mtClass>::free_entry(entry); } // Enhanced Class Redefinition support @@ -106,7 +106,7 @@ LoaderConstraintEntry** p = bucket_addr(index); while(*p) { LoaderConstraintEntry* probe = *p; - Klass* klass = probe->klass(); + InstanceKlass* klass = probe->klass(); // Remove klass that is no longer alive if (klass != NULL && klass->class_loader_data()->is_unloading()) { @@ -186,14 +186,14 @@ } bool LoaderConstraintTable::add_entry(Symbol* class_name, - Klass* klass1, Handle class_loader1, - Klass* klass2, Handle class_loader2) { + InstanceKlass* klass1, Handle class_loader1, + InstanceKlass* klass2, Handle class_loader2) { int failure_code = 0; // encode different reasons for failing if (klass1 != NULL && klass2 != NULL && klass1 != klass2) { failure_code = 1; } else { - Klass* klass = klass1 != NULL ? klass1 : klass2; + InstanceKlass* klass = klass1 != NULL ? klass1 : klass2; LoaderConstraintEntry** pp1 = find_loader_constraint(class_name, class_loader1); @@ -295,11 +295,11 @@ // return true if the constraint was updated, false if the constraint is // violated -bool LoaderConstraintTable::check_or_update(instanceKlassHandle k, - Handle loader, - Symbol* name) { +bool LoaderConstraintTable::check_or_update(InstanceKlass* k, + Handle loader, + Symbol* name) { LoaderConstraintEntry* p = *(find_loader_constraint(name, loader)); - if (p && p->klass() != NULL && p->klass() != k()) { + if (p && p->klass() != NULL && p->klass() != k) { if (log_is_enabled(Info, class, loader, constraints)) { ResourceMark rm; outputStream* out = Log(class, loader, constraints)::info_stream(); @@ -311,7 +311,7 @@ return false; } else { if (p && p->klass() == NULL) { - p->set_klass(k()); + p->set_klass(k); if (log_is_enabled(Info, class, loader, constraints)) { ResourceMark rm; outputStream* out = Log(class, loader, constraints)::info_stream(); @@ -325,11 +325,12 @@ } } -Klass* LoaderConstraintTable::find_constrained_klass(Symbol* name, +InstanceKlass* LoaderConstraintTable::find_constrained_klass(Symbol* name, Handle loader) { LoaderConstraintEntry *p = *(find_loader_constraint(name, loader)); if (p != NULL && p->klass() != NULL) { - if (p->klass()->is_instance_klass() && !InstanceKlass::cast(p->klass())->is_loaded()) { + assert(p->klass()->is_instance_klass(), "sanity"); + if (p->klass()->is_loaded()) { // Only return fully loaded classes. Classes found through the // constraints might still be in the process of loading. return NULL; @@ -357,7 +358,7 @@ void LoaderConstraintTable::extend_loader_constraint(LoaderConstraintEntry* p, Handle loader, - Klass* klass) { + InstanceKlass* klass) { ensure_loader_constraint_capacity(p, 1); int num = p->num_loaders(); p->set_loader(num, loader()); @@ -383,7 +384,7 @@ void LoaderConstraintTable::merge_loader_constraints( LoaderConstraintEntry** pp1, LoaderConstraintEntry** pp2, - Klass* klass) { + InstanceKlass* klass) { // make sure *pp1 has higher capacity if ((*pp1)->max_loaders() < (*pp2)->max_loaders()) { LoaderConstraintEntry** tmp = pp2; @@ -447,13 +448,13 @@ probe != NULL; probe = probe->next()) { if (probe->klass() != NULL) { - InstanceKlass* ik = InstanceKlass::cast(probe->klass()); + InstanceKlass* ik = probe->klass(); guarantee(ik->name() == probe->name(), "name should match"); Symbol* name = ik->name(); ClassLoaderData* loader_data = ik->class_loader_data(); unsigned int d_hash = dictionary->compute_hash(name, loader_data); int d_index = dictionary->hash_to_index(d_hash); - Klass* k = dictionary->find_class(d_index, d_hash, name, loader_data); + InstanceKlass* k = dictionary->find_class(d_index, d_hash, name, loader_data); if (k != NULL) { // We found the class in the system dictionary, so we should // make sure that the Klass* matches what we already have.
--- a/hotspot/src/share/vm/classfile/loaderConstraints.hpp Wed Mar 15 11:44:46 2017 +0100 +++ b/hotspot/src/share/vm/classfile/loaderConstraints.hpp Wed Mar 15 10:25:37 2017 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2017, 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,7 +32,7 @@ class LoaderConstraintEntry; class Symbol; -class LoaderConstraintTable : public Hashtable<Klass*, mtClass> { +class LoaderConstraintTable : public Hashtable<InstanceKlass*, mtClass> { friend class VMStructs; private: @@ -49,43 +49,41 @@ LoaderConstraintTable(int nof_buckets); LoaderConstraintEntry* new_entry(unsigned int hash, Symbol* name, - Klass* klass, int num_loaders, + InstanceKlass* klass, int num_loaders, int max_loaders); void free_entry(LoaderConstraintEntry *entry); LoaderConstraintEntry* bucket(int i) { - return (LoaderConstraintEntry*)Hashtable<Klass*, mtClass>::bucket(i); + return (LoaderConstraintEntry*)Hashtable<InstanceKlass*, mtClass>::bucket(i); } LoaderConstraintEntry** bucket_addr(int i) { - return (LoaderConstraintEntry**)Hashtable<Klass*, mtClass>::bucket_addr(i); + return (LoaderConstraintEntry**)Hashtable<InstanceKlass*, mtClass>::bucket_addr(i); } // Enhanced Class Redefinition support void classes_do(KlassClosure* f); // Check class loader constraints - bool add_entry(Symbol* name, Klass* klass1, Handle loader1, - Klass* klass2, Handle loader2); + bool add_entry(Symbol* name, InstanceKlass* klass1, Handle loader1, + InstanceKlass* klass2, Handle loader2); // Note: The main entry point for this module is via SystemDictionary. // SystemDictionary::check_signature_loaders(Symbol* signature, // Handle loader1, Handle loader2, // bool is_method, TRAPS) - Klass* find_constrained_klass(Symbol* name, Handle loader); + InstanceKlass* find_constrained_klass(Symbol* name, Handle loader); // Class loader constraints void ensure_loader_constraint_capacity(LoaderConstraintEntry *p, int nfree); void extend_loader_constraint(LoaderConstraintEntry* p, Handle loader, - Klass* klass); + InstanceKlass* klass); void merge_loader_constraints(LoaderConstraintEntry** pp1, - LoaderConstraintEntry** pp2, Klass* klass); + LoaderConstraintEntry** pp2, InstanceKlass* klass); - bool check_or_update(instanceKlassHandle k, Handle loader, - Symbol* name); - + bool check_or_update(InstanceKlass* k, Handle loader, Symbol* name); void purge_loader_constraints(); @@ -95,7 +93,7 @@ #endif }; -class LoaderConstraintEntry : public HashtableEntry<Klass*, mtClass> { +class LoaderConstraintEntry : public HashtableEntry<InstanceKlass*, mtClass> { friend class VMStructs; private: Symbol* _name; // class name @@ -108,19 +106,19 @@ public: - Klass* klass() { return literal(); } - Klass** klass_addr() { return literal_addr(); } - void set_klass(Klass* k) { set_literal(k); } + InstanceKlass* klass() { return literal(); } + InstanceKlass** klass_addr() { return literal_addr(); } + void set_klass(InstanceKlass* k) { set_literal(k); } LoaderConstraintEntry* next() { - return (LoaderConstraintEntry*)HashtableEntry<Klass*, mtClass>::next(); + return (LoaderConstraintEntry*)HashtableEntry<InstanceKlass*, mtClass>::next(); } LoaderConstraintEntry** next_addr() { - return (LoaderConstraintEntry**)HashtableEntry<Klass*, mtClass>::next_addr(); + return (LoaderConstraintEntry**)HashtableEntry<InstanceKlass*, mtClass>::next_addr(); } void set_next(LoaderConstraintEntry* next) { - HashtableEntry<Klass*, mtClass>::set_next(next); + HashtableEntry<InstanceKlass*, mtClass>::set_next(next); } Symbol* name() { return _name; }
--- a/hotspot/src/share/vm/classfile/moduleEntry.cpp Wed Mar 15 11:44:46 2017 +0100 +++ b/hotspot/src/share/vm/classfile/moduleEntry.cpp Wed Mar 15 10:25:37 2017 -0400 @@ -428,7 +428,7 @@ for (int i = 0; i < list_length; i++) { Klass* k = list->at(i); assert(k->is_klass(), "List should only hold classes"); - java_lang_Class::fixup_module_field(KlassHandle(k), module_handle); + java_lang_Class::fixup_module_field(k, module_handle); k->class_loader_data()->dec_keep_alive(); }
--- a/hotspot/src/share/vm/classfile/placeholders.hpp Wed Mar 15 11:44:46 2017 +0100 +++ b/hotspot/src/share/vm/classfile/placeholders.hpp Wed Mar 15 10:25:37 2017 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2017, 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 @@ -163,7 +163,7 @@ bool _havesupername; // distinguish between null supername, and unknown Symbol* _supername; Thread* _definer; // owner of define token - Klass* _instanceKlass; // InstanceKlass from successful define + InstanceKlass* _instanceKlass; // InstanceKlass from successful define SeenThread* _superThreadQ; // doubly-linked queue of Threads loading a superclass for this class SeenThread* _loadInstanceThreadQ; // loadInstance thread // can be multiple threads if classloader object lock broken by application @@ -193,8 +193,8 @@ Thread* definer() const {return _definer; } void set_definer(Thread* definer) { _definer = definer; } - Klass* instance_klass() const {return _instanceKlass; } - void set_instance_klass(Klass* ik) { _instanceKlass = ik; } + InstanceKlass* instance_klass() const {return _instanceKlass; } + void set_instance_klass(InstanceKlass* ik) { _instanceKlass = ik; } SeenThread* superThreadQ() const { return _superThreadQ; } void set_superThreadQ(SeenThread* SeenThread) { _superThreadQ = SeenThread; }
--- a/hotspot/src/share/vm/classfile/systemDictionary.cpp Wed Mar 15 11:44:46 2017 +0100 +++ b/hotspot/src/share/vm/classfile/systemDictionary.cpp Wed Mar 15 10:25:37 2017 -0400 @@ -120,10 +120,10 @@ } void SystemDictionary::compute_java_system_loader(TRAPS) { - KlassHandle system_klass(THREAD, WK_KLASS(ClassLoader_klass)); + Klass* system_klass = WK_KLASS(ClassLoader_klass); JavaValue result(T_OBJECT); JavaCalls::call_static(&result, - KlassHandle(THREAD, WK_KLASS(ClassLoader_klass)), + WK_KLASS(ClassLoader_klass), vmSymbols::getSystemClassLoader_name(), vmSymbols::void_classloader_signature(), CHECK); @@ -184,16 +184,15 @@ Klass* SystemDictionary::resolve_or_fail(Symbol* class_name, Handle class_loader, Handle protection_domain, bool throw_error, TRAPS) { Klass* klass = resolve_or_null(class_name, class_loader, protection_domain, THREAD); if (HAS_PENDING_EXCEPTION || klass == NULL) { - KlassHandle k_h(THREAD, klass); // can return a null klass - klass = handle_resolution_exception(class_name, throw_error, k_h, THREAD); + klass = handle_resolution_exception(class_name, throw_error, klass, THREAD); } return klass; } Klass* SystemDictionary::handle_resolution_exception(Symbol* class_name, bool throw_error, - KlassHandle klass_h, TRAPS) { + Klass* klass, TRAPS) { if (HAS_PENDING_EXCEPTION) { // If we have a pending exception we forward it to the caller, unless throw_error is true, // in which case we have to check whether the pending exception is a ClassNotFoundException, @@ -201,7 +200,7 @@ // And chain the original ClassNotFoundException if (throw_error && PENDING_EXCEPTION->is_a(SystemDictionary::ClassNotFoundException_klass())) { ResourceMark rm(THREAD); - assert(klass_h() == NULL, "Should not have result with exception pending"); + assert(klass == NULL, "Should not have result with exception pending"); Handle e(THREAD, PENDING_EXCEPTION); CLEAR_PENDING_EXCEPTION; THROW_MSG_CAUSE_NULL(vmSymbols::java_lang_NoClassDefFoundError(), class_name->as_C_string(), e); @@ -210,7 +209,7 @@ } } // Class not found, throw appropriate error or exception depending on value of throw_error - if (klass_h() == NULL) { + if (klass == NULL) { ResourceMark rm(THREAD); if (throw_error) { THROW_MSG_NULL(vmSymbols::java_lang_NoClassDefFoundError(), class_name->as_C_string()); @@ -218,7 +217,7 @@ THROW_MSG_NULL(vmSymbols::java_lang_ClassNotFoundException(), class_name->as_C_string()); } } - return (Klass*)klass_h(); + return klass; } @@ -256,9 +255,9 @@ // Forwards to resolve_instance_class_or_null Klass* SystemDictionary::resolve_array_class_or_null(Symbol* class_name, - Handle class_loader, - Handle protection_domain, - TRAPS) { + Handle class_loader, + Handle protection_domain, + TRAPS) { assert(FieldType::is_array(class_name), "must be array"); Klass* k = NULL; FieldArrayInfo fd; @@ -398,11 +397,9 @@ assert(class_name != NULL, "null super class for resolving"); // Resolve the super class or interface, check results on return Klass* superk = SystemDictionary::resolve_or_null(class_name, - class_loader, - protection_domain, - THREAD); - - KlassHandle superk_h(THREAD, superk); + class_loader, + protection_domain, + THREAD); // Clean up of placeholders moved so that each classloadAction registrar self-cleans up // It is no longer necessary to keep the placeholder table alive until update_dictionary @@ -415,15 +412,15 @@ placeholders()->find_and_remove(p_index, p_hash, child_name, loader_data, PlaceholderTable::LOAD_SUPER, THREAD); SystemDictionary_lock->notify_all(); } - if (HAS_PENDING_EXCEPTION || superk_h() == NULL) { + if (HAS_PENDING_EXCEPTION || superk == NULL) { // can null superk - superk_h = KlassHandle(THREAD, handle_resolution_exception(class_name, true, superk_h, THREAD)); + superk = handle_resolution_exception(class_name, true, superk, THREAD); } - return superk_h(); + return superk; } -void SystemDictionary::validate_protection_domain(instanceKlassHandle klass, +void SystemDictionary::validate_protection_domain(InstanceKlass* klass, Handle class_loader, Handle protection_domain, TRAPS) { @@ -438,11 +435,11 @@ log->print_cr("Checking package access"); log->print("class loader: "); class_loader()->print_value_on(log); log->print(" protection domain: "); protection_domain()->print_value_on(log); - log->print(" loading: "); klass()->print_value_on(log); + log->print(" loading: "); klass->print_value_on(log); log->cr(); } - KlassHandle system_loader(THREAD, SystemDictionary::ClassLoader_klass()); + InstanceKlass* system_loader = SystemDictionary::ClassLoader_klass(); JavaCalls::call_special(&result, class_loader, system_loader, @@ -540,11 +537,10 @@ // Returns non-null Klass* if other thread has completed load // and we are done, // If return null Klass* and no pending exception, the caller must load the class -instanceKlassHandle SystemDictionary::handle_parallel_super_load( +InstanceKlass* SystemDictionary::handle_parallel_super_load( Symbol* name, Symbol* superclassname, Handle class_loader, Handle protection_domain, Handle lockObject, TRAPS) { - instanceKlassHandle nh = instanceKlassHandle(); // null Handle ClassLoaderData* loader_data = class_loader_data(class_loader); unsigned int d_hash = dictionary()->compute_hash(name, loader_data); int d_index = dictionary()->hash_to_index(d_hash); @@ -564,20 +560,14 @@ class_loader, protection_domain, true, - CHECK_(nh)); + CHECK_NULL); // parallelCapable class loaders do NOT wait for parallel superclass loads to complete // Serial class loaders and bootstrap classloader do wait for superclass loads if (!class_loader.is_null() && is_parallelCapable(class_loader)) { MutexLocker mu(SystemDictionary_lock, THREAD); // Check if classloading completed while we were loading superclass or waiting - Klass* check = find_class(d_index, d_hash, name, loader_data); - if (check != NULL) { - // Klass is already loaded, so just return it - return(instanceKlassHandle(THREAD, check)); - } else { - return nh; - } + return find_class(d_index, d_hash, name, loader_data); } // must loop to both handle other placeholder updates @@ -587,10 +577,10 @@ while (super_load_in_progress) { MutexLocker mu(SystemDictionary_lock, THREAD); // Check if classloading completed while we were loading superclass or waiting - Klass* check = find_class(d_index, d_hash, name, loader_data); + InstanceKlass* check = find_class(d_index, d_hash, name, loader_data); if (check != NULL) { // Klass is already loaded, so just return it - return(instanceKlassHandle(THREAD, check)); + return check; } else { placeholder = placeholders()->get_entry(p_index, p_hash, name, loader_data); if (placeholder && placeholder->super_load_in_progress() ){ @@ -619,17 +609,17 @@ } } } - return (nh); + return NULL; } static void post_class_load_event(const Ticks& start_time, - instanceKlassHandle k, + InstanceKlass* k, const ClassLoaderData* init_cld) { #if INCLUDE_TRACE EventClassLoad event(UNTIMED); if (event.should_commit()) { event.set_starttime(start_time); - event.set_loadedClass(k()); + event.set_loadedClass(k); event.set_definingClassLoader(k->class_loader_data()); event.set_initiatingClassLoader(init_cld); event.commit(); @@ -637,12 +627,12 @@ #endif // INCLUDE_TRACE } -static void class_define_event(instanceKlassHandle k, +static void class_define_event(InstanceKlass* k, const ClassLoaderData* def_cld) { #if INCLUDE_TRACE EventClassDefine event; if (event.should_commit()) { - event.set_definedClass(k()); + event.set_definedClass(k); event.set_definingClassLoader(def_cld); event.commit(); } @@ -708,17 +698,17 @@ bool class_has_been_loaded = false; bool super_load_in_progress = false; bool havesupername = false; - instanceKlassHandle k; + InstanceKlass* k = NULL; PlaceholderEntry* placeholder; Symbol* superclassname = NULL; { MutexLocker mu(SystemDictionary_lock, THREAD); - Klass* check = find_class(d_index, d_hash, name, loader_data); + InstanceKlass* check = find_class(d_index, d_hash, name, loader_data); if (check != NULL) { // Klass is already loaded, so just return it class_has_been_loaded = true; - k = instanceKlassHandle(THREAD, check); + k = check; } else { placeholder = placeholders()->get_entry(p_index, p_hash, name, loader_data); if (placeholder && placeholder->super_load_in_progress()) { @@ -733,12 +723,15 @@ // If the class is in the placeholder table, class loading is in progress if (super_load_in_progress && havesupername==true) { - k = SystemDictionary::handle_parallel_super_load(name, superclassname, - class_loader, protection_domain, lockObject, THREAD); + k = handle_parallel_super_load(name, + superclassname, + class_loader, + protection_domain, + lockObject, THREAD); if (HAS_PENDING_EXCEPTION) { return NULL; } - if (!k.is_null()) { + if (k != NULL) { class_has_been_loaded = true; } } @@ -795,10 +788,10 @@ double_lock_wait(lockObject, THREAD); } // Check if classloading completed while we were waiting - Klass* check = find_class(d_index, d_hash, name, loader_data); + InstanceKlass* check = find_class(d_index, d_hash, name, loader_data); if (check != NULL) { // Klass is already loaded, so just return it - k = instanceKlassHandle(THREAD, check); + k = check; class_has_been_loaded = true; } // check if other thread failed to load and cleaned up @@ -820,10 +813,10 @@ // i.e. now that we hold the LOAD_INSTANCE token on loading this class/CL // one final check if the load has already completed // class loaders holding the ObjectLock shouldn't find the class here - Klass* check = find_class(d_index, d_hash, name, loader_data); + InstanceKlass* check = find_class(d_index, d_hash, name, loader_data); if (check != NULL) { // Klass is already loaded, so return it after checking/adding protection domain - k = instanceKlassHandle(THREAD, check); + k = check; class_has_been_loaded = true; } } @@ -850,13 +843,13 @@ // with the new cleaner mechanism, even with AllowParallelDefineClass // Bootstrap goes through here to allow for an extra guarantee check if (UnsyncloadClass || (class_loader.is_null())) { - if (k.is_null() && HAS_PENDING_EXCEPTION + if (k == NULL && HAS_PENDING_EXCEPTION && PENDING_EXCEPTION->is_a(SystemDictionary::LinkageError_klass())) { MutexLocker mu(SystemDictionary_lock, THREAD); - Klass* check = find_class(d_index, d_hash, name, loader_data); + InstanceKlass* check = find_class(d_index, d_hash, name, loader_data); if (check != NULL) { // Klass is already loaded, so just use it - k = instanceKlassHandle(THREAD, check); + k = check; CLEAR_PENDING_EXCEPTION; guarantee((!class_loader.is_null()), "dup definition for bootstrap loader?"); } @@ -865,7 +858,7 @@ // If everything was OK (no exceptions, no null return value), and // class_loader is NOT the defining loader, do a little more bookkeeping. - if (!HAS_PENDING_EXCEPTION && !k.is_null() && + if (!HAS_PENDING_EXCEPTION && k != NULL && k->class_loader() != class_loader()) { check_constraints(d_index, d_hash, k, class_loader, false, THREAD); @@ -883,7 +876,7 @@ if (JvmtiExport::should_post_class_load()) { Thread *thread = THREAD; assert(thread->is_Java_thread(), "thread->is_Java_thread()"); - JvmtiExport::post_class_load((JavaThread *) thread, k()); + JvmtiExport::post_class_load((JavaThread *) thread, k); } } } @@ -899,7 +892,7 @@ } } - if (HAS_PENDING_EXCEPTION || k.is_null()) { + if (HAS_PENDING_EXCEPTION || k == NULL) { return NULL; } @@ -910,12 +903,12 @@ ClassLoaderData* loader_data = k->class_loader_data(); MutexLocker mu(SystemDictionary_lock, THREAD); Klass* kk = find_class(name, loader_data); - assert(kk == k(), "should be present in dictionary"); + assert(kk == k, "should be present in dictionary"); } #endif // return if the protection domain in NULL - if (protection_domain() == NULL) return k(); + if (protection_domain() == NULL) return k; // Check the protection domain has the right access { @@ -930,14 +923,14 @@ if (dictionary()->is_valid_protection_domain(d_index, d_hash, name, loader_data, protection_domain)) { - return k(); + return k; } } // Verify protection domain. If it fails an exception is thrown validate_protection_domain(k, class_loader, protection_domain, CHECK_NULL); - return k(); + return k; } @@ -1019,13 +1012,13 @@ // does not publish the classes via the SystemDictionary. // Handles unsafe_DefineAnonymousClass and redefineclasses // RedefinedClasses do not add to the class hierarchy -Klass* SystemDictionary::parse_stream(Symbol* class_name, - Handle class_loader, - Handle protection_domain, - ClassFileStream* st, - const InstanceKlass* host_klass, - GrowableArray<Handle>* cp_patches, - TRAPS) { +InstanceKlass* SystemDictionary::parse_stream(Symbol* class_name, + Handle class_loader, + Handle protection_domain, + ClassFileStream* st, + const InstanceKlass* host_klass, + GrowableArray<Handle>* cp_patches, + TRAPS) { Ticks class_load_start_time = Ticks::now(); @@ -1049,15 +1042,15 @@ // already be present in the SystemDictionary, otherwise we would not // throw potential ClassFormatErrors. - instanceKlassHandle k = KlassFactory::create_from_stream(st, - class_name, - loader_data, - protection_domain, - host_klass, - cp_patches, - CHECK_NULL); - - if (host_klass != NULL && k.not_null()) { + InstanceKlass* k = KlassFactory::create_from_stream(st, + class_name, + loader_data, + protection_domain, + host_klass, + cp_patches, + CHECK_NULL); + + if (host_klass != NULL && k != NULL) { // If it's anonymous, initialize it now, since nobody else will. { @@ -1083,7 +1076,7 @@ // notify jvmti if (JvmtiExport::should_post_class_load()) { assert(THREAD->is_Java_thread(), "thread->is_Java_thread()"); - JvmtiExport::post_class_load((JavaThread *) THREAD, k()); + JvmtiExport::post_class_load((JavaThread *) THREAD, k); } post_class_load_event(class_load_start_time, k, loader_data); @@ -1091,7 +1084,7 @@ assert(host_klass != NULL || NULL == cp_patches, "cp_patches only found with host_klass"); - return k(); + return k; } // Add a klass to the system from a stream (called by jni_DefineClass and @@ -1099,11 +1092,11 @@ // Note: class_name can be NULL. In that case we do not know the name of // the class until we have parsed the stream. -Klass* SystemDictionary::resolve_from_stream(Symbol* class_name, - Handle class_loader, - Handle protection_domain, - ClassFileStream* st, - TRAPS) { +InstanceKlass* SystemDictionary::resolve_from_stream(Symbol* class_name, + Handle class_loader, + Handle protection_domain, + ClassFileStream* st, + TRAPS) { HandleMark hm(THREAD); @@ -1127,9 +1120,7 @@ // Note that we do this even though this klass might // already be present in the SystemDictionary, otherwise we would not // throw potential ClassFormatErrors. - // - - instanceKlassHandle k; + InstanceKlass* k = NULL; #if INCLUDE_CDS k = SystemDictionaryShared::lookup_from_stream(class_name, @@ -1139,7 +1130,7 @@ CHECK_NULL); #endif - if (k.is_null()) { + if (k == NULL) { if (st->buffer() == NULL) { return NULL; } @@ -1152,7 +1143,7 @@ CHECK_NULL); } - assert(k.not_null(), "no klass created"); + assert(k != NULL, "no klass created"); Symbol* h_name = k->name(); assert(class_name == NULL || class_name == h_name, "name mismatch"); @@ -1160,11 +1151,11 @@ // If a class loader supports parallel classloading handle parallel define requests // find_or_define_instance_class may return a different InstanceKlass if (is_parallelCapable(class_loader)) { - instanceKlassHandle defined_k = find_or_define_instance_class(h_name, class_loader, k, THREAD); - if (!HAS_PENDING_EXCEPTION && defined_k() != k()) { + InstanceKlass* defined_k = find_or_define_instance_class(h_name, class_loader, k, THREAD); + if (!HAS_PENDING_EXCEPTION && defined_k != k) { // If a parallel capable class loader already defined this class, register 'k' for cleanup. - assert(defined_k.not_null(), "Should have a klass if there's no exception"); - loader_data->add_to_deallocate_list(k()); + assert(defined_k != NULL, "Should have a klass if there's no exception"); + loader_data->add_to_deallocate_list(k); k = defined_k; } } else { @@ -1173,8 +1164,8 @@ // If defining the class throws an exception register 'k' for cleanup. if (HAS_PENDING_EXCEPTION) { - assert(k.not_null(), "Must have an instance klass here!"); - loader_data->add_to_deallocate_list(k()); + assert(k != NULL, "Must have an instance klass here!"); + loader_data->add_to_deallocate_list(k); return NULL; } @@ -1183,10 +1174,10 @@ MutexLocker mu(SystemDictionary_lock, THREAD); Klass* check = find_class(h_name, k->class_loader_data()); - assert(check == k(), "should be present in the dictionary"); + assert(check == k, "should be present in the dictionary"); } ); - return k(); + return k; } #if INCLUDE_CDS @@ -1201,7 +1192,7 @@ // If there is a shared dictionary, then find the entry for the // given shared system class, if any. -Klass* SystemDictionary::find_shared_class(Symbol* class_name) { +InstanceKlass* SystemDictionary::find_shared_class(Symbol* class_name) { if (shared_dictionary() != NULL) { unsigned int d_hash = shared_dictionary()->compute_hash(class_name, NULL); int d_index = shared_dictionary()->hash_to_index(d_hash); @@ -1219,16 +1210,16 @@ // subclasses (yet). [Classes in the shared space are not part of the // object hierarchy until loaded.] -instanceKlassHandle SystemDictionary::load_shared_class( +InstanceKlass* SystemDictionary::load_shared_class( Symbol* class_name, Handle class_loader, TRAPS) { - instanceKlassHandle ik (THREAD, find_shared_class(class_name)); + InstanceKlass* ik = find_shared_class(class_name); // Make sure we only return the boot class for the NULL classloader. - if (ik.not_null() && + if (ik != NULL && ik->is_shared_boot_class() && class_loader.is_null()) { Handle protection_domain; return load_shared_class(ik, class_loader, protection_domain, THREAD); } - return instanceKlassHandle(); + return NULL; } // Check if a shared class can be loaded by the specific classloader: @@ -1238,7 +1229,7 @@ // - Class from -Xbootclasspath/a. The class has no defined PackageEntry, or must // be defined in an unnamed module. bool SystemDictionary::is_shared_class_visible(Symbol* class_name, - instanceKlassHandle ik, + InstanceKlass* ik, Handle class_loader, TRAPS) { assert(!ModuleEntryTable::javabase_moduleEntry()->is_patched(), "Cannot use sharing if java.base is patched"); @@ -1315,18 +1306,17 @@ } } -instanceKlassHandle SystemDictionary::load_shared_class(instanceKlassHandle ik, - Handle class_loader, - Handle protection_domain, TRAPS) { - instanceKlassHandle nh = instanceKlassHandle(); // null Handle - - if (ik.not_null()) { +InstanceKlass* SystemDictionary::load_shared_class(InstanceKlass* ik, + Handle class_loader, + Handle protection_domain, TRAPS) { + + if (ik != NULL) { Symbol* class_name = ik->name(); bool visible = is_shared_class_visible( - class_name, ik, class_loader, CHECK_(nh)); + class_name, ik, class_loader, CHECK_NULL); if (!visible) { - return nh; + return NULL; } // Resolve the superclass and interfaces. They must be the same @@ -1339,11 +1329,11 @@ if (ik->super() != NULL) { Symbol* cn = ik->super()->name(); Klass *s = resolve_super_or_fail(class_name, cn, - class_loader, protection_domain, true, CHECK_(nh)); + class_loader, protection_domain, true, CHECK_NULL); if (s != ik->super()) { // The dynamically resolved super class is not the same as the one we used during dump time, // so we cannot use ik. - return nh; + return NULL; } else { assert(s->is_shared(), "must be"); } @@ -1354,19 +1344,19 @@ for (int index = 0; index < num_interfaces; index++) { Klass* k = interfaces->at(index); Symbol* name = k->name(); - Klass* i = resolve_super_or_fail(class_name, name, class_loader, protection_domain, false, CHECK_(nh)); + Klass* i = resolve_super_or_fail(class_name, name, class_loader, protection_domain, false, CHECK_NULL); if (k != i) { // The dynamically resolved interface class is not the same as the one we used during dump time, // so we cannot use ik. - return nh; + return NULL; } else { assert(i->is_shared(), "must be"); } } - instanceKlassHandle new_ik = KlassFactory::check_shared_class_file_load_hook( - ik, class_name, class_loader, protection_domain, CHECK_(nh)); - if (new_ik.not_null()) { + InstanceKlass* new_ik = KlassFactory::check_shared_class_file_load_hook( + ik, class_name, class_loader, protection_domain, CHECK_NULL); + if (new_ik != NULL) { // The class is changed by CFLH. Return the new class. The shared class is // not used. return new_ik; @@ -1391,16 +1381,16 @@ ObjectLocker ol(lockObject, THREAD, true); // prohibited package check assumes all classes loaded from archive call // restore_unshareable_info which calls ik->set_package() - ik->restore_unshareable_info(loader_data, protection_domain, CHECK_(nh)); + ik->restore_unshareable_info(loader_data, protection_domain, CHECK_NULL); } if (log_is_enabled(Info, class, load)) { - ik()->print_loading_log(LogLevel::Info, loader_data, NULL, NULL); + ik->print_loading_log(LogLevel::Info, loader_data, NULL, NULL); } // No 'else' here as logging levels are not mutually exclusive if (log_is_enabled(Debug, class, load)) { - ik()->print_loading_log(LogLevel::Debug, loader_data, NULL, NULL); + ik->print_loading_log(LogLevel::Debug, loader_data, NULL, NULL); } // For boot loader, ensure that GetSystemPackage knows that a class in this @@ -1421,12 +1411,12 @@ } // notify a class loaded from shared object - ClassLoadingService::notify_class_loaded(ik(), true /* shared class */); + ClassLoadingService::notify_class_loaded(ik, true /* shared class */); } ik->set_has_passed_fingerprint_check(false); if (UseAOT && ik->supers_have_passed_fingerprint_checks()) { - uint64_t aot_fp = AOTLoader::get_saved_fingerprint(ik()); + uint64_t aot_fp = AOTLoader::get_saved_fingerprint(ik); uint64_t cds_fp = ik->get_stored_fingerprint(); if (aot_fp != 0 && aot_fp == cds_fp) { // This class matches with a class saved in an AOT library @@ -1440,8 +1430,7 @@ } #endif // INCLUDE_CDS -instanceKlassHandle SystemDictionary::load_instance_class(Symbol* class_name, Handle class_loader, TRAPS) { - instanceKlassHandle nh = instanceKlassHandle(); // null Handle +InstanceKlass* SystemDictionary::load_instance_class(Symbol* class_name, Handle class_loader, TRAPS) { if (class_loader.is_null()) { ResourceMark rm; @@ -1473,14 +1462,14 @@ // and its package will be checked later by // ModuleEntryTable::verify_javabase_packages. if (ModuleEntryTable::javabase_defined()) { - return nh; + return NULL; } } else { // Check that the class' package is defined within java.base. ModuleEntry* mod_entry = pkg_entry->module(); Symbol* mod_entry_name = mod_entry->name(); if (mod_entry_name->fast_compare(vmSymbols::java_base()) != 0) { - return nh; + return NULL; } } } @@ -1506,7 +1495,7 @@ // Search the shared system dictionary for classes preloaded into the // shared spaces. - instanceKlassHandle k; + InstanceKlass* k = NULL; { #if INCLUDE_CDS PerfTraceTime vmtimer(ClassLoader::perf_shared_classload_time()); @@ -1514,24 +1503,24 @@ #endif } - if (k.is_null()) { + if (k == NULL) { // Use VM class loader PerfTraceTime vmtimer(ClassLoader::perf_sys_classload_time()); - k = ClassLoader::load_class(class_name, search_only_bootloader_append, CHECK_(nh)); + k = ClassLoader::load_class(class_name, search_only_bootloader_append, CHECK_NULL); } // find_or_define_instance_class may return a different InstanceKlass - if (!k.is_null()) { - instanceKlassHandle defined_k = + if (k != NULL) { + InstanceKlass* defined_k = find_or_define_instance_class(class_name, class_loader, k, THREAD); - if (!HAS_PENDING_EXCEPTION && defined_k() != k()) { + if (!HAS_PENDING_EXCEPTION && defined_k != k) { // If a parallel capable class loader already defined this class, register 'k' for cleanup. - assert(defined_k.not_null(), "Should have a klass if there's no exception"); - loader_data->add_to_deallocate_list(k()); + assert(defined_k != NULL, "Should have a klass if there's no exception"); + loader_data->add_to_deallocate_list(k); k = defined_k; } else if (HAS_PENDING_EXCEPTION) { - loader_data->add_to_deallocate_list(k()); - return nh; + loader_data->add_to_deallocate_list(k); + return NULL; } } return k; @@ -1549,13 +1538,13 @@ jt->get_thread_stat()->perf_timers_addr(), PerfClassTraceTime::CLASS_LOAD); - Handle s = java_lang_String::create_from_symbol(class_name, CHECK_(nh)); + Handle s = java_lang_String::create_from_symbol(class_name, CHECK_NULL); // Translate to external class name format, i.e., convert '/' chars to '.' - Handle string = java_lang_String::externalize_classname(s, CHECK_(nh)); + Handle string = java_lang_String::externalize_classname(s, CHECK_NULL); JavaValue result(T_OBJECT); - KlassHandle spec_klass (THREAD, SystemDictionary::ClassLoader_klass()); + InstanceKlass* spec_klass = SystemDictionary::ClassLoader_klass(); // Call public unsynchronized loadClass(String) directly for all class loaders // for parallelCapable class loaders. JDK >=7, loadClass(String, boolean) will @@ -1581,7 +1570,7 @@ vmSymbols::loadClassInternal_name(), vmSymbols::string_class_signature(), string, - CHECK_(nh)); + CHECK_NULL); } else { JavaCalls::call_virtual(&result, class_loader, @@ -1589,7 +1578,7 @@ vmSymbols::loadClass_name(), vmSymbols::string_class_signature(), string, - CHECK_(nh)); + CHECK_NULL); } assert(result.get_type() == T_OBJECT, "just checking"); @@ -1598,8 +1587,7 @@ // Primitive classes return null since forName() can not be // used to obtain any of the Class objects representing primitives or void if ((obj != NULL) && !(java_lang_Class::is_primitive(obj))) { - instanceKlassHandle k = - instanceKlassHandle(THREAD, java_lang_Class::as_Klass(obj)); + InstanceKlass* k = InstanceKlass::cast(java_lang_Class::as_Klass(obj)); // For user defined Java class loaders, check that the name returned is // the same as that requested. This check is done for the bootstrap // loader when parsing the class file. @@ -1608,11 +1596,11 @@ } } // Class is not found or has the wrong name, return NULL - return nh; + return NULL; } } -void SystemDictionary::define_instance_class(instanceKlassHandle k, TRAPS) { +void SystemDictionary::define_instance_class(InstanceKlass* k, TRAPS) { HandleMark hm(THREAD); ClassLoaderData* loader_data = k->class_loader_data(); @@ -1677,7 +1665,7 @@ // notify jvmti if (JvmtiExport::should_post_class_load()) { assert(THREAD->is_Java_thread(), "thread->is_Java_thread()"); - JvmtiExport::post_class_load((JavaThread *) THREAD, k()); + JvmtiExport::post_class_load((JavaThread *) THREAD, k); } class_define_event(k, loader_data); @@ -1703,16 +1691,16 @@ // placeholders()->find_and_add(PlaceholderTable::DEFINE_CLASS), // you need to find_and_remove it before returning. // So be careful to not exit with a CHECK_ macro betweeen these calls. -instanceKlassHandle SystemDictionary::find_or_define_instance_class(Symbol* class_name, Handle class_loader, instanceKlassHandle k, TRAPS) { - - instanceKlassHandle nh = instanceKlassHandle(); // null Handle +InstanceKlass* SystemDictionary::find_or_define_instance_class(Symbol* class_name, Handle class_loader, + InstanceKlass* k, TRAPS) { + Symbol* name_h = k->name(); // passed in class_name may be null ClassLoaderData* loader_data = class_loader_data(class_loader); unsigned int d_hash = dictionary()->compute_hash(name_h, loader_data); int d_index = dictionary()->hash_to_index(d_hash); -// Hold SD lock around find_class and placeholder creation for DEFINE_CLASS + // Hold SD lock around find_class and placeholder creation for DEFINE_CLASS unsigned int p_hash = placeholders()->compute_hash(name_h, loader_data); int p_index = placeholders()->hash_to_index(p_hash); PlaceholderEntry* probe; @@ -1721,9 +1709,9 @@ MutexLocker mu(SystemDictionary_lock, THREAD); // First check if class already defined if (UnsyncloadClass || (is_parallelDefine(class_loader))) { - Klass* check = find_class(d_index, d_hash, name_h, loader_data); + InstanceKlass* check = find_class(d_index, d_hash, name_h, loader_data); if (check != NULL) { - return(instanceKlassHandle(THREAD, check)); + return check; } } @@ -1743,10 +1731,10 @@ placeholders()->find_and_remove(p_index, p_hash, name_h, loader_data, PlaceholderTable::DEFINE_CLASS, THREAD); SystemDictionary_lock->notify_all(); #ifdef ASSERT - Klass* check = find_class(d_index, d_hash, name_h, loader_data); + InstanceKlass* check = find_class(d_index, d_hash, name_h, loader_data); assert(check != NULL, "definer missed recording success"); #endif - return(instanceKlassHandle(THREAD, probe->instance_klass())); + return probe->instance_klass(); } else { // This thread will define the class (even if earlier thread tried and had an error) probe->set_definer(THREAD); @@ -1767,7 +1755,7 @@ linkage_exception = Handle(THREAD,PENDING_EXCEPTION); CLEAR_PENDING_EXCEPTION; } else { - probe->set_instance_klass(k()); + probe->set_instance_klass(k); } probe->set_definer(NULL); placeholders()->find_and_remove(p_index, p_hash, name_h, loader_data, PlaceholderTable::DEFINE_CLASS, THREAD); @@ -1777,7 +1765,7 @@ // Can't throw exception while holding lock due to rank ordering if (linkage_exception() != NULL) { - THROW_OOP_(linkage_exception(), nh); // throws exception and returns + THROW_OOP_(linkage_exception(), NULL); // throws exception and returns } return k; @@ -1817,15 +1805,14 @@ // ---------------------------------------------------------------------------- // Lookup -Klass* SystemDictionary::find_class(int index, unsigned int hash, - Symbol* class_name, - ClassLoaderData* loader_data) { +InstanceKlass* SystemDictionary::find_class(int index, unsigned int hash, + Symbol* class_name, + ClassLoaderData* loader_data) { assert_locked_or_safepoint(SystemDictionary_lock); assert (index == dictionary()->index_for(class_name, loader_data), "incorrect index?"); - Klass* k = dictionary()->find_class(index, hash, class_name, loader_data); - return k; + return dictionary()->find_class(index, hash, class_name, loader_data); } @@ -1840,7 +1827,7 @@ // Used for assertions and verification only -Klass* SystemDictionary::find_class(Symbol* class_name, ClassLoaderData* loader_data) { +InstanceKlass* SystemDictionary::find_class(Symbol* class_name, ClassLoaderData* loader_data) { #ifndef ASSERT guarantee(VerifyBeforeGC || VerifyDuringGC || @@ -1868,8 +1855,8 @@ // is held, to ensure that the compiler is not using the class hierachy, and that deoptimization will kick in // before a new class is used. -void SystemDictionary::add_to_hierarchy(instanceKlassHandle k, TRAPS) { - assert(k.not_null(), "just checking"); +void SystemDictionary::add_to_hierarchy(InstanceKlass* k, TRAPS) { + assert(k != NULL, "just checking"); assert_locked_or_safepoint(Compile_lock); // Link into hierachy. Make sure the vtables are initialized before linking into @@ -2150,8 +2137,7 @@ if (UseSharedSpaces) { initialize_wk_klasses_through(WK_KLASS_ENUM_NAME(Object_klass), scan, CHECK); // Initialize the constant pool for the Object_class - InstanceKlass* ik = InstanceKlass::cast(Object_klass()); - ik->constants()->restore_unshareable_info(CHECK); + Object_klass()->constants()->restore_unshareable_info(CHECK); initialize_wk_klasses_through(WK_KLASS_ENUM_NAME(Class_klass), scan, CHECK); } else { initialize_wk_klasses_through(WK_KLASS_ENUM_NAME(Class_klass), scan, CHECK); @@ -2231,7 +2217,7 @@ // if initiating loader, then ok if InstanceKlass matches existing entry void SystemDictionary::check_constraints(int d_index, unsigned int d_hash, - instanceKlassHandle k, + InstanceKlass* k, Handle class_loader, bool defining, TRAPS) { const char *linkage_error1 = NULL; @@ -2242,8 +2228,8 @@ MutexLocker mu(SystemDictionary_lock, THREAD); - Klass* check = find_class(d_index, d_hash, name, loader_data); - if (check != (Klass*)NULL) { + InstanceKlass* check = find_class(d_index, d_hash, name, loader_data); + if (check != NULL) { // if different InstanceKlass - duplicate class definition, // else - ok, class loaded by a different thread in parallel, // we should only have found it if it was done loading and ok to use @@ -2251,9 +2237,9 @@ // also holds array classes assert(check->is_instance_klass(), "noninstance in systemdictionary"); - if ((defining == true) || (k() != check)) { - linkage_error1 = "loader (instance of "; - linkage_error2 = "): attempted duplicate class definition for name: \""; + if ((defining == true) || (k != check)) { + linkage_error1 = "loader (instance of "; + linkage_error2 = "): attempted duplicate class definition for name: \""; } else { return; } @@ -2292,7 +2278,7 @@ // have been called. void SystemDictionary::update_dictionary(int d_index, unsigned int d_hash, int p_index, unsigned int p_hash, - instanceKlassHandle k, + InstanceKlass* k, Handle class_loader, TRAPS) { // Compile_lock prevents systemDictionary updates during compilations @@ -2324,7 +2310,7 @@ } // Make a new system dictionary entry. - Klass* sd_check = find_class(d_index, d_hash, name, loader_data); + InstanceKlass* sd_check = find_class(d_index, d_hash, name, loader_data); if (sd_check == NULL) { dictionary()->add_klass(name, loader_data, k); notice_modification(); @@ -2415,8 +2401,8 @@ // Better never do a GC while we're holding these oops NoSafepointVerifier nosafepoint; - Klass* klass1 = find_class(d_index1, d_hash1, constraint_name, loader_data1); - Klass* klass2 = find_class(d_index2, d_hash2, constraint_name, loader_data2); + InstanceKlass* klass1 = find_class(d_index1, d_hash1, constraint_name, loader_data1); + InstanceKlass* klass2 = find_class(d_index2, d_hash2, constraint_name, loader_data2); return constraints()->add_entry(constraint_name, klass1, class_loader1, klass2, class_loader2); } @@ -2576,7 +2562,7 @@ // Helper for unpacking the return value from linkMethod and linkCallSite. static methodHandle unpack_method_and_appendix(Handle mname, - KlassHandle accessing_klass, + Klass* accessing_klass, objArrayHandle appendix_box, Handle* appendix_result, TRAPS) { @@ -2600,7 +2586,7 @@ // MethodName is dropped we need a way to make sure the // class_loader containing this method is kept alive. // FIXME: the appendix might also preserve this dependency. - ClassLoaderData* this_key = InstanceKlass::cast(accessing_klass())->class_loader_data(); + ClassLoaderData* this_key = accessing_klass->class_loader_data(); this_key->record_dependency(m->method_holder(), CHECK_NULL); // Can throw OOM return methodHandle(THREAD, m); } @@ -2609,10 +2595,10 @@ return empty; } -methodHandle SystemDictionary::find_method_handle_invoker(KlassHandle klass, +methodHandle SystemDictionary::find_method_handle_invoker(Klass* klass, Symbol* name, Symbol* signature, - KlassHandle accessing_klass, + Klass* accessing_klass, Handle *appendix_result, Handle *method_type_result, TRAPS) { @@ -2628,15 +2614,15 @@ assert(appendix_box->obj_at(0) == NULL, ""); // This should not happen. JDK code should take care of that. - if (accessing_klass.is_null() || method_type.is_null()) { + if (accessing_klass == NULL || method_type.is_null()) { THROW_MSG_(vmSymbols::java_lang_InternalError(), "bad invokehandle", empty); } // call java.lang.invoke.MethodHandleNatives::linkMethod(... String, MethodType) -> MemberName JavaCallArguments args; - args.push_oop(Handle(THREAD, accessing_klass()->java_mirror())); + args.push_oop(Handle(THREAD, accessing_klass->java_mirror())); args.push_int(ref_kind); - args.push_oop(Handle(THREAD, klass()->java_mirror())); + args.push_oop(Handle(THREAD, klass->java_mirror())); args.push_oop(name_str); args.push_oop(method_type); args.push_oop(appendix_box); @@ -2675,7 +2661,7 @@ // Because of class loader constraints, all method handle usage must be // consistent with this loader. Handle SystemDictionary::find_method_handle_type(Symbol* signature, - KlassHandle accessing_klass, + Klass* accessing_klass, TRAPS) { Handle empty; vmIntrinsics::ID null_iid = vmIntrinsics::_none; // distinct from all method handle invoker intrinsics @@ -2691,9 +2677,9 @@ } Handle class_loader, protection_domain; - if (accessing_klass.not_null()) { - class_loader = Handle(THREAD, InstanceKlass::cast(accessing_klass())->class_loader()); - protection_domain = Handle(THREAD, InstanceKlass::cast(accessing_klass())->protection_domain()); + if (accessing_klass != NULL) { + class_loader = Handle(THREAD, accessing_klass->class_loader()); + protection_domain = Handle(THREAD, accessing_klass->protection_domain()); } bool can_be_cached = true; int npts = ArgumentCount(signature).size(); @@ -2724,15 +2710,14 @@ pts->obj_at_put(arg++, mirror); // Check accessibility. - if (ss.is_object() && accessing_klass.not_null()) { + if (ss.is_object() && accessing_klass != NULL) { Klass* sel_klass = java_lang_Class::as_Klass(mirror); mirror = NULL; // safety // Emulate ConstantPool::verify_constant_pool_resolve. if (sel_klass->is_objArray_klass()) sel_klass = ObjArrayKlass::cast(sel_klass)->bottom_klass(); if (sel_klass->is_instance_klass()) { - KlassHandle sel_kh(THREAD, sel_klass); - LinkResolver::check_klass_accessability(accessing_klass, sel_kh, CHECK_(empty)); + LinkResolver::check_klass_accessability(accessing_klass, sel_klass, CHECK_(empty)); } } } @@ -2765,9 +2750,9 @@ } // Ask Java code to find or construct a method handle constant. -Handle SystemDictionary::link_method_handle_constant(KlassHandle caller, +Handle SystemDictionary::link_method_handle_constant(Klass* caller, int ref_kind, //e.g., JVM_REF_invokeVirtual - KlassHandle callee, + Klass* callee, Symbol* name_sym, Symbol* signature, TRAPS) { @@ -2776,7 +2761,7 @@ Handle type; if (signature->utf8_length() > 0 && signature->byte_at(0) == '(') { type = find_method_handle_type(signature, caller, CHECK_(empty)); - } else if (caller.is_null()) { + } else if (caller == NULL) { // This should not happen. JDK code should take care of that. THROW_MSG_(vmSymbols::java_lang_InternalError(), "bad MH constant", empty); } else { @@ -2813,7 +2798,7 @@ // Ask Java code to find or construct a java.lang.invoke.CallSite for the given // name and signature, as interpreted relative to the given class loader. -methodHandle SystemDictionary::find_dynamic_call_site_invoker(KlassHandle caller, +methodHandle SystemDictionary::find_dynamic_call_site_invoker(Klass* caller, Handle bootstrap_specifier, Symbol* name, Symbol* type, @@ -2844,7 +2829,7 @@ Handle method_type = find_method_handle_type(type, caller, CHECK_(empty)); // This should not happen. JDK code should take care of that. - if (caller.is_null() || method_type.is_null()) { + if (caller == NULL || method_type.is_null()) { THROW_MSG_(vmSymbols::java_lang_InternalError(), "bad invokedynamic", empty); }
--- a/hotspot/src/share/vm/classfile/systemDictionary.hpp Wed Mar 15 11:44:46 2017 +0100 +++ b/hotspot/src/share/vm/classfile/systemDictionary.hpp Wed Mar 15 10:25:37 2017 -0400 @@ -259,7 +259,7 @@ static Klass* resolve_or_fail(Symbol* class_name, bool throw_error, TRAPS); protected: // handle error translation for resolve_or_null results - static Klass* handle_resolution_exception(Symbol* class_name, bool throw_error, KlassHandle klass_h, TRAPS); + static Klass* handle_resolution_exception(Symbol* class_name, bool throw_error, Klass* klass, TRAPS); public: @@ -282,11 +282,11 @@ // Parse new stream. This won't update the system dictionary or // class hierarchy, simply parse the stream. Used by JVMTI RedefineClasses. // Also used by Unsafe_DefineAnonymousClass - static Klass* parse_stream(Symbol* class_name, - Handle class_loader, - Handle protection_domain, - ClassFileStream* st, - TRAPS) { + static InstanceKlass* parse_stream(Symbol* class_name, + Handle class_loader, + Handle protection_domain, + ClassFileStream* st, + TRAPS) { return parse_stream(class_name, class_loader, protection_domain, @@ -295,20 +295,20 @@ NULL, // cp_patches THREAD); } - static Klass* parse_stream(Symbol* class_name, - Handle class_loader, - Handle protection_domain, - ClassFileStream* st, - const InstanceKlass* host_klass, - GrowableArray<Handle>* cp_patches, - TRAPS); + static InstanceKlass* parse_stream(Symbol* class_name, + Handle class_loader, + Handle protection_domain, + ClassFileStream* st, + const InstanceKlass* host_klass, + GrowableArray<Handle>* cp_patches, + TRAPS); // Resolve from stream (called by jni_DefineClass and JVM_DefineClass) - static Klass* resolve_from_stream(Symbol* class_name, - Handle class_loader, - Handle protection_domain, - ClassFileStream* st, - TRAPS); + static InstanceKlass* resolve_from_stream(Symbol* class_name, + Handle class_loader, + Handle protection_domain, + ClassFileStream* st, + TRAPS); // Lookup an already loaded class. If not found NULL is returned. static Klass* find(Symbol* class_name, Handle class_loader, Handle protection_domain, TRAPS); @@ -516,10 +516,10 @@ // JSR 292 // find a java.lang.invoke.MethodHandle.invoke* method for a given signature // (asks Java to compute it if necessary, except in a compiler thread) - static methodHandle find_method_handle_invoker(KlassHandle klass, + static methodHandle find_method_handle_invoker(Klass* klass, Symbol* name, Symbol* signature, - KlassHandle accessing_klass, + Klass* accessing_klass, Handle *appendix_result, Handle *method_type_result, TRAPS); @@ -531,19 +531,19 @@ // find a java.lang.invoke.MethodType object for a given signature // (asks Java to compute it if necessary, except in a compiler thread) static Handle find_method_handle_type(Symbol* signature, - KlassHandle accessing_klass, + Klass* accessing_klass, TRAPS); // ask Java to compute a java.lang.invoke.MethodHandle object for a given CP entry - static Handle link_method_handle_constant(KlassHandle caller, + static Handle link_method_handle_constant(Klass* caller, int ref_kind, //e.g., JVM_REF_invokeVirtual - KlassHandle callee, + Klass* callee, Symbol* name, Symbol* signature, TRAPS); // ask Java to create a dynamic call site, while linking an invokedynamic op - static methodHandle find_dynamic_call_site_invoker(KlassHandle caller, + static methodHandle find_dynamic_call_site_invoker(Klass* caller, Handle bootstrap_method, Symbol* name, Symbol* type, @@ -615,7 +615,7 @@ static Klass* try_get_next_class(); protected: - static void validate_protection_domain(instanceKlassHandle klass, + static void validate_protection_domain(InstanceKlass* klass, Handle class_loader, Handle protection_domain, TRAPS); @@ -631,48 +631,48 @@ // Basic loading operations static Klass* resolve_instance_class_or_null(Symbol* class_name, Handle class_loader, Handle protection_domain, TRAPS); static Klass* resolve_array_class_or_null(Symbol* class_name, Handle class_loader, Handle protection_domain, TRAPS); - static instanceKlassHandle handle_parallel_super_load(Symbol* class_name, Symbol* supername, Handle class_loader, Handle protection_domain, Handle lockObject, TRAPS); + static InstanceKlass* handle_parallel_super_load(Symbol* class_name, Symbol* supername, Handle class_loader, Handle protection_domain, Handle lockObject, TRAPS); // Wait on SystemDictionary_lock; unlocks lockObject before // waiting; relocks lockObject with correct recursion count // after waiting, but before reentering SystemDictionary_lock // to preserve lock order semantics. static void double_lock_wait(Handle lockObject, TRAPS); - static void define_instance_class(instanceKlassHandle k, TRAPS); - static instanceKlassHandle find_or_define_instance_class(Symbol* class_name, + static void define_instance_class(InstanceKlass* k, TRAPS); + static InstanceKlass* find_or_define_instance_class(Symbol* class_name, Handle class_loader, - instanceKlassHandle k, TRAPS); - static bool is_shared_class_visible(Symbol* class_name, instanceKlassHandle ik, + InstanceKlass* k, TRAPS); + static bool is_shared_class_visible(Symbol* class_name, InstanceKlass* ik, Handle class_loader, TRAPS); - static instanceKlassHandle load_shared_class(instanceKlassHandle ik, - Handle class_loader, - Handle protection_domain, - TRAPS); - static instanceKlassHandle load_instance_class(Symbol* class_name, Handle class_loader, TRAPS); + static InstanceKlass* load_shared_class(InstanceKlass* ik, + Handle class_loader, + Handle protection_domain, + TRAPS); + static InstanceKlass* load_instance_class(Symbol* class_name, Handle class_loader, TRAPS); static Handle compute_loader_lock_object(Handle class_loader, TRAPS); static void check_loader_lock_contention(Handle loader_lock, TRAPS); static bool is_parallelCapable(Handle class_loader); static bool is_parallelDefine(Handle class_loader); public: - static instanceKlassHandle load_shared_class(Symbol* class_name, - Handle class_loader, - TRAPS); + static InstanceKlass* load_shared_class(Symbol* class_name, + Handle class_loader, + TRAPS); static bool is_system_class_loader(oop class_loader); static bool is_platform_class_loader(oop class_loader); protected: - static Klass* find_shared_class(Symbol* class_name); + static InstanceKlass* find_shared_class(Symbol* class_name); // Setup link to hierarchy - static void add_to_hierarchy(instanceKlassHandle k, TRAPS); + static void add_to_hierarchy(InstanceKlass* k, TRAPS); // We pass in the hashtable index so we can calculate it outside of // the SystemDictionary_lock. // Basic find on loaded classes - static Klass* find_class(int index, unsigned int hash, - Symbol* name, ClassLoaderData* loader_data); - static Klass* find_class(Symbol* class_name, ClassLoaderData* loader_data); + static InstanceKlass* find_class(int index, unsigned int hash, + Symbol* name, ClassLoaderData* loader_data); + static InstanceKlass* find_class(Symbol* class_name, ClassLoaderData* loader_data); // Basic find on classes in the midst of being loaded static Symbol* find_placeholder(Symbol* name, ClassLoaderData* loader_data); @@ -697,11 +697,11 @@ // Class loader constraints static void check_constraints(int index, unsigned int hash, - instanceKlassHandle k, Handle loader, + InstanceKlass* k, Handle loader, bool defining, TRAPS); static void update_dictionary(int d_index, unsigned int d_hash, int p_index, unsigned int p_hash, - instanceKlassHandle k, Handle loader, + InstanceKlass* k, Handle loader, TRAPS); // Variables holding commonly used klasses (preloaded)
--- a/hotspot/src/share/vm/classfile/systemDictionaryShared.hpp Wed Mar 15 11:44:46 2017 +0100 +++ b/hotspot/src/share/vm/classfile/systemDictionaryShared.hpp Wed Mar 15 10:25:37 2017 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2017, 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 @@ -33,10 +33,10 @@ class SystemDictionaryShared: public SystemDictionary { public: static void initialize(TRAPS) {} - static instanceKlassHandle find_or_load_shared_class(Symbol* class_name, - Handle class_loader, - TRAPS) { - return instanceKlassHandle(); + static InstanceKlass* find_or_load_shared_class(Symbol* class_name, + Handle class_loader, + TRAPS) { + return NULL; } static void roots_oops_do(OopClosure* blk) {} static void oops_do(OopClosure* f) {} @@ -45,7 +45,7 @@ return (class_loader == NULL); } static bool is_shared_class_visible_for_classloader( - instanceKlassHandle ik, + InstanceKlass* ik, Handle class_loader, const char* pkg_string, Symbol* pkg_name, @@ -86,7 +86,7 @@ Symbol* from_name, bool from_field_is_protected, bool from_is_array, bool from_is_object) {return false;} static void finalize_verification_constraints() {} - static void check_verification_constraints(instanceKlassHandle klass, + static void check_verification_constraints(InstanceKlass* klass, TRAPS) {} };
--- a/hotspot/src/share/vm/classfile/verificationType.cpp Wed Mar 15 11:44:46 2017 +0100 +++ b/hotspot/src/share/vm/classfile/verificationType.cpp Wed Mar 15 10:25:37 2017 -0400 @@ -42,18 +42,16 @@ } } -bool VerificationType::resolve_and_check_assignability(instanceKlassHandle klass, Symbol* name, +bool VerificationType::resolve_and_check_assignability(InstanceKlass* klass, Symbol* name, Symbol* from_name, bool from_field_is_protected, bool from_is_array, bool from_is_object, TRAPS) { HandleMark hm(THREAD); - Klass* obj = SystemDictionary::resolve_or_fail( + Klass* this_class = SystemDictionary::resolve_or_fail( name, Handle(THREAD, klass->class_loader()), Handle(THREAD, klass->protection_domain()), true, CHECK_false); if (log_is_enabled(Debug, class, resolve)) { - Verifier::trace_class_resolution(obj, klass()); + Verifier::trace_class_resolution(this_class, klass); } - KlassHandle this_class(THREAD, obj); - if (this_class->is_interface() && (!from_field_is_protected || from_name != vmSymbols::java_lang_Object())) { // If we are not trying to access a protected field or method in @@ -68,9 +66,9 @@ from_name, Handle(THREAD, klass->class_loader()), Handle(THREAD, klass->protection_domain()), true, CHECK_false); if (log_is_enabled(Debug, class, resolve)) { - Verifier::trace_class_resolution(from_class, klass()); + Verifier::trace_class_resolution(from_class, klass); } - return InstanceKlass::cast(from_class)->is_subclass_of(this_class()); + return InstanceKlass::cast(from_class)->is_subclass_of(this_class); } return false; @@ -79,7 +77,7 @@ bool VerificationType::is_reference_assignable_from( const VerificationType& from, ClassVerifier* context, bool from_field_is_protected, TRAPS) const { - instanceKlassHandle klass = context->current_class(); + InstanceKlass* klass = context->current_class(); if (from.is_null()) { // null is assignable to any reference return true; @@ -94,7 +92,7 @@ return true; } - if (DumpSharedSpaces && SystemDictionaryShared::add_verification_constraint(klass(), + if (DumpSharedSpaces && SystemDictionaryShared::add_verification_constraint(klass, name(), from.name(), from_field_is_protected, from.is_array(), from.is_object())) { // If add_verification_constraint() returns true, the resolution/check should be @@ -102,7 +100,7 @@ return true; } - return resolve_and_check_assignability(klass(), name(), from.name(), + return resolve_and_check_assignability(klass, name(), from.name(), from_field_is_protected, from.is_array(), from.is_object(), THREAD); } else if (is_array() && from.is_array()) { VerificationType comp_this = get_component(context, CHECK_false);
--- a/hotspot/src/share/vm/classfile/verificationType.hpp Wed Mar 15 11:44:46 2017 +0100 +++ b/hotspot/src/share/vm/classfile/verificationType.hpp Wed Mar 15 10:25:37 2017 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2017, 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 @@ -336,7 +336,7 @@ TRAPS) const; public: - static bool resolve_and_check_assignability(instanceKlassHandle klass, Symbol* name, + static bool resolve_and_check_assignability(InstanceKlass* klass, Symbol* name, Symbol* from_name, bool from_field_is_protected, bool from_is_array, bool from_is_object, TRAPS);
--- a/hotspot/src/share/vm/classfile/verifier.cpp Wed Mar 15 11:44:46 2017 +0100 +++ b/hotspot/src/share/vm/classfile/verifier.cpp Wed Mar 15 10:25:37 2017 -0400 @@ -125,7 +125,7 @@ st->print_cr("End class verification for: %s", klassName); } -bool Verifier::verify(instanceKlassHandle klass, Verifier::Mode mode, bool should_verify_class, TRAPS) { +bool Verifier::verify(InstanceKlass* klass, Verifier::Mode mode, bool should_verify_class, TRAPS) { HandleMark hm(THREAD); ResourceMark rm(THREAD); @@ -203,13 +203,13 @@ return true; // verifcation succeeded } else { // VerifyError or ClassFormatError to be created and thrown ResourceMark rm(THREAD); - instanceKlassHandle kls = + Klass* kls = SystemDictionary::resolve_or_fail(exception_name, true, CHECK_false); if (log_is_enabled(Debug, class, resolve)) { - Verifier::trace_class_resolution(kls(), klass()); + Verifier::trace_class_resolution(kls, klass); } - while (!kls.is_null()) { + while (kls != NULL) { if (kls == klass) { // If the class being verified is the exception we're creating // or one of it's superclasses, we're in trouble and are going @@ -224,7 +224,7 @@ } } -bool Verifier::is_eligible_for_verification(instanceKlassHandle klass, bool should_verify_class) { +bool Verifier::is_eligible_for_verification(InstanceKlass* klass, bool should_verify_class) { Symbol* name = klass->name(); Klass* refl_magic_klass = SystemDictionary::reflect_MagicAccessorImpl_klass(); @@ -243,7 +243,7 @@ // already been rewritten to contain constant pool cache indices, // which the verifier can't understand. // Shared classes shouldn't have stackmaps either. - !klass()->is_shared() && + !klass->is_shared() && // As of the fix for 4486457 we disable verification for all of the // dynamically-generated bytecodes associated with the 1.4 @@ -256,7 +256,7 @@ } Symbol* Verifier::inference_verify( - instanceKlassHandle klass, char* message, size_t message_len, TRAPS) { + InstanceKlass* klass, char* message, size_t message_len, TRAPS) { JavaThread* thread = (JavaThread*)THREAD; JNIEnv *env = thread->jni_environment(); @@ -559,7 +559,7 @@ // Methods in ClassVerifier ClassVerifier::ClassVerifier( - instanceKlassHandle klass, TRAPS) + InstanceKlass* klass, TRAPS) : _thread(THREAD), _exception_type(NULL), _message(NULL), _klass(klass) { _this_type = VerificationType::reference_type(klass->name()); // Create list to hold symbols in reference area. @@ -2001,13 +2001,13 @@ true, THREAD); if (log_is_enabled(Debug, class, resolve)) { - instanceKlassHandle cur_class = current_class(); - Verifier::trace_class_resolution(kls, cur_class()); + InstanceKlass* cur_class = InstanceKlass::cast(current_class()); + Verifier::trace_class_resolution(kls, cur_class); } return kls; } -bool ClassVerifier::is_protected_access(instanceKlassHandle this_class, +bool ClassVerifier::is_protected_access(InstanceKlass* this_class, Klass* target_class, Symbol* field_name, Symbol* field_sig, @@ -2170,7 +2170,7 @@ } bool ClassVerifier::name_in_supers( - Symbol* ref_name, instanceKlassHandle current) { + Symbol* ref_name, InstanceKlass* current) { Klass* super = current->super(); while (super != NULL) { if (super->name() == ref_name) { @@ -2600,8 +2600,8 @@ Klass::find_overpass); // Do nothing if method is not found. Let resolution detect the error. if (m != NULL) { - instanceKlassHandle mh(THREAD, m->method_holder()); - if (m->is_protected() && !mh->is_same_class_package(_klass())) { + InstanceKlass* mh = m->method_holder(); + if (m->is_protected() && !mh->is_same_class_package(_klass)) { bool assignable = current_type().is_assignable_from( objectref_type, this, true, CHECK_VERIFY(this)); if (!assignable) { @@ -2631,7 +2631,7 @@ } bool ClassVerifier::is_same_or_direct_interface( - instanceKlassHandle klass, + InstanceKlass* klass, VerificationType klass_type, VerificationType ref_class_type) { if (ref_class_type.equals(klass_type)) return true;
--- a/hotspot/src/share/vm/classfile/verifier.hpp Wed Mar 15 11:44:46 2017 +0100 +++ b/hotspot/src/share/vm/classfile/verifier.hpp Wed Mar 15 10:25:37 2017 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2017, 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 @@ -51,7 +51,7 @@ * error. */ static void log_end_verification(outputStream* st, const char* klassName, Symbol* exception_name, TRAPS); - static bool verify(instanceKlassHandle klass, Mode mode, bool should_verify_class, TRAPS); + static bool verify(InstanceKlass* klass, Mode mode, bool should_verify_class, TRAPS); // Return false if the class is loaded by the bootstrap loader, // or if defineClass was called requesting skipping verification @@ -65,9 +65,9 @@ static void trace_class_resolution(Klass* resolve_class, InstanceKlass* verify_class); private: - static bool is_eligible_for_verification(instanceKlassHandle klass, bool should_verify_class); + static bool is_eligible_for_verification(InstanceKlass* klass, bool should_verify_class); static Symbol* inference_verify( - instanceKlassHandle klass, char* msg, size_t msg_len, TRAPS); + InstanceKlass* klass, char* msg, size_t msg_len, TRAPS); }; class RawBytecodeStream; @@ -275,7 +275,7 @@ } bool is_protected_access( - instanceKlassHandle this_class, Klass* target_class, + InstanceKlass* this_class, Klass* target_class, Symbol* field_name, Symbol* field_sig, bool is_method); void verify_cp_index(u2 bci, const constantPoolHandle& cp, int index, TRAPS); @@ -344,11 +344,11 @@ void verify_astore(u2 index, StackMapFrame* current_frame, TRAPS); void verify_iinc (u2 index, StackMapFrame* current_frame, TRAPS); - bool name_in_supers(Symbol* ref_name, instanceKlassHandle current); + bool name_in_supers(Symbol* ref_name, InstanceKlass* current); VerificationType object_type() const; - instanceKlassHandle _klass; // the class being verified + InstanceKlass* _klass; // the class being verified methodHandle _method; // current method being verified VerificationType _this_type; // the verification type of the current class @@ -362,7 +362,7 @@ // that a class has been verified and prepared for execution. bool was_recursively_verified() { return _klass->is_rewritten(); } - bool is_same_or_direct_interface(instanceKlassHandle klass, + bool is_same_or_direct_interface(InstanceKlass* klass, VerificationType klass_type, VerificationType ref_class_type); public: @@ -372,14 +372,14 @@ }; // constructor - ClassVerifier(instanceKlassHandle klass, TRAPS); + ClassVerifier(InstanceKlass* klass, TRAPS); // destructor ~ClassVerifier(); Thread* thread() { return _thread; } const methodHandle& method() { return _method; } - instanceKlassHandle current_class() const { return _klass; } + InstanceKlass* current_class() const { return _klass; } VerificationType current_type() const { return _this_type; } // Verifies the class. If a verify or class file format error occurs,
--- a/hotspot/src/share/vm/code/codeCache.cpp Wed Mar 15 11:44:46 2017 +0100 +++ b/hotspot/src/share/vm/code/codeCache.cpp Wed Mar 15 10:25:37 2017 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2017, 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 @@ -1141,7 +1141,7 @@ } #ifdef HOTSWAP -int CodeCache::mark_for_evol_deoptimization(instanceKlassHandle dependee) { +int CodeCache::mark_for_evol_deoptimization(InstanceKlass* dependee) { MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); int number_of_marked_CodeBlobs = 0; @@ -1162,7 +1162,7 @@ CompiledMethod* nm = iter.method(); if (nm->is_marked_for_deoptimization()) { // ...Already marked in the previous pass; don't count it again. - } else if (nm->is_evol_dependent_on(dependee())) { + } else if (nm->is_evol_dependent_on(dependee)) { ResourceMark rm; nm->mark_for_deoptimization(); number_of_marked_CodeBlobs++; @@ -1218,7 +1218,7 @@ } // Flushes compiled methods dependent on dependee. -void CodeCache::flush_dependents_on(instanceKlassHandle dependee) { +void CodeCache::flush_dependents_on(InstanceKlass* dependee) { assert_lock_strong(Compile_lock); if (number_of_nmethods_with_dependencies() == 0) return; @@ -1239,7 +1239,7 @@ #ifdef HOTSWAP // Flushes compiled methods dependent on dependee in the evolutionary sense -void CodeCache::flush_evol_dependents_on(instanceKlassHandle ev_k_h) { +void CodeCache::flush_evol_dependents_on(InstanceKlass* ev_k) { // --- Compile_lock is not held. However we are at a safepoint. assert_locked_or_safepoint(Compile_lock); if (number_of_nmethods_with_dependencies() == 0 && !UseAOT) return; @@ -1249,7 +1249,7 @@ // holding the CodeCache_lock. // Compute the dependent nmethods - if (mark_for_evol_deoptimization(ev_k_h) > 0) { + if (mark_for_evol_deoptimization(ev_k) > 0) { // At least one nmethod has been marked for deoptimization // All this already happens inside a VM_Operation, so we'll do all the work here.
--- a/hotspot/src/share/vm/code/codeCache.hpp Wed Mar 15 11:44:46 2017 +0100 +++ b/hotspot/src/share/vm/code/codeCache.hpp Wed Mar 15 10:25:37 2017 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2017, 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 @@ -260,7 +260,7 @@ private: static int mark_for_deoptimization(KlassDepChange& changes); #ifdef HOTSWAP - static int mark_for_evol_deoptimization(instanceKlassHandle dependee); + static int mark_for_evol_deoptimization(InstanceKlass* dependee); #endif // HOTSWAP public: @@ -269,10 +269,10 @@ static void make_marked_nmethods_not_entrant(); // Flushing and deoptimization - static void flush_dependents_on(instanceKlassHandle dependee); + static void flush_dependents_on(InstanceKlass* dependee); #ifdef HOTSWAP // Flushing and deoptimization in case of evolution - static void flush_evol_dependents_on(instanceKlassHandle dependee); + static void flush_evol_dependents_on(InstanceKlass* dependee); #endif // HOTSWAP // Support for fullspeed debugging static void flush_dependents_on_method(methodHandle dependee);
--- a/hotspot/src/share/vm/code/compiledIC.cpp Wed Mar 15 11:44:46 2017 +0100 +++ b/hotspot/src/share/vm/code/compiledIC.cpp Wed Mar 15 10:25:37 2017 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2017, 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 @@ -457,7 +457,7 @@ // null check, while a static_bound won't. A static_bound (but not optimized) must // therefore use the unverified entry point. void CompiledIC::compute_monomorphic_entry(const methodHandle& method, - KlassHandle receiver_klass, + Klass* receiver_klass, bool is_optimized, bool static_bound, bool caller_is_nmethod, @@ -494,7 +494,7 @@ bool far_c2a = entry != NULL && caller_is_nmethod && method_code->is_far_code(); if (entry != NULL && !far_c2a) { // Call to near compiled code (nmethod or aot). - info.set_compiled_entry(entry, (static_bound || is_optimized) ? NULL : receiver_klass(), is_optimized); + info.set_compiled_entry(entry, (static_bound || is_optimized) ? NULL : receiver_klass, is_optimized); } else { if (is_optimized) { if (far_c2a) { @@ -507,7 +507,7 @@ } else { // Use icholder entry assert(method_code == NULL || method_code->is_compiled(), "must be compiled"); - CompiledICHolder* holder = new CompiledICHolder(method(), receiver_klass()); + CompiledICHolder* holder = new CompiledICHolder(method(), receiver_klass); info.set_icholder_entry(method()->get_c2i_unverified_entry(), holder); } }
--- a/hotspot/src/share/vm/code/compiledIC.hpp Wed Mar 15 11:44:46 2017 +0100 +++ b/hotspot/src/share/vm/code/compiledIC.hpp Wed Mar 15 10:25:37 2017 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2017, 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 @@ -266,7 +266,7 @@ // allocation in the code cache fails. bool set_to_megamorphic(CallInfo* call_info, Bytecodes::Code bytecode, TRAPS); - static void compute_monomorphic_entry(const methodHandle& method, KlassHandle receiver_klass, + static void compute_monomorphic_entry(const methodHandle& method, Klass* receiver_klass, bool is_optimized, bool static_bound, bool caller_is_nmethod, CompiledICInfo& info, TRAPS);
--- a/hotspot/src/share/vm/code/dependencies.hpp Wed Mar 15 11:44:46 2017 +0100 +++ b/hotspot/src/share/vm/code/dependencies.hpp Wed Mar 15 10:25:37 2017 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2017, 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 @@ -737,13 +737,13 @@ class KlassDepChange : public DepChange { private: // each change set is rooted in exactly one new type (at present): - KlassHandle _new_type; + Klass* _new_type; void initialize(); public: // notes the new type, marks it and all its super-types - KlassDepChange(KlassHandle new_type) + KlassDepChange(Klass* new_type) : _new_type(new_type) { initialize(); @@ -759,7 +759,7 @@ nm->mark_for_deoptimization(/*inc_recompile_counts=*/true); } - Klass* new_type() { return _new_type(); } + Klass* new_type() { return _new_type; } // involves_context(k) is true if k is new_type or any of the super types bool involves_context(Klass* k);
--- a/hotspot/src/share/vm/compiler/compileBroker.cpp Wed Mar 15 11:44:46 2017 +0100 +++ b/hotspot/src/share/vm/compiler/compileBroker.cpp Wed Mar 15 10:25:37 2017 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2017, 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 @@ -683,7 +683,7 @@ AbstractCompiler* comp, bool compiler_thread, TRAPS) { JavaThread* thread = NULL; Klass* k = SystemDictionary::resolve_or_fail(vmSymbols::java_lang_Thread(), true, CHECK_0); - instanceKlassHandle klass (THREAD, k); + InstanceKlass* klass = InstanceKlass::cast(k); instanceHandle thread_oop = klass->allocate_instance_handle(CHECK_0); Handle string = java_lang_String::create_from_str(name, CHECK_0);
--- a/hotspot/src/share/vm/gc/shared/allocTracer.cpp Wed Mar 15 11:44:46 2017 +0100 +++ b/hotspot/src/share/vm/gc/shared/allocTracer.cpp Wed Mar 15 10:25:37 2017 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2017, 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 @@ -28,19 +28,19 @@ #include "trace/tracing.hpp" #include "utilities/globalDefinitions.hpp" -void AllocTracer::send_allocation_outside_tlab_event(KlassHandle klass, size_t alloc_size) { +void AllocTracer::send_allocation_outside_tlab_event(Klass* klass, size_t alloc_size) { EventObjectAllocationOutsideTLAB event; if (event.should_commit()) { - event.set_objectClass(klass()); + event.set_objectClass(klass); event.set_allocationSize(alloc_size); event.commit(); } } -void AllocTracer::send_allocation_in_new_tlab_event(KlassHandle klass, size_t tlab_size, size_t alloc_size) { +void AllocTracer::send_allocation_in_new_tlab_event(Klass* klass, size_t tlab_size, size_t alloc_size) { EventObjectAllocationInNewTLAB event; if (event.should_commit()) { - event.set_objectClass(klass()); + event.set_objectClass(klass); event.set_allocationSize(alloc_size); event.set_tlabSize(tlab_size); event.commit();
--- a/hotspot/src/share/vm/gc/shared/allocTracer.hpp Wed Mar 15 11:44:46 2017 +0100 +++ b/hotspot/src/share/vm/gc/shared/allocTracer.hpp Wed Mar 15 10:25:37 2017 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2017, 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 @@ -30,8 +30,8 @@ class AllocTracer : AllStatic { public: - static void send_allocation_outside_tlab_event(KlassHandle klass, size_t alloc_size); - static void send_allocation_in_new_tlab_event(KlassHandle klass, size_t tlab_size, size_t alloc_size); + static void send_allocation_outside_tlab_event(Klass* klass, size_t alloc_size); + static void send_allocation_in_new_tlab_event(Klass* klass, size_t tlab_size, size_t alloc_size); static void send_allocation_requiring_gc_event(size_t size, uint gcId); };
--- a/hotspot/src/share/vm/gc/shared/collectedHeap.cpp Wed Mar 15 11:44:46 2017 +0100 +++ b/hotspot/src/share/vm/gc/shared/collectedHeap.cpp Wed Mar 15 10:25:37 2017 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2017, 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 @@ -279,7 +279,7 @@ } #endif -HeapWord* CollectedHeap::allocate_from_tlab_slow(KlassHandle klass, Thread* thread, size_t size) { +HeapWord* CollectedHeap::allocate_from_tlab_slow(Klass* klass, Thread* thread, size_t size) { // Retain tlab and allocate object in shared space if // the amount free in the tlab is too large to discard.
--- a/hotspot/src/share/vm/gc/shared/collectedHeap.hpp Wed Mar 15 11:44:46 2017 +0100 +++ b/hotspot/src/share/vm/gc/shared/collectedHeap.hpp Wed Mar 15 10:25:37 2017 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2017, 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 @@ -138,28 +138,28 @@ virtual void resize_all_tlabs(); // Allocate from the current thread's TLAB, with broken-out slow path. - inline static HeapWord* allocate_from_tlab(KlassHandle klass, Thread* thread, size_t size); - static HeapWord* allocate_from_tlab_slow(KlassHandle klass, Thread* thread, size_t size); + inline static HeapWord* allocate_from_tlab(Klass* klass, Thread* thread, size_t size); + static HeapWord* allocate_from_tlab_slow(Klass* klass, Thread* thread, size_t size); // Allocate an uninitialized block of the given size, or returns NULL if // this is impossible. - inline static HeapWord* common_mem_allocate_noinit(KlassHandle klass, size_t size, TRAPS); + inline static HeapWord* common_mem_allocate_noinit(Klass* klass, size_t size, TRAPS); // Like allocate_init, but the block returned by a successful allocation // is guaranteed initialized to zeros. - inline static HeapWord* common_mem_allocate_init(KlassHandle klass, size_t size, TRAPS); + inline static HeapWord* common_mem_allocate_init(Klass* klass, size_t size, TRAPS); // Helper functions for (VM) allocation. - inline static void post_allocation_setup_common(KlassHandle klass, HeapWord* obj); - inline static void post_allocation_setup_no_klass_install(KlassHandle klass, + inline static void post_allocation_setup_common(Klass* klass, HeapWord* obj); + inline static void post_allocation_setup_no_klass_install(Klass* klass, HeapWord* objPtr); - inline static void post_allocation_setup_obj(KlassHandle klass, HeapWord* obj, int size); + inline static void post_allocation_setup_obj(Klass* klass, HeapWord* obj, int size); - inline static void post_allocation_setup_array(KlassHandle klass, + inline static void post_allocation_setup_array(Klass* klass, HeapWord* obj, int length); - inline static void post_allocation_setup_class(KlassHandle klass, HeapWord* obj, int size); + inline static void post_allocation_setup_class(Klass* klass, HeapWord* obj, int size); // Clears an allocated object. inline static void init_obj(HeapWord* obj, size_t size); @@ -299,10 +299,10 @@ GCCause::Cause gc_cause() { return _gc_cause; } // General obj/array allocation facilities. - inline static oop obj_allocate(KlassHandle klass, int size, TRAPS); - inline static oop array_allocate(KlassHandle klass, int size, int length, TRAPS); - inline static oop array_allocate_nozero(KlassHandle klass, int size, int length, TRAPS); - inline static oop class_allocate(KlassHandle klass, int size, TRAPS); + inline static oop obj_allocate(Klass* klass, int size, TRAPS); + inline static oop array_allocate(Klass* klass, int size, int length, TRAPS); + inline static oop array_allocate_nozero(Klass* klass, int size, int length, TRAPS); + inline static oop class_allocate(Klass* klass, int size, TRAPS); // Raw memory allocation facilities // The obj and array allocate methods are covers for these methods.
--- a/hotspot/src/share/vm/gc/shared/collectedHeap.inline.hpp Wed Mar 15 11:44:46 2017 +0100 +++ b/hotspot/src/share/vm/gc/shared/collectedHeap.inline.hpp Wed Mar 15 10:25:37 2017 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2017, 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,26 +40,26 @@ // Inline allocation implementations. -void CollectedHeap::post_allocation_setup_common(KlassHandle klass, +void CollectedHeap::post_allocation_setup_common(Klass* klass, HeapWord* obj_ptr) { post_allocation_setup_no_klass_install(klass, obj_ptr); oop obj = (oop)obj_ptr; #if ! INCLUDE_ALL_GCS - obj->set_klass(klass()); + obj->set_klass(klass); #else // Need a release store to ensure array/class length, mark word, and // object zeroing are visible before setting the klass non-NULL, for // concurrent collectors. - obj->release_set_klass(klass()); + obj->release_set_klass(klass); #endif } -void CollectedHeap::post_allocation_setup_no_klass_install(KlassHandle klass, +void CollectedHeap::post_allocation_setup_no_klass_install(Klass* klass, HeapWord* obj_ptr) { oop obj = (oop)obj_ptr; assert(obj != NULL, "NULL object pointer"); - if (UseBiasedLocking && (klass() != NULL)) { + if (UseBiasedLocking && (klass != NULL)) { obj->set_mark(klass->prototype_header()); } else { // May be bootstrapping @@ -68,7 +68,7 @@ } // Support for jvmti and dtrace -inline void post_allocation_notify(KlassHandle klass, oop obj, int size) { +inline void post_allocation_notify(Klass* klass, oop obj, int size) { // support low memory notifications (no-op if not enabled) LowMemoryDetector::detect_low_memory_for_collected_pools(); @@ -77,13 +77,13 @@ if (DTraceAllocProbes) { // support for Dtrace object alloc event (no-op most of the time) - if (klass() != NULL && klass()->name() != NULL) { + if (klass != NULL && klass->name() != NULL) { SharedRuntime::dtrace_object_alloc(obj, size); } } } -void CollectedHeap::post_allocation_setup_obj(KlassHandle klass, +void CollectedHeap::post_allocation_setup_obj(Klass* klass, HeapWord* obj_ptr, int size) { post_allocation_setup_common(klass, obj_ptr); @@ -94,7 +94,7 @@ post_allocation_notify(klass, obj, size); } -void CollectedHeap::post_allocation_setup_class(KlassHandle klass, +void CollectedHeap::post_allocation_setup_class(Klass* klass, HeapWord* obj_ptr, int size) { // Set oop_size field before setting the _klass field because a @@ -110,7 +110,7 @@ post_allocation_notify(klass, new_cls, size); } -void CollectedHeap::post_allocation_setup_array(KlassHandle klass, +void CollectedHeap::post_allocation_setup_array(Klass* klass, HeapWord* obj_ptr, int length) { // Set array length before setting the _klass field because a @@ -125,7 +125,7 @@ post_allocation_notify(klass, new_obj, new_obj->size()); } -HeapWord* CollectedHeap::common_mem_allocate_noinit(KlassHandle klass, size_t size, TRAPS) { +HeapWord* CollectedHeap::common_mem_allocate_noinit(Klass* klass, size_t size, TRAPS) { // Clear unhandled oops for memory allocation. Memory allocation might // not take out a lock if from tlab, so clear here. @@ -186,13 +186,13 @@ } } -HeapWord* CollectedHeap::common_mem_allocate_init(KlassHandle klass, size_t size, TRAPS) { +HeapWord* CollectedHeap::common_mem_allocate_init(Klass* klass, size_t size, TRAPS) { HeapWord* obj = common_mem_allocate_noinit(klass, size, CHECK_NULL); init_obj(obj, size); return obj; } -HeapWord* CollectedHeap::allocate_from_tlab(KlassHandle klass, Thread* thread, size_t size) { +HeapWord* CollectedHeap::allocate_from_tlab(Klass* klass, Thread* thread, size_t size) { assert(UseTLAB, "should use UseTLAB"); HeapWord* obj = thread->tlab().allocate(size); @@ -211,7 +211,7 @@ Copy::fill_to_aligned_words(obj + hs, size - hs); } -oop CollectedHeap::obj_allocate(KlassHandle klass, int size, TRAPS) { +oop CollectedHeap::obj_allocate(Klass* klass, int size, TRAPS) { debug_only(check_for_valid_allocation_state()); assert(!Universe::heap()->is_gc_active(), "Allocation during gc not allowed"); assert(size >= 0, "int won't convert to size_t"); @@ -221,7 +221,7 @@ return (oop)obj; } -oop CollectedHeap::class_allocate(KlassHandle klass, int size, TRAPS) { +oop CollectedHeap::class_allocate(Klass* klass, int size, TRAPS) { debug_only(check_for_valid_allocation_state()); assert(!Universe::heap()->is_gc_active(), "Allocation during gc not allowed"); assert(size >= 0, "int won't convert to size_t"); @@ -231,7 +231,7 @@ return (oop)obj; } -oop CollectedHeap::array_allocate(KlassHandle klass, +oop CollectedHeap::array_allocate(Klass* klass, int size, int length, TRAPS) { @@ -244,7 +244,7 @@ return (oop)obj; } -oop CollectedHeap::array_allocate_nozero(KlassHandle klass, +oop CollectedHeap::array_allocate_nozero(Klass* klass, int size, int length, TRAPS) {
--- a/hotspot/src/share/vm/interpreter/interpreterRuntime.cpp Wed Mar 15 11:44:46 2017 +0100 +++ b/hotspot/src/share/vm/interpreter/interpreterRuntime.cpp Wed Mar 15 10:25:37 2017 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2017, 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 @@ -138,8 +138,8 @@ // Allocation IRT_ENTRY(void, InterpreterRuntime::_new(JavaThread* thread, ConstantPool* pool, int index)) - Klass* k_oop = pool->klass_at(index, CHECK); - instanceKlassHandle klass (THREAD, k_oop); + Klass* k = pool->klass_at(index, CHECK); + InstanceKlass* klass = InstanceKlass::cast(k); // Make sure we are not instantiating an abstract klass klass->check_valid_for_instantiation(true, CHECK); @@ -461,8 +461,8 @@ Exceptions::debug_check_abort(h_exception); // exception handler lookup - KlassHandle h_klass(THREAD, h_exception->klass()); - handler_bci = Method::fast_exception_handler_bci_for(h_method, h_klass, current_bci, THREAD); + Klass* klass = h_exception->klass(); + handler_bci = Method::fast_exception_handler_bci_for(h_method, klass, current_bci, THREAD); if (HAS_PENDING_EXCEPTION) { // We threw an exception while trying to find the exception handler. // Transfer the new exception to the exception handle which will @@ -1070,15 +1070,15 @@ // non-static field accessors have an object, but we need a handle h_obj = Handle(thread, obj); } - instanceKlassHandle h_cp_entry_f1(thread, (Klass*)cp_entry->f1_as_klass()); - jfieldID fid = jfieldIDWorkaround::to_jfieldID(h_cp_entry_f1, cp_entry->f2_as_index(), is_static); - JvmtiExport::post_field_access(thread, method(thread), bcp(thread), h_cp_entry_f1, h_obj, fid); + InstanceKlass* cp_entry_f1 = InstanceKlass::cast(cp_entry->f1_as_klass()); + jfieldID fid = jfieldIDWorkaround::to_jfieldID(cp_entry_f1, cp_entry->f2_as_index(), is_static); + JvmtiExport::post_field_access(thread, method(thread), bcp(thread), cp_entry_f1, h_obj, fid); IRT_END IRT_ENTRY(void, InterpreterRuntime::post_field_modification(JavaThread *thread, oopDesc* obj, ConstantPoolCacheEntry *cp_entry, jvalue *value)) - Klass* k = (Klass*)cp_entry->f1_as_klass(); + Klass* k = cp_entry->f1_as_klass(); // check the access_flags for the field in the klass InstanceKlass* ik = InstanceKlass::cast(k); @@ -1103,8 +1103,7 @@ bool is_static = (obj == NULL); HandleMark hm(thread); - instanceKlassHandle h_klass(thread, k); - jfieldID fid = jfieldIDWorkaround::to_jfieldID(h_klass, cp_entry->f2_as_index(), is_static); + jfieldID fid = jfieldIDWorkaround::to_jfieldID(ik, cp_entry->f2_as_index(), is_static); jvalue fvalue; #ifdef _LP64 fvalue = *value; @@ -1128,7 +1127,7 @@ h_obj = Handle(thread, obj); } - JvmtiExport::post_raw_field_modification(thread, method(thread), bcp(thread), h_klass, h_obj, + JvmtiExport::post_raw_field_modification(thread, method(thread), bcp(thread), ik, h_obj, fid, sig_type, &fvalue); IRT_END
--- a/hotspot/src/share/vm/interpreter/linkResolver.cpp Wed Mar 15 11:44:46 2017 +0100 +++ b/hotspot/src/share/vm/interpreter/linkResolver.cpp Wed Mar 15 10:25:37 2017 -0400 @@ -55,14 +55,14 @@ // Implementation of CallInfo -void CallInfo::set_static(KlassHandle resolved_klass, const methodHandle& resolved_method, TRAPS) { +void CallInfo::set_static(Klass* resolved_klass, const methodHandle& resolved_method, TRAPS) { int vtable_index = Method::nonvirtual_vtable_index; set_common(resolved_klass, resolved_klass, resolved_method, resolved_method, CallInfo::direct_call, vtable_index, CHECK); } -void CallInfo::set_interface(KlassHandle resolved_klass, - KlassHandle selected_klass, +void CallInfo::set_interface(Klass* resolved_klass, + Klass* selected_klass, const methodHandle& resolved_method, const methodHandle& selected_method, int itable_index, TRAPS) { @@ -75,8 +75,8 @@ set_common(resolved_klass, selected_klass, resolved_method, selected_method, CallInfo::itable_call, itable_index, CHECK); } -void CallInfo::set_virtual(KlassHandle resolved_klass, - KlassHandle selected_klass, +void CallInfo::set_virtual(Klass* resolved_klass, + Klass* selected_klass, const methodHandle& resolved_method, const methodHandle& selected_method, int vtable_index, TRAPS) { @@ -93,7 +93,7 @@ set_handle(SystemDictionary::MethodHandle_klass(), resolved_method, resolved_appendix, resolved_method_type, CHECK); } -void CallInfo::set_handle(KlassHandle resolved_klass, +void CallInfo::set_handle(Klass* resolved_klass, const methodHandle& resolved_method, Handle resolved_appendix, Handle resolved_method_type, TRAPS) { @@ -110,8 +110,8 @@ _resolved_method_type = resolved_method_type; } -void CallInfo::set_common(KlassHandle resolved_klass, - KlassHandle selected_klass, +void CallInfo::set_common(Klass* resolved_klass, + Klass* selected_klass, const methodHandle& resolved_method, const methodHandle& selected_method, CallKind kind, @@ -162,8 +162,8 @@ #ifdef ASSERT // Ensure that this is really the case. - KlassHandle object_klass = SystemDictionary::Object_klass(); - Method * object_resolved_method = object_klass()->vtable()->method_at(index); + Klass* object_klass = SystemDictionary::Object_klass(); + Method * object_resolved_method = object_klass->vtable()->method_at(index); assert(object_resolved_method->name() == resolved_method->name(), "Object and interface method names should match at vtable index %d, %s != %s", index, object_resolved_method->name()->as_C_string(), resolved_method->name()->as_C_string()); @@ -225,14 +225,13 @@ LinkInfo::LinkInfo(const constantPoolHandle& pool, int index, methodHandle current_method, TRAPS) { // resolve klass - Klass* result = pool->klass_ref_at(index, CHECK); - _resolved_klass = KlassHandle(THREAD, result); + _resolved_klass = pool->klass_ref_at(index, CHECK); // Get name, signature, and static klass _name = pool->name_ref_at(index); _signature = pool->signature_ref_at(index); _tag = pool->tag_ref_at(index); - _current_klass = KlassHandle(THREAD, pool->pool_holder()); + _current_klass = pool->pool_holder(); _current_method = current_method; // Coming from the constant pool always checks access @@ -241,14 +240,13 @@ LinkInfo::LinkInfo(const constantPoolHandle& pool, int index, TRAPS) { // resolve klass - Klass* result = pool->klass_ref_at(index, CHECK); - _resolved_klass = KlassHandle(THREAD, result); + _resolved_klass = pool->klass_ref_at(index, CHECK); // Get name, signature, and static klass _name = pool->name_ref_at(index); _signature = pool->signature_ref_at(index); _tag = pool->tag_ref_at(index); - _current_klass = KlassHandle(THREAD, pool->pool_holder()); + _current_klass = pool->pool_holder(); _current_method = methodHandle(); // Coming from the constant pool always checks access @@ -256,7 +254,7 @@ } char* LinkInfo::method_string() const { - return Method::name_and_sig_as_C_string(_resolved_klass(), _name, _signature); + return Method::name_and_sig_as_C_string(_resolved_klass, _name, _signature); } #ifndef PRODUCT @@ -266,20 +264,20 @@ _resolved_klass->name()->as_C_string(), _name->as_C_string(), _signature->as_C_string(), - _current_klass.is_null() ? "(none)" : _current_klass->name()->as_C_string(), + _current_klass == NULL ? "(none)" : _current_klass->name()->as_C_string(), _check_access ? "true" : "false"); } #endif // PRODUCT //------------------------------------------------------------------------------------------------------------------------ // Klass resolution -void LinkResolver::check_klass_accessability(KlassHandle ref_klass, KlassHandle sel_klass, TRAPS) { +void LinkResolver::check_klass_accessability(Klass* ref_klass, Klass* sel_klass, TRAPS) { Reflection::VerifyClassAccessResults vca_result = - Reflection::verify_class_access(ref_klass(), InstanceKlass::cast(sel_klass()), true); + Reflection::verify_class_access(ref_klass, InstanceKlass::cast(sel_klass), true); if (vca_result != Reflection::ACCESS_OK) { ResourceMark rm(THREAD); - char* msg = Reflection::verify_class_access_msg(ref_klass(), - InstanceKlass::cast(sel_klass()), + char* msg = Reflection::verify_class_access_msg(ref_klass, + InstanceKlass::cast(sel_klass), vca_result); if (msg == NULL) { Exceptions::fthrow( @@ -308,7 +306,7 @@ methodHandle LinkResolver::lookup_method_in_klasses(const LinkInfo& link_info, bool checkpolymorphism, bool in_imethod_resolve, TRAPS) { - KlassHandle klass = link_info.resolved_klass(); + Klass* klass = link_info.resolved_klass(); Symbol* name = link_info.name(); Symbol* signature = link_info.signature(); @@ -320,7 +318,7 @@ return methodHandle(THREAD, result); } - InstanceKlass* ik = InstanceKlass::cast(klass()); + InstanceKlass* ik = InstanceKlass::cast(klass); // JDK 8, JVMS 5.4.3.4: Interface method resolution should // ignore static and non-public methods of java.lang.Object, @@ -358,7 +356,7 @@ // returns first instance method // Looks up method in classes, then looks up local default methods -methodHandle LinkResolver::lookup_instance_method_in_klasses(KlassHandle klass, +methodHandle LinkResolver::lookup_instance_method_in_klasses(Klass* klass, Symbol* name, Symbol* signature, TRAPS) { Method* result = klass->uncached_lookup_method(name, signature, Klass::find_overpass); @@ -374,7 +372,7 @@ } if (result == NULL) { - Array<Method*>* default_methods = InstanceKlass::cast(klass())->default_methods(); + Array<Method*>* default_methods = InstanceKlass::cast(klass)->default_methods(); if (default_methods != NULL) { result = InstanceKlass::find_method(default_methods, name, signature); assert(result == NULL || !result->is_static(), "static defaults not allowed"); @@ -383,13 +381,13 @@ return methodHandle(THREAD, result); } -int LinkResolver::vtable_index_of_interface_method(KlassHandle klass, +int LinkResolver::vtable_index_of_interface_method(Klass* klass, const methodHandle& resolved_method) { int vtable_index = Method::invalid_vtable_index; Symbol* name = resolved_method->name(); Symbol* signature = resolved_method->signature(); - InstanceKlass* ik = InstanceKlass::cast(klass()); + InstanceKlass* ik = InstanceKlass::cast(klass); // First check in default method array if (!resolved_method->is_abstract() && ik->default_methods() != NULL) { @@ -410,7 +408,7 @@ } methodHandle LinkResolver::lookup_method_in_interfaces(const LinkInfo& cp_info, TRAPS) { - InstanceKlass *ik = InstanceKlass::cast(cp_info.resolved_klass()()); + InstanceKlass *ik = InstanceKlass::cast(cp_info.resolved_klass()); // Specify 'true' in order to skip default methods when searching the // interfaces. Function lookup_method_in_klasses() already looked for @@ -425,7 +423,7 @@ Handle *appendix_result_or_null, Handle *method_type_result, TRAPS) { - KlassHandle klass = link_info.resolved_klass(); + Klass* klass = link_info.resolved_klass(); Symbol* name = link_info.name(); Symbol* full_signature = link_info.signature(); @@ -436,8 +434,8 @@ vmIntrinsics::name_at(iid), klass->external_name(), name->as_C_string(), full_signature->as_C_string()); } - if ((klass() == SystemDictionary::MethodHandle_klass() || - klass() == SystemDictionary::VarHandle_klass()) && + if ((klass == SystemDictionary::MethodHandle_klass() || + klass == SystemDictionary::VarHandle_klass()) && iid != vmIntrinsics::_none) { if (MethodHandles::is_signature_polymorphic_intrinsic(iid)) { // Most of these do not need an up-call to Java to resolve, so can be done anywhere. @@ -531,9 +529,9 @@ return NULL; } -void LinkResolver::check_method_accessability(KlassHandle ref_klass, - KlassHandle resolved_klass, - KlassHandle sel_klass, +void LinkResolver::check_method_accessability(Klass* ref_klass, + Klass* resolved_klass, + Klass* sel_klass, const methodHandle& sel_method, TRAPS) { @@ -547,7 +545,7 @@ // We'll check for the method name first, as that's most likely // to be false (so we'll short-circuit out of these tests). if (sel_method->name() == vmSymbols::clone_name() && - sel_klass() == SystemDictionary::Object_klass() && + sel_klass == SystemDictionary::Object_klass() && resolved_klass->is_array_klass()) { // We need to change "protected" to "public". assert(flags.is_protected(), "clone not protected?"); @@ -558,9 +556,9 @@ } // assert(extra_arg_result_or_null != NULL, "must be able to return extra argument"); - if (!Reflection::verify_field_access(ref_klass(), - resolved_klass(), - sel_klass(), + if (!Reflection::verify_field_access(ref_klass, + resolved_klass, + sel_klass, flags, true)) { ResourceMark rm(THREAD); @@ -586,22 +584,21 @@ // It appears to fail when applied to an invokeinterface call site. // FIXME: Remove this method and ciMethod::check_call; refactor to use the other LinkResolver entry points. // resolve klass - KlassHandle resolved_klass; if (code == Bytecodes::_invokedynamic) { - resolved_klass = SystemDictionary::MethodHandle_klass(); + Klass* resolved_klass = SystemDictionary::MethodHandle_klass(); Symbol* method_name = vmSymbols::invoke_name(); Symbol* method_signature = pool->signature_ref_at(index); - KlassHandle current_klass(THREAD, pool->pool_holder()); + Klass* current_klass = pool->pool_holder(); LinkInfo link_info(resolved_klass, method_name, method_signature, current_klass); return resolve_method(link_info, code, THREAD); } LinkInfo link_info(pool, index, methodHandle(), CHECK_NULL); - resolved_klass = link_info.resolved_klass(); + Klass* resolved_klass = link_info.resolved_klass(); if (pool->has_preresolution() - || (resolved_klass() == SystemDictionary::MethodHandle_klass() && - MethodHandles::is_signature_polymorphic_name(resolved_klass(), link_info.name()))) { + || (resolved_klass == SystemDictionary::MethodHandle_klass() && + MethodHandles::is_signature_polymorphic_name(resolved_klass, link_info.name()))) { Method* result = ConstantPool::method_at_if_loaded(pool, index); if (result != NULL) { return methodHandle(THREAD, result); @@ -652,8 +649,8 @@ } void LinkResolver::check_field_loader_constraints(Symbol* field, Symbol* sig, - KlassHandle current_klass, - KlassHandle sel_klass, TRAPS) { + Klass* current_klass, + Klass* sel_klass, TRAPS) { Handle ref_loader(THREAD, current_klass->class_loader()); Handle sel_loader(THREAD, sel_klass->class_loader()); @@ -686,14 +683,14 @@ Bytecodes::Code code, TRAPS) { Handle nested_exception; - KlassHandle resolved_klass = link_info.resolved_klass(); + Klass* resolved_klass = link_info.resolved_klass(); // 1. For invokevirtual, cannot call an interface method if (code == Bytecodes::_invokevirtual && resolved_klass->is_interface()) { ResourceMark rm(THREAD); char buf[200]; jio_snprintf(buf, sizeof(buf), "Found interface %s, but class was expected", - resolved_klass()->external_name()); + resolved_klass->external_name()); THROW_MSG_NULL(vmSymbols::java_lang_IncompatibleClassChangeError(), buf); } @@ -727,21 +724,21 @@ if (resolved_method.is_null()) { ResourceMark rm(THREAD); THROW_MSG_CAUSE_(vmSymbols::java_lang_NoSuchMethodError(), - Method::name_and_sig_as_C_string(resolved_klass(), + Method::name_and_sig_as_C_string(resolved_klass, link_info.name(), link_info.signature()), nested_exception, NULL); } - // 6. access checks, access checking may be turned off when calling from within the VM. - KlassHandle current_klass = link_info.current_klass(); + // 5. access checks, access checking may be turned off when calling from within the VM. + Klass* current_klass = link_info.current_klass(); if (link_info.check_access()) { - assert(current_klass.not_null() , "current_klass should not be null"); + assert(current_klass != NULL , "current_klass should not be null"); // check if method can be accessed by the referring class check_method_accessability(current_klass, resolved_klass, - KlassHandle(THREAD, resolved_method->method_holder()), + resolved_method->method_holder(), resolved_method, CHECK_NULL); @@ -753,8 +750,8 @@ } static void trace_method_resolution(const char* prefix, - KlassHandle klass, - KlassHandle resolved_klass, + Klass* klass, + Klass* resolved_klass, const methodHandle& method, bool logitables, int index = -1) { @@ -768,9 +765,9 @@ } st->print("%s%s, compile-time-class:%s, method:%s, method_holder:%s, access_flags: ", prefix, - (klass.is_null() ? "<NULL>" : klass->internal_name()), - (resolved_klass.is_null() ? "<NULL>" : resolved_klass->internal_name()), - Method::name_and_sig_as_C_string(resolved_klass(), + (klass == NULL ? "<NULL>" : klass->internal_name()), + (resolved_klass == NULL ? "<NULL>" : resolved_klass->internal_name()), + Method::name_and_sig_as_C_string(resolved_klass, method->name(), method->signature()), method->method_holder()->internal_name()); @@ -785,13 +782,13 @@ // Do linktime resolution of a method in the interface within the context of the specied bytecode. methodHandle LinkResolver::resolve_interface_method(const LinkInfo& link_info, Bytecodes::Code code, TRAPS) { - KlassHandle resolved_klass = link_info.resolved_klass(); + Klass* resolved_klass = link_info.resolved_klass(); // check if klass is interface if (!resolved_klass->is_interface()) { ResourceMark rm(THREAD); char buf[200]; - jio_snprintf(buf, sizeof(buf), "Found class %s, but interface was expected", resolved_klass()->external_name()); + jio_snprintf(buf, sizeof(buf), "Found class %s, but interface was expected", resolved_klass->external_name()); THROW_MSG_NULL(vmSymbols::java_lang_IncompatibleClassChangeError(), buf); } @@ -816,21 +813,21 @@ // no method found ResourceMark rm(THREAD); THROW_MSG_NULL(vmSymbols::java_lang_NoSuchMethodError(), - Method::name_and_sig_as_C_string(resolved_klass(), + Method::name_and_sig_as_C_string(resolved_klass, link_info.name(), link_info.signature())); } if (link_info.check_access()) { // JDK8 adds non-public interface methods, and accessability check requirement - KlassHandle current_klass = link_info.current_klass(); + Klass* current_klass = link_info.current_klass(); - assert(current_klass.not_null() , "current_klass should not be null"); + assert(current_klass != NULL , "current_klass should not be null"); // check if method can be accessed by the referring class check_method_accessability(current_klass, resolved_klass, - KlassHandle(THREAD, resolved_method->method_holder()), + resolved_method->method_holder(), resolved_method, CHECK_NULL); @@ -841,7 +838,7 @@ ResourceMark rm(THREAD); char buf[200]; jio_snprintf(buf, sizeof(buf), "Expected instance not static method %s", - Method::name_and_sig_as_C_string(resolved_klass(), + Method::name_and_sig_as_C_string(resolved_klass, resolved_method->name(), resolved_method->signature())); THROW_MSG_NULL(vmSymbols::java_lang_IncompatibleClassChangeError(), buf); } @@ -850,12 +847,12 @@ ResourceMark rm(THREAD); char buf[200]; - KlassHandle current_klass = link_info.current_klass(); + Klass* current_klass = link_info.current_klass(); jio_snprintf(buf, sizeof(buf), "private interface method requires invokespecial, not invokeinterface: method %s, caller-class:%s", - Method::name_and_sig_as_C_string(resolved_klass(), + Method::name_and_sig_as_C_string(resolved_klass, resolved_method->name(), resolved_method->signature()), - (current_klass.is_null() ? "<NULL>" : current_klass->internal_name())); + (current_klass == NULL ? "<NULL>" : current_klass->internal_name())); THROW_MSG_NULL(vmSymbols::java_lang_IncompatibleClassChangeError(), buf); } @@ -873,14 +870,14 @@ //------------------------------------------------------------------------------------------------------------------------ // Field resolution -void LinkResolver::check_field_accessability(KlassHandle ref_klass, - KlassHandle resolved_klass, - KlassHandle sel_klass, +void LinkResolver::check_field_accessability(Klass* ref_klass, + Klass* resolved_klass, + Klass* sel_klass, const fieldDescriptor& fd, TRAPS) { - if (!Reflection::verify_field_access(ref_klass(), - resolved_klass(), - sel_klass(), + if (!Reflection::verify_field_access(ref_klass, + resolved_klass, + sel_klass, fd.access_flags(), true)) { ResourceMark rm(THREAD); @@ -913,19 +910,19 @@ bool is_static = (byte == Bytecodes::_getstatic || byte == Bytecodes::_putstatic); bool is_put = (byte == Bytecodes::_putfield || byte == Bytecodes::_putstatic || byte == Bytecodes::_nofast_putfield); // Check if there's a resolved klass containing the field - KlassHandle resolved_klass = link_info.resolved_klass(); + Klass* resolved_klass = link_info.resolved_klass(); Symbol* field = link_info.name(); Symbol* sig = link_info.signature(); - if (resolved_klass.is_null()) { + if (resolved_klass == NULL) { ResourceMark rm(THREAD); THROW_MSG(vmSymbols::java_lang_NoSuchFieldError(), field->as_C_string()); } // Resolve instance field - KlassHandle sel_klass(THREAD, resolved_klass->find_field(field, sig, &fd)); + Klass* sel_klass = resolved_klass->find_field(field, sig, &fd); // check if field exists; i.e., if a klass containing the field def has been selected - if (sel_klass.is_null()) { + if (sel_klass == NULL) { ResourceMark rm(THREAD); THROW_MSG(vmSymbols::java_lang_NoSuchFieldError(), field->as_C_string()); } @@ -935,14 +932,14 @@ return; // check access - KlassHandle current_klass = link_info.current_klass(); + Klass* current_klass = link_info.current_klass(); check_field_accessability(current_klass, resolved_klass, sel_klass, fd, CHECK); // check for errors if (is_static != fd.is_static()) { ResourceMark rm(THREAD); char msg[200]; - jio_snprintf(msg, sizeof(msg), "Expected %s field %s.%s", is_static ? "static" : "non-static", resolved_klass()->external_name(), fd.name()->as_C_string()); + jio_snprintf(msg, sizeof(msg), "Expected %s field %s.%s", is_static ? "static" : "non-static", resolved_klass->external_name(), fd.name()->as_C_string()); THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(), msg); } @@ -954,10 +951,10 @@ ResourceMark rm(THREAD); stringStream ss; - if (sel_klass() != current_klass()) { + if (sel_klass != current_klass) { ss.print("Update to %s final field %s.%s attempted from a different class (%s) than the field's declaring class", - is_static ? "static" : "non-static", resolved_klass()->external_name(), fd.name()->as_C_string(), - current_klass()->external_name()); + is_static ? "static" : "non-static", resolved_klass->external_name(), fd.name()->as_C_string(), + current_klass->external_name()); THROW_MSG(vmSymbols::java_lang_IllegalAccessError(), ss.as_string()); } @@ -973,7 +970,7 @@ if (is_initialized_static_final_update || is_initialized_instance_final_update) { ss.print("Update to %s final field %s.%s attempted from a different method (%s) than the initializer method %s ", - is_static ? "static" : "non-static", resolved_klass()->external_name(), fd.name()->as_C_string(), + is_static ? "static" : "non-static", resolved_klass->external_name(), fd.name()->as_C_string(), m()->name()->as_C_string(), is_static ? "<clinit>" : "<init>"); THROW_MSG(vmSymbols::java_lang_IllegalAccessError(), ss.as_string()); @@ -991,7 +988,7 @@ sel_klass->initialize(CHECK); } - if (sel_klass() != current_klass()) { + if (sel_klass != current_klass) { check_field_loader_constraints(field, sig, current_klass, sel_klass, CHECK); } @@ -1017,7 +1014,7 @@ methodHandle resolved_method = linktime_resolve_static_method(link_info, CHECK); // The resolved class can change as a result of this resolution. - KlassHandle resolved_klass(THREAD, resolved_method->method_holder()); + Klass* resolved_klass = resolved_method->method_holder(); // Initialize klass (this should only happen if everything is ok) if (initialize_class && resolved_klass->should_be_initialized()) { @@ -1036,7 +1033,7 @@ // throws linktime exceptions methodHandle LinkResolver::linktime_resolve_static_method(const LinkInfo& link_info, TRAPS) { - KlassHandle resolved_klass = link_info.resolved_klass(); + Klass* resolved_klass = link_info.resolved_klass(); methodHandle resolved_method; if (!resolved_klass->is_interface()) { resolved_method = resolve_method(link_info, Bytecodes::_invokestatic, CHECK_NULL); @@ -1049,7 +1046,7 @@ if (!resolved_method->is_static()) { ResourceMark rm(THREAD); char buf[200]; - jio_snprintf(buf, sizeof(buf), "Expected static method %s", Method::name_and_sig_as_C_string(resolved_klass(), + jio_snprintf(buf, sizeof(buf), "Expected static method %s", Method::name_and_sig_as_C_string(resolved_klass, resolved_method->name(), resolved_method->signature())); THROW_MSG_NULL(vmSymbols::java_lang_IncompatibleClassChangeError(), buf); @@ -1078,7 +1075,7 @@ // superclass.method, which can also resolve to a default method // and the selected method is recalculated relative to the direct superclass // superinterface.method, which explicitly does not check shadowing - KlassHandle resolved_klass = link_info.resolved_klass(); + Klass* resolved_klass = link_info.resolved_klass(); methodHandle resolved_method; if (!resolved_klass->is_interface()) { @@ -1089,7 +1086,7 @@ // check if method name is <init>, that it is found in same klass as static type if (resolved_method->name() == vmSymbols::object_initializer_name() && - resolved_method->method_holder() != resolved_klass()) { + resolved_method->method_holder() != resolved_klass) { ResourceMark rm(THREAD); Exceptions::fthrow( THREAD_AND_LOCATION, @@ -1103,24 +1100,25 @@ } // check if invokespecial's interface method reference is in an indirect superinterface - KlassHandle current_klass = link_info.current_klass(); - if (!current_klass.is_null() && resolved_klass->is_interface()) { - Klass *klass_to_check = !InstanceKlass::cast(current_klass())->is_anonymous() ? - current_klass() : - InstanceKlass::cast(current_klass())->host_klass(); + Klass* current_klass = link_info.current_klass(); + if (current_klass != NULL && resolved_klass->is_interface()) { + InstanceKlass* ck = InstanceKlass::cast(current_klass); + InstanceKlass *klass_to_check = !ck->is_anonymous() ? + ck : + InstanceKlass::cast(ck->host_klass()); // Disable verification for the dynamically-generated reflection bytecodes. bool is_reflect = klass_to_check->is_subclass_of( SystemDictionary::reflect_MagicAccessorImpl_klass()); if (!is_reflect && - !InstanceKlass::cast(klass_to_check)->is_same_or_direct_interface(resolved_klass())) { + !klass_to_check->is_same_or_direct_interface(resolved_klass)) { ResourceMark rm(THREAD); char buf[200]; jio_snprintf(buf, sizeof(buf), "Interface method reference: %s, is in an indirect superinterface of %s", - Method::name_and_sig_as_C_string(resolved_klass(), - resolved_method->name(), - resolved_method->signature()), + Method::name_and_sig_as_C_string(resolved_klass, + resolved_method->name(), + resolved_method->signature()), current_klass->external_name()); THROW_MSG_NULL(vmSymbols::java_lang_IncompatibleClassChangeError(), buf); } @@ -1132,7 +1130,7 @@ char buf[200]; jio_snprintf(buf, sizeof(buf), "Expecting non-static method %s", - Method::name_and_sig_as_C_string(resolved_klass(), + Method::name_and_sig_as_C_string(resolved_klass, resolved_method->name(), resolved_method->signature())); THROW_MSG_NULL(vmSymbols::java_lang_IncompatibleClassChangeError(), buf); @@ -1149,8 +1147,8 @@ // throws runtime exceptions void LinkResolver::runtime_resolve_special_method(CallInfo& result, const methodHandle& resolved_method, - KlassHandle resolved_klass, - KlassHandle current_klass, + Klass* resolved_klass, + Klass* current_klass, bool check_access, TRAPS) { // resolved method is selected method unless we have an old-style lookup @@ -1160,33 +1158,29 @@ methodHandle sel_method(THREAD, resolved_method()); // check if this is an old-style super call and do a new lookup if so - { KlassHandle method_klass = KlassHandle(THREAD, - resolved_method->method_holder()); - - if (check_access && - // a) check if ACC_SUPER flag is set for the current class - (current_klass->is_super() || !AllowNonVirtualCalls) && - // b) check if the class of the resolved_klass is a superclass - // (not supertype in order to exclude interface classes) of the current class. - // This check is not performed for super.invoke for interface methods - // in super interfaces. - current_klass->is_subclass_of(resolved_klass()) && - current_klass() != resolved_klass() && - // c) check if the method is not <init> - resolved_method->name() != vmSymbols::object_initializer_name()) { - // Lookup super method - KlassHandle super_klass(THREAD, current_klass->super()); - sel_method = lookup_instance_method_in_klasses(super_klass, - resolved_method->name(), - resolved_method->signature(), CHECK); - // check if found - if (sel_method.is_null()) { - ResourceMark rm(THREAD); - THROW_MSG(vmSymbols::java_lang_AbstractMethodError(), - Method::name_and_sig_as_C_string(resolved_klass(), - resolved_method->name(), - resolved_method->signature())); - } + if (check_access && + // a) check if ACC_SUPER flag is set for the current class + (current_klass->is_super() || !AllowNonVirtualCalls) && + // b) check if the class of the resolved_klass is a superclass + // (not supertype in order to exclude interface classes) of the current class. + // This check is not performed for super.invoke for interface methods + // in super interfaces. + current_klass->is_subclass_of(resolved_klass) && + current_klass != resolved_klass && + // c) check if the method is not <init> + resolved_method->name() != vmSymbols::object_initializer_name()) { + // Lookup super method + Klass* super_klass = current_klass->super(); + sel_method = lookup_instance_method_in_klasses(super_klass, + resolved_method->name(), + resolved_method->signature(), CHECK); + // check if found + if (sel_method.is_null()) { + ResourceMark rm(THREAD); + THROW_MSG(vmSymbols::java_lang_AbstractMethodError(), + Method::name_and_sig_as_C_string(resolved_klass, + resolved_method->name(), + resolved_method->signature())); } } @@ -1194,9 +1188,9 @@ if (sel_method->is_static()) { ResourceMark rm(THREAD); char buf[200]; - jio_snprintf(buf, sizeof(buf), "Expecting non-static method %s", Method::name_and_sig_as_C_string(resolved_klass(), - resolved_method->name(), - resolved_method->signature())); + jio_snprintf(buf, sizeof(buf), "Expecting non-static method %s", Method::name_and_sig_as_C_string(resolved_klass, + resolved_method->name(), + resolved_method->signature())); THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(), buf); } @@ -1204,7 +1198,7 @@ if (sel_method->is_abstract()) { ResourceMark rm(THREAD); THROW_MSG(vmSymbols::java_lang_AbstractMethodError(), - Method::name_and_sig_as_C_string(resolved_klass(), + Method::name_and_sig_as_C_string(resolved_klass, sel_method->name(), sel_method->signature())); } @@ -1218,7 +1212,7 @@ result.set_static(resolved_klass, sel_method, CHECK); } -void LinkResolver::resolve_virtual_call(CallInfo& result, Handle recv, KlassHandle receiver_klass, +void LinkResolver::resolve_virtual_call(CallInfo& result, Handle recv, Klass* receiver_klass, const LinkInfo& link_info, bool check_null_and_abstract, TRAPS) { methodHandle resolved_method = linktime_resolve_virtual_method(link_info, CHECK); @@ -1238,18 +1232,18 @@ assert(resolved_method->name() != vmSymbols::class_initializer_name (), "should have been checked in verifier"); // check if private interface method - KlassHandle resolved_klass = link_info.resolved_klass(); - KlassHandle current_klass = link_info.current_klass(); + Klass* resolved_klass = link_info.resolved_klass(); + Klass* current_klass = link_info.current_klass(); // This is impossible, if resolve_klass is an interface, we've thrown icce in resolve_method if (resolved_klass->is_interface() && resolved_method->is_private()) { ResourceMark rm(THREAD); char buf[200]; jio_snprintf(buf, sizeof(buf), "private interface method requires invokespecial, not invokevirtual: method %s, caller-class:%s", - Method::name_and_sig_as_C_string(resolved_klass(), + Method::name_and_sig_as_C_string(resolved_klass, resolved_method->name(), resolved_method->signature()), - (current_klass.is_null() ? "<NULL>" : current_klass->internal_name())); + (current_klass == NULL ? "<NULL>" : current_klass->internal_name())); THROW_MSG_NULL(vmSymbols::java_lang_IncompatibleClassChangeError(), buf); } @@ -1257,9 +1251,9 @@ if (resolved_method->is_static()) { ResourceMark rm(THREAD); char buf[200]; - jio_snprintf(buf, sizeof(buf), "Expecting non-static method %s", Method::name_and_sig_as_C_string(resolved_klass(), - resolved_method->name(), - resolved_method->signature())); + jio_snprintf(buf, sizeof(buf), "Expecting non-static method %s", Method::name_and_sig_as_C_string(resolved_klass, + resolved_method->name(), + resolved_method->signature())); THROW_MSG_NULL(vmSymbols::java_lang_IncompatibleClassChangeError(), buf); } @@ -1274,9 +1268,9 @@ // throws runtime exceptions void LinkResolver::runtime_resolve_virtual_method(CallInfo& result, const methodHandle& resolved_method, - KlassHandle resolved_klass, + Klass* resolved_klass, Handle recv, - KlassHandle recv_klass, + Klass* recv_klass, bool check_null_and_abstract, TRAPS) { @@ -1325,18 +1319,18 @@ if (selected_method.is_null()) { ResourceMark rm(THREAD); THROW_MSG(vmSymbols::java_lang_AbstractMethodError(), - Method::name_and_sig_as_C_string(resolved_klass(), - resolved_method->name(), - resolved_method->signature())); + Method::name_and_sig_as_C_string(resolved_klass, + resolved_method->name(), + resolved_method->signature())); } // check if abstract if (check_null_and_abstract && selected_method->is_abstract()) { ResourceMark rm(THREAD); THROW_MSG(vmSymbols::java_lang_AbstractMethodError(), - Method::name_and_sig_as_C_string(resolved_klass(), - selected_method->name(), - selected_method->signature())); + Method::name_and_sig_as_C_string(resolved_klass, + selected_method->name(), + selected_method->signature())); } if (log_develop_is_enabled(Trace, vtables)) { @@ -1348,7 +1342,7 @@ result.set_virtual(resolved_klass, recv_klass, resolved_method, selected_method, vtable_index, CHECK); } -void LinkResolver::resolve_interface_call(CallInfo& result, Handle recv, KlassHandle recv_klass, +void LinkResolver::resolve_interface_call(CallInfo& result, Handle recv, Klass* recv_klass, const LinkInfo& link_info, bool check_null_and_abstract, TRAPS) { // throws linktime exceptions @@ -1370,9 +1364,9 @@ // throws runtime exceptions void LinkResolver::runtime_resolve_interface_method(CallInfo& result, const methodHandle& resolved_method, - KlassHandle resolved_klass, + Klass* resolved_klass, Handle recv, - KlassHandle recv_klass, + Klass* recv_klass, bool check_null_and_abstract, TRAPS) { // check if receiver exists if (check_null_and_abstract && recv.is_null()) { @@ -1380,12 +1374,12 @@ } // check if receiver klass implements the resolved interface - if (!recv_klass->is_subtype_of(resolved_klass())) { + if (!recv_klass->is_subtype_of(resolved_klass)) { ResourceMark rm(THREAD); char buf[200]; jio_snprintf(buf, sizeof(buf), "Class %s does not implement the requested interface %s", - recv_klass()->external_name(), - resolved_klass()->external_name()); + recv_klass->external_name(), + resolved_klass->external_name()); THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(), buf); } @@ -1405,7 +1399,7 @@ if (sel_method.is_null()) { ResourceMark rm(THREAD); THROW_MSG(vmSymbols::java_lang_AbstractMethodError(), - Method::name_and_sig_as_C_string(recv_klass(), + Method::name_and_sig_as_C_string(recv_klass, resolved_method->name(), resolved_method->signature())); } @@ -1414,7 +1408,7 @@ if (!sel_method->is_public()) { ResourceMark rm(THREAD); THROW_MSG(vmSymbols::java_lang_IllegalAccessError(), - Method::name_and_sig_as_C_string(recv_klass(), + Method::name_and_sig_as_C_string(recv_klass, sel_method->name(), sel_method->signature())); } @@ -1422,9 +1416,9 @@ if (check_null_and_abstract && sel_method->is_abstract()) { ResourceMark rm(THREAD); THROW_MSG(vmSymbols::java_lang_AbstractMethodError(), - Method::name_and_sig_as_C_string(recv_klass(), - sel_method->name(), - sel_method->signature())); + Method::name_and_sig_as_C_string(recv_klass, + sel_method->name(), + sel_method->signature())); } if (log_develop_is_enabled(Trace, itables)) { @@ -1468,7 +1462,7 @@ } methodHandle LinkResolver::resolve_virtual_call_or_null( - KlassHandle receiver_klass, + Klass* receiver_klass, const LinkInfo& link_info) { EXCEPTION_MARK; CallInfo info; @@ -1481,7 +1475,7 @@ } methodHandle LinkResolver::resolve_interface_call_or_null( - KlassHandle receiver_klass, + Klass* receiver_klass, const LinkInfo& link_info) { EXCEPTION_MARK; CallInfo info; @@ -1493,7 +1487,7 @@ return info.selected_method(); } -int LinkResolver::resolve_virtual_vtable_index(KlassHandle receiver_klass, +int LinkResolver::resolve_virtual_vtable_index(Klass* receiver_klass, const LinkInfo& link_info) { EXCEPTION_MARK; CallInfo info; @@ -1548,7 +1542,7 @@ void LinkResolver::resolve_invoke(CallInfo& result, Handle& recv, const methodHandle& attached_method, Bytecodes::Code byte, TRAPS) { - KlassHandle defc = attached_method->method_holder(); + Klass* defc = attached_method->method_holder(); Symbol* name = attached_method->name(); Symbol* type = attached_method->signature(); LinkInfo link_info(defc, name, type); @@ -1589,14 +1583,14 @@ TRAPS) { LinkInfo link_info(pool, index, CHECK); - KlassHandle recvrKlass (THREAD, recv.is_null() ? (Klass*)NULL : recv->klass()); + Klass* recvrKlass = recv.is_null() ? (Klass*)NULL : recv->klass(); resolve_virtual_call(result, recv, recvrKlass, link_info, /*check_null_or_abstract*/true, CHECK); } void LinkResolver::resolve_invokeinterface(CallInfo& result, Handle recv, const constantPoolHandle& pool, int index, TRAPS) { LinkInfo link_info(pool, index, CHECK); - KlassHandle recvrKlass (THREAD, recv.is_null() ? (Klass*)NULL : recv->klass()); + Klass* recvrKlass = recv.is_null() ? (Klass*)NULL : recv->klass(); resolve_interface_call(result, recv, recvrKlass, link_info, true, CHECK); } @@ -1616,9 +1610,9 @@ const LinkInfo& link_info, TRAPS) { // JSR 292: this must be an implicitly generated method MethodHandle.invokeExact(*...) or similar - KlassHandle resolved_klass = link_info.resolved_klass(); - assert(resolved_klass() == SystemDictionary::MethodHandle_klass() || - resolved_klass() == SystemDictionary::VarHandle_klass(), ""); + Klass* resolved_klass = link_info.resolved_klass(); + assert(resolved_klass == SystemDictionary::MethodHandle_klass() || + resolved_klass == SystemDictionary::VarHandle_klass(), ""); assert(MethodHandles::is_signature_polymorphic_name(link_info.name()), ""); Handle resolved_appendix; Handle resolved_method_type; @@ -1655,7 +1649,7 @@ void LinkResolver::resolve_invokedynamic(CallInfo& result, const constantPoolHandle& pool, int index, TRAPS) { Symbol* method_name = pool->name_ref_at(index); Symbol* method_signature = pool->signature_ref_at(index); - KlassHandle current_klass = KlassHandle(THREAD, pool->pool_holder()); + Klass* current_klass = pool->pool_holder(); // Resolve the bootstrap specifier (BSM + optional arguments). Handle bootstrap_specifier; @@ -1693,7 +1687,7 @@ void LinkResolver::resolve_dynamic_call(CallInfo& result, Handle bootstrap_specifier, Symbol* method_name, Symbol* method_signature, - KlassHandle current_klass, + Klass* current_klass, TRAPS) { // JSR 292: this must resolve to an implicitly generated method MH.linkToCallSite(*...) // The appendix argument is likely to be a freshly-created CallSite.
--- a/hotspot/src/share/vm/interpreter/linkResolver.hpp Wed Mar 15 11:44:46 2017 +0100 +++ b/hotspot/src/share/vm/interpreter/linkResolver.hpp Wed Mar 15 10:25:37 2017 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2017, 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 @@ -47,8 +47,8 @@ unknown_kind = -1 }; private: - KlassHandle _resolved_klass; // static receiver klass, resolved from a symbolic reference - KlassHandle _selected_klass; // dynamic receiver class (same as static, or subklass) + Klass* _resolved_klass; // static receiver klass, resolved from a symbolic reference + Klass* _selected_klass; // dynamic receiver class (same as static, or subklass) methodHandle _resolved_method; // static target method methodHandle _selected_method; // dynamic (actual) target method CallKind _call_kind; // kind of call (static(=bytecode static/special + @@ -57,21 +57,21 @@ Handle _resolved_appendix; // extra argument in constant pool (if CPCE::has_appendix) Handle _resolved_method_type; // MethodType (for invokedynamic and invokehandle call sites) - void set_static(KlassHandle resolved_klass, const methodHandle& resolved_method, TRAPS); - void set_interface(KlassHandle resolved_klass, KlassHandle selected_klass, + void set_static(Klass* resolved_klass, const methodHandle& resolved_method, TRAPS); + void set_interface(Klass* resolved_klass, Klass* selected_klass, const methodHandle& resolved_method, const methodHandle& selected_method, int itable_index, TRAPS); - void set_virtual(KlassHandle resolved_klass, KlassHandle selected_klass, + void set_virtual(Klass* resolved_klass, Klass* selected_klass, const methodHandle& resolved_method, const methodHandle& selected_method, int vtable_index, TRAPS); void set_handle(const methodHandle& resolved_method, Handle resolved_appendix, Handle resolved_method_type, TRAPS); - void set_handle(KlassHandle resolved_klass, + void set_handle(Klass* resolved_klass, const methodHandle& resolved_method, Handle resolved_appendix, Handle resolved_method_type, TRAPS); - void set_common(KlassHandle resolved_klass, KlassHandle selected_klass, + void set_common(Klass* resolved_klass, Klass* selected_klass, const methodHandle& resolved_method, const methodHandle& selected_method, CallKind kind, @@ -91,8 +91,8 @@ // does not queue the method for compilation CallInfo(Method* resolved_method, Klass* resolved_klass = NULL); - KlassHandle resolved_klass() const { return _resolved_klass; } - KlassHandle selected_klass() const { return _selected_klass; } + Klass* resolved_klass() const { return _resolved_klass; } + Klass* selected_klass() const { return _selected_klass; } methodHandle resolved_method() const { return _resolved_method; } methodHandle selected_method() const { return _selected_method; } Handle resolved_appendix() const { return _resolved_appendix; } @@ -135,8 +135,8 @@ class LinkInfo : public StackObj { Symbol* _name; // extracted from JVM_CONSTANT_NameAndType Symbol* _signature; - KlassHandle _resolved_klass; // class that the constant pool entry points to - KlassHandle _current_klass; // class that owns the constant pool + Klass* _resolved_klass; // class that the constant pool entry points to + Klass* _current_klass; // class that owns the constant pool methodHandle _current_method; // sending method bool _check_access; constantTag _tag; @@ -151,14 +151,14 @@ LinkInfo(const constantPoolHandle& pool, int index, TRAPS); // Condensed information from other call sites within the vm. - LinkInfo(KlassHandle resolved_klass, Symbol* name, Symbol* signature, KlassHandle current_klass, + LinkInfo(Klass* resolved_klass, Symbol* name, Symbol* signature, Klass* current_klass, AccessCheck check_access = needs_access_check, constantTag tag = JVM_CONSTANT_Invalid) : _resolved_klass(resolved_klass), - _name(name), _signature(signature), _current_klass(current_klass), _current_method(NULL), + _name(name), _signature(signature), _current_klass(current_klass), _current_method(methodHandle()), _check_access(check_access == needs_access_check), _tag(tag) {} - LinkInfo(KlassHandle resolved_klass, Symbol* name, Symbol* signature, methodHandle current_method, + LinkInfo(Klass* resolved_klass, Symbol* name, Symbol* signature, methodHandle current_method, AccessCheck check_access = needs_access_check, constantTag tag = JVM_CONSTANT_Invalid) : _resolved_klass(resolved_klass), @@ -166,16 +166,16 @@ _check_access(check_access == needs_access_check), _tag(tag) {} // Case where we just find the method and don't check access against the current class - LinkInfo(KlassHandle resolved_klass, Symbol*name, Symbol* signature) : + LinkInfo(Klass* resolved_klass, Symbol*name, Symbol* signature) : _resolved_klass(resolved_klass), - _name(name), _signature(signature), _current_klass(NULL), _current_method(NULL), + _name(name), _signature(signature), _current_klass(NULL), _current_method(methodHandle()), _check_access(false), _tag(JVM_CONSTANT_Invalid) {} // accessors Symbol* name() const { return _name; } Symbol* signature() const { return _signature; } - KlassHandle resolved_klass() const { return _resolved_klass; } - KlassHandle current_klass() const { return _current_klass; } + Klass* resolved_klass() const { return _resolved_klass; } + Klass* current_klass() const { return _current_klass; } methodHandle current_method() const { return _current_method; } constantTag tag() const { return _tag; } bool check_access() const { return _check_access; } @@ -206,7 +206,7 @@ JVMCI_ONLY(public:) // Needed for CompilerToVM.resolveMethod() // Not Linktime so doesn't take LinkInfo static methodHandle lookup_instance_method_in_klasses ( - KlassHandle klass, Symbol* name, Symbol* signature, TRAPS); + Klass* klass, Symbol* name, Symbol* signature, TRAPS); JVMCI_ONLY(private:) // Similar loader constraint checking functions that throw @@ -215,8 +215,8 @@ const methodHandle& resolved_method, const char* method_type, TRAPS); static void check_field_loader_constraints(Symbol* field, Symbol* sig, - KlassHandle current_klass, - KlassHandle sel_klass, TRAPS); + Klass* current_klass, + Klass* sel_klass, TRAPS); static methodHandle resolve_interface_method(const LinkInfo& link_info, Bytecodes::Code code, TRAPS); static methodHandle resolve_method (const LinkInfo& link_info, Bytecodes::Code code, TRAPS); @@ -228,29 +228,29 @@ static void runtime_resolve_special_method (CallInfo& result, const methodHandle& resolved_method, - KlassHandle resolved_klass, - KlassHandle current_klass, + Klass* resolved_klass, + Klass* current_klass, bool check_access, TRAPS); static void runtime_resolve_virtual_method (CallInfo& result, const methodHandle& resolved_method, - KlassHandle resolved_klass, + Klass* resolved_klass, Handle recv, - KlassHandle recv_klass, + Klass* recv_klass, bool check_null_and_abstract, TRAPS); static void runtime_resolve_interface_method (CallInfo& result, const methodHandle& resolved_method, - KlassHandle resolved_klass, + Klass* resolved_klass, Handle recv, - KlassHandle recv_klass, + Klass* recv_klass, bool check_null_and_abstract, TRAPS); - static void check_field_accessability(KlassHandle ref_klass, - KlassHandle resolved_klass, - KlassHandle sel_klass, + static void check_field_accessability(Klass* ref_klass, + Klass* resolved_klass, + Klass* sel_klass, const fieldDescriptor& fd, TRAPS); - static void check_method_accessability(KlassHandle ref_klass, - KlassHandle resolved_klass, - KlassHandle sel_klass, + static void check_method_accessability(Klass* ref_klass, + Klass* resolved_klass, + Klass* sel_klass, const methodHandle& sel_method, TRAPS); // runtime resolving from constant pool @@ -268,7 +268,7 @@ const constantPoolHandle& pool, int index, TRAPS); public: // constant pool resolving - static void check_klass_accessability(KlassHandle ref_klass, KlassHandle sel_klass, TRAPS); + static void check_klass_accessability(Klass* ref_klass, Klass* sel_klass, TRAPS); // static resolving calls (will not run any Java code); // used only from Bytecode_invoke::static_target @@ -291,31 +291,31 @@ static void resolve_special_call (CallInfo& result, const LinkInfo& link_info, TRAPS); - static void resolve_virtual_call (CallInfo& result, Handle recv, KlassHandle recv_klass, + static void resolve_virtual_call (CallInfo& result, Handle recv, Klass* recv_klass, const LinkInfo& link_info, bool check_null_and_abstract, TRAPS); - static void resolve_interface_call(CallInfo& result, Handle recv, KlassHandle recv_klass, + static void resolve_interface_call(CallInfo& result, Handle recv, Klass* recv_klass, const LinkInfo& link_info, bool check_null_and_abstract, TRAPS); static void resolve_handle_call (CallInfo& result, const LinkInfo& link_info, TRAPS); static void resolve_dynamic_call (CallInfo& result, Handle bootstrap_specifier, Symbol* method_name, Symbol* method_signature, - KlassHandle current_klass, TRAPS); + Klass* current_klass, TRAPS); // same as above for compile-time resolution; but returns null handle instead of throwing // an exception on error also, does not initialize klass (i.e., no side effects) - static methodHandle resolve_virtual_call_or_null (KlassHandle receiver_klass, + static methodHandle resolve_virtual_call_or_null (Klass* receiver_klass, const LinkInfo& link_info); - static methodHandle resolve_interface_call_or_null(KlassHandle receiver_klass, + static methodHandle resolve_interface_call_or_null(Klass* receiver_klass, const LinkInfo& link_info); static methodHandle resolve_static_call_or_null (const LinkInfo& link_info); static methodHandle resolve_special_call_or_null (const LinkInfo& link_info); - static int vtable_index_of_interface_method(KlassHandle klass, const methodHandle& resolved_method); + static int vtable_index_of_interface_method(Klass* klass, const methodHandle& resolved_method); // same as above for compile-time resolution; returns vtable_index if current_klass if linked - static int resolve_virtual_vtable_index (KlassHandle receiver_klass, + static int resolve_virtual_vtable_index (Klass* receiver_klass, const LinkInfo& link_info); // static resolving for compiler (does not throw exceptions, returns null handle if unsuccessful)
--- a/hotspot/src/share/vm/interpreter/rewriter.cpp Wed Mar 15 11:44:46 2017 +0100 +++ b/hotspot/src/share/vm/interpreter/rewriter.cpp Wed Mar 15 10:25:37 2017 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2017, 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 @@ -544,16 +544,16 @@ patch_invokedynamic_bytecodes(); } -void Rewriter::rewrite(instanceKlassHandle klass, TRAPS) { +void Rewriter::rewrite(InstanceKlass* klass, TRAPS) { if (!DumpSharedSpaces) { - assert(!MetaspaceShared::is_in_shared_space(klass()), "archive methods must not be rewritten at run time"); + assert(!MetaspaceShared::is_in_shared_space(klass), "archive methods must not be rewritten at run time"); } ResourceMark rm(THREAD); Rewriter rw(klass, klass->constants(), klass->methods(), CHECK); // (That's all, folks.) } -Rewriter::Rewriter(instanceKlassHandle klass, const constantPoolHandle& cpool, Array<Method*>* methods, TRAPS) +Rewriter::Rewriter(InstanceKlass* klass, const constantPoolHandle& cpool, Array<Method*>* methods, TRAPS) : _klass(klass), _pool(cpool), _methods(methods),
--- a/hotspot/src/share/vm/interpreter/rewriter.hpp Wed Mar 15 11:44:46 2017 +0100 +++ b/hotspot/src/share/vm/interpreter/rewriter.hpp Wed Mar 15 10:25:37 2017 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2017, 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 @@ -34,7 +34,7 @@ class Rewriter: public StackObj { private: - instanceKlassHandle _klass; + InstanceKlass* _klass; constantPoolHandle _pool; Array<Method*>* _methods; GrowableArray<int> _cp_map; @@ -188,7 +188,7 @@ } // All the work goes in here: - Rewriter(instanceKlassHandle klass, const constantPoolHandle& cpool, Array<Method*>* methods, TRAPS); + Rewriter(InstanceKlass* klass, const constantPoolHandle& cpool, Array<Method*>* methods, TRAPS); void compute_index_maps(); void make_constant_pool_cache(TRAPS); @@ -211,7 +211,7 @@ static methodHandle rewrite_jsrs(methodHandle m, TRAPS); public: // Driver routine: - static void rewrite(instanceKlassHandle klass, TRAPS); + static void rewrite(InstanceKlass* klass, TRAPS); }; #endif // SHARE_VM_INTERPRETER_REWRITER_HPP
--- a/hotspot/src/share/vm/jvmci/jvmciCompilerToVM.cpp Wed Mar 15 11:44:46 2017 +0100 +++ b/hotspot/src/share/vm/jvmci/jvmciCompilerToVM.cpp Wed Mar 15 10:25:37 2017 -0400 @@ -77,8 +77,8 @@ return NULL; } -oop CompilerToVM::get_jvmci_type(KlassHandle klass, TRAPS) { - if (klass() != NULL) { +oop CompilerToVM::get_jvmci_type(Klass* klass, TRAPS) { + if (klass != NULL) { JavaValue result(T_OBJECT); JavaCallArguments args; args.push_oop(Handle(THREAD, klass->java_mirror())); @@ -678,7 +678,7 @@ } C2V_VMENTRY(jobject, getResolvedJavaType, (JNIEnv *, jobject, jobject base, jlong offset, jboolean compressed)) - KlassHandle klass; + Klass* klass = NULL; oop base_object = JNIHandles::resolve(base); jlong base_address = 0; if (base_object != NULL && offset == oopDesc::klass_offset_in_bytes()) { @@ -703,7 +703,7 @@ THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(), err_msg("Unexpected arguments: %s " JLONG_FORMAT " %s", base_object->klass()->external_name(), offset, compressed ? "true" : "false")); } - assert (klass.is_null() || klass->is_klass(), "invalid read"); + assert (klass == NULL || klass->is_klass(), "invalid read"); oop result = CompilerToVM::get_jvmci_type(klass, CHECK_NULL); return JNIHandles::make_local(THREAD, result); } @@ -711,7 +711,7 @@ C2V_VMENTRY(jobject, findUniqueConcreteMethod, (JNIEnv *, jobject, jobject jvmci_type, jobject jvmci_method)) ResourceMark rm; methodHandle method = CompilerToVM::asMethod(jvmci_method); - KlassHandle holder = CompilerToVM::asKlass(jvmci_type); + Klass* holder = CompilerToVM::asKlass(jvmci_type); if (holder->is_interface()) { THROW_MSG_0(vmSymbols::java_lang_InternalError(), err_msg("Interface %s should be handled in Java code", holder->external_name())); } @@ -719,7 +719,7 @@ methodHandle ucm; { MutexLocker locker(Compile_lock); - ucm = Dependencies::find_unique_concrete_method(holder(), method()); + ucm = Dependencies::find_unique_concrete_method(holder, method()); } oop result = CompilerToVM::get_jvmci_method(ucm, CHECK_NULL); return JNIHandles::make_local(THREAD, result); @@ -848,15 +848,15 @@ C2V_VMENTRY(jobject, lookupKlassInPool, (JNIEnv*, jobject, jobject jvmci_constant_pool, jint index, jbyte opcode)) constantPoolHandle cp = CompilerToVM::asConstantPool(jvmci_constant_pool); - KlassHandle loading_klass(cp->pool_holder()); + Klass* loading_klass = cp->pool_holder(); bool is_accessible = false; - KlassHandle klass = JVMCIEnv::get_klass_by_index(cp, index, is_accessible, loading_klass); + Klass* klass = JVMCIEnv::get_klass_by_index(cp, index, is_accessible, loading_klass); Symbol* symbol = NULL; - if (klass.is_null()) { + if (klass == NULL) { symbol = cp->klass_name_at(index); } oop result_oop; - if (!klass.is_null()) { + if (klass != NULL) { result_oop = CompilerToVM::get_jvmci_type(klass, CHECK_NULL); } else { Handle result = java_lang_String::create_from_symbol(symbol, CHECK_NULL); @@ -873,7 +873,7 @@ C2V_VMENTRY(jobject, lookupMethodInPool, (JNIEnv*, jobject, jobject jvmci_constant_pool, jint index, jbyte opcode)) constantPoolHandle cp = CompilerToVM::asConstantPool(jvmci_constant_pool); - instanceKlassHandle pool_holder(cp->pool_holder()); + InstanceKlass* pool_holder = cp->pool_holder(); Bytecodes::Code bc = (Bytecodes::Code) (((int) opcode) & 0xFF); methodHandle method = JVMCIEnv::get_method_by_index(cp, index, bc, pool_holder); oop result = CompilerToVM::get_jvmci_method(method, CHECK_NULL); @@ -920,11 +920,11 @@ C2V_END C2V_VMENTRY(jobject, resolveMethod, (JNIEnv *, jobject, jobject receiver_jvmci_type, jobject jvmci_method, jobject caller_jvmci_type)) - KlassHandle recv_klass = CompilerToVM::asKlass(receiver_jvmci_type); - KlassHandle caller_klass = CompilerToVM::asKlass(caller_jvmci_type); + Klass* recv_klass = CompilerToVM::asKlass(receiver_jvmci_type); + Klass* caller_klass = CompilerToVM::asKlass(caller_jvmci_type); methodHandle method = CompilerToVM::asMethod(jvmci_method); - KlassHandle h_resolved (THREAD, method->method_holder()); + Klass* resolved = method->method_holder(); Symbol* h_name = method->name(); Symbol* h_signature = method->signature(); @@ -933,13 +933,13 @@ return NULL; } - LinkInfo link_info(h_resolved, h_name, h_signature, caller_klass); + LinkInfo link_info(resolved, h_name, h_signature, caller_klass); methodHandle m; // Only do exact lookup if receiver klass has been linked. Otherwise, // the vtable has not been setup, and the LinkResolver will fail. if (recv_klass->is_array_klass() || - InstanceKlass::cast(recv_klass())->is_linked() && !recv_klass->is_interface()) { - if (h_resolved->is_interface()) { + InstanceKlass::cast(recv_klass)->is_linked() && !recv_klass->is_interface()) { + if (resolved->is_interface()) { m = LinkResolver::resolve_interface_call_or_null(recv_klass, link_info); } else { m = LinkResolver::resolve_virtual_call_or_null(recv_klass, link_info); @@ -1482,12 +1482,12 @@ C2V_VMENTRY(void, resolveInvokeHandleInPool, (JNIEnv*, jobject, jobject jvmci_constant_pool, jint index)) constantPoolHandle cp = CompilerToVM::asConstantPool(jvmci_constant_pool); - KlassHandle holder = cp->klass_ref_at(index, CHECK); + Klass* holder = cp->klass_ref_at(index, CHECK); Symbol* name = cp->name_ref_at(index); - if (MethodHandles::is_signature_polymorphic_name(holder(), name)) { + if (MethodHandles::is_signature_polymorphic_name(holder, name)) { CallInfo callInfo; LinkResolver::resolve_invoke(callInfo, Handle(), cp, index, Bytecodes::_invokehandle, CHECK); - ConstantPoolCacheEntry* cp_cache_entry = cp_cache_entry = cp->cache()->entry_at(cp->decode_cpcache_index(index)); + ConstantPoolCacheEntry* cp_cache_entry = cp->cache()->entry_at(cp->decode_cpcache_index(index)); cp_cache_entry->set_method_handle(cp, callInfo); } C2V_END
--- a/hotspot/src/share/vm/jvmci/jvmciCompilerToVM.hpp Wed Mar 15 11:44:46 2017 +0100 +++ b/hotspot/src/share/vm/jvmci/jvmciCompilerToVM.hpp Wed Mar 15 10:25:37 2017 -0400 @@ -161,7 +161,7 @@ static oop get_jvmci_method(const methodHandle& method, TRAPS); - static oop get_jvmci_type(KlassHandle klass, TRAPS); + static oop get_jvmci_type(Klass* klass, TRAPS); }; class JavaArgumentUnboxer : public SignatureIterator {
--- a/hotspot/src/share/vm/jvmci/jvmciEnv.cpp Wed Mar 15 11:44:46 2017 +0100 +++ b/hotspot/src/share/vm/jvmci/jvmciEnv.cpp Wed Mar 15 10:25:37 2017 -0400 @@ -65,9 +65,9 @@ // ------------------------------------------------------------------ // Note: the logic of this method should mirror the logic of // constantPoolOopDesc::verify_constant_pool_resolve. -bool JVMCIEnv::check_klass_accessibility(KlassHandle accessing_klass, KlassHandle resolved_klass) { +bool JVMCIEnv::check_klass_accessibility(Klass* accessing_klass, Klass* resolved_klass) { if (accessing_klass->is_objArray_klass()) { - accessing_klass = ObjArrayKlass::cast(accessing_klass())->bottom_klass(); + accessing_klass = ObjArrayKlass::cast(accessing_klass)->bottom_klass(); } if (!accessing_klass->is_instance_klass()) { return true; @@ -75,21 +75,21 @@ if (resolved_klass->is_objArray_klass()) { // Find the element klass, if this is an array. - resolved_klass = ObjArrayKlass::cast(resolved_klass())->bottom_klass(); + resolved_klass = ObjArrayKlass::cast(resolved_klass)->bottom_klass(); } if (resolved_klass->is_instance_klass()) { Reflection::VerifyClassAccessResults result = - Reflection::verify_class_access(accessing_klass(), InstanceKlass::cast(resolved_klass()), true); + Reflection::verify_class_access(accessing_klass, InstanceKlass::cast(resolved_klass), true); return result == Reflection::ACCESS_OK; } return true; } // ------------------------------------------------------------------ -KlassHandle JVMCIEnv::get_klass_by_name_impl(KlassHandle& accessing_klass, - const constantPoolHandle& cpool, - Symbol* sym, - bool require_local) { +Klass* JVMCIEnv::get_klass_by_name_impl(Klass* accessing_klass, + const constantPoolHandle& cpool, + Symbol* sym, + bool require_local) { JVMCI_EXCEPTION_CONTEXT; // Now we need to check the SystemDictionary @@ -99,28 +99,26 @@ // Call recursive to keep scope of strippedsym. TempNewSymbol strippedsym = SymbolTable::new_symbol(sym->as_utf8()+1, sym->utf8_length()-2, - CHECK_(KlassHandle())); + CHECK_NULL); return get_klass_by_name_impl(accessing_klass, cpool, strippedsym, require_local); } Handle loader(THREAD, (oop)NULL); Handle domain(THREAD, (oop)NULL); - if (!accessing_klass.is_null()) { + if (accessing_klass != NULL) { loader = Handle(THREAD, accessing_klass->class_loader()); domain = Handle(THREAD, accessing_klass->protection_domain()); } - KlassHandle found_klass; + Klass* found_klass = NULL; { ttyUnlocker ttyul; // release tty lock to avoid ordering problems MutexLocker ml(Compile_lock); - Klass* kls; if (!require_local) { - kls = SystemDictionary::find_constrained_instance_or_array_klass(sym, loader, CHECK_(KlassHandle())); + found_klass = SystemDictionary::find_constrained_instance_or_array_klass(sym, loader, CHECK_NULL); } else { - kls = SystemDictionary::find_instance_or_array_klass(sym, loader, domain, CHECK_(KlassHandle())); + found_klass = SystemDictionary::find_instance_or_array_klass(sym, loader, domain, CHECK_NULL); } - found_klass = KlassHandle(THREAD, kls); } // If we fail to find an array klass, look again for its element type. @@ -135,21 +133,21 @@ // Build it on the fly if the element class exists. TempNewSymbol elem_sym = SymbolTable::new_symbol(sym->as_utf8()+1, sym->utf8_length()-1, - CHECK_(KlassHandle())); + CHECK_NULL); // Get element Klass recursively. - KlassHandle elem_klass = + Klass* elem_klass = get_klass_by_name_impl(accessing_klass, cpool, elem_sym, require_local); - if (!elem_klass.is_null()) { + if (elem_klass != NULL) { // Now make an array for it - return elem_klass->array_klass(CHECK_(KlassHandle())); + return elem_klass->array_klass(CHECK_NULL); } } - if (found_klass.is_null() && !cpool.is_null() && cpool->has_preresolution()) { + if (found_klass == NULL && !cpool.is_null() && cpool->has_preresolution()) { // Look inside the constant pool for pre-resolved class entries. for (int i = cpool->length() - 1; i >= 1; i--) { if (cpool->tag_at(i).is_klass()) { @@ -161,45 +159,45 @@ } } - return found_klass(); + return found_klass; } // ------------------------------------------------------------------ -KlassHandle JVMCIEnv::get_klass_by_name(KlassHandle accessing_klass, +Klass* JVMCIEnv::get_klass_by_name(Klass* accessing_klass, Symbol* klass_name, bool require_local) { ResourceMark rm; constantPoolHandle cpool; return get_klass_by_name_impl(accessing_klass, - cpool, - klass_name, - require_local); + cpool, + klass_name, + require_local); } // ------------------------------------------------------------------ // Implementation of get_klass_by_index. -KlassHandle JVMCIEnv::get_klass_by_index_impl(const constantPoolHandle& cpool, +Klass* JVMCIEnv::get_klass_by_index_impl(const constantPoolHandle& cpool, int index, bool& is_accessible, - KlassHandle accessor) { + Klass* accessor) { JVMCI_EXCEPTION_CONTEXT; - KlassHandle klass (THREAD, ConstantPool::klass_at_if_loaded(cpool, index)); + Klass* klass = ConstantPool::klass_at_if_loaded(cpool, index); Symbol* klass_name = NULL; - if (klass.is_null()) { + if (klass == NULL) { klass_name = cpool->klass_name_at(index); } - if (klass.is_null()) { + if (klass == NULL) { // Not found in constant pool. Use the name to do the lookup. - KlassHandle k = get_klass_by_name_impl(accessor, - cpool, - klass_name, - false); + Klass* k = get_klass_by_name_impl(accessor, + cpool, + klass_name, + false); // Calculate accessibility the hard way. - if (k.is_null()) { + if (k == NULL) { is_accessible = false; } else if (k->class_loader() != accessor->class_loader() && - get_klass_by_name_impl(accessor, cpool, k->name(), true).is_null()) { + get_klass_by_name_impl(accessor, cpool, k->name(), true) == NULL) { // Loaded only remotely. Not linked yet. is_accessible = false; } else { @@ -207,7 +205,7 @@ is_accessible = check_klass_accessibility(accessor, k); } if (!is_accessible) { - return KlassHandle(); + return NULL; } return k; } @@ -219,13 +217,12 @@ // ------------------------------------------------------------------ // Get a klass from the constant pool. -KlassHandle JVMCIEnv::get_klass_by_index(const constantPoolHandle& cpool, - int index, - bool& is_accessible, - KlassHandle accessor) { +Klass* JVMCIEnv::get_klass_by_index(const constantPoolHandle& cpool, + int index, + bool& is_accessible, + Klass* accessor) { ResourceMark rm; - KlassHandle result = get_klass_by_index_impl(cpool, index, is_accessible, accessor); - return result; + return get_klass_by_index_impl(cpool, index, is_accessible, accessor); } // ------------------------------------------------------------------ @@ -233,7 +230,7 @@ // // Implementation note: the results of field lookups are cached // in the accessor klass. -void JVMCIEnv::get_field_by_index_impl(instanceKlassHandle klass, fieldDescriptor& field_desc, +void JVMCIEnv::get_field_by_index_impl(InstanceKlass* klass, fieldDescriptor& field_desc, int index) { JVMCI_EXCEPTION_CONTEXT; @@ -251,9 +248,9 @@ // Get the field's declared holder. int holder_index = cpool->klass_ref_index_at(index); bool holder_is_accessible; - KlassHandle declared_holder = get_klass_by_index(cpool, holder_index, - holder_is_accessible, - klass); + Klass* declared_holder = get_klass_by_index(cpool, holder_index, + holder_is_accessible, + klass); // The declared holder of this field may not have been loaded. // Bail out with partial field information. @@ -264,7 +261,7 @@ // Perform the field lookup. Klass* canonical_holder = - InstanceKlass::cast(declared_holder())->find_field(name, signature, &field_desc); + InstanceKlass::cast(declared_holder)->find_field(name, signature, &field_desc); if (canonical_holder == NULL) { return; } @@ -274,7 +271,7 @@ // ------------------------------------------------------------------ // Get a field by index from a klass's constant pool. -void JVMCIEnv::get_field_by_index(instanceKlassHandle accessor, fieldDescriptor& fd, int index) { +void JVMCIEnv::get_field_by_index(InstanceKlass* accessor, fieldDescriptor& fd, int index) { ResourceMark rm; return get_field_by_index_impl(accessor, fd, index); } @@ -282,17 +279,17 @@ // ------------------------------------------------------------------ // Perform an appropriate method lookup based on accessor, holder, // name, signature, and bytecode. -methodHandle JVMCIEnv::lookup_method(instanceKlassHandle h_accessor, - KlassHandle h_holder, - Symbol* name, - Symbol* sig, +methodHandle JVMCIEnv::lookup_method(InstanceKlass* accessor, + Klass* holder, + Symbol* name, + Symbol* sig, Bytecodes::Code bc, constantTag tag) { // Accessibility checks are performed in JVMCIEnv::get_method_by_index_impl(). - assert(check_klass_accessibility(h_accessor, h_holder), "holder not accessible"); + assert(check_klass_accessibility(accessor, holder), "holder not accessible"); methodHandle dest_method; - LinkInfo link_info(h_holder, name, sig, h_accessor, LinkInfo::needs_access_check, tag); + LinkInfo link_info(holder, name, sig, accessor, LinkInfo::needs_access_check, tag); switch (bc) { case Bytecodes::_invokestatic: dest_method = @@ -320,7 +317,7 @@ // ------------------------------------------------------------------ methodHandle JVMCIEnv::get_method_by_index_impl(const constantPoolHandle& cpool, int index, Bytecodes::Code bc, - instanceKlassHandle accessor) { + InstanceKlass* accessor) { if (bc == Bytecodes::_invokedynamic) { ConstantPoolCacheEntry* cpce = cpool->invokedynamic_cp_cache_entry_at(index); bool is_resolved = !cpce->is_f1_null(); @@ -336,15 +333,15 @@ int holder_index = cpool->klass_ref_index_at(index); bool holder_is_accessible; - KlassHandle holder = get_klass_by_index_impl(cpool, holder_index, holder_is_accessible, accessor); + Klass* holder = get_klass_by_index_impl(cpool, holder_index, holder_is_accessible, accessor); // Get the method's name and signature. Symbol* name_sym = cpool->name_ref_at(index); Symbol* sig_sym = cpool->signature_ref_at(index); if (cpool->has_preresolution() - || ((holder() == SystemDictionary::MethodHandle_klass() || holder() == SystemDictionary::VarHandle_klass()) && - MethodHandles::is_signature_polymorphic_name(holder(), name_sym))) { + || ((holder == SystemDictionary::MethodHandle_klass() || holder == SystemDictionary::VarHandle_klass()) && + MethodHandles::is_signature_polymorphic_name(holder, name_sym))) { // Short-circuit lookups for JSR 292-related call sites. // That is, do not rely only on name-based lookups, because they may fail // if the names are not resolvable in the boot class loader (7056328). @@ -385,14 +382,14 @@ } // ------------------------------------------------------------------ -instanceKlassHandle JVMCIEnv::get_instance_klass_for_declared_method_holder(KlassHandle method_holder) { +InstanceKlass* JVMCIEnv::get_instance_klass_for_declared_method_holder(Klass* method_holder) { // For the case of <array>.clone(), the method holder can be an ArrayKlass* // instead of an InstanceKlass*. For that case simply pretend that the // declared holder is Object.clone since that's where the call will bottom out. if (method_holder->is_instance_klass()) { - return instanceKlassHandle(method_holder()); + return InstanceKlass::cast(method_holder); } else if (method_holder->is_array_klass()) { - return instanceKlassHandle(SystemDictionary::Object_klass()); + return SystemDictionary::Object_klass(); } else { ShouldNotReachHere(); } @@ -403,7 +400,7 @@ // ------------------------------------------------------------------ methodHandle JVMCIEnv::get_method_by_index(const constantPoolHandle& cpool, int index, Bytecodes::Code bc, - instanceKlassHandle accessor) { + InstanceKlass* accessor) { ResourceMark rm; return get_method_by_index_impl(cpool, index, bc, accessor); }
--- a/hotspot/src/share/vm/jvmci/jvmciEnv.hpp Wed Mar 15 11:44:46 2017 +0100 +++ b/hotspot/src/share/vm/jvmci/jvmciEnv.hpp Wed Mar 15 10:25:37 2017 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2017, 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 @@ -79,20 +79,18 @@ // The CI treats a klass as loaded if it is consistently defined in // another loader, even if it hasn't yet been loaded in all loaders // that could potentially see it via delegation. - static KlassHandle get_klass_by_name(KlassHandle accessing_klass, - Symbol* klass_name, - bool require_local); + static Klass* get_klass_by_name(Klass* accessing_klass, Symbol* klass_name, bool require_local); // Constant pool access. - static KlassHandle get_klass_by_index(const constantPoolHandle& cpool, - int klass_index, - bool& is_accessible, - KlassHandle loading_klass); - static void get_field_by_index(instanceKlassHandle loading_klass, fieldDescriptor& fd, - int field_index); + static Klass* get_klass_by_index(const constantPoolHandle& cpool, + int klass_index, + bool& is_accessible, + Klass* loading_klass); + static void get_field_by_index(InstanceKlass* loading_klass, fieldDescriptor& fd, + int field_index); static methodHandle get_method_by_index(const constantPoolHandle& cpool, - int method_index, Bytecodes::Code bc, - instanceKlassHandle loading_klass); + int method_index, Bytecodes::Code bc, + InstanceKlass* loading_klass); JVMCIEnv(CompileTask* task, int system_dictionary_modification_counter); @@ -110,26 +108,26 @@ bool _jvmti_can_post_on_exceptions; // Implementation methods for loading and constant pool access. - static KlassHandle get_klass_by_name_impl(KlassHandle& accessing_klass, + static Klass* get_klass_by_name_impl(Klass* accessing_klass, const constantPoolHandle& cpool, Symbol* klass_name, bool require_local); - static KlassHandle get_klass_by_index_impl(const constantPoolHandle& cpool, + static Klass* get_klass_by_index_impl(const constantPoolHandle& cpool, int klass_index, bool& is_accessible, - KlassHandle loading_klass); - static void get_field_by_index_impl(instanceKlassHandle loading_klass, fieldDescriptor& fd, + Klass* loading_klass); + static void get_field_by_index_impl(InstanceKlass* loading_klass, fieldDescriptor& fd, int field_index); static methodHandle get_method_by_index_impl(const constantPoolHandle& cpool, int method_index, Bytecodes::Code bc, - instanceKlassHandle loading_klass); + InstanceKlass* loading_klass); // Helper methods - static bool check_klass_accessibility(KlassHandle accessing_klass, KlassHandle resolved_klass); - static methodHandle lookup_method(instanceKlassHandle accessor, - KlassHandle holder, - Symbol* name, - Symbol* sig, + static bool check_klass_accessibility(Klass* accessing_klass, Klass* resolved_klass); + static methodHandle lookup_method(InstanceKlass* accessor, + Klass* holder, + Symbol* name, + Symbol* sig, Bytecodes::Code bc, constantTag tag); @@ -180,7 +178,7 @@ // InstanceKlass*. This is needed since the holder of a method in // the bytecodes could be an array type. Basically this converts // array types into java/lang/Object and other types stay as they are. - static instanceKlassHandle get_instance_klass_for_declared_method_holder(KlassHandle klass); + static InstanceKlass* get_instance_klass_for_declared_method_holder(Klass* klass); }; #endif // SHARE_VM_JVMCI_JVMCIENV_HPP
--- a/hotspot/src/share/vm/jvmci/jvmciRuntime.cpp Wed Mar 15 11:44:46 2017 +0100 +++ b/hotspot/src/share/vm/jvmci/jvmciRuntime.cpp Wed Mar 15 10:25:37 2017 -0400 @@ -107,12 +107,12 @@ JRT_BLOCK; assert(klass->is_klass(), "not a class"); Handle holder(THREAD, klass->klass_holder()); // keep the klass alive - instanceKlassHandle h(thread, klass); - h->check_valid_for_instantiation(true, CHECK); + InstanceKlass* ik = InstanceKlass::cast(klass); + ik->check_valid_for_instantiation(true, CHECK); // make sure klass is initialized - h->initialize(CHECK); + ik->initialize(CHECK); // allocate instance and return via TLS - oop obj = h->allocate_instance(CHECK); + oop obj = ik->allocate_instance(CHECK); thread->set_vm_result(obj); JRT_BLOCK_END; @@ -187,7 +187,7 @@ JRT_END JRT_ENTRY(void, JVMCIRuntime::dynamic_new_instance(JavaThread* thread, oopDesc* type_mirror)) - instanceKlassHandle klass(THREAD, java_lang_Class::as_Klass(type_mirror)); + InstanceKlass* klass = InstanceKlass::cast(java_lang_Class::as_Klass(type_mirror)); if (klass == NULL) { ResourceMark rm(THREAD); @@ -641,7 +641,7 @@ Handle JVMCIRuntime::callStatic(const char* className, const char* methodName, const char* signature, JavaCallArguments* args, TRAPS) { TempNewSymbol name = SymbolTable::new_symbol(className, CHECK_(Handle())); - KlassHandle klass = SystemDictionary::resolve_or_fail(name, true, CHECK_(Handle())); + Klass* klass = SystemDictionary::resolve_or_fail(name, true, CHECK_(Handle())); TempNewSymbol runtime = SymbolTable::new_symbol(methodName, CHECK_(Handle())); TempNewSymbol sig = SymbolTable::new_symbol(signature, CHECK_(Handle())); JavaValue result(T_OBJECT); @@ -657,7 +657,7 @@ guarantee(!_HotSpotJVMCIRuntime_initialized, "cannot reinitialize HotSpotJVMCIRuntime"); JVMCIRuntime::initialize_well_known_classes(CHECK); // This should only be called in the context of the JVMCI class being initialized - instanceKlassHandle klass = InstanceKlass::cast(SystemDictionary::JVMCI_klass()); + InstanceKlass* klass = SystemDictionary::JVMCI_klass(); guarantee(klass->is_being_initialized() && klass->is_reentrant_initialization(THREAD), "HotSpotJVMCIRuntime initialization should only be triggered through JVMCI initialization");
--- a/hotspot/src/share/vm/memory/universe.cpp Wed Mar 15 11:44:46 2017 +0100 +++ b/hotspot/src/share/vm/memory/universe.cpp Wed Mar 15 10:25:37 2017 -0400 @@ -460,9 +460,8 @@ Klass* k = list->at(i); assert(k->is_klass(), "List should only hold classes"); EXCEPTION_MARK; - KlassHandle kh(THREAD, k); - java_lang_Class::fixup_mirror(kh, CATCH); -} + java_lang_Class::fixup_mirror(k, CATCH); + } delete java_lang_Class::fixup_mirror_list(); java_lang_Class::set_fixup_mirror_list(NULL); } @@ -506,7 +505,7 @@ log_trace(ref)("Callback to run finalizers on exit"); { PRESERVE_EXCEPTION_MARK; - KlassHandle finalizer_klass(THREAD, SystemDictionary::Finalizer_klass()); + Klass* finalizer_klass = SystemDictionary::Finalizer_klass(); JavaValue result(T_VOID); JavaCalls::call_static( &result, @@ -525,16 +524,15 @@ // 1) we specified true to initialize_vtable and // 2) this ran after gc was enabled // In case those ever change we use handles for oops -void Universe::reinitialize_vtable_of(KlassHandle k_h, TRAPS) { +void Universe::reinitialize_vtable_of(Klass* ko, TRAPS) { // init vtable of k and all subclasses - Klass* ko = k_h(); klassVtable* vt = ko->vtable(); if (vt) vt->initialize_vtable(false, CHECK); if (ko->is_instance_klass()) { - for (KlassHandle s_h(THREAD, ko->subklass()); - s_h() != NULL; - s_h = KlassHandle(THREAD, s_h()->next_sibling())) { - reinitialize_vtable_of(s_h, CHECK); + for (Klass* sk = ko->subklass(); + sk != NULL; + sk = sk->next_sibling()) { + reinitialize_vtable_of(sk, CHECK); } } } @@ -964,28 +962,26 @@ Interpreter::initialize(); // needed for interpreter entry points if (!UseSharedSpaces) { HandleMark hm(THREAD); - KlassHandle ok_h(THREAD, SystemDictionary::Object_klass()); - Universe::reinitialize_vtable_of(ok_h, CHECK_false); + Klass* ok = SystemDictionary::Object_klass(); + Universe::reinitialize_vtable_of(ok, CHECK_false); Universe::reinitialize_itables(CHECK_false); } } HandleMark hm(THREAD); - Klass* k; - instanceKlassHandle k_h; // Setup preallocated empty java.lang.Class array Universe::_the_empty_class_klass_array = oopFactory::new_objArray(SystemDictionary::Class_klass(), 0, CHECK_false); // Setup preallocated OutOfMemoryError errors - k = SystemDictionary::resolve_or_fail(vmSymbols::java_lang_OutOfMemoryError(), true, CHECK_false); - k_h = instanceKlassHandle(THREAD, k); - Universe::_out_of_memory_error_java_heap = k_h->allocate_instance(CHECK_false); - Universe::_out_of_memory_error_metaspace = k_h->allocate_instance(CHECK_false); - Universe::_out_of_memory_error_class_metaspace = k_h->allocate_instance(CHECK_false); - Universe::_out_of_memory_error_array_size = k_h->allocate_instance(CHECK_false); + Klass* k = SystemDictionary::resolve_or_fail(vmSymbols::java_lang_OutOfMemoryError(), true, CHECK_false); + InstanceKlass* ik = InstanceKlass::cast(k); + Universe::_out_of_memory_error_java_heap = ik->allocate_instance(CHECK_false); + Universe::_out_of_memory_error_metaspace = ik->allocate_instance(CHECK_false); + Universe::_out_of_memory_error_class_metaspace = ik->allocate_instance(CHECK_false); + Universe::_out_of_memory_error_array_size = ik->allocate_instance(CHECK_false); Universe::_out_of_memory_error_gc_overhead_limit = - k_h->allocate_instance(CHECK_false); - Universe::_out_of_memory_error_realloc_objects = k_h->allocate_instance(CHECK_false); + ik->allocate_instance(CHECK_false); + Universe::_out_of_memory_error_realloc_objects = ik->allocate_instance(CHECK_false); // Setup preallocated cause message for delayed StackOverflowError if (StackReservedPages > 0) { @@ -1006,8 +1002,8 @@ vmSymbols::java_lang_VirtualMachineError(), true, CHECK_false); bool linked = InstanceKlass::cast(k)->link_class_or_fail(CHECK_false); if (!linked) { - tty->print_cr("Unable to link/verify VirtualMachineError class"); - return false; // initialization failed + tty->print_cr("Unable to link/verify VirtualMachineError class"); + return false; // initialization failed } Universe::_virtual_machine_error_instance = InstanceKlass::cast(k)->allocate_instance(CHECK_false); @@ -1040,12 +1036,12 @@ // Setup the array of errors that have preallocated backtrace k = Universe::_out_of_memory_error_java_heap->klass(); assert(k->name() == vmSymbols::java_lang_OutOfMemoryError(), "should be out of memory error"); - k_h = instanceKlassHandle(THREAD, k); + ik = InstanceKlass::cast(k); int len = (StackTraceInThrowable) ? (int)PreallocatedOutOfMemoryErrorCount : 0; - Universe::_preallocated_out_of_memory_error_array = oopFactory::new_objArray(k_h(), len, CHECK_false); + Universe::_preallocated_out_of_memory_error_array = oopFactory::new_objArray(ik, len, CHECK_false); for (int i=0; i<len; i++) { - oop err = k_h->allocate_instance(CHECK_false); + oop err = ik->allocate_instance(CHECK_false); Handle err_h = Handle(THREAD, err); java_lang_Throwable::allocate_backtrace(err_h, CHECK_false); Universe::preallocated_out_of_memory_errors()->obj_at_put(i, err_h());
--- a/hotspot/src/share/vm/memory/universe.hpp Wed Mar 15 11:44:46 2017 +0100 +++ b/hotspot/src/share/vm/memory/universe.hpp Wed Mar 15 10:25:37 2017 -0400 @@ -230,7 +230,7 @@ static void initialize_basic_type_mirrors(TRAPS); static void fixup_mirrors(TRAPS); - static void reinitialize_vtable_of(KlassHandle h_k, TRAPS); + static void reinitialize_vtable_of(Klass* k, TRAPS); static void reinitialize_itables(TRAPS); static void compute_base_vtable_size(); // compute vtable size of class Object
--- a/hotspot/src/share/vm/oops/arrayKlass.cpp Wed Mar 15 11:44:46 2017 +0100 +++ b/hotspot/src/share/vm/oops/arrayKlass.cpp Wed Mar 15 10:25:37 2017 -0400 @@ -96,9 +96,9 @@ // Initialization of vtables and mirror object is done separatly from base_create_array_klass, // since a GC can happen. At this point all instance variables of the ArrayKlass must be setup. -void ArrayKlass::complete_create_array_klass(ArrayKlass* k, KlassHandle super_klass, ModuleEntry* module_entry, TRAPS) { +void ArrayKlass::complete_create_array_klass(ArrayKlass* k, Klass* super_klass, ModuleEntry* module_entry, TRAPS) { ResourceMark rm(THREAD); - k->initialize_supers(super_klass(), CHECK); + k->initialize_supers(super_klass, CHECK); k->vtable()->initialize_vtable(false, CHECK); // During bootstrapping, before java.base is defined, the module_entry may not be present yet.
--- a/hotspot/src/share/vm/oops/arrayKlass.hpp Wed Mar 15 11:44:46 2017 +0100 +++ b/hotspot/src/share/vm/oops/arrayKlass.hpp Wed Mar 15 10:25:37 2017 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2017, 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 @@ -115,7 +115,7 @@ void array_klasses_do(void f(Klass* k, TRAPS), TRAPS); // Return a handle. - static void complete_create_array_klass(ArrayKlass* k, KlassHandle super_klass, ModuleEntry* module, TRAPS); + static void complete_create_array_klass(ArrayKlass* k, Klass* super_klass, ModuleEntry* module, TRAPS); // jvm support
--- a/hotspot/src/share/vm/oops/constantPool.cpp Wed Mar 15 11:44:46 2017 +0100 +++ b/hotspot/src/share/vm/oops/constantPool.cpp Wed Mar 15 10:25:37 2017 -0400 @@ -193,7 +193,7 @@ resolved_references()->obj_at_put(obj_index, str); } -void ConstantPool::trace_class_resolution(const constantPoolHandle& this_cp, KlassHandle k) { +void ConstantPool::trace_class_resolution(const constantPoolHandle& this_cp, Klass* k) { ResourceMark rm; int line_number = -1; const char * source_file = NULL; @@ -208,7 +208,7 @@ } } } - if (k() != this_cp->pool_holder()) { + if (k != this_cp->pool_holder()) { // only print something if the classes are different if (source_file != NULL) { log_debug(class, resolve)("%s %s %s:%d", @@ -254,11 +254,10 @@ Symbol* name = entry.get_symbol(); Handle loader (THREAD, this_cp->pool_holder()->class_loader()); Handle protection_domain (THREAD, this_cp->pool_holder()->protection_domain()); - Klass* kk = SystemDictionary::resolve_or_fail(name, loader, protection_domain, true, THREAD); - KlassHandle k (THREAD, kk); + Klass* k = SystemDictionary::resolve_or_fail(name, loader, protection_domain, true, THREAD); if (!HAS_PENDING_EXCEPTION) { // preserve the resolved klass from unloading - mirror_handle = Handle(THREAD, kk->java_mirror()); + mirror_handle = Handle(THREAD, k->java_mirror()); // Do access check for klasses verify_constant_pool_resolve(this_cp, k, THREAD); } @@ -282,13 +281,13 @@ // Make this class loader depend upon the class loader owning the class reference ClassLoaderData* this_key = this_cp->pool_holder()->class_loader_data(); - this_key->record_dependency(k(), CHECK_NULL); // Can throw OOM + this_key->record_dependency(k, CHECK_NULL); // Can throw OOM // logging for class+resolve. if (log_is_enabled(Debug, class, resolve)){ trace_class_resolution(this_cp, k); } - this_cp->klass_at_put(which, k()); + this_cp->klass_at_put(which, k); entry = this_cp->resolved_klass_at(which); assert(entry.is_resolved() && entry.get_klass()->is_klass(), "must be resolved at this point"); return entry.get_klass(); @@ -317,14 +316,13 @@ if (k != NULL) { // Make sure that resolving is legal EXCEPTION_MARK; - KlassHandle klass(THREAD, k); // return NULL if verification fails - verify_constant_pool_resolve(this_cp, klass, THREAD); + verify_constant_pool_resolve(this_cp, k, THREAD); if (HAS_PENDING_EXCEPTION) { CLEAR_PENDING_EXCEPTION; return NULL; } - return klass(); + return k; } else { return k; } @@ -456,16 +454,15 @@ } -void ConstantPool::verify_constant_pool_resolve(const constantPoolHandle& this_cp, KlassHandle k, TRAPS) { +void ConstantPool::verify_constant_pool_resolve(const constantPoolHandle& this_cp, Klass* k, TRAPS) { if (k->is_instance_klass() || k->is_objArray_klass()) { - instanceKlassHandle holder (THREAD, this_cp->pool_holder()); - Klass* elem = k->is_instance_klass() ? k() : ObjArrayKlass::cast(k())->bottom_klass(); - KlassHandle element (THREAD, elem); + InstanceKlass* holder = this_cp->pool_holder(); + Klass* elem = k->is_instance_klass() ? k : ObjArrayKlass::cast(k)->bottom_klass(); // The element type could be a typeArray - we only need the access check if it is // an reference to another class - if (element->is_instance_klass()) { - LinkResolver::check_klass_accessability(holder, element, CHECK); + if (elem->is_instance_klass()) { + LinkResolver::check_klass_accessability(holder, elem, CHECK); } } } @@ -693,8 +690,7 @@ callee_index, name->as_C_string(), signature->as_C_string()); } - Klass* k = klass_at_impl(this_cp, callee_index, true, CHECK_NULL); - KlassHandle callee(THREAD, k); + Klass* callee = klass_at_impl(this_cp, callee_index, true, CHECK_NULL); // Check constant pool method consistency if ((callee->is_interface() && m_tag.is_method()) || @@ -710,7 +706,7 @@ THROW_MSG_NULL(vmSymbols::java_lang_IncompatibleClassChangeError(), buf); } - KlassHandle klass(THREAD, this_cp->pool_holder()); + Klass* klass = this_cp->pool_holder(); Handle value = SystemDictionary::link_method_handle_constant(klass, ref_kind, callee, name, signature, THREAD); @@ -729,7 +725,7 @@ index, this_cp->method_type_index_at(index), signature->as_C_string()); } - KlassHandle klass(THREAD, this_cp->pool_holder()); + Klass* klass = this_cp->pool_holder(); Handle value = SystemDictionary::find_method_handle_type(signature, klass, THREAD); result_oop = value(); if (HAS_PENDING_EXCEPTION) { @@ -845,8 +841,7 @@ } -bool ConstantPool::klass_name_at_matches(instanceKlassHandle k, - int which) { +bool ConstantPool::klass_name_at_matches(const InstanceKlass* k, int which) { // Names are interned, so we can compare Symbol*s directly Symbol* cp_name = klass_name_at(which); return (cp_name == k->name());
--- a/hotspot/src/share/vm/oops/constantPool.hpp Wed Mar 15 11:44:46 2017 +0100 +++ b/hotspot/src/share/vm/oops/constantPool.hpp Wed Mar 15 10:25:37 2017 -0400 @@ -693,7 +693,7 @@ } // Klass name matches name at offset - bool klass_name_at_matches(instanceKlassHandle k, int which); + bool klass_name_at_matches(const InstanceKlass* k, int which); // Sizing int length() const { return _length; } @@ -784,7 +784,7 @@ } // Performs the LinkResolver checks - static void verify_constant_pool_resolve(const constantPoolHandle& this_cp, KlassHandle klass, TRAPS); + static void verify_constant_pool_resolve(const constantPoolHandle& this_cp, Klass* klass, TRAPS); // Implementation of methods that needs an exposed 'this' pointer, in order to // handle GC while executing the method @@ -792,7 +792,7 @@ bool save_resolution_error, TRAPS); static oop string_at_impl(const constantPoolHandle& this_cp, int which, int obj_index, TRAPS); - static void trace_class_resolution(const constantPoolHandle& this_cp, KlassHandle k); + static void trace_class_resolution(const constantPoolHandle& this_cp, Klass* k); // Resolve string constants (to prevent allocation during compilation) static void resolve_string_constants_impl(const constantPoolHandle& this_cp, TRAPS);
--- a/hotspot/src/share/vm/oops/cpCache.cpp Wed Mar 15 11:44:46 2017 +0100 +++ b/hotspot/src/share/vm/oops/cpCache.cpp Wed Mar 15 10:25:37 2017 -0400 @@ -101,14 +101,14 @@ // are updated, lest other processors see a non-zero bytecode but zero f1/f2. void ConstantPoolCacheEntry::set_field(Bytecodes::Code get_code, Bytecodes::Code put_code, - KlassHandle field_holder, + Klass* field_holder, int field_index, int field_offset, TosState field_type, bool is_final, bool is_volatile, Klass* root_klass) { - set_f1(field_holder()); + set_f1(field_holder); set_f2(field_offset); assert((field_index & field_index_mask) == field_index, "field index does not fit in low flag bits");
--- a/hotspot/src/share/vm/oops/cpCache.hpp Wed Mar 15 11:44:46 2017 +0100 +++ b/hotspot/src/share/vm/oops/cpCache.hpp Wed Mar 15 10:25:37 2017 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2017, 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 @@ -217,7 +217,7 @@ void set_field( // sets entry to resolved field state Bytecodes::Code get_code, // the bytecode used for reading the field Bytecodes::Code put_code, // the bytecode used for writing the field - KlassHandle field_holder, // the object/klass holding the field + Klass* field_holder, // the object/klass holding the field int orig_field_index, // the original field index in the field holder int field_offset, // the field offset in words in the field holder TosState field_type, // the (machine) field type
--- a/hotspot/src/share/vm/oops/fieldStreams.hpp Wed Mar 15 11:44:46 2017 +0100 +++ b/hotspot/src/share/vm/oops/fieldStreams.hpp Wed Mar 15 10:25:37 2017 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2017, 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 @@ -107,14 +107,6 @@ init_generic_signature_start_slot(); assert(klass == field_holder(), ""); } - FieldStreamBase(instanceKlassHandle klass) { - _fields = klass->fields(); - _constants = klass->constants(); - _index = 0; - _limit = klass->java_fields_count(); - init_generic_signature_start_slot(); - assert(klass == field_holder(), ""); - } // accessors int index() const { return _index; } @@ -196,7 +188,7 @@ // Iterate over only the internal fields class JavaFieldStream : public FieldStreamBase { public: - JavaFieldStream(instanceKlassHandle k): FieldStreamBase(k->fields(), k->constants(), 0, k->java_fields_count()) {} + JavaFieldStream(const InstanceKlass* k): FieldStreamBase(k->fields(), k->constants(), 0, k->java_fields_count()) {} int name_index() const { assert(!field()->is_internal(), "regular only"); @@ -245,7 +237,6 @@ class InternalFieldStream : public FieldStreamBase { public: InternalFieldStream(InstanceKlass* k): FieldStreamBase(k->fields(), k->constants(), k->java_fields_count(), 0) {} - InternalFieldStream(instanceKlassHandle k): FieldStreamBase(k->fields(), k->constants(), k->java_fields_count(), 0) {} }; @@ -253,7 +244,6 @@ public: AllFieldStream(Array<u2>* fields, const constantPoolHandle& constants): FieldStreamBase(fields, constants) {} AllFieldStream(InstanceKlass* k): FieldStreamBase(k->fields(), k->constants()) {} - AllFieldStream(instanceKlassHandle k): FieldStreamBase(k->fields(), k->constants()) {} }; #endif // SHARE_VM_OOPS_FIELDSTREAMS_HPP
--- a/hotspot/src/share/vm/oops/instanceKlass.cpp Wed Mar 15 11:44:46 2017 +0100 +++ b/hotspot/src/share/vm/oops/instanceKlass.cpp Wed Mar 15 10:25:37 2017 -0400 @@ -374,7 +374,7 @@ } klassItable* InstanceKlass::itable() const { - return new klassItable(instanceKlassHandle(this)); + return new klassItable(const_cast<InstanceKlass*>(this)); } void InstanceKlass::eager_initialize(Thread *thread) { @@ -392,8 +392,7 @@ if (!InstanceKlass::cast(super)->is_initialized()) return; // call body to expose the this pointer - instanceKlassHandle this_k(thread, this); - eager_initialize_impl(this_k); + eager_initialize_impl(this); } } @@ -432,7 +431,7 @@ assert(!is_not_initialized(), "class must be initialized now"); } -void InstanceKlass::eager_initialize_impl(instanceKlassHandle this_k) { +void InstanceKlass::eager_initialize_impl(InstanceKlass* this_k) { EXCEPTION_MARK; HandleMark hm(THREAD); Handle init_lock(THREAD, this_k->init_lock()); @@ -470,8 +469,7 @@ // Note: implementation moved to static method to expose the this pointer. void InstanceKlass::initialize(TRAPS) { if (this->should_be_initialized()) { - instanceKlassHandle this_k(THREAD, this); - initialize_impl(this_k, CHECK); + initialize_impl(this, CHECK); // Note: at this point the class may be initialized // OR it may be in the state of being initialized // in case of recursive initialization! @@ -482,7 +480,7 @@ bool InstanceKlass::verify_code( - instanceKlassHandle this_k, bool throw_verifyerror, TRAPS) { + InstanceKlass* this_k, bool throw_verifyerror, TRAPS) { // 1) Verify the bytecodes Verifier::Mode mode = throw_verifyerror ? Verifier::ThrowException : Verifier::NoException; @@ -501,8 +499,7 @@ void InstanceKlass::link_class(TRAPS) { assert(is_loaded(), "must be loaded"); if (!is_linked()) { - instanceKlassHandle this_k(THREAD, this); - link_class_impl(this_k, true, CHECK); + link_class_impl(this, true, CHECK); } } @@ -511,14 +508,13 @@ bool InstanceKlass::link_class_or_fail(TRAPS) { assert(is_loaded(), "must be loaded"); if (!is_linked()) { - instanceKlassHandle this_k(THREAD, this); - link_class_impl(this_k, false, CHECK_false); + link_class_impl(this, false, CHECK_false); } return is_linked(); } bool InstanceKlass::link_class_impl( - instanceKlassHandle this_k, bool throw_verifyerror, TRAPS) { + InstanceKlass* this_k, bool throw_verifyerror, TRAPS) { if (DumpSharedSpaces && this_k->is_in_error_state()) { // This is for CDS dumping phase only -- we use the in_error_state to indicate that // the class has failed verification. Throwing the NoClassDefFoundError here is just @@ -542,8 +538,8 @@ JavaThread* jt = (JavaThread*)THREAD; // link super class before linking this class - instanceKlassHandle super(THREAD, this_k->super()); - if (super.not_null()) { + Klass* super = this_k->super(); + if (super != NULL) { if (super->is_interface()) { // check if super class is an interface ResourceMark rm(THREAD); Exceptions::fthrow( @@ -556,15 +552,16 @@ return false; } - link_class_impl(super, throw_verifyerror, CHECK_false); + InstanceKlass* ik_super = InstanceKlass::cast(super); + link_class_impl(ik_super, throw_verifyerror, CHECK_false); } // link all interfaces implemented by this class before linking this class Array<Klass*>* interfaces = this_k->local_interfaces(); int num_interfaces = interfaces->length(); for (int index = 0; index < num_interfaces; index++) { - instanceKlassHandle ih(THREAD, interfaces->at(index)); - link_class_impl(ih, throw_verifyerror, CHECK_false); + InstanceKlass* interk = InstanceKlass::cast(interfaces->at(index)); + link_class_impl(interk, throw_verifyerror, CHECK_false); } // in case the class is linked in the process of linking its superclasses @@ -642,7 +639,7 @@ if (JvmtiExport::should_post_class_prepare()) { Thread *thread = THREAD; assert(thread->is_Java_thread(), "thread->is_Java_thread()"); - JvmtiExport::post_class_prepare((JavaThread *) thread, this_k()); + JvmtiExport::post_class_prepare((JavaThread *) thread, this_k); } } } @@ -655,13 +652,12 @@ // verification but before the first method of the class is executed. void InstanceKlass::rewrite_class(TRAPS) { assert(is_loaded(), "must be loaded"); - instanceKlassHandle this_k(THREAD, this); - if (this_k->is_rewritten()) { - assert(this_k()->is_shared(), "rewriting an unshared class?"); + if (is_rewritten()) { + assert(is_shared(), "rewriting an unshared class?"); return; } - Rewriter::rewrite(this_k, CHECK); - this_k->set_rewritten(); + Rewriter::rewrite(this, CHECK); + set_rewritten(); } // Now relocate and link method entry points after class is rewritten. @@ -678,7 +674,7 @@ } // Eagerly initialize superinterfaces that declare default methods (concrete instance: any access) -void InstanceKlass::initialize_super_interfaces(instanceKlassHandle this_k, TRAPS) { +void InstanceKlass::initialize_super_interfaces(InstanceKlass* this_k, TRAPS) { assert (this_k->has_nonstatic_concrete_methods(), "caller should have checked this"); for (int i = 0; i < this_k->local_interfaces()->length(); ++i) { Klass* iface = this_k->local_interfaces()->at(i); @@ -698,14 +694,14 @@ } } -void InstanceKlass::initialize_impl(instanceKlassHandle this_k, TRAPS) { +void InstanceKlass::initialize_impl(InstanceKlass* this_k, TRAPS) { HandleMark hm(THREAD); // Make sure klass is linked (verified) before initialization // A class could already be verified, since it has been reflected upon. this_k->link_class(CHECK); - DTRACE_CLASSINIT_PROBE(required, this_k(), -1); + DTRACE_CLASSINIT_PROBE(required, this_k, -1); bool wait = false; @@ -728,19 +724,19 @@ // Step 3 if (this_k->is_being_initialized() && this_k->is_reentrant_initialization(self)) { - DTRACE_CLASSINIT_PROBE_WAIT(recursive, this_k(), -1,wait); + DTRACE_CLASSINIT_PROBE_WAIT(recursive, this_k, -1,wait); return; } // Step 4 if (this_k->is_initialized()) { - DTRACE_CLASSINIT_PROBE_WAIT(concurrent, this_k(), -1,wait); + DTRACE_CLASSINIT_PROBE_WAIT(concurrent, this_k, -1,wait); return; } // Step 5 if (this_k->is_in_error_state()) { - DTRACE_CLASSINIT_PROBE_WAIT(erroneous, this_k(), -1,wait); + DTRACE_CLASSINIT_PROBE_WAIT(erroneous, this_k, -1,wait); ResourceMark rm(THREAD); const char* desc = "Could not initialize class "; const char* className = this_k->external_name(); @@ -786,7 +782,7 @@ this_k->set_initialization_state_and_notify(initialization_error, THREAD); CLEAR_PENDING_EXCEPTION; } - DTRACE_CLASSINIT_PROBE_WAIT(super__failed, this_k(), -1,wait); + DTRACE_CLASSINIT_PROBE_WAIT(super__failed, this_k, -1,wait); THROW_OOP(e()); } } @@ -799,7 +795,7 @@ { assert(THREAD->is_Java_thread(), "non-JavaThread in initialize_impl"); JavaThread* jt = (JavaThread*)THREAD; - DTRACE_CLASSINIT_PROBE_WAIT(clinit, this_k(), -1,wait); + DTRACE_CLASSINIT_PROBE_WAIT(clinit, this_k, -1,wait); // Timer includes any side effects of class initialization (resolution, // etc), but not recursive entry into call_class_initializer(). PerfClassTraceTime timer(ClassLoader::perf_class_init_time(), @@ -833,7 +829,7 @@ // JVMTI internal flag reset is needed in order to report ExceptionInInitializerError JvmtiExport::clear_detected_exception((JavaThread*)THREAD); } - DTRACE_CLASSINIT_PROBE_WAIT(error, this_k(), -1,wait); + DTRACE_CLASSINIT_PROBE_WAIT(error, this_k, -1,wait); if (e->is_a(SystemDictionary::Error_klass())) { THROW_OOP(e()); } else { @@ -843,17 +839,16 @@ &args); } } - DTRACE_CLASSINIT_PROBE_WAIT(end, this_k(), -1,wait); + DTRACE_CLASSINIT_PROBE_WAIT(end, this_k, -1,wait); } // Note: implementation moved to static method to expose the this pointer. void InstanceKlass::set_initialization_state_and_notify(ClassState state, TRAPS) { - instanceKlassHandle kh(THREAD, this); - set_initialization_state_and_notify_impl(kh, state, CHECK); + set_initialization_state_and_notify_impl(this, state, CHECK); } -void InstanceKlass::set_initialization_state_and_notify_impl(instanceKlassHandle this_k, ClassState state, TRAPS) { +void InstanceKlass::set_initialization_state_and_notify_impl(InstanceKlass* this_k, ClassState state, TRAPS) { Handle init_lock(THREAD, this_k->init_lock()); if (init_lock() != NULL) { ObjectLocker ol(init_lock, THREAD); @@ -995,9 +990,8 @@ } int size = objArrayOopDesc::object_size(length); Klass* ak = array_klass(n, CHECK_NULL); - KlassHandle h_ak (THREAD, ak); objArrayOop o = - (objArrayOop)CollectedHeap::array_allocate(h_ak, size, length, CHECK_NULL); + (objArrayOop)CollectedHeap::array_allocate(ak, size, length, CHECK_NULL); return o; } @@ -1020,11 +1014,9 @@ bool has_finalizer_flag = has_finalizer(); // Query before possible GC int size = size_helper(); // Query before forming handle. - KlassHandle h_k(THREAD, this); - instanceOop i; - i = (instanceOop)CollectedHeap::obj_allocate(h_k, size, CHECK_NULL); + i = (instanceOop)CollectedHeap::obj_allocate(this, size, CHECK_NULL); if (has_finalizer_flag && !RegisterFinalizersAtInit) { i = register_finalizer(i, CHECK_NULL); } @@ -1045,11 +1037,10 @@ } Klass* InstanceKlass::array_klass_impl(bool or_null, int n, TRAPS) { - instanceKlassHandle this_k(THREAD, this); - return array_klass_impl(this_k, or_null, n, THREAD); + return array_klass_impl(this, or_null, n, THREAD); } -Klass* InstanceKlass::array_klass_impl(instanceKlassHandle this_k, bool or_null, int n, TRAPS) { +Klass* InstanceKlass::array_klass_impl(InstanceKlass* this_k, bool or_null, int n, TRAPS) { // Need load-acquire for lock-free read if (this_k->array_klasses_acquire() == NULL) { if (or_null) return NULL; @@ -1082,13 +1073,12 @@ } void InstanceKlass::call_class_initializer(TRAPS) { - instanceKlassHandle ik (THREAD, this); - call_class_initializer_impl(ik, THREAD); + call_class_initializer_impl(this, THREAD); } static int call_class_initializer_impl_counter = 0; // for debugging -Method* InstanceKlass::class_initializer() { +Method* InstanceKlass::class_initializer() const { Method* clinit = find_method( vmSymbols::class_initializer_name(), vmSymbols::void_method_signature()); if (clinit != NULL && clinit->has_valid_initializer_flags()) { @@ -1097,7 +1087,7 @@ return NULL; } -void InstanceKlass::call_class_initializer_impl(instanceKlassHandle this_k, TRAPS) { +void InstanceKlass::call_class_initializer_impl(InstanceKlass* this_k, TRAPS) { if (ReplayCompiles && (ReplaySuppressInitializers == 1 || ReplaySuppressInitializers >= 2 && this_k->class_loader() != NULL)) { @@ -1112,7 +1102,7 @@ outputStream* log = Log(class, init)::info_stream(); log->print("%d Initializing ", call_class_initializer_impl_counter++); this_k->name()->print_value_on(log); - log->print_cr("%s (" INTPTR_FORMAT ")", h_method() == NULL ? "(no method)" : "", p2i(this_k())); + log->print_cr("%s (" INTPTR_FORMAT ")", h_method() == NULL ? "(no method)" : "", p2i(this_k)); } if (h_method() != NULL) { JavaCallArguments args; // No arguments @@ -1263,14 +1253,13 @@ void InstanceKlass::do_local_static_fields(void f(fieldDescriptor*, Handle, TRAPS), Handle mirror, TRAPS) { - instanceKlassHandle h_this(THREAD, this); - do_local_static_fields_impl(h_this, f, mirror, CHECK); + do_local_static_fields_impl(this, f, mirror, CHECK); } -void InstanceKlass::do_local_static_fields_impl(instanceKlassHandle this_k, +void InstanceKlass::do_local_static_fields_impl(InstanceKlass* this_k, void f(fieldDescriptor* fd, Handle, TRAPS), Handle mirror, TRAPS) { - for (JavaFieldStream fs(this_k()); !fs.done(); fs.next()) { + for (JavaFieldStream fs(this_k); !fs.done(); fs.next()) { if (fs.access_flags().is_static()) { fieldDescriptor& fd = fs.field_descriptor(); f(&fd, mirror, CHECK); @@ -1629,13 +1618,13 @@ } /* jni_id_for_impl for jfieldIds only */ -JNIid* InstanceKlass::jni_id_for_impl(instanceKlassHandle this_k, int offset) { +JNIid* InstanceKlass::jni_id_for_impl(InstanceKlass* this_k, int offset) { MutexLocker ml(JfieldIdCreation_lock); // Retry lookup after we got the lock JNIid* probe = this_k->jni_ids() == NULL ? NULL : this_k->jni_ids()->find(offset); if (probe == NULL) { // Slow case, allocate new static field identifier - probe = new JNIid(this_k(), offset, this_k->jni_ids()); + probe = new JNIid(this_k, offset, this_k->jni_ids()); this_k->set_jni_ids(probe); } return probe; @@ -1684,9 +1673,9 @@ // locking has to be done very carefully to avoid deadlocks // and/or other cache consistency problems. // -jmethodID InstanceKlass::get_jmethod_id(instanceKlassHandle ik_h, const methodHandle& method_h) { +jmethodID InstanceKlass::get_jmethod_id(InstanceKlass* ik, const methodHandle& method_h) { size_t idnum = (size_t)method_h->method_idnum(); - jmethodID* jmeths = ik_h->methods_jmethod_ids_acquire(); + jmethodID* jmeths = ik->methods_jmethod_ids_acquire(); size_t length = 0; jmethodID id = NULL; @@ -1710,7 +1699,7 @@ if (jmeths != NULL) { // the cache already exists - if (!ik_h->idnum_can_increment()) { + if (!ik->idnum_can_increment()) { // the cache can't grow so we can just get the current values get_jmethod_id_length_value(jmeths, idnum, &length, &id); } else { @@ -1744,7 +1733,7 @@ jmethodID* new_jmeths = NULL; if (length <= idnum) { // allocate a new cache that might be used - size_t size = MAX2(idnum+1, (size_t)ik_h->idnum_allocated_count()); + size_t size = MAX2(idnum+1, (size_t)ik->idnum_allocated_count()); new_jmeths = NEW_C_HEAP_ARRAY(jmethodID, size+1, mtClass); memset(new_jmeths, 0, (size+1)*sizeof(jmethodID)); // cache size is stored in element[0], other elements offset by one @@ -1755,23 +1744,23 @@ jmethodID new_id = NULL; if (method_h->is_old() && !method_h->is_obsolete()) { // The method passed in is old (but not obsolete), we need to use the current version - Method* current_method = ik_h->method_with_idnum((int)idnum); + Method* current_method = ik->method_with_idnum((int)idnum); assert(current_method != NULL, "old and but not obsolete, so should exist"); - new_id = Method::make_jmethod_id(ik_h->class_loader_data(), current_method); + new_id = Method::make_jmethod_id(ik->class_loader_data(), current_method); } else { // It is the current version of the method or an obsolete method, // use the version passed in - new_id = Method::make_jmethod_id(ik_h->class_loader_data(), method_h()); + new_id = Method::make_jmethod_id(ik->class_loader_data(), method_h()); } if (Threads::number_of_threads() == 0 || SafepointSynchronize::is_at_safepoint()) { // we're single threaded or at a safepoint - no locking needed - id = get_jmethod_id_fetch_or_update(ik_h, idnum, new_id, new_jmeths, + id = get_jmethod_id_fetch_or_update(ik, idnum, new_id, new_jmeths, &to_dealloc_id, &to_dealloc_jmeths); } else { MutexLocker ml(JmethodIdCreation_lock); - id = get_jmethod_id_fetch_or_update(ik_h, idnum, new_id, new_jmeths, + id = get_jmethod_id_fetch_or_update(ik, idnum, new_id, new_jmeths, &to_dealloc_id, &to_dealloc_jmeths); } @@ -1782,7 +1771,7 @@ } // free up the new ID since it wasn't needed if (to_dealloc_id != NULL) { - Method::destroy_jmethod_id(ik_h->class_loader_data(), to_dealloc_id); + Method::destroy_jmethod_id(ik->class_loader_data(), to_dealloc_id); } } return id; @@ -1814,7 +1803,7 @@ // the VMThread or have cache consistency issues. // jmethodID InstanceKlass::get_jmethod_id_fetch_or_update( - instanceKlassHandle ik_h, size_t idnum, jmethodID new_id, + InstanceKlass* ik, size_t idnum, jmethodID new_id, jmethodID* new_jmeths, jmethodID* to_dealloc_id_p, jmethodID** to_dealloc_jmeths_p) { assert(new_id != NULL, "sanity check"); @@ -1825,7 +1814,7 @@ JmethodIdCreation_lock->owned_by_self(), "sanity check"); // reacquire the cache - we are locked, single threaded or at a safepoint - jmethodID* jmeths = ik_h->methods_jmethod_ids_acquire(); + jmethodID* jmeths = ik->methods_jmethod_ids_acquire(); jmethodID id = NULL; size_t length = 0; @@ -1838,7 +1827,7 @@ } *to_dealloc_jmeths_p = jmeths; // save old cache for later delete } - ik_h->release_set_methods_jmethod_ids(jmeths = new_jmeths); + ik->release_set_methods_jmethod_ids(jmeths = new_jmeths); } else { // fetch jmethodID (if any) from the existing cache id = jmeths[idnum+1]; @@ -2058,11 +2047,10 @@ } void InstanceKlass::restore_unshareable_info(ClassLoaderData* loader_data, Handle protection_domain, TRAPS) { - instanceKlassHandle ik(THREAD, this); - ik->set_package(loader_data, CHECK); + set_package(loader_data, CHECK); Klass::restore_unshareable_info(loader_data, protection_domain, CHECK); - Array<Method*>* methods = ik->methods(); + Array<Method*>* methods = this->methods(); int num_methods = methods->length(); for (int index2 = 0; index2 < num_methods; ++index2) { methodHandle m(THREAD, methods->at(index2)); @@ -2075,14 +2063,14 @@ // vtables in the shared system dictionary, only the main one. // It also redefines the itable too so fix that too. ResourceMark rm(THREAD); - ik->vtable()->initialize_vtable(false, CHECK); - ik->itable()->initialize_itable(false, CHECK); + vtable()->initialize_vtable(false, CHECK); + itable()->initialize_itable(false, CHECK); } // restore constant pool resolved references - ik->constants()->restore_unshareable_info(CHECK); - - ik->array_klasses_do(restore_unshareable_in_class, CHECK); + constants()->restore_unshareable_info(CHECK); + + array_klasses_do(restore_unshareable_in_class, CHECK); } // returns true IFF is_in_error_state() has been changed as a result of this call. @@ -2448,7 +2436,7 @@ } /* defined for now in jvm.cpp, for historical reasons *-- -Klass* InstanceKlass::compute_enclosing_class_impl(instanceKlassHandle self, +Klass* InstanceKlass::compute_enclosing_class_impl(InstanceKlass* self, Symbol*& simple_name_result, TRAPS) { ... } @@ -2522,7 +2510,7 @@ return false; } -bool InstanceKlass::find_inner_classes_attr(instanceKlassHandle k, int* ooff, int* noff, TRAPS) { +bool InstanceKlass::find_inner_classes_attr(const InstanceKlass* k, int* ooff, int* noff, TRAPS) { constantPoolHandle i_cp(THREAD, k->constants()); for (InnerClassesIterator iter(k); !iter.done(); iter.next()) { int ioff = iter.inner_class_info_index(); @@ -2531,7 +2519,7 @@ // before attempting to find the class. if (i_cp->klass_name_at_matches(k, ioff)) { Klass* inner_klass = i_cp->klass_at(ioff, CHECK_false); - if (k() == inner_klass) { + if (k == inner_klass) { *ooff = iter.outer_class_info_index(); *noff = iter.inner_name_index(); return true; @@ -2580,8 +2568,7 @@ jint access = access_flags().as_int(); // But check if it happens to be member class. - instanceKlassHandle ik(THREAD, this); - InnerClassesIterator iter(ik); + InnerClassesIterator iter(this); for (; !iter.done(); iter.next()) { int ioff = iter.inner_class_info_index(); // Inner class attribute can be zero, skip it. @@ -2590,8 +2577,8 @@ // only look at classes that are already loaded // since we are looking for the flags for our self. - Symbol* inner_name = ik->constants()->klass_name_at(ioff); - if ((ik->name() == inner_name)) { + Symbol* inner_name = constants()->klass_name_at(ioff); + if (name() == inner_name) { // This is really a member class. access = iter.inner_access_flags(); break; @@ -3612,7 +3599,7 @@ // Save the scratch_class as the previous version if any of the methods are running. // The previous_versions are used to set breakpoints in EMCP methods and they are // also used to clean MethodData links to redefined methods that are no longer running. -void InstanceKlass::add_previous_version(instanceKlassHandle scratch_class, +void InstanceKlass::add_previous_version(InstanceKlass* scratch_class, int emcp_method_count) { assert(Thread::current()->is_VM_thread(), "only VMThread can add previous versions"); @@ -3638,7 +3625,7 @@ log_trace(redefine, class, iklass, add)("scratch class not added; no methods are running"); // For debugging purposes. scratch_class->set_is_scratch_class(); - scratch_class->class_loader_data()->add_to_deallocate_list(scratch_class()); + scratch_class->class_loader_data()->add_to_deallocate_list(scratch_class); return; } @@ -3671,7 +3658,7 @@ log_trace(redefine, class, iklass, add) ("scratch class added; one of its methods is on_stack."); assert(scratch_class->previous_versions() == NULL, "shouldn't have a previous version"); scratch_class->link_previous_versions(previous_versions()); - link_previous_versions(scratch_class()); + link_previous_versions(scratch_class); } // end add_previous_version() #endif // INCLUDE_JVMTI
--- a/hotspot/src/share/vm/oops/instanceKlass.hpp Wed Mar 15 11:44:46 2017 +0100 +++ b/hotspot/src/share/vm/oops/instanceKlass.hpp Wed Mar 15 10:25:37 2017 -0400 @@ -472,7 +472,7 @@ TRAPS); // Find InnerClasses attribute for k and return outer_class_info_index & inner_name_index. - static bool find_inner_classes_attr(instanceKlassHandle k, + static bool find_inner_classes_attr(const InstanceKlass* k, int* ooff, int* noff, TRAPS); private: @@ -524,7 +524,7 @@ void unlink_class(); void rewrite_class(TRAPS); void link_methods(TRAPS); - Method* class_initializer(); + Method* class_initializer() const; // set the class to initialized if no static initializer is present void eager_initialize(Thread *thread); @@ -711,7 +711,7 @@ void set_is_being_redefined(bool value) { _is_being_redefined = value; } // RedefineClasses() support for previous versions: - void add_previous_version(instanceKlassHandle ikh, int emcp_method_count); + void add_previous_version(InstanceKlass* ik, int emcp_method_count); void purge_previous_version_list(); InstanceKlass* previous_versions() const { return _previous_versions; } @@ -883,9 +883,9 @@ u2 method_index); // jmethodID support - static jmethodID get_jmethod_id(instanceKlassHandle ik_h, + static jmethodID get_jmethod_id(InstanceKlass* ik, const methodHandle& method_h); - static jmethodID get_jmethod_id_fetch_or_update(instanceKlassHandle ik_h, + static jmethodID get_jmethod_id_fetch_or_update(InstanceKlass* ik, size_t idnum, jmethodID new_id, jmethodID* new_jmeths, jmethodID* to_dealloc_id_p, jmethodID** to_dealloc_jmeths_p); @@ -1308,17 +1308,17 @@ // 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_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 initialize_super_interfaces (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, Handle, TRAPS), Handle, TRAPS); + static bool link_class_impl (InstanceKlass* this_k, bool throw_verifyerror, TRAPS); + static bool verify_code (InstanceKlass* this_k, bool throw_verifyerror, TRAPS); + static void initialize_impl (InstanceKlass* this_k, TRAPS); + static void initialize_super_interfaces (InstanceKlass* this_k, TRAPS); + static void eager_initialize_impl (InstanceKlass* this_k); + static void set_initialization_state_and_notify_impl (InstanceKlass* this_k, ClassState state, TRAPS); + static void call_class_initializer_impl (InstanceKlass* this_k, TRAPS); + static Klass* array_klass_impl (InstanceKlass* this_k, bool or_null, int n, TRAPS); + static void do_local_static_fields_impl (InstanceKlass* this_k, void f(fieldDescriptor* fd, Handle, TRAPS), Handle, TRAPS); /* jni_id_for_impl for jfieldID only */ - static JNIid* jni_id_for_impl (instanceKlassHandle this_k, int offset); + static JNIid* jni_id_for_impl (InstanceKlass* this_k, int offset); // Returns the array class for the n'th dimension Klass* array_klass_impl(bool or_null, int n, TRAPS); @@ -1447,7 +1447,7 @@ int _idx; public: - InnerClassesIterator(instanceKlassHandle k) { + InnerClassesIterator(const InstanceKlass* k) { _inner_classes = k->inner_classes(); if (k->inner_classes() != NULL) { _length = _inner_classes->length();
--- a/hotspot/src/share/vm/oops/instanceMirrorKlass.cpp Wed Mar 15 11:44:46 2017 +0100 +++ b/hotspot/src/share/vm/oops/instanceMirrorKlass.cpp Wed Mar 15 10:25:37 2017 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2017, 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 @@ -39,23 +39,21 @@ int InstanceMirrorKlass::_offset_of_static_fields = 0; -int InstanceMirrorKlass::instance_size(KlassHandle k) { - if (k() != NULL && k->is_instance_klass()) { - return align_object_size(size_helper() + InstanceKlass::cast(k())->static_field_size()); +int InstanceMirrorKlass::instance_size(Klass* k) { + if (k != NULL && k->is_instance_klass()) { + return align_object_size(size_helper() + InstanceKlass::cast(k)->static_field_size()); } return size_helper(); } -instanceOop InstanceMirrorKlass::allocate_instance(KlassHandle k, TRAPS) { +instanceOop InstanceMirrorKlass::allocate_instance(Klass* k, TRAPS) { // Query before forming handle. int size = instance_size(k); - KlassHandle h_k(THREAD, this); - assert(size > 0, "total object size must be positive: %d", size); // Since mirrors can be variable sized because of the static fields, store // the size in the mirror itself. - return (instanceOop)CollectedHeap::class_allocate(h_k, size, CHECK_NULL); + return (instanceOop)CollectedHeap::class_allocate(this, size, CHECK_NULL); } int InstanceMirrorKlass::oop_size(oop obj) const {
--- a/hotspot/src/share/vm/oops/instanceMirrorKlass.hpp Wed Mar 15 11:44:46 2017 +0100 +++ b/hotspot/src/share/vm/oops/instanceMirrorKlass.hpp Wed Mar 15 10:25:37 2017 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2017, 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 @@ -82,10 +82,10 @@ int compute_static_oop_field_count(oop obj); // Given a Klass return the size of the instance - int instance_size(KlassHandle k); + int instance_size(Klass* k); // allocation - instanceOop allocate_instance(KlassHandle k, TRAPS); + instanceOop allocate_instance(Klass* k, TRAPS); // GC specific object visitors //
--- a/hotspot/src/share/vm/oops/klass.cpp Wed Mar 15 11:44:46 2017 +0100 +++ b/hotspot/src/share/vm/oops/klass.cpp Wed Mar 15 10:25:37 2017 -0400 @@ -264,7 +264,6 @@ } if (secondary_supers() == NULL) { - KlassHandle this_kh (THREAD, this); // Now compute the list of secondary supertypes. // Secondaries can occasionally be on the super chain, @@ -286,7 +285,7 @@ GrowableArray<Klass*>* primaries = new GrowableArray<Klass*>(extras); - for (p = this_kh->super(); !(p == NULL || p->can_be_primary_super()); p = p->super()) { + for (p = super(); !(p == NULL || p->can_be_primary_super()); p = p->super()) { int i; // Scan for overflow primaries being duplicates of 2nd'arys // This happens frequently for very deeply nested arrays: the @@ -324,7 +323,7 @@ } #endif - this_kh->set_secondary_supers(s2); + set_secondary_supers(s2); } } @@ -698,7 +697,7 @@ } klassVtable* Klass::vtable() const { - return new klassVtable(this, start_of_vtable(), vtable_length() / vtableEntry::size()); + return new klassVtable(const_cast<Klass*>(this), start_of_vtable(), vtable_length() / vtableEntry::size()); } vtableEntry* Klass::start_of_vtable() const {
--- a/hotspot/src/share/vm/oops/klassVtable.cpp Wed Mar 15 11:44:46 2017 +0100 +++ b/hotspot/src/share/vm/oops/klassVtable.cpp Wed Mar 15 10:25:37 2017 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2017, 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,7 +40,7 @@ #include "utilities/copy.hpp" inline InstanceKlass* klassVtable::ik() const { - return InstanceKlass::cast(_klass()); + return InstanceKlass::cast(_klass); } bool klassVtable::is_preinitialized_vtable() { @@ -128,8 +128,8 @@ // Copy super class's vtable to the first part (prefix) of this class's vtable, // and return the number of entries copied. Expects that 'super' is the Java // super class (arrays can have "array" super classes that must be skipped). -int klassVtable::initialize_from_super(KlassHandle super) { - if (super.is_null()) { +int klassVtable::initialize_from_super(Klass* super) { + if (super == NULL) { return 0; } else if (is_preinitialized_vtable()) { // A shared class' vtable is preinitialized at dump time. No need to copy @@ -160,18 +160,18 @@ void klassVtable::initialize_vtable(bool checkconstraints, TRAPS) { // Note: Arrays can have intermediate array supers. Use java_super to skip them. - KlassHandle super (THREAD, klass()->java_super()); + Klass* super = _klass->java_super(); int nofNewEntries = 0; bool is_shared = _klass->is_shared(); - if (!klass()->is_array_klass()) { + if (!_klass->is_array_klass()) { ResourceMark rm(THREAD); log_develop_debug(vtables)("Initializing: %s", _klass->name()->as_C_string()); } #ifdef ASSERT - oop* end_of_obj = (oop*)_klass() + _klass()->size(); + oop* end_of_obj = (oop*)_klass + _klass->size(); oop* end_of_vtable = (oop*)&table()[_length]; assert(end_of_vtable <= end_of_obj, "vtable extends beyond end"); #endif @@ -184,7 +184,7 @@ } int super_vtable_len = initialize_from_super(super); - if (klass()->is_array_klass()) { + if (_klass->is_array_klass()) { assert(super_vtable_len == _length, "arrays shouldn't introduce new methods"); } else { assert(_klass->is_instance_klass(), "must be InstanceKlass"); @@ -327,7 +327,7 @@ } static void log_vtables(int i, bool overrides, methodHandle target_method, - KlassHandle target_klass, Method* super_method, + Klass* target_klass, Method* super_method, Thread* thread) { #ifndef PRODUCT if (log_develop_is_enabled(Trace, vtables)) { @@ -432,7 +432,7 @@ Symbol* name = target_method()->name(); Symbol* signature = target_method()->signature(); - KlassHandle target_klass(THREAD, target_method()->method_holder()); + Klass* target_klass = target_method()->method_holder(); if (target_klass == NULL) { target_klass = _klass; } @@ -955,7 +955,7 @@ if (!(*trace_name_printed)) { log_info(redefine, class, update) ("adjust: klassname=%s for methods from name=%s", - klass()->external_name(), old_method->method_holder()->external_name()); + _klass->external_name(), old_method->method_holder()->external_name()); *trace_name_printed = true; } log_debug(redefine, class, update, vtables) @@ -1025,17 +1025,17 @@ } } -klassItable::klassItable(instanceKlassHandle klass) { +klassItable::klassItable(InstanceKlass* klass) { _klass = klass; if (klass->itable_length() > 0) { itableOffsetEntry* offset_entry = (itableOffsetEntry*)klass->start_of_itable(); if (offset_entry != NULL && offset_entry->interface_klass() != NULL) { // Check that itable is initialized // First offset entry points to the first method_entry - intptr_t* method_entry = (intptr_t *)(((address)klass()) + offset_entry->offset()); + intptr_t* method_entry = (intptr_t *)(((address)klass) + offset_entry->offset()); intptr_t* end = klass->end_of_itable(); - _table_offset = (intptr_t*)offset_entry - (intptr_t*)klass(); + _table_offset = (intptr_t*)offset_entry - (intptr_t*)klass; _size_offset_table = (method_entry - ((intptr_t*)offset_entry)) / itableOffsetEntry::size(); _size_method_table = (end - method_entry) / itableMethodEntry::size(); assert(_table_offset >= 0 && _size_offset_table >= 0 && _size_method_table >= 0, "wrong computation"); @@ -1056,7 +1056,7 @@ if (_klass->is_interface()) { // This needs to go after vtable indices are assigned but // before implementors need to know the number of itable indices. - assign_itable_indices_for_interface(_klass()); + assign_itable_indices_for_interface(_klass); } // Cannot be setup doing bootstrapping, interfaces don't have @@ -1078,9 +1078,9 @@ for(i = 0; i < num_interfaces; i++) { itableOffsetEntry* ioe = offset_entry(i); HandleMark hm(THREAD); - KlassHandle interf_h (THREAD, ioe->interface_klass()); - assert(interf_h() != NULL && ioe->offset() != 0, "bad offset entry in itable"); - initialize_itable_for_interface(ioe->offset(), interf_h, checkconstraints, CHECK); + Klass* interf = ioe->interface_klass(); + assert(interf != NULL && ioe->offset() != 0, "bad offset entry in itable"); + initialize_itable_for_interface(ioe->offset(), interf, checkconstraints, CHECK); } } @@ -1169,14 +1169,14 @@ } -void klassItable::initialize_itable_for_interface(int method_table_offset, KlassHandle interf_h, bool checkconstraints, TRAPS) { - Array<Method*>* methods = InstanceKlass::cast(interf_h())->methods(); +void klassItable::initialize_itable_for_interface(int method_table_offset, Klass* interf, bool checkconstraints, TRAPS) { + Array<Method*>* methods = InstanceKlass::cast(interf)->methods(); int nof_methods = methods->length(); HandleMark hm; assert(nof_methods > 0, "at least one method must exist for interface to be in vtable"); - Handle interface_loader (THREAD, InstanceKlass::cast(interf_h())->class_loader()); + Handle interface_loader (THREAD, InstanceKlass::cast(interf)->class_loader()); - int ime_count = method_count_for_interface(interf_h()); + int ime_count = method_count_for_interface(interf); for (int i = 0; i < nof_methods; i++) { Method* m = methods->at(i); methodHandle target; @@ -1189,7 +1189,7 @@ // Entry does not resolve. Leave it empty for AbstractMethodError. if (!(target == NULL) && !target->is_public()) { // Stuff an IllegalAccessError throwing method in there instead. - itableOffsetEntry::method_entry(_klass(), method_table_offset)[m->itable_index()]. + itableOffsetEntry::method_entry(_klass, method_table_offset)[m->itable_index()]. initialize(Universe::throw_illegal_access_error()); } } else { @@ -1215,7 +1215,7 @@ const char* loader1 = SystemDictionary::loader_name(method_holder_loader()); char* current = _klass->name()->as_C_string(); const char* loader2 = SystemDictionary::loader_name(interface_loader()); - char* iface = InstanceKlass::cast(interf_h())->name()->as_C_string(); + char* iface = InstanceKlass::cast(interf)->name()->as_C_string(); char* failed_type_name = failed_type_symbol->as_C_string(); size_t buflen = strlen(msg) + strlen(sig) + strlen(loader1) + strlen(current) + strlen(loader2) + strlen(iface) + @@ -1231,14 +1231,14 @@ // ime may have moved during GC so recalculate address int ime_num = m->itable_index(); assert(ime_num < ime_count, "oob"); - itableOffsetEntry::method_entry(_klass(), method_table_offset)[ime_num].initialize(target()); + itableOffsetEntry::method_entry(_klass, method_table_offset)[ime_num].initialize(target()); if (log_develop_is_enabled(Trace, itables)) { ResourceMark rm(THREAD); if (target() != NULL) { outputStream* logst = Log(itables)::trace_stream(); char* sig = target()->name_and_sig_as_C_string(); logst->print("interface: %s, ime_num: %d, target: %s, method_holder: %s ", - interf_h()->internal_name(), ime_num, sig, + interf->internal_name(), ime_num, sig, target()->method_holder()->internal_name()); logst->print("target_method flags: "); target()->print_linkage_flags(logst); @@ -1408,7 +1408,7 @@ // Fill out offset table and interface klasses into the itable space -void klassItable::setup_itable_offset_table(instanceKlassHandle klass) { +void klassItable::setup_itable_offset_table(InstanceKlass* klass) { if (klass->itable_length() == 0) return; assert(!klass->is_interface(), "Should have zero length itable"); @@ -1433,7 +1433,7 @@ assert((oop*)(end) == (oop*)(ime + nof_methods), "wrong offset calculation (2)"); // Visit all interfaces and initialize itable offset table - SetupItableClosure sic((address)klass(), ioe, ime); + SetupItableClosure sic((address)klass, ioe, ime); visit_all_interfaces(klass->transitive_interfaces(), &sic); #ifdef ASSERT @@ -1476,7 +1476,7 @@ if (!forced && _verify_count == Universe::verify_count()) return; _verify_count = Universe::verify_count(); #endif - oop* end_of_obj = (oop*)_klass() + _klass()->size(); + oop* end_of_obj = (oop*)_klass + _klass->size(); oop* end_of_vtable = (oop *)&table()[_length]; if (end_of_vtable > end_of_obj) { fatal("klass %s: klass object too short (vtable extends beyond end)", @@ -1516,8 +1516,7 @@ void vtableEntry::verify(klassVtable* vt, outputStream* st) { NOT_PRODUCT(FlagSetting fs(IgnoreLockingAssertions, true)); - KlassHandle vtklass_h = vt->klass(); - Klass* vtklass = vtklass_h(); + Klass* vtklass = vt->klass(); if (vtklass->is_instance_klass() && (InstanceKlass::cast(vtklass)->major_version() >= klassVtable::VTABLE_TRANSITIVE_OVERRIDE_VERSION)) { assert(method() != NULL, "must have set method"); @@ -1525,7 +1524,7 @@ if (method() != NULL) { method()->verify(); // we sub_type, because it could be a miranda method - if (!vtklass_h->is_subtype_of(method()->method_holder())) { + if (!vtklass->is_subtype_of(method()->method_holder())) { #ifndef PRODUCT print(); #endif
--- a/hotspot/src/share/vm/oops/klassVtable.hpp Wed Mar 15 11:44:46 2017 +0100 +++ b/hotspot/src/share/vm/oops/klassVtable.hpp Wed Mar 15 10:25:37 2017 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2017, 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 @@ -42,7 +42,7 @@ class vtableEntry; class klassVtable : public ResourceObj { - KlassHandle _klass; // my klass + Klass* _klass; // my klass int _tableOffset; // offset of start of vtable data within klass int _length; // length of vtable (number of entries) #ifndef PRODUCT @@ -57,13 +57,13 @@ }; public: - klassVtable(KlassHandle h_klass, void* base, int length) : _klass(h_klass) { - _tableOffset = (address)base - (address)h_klass(); _length = length; + klassVtable(Klass* klass, void* base, int length) : _klass(klass) { + _tableOffset = (address)base - (address)klass; _length = length; } // accessors - vtableEntry* table() const { return (vtableEntry*)(address(_klass()) + _tableOffset); } - KlassHandle klass() const { return _klass; } + vtableEntry* table() const { return (vtableEntry*)(address(_klass) + _tableOffset); } + Klass* klass() const { return _klass; } int length() const { return _length; } inline Method* method_at(int i) const; inline Method* unchecked_method_at(int i) const; @@ -125,7 +125,7 @@ private: void copy_vtable_to(vtableEntry* start); - int initialize_from_super(KlassHandle super); + int initialize_from_super(Klass* super); int index_of(Method* m, int len) const; // same as index_of, but search only up to len void put_method_at(Method* m, int index); static bool needs_new_vtable_entry(methodHandle m, @@ -290,14 +290,14 @@ // class klassItable : public ResourceObj { private: - instanceKlassHandle _klass; // my klass + InstanceKlass* _klass; // my klass int _table_offset; // offset of start of itable data within klass (in words) int _size_offset_table; // size of offset table (in itableOffset entries) int _size_method_table; // size of methodtable (in itableMethodEntry entries) - void initialize_itable_for_interface(int method_table_offset, KlassHandle interf_h, bool checkconstraints, TRAPS); + void initialize_itable_for_interface(int method_table_offset, Klass* interf_h, bool checkconstraints, TRAPS); public: - klassItable(instanceKlassHandle klass); + klassItable(InstanceKlass* klass); itableOffsetEntry* offset_entry(int i) { assert(0 <= i && i <= _size_offset_table, "index out of bounds"); return &((itableOffsetEntry*)vtable_start())[i]; } @@ -329,7 +329,7 @@ static int assign_itable_indices_for_interface(Klass* klass); static int method_count_for_interface(Klass* klass); static int compute_itable_size(Array<Klass*>* transitive_interfaces); - static void setup_itable_offset_table(instanceKlassHandle klass); + static void setup_itable_offset_table(InstanceKlass* klass); // Resolving of method to index static Method* method_for_itable_index(Klass* klass, int itable_index); @@ -337,7 +337,7 @@ // Debugging/Statistics static void print_statistics() PRODUCT_RETURN; private: - intptr_t* vtable_start() const { return ((intptr_t*)_klass()) + _table_offset; } + intptr_t* vtable_start() const { return ((intptr_t*)_klass) + _table_offset; } intptr_t* method_start() const { return vtable_start() + _size_offset_table * itableOffsetEntry::size(); } // Helper methods
--- a/hotspot/src/share/vm/oops/method.cpp Wed Mar 15 11:44:46 2017 +0100 +++ b/hotspot/src/share/vm/oops/method.cpp Wed Mar 15 10:25:37 2017 -0400 @@ -173,7 +173,7 @@ return buf; } -int Method::fast_exception_handler_bci_for(methodHandle mh, KlassHandle ex_klass, int throw_bci, TRAPS) { +int Method::fast_exception_handler_bci_for(methodHandle mh, Klass* ex_klass, int throw_bci, TRAPS) { // exception table holds quadruple entries of the form (beg_bci, end_bci, handler_bci, klass_index) // access exception table ExceptionTable table(mh()); @@ -192,16 +192,15 @@ int klass_index = table.catch_type_index(i); if (klass_index == 0) { return handler_bci; - } else if (ex_klass.is_null()) { + } else if (ex_klass == NULL) { return handler_bci; } else { // we know the exception class => get the constraint class // this may require loading of the constraint class; if verification // fails or some other exception occurs, return handler_bci Klass* k = pool->klass_at(klass_index, CHECK_(handler_bci)); - KlassHandle klass = KlassHandle(THREAD, k); - assert(klass.not_null(), "klass not loaded"); - if (ex_klass->is_subtype_of(klass())) { + assert(k != NULL, "klass not loaded"); + if (ex_klass->is_subtype_of(k)) { return handler_bci; } } @@ -1271,7 +1270,7 @@ ResourceMark rm; methodHandle empty; - KlassHandle holder = SystemDictionary::MethodHandle_klass(); + InstanceKlass* holder = SystemDictionary::MethodHandle_klass(); Symbol* name = MethodHandles::signature_polymorphic_intrinsic_name(iid); assert(iid == MethodHandles::signature_polymorphic_name_id(name), ""); if (TraceMethodHandles) { @@ -1289,7 +1288,7 @@ ConstantPool* cp_oop = ConstantPool::allocate(loader_data, cp_length, CHECK_(empty)); cp = constantPoolHandle(THREAD, cp_oop); } - cp->set_pool_holder(InstanceKlass::cast(holder())); + cp->set_pool_holder(holder); cp->symbol_at_put(_imcp_invoke_name, name); cp->symbol_at_put(_imcp_invoke_signature, signature); cp->set_has_preresolution();
--- a/hotspot/src/share/vm/oops/method.hpp Wed Mar 15 11:44:46 2017 +0100 +++ b/hotspot/src/share/vm/oops/method.hpp Wed Mar 15 10:25:37 2017 -0400 @@ -323,7 +323,7 @@ // exception handler which caused the exception to be thrown, which // is needed for proper retries. See, for example, // InterpreterRuntime::exception_handler_for_exception. - static int fast_exception_handler_bci_for(methodHandle mh, KlassHandle ex_klass, int throw_bci, TRAPS); + static int fast_exception_handler_bci_for(methodHandle mh, Klass* ex_klass, int throw_bci, TRAPS); // method data access MethodData* method_data() const { @@ -811,8 +811,7 @@ static void print_jmethod_ids(ClassLoaderData* loader_data, outputStream* out) PRODUCT_RETURN; // Get this method's jmethodID -- allocate if it doesn't exist - jmethodID jmethod_id() { methodHandle this_h(this); - return InstanceKlass::get_jmethod_id(method_holder(), this_h); } + jmethodID jmethod_id() { return InstanceKlass::get_jmethod_id(method_holder(), this); } // Lookup the jmethodID for this method. Return NULL if not found. // NOTE that this function can be called from a signal handler
--- a/hotspot/src/share/vm/oops/objArrayKlass.cpp Wed Mar 15 11:44:46 2017 +0100 +++ b/hotspot/src/share/vm/oops/objArrayKlass.cpp Wed Mar 15 10:25:37 2017 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2017, 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 @@ -46,26 +46,26 @@ #include "utilities/copy.hpp" #include "utilities/macros.hpp" -ObjArrayKlass* ObjArrayKlass::allocate(ClassLoaderData* loader_data, int n, KlassHandle klass_handle, Symbol* name, TRAPS) { +ObjArrayKlass* ObjArrayKlass::allocate(ClassLoaderData* loader_data, int n, Klass* k, Symbol* name, TRAPS) { assert(ObjArrayKlass::header_size() <= InstanceKlass::header_size(), "array klasses must be same size as InstanceKlass"); int size = ArrayKlass::static_size(ObjArrayKlass::header_size()); - return new (loader_data, size, THREAD) ObjArrayKlass(n, klass_handle, name); + return new (loader_data, size, THREAD) ObjArrayKlass(n, k, name); } Klass* ObjArrayKlass::allocate_objArray_klass(ClassLoaderData* loader_data, - int n, KlassHandle element_klass, TRAPS) { + int n, Klass* element_klass, TRAPS) { // Eagerly allocate the direct array supertype. - KlassHandle super_klass = KlassHandle(); + Klass* super_klass = NULL; if (!Universe::is_bootstrapping() || SystemDictionary::Object_klass_loaded()) { - KlassHandle element_super (THREAD, element_klass->super()); - if (element_super.not_null()) { + Klass* element_super = element_klass->super(); + if (element_super != NULL) { // The element type has a direct super. E.g., String[] has direct super of Object[]. - super_klass = KlassHandle(THREAD, element_super->array_klass_or_null()); - bool supers_exist = super_klass.not_null(); + super_klass = element_super->array_klass_or_null(); + bool supers_exist = super_klass != NULL; // Also, see if the element has secondary supertypes. // We need an array type for each. Array<Klass*>* element_supers = element_klass->secondary_supers(); @@ -78,34 +78,30 @@ } if (!supers_exist) { // Oops. Not allocated yet. Back out, allocate it, and retry. - KlassHandle ek; + Klass* ek = NULL; { MutexUnlocker mu(MultiArray_lock); MutexUnlocker mc(Compile_lock); // for vtables - Klass* sk = element_super->array_klass(CHECK_0); - super_klass = KlassHandle(THREAD, sk); + super_klass = element_super->array_klass(CHECK_0); for( int i = element_supers->length()-1; i >= 0; i-- ) { - KlassHandle elem_super (THREAD, element_supers->at(i)); + Klass* elem_super = element_supers->at(i); elem_super->array_klass(CHECK_0); } // Now retry from the beginning - Klass* klass_oop = element_klass->array_klass(n, CHECK_0); - // Create a handle because the enclosing brace, when locking - // can cause a gc. Better to have this function return a Handle. - ek = KlassHandle(THREAD, klass_oop); + ek = element_klass->array_klass(n, CHECK_0); } // re-lock - return ek(); + return ek; } } else { // The element type is already Object. Object[] has direct super of Object. - super_klass = KlassHandle(THREAD, SystemDictionary::Object_klass()); + super_klass = SystemDictionary::Object_klass(); } } // Create type name for klass. Symbol* name = NULL; if (!element_klass->is_instance_klass() || - (name = InstanceKlass::cast(element_klass())->array_name()) == NULL) { + (name = InstanceKlass::cast(element_klass)->array_name()) == NULL) { ResourceMark rm(THREAD); char *name_str = element_klass->name()->as_C_string(); @@ -124,7 +120,7 @@ new_str[idx++] = '\0'; name = SymbolTable::new_permanent_symbol(new_str, CHECK_0); if (element_klass->is_instance_klass()) { - InstanceKlass* ik = InstanceKlass::cast(element_klass()); + InstanceKlass* ik = InstanceKlass::cast(element_klass); ik->set_array_name(name); } } @@ -146,9 +142,9 @@ return oak; } -ObjArrayKlass::ObjArrayKlass(int n, KlassHandle element_klass, Symbol* name) : ArrayKlass(name) { +ObjArrayKlass::ObjArrayKlass(int n, Klass* element_klass, Symbol* name) : ArrayKlass(name) { this->set_dimension(n); - this->set_element_klass(element_klass()); + this->set_element_klass(element_klass); // decrement refcount because object arrays are not explicitly freed. The // InstanceKlass array_name() keeps the name counted while the klass is // loaded. @@ -156,9 +152,9 @@ Klass* bk; if (element_klass->is_objArray_klass()) { - bk = ObjArrayKlass::cast(element_klass())->bottom_klass(); + bk = ObjArrayKlass::cast(element_klass)->bottom_klass(); } else { - bk = element_klass(); + bk = element_klass; } assert(bk != NULL && (bk->is_instance_klass() || bk->is_typeArray_klass()), "invalid bottom klass"); this->set_bottom_klass(bk); @@ -178,8 +174,7 @@ if (length >= 0) { if (length <= arrayOopDesc::max_array_length(T_OBJECT)) { int size = objArrayOopDesc::object_size(length); - KlassHandle h_k(THREAD, this); - return (objArrayOop)CollectedHeap::array_allocate(h_k, size, length, THREAD); + return (objArrayOop)CollectedHeap::array_allocate(this, size, length, THREAD); } else { report_java_out_of_memory("Requested array size exceeds VM limit"); JvmtiExport::post_array_size_exhausted(); @@ -196,14 +191,14 @@ int length = *sizes; // Call to lower_dimension uses this pointer, so most be called before a // possible GC - KlassHandle h_lower_dimension(THREAD, lower_dimension()); + Klass* ld_klass = lower_dimension(); // If length < 0 allocate will throw an exception. objArrayOop array = allocate(length, CHECK_NULL); objArrayHandle h_array (THREAD, array); if (rank > 1) { if (length != 0) { for (int index = 0; index < length; index++) { - ArrayKlass* ak = ArrayKlass::cast(h_lower_dimension()); + ArrayKlass* ak = ArrayKlass::cast(ld_klass); oop sub_array = ak->multi_allocate(rank-1, &sizes[1], CHECK_NULL); h_array->obj_at_put(index, sub_array); }
--- a/hotspot/src/share/vm/oops/objArrayKlass.hpp Wed Mar 15 11:44:46 2017 +0100 +++ b/hotspot/src/share/vm/oops/objArrayKlass.hpp Wed Mar 15 10:25:37 2017 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2017, 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 @@ -39,8 +39,8 @@ Klass* _bottom_klass; // The one-dimensional type (InstanceKlass or TypeArrayKlass) // Constructor - ObjArrayKlass(int n, KlassHandle element_klass, Symbol* name); - static ObjArrayKlass* allocate(ClassLoaderData* loader_data, int n, KlassHandle klass_handle, Symbol* name, TRAPS); + ObjArrayKlass(int n, Klass* element_klass, Symbol* name); + static ObjArrayKlass* allocate(ClassLoaderData* loader_data, int n, Klass* k, Symbol* name, TRAPS); public: // For dummy objects ObjArrayKlass() {} @@ -69,7 +69,7 @@ // Allocation static Klass* allocate_objArray_klass(ClassLoaderData* loader_data, - int n, KlassHandle element_klass, TRAPS); + int n, Klass* element_klass, TRAPS); objArrayOop allocate(int length, TRAPS); oop multi_allocate(int rank, jint* sizes, TRAPS);
--- a/hotspot/src/share/vm/oops/typeArrayKlass.cpp Wed Mar 15 11:44:46 2017 +0100 +++ b/hotspot/src/share/vm/oops/typeArrayKlass.cpp Wed Mar 15 10:25:37 2017 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2017, 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,13 +102,12 @@ if (length >= 0) { if (length <= max_length()) { size_t size = typeArrayOopDesc::object_size(layout_helper(), length); - KlassHandle h_k(THREAD, this); typeArrayOop t; CollectedHeap* ch = Universe::heap(); if (do_zero) { - t = (typeArrayOop)CollectedHeap::array_allocate(h_k, (int)size, length, CHECK_NULL); + t = (typeArrayOop)CollectedHeap::array_allocate(this, (int)size, length, CHECK_NULL); } else { - t = (typeArrayOop)CollectedHeap::array_allocate_nozero(h_k, (int)size, length, CHECK_NULL); + t = (typeArrayOop)CollectedHeap::array_allocate_nozero(this, (int)size, length, CHECK_NULL); } return t; } else {
--- a/hotspot/src/share/vm/prims/jni.cpp Wed Mar 15 11:44:46 2017 +0100 +++ b/hotspot/src/share/vm/prims/jni.cpp Wed Mar 15 10:25:37 2017 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2012 Red Hat, Inc. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -386,8 +386,8 @@ Handle loader; Handle protection_domain; // Find calling class - instanceKlassHandle k (THREAD, thread->security_get_caller_class(0)); - if (k.not_null()) { + Klass* k = thread->security_get_caller_class(0); + if (k != NULL) { loader = Handle(THREAD, k->class_loader()); // Special handling to make sure JNI_OnLoad and JNI_OnUnload are executed // in the correct class context. @@ -395,9 +395,9 @@ k->name() == vmSymbols::java_lang_ClassLoader_NativeLibrary()) { JavaValue result(T_OBJECT); JavaCalls::call_static(&result, k, - vmSymbols::getFromClass_name(), - vmSymbols::void_class_signature(), - thread); + vmSymbols::getFromClass_name(), + vmSymbols::void_class_signature(), + thread); if (HAS_PENDING_EXCEPTION) { Handle ex(thread, thread->pending_exception()); CLEAR_PENDING_EXCEPTION; @@ -455,12 +455,11 @@ mirror = java_lang_reflect_Method::clazz(reflected); slot = java_lang_reflect_Method::slot(reflected); } - Klass* k = java_lang_Class::as_Klass(mirror); - - KlassHandle k1(THREAD, k); + Klass* k1 = java_lang_Class::as_Klass(mirror); + // Make sure class is initialized before handing id's out to methods - k1()->initialize(CHECK_NULL); - Method* m = InstanceKlass::cast(k1())->method_with_idnum(slot); + k1->initialize(CHECK_NULL); + Method* m = InstanceKlass::cast(k1)->method_with_idnum(slot); ret = m==NULL? NULL : m->jmethod_id(); // return NULL if reflected method deleted return ret; JNI_END @@ -479,18 +478,17 @@ // field is a handle to a java.lang.reflect.Field object oop reflected = JNIHandles::resolve_non_null(field); oop mirror = java_lang_reflect_Field::clazz(reflected); - Klass* k = java_lang_Class::as_Klass(mirror); + Klass* k1 = java_lang_Class::as_Klass(mirror); int slot = java_lang_reflect_Field::slot(reflected); int modifiers = java_lang_reflect_Field::modifiers(reflected); - KlassHandle k1(THREAD, k); // Make sure class is initialized before handing id's out to fields - k1()->initialize(CHECK_NULL); + k1->initialize(CHECK_NULL); // First check if this is a static field if (modifiers & JVM_ACC_STATIC) { - intptr_t offset = InstanceKlass::cast(k1())->field_offset( slot ); - JNIid* id = InstanceKlass::cast(k1())->jni_id_for(offset); + intptr_t offset = InstanceKlass::cast(k1)->field_offset( slot ); + JNIid* id = InstanceKlass::cast(k1)->jni_id_for(offset); assert(id != NULL, "corrupt Field object"); debug_only(id->set_is_static_field_id();) // A jfieldID for a static field is a JNIid specifying the field holder and the offset within the Klass* @@ -501,9 +499,9 @@ // The slot is the index of the field description in the field-array // The jfieldID is the offset of the field within the object // It may also have hash bits for k, if VerifyJNIFields is turned on. - intptr_t offset = InstanceKlass::cast(k1())->field_offset( slot ); - assert(InstanceKlass::cast(k1())->contains_field_offset(offset), "stay within object"); - ret = jfieldIDWorkaround::to_instance_jfieldID(k1(), offset); + intptr_t offset = InstanceKlass::cast(k1)->field_offset( slot ); + assert(InstanceKlass::cast(k1)->contains_field_offset(offset), "stay within object"); + ret = jfieldIDWorkaround::to_instance_jfieldID(k1, offset); return ret; JNI_END @@ -677,8 +675,7 @@ JavaValue result(T_VOID); JavaCalls::call_virtual(&result, ex, - KlassHandle(THREAD, - SystemDictionary::Throwable_klass()), + SystemDictionary::Throwable_klass(), vmSymbols::printStackTrace_name(), vmSymbols::void_method_signature(), THREAD); @@ -1156,11 +1153,9 @@ } } else { // interface call - KlassHandle h_holder(THREAD, holder); - int itbl_index = m->itable_index(); Klass* k = h_recv->klass(); - selected_method = InstanceKlass::cast(k)->method_at_itable(h_holder(), itbl_index, CHECK); + selected_method = InstanceKlass::cast(k)->method_at_itable(holder, itbl_index, CHECK); } } @@ -1192,14 +1187,14 @@ static instanceOop alloc_object(jclass clazz, TRAPS) { - KlassHandle k(THREAD, java_lang_Class::as_Klass(JNIHandles::resolve_non_null(clazz))); + Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(clazz)); if (k == NULL) { ResourceMark rm(THREAD); THROW_(vmSymbols::java_lang_InstantiationException(), NULL); } - k()->check_valid_for_instantiation(false, CHECK_NULL); - InstanceKlass::cast(k())->initialize(CHECK_NULL); - instanceOop ih = InstanceKlass::cast(k())->allocate_instance(THREAD); + k->check_valid_for_instantiation(false, CHECK_NULL); + k->initialize(CHECK_NULL); + instanceOop ih = InstanceKlass::cast(k)->allocate_instance(THREAD); return ih; } @@ -1338,26 +1333,25 @@ THROW_MSG_0(vmSymbols::java_lang_NoSuchMethodError(), name_str); } - KlassHandle klass(THREAD, - java_lang_Class::as_Klass(JNIHandles::resolve_non_null(clazz))); + Klass* klass = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(clazz)); // Make sure class is linked and initialized before handing id's out to // Method*s. - klass()->initialize(CHECK_NULL); + klass->initialize(CHECK_NULL); Method* m; if (name == vmSymbols::object_initializer_name() || name == vmSymbols::class_initializer_name()) { // Never search superclasses for constructors if (klass->is_instance_klass()) { - m = InstanceKlass::cast(klass())->find_method(name, signature); + m = InstanceKlass::cast(klass)->find_method(name, signature); } else { m = NULL; } } else { m = klass->lookup_method(name, signature); if (m == NULL && klass->is_instance_klass()) { - m = InstanceKlass::cast(klass())->lookup_method_in_ordered_interfaces(name, signature); + m = InstanceKlass::cast(klass)->lookup_method_in_ordered_interfaces(name, signature); } } if (m == NULL || (m->is_static() != is_static)) { @@ -1879,8 +1873,8 @@ JavaValue jvalue(Tag); \ JNI_ArgumentPusherVaArg ap(methodID, args); \ /* Make sure class is initialized before trying to invoke its method */ \ - KlassHandle k(THREAD, java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls))); \ - k()->initialize(CHECK_0); \ + Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); \ + k->initialize(CHECK_0); \ jni_invoke_static(env, &jvalue, NULL, JNI_STATIC, methodID, &ap, CHECK_0); \ va_end(args); \ ret = jvalue.get_##ResultType(); \ @@ -2037,20 +2031,19 @@ if (fieldname == NULL || signame == NULL) { THROW_MSG_0(vmSymbols::java_lang_NoSuchFieldError(), (char*) name); } - KlassHandle k(THREAD, - java_lang_Class::as_Klass(JNIHandles::resolve_non_null(clazz))); + Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(clazz)); // Make sure class is initialized before handing id's out to fields - k()->initialize(CHECK_NULL); + k->initialize(CHECK_NULL); fieldDescriptor fd; - if (!k()->is_instance_klass() || - !InstanceKlass::cast(k())->find_field(fieldname, signame, false, &fd)) { + if (!k->is_instance_klass() || + !InstanceKlass::cast(k)->find_field(fieldname, signame, false, &fd)) { THROW_MSG_0(vmSymbols::java_lang_NoSuchFieldError(), (char*) name); } // A jfieldID for a non-static field is simply the offset of the field within the instanceOop // It may also have hash bits for k, if VerifyJNIFields is turned on. - ret = jfieldIDWorkaround::to_instance_jfieldID(k(), fd.offset()); + ret = jfieldIDWorkaround::to_instance_jfieldID(k, fd.offset()); return ret; JNI_END @@ -2292,14 +2285,13 @@ if (fieldname == NULL || signame == NULL) { THROW_MSG_0(vmSymbols::java_lang_NoSuchFieldError(), (char*) name); } - KlassHandle k(THREAD, - java_lang_Class::as_Klass(JNIHandles::resolve_non_null(clazz))); + Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(clazz)); // Make sure class is initialized before handing id's out to static fields - k()->initialize(CHECK_NULL); + k->initialize(CHECK_NULL); fieldDescriptor fd; - if (!k()->is_instance_klass() || - !InstanceKlass::cast(k())->find_field(fieldname, signame, true, &fd)) { + if (!k->is_instance_klass() || + !InstanceKlass::cast(k)->find_field(fieldname, signame, true, &fd)) { THROW_MSG_0(vmSymbols::java_lang_NoSuchFieldError(), (char*) name); } @@ -2603,11 +2595,10 @@ HOTSPOT_JNI_NEWOBJECTARRAY_ENTRY(env, length, elementClass, initialElement); jobjectArray ret = NULL; DT_RETURN_MARK(NewObjectArray, jobjectArray, (const jobjectArray&)ret); - KlassHandle ek(THREAD, java_lang_Class::as_Klass(JNIHandles::resolve_non_null(elementClass))); - Klass* ako = ek()->array_klass(CHECK_NULL); - KlassHandle ak = KlassHandle(THREAD, ako); - ObjArrayKlass::cast(ak())->initialize(CHECK_NULL); - objArrayOop result = ObjArrayKlass::cast(ak())->allocate(length, CHECK_NULL); + Klass* ek = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(elementClass)); + Klass* ak = ek->array_klass(CHECK_NULL); + ObjArrayKlass::cast(ak)->initialize(CHECK_NULL); + objArrayOop result = ObjArrayKlass::cast(ak)->allocate(length, CHECK_NULL); oop initial_value = JNIHandles::resolve(initialElement); if (initial_value != NULL) { // array already initialized with NULL for (int index = 0; index < length; index++) { @@ -2936,8 +2927,7 @@ // is not native. Ask JVM TI what prefixes have been specified. Then check // to see if the native method is now wrapped with the prefixes. See the // SetNativeMethodPrefix(es) functions in the JVM TI Spec for details. -static Method* find_prefixed_native(KlassHandle k, - Symbol* name, Symbol* signature, TRAPS) { +static Method* find_prefixed_native(Klass* k, Symbol* name, Symbol* signature, TRAPS) { #if INCLUDE_JVMTI ResourceMark rm(THREAD); Method* method; @@ -2958,7 +2948,7 @@ if (trial_name == NULL) { continue; // no such symbol, so this prefix wasn't used, try the next prefix } - method = k()->lookup_method(trial_name, signature); + method = k->lookup_method(trial_name, signature); if (method == NULL) { continue; // signature doesn't match, try the next prefix } @@ -2974,13 +2964,13 @@ return NULL; // not found } -static bool register_native(KlassHandle k, Symbol* name, Symbol* signature, address entry, TRAPS) { - Method* method = k()->lookup_method(name, signature); +static bool register_native(Klass* k, Symbol* name, Symbol* signature, address entry, TRAPS) { + Method* method = k->lookup_method(name, signature); if (method == NULL) { ResourceMark rm; stringStream st; st.print("Method %s name or signature does not match", - Method::name_and_sig_as_C_string(k(), name, signature)); + Method::name_and_sig_as_C_string(k, name, signature)); THROW_MSG_(vmSymbols::java_lang_NoSuchMethodError(), st.as_string(), false); } if (!method->is_native()) { @@ -2990,7 +2980,7 @@ ResourceMark rm; stringStream st; st.print("Method %s is not declared as native", - Method::name_and_sig_as_C_string(k(), name, signature)); + Method::name_and_sig_as_C_string(k, name, signature)); THROW_MSG_(vmSymbols::java_lang_NoSuchMethodError(), st.as_string(), false); } } @@ -3021,7 +3011,7 @@ jint ret = 0; DT_RETURN_MARK(RegisterNatives, jint, (const jint&)ret); - KlassHandle h_k(thread, java_lang_Class::as_Klass(JNIHandles::resolve_non_null(clazz))); + Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(clazz)); for (int index = 0; index < nMethods; index++) { const char* meth_name = methods[index].name; @@ -3037,12 +3027,12 @@ if (name == NULL || signature == NULL) { ResourceMark rm; stringStream st; - st.print("Method %s.%s%s not found", h_k()->external_name(), meth_name, meth_sig); + st.print("Method %s.%s%s not found", k->external_name(), meth_name, meth_sig); // Must return negative value on failure THROW_MSG_(vmSymbols::java_lang_NoSuchMethodError(), st.as_string(), -1); } - bool res = register_native(h_k, name, signature, + bool res = register_native(k, name, signature, (address) methods[index].fnPtr, THREAD); if (!res) { ret = -1;
--- a/hotspot/src/share/vm/prims/jvm.cpp Wed Mar 15 11:44:46 2017 +0100 +++ b/hotspot/src/share/vm/prims/jvm.cpp Wed Mar 15 10:25:37 2017 -0400 @@ -341,7 +341,7 @@ Handle value_str = java_lang_String::create_from_platform_dependent_str((value != NULL ? value : ""), CHECK); JavaCalls::call_virtual(&r, props, - KlassHandle(THREAD, SystemDictionary::Properties_klass()), + SystemDictionary::Properties_klass(), vmSymbols::put_name(), vmSymbols::object_object_object_signature(), key_str, @@ -621,7 +621,7 @@ JVM_ENTRY(jobject, JVM_Clone(JNIEnv* env, jobject handle)) JVMWrapper("JVM_Clone"); Handle obj(THREAD, JNIHandles::resolve_non_null(handle)); - const KlassHandle klass (THREAD, obj->klass()); + Klass* klass = obj->klass(); JvmtiVMObjectAllocEventCollector oam; #ifdef ASSERT @@ -997,9 +997,7 @@ if (k == NULL) { // If the class is not already loaded, try to see if it's in the shared // archive for the current classloader (h_loader). - instanceKlassHandle ik = SystemDictionaryShared::find_or_load_shared_class( - klass_name, h_loader, CHECK_NULL); - k = ik(); + k = SystemDictionaryShared::find_or_load_shared_class(klass_name, h_loader, CHECK_NULL); } #endif return (k == NULL) ? NULL : @@ -1077,11 +1075,11 @@ return (jobjectArray) JNIHandles::make_local(env, r); } - KlassHandle klass(thread, java_lang_Class::as_Klass(mirror)); + Klass* klass = java_lang_Class::as_Klass(mirror); // Figure size of result array int size; if (klass->is_instance_klass()) { - size = InstanceKlass::cast(klass())->local_interfaces()->length(); + size = InstanceKlass::cast(klass)->local_interfaces()->length(); } else { assert(klass->is_objArray_klass() || klass->is_typeArray_klass(), "Illegal mirror klass"); size = 2; @@ -1094,7 +1092,7 @@ if (klass->is_instance_klass()) { // Regular instance klass, fill in all local interfaces for (int index = 0; index < size; index++) { - Klass* k = InstanceKlass::cast(klass())->local_interfaces()->at(index); + Klass* k = InstanceKlass::cast(klass)->local_interfaces()->at(index); result->obj_at_put(index, k->java_mirror()); } } else { @@ -1178,7 +1176,7 @@ JVM_END -static bool is_authorized(Handle context, instanceKlassHandle klass, TRAPS) { +static bool is_authorized(Handle context, InstanceKlass* klass, TRAPS) { // If there is a security manager and protection domain, check the access // in the protection domain, otherwise it is authorized. if (java_lang_System::has_security_manager()) { @@ -1218,7 +1216,7 @@ Handle obj = pd_klass->allocate_instance_handle(CHECK_NULL); // Call constructor ProtectionDomain(null, null); JavaValue result(T_VOID); - JavaCalls::call_special(&result, obj, KlassHandle(THREAD, pd_klass), + JavaCalls::call_special(&result, obj, pd_klass, vmSymbols::object_initializer_name(), vmSymbols::codesource_permissioncollection_signature(), Handle(), Handle(), CHECK_NULL); @@ -1249,7 +1247,7 @@ } Method* method = vfst.method(); - instanceKlassHandle klass (THREAD, method->method_holder()); + InstanceKlass* klass = method->method_holder(); // Check that action object understands "Object run()" Handle h_context; @@ -1452,7 +1450,7 @@ return (jobjectArray)JNIHandles::make_local(env, result); } - instanceKlassHandle k(thread, java_lang_Class::as_Klass(JNIHandles::resolve_non_null(ofClass))); + InstanceKlass* k = InstanceKlass::cast(java_lang_Class::as_Klass(JNIHandles::resolve_non_null(ofClass))); InnerClassesIterator iter(k); if (iter.length() == 0) { @@ -1479,9 +1477,9 @@ // before attempting to find the class. if (cp->klass_name_at_matches(k, ooff)) { Klass* outer_klass = cp->klass_at(ooff, CHECK_NULL); - if (outer_klass == k()) { + if (outer_klass == k) { Klass* ik = cp->klass_at(ioff, CHECK_NULL); - instanceKlassHandle inner_klass (THREAD, ik); + InstanceKlass* inner_klass = InstanceKlass::cast(ik); // Throws an exception if outer klass has not declared k as // an inner klass @@ -1532,7 +1530,7 @@ !java_lang_Class::as_Klass(mirror)->is_instance_klass()) { return NULL; } - instanceKlassHandle k(THREAD, InstanceKlass::cast(java_lang_Class::as_Klass(mirror))); + InstanceKlass* k = InstanceKlass::cast(java_lang_Class::as_Klass(mirror)); int ooff = 0, noff = 0; if (InstanceKlass::find_inner_classes_attr(k, &ooff, &noff, THREAD)) { if (noff != 0) { @@ -1590,19 +1588,19 @@ int slot = java_lang_reflect_Field::slot(reflected); int modifiers = java_lang_reflect_Field::modifiers(reflected); - KlassHandle kh(THREAD, k); - intptr_t offset = InstanceKlass::cast(kh())->field_offset(slot); + InstanceKlass* ik = InstanceKlass::cast(k); + intptr_t offset = ik->field_offset(slot); if (modifiers & JVM_ACC_STATIC) { // for static fields we only look in the current class - if (!InstanceKlass::cast(kh())->find_local_field_from_offset(offset, true, &fd)) { + if (!ik->find_local_field_from_offset(offset, true, &fd)) { assert(false, "cannot find static field"); return false; } } else { // for instance fields we start with the current class and work // our way up through the superclass chain - if (!InstanceKlass::cast(kh())->find_field_from_offset(offset, false, &fd)) { + if (!ik->find_field_from_offset(offset, false, &fd)) { assert(false, "cannot find instance field"); return false; } @@ -1757,7 +1755,7 @@ return (jobjectArray) JNIHandles::make_local(env, res); } - instanceKlassHandle k(THREAD, java_lang_Class::as_Klass(JNIHandles::resolve_non_null(ofClass))); + InstanceKlass* k = InstanceKlass::cast(java_lang_Class::as_Klass(JNIHandles::resolve_non_null(ofClass))); constantPoolHandle cp(THREAD, k->constants()); // Ensure class is linked @@ -1768,7 +1766,7 @@ if (publicOnly) { num_fields = 0; - for (JavaFieldStream fs(k()); !fs.done(); fs.next()) { + for (JavaFieldStream fs(k); !fs.done(); fs.next()) { if (fs.access_flags().is_public()) ++num_fields; } } else { @@ -1782,7 +1780,7 @@ fieldDescriptor fd; for (JavaFieldStream fs(k); !fs.done(); fs.next()) { if (!publicOnly || fs.access_flags().is_public()) { - fd.reinitialize(k(), fs.index()); + fd.reinitialize(k, fs.index()); oop field = Reflection::new_field(&fd, CHECK_NULL); result->obj_at_put(out_idx, field); ++out_idx; @@ -1817,7 +1815,7 @@ return (jobjectArray) JNIHandles::make_local(env, res); } - instanceKlassHandle k(THREAD, java_lang_Class::as_Klass(JNIHandles::resolve_non_null(ofClass))); + InstanceKlass* k = InstanceKlass::cast(java_lang_Class::as_Klass(JNIHandles::resolve_non_null(ofClass))); // Ensure class is linked k->link_class(CHECK_NULL); @@ -1913,7 +1911,7 @@ if (!java_lang_Class::is_primitive(JNIHandles::resolve_non_null(cls))) { Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); if (k->is_instance_klass()) { - instanceKlassHandle k_h(THREAD, k); + InstanceKlass* k_h = InstanceKlass::cast(k); Handle jcp = reflect_ConstantPool::create(CHECK_NULL); reflect_ConstantPool::set_cp(jcp(), k_h->constants()); return JNIHandles::make_local(jcp()); @@ -1975,7 +1973,7 @@ k_o = ConstantPool::klass_at_if_loaded(cp, klass_ref); if (k_o == NULL) return NULL; } - instanceKlassHandle k(THREAD, k_o); + InstanceKlass* k = InstanceKlass::cast(k_o); Symbol* name = cp->uncached_name_ref_at(index); Symbol* sig = cp->uncached_signature_ref_at(index); methodHandle m (THREAD, k->find_method(name, sig)); @@ -2026,7 +2024,7 @@ k_o = ConstantPool::klass_at_if_loaded(cp, klass_ref); if (k_o == NULL) return NULL; } - instanceKlassHandle k(THREAD, k_o); + InstanceKlass* k = InstanceKlass::cast(k_o); Symbol* name = cp->uncached_name_ref_at(index); Symbol* sig = cp->uncached_signature_ref_at(index); fieldDescriptor fd; @@ -2616,7 +2614,8 @@ case JVM_CONSTANT_Fieldref: { Symbol* name = cp->uncached_name_ref_at(cp_index); Symbol* signature = cp->uncached_signature_ref_at(cp_index); - for (JavaFieldStream fs(k_called); !fs.done(); fs.next()) { + InstanceKlass* ik = InstanceKlass::cast(k_called); + for (JavaFieldStream fs(ik); !fs.done(); fs.next()) { if (fs.name() == name && fs.signature() == signature) { return fs.access_flags().as_short() & JVM_RECOGNIZED_FIELD_MODIFIERS; } @@ -2770,7 +2769,7 @@ JavaValue result(T_VOID); JavaCalls::call_virtual(&result, obj, - KlassHandle(THREAD, SystemDictionary::Thread_klass()), + SystemDictionary::Thread_klass(), vmSymbols::run_method_name(), vmSymbols::void_method_signature(), THREAD); @@ -3226,7 +3225,7 @@ } // Collect method holders - GrowableArray<KlassHandle>* klass_array = new GrowableArray<KlassHandle>(); + GrowableArray<Klass*>* klass_array = new GrowableArray<Klass*>(); for (; !vfst.at_end(); vfst.security_next()) { Method* m = vfst.method(); // Native frames are not returned @@ -3593,12 +3592,11 @@ // if there is no security manager in 3-arg Class.forName(). Klass* klass = SystemDictionary::resolve_or_fail(name, loader, protection_domain, throwError != 0, CHECK_NULL); - KlassHandle klass_handle(THREAD, klass); // Check if we should initialize the class - if (init && klass_handle->is_instance_klass()) { - klass_handle->initialize(CHECK_NULL); + if (init && klass->is_instance_klass()) { + klass->initialize(CHECK_NULL); } - return (jclass) JNIHandles::make_local(env, klass_handle->java_mirror()); + return (jclass) JNIHandles::make_local(env, klass->java_mirror()); } @@ -3746,25 +3744,25 @@ if (!k->is_instance_klass()) { return NULL; } - instanceKlassHandle ik_h(THREAD, k); - int encl_method_class_idx = ik_h->enclosing_method_class_index(); + InstanceKlass* ik = InstanceKlass::cast(k); + int encl_method_class_idx = ik->enclosing_method_class_index(); if (encl_method_class_idx == 0) { return NULL; } objArrayOop dest_o = oopFactory::new_objArray(SystemDictionary::Object_klass(), 3, CHECK_NULL); objArrayHandle dest(THREAD, dest_o); - Klass* enc_k = ik_h->constants()->klass_at(encl_method_class_idx, CHECK_NULL); + Klass* enc_k = ik->constants()->klass_at(encl_method_class_idx, CHECK_NULL); dest->obj_at_put(0, enc_k->java_mirror()); - int encl_method_method_idx = ik_h->enclosing_method_method_index(); + int encl_method_method_idx = ik->enclosing_method_method_index(); if (encl_method_method_idx != 0) { - Symbol* sym = ik_h->constants()->symbol_at( + Symbol* sym = ik->constants()->symbol_at( extract_low_short_from_int( - ik_h->constants()->name_and_type_at(encl_method_method_idx))); + ik->constants()->name_and_type_at(encl_method_method_idx))); Handle str = java_lang_String::create_from_symbol(sym, CHECK_NULL); dest->obj_at_put(1, str()); - sym = ik_h->constants()->symbol_at( + sym = ik->constants()->symbol_at( extract_high_short_from_int( - ik_h->constants()->name_and_type_at(encl_method_method_idx))); + ik->constants()->name_and_type_at(encl_method_method_idx))); str = java_lang_String::create_from_symbol(sym, CHECK_NULL); dest->obj_at_put(2, str()); } @@ -3799,8 +3797,8 @@ int num_flags = Arguments::num_jvm_flags(); int num_args = Arguments::num_jvm_args(); - instanceKlassHandle ik (THREAD, SystemDictionary::String_klass()); - objArrayOop r = oopFactory::new_objArray(ik(), num_args + num_flags, CHECK_NULL); + InstanceKlass* ik = SystemDictionary::String_klass(); + objArrayOop r = oopFactory::new_objArray(ik, num_args + num_flags, CHECK_NULL); objArrayHandle result_h(THREAD, r); int index = 0;
--- a/hotspot/src/share/vm/prims/jvmtiClassFileReconstituter.cpp Wed Mar 15 11:44:46 2017 +0100 +++ b/hotspot/src/share/vm/prims/jvmtiClassFileReconstituter.cpp Wed Mar 15 10:25:37 2017 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2017, 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,20 +40,20 @@ // JVMSpec| field_info fields[fields_count]; void JvmtiClassFileReconstituter::write_field_infos() { HandleMark hm(thread()); - Array<AnnotationArray*>* fields_anno = ikh()->fields_annotations(); - Array<AnnotationArray*>* fields_type_anno = ikh()->fields_type_annotations(); + Array<AnnotationArray*>* fields_anno = ik()->fields_annotations(); + Array<AnnotationArray*>* fields_type_anno = ik()->fields_type_annotations(); // Compute the real number of Java fields - int java_fields = ikh()->java_fields_count(); + int java_fields = ik()->java_fields_count(); write_u2(java_fields); - for (JavaFieldStream fs(ikh()); !fs.done(); fs.next()) { + for (JavaFieldStream fs(ik()); !fs.done(); fs.next()) { AccessFlags access_flags = fs.access_flags(); int name_index = fs.name_index(); int signature_index = fs.signature_index(); int initial_value_index = fs.initval_index(); guarantee(name_index != 0 && signature_index != 0, "bad constant pool index for field"); - // int offset = ikh()->field_offset( index ); + // int offset = ik()->field_offset( index ); int generic_signature_index = fs.generic_signature_index(); AnnotationArray* anno = fields_anno == NULL ? NULL : fields_anno->at(fs.index()); AnnotationArray* type_anno = fields_type_anno == NULL ? NULL : fields_type_anno->at(fs.index()); @@ -278,11 +278,11 @@ // JVMSpec| u2 sourcefile_index; // JVMSpec| } void JvmtiClassFileReconstituter::write_source_file_attribute() { - assert(ikh()->source_file_name() != NULL, "caller must check"); + assert(ik()->source_file_name() != NULL, "caller must check"); write_attribute_name_index("SourceFile"); write_u4(2); // always length 2 - write_u2(symbol_to_cpool_index(ikh()->source_file_name())); + write_u2(symbol_to_cpool_index(ik()->source_file_name())); } // Write SourceDebugExtension attribute @@ -292,12 +292,12 @@ // JSR45| u1 debug_extension[attribute_length]; // JSR45| } void JvmtiClassFileReconstituter::write_source_debug_extension_attribute() { - assert(ikh()->source_debug_extension() != NULL, "caller must check"); + assert(ik()->source_debug_extension() != NULL, "caller must check"); write_attribute_name_index("SourceDebugExtension"); - int len = (int)strlen(ikh()->source_debug_extension()); + int len = (int)strlen(ik()->source_debug_extension()); write_u4(len); - u1* ext = (u1*)ikh()->source_debug_extension(); + u1* ext = (u1*)ik()->source_debug_extension(); for (int i=0; i<len; i++) { write_u1(ext[i]); } @@ -317,7 +317,7 @@ // Compute the number of entries in the InnerClasses attribute u2 JvmtiClassFileReconstituter::inner_classes_attribute_length() { - InnerClassesIterator iter(ikh()); + InnerClassesIterator iter(ik()); return iter.length(); } @@ -387,7 +387,7 @@ // JVMSpec| } classes[number_of_classes]; // JVMSpec| } void JvmtiClassFileReconstituter::write_inner_classes_attribute(int length) { - InnerClassesIterator iter(ikh()); + InnerClassesIterator iter(ik()); guarantee(iter.length() != 0 && iter.length() == length, "caller must check"); u2 entry_count = length / InstanceKlass::inner_class_next_offset; @@ -618,18 +618,18 @@ // JVMSpec| attribute_info attributes[attributes_count]; void JvmtiClassFileReconstituter::write_class_attributes() { u2 inner_classes_length = inner_classes_attribute_length(); - Symbol* generic_signature = ikh()->generic_signature(); - AnnotationArray* anno = ikh()->class_annotations(); - AnnotationArray* type_anno = ikh()->class_type_annotations(); + Symbol* generic_signature = ik()->generic_signature(); + AnnotationArray* anno = ik()->class_annotations(); + AnnotationArray* type_anno = ik()->class_type_annotations(); int attr_count = 0; if (generic_signature != NULL) { ++attr_count; } - if (ikh()->source_file_name() != NULL) { + if (ik()->source_file_name() != NULL) { ++attr_count; } - if (ikh()->source_debug_extension() != NULL) { + if (ik()->source_debug_extension() != NULL) { ++attr_count; } if (inner_classes_length > 0) { @@ -650,10 +650,10 @@ if (generic_signature != NULL) { write_signature_attribute(symbol_to_cpool_index(generic_signature)); } - if (ikh()->source_file_name() != NULL) { + if (ik()->source_file_name() != NULL) { write_source_file_attribute(); } - if (ikh()->source_debug_extension() != NULL) { + if (ik()->source_debug_extension() != NULL) { write_source_debug_extension_attribute(); } if (inner_classes_length > 0) { @@ -675,7 +675,7 @@ // JVMSpec| method_info methods[methods_count]; void JvmtiClassFileReconstituter::write_method_infos() { HandleMark hm(thread()); - Array<Method*>* methods = ikh()->methods(); + Array<Method*>* methods = ik()->methods(); int num_methods = methods->length(); int num_overpass = 0; @@ -697,7 +697,7 @@ // invert the method order mapping for (index = 0; index < num_methods; index++) { - original_index = ikh()->method_ordering()->at(index); + original_index = ik()->method_ordering()->at(index); assert(original_index >= 0 && original_index < num_methods, "invalid original method index"); method_order.at_put(original_index, index); @@ -727,8 +727,8 @@ // JVMSpec| u2 minor_version; // JVMSpec| u2 major_version; - write_u2(ikh()->minor_version()); - u2 major = ikh()->major_version(); + write_u2(ik()->minor_version()); + u2 major = ik()->major_version(); write_u2(major); // JVMSpec| u2 constant_pool_count; @@ -737,24 +737,24 @@ copy_cpool_bytes(writeable_address(cpool_size())); // JVMSpec| u2 access_flags; - write_u2(ikh()->access_flags().get_flags() & JVM_RECOGNIZED_CLASS_MODIFIERS); + write_u2(ik()->access_flags().get_flags() & JVM_RECOGNIZED_CLASS_MODIFIERS); // JVMSpec| u2 this_class; // JVMSpec| u2 super_class; - write_u2(class_symbol_to_cpool_index(ikh()->name())); - Klass* super_class = ikh()->super(); + write_u2(class_symbol_to_cpool_index(ik()->name())); + Klass* super_class = ik()->super(); write_u2(super_class == NULL? 0 : // zero for java.lang.Object class_symbol_to_cpool_index(super_class->name())); // JVMSpec| u2 interfaces_count; // JVMSpec| u2 interfaces[interfaces_count]; - Array<Klass*>* interfaces = ikh()->local_interfaces(); + Array<Klass*>* interfaces = ik()->local_interfaces(); int num_interfaces = interfaces->length(); write_u2(num_interfaces); for (int index = 0; index < num_interfaces; index++) { HandleMark hm(thread()); - instanceKlassHandle iikh(thread(), interfaces->at(index)); - write_u2(class_symbol_to_cpool_index(iikh->name())); + InstanceKlass* iik = InstanceKlass::cast(interfaces->at(index)); + write_u2(class_symbol_to_cpool_index(iik->name())); } // JVMSpec| u2 fields_count;
--- a/hotspot/src/share/vm/prims/jvmtiClassFileReconstituter.hpp Wed Mar 15 11:44:46 2017 +0100 +++ b/hotspot/src/share/vm/prims/jvmtiClassFileReconstituter.hpp Wed Mar 15 10:25:37 2017 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2017, 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 @@ -34,11 +34,11 @@ SymbolHashMap* _symmap; SymbolHashMap* _classmap; constantPoolHandle _cpool; - instanceKlassHandle _ikh; + InstanceKlass* _ik; jvmtiError _err; protected: - instanceKlassHandle ikh() { return _ikh; }; + InstanceKlass* ik() { return _ik; }; constantPoolHandle cpool() { return _cpool; }; u2 symbol_to_cpool_index(Symbol* sym) { @@ -52,10 +52,10 @@ public: // Calls to this constructor must be proceeded by a ResourceMark // and a HandleMark - JvmtiConstantPoolReconstituter(instanceKlassHandle ikh){ + JvmtiConstantPoolReconstituter(InstanceKlass* ik){ set_error(JVMTI_ERROR_NONE); - _ikh = ikh; - _cpool = constantPoolHandle(Thread::current(), ikh->constants()); + _ik = ik; + _cpool = constantPoolHandle(Thread::current(), ik->constants()); _symmap = new SymbolHashMap(); _classmap = new SymbolHashMap(); _cpool_size = _cpool->hash_entries_to(_symmap, _classmap); @@ -138,8 +138,8 @@ public: // Calls to this constructor must be proceeded by a ResourceMark // and a HandleMark - JvmtiClassFileReconstituter(instanceKlassHandle ikh) : - JvmtiConstantPoolReconstituter(ikh) { + JvmtiClassFileReconstituter(InstanceKlass* ik) : + JvmtiConstantPoolReconstituter(ik) { _buffer_size = initial_buffer_size; _buffer = _buffer_ptr = NEW_RESOURCE_ARRAY(u1, _buffer_size); _thread = Thread::current();
--- a/hotspot/src/share/vm/prims/jvmtiEnv.cpp Wed Mar 15 11:44:46 2017 +0100 +++ b/hotspot/src/share/vm/prims/jvmtiEnv.cpp Wed Mar 15 10:25:37 2017 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2017, 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 @@ -400,21 +400,20 @@ return JVMTI_ERROR_UNMODIFIABLE_CLASS; } - Klass* k_oop = java_lang_Class::as_Klass(k_mirror); - KlassHandle klass(current_thread, k_oop); + Klass* klass = java_lang_Class::as_Klass(k_mirror); jint status = klass->jvmti_class_status(); if (status & (JVMTI_CLASS_STATUS_ERROR)) { return JVMTI_ERROR_INVALID_CLASS; } - instanceKlassHandle ikh(current_thread, k_oop); - if (ikh->get_cached_class_file_bytes() == NULL) { + InstanceKlass* ik = InstanceKlass::cast(klass); + if (ik->get_cached_class_file_bytes() == NULL) { // Not cached, we need to reconstitute the class file from the // VM representation. We don't attach the reconstituted class // bytes to the InstanceKlass here because they have not been // validated and we're not at a safepoint. - JvmtiClassFileReconstituter reconstituter(ikh); + JvmtiClassFileReconstituter reconstituter(ik); if (reconstituter.get_error() != JVMTI_ERROR_NONE) { return reconstituter.get_error(); } @@ -424,8 +423,8 @@ reconstituter.class_file_bytes(); } else { // it is cached, get it from the cache - class_definitions[index].class_byte_count = ikh->get_cached_class_file_len(); - class_definitions[index].class_bytes = ikh->get_cached_class_file_bytes(); + class_definitions[index].class_byte_count = ik->get_cached_class_file_len(); + class_definitions[index].class_bytes = ik->get_cached_class_file_bytes(); } class_definitions[index].klass = jcls; } @@ -667,8 +666,6 @@ return JVMTI_ERROR_INTERNAL; } - instanceKlassHandle loader_ik(THREAD, loader->klass()); - // Invoke the appendToClassPathForInstrumentation method - if the method // is not found it means the loader doesn't support adding to the class path // in the live phase. @@ -676,7 +673,7 @@ JavaValue res(T_VOID); JavaCalls::call_special(&res, loader, - loader_ik, + loader->klass(), vmSymbols::appendToClassPathForInstrumentation_name(), vmSymbols::appendToClassPathForInstrumentation_signature(), path, @@ -1781,7 +1778,7 @@ jvmtiError JvmtiEnv::FollowReferences(jint heap_filter, jclass klass, jobject initial_object, const jvmtiHeapCallbacks* callbacks, const void* user_data) { // check klass if provided - Klass* k_oop = NULL; + Klass* k = NULL; if (klass != NULL) { oop k_mirror = JNIHandles::resolve_external_guard(klass); if (k_mirror == NULL) { @@ -1790,18 +1787,17 @@ if (java_lang_Class::is_primitive(k_mirror)) { return JVMTI_ERROR_NONE; } - k_oop = java_lang_Class::as_Klass(k_mirror); - if (k_oop == NULL) { + k = java_lang_Class::as_Klass(k_mirror); + if (klass == NULL) { return JVMTI_ERROR_INVALID_CLASS; } } Thread *thread = Thread::current(); HandleMark hm(thread); - KlassHandle kh (thread, k_oop); TraceTime t("FollowReferences", TRACETIME_LOG(Debug, jvmti, objecttagging)); - JvmtiTagMap::tag_map_for(this)->follow_references(heap_filter, kh, initial_object, callbacks, user_data); + JvmtiTagMap::tag_map_for(this)->follow_references(heap_filter, k, initial_object, callbacks, user_data); return JVMTI_ERROR_NONE; } /* end FollowReferences */ @@ -1812,7 +1808,7 @@ jvmtiError JvmtiEnv::IterateThroughHeap(jint heap_filter, jclass klass, const jvmtiHeapCallbacks* callbacks, const void* user_data) { // check klass if provided - Klass* k_oop = NULL; + Klass* k = NULL; if (klass != NULL) { oop k_mirror = JNIHandles::resolve_external_guard(klass); if (k_mirror == NULL) { @@ -1821,18 +1817,14 @@ if (java_lang_Class::is_primitive(k_mirror)) { return JVMTI_ERROR_NONE; } - k_oop = java_lang_Class::as_Klass(k_mirror); - if (k_oop == NULL) { + k = java_lang_Class::as_Klass(k_mirror); + if (k == NULL) { return JVMTI_ERROR_INVALID_CLASS; } } - Thread *thread = Thread::current(); - HandleMark hm(thread); - KlassHandle kh (thread, k_oop); - TraceTime t("IterateThroughHeap", TRACETIME_LOG(Debug, jvmti, objecttagging)); - JvmtiTagMap::tag_map_for(this)->iterate_through_heap(heap_filter, kh, callbacks, user_data); + JvmtiTagMap::tag_map_for(this)->iterate_through_heap(heap_filter, k, callbacks, user_data); return JVMTI_ERROR_NONE; } /* end IterateThroughHeap */ @@ -1909,7 +1901,7 @@ TraceTime t("IterateOverHeap", TRACETIME_LOG(Debug, jvmti, objecttagging)); Thread *thread = Thread::current(); HandleMark hm(thread); - JvmtiTagMap::tag_map_for(this)->iterate_over_heap(object_filter, KlassHandle(), heap_object_callback, user_data); + JvmtiTagMap::tag_map_for(this)->iterate_over_heap(object_filter, NULL, heap_object_callback, user_data); return JVMTI_ERROR_NONE; } /* end IterateOverHeap */ @@ -1923,13 +1915,10 @@ // DO PRIMITIVE CLASS PROCESSING return JVMTI_ERROR_NONE; } - Klass* k_oop = java_lang_Class::as_Klass(k_mirror); - if (k_oop == NULL) { + Klass* klass = java_lang_Class::as_Klass(k_mirror); + if (klass == NULL) { return JVMTI_ERROR_INVALID_CLASS; } - Thread *thread = Thread::current(); - HandleMark hm(thread); - KlassHandle klass (thread, k_oop); TraceTime t("IterateOverInstancesOfClass", TRACETIME_LOG(Debug, jvmti, objecttagging)); JvmtiTagMap::tag_map_for(this)->iterate_over_heap(object_filter, klass, heap_object_callback, user_data); return JVMTI_ERROR_NONE; @@ -2408,9 +2397,9 @@ *methods_ptr = (jmethodID*) jvmtiMalloc(0 * sizeof(jmethodID)); return JVMTI_ERROR_NONE; } - instanceKlassHandle instanceK_h(current_thread, k); + InstanceKlass* ik = InstanceKlass::cast(k); // Allocate the result and fill it in - int result_length = instanceK_h->methods()->length(); + int result_length = ik->methods()->length(); jmethodID* result_list = (jmethodID*)jvmtiMalloc(result_length * sizeof(jmethodID)); int index; bool jmethodids_found = true; @@ -2419,8 +2408,8 @@ // Use the original method ordering indices stored in the class, so we can emit // jmethodIDs in the order they appeared in the class file for (index = 0; index < result_length; index++) { - Method* m = instanceK_h->methods()->at(index); - int original_index = instanceK_h->method_ordering()->at(index); + Method* m = ik->methods()->at(index); + int original_index = ik->method_ordering()->at(index); assert(original_index >= 0 && original_index < result_length, "invalid original method index"); jmethodID id; if (jmethodids_found) { @@ -2429,7 +2418,7 @@ // If we find an uninitialized value, make sure there is // enough space for all the uninitialized values we might // find. - instanceK_h->ensure_space_for_methodids(index); + ik->ensure_space_for_methodids(index); jmethodids_found = false; id = m->jmethod_id(); } @@ -2441,7 +2430,7 @@ } else { // otherwise just copy in any order for (index = 0; index < result_length; index++) { - Method* m = instanceK_h->methods()->at(index); + Method* m = ik->methods()->at(index); jmethodID id; if (jmethodids_found) { id = m->find_jmethod_id_or_null(); @@ -2449,7 +2438,7 @@ // If we find an uninitialized value, make sure there is // enough space for all the uninitialized values we might // find. - instanceK_h->ensure_space_for_methodids(index); + ik->ensure_space_for_methodids(index); jmethodids_found = false; id = m->jmethod_id(); } @@ -2494,11 +2483,11 @@ } - instanceKlassHandle instanceK_h(current_thread, k); + InstanceKlass* ik = InstanceKlass::cast(k); int result_count = 0; // First, count the fields. - FilteredFieldStream flds(instanceK_h, true, true); + FilteredFieldStream flds(ik, true, true); result_count = flds.field_count(); // Allocate the result and fill it in @@ -2507,9 +2496,9 @@ // this is the reverse order of what FieldStream hands out. int id_index = (result_count - 1); - for (FilteredFieldStream src_st(instanceK_h, true, true); !src_st.eos(); src_st.next()) { + for (FilteredFieldStream src_st(ik, true, true); !src_st.eos(); src_st.next()) { result_list[id_index--] = jfieldIDWorkaround::to_jfieldID( - instanceK_h, src_st.offset(), + ik, src_st.offset(), src_st.access_flags().is_static()); } assert(id_index == -1, "just checking"); @@ -2574,10 +2563,7 @@ if (java_lang_Class::is_primitive(k_mirror)) { return JVMTI_ERROR_ABSENT_INFORMATION; } - Klass* k_oop = java_lang_Class::as_Klass(k_mirror); - Thread *thread = Thread::current(); - HandleMark hm(thread); - KlassHandle klass(thread, k_oop); + Klass* klass = java_lang_Class::as_Klass(k_mirror); jint status = klass->jvmti_class_status(); if (status & (JVMTI_CLASS_STATUS_ERROR)) { @@ -2587,7 +2573,7 @@ return JVMTI_ERROR_ABSENT_INFORMATION; } - instanceKlassHandle ik(thread, k_oop); + InstanceKlass* ik = InstanceKlass::cast(klass); *minor_version_ptr = ik->minor_version(); *major_version_ptr = ik->major_version(); @@ -2605,11 +2591,9 @@ return JVMTI_ERROR_ABSENT_INFORMATION; } - Klass* k_oop = java_lang_Class::as_Klass(k_mirror); + Klass* klass = java_lang_Class::as_Klass(k_mirror); Thread *thread = Thread::current(); - HandleMark hm(thread); ResourceMark rm(thread); - KlassHandle klass(thread, k_oop); jint status = klass->jvmti_class_status(); if (status & (JVMTI_CLASS_STATUS_ERROR)) { @@ -2619,8 +2603,8 @@ return JVMTI_ERROR_ABSENT_INFORMATION; } - instanceKlassHandle ikh(thread, k_oop); - JvmtiConstantPoolReconstituter reconstituter(ikh); + InstanceKlass* ik = InstanceKlass::cast(klass); + JvmtiConstantPoolReconstituter reconstituter(ik); if (reconstituter.get_error() != JVMTI_ERROR_NONE) { return reconstituter.get_error(); } @@ -2639,7 +2623,7 @@ return reconstituter.get_error(); } - constantPoolHandle constants(thread, ikh->constants()); + constantPoolHandle constants(thread, ik->constants()); *constant_pool_count_ptr = constants->length(); *constant_pool_byte_count_ptr = cpool_size; *constant_pool_bytes_ptr = cpool_bytes;
--- a/hotspot/src/share/vm/prims/jvmtiEnvBase.cpp Wed Mar 15 11:44:46 2017 +0100 +++ b/hotspot/src/share/vm/prims/jvmtiEnvBase.cpp Wed Mar 15 10:25:37 2017 -0400 @@ -1366,13 +1366,13 @@ if (tos == atos && jobj != NULL) { // NULL reference is allowed Handle ob_h(current_thread, JNIHandles::resolve_external_guard(jobj)); NULL_CHECK(ob_h, JVMTI_ERROR_INVALID_OBJECT); - KlassHandle ob_kh = KlassHandle(current_thread, ob_h()->klass()); - NULL_CHECK(ob_kh, JVMTI_ERROR_INVALID_OBJECT); + Klass* ob_k = ob_h()->klass(); + NULL_CHECK(ob_k, JVMTI_ERROR_INVALID_OBJECT); // Method return type signature. char* ty_sign = 1 + strchr(signature->as_C_string(), ')'); - if (!VM_GetOrSetLocal::is_assignable(ty_sign, ob_kh(), current_thread)) { + if (!VM_GetOrSetLocal::is_assignable(ty_sign, ob_k, current_thread)) { return JVMTI_ERROR_TYPE_MISMATCH; } *ret_ob_h = ob_h;
--- a/hotspot/src/share/vm/prims/jvmtiExport.cpp Wed Mar 15 11:44:46 2017 +0100 +++ b/hotspot/src/share/vm/prims/jvmtiExport.cpp Wed Mar 15 10:25:37 2017 -0400 @@ -267,14 +267,14 @@ public: JvmtiClassFileLoadEventMark(JavaThread *thread, Symbol* name, - Handle class_loader, Handle prot_domain, KlassHandle *class_being_redefined) : JvmtiThreadEventMark(thread) { + Handle class_loader, Handle prot_domain, Klass* class_being_redefined) : JvmtiThreadEventMark(thread) { _class_name = name != NULL? name->as_utf8() : NULL; _jloader = (jobject)to_jobject(class_loader()); _protection_domain = (jobject)to_jobject(prot_domain()); if (class_being_redefined == NULL) { _class_being_redefined = NULL; } else { - _class_being_redefined = (jclass)to_jclass((*class_being_redefined)()); + _class_being_redefined = (jclass)to_jclass(class_being_redefined); } }; const char *class_name() { @@ -735,7 +735,7 @@ JvmtiEnv * _curr_env; JvmtiCachedClassFileData ** _cached_class_file_ptr; JvmtiThreadState * _state; - KlassHandle * _h_class_being_redefined; + Klass* _class_being_redefined; JvmtiClassLoadKind _load_kind; bool _has_been_modified; @@ -758,9 +758,9 @@ _state = _thread->jvmti_thread_state(); if (_state != NULL) { - _h_class_being_redefined = _state->get_class_being_redefined(); + _class_being_redefined = _state->get_class_being_redefined(); _load_kind = _state->get_class_load_kind(); - Klass* klass = (_h_class_being_redefined == NULL) ? NULL : (*_h_class_being_redefined)(); + Klass* klass = (_class_being_redefined == NULL) ? NULL : _class_being_redefined; if (_load_kind != jvmti_class_load_kind_load && klass != NULL) { ModuleEntry* module_entry = InstanceKlass::cast(klass)->module(); assert(module_entry != NULL, "module_entry should always be set"); @@ -783,7 +783,7 @@ _state->clear_class_being_redefined(); } else { // redefine and retransform will always set the thread state - _h_class_being_redefined = (KlassHandle *) NULL; + _class_being_redefined = NULL; _load_kind = jvmti_class_load_kind_load; } } @@ -828,7 +828,7 @@ jint new_len = 0; JvmtiClassFileLoadEventMark jem(_thread, _h_name, _class_loader, _h_protection_domain, - _h_class_being_redefined); + _class_being_redefined); JvmtiJavaThreadEventTransition jet(_thread); jvmtiEventClassFileLoadHook callback = env->callbacks()->ClassFileLoadHook; if (callback != NULL) { @@ -1155,7 +1155,6 @@ return; } HandleMark hm(thread); - KlassHandle kh(thread, klass); EVT_TRIG_TRACE(JVMTI_EVENT_CLASS_LOAD, ("[%s] Trg Class Load triggered", JvmtiTrace::safe_get_thread_name(thread))); @@ -1172,8 +1171,8 @@ } EVT_TRACE(JVMTI_EVENT_CLASS_LOAD, ("[%s] Evt Class Load sent %s", JvmtiTrace::safe_get_thread_name(thread), - kh()==NULL? "NULL" : kh()->external_name() )); - JvmtiClassEventMark jem(thread, kh()); + klass==NULL? "NULL" : klass->external_name() )); + JvmtiClassEventMark jem(thread, klass); JvmtiJavaThreadEventTransition jet(thread); jvmtiEventClassLoad callback = env->callbacks()->ClassLoad; if (callback != NULL) { @@ -1189,7 +1188,6 @@ return; } HandleMark hm(thread); - KlassHandle kh(thread, klass); EVT_TRIG_TRACE(JVMTI_EVENT_CLASS_PREPARE, ("[%s] Trg Class Prepare triggered", JvmtiTrace::safe_get_thread_name(thread))); @@ -1206,8 +1204,8 @@ } EVT_TRACE(JVMTI_EVENT_CLASS_PREPARE, ("[%s] Evt Class Prepare sent %s", JvmtiTrace::safe_get_thread_name(thread), - kh()==NULL? "NULL" : kh()->external_name() )); - JvmtiClassEventMark jem(thread, kh()); + klass==NULL? "NULL" : klass->external_name() )); + JvmtiClassEventMark jem(thread, klass); JvmtiJavaThreadEventTransition jet(thread); jvmtiEventClassPrepare callback = env->callbacks()->ClassPrepare; if (callback != NULL) { @@ -1223,7 +1221,6 @@ } Thread *thread = Thread::current(); HandleMark hm(thread); - KlassHandle kh(thread, klass); EVT_TRIG_TRACE(EXT_EVENT_CLASS_UNLOAD, ("[?] Trg Class Unload triggered" )); if (JvmtiEventController::is_enabled((jvmtiEvent)EXT_EVENT_CLASS_UNLOAD)) { @@ -1244,12 +1241,12 @@ } if (env->is_enabled((jvmtiEvent)EXT_EVENT_CLASS_UNLOAD)) { EVT_TRACE(EXT_EVENT_CLASS_UNLOAD, ("[?] Evt Class Unload sent %s", - kh()==NULL? "NULL" : kh()->external_name() )); + klass==NULL? "NULL" : klass->external_name() )); // do everything manually, since this is a proxy - needs special care JNIEnv* jni_env = real_thread->jni_environment(); jthread jt = (jthread)JNIHandles::make_local(real_thread, real_thread->threadObj()); - jclass jk = (jclass)JNIHandles::make_local(real_thread, kh()->java_mirror()); + jclass jk = (jclass)JNIHandles::make_local(real_thread, klass->java_mirror()); // Before we call the JVMTI agent, we have to set the state in the // thread for which we are proxying. @@ -1595,7 +1592,7 @@ current_bci = st.bci(); do { should_repeat = false; - KlassHandle eh_klass(thread, exception_handle()->klass()); + Klass* eh_klass = exception_handle()->klass(); current_bci = Method::fast_exception_handler_bci_for( current_mh, eh_klass, current_bci, THREAD); if (HAS_PENDING_EXCEPTION) { @@ -1743,7 +1740,6 @@ if (!fd.is_field_access_watched()) return; HandleMark hm(thread); - KlassHandle h_klass(thread, klass); Handle h_obj; if (!is_static) { // non-static field accessors have an object, but we need a handle @@ -1753,11 +1749,11 @@ post_field_access(thread, thread->last_frame().interpreter_frame_method(), thread->last_frame().interpreter_frame_bcp(), - h_klass, h_obj, fieldID); + klass, h_obj, fieldID); } void JvmtiExport::post_field_access(JavaThread *thread, Method* method, - address location, KlassHandle field_klass, Handle object, jfieldID field) { + address location, Klass* field_klass, Handle object, jfieldID field) { HandleMark hm(thread); methodHandle mh(thread, method); @@ -1779,7 +1775,7 @@ JvmtiEnv *env = ets->get_env(); JvmtiLocationEventMark jem(thread, mh, location); - jclass field_jclass = jem.to_jclass(field_klass()); + jclass field_jclass = jem.to_jclass(field_klass); jobject field_jobject = jem.to_jobject(object()); JvmtiJavaThreadEventTransition jet(thread); jvmtiEventFieldAccess callback = env->callbacks()->FieldAccess; @@ -1847,22 +1843,21 @@ assert(obj != NULL, "non-static needs an object"); h_obj = Handle(thread, obj); } - KlassHandle h_klass(thread, klass); post_field_modification(thread, thread->last_frame().interpreter_frame_method(), thread->last_frame().interpreter_frame_bcp(), - h_klass, h_obj, fieldID, sig_type, value); + klass, h_obj, fieldID, sig_type, value); } void JvmtiExport::post_raw_field_modification(JavaThread *thread, Method* method, - address location, KlassHandle field_klass, Handle object, jfieldID field, + address location, Klass* field_klass, Handle object, jfieldID field, char sig_type, jvalue *value) { if (sig_type == 'I' || sig_type == 'Z' || sig_type == 'B' || sig_type == 'C' || sig_type == 'S') { // 'I' instructions are used for byte, char, short and int. // determine which it really is, and convert fieldDescriptor fd; - bool found = JvmtiEnv::get_field_descriptor(field_klass(), field, &fd); + bool found = JvmtiEnv::get_field_descriptor(field_klass, field, &fd); // should be found (if not, leave as is) if (found) { jint ival = value->i; @@ -1917,7 +1912,7 @@ } void JvmtiExport::post_field_modification(JavaThread *thread, Method* method, - address location, KlassHandle field_klass, Handle object, jfieldID field, + address location, Klass* field_klass, Handle object, jfieldID field, char sig_type, jvalue *value_ptr) { HandleMark hm(thread); @@ -1943,7 +1938,7 @@ JvmtiEnv *env = ets->get_env(); JvmtiLocationEventMark jem(thread, mh, location); - jclass field_jclass = jem.to_jclass(field_klass()); + jclass field_jclass = jem.to_jclass(field_klass); jobject field_jobject = jem.to_jobject(object()); JvmtiJavaThreadEventTransition jet(thread); jvmtiEventFieldModification callback = env->callbacks()->FieldModification;
--- a/hotspot/src/share/vm/prims/jvmtiExport.hpp Wed Mar 15 11:44:46 2017 +0100 +++ b/hotspot/src/share/vm/prims/jvmtiExport.hpp Wed Mar 15 10:25:37 2017 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2017, 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 @@ -150,7 +150,7 @@ }; static void post_field_modification(JavaThread *thread, Method* method, address location, - KlassHandle field_klass, Handle object, jfieldID field, + Klass* field_klass, Handle object, jfieldID field, char sig_type, jvalue *value); @@ -310,7 +310,7 @@ static void post_field_access_by_jni (JavaThread *thread, oop obj, Klass* klass, jfieldID fieldID, bool is_static) NOT_JVMTI_RETURN; static void post_field_access (JavaThread *thread, Method* method, - address location, KlassHandle field_klass, Handle object, jfieldID field) NOT_JVMTI_RETURN; + address location, Klass* field_klass, Handle object, jfieldID field) NOT_JVMTI_RETURN; static oop jni_SetField_probe (JavaThread *thread, jobject jobj, oop obj, Klass* klass, jfieldID fieldID, bool is_static, char sig_type, jvalue *value) NOT_JVMTI_RETURN_(NULL); @@ -321,7 +321,7 @@ Klass* klass, jfieldID fieldID, bool is_static, char sig_type, jvalue *value); static void post_raw_field_modification(JavaThread *thread, Method* method, - address location, KlassHandle field_klass, Handle object, jfieldID field, + address location, Klass* field_klass, Handle object, jfieldID field, char sig_type, jvalue *value) NOT_JVMTI_RETURN; static void post_method_entry (JavaThread *thread, Method* method, frame current_frame) NOT_JVMTI_RETURN;
--- a/hotspot/src/share/vm/prims/jvmtiImpl.cpp Wed Mar 15 11:44:46 2017 +0100 +++ b/hotspot/src/share/vm/prims/jvmtiImpl.cpp Wed Mar 15 10:25:37 2017 -0400 @@ -287,12 +287,12 @@ // add/remove breakpoint to/from versions of the method that are EMCP. Thread *thread = Thread::current(); - instanceKlassHandle ikh = instanceKlassHandle(thread, _method->method_holder()); + InstanceKlass* ik = _method->method_holder(); Symbol* m_name = _method->name(); Symbol* m_signature = _method->signature(); // search previous versions if they exist - for (InstanceKlass* pv_node = ikh->previous_versions(); + for (InstanceKlass* pv_node = ik->previous_versions(); pv_node != NULL; pv_node = pv_node->previous_versions()) { Array<Method*>* methods = pv_node->methods(); @@ -696,10 +696,10 @@ Handle obj(cur_thread, JNIHandles::resolve_external_guard(jobj)); NULL_CHECK(obj, (_result = JVMTI_ERROR_INVALID_OBJECT, false)); - KlassHandle ob_kh = KlassHandle(cur_thread, obj->klass()); - NULL_CHECK(ob_kh, (_result = JVMTI_ERROR_INVALID_OBJECT, false)); + Klass* ob_k = obj->klass(); + NULL_CHECK(ob_k, (_result = JVMTI_ERROR_INVALID_OBJECT, false)); - if (!is_assignable(signature, ob_kh(), cur_thread)) { + if (!is_assignable(signature, ob_k, cur_thread)) { _result = JVMTI_ERROR_TYPE_MISMATCH; return false; }
--- a/hotspot/src/share/vm/prims/jvmtiRedefineClasses.cpp Wed Mar 15 11:44:46 2017 +0100 +++ b/hotspot/src/share/vm/prims/jvmtiRedefineClasses.cpp Wed Mar 15 10:25:37 2017 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2017, 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 @@ -58,7 +58,7 @@ int VM_RedefineClasses::_matching_methods_length = 0; int VM_RedefineClasses::_deleted_methods_length = 0; int VM_RedefineClasses::_added_methods_length = 0; -Klass* VM_RedefineClasses::_the_class_oop = NULL; +Klass* VM_RedefineClasses::_the_class = NULL; VM_RedefineClasses::VM_RedefineClasses(jint class_count, @@ -227,8 +227,8 @@ // Free os::malloc allocated memory. os::free(_scratch_classes); - // Reset the_class_oop to null for error printing. - _the_class_oop = NULL; + // Reset the_class to null for error printing. + _the_class = NULL; if (log_is_enabled(Info, redefine, class, timer)) { // Used to have separate timers for "doit" and "all", but the timer @@ -657,8 +657,8 @@ jvmtiError VM_RedefineClasses::compare_and_normalize_class_versions( - instanceKlassHandle the_class, - instanceKlassHandle scratch_class) { + InstanceKlass* the_class, + InstanceKlass* scratch_class) { int i; // Check superclasses, or rather their names, since superclasses themselves can be @@ -993,8 +993,8 @@ jvmtiError VM_RedefineClasses::load_new_class_versions(TRAPS) { // For consistency allocate memory using os::malloc wrapper. - _scratch_classes = (Klass**) - os::malloc(sizeof(Klass*) * _class_count, mtClass); + _scratch_classes = (InstanceKlass**) + os::malloc(sizeof(InstanceKlass*) * _class_count, mtClass); if (_scratch_classes == NULL) { return JVMTI_ERROR_OUT_OF_MEMORY; } @@ -1014,7 +1014,7 @@ // versions are deleted. Constant pools are deallocated while merging // constant pools HandleMark hm(THREAD); - instanceKlassHandle the_class(THREAD, get_ik(_class_defs[i].klass)); + InstanceKlass* the_class = get_ik(_class_defs[i].klass); Symbol* the_class_sym = the_class->name(); log_debug(redefine, class, load) @@ -1032,24 +1032,23 @@ // Set redefined class handle in JvmtiThreadState class. // This redefined class is sent to agent event handler for class file // load hook event. - state->set_class_being_redefined(&the_class, _class_load_kind); - - Klass* k = SystemDictionary::parse_stream(the_class_sym, - the_class_loader, - protection_domain, - &st, - THREAD); + state->set_class_being_redefined(the_class, _class_load_kind); + + InstanceKlass* scratch_class = SystemDictionary::parse_stream( + the_class_sym, + the_class_loader, + protection_domain, + &st, + THREAD); // Clear class_being_redefined just to be sure. state->clear_class_being_redefined(); // TODO: if this is retransform, and nothing changed we can skip it - instanceKlassHandle scratch_class (THREAD, k); - // Need to clean up allocated InstanceKlass if there's an error so assign // the result here. Caller deallocates all the scratch classes in case of // an error. - _scratch_classes[i] = k; + _scratch_classes[i] = scratch_class; if (HAS_PENDING_EXCEPTION) { Symbol* ex_name = PENDING_EXCEPTION->klass()->name(); @@ -1106,7 +1105,7 @@ // the_class to scratch_class in the JVM_* functions called by the // verifier. Please, refer to jvmtiThreadState.hpp for the detailed // description. - RedefineVerifyMark rvm(&the_class, &scratch_class, state); + RedefineVerifyMark rvm(the_class, scratch_class, state); Verifier::verify( scratch_class, Verifier::ThrowException, true, THREAD); } @@ -1138,7 +1137,7 @@ if (VerifyMergedCPBytecodes) { // verify what we have done during constant pool merging { - RedefineVerifyMark rvm(&the_class, &scratch_class, state); + RedefineVerifyMark rvm(the_class, scratch_class, state); Verifier::verify(scratch_class, Verifier::ThrowException, true, THREAD); } @@ -1434,7 +1433,7 @@ // potentially rewrite bytecodes in scratch_class to use the merged // constant pool. jvmtiError VM_RedefineClasses::merge_cp_and_rewrite( - instanceKlassHandle the_class, instanceKlassHandle scratch_class, + InstanceKlass* the_class, InstanceKlass* scratch_class, TRAPS) { // worst case merged constant pool length is old and new combined int merge_cp_length = the_class->constants()->length() @@ -1483,7 +1482,7 @@ _operands_index_map_p = new intArray(operands_index_map_len, operands_index_map_len, -1); // reference to the cp holder is needed for copy_operands() - merge_cp->set_pool_holder(scratch_class()); + merge_cp->set_pool_holder(scratch_class); bool result = merge_constant_pools(old_cp, scratch_cp, &merge_cp, &merge_cp_length, THREAD); merge_cp->set_pool_holder(NULL); @@ -1568,7 +1567,7 @@ // Rewrite constant pool references in klass scratch_class. -bool VM_RedefineClasses::rewrite_cp_refs(instanceKlassHandle scratch_class, +bool VM_RedefineClasses::rewrite_cp_refs(InstanceKlass* scratch_class, TRAPS) { // rewrite constant pool references in the methods: @@ -1655,7 +1654,7 @@ // Rewrite constant pool references in the methods. bool VM_RedefineClasses::rewrite_cp_refs_in_methods( - instanceKlassHandle scratch_class, TRAPS) { + InstanceKlass* scratch_class, TRAPS) { Array<Method*>* methods = scratch_class->methods(); @@ -1834,7 +1833,7 @@ // Rewrite constant pool references in the class_annotations field. bool VM_RedefineClasses::rewrite_cp_refs_in_class_annotations( - instanceKlassHandle scratch_class, TRAPS) { + InstanceKlass* scratch_class, TRAPS) { AnnotationArray* class_annotations = scratch_class->class_annotations(); if (class_annotations == NULL || class_annotations->length() == 0) { @@ -2124,7 +2123,7 @@ // Rewrite constant pool references in a fields_annotations field. bool VM_RedefineClasses::rewrite_cp_refs_in_fields_annotations( - instanceKlassHandle scratch_class, TRAPS) { + InstanceKlass* scratch_class, TRAPS) { Array<AnnotationArray*>* fields_annotations = scratch_class->fields_annotations(); @@ -2157,7 +2156,7 @@ // Rewrite constant pool references in a methods_annotations field. bool VM_RedefineClasses::rewrite_cp_refs_in_methods_annotations( - instanceKlassHandle scratch_class, TRAPS) { + InstanceKlass* scratch_class, TRAPS) { for (int i = 0; i < scratch_class->methods()->length(); i++) { Method* m = scratch_class->methods()->at(i); @@ -2195,7 +2194,7 @@ // } // bool VM_RedefineClasses::rewrite_cp_refs_in_methods_parameter_annotations( - instanceKlassHandle scratch_class, TRAPS) { + InstanceKlass* scratch_class, TRAPS) { for (int i = 0; i < scratch_class->methods()->length(); i++) { Method* m = scratch_class->methods()->at(i); @@ -2244,7 +2243,7 @@ // } // bool VM_RedefineClasses::rewrite_cp_refs_in_methods_default_annotations( - instanceKlassHandle scratch_class, TRAPS) { + InstanceKlass* scratch_class, TRAPS) { for (int i = 0; i < scratch_class->methods()->length(); i++) { Method* m = scratch_class->methods()->at(i); @@ -2271,7 +2270,7 @@ // Rewrite constant pool references in a class_type_annotations field. bool VM_RedefineClasses::rewrite_cp_refs_in_class_type_annotations( - instanceKlassHandle scratch_class, TRAPS) { + InstanceKlass* scratch_class, TRAPS) { AnnotationArray* class_type_annotations = scratch_class->class_type_annotations(); if (class_type_annotations == NULL || class_type_annotations->length() == 0) { @@ -2289,7 +2288,7 @@ // Rewrite constant pool references in a fields_type_annotations field. bool VM_RedefineClasses::rewrite_cp_refs_in_fields_type_annotations( - instanceKlassHandle scratch_class, TRAPS) { + InstanceKlass* scratch_class, TRAPS) { Array<AnnotationArray*>* fields_type_annotations = scratch_class->fields_type_annotations(); if (fields_type_annotations == NULL || fields_type_annotations->length() == 0) { @@ -2321,7 +2320,7 @@ // Rewrite constant pool references in a methods_type_annotations field. bool VM_RedefineClasses::rewrite_cp_refs_in_methods_type_annotations( - instanceKlassHandle scratch_class, TRAPS) { + InstanceKlass* scratch_class, TRAPS) { for (int i = 0; i < scratch_class->methods()->length(); i++) { Method* m = scratch_class->methods()->at(i); @@ -3074,7 +3073,7 @@ // smaller constant pool is associated with scratch_class. void VM_RedefineClasses::set_new_constant_pool( ClassLoaderData* loader_data, - instanceKlassHandle scratch_class, constantPoolHandle scratch_cp, + InstanceKlass* scratch_class, constantPoolHandle scratch_cp, int scratch_cp_length, TRAPS) { assert(scratch_cp->length() >= scratch_cp_length, "sanity check"); @@ -3091,7 +3090,7 @@ // attach klass to new constant pool // reference to the cp holder is needed for copy_operands() - smaller_cp->set_pool_holder(scratch_class()); + smaller_cp->set_pool_holder(scratch_class); scratch_cp->copy_cp_to(1, scratch_cp_length - 1, smaller_cp, 1, THREAD); if (HAS_PENDING_EXCEPTION) { @@ -3268,11 +3267,11 @@ // This is a very busy routine. We don't want too much tracing // printed out. bool trace_name_printed = false; - InstanceKlass *the_class = InstanceKlass::cast(_the_class_oop); + InstanceKlass *the_class = InstanceKlass::cast(_the_class); // If the class being redefined is java.lang.Object, we need to fix all // array class vtables also - if (k->is_array_klass() && _the_class_oop == SystemDictionary::Object_klass()) { + if (k->is_array_klass() && _the_class == SystemDictionary::Object_klass()) { k->vtable()->adjust_method_entries(the_class, &trace_name_printed); } else if (k->is_instance_klass()) { @@ -3291,8 +3290,7 @@ // If the current class being redefined has a user-defined class // loader as its defining class loader, then we can skip all // classes loaded by the bootstrap class loader. - bool is_user_defined = - InstanceKlass::cast(_the_class_oop)->class_loader() != NULL; + bool is_user_defined = (_the_class->class_loader() != NULL); if (is_user_defined && ik->class_loader() == NULL) { return; } @@ -3311,9 +3309,9 @@ // This must be done after we adjust the default_methods and // default_vtable_indices for methods already in the vtable. // If redefining Unsafe, walk all the vtables looking for entries. - if (ik->vtable_length() > 0 && (_the_class_oop->is_interface() - || _the_class_oop == SystemDictionary::internal_Unsafe_klass() - || ik->is_subtype_of(_the_class_oop))) { + if (ik->vtable_length() > 0 && (_the_class->is_interface() + || _the_class == SystemDictionary::internal_Unsafe_klass() + || ik->is_subtype_of(_the_class))) { // ik->vtable() creates a wrapper object; rm cleans it up ResourceMark rm(_thread); @@ -3328,9 +3326,9 @@ // every InstanceKlass that has an itable since there isn't a // subclass relationship between an interface and an InstanceKlass. // If redefining Unsafe, walk all the itables looking for entries. - if (ik->itable_length() > 0 && (_the_class_oop->is_interface() - || _the_class_oop == SystemDictionary::internal_Unsafe_klass() - || ik->is_subclass_of(_the_class_oop))) { + if (ik->itable_length() > 0 && (_the_class->is_interface() + || _the_class == SystemDictionary::internal_Unsafe_klass() + || ik->is_subclass_of(_the_class))) { // ik->itable() creates a wrapper object; rm cleans it up ResourceMark rm(_thread); @@ -3353,7 +3351,7 @@ constantPoolHandle other_cp; ConstantPoolCache* cp_cache; - if (ik != _the_class_oop) { + if (ik != _the_class) { // this klass' constant pool cache may need adjustment other_cp = constantPoolHandle(ik->constants()); cp_cache = other_cp->cache(); @@ -3499,7 +3497,7 @@ // obsolete methods need a unique idnum so they become new entries in // the jmethodID cache in InstanceKlass assert(old_method->method_idnum() == new_method->method_idnum(), "must match"); - u2 num = InstanceKlass::cast(_the_class_oop)->next_method_idnum(); + u2 num = InstanceKlass::cast(_the_class)->next_method_idnum(); if (num != ConstMethod::UNSET_IDNUM) { old_method->set_method_idnum(num); } @@ -3563,7 +3561,7 @@ // class TransferNativeFunctionRegistration { private: - instanceKlassHandle the_class; + InstanceKlass* the_class; int prefix_count; char** prefixes; @@ -3578,7 +3576,7 @@ Symbol* signature) { TempNewSymbol name_symbol = SymbolTable::probe(name_str, (int)name_len); if (name_symbol != NULL) { - Method* method = the_class()->lookup_method(name_symbol, signature); + Method* method = the_class->lookup_method(name_symbol, signature); if (method != NULL) { // Even if prefixed, intermediate methods must exist. if (method->is_native()) { @@ -3641,7 +3639,7 @@ public: // Construct a native method transfer processor for this class. - TransferNativeFunctionRegistration(instanceKlassHandle _the_class) { + TransferNativeFunctionRegistration(InstanceKlass* _the_class) { assert(SafepointSynchronize::is_at_safepoint(), "sanity check"); the_class = _the_class; @@ -3668,7 +3666,7 @@ };