8155672: Remove instanceKlassHandles and KlassHandles

Use unhandled pointers for Klass and InstanceKlass, remove handles with no implementation.

Reviewed-by: dholmes, lfoltan, vlivanov, sspitsyn
This commit is contained in:
Coleen Phillimore 2017-03-15 10:25:37 -04:00
parent 7bca463789
commit 4b9562288f
152 changed files with 1892 additions and 2112 deletions

View file

@ -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. * Copyright (c) 2014, Red Hat Inc. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
@ -63,7 +63,7 @@ void MethodHandles::verify_klass(MacroAssembler* _masm,
Register obj, SystemDictionary::WKID klass_id, Register obj, SystemDictionary::WKID klass_id,
const char* error_message) { const char* error_message) {
InstanceKlass** klass_addr = SystemDictionary::well_known_klass_addr(klass_id); 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 temp = rscratch2;
Register temp2 = rscratch1; // used by MacroAssembler::cmpptr Register temp2 = rscratch1; // used by MacroAssembler::cmpptr
Label L_ok, L_bad; Label L_ok, L_bad;

View file

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -67,7 +67,7 @@ void MethodHandles::verify_klass(MacroAssembler* _masm,
Register obj, Register temp1, Register temp2, SystemDictionary::WKID klass_id, Register obj, Register temp1, Register temp2, SystemDictionary::WKID klass_id,
const char* error_message) { const char* error_message) {
InstanceKlass** klass_addr = SystemDictionary::well_known_klass_addr(klass_id); 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; Label L_ok, L_bad;
BLOCK_COMMENT("verify_klass {"); BLOCK_COMMENT("verify_klass {");
__ verify_oop(obj); __ verify_oop(obj);

View file

@ -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. * Copyright (c) 2012, 2015 SAP SE. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
@ -71,7 +71,7 @@ void MethodHandles::verify_klass(MacroAssembler* _masm,
Register temp_reg, Register temp2_reg, Register temp_reg, Register temp2_reg,
const char* error_message) { const char* error_message) {
InstanceKlass** klass_addr = SystemDictionary::well_known_klass_addr(klass_id); 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; Label L_ok, L_bad;
BLOCK_COMMENT("verify_klass {"); BLOCK_COMMENT("verify_klass {");
__ verify_oop(obj_reg); __ verify_oop(obj_reg);

View file

@ -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. * Copyright (c) 2016 SAP SE. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
@ -73,7 +73,7 @@ void MethodHandles::verify_klass(MacroAssembler* _masm,
const char* error_message) { const char* error_message) {
InstanceKlass** klass_addr = SystemDictionary::well_known_klass_addr(klass_id); 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! assert(temp_reg != Z_R0 && // Is used as base register!
temp_reg != noreg && temp2_reg != noreg, "need valid registers!"); temp_reg != noreg && temp2_reg != noreg, "need valid registers!");

View file

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -71,7 +71,7 @@ void MethodHandles::verify_klass(MacroAssembler* _masm,
Register temp_reg, Register temp2_reg, Register temp_reg, Register temp2_reg,
const char* error_message) { const char* error_message) {
InstanceKlass** klass_addr = SystemDictionary::well_known_klass_addr(klass_id); 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; bool did_save = false;
if (temp_reg == noreg || temp2_reg == noreg) { if (temp_reg == noreg || temp2_reg == noreg) {
temp_reg = L1; temp_reg = L1;

View file

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -65,7 +65,7 @@ void MethodHandles::verify_klass(MacroAssembler* _masm,
Register obj, SystemDictionary::WKID klass_id, Register obj, SystemDictionary::WKID klass_id,
const char* error_message) { const char* error_message) {
InstanceKlass** klass_addr = SystemDictionary::well_known_klass_addr(klass_id); 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 temp = rdi;
Register temp2 = noreg; Register temp2 = noreg;
LP64_ONLY(temp2 = rscratch1); // used by MacroAssembler::cmpptr LP64_ONLY(temp2 = rscratch1); // used by MacroAssembler::cmpptr

View file

@ -560,7 +560,7 @@ void AOTCodeHeap::print_statistics() {
} }
#endif #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); int method_name_len = build_u2_from((address)method_name);
method_name += 2; method_name += 2;
const char* signature_name = method_name + method_name_len; const char* signature_name = method_name + method_name_len;
@ -578,14 +578,14 @@ Method* AOTCodeHeap::find_method(KlassHandle klass, Thread* thread, const char*
name == vmSymbols::class_initializer_name()) { name == vmSymbols::class_initializer_name()) {
// Never search superclasses for constructors // Never search superclasses for constructors
if (klass->is_instance_klass()) { if (klass->is_instance_klass()) {
m = InstanceKlass::cast(klass())->find_method(name, signature); m = InstanceKlass::cast(klass)->find_method(name, signature);
} else { } else {
m = NULL; m = NULL;
} }
} else { } else {
m = klass->lookup_method(name, signature); m = klass->lookup_method(name, signature);
if (m == NULL && klass->is_instance_klass()) { 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) { if (m == NULL) {
@ -669,28 +669,28 @@ void AOTCodeHeap::sweep_dependent_methods(AOTKlassData* klass_data) {
} }
} }
bool AOTCodeHeap::load_klass_data(instanceKlassHandle kh, Thread* thread) { bool AOTCodeHeap::load_klass_data(InstanceKlass* ik, Thread* thread) {
ResourceMark rm; ResourceMark rm;
NOT_PRODUCT( klasses_seen++; ) NOT_PRODUCT( klasses_seen++; )
AOTKlassData* klass_data = find_klass(kh()); AOTKlassData* klass_data = find_klass(ik);
if (klass_data == NULL) { if (klass_data == NULL) {
return false; return false;
} }
if (!kh->has_passed_fingerprint_check()) { if (!ik->has_passed_fingerprint_check()) {
NOT_PRODUCT( aot_klasses_fp_miss++; ) NOT_PRODUCT( aot_klasses_fp_miss++; )
log_trace(aot, class, fingerprint)("class %s%s has bad fingerprint in %s tid=" INTPTR_FORMAT, 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)); _lib->name(), p2i(thread));
sweep_dependent_methods(klass_data); sweep_dependent_methods(klass_data);
return false; 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, 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)); _lib->name(), p2i(thread));
sweep_dependent_methods(klass_data); sweep_dependent_methods(klass_data);
return false; return false;
@ -698,26 +698,26 @@ bool AOTCodeHeap::load_klass_data(instanceKlassHandle kh, Thread* thread) {
assert(klass_data->_class_id < _class_count, "invalid class id"); assert(klass_data->_class_id < _class_count, "invalid class id");
AOTClass* aot_class = &_classes[klass_data->_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, 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++; ) NOT_PRODUCT( aot_klasses_cl_miss++; )
return false; return false;
} }
if (_lib->config()->_omitAssertions && JavaAssertions::enabled(kh->name()->as_C_string(), kh->class_loader() == NULL)) { 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.", kh->internal_name(), _lib->name()); 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); sweep_dependent_methods(klass_data);
return false; return false;
} }
NOT_PRODUCT( aot_klasses_found++; ) 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. // 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. // Initialize global symbols of the DSO to the corresponding VM symbol values.
link_global_lib_symbols(); link_global_lib_symbols();
@ -745,7 +745,7 @@ bool AOTCodeHeap::load_klass_data(instanceKlassHandle kh, Thread* thread) {
// aot_name format: "<u2_size>Ljava/lang/ThreadGroup;<u2_size>addUnstarted<u2_size>()V" // aot_name format: "<u2_size>Ljava/lang/ThreadGroup;<u2_size>addUnstarted<u2_size>()V"
int klass_len = build_u2_from((address)aot_name); int klass_len = build_u2_from((address)aot_name);
const char* method_name = aot_name + 2 + klass_len; 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); methodHandle mh(thread, m);
if (mh->code() != NULL) { // Does it have already compiled code? if (mh->code() != NULL) { // Does it have already compiled code?
continue; // Don't overwrite continue; // Don't overwrite
@ -866,7 +866,7 @@ int AOTCodeHeap::verify_icholder_relocations() {
} }
#endif #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++) { for (int index = 0; index < _method_count; index++) {
if (_code_to_aot[index]._state != in_use) { if (_code_to_aot[index]._state != in_use) {
continue; // Skip uninitialized entries. continue; // Skip uninitialized entries.

View file

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -253,7 +253,7 @@ public:
virtual void* next(void *p) const; virtual void* next(void *p) const;
AOTKlassData* find_klass(InstanceKlass* ik); 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); Klass* get_klass_from_got(const char* klass_name, int klass_len, const Method* method);
void sweep_dependent_methods(AOTKlassData* klass_data); void sweep_dependent_methods(AOTKlassData* klass_data);
bool is_dependent_method(Klass* dependee, AOTCompiledMethod* aot); bool is_dependent_method(Klass* dependee, AOTCompiledMethod* aot);
@ -289,13 +289,13 @@ public:
return NULL; 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(); void cleanup_inline_caches();
DEBUG_ONLY( int verify_icholder_relocations(); ) 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)); void alive_methods_do(void f(CompiledMethod* nm));

View file

@ -143,9 +143,8 @@ Metadata* AOTCompiledMethod::metadata_at(int index) const {
int full_len = 2 + klass_len + 2 + method_name_len + 2 + signature_len; 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? if (!klass_matched || memcmp(_name, meta_name, full_len) != 0) { // Does not match?
Thread* thread = Thread::current(); Thread* thread = Thread::current();
KlassHandle klass = KlassHandle(thread, k);
const char* method_name = klass_name + klass_len; 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; meta = ((intptr_t)m) | 1;
*entry = (Metadata*)meta; // Should be atomic on x64 *entry = (Metadata*)meta; // Should be atomic on x64
@ -239,7 +238,7 @@ bool AOTCompiledMethod::make_entrant() {
// We don't have full dependencies for AOT methods, so flushing is // We don't have full dependencies for AOT methods, so flushing is
// more conservative than for nmethods. // 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()) { if (is_java_method()) {
cleanup_inline_caches(); cleanup_inline_caches();
mark_for_deoptimization(); mark_for_deoptimization();

View file

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -240,7 +240,7 @@ private:
#ifdef HOTSWAP #ifdef HOTSWAP
// Flushing and deoptimization in case of evolution // Flushing and deoptimization in case of evolution
void flush_evol_dependents_on(instanceKlassHandle dependee); void flush_evol_dependents_on(InstanceKlass* dependee);
#endif // HOTSWAP #endif // HOTSWAP
virtual void metadata_do(void f(Metadata*)); virtual void metadata_do(void f(Metadata*));

View file

@ -37,10 +37,10 @@ GrowableArray<AOTLib*>* AOTLoader::_libraries = new(ResourceObj::C_HEAP, mtCode)
// Iterate over all AOT Libraries // Iterate over all AOT Libraries
#define FOR_ALL_AOT_LIBRARIES(lib) for (GrowableArrayIterator<AOTLib*> lib = libraries()->begin(); lib != libraries()->end(); ++lib) #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) { if (UseAOT) {
FOR_ALL_AOT_HEAPS(heap) { FOR_ALL_AOT_HEAPS(heap) {
(*heap)->load_klass_data(kh, thread); (*heap)->load_klass_data(ik, thread);
} }
} }
} }
@ -98,7 +98,7 @@ address AOTLoader::exception_begin(JavaThread* thread, CodeBlob* blob, address r
} }
// Flushing and deoptimization in case of evolution // 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 // make non entrant and mark for deoptimization
FOR_ALL_AOT_HEAPS(heap) { FOR_ALL_AOT_HEAPS(heap) {
(*heap)->flush_evol_dependents_on(dependee); (*heap)->flush_evol_dependents_on(dependee);

View file

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -58,7 +58,7 @@ public:
static void universe_init() NOT_AOT_RETURN; static void universe_init() NOT_AOT_RETURN;
static void set_narrow_klass_shift() NOT_AOT_RETURN; static void set_narrow_klass_shift() NOT_AOT_RETURN;
static bool contains(address p) NOT_AOT({ return false; }); 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 bool find_klass(InstanceKlass* ik) NOT_AOT({ return false; });
static uint64_t get_saved_fingerprint(InstanceKlass* ik) NOT_AOT({ return 0; }); static uint64_t get_saved_fingerprint(InstanceKlass* ik) NOT_AOT({ return 0; });
static void oops_do(OopClosure* f) NOT_AOT_RETURN; static void oops_do(OopClosure* f) NOT_AOT_RETURN;
@ -69,7 +69,7 @@ public:
#ifdef HOTSWAP #ifdef HOTSWAP
// Flushing and deoptimization in case of evolution // 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 #endif // HOTSWAP
}; };

View file

@ -331,7 +331,7 @@ JRT_ENTRY(void, Runtime1::new_instance(JavaThread* thread, Klass* klass))
assert(klass->is_klass(), "not a class"); assert(klass->is_klass(), "not a class");
Handle holder(THREAD, klass->klass_holder()); // keep the klass alive 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); h->check_valid_for_instantiation(true, CHECK);
// make sure klass is initialized // make sure klass is initialized
h->initialize(CHECK); h->initialize(CHECK);
@ -857,8 +857,8 @@ JRT_ENTRY(void, Runtime1::patch_code(JavaThread* thread, Runtime1::StubID stub_i
bool deoptimize_for_volatile = false; bool deoptimize_for_volatile = false;
bool deoptimize_for_atomic = false; bool deoptimize_for_atomic = false;
int patch_field_offset = -1; int patch_field_offset = -1;
KlassHandle init_klass(THREAD, NULL); // klass needed by load_klass_patching code Klass* init_klass = NULL; // klass needed by load_klass_patching code
KlassHandle load_klass(THREAD, 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 mirror(THREAD, NULL); // oop needed by load_mirror_patching code
Handle appendix(THREAD, NULL); // oop needed by appendix_patching code Handle appendix(THREAD, NULL); // oop needed by appendix_patching code
bool load_klass_or_mirror_patch_id = bool load_klass_or_mirror_patch_id =
@ -905,7 +905,7 @@ JRT_ENTRY(void, Runtime1::patch_code(JavaThread* thread, Runtime1::StubID stub_i
case Bytecodes::_putstatic: case Bytecodes::_putstatic:
case Bytecodes::_getstatic: case Bytecodes::_getstatic:
{ Klass* klass = resolve_field_return_klass(caller_method, bci, CHECK); { Klass* klass = resolve_field_return_klass(caller_method, bci, CHECK);
init_klass = KlassHandle(THREAD, klass); init_klass = klass;
mirror = Handle(THREAD, klass->java_mirror()); mirror = Handle(THREAD, klass->java_mirror());
} }
break; break;
@ -945,8 +945,7 @@ JRT_ENTRY(void, Runtime1::patch_code(JavaThread* thread, Runtime1::StubID stub_i
break; break;
default: fatal("unexpected bytecode for load_klass_or_mirror_patch_id"); default: fatal("unexpected bytecode for load_klass_or_mirror_patch_id");
} }
// convert to handle load_klass = k;
load_klass = KlassHandle(THREAD, k);
} else if (stub_id == load_appendix_patching_id) { } else if (stub_id == load_appendix_patching_id) {
Bytecode_invoke bytecode(caller_method, bci); Bytecode_invoke bytecode(caller_method, bci);
Bytecodes::Code bc = bytecode.invoke_code(); Bytecodes::Code bc = bytecode.invoke_code();
@ -1067,7 +1066,7 @@ JRT_ENTRY(void, Runtime1::patch_code(JavaThread* thread, Runtime1::StubID stub_i
// initializing thread are forced to come into the VM and // initializing thread are forced to come into the VM and
// block. // block.
do_patch = (code != Bytecodes::_getstatic && code != Bytecodes::_putstatic) || 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); NativeGeneralJump* jump = nativeGeneralJump_at(instr_pc);
if (jump->jump_destination() == being_initialized_entry) { if (jump->jump_destination() == being_initialized_entry) {
assert(do_patch == true, "initialization must be complete at this point"); assert(do_patch == true, "initialization must be complete at this point");
@ -1079,8 +1078,8 @@ JRT_ENTRY(void, Runtime1::patch_code(JavaThread* thread, Runtime1::StubID stub_i
n_copy->data() == (intptr_t)Universe::non_oop_word(), n_copy->data() == (intptr_t)Universe::non_oop_word(),
"illegal init value"); "illegal init value");
if (stub_id == Runtime1::load_klass_patching_id) { if (stub_id == Runtime1::load_klass_patching_id) {
assert(load_klass() != NULL, "klass not set"); assert(load_klass != NULL, "klass not set");
n_copy->set_data((intx) (load_klass())); n_copy->set_data((intx) (load_klass));
} else { } else {
assert(mirror() != NULL, "klass not set"); assert(mirror() != NULL, "klass not set");
// Don't need a G1 pre-barrier here since we assert above that data isn't an oop. // Don't need a G1 pre-barrier here since we assert above that data isn't an oop.
@ -1131,7 +1130,7 @@ JRT_ENTRY(void, Runtime1::patch_code(JavaThread* thread, Runtime1::StubID stub_i
assert(stub_id == Runtime1::load_klass_patching_id, "wrong stub id"); assert(stub_id == Runtime1::load_klass_patching_id, "wrong stub id");
metadata_Relocation* r = mds.metadata_reloc(); metadata_Relocation* r = mds.metadata_reloc();
Metadata** metadata_adr = r->metadata_addr(); Metadata** metadata_adr = r->metadata_addr();
*metadata_adr = load_klass(); *metadata_adr = load_klass;
r->fix_metadata_relocation(); r->fix_metadata_relocation();
found = true; found = true;
} }

View file

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -37,7 +37,7 @@
// ciArrayKlass::ciArrayKlass // ciArrayKlass::ciArrayKlass
// //
// Loaded array klass. // 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"); assert(get_Klass()->is_array_klass(), "wrong type");
_dimension = get_ArrayKlass()->dimension(); _dimension = get_ArrayKlass()->dimension();
} }

View file

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -37,7 +37,7 @@ private:
jint _dimension; jint _dimension;
protected: protected:
ciArrayKlass(KlassHandle h_k); ciArrayKlass(Klass* k);
ciArrayKlass(ciSymbol* name, int dimension, BasicType bt); ciArrayKlass(ciSymbol* name, int dimension, BasicType bt);
ArrayKlass* get_ArrayKlass() { ArrayKlass* get_ArrayKlass() {

View file

@ -426,7 +426,7 @@ ciKlass* ciEnv::get_klass_by_name_impl(ciKlass* accessing_klass,
} else { } else {
fail_type = _unloaded_ciinstance_klass; fail_type = _unloaded_ciinstance_klass;
} }
KlassHandle found_klass; Klass* found_klass;
{ {
ttyUnlocker ttyul; // release tty lock to avoid ordering problems ttyUnlocker ttyul; // release tty lock to avoid ordering problems
MutexLocker ml(Compile_lock); MutexLocker ml(Compile_lock);
@ -438,7 +438,7 @@ ciKlass* ciEnv::get_klass_by_name_impl(ciKlass* accessing_klass,
kls = SystemDictionary::find_instance_or_array_klass(sym, loader, domain, kls = SystemDictionary::find_instance_or_array_klass(sym, loader, domain,
KILL_COMPILE_ON_FATAL_(fail_type)); 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. // If we fail to find an array klass, look again for its element type.
@ -467,22 +467,22 @@ ciKlass* ciEnv::get_klass_by_name_impl(ciKlass* accessing_klass,
} }
} }
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. // Look inside the constant pool for pre-resolved class entries.
for (int i = cpool->length() - 1; i >= 1; i--) { for (int i = cpool->length() - 1; i >= 1; i--) {
if (cpool->tag_at(i).is_klass()) { if (cpool->tag_at(i).is_klass()) {
Klass* kls = cpool->resolved_klass_at(i); Klass* kls = cpool->resolved_klass_at(i);
if (kls->name() == sym) { if (kls->name() == sym) {
found_klass = KlassHandle(THREAD, kls); found_klass = kls;
break; break;
} }
} }
} }
} }
if (found_klass() != NULL) { if (found_klass != NULL) {
// Found it. Build a CI handle. // Found it. Build a CI handle.
return get_klass(found_klass()); return get_klass(found_klass);
} }
if (require_local) return NULL; if (require_local) return NULL;
@ -512,21 +512,21 @@ ciKlass* ciEnv::get_klass_by_index_impl(const constantPoolHandle& cpool,
bool& is_accessible, bool& is_accessible,
ciInstanceKlass* accessor) { ciInstanceKlass* accessor) {
EXCEPTION_CONTEXT; EXCEPTION_CONTEXT;
KlassHandle klass; // = NULL; Klass* klass = NULL;
Symbol* klass_name = NULL; Symbol* klass_name = NULL;
if (cpool->tag_at(index).is_symbol()) { if (cpool->tag_at(index).is_symbol()) {
klass_name = cpool->symbol_at(index); klass_name = cpool->symbol_at(index);
} else { } else {
// Check if it's resolved if it's not a symbol constant pool entry. // 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. // Try to look it up by name.
if (klass.is_null()) { if (klass == NULL) {
klass_name = cpool->klass_name_at(index); 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. // Not found in constant pool. Use the name to do the lookup.
ciKlass* k = get_klass_by_name_impl(accessor, ciKlass* k = get_klass_by_name_impl(accessor,
cpool, cpool,
@ -548,7 +548,7 @@ ciKlass* ciEnv::get_klass_by_index_impl(const constantPoolHandle& cpool,
// Check for prior unloaded klass. The SystemDictionary's answers // Check for prior unloaded klass. The SystemDictionary's answers
// can vary over time but the compiler needs consistency. // 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); ciKlass* unloaded_klass = check_get_unloaded_klass(accessor, name);
if (unloaded_klass != NULL) { if (unloaded_klass != NULL) {
is_accessible = false; is_accessible = false;
@ -557,7 +557,7 @@ ciKlass* ciEnv::get_klass_by_index_impl(const constantPoolHandle& cpool,
// It is known to be accessible, since it was found in the constant pool. // It is known to be accessible, since it was found in the constant pool.
is_accessible = true; is_accessible = true;
return get_klass(klass()); return get_klass(klass);
} }
// ------------------------------------------------------------------ // ------------------------------------------------------------------
@ -713,10 +713,10 @@ Method* ciEnv::lookup_method(ciInstanceKlass* accessor,
// Accessibility checks are performed in ciEnv::get_method_by_index_impl. // Accessibility checks are performed in ciEnv::get_method_by_index_impl.
assert(check_klass_accessibility(accessor, holder->get_Klass()), "holder not accessible"); assert(check_klass_accessibility(accessor, holder->get_Klass()), "holder not accessible");
KlassHandle h_accessor(accessor->get_instanceKlass()); InstanceKlass* accessor_klass = accessor->get_instanceKlass();
KlassHandle h_holder(holder->get_Klass()); Klass* holder_klass = holder->get_Klass();
methodHandle dest_method; 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) { switch (bc) {
case Bytecodes::_invokestatic: case Bytecodes::_invokestatic:
dest_method = dest_method =

View file

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -44,8 +44,8 @@
// ciInstanceKlass::ciInstanceKlass // ciInstanceKlass::ciInstanceKlass
// //
// Loaded instance klass. // Loaded instance klass.
ciInstanceKlass::ciInstanceKlass(KlassHandle h_k) : ciInstanceKlass::ciInstanceKlass(Klass* k) :
ciKlass(h_k) ciKlass(k)
{ {
assert(get_Klass()->is_instance_klass(), "wrong type"); assert(get_Klass()->is_instance_klass(), "wrong type");
assert(get_instanceKlass()->is_loaded(), "must be at least loaded"); assert(get_instanceKlass()->is_loaded(), "must be at least loaded");
@ -83,7 +83,7 @@ ciInstanceKlass::ciInstanceKlass(KlassHandle h_k) :
_java_mirror = NULL; _java_mirror = NULL;
if (is_shared()) { if (is_shared()) {
if (h_k() != SystemDictionary::Object_klass()) { if (k != SystemDictionary::Object_klass()) {
super(); super();
} }
//compute_nonstatic_fields(); // done outside of constructor //compute_nonstatic_fields(); // done outside of constructor

View file

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -77,7 +77,7 @@ private:
bool compute_injected_fields_helper(); bool compute_injected_fields_helper();
protected: protected:
ciInstanceKlass(KlassHandle h_k); ciInstanceKlass(Klass* k);
ciInstanceKlass(ciSymbol* name, jobject loader, jobject protection_domain); ciInstanceKlass(ciSymbol* name, jobject loader, jobject protection_domain);
InstanceKlass* get_instanceKlass() const { InstanceKlass* get_instanceKlass() const {

View file

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -35,11 +35,11 @@
// ------------------------------------------------------------------ // ------------------------------------------------------------------
// ciKlass::ciKlass // ciKlass::ciKlass
ciKlass::ciKlass(KlassHandle h_k) : ciType(h_k) { ciKlass::ciKlass(Klass* k) : ciType(k) {
assert(get_Klass()->is_klass(), "wrong type"); assert(get_Klass()->is_klass(), "wrong type");
Klass* k = get_Klass(); Klass* klass = get_Klass();
_layout_helper = k->layout_helper(); _layout_helper = klass->layout_helper();
Symbol* klass_name = k->name(); Symbol* klass_name = klass->name();
assert(klass_name != NULL, "wrong ciKlass constructor"); assert(klass_name != NULL, "wrong ciKlass constructor");
_name = CURRENT_ENV->get_symbol(klass_name); _name = CURRENT_ENV->get_symbol(klass_name);
} }
@ -48,7 +48,7 @@ ciKlass::ciKlass(KlassHandle h_k) : ciType(h_k) {
// ciKlass::ciKlass // ciKlass::ciKlass
// //
// Nameless klass variant. // 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"); assert(get_Klass()->is_klass(), "wrong type");
_name = name; _name = name;
_layout_helper = Klass::_lh_neutral_value; _layout_helper = Klass::_lh_neutral_value;

View file

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -51,7 +51,7 @@ private:
jint _layout_helper; jint _layout_helper;
protected: protected:
ciKlass(KlassHandle k_h, ciSymbol* name); ciKlass(Klass* k, ciSymbol* name);
ciKlass(ciSymbol* name, BasicType bt); ciKlass(ciSymbol* name, BasicType bt);
Klass* get_Klass() const { Klass* get_Klass() const {
@ -72,7 +72,7 @@ protected:
void print_impl(outputStream* st); void print_impl(outputStream* st);
public: public:
ciKlass(KlassHandle k_h); ciKlass(Klass* k);
// What is the name of this klass? // What is the name of this klass?
ciSymbol* name() const { return _name; } ciSymbol* name() const { return _name; }

View file

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -783,24 +783,24 @@ ciMethod* ciMethod::resolve_invoke(ciKlass* caller, ciKlass* exact_receiver, boo
check_is_loaded(); check_is_loaded();
VM_ENTRY_MARK; VM_ENTRY_MARK;
KlassHandle caller_klass (THREAD, caller->get_Klass()); Klass* caller_klass = caller->get_Klass();
KlassHandle h_recv (THREAD, exact_receiver->get_Klass()); Klass* recv = exact_receiver->get_Klass();
KlassHandle h_resolved (THREAD, holder()->get_Klass()); Klass* resolved = holder()->get_Klass();
Symbol* h_name = name()->get_symbol(); Symbol* h_name = name()->get_symbol();
Symbol* h_signature = signature()->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); check_access ? LinkInfo::needs_access_check : LinkInfo::skip_access_check);
methodHandle m; methodHandle m;
// Only do exact lookup if receiver klass has been linked. Otherwise, // Only do exact lookup if receiver klass has been linked. Otherwise,
// the vtable has not been setup, and the LinkResolver will fail. // 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()) { 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 { } 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 @@ int ciMethod::resolve_vtable_index(ciKlass* caller, ciKlass* receiver) {
receiver->as_instance_klass()->is_linked())) { receiver->as_instance_klass()->is_linked())) {
VM_ENTRY_MARK; VM_ENTRY_MARK;
KlassHandle caller_klass (THREAD, caller->get_Klass()); Klass* caller_klass = caller->get_Klass();
KlassHandle h_recv (THREAD, receiver->get_Klass()); Klass* recv = receiver->get_Klass();
Symbol* h_name = name()->get_symbol(); Symbol* h_name = name()->get_symbol();
Symbol* h_signature = signature()->get_symbol(); Symbol* h_signature = signature()->get_symbol();
LinkInfo link_info(h_recv, h_name, h_signature, caller_klass); LinkInfo link_info(recv, h_name, h_signature, caller_klass);
vtable_index = LinkResolver::resolve_virtual_vtable_index(h_recv, link_info); vtable_index = LinkResolver::resolve_virtual_vtable_index(recv, link_info);
if (vtable_index == Method::nonvirtual_vtable_index) { if (vtable_index == Method::nonvirtual_vtable_index) {
// A statically bound method. Return "no such index". // A statically bound method. Return "no such index".
vtable_index = Method::invalid_vtable_index; vtable_index = Method::invalid_vtable_index;

View file

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -38,7 +38,7 @@
// ciObjArrayKlass::ciObjArrayKlass // ciObjArrayKlass::ciObjArrayKlass
// //
// Constructor for loaded object array klasses. // 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"); assert(get_Klass()->is_objArray_klass(), "wrong type");
Klass* element_Klass = get_ObjArrayKlass()->bottom_klass(); Klass* element_Klass = get_ObjArrayKlass()->bottom_klass();
_base_element_klass = CURRENT_ENV->get_klass(element_Klass); _base_element_klass = CURRENT_ENV->get_klass(element_Klass);

View file

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -40,7 +40,7 @@ private:
ciKlass* _base_element_klass; ciKlass* _base_element_klass;
protected: protected:
ciObjArrayKlass(KlassHandle h_k); ciObjArrayKlass(Klass* k);
ciObjArrayKlass(ciSymbol* array_name, ciObjArrayKlass(ciSymbol* array_name,
ciKlass* base_element_klass, ciKlass* base_element_klass,
int dimension); int dimension);

View file

@ -377,14 +377,13 @@ ciMetadata* ciObjectFactory::create_new_metadata(Metadata* o) {
} }
if (o->is_klass()) { if (o->is_klass()) {
KlassHandle h_k(THREAD, (Klass*)o);
Klass* k = (Klass*)o; Klass* k = (Klass*)o;
if (k->is_instance_klass()) { if (k->is_instance_klass()) {
return new (arena()) ciInstanceKlass(h_k); return new (arena()) ciInstanceKlass(k);
} else if (k->is_objArray_klass()) { } else if (k->is_objArray_klass()) {
return new (arena()) ciObjArrayKlass(h_k); return new (arena()) ciObjArrayKlass(k);
} else if (k->is_typeArray_klass()) { } else if (k->is_typeArray_klass()) {
return new (arena()) ciTypeArrayKlass(h_k); return new (arena()) ciTypeArrayKlass(k);
} }
} else if (o->is_method()) { } else if (o->is_method()) {
methodHandle h_m(THREAD, (Method*)o); methodHandle h_m(THREAD, (Method*)o);

View file

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -799,8 +799,8 @@ class CompileReplay : public StackObj {
} else if (strcmp(field_signature, "[J") == 0) { } else if (strcmp(field_signature, "[J") == 0) {
value = oopFactory::new_longArray(length, CHECK); value = oopFactory::new_longArray(length, CHECK);
} else if (field_signature[0] == '[' && field_signature[1] == 'L') { } else if (field_signature[0] == '[' && field_signature[1] == 'L') {
KlassHandle kelem = resolve_klass(field_signature + 1, CHECK); Klass* kelem = resolve_klass(field_signature + 1, CHECK);
value = oopFactory::new_objArray(kelem(), length, CHECK); value = oopFactory::new_objArray(kelem, length, CHECK);
} else { } else {
report_error("unhandled array staticfield"); report_error("unhandled array staticfield");
} }
@ -840,8 +840,8 @@ class CompileReplay : public StackObj {
Handle value = java_lang_String::create_from_str(string_value, CHECK); Handle value = java_lang_String::create_from_str(string_value, CHECK);
java_mirror->obj_field_put(fd.offset(), value()); java_mirror->obj_field_put(fd.offset(), value());
} else if (field_signature[0] == 'L') { } else if (field_signature[0] == 'L') {
KlassHandle k = resolve_klass(string_value, CHECK); Klass* k = resolve_klass(string_value, CHECK);
oop value = InstanceKlass::cast(k())->allocate_instance(CHECK); oop value = InstanceKlass::cast(k)->allocate_instance(CHECK);
java_mirror->obj_field_put(fd.offset(), value); java_mirror->obj_field_put(fd.offset(), value);
} else { } else {
report_error("unhandled staticfield"); report_error("unhandled staticfield");

View file

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -45,8 +45,8 @@ ciType::ciType(BasicType basic_type) : ciMetadata() {
_basic_type = basic_type; _basic_type = basic_type;
} }
ciType::ciType(KlassHandle k) : ciMetadata(k()) { ciType::ciType(Klass* k) : ciMetadata(k) {
_basic_type = k()->is_array_klass() ? T_ARRAY : T_OBJECT; _basic_type = k->is_array_klass() ? T_ARRAY : T_OBJECT;
} }

View file

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -40,7 +40,7 @@ private:
BasicType _basic_type; BasicType _basic_type;
ciType(BasicType t); // for primitive and unloaded types 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"; } const char* type_string() { return "ciType"; }

View file

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -33,7 +33,7 @@
// ------------------------------------------------------------------ // ------------------------------------------------------------------
// ciTypeArrayKlass::ciTypeArrayKlass // 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(get_Klass()->is_typeArray_klass(), "wrong type");
assert(element_type() == get_TypeArrayKlass()->element_type(), ""); assert(element_type() == get_TypeArrayKlass()->element_type(), "");
} }

View file

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -35,7 +35,7 @@ class ciTypeArrayKlass : public ciArrayKlass {
CI_PACKAGE_ACCESS CI_PACKAGE_ACCESS
protected: protected:
ciTypeArrayKlass(KlassHandle h_k); ciTypeArrayKlass(Klass* k);
TypeArrayKlass* get_TypeArrayKlass() { TypeArrayKlass* get_TypeArrayKlass() {
return (TypeArrayKlass*)get_Klass(); return (TypeArrayKlass*)get_Klass();

View file

@ -815,13 +815,13 @@ void ClassFileParser::parse_interfaces(const ClassFileStream* const stream,
int index; int index;
for (index = 0; index < itfs_len; index++) { for (index = 0; index < itfs_len; index++) {
const u2 interface_index = stream->get_u2(CHECK); const u2 interface_index = stream->get_u2(CHECK);
KlassHandle interf; Klass* interf;
check_property( check_property(
valid_klass_reference_at(interface_index), valid_klass_reference_at(interface_index),
"Interface name has bad constant pool index %u in class file %s", "Interface name has bad constant pool index %u in class file %s",
interface_index, CHECK); interface_index, CHECK);
if (cp->tag_at(interface_index).is_klass()) { 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 { } else {
Symbol* const unresolved_klass = cp->klass_name_at(interface_index); Symbol* const unresolved_klass = cp->klass_name_at(interface_index);
@ -831,25 +831,24 @@ void ClassFileParser::parse_interfaces(const ClassFileStream* const stream,
"Bad interface name in class file %s", CHECK); "Bad interface name in class file %s", CHECK);
// Call resolve_super so classcircularity is checked // Call resolve_super so classcircularity is checked
const Klass* const k = interf = SystemDictionary::resolve_super_or_fail(
SystemDictionary::resolve_super_or_fail(_class_name, _class_name,
unresolved_klass, unresolved_klass,
Handle(THREAD, _loader_data->class_loader()), Handle(THREAD, _loader_data->class_loader()),
_protection_domain, _protection_domain,
false, false,
CHECK); CHECK);
interf = KlassHandle(THREAD, k);
} }
if (!interf()->is_interface()) { if (!interf->is_interface()) {
THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(), THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(),
"Implementing class"); "Implementing class");
} }
if (InstanceKlass::cast(interf())->has_nonstatic_concrete_methods()) { if (InstanceKlass::cast(interf)->has_nonstatic_concrete_methods()) {
*has_nonstatic_concrete_methods = true; *has_nonstatic_concrete_methods = true;
} }
_local_interfaces->at_put(index, interf()); _local_interfaces->at_put(index, interf);
} }
if (!_need_verify || itfs_len <= 1) { if (!_need_verify || itfs_len <= 1) {

View file

@ -1405,7 +1405,7 @@ ClassFileStream* ClassLoader::search_module_entries(const GrowableArray<ModuleCl
return NULL; 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(name != NULL, "invariant");
assert(THREAD->is_Java_thread(), "must be a JavaThread"); assert(THREAD->is_Java_thread(), "must be a JavaThread");
@ -1512,7 +1512,7 @@ instanceKlassHandle ClassLoader::load_class(Symbol* name, bool search_append_onl
ClassLoaderData* loader_data = ClassLoaderData::the_null_class_loader_data(); ClassLoaderData* loader_data = ClassLoaderData::the_null_class_loader_data();
Handle protection_domain; Handle protection_domain;
instanceKlassHandle result = KlassFactory::create_from_stream(stream, InstanceKlass* result = KlassFactory::create_from_stream(stream,
name, name,
loader_data, loader_data,
protection_domain, protection_domain,
@ -1891,15 +1891,15 @@ void ClassLoader::compile_the_world_in(char* name, Handle loader, TRAPS) {
// Construct name without extension // Construct name without extension
TempNewSymbol sym = SymbolTable::new_symbol(buffer, CHECK); TempNewSymbol sym = SymbolTable::new_symbol(buffer, CHECK);
// Use loader to load and initialize class // Use loader to load and initialize class
Klass* ik = SystemDictionary::resolve_or_null(sym, loader, Handle(), THREAD); Klass* k = SystemDictionary::resolve_or_null(sym, loader, Handle(), THREAD);
instanceKlassHandle k (THREAD, ik); if (k != NULL && !HAS_PENDING_EXCEPTION) {
if (k.not_null() && !HAS_PENDING_EXCEPTION) {
k->initialize(THREAD); k->initialize(THREAD);
} }
bool exception_occurred = HAS_PENDING_EXCEPTION; bool exception_occurred = HAS_PENDING_EXCEPTION;
clear_pending_exception_if_not_oom(CHECK); clear_pending_exception_if_not_oom(CHECK);
if (CompileTheWorldPreloadClasses && k.not_null()) { if (CompileTheWorldPreloadClasses && k != NULL) {
ConstantPool::preload_and_initialize_all_classes(k->constants(), THREAD); InstanceKlass* ik = InstanceKlass::cast(k);
ConstantPool::preload_and_initialize_all_classes(ik->constants(), THREAD);
if (HAS_PENDING_EXCEPTION) { if (HAS_PENDING_EXCEPTION) {
// If something went wrong in preloading we just ignore it // If something went wrong in preloading we just ignore it
clear_pending_exception_if_not_oom(CHECK); clear_pending_exception_if_not_oom(CHECK);
@ -1908,7 +1908,7 @@ void ClassLoader::compile_the_world_in(char* name, Handle loader, TRAPS) {
} }
if (_compile_the_world_class_counter >= CompileTheWorldStartAt) { 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 // If something went wrong (e.g. ExceptionInInitializerError) we skip this class
tty->print_cr("CompileTheWorld (%d) : Skipping %s", _compile_the_world_class_counter, buffer); tty->print_cr("CompileTheWorld (%d) : Skipping %s", _compile_the_world_class_counter, buffer);
} else { } else {
@ -1916,8 +1916,9 @@ void ClassLoader::compile_the_world_in(char* name, Handle loader, TRAPS) {
// Preload all classes to get around uncommon traps // Preload all classes to get around uncommon traps
// Iterate over all methods in class // Iterate over all methods in class
int comp_level = CompilationPolicy::policy()->initial_compile_level(); int comp_level = CompilationPolicy::policy()->initial_compile_level();
for (int n = 0; n < k->methods()->length(); n++) { InstanceKlass* ik = InstanceKlass::cast(k);
methodHandle m (THREAD, k->methods()->at(n)); for (int n = 0; n < ik->methods()->length(); n++) {
methodHandle m (THREAD, ik->methods()->at(n));
if (can_be_compiled(m, comp_level)) { if (can_be_compiled(m, comp_level)) {
if (++_codecache_sweep_counter == CompileTheWorldSafepointInterval) { if (++_codecache_sweep_counter == CompileTheWorldSafepointInterval) {
// Give sweeper a chance to keep up with CTW // Give sweeper a chance to keep up with CTW

View file

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -371,7 +371,7 @@ class ClassLoader: AllStatic {
const char* const file_name, TRAPS); const char* const file_name, TRAPS);
// Load individual .class file // 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 // 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. // the name of the directory or ZIP file that the package was loaded from.

View file

@ -760,7 +760,7 @@ void ClassLoaderDataGraph::log_creation(Handle loader, ClassLoaderData* cld, TRA
// Include the result of loader.toString() in the output. This allows // Include the result of loader.toString() in the output. This allows
// the user of the log to identify the class loader instance. // the user of the log to identify the class loader instance.
JavaValue result(T_OBJECT); JavaValue result(T_OBJECT);
KlassHandle spec_klass(THREAD, SystemDictionary::ClassLoader_klass()); Klass* spec_klass = SystemDictionary::ClassLoader_klass();
JavaCalls::call_virtual(&result, JavaCalls::call_virtual(&result,
loader, loader,
spec_klass, spec_klass,

View file

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -49,10 +49,10 @@ public:
return false; return false;
} }
instanceKlassHandle record_result(Symbol* class_name, InstanceKlass* record_result(Symbol* class_name,
ClassPathEntry* e, ClassPathEntry* e,
const s2 classpath_index, const s2 classpath_index,
instanceKlassHandle result, TRAPS) { InstanceKlass* result, TRAPS) {
if (ClassLoader::add_package(_file_name, classpath_index, THREAD)) { if (ClassLoader::add_package(_file_name, classpath_index, THREAD)) {
#if INCLUDE_CDS #if INCLUDE_CDS
if (DumpSharedSpaces) { if (DumpSharedSpaces) {
@ -64,7 +64,7 @@ public:
#endif #endif
return result; return result;
} else { } else {
return instanceKlassHandle(); // NULL return NULL;
} }
} }
}; };

View file

@ -46,7 +46,7 @@ size_t Dictionary::entry_size() {
} }
Dictionary::Dictionary(int table_size) 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_index = 0;
_current_class_entry = NULL; _current_class_entry = NULL;
_pd_cache_table = new ProtectionDomainCacheTable(defaultProtectionDomainCacheSize); _pd_cache_table = new ProtectionDomainCacheTable(defaultProtectionDomainCacheSize);
@ -55,7 +55,7 @@ Dictionary::Dictionary(int table_size)
Dictionary::Dictionary(int table_size, HashtableBucket<mtClass>* t, Dictionary::Dictionary(int table_size, HashtableBucket<mtClass>* t,
int number_of_entries) 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_index = 0;
_current_class_entry = NULL; _current_class_entry = NULL;
_pd_cache_table = new ProtectionDomainCacheTable(defaultProtectionDomainCacheSize); _pd_cache_table = new ProtectionDomainCacheTable(defaultProtectionDomainCacheSize);
@ -65,9 +65,9 @@ ProtectionDomainCacheEntry* Dictionary::cache_get(Handle protection_domain) {
return _pd_cache_table->get(protection_domain); 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) { 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_loader_data(loader_data);
entry->set_pd_set(NULL); entry->set_pd_set(NULL);
assert(klass->is_instance_klass(), "Must be"); assert(klass->is_instance_klass(), "Must be");
@ -85,7 +85,7 @@ void Dictionary::free_entry(DictionaryEntry* entry) {
entry->set_pd_set(to_delete->next()); entry->set_pd_set(to_delete->next());
delete to_delete; delete to_delete;
} }
Hashtable<Klass*, mtClass>::free_entry(entry); Hashtable<InstanceKlass*, mtClass>::free_entry(entry);
} }
@ -351,10 +351,10 @@ void Dictionary::unlink(BoolObjectClosure* is_alive) {
_pd_cache_table->unlink(is_alive); _pd_cache_table->unlink(is_alive);
} }
Klass* Dictionary::try_get_next_class() { InstanceKlass* Dictionary::try_get_next_class() {
while (true) { while (true) {
if (_current_class_entry != NULL) { if (_current_class_entry != NULL) {
Klass* k = _current_class_entry->klass(); InstanceKlass* k = _current_class_entry->klass();
_current_class_entry = _current_class_entry->next(); _current_class_entry = _current_class_entry->next();
return k; return k;
} }
@ -371,15 +371,15 @@ Klass* Dictionary::try_get_next_class() {
// by the compilers. // by the compilers.
void Dictionary::add_klass(Symbol* class_name, ClassLoaderData* loader_data, void Dictionary::add_klass(Symbol* class_name, ClassLoaderData* loader_data,
KlassHandle obj) { InstanceKlass* obj) {
assert_locked_or_safepoint(SystemDictionary_lock); assert_locked_or_safepoint(SystemDictionary_lock);
assert(obj() != NULL, "adding NULL obj"); assert(obj != NULL, "adding NULL obj");
assert(obj()->name() == class_name, "sanity check on name"); assert(obj->name() == class_name, "sanity check on name");
assert(loader_data != NULL, "Must be non-NULL"); assert(loader_data != NULL, "Must be non-NULL");
unsigned int hash = compute_hash(class_name, loader_data); unsigned int hash = compute_hash(class_name, loader_data);
int index = hash_to_index(hash); 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); add_entry(index, entry);
} }
@ -410,7 +410,7 @@ DictionaryEntry* Dictionary::get_entry(int index, unsigned int hash,
} }
Klass* Dictionary::find(int index, unsigned int hash, Symbol* name, InstanceKlass* Dictionary::find(int index, unsigned int hash, Symbol* name,
ClassLoaderData* loader_data, Handle protection_domain, TRAPS) { ClassLoaderData* loader_data, Handle protection_domain, TRAPS) {
DictionaryEntry* entry = get_entry(index, hash, name, loader_data); DictionaryEntry* entry = get_entry(index, hash, name, loader_data);
if (entry != NULL && entry->is_valid_protection_domain(protection_domain)) { if (entry != NULL && entry->is_valid_protection_domain(protection_domain)) {
@ -421,30 +421,30 @@ Klass* Dictionary::find(int index, unsigned int hash, Symbol* name,
} }
Klass* Dictionary::find_class(int index, unsigned int hash, InstanceKlass* Dictionary::find_class(int index, unsigned int hash,
Symbol* name, ClassLoaderData* loader_data) { Symbol* name, ClassLoaderData* loader_data) {
assert_locked_or_safepoint(SystemDictionary_lock); assert_locked_or_safepoint(SystemDictionary_lock);
assert (index == index_for(name, loader_data), "incorrect index?"); assert (index == index_for(name, loader_data), "incorrect index?");
DictionaryEntry* entry = get_entry(index, hash, name, loader_data); 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 // Variant of find_class for shared classes. No locking required, as
// that table is static. // that table is static.
Klass* Dictionary::find_shared_class(int index, unsigned int hash, InstanceKlass* Dictionary::find_shared_class(int index, unsigned int hash,
Symbol* name) { Symbol* name) {
assert (index == index_for(name, NULL), "incorrect index?"); assert (index == index_for(name, NULL), "incorrect index?");
DictionaryEntry* entry = get_entry(index, hash, name, NULL); 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, void Dictionary::add_protection_domain(int index, unsigned int hash,
instanceKlassHandle klass, InstanceKlass* klass,
ClassLoaderData* loader_data, Handle protection_domain, ClassLoaderData* loader_data, Handle protection_domain,
TRAPS) { TRAPS) {
Symbol* klass_name = klass->name(); Symbol* klass_name = klass->name();

View file

@ -41,7 +41,7 @@ class BoolObjectClosure;
// The data structure for the system dictionary (and the shared system // The data structure for the system dictionary (and the shared system
// dictionary). // dictionary).
class Dictionary : public TwoOopHashtable<Klass*, mtClass> { class Dictionary : public TwoOopHashtable<InstanceKlass*, mtClass> {
friend class VMStructs; friend class VMStructs;
private: private:
// current iteration index. // current iteration index.
@ -56,16 +56,16 @@ private:
protected: protected:
DictionaryEntry* bucket(int i) const { 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. // The following method is not MT-safe and must be done under lock.
DictionaryEntry** bucket_addr(int i) { 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) { 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(); static size_t entry_size();
@ -73,21 +73,21 @@ public:
Dictionary(int table_size); Dictionary(int table_size);
Dictionary(int table_size, HashtableBucket<mtClass>* t, int number_of_entries); 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(); DictionaryEntry* new_entry();
void free_entry(DictionaryEntry* 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, InstanceKlass* find_class(int index, unsigned int hash,
Symbol* name, ClassLoaderData* loader_data); 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 // Compiler support
Klass* try_get_next_class(); InstanceKlass* try_get_next_class();
// GC support // GC support
void oops_do(OopClosure* f); void oops_do(OopClosure* f);
@ -116,13 +116,13 @@ public:
void do_unloading(); void do_unloading();
// Protection domains // Protection domains
Klass* find(int index, unsigned int hash, Symbol* name, InstanceKlass* find(int index, unsigned int hash, Symbol* name,
ClassLoaderData* loader_data, Handle protection_domain, TRAPS); ClassLoaderData* loader_data, Handle protection_domain, TRAPS);
bool is_valid_protection_domain(int index, unsigned int hash, bool is_valid_protection_domain(int index, unsigned int hash,
Symbol* name, ClassLoaderData* loader_data, Symbol* name, ClassLoaderData* loader_data,
Handle protection_domain); Handle protection_domain);
void add_protection_domain(int index, unsigned int hash, void add_protection_domain(int index, unsigned int hash,
instanceKlassHandle klass, ClassLoaderData* loader_data, InstanceKlass* klass, ClassLoaderData* loader_data,
Handle protection_domain, TRAPS); Handle protection_domain, TRAPS);
// Sharing support // Sharing support
@ -243,9 +243,9 @@ class ProtectionDomainEntry :public CHeapObj<mtClass> {
}; };
// An entry in the system dictionary, this describes a class as // 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; friend class VMStructs;
private: private:
// Contains the set of approved protection domains that can access // Contains the set of approved protection domains that can access
@ -277,15 +277,15 @@ class DictionaryEntry : public HashtableEntry<Klass*, mtClass> {
// Adds a protection domain to the approved set. // Adds a protection domain to the approved set.
void add_protection_domain(Dictionary* dict, Handle protection_domain); void add_protection_domain(Dictionary* dict, Handle protection_domain);
Klass* klass() const { return (Klass*)literal(); } InstanceKlass* klass() const { return (InstanceKlass*)literal(); }
Klass** klass_addr() { return (Klass**)literal_addr(); } InstanceKlass** klass_addr() { return (InstanceKlass**)literal_addr(); }
DictionaryEntry* next() const { DictionaryEntry* next() const {
return (DictionaryEntry*)HashtableEntry<Klass*, mtClass>::next(); return (DictionaryEntry*)HashtableEntry<InstanceKlass*, mtClass>::next();
} }
DictionaryEntry** next_addr() { DictionaryEntry** next_addr() {
return (DictionaryEntry**)HashtableEntry<Klass*, mtClass>::next_addr(); return (DictionaryEntry**)HashtableEntry<InstanceKlass*, mtClass>::next_addr();
} }
ClassLoaderData* loader_data() const { return _loader_data; } ClassLoaderData* loader_data() const { return _loader_data; }
@ -323,7 +323,7 @@ class DictionaryEntry : public HashtableEntry<Klass*, mtClass> {
} }
bool equals(const Symbol* class_name, ClassLoaderData* loader_data) const { 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); return (klass->name() == class_name && _loader_data == loader_data);
} }

View file

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -96,7 +96,7 @@ void JavaAssertions::addOption(const char* name, bool enable) {
oop JavaAssertions::createAssertionStatusDirectives(TRAPS) { oop JavaAssertions::createAssertionStatusDirectives(TRAPS) {
Symbol* asd_sym = vmSymbols::java_lang_AssertionStatusDirectives(); Symbol* asd_sym = vmSymbols::java_lang_AssertionStatusDirectives();
Klass* k = SystemDictionary::resolve_or_fail(asd_sym, true, CHECK_NULL); 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); asd_klass->initialize(CHECK_NULL);
Handle h = asd_klass->allocate_instance_handle(CHECK_NULL); Handle h = asd_klass->allocate_instance_handle(CHECK_NULL);

View file

@ -735,7 +735,7 @@ static void initialize_static_field(fieldDescriptor* fd, Handle mirror, TRAPS) {
} }
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"); 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 // If the offset was read from the shared archive, it was fixed up already
@ -744,7 +744,7 @@ void java_lang_Class::fixup_mirror(KlassHandle k, TRAPS) {
// During bootstrap, java.lang.Class wasn't loaded so static field // During bootstrap, java.lang.Class wasn't loaded so static field
// offsets were computed without the size added it. Go back and // offsets were computed without the size added it. Go back and
// update all the static field offsets to included the size. // 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()) { if (fs.access_flags().is_static()) {
int real_offset = fs.offset() + InstanceMirrorKlass::offset_of_static_fields(); int real_offset = fs.offset() + InstanceMirrorKlass::offset_of_static_fields();
fs.set_offset(real_offset); fs.set_offset(real_offset);
@ -755,7 +755,7 @@ void java_lang_Class::fixup_mirror(KlassHandle k, TRAPS) {
create_mirror(k, Handle(), Handle(), Handle(), CHECK); 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 mirror,
Handle protection_domain, Handle protection_domain,
TRAPS) { TRAPS) {
@ -769,11 +769,11 @@ void java_lang_Class::initialize_mirror_fields(KlassHandle k,
set_protection_domain(mirror(), protection_domain()); set_protection_domain(mirror(), protection_domain());
// Initialize static fields // 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 // 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()) { if (module.is_null()) {
// During startup, the module may be NULL only if java.base has not been defined yet. // 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 // Put the class on the fixup_module_list to patch later when the java.lang.reflect.Module
@ -791,7 +791,7 @@ void java_lang_Class::set_mirror_module_field(KlassHandle k, Handle mirror, Hand
set_fixup_module_field_list(list); set_fixup_module_field_list(list);
} }
k->class_loader_data()->inc_keep_alive(); k->class_loader_data()->inc_keep_alive();
fixup_module_field_list()->push(k()); fixup_module_field_list()->push(k);
} else { } else {
javabase_was_defined = true; javabase_was_defined = true;
} }
@ -814,7 +814,7 @@ void java_lang_Class::set_mirror_module_field(KlassHandle k, Handle mirror, Hand
} }
} }
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) { Handle module, Handle protection_domain, TRAPS) {
assert(k->java_mirror() == NULL, "should only assign mirror once"); assert(k->java_mirror() == NULL, "should only assign mirror once");
// Use this moment of initialization to cache modifier_flags also, // Use this moment of initialization to cache modifier_flags also,
@ -831,8 +831,8 @@ void java_lang_Class::create_mirror(KlassHandle k, Handle class_loader,
Handle mirror(THREAD, mirror_oop); Handle mirror(THREAD, mirror_oop);
// Setup indirection from mirror->klass // Setup indirection from mirror->klass
if (!k.is_null()) { if (k != NULL) {
java_lang_Class::set_klass(mirror(), k()); java_lang_Class::set_klass(mirror(), k);
} }
InstanceMirrorKlass* mk = InstanceMirrorKlass::cast(mirror->klass()); InstanceMirrorKlass* mk = InstanceMirrorKlass::cast(mirror->klass());
@ -844,11 +844,11 @@ void java_lang_Class::create_mirror(KlassHandle k, Handle class_loader,
if (k->is_array_klass()) { if (k->is_array_klass()) {
oop comp_mirror; oop comp_mirror;
if (k->is_typeArray_klass()) { 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); comp_mirror = Universe::java_mirror(type);
} else { } else {
assert(k->is_objArray_klass(), "Must be"); 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"); assert(element_klass != NULL, "Must have an element klass");
comp_mirror = element_klass->java_mirror(); comp_mirror = element_klass->java_mirror();
} }
@ -857,7 +857,7 @@ void java_lang_Class::create_mirror(KlassHandle k, Handle class_loader,
// Two-way link between the array klass and its component mirror: // Two-way link between the array klass and its component mirror:
// (array_klass) k -> mirror -> component_mirror -> array_klass -> k // (array_klass) k -> mirror -> component_mirror -> array_klass -> k
set_component_mirror(mirror(), comp_mirror); set_component_mirror(mirror(), comp_mirror);
set_array_klass(comp_mirror, k()); set_array_klass(comp_mirror, k);
} else { } else {
assert(k->is_instance_klass(), "Must be"); assert(k->is_instance_klass(), "Must be");
@ -881,7 +881,7 @@ void java_lang_Class::create_mirror(KlassHandle k, Handle class_loader,
// Setup indirection from klass->mirror last // Setup indirection from klass->mirror last
// after any exceptions can happen during allocations. // after any exceptions can happen during allocations.
if (!k.is_null()) { if (k != NULL) {
k->set_java_mirror(mirror()); k->set_java_mirror(mirror());
} }
} else { } else {
@ -890,11 +890,11 @@ void java_lang_Class::create_mirror(KlassHandle k, Handle class_loader,
new (ResourceObj::C_HEAP, mtClass) GrowableArray<Klass*>(40, true); new (ResourceObj::C_HEAP, mtClass) GrowableArray<Klass*>(40, true);
set_fixup_mirror_list(list); 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"); assert(_module_offset != 0, "must have been computed already");
java_lang_Class::set_module(k->java_mirror(), module()); java_lang_Class::set_module(k->java_mirror(), module());
} }
@ -1876,7 +1876,7 @@ void java_lang_Throwable::print_stack_trace(Handle throwable, outputStream* st)
JavaValue cause(T_OBJECT); JavaValue cause(T_OBJECT);
JavaCalls::call_virtual(&cause, JavaCalls::call_virtual(&cause,
throwable, throwable,
KlassHandle(THREAD, throwable->klass()), throwable->klass(),
vmSymbols::getCause_name(), vmSymbols::getCause_name(),
vmSymbols::void_throwable_signature(), vmSymbols::void_throwable_signature(),
THREAD); THREAD);
@ -1904,7 +1904,7 @@ void java_lang_Throwable::java_printStackTrace(Handle throwable, TRAPS) {
JavaValue result(T_VOID); JavaValue result(T_VOID);
JavaCalls::call_virtual(&result, JavaCalls::call_virtual(&result,
throwable, throwable,
KlassHandle(THREAD, SystemDictionary::Throwable_klass()), SystemDictionary::Throwable_klass(),
vmSymbols::printStackTrace_name(), vmSymbols::printStackTrace_name(),
vmSymbols::void_method_signature(), vmSymbols::void_method_signature(),
THREAD); THREAD);
@ -2153,14 +2153,13 @@ void java_lang_Throwable::get_stack_trace_elements(Handle throwable,
oop java_lang_StackTraceElement::create(const methodHandle& method, int bci, TRAPS) { oop java_lang_StackTraceElement::create(const methodHandle& method, int bci, TRAPS) {
// Allocate java.lang.StackTraceElement instance // Allocate java.lang.StackTraceElement instance
Klass* k = SystemDictionary::StackTraceElement_klass(); InstanceKlass* k = SystemDictionary::StackTraceElement_klass();
assert(k != NULL, "must be loaded in 1.4+"); assert(k != NULL, "must be loaded in 1.4+");
instanceKlassHandle ik (THREAD, k); if (k->should_be_initialized()) {
if (ik->should_be_initialized()) { k->initialize(CHECK_0);
ik->initialize(CHECK_0);
} }
Handle element = ik->allocate_instance_handle(CHECK_0); Handle element = k->allocate_instance_handle(CHECK_0);
int version = method->constants()->version(); int version = method->constants()->version();
fill_in(element, method->method_holder(), method, version, bci, method->name(), CHECK_0); fill_in(element, method->method_holder(), method, version, bci, method->name(), CHECK_0);
@ -2489,10 +2488,10 @@ Handle java_lang_reflect_Constructor::create(TRAPS) {
assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem"); assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
Symbol* name = vmSymbols::java_lang_reflect_Constructor(); Symbol* name = vmSymbols::java_lang_reflect_Constructor();
Klass* k = SystemDictionary::resolve_or_fail(name, true, CHECK_NH); Klass* k = SystemDictionary::resolve_or_fail(name, true, CHECK_NH);
instanceKlassHandle klass (THREAD, k); InstanceKlass* ik = InstanceKlass::cast(k);
// Ensure it is initialized // Ensure it is initialized
klass->initialize(CHECK_NH); ik->initialize(CHECK_NH);
return klass->allocate_instance_handle(THREAD); return ik->allocate_instance_handle(THREAD);
} }
oop java_lang_reflect_Constructor::clazz(oop reflect) { oop java_lang_reflect_Constructor::clazz(oop reflect) {
@ -2629,10 +2628,10 @@ Handle java_lang_reflect_Field::create(TRAPS) {
assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem"); assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
Symbol* name = vmSymbols::java_lang_reflect_Field(); Symbol* name = vmSymbols::java_lang_reflect_Field();
Klass* k = SystemDictionary::resolve_or_fail(name, true, CHECK_NH); Klass* k = SystemDictionary::resolve_or_fail(name, true, CHECK_NH);
instanceKlassHandle klass (THREAD, k); InstanceKlass* ik = InstanceKlass::cast(k);
// Ensure it is initialized // Ensure it is initialized
klass->initialize(CHECK_NH); ik->initialize(CHECK_NH);
return klass->allocate_instance_handle(THREAD); return ik->allocate_instance_handle(THREAD);
} }
oop java_lang_reflect_Field::clazz(oop reflect) { oop java_lang_reflect_Field::clazz(oop reflect) {
@ -2756,10 +2755,10 @@ Handle java_lang_reflect_Parameter::create(TRAPS) {
assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem"); assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
Symbol* name = vmSymbols::java_lang_reflect_Parameter(); Symbol* name = vmSymbols::java_lang_reflect_Parameter();
Klass* k = SystemDictionary::resolve_or_fail(name, true, CHECK_NH); Klass* k = SystemDictionary::resolve_or_fail(name, true, CHECK_NH);
instanceKlassHandle klass (THREAD, k); InstanceKlass* ik = InstanceKlass::cast(k);
// Ensure it is initialized // Ensure it is initialized
klass->initialize(CHECK_NH); ik->initialize(CHECK_NH);
return klass->allocate_instance_handle(THREAD); return ik->allocate_instance_handle(THREAD);
} }
oop java_lang_reflect_Parameter::name(oop param) { oop java_lang_reflect_Parameter::name(oop param) {
@ -2812,11 +2811,10 @@ Handle java_lang_reflect_Module::create(Handle loader, Handle module_name, TRAPS
Symbol* name = vmSymbols::java_lang_reflect_Module(); Symbol* name = vmSymbols::java_lang_reflect_Module();
Klass* k = SystemDictionary::resolve_or_fail(name, true, CHECK_NH); Klass* k = SystemDictionary::resolve_or_fail(name, true, CHECK_NH);
instanceKlassHandle klass (THREAD, k); InstanceKlass* ik = InstanceKlass::cast(k);
Handle jlrmh = ik->allocate_instance_handle(CHECK_NH);
Handle jlrmh = klass->allocate_instance_handle(CHECK_NH);
JavaValue result(T_VOID); JavaValue result(T_VOID);
JavaCalls::call_special(&result, jlrmh, KlassHandle(THREAD, klass()), JavaCalls::call_special(&result, jlrmh, ik,
vmSymbols::object_initializer_name(), vmSymbols::object_initializer_name(),
vmSymbols::java_lang_reflect_module_init_signature(), vmSymbols::java_lang_reflect_module_init_signature(),
loader, module_name, CHECK_NH); loader, module_name, CHECK_NH);
@ -2879,11 +2877,10 @@ void java_lang_reflect_Module::set_module_entry(oop module, ModuleEntry* module_
Handle reflect_ConstantPool::create(TRAPS) { Handle reflect_ConstantPool::create(TRAPS) {
assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem"); assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
Klass* k = SystemDictionary::reflect_ConstantPool_klass(); InstanceKlass* k = SystemDictionary::reflect_ConstantPool_klass();
instanceKlassHandle klass (THREAD, k);
// Ensure it is initialized // Ensure it is initialized
klass->initialize(CHECK_NH); k->initialize(CHECK_NH);
return klass->allocate_instance_handle(THREAD); return k->allocate_instance_handle(THREAD);
} }
@ -2921,9 +2918,9 @@ void reflect_UnsafeStaticFieldAccessorImpl::compute_offsets() {
oop java_lang_boxing_object::initialize_and_allocate(BasicType type, TRAPS) { oop java_lang_boxing_object::initialize_and_allocate(BasicType type, TRAPS) {
Klass* k = SystemDictionary::box_klass(type); Klass* k = SystemDictionary::box_klass(type);
if (k == NULL) return NULL; if (k == NULL) return NULL;
instanceKlassHandle h (THREAD, k); InstanceKlass* ik = InstanceKlass::cast(k);
if (!h->is_initialized()) h->initialize(CHECK_0); if (!ik->is_initialized()) ik->initialize(CHECK_0);
return h->allocate_instance(THREAD); return ik->allocate_instance(THREAD);
} }
@ -3894,10 +3891,10 @@ bool JavaClasses::check_offset(const char *klass_name, int hardcoded_offset, con
fieldDescriptor fd; fieldDescriptor fd;
TempNewSymbol klass_sym = SymbolTable::new_symbol(klass_name, CATCH); TempNewSymbol klass_sym = SymbolTable::new_symbol(klass_name, CATCH);
Klass* k = SystemDictionary::resolve_or_fail(klass_sym, true, 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_name = SymbolTable::new_symbol(field_name, CATCH);
TempNewSymbol f_sig = SymbolTable::new_symbol(field_sig, 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); tty->print_cr("Nonstatic field %s.%s not found", klass_name, field_name);
return false; return false;
} }
@ -3920,10 +3917,10 @@ bool JavaClasses::check_static_offset(const char *klass_name, int hardcoded_offs
fieldDescriptor fd; fieldDescriptor fd;
TempNewSymbol klass_sym = SymbolTable::new_symbol(klass_name, CATCH); TempNewSymbol klass_sym = SymbolTable::new_symbol(klass_name, CATCH);
Klass* k = SystemDictionary::resolve_or_fail(klass_sym, true, 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_name = SymbolTable::new_symbol(field_name, CATCH);
TempNewSymbol f_sig = SymbolTable::new_symbol(field_sig, 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); tty->print_cr("Static field %s.%s not found", klass_name, field_name);
return false; return false;
} }
@ -3945,10 +3942,10 @@ bool JavaClasses::check_constant(const char *klass_name, int hardcoded_constant,
fieldDescriptor fd; fieldDescriptor fd;
TempNewSymbol klass_sym = SymbolTable::new_symbol(klass_name, CATCH); TempNewSymbol klass_sym = SymbolTable::new_symbol(klass_name, CATCH);
Klass* k = SystemDictionary::resolve_or_fail(klass_sym, true, 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_name = SymbolTable::new_symbol(field_name, CATCH);
TempNewSymbol f_sig = SymbolTable::new_symbol(field_sig, 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); tty->print_cr("Static field %s.%s not found", klass_name, field_name);
return false; return false;
} }

View file

@ -209,29 +209,23 @@ class java_lang_Class : AllStatic {
static void set_protection_domain(oop java_class, oop protection_domain); 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_class_loader(oop java_class, oop class_loader);
static void set_component_mirror(oop java_class, oop comp_mirror); 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 initialize_mirror_fields(Klass* k, Handle mirror, Handle protection_domain, TRAPS);
static void set_mirror_module_field(KlassHandle K, Handle mirror, Handle module, TRAPS); static void set_mirror_module_field(Klass* K, Handle mirror, Handle module, TRAPS);
public: public:
static void compute_offsets(); static void compute_offsets();
// Instance creation // 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); 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 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 // Conversion
static Klass* as_Klass(oop java_class); static Klass* as_Klass(oop java_class);
static void set_klass(oop java_class, Klass* klass); 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, 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 Symbol* as_signature(oop java_class, bool intern_if_not_found, TRAPS);
static void print_signature(oop java_class, outputStream *st); static void print_signature(oop java_class, outputStream *st);
static const char* as_external_name(oop java_class); static const char* as_external_name(oop java_class);

View file

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -37,14 +37,14 @@
#include "trace/traceMacros.hpp" #include "trace/traceMacros.hpp"
// called during initial loading of a shared class // called during initial loading of a shared class
instanceKlassHandle KlassFactory::check_shared_class_file_load_hook( InstanceKlass* KlassFactory::check_shared_class_file_load_hook(
instanceKlassHandle ik, InstanceKlass* ik,
Symbol* class_name, Symbol* class_name,
Handle class_loader, Handle class_loader,
Handle protection_domain, TRAPS) { Handle protection_domain, TRAPS) {
#if INCLUDE_CDS && INCLUDE_JVMTI #if INCLUDE_CDS && INCLUDE_JVMTI
assert(ik.not_null(), "sanity"); assert(ik != NULL, "sanity");
assert(ik()->is_shared(), "expecting a shared class"); assert(ik->is_shared(), "expecting a shared class");
if (JvmtiExport::should_post_class_file_load_hook()) { if (JvmtiExport::should_post_class_file_load_hook()) {
assert(THREAD->is_Java_thread(), "must be JavaThread"); assert(THREAD->is_Java_thread(), "must be JavaThread");
@ -84,7 +84,7 @@ instanceKlassHandle KlassFactory::check_shared_class_file_load_hook(
NULL, NULL,
ClassFileParser::BROADCAST, // publicity level ClassFileParser::BROADCAST, // publicity level
CHECK_NULL); CHECK_NULL);
instanceKlassHandle new_ik = parser.create_instance_klass(true /* changed_by_loadhook */, InstanceKlass* new_ik = parser.create_instance_klass(true /* changed_by_loadhook */,
CHECK_NULL); CHECK_NULL);
if (cached_class_file != NULL) { if (cached_class_file != NULL) {
new_ik->set_cached_class_file(cached_class_file); new_ik->set_cached_class_file(cached_class_file);
@ -128,14 +128,11 @@ static ClassFileStream* check_class_file_load_hook(ClassFileStream* stream,
JvmtiThreadState* state = jt->jvmti_thread_state(); JvmtiThreadState* state = jt->jvmti_thread_state();
if (state != NULL) { if (state != NULL) {
KlassHandle* h_class_being_redefined = Klass* k = state->get_class_being_redefined();
state->get_class_being_redefined();
if (h_class_being_redefined != NULL) { if (k != NULL) {
instanceKlassHandle ikh_class_being_redefined = InstanceKlass* class_being_redefined = InstanceKlass::cast(k);
instanceKlassHandle(THREAD, (*h_class_being_redefined)()); *cached_class_file = class_being_redefined->get_cached_class_file();
*cached_class_file = ikh_class_being_redefined->get_cached_class_file();
} }
} }
@ -163,7 +160,7 @@ static ClassFileStream* check_class_file_load_hook(ClassFileStream* stream,
} }
instanceKlassHandle KlassFactory::create_from_stream(ClassFileStream* stream, InstanceKlass* KlassFactory::create_from_stream(ClassFileStream* stream,
Symbol* name, Symbol* name,
ClassLoaderData* loader_data, ClassLoaderData* loader_data,
Handle protection_domain, Handle protection_domain,
@ -200,10 +197,10 @@ instanceKlassHandle KlassFactory::create_from_stream(ClassFileStream* stream,
ClassFileParser::BROADCAST, // publicity level ClassFileParser::BROADCAST, // publicity level
CHECK_NULL); 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"); assert(result == parser.create_instance_klass(old_stream != stream, THREAD), "invariant");
if (result.is_null()) { if (result == NULL) {
return NULL; return NULL;
} }

View file

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -68,7 +68,7 @@ class KlassFactory : AllStatic {
friend class SystemDictionary; friend class SystemDictionary;
private: private:
static instanceKlassHandle create_from_stream(ClassFileStream* stream, static InstanceKlass* create_from_stream(ClassFileStream* stream,
Symbol* name, Symbol* name,
ClassLoaderData* loader_data, ClassLoaderData* loader_data,
Handle protection_domain, Handle protection_domain,
@ -76,8 +76,8 @@ class KlassFactory : AllStatic {
GrowableArray<Handle>* cp_patches, GrowableArray<Handle>* cp_patches,
TRAPS); TRAPS);
public: public:
static instanceKlassHandle check_shared_class_file_load_hook( static InstanceKlass* check_shared_class_file_load_hook(
instanceKlassHandle ik, InstanceKlass* ik,
Symbol* class_name, Symbol* class_name,
Handle class_loader, Handle class_loader,
Handle protection_domain, TRAPS); Handle protection_domain, TRAPS);

View file

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -36,15 +36,15 @@ void LoaderConstraintEntry::set_loader(int i, oop p) {
} }
LoaderConstraintTable::LoaderConstraintTable(int nof_buckets) LoaderConstraintTable::LoaderConstraintTable(int nof_buckets)
: Hashtable<Klass*, mtClass>(nof_buckets, sizeof(LoaderConstraintEntry)) {}; : Hashtable<InstanceKlass*, mtClass>(nof_buckets, sizeof(LoaderConstraintEntry)) {};
LoaderConstraintEntry* LoaderConstraintTable::new_entry( LoaderConstraintEntry* LoaderConstraintTable::new_entry(
unsigned int hash, Symbol* name, unsigned int hash, Symbol* name,
Klass* klass, int num_loaders, InstanceKlass* klass, int num_loaders,
int max_loaders) { int max_loaders) {
LoaderConstraintEntry* entry; 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_name(name);
entry->set_num_loaders(num_loaders); entry->set_num_loaders(num_loaders);
entry->set_max_loaders(max_loaders); entry->set_max_loaders(max_loaders);
@ -54,7 +54,7 @@ LoaderConstraintEntry* LoaderConstraintTable::new_entry(
void LoaderConstraintTable::free_entry(LoaderConstraintEntry *entry) { void LoaderConstraintTable::free_entry(LoaderConstraintEntry *entry) {
// decrement name refcount before freeing // decrement name refcount before freeing
entry->name()->decrement_refcount(); entry->name()->decrement_refcount();
Hashtable<Klass*, mtClass>::free_entry(entry); Hashtable<InstanceKlass*, mtClass>::free_entry(entry);
} }
// Enhanced Class Redefinition support // Enhanced Class Redefinition support
@ -106,7 +106,7 @@ void LoaderConstraintTable::purge_loader_constraints() {
LoaderConstraintEntry** p = bucket_addr(index); LoaderConstraintEntry** p = bucket_addr(index);
while(*p) { while(*p) {
LoaderConstraintEntry* probe = *p; LoaderConstraintEntry* probe = *p;
Klass* klass = probe->klass(); InstanceKlass* klass = probe->klass();
// Remove klass that is no longer alive // Remove klass that is no longer alive
if (klass != NULL && if (klass != NULL &&
klass->class_loader_data()->is_unloading()) { klass->class_loader_data()->is_unloading()) {
@ -186,14 +186,14 @@ void LoaderConstraintTable::purge_loader_constraints() {
} }
bool LoaderConstraintTable::add_entry(Symbol* class_name, bool LoaderConstraintTable::add_entry(Symbol* class_name,
Klass* klass1, Handle class_loader1, InstanceKlass* klass1, Handle class_loader1,
Klass* klass2, Handle class_loader2) { InstanceKlass* klass2, Handle class_loader2) {
int failure_code = 0; // encode different reasons for failing int failure_code = 0; // encode different reasons for failing
if (klass1 != NULL && klass2 != NULL && klass1 != klass2) { if (klass1 != NULL && klass2 != NULL && klass1 != klass2) {
failure_code = 1; failure_code = 1;
} else { } else {
Klass* klass = klass1 != NULL ? klass1 : klass2; InstanceKlass* klass = klass1 != NULL ? klass1 : klass2;
LoaderConstraintEntry** pp1 = find_loader_constraint(class_name, LoaderConstraintEntry** pp1 = find_loader_constraint(class_name,
class_loader1); class_loader1);
@ -295,11 +295,11 @@ bool LoaderConstraintTable::add_entry(Symbol* class_name,
// return true if the constraint was updated, false if the constraint is // return true if the constraint was updated, false if the constraint is
// violated // violated
bool LoaderConstraintTable::check_or_update(instanceKlassHandle k, bool LoaderConstraintTable::check_or_update(InstanceKlass* k,
Handle loader, Handle loader,
Symbol* name) { Symbol* name) {
LoaderConstraintEntry* p = *(find_loader_constraint(name, loader)); 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)) { if (log_is_enabled(Info, class, loader, constraints)) {
ResourceMark rm; ResourceMark rm;
outputStream* out = Log(class, loader, constraints)::info_stream(); outputStream* out = Log(class, loader, constraints)::info_stream();
@ -311,7 +311,7 @@ bool LoaderConstraintTable::check_or_update(instanceKlassHandle k,
return false; return false;
} else { } else {
if (p && p->klass() == NULL) { if (p && p->klass() == NULL) {
p->set_klass(k()); p->set_klass(k);
if (log_is_enabled(Info, class, loader, constraints)) { if (log_is_enabled(Info, class, loader, constraints)) {
ResourceMark rm; ResourceMark rm;
outputStream* out = Log(class, loader, constraints)::info_stream(); outputStream* out = Log(class, loader, constraints)::info_stream();
@ -325,11 +325,12 @@ bool LoaderConstraintTable::check_or_update(instanceKlassHandle k,
} }
} }
Klass* LoaderConstraintTable::find_constrained_klass(Symbol* name, InstanceKlass* LoaderConstraintTable::find_constrained_klass(Symbol* name,
Handle loader) { Handle loader) {
LoaderConstraintEntry *p = *(find_loader_constraint(name, loader)); LoaderConstraintEntry *p = *(find_loader_constraint(name, loader));
if (p != NULL && p->klass() != NULL) { 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 // Only return fully loaded classes. Classes found through the
// constraints might still be in the process of loading. // constraints might still be in the process of loading.
return NULL; return NULL;
@ -357,7 +358,7 @@ void LoaderConstraintTable::ensure_loader_constraint_capacity(
void LoaderConstraintTable::extend_loader_constraint(LoaderConstraintEntry* p, void LoaderConstraintTable::extend_loader_constraint(LoaderConstraintEntry* p,
Handle loader, Handle loader,
Klass* klass) { InstanceKlass* klass) {
ensure_loader_constraint_capacity(p, 1); ensure_loader_constraint_capacity(p, 1);
int num = p->num_loaders(); int num = p->num_loaders();
p->set_loader(num, loader()); p->set_loader(num, loader());
@ -383,7 +384,7 @@ void LoaderConstraintTable::extend_loader_constraint(LoaderConstraintEntry* p,
void LoaderConstraintTable::merge_loader_constraints( void LoaderConstraintTable::merge_loader_constraints(
LoaderConstraintEntry** pp1, LoaderConstraintEntry** pp1,
LoaderConstraintEntry** pp2, LoaderConstraintEntry** pp2,
Klass* klass) { InstanceKlass* klass) {
// make sure *pp1 has higher capacity // make sure *pp1 has higher capacity
if ((*pp1)->max_loaders() < (*pp2)->max_loaders()) { if ((*pp1)->max_loaders() < (*pp2)->max_loaders()) {
LoaderConstraintEntry** tmp = pp2; LoaderConstraintEntry** tmp = pp2;
@ -447,13 +448,13 @@ void LoaderConstraintTable::verify(Dictionary* dictionary,
probe != NULL; probe != NULL;
probe = probe->next()) { probe = probe->next()) {
if (probe->klass() != NULL) { if (probe->klass() != NULL) {
InstanceKlass* ik = InstanceKlass::cast(probe->klass()); InstanceKlass* ik = probe->klass();
guarantee(ik->name() == probe->name(), "name should match"); guarantee(ik->name() == probe->name(), "name should match");
Symbol* name = ik->name(); Symbol* name = ik->name();
ClassLoaderData* loader_data = ik->class_loader_data(); ClassLoaderData* loader_data = ik->class_loader_data();
unsigned int d_hash = dictionary->compute_hash(name, loader_data); unsigned int d_hash = dictionary->compute_hash(name, loader_data);
int d_index = dictionary->hash_to_index(d_hash); 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) { if (k != NULL) {
// We found the class in the system dictionary, so we should // We found the class in the system dictionary, so we should
// make sure that the Klass* matches what we already have. // make sure that the Klass* matches what we already have.

View file

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -32,7 +32,7 @@
class LoaderConstraintEntry; class LoaderConstraintEntry;
class Symbol; class Symbol;
class LoaderConstraintTable : public Hashtable<Klass*, mtClass> { class LoaderConstraintTable : public Hashtable<InstanceKlass*, mtClass> {
friend class VMStructs; friend class VMStructs;
private: private:
@ -49,43 +49,41 @@ public:
LoaderConstraintTable(int nof_buckets); LoaderConstraintTable(int nof_buckets);
LoaderConstraintEntry* new_entry(unsigned int hash, Symbol* name, LoaderConstraintEntry* new_entry(unsigned int hash, Symbol* name,
Klass* klass, int num_loaders, InstanceKlass* klass, int num_loaders,
int max_loaders); int max_loaders);
void free_entry(LoaderConstraintEntry *entry); void free_entry(LoaderConstraintEntry *entry);
LoaderConstraintEntry* bucket(int i) { LoaderConstraintEntry* bucket(int i) {
return (LoaderConstraintEntry*)Hashtable<Klass*, mtClass>::bucket(i); return (LoaderConstraintEntry*)Hashtable<InstanceKlass*, mtClass>::bucket(i);
} }
LoaderConstraintEntry** bucket_addr(int 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 // Enhanced Class Redefinition support
void classes_do(KlassClosure* f); void classes_do(KlassClosure* f);
// Check class loader constraints // Check class loader constraints
bool add_entry(Symbol* name, Klass* klass1, Handle loader1, bool add_entry(Symbol* name, InstanceKlass* klass1, Handle loader1,
Klass* klass2, Handle loader2); InstanceKlass* klass2, Handle loader2);
// Note: The main entry point for this module is via SystemDictionary. // Note: The main entry point for this module is via SystemDictionary.
// SystemDictionary::check_signature_loaders(Symbol* signature, // SystemDictionary::check_signature_loaders(Symbol* signature,
// Handle loader1, Handle loader2, // Handle loader1, Handle loader2,
// bool is_method, TRAPS) // bool is_method, TRAPS)
Klass* find_constrained_klass(Symbol* name, Handle loader); InstanceKlass* find_constrained_klass(Symbol* name, Handle loader);
// Class loader constraints // Class loader constraints
void ensure_loader_constraint_capacity(LoaderConstraintEntry *p, int nfree); void ensure_loader_constraint_capacity(LoaderConstraintEntry *p, int nfree);
void extend_loader_constraint(LoaderConstraintEntry* p, Handle loader, void extend_loader_constraint(LoaderConstraintEntry* p, Handle loader,
Klass* klass); InstanceKlass* klass);
void merge_loader_constraints(LoaderConstraintEntry** pp1, 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(); void purge_loader_constraints();
@ -95,7 +93,7 @@ public:
#endif #endif
}; };
class LoaderConstraintEntry : public HashtableEntry<Klass*, mtClass> { class LoaderConstraintEntry : public HashtableEntry<InstanceKlass*, mtClass> {
friend class VMStructs; friend class VMStructs;
private: private:
Symbol* _name; // class name Symbol* _name; // class name
@ -108,19 +106,19 @@ private:
public: public:
Klass* klass() { return literal(); } InstanceKlass* klass() { return literal(); }
Klass** klass_addr() { return literal_addr(); } InstanceKlass** klass_addr() { return literal_addr(); }
void set_klass(Klass* k) { set_literal(k); } void set_klass(InstanceKlass* k) { set_literal(k); }
LoaderConstraintEntry* next() { LoaderConstraintEntry* next() {
return (LoaderConstraintEntry*)HashtableEntry<Klass*, mtClass>::next(); return (LoaderConstraintEntry*)HashtableEntry<InstanceKlass*, mtClass>::next();
} }
LoaderConstraintEntry** next_addr() { LoaderConstraintEntry** next_addr() {
return (LoaderConstraintEntry**)HashtableEntry<Klass*, mtClass>::next_addr(); return (LoaderConstraintEntry**)HashtableEntry<InstanceKlass*, mtClass>::next_addr();
} }
void set_next(LoaderConstraintEntry* next) { void set_next(LoaderConstraintEntry* next) {
HashtableEntry<Klass*, mtClass>::set_next(next); HashtableEntry<InstanceKlass*, mtClass>::set_next(next);
} }
Symbol* name() { return _name; } Symbol* name() { return _name; }

View file

@ -428,7 +428,7 @@ void ModuleEntryTable::patch_javabase_entries(Handle module_handle) {
for (int i = 0; i < list_length; i++) { for (int i = 0; i < list_length; i++) {
Klass* k = list->at(i); Klass* k = list->at(i);
assert(k->is_klass(), "List should only hold classes"); 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(); k->class_loader_data()->dec_keep_alive();
} }

View file

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -163,7 +163,7 @@ class PlaceholderEntry : public HashtableEntry<Symbol*, mtClass> {
bool _havesupername; // distinguish between null supername, and unknown bool _havesupername; // distinguish between null supername, and unknown
Symbol* _supername; Symbol* _supername;
Thread* _definer; // owner of define token 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* _superThreadQ; // doubly-linked queue of Threads loading a superclass for this class
SeenThread* _loadInstanceThreadQ; // loadInstance thread SeenThread* _loadInstanceThreadQ; // loadInstance thread
// can be multiple threads if classloader object lock broken by application // can be multiple threads if classloader object lock broken by application
@ -193,8 +193,8 @@ class PlaceholderEntry : public HashtableEntry<Symbol*, mtClass> {
Thread* definer() const {return _definer; } Thread* definer() const {return _definer; }
void set_definer(Thread* definer) { _definer = definer; } void set_definer(Thread* definer) { _definer = definer; }
Klass* instance_klass() const {return _instanceKlass; } InstanceKlass* instance_klass() const {return _instanceKlass; }
void set_instance_klass(Klass* ik) { _instanceKlass = ik; } void set_instance_klass(InstanceKlass* ik) { _instanceKlass = ik; }
SeenThread* superThreadQ() const { return _superThreadQ; } SeenThread* superThreadQ() const { return _superThreadQ; }
void set_superThreadQ(SeenThread* SeenThread) { _superThreadQ = SeenThread; } void set_superThreadQ(SeenThread* SeenThread) { _superThreadQ = SeenThread; }

View file

@ -120,10 +120,10 @@ oop SystemDictionary::java_system_loader() {
} }
void SystemDictionary::compute_java_system_loader(TRAPS) { 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); JavaValue result(T_OBJECT);
JavaCalls::call_static(&result, JavaCalls::call_static(&result,
KlassHandle(THREAD, WK_KLASS(ClassLoader_klass)), WK_KLASS(ClassLoader_klass),
vmSymbols::getSystemClassLoader_name(), vmSymbols::getSystemClassLoader_name(),
vmSymbols::void_classloader_signature(), vmSymbols::void_classloader_signature(),
CHECK); CHECK);
@ -184,16 +184,15 @@ bool SystemDictionary::is_platform_class_loader(oop class_loader) {
Klass* SystemDictionary::resolve_or_fail(Symbol* class_name, Handle class_loader, Handle protection_domain, bool throw_error, TRAPS) { 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); Klass* klass = resolve_or_null(class_name, class_loader, protection_domain, THREAD);
if (HAS_PENDING_EXCEPTION || klass == NULL) { if (HAS_PENDING_EXCEPTION || klass == NULL) {
KlassHandle k_h(THREAD, klass);
// can return a null 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; return klass;
} }
Klass* SystemDictionary::handle_resolution_exception(Symbol* class_name, Klass* SystemDictionary::handle_resolution_exception(Symbol* class_name,
bool throw_error, bool throw_error,
KlassHandle klass_h, TRAPS) { Klass* klass, TRAPS) {
if (HAS_PENDING_EXCEPTION) { if (HAS_PENDING_EXCEPTION) {
// If we have a pending exception we forward it to the caller, unless throw_error is true, // 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, // in which case we have to check whether the pending exception is a ClassNotFoundException,
@ -201,7 +200,7 @@ Klass* SystemDictionary::handle_resolution_exception(Symbol* class_name,
// And chain the original ClassNotFoundException // And chain the original ClassNotFoundException
if (throw_error && PENDING_EXCEPTION->is_a(SystemDictionary::ClassNotFoundException_klass())) { if (throw_error && PENDING_EXCEPTION->is_a(SystemDictionary::ClassNotFoundException_klass())) {
ResourceMark rm(THREAD); 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); Handle e(THREAD, PENDING_EXCEPTION);
CLEAR_PENDING_EXCEPTION; CLEAR_PENDING_EXCEPTION;
THROW_MSG_CAUSE_NULL(vmSymbols::java_lang_NoClassDefFoundError(), class_name->as_C_string(), e); THROW_MSG_CAUSE_NULL(vmSymbols::java_lang_NoClassDefFoundError(), class_name->as_C_string(), e);
@ -210,7 +209,7 @@ Klass* SystemDictionary::handle_resolution_exception(Symbol* class_name,
} }
} }
// Class not found, throw appropriate error or exception depending on value of throw_error // Class not found, throw appropriate error or exception depending on value of throw_error
if (klass_h() == NULL) { if (klass == NULL) {
ResourceMark rm(THREAD); ResourceMark rm(THREAD);
if (throw_error) { if (throw_error) {
THROW_MSG_NULL(vmSymbols::java_lang_NoClassDefFoundError(), class_name->as_C_string()); THROW_MSG_NULL(vmSymbols::java_lang_NoClassDefFoundError(), class_name->as_C_string());
@ -218,7 +217,7 @@ Klass* SystemDictionary::handle_resolution_exception(Symbol* class_name,
THROW_MSG_NULL(vmSymbols::java_lang_ClassNotFoundException(), class_name->as_C_string()); THROW_MSG_NULL(vmSymbols::java_lang_ClassNotFoundException(), class_name->as_C_string());
} }
} }
return (Klass*)klass_h(); return klass;
} }
@ -402,8 +401,6 @@ Klass* SystemDictionary::resolve_super_or_fail(Symbol* child_name,
protection_domain, protection_domain,
THREAD); THREAD);
KlassHandle superk_h(THREAD, superk);
// Clean up of placeholders moved so that each classloadAction registrar self-cleans up // 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 // It is no longer necessary to keep the placeholder table alive until update_dictionary
// or error. GC used to walk the placeholder table as strong roots. // or error. GC used to walk the placeholder table as strong roots.
@ -415,15 +412,15 @@ Klass* SystemDictionary::resolve_super_or_fail(Symbol* child_name,
placeholders()->find_and_remove(p_index, p_hash, child_name, loader_data, PlaceholderTable::LOAD_SUPER, THREAD); placeholders()->find_and_remove(p_index, p_hash, child_name, loader_data, PlaceholderTable::LOAD_SUPER, THREAD);
SystemDictionary_lock->notify_all(); SystemDictionary_lock->notify_all();
} }
if (HAS_PENDING_EXCEPTION || superk_h() == NULL) { if (HAS_PENDING_EXCEPTION || superk == NULL) {
// can null superk // 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 class_loader,
Handle protection_domain, Handle protection_domain,
TRAPS) { TRAPS) {
@ -438,11 +435,11 @@ void SystemDictionary::validate_protection_domain(instanceKlassHandle klass,
log->print_cr("Checking package access"); log->print_cr("Checking package access");
log->print("class loader: "); class_loader()->print_value_on(log); log->print("class loader: "); class_loader()->print_value_on(log);
log->print(" protection domain: "); protection_domain()->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(); log->cr();
} }
KlassHandle system_loader(THREAD, SystemDictionary::ClassLoader_klass()); InstanceKlass* system_loader = SystemDictionary::ClassLoader_klass();
JavaCalls::call_special(&result, JavaCalls::call_special(&result,
class_loader, class_loader,
system_loader, system_loader,
@ -540,11 +537,10 @@ void SystemDictionary::double_lock_wait(Handle lockObject, TRAPS) {
// Returns non-null Klass* if other thread has completed load // Returns non-null Klass* if other thread has completed load
// and we are done, // and we are done,
// If return null Klass* and no pending exception, the caller must load the class // 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, Symbol* name, Symbol* superclassname, Handle class_loader,
Handle protection_domain, Handle lockObject, TRAPS) { Handle protection_domain, Handle lockObject, TRAPS) {
instanceKlassHandle nh = instanceKlassHandle(); // null Handle
ClassLoaderData* loader_data = class_loader_data(class_loader); ClassLoaderData* loader_data = class_loader_data(class_loader);
unsigned int d_hash = dictionary()->compute_hash(name, loader_data); unsigned int d_hash = dictionary()->compute_hash(name, loader_data);
int d_index = dictionary()->hash_to_index(d_hash); int d_index = dictionary()->hash_to_index(d_hash);
@ -564,20 +560,14 @@ instanceKlassHandle SystemDictionary::handle_parallel_super_load(
class_loader, class_loader,
protection_domain, protection_domain,
true, true,
CHECK_(nh)); CHECK_NULL);
// parallelCapable class loaders do NOT wait for parallel superclass loads to complete // parallelCapable class loaders do NOT wait for parallel superclass loads to complete
// Serial class loaders and bootstrap classloader do wait for superclass loads // Serial class loaders and bootstrap classloader do wait for superclass loads
if (!class_loader.is_null() && is_parallelCapable(class_loader)) { if (!class_loader.is_null() && is_parallelCapable(class_loader)) {
MutexLocker mu(SystemDictionary_lock, THREAD); MutexLocker mu(SystemDictionary_lock, THREAD);
// Check if classloading completed while we were loading superclass or waiting // Check if classloading completed while we were loading superclass or waiting
Klass* check = find_class(d_index, d_hash, name, loader_data); return 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;
}
} }
// must loop to both handle other placeholder updates // must loop to both handle other placeholder updates
@ -587,10 +577,10 @@ instanceKlassHandle SystemDictionary::handle_parallel_super_load(
while (super_load_in_progress) { while (super_load_in_progress) {
MutexLocker mu(SystemDictionary_lock, THREAD); MutexLocker mu(SystemDictionary_lock, THREAD);
// Check if classloading completed while we were loading superclass or waiting // 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) { if (check != NULL) {
// Klass is already loaded, so just return it // Klass is already loaded, so just return it
return(instanceKlassHandle(THREAD, check)); return check;
} else { } else {
placeholder = placeholders()->get_entry(p_index, p_hash, name, loader_data); placeholder = placeholders()->get_entry(p_index, p_hash, name, loader_data);
if (placeholder && placeholder->super_load_in_progress() ){ if (placeholder && placeholder->super_load_in_progress() ){
@ -619,17 +609,17 @@ instanceKlassHandle SystemDictionary::handle_parallel_super_load(
} }
} }
} }
return (nh); return NULL;
} }
static void post_class_load_event(const Ticks& start_time, static void post_class_load_event(const Ticks& start_time,
instanceKlassHandle k, InstanceKlass* k,
const ClassLoaderData* init_cld) { const ClassLoaderData* init_cld) {
#if INCLUDE_TRACE #if INCLUDE_TRACE
EventClassLoad event(UNTIMED); EventClassLoad event(UNTIMED);
if (event.should_commit()) { if (event.should_commit()) {
event.set_starttime(start_time); event.set_starttime(start_time);
event.set_loadedClass(k()); event.set_loadedClass(k);
event.set_definingClassLoader(k->class_loader_data()); event.set_definingClassLoader(k->class_loader_data());
event.set_initiatingClassLoader(init_cld); event.set_initiatingClassLoader(init_cld);
event.commit(); event.commit();
@ -637,12 +627,12 @@ static void post_class_load_event(const Ticks& start_time,
#endif // INCLUDE_TRACE #endif // INCLUDE_TRACE
} }
static void class_define_event(instanceKlassHandle k, static void class_define_event(InstanceKlass* k,
const ClassLoaderData* def_cld) { const ClassLoaderData* def_cld) {
#if INCLUDE_TRACE #if INCLUDE_TRACE
EventClassDefine event; EventClassDefine event;
if (event.should_commit()) { if (event.should_commit()) {
event.set_definedClass(k()); event.set_definedClass(k);
event.set_definingClassLoader(def_cld); event.set_definingClassLoader(def_cld);
event.commit(); event.commit();
} }
@ -708,17 +698,17 @@ Klass* SystemDictionary::resolve_instance_class_or_null(Symbol* name,
bool class_has_been_loaded = false; bool class_has_been_loaded = false;
bool super_load_in_progress = false; bool super_load_in_progress = false;
bool havesupername = false; bool havesupername = false;
instanceKlassHandle k; InstanceKlass* k = NULL;
PlaceholderEntry* placeholder; PlaceholderEntry* placeholder;
Symbol* superclassname = NULL; Symbol* superclassname = NULL;
{ {
MutexLocker mu(SystemDictionary_lock, THREAD); 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) { if (check != NULL) {
// Klass is already loaded, so just return it // Klass is already loaded, so just return it
class_has_been_loaded = true; class_has_been_loaded = true;
k = instanceKlassHandle(THREAD, check); k = check;
} else { } else {
placeholder = placeholders()->get_entry(p_index, p_hash, name, loader_data); placeholder = placeholders()->get_entry(p_index, p_hash, name, loader_data);
if (placeholder && placeholder->super_load_in_progress()) { if (placeholder && placeholder->super_load_in_progress()) {
@ -733,12 +723,15 @@ Klass* SystemDictionary::resolve_instance_class_or_null(Symbol* name,
// If the class is in the placeholder table, class loading is in progress // If the class is in the placeholder table, class loading is in progress
if (super_load_in_progress && havesupername==true) { if (super_load_in_progress && havesupername==true) {
k = SystemDictionary::handle_parallel_super_load(name, superclassname, k = handle_parallel_super_load(name,
class_loader, protection_domain, lockObject, THREAD); superclassname,
class_loader,
protection_domain,
lockObject, THREAD);
if (HAS_PENDING_EXCEPTION) { if (HAS_PENDING_EXCEPTION) {
return NULL; return NULL;
} }
if (!k.is_null()) { if (k != NULL) {
class_has_been_loaded = true; class_has_been_loaded = true;
} }
} }
@ -795,10 +788,10 @@ Klass* SystemDictionary::resolve_instance_class_or_null(Symbol* name,
double_lock_wait(lockObject, THREAD); double_lock_wait(lockObject, THREAD);
} }
// Check if classloading completed while we were waiting // 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) { if (check != NULL) {
// Klass is already loaded, so just return it // Klass is already loaded, so just return it
k = instanceKlassHandle(THREAD, check); k = check;
class_has_been_loaded = true; class_has_been_loaded = true;
} }
// check if other thread failed to load and cleaned up // check if other thread failed to load and cleaned up
@ -820,10 +813,10 @@ Klass* SystemDictionary::resolve_instance_class_or_null(Symbol* name,
// i.e. now that we hold the LOAD_INSTANCE token on loading this class/CL // i.e. now that we hold the LOAD_INSTANCE token on loading this class/CL
// one final check if the load has already completed // one final check if the load has already completed
// class loaders holding the ObjectLock shouldn't find the class here // 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) { if (check != NULL) {
// Klass is already loaded, so return it after checking/adding protection domain // Klass is already loaded, so return it after checking/adding protection domain
k = instanceKlassHandle(THREAD, check); k = check;
class_has_been_loaded = true; class_has_been_loaded = true;
} }
} }
@ -850,13 +843,13 @@ Klass* SystemDictionary::resolve_instance_class_or_null(Symbol* name,
// with the new cleaner mechanism, even with AllowParallelDefineClass // with the new cleaner mechanism, even with AllowParallelDefineClass
// Bootstrap goes through here to allow for an extra guarantee check // Bootstrap goes through here to allow for an extra guarantee check
if (UnsyncloadClass || (class_loader.is_null())) { 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())) { && PENDING_EXCEPTION->is_a(SystemDictionary::LinkageError_klass())) {
MutexLocker mu(SystemDictionary_lock, THREAD); 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) { if (check != NULL) {
// Klass is already loaded, so just use it // Klass is already loaded, so just use it
k = instanceKlassHandle(THREAD, check); k = check;
CLEAR_PENDING_EXCEPTION; CLEAR_PENDING_EXCEPTION;
guarantee((!class_loader.is_null()), "dup definition for bootstrap loader?"); guarantee((!class_loader.is_null()), "dup definition for bootstrap loader?");
} }
@ -865,7 +858,7 @@ Klass* SystemDictionary::resolve_instance_class_or_null(Symbol* name,
// If everything was OK (no exceptions, no null return value), and // If everything was OK (no exceptions, no null return value), and
// class_loader is NOT the defining loader, do a little more bookkeeping. // 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()) { k->class_loader() != class_loader()) {
check_constraints(d_index, d_hash, k, class_loader, false, THREAD); check_constraints(d_index, d_hash, k, class_loader, false, THREAD);
@ -883,7 +876,7 @@ Klass* SystemDictionary::resolve_instance_class_or_null(Symbol* name,
if (JvmtiExport::should_post_class_load()) { if (JvmtiExport::should_post_class_load()) {
Thread *thread = THREAD; Thread *thread = THREAD;
assert(thread->is_Java_thread(), "thread->is_Java_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 @@ Klass* SystemDictionary::resolve_instance_class_or_null(Symbol* name,
} }
} }
if (HAS_PENDING_EXCEPTION || k.is_null()) { if (HAS_PENDING_EXCEPTION || k == NULL) {
return NULL; return NULL;
} }
@ -910,12 +903,12 @@ Klass* SystemDictionary::resolve_instance_class_or_null(Symbol* name,
ClassLoaderData* loader_data = k->class_loader_data(); ClassLoaderData* loader_data = k->class_loader_data();
MutexLocker mu(SystemDictionary_lock, THREAD); MutexLocker mu(SystemDictionary_lock, THREAD);
Klass* kk = find_class(name, loader_data); Klass* kk = find_class(name, loader_data);
assert(kk == k(), "should be present in dictionary"); assert(kk == k, "should be present in dictionary");
} }
#endif #endif
// return if the protection domain in NULL // 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 // Check the protection domain has the right access
{ {
@ -930,14 +923,14 @@ Klass* SystemDictionary::resolve_instance_class_or_null(Symbol* name,
if (dictionary()->is_valid_protection_domain(d_index, d_hash, name, if (dictionary()->is_valid_protection_domain(d_index, d_hash, name,
loader_data, loader_data,
protection_domain)) { protection_domain)) {
return k(); return k;
} }
} }
// Verify protection domain. If it fails an exception is thrown // Verify protection domain. If it fails an exception is thrown
validate_protection_domain(k, class_loader, protection_domain, CHECK_NULL); validate_protection_domain(k, class_loader, protection_domain, CHECK_NULL);
return k(); return k;
} }
@ -1019,7 +1012,7 @@ Klass* SystemDictionary::find_instance_or_array_klass(Symbol* class_name,
// does not publish the classes via the SystemDictionary. // does not publish the classes via the SystemDictionary.
// Handles unsafe_DefineAnonymousClass and redefineclasses // Handles unsafe_DefineAnonymousClass and redefineclasses
// RedefinedClasses do not add to the class hierarchy // RedefinedClasses do not add to the class hierarchy
Klass* SystemDictionary::parse_stream(Symbol* class_name, InstanceKlass* SystemDictionary::parse_stream(Symbol* class_name,
Handle class_loader, Handle class_loader,
Handle protection_domain, Handle protection_domain,
ClassFileStream* st, ClassFileStream* st,
@ -1049,7 +1042,7 @@ Klass* SystemDictionary::parse_stream(Symbol* class_name,
// already be present in the SystemDictionary, otherwise we would not // already be present in the SystemDictionary, otherwise we would not
// throw potential ClassFormatErrors. // throw potential ClassFormatErrors.
instanceKlassHandle k = KlassFactory::create_from_stream(st, InstanceKlass* k = KlassFactory::create_from_stream(st,
class_name, class_name,
loader_data, loader_data,
protection_domain, protection_domain,
@ -1057,7 +1050,7 @@ Klass* SystemDictionary::parse_stream(Symbol* class_name,
cp_patches, cp_patches,
CHECK_NULL); CHECK_NULL);
if (host_klass != NULL && k.not_null()) { if (host_klass != NULL && k != NULL) {
// If it's anonymous, initialize it now, since nobody else will. // If it's anonymous, initialize it now, since nobody else will.
{ {
@ -1083,7 +1076,7 @@ Klass* SystemDictionary::parse_stream(Symbol* class_name,
// notify jvmti // notify jvmti
if (JvmtiExport::should_post_class_load()) { if (JvmtiExport::should_post_class_load()) {
assert(THREAD->is_Java_thread(), "thread->is_Java_thread()"); 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); post_class_load_event(class_load_start_time, k, loader_data);
@ -1091,7 +1084,7 @@ Klass* SystemDictionary::parse_stream(Symbol* class_name,
assert(host_klass != NULL || NULL == cp_patches, assert(host_klass != NULL || NULL == cp_patches,
"cp_patches only found with host_klass"); "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 // Add a klass to the system from a stream (called by jni_DefineClass and
@ -1099,7 +1092,7 @@ Klass* SystemDictionary::parse_stream(Symbol* class_name,
// Note: class_name can be NULL. In that case we do not know the name of // Note: class_name can be NULL. In that case we do not know the name of
// the class until we have parsed the stream. // the class until we have parsed the stream.
Klass* SystemDictionary::resolve_from_stream(Symbol* class_name, InstanceKlass* SystemDictionary::resolve_from_stream(Symbol* class_name,
Handle class_loader, Handle class_loader,
Handle protection_domain, Handle protection_domain,
ClassFileStream* st, ClassFileStream* st,
@ -1127,9 +1120,7 @@ Klass* SystemDictionary::resolve_from_stream(Symbol* class_name,
// Note that we do this even though this klass might // Note that we do this even though this klass might
// already be present in the SystemDictionary, otherwise we would not // already be present in the SystemDictionary, otherwise we would not
// throw potential ClassFormatErrors. // throw potential ClassFormatErrors.
// InstanceKlass* k = NULL;
instanceKlassHandle k;
#if INCLUDE_CDS #if INCLUDE_CDS
k = SystemDictionaryShared::lookup_from_stream(class_name, k = SystemDictionaryShared::lookup_from_stream(class_name,
@ -1139,7 +1130,7 @@ Klass* SystemDictionary::resolve_from_stream(Symbol* class_name,
CHECK_NULL); CHECK_NULL);
#endif #endif
if (k.is_null()) { if (k == NULL) {
if (st->buffer() == NULL) { if (st->buffer() == NULL) {
return NULL; return NULL;
} }
@ -1152,7 +1143,7 @@ Klass* SystemDictionary::resolve_from_stream(Symbol* class_name,
CHECK_NULL); CHECK_NULL);
} }
assert(k.not_null(), "no klass created"); assert(k != NULL, "no klass created");
Symbol* h_name = k->name(); Symbol* h_name = k->name();
assert(class_name == NULL || class_name == h_name, "name mismatch"); assert(class_name == NULL || class_name == h_name, "name mismatch");
@ -1160,11 +1151,11 @@ Klass* SystemDictionary::resolve_from_stream(Symbol* class_name,
// If a class loader supports parallel classloading handle parallel define requests // If a class loader supports parallel classloading handle parallel define requests
// find_or_define_instance_class may return a different InstanceKlass // find_or_define_instance_class may return a different InstanceKlass
if (is_parallelCapable(class_loader)) { if (is_parallelCapable(class_loader)) {
instanceKlassHandle defined_k = find_or_define_instance_class(h_name, class_loader, k, THREAD); InstanceKlass* defined_k = find_or_define_instance_class(h_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. // 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"); assert(defined_k != NULL, "Should have a klass if there's no exception");
loader_data->add_to_deallocate_list(k()); loader_data->add_to_deallocate_list(k);
k = defined_k; k = defined_k;
} }
} else { } else {
@ -1173,8 +1164,8 @@ Klass* SystemDictionary::resolve_from_stream(Symbol* class_name,
// If defining the class throws an exception register 'k' for cleanup. // If defining the class throws an exception register 'k' for cleanup.
if (HAS_PENDING_EXCEPTION) { if (HAS_PENDING_EXCEPTION) {
assert(k.not_null(), "Must have an instance klass here!"); assert(k != NULL, "Must have an instance klass here!");
loader_data->add_to_deallocate_list(k()); loader_data->add_to_deallocate_list(k);
return NULL; return NULL;
} }
@ -1183,10 +1174,10 @@ Klass* SystemDictionary::resolve_from_stream(Symbol* class_name,
MutexLocker mu(SystemDictionary_lock, THREAD); MutexLocker mu(SystemDictionary_lock, THREAD);
Klass* check = find_class(h_name, k->class_loader_data()); 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 #if INCLUDE_CDS
@ -1201,7 +1192,7 @@ void SystemDictionary::set_shared_dictionary(HashtableBucket<mtClass>* t, int le
// If there is a shared dictionary, then find the entry for the // If there is a shared dictionary, then find the entry for the
// given shared system class, if any. // 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) { if (shared_dictionary() != NULL) {
unsigned int d_hash = shared_dictionary()->compute_hash(class_name, NULL); unsigned int d_hash = shared_dictionary()->compute_hash(class_name, NULL);
int d_index = shared_dictionary()->hash_to_index(d_hash); int d_index = shared_dictionary()->hash_to_index(d_hash);
@ -1219,16 +1210,16 @@ Klass* SystemDictionary::find_shared_class(Symbol* class_name) {
// subclasses (yet). [Classes in the shared space are not part of the // subclasses (yet). [Classes in the shared space are not part of the
// object hierarchy until loaded.] // object hierarchy until loaded.]
instanceKlassHandle SystemDictionary::load_shared_class( InstanceKlass* SystemDictionary::load_shared_class(
Symbol* class_name, Handle class_loader, TRAPS) { 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. // 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()) { ik->is_shared_boot_class() && class_loader.is_null()) {
Handle protection_domain; Handle protection_domain;
return load_shared_class(ik, class_loader, protection_domain, THREAD); 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: // Check if a shared class can be loaded by the specific classloader:
@ -1238,7 +1229,7 @@ instanceKlassHandle SystemDictionary::load_shared_class(
// - Class from -Xbootclasspath/a. The class has no defined PackageEntry, or must // - Class from -Xbootclasspath/a. The class has no defined PackageEntry, or must
// be defined in an unnamed module. // be defined in an unnamed module.
bool SystemDictionary::is_shared_class_visible(Symbol* class_name, bool SystemDictionary::is_shared_class_visible(Symbol* class_name,
instanceKlassHandle ik, InstanceKlass* ik,
Handle class_loader, TRAPS) { Handle class_loader, TRAPS) {
assert(!ModuleEntryTable::javabase_moduleEntry()->is_patched(), assert(!ModuleEntryTable::javabase_moduleEntry()->is_patched(),
"Cannot use sharing if java.base is patched"); "Cannot use sharing if java.base is patched");
@ -1315,18 +1306,17 @@ bool SystemDictionary::is_shared_class_visible(Symbol* class_name,
} }
} }
instanceKlassHandle SystemDictionary::load_shared_class(instanceKlassHandle ik, InstanceKlass* SystemDictionary::load_shared_class(InstanceKlass* ik,
Handle class_loader, Handle class_loader,
Handle protection_domain, TRAPS) { Handle protection_domain, TRAPS) {
instanceKlassHandle nh = instanceKlassHandle(); // null Handle
if (ik.not_null()) { if (ik != NULL) {
Symbol* class_name = ik->name(); Symbol* class_name = ik->name();
bool visible = is_shared_class_visible( bool visible = is_shared_class_visible(
class_name, ik, class_loader, CHECK_(nh)); class_name, ik, class_loader, CHECK_NULL);
if (!visible) { if (!visible) {
return nh; return NULL;
} }
// Resolve the superclass and interfaces. They must be the same // Resolve the superclass and interfaces. They must be the same
@ -1339,11 +1329,11 @@ instanceKlassHandle SystemDictionary::load_shared_class(instanceKlassHandle ik,
if (ik->super() != NULL) { if (ik->super() != NULL) {
Symbol* cn = ik->super()->name(); Symbol* cn = ik->super()->name();
Klass *s = resolve_super_or_fail(class_name, cn, 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()) { if (s != ik->super()) {
// The dynamically resolved super class is not the same as the one we used during dump time, // The dynamically resolved super class is not the same as the one we used during dump time,
// so we cannot use ik. // so we cannot use ik.
return nh; return NULL;
} else { } else {
assert(s->is_shared(), "must be"); assert(s->is_shared(), "must be");
} }
@ -1354,19 +1344,19 @@ instanceKlassHandle SystemDictionary::load_shared_class(instanceKlassHandle ik,
for (int index = 0; index < num_interfaces; index++) { for (int index = 0; index < num_interfaces; index++) {
Klass* k = interfaces->at(index); Klass* k = interfaces->at(index);
Symbol* name = k->name(); 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) { if (k != i) {
// The dynamically resolved interface class is not the same as the one we used during dump time, // The dynamically resolved interface class is not the same as the one we used during dump time,
// so we cannot use ik. // so we cannot use ik.
return nh; return NULL;
} else { } else {
assert(i->is_shared(), "must be"); assert(i->is_shared(), "must be");
} }
} }
instanceKlassHandle new_ik = KlassFactory::check_shared_class_file_load_hook( InstanceKlass* new_ik = KlassFactory::check_shared_class_file_load_hook(
ik, class_name, class_loader, protection_domain, CHECK_(nh)); ik, class_name, class_loader, protection_domain, CHECK_NULL);
if (new_ik.not_null()) { if (new_ik != NULL) {
// The class is changed by CFLH. Return the new class. The shared class is // The class is changed by CFLH. Return the new class. The shared class is
// not used. // not used.
return new_ik; return new_ik;
@ -1391,16 +1381,16 @@ instanceKlassHandle SystemDictionary::load_shared_class(instanceKlassHandle ik,
ObjectLocker ol(lockObject, THREAD, true); ObjectLocker ol(lockObject, THREAD, true);
// prohibited package check assumes all classes loaded from archive call // prohibited package check assumes all classes loaded from archive call
// restore_unshareable_info which calls ik->set_package() // 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)) { 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 // No 'else' here as logging levels are not mutually exclusive
if (log_is_enabled(Debug, class, load)) { 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 // For boot loader, ensure that GetSystemPackage knows that a class in this
@ -1421,12 +1411,12 @@ instanceKlassHandle SystemDictionary::load_shared_class(instanceKlassHandle ik,
} }
// notify a class loaded from shared object // 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); ik->set_has_passed_fingerprint_check(false);
if (UseAOT && ik->supers_have_passed_fingerprint_checks()) { 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(); uint64_t cds_fp = ik->get_stored_fingerprint();
if (aot_fp != 0 && aot_fp == cds_fp) { if (aot_fp != 0 && aot_fp == cds_fp) {
// This class matches with a class saved in an AOT library // This class matches with a class saved in an AOT library
@ -1440,8 +1430,7 @@ instanceKlassHandle SystemDictionary::load_shared_class(instanceKlassHandle ik,
} }
#endif // INCLUDE_CDS #endif // INCLUDE_CDS
instanceKlassHandle SystemDictionary::load_instance_class(Symbol* class_name, Handle class_loader, TRAPS) { InstanceKlass* SystemDictionary::load_instance_class(Symbol* class_name, Handle class_loader, TRAPS) {
instanceKlassHandle nh = instanceKlassHandle(); // null Handle
if (class_loader.is_null()) { if (class_loader.is_null()) {
ResourceMark rm; ResourceMark rm;
@ -1473,14 +1462,14 @@ instanceKlassHandle SystemDictionary::load_instance_class(Symbol* class_name, Ha
// and its package will be checked later by // and its package will be checked later by
// ModuleEntryTable::verify_javabase_packages. // ModuleEntryTable::verify_javabase_packages.
if (ModuleEntryTable::javabase_defined()) { if (ModuleEntryTable::javabase_defined()) {
return nh; return NULL;
} }
} else { } else {
// Check that the class' package is defined within java.base. // Check that the class' package is defined within java.base.
ModuleEntry* mod_entry = pkg_entry->module(); ModuleEntry* mod_entry = pkg_entry->module();
Symbol* mod_entry_name = mod_entry->name(); Symbol* mod_entry_name = mod_entry->name();
if (mod_entry_name->fast_compare(vmSymbols::java_base()) != 0) { if (mod_entry_name->fast_compare(vmSymbols::java_base()) != 0) {
return nh; return NULL;
} }
} }
} }
@ -1506,7 +1495,7 @@ instanceKlassHandle SystemDictionary::load_instance_class(Symbol* class_name, Ha
// Search the shared system dictionary for classes preloaded into the // Search the shared system dictionary for classes preloaded into the
// shared spaces. // shared spaces.
instanceKlassHandle k; InstanceKlass* k = NULL;
{ {
#if INCLUDE_CDS #if INCLUDE_CDS
PerfTraceTime vmtimer(ClassLoader::perf_shared_classload_time()); PerfTraceTime vmtimer(ClassLoader::perf_shared_classload_time());
@ -1514,24 +1503,24 @@ instanceKlassHandle SystemDictionary::load_instance_class(Symbol* class_name, Ha
#endif #endif
} }
if (k.is_null()) { if (k == NULL) {
// Use VM class loader // Use VM class loader
PerfTraceTime vmtimer(ClassLoader::perf_sys_classload_time()); 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 // find_or_define_instance_class may return a different InstanceKlass
if (!k.is_null()) { if (k != NULL) {
instanceKlassHandle defined_k = InstanceKlass* defined_k =
find_or_define_instance_class(class_name, class_loader, k, THREAD); 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. // 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"); assert(defined_k != NULL, "Should have a klass if there's no exception");
loader_data->add_to_deallocate_list(k()); loader_data->add_to_deallocate_list(k);
k = defined_k; k = defined_k;
} else if (HAS_PENDING_EXCEPTION) { } else if (HAS_PENDING_EXCEPTION) {
loader_data->add_to_deallocate_list(k()); loader_data->add_to_deallocate_list(k);
return nh; return NULL;
} }
} }
return k; return k;
@ -1549,13 +1538,13 @@ instanceKlassHandle SystemDictionary::load_instance_class(Symbol* class_name, Ha
jt->get_thread_stat()->perf_timers_addr(), jt->get_thread_stat()->perf_timers_addr(),
PerfClassTraceTime::CLASS_LOAD); 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 '.' // 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); 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 // Call public unsynchronized loadClass(String) directly for all class loaders
// for parallelCapable class loaders. JDK >=7, loadClass(String, boolean) will // for parallelCapable class loaders. JDK >=7, loadClass(String, boolean) will
@ -1581,7 +1570,7 @@ instanceKlassHandle SystemDictionary::load_instance_class(Symbol* class_name, Ha
vmSymbols::loadClassInternal_name(), vmSymbols::loadClassInternal_name(),
vmSymbols::string_class_signature(), vmSymbols::string_class_signature(),
string, string,
CHECK_(nh)); CHECK_NULL);
} else { } else {
JavaCalls::call_virtual(&result, JavaCalls::call_virtual(&result,
class_loader, class_loader,
@ -1589,7 +1578,7 @@ instanceKlassHandle SystemDictionary::load_instance_class(Symbol* class_name, Ha
vmSymbols::loadClass_name(), vmSymbols::loadClass_name(),
vmSymbols::string_class_signature(), vmSymbols::string_class_signature(),
string, string,
CHECK_(nh)); CHECK_NULL);
} }
assert(result.get_type() == T_OBJECT, "just checking"); assert(result.get_type() == T_OBJECT, "just checking");
@ -1598,8 +1587,7 @@ instanceKlassHandle SystemDictionary::load_instance_class(Symbol* class_name, Ha
// Primitive classes return null since forName() can not be // Primitive classes return null since forName() can not be
// used to obtain any of the Class objects representing primitives or void // used to obtain any of the Class objects representing primitives or void
if ((obj != NULL) && !(java_lang_Class::is_primitive(obj))) { if ((obj != NULL) && !(java_lang_Class::is_primitive(obj))) {
instanceKlassHandle k = InstanceKlass* k = InstanceKlass::cast(java_lang_Class::as_Klass(obj));
instanceKlassHandle(THREAD, java_lang_Class::as_Klass(obj));
// For user defined Java class loaders, check that the name returned is // For user defined Java class loaders, check that the name returned is
// the same as that requested. This check is done for the bootstrap // the same as that requested. This check is done for the bootstrap
// loader when parsing the class file. // loader when parsing the class file.
@ -1608,11 +1596,11 @@ instanceKlassHandle SystemDictionary::load_instance_class(Symbol* class_name, Ha
} }
} }
// Class is not found or has the wrong name, return NULL // 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); HandleMark hm(THREAD);
ClassLoaderData* loader_data = k->class_loader_data(); ClassLoaderData* loader_data = k->class_loader_data();
@ -1677,7 +1665,7 @@ void SystemDictionary::define_instance_class(instanceKlassHandle k, TRAPS) {
// notify jvmti // notify jvmti
if (JvmtiExport::should_post_class_load()) { if (JvmtiExport::should_post_class_load()) {
assert(THREAD->is_Java_thread(), "thread->is_Java_thread()"); 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); class_define_event(k, loader_data);
@ -1703,16 +1691,16 @@ void SystemDictionary::define_instance_class(instanceKlassHandle k, TRAPS) {
// placeholders()->find_and_add(PlaceholderTable::DEFINE_CLASS), // placeholders()->find_and_add(PlaceholderTable::DEFINE_CLASS),
// you need to find_and_remove it before returning. // you need to find_and_remove it before returning.
// So be careful to not exit with a CHECK_ macro betweeen these calls. // 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) { InstanceKlass* SystemDictionary::find_or_define_instance_class(Symbol* class_name, Handle class_loader,
InstanceKlass* k, TRAPS) {
instanceKlassHandle nh = instanceKlassHandle(); // null Handle
Symbol* name_h = k->name(); // passed in class_name may be null Symbol* name_h = k->name(); // passed in class_name may be null
ClassLoaderData* loader_data = class_loader_data(class_loader); ClassLoaderData* loader_data = class_loader_data(class_loader);
unsigned int d_hash = dictionary()->compute_hash(name_h, loader_data); unsigned int d_hash = dictionary()->compute_hash(name_h, loader_data);
int d_index = dictionary()->hash_to_index(d_hash); 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); unsigned int p_hash = placeholders()->compute_hash(name_h, loader_data);
int p_index = placeholders()->hash_to_index(p_hash); int p_index = placeholders()->hash_to_index(p_hash);
PlaceholderEntry* probe; PlaceholderEntry* probe;
@ -1721,9 +1709,9 @@ instanceKlassHandle SystemDictionary::find_or_define_instance_class(Symbol* clas
MutexLocker mu(SystemDictionary_lock, THREAD); MutexLocker mu(SystemDictionary_lock, THREAD);
// First check if class already defined // First check if class already defined
if (UnsyncloadClass || (is_parallelDefine(class_loader))) { 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) { if (check != NULL) {
return(instanceKlassHandle(THREAD, check)); return check;
} }
} }
@ -1743,10 +1731,10 @@ instanceKlassHandle SystemDictionary::find_or_define_instance_class(Symbol* clas
placeholders()->find_and_remove(p_index, p_hash, name_h, loader_data, PlaceholderTable::DEFINE_CLASS, THREAD); placeholders()->find_and_remove(p_index, p_hash, name_h, loader_data, PlaceholderTable::DEFINE_CLASS, THREAD);
SystemDictionary_lock->notify_all(); SystemDictionary_lock->notify_all();
#ifdef ASSERT #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"); assert(check != NULL, "definer missed recording success");
#endif #endif
return(instanceKlassHandle(THREAD, probe->instance_klass())); return probe->instance_klass();
} else { } else {
// This thread will define the class (even if earlier thread tried and had an error) // This thread will define the class (even if earlier thread tried and had an error)
probe->set_definer(THREAD); probe->set_definer(THREAD);
@ -1767,7 +1755,7 @@ instanceKlassHandle SystemDictionary::find_or_define_instance_class(Symbol* clas
linkage_exception = Handle(THREAD,PENDING_EXCEPTION); linkage_exception = Handle(THREAD,PENDING_EXCEPTION);
CLEAR_PENDING_EXCEPTION; CLEAR_PENDING_EXCEPTION;
} else { } else {
probe->set_instance_klass(k()); probe->set_instance_klass(k);
} }
probe->set_definer(NULL); probe->set_definer(NULL);
placeholders()->find_and_remove(p_index, p_hash, name_h, loader_data, PlaceholderTable::DEFINE_CLASS, THREAD); placeholders()->find_and_remove(p_index, p_hash, name_h, loader_data, PlaceholderTable::DEFINE_CLASS, THREAD);
@ -1777,7 +1765,7 @@ instanceKlassHandle SystemDictionary::find_or_define_instance_class(Symbol* clas
// Can't throw exception while holding lock due to rank ordering // Can't throw exception while holding lock due to rank ordering
if (linkage_exception() != NULL) { if (linkage_exception() != NULL) {
THROW_OOP_(linkage_exception(), nh); // throws exception and returns THROW_OOP_(linkage_exception(), NULL); // throws exception and returns
} }
return k; return k;
@ -1817,15 +1805,14 @@ void SystemDictionary::check_loader_lock_contention(Handle loader_lock, TRAPS) {
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// Lookup // Lookup
Klass* SystemDictionary::find_class(int index, unsigned int hash, InstanceKlass* SystemDictionary::find_class(int index, unsigned int hash,
Symbol* class_name, Symbol* class_name,
ClassLoaderData* loader_data) { ClassLoaderData* loader_data) {
assert_locked_or_safepoint(SystemDictionary_lock); assert_locked_or_safepoint(SystemDictionary_lock);
assert (index == dictionary()->index_for(class_name, loader_data), assert (index == dictionary()->index_for(class_name, loader_data),
"incorrect index?"); "incorrect index?");
Klass* k = dictionary()->find_class(index, hash, class_name, loader_data); return dictionary()->find_class(index, hash, class_name, loader_data);
return k;
} }
@ -1840,7 +1827,7 @@ Symbol* SystemDictionary::find_placeholder(Symbol* class_name,
// Used for assertions and verification only // 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 #ifndef ASSERT
guarantee(VerifyBeforeGC || guarantee(VerifyBeforeGC ||
VerifyDuringGC || VerifyDuringGC ||
@ -1868,8 +1855,8 @@ Klass* SystemDictionary::try_get_next_class() {
// is held, to ensure that the compiler is not using the class hierachy, and that deoptimization will kick in // 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. // before a new class is used.
void SystemDictionary::add_to_hierarchy(instanceKlassHandle k, TRAPS) { void SystemDictionary::add_to_hierarchy(InstanceKlass* k, TRAPS) {
assert(k.not_null(), "just checking"); assert(k != NULL, "just checking");
assert_locked_or_safepoint(Compile_lock); assert_locked_or_safepoint(Compile_lock);
// Link into hierachy. Make sure the vtables are initialized before linking into // Link into hierachy. Make sure the vtables are initialized before linking into
@ -2150,8 +2137,7 @@ void SystemDictionary::initialize_preloaded_classes(TRAPS) {
if (UseSharedSpaces) { if (UseSharedSpaces) {
initialize_wk_klasses_through(WK_KLASS_ENUM_NAME(Object_klass), scan, CHECK); initialize_wk_klasses_through(WK_KLASS_ENUM_NAME(Object_klass), scan, CHECK);
// Initialize the constant pool for the Object_class // Initialize the constant pool for the Object_class
InstanceKlass* ik = InstanceKlass::cast(Object_klass()); Object_klass()->constants()->restore_unshareable_info(CHECK);
ik->constants()->restore_unshareable_info(CHECK);
initialize_wk_klasses_through(WK_KLASS_ENUM_NAME(Class_klass), scan, CHECK); initialize_wk_klasses_through(WK_KLASS_ENUM_NAME(Class_klass), scan, CHECK);
} else { } else {
initialize_wk_klasses_through(WK_KLASS_ENUM_NAME(Class_klass), scan, CHECK); initialize_wk_klasses_through(WK_KLASS_ENUM_NAME(Class_klass), scan, CHECK);
@ -2231,7 +2217,7 @@ BasicType SystemDictionary::box_klass_type(Klass* k) {
// if initiating loader, then ok if InstanceKlass matches existing entry // if initiating loader, then ok if InstanceKlass matches existing entry
void SystemDictionary::check_constraints(int d_index, unsigned int d_hash, void SystemDictionary::check_constraints(int d_index, unsigned int d_hash,
instanceKlassHandle k, InstanceKlass* k,
Handle class_loader, bool defining, Handle class_loader, bool defining,
TRAPS) { TRAPS) {
const char *linkage_error1 = NULL; const char *linkage_error1 = NULL;
@ -2242,8 +2228,8 @@ void SystemDictionary::check_constraints(int d_index, unsigned int d_hash,
MutexLocker mu(SystemDictionary_lock, THREAD); 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 != (Klass*)NULL) { if (check != NULL) {
// if different InstanceKlass - duplicate class definition, // if different InstanceKlass - duplicate class definition,
// else - ok, class loaded by a different thread in parallel, // 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 // we should only have found it if it was done loading and ok to use
@ -2251,7 +2237,7 @@ void SystemDictionary::check_constraints(int d_index, unsigned int d_hash,
// also holds array classes // also holds array classes
assert(check->is_instance_klass(), "noninstance in systemdictionary"); assert(check->is_instance_klass(), "noninstance in systemdictionary");
if ((defining == true) || (k() != check)) { if ((defining == true) || (k != check)) {
linkage_error1 = "loader (instance of "; linkage_error1 = "loader (instance of ";
linkage_error2 = "): attempted duplicate class definition for name: \""; linkage_error2 = "): attempted duplicate class definition for name: \"";
} else { } else {
@ -2292,7 +2278,7 @@ void SystemDictionary::check_constraints(int d_index, unsigned int d_hash,
// have been called. // have been called.
void SystemDictionary::update_dictionary(int d_index, unsigned int d_hash, void SystemDictionary::update_dictionary(int d_index, unsigned int d_hash,
int p_index, unsigned int p_hash, int p_index, unsigned int p_hash,
instanceKlassHandle k, InstanceKlass* k,
Handle class_loader, Handle class_loader,
TRAPS) { TRAPS) {
// Compile_lock prevents systemDictionary updates during compilations // Compile_lock prevents systemDictionary updates during compilations
@ -2324,7 +2310,7 @@ void SystemDictionary::update_dictionary(int d_index, unsigned int d_hash,
} }
// Make a new system dictionary entry. // 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) { if (sd_check == NULL) {
dictionary()->add_klass(name, loader_data, k); dictionary()->add_klass(name, loader_data, k);
notice_modification(); notice_modification();
@ -2415,8 +2401,8 @@ bool SystemDictionary::add_loader_constraint(Symbol* class_name,
// Better never do a GC while we're holding these oops // Better never do a GC while we're holding these oops
NoSafepointVerifier nosafepoint; NoSafepointVerifier nosafepoint;
Klass* klass1 = find_class(d_index1, d_hash1, constraint_name, loader_data1); InstanceKlass* klass1 = find_class(d_index1, d_hash1, constraint_name, loader_data1);
Klass* klass2 = find_class(d_index2, d_hash2, constraint_name, loader_data2); InstanceKlass* klass2 = find_class(d_index2, d_hash2, constraint_name, loader_data2);
return constraints()->add_entry(constraint_name, klass1, class_loader1, return constraints()->add_entry(constraint_name, klass1, class_loader1,
klass2, class_loader2); klass2, class_loader2);
} }
@ -2576,7 +2562,7 @@ methodHandle SystemDictionary::find_method_handle_intrinsic(vmIntrinsics::ID iid
// Helper for unpacking the return value from linkMethod and linkCallSite. // Helper for unpacking the return value from linkMethod and linkCallSite.
static methodHandle unpack_method_and_appendix(Handle mname, static methodHandle unpack_method_and_appendix(Handle mname,
KlassHandle accessing_klass, Klass* accessing_klass,
objArrayHandle appendix_box, objArrayHandle appendix_box,
Handle* appendix_result, Handle* appendix_result,
TRAPS) { TRAPS) {
@ -2600,7 +2586,7 @@ static methodHandle unpack_method_and_appendix(Handle mname,
// MethodName is dropped we need a way to make sure the // MethodName is dropped we need a way to make sure the
// class_loader containing this method is kept alive. // class_loader containing this method is kept alive.
// FIXME: the appendix might also preserve this dependency. // 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 this_key->record_dependency(m->method_holder(), CHECK_NULL); // Can throw OOM
return methodHandle(THREAD, m); return methodHandle(THREAD, m);
} }
@ -2609,10 +2595,10 @@ static methodHandle unpack_method_and_appendix(Handle mname,
return empty; return empty;
} }
methodHandle SystemDictionary::find_method_handle_invoker(KlassHandle klass, methodHandle SystemDictionary::find_method_handle_invoker(Klass* klass,
Symbol* name, Symbol* name,
Symbol* signature, Symbol* signature,
KlassHandle accessing_klass, Klass* accessing_klass,
Handle *appendix_result, Handle *appendix_result,
Handle *method_type_result, Handle *method_type_result,
TRAPS) { TRAPS) {
@ -2628,15 +2614,15 @@ methodHandle SystemDictionary::find_method_handle_invoker(KlassHandle klass,
assert(appendix_box->obj_at(0) == NULL, ""); assert(appendix_box->obj_at(0) == NULL, "");
// This should not happen. JDK code should take care of that. // 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); THROW_MSG_(vmSymbols::java_lang_InternalError(), "bad invokehandle", empty);
} }
// call java.lang.invoke.MethodHandleNatives::linkMethod(... String, MethodType) -> MemberName // call java.lang.invoke.MethodHandleNatives::linkMethod(... String, MethodType) -> MemberName
JavaCallArguments args; 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_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(name_str);
args.push_oop(method_type); args.push_oop(method_type);
args.push_oop(appendix_box); args.push_oop(appendix_box);
@ -2675,7 +2661,7 @@ static bool is_always_visible_class(oop mirror) {
// Because of class loader constraints, all method handle usage must be // Because of class loader constraints, all method handle usage must be
// consistent with this loader. // consistent with this loader.
Handle SystemDictionary::find_method_handle_type(Symbol* signature, Handle SystemDictionary::find_method_handle_type(Symbol* signature,
KlassHandle accessing_klass, Klass* accessing_klass,
TRAPS) { TRAPS) {
Handle empty; Handle empty;
vmIntrinsics::ID null_iid = vmIntrinsics::_none; // distinct from all method handle invoker intrinsics vmIntrinsics::ID null_iid = vmIntrinsics::_none; // distinct from all method handle invoker intrinsics
@ -2691,9 +2677,9 @@ Handle SystemDictionary::find_method_handle_type(Symbol* signature,
} }
Handle class_loader, protection_domain; Handle class_loader, protection_domain;
if (accessing_klass.not_null()) { if (accessing_klass != NULL) {
class_loader = Handle(THREAD, InstanceKlass::cast(accessing_klass())->class_loader()); class_loader = Handle(THREAD, accessing_klass->class_loader());
protection_domain = Handle(THREAD, InstanceKlass::cast(accessing_klass())->protection_domain()); protection_domain = Handle(THREAD, accessing_klass->protection_domain());
} }
bool can_be_cached = true; bool can_be_cached = true;
int npts = ArgumentCount(signature).size(); int npts = ArgumentCount(signature).size();
@ -2724,15 +2710,14 @@ Handle SystemDictionary::find_method_handle_type(Symbol* signature,
pts->obj_at_put(arg++, mirror); pts->obj_at_put(arg++, mirror);
// Check accessibility. // 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); Klass* sel_klass = java_lang_Class::as_Klass(mirror);
mirror = NULL; // safety mirror = NULL; // safety
// Emulate ConstantPool::verify_constant_pool_resolve. // Emulate ConstantPool::verify_constant_pool_resolve.
if (sel_klass->is_objArray_klass()) if (sel_klass->is_objArray_klass())
sel_klass = ObjArrayKlass::cast(sel_klass)->bottom_klass(); sel_klass = ObjArrayKlass::cast(sel_klass)->bottom_klass();
if (sel_klass->is_instance_klass()) { if (sel_klass->is_instance_klass()) {
KlassHandle sel_kh(THREAD, sel_klass); LinkResolver::check_klass_accessability(accessing_klass, sel_klass, CHECK_(empty));
LinkResolver::check_klass_accessability(accessing_klass, sel_kh, CHECK_(empty));
} }
} }
} }
@ -2765,9 +2750,9 @@ Handle SystemDictionary::find_method_handle_type(Symbol* signature,
} }
// Ask Java code to find or construct a method handle constant. // 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 int ref_kind, //e.g., JVM_REF_invokeVirtual
KlassHandle callee, Klass* callee,
Symbol* name_sym, Symbol* name_sym,
Symbol* signature, Symbol* signature,
TRAPS) { TRAPS) {
@ -2776,7 +2761,7 @@ Handle SystemDictionary::link_method_handle_constant(KlassHandle caller,
Handle type; Handle type;
if (signature->utf8_length() > 0 && signature->byte_at(0) == '(') { if (signature->utf8_length() > 0 && signature->byte_at(0) == '(') {
type = find_method_handle_type(signature, caller, CHECK_(empty)); 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. // This should not happen. JDK code should take care of that.
THROW_MSG_(vmSymbols::java_lang_InternalError(), "bad MH constant", empty); THROW_MSG_(vmSymbols::java_lang_InternalError(), "bad MH constant", empty);
} else { } else {
@ -2813,7 +2798,7 @@ Handle SystemDictionary::link_method_handle_constant(KlassHandle caller,
// Ask Java code to find or construct a java.lang.invoke.CallSite for the given // 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. // 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, Handle bootstrap_specifier,
Symbol* name, Symbol* name,
Symbol* type, Symbol* type,
@ -2844,7 +2829,7 @@ methodHandle SystemDictionary::find_dynamic_call_site_invoker(KlassHandle caller
Handle method_type = find_method_handle_type(type, caller, CHECK_(empty)); Handle method_type = find_method_handle_type(type, caller, CHECK_(empty));
// This should not happen. JDK code should take care of that. // 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); THROW_MSG_(vmSymbols::java_lang_InternalError(), "bad invokedynamic", empty);
} }

View file

@ -259,7 +259,7 @@ class SystemDictionary : AllStatic {
static Klass* resolve_or_fail(Symbol* class_name, bool throw_error, TRAPS); static Klass* resolve_or_fail(Symbol* class_name, bool throw_error, TRAPS);
protected: protected:
// handle error translation for resolve_or_null results // 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: public:
@ -282,7 +282,7 @@ public:
// Parse new stream. This won't update the system dictionary or // Parse new stream. This won't update the system dictionary or
// class hierarchy, simply parse the stream. Used by JVMTI RedefineClasses. // class hierarchy, simply parse the stream. Used by JVMTI RedefineClasses.
// Also used by Unsafe_DefineAnonymousClass // Also used by Unsafe_DefineAnonymousClass
static Klass* parse_stream(Symbol* class_name, static InstanceKlass* parse_stream(Symbol* class_name,
Handle class_loader, Handle class_loader,
Handle protection_domain, Handle protection_domain,
ClassFileStream* st, ClassFileStream* st,
@ -295,7 +295,7 @@ public:
NULL, // cp_patches NULL, // cp_patches
THREAD); THREAD);
} }
static Klass* parse_stream(Symbol* class_name, static InstanceKlass* parse_stream(Symbol* class_name,
Handle class_loader, Handle class_loader,
Handle protection_domain, Handle protection_domain,
ClassFileStream* st, ClassFileStream* st,
@ -304,7 +304,7 @@ public:
TRAPS); TRAPS);
// Resolve from stream (called by jni_DefineClass and JVM_DefineClass) // Resolve from stream (called by jni_DefineClass and JVM_DefineClass)
static Klass* resolve_from_stream(Symbol* class_name, static InstanceKlass* resolve_from_stream(Symbol* class_name,
Handle class_loader, Handle class_loader,
Handle protection_domain, Handle protection_domain,
ClassFileStream* st, ClassFileStream* st,
@ -516,10 +516,10 @@ public:
// JSR 292 // JSR 292
// find a java.lang.invoke.MethodHandle.invoke* method for a given signature // find a java.lang.invoke.MethodHandle.invoke* method for a given signature
// (asks Java to compute it if necessary, except in a compiler thread) // (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* name,
Symbol* signature, Symbol* signature,
KlassHandle accessing_klass, Klass* accessing_klass,
Handle *appendix_result, Handle *appendix_result,
Handle *method_type_result, Handle *method_type_result,
TRAPS); TRAPS);
@ -531,19 +531,19 @@ public:
// find a java.lang.invoke.MethodType object for a given signature // find a java.lang.invoke.MethodType object for a given signature
// (asks Java to compute it if necessary, except in a compiler thread) // (asks Java to compute it if necessary, except in a compiler thread)
static Handle find_method_handle_type(Symbol* signature, static Handle find_method_handle_type(Symbol* signature,
KlassHandle accessing_klass, Klass* accessing_klass,
TRAPS); TRAPS);
// ask Java to compute a java.lang.invoke.MethodHandle object for a given CP entry // 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 int ref_kind, //e.g., JVM_REF_invokeVirtual
KlassHandle callee, Klass* callee,
Symbol* name, Symbol* name,
Symbol* signature, Symbol* signature,
TRAPS); TRAPS);
// ask Java to create a dynamic call site, while linking an invokedynamic op // 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, Handle bootstrap_method,
Symbol* name, Symbol* name,
Symbol* type, Symbol* type,
@ -615,7 +615,7 @@ public:
static Klass* try_get_next_class(); static Klass* try_get_next_class();
protected: protected:
static void validate_protection_domain(instanceKlassHandle klass, static void validate_protection_domain(InstanceKlass* klass,
Handle class_loader, Handle class_loader,
Handle protection_domain, TRAPS); Handle protection_domain, TRAPS);
@ -631,48 +631,48 @@ protected:
// Basic loading operations // Basic loading operations
static Klass* resolve_instance_class_or_null(Symbol* class_name, Handle class_loader, Handle protection_domain, TRAPS); 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 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 // Wait on SystemDictionary_lock; unlocks lockObject before
// waiting; relocks lockObject with correct recursion count // waiting; relocks lockObject with correct recursion count
// after waiting, but before reentering SystemDictionary_lock // after waiting, but before reentering SystemDictionary_lock
// to preserve lock order semantics. // to preserve lock order semantics.
static void double_lock_wait(Handle lockObject, TRAPS); static void double_lock_wait(Handle lockObject, TRAPS);
static void define_instance_class(instanceKlassHandle k, TRAPS); static void define_instance_class(InstanceKlass* k, TRAPS);
static instanceKlassHandle find_or_define_instance_class(Symbol* class_name, static InstanceKlass* find_or_define_instance_class(Symbol* class_name,
Handle class_loader, Handle class_loader,
instanceKlassHandle k, TRAPS); InstanceKlass* k, TRAPS);
static bool is_shared_class_visible(Symbol* class_name, instanceKlassHandle ik, static bool is_shared_class_visible(Symbol* class_name, InstanceKlass* ik,
Handle class_loader, TRAPS); Handle class_loader, TRAPS);
static instanceKlassHandle load_shared_class(instanceKlassHandle ik, static InstanceKlass* load_shared_class(InstanceKlass* ik,
Handle class_loader, Handle class_loader,
Handle protection_domain, Handle protection_domain,
TRAPS); TRAPS);
static instanceKlassHandle load_instance_class(Symbol* class_name, Handle class_loader, TRAPS); static InstanceKlass* load_instance_class(Symbol* class_name, Handle class_loader, TRAPS);
static Handle compute_loader_lock_object(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 void check_loader_lock_contention(Handle loader_lock, TRAPS);
static bool is_parallelCapable(Handle class_loader); static bool is_parallelCapable(Handle class_loader);
static bool is_parallelDefine(Handle class_loader); static bool is_parallelDefine(Handle class_loader);
public: public:
static instanceKlassHandle load_shared_class(Symbol* class_name, static InstanceKlass* load_shared_class(Symbol* class_name,
Handle class_loader, Handle class_loader,
TRAPS); TRAPS);
static bool is_system_class_loader(oop class_loader); static bool is_system_class_loader(oop class_loader);
static bool is_platform_class_loader(oop class_loader); static bool is_platform_class_loader(oop class_loader);
protected: protected:
static Klass* find_shared_class(Symbol* class_name); static InstanceKlass* find_shared_class(Symbol* class_name);
// Setup link to hierarchy // 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 // We pass in the hashtable index so we can calculate it outside of
// the SystemDictionary_lock. // the SystemDictionary_lock.
// Basic find on loaded classes // Basic find on loaded classes
static Klass* find_class(int index, unsigned int hash, static InstanceKlass* find_class(int index, unsigned int hash,
Symbol* name, ClassLoaderData* loader_data); Symbol* name, ClassLoaderData* loader_data);
static Klass* find_class(Symbol* class_name, ClassLoaderData* loader_data); static InstanceKlass* find_class(Symbol* class_name, ClassLoaderData* loader_data);
// Basic find on classes in the midst of being loaded // Basic find on classes in the midst of being loaded
static Symbol* find_placeholder(Symbol* name, ClassLoaderData* loader_data); static Symbol* find_placeholder(Symbol* name, ClassLoaderData* loader_data);
@ -697,11 +697,11 @@ protected:
// Class loader constraints // Class loader constraints
static void check_constraints(int index, unsigned int hash, static void check_constraints(int index, unsigned int hash,
instanceKlassHandle k, Handle loader, InstanceKlass* k, Handle loader,
bool defining, TRAPS); bool defining, TRAPS);
static void update_dictionary(int d_index, unsigned int d_hash, static void update_dictionary(int d_index, unsigned int d_hash,
int p_index, unsigned int p_hash, int p_index, unsigned int p_hash,
instanceKlassHandle k, Handle loader, InstanceKlass* k, Handle loader,
TRAPS); TRAPS);
// Variables holding commonly used klasses (preloaded) // Variables holding commonly used klasses (preloaded)

View file

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -33,10 +33,10 @@ class ClassFileStream;
class SystemDictionaryShared: public SystemDictionary { class SystemDictionaryShared: public SystemDictionary {
public: public:
static void initialize(TRAPS) {} static void initialize(TRAPS) {}
static instanceKlassHandle find_or_load_shared_class(Symbol* class_name, static InstanceKlass* find_or_load_shared_class(Symbol* class_name,
Handle class_loader, Handle class_loader,
TRAPS) { TRAPS) {
return instanceKlassHandle(); return NULL;
} }
static void roots_oops_do(OopClosure* blk) {} static void roots_oops_do(OopClosure* blk) {}
static void oops_do(OopClosure* f) {} static void oops_do(OopClosure* f) {}
@ -45,7 +45,7 @@ public:
return (class_loader == NULL); return (class_loader == NULL);
} }
static bool is_shared_class_visible_for_classloader( static bool is_shared_class_visible_for_classloader(
instanceKlassHandle ik, InstanceKlass* ik,
Handle class_loader, Handle class_loader,
const char* pkg_string, const char* pkg_string,
Symbol* pkg_name, Symbol* pkg_name,
@ -86,7 +86,7 @@ public:
Symbol* from_name, bool from_field_is_protected, Symbol* from_name, bool from_field_is_protected,
bool from_is_array, bool from_is_object) {return false;} bool from_is_array, bool from_is_object) {return false;}
static void finalize_verification_constraints() {} static void finalize_verification_constraints() {}
static void check_verification_constraints(instanceKlassHandle klass, static void check_verification_constraints(InstanceKlass* klass,
TRAPS) {} TRAPS) {}
}; };

View file

@ -42,18 +42,16 @@ VerificationType VerificationType::from_tag(u1 tag) {
} }
} }
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) { Symbol* from_name, bool from_field_is_protected, bool from_is_array, bool from_is_object, TRAPS) {
HandleMark hm(THREAD); HandleMark hm(THREAD);
Klass* obj = SystemDictionary::resolve_or_fail( Klass* this_class = SystemDictionary::resolve_or_fail(
name, Handle(THREAD, klass->class_loader()), name, Handle(THREAD, klass->class_loader()),
Handle(THREAD, klass->protection_domain()), true, CHECK_false); Handle(THREAD, klass->protection_domain()), true, CHECK_false);
if (log_is_enabled(Debug, class, resolve)) { 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 || if (this_class->is_interface() && (!from_field_is_protected ||
from_name != vmSymbols::java_lang_Object())) { from_name != vmSymbols::java_lang_Object())) {
// If we are not trying to access a protected field or method in // If we are not trying to access a protected field or method in
@ -68,9 +66,9 @@ bool VerificationType::resolve_and_check_assignability(instanceKlassHandle klass
from_name, Handle(THREAD, klass->class_loader()), from_name, Handle(THREAD, klass->class_loader()),
Handle(THREAD, klass->protection_domain()), true, CHECK_false); Handle(THREAD, klass->protection_domain()), true, CHECK_false);
if (log_is_enabled(Debug, class, resolve)) { 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; return false;
@ -79,7 +77,7 @@ bool VerificationType::resolve_and_check_assignability(instanceKlassHandle klass
bool VerificationType::is_reference_assignable_from( bool VerificationType::is_reference_assignable_from(
const VerificationType& from, ClassVerifier* context, const VerificationType& from, ClassVerifier* context,
bool from_field_is_protected, TRAPS) const { bool from_field_is_protected, TRAPS) const {
instanceKlassHandle klass = context->current_class(); InstanceKlass* klass = context->current_class();
if (from.is_null()) { if (from.is_null()) {
// null is assignable to any reference // null is assignable to any reference
return true; return true;
@ -94,7 +92,7 @@ bool VerificationType::is_reference_assignable_from(
return true; 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(), name(), from.name(), from_field_is_protected, from.is_array(),
from.is_object())) { from.is_object())) {
// If add_verification_constraint() returns true, the resolution/check should be // If add_verification_constraint() returns true, the resolution/check should be
@ -102,7 +100,7 @@ bool VerificationType::is_reference_assignable_from(
return true; 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); from_field_is_protected, from.is_array(), from.is_object(), THREAD);
} else if (is_array() && from.is_array()) { } else if (is_array() && from.is_array()) {
VerificationType comp_this = get_component(context, CHECK_false); VerificationType comp_this = get_component(context, CHECK_false);

View file

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -336,7 +336,7 @@ class VerificationType VALUE_OBJ_CLASS_SPEC {
TRAPS) const; TRAPS) const;
public: 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, Symbol* from_name, bool from_field_is_protected,
bool from_is_array, bool from_is_object, bool from_is_array, bool from_is_object,
TRAPS); TRAPS);

View file

@ -125,7 +125,7 @@ void Verifier::log_end_verification(outputStream* st, const char* klassName, Sym
st->print_cr("End class verification for: %s", klassName); 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); HandleMark hm(THREAD);
ResourceMark rm(THREAD); ResourceMark rm(THREAD);
@ -203,13 +203,13 @@ bool Verifier::verify(instanceKlassHandle klass, Verifier::Mode mode, bool shoul
return true; // verifcation succeeded return true; // verifcation succeeded
} else { // VerifyError or ClassFormatError to be created and thrown } else { // VerifyError or ClassFormatError to be created and thrown
ResourceMark rm(THREAD); ResourceMark rm(THREAD);
instanceKlassHandle kls = Klass* kls =
SystemDictionary::resolve_or_fail(exception_name, true, CHECK_false); SystemDictionary::resolve_or_fail(exception_name, true, CHECK_false);
if (log_is_enabled(Debug, class, resolve)) { 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 (kls == klass) {
// If the class being verified is the exception we're creating // If the class being verified is the exception we're creating
// or one of it's superclasses, we're in trouble and are going // or one of it's superclasses, we're in trouble and are going
@ -224,7 +224,7 @@ bool Verifier::verify(instanceKlassHandle klass, Verifier::Mode mode, bool shoul
} }
} }
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(); Symbol* name = klass->name();
Klass* refl_magic_klass = SystemDictionary::reflect_MagicAccessorImpl_klass(); Klass* refl_magic_klass = SystemDictionary::reflect_MagicAccessorImpl_klass();
@ -243,7 +243,7 @@ bool Verifier::is_eligible_for_verification(instanceKlassHandle klass, bool shou
// already been rewritten to contain constant pool cache indices, // already been rewritten to contain constant pool cache indices,
// which the verifier can't understand. // which the verifier can't understand.
// Shared classes shouldn't have stackmaps either. // 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 // As of the fix for 4486457 we disable verification for all of the
// dynamically-generated bytecodes associated with the 1.4 // dynamically-generated bytecodes associated with the 1.4
@ -256,7 +256,7 @@ bool Verifier::is_eligible_for_verification(instanceKlassHandle klass, bool shou
} }
Symbol* Verifier::inference_verify( 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; JavaThread* thread = (JavaThread*)THREAD;
JNIEnv *env = thread->jni_environment(); JNIEnv *env = thread->jni_environment();
@ -559,7 +559,7 @@ void ErrorContext::stackmap_details(outputStream* ss, const Method* method) cons
// Methods in ClassVerifier // Methods in ClassVerifier
ClassVerifier::ClassVerifier( ClassVerifier::ClassVerifier(
instanceKlassHandle klass, TRAPS) InstanceKlass* klass, TRAPS)
: _thread(THREAD), _exception_type(NULL), _message(NULL), _klass(klass) { : _thread(THREAD), _exception_type(NULL), _message(NULL), _klass(klass) {
_this_type = VerificationType::reference_type(klass->name()); _this_type = VerificationType::reference_type(klass->name());
// Create list to hold symbols in reference area. // Create list to hold symbols in reference area.
@ -2001,13 +2001,13 @@ Klass* ClassVerifier::load_class(Symbol* name, TRAPS) {
true, THREAD); true, THREAD);
if (log_is_enabled(Debug, class, resolve)) { if (log_is_enabled(Debug, class, resolve)) {
instanceKlassHandle cur_class = current_class(); InstanceKlass* cur_class = InstanceKlass::cast(current_class());
Verifier::trace_class_resolution(kls, cur_class()); Verifier::trace_class_resolution(kls, cur_class);
} }
return kls; return kls;
} }
bool ClassVerifier::is_protected_access(instanceKlassHandle this_class, bool ClassVerifier::is_protected_access(InstanceKlass* this_class,
Klass* target_class, Klass* target_class,
Symbol* field_name, Symbol* field_name,
Symbol* field_sig, Symbol* field_sig,
@ -2170,7 +2170,7 @@ void ClassVerifier::verify_switch(
} }
bool ClassVerifier::name_in_supers( bool ClassVerifier::name_in_supers(
Symbol* ref_name, instanceKlassHandle current) { Symbol* ref_name, InstanceKlass* current) {
Klass* super = current->super(); Klass* super = current->super();
while (super != NULL) { while (super != NULL) {
if (super->name() == ref_name) { if (super->name() == ref_name) {
@ -2600,8 +2600,8 @@ void ClassVerifier::verify_invoke_init(
Klass::find_overpass); Klass::find_overpass);
// Do nothing if method is not found. Let resolution detect the error. // Do nothing if method is not found. Let resolution detect the error.
if (m != NULL) { if (m != NULL) {
instanceKlassHandle mh(THREAD, m->method_holder()); InstanceKlass* mh = m->method_holder();
if (m->is_protected() && !mh->is_same_class_package(_klass())) { if (m->is_protected() && !mh->is_same_class_package(_klass)) {
bool assignable = current_type().is_assignable_from( bool assignable = current_type().is_assignable_from(
objectref_type, this, true, CHECK_VERIFY(this)); objectref_type, this, true, CHECK_VERIFY(this));
if (!assignable) { if (!assignable) {
@ -2631,7 +2631,7 @@ void ClassVerifier::verify_invoke_init(
} }
bool ClassVerifier::is_same_or_direct_interface( bool ClassVerifier::is_same_or_direct_interface(
instanceKlassHandle klass, InstanceKlass* klass,
VerificationType klass_type, VerificationType klass_type,
VerificationType ref_class_type) { VerificationType ref_class_type) {
if (ref_class_type.equals(klass_type)) return true; if (ref_class_type.equals(klass_type)) return true;

View file

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -51,7 +51,7 @@ class Verifier : AllStatic {
* error. * error.
*/ */
static void log_end_verification(outputStream* st, const char* klassName, Symbol* exception_name, TRAPS); 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, // Return false if the class is loaded by the bootstrap loader,
// or if defineClass was called requesting skipping verification // or if defineClass was called requesting skipping verification
@ -65,9 +65,9 @@ class Verifier : AllStatic {
static void trace_class_resolution(Klass* resolve_class, InstanceKlass* verify_class); static void trace_class_resolution(Klass* resolve_class, InstanceKlass* verify_class);
private: 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( static Symbol* inference_verify(
instanceKlassHandle klass, char* msg, size_t msg_len, TRAPS); InstanceKlass* klass, char* msg, size_t msg_len, TRAPS);
}; };
class RawBytecodeStream; class RawBytecodeStream;
@ -275,7 +275,7 @@ class ClassVerifier : public StackObj {
} }
bool is_protected_access( 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); Symbol* field_name, Symbol* field_sig, bool is_method);
void verify_cp_index(u2 bci, const constantPoolHandle& cp, int index, TRAPS); void verify_cp_index(u2 bci, const constantPoolHandle& cp, int index, TRAPS);
@ -344,11 +344,11 @@ class ClassVerifier : public StackObj {
void verify_astore(u2 index, StackMapFrame* current_frame, TRAPS); void verify_astore(u2 index, StackMapFrame* current_frame, TRAPS);
void verify_iinc (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; VerificationType object_type() const;
instanceKlassHandle _klass; // the class being verified InstanceKlass* _klass; // the class being verified
methodHandle _method; // current method being verified methodHandle _method; // current method being verified
VerificationType _this_type; // the verification type of the current class VerificationType _this_type; // the verification type of the current class
@ -362,7 +362,7 @@ class ClassVerifier : public StackObj {
// that a class has been verified and prepared for execution. // that a class has been verified and prepared for execution.
bool was_recursively_verified() { return _klass->is_rewritten(); } 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); VerificationType klass_type, VerificationType ref_class_type);
public: public:
@ -372,14 +372,14 @@ class ClassVerifier : public StackObj {
}; };
// constructor // constructor
ClassVerifier(instanceKlassHandle klass, TRAPS); ClassVerifier(InstanceKlass* klass, TRAPS);
// destructor // destructor
~ClassVerifier(); ~ClassVerifier();
Thread* thread() { return _thread; } Thread* thread() { return _thread; }
const methodHandle& method() { return _method; } const methodHandle& method() { return _method; }
instanceKlassHandle current_class() const { return _klass; } InstanceKlass* current_class() const { return _klass; }
VerificationType current_type() const { return _this_type; } VerificationType current_type() const { return _this_type; }
// Verifies the class. If a verify or class file format error occurs, // Verifies the class. If a verify or class file format error occurs,

View file

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -1141,7 +1141,7 @@ bool CodeCache::is_far_target(address target) {
} }
#ifdef HOTSWAP #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); MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
int number_of_marked_CodeBlobs = 0; int number_of_marked_CodeBlobs = 0;
@ -1162,7 +1162,7 @@ int CodeCache::mark_for_evol_deoptimization(instanceKlassHandle dependee) {
CompiledMethod* nm = iter.method(); CompiledMethod* nm = iter.method();
if (nm->is_marked_for_deoptimization()) { if (nm->is_marked_for_deoptimization()) {
// ...Already marked in the previous pass; don't count it again. // ...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; ResourceMark rm;
nm->mark_for_deoptimization(); nm->mark_for_deoptimization();
number_of_marked_CodeBlobs++; number_of_marked_CodeBlobs++;
@ -1218,7 +1218,7 @@ void CodeCache::make_marked_nmethods_not_entrant() {
} }
// Flushes compiled methods dependent on dependee. // 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); assert_lock_strong(Compile_lock);
if (number_of_nmethods_with_dependencies() == 0) return; if (number_of_nmethods_with_dependencies() == 0) return;
@ -1239,7 +1239,7 @@ void CodeCache::flush_dependents_on(instanceKlassHandle dependee) {
#ifdef HOTSWAP #ifdef HOTSWAP
// Flushes compiled methods dependent on dependee in the evolutionary sense // 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. // --- Compile_lock is not held. However we are at a safepoint.
assert_locked_or_safepoint(Compile_lock); assert_locked_or_safepoint(Compile_lock);
if (number_of_nmethods_with_dependencies() == 0 && !UseAOT) return; if (number_of_nmethods_with_dependencies() == 0 && !UseAOT) return;
@ -1249,7 +1249,7 @@ void CodeCache::flush_evol_dependents_on(instanceKlassHandle ev_k_h) {
// holding the CodeCache_lock. // holding the CodeCache_lock.
// Compute the dependent nmethods // 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 // 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. // All this already happens inside a VM_Operation, so we'll do all the work here.

View file

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -260,7 +260,7 @@ class CodeCache : AllStatic {
private: private:
static int mark_for_deoptimization(KlassDepChange& changes); static int mark_for_deoptimization(KlassDepChange& changes);
#ifdef HOTSWAP #ifdef HOTSWAP
static int mark_for_evol_deoptimization(instanceKlassHandle dependee); static int mark_for_evol_deoptimization(InstanceKlass* dependee);
#endif // HOTSWAP #endif // HOTSWAP
public: public:
@ -269,10 +269,10 @@ class CodeCache : AllStatic {
static void make_marked_nmethods_not_entrant(); static void make_marked_nmethods_not_entrant();
// Flushing and deoptimization // Flushing and deoptimization
static void flush_dependents_on(instanceKlassHandle dependee); static void flush_dependents_on(InstanceKlass* dependee);
#ifdef HOTSWAP #ifdef HOTSWAP
// Flushing and deoptimization in case of evolution // 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 #endif // HOTSWAP
// Support for fullspeed debugging // Support for fullspeed debugging
static void flush_dependents_on_method(methodHandle dependee); static void flush_dependents_on_method(methodHandle dependee);

View file

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -457,7 +457,7 @@ void CompiledIC::set_to_monomorphic(CompiledICInfo& info) {
// null check, while a static_bound won't. A static_bound (but not optimized) must // null check, while a static_bound won't. A static_bound (but not optimized) must
// therefore use the unverified entry point. // therefore use the unverified entry point.
void CompiledIC::compute_monomorphic_entry(const methodHandle& method, void CompiledIC::compute_monomorphic_entry(const methodHandle& method,
KlassHandle receiver_klass, Klass* receiver_klass,
bool is_optimized, bool is_optimized,
bool static_bound, bool static_bound,
bool caller_is_nmethod, bool caller_is_nmethod,
@ -494,7 +494,7 @@ void CompiledIC::compute_monomorphic_entry(const methodHandle& method,
bool far_c2a = entry != NULL && caller_is_nmethod && method_code->is_far_code(); bool far_c2a = entry != NULL && caller_is_nmethod && method_code->is_far_code();
if (entry != NULL && !far_c2a) { if (entry != NULL && !far_c2a) {
// Call to near compiled code (nmethod or aot). // 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 { } else {
if (is_optimized) { if (is_optimized) {
if (far_c2a) { if (far_c2a) {
@ -507,7 +507,7 @@ void CompiledIC::compute_monomorphic_entry(const methodHandle& method,
} else { } else {
// Use icholder entry // Use icholder entry
assert(method_code == NULL || method_code->is_compiled(), "must be compiled"); 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); info.set_icholder_entry(method()->get_c2i_unverified_entry(), holder);
} }
} }

View file

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -266,7 +266,7 @@ class CompiledIC: public ResourceObj {
// allocation in the code cache fails. // allocation in the code cache fails.
bool set_to_megamorphic(CallInfo* call_info, Bytecodes::Code bytecode, TRAPS); 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, bool is_optimized, bool static_bound, bool caller_is_nmethod,
CompiledICInfo& info, TRAPS); CompiledICInfo& info, TRAPS);

View file

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -737,13 +737,13 @@ class DepChange : public StackObj {
class KlassDepChange : public DepChange { class KlassDepChange : public DepChange {
private: private:
// each change set is rooted in exactly one new type (at present): // each change set is rooted in exactly one new type (at present):
KlassHandle _new_type; Klass* _new_type;
void initialize(); void initialize();
public: public:
// notes the new type, marks it and all its super-types // notes the new type, marks it and all its super-types
KlassDepChange(KlassHandle new_type) KlassDepChange(Klass* new_type)
: _new_type(new_type) : _new_type(new_type)
{ {
initialize(); initialize();
@ -759,7 +759,7 @@ class KlassDepChange : public DepChange {
nm->mark_for_deoptimization(/*inc_recompile_counts=*/true); 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 // involves_context(k) is true if k is new_type or any of the super types
bool involves_context(Klass* k); bool involves_context(Klass* k);

View file

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -683,7 +683,7 @@ JavaThread* CompileBroker::make_thread(const char* name, CompileQueue* queue, Co
AbstractCompiler* comp, bool compiler_thread, TRAPS) { AbstractCompiler* comp, bool compiler_thread, TRAPS) {
JavaThread* thread = NULL; JavaThread* thread = NULL;
Klass* k = SystemDictionary::resolve_or_fail(vmSymbols::java_lang_Thread(), true, CHECK_0); 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); instanceHandle thread_oop = klass->allocate_instance_handle(CHECK_0);
Handle string = java_lang_String::create_from_str(name, CHECK_0); Handle string = java_lang_String::create_from_str(name, CHECK_0);

View file

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -28,19 +28,19 @@
#include "trace/tracing.hpp" #include "trace/tracing.hpp"
#include "utilities/globalDefinitions.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; EventObjectAllocationOutsideTLAB event;
if (event.should_commit()) { if (event.should_commit()) {
event.set_objectClass(klass()); event.set_objectClass(klass);
event.set_allocationSize(alloc_size); event.set_allocationSize(alloc_size);
event.commit(); 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; EventObjectAllocationInNewTLAB event;
if (event.should_commit()) { if (event.should_commit()) {
event.set_objectClass(klass()); event.set_objectClass(klass);
event.set_allocationSize(alloc_size); event.set_allocationSize(alloc_size);
event.set_tlabSize(tlab_size); event.set_tlabSize(tlab_size);
event.commit(); event.commit();

View file

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -30,8 +30,8 @@
class AllocTracer : AllStatic { class AllocTracer : AllStatic {
public: public:
static void send_allocation_outside_tlab_event(KlassHandle klass, 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(KlassHandle klass, size_t tlab_size, 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); static void send_allocation_requiring_gc_event(size_t size, uint gcId);
}; };

View file

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -279,7 +279,7 @@ void CollectedHeap::check_for_valid_allocation_state() {
} }
#endif #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 // Retain tlab and allocate object in shared space if
// the amount free in the tlab is too large to discard. // the amount free in the tlab is too large to discard.

View file

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -138,28 +138,28 @@ class CollectedHeap : public CHeapObj<mtInternal> {
virtual void resize_all_tlabs(); virtual void resize_all_tlabs();
// Allocate from the current thread's TLAB, with broken-out slow path. // 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); inline static HeapWord* allocate_from_tlab(Klass* klass, Thread* thread, size_t size);
static HeapWord* allocate_from_tlab_slow(KlassHandle 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 // Allocate an uninitialized block of the given size, or returns NULL if
// this is impossible. // 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 // Like allocate_init, but the block returned by a successful allocation
// is guaranteed initialized to zeros. // 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. // Helper functions for (VM) allocation.
inline static void post_allocation_setup_common(KlassHandle klass, HeapWord* obj); inline static void post_allocation_setup_common(Klass* klass, HeapWord* obj);
inline static void post_allocation_setup_no_klass_install(KlassHandle klass, inline static void post_allocation_setup_no_klass_install(Klass* klass,
HeapWord* objPtr); 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); 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. // Clears an allocated object.
inline static void init_obj(HeapWord* obj, size_t size); inline static void init_obj(HeapWord* obj, size_t size);
@ -299,10 +299,10 @@ class CollectedHeap : public CHeapObj<mtInternal> {
GCCause::Cause gc_cause() { return _gc_cause; } GCCause::Cause gc_cause() { return _gc_cause; }
// General obj/array allocation facilities. // General obj/array allocation facilities.
inline static oop obj_allocate(KlassHandle klass, int size, TRAPS); inline static oop obj_allocate(Klass* klass, int size, TRAPS);
inline static oop array_allocate(KlassHandle klass, int size, int length, TRAPS); inline static oop array_allocate(Klass* klass, int size, int length, TRAPS);
inline static oop array_allocate_nozero(KlassHandle klass, int size, int length, TRAPS); inline static oop array_allocate_nozero(Klass* klass, int size, int length, TRAPS);
inline static oop class_allocate(KlassHandle klass, int size, TRAPS); inline static oop class_allocate(Klass* klass, int size, TRAPS);
// Raw memory allocation facilities // Raw memory allocation facilities
// The obj and array allocate methods are covers for these methods. // The obj and array allocate methods are covers for these methods.

View file

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -40,26 +40,26 @@
// Inline allocation implementations. // Inline allocation implementations.
void CollectedHeap::post_allocation_setup_common(KlassHandle klass, void CollectedHeap::post_allocation_setup_common(Klass* klass,
HeapWord* obj_ptr) { HeapWord* obj_ptr) {
post_allocation_setup_no_klass_install(klass, obj_ptr); post_allocation_setup_no_klass_install(klass, obj_ptr);
oop obj = (oop)obj_ptr; oop obj = (oop)obj_ptr;
#if ! INCLUDE_ALL_GCS #if ! INCLUDE_ALL_GCS
obj->set_klass(klass()); obj->set_klass(klass);
#else #else
// Need a release store to ensure array/class length, mark word, and // Need a release store to ensure array/class length, mark word, and
// object zeroing are visible before setting the klass non-NULL, for // object zeroing are visible before setting the klass non-NULL, for
// concurrent collectors. // concurrent collectors.
obj->release_set_klass(klass()); obj->release_set_klass(klass);
#endif #endif
} }
void CollectedHeap::post_allocation_setup_no_klass_install(KlassHandle klass, void CollectedHeap::post_allocation_setup_no_klass_install(Klass* klass,
HeapWord* obj_ptr) { HeapWord* obj_ptr) {
oop obj = (oop)obj_ptr; oop obj = (oop)obj_ptr;
assert(obj != NULL, "NULL object pointer"); assert(obj != NULL, "NULL object pointer");
if (UseBiasedLocking && (klass() != NULL)) { if (UseBiasedLocking && (klass != NULL)) {
obj->set_mark(klass->prototype_header()); obj->set_mark(klass->prototype_header());
} else { } else {
// May be bootstrapping // May be bootstrapping
@ -68,7 +68,7 @@ void CollectedHeap::post_allocation_setup_no_klass_install(KlassHandle klass,
} }
// Support for jvmti and dtrace // 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) // support low memory notifications (no-op if not enabled)
LowMemoryDetector::detect_low_memory_for_collected_pools(); LowMemoryDetector::detect_low_memory_for_collected_pools();
@ -77,13 +77,13 @@ inline void post_allocation_notify(KlassHandle klass, oop obj, int size) {
if (DTraceAllocProbes) { if (DTraceAllocProbes) {
// support for Dtrace object alloc event (no-op most of the time) // 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); 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, HeapWord* obj_ptr,
int size) { int size) {
post_allocation_setup_common(klass, obj_ptr); post_allocation_setup_common(klass, obj_ptr);
@ -94,7 +94,7 @@ void CollectedHeap::post_allocation_setup_obj(KlassHandle klass,
post_allocation_notify(klass, obj, size); 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, HeapWord* obj_ptr,
int size) { int size) {
// Set oop_size field before setting the _klass field because a // Set oop_size field before setting the _klass field because a
@ -110,7 +110,7 @@ void CollectedHeap::post_allocation_setup_class(KlassHandle klass,
post_allocation_notify(klass, new_cls, size); 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, HeapWord* obj_ptr,
int length) { int length) {
// Set array length before setting the _klass field because a // Set array length before setting the _klass field because a
@ -125,7 +125,7 @@ void CollectedHeap::post_allocation_setup_array(KlassHandle klass,
post_allocation_notify(klass, new_obj, new_obj->size()); 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 // Clear unhandled oops for memory allocation. Memory allocation might
// not take out a lock if from tlab, so clear here. // not take out a lock if from tlab, so clear here.
@ -186,13 +186,13 @@ HeapWord* CollectedHeap::common_mem_allocate_noinit(KlassHandle klass, size_t si
} }
} }
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); HeapWord* obj = common_mem_allocate_noinit(klass, size, CHECK_NULL);
init_obj(obj, size); init_obj(obj, size);
return obj; 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"); assert(UseTLAB, "should use UseTLAB");
HeapWord* obj = thread->tlab().allocate(size); HeapWord* obj = thread->tlab().allocate(size);
@ -211,7 +211,7 @@ void CollectedHeap::init_obj(HeapWord* obj, size_t size) {
Copy::fill_to_aligned_words(obj + hs, size - hs); 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()); debug_only(check_for_valid_allocation_state());
assert(!Universe::heap()->is_gc_active(), "Allocation during gc not allowed"); assert(!Universe::heap()->is_gc_active(), "Allocation during gc not allowed");
assert(size >= 0, "int won't convert to size_t"); assert(size >= 0, "int won't convert to size_t");
@ -221,7 +221,7 @@ oop CollectedHeap::obj_allocate(KlassHandle klass, int size, TRAPS) {
return (oop)obj; 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()); debug_only(check_for_valid_allocation_state());
assert(!Universe::heap()->is_gc_active(), "Allocation during gc not allowed"); assert(!Universe::heap()->is_gc_active(), "Allocation during gc not allowed");
assert(size >= 0, "int won't convert to size_t"); assert(size >= 0, "int won't convert to size_t");
@ -231,7 +231,7 @@ oop CollectedHeap::class_allocate(KlassHandle klass, int size, TRAPS) {
return (oop)obj; return (oop)obj;
} }
oop CollectedHeap::array_allocate(KlassHandle klass, oop CollectedHeap::array_allocate(Klass* klass,
int size, int size,
int length, int length,
TRAPS) { TRAPS) {
@ -244,7 +244,7 @@ oop CollectedHeap::array_allocate(KlassHandle klass,
return (oop)obj; return (oop)obj;
} }
oop CollectedHeap::array_allocate_nozero(KlassHandle klass, oop CollectedHeap::array_allocate_nozero(Klass* klass,
int size, int size,
int length, int length,
TRAPS) { TRAPS) {

View file

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -138,8 +138,8 @@ IRT_END
// Allocation // Allocation
IRT_ENTRY(void, InterpreterRuntime::_new(JavaThread* thread, ConstantPool* pool, int index)) IRT_ENTRY(void, InterpreterRuntime::_new(JavaThread* thread, ConstantPool* pool, int index))
Klass* k_oop = pool->klass_at(index, CHECK); Klass* k = pool->klass_at(index, CHECK);
instanceKlassHandle klass (THREAD, k_oop); InstanceKlass* klass = InstanceKlass::cast(k);
// Make sure we are not instantiating an abstract klass // Make sure we are not instantiating an abstract klass
klass->check_valid_for_instantiation(true, CHECK); klass->check_valid_for_instantiation(true, CHECK);
@ -461,8 +461,8 @@ IRT_ENTRY(address, InterpreterRuntime::exception_handler_for_exception(JavaThrea
Exceptions::debug_check_abort(h_exception); Exceptions::debug_check_abort(h_exception);
// exception handler lookup // exception handler lookup
KlassHandle h_klass(THREAD, h_exception->klass()); Klass* klass = h_exception->klass();
handler_bci = Method::fast_exception_handler_bci_for(h_method, h_klass, current_bci, THREAD); handler_bci = Method::fast_exception_handler_bci_for(h_method, klass, current_bci, THREAD);
if (HAS_PENDING_EXCEPTION) { if (HAS_PENDING_EXCEPTION) {
// We threw an exception while trying to find the exception handler. // We threw an exception while trying to find the exception handler.
// Transfer the new exception to the exception handle which will // Transfer the new exception to the exception handle which will
@ -1070,15 +1070,15 @@ ConstantPoolCacheEntry *cp_entry))
// non-static field accessors have an object, but we need a handle // non-static field accessors have an object, but we need a handle
h_obj = Handle(thread, obj); h_obj = Handle(thread, obj);
} }
instanceKlassHandle h_cp_entry_f1(thread, (Klass*)cp_entry->f1_as_klass()); InstanceKlass* cp_entry_f1 = InstanceKlass::cast(cp_entry->f1_as_klass());
jfieldID fid = jfieldIDWorkaround::to_jfieldID(h_cp_entry_f1, cp_entry->f2_as_index(), is_static); jfieldID fid = jfieldIDWorkaround::to_jfieldID(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); JvmtiExport::post_field_access(thread, method(thread), bcp(thread), cp_entry_f1, h_obj, fid);
IRT_END IRT_END
IRT_ENTRY(void, InterpreterRuntime::post_field_modification(JavaThread *thread, IRT_ENTRY(void, InterpreterRuntime::post_field_modification(JavaThread *thread,
oopDesc* obj, ConstantPoolCacheEntry *cp_entry, jvalue *value)) 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 // check the access_flags for the field in the klass
InstanceKlass* ik = InstanceKlass::cast(k); InstanceKlass* ik = InstanceKlass::cast(k);
@ -1103,8 +1103,7 @@ IRT_ENTRY(void, InterpreterRuntime::post_field_modification(JavaThread *thread,
bool is_static = (obj == NULL); bool is_static = (obj == NULL);
HandleMark hm(thread); HandleMark hm(thread);
instanceKlassHandle h_klass(thread, k); jfieldID fid = jfieldIDWorkaround::to_jfieldID(ik, cp_entry->f2_as_index(), is_static);
jfieldID fid = jfieldIDWorkaround::to_jfieldID(h_klass, cp_entry->f2_as_index(), is_static);
jvalue fvalue; jvalue fvalue;
#ifdef _LP64 #ifdef _LP64
fvalue = *value; fvalue = *value;
@ -1128,7 +1127,7 @@ IRT_ENTRY(void, InterpreterRuntime::post_field_modification(JavaThread *thread,
h_obj = Handle(thread, obj); 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); fid, sig_type, &fvalue);
IRT_END IRT_END

View file

@ -55,14 +55,14 @@
// Implementation of CallInfo // 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; int vtable_index = Method::nonvirtual_vtable_index;
set_common(resolved_klass, resolved_klass, resolved_method, resolved_method, CallInfo::direct_call, vtable_index, CHECK); set_common(resolved_klass, resolved_klass, resolved_method, resolved_method, CallInfo::direct_call, vtable_index, CHECK);
} }
void CallInfo::set_interface(KlassHandle resolved_klass, void CallInfo::set_interface(Klass* resolved_klass,
KlassHandle selected_klass, Klass* selected_klass,
const methodHandle& resolved_method, const methodHandle& resolved_method,
const methodHandle& selected_method, const methodHandle& selected_method,
int itable_index, TRAPS) { int itable_index, TRAPS) {
@ -75,8 +75,8 @@ void CallInfo::set_interface(KlassHandle resolved_klass,
set_common(resolved_klass, selected_klass, resolved_method, selected_method, CallInfo::itable_call, itable_index, CHECK); set_common(resolved_klass, selected_klass, resolved_method, selected_method, CallInfo::itable_call, itable_index, CHECK);
} }
void CallInfo::set_virtual(KlassHandle resolved_klass, void CallInfo::set_virtual(Klass* resolved_klass,
KlassHandle selected_klass, Klass* selected_klass,
const methodHandle& resolved_method, const methodHandle& resolved_method,
const methodHandle& selected_method, const methodHandle& selected_method,
int vtable_index, TRAPS) { int vtable_index, TRAPS) {
@ -93,7 +93,7 @@ void CallInfo::set_handle(const methodHandle& resolved_method,
set_handle(SystemDictionary::MethodHandle_klass(), resolved_method, resolved_appendix, resolved_method_type, CHECK); 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, const methodHandle& resolved_method,
Handle resolved_appendix, Handle resolved_appendix,
Handle resolved_method_type, TRAPS) { Handle resolved_method_type, TRAPS) {
@ -110,8 +110,8 @@ void CallInfo::set_handle(KlassHandle resolved_klass,
_resolved_method_type = resolved_method_type; _resolved_method_type = resolved_method_type;
} }
void CallInfo::set_common(KlassHandle resolved_klass, void CallInfo::set_common(Klass* resolved_klass,
KlassHandle selected_klass, Klass* selected_klass,
const methodHandle& resolved_method, const methodHandle& resolved_method,
const methodHandle& selected_method, const methodHandle& selected_method,
CallKind kind, CallKind kind,
@ -162,8 +162,8 @@ CallInfo::CallInfo(Method* resolved_method, Klass* resolved_klass) {
#ifdef ASSERT #ifdef ASSERT
// Ensure that this is really the case. // Ensure that this is really the case.
KlassHandle object_klass = SystemDictionary::Object_klass(); Klass* object_klass = SystemDictionary::Object_klass();
Method * object_resolved_method = object_klass()->vtable()->method_at(index); Method * object_resolved_method = object_klass->vtable()->method_at(index);
assert(object_resolved_method->name() == resolved_method->name(), assert(object_resolved_method->name() == resolved_method->name(),
"Object and interface method names should match at vtable index %d, %s != %s", "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()); index, object_resolved_method->name()->as_C_string(), resolved_method->name()->as_C_string());
@ -225,14 +225,13 @@ void CallInfo::print() {
LinkInfo::LinkInfo(const constantPoolHandle& pool, int index, methodHandle current_method, TRAPS) { LinkInfo::LinkInfo(const constantPoolHandle& pool, int index, methodHandle current_method, TRAPS) {
// resolve klass // resolve klass
Klass* result = pool->klass_ref_at(index, CHECK); _resolved_klass = pool->klass_ref_at(index, CHECK);
_resolved_klass = KlassHandle(THREAD, result);
// Get name, signature, and static klass // Get name, signature, and static klass
_name = pool->name_ref_at(index); _name = pool->name_ref_at(index);
_signature = pool->signature_ref_at(index); _signature = pool->signature_ref_at(index);
_tag = pool->tag_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; _current_method = current_method;
// Coming from the constant pool always checks access // Coming from the constant pool always checks access
@ -241,14 +240,13 @@ LinkInfo::LinkInfo(const constantPoolHandle& pool, int index, methodHandle curre
LinkInfo::LinkInfo(const constantPoolHandle& pool, int index, TRAPS) { LinkInfo::LinkInfo(const constantPoolHandle& pool, int index, TRAPS) {
// resolve klass // resolve klass
Klass* result = pool->klass_ref_at(index, CHECK); _resolved_klass = pool->klass_ref_at(index, CHECK);
_resolved_klass = KlassHandle(THREAD, result);
// Get name, signature, and static klass // Get name, signature, and static klass
_name = pool->name_ref_at(index); _name = pool->name_ref_at(index);
_signature = pool->signature_ref_at(index); _signature = pool->signature_ref_at(index);
_tag = pool->tag_ref_at(index); _tag = pool->tag_ref_at(index);
_current_klass = KlassHandle(THREAD, pool->pool_holder()); _current_klass = pool->pool_holder();
_current_method = methodHandle(); _current_method = methodHandle();
// Coming from the constant pool always checks access // Coming from the constant pool always checks access
@ -256,7 +254,7 @@ LinkInfo::LinkInfo(const constantPoolHandle& pool, int index, TRAPS) {
} }
char* LinkInfo::method_string() const { 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 #ifndef PRODUCT
@ -266,20 +264,20 @@ void LinkInfo::print() {
_resolved_klass->name()->as_C_string(), _resolved_klass->name()->as_C_string(),
_name->as_C_string(), _name->as_C_string(),
_signature->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"); _check_access ? "true" : "false");
} }
#endif // PRODUCT #endif // PRODUCT
//------------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------------
// Klass resolution // 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::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) { if (vca_result != Reflection::ACCESS_OK) {
ResourceMark rm(THREAD); ResourceMark rm(THREAD);
char* msg = Reflection::verify_class_access_msg(ref_klass(), char* msg = Reflection::verify_class_access_msg(ref_klass,
InstanceKlass::cast(sel_klass()), InstanceKlass::cast(sel_klass),
vca_result); vca_result);
if (msg == NULL) { if (msg == NULL) {
Exceptions::fthrow( Exceptions::fthrow(
@ -308,7 +306,7 @@ void LinkResolver::check_klass_accessability(KlassHandle ref_klass, KlassHandle
methodHandle LinkResolver::lookup_method_in_klasses(const LinkInfo& link_info, methodHandle LinkResolver::lookup_method_in_klasses(const LinkInfo& link_info,
bool checkpolymorphism, bool checkpolymorphism,
bool in_imethod_resolve, TRAPS) { bool in_imethod_resolve, TRAPS) {
KlassHandle klass = link_info.resolved_klass(); Klass* klass = link_info.resolved_klass();
Symbol* name = link_info.name(); Symbol* name = link_info.name();
Symbol* signature = link_info.signature(); Symbol* signature = link_info.signature();
@ -320,7 +318,7 @@ methodHandle LinkResolver::lookup_method_in_klasses(const LinkInfo& link_info,
return methodHandle(THREAD, result); 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 // JDK 8, JVMS 5.4.3.4: Interface method resolution should
// ignore static and non-public methods of java.lang.Object, // ignore static and non-public methods of java.lang.Object,
@ -358,7 +356,7 @@ methodHandle LinkResolver::lookup_method_in_klasses(const LinkInfo& link_info,
// returns first instance method // returns first instance method
// Looks up method in classes, then looks up local default methods // 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* name,
Symbol* signature, TRAPS) { Symbol* signature, TRAPS) {
Method* result = klass->uncached_lookup_method(name, signature, Klass::find_overpass); Method* result = klass->uncached_lookup_method(name, signature, Klass::find_overpass);
@ -374,7 +372,7 @@ methodHandle LinkResolver::lookup_instance_method_in_klasses(KlassHandle klass,
} }
if (result == NULL) { 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) { if (default_methods != NULL) {
result = InstanceKlass::find_method(default_methods, name, signature); result = InstanceKlass::find_method(default_methods, name, signature);
assert(result == NULL || !result->is_static(), "static defaults not allowed"); assert(result == NULL || !result->is_static(), "static defaults not allowed");
@ -383,13 +381,13 @@ methodHandle LinkResolver::lookup_instance_method_in_klasses(KlassHandle klass,
return methodHandle(THREAD, result); 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) { const methodHandle& resolved_method) {
int vtable_index = Method::invalid_vtable_index; int vtable_index = Method::invalid_vtable_index;
Symbol* name = resolved_method->name(); Symbol* name = resolved_method->name();
Symbol* signature = resolved_method->signature(); Symbol* signature = resolved_method->signature();
InstanceKlass* ik = InstanceKlass::cast(klass()); InstanceKlass* ik = InstanceKlass::cast(klass);
// First check in default method array // First check in default method array
if (!resolved_method->is_abstract() && ik->default_methods() != NULL) { if (!resolved_method->is_abstract() && ik->default_methods() != NULL) {
@ -410,7 +408,7 @@ int LinkResolver::vtable_index_of_interface_method(KlassHandle klass,
} }
methodHandle LinkResolver::lookup_method_in_interfaces(const LinkInfo& cp_info, TRAPS) { 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 // Specify 'true' in order to skip default methods when searching the
// interfaces. Function lookup_method_in_klasses() already looked for // interfaces. Function lookup_method_in_klasses() already looked for
@ -425,7 +423,7 @@ methodHandle LinkResolver::lookup_polymorphic_method(
Handle *appendix_result_or_null, Handle *appendix_result_or_null,
Handle *method_type_result, Handle *method_type_result,
TRAPS) { TRAPS) {
KlassHandle klass = link_info.resolved_klass(); Klass* klass = link_info.resolved_klass();
Symbol* name = link_info.name(); Symbol* name = link_info.name();
Symbol* full_signature = link_info.signature(); Symbol* full_signature = link_info.signature();
@ -436,8 +434,8 @@ methodHandle LinkResolver::lookup_polymorphic_method(
vmIntrinsics::name_at(iid), klass->external_name(), vmIntrinsics::name_at(iid), klass->external_name(),
name->as_C_string(), full_signature->as_C_string()); name->as_C_string(), full_signature->as_C_string());
} }
if ((klass() == SystemDictionary::MethodHandle_klass() || if ((klass == SystemDictionary::MethodHandle_klass() ||
klass() == SystemDictionary::VarHandle_klass()) && klass == SystemDictionary::VarHandle_klass()) &&
iid != vmIntrinsics::_none) { iid != vmIntrinsics::_none) {
if (MethodHandles::is_signature_polymorphic_intrinsic(iid)) { 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. // Most of these do not need an up-call to Java to resolve, so can be done anywhere.
@ -531,9 +529,9 @@ methodHandle LinkResolver::lookup_polymorphic_method(
return NULL; return NULL;
} }
void LinkResolver::check_method_accessability(KlassHandle ref_klass, void LinkResolver::check_method_accessability(Klass* ref_klass,
KlassHandle resolved_klass, Klass* resolved_klass,
KlassHandle sel_klass, Klass* sel_klass,
const methodHandle& sel_method, const methodHandle& sel_method,
TRAPS) { TRAPS) {
@ -547,7 +545,7 @@ void LinkResolver::check_method_accessability(KlassHandle ref_klass,
// We'll check for the method name first, as that's most likely // 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). // to be false (so we'll short-circuit out of these tests).
if (sel_method->name() == vmSymbols::clone_name() && if (sel_method->name() == vmSymbols::clone_name() &&
sel_klass() == SystemDictionary::Object_klass() && sel_klass == SystemDictionary::Object_klass() &&
resolved_klass->is_array_klass()) { resolved_klass->is_array_klass()) {
// We need to change "protected" to "public". // We need to change "protected" to "public".
assert(flags.is_protected(), "clone not protected?"); assert(flags.is_protected(), "clone not protected?");
@ -558,9 +556,9 @@ void LinkResolver::check_method_accessability(KlassHandle ref_klass,
} }
// assert(extra_arg_result_or_null != NULL, "must be able to return extra argument"); // assert(extra_arg_result_or_null != NULL, "must be able to return extra argument");
if (!Reflection::verify_field_access(ref_klass(), if (!Reflection::verify_field_access(ref_klass,
resolved_klass(), resolved_klass,
sel_klass(), sel_klass,
flags, flags,
true)) { true)) {
ResourceMark rm(THREAD); ResourceMark rm(THREAD);
@ -586,22 +584,21 @@ methodHandle LinkResolver::resolve_method_statically(Bytecodes::Code code,
// It appears to fail when applied to an invokeinterface call site. // 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. // FIXME: Remove this method and ciMethod::check_call; refactor to use the other LinkResolver entry points.
// resolve klass // resolve klass
KlassHandle resolved_klass;
if (code == Bytecodes::_invokedynamic) { if (code == Bytecodes::_invokedynamic) {
resolved_klass = SystemDictionary::MethodHandle_klass(); Klass* resolved_klass = SystemDictionary::MethodHandle_klass();
Symbol* method_name = vmSymbols::invoke_name(); Symbol* method_name = vmSymbols::invoke_name();
Symbol* method_signature = pool->signature_ref_at(index); 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); LinkInfo link_info(resolved_klass, method_name, method_signature, current_klass);
return resolve_method(link_info, code, THREAD); return resolve_method(link_info, code, THREAD);
} }
LinkInfo link_info(pool, index, methodHandle(), CHECK_NULL); 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() if (pool->has_preresolution()
|| (resolved_klass() == SystemDictionary::MethodHandle_klass() && || (resolved_klass == SystemDictionary::MethodHandle_klass() &&
MethodHandles::is_signature_polymorphic_name(resolved_klass(), link_info.name()))) { MethodHandles::is_signature_polymorphic_name(resolved_klass, link_info.name()))) {
Method* result = ConstantPool::method_at_if_loaded(pool, index); Method* result = ConstantPool::method_at_if_loaded(pool, index);
if (result != NULL) { if (result != NULL) {
return methodHandle(THREAD, result); return methodHandle(THREAD, result);
@ -652,8 +649,8 @@ void LinkResolver::check_method_loader_constraints(const LinkInfo& link_info,
} }
void LinkResolver::check_field_loader_constraints(Symbol* field, Symbol* sig, void LinkResolver::check_field_loader_constraints(Symbol* field, Symbol* sig,
KlassHandle current_klass, Klass* current_klass,
KlassHandle sel_klass, TRAPS) { Klass* sel_klass, TRAPS) {
Handle ref_loader(THREAD, current_klass->class_loader()); Handle ref_loader(THREAD, current_klass->class_loader());
Handle sel_loader(THREAD, sel_klass->class_loader()); Handle sel_loader(THREAD, sel_klass->class_loader());
@ -686,14 +683,14 @@ methodHandle LinkResolver::resolve_method(const LinkInfo& link_info,
Bytecodes::Code code, TRAPS) { Bytecodes::Code code, TRAPS) {
Handle nested_exception; 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 // 1. For invokevirtual, cannot call an interface method
if (code == Bytecodes::_invokevirtual && resolved_klass->is_interface()) { if (code == Bytecodes::_invokevirtual && resolved_klass->is_interface()) {
ResourceMark rm(THREAD); ResourceMark rm(THREAD);
char buf[200]; char buf[200];
jio_snprintf(buf, sizeof(buf), "Found interface %s, but class was expected", 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); THROW_MSG_NULL(vmSymbols::java_lang_IncompatibleClassChangeError(), buf);
} }
@ -727,21 +724,21 @@ methodHandle LinkResolver::resolve_method(const LinkInfo& link_info,
if (resolved_method.is_null()) { if (resolved_method.is_null()) {
ResourceMark rm(THREAD); ResourceMark rm(THREAD);
THROW_MSG_CAUSE_(vmSymbols::java_lang_NoSuchMethodError(), 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.name(),
link_info.signature()), link_info.signature()),
nested_exception, NULL); nested_exception, NULL);
} }
// 6. access checks, access checking may be turned off when calling from within the VM. // 5. access checks, access checking may be turned off when calling from within the VM.
KlassHandle current_klass = link_info.current_klass(); Klass* current_klass = link_info.current_klass();
if (link_info.check_access()) { 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 if method can be accessed by the referring class
check_method_accessability(current_klass, check_method_accessability(current_klass,
resolved_klass, resolved_klass,
KlassHandle(THREAD, resolved_method->method_holder()), resolved_method->method_holder(),
resolved_method, resolved_method,
CHECK_NULL); CHECK_NULL);
@ -753,8 +750,8 @@ methodHandle LinkResolver::resolve_method(const LinkInfo& link_info,
} }
static void trace_method_resolution(const char* prefix, static void trace_method_resolution(const char* prefix,
KlassHandle klass, Klass* klass,
KlassHandle resolved_klass, Klass* resolved_klass,
const methodHandle& method, const methodHandle& method,
bool logitables, bool logitables,
int index = -1) { int index = -1) {
@ -768,9 +765,9 @@ static void trace_method_resolution(const char* prefix,
} }
st->print("%s%s, compile-time-class:%s, method:%s, method_holder:%s, access_flags: ", st->print("%s%s, compile-time-class:%s, method:%s, method_holder:%s, access_flags: ",
prefix, prefix,
(klass.is_null() ? "<NULL>" : klass->internal_name()), (klass == NULL ? "<NULL>" : klass->internal_name()),
(resolved_klass.is_null() ? "<NULL>" : resolved_klass->internal_name()), (resolved_klass == NULL ? "<NULL>" : resolved_klass->internal_name()),
Method::name_and_sig_as_C_string(resolved_klass(), Method::name_and_sig_as_C_string(resolved_klass,
method->name(), method->name(),
method->signature()), method->signature()),
method->method_holder()->internal_name()); method->method_holder()->internal_name());
@ -785,13 +782,13 @@ static void trace_method_resolution(const char* prefix,
// Do linktime resolution of a method in the interface within the context of the specied bytecode. // 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) { 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 // check if klass is interface
if (!resolved_klass->is_interface()) { if (!resolved_klass->is_interface()) {
ResourceMark rm(THREAD); ResourceMark rm(THREAD);
char buf[200]; 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); THROW_MSG_NULL(vmSymbols::java_lang_IncompatibleClassChangeError(), buf);
} }
@ -816,21 +813,21 @@ methodHandle LinkResolver::resolve_interface_method(const LinkInfo& link_info, B
// no method found // no method found
ResourceMark rm(THREAD); ResourceMark rm(THREAD);
THROW_MSG_NULL(vmSymbols::java_lang_NoSuchMethodError(), 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.name(),
link_info.signature())); link_info.signature()));
} }
if (link_info.check_access()) { if (link_info.check_access()) {
// JDK8 adds non-public interface methods, and accessability check requirement // 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 if method can be accessed by the referring class
check_method_accessability(current_klass, check_method_accessability(current_klass,
resolved_klass, resolved_klass,
KlassHandle(THREAD, resolved_method->method_holder()), resolved_method->method_holder(),
resolved_method, resolved_method,
CHECK_NULL); CHECK_NULL);
@ -841,7 +838,7 @@ methodHandle LinkResolver::resolve_interface_method(const LinkInfo& link_info, B
ResourceMark rm(THREAD); ResourceMark rm(THREAD);
char buf[200]; char buf[200];
jio_snprintf(buf, sizeof(buf), "Expected instance not static method %s", 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())); resolved_method->name(), resolved_method->signature()));
THROW_MSG_NULL(vmSymbols::java_lang_IncompatibleClassChangeError(), buf); THROW_MSG_NULL(vmSymbols::java_lang_IncompatibleClassChangeError(), buf);
} }
@ -850,12 +847,12 @@ methodHandle LinkResolver::resolve_interface_method(const LinkInfo& link_info, B
ResourceMark rm(THREAD); ResourceMark rm(THREAD);
char buf[200]; 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", 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->name(),
resolved_method->signature()), 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); THROW_MSG_NULL(vmSymbols::java_lang_IncompatibleClassChangeError(), buf);
} }
@ -873,14 +870,14 @@ methodHandle LinkResolver::resolve_interface_method(const LinkInfo& link_info, B
//------------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------------
// Field resolution // Field resolution
void LinkResolver::check_field_accessability(KlassHandle ref_klass, void LinkResolver::check_field_accessability(Klass* ref_klass,
KlassHandle resolved_klass, Klass* resolved_klass,
KlassHandle sel_klass, Klass* sel_klass,
const fieldDescriptor& fd, const fieldDescriptor& fd,
TRAPS) { TRAPS) {
if (!Reflection::verify_field_access(ref_klass(), if (!Reflection::verify_field_access(ref_klass,
resolved_klass(), resolved_klass,
sel_klass(), sel_klass,
fd.access_flags(), fd.access_flags(),
true)) { true)) {
ResourceMark rm(THREAD); ResourceMark rm(THREAD);
@ -913,19 +910,19 @@ void LinkResolver::resolve_field(fieldDescriptor& fd,
bool is_static = (byte == Bytecodes::_getstatic || byte == Bytecodes::_putstatic); bool is_static = (byte == Bytecodes::_getstatic || byte == Bytecodes::_putstatic);
bool is_put = (byte == Bytecodes::_putfield || byte == Bytecodes::_putstatic || byte == Bytecodes::_nofast_putfield); bool is_put = (byte == Bytecodes::_putfield || byte == Bytecodes::_putstatic || byte == Bytecodes::_nofast_putfield);
// Check if there's a resolved klass containing the field // 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* field = link_info.name();
Symbol* sig = link_info.signature(); Symbol* sig = link_info.signature();
if (resolved_klass.is_null()) { if (resolved_klass == NULL) {
ResourceMark rm(THREAD); ResourceMark rm(THREAD);
THROW_MSG(vmSymbols::java_lang_NoSuchFieldError(), field->as_C_string()); THROW_MSG(vmSymbols::java_lang_NoSuchFieldError(), field->as_C_string());
} }
// Resolve instance field // 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 // 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); ResourceMark rm(THREAD);
THROW_MSG(vmSymbols::java_lang_NoSuchFieldError(), field->as_C_string()); THROW_MSG(vmSymbols::java_lang_NoSuchFieldError(), field->as_C_string());
} }
@ -935,14 +932,14 @@ void LinkResolver::resolve_field(fieldDescriptor& fd,
return; return;
// check access // 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_field_accessability(current_klass, resolved_klass, sel_klass, fd, CHECK);
// check for errors // check for errors
if (is_static != fd.is_static()) { if (is_static != fd.is_static()) {
ResourceMark rm(THREAD); ResourceMark rm(THREAD);
char msg[200]; 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); THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(), msg);
} }
@ -954,10 +951,10 @@ void LinkResolver::resolve_field(fieldDescriptor& fd,
ResourceMark rm(THREAD); ResourceMark rm(THREAD);
stringStream ss; 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", 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(), is_static ? "static" : "non-static", resolved_klass->external_name(), fd.name()->as_C_string(),
current_klass()->external_name()); current_klass->external_name());
THROW_MSG(vmSymbols::java_lang_IllegalAccessError(), ss.as_string()); THROW_MSG(vmSymbols::java_lang_IllegalAccessError(), ss.as_string());
} }
@ -973,7 +970,7 @@ void LinkResolver::resolve_field(fieldDescriptor& fd,
if (is_initialized_static_final_update || is_initialized_instance_final_update) { 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 ", 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(), m()->name()->as_C_string(),
is_static ? "<clinit>" : "<init>"); is_static ? "<clinit>" : "<init>");
THROW_MSG(vmSymbols::java_lang_IllegalAccessError(), ss.as_string()); THROW_MSG(vmSymbols::java_lang_IllegalAccessError(), ss.as_string());
@ -991,7 +988,7 @@ void LinkResolver::resolve_field(fieldDescriptor& fd,
sel_klass->initialize(CHECK); 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); check_field_loader_constraints(field, sig, current_klass, sel_klass, CHECK);
} }
@ -1017,7 +1014,7 @@ void LinkResolver::resolve_static_call(CallInfo& result,
methodHandle resolved_method = linktime_resolve_static_method(link_info, CHECK); methodHandle resolved_method = linktime_resolve_static_method(link_info, CHECK);
// The resolved class can change as a result of this resolution. // 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) // Initialize klass (this should only happen if everything is ok)
if (initialize_class && resolved_klass->should_be_initialized()) { if (initialize_class && resolved_klass->should_be_initialized()) {
@ -1036,7 +1033,7 @@ void LinkResolver::resolve_static_call(CallInfo& result,
// throws linktime exceptions // throws linktime exceptions
methodHandle LinkResolver::linktime_resolve_static_method(const LinkInfo& link_info, TRAPS) { 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; methodHandle resolved_method;
if (!resolved_klass->is_interface()) { if (!resolved_klass->is_interface()) {
resolved_method = resolve_method(link_info, Bytecodes::_invokestatic, CHECK_NULL); resolved_method = resolve_method(link_info, Bytecodes::_invokestatic, CHECK_NULL);
@ -1049,7 +1046,7 @@ methodHandle LinkResolver::linktime_resolve_static_method(const LinkInfo& link_i
if (!resolved_method->is_static()) { if (!resolved_method->is_static()) {
ResourceMark rm(THREAD); ResourceMark rm(THREAD);
char buf[200]; 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->name(),
resolved_method->signature())); resolved_method->signature()));
THROW_MSG_NULL(vmSymbols::java_lang_IncompatibleClassChangeError(), buf); THROW_MSG_NULL(vmSymbols::java_lang_IncompatibleClassChangeError(), buf);
@ -1078,7 +1075,7 @@ methodHandle LinkResolver::linktime_resolve_special_method(const LinkInfo& link_
// superclass.method, which can also resolve to a default method // superclass.method, which can also resolve to a default method
// and the selected method is recalculated relative to the direct superclass // and the selected method is recalculated relative to the direct superclass
// superinterface.method, which explicitly does not check shadowing // 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; methodHandle resolved_method;
if (!resolved_klass->is_interface()) { if (!resolved_klass->is_interface()) {
@ -1089,7 +1086,7 @@ methodHandle LinkResolver::linktime_resolve_special_method(const LinkInfo& link_
// check if method name is <init>, that it is found in same klass as static type // check if method name is <init>, that it is found in same klass as static type
if (resolved_method->name() == vmSymbols::object_initializer_name() && if (resolved_method->name() == vmSymbols::object_initializer_name() &&
resolved_method->method_holder() != resolved_klass()) { resolved_method->method_holder() != resolved_klass) {
ResourceMark rm(THREAD); ResourceMark rm(THREAD);
Exceptions::fthrow( Exceptions::fthrow(
THREAD_AND_LOCATION, THREAD_AND_LOCATION,
@ -1103,22 +1100,23 @@ methodHandle LinkResolver::linktime_resolve_special_method(const LinkInfo& link_
} }
// check if invokespecial's interface method reference is in an indirect superinterface // check if invokespecial's interface method reference is in an indirect superinterface
KlassHandle current_klass = link_info.current_klass(); Klass* current_klass = link_info.current_klass();
if (!current_klass.is_null() && resolved_klass->is_interface()) { if (current_klass != NULL && resolved_klass->is_interface()) {
Klass *klass_to_check = !InstanceKlass::cast(current_klass())->is_anonymous() ? InstanceKlass* ck = InstanceKlass::cast(current_klass);
current_klass() : InstanceKlass *klass_to_check = !ck->is_anonymous() ?
InstanceKlass::cast(current_klass())->host_klass(); ck :
InstanceKlass::cast(ck->host_klass());
// Disable verification for the dynamically-generated reflection bytecodes. // Disable verification for the dynamically-generated reflection bytecodes.
bool is_reflect = klass_to_check->is_subclass_of( bool is_reflect = klass_to_check->is_subclass_of(
SystemDictionary::reflect_MagicAccessorImpl_klass()); SystemDictionary::reflect_MagicAccessorImpl_klass());
if (!is_reflect && 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); ResourceMark rm(THREAD);
char buf[200]; char buf[200];
jio_snprintf(buf, sizeof(buf), jio_snprintf(buf, sizeof(buf),
"Interface method reference: %s, is in an indirect superinterface of %s", "Interface method reference: %s, is in an indirect superinterface of %s",
Method::name_and_sig_as_C_string(resolved_klass(), Method::name_and_sig_as_C_string(resolved_klass,
resolved_method->name(), resolved_method->name(),
resolved_method->signature()), resolved_method->signature()),
current_klass->external_name()); current_klass->external_name());
@ -1132,7 +1130,7 @@ methodHandle LinkResolver::linktime_resolve_special_method(const LinkInfo& link_
char buf[200]; char buf[200];
jio_snprintf(buf, sizeof(buf), jio_snprintf(buf, sizeof(buf),
"Expecting non-static method %s", "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->name(),
resolved_method->signature())); resolved_method->signature()));
THROW_MSG_NULL(vmSymbols::java_lang_IncompatibleClassChangeError(), buf); THROW_MSG_NULL(vmSymbols::java_lang_IncompatibleClassChangeError(), buf);
@ -1149,8 +1147,8 @@ methodHandle LinkResolver::linktime_resolve_special_method(const LinkInfo& link_
// throws runtime exceptions // throws runtime exceptions
void LinkResolver::runtime_resolve_special_method(CallInfo& result, void LinkResolver::runtime_resolve_special_method(CallInfo& result,
const methodHandle& resolved_method, const methodHandle& resolved_method,
KlassHandle resolved_klass, Klass* resolved_klass,
KlassHandle current_klass, Klass* current_klass,
bool check_access, TRAPS) { bool check_access, TRAPS) {
// resolved method is selected method unless we have an old-style lookup // resolved method is selected method unless we have an old-style lookup
@ -1160,9 +1158,6 @@ void LinkResolver::runtime_resolve_special_method(CallInfo& result,
methodHandle sel_method(THREAD, resolved_method()); methodHandle sel_method(THREAD, resolved_method());
// check if this is an old-style super call and do a new lookup if so // 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 && if (check_access &&
// a) check if ACC_SUPER flag is set for the current class // a) check if ACC_SUPER flag is set for the current class
(current_klass->is_super() || !AllowNonVirtualCalls) && (current_klass->is_super() || !AllowNonVirtualCalls) &&
@ -1170,12 +1165,12 @@ void LinkResolver::runtime_resolve_special_method(CallInfo& result,
// (not supertype in order to exclude interface classes) of the current class. // (not supertype in order to exclude interface classes) of the current class.
// This check is not performed for super.invoke for interface methods // This check is not performed for super.invoke for interface methods
// in super interfaces. // in super interfaces.
current_klass->is_subclass_of(resolved_klass()) && current_klass->is_subclass_of(resolved_klass) &&
current_klass() != resolved_klass() && current_klass != resolved_klass &&
// c) check if the method is not <init> // c) check if the method is not <init>
resolved_method->name() != vmSymbols::object_initializer_name()) { resolved_method->name() != vmSymbols::object_initializer_name()) {
// Lookup super method // Lookup super method
KlassHandle super_klass(THREAD, current_klass->super()); Klass* super_klass = current_klass->super();
sel_method = lookup_instance_method_in_klasses(super_klass, sel_method = lookup_instance_method_in_klasses(super_klass,
resolved_method->name(), resolved_method->name(),
resolved_method->signature(), CHECK); resolved_method->signature(), CHECK);
@ -1183,18 +1178,17 @@ void LinkResolver::runtime_resolve_special_method(CallInfo& result,
if (sel_method.is_null()) { if (sel_method.is_null()) {
ResourceMark rm(THREAD); ResourceMark rm(THREAD);
THROW_MSG(vmSymbols::java_lang_AbstractMethodError(), THROW_MSG(vmSymbols::java_lang_AbstractMethodError(),
Method::name_and_sig_as_C_string(resolved_klass(), Method::name_and_sig_as_C_string(resolved_klass,
resolved_method->name(), resolved_method->name(),
resolved_method->signature())); resolved_method->signature()));
} }
} }
}
// check if not static // check if not static
if (sel_method->is_static()) { if (sel_method->is_static()) {
ResourceMark rm(THREAD); ResourceMark rm(THREAD);
char buf[200]; char buf[200];
jio_snprintf(buf, sizeof(buf), "Expecting non-static method %s", Method::name_and_sig_as_C_string(resolved_klass(), jio_snprintf(buf, sizeof(buf), "Expecting non-static method %s", Method::name_and_sig_as_C_string(resolved_klass,
resolved_method->name(), resolved_method->name(),
resolved_method->signature())); resolved_method->signature()));
THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(), buf); THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(), buf);
@ -1204,7 +1198,7 @@ void LinkResolver::runtime_resolve_special_method(CallInfo& result,
if (sel_method->is_abstract()) { if (sel_method->is_abstract()) {
ResourceMark rm(THREAD); ResourceMark rm(THREAD);
THROW_MSG(vmSymbols::java_lang_AbstractMethodError(), 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->name(),
sel_method->signature())); sel_method->signature()));
} }
@ -1218,7 +1212,7 @@ void LinkResolver::runtime_resolve_special_method(CallInfo& result,
result.set_static(resolved_klass, sel_method, CHECK); 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, const LinkInfo& link_info,
bool check_null_and_abstract, TRAPS) { bool check_null_and_abstract, TRAPS) {
methodHandle resolved_method = linktime_resolve_virtual_method(link_info, CHECK); methodHandle resolved_method = linktime_resolve_virtual_method(link_info, CHECK);
@ -1238,18 +1232,18 @@ methodHandle LinkResolver::linktime_resolve_virtual_method(const LinkInfo& link_
assert(resolved_method->name() != vmSymbols::class_initializer_name (), "should have been checked in verifier"); assert(resolved_method->name() != vmSymbols::class_initializer_name (), "should have been checked in verifier");
// check if private interface method // check if private interface method
KlassHandle resolved_klass = link_info.resolved_klass(); Klass* resolved_klass = link_info.resolved_klass();
KlassHandle current_klass = link_info.current_klass(); Klass* current_klass = link_info.current_klass();
// This is impossible, if resolve_klass is an interface, we've thrown icce in resolve_method // 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()) { if (resolved_klass->is_interface() && resolved_method->is_private()) {
ResourceMark rm(THREAD); ResourceMark rm(THREAD);
char buf[200]; char buf[200];
jio_snprintf(buf, sizeof(buf), "private interface method requires invokespecial, not invokevirtual: method %s, caller-class:%s", 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->name(),
resolved_method->signature()), 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); THROW_MSG_NULL(vmSymbols::java_lang_IncompatibleClassChangeError(), buf);
} }
@ -1257,7 +1251,7 @@ methodHandle LinkResolver::linktime_resolve_virtual_method(const LinkInfo& link_
if (resolved_method->is_static()) { if (resolved_method->is_static()) {
ResourceMark rm(THREAD); ResourceMark rm(THREAD);
char buf[200]; char buf[200];
jio_snprintf(buf, sizeof(buf), "Expecting non-static method %s", Method::name_and_sig_as_C_string(resolved_klass(), jio_snprintf(buf, sizeof(buf), "Expecting non-static method %s", Method::name_and_sig_as_C_string(resolved_klass,
resolved_method->name(), resolved_method->name(),
resolved_method->signature())); resolved_method->signature()));
THROW_MSG_NULL(vmSymbols::java_lang_IncompatibleClassChangeError(), buf); THROW_MSG_NULL(vmSymbols::java_lang_IncompatibleClassChangeError(), buf);
@ -1274,9 +1268,9 @@ methodHandle LinkResolver::linktime_resolve_virtual_method(const LinkInfo& link_
// throws runtime exceptions // throws runtime exceptions
void LinkResolver::runtime_resolve_virtual_method(CallInfo& result, void LinkResolver::runtime_resolve_virtual_method(CallInfo& result,
const methodHandle& resolved_method, const methodHandle& resolved_method,
KlassHandle resolved_klass, Klass* resolved_klass,
Handle recv, Handle recv,
KlassHandle recv_klass, Klass* recv_klass,
bool check_null_and_abstract, bool check_null_and_abstract,
TRAPS) { TRAPS) {
@ -1325,7 +1319,7 @@ void LinkResolver::runtime_resolve_virtual_method(CallInfo& result,
if (selected_method.is_null()) { if (selected_method.is_null()) {
ResourceMark rm(THREAD); ResourceMark rm(THREAD);
THROW_MSG(vmSymbols::java_lang_AbstractMethodError(), THROW_MSG(vmSymbols::java_lang_AbstractMethodError(),
Method::name_and_sig_as_C_string(resolved_klass(), Method::name_and_sig_as_C_string(resolved_klass,
resolved_method->name(), resolved_method->name(),
resolved_method->signature())); resolved_method->signature()));
} }
@ -1334,7 +1328,7 @@ void LinkResolver::runtime_resolve_virtual_method(CallInfo& result,
if (check_null_and_abstract && selected_method->is_abstract()) { if (check_null_and_abstract && selected_method->is_abstract()) {
ResourceMark rm(THREAD); ResourceMark rm(THREAD);
THROW_MSG(vmSymbols::java_lang_AbstractMethodError(), THROW_MSG(vmSymbols::java_lang_AbstractMethodError(),
Method::name_and_sig_as_C_string(resolved_klass(), Method::name_and_sig_as_C_string(resolved_klass,
selected_method->name(), selected_method->name(),
selected_method->signature())); selected_method->signature()));
} }
@ -1348,7 +1342,7 @@ void LinkResolver::runtime_resolve_virtual_method(CallInfo& result,
result.set_virtual(resolved_klass, recv_klass, resolved_method, selected_method, vtable_index, CHECK); 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, const LinkInfo& link_info,
bool check_null_and_abstract, TRAPS) { bool check_null_and_abstract, TRAPS) {
// throws linktime exceptions // throws linktime exceptions
@ -1370,9 +1364,9 @@ methodHandle LinkResolver::linktime_resolve_interface_method(const LinkInfo& lin
// throws runtime exceptions // throws runtime exceptions
void LinkResolver::runtime_resolve_interface_method(CallInfo& result, void LinkResolver::runtime_resolve_interface_method(CallInfo& result,
const methodHandle& resolved_method, const methodHandle& resolved_method,
KlassHandle resolved_klass, Klass* resolved_klass,
Handle recv, Handle recv,
KlassHandle recv_klass, Klass* recv_klass,
bool check_null_and_abstract, TRAPS) { bool check_null_and_abstract, TRAPS) {
// check if receiver exists // check if receiver exists
if (check_null_and_abstract && recv.is_null()) { if (check_null_and_abstract && recv.is_null()) {
@ -1380,12 +1374,12 @@ void LinkResolver::runtime_resolve_interface_method(CallInfo& result,
} }
// check if receiver klass implements the resolved interface // 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); ResourceMark rm(THREAD);
char buf[200]; char buf[200];
jio_snprintf(buf, sizeof(buf), "Class %s does not implement the requested interface %s", jio_snprintf(buf, sizeof(buf), "Class %s does not implement the requested interface %s",
recv_klass()->external_name(), recv_klass->external_name(),
resolved_klass()->external_name()); resolved_klass->external_name());
THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(), buf); THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(), buf);
} }
@ -1405,7 +1399,7 @@ void LinkResolver::runtime_resolve_interface_method(CallInfo& result,
if (sel_method.is_null()) { if (sel_method.is_null()) {
ResourceMark rm(THREAD); ResourceMark rm(THREAD);
THROW_MSG(vmSymbols::java_lang_AbstractMethodError(), 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->name(),
resolved_method->signature())); resolved_method->signature()));
} }
@ -1414,7 +1408,7 @@ void LinkResolver::runtime_resolve_interface_method(CallInfo& result,
if (!sel_method->is_public()) { if (!sel_method->is_public()) {
ResourceMark rm(THREAD); ResourceMark rm(THREAD);
THROW_MSG(vmSymbols::java_lang_IllegalAccessError(), 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->name(),
sel_method->signature())); sel_method->signature()));
} }
@ -1422,7 +1416,7 @@ void LinkResolver::runtime_resolve_interface_method(CallInfo& result,
if (check_null_and_abstract && sel_method->is_abstract()) { if (check_null_and_abstract && sel_method->is_abstract()) {
ResourceMark rm(THREAD); ResourceMark rm(THREAD);
THROW_MSG(vmSymbols::java_lang_AbstractMethodError(), THROW_MSG(vmSymbols::java_lang_AbstractMethodError(),
Method::name_and_sig_as_C_string(recv_klass(), Method::name_and_sig_as_C_string(recv_klass,
sel_method->name(), sel_method->name(),
sel_method->signature())); sel_method->signature()));
} }
@ -1468,7 +1462,7 @@ methodHandle LinkResolver::linktime_resolve_virtual_method_or_null(
} }
methodHandle LinkResolver::resolve_virtual_call_or_null( methodHandle LinkResolver::resolve_virtual_call_or_null(
KlassHandle receiver_klass, Klass* receiver_klass,
const LinkInfo& link_info) { const LinkInfo& link_info) {
EXCEPTION_MARK; EXCEPTION_MARK;
CallInfo info; CallInfo info;
@ -1481,7 +1475,7 @@ methodHandle LinkResolver::resolve_virtual_call_or_null(
} }
methodHandle LinkResolver::resolve_interface_call_or_null( methodHandle LinkResolver::resolve_interface_call_or_null(
KlassHandle receiver_klass, Klass* receiver_klass,
const LinkInfo& link_info) { const LinkInfo& link_info) {
EXCEPTION_MARK; EXCEPTION_MARK;
CallInfo info; CallInfo info;
@ -1493,7 +1487,7 @@ methodHandle LinkResolver::resolve_interface_call_or_null(
return info.selected_method(); 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) { const LinkInfo& link_info) {
EXCEPTION_MARK; EXCEPTION_MARK;
CallInfo info; CallInfo info;
@ -1548,7 +1542,7 @@ void LinkResolver::resolve_invoke(CallInfo& result, Handle recv, const constantP
void LinkResolver::resolve_invoke(CallInfo& result, Handle& recv, void LinkResolver::resolve_invoke(CallInfo& result, Handle& recv,
const methodHandle& attached_method, const methodHandle& attached_method,
Bytecodes::Code byte, TRAPS) { Bytecodes::Code byte, TRAPS) {
KlassHandle defc = attached_method->method_holder(); Klass* defc = attached_method->method_holder();
Symbol* name = attached_method->name(); Symbol* name = attached_method->name();
Symbol* type = attached_method->signature(); Symbol* type = attached_method->signature();
LinkInfo link_info(defc, name, type); LinkInfo link_info(defc, name, type);
@ -1589,14 +1583,14 @@ void LinkResolver::resolve_invokevirtual(CallInfo& result, Handle recv,
TRAPS) { TRAPS) {
LinkInfo link_info(pool, index, CHECK); 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); 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) { void LinkResolver::resolve_invokeinterface(CallInfo& result, Handle recv, const constantPoolHandle& pool, int index, TRAPS) {
LinkInfo link_info(pool, index, CHECK); 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); resolve_interface_call(result, recv, recvrKlass, link_info, true, CHECK);
} }
@ -1616,9 +1610,9 @@ void LinkResolver::resolve_handle_call(CallInfo& result,
const LinkInfo& link_info, const LinkInfo& link_info,
TRAPS) { TRAPS) {
// JSR 292: this must be an implicitly generated method MethodHandle.invokeExact(*...) or similar // JSR 292: this must be an implicitly generated method MethodHandle.invokeExact(*...) or similar
KlassHandle resolved_klass = link_info.resolved_klass(); Klass* resolved_klass = link_info.resolved_klass();
assert(resolved_klass() == SystemDictionary::MethodHandle_klass() || assert(resolved_klass == SystemDictionary::MethodHandle_klass() ||
resolved_klass() == SystemDictionary::VarHandle_klass(), ""); resolved_klass == SystemDictionary::VarHandle_klass(), "");
assert(MethodHandles::is_signature_polymorphic_name(link_info.name()), ""); assert(MethodHandles::is_signature_polymorphic_name(link_info.name()), "");
Handle resolved_appendix; Handle resolved_appendix;
Handle resolved_method_type; Handle resolved_method_type;
@ -1655,7 +1649,7 @@ static void wrap_invokedynamic_exception(TRAPS) {
void LinkResolver::resolve_invokedynamic(CallInfo& result, const constantPoolHandle& pool, int index, TRAPS) { void LinkResolver::resolve_invokedynamic(CallInfo& result, const constantPoolHandle& pool, int index, TRAPS) {
Symbol* method_name = pool->name_ref_at(index); Symbol* method_name = pool->name_ref_at(index);
Symbol* method_signature = pool->signature_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). // Resolve the bootstrap specifier (BSM + optional arguments).
Handle bootstrap_specifier; Handle bootstrap_specifier;
@ -1693,7 +1687,7 @@ void LinkResolver::resolve_invokedynamic(CallInfo& result, const constantPoolHan
void LinkResolver::resolve_dynamic_call(CallInfo& result, void LinkResolver::resolve_dynamic_call(CallInfo& result,
Handle bootstrap_specifier, Handle bootstrap_specifier,
Symbol* method_name, Symbol* method_signature, Symbol* method_name, Symbol* method_signature,
KlassHandle current_klass, Klass* current_klass,
TRAPS) { TRAPS) {
// JSR 292: this must resolve to an implicitly generated method MH.linkToCallSite(*...) // JSR 292: this must resolve to an implicitly generated method MH.linkToCallSite(*...)
// The appendix argument is likely to be a freshly-created CallSite. // The appendix argument is likely to be a freshly-created CallSite.

View file

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -47,8 +47,8 @@ class CallInfo : public StackObj {
unknown_kind = -1 unknown_kind = -1
}; };
private: private:
KlassHandle _resolved_klass; // static receiver klass, resolved from a symbolic reference Klass* _resolved_klass; // static receiver klass, resolved from a symbolic reference
KlassHandle _selected_klass; // dynamic receiver class (same as static, or subklass) Klass* _selected_klass; // dynamic receiver class (same as static, or subklass)
methodHandle _resolved_method; // static target method methodHandle _resolved_method; // static target method
methodHandle _selected_method; // dynamic (actual) target method methodHandle _selected_method; // dynamic (actual) target method
CallKind _call_kind; // kind of call (static(=bytecode static/special + CallKind _call_kind; // kind of call (static(=bytecode static/special +
@ -57,21 +57,21 @@ class CallInfo : public StackObj {
Handle _resolved_appendix; // extra argument in constant pool (if CPCE::has_appendix) Handle _resolved_appendix; // extra argument in constant pool (if CPCE::has_appendix)
Handle _resolved_method_type; // MethodType (for invokedynamic and invokehandle call sites) Handle _resolved_method_type; // MethodType (for invokedynamic and invokehandle call sites)
void set_static(KlassHandle resolved_klass, const methodHandle& resolved_method, TRAPS); void set_static(Klass* resolved_klass, const methodHandle& resolved_method, TRAPS);
void set_interface(KlassHandle resolved_klass, KlassHandle selected_klass, void set_interface(Klass* resolved_klass, Klass* selected_klass,
const methodHandle& resolved_method, const methodHandle& resolved_method,
const methodHandle& selected_method, const methodHandle& selected_method,
int itable_index, TRAPS); 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& resolved_method,
const methodHandle& selected_method, const methodHandle& selected_method,
int vtable_index, TRAPS); int vtable_index, TRAPS);
void set_handle(const methodHandle& resolved_method, void set_handle(const methodHandle& resolved_method,
Handle resolved_appendix, Handle resolved_method_type, TRAPS); Handle resolved_appendix, Handle resolved_method_type, TRAPS);
void set_handle(KlassHandle resolved_klass, void set_handle(Klass* resolved_klass,
const methodHandle& resolved_method, const methodHandle& resolved_method,
Handle resolved_appendix, Handle resolved_method_type, TRAPS); 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& resolved_method,
const methodHandle& selected_method, const methodHandle& selected_method,
CallKind kind, CallKind kind,
@ -91,8 +91,8 @@ class CallInfo : public StackObj {
// does not queue the method for compilation // does not queue the method for compilation
CallInfo(Method* resolved_method, Klass* resolved_klass = NULL); CallInfo(Method* resolved_method, Klass* resolved_klass = NULL);
KlassHandle resolved_klass() const { return _resolved_klass; } Klass* resolved_klass() const { return _resolved_klass; }
KlassHandle selected_klass() const { return _selected_klass; } Klass* selected_klass() const { return _selected_klass; }
methodHandle resolved_method() const { return _resolved_method; } methodHandle resolved_method() const { return _resolved_method; }
methodHandle selected_method() const { return _selected_method; } methodHandle selected_method() const { return _selected_method; }
Handle resolved_appendix() const { return _resolved_appendix; } Handle resolved_appendix() const { return _resolved_appendix; }
@ -135,8 +135,8 @@ class CallInfo : public StackObj {
class LinkInfo : public StackObj { class LinkInfo : public StackObj {
Symbol* _name; // extracted from JVM_CONSTANT_NameAndType Symbol* _name; // extracted from JVM_CONSTANT_NameAndType
Symbol* _signature; Symbol* _signature;
KlassHandle _resolved_klass; // class that the constant pool entry points to Klass* _resolved_klass; // class that the constant pool entry points to
KlassHandle _current_klass; // class that owns the constant pool Klass* _current_klass; // class that owns the constant pool
methodHandle _current_method; // sending method methodHandle _current_method; // sending method
bool _check_access; bool _check_access;
constantTag _tag; constantTag _tag;
@ -151,14 +151,14 @@ class LinkInfo : public StackObj {
LinkInfo(const constantPoolHandle& pool, int index, TRAPS); LinkInfo(const constantPoolHandle& pool, int index, TRAPS);
// Condensed information from other call sites within the vm. // 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, AccessCheck check_access = needs_access_check,
constantTag tag = JVM_CONSTANT_Invalid) : constantTag tag = JVM_CONSTANT_Invalid) :
_resolved_klass(resolved_klass), _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) {} _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, AccessCheck check_access = needs_access_check,
constantTag tag = JVM_CONSTANT_Invalid) : constantTag tag = JVM_CONSTANT_Invalid) :
_resolved_klass(resolved_klass), _resolved_klass(resolved_klass),
@ -166,16 +166,16 @@ class LinkInfo : public StackObj {
_check_access(check_access == needs_access_check), _tag(tag) {} _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 // 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), _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) {} _check_access(false), _tag(JVM_CONSTANT_Invalid) {}
// accessors // accessors
Symbol* name() const { return _name; } Symbol* name() const { return _name; }
Symbol* signature() const { return _signature; } Symbol* signature() const { return _signature; }
KlassHandle resolved_klass() const { return _resolved_klass; } Klass* resolved_klass() const { return _resolved_klass; }
KlassHandle current_klass() const { return _current_klass; } Klass* current_klass() const { return _current_klass; }
methodHandle current_method() const { return _current_method; } methodHandle current_method() const { return _current_method; }
constantTag tag() const { return _tag; } constantTag tag() const { return _tag; }
bool check_access() const { return _check_access; } bool check_access() const { return _check_access; }
@ -206,7 +206,7 @@ class LinkResolver: AllStatic {
JVMCI_ONLY(public:) // Needed for CompilerToVM.resolveMethod() JVMCI_ONLY(public:) // Needed for CompilerToVM.resolveMethod()
// Not Linktime so doesn't take LinkInfo // Not Linktime so doesn't take LinkInfo
static methodHandle lookup_instance_method_in_klasses ( static methodHandle lookup_instance_method_in_klasses (
KlassHandle klass, Symbol* name, Symbol* signature, TRAPS); Klass* klass, Symbol* name, Symbol* signature, TRAPS);
JVMCI_ONLY(private:) JVMCI_ONLY(private:)
// Similar loader constraint checking functions that throw // Similar loader constraint checking functions that throw
@ -215,8 +215,8 @@ class LinkResolver: AllStatic {
const methodHandle& resolved_method, const methodHandle& resolved_method,
const char* method_type, TRAPS); const char* method_type, TRAPS);
static void check_field_loader_constraints(Symbol* field, Symbol* sig, static void check_field_loader_constraints(Symbol* field, Symbol* sig,
KlassHandle current_klass, Klass* current_klass,
KlassHandle sel_klass, TRAPS); Klass* sel_klass, TRAPS);
static methodHandle resolve_interface_method(const LinkInfo& link_info, Bytecodes::Code code, 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); static methodHandle resolve_method (const LinkInfo& link_info, Bytecodes::Code code, TRAPS);
@ -228,29 +228,29 @@ class LinkResolver: AllStatic {
static void runtime_resolve_special_method (CallInfo& result, static void runtime_resolve_special_method (CallInfo& result,
const methodHandle& resolved_method, const methodHandle& resolved_method,
KlassHandle resolved_klass, Klass* resolved_klass,
KlassHandle current_klass, Klass* current_klass,
bool check_access, TRAPS); bool check_access, TRAPS);
static void runtime_resolve_virtual_method (CallInfo& result, static void runtime_resolve_virtual_method (CallInfo& result,
const methodHandle& resolved_method, const methodHandle& resolved_method,
KlassHandle resolved_klass, Klass* resolved_klass,
Handle recv, Handle recv,
KlassHandle recv_klass, Klass* recv_klass,
bool check_null_and_abstract, TRAPS); bool check_null_and_abstract, TRAPS);
static void runtime_resolve_interface_method (CallInfo& result, static void runtime_resolve_interface_method (CallInfo& result,
const methodHandle& resolved_method, const methodHandle& resolved_method,
KlassHandle resolved_klass, Klass* resolved_klass,
Handle recv, Handle recv,
KlassHandle recv_klass, Klass* recv_klass,
bool check_null_and_abstract, TRAPS); bool check_null_and_abstract, TRAPS);
static void check_field_accessability(KlassHandle ref_klass, static void check_field_accessability(Klass* ref_klass,
KlassHandle resolved_klass, Klass* resolved_klass,
KlassHandle sel_klass, Klass* sel_klass,
const fieldDescriptor& fd, TRAPS); const fieldDescriptor& fd, TRAPS);
static void check_method_accessability(KlassHandle ref_klass, static void check_method_accessability(Klass* ref_klass,
KlassHandle resolved_klass, Klass* resolved_klass,
KlassHandle sel_klass, Klass* sel_klass,
const methodHandle& sel_method, TRAPS); const methodHandle& sel_method, TRAPS);
// runtime resolving from constant pool // runtime resolving from constant pool
@ -268,7 +268,7 @@ class LinkResolver: AllStatic {
const constantPoolHandle& pool, int index, TRAPS); const constantPoolHandle& pool, int index, TRAPS);
public: public:
// constant pool resolving // 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); // static resolving calls (will not run any Java code);
// used only from Bytecode_invoke::static_target // used only from Bytecode_invoke::static_target
@ -291,31 +291,31 @@ class LinkResolver: AllStatic {
static void resolve_special_call (CallInfo& result, static void resolve_special_call (CallInfo& result,
const LinkInfo& link_info, const LinkInfo& link_info,
TRAPS); 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, const LinkInfo& link_info,
bool check_null_and_abstract, TRAPS); 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, const LinkInfo& link_info,
bool check_null_and_abstract, TRAPS); bool check_null_and_abstract, TRAPS);
static void resolve_handle_call (CallInfo& result, static void resolve_handle_call (CallInfo& result,
const LinkInfo& link_info, TRAPS); const LinkInfo& link_info, TRAPS);
static void resolve_dynamic_call (CallInfo& result, Handle bootstrap_specifier, static void resolve_dynamic_call (CallInfo& result, Handle bootstrap_specifier,
Symbol* method_name, Symbol* method_signature, 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 // 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) // 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); 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); const LinkInfo& link_info);
static methodHandle resolve_static_call_or_null (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 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 // 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); const LinkInfo& link_info);
// static resolving for compiler (does not throw exceptions, returns null handle if unsuccessful) // static resolving for compiler (does not throw exceptions, returns null handle if unsuccessful)

View file

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -544,16 +544,16 @@ void Rewriter::rewrite_bytecodes(TRAPS) {
patch_invokedynamic_bytecodes(); patch_invokedynamic_bytecodes();
} }
void Rewriter::rewrite(instanceKlassHandle klass, TRAPS) { void Rewriter::rewrite(InstanceKlass* klass, TRAPS) {
if (!DumpSharedSpaces) { 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); ResourceMark rm(THREAD);
Rewriter rw(klass, klass->constants(), klass->methods(), CHECK); Rewriter rw(klass, klass->constants(), klass->methods(), CHECK);
// (That's all, folks.) // (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), : _klass(klass),
_pool(cpool), _pool(cpool),
_methods(methods), _methods(methods),

View file

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -34,7 +34,7 @@
class Rewriter: public StackObj { class Rewriter: public StackObj {
private: private:
instanceKlassHandle _klass; InstanceKlass* _klass;
constantPoolHandle _pool; constantPoolHandle _pool;
Array<Method*>* _methods; Array<Method*>* _methods;
GrowableArray<int> _cp_map; GrowableArray<int> _cp_map;
@ -188,7 +188,7 @@ class Rewriter: public StackObj {
} }
// All the work goes in here: // 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 compute_index_maps();
void make_constant_pool_cache(TRAPS); void make_constant_pool_cache(TRAPS);
@ -211,7 +211,7 @@ class Rewriter: public StackObj {
static methodHandle rewrite_jsrs(methodHandle m, TRAPS); static methodHandle rewrite_jsrs(methodHandle m, TRAPS);
public: public:
// Driver routine: // Driver routine:
static void rewrite(instanceKlassHandle klass, TRAPS); static void rewrite(InstanceKlass* klass, TRAPS);
}; };
#endif // SHARE_VM_INTERPRETER_REWRITER_HPP #endif // SHARE_VM_INTERPRETER_REWRITER_HPP

View file

@ -77,8 +77,8 @@ oop CompilerToVM::get_jvmci_method(const methodHandle& method, TRAPS) {
return NULL; return NULL;
} }
oop CompilerToVM::get_jvmci_type(KlassHandle klass, TRAPS) { oop CompilerToVM::get_jvmci_type(Klass* klass, TRAPS) {
if (klass() != NULL) { if (klass != NULL) {
JavaValue result(T_OBJECT); JavaValue result(T_OBJECT);
JavaCallArguments args; JavaCallArguments args;
args.push_oop(Handle(THREAD, klass->java_mirror())); args.push_oop(Handle(THREAD, klass->java_mirror()));
@ -678,7 +678,7 @@ C2V_VMENTRY(jobject, getConstantPool, (JNIEnv *, jobject, jobject object_handle)
} }
C2V_VMENTRY(jobject, getResolvedJavaType, (JNIEnv *, jobject, jobject base, jlong offset, jboolean compressed)) C2V_VMENTRY(jobject, getResolvedJavaType, (JNIEnv *, jobject, jobject base, jlong offset, jboolean compressed))
KlassHandle klass; Klass* klass = NULL;
oop base_object = JNIHandles::resolve(base); oop base_object = JNIHandles::resolve(base);
jlong base_address = 0; jlong base_address = 0;
if (base_object != NULL && offset == oopDesc::klass_offset_in_bytes()) { if (base_object != NULL && offset == oopDesc::klass_offset_in_bytes()) {
@ -703,7 +703,7 @@ C2V_VMENTRY(jobject, getResolvedJavaType, (JNIEnv *, jobject, jobject base, jlon
THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(), THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(),
err_msg("Unexpected arguments: %s " JLONG_FORMAT " %s", base_object->klass()->external_name(), offset, compressed ? "true" : "false")); 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); oop result = CompilerToVM::get_jvmci_type(klass, CHECK_NULL);
return JNIHandles::make_local(THREAD, result); return JNIHandles::make_local(THREAD, result);
} }
@ -711,7 +711,7 @@ C2V_VMENTRY(jobject, getResolvedJavaType, (JNIEnv *, jobject, jobject base, jlon
C2V_VMENTRY(jobject, findUniqueConcreteMethod, (JNIEnv *, jobject, jobject jvmci_type, jobject jvmci_method)) C2V_VMENTRY(jobject, findUniqueConcreteMethod, (JNIEnv *, jobject, jobject jvmci_type, jobject jvmci_method))
ResourceMark rm; ResourceMark rm;
methodHandle method = CompilerToVM::asMethod(jvmci_method); methodHandle method = CompilerToVM::asMethod(jvmci_method);
KlassHandle holder = CompilerToVM::asKlass(jvmci_type); Klass* holder = CompilerToVM::asKlass(jvmci_type);
if (holder->is_interface()) { if (holder->is_interface()) {
THROW_MSG_0(vmSymbols::java_lang_InternalError(), err_msg("Interface %s should be handled in Java code", holder->external_name())); THROW_MSG_0(vmSymbols::java_lang_InternalError(), err_msg("Interface %s should be handled in Java code", holder->external_name()));
} }
@ -719,7 +719,7 @@ C2V_VMENTRY(jobject, findUniqueConcreteMethod, (JNIEnv *, jobject, jobject jvmci
methodHandle ucm; methodHandle ucm;
{ {
MutexLocker locker(Compile_lock); 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); oop result = CompilerToVM::get_jvmci_method(ucm, CHECK_NULL);
return JNIHandles::make_local(THREAD, result); return JNIHandles::make_local(THREAD, result);
@ -848,15 +848,15 @@ C2V_END
C2V_VMENTRY(jobject, lookupKlassInPool, (JNIEnv*, jobject, jobject jvmci_constant_pool, jint index, jbyte opcode)) C2V_VMENTRY(jobject, lookupKlassInPool, (JNIEnv*, jobject, jobject jvmci_constant_pool, jint index, jbyte opcode))
constantPoolHandle cp = CompilerToVM::asConstantPool(jvmci_constant_pool); constantPoolHandle cp = CompilerToVM::asConstantPool(jvmci_constant_pool);
KlassHandle loading_klass(cp->pool_holder()); Klass* loading_klass = cp->pool_holder();
bool is_accessible = false; 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; Symbol* symbol = NULL;
if (klass.is_null()) { if (klass == NULL) {
symbol = cp->klass_name_at(index); symbol = cp->klass_name_at(index);
} }
oop result_oop; oop result_oop;
if (!klass.is_null()) { if (klass != NULL) {
result_oop = CompilerToVM::get_jvmci_type(klass, CHECK_NULL); result_oop = CompilerToVM::get_jvmci_type(klass, CHECK_NULL);
} else { } else {
Handle result = java_lang_String::create_from_symbol(symbol, CHECK_NULL); Handle result = java_lang_String::create_from_symbol(symbol, CHECK_NULL);
@ -873,7 +873,7 @@ C2V_END
C2V_VMENTRY(jobject, lookupMethodInPool, (JNIEnv*, jobject, jobject jvmci_constant_pool, jint index, jbyte opcode)) C2V_VMENTRY(jobject, lookupMethodInPool, (JNIEnv*, jobject, jobject jvmci_constant_pool, jint index, jbyte opcode))
constantPoolHandle cp = CompilerToVM::asConstantPool(jvmci_constant_pool); 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); Bytecodes::Code bc = (Bytecodes::Code) (((int) opcode) & 0xFF);
methodHandle method = JVMCIEnv::get_method_by_index(cp, index, bc, pool_holder); methodHandle method = JVMCIEnv::get_method_by_index(cp, index, bc, pool_holder);
oop result = CompilerToVM::get_jvmci_method(method, CHECK_NULL); oop result = CompilerToVM::get_jvmci_method(method, CHECK_NULL);
@ -920,11 +920,11 @@ C2V_VMENTRY(jint, getVtableIndexForInterfaceMethod, (JNIEnv *, jobject, jobject
C2V_END C2V_END
C2V_VMENTRY(jobject, resolveMethod, (JNIEnv *, jobject, jobject receiver_jvmci_type, jobject jvmci_method, jobject caller_jvmci_type)) 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); Klass* recv_klass = CompilerToVM::asKlass(receiver_jvmci_type);
KlassHandle caller_klass = CompilerToVM::asKlass(caller_jvmci_type); Klass* caller_klass = CompilerToVM::asKlass(caller_jvmci_type);
methodHandle method = CompilerToVM::asMethod(jvmci_method); 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_name = method->name();
Symbol* h_signature = method->signature(); Symbol* h_signature = method->signature();
@ -933,13 +933,13 @@ C2V_VMENTRY(jobject, resolveMethod, (JNIEnv *, jobject, jobject receiver_jvmci_t
return NULL; 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; methodHandle m;
// Only do exact lookup if receiver klass has been linked. Otherwise, // Only do exact lookup if receiver klass has been linked. Otherwise,
// the vtable has not been setup, and the LinkResolver will fail. // the vtable has not been setup, and the LinkResolver will fail.
if (recv_klass->is_array_klass() || if (recv_klass->is_array_klass() ||
InstanceKlass::cast(recv_klass())->is_linked() && !recv_klass->is_interface()) { InstanceKlass::cast(recv_klass)->is_linked() && !recv_klass->is_interface()) {
if (h_resolved->is_interface()) { if (resolved->is_interface()) {
m = LinkResolver::resolve_interface_call_or_null(recv_klass, link_info); m = LinkResolver::resolve_interface_call_or_null(recv_klass, link_info);
} else { } else {
m = LinkResolver::resolve_virtual_call_or_null(recv_klass, link_info); m = LinkResolver::resolve_virtual_call_or_null(recv_klass, link_info);
@ -1482,12 +1482,12 @@ C2V_END
C2V_VMENTRY(void, resolveInvokeHandleInPool, (JNIEnv*, jobject, jobject jvmci_constant_pool, jint index)) C2V_VMENTRY(void, resolveInvokeHandleInPool, (JNIEnv*, jobject, jobject jvmci_constant_pool, jint index))
constantPoolHandle cp = CompilerToVM::asConstantPool(jvmci_constant_pool); 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); 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; CallInfo callInfo;
LinkResolver::resolve_invoke(callInfo, Handle(), cp, index, Bytecodes::_invokehandle, CHECK); 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); cp_cache_entry->set_method_handle(cp, callInfo);
} }
C2V_END C2V_END

View file

@ -161,7 +161,7 @@ class CompilerToVM {
static oop get_jvmci_method(const methodHandle& method, TRAPS); 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 { class JavaArgumentUnboxer : public SignatureIterator {

View file

@ -65,9 +65,9 @@ JVMCIEnv::JVMCIEnv(CompileTask* task, int system_dictionary_modification_counter
// ------------------------------------------------------------------ // ------------------------------------------------------------------
// Note: the logic of this method should mirror the logic of // Note: the logic of this method should mirror the logic of
// constantPoolOopDesc::verify_constant_pool_resolve. // 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()) { 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()) { if (!accessing_klass->is_instance_klass()) {
return true; return true;
@ -75,18 +75,18 @@ bool JVMCIEnv::check_klass_accessibility(KlassHandle accessing_klass, KlassHandl
if (resolved_klass->is_objArray_klass()) { if (resolved_klass->is_objArray_klass()) {
// Find the element klass, if this is an array. // 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()) { if (resolved_klass->is_instance_klass()) {
Reflection::VerifyClassAccessResults result = 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 result == Reflection::ACCESS_OK;
} }
return true; return true;
} }
// ------------------------------------------------------------------ // ------------------------------------------------------------------
KlassHandle JVMCIEnv::get_klass_by_name_impl(KlassHandle& accessing_klass, Klass* JVMCIEnv::get_klass_by_name_impl(Klass* accessing_klass,
const constantPoolHandle& cpool, const constantPoolHandle& cpool,
Symbol* sym, Symbol* sym,
bool require_local) { bool require_local) {
@ -99,28 +99,26 @@ KlassHandle JVMCIEnv::get_klass_by_name_impl(KlassHandle& accessing_klass,
// Call recursive to keep scope of strippedsym. // Call recursive to keep scope of strippedsym.
TempNewSymbol strippedsym = SymbolTable::new_symbol(sym->as_utf8()+1, TempNewSymbol strippedsym = SymbolTable::new_symbol(sym->as_utf8()+1,
sym->utf8_length()-2, sym->utf8_length()-2,
CHECK_(KlassHandle())); CHECK_NULL);
return get_klass_by_name_impl(accessing_klass, cpool, strippedsym, require_local); return get_klass_by_name_impl(accessing_klass, cpool, strippedsym, require_local);
} }
Handle loader(THREAD, (oop)NULL); Handle loader(THREAD, (oop)NULL);
Handle domain(THREAD, (oop)NULL); Handle domain(THREAD, (oop)NULL);
if (!accessing_klass.is_null()) { if (accessing_klass != NULL) {
loader = Handle(THREAD, accessing_klass->class_loader()); loader = Handle(THREAD, accessing_klass->class_loader());
domain = Handle(THREAD, accessing_klass->protection_domain()); domain = Handle(THREAD, accessing_klass->protection_domain());
} }
KlassHandle found_klass; Klass* found_klass = NULL;
{ {
ttyUnlocker ttyul; // release tty lock to avoid ordering problems ttyUnlocker ttyul; // release tty lock to avoid ordering problems
MutexLocker ml(Compile_lock); MutexLocker ml(Compile_lock);
Klass* kls;
if (!require_local) { 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 { } 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. // If we fail to find an array klass, look again for its element type.
@ -135,21 +133,21 @@ KlassHandle JVMCIEnv::get_klass_by_name_impl(KlassHandle& accessing_klass,
// Build it on the fly if the element class exists. // Build it on the fly if the element class exists.
TempNewSymbol elem_sym = SymbolTable::new_symbol(sym->as_utf8()+1, TempNewSymbol elem_sym = SymbolTable::new_symbol(sym->as_utf8()+1,
sym->utf8_length()-1, sym->utf8_length()-1,
CHECK_(KlassHandle())); CHECK_NULL);
// Get element Klass recursively. // Get element Klass recursively.
KlassHandle elem_klass = Klass* elem_klass =
get_klass_by_name_impl(accessing_klass, get_klass_by_name_impl(accessing_klass,
cpool, cpool,
elem_sym, elem_sym,
require_local); require_local);
if (!elem_klass.is_null()) { if (elem_klass != NULL) {
// Now make an array for it // 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. // Look inside the constant pool for pre-resolved class entries.
for (int i = cpool->length() - 1; i >= 1; i--) { for (int i = cpool->length() - 1; i >= 1; i--) {
if (cpool->tag_at(i).is_klass()) { if (cpool->tag_at(i).is_klass()) {
@ -161,11 +159,11 @@ KlassHandle JVMCIEnv::get_klass_by_name_impl(KlassHandle& accessing_klass,
} }
} }
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, Symbol* klass_name,
bool require_local) { bool require_local) {
ResourceMark rm; ResourceMark rm;
@ -178,28 +176,28 @@ KlassHandle JVMCIEnv::get_klass_by_name(KlassHandle accessing_klass,
// ------------------------------------------------------------------ // ------------------------------------------------------------------
// Implementation of get_klass_by_index. // 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, int index,
bool& is_accessible, bool& is_accessible,
KlassHandle accessor) { Klass* accessor) {
JVMCI_EXCEPTION_CONTEXT; 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; Symbol* klass_name = NULL;
if (klass.is_null()) { if (klass == NULL) {
klass_name = cpool->klass_name_at(index); 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. // Not found in constant pool. Use the name to do the lookup.
KlassHandle k = get_klass_by_name_impl(accessor, Klass* k = get_klass_by_name_impl(accessor,
cpool, cpool,
klass_name, klass_name,
false); false);
// Calculate accessibility the hard way. // Calculate accessibility the hard way.
if (k.is_null()) { if (k == NULL) {
is_accessible = false; is_accessible = false;
} else if (k->class_loader() != accessor->class_loader() && } 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. // Loaded only remotely. Not linked yet.
is_accessible = false; is_accessible = false;
} else { } else {
@ -207,7 +205,7 @@ KlassHandle JVMCIEnv::get_klass_by_index_impl(const constantPoolHandle& cpool,
is_accessible = check_klass_accessibility(accessor, k); is_accessible = check_klass_accessibility(accessor, k);
} }
if (!is_accessible) { if (!is_accessible) {
return KlassHandle(); return NULL;
} }
return k; return k;
} }
@ -219,13 +217,12 @@ KlassHandle JVMCIEnv::get_klass_by_index_impl(const constantPoolHandle& cpool,
// ------------------------------------------------------------------ // ------------------------------------------------------------------
// Get a klass from the constant pool. // Get a klass from the constant pool.
KlassHandle JVMCIEnv::get_klass_by_index(const constantPoolHandle& cpool, Klass* JVMCIEnv::get_klass_by_index(const constantPoolHandle& cpool,
int index, int index,
bool& is_accessible, bool& is_accessible,
KlassHandle accessor) { Klass* accessor) {
ResourceMark rm; ResourceMark rm;
KlassHandle result = get_klass_by_index_impl(cpool, index, is_accessible, accessor); return get_klass_by_index_impl(cpool, index, is_accessible, accessor);
return result;
} }
// ------------------------------------------------------------------ // ------------------------------------------------------------------
@ -233,7 +230,7 @@ KlassHandle JVMCIEnv::get_klass_by_index(const constantPoolHandle& cpool,
// //
// Implementation note: the results of field lookups are cached // Implementation note: the results of field lookups are cached
// in the accessor klass. // 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) { int index) {
JVMCI_EXCEPTION_CONTEXT; JVMCI_EXCEPTION_CONTEXT;
@ -251,7 +248,7 @@ void JVMCIEnv::get_field_by_index_impl(instanceKlassHandle klass, fieldDescripto
// Get the field's declared holder. // Get the field's declared holder.
int holder_index = cpool->klass_ref_index_at(index); int holder_index = cpool->klass_ref_index_at(index);
bool holder_is_accessible; bool holder_is_accessible;
KlassHandle declared_holder = get_klass_by_index(cpool, holder_index, Klass* declared_holder = get_klass_by_index(cpool, holder_index,
holder_is_accessible, holder_is_accessible,
klass); klass);
@ -264,7 +261,7 @@ void JVMCIEnv::get_field_by_index_impl(instanceKlassHandle klass, fieldDescripto
// Perform the field lookup. // Perform the field lookup.
Klass* canonical_holder = 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) { if (canonical_holder == NULL) {
return; return;
} }
@ -274,7 +271,7 @@ void JVMCIEnv::get_field_by_index_impl(instanceKlassHandle klass, fieldDescripto
// ------------------------------------------------------------------ // ------------------------------------------------------------------
// Get a field by index from a klass's constant pool. // 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; ResourceMark rm;
return get_field_by_index_impl(accessor, fd, index); return get_field_by_index_impl(accessor, fd, index);
} }
@ -282,17 +279,17 @@ void JVMCIEnv::get_field_by_index(instanceKlassHandle accessor, fieldDescriptor&
// ------------------------------------------------------------------ // ------------------------------------------------------------------
// Perform an appropriate method lookup based on accessor, holder, // Perform an appropriate method lookup based on accessor, holder,
// name, signature, and bytecode. // name, signature, and bytecode.
methodHandle JVMCIEnv::lookup_method(instanceKlassHandle h_accessor, methodHandle JVMCIEnv::lookup_method(InstanceKlass* accessor,
KlassHandle h_holder, Klass* holder,
Symbol* name, Symbol* name,
Symbol* sig, Symbol* sig,
Bytecodes::Code bc, Bytecodes::Code bc,
constantTag tag) { constantTag tag) {
// Accessibility checks are performed in JVMCIEnv::get_method_by_index_impl(). // 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; 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) { switch (bc) {
case Bytecodes::_invokestatic: case Bytecodes::_invokestatic:
dest_method = dest_method =
@ -320,7 +317,7 @@ methodHandle JVMCIEnv::lookup_method(instanceKlassHandle h_accessor,
// ------------------------------------------------------------------ // ------------------------------------------------------------------
methodHandle JVMCIEnv::get_method_by_index_impl(const constantPoolHandle& cpool, methodHandle JVMCIEnv::get_method_by_index_impl(const constantPoolHandle& cpool,
int index, Bytecodes::Code bc, int index, Bytecodes::Code bc,
instanceKlassHandle accessor) { InstanceKlass* accessor) {
if (bc == Bytecodes::_invokedynamic) { if (bc == Bytecodes::_invokedynamic) {
ConstantPoolCacheEntry* cpce = cpool->invokedynamic_cp_cache_entry_at(index); ConstantPoolCacheEntry* cpce = cpool->invokedynamic_cp_cache_entry_at(index);
bool is_resolved = !cpce->is_f1_null(); bool is_resolved = !cpce->is_f1_null();
@ -336,15 +333,15 @@ methodHandle JVMCIEnv::get_method_by_index_impl(const constantPoolHandle& cpool,
int holder_index = cpool->klass_ref_index_at(index); int holder_index = cpool->klass_ref_index_at(index);
bool holder_is_accessible; 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. // Get the method's name and signature.
Symbol* name_sym = cpool->name_ref_at(index); Symbol* name_sym = cpool->name_ref_at(index);
Symbol* sig_sym = cpool->signature_ref_at(index); Symbol* sig_sym = cpool->signature_ref_at(index);
if (cpool->has_preresolution() if (cpool->has_preresolution()
|| ((holder() == SystemDictionary::MethodHandle_klass() || holder() == SystemDictionary::VarHandle_klass()) && || ((holder == SystemDictionary::MethodHandle_klass() || holder == SystemDictionary::VarHandle_klass()) &&
MethodHandles::is_signature_polymorphic_name(holder(), name_sym))) { MethodHandles::is_signature_polymorphic_name(holder, name_sym))) {
// Short-circuit lookups for JSR 292-related call sites. // Short-circuit lookups for JSR 292-related call sites.
// That is, do not rely only on name-based lookups, because they may fail // 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). // if the names are not resolvable in the boot class loader (7056328).
@ -385,14 +382,14 @@ methodHandle JVMCIEnv::get_method_by_index_impl(const constantPoolHandle& cpool,
} }
// ------------------------------------------------------------------ // ------------------------------------------------------------------
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* // For the case of <array>.clone(), the method holder can be an ArrayKlass*
// instead of an InstanceKlass*. For that case simply pretend that the // 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. // declared holder is Object.clone since that's where the call will bottom out.
if (method_holder->is_instance_klass()) { if (method_holder->is_instance_klass()) {
return instanceKlassHandle(method_holder()); return InstanceKlass::cast(method_holder);
} else if (method_holder->is_array_klass()) { } else if (method_holder->is_array_klass()) {
return instanceKlassHandle(SystemDictionary::Object_klass()); return SystemDictionary::Object_klass();
} else { } else {
ShouldNotReachHere(); ShouldNotReachHere();
} }
@ -403,7 +400,7 @@ instanceKlassHandle JVMCIEnv::get_instance_klass_for_declared_method_holder(Klas
// ------------------------------------------------------------------ // ------------------------------------------------------------------
methodHandle JVMCIEnv::get_method_by_index(const constantPoolHandle& cpool, methodHandle JVMCIEnv::get_method_by_index(const constantPoolHandle& cpool,
int index, Bytecodes::Code bc, int index, Bytecodes::Code bc,
instanceKlassHandle accessor) { InstanceKlass* accessor) {
ResourceMark rm; ResourceMark rm;
return get_method_by_index_impl(cpool, index, bc, accessor); return get_method_by_index_impl(cpool, index, bc, accessor);
} }

View file

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -79,20 +79,18 @@ public:
// The CI treats a klass as loaded if it is consistently defined in // 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 // another loader, even if it hasn't yet been loaded in all loaders
// that could potentially see it via delegation. // that could potentially see it via delegation.
static KlassHandle get_klass_by_name(KlassHandle accessing_klass, static Klass* get_klass_by_name(Klass* accessing_klass, Symbol* klass_name, bool require_local);
Symbol* klass_name,
bool require_local);
// Constant pool access. // Constant pool access.
static KlassHandle get_klass_by_index(const constantPoolHandle& cpool, static Klass* get_klass_by_index(const constantPoolHandle& cpool,
int klass_index, int klass_index,
bool& is_accessible, bool& is_accessible,
KlassHandle loading_klass); Klass* loading_klass);
static void get_field_by_index(instanceKlassHandle loading_klass, fieldDescriptor& fd, static void get_field_by_index(InstanceKlass* loading_klass, fieldDescriptor& fd,
int field_index); int field_index);
static methodHandle get_method_by_index(const constantPoolHandle& cpool, static methodHandle get_method_by_index(const constantPoolHandle& cpool,
int method_index, Bytecodes::Code bc, int method_index, Bytecodes::Code bc,
instanceKlassHandle loading_klass); InstanceKlass* loading_klass);
JVMCIEnv(CompileTask* task, int system_dictionary_modification_counter); JVMCIEnv(CompileTask* task, int system_dictionary_modification_counter);
@ -110,24 +108,24 @@ private:
bool _jvmti_can_post_on_exceptions; bool _jvmti_can_post_on_exceptions;
// Implementation methods for loading and constant pool access. // 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, const constantPoolHandle& cpool,
Symbol* klass_name, Symbol* klass_name,
bool require_local); 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, int klass_index,
bool& is_accessible, bool& is_accessible,
KlassHandle loading_klass); Klass* loading_klass);
static void get_field_by_index_impl(instanceKlassHandle loading_klass, fieldDescriptor& fd, static void get_field_by_index_impl(InstanceKlass* loading_klass, fieldDescriptor& fd,
int field_index); int field_index);
static methodHandle get_method_by_index_impl(const constantPoolHandle& cpool, static methodHandle get_method_by_index_impl(const constantPoolHandle& cpool,
int method_index, Bytecodes::Code bc, int method_index, Bytecodes::Code bc,
instanceKlassHandle loading_klass); InstanceKlass* loading_klass);
// Helper methods // Helper methods
static bool check_klass_accessibility(KlassHandle accessing_klass, KlassHandle resolved_klass); static bool check_klass_accessibility(Klass* accessing_klass, Klass* resolved_klass);
static methodHandle lookup_method(instanceKlassHandle accessor, static methodHandle lookup_method(InstanceKlass* accessor,
KlassHandle holder, Klass* holder,
Symbol* name, Symbol* name,
Symbol* sig, Symbol* sig,
Bytecodes::Code bc, Bytecodes::Code bc,
@ -180,7 +178,7 @@ public:
// InstanceKlass*. This is needed since the holder of a method in // InstanceKlass*. This is needed since the holder of a method in
// the bytecodes could be an array type. Basically this converts // the bytecodes could be an array type. Basically this converts
// array types into java/lang/Object and other types stay as they are. // 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 #endif // SHARE_VM_JVMCI_JVMCIENV_HPP

View file

@ -107,12 +107,12 @@ JRT_BLOCK_ENTRY(void, JVMCIRuntime::new_instance(JavaThread* thread, Klass* klas
JRT_BLOCK; JRT_BLOCK;
assert(klass->is_klass(), "not a class"); assert(klass->is_klass(), "not a class");
Handle holder(THREAD, klass->klass_holder()); // keep the klass alive Handle holder(THREAD, klass->klass_holder()); // keep the klass alive
instanceKlassHandle h(thread, klass); InstanceKlass* ik = InstanceKlass::cast(klass);
h->check_valid_for_instantiation(true, CHECK); ik->check_valid_for_instantiation(true, CHECK);
// make sure klass is initialized // make sure klass is initialized
h->initialize(CHECK); ik->initialize(CHECK);
// allocate instance and return via TLS // allocate instance and return via TLS
oop obj = h->allocate_instance(CHECK); oop obj = ik->allocate_instance(CHECK);
thread->set_vm_result(obj); thread->set_vm_result(obj);
JRT_BLOCK_END; JRT_BLOCK_END;
@ -187,7 +187,7 @@ JRT_ENTRY(void, JVMCIRuntime::dynamic_new_array(JavaThread* thread, oopDesc* ele
JRT_END JRT_END
JRT_ENTRY(void, JVMCIRuntime::dynamic_new_instance(JavaThread* thread, oopDesc* type_mirror)) 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) { if (klass == NULL) {
ResourceMark rm(THREAD); ResourceMark rm(THREAD);
@ -641,7 +641,7 @@ JVM_END
Handle JVMCIRuntime::callStatic(const char* className, const char* methodName, const char* signature, JavaCallArguments* args, TRAPS) { Handle JVMCIRuntime::callStatic(const char* className, const char* methodName, const char* signature, JavaCallArguments* args, TRAPS) {
TempNewSymbol name = SymbolTable::new_symbol(className, CHECK_(Handle())); 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 runtime = SymbolTable::new_symbol(methodName, CHECK_(Handle()));
TempNewSymbol sig = SymbolTable::new_symbol(signature, CHECK_(Handle())); TempNewSymbol sig = SymbolTable::new_symbol(signature, CHECK_(Handle()));
JavaValue result(T_OBJECT); JavaValue result(T_OBJECT);
@ -657,7 +657,7 @@ void JVMCIRuntime::initialize_HotSpotJVMCIRuntime(TRAPS) {
guarantee(!_HotSpotJVMCIRuntime_initialized, "cannot reinitialize HotSpotJVMCIRuntime"); guarantee(!_HotSpotJVMCIRuntime_initialized, "cannot reinitialize HotSpotJVMCIRuntime");
JVMCIRuntime::initialize_well_known_classes(CHECK); JVMCIRuntime::initialize_well_known_classes(CHECK);
// This should only be called in the context of the JVMCI class being initialized // 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), guarantee(klass->is_being_initialized() && klass->is_reentrant_initialization(THREAD),
"HotSpotJVMCIRuntime initialization should only be triggered through JVMCI initialization"); "HotSpotJVMCIRuntime initialization should only be triggered through JVMCI initialization");

View file

@ -460,9 +460,8 @@ void Universe::fixup_mirrors(TRAPS) {
Klass* k = list->at(i); Klass* k = list->at(i);
assert(k->is_klass(), "List should only hold classes"); assert(k->is_klass(), "List should only hold classes");
EXCEPTION_MARK; EXCEPTION_MARK;
KlassHandle kh(THREAD, k); java_lang_Class::fixup_mirror(k, CATCH);
java_lang_Class::fixup_mirror(kh, CATCH); }
}
delete java_lang_Class::fixup_mirror_list(); delete java_lang_Class::fixup_mirror_list();
java_lang_Class::set_fixup_mirror_list(NULL); java_lang_Class::set_fixup_mirror_list(NULL);
} }
@ -506,7 +505,7 @@ void Universe::run_finalizers_on_exit() {
log_trace(ref)("Callback to run finalizers on exit"); log_trace(ref)("Callback to run finalizers on exit");
{ {
PRESERVE_EXCEPTION_MARK; PRESERVE_EXCEPTION_MARK;
KlassHandle finalizer_klass(THREAD, SystemDictionary::Finalizer_klass()); Klass* finalizer_klass = SystemDictionary::Finalizer_klass();
JavaValue result(T_VOID); JavaValue result(T_VOID);
JavaCalls::call_static( JavaCalls::call_static(
&result, &result,
@ -525,16 +524,15 @@ void Universe::run_finalizers_on_exit() {
// 1) we specified true to initialize_vtable and // 1) we specified true to initialize_vtable and
// 2) this ran after gc was enabled // 2) this ran after gc was enabled
// In case those ever change we use handles for oops // 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 // init vtable of k and all subclasses
Klass* ko = k_h();
klassVtable* vt = ko->vtable(); klassVtable* vt = ko->vtable();
if (vt) vt->initialize_vtable(false, CHECK); if (vt) vt->initialize_vtable(false, CHECK);
if (ko->is_instance_klass()) { if (ko->is_instance_klass()) {
for (KlassHandle s_h(THREAD, ko->subklass()); for (Klass* sk = ko->subklass();
s_h() != NULL; sk != NULL;
s_h = KlassHandle(THREAD, s_h()->next_sibling())) { sk = sk->next_sibling()) {
reinitialize_vtable_of(s_h, CHECK); reinitialize_vtable_of(sk, CHECK);
} }
} }
} }
@ -964,28 +962,26 @@ bool universe_post_init() {
Interpreter::initialize(); // needed for interpreter entry points Interpreter::initialize(); // needed for interpreter entry points
if (!UseSharedSpaces) { if (!UseSharedSpaces) {
HandleMark hm(THREAD); HandleMark hm(THREAD);
KlassHandle ok_h(THREAD, SystemDictionary::Object_klass()); Klass* ok = SystemDictionary::Object_klass();
Universe::reinitialize_vtable_of(ok_h, CHECK_false); Universe::reinitialize_vtable_of(ok, CHECK_false);
Universe::reinitialize_itables(CHECK_false); Universe::reinitialize_itables(CHECK_false);
} }
} }
HandleMark hm(THREAD); HandleMark hm(THREAD);
Klass* k;
instanceKlassHandle k_h;
// Setup preallocated empty java.lang.Class array // Setup preallocated empty java.lang.Class array
Universe::_the_empty_class_klass_array = oopFactory::new_objArray(SystemDictionary::Class_klass(), 0, CHECK_false); Universe::_the_empty_class_klass_array = oopFactory::new_objArray(SystemDictionary::Class_klass(), 0, CHECK_false);
// Setup preallocated OutOfMemoryError errors // Setup preallocated OutOfMemoryError errors
k = SystemDictionary::resolve_or_fail(vmSymbols::java_lang_OutOfMemoryError(), true, CHECK_false); Klass* k = SystemDictionary::resolve_or_fail(vmSymbols::java_lang_OutOfMemoryError(), true, CHECK_false);
k_h = instanceKlassHandle(THREAD, k); InstanceKlass* ik = InstanceKlass::cast(k);
Universe::_out_of_memory_error_java_heap = k_h->allocate_instance(CHECK_false); Universe::_out_of_memory_error_java_heap = ik->allocate_instance(CHECK_false);
Universe::_out_of_memory_error_metaspace = k_h->allocate_instance(CHECK_false); Universe::_out_of_memory_error_metaspace = ik->allocate_instance(CHECK_false);
Universe::_out_of_memory_error_class_metaspace = k_h->allocate_instance(CHECK_false); Universe::_out_of_memory_error_class_metaspace = ik->allocate_instance(CHECK_false);
Universe::_out_of_memory_error_array_size = k_h->allocate_instance(CHECK_false); Universe::_out_of_memory_error_array_size = ik->allocate_instance(CHECK_false);
Universe::_out_of_memory_error_gc_overhead_limit = Universe::_out_of_memory_error_gc_overhead_limit =
k_h->allocate_instance(CHECK_false); ik->allocate_instance(CHECK_false);
Universe::_out_of_memory_error_realloc_objects = k_h->allocate_instance(CHECK_false); Universe::_out_of_memory_error_realloc_objects = ik->allocate_instance(CHECK_false);
// Setup preallocated cause message for delayed StackOverflowError // Setup preallocated cause message for delayed StackOverflowError
if (StackReservedPages > 0) { if (StackReservedPages > 0) {
@ -1040,12 +1036,12 @@ bool universe_post_init() {
// Setup the array of errors that have preallocated backtrace // Setup the array of errors that have preallocated backtrace
k = Universe::_out_of_memory_error_java_heap->klass(); k = Universe::_out_of_memory_error_java_heap->klass();
assert(k->name() == vmSymbols::java_lang_OutOfMemoryError(), "should be out of memory error"); 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; 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++) { 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); Handle err_h = Handle(THREAD, err);
java_lang_Throwable::allocate_backtrace(err_h, CHECK_false); java_lang_Throwable::allocate_backtrace(err_h, CHECK_false);
Universe::preallocated_out_of_memory_errors()->obj_at_put(i, err_h()); Universe::preallocated_out_of_memory_errors()->obj_at_put(i, err_h());

View file

@ -230,7 +230,7 @@ class Universe: AllStatic {
static void initialize_basic_type_mirrors(TRAPS); static void initialize_basic_type_mirrors(TRAPS);
static void fixup_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 reinitialize_itables(TRAPS);
static void compute_base_vtable_size(); // compute vtable size of class Object static void compute_base_vtable_size(); // compute vtable size of class Object

View file

@ -96,9 +96,9 @@ ArrayKlass::ArrayKlass(Symbol* name) :
// Initialization of vtables and mirror object is done separatly from base_create_array_klass, // 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. // 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); ResourceMark rm(THREAD);
k->initialize_supers(super_klass(), CHECK); k->initialize_supers(super_klass, CHECK);
k->vtable()->initialize_vtable(false, CHECK); k->vtable()->initialize_vtable(false, CHECK);
// During bootstrapping, before java.base is defined, the module_entry may not be present yet. // During bootstrapping, before java.base is defined, the module_entry may not be present yet.

View file

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -115,7 +115,7 @@ class ArrayKlass: public Klass {
void array_klasses_do(void f(Klass* k, TRAPS), TRAPS); void array_klasses_do(void f(Klass* k, TRAPS), TRAPS);
// Return a handle. // 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 // jvm support

View file

@ -193,7 +193,7 @@ void ConstantPool::string_at_put(int which, int obj_index, oop str) {
resolved_references()->obj_at_put(obj_index, str); 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; ResourceMark rm;
int line_number = -1; int line_number = -1;
const char * source_file = NULL; const char * source_file = NULL;
@ -208,7 +208,7 @@ void ConstantPool::trace_class_resolution(const constantPoolHandle& this_cp, Kla
} }
} }
} }
if (k() != this_cp->pool_holder()) { if (k != this_cp->pool_holder()) {
// only print something if the classes are different // only print something if the classes are different
if (source_file != NULL) { if (source_file != NULL) {
log_debug(class, resolve)("%s %s %s:%d", log_debug(class, resolve)("%s %s %s:%d",
@ -254,11 +254,10 @@ Klass* ConstantPool::klass_at_impl(const constantPoolHandle& this_cp, int which,
Symbol* name = entry.get_symbol(); Symbol* name = entry.get_symbol();
Handle loader (THREAD, this_cp->pool_holder()->class_loader()); Handle loader (THREAD, this_cp->pool_holder()->class_loader());
Handle protection_domain (THREAD, this_cp->pool_holder()->protection_domain()); Handle protection_domain (THREAD, this_cp->pool_holder()->protection_domain());
Klass* kk = SystemDictionary::resolve_or_fail(name, loader, protection_domain, true, THREAD); Klass* k = SystemDictionary::resolve_or_fail(name, loader, protection_domain, true, THREAD);
KlassHandle k (THREAD, kk);
if (!HAS_PENDING_EXCEPTION) { if (!HAS_PENDING_EXCEPTION) {
// preserve the resolved klass from unloading // 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 // Do access check for klasses
verify_constant_pool_resolve(this_cp, k, THREAD); verify_constant_pool_resolve(this_cp, k, THREAD);
} }
@ -282,13 +281,13 @@ Klass* ConstantPool::klass_at_impl(const constantPoolHandle& this_cp, int which,
// Make this class loader depend upon the class loader owning the class reference // Make this class loader depend upon the class loader owning the class reference
ClassLoaderData* this_key = this_cp->pool_holder()->class_loader_data(); 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. // logging for class+resolve.
if (log_is_enabled(Debug, class, resolve)){ if (log_is_enabled(Debug, class, resolve)){
trace_class_resolution(this_cp, k); 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); entry = this_cp->resolved_klass_at(which);
assert(entry.is_resolved() && entry.get_klass()->is_klass(), "must be resolved at this point"); assert(entry.is_resolved() && entry.get_klass()->is_klass(), "must be resolved at this point");
return entry.get_klass(); return entry.get_klass();
@ -317,14 +316,13 @@ Klass* ConstantPool::klass_at_if_loaded(const constantPoolHandle& this_cp, int w
if (k != NULL) { if (k != NULL) {
// Make sure that resolving is legal // Make sure that resolving is legal
EXCEPTION_MARK; EXCEPTION_MARK;
KlassHandle klass(THREAD, k);
// return NULL if verification fails // 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) { if (HAS_PENDING_EXCEPTION) {
CLEAR_PENDING_EXCEPTION; CLEAR_PENDING_EXCEPTION;
return NULL; return NULL;
} }
return klass(); return k;
} else { } else {
return k; return k;
} }
@ -456,16 +454,15 @@ int ConstantPool::remap_instruction_operand_from_cache(int operand) {
} }
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()) { if (k->is_instance_klass() || k->is_objArray_klass()) {
instanceKlassHandle holder (THREAD, this_cp->pool_holder()); InstanceKlass* holder = this_cp->pool_holder();
Klass* elem = k->is_instance_klass() ? k() : ObjArrayKlass::cast(k())->bottom_klass(); Klass* elem = k->is_instance_klass() ? k : ObjArrayKlass::cast(k)->bottom_klass();
KlassHandle element (THREAD, elem);
// The element type could be a typeArray - we only need the access check if it is // The element type could be a typeArray - we only need the access check if it is
// an reference to another class // an reference to another class
if (element->is_instance_klass()) { if (elem->is_instance_klass()) {
LinkResolver::check_klass_accessability(holder, element, CHECK); LinkResolver::check_klass_accessability(holder, elem, CHECK);
} }
} }
} }
@ -693,8 +690,7 @@ oop ConstantPool::resolve_constant_at_impl(const constantPoolHandle& this_cp, in
callee_index, name->as_C_string(), signature->as_C_string()); callee_index, name->as_C_string(), signature->as_C_string());
} }
Klass* k = klass_at_impl(this_cp, callee_index, true, CHECK_NULL); Klass* callee = klass_at_impl(this_cp, callee_index, true, CHECK_NULL);
KlassHandle callee(THREAD, k);
// Check constant pool method consistency // Check constant pool method consistency
if ((callee->is_interface() && m_tag.is_method()) || if ((callee->is_interface() && m_tag.is_method()) ||
@ -710,7 +706,7 @@ oop ConstantPool::resolve_constant_at_impl(const constantPoolHandle& this_cp, in
THROW_MSG_NULL(vmSymbols::java_lang_IncompatibleClassChangeError(), buf); 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, Handle value = SystemDictionary::link_method_handle_constant(klass, ref_kind,
callee, name, signature, callee, name, signature,
THREAD); THREAD);
@ -729,7 +725,7 @@ oop ConstantPool::resolve_constant_at_impl(const constantPoolHandle& this_cp, in
index, this_cp->method_type_index_at(index), index, this_cp->method_type_index_at(index),
signature->as_C_string()); 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); Handle value = SystemDictionary::find_method_handle_type(signature, klass, THREAD);
result_oop = value(); result_oop = value();
if (HAS_PENDING_EXCEPTION) { if (HAS_PENDING_EXCEPTION) {
@ -845,8 +841,7 @@ oop ConstantPool::string_at_impl(const constantPoolHandle& this_cp, int which, i
} }
bool ConstantPool::klass_name_at_matches(instanceKlassHandle k, bool ConstantPool::klass_name_at_matches(const InstanceKlass* k, int which) {
int which) {
// Names are interned, so we can compare Symbol*s directly // Names are interned, so we can compare Symbol*s directly
Symbol* cp_name = klass_name_at(which); Symbol* cp_name = klass_name_at(which);
return (cp_name == k->name()); return (cp_name == k->name());

View file

@ -693,7 +693,7 @@ class ConstantPool : public Metadata {
} }
// Klass name matches name at offset // 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 // Sizing
int length() const { return _length; } int length() const { return _length; }
@ -784,7 +784,7 @@ class ConstantPool : public Metadata {
} }
// Performs the LinkResolver checks // 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 // Implementation of methods that needs an exposed 'this' pointer, in order to
// handle GC while executing the method // handle GC while executing the method
@ -792,7 +792,7 @@ class ConstantPool : public Metadata {
bool save_resolution_error, TRAPS); bool save_resolution_error, TRAPS);
static oop string_at_impl(const constantPoolHandle& this_cp, int which, int obj_index, 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) // Resolve string constants (to prevent allocation during compilation)
static void resolve_string_constants_impl(const constantPoolHandle& this_cp, TRAPS); static void resolve_string_constants_impl(const constantPoolHandle& this_cp, TRAPS);

View file

@ -101,14 +101,14 @@ bool ConstantPoolCacheEntry::init_flags_atomic(intptr_t flags) {
// are updated, lest other processors see a non-zero bytecode but zero f1/f2. // are updated, lest other processors see a non-zero bytecode but zero f1/f2.
void ConstantPoolCacheEntry::set_field(Bytecodes::Code get_code, void ConstantPoolCacheEntry::set_field(Bytecodes::Code get_code,
Bytecodes::Code put_code, Bytecodes::Code put_code,
KlassHandle field_holder, Klass* field_holder,
int field_index, int field_index,
int field_offset, int field_offset,
TosState field_type, TosState field_type,
bool is_final, bool is_final,
bool is_volatile, bool is_volatile,
Klass* root_klass) { Klass* root_klass) {
set_f1(field_holder()); set_f1(field_holder);
set_f2(field_offset); set_f2(field_offset);
assert((field_index & field_index_mask) == field_index, assert((field_index & field_index_mask) == field_index,
"field index does not fit in low flag bits"); "field index does not fit in low flag bits");

View file

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -217,7 +217,7 @@ class ConstantPoolCacheEntry VALUE_OBJ_CLASS_SPEC {
void set_field( // sets entry to resolved field state void set_field( // sets entry to resolved field state
Bytecodes::Code get_code, // the bytecode used for reading the field Bytecodes::Code get_code, // the bytecode used for reading the field
Bytecodes::Code put_code, // the bytecode used for writing 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 orig_field_index, // the original field index in the field holder
int field_offset, // the field offset in words in the field holder int field_offset, // the field offset in words in the field holder
TosState field_type, // the (machine) field type TosState field_type, // the (machine) field type

View file

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -107,14 +107,6 @@ class FieldStreamBase : public StackObj {
init_generic_signature_start_slot(); init_generic_signature_start_slot();
assert(klass == field_holder(), ""); 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 // accessors
int index() const { return _index; } int index() const { return _index; }
@ -196,7 +188,7 @@ class FieldStreamBase : public StackObj {
// Iterate over only the internal fields // Iterate over only the internal fields
class JavaFieldStream : public FieldStreamBase { class JavaFieldStream : public FieldStreamBase {
public: 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 { int name_index() const {
assert(!field()->is_internal(), "regular only"); assert(!field()->is_internal(), "regular only");
@ -245,7 +237,6 @@ class JavaFieldStream : public FieldStreamBase {
class InternalFieldStream : public FieldStreamBase { class InternalFieldStream : public FieldStreamBase {
public: public:
InternalFieldStream(InstanceKlass* k): FieldStreamBase(k->fields(), k->constants(), k->java_fields_count(), 0) {} 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 @@ class AllFieldStream : public FieldStreamBase {
public: public:
AllFieldStream(Array<u2>* fields, const constantPoolHandle& constants): FieldStreamBase(fields, constants) {} AllFieldStream(Array<u2>* fields, const constantPoolHandle& constants): FieldStreamBase(fields, constants) {}
AllFieldStream(InstanceKlass* k): FieldStreamBase(k->fields(), k->constants()) {} AllFieldStream(InstanceKlass* k): FieldStreamBase(k->fields(), k->constants()) {}
AllFieldStream(instanceKlassHandle k): FieldStreamBase(k->fields(), k->constants()) {}
}; };
#endif // SHARE_VM_OOPS_FIELDSTREAMS_HPP #endif // SHARE_VM_OOPS_FIELDSTREAMS_HPP

View file

@ -374,7 +374,7 @@ bool InstanceKlass::should_be_initialized() const {
} }
klassItable* InstanceKlass::itable() const { klassItable* InstanceKlass::itable() const {
return new klassItable(instanceKlassHandle(this)); return new klassItable(const_cast<InstanceKlass*>(this));
} }
void InstanceKlass::eager_initialize(Thread *thread) { void InstanceKlass::eager_initialize(Thread *thread) {
@ -392,8 +392,7 @@ void InstanceKlass::eager_initialize(Thread *thread) {
if (!InstanceKlass::cast(super)->is_initialized()) return; if (!InstanceKlass::cast(super)->is_initialized()) return;
// call body to expose the this pointer // call body to expose the this pointer
instanceKlassHandle this_k(thread, this); eager_initialize_impl(this);
eager_initialize_impl(this_k);
} }
} }
@ -432,7 +431,7 @@ void InstanceKlass::fence_and_clear_init_lock() {
assert(!is_not_initialized(), "class must be initialized now"); 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; EXCEPTION_MARK;
HandleMark hm(THREAD); HandleMark hm(THREAD);
Handle init_lock(THREAD, this_k->init_lock()); Handle init_lock(THREAD, this_k->init_lock());
@ -470,8 +469,7 @@ void InstanceKlass::eager_initialize_impl(instanceKlassHandle this_k) {
// Note: implementation moved to static method to expose the this pointer. // Note: implementation moved to static method to expose the this pointer.
void InstanceKlass::initialize(TRAPS) { void InstanceKlass::initialize(TRAPS) {
if (this->should_be_initialized()) { if (this->should_be_initialized()) {
instanceKlassHandle this_k(THREAD, this); initialize_impl(this, CHECK);
initialize_impl(this_k, CHECK);
// Note: at this point the class may be initialized // Note: at this point the class may be initialized
// OR it may be in the state of being initialized // OR it may be in the state of being initialized
// in case of recursive initialization! // in case of recursive initialization!
@ -482,7 +480,7 @@ void InstanceKlass::initialize(TRAPS) {
bool InstanceKlass::verify_code( bool InstanceKlass::verify_code(
instanceKlassHandle this_k, bool throw_verifyerror, TRAPS) { InstanceKlass* this_k, bool throw_verifyerror, TRAPS) {
// 1) Verify the bytecodes // 1) Verify the bytecodes
Verifier::Mode mode = Verifier::Mode mode =
throw_verifyerror ? Verifier::ThrowException : Verifier::NoException; throw_verifyerror ? Verifier::ThrowException : Verifier::NoException;
@ -501,8 +499,7 @@ void InstanceKlass::unlink_class() {
void InstanceKlass::link_class(TRAPS) { void InstanceKlass::link_class(TRAPS) {
assert(is_loaded(), "must be loaded"); assert(is_loaded(), "must be loaded");
if (!is_linked()) { if (!is_linked()) {
instanceKlassHandle this_k(THREAD, this); link_class_impl(this, true, CHECK);
link_class_impl(this_k, true, CHECK);
} }
} }
@ -511,14 +508,13 @@ void InstanceKlass::link_class(TRAPS) {
bool InstanceKlass::link_class_or_fail(TRAPS) { bool InstanceKlass::link_class_or_fail(TRAPS) {
assert(is_loaded(), "must be loaded"); assert(is_loaded(), "must be loaded");
if (!is_linked()) { if (!is_linked()) {
instanceKlassHandle this_k(THREAD, this); link_class_impl(this, false, CHECK_false);
link_class_impl(this_k, false, CHECK_false);
} }
return is_linked(); return is_linked();
} }
bool InstanceKlass::link_class_impl( 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()) { if (DumpSharedSpaces && this_k->is_in_error_state()) {
// This is for CDS dumping phase only -- we use the in_error_state to indicate that // 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 // the class has failed verification. Throwing the NoClassDefFoundError here is just
@ -542,8 +538,8 @@ bool InstanceKlass::link_class_impl(
JavaThread* jt = (JavaThread*)THREAD; JavaThread* jt = (JavaThread*)THREAD;
// link super class before linking this class // link super class before linking this class
instanceKlassHandle super(THREAD, this_k->super()); Klass* super = this_k->super();
if (super.not_null()) { if (super != NULL) {
if (super->is_interface()) { // check if super class is an interface if (super->is_interface()) { // check if super class is an interface
ResourceMark rm(THREAD); ResourceMark rm(THREAD);
Exceptions::fthrow( Exceptions::fthrow(
@ -556,15 +552,16 @@ bool InstanceKlass::link_class_impl(
return false; 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 // link all interfaces implemented by this class before linking this class
Array<Klass*>* interfaces = this_k->local_interfaces(); Array<Klass*>* interfaces = this_k->local_interfaces();
int num_interfaces = interfaces->length(); int num_interfaces = interfaces->length();
for (int index = 0; index < num_interfaces; index++) { for (int index = 0; index < num_interfaces; index++) {
instanceKlassHandle ih(THREAD, interfaces->at(index)); InstanceKlass* interk = InstanceKlass::cast(interfaces->at(index));
link_class_impl(ih, throw_verifyerror, CHECK_false); link_class_impl(interk, throw_verifyerror, CHECK_false);
} }
// in case the class is linked in the process of linking its superclasses // in case the class is linked in the process of linking its superclasses
@ -642,7 +639,7 @@ bool InstanceKlass::link_class_impl(
if (JvmtiExport::should_post_class_prepare()) { if (JvmtiExport::should_post_class_prepare()) {
Thread *thread = THREAD; Thread *thread = THREAD;
assert(thread->is_Java_thread(), "thread->is_Java_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 @@ bool InstanceKlass::link_class_impl(
// verification but before the first method of the class is executed. // verification but before the first method of the class is executed.
void InstanceKlass::rewrite_class(TRAPS) { void InstanceKlass::rewrite_class(TRAPS) {
assert(is_loaded(), "must be loaded"); assert(is_loaded(), "must be loaded");
instanceKlassHandle this_k(THREAD, this); if (is_rewritten()) {
if (this_k->is_rewritten()) { assert(is_shared(), "rewriting an unshared class?");
assert(this_k()->is_shared(), "rewriting an unshared class?");
return; return;
} }
Rewriter::rewrite(this_k, CHECK); Rewriter::rewrite(this, CHECK);
this_k->set_rewritten(); set_rewritten();
} }
// Now relocate and link method entry points after class is rewritten. // Now relocate and link method entry points after class is rewritten.
@ -678,7 +674,7 @@ void InstanceKlass::link_methods(TRAPS) {
} }
// Eagerly initialize superinterfaces that declare default methods (concrete instance: any access) // 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"); assert (this_k->has_nonstatic_concrete_methods(), "caller should have checked this");
for (int i = 0; i < this_k->local_interfaces()->length(); ++i) { for (int i = 0; i < this_k->local_interfaces()->length(); ++i) {
Klass* iface = this_k->local_interfaces()->at(i); Klass* iface = this_k->local_interfaces()->at(i);
@ -698,14 +694,14 @@ void InstanceKlass::initialize_super_interfaces(instanceKlassHandle this_k, TRAP
} }
} }
void InstanceKlass::initialize_impl(instanceKlassHandle this_k, TRAPS) { void InstanceKlass::initialize_impl(InstanceKlass* this_k, TRAPS) {
HandleMark hm(THREAD); HandleMark hm(THREAD);
// Make sure klass is linked (verified) before initialization // Make sure klass is linked (verified) before initialization
// A class could already be verified, since it has been reflected upon. // A class could already be verified, since it has been reflected upon.
this_k->link_class(CHECK); this_k->link_class(CHECK);
DTRACE_CLASSINIT_PROBE(required, this_k(), -1); DTRACE_CLASSINIT_PROBE(required, this_k, -1);
bool wait = false; bool wait = false;
@ -728,19 +724,19 @@ void InstanceKlass::initialize_impl(instanceKlassHandle this_k, TRAPS) {
// Step 3 // Step 3
if (this_k->is_being_initialized() && this_k->is_reentrant_initialization(self)) { 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; return;
} }
// Step 4 // Step 4
if (this_k->is_initialized()) { if (this_k->is_initialized()) {
DTRACE_CLASSINIT_PROBE_WAIT(concurrent, this_k(), -1,wait); DTRACE_CLASSINIT_PROBE_WAIT(concurrent, this_k, -1,wait);
return; return;
} }
// Step 5 // Step 5
if (this_k->is_in_error_state()) { 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); ResourceMark rm(THREAD);
const char* desc = "Could not initialize class "; const char* desc = "Could not initialize class ";
const char* className = this_k->external_name(); const char* className = this_k->external_name();
@ -786,7 +782,7 @@ void InstanceKlass::initialize_impl(instanceKlassHandle this_k, TRAPS) {
this_k->set_initialization_state_and_notify(initialization_error, THREAD); this_k->set_initialization_state_and_notify(initialization_error, THREAD);
CLEAR_PENDING_EXCEPTION; 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()); THROW_OOP(e());
} }
} }
@ -799,7 +795,7 @@ void InstanceKlass::initialize_impl(instanceKlassHandle this_k, TRAPS) {
{ {
assert(THREAD->is_Java_thread(), "non-JavaThread in initialize_impl"); assert(THREAD->is_Java_thread(), "non-JavaThread in initialize_impl");
JavaThread* jt = (JavaThread*)THREAD; 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, // Timer includes any side effects of class initialization (resolution,
// etc), but not recursive entry into call_class_initializer(). // etc), but not recursive entry into call_class_initializer().
PerfClassTraceTime timer(ClassLoader::perf_class_init_time(), PerfClassTraceTime timer(ClassLoader::perf_class_init_time(),
@ -833,7 +829,7 @@ void InstanceKlass::initialize_impl(instanceKlassHandle this_k, TRAPS) {
// JVMTI internal flag reset is needed in order to report ExceptionInInitializerError // JVMTI internal flag reset is needed in order to report ExceptionInInitializerError
JvmtiExport::clear_detected_exception((JavaThread*)THREAD); 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())) { if (e->is_a(SystemDictionary::Error_klass())) {
THROW_OOP(e()); THROW_OOP(e());
} else { } else {
@ -843,17 +839,16 @@ void InstanceKlass::initialize_impl(instanceKlassHandle this_k, TRAPS) {
&args); &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. // Note: implementation moved to static method to expose the this pointer.
void InstanceKlass::set_initialization_state_and_notify(ClassState state, TRAPS) { void InstanceKlass::set_initialization_state_and_notify(ClassState state, TRAPS) {
instanceKlassHandle kh(THREAD, this); set_initialization_state_and_notify_impl(this, state, CHECK);
set_initialization_state_and_notify_impl(kh, 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()); Handle init_lock(THREAD, this_k->init_lock());
if (init_lock() != NULL) { if (init_lock() != NULL) {
ObjectLocker ol(init_lock, THREAD); ObjectLocker ol(init_lock, THREAD);
@ -995,9 +990,8 @@ objArrayOop InstanceKlass::allocate_objArray(int n, int length, TRAPS) {
} }
int size = objArrayOopDesc::object_size(length); int size = objArrayOopDesc::object_size(length);
Klass* ak = array_klass(n, CHECK_NULL); Klass* ak = array_klass(n, CHECK_NULL);
KlassHandle h_ak (THREAD, ak);
objArrayOop o = objArrayOop o =
(objArrayOop)CollectedHeap::array_allocate(h_ak, size, length, CHECK_NULL); (objArrayOop)CollectedHeap::array_allocate(ak, size, length, CHECK_NULL);
return o; return o;
} }
@ -1020,11 +1014,9 @@ instanceOop InstanceKlass::allocate_instance(TRAPS) {
bool has_finalizer_flag = has_finalizer(); // Query before possible GC bool has_finalizer_flag = has_finalizer(); // Query before possible GC
int size = size_helper(); // Query before forming handle. int size = size_helper(); // Query before forming handle.
KlassHandle h_k(THREAD, this);
instanceOop i; 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) { if (has_finalizer_flag && !RegisterFinalizersAtInit) {
i = register_finalizer(i, CHECK_NULL); i = register_finalizer(i, CHECK_NULL);
} }
@ -1045,11 +1037,10 @@ void InstanceKlass::check_valid_for_instantiation(bool throwError, TRAPS) {
} }
Klass* InstanceKlass::array_klass_impl(bool or_null, int n, TRAPS) { Klass* InstanceKlass::array_klass_impl(bool or_null, int n, TRAPS) {
instanceKlassHandle this_k(THREAD, this); return array_klass_impl(this, or_null, n, THREAD);
return array_klass_impl(this_k, 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 // Need load-acquire for lock-free read
if (this_k->array_klasses_acquire() == NULL) { if (this_k->array_klasses_acquire() == NULL) {
if (or_null) return NULL; if (or_null) return NULL;
@ -1082,13 +1073,12 @@ Klass* InstanceKlass::array_klass_impl(bool or_null, TRAPS) {
} }
void InstanceKlass::call_class_initializer(TRAPS) { void InstanceKlass::call_class_initializer(TRAPS) {
instanceKlassHandle ik (THREAD, this); call_class_initializer_impl(this, THREAD);
call_class_initializer_impl(ik, THREAD);
} }
static int call_class_initializer_impl_counter = 0; // for debugging static int call_class_initializer_impl_counter = 0; // for debugging
Method* InstanceKlass::class_initializer() { Method* InstanceKlass::class_initializer() const {
Method* clinit = find_method( Method* clinit = find_method(
vmSymbols::class_initializer_name(), vmSymbols::void_method_signature()); vmSymbols::class_initializer_name(), vmSymbols::void_method_signature());
if (clinit != NULL && clinit->has_valid_initializer_flags()) { if (clinit != NULL && clinit->has_valid_initializer_flags()) {
@ -1097,7 +1087,7 @@ Method* InstanceKlass::class_initializer() {
return NULL; return NULL;
} }
void InstanceKlass::call_class_initializer_impl(instanceKlassHandle this_k, TRAPS) { void InstanceKlass::call_class_initializer_impl(InstanceKlass* this_k, TRAPS) {
if (ReplayCompiles && if (ReplayCompiles &&
(ReplaySuppressInitializers == 1 || (ReplaySuppressInitializers == 1 ||
ReplaySuppressInitializers >= 2 && this_k->class_loader() != NULL)) { ReplaySuppressInitializers >= 2 && this_k->class_loader() != NULL)) {
@ -1112,7 +1102,7 @@ void InstanceKlass::call_class_initializer_impl(instanceKlassHandle this_k, TRAP
outputStream* log = Log(class, init)::info_stream(); outputStream* log = Log(class, init)::info_stream();
log->print("%d Initializing ", call_class_initializer_impl_counter++); log->print("%d Initializing ", call_class_initializer_impl_counter++);
this_k->name()->print_value_on(log); 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) { if (h_method() != NULL) {
JavaCallArguments args; // No arguments JavaCallArguments args; // No arguments
@ -1263,14 +1253,13 @@ void InstanceKlass::do_local_static_fields(FieldClosure* cl) {
void InstanceKlass::do_local_static_fields(void f(fieldDescriptor*, Handle, TRAPS), Handle mirror, TRAPS) { void InstanceKlass::do_local_static_fields(void f(fieldDescriptor*, Handle, TRAPS), Handle mirror, TRAPS) {
instanceKlassHandle h_this(THREAD, this); do_local_static_fields_impl(this, f, mirror, CHECK);
do_local_static_fields_impl(h_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) { 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()) { if (fs.access_flags().is_static()) {
fieldDescriptor& fd = fs.field_descriptor(); fieldDescriptor& fd = fs.field_descriptor();
f(&fd, mirror, CHECK); f(&fd, mirror, CHECK);
@ -1629,13 +1618,13 @@ Method* InstanceKlass::lookup_method_in_all_interfaces(Symbol* name,
} }
/* jni_id_for_impl for jfieldIds only */ /* 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); MutexLocker ml(JfieldIdCreation_lock);
// Retry lookup after we got the lock // Retry lookup after we got the lock
JNIid* probe = this_k->jni_ids() == NULL ? NULL : this_k->jni_ids()->find(offset); JNIid* probe = this_k->jni_ids() == NULL ? NULL : this_k->jni_ids()->find(offset);
if (probe == NULL) { if (probe == NULL) {
// Slow case, allocate new static field identifier // 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); this_k->set_jni_ids(probe);
} }
return probe; return probe;
@ -1684,9 +1673,9 @@ void InstanceKlass::set_enclosing_method_indices(u2 class_index,
// locking has to be done very carefully to avoid deadlocks // locking has to be done very carefully to avoid deadlocks
// and/or other cache consistency problems. // 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(); 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; size_t length = 0;
jmethodID id = NULL; jmethodID id = NULL;
@ -1710,7 +1699,7 @@ jmethodID InstanceKlass::get_jmethod_id(instanceKlassHandle ik_h, const methodHa
if (jmeths != NULL) { if (jmeths != NULL) {
// the cache already exists // 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 // the cache can't grow so we can just get the current values
get_jmethod_id_length_value(jmeths, idnum, &length, &id); get_jmethod_id_length_value(jmeths, idnum, &length, &id);
} else { } else {
@ -1744,7 +1733,7 @@ jmethodID InstanceKlass::get_jmethod_id(instanceKlassHandle ik_h, const methodHa
jmethodID* new_jmeths = NULL; jmethodID* new_jmeths = NULL;
if (length <= idnum) { if (length <= idnum) {
// allocate a new cache that might be used // 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); new_jmeths = NEW_C_HEAP_ARRAY(jmethodID, size+1, mtClass);
memset(new_jmeths, 0, (size+1)*sizeof(jmethodID)); memset(new_jmeths, 0, (size+1)*sizeof(jmethodID));
// cache size is stored in element[0], other elements offset by one // cache size is stored in element[0], other elements offset by one
@ -1755,23 +1744,23 @@ jmethodID InstanceKlass::get_jmethod_id(instanceKlassHandle ik_h, const methodHa
jmethodID new_id = NULL; jmethodID new_id = NULL;
if (method_h->is_old() && !method_h->is_obsolete()) { 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 // 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"); 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 { } else {
// It is the current version of the method or an obsolete method, // It is the current version of the method or an obsolete method,
// use the version passed in // 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 || if (Threads::number_of_threads() == 0 ||
SafepointSynchronize::is_at_safepoint()) { SafepointSynchronize::is_at_safepoint()) {
// we're single threaded or at a safepoint - no locking needed // 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); &to_dealloc_id, &to_dealloc_jmeths);
} else { } else {
MutexLocker ml(JmethodIdCreation_lock); 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); &to_dealloc_id, &to_dealloc_jmeths);
} }
@ -1782,7 +1771,7 @@ jmethodID InstanceKlass::get_jmethod_id(instanceKlassHandle ik_h, const methodHa
} }
// free up the new ID since it wasn't needed // free up the new ID since it wasn't needed
if (to_dealloc_id != NULL) { 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; return id;
@ -1814,7 +1803,7 @@ void InstanceKlass::ensure_space_for_methodids(int start_offset) {
// the VMThread or have cache consistency issues. // the VMThread or have cache consistency issues.
// //
jmethodID InstanceKlass::get_jmethod_id_fetch_or_update( 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* new_jmeths, jmethodID* to_dealloc_id_p,
jmethodID** to_dealloc_jmeths_p) { jmethodID** to_dealloc_jmeths_p) {
assert(new_id != NULL, "sanity check"); assert(new_id != NULL, "sanity check");
@ -1825,7 +1814,7 @@ jmethodID InstanceKlass::get_jmethod_id_fetch_or_update(
JmethodIdCreation_lock->owned_by_self(), "sanity check"); JmethodIdCreation_lock->owned_by_self(), "sanity check");
// reacquire the cache - we are locked, single threaded or at a safepoint // 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; jmethodID id = NULL;
size_t length = 0; size_t length = 0;
@ -1838,7 +1827,7 @@ jmethodID InstanceKlass::get_jmethod_id_fetch_or_update(
} }
*to_dealloc_jmeths_p = jmeths; // save old cache for later delete *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 { } else {
// fetch jmethodID (if any) from the existing cache // fetch jmethodID (if any) from the existing cache
id = jmeths[idnum+1]; id = jmeths[idnum+1];
@ -2058,11 +2047,10 @@ static void restore_unshareable_in_class(Klass* k, TRAPS) {
} }
void InstanceKlass::restore_unshareable_info(ClassLoaderData* loader_data, Handle protection_domain, TRAPS) { void InstanceKlass::restore_unshareable_info(ClassLoaderData* loader_data, Handle protection_domain, TRAPS) {
instanceKlassHandle ik(THREAD, this); set_package(loader_data, CHECK);
ik->set_package(loader_data, CHECK);
Klass::restore_unshareable_info(loader_data, protection_domain, 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(); int num_methods = methods->length();
for (int index2 = 0; index2 < num_methods; ++index2) { for (int index2 = 0; index2 < num_methods; ++index2) {
methodHandle m(THREAD, methods->at(index2)); methodHandle m(THREAD, methods->at(index2));
@ -2075,14 +2063,14 @@ void InstanceKlass::restore_unshareable_info(ClassLoaderData* loader_data, Handl
// vtables in the shared system dictionary, only the main one. // vtables in the shared system dictionary, only the main one.
// It also redefines the itable too so fix that too. // It also redefines the itable too so fix that too.
ResourceMark rm(THREAD); ResourceMark rm(THREAD);
ik->vtable()->initialize_vtable(false, CHECK); vtable()->initialize_vtable(false, CHECK);
ik->itable()->initialize_itable(false, CHECK); itable()->initialize_itable(false, CHECK);
} }
// restore constant pool resolved references // restore constant pool resolved references
ik->constants()->restore_unshareable_info(CHECK); constants()->restore_unshareable_info(CHECK);
ik->array_klasses_do(restore_unshareable_in_class, 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. // returns true IFF is_in_error_state() has been changed as a result of this call.
@ -2448,7 +2436,7 @@ bool InstanceKlass::is_override(const methodHandle& super_method, Handle targetc
} }
/* defined for now in jvm.cpp, for historical reasons *-- /* 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) { Symbol*& simple_name_result, TRAPS) {
... ...
} }
@ -2522,7 +2510,7 @@ bool InstanceKlass::is_same_package_member_impl(const InstanceKlass* class1,
return false; 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()); constantPoolHandle i_cp(THREAD, k->constants());
for (InnerClassesIterator iter(k); !iter.done(); iter.next()) { for (InnerClassesIterator iter(k); !iter.done(); iter.next()) {
int ioff = iter.inner_class_info_index(); int ioff = iter.inner_class_info_index();
@ -2531,7 +2519,7 @@ bool InstanceKlass::find_inner_classes_attr(instanceKlassHandle k, int* ooff, in
// before attempting to find the class. // before attempting to find the class.
if (i_cp->klass_name_at_matches(k, ioff)) { if (i_cp->klass_name_at_matches(k, ioff)) {
Klass* inner_klass = i_cp->klass_at(ioff, CHECK_false); Klass* inner_klass = i_cp->klass_at(ioff, CHECK_false);
if (k() == inner_klass) { if (k == inner_klass) {
*ooff = iter.outer_class_info_index(); *ooff = iter.outer_class_info_index();
*noff = iter.inner_name_index(); *noff = iter.inner_name_index();
return true; return true;
@ -2580,8 +2568,7 @@ jint InstanceKlass::compute_modifier_flags(TRAPS) const {
jint access = access_flags().as_int(); jint access = access_flags().as_int();
// But check if it happens to be member class. // But check if it happens to be member class.
instanceKlassHandle ik(THREAD, this); InnerClassesIterator iter(this);
InnerClassesIterator iter(ik);
for (; !iter.done(); iter.next()) { for (; !iter.done(); iter.next()) {
int ioff = iter.inner_class_info_index(); int ioff = iter.inner_class_info_index();
// Inner class attribute can be zero, skip it. // Inner class attribute can be zero, skip it.
@ -2590,8 +2577,8 @@ jint InstanceKlass::compute_modifier_flags(TRAPS) const {
// only look at classes that are already loaded // only look at classes that are already loaded
// since we are looking for the flags for our self. // since we are looking for the flags for our self.
Symbol* inner_name = ik->constants()->klass_name_at(ioff); Symbol* inner_name = constants()->klass_name_at(ioff);
if ((ik->name() == inner_name)) { if (name() == inner_name) {
// This is really a member class. // This is really a member class.
access = iter.inner_access_flags(); access = iter.inner_access_flags();
break; break;
@ -3612,7 +3599,7 @@ void InstanceKlass::mark_newly_obsolete_methods(Array<Method*>* old_methods,
// Save the scratch_class as the previous version if any of the methods are running. // 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 // 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. // 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) { int emcp_method_count) {
assert(Thread::current()->is_VM_thread(), assert(Thread::current()->is_VM_thread(),
"only VMThread can add previous versions"); "only VMThread can add previous versions");
@ -3638,7 +3625,7 @@ void InstanceKlass::add_previous_version(instanceKlassHandle scratch_class,
log_trace(redefine, class, iklass, add)("scratch class not added; no methods are running"); log_trace(redefine, class, iklass, add)("scratch class not added; no methods are running");
// For debugging purposes. // For debugging purposes.
scratch_class->set_is_scratch_class(); 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; return;
} }
@ -3671,7 +3658,7 @@ void InstanceKlass::add_previous_version(instanceKlassHandle scratch_class,
log_trace(redefine, class, iklass, add) ("scratch class added; one of its methods is on_stack."); 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"); assert(scratch_class->previous_versions() == NULL, "shouldn't have a previous version");
scratch_class->link_previous_versions(previous_versions()); scratch_class->link_previous_versions(previous_versions());
link_previous_versions(scratch_class()); link_previous_versions(scratch_class);
} // end add_previous_version() } // end add_previous_version()
#endif // INCLUDE_JVMTI #endif // INCLUDE_JVMTI

View file

@ -472,7 +472,7 @@ class InstanceKlass: public Klass {
TRAPS); TRAPS);
// Find InnerClasses attribute for k and return outer_class_info_index & inner_name_index. // 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); int* ooff, int* noff, TRAPS);
private: private:
@ -524,7 +524,7 @@ class InstanceKlass: public Klass {
void unlink_class(); void unlink_class();
void rewrite_class(TRAPS); void rewrite_class(TRAPS);
void link_methods(TRAPS); void link_methods(TRAPS);
Method* class_initializer(); Method* class_initializer() const;
// set the class to initialized if no static initializer is present // set the class to initialized if no static initializer is present
void eager_initialize(Thread *thread); void eager_initialize(Thread *thread);
@ -711,7 +711,7 @@ class InstanceKlass: public Klass {
void set_is_being_redefined(bool value) { _is_being_redefined = value; } void set_is_being_redefined(bool value) { _is_being_redefined = value; }
// RedefineClasses() support for previous versions: // 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(); void purge_previous_version_list();
InstanceKlass* previous_versions() const { return _previous_versions; } InstanceKlass* previous_versions() const { return _previous_versions; }
@ -883,9 +883,9 @@ public:
u2 method_index); u2 method_index);
// jmethodID support // jmethodID support
static jmethodID get_jmethod_id(instanceKlassHandle ik_h, static jmethodID get_jmethod_id(InstanceKlass* ik,
const methodHandle& method_h); 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, size_t idnum, jmethodID new_id, jmethodID* new_jmeths,
jmethodID* to_dealloc_id_p, jmethodID* to_dealloc_id_p,
jmethodID** to_dealloc_jmeths_p); jmethodID** to_dealloc_jmeths_p);
@ -1308,17 +1308,17 @@ private:
// Static methods that are used to implement member methods where an exposed this pointer // Static methods that are used to implement member methods where an exposed this pointer
// is needed due to possible GCs // is needed due to possible GCs
static bool link_class_impl (instanceKlassHandle this_k, bool throw_verifyerror, TRAPS); static bool link_class_impl (InstanceKlass* this_k, bool throw_verifyerror, TRAPS);
static bool verify_code (instanceKlassHandle this_k, bool throw_verifyerror, TRAPS); static bool verify_code (InstanceKlass* this_k, bool throw_verifyerror, TRAPS);
static void initialize_impl (instanceKlassHandle this_k, TRAPS); static void initialize_impl (InstanceKlass* this_k, TRAPS);
static void initialize_super_interfaces (instanceKlassHandle this_k, TRAPS); static void initialize_super_interfaces (InstanceKlass* this_k, TRAPS);
static void eager_initialize_impl (instanceKlassHandle this_k); static void eager_initialize_impl (InstanceKlass* this_k);
static void set_initialization_state_and_notify_impl (instanceKlassHandle this_k, ClassState state, TRAPS); static void set_initialization_state_and_notify_impl (InstanceKlass* this_k, ClassState state, TRAPS);
static void call_class_initializer_impl (instanceKlassHandle this_k, TRAPS); static void call_class_initializer_impl (InstanceKlass* this_k, TRAPS);
static Klass* array_klass_impl (instanceKlassHandle this_k, bool or_null, int n, TRAPS); static Klass* array_klass_impl (InstanceKlass* 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 void do_local_static_fields_impl (InstanceKlass* this_k, void f(fieldDescriptor* fd, Handle, TRAPS), Handle, TRAPS);
/* jni_id_for_impl for jfieldID only */ /* 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 // Returns the array class for the n'th dimension
Klass* array_klass_impl(bool or_null, int n, TRAPS); Klass* array_klass_impl(bool or_null, int n, TRAPS);
@ -1447,7 +1447,7 @@ class InnerClassesIterator : public StackObj {
int _idx; int _idx;
public: public:
InnerClassesIterator(instanceKlassHandle k) { InnerClassesIterator(const InstanceKlass* k) {
_inner_classes = k->inner_classes(); _inner_classes = k->inner_classes();
if (k->inner_classes() != NULL) { if (k->inner_classes() != NULL) {
_length = _inner_classes->length(); _length = _inner_classes->length();

View file

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * 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::_offset_of_static_fields = 0;
int InstanceMirrorKlass::instance_size(KlassHandle k) { int InstanceMirrorKlass::instance_size(Klass* k) {
if (k() != NULL && k->is_instance_klass()) { if (k != NULL && k->is_instance_klass()) {
return align_object_size(size_helper() + InstanceKlass::cast(k())->static_field_size()); return align_object_size(size_helper() + InstanceKlass::cast(k)->static_field_size());
} }
return size_helper(); return size_helper();
} }
instanceOop InstanceMirrorKlass::allocate_instance(KlassHandle k, TRAPS) { instanceOop InstanceMirrorKlass::allocate_instance(Klass* k, TRAPS) {
// Query before forming handle. // Query before forming handle.
int size = instance_size(k); int size = instance_size(k);
KlassHandle h_k(THREAD, this);
assert(size > 0, "total object size must be positive: %d", size); assert(size > 0, "total object size must be positive: %d", size);
// Since mirrors can be variable sized because of the static fields, store // Since mirrors can be variable sized because of the static fields, store
// the size in the mirror itself. // 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 { int InstanceMirrorKlass::oop_size(oop obj) const {

View file

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -82,10 +82,10 @@ class InstanceMirrorKlass: public InstanceKlass {
int compute_static_oop_field_count(oop obj); int compute_static_oop_field_count(oop obj);
// Given a Klass return the size of the instance // Given a Klass return the size of the instance
int instance_size(KlassHandle k); int instance_size(Klass* k);
// allocation // allocation
instanceOop allocate_instance(KlassHandle k, TRAPS); instanceOop allocate_instance(Klass* k, TRAPS);
// GC specific object visitors // GC specific object visitors
// //

View file

@ -264,7 +264,6 @@ void Klass::initialize_supers(Klass* k, TRAPS) {
} }
if (secondary_supers() == NULL) { if (secondary_supers() == NULL) {
KlassHandle this_kh (THREAD, this);
// Now compute the list of secondary supertypes. // Now compute the list of secondary supertypes.
// Secondaries can occasionally be on the super chain, // Secondaries can occasionally be on the super chain,
@ -286,7 +285,7 @@ void Klass::initialize_supers(Klass* k, TRAPS) {
GrowableArray<Klass*>* primaries = new GrowableArray<Klass*>(extras); 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 int i; // Scan for overflow primaries being duplicates of 2nd'arys
// This happens frequently for very deeply nested arrays: the // This happens frequently for very deeply nested arrays: the
@ -324,7 +323,7 @@ void Klass::initialize_supers(Klass* k, TRAPS) {
} }
#endif #endif
this_kh->set_secondary_supers(s2); set_secondary_supers(s2);
} }
} }
@ -698,7 +697,7 @@ void Klass::oop_verify_on(oop obj, outputStream* st) {
} }
klassVtable* Klass::vtable() const { 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 { vtableEntry* Klass::start_of_vtable() const {

View file

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -40,7 +40,7 @@
#include "utilities/copy.hpp" #include "utilities/copy.hpp"
inline InstanceKlass* klassVtable::ik() const { inline InstanceKlass* klassVtable::ik() const {
return InstanceKlass::cast(_klass()); return InstanceKlass::cast(_klass);
} }
bool klassVtable::is_preinitialized_vtable() { bool klassVtable::is_preinitialized_vtable() {
@ -128,8 +128,8 @@ int klassVtable::index_of(Method* m, int len) const {
// Copy super class's vtable to the first part (prefix) of this class's vtable, // 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 // 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). // super class (arrays can have "array" super classes that must be skipped).
int klassVtable::initialize_from_super(KlassHandle super) { int klassVtable::initialize_from_super(Klass* super) {
if (super.is_null()) { if (super == NULL) {
return 0; return 0;
} else if (is_preinitialized_vtable()) { } else if (is_preinitialized_vtable()) {
// A shared class' vtable is preinitialized at dump time. No need to copy // A shared class' vtable is preinitialized at dump time. No need to copy
@ -160,18 +160,18 @@ int klassVtable::initialize_from_super(KlassHandle super) {
void klassVtable::initialize_vtable(bool checkconstraints, TRAPS) { void klassVtable::initialize_vtable(bool checkconstraints, TRAPS) {
// Note: Arrays can have intermediate array supers. Use java_super to skip them. // 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; int nofNewEntries = 0;
bool is_shared = _klass->is_shared(); bool is_shared = _klass->is_shared();
if (!klass()->is_array_klass()) { if (!_klass->is_array_klass()) {
ResourceMark rm(THREAD); ResourceMark rm(THREAD);
log_develop_debug(vtables)("Initializing: %s", _klass->name()->as_C_string()); log_develop_debug(vtables)("Initializing: %s", _klass->name()->as_C_string());
} }
#ifdef ASSERT #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]; oop* end_of_vtable = (oop*)&table()[_length];
assert(end_of_vtable <= end_of_obj, "vtable extends beyond end"); assert(end_of_vtable <= end_of_obj, "vtable extends beyond end");
#endif #endif
@ -184,7 +184,7 @@ void klassVtable::initialize_vtable(bool checkconstraints, TRAPS) {
} }
int super_vtable_len = initialize_from_super(super); 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"); assert(super_vtable_len == _length, "arrays shouldn't introduce new methods");
} else { } else {
assert(_klass->is_instance_klass(), "must be InstanceKlass"); assert(_klass->is_instance_klass(), "must be InstanceKlass");
@ -327,7 +327,7 @@ InstanceKlass* klassVtable::find_transitive_override(InstanceKlass* initialsuper
} }
static void log_vtables(int i, bool overrides, methodHandle target_method, 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) { Thread* thread) {
#ifndef PRODUCT #ifndef PRODUCT
if (log_develop_is_enabled(Trace, vtables)) { if (log_develop_is_enabled(Trace, vtables)) {
@ -432,7 +432,7 @@ bool klassVtable::update_inherited_vtable(InstanceKlass* klass, methodHandle tar
Symbol* name = target_method()->name(); Symbol* name = target_method()->name();
Symbol* signature = target_method()->signature(); Symbol* signature = target_method()->signature();
KlassHandle target_klass(THREAD, target_method()->method_holder()); Klass* target_klass = target_method()->method_holder();
if (target_klass == NULL) { if (target_klass == NULL) {
target_klass = _klass; target_klass = _klass;
} }
@ -955,7 +955,7 @@ void klassVtable::adjust_method_entries(InstanceKlass* holder, bool * trace_name
if (!(*trace_name_printed)) { if (!(*trace_name_printed)) {
log_info(redefine, class, update) log_info(redefine, class, update)
("adjust: klassname=%s for methods from name=%s", ("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; *trace_name_printed = true;
} }
log_debug(redefine, class, update, vtables) log_debug(redefine, class, update, vtables)
@ -1025,17 +1025,17 @@ void itableMethodEntry::initialize(Method* m) {
} }
} }
klassItable::klassItable(instanceKlassHandle klass) { klassItable::klassItable(InstanceKlass* klass) {
_klass = klass; _klass = klass;
if (klass->itable_length() > 0) { if (klass->itable_length() > 0) {
itableOffsetEntry* offset_entry = (itableOffsetEntry*)klass->start_of_itable(); itableOffsetEntry* offset_entry = (itableOffsetEntry*)klass->start_of_itable();
if (offset_entry != NULL && offset_entry->interface_klass() != NULL) { // Check that itable is initialized if (offset_entry != NULL && offset_entry->interface_klass() != NULL) { // Check that itable is initialized
// First offset entry points to the first method_entry // 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(); 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_offset_table = (method_entry - ((intptr_t*)offset_entry)) / itableOffsetEntry::size();
_size_method_table = (end - method_entry) / itableMethodEntry::size(); _size_method_table = (end - method_entry) / itableMethodEntry::size();
assert(_table_offset >= 0 && _size_offset_table >= 0 && _size_method_table >= 0, "wrong computation"); assert(_table_offset >= 0 && _size_offset_table >= 0 && _size_method_table >= 0, "wrong computation");
@ -1056,7 +1056,7 @@ void klassItable::initialize_itable(bool checkconstraints, TRAPS) {
if (_klass->is_interface()) { if (_klass->is_interface()) {
// This needs to go after vtable indices are assigned but // This needs to go after vtable indices are assigned but
// before implementors need to know the number of itable indices. // 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 // Cannot be setup doing bootstrapping, interfaces don't have
@ -1078,9 +1078,9 @@ void klassItable::initialize_itable(bool checkconstraints, TRAPS) {
for(i = 0; i < num_interfaces; i++) { for(i = 0; i < num_interfaces; i++) {
itableOffsetEntry* ioe = offset_entry(i); itableOffsetEntry* ioe = offset_entry(i);
HandleMark hm(THREAD); HandleMark hm(THREAD);
KlassHandle interf_h (THREAD, ioe->interface_klass()); Klass* interf = ioe->interface_klass();
assert(interf_h() != NULL && ioe->offset() != 0, "bad offset entry in itable"); assert(interf != NULL && ioe->offset() != 0, "bad offset entry in itable");
initialize_itable_for_interface(ioe->offset(), interf_h, checkconstraints, CHECK); initialize_itable_for_interface(ioe->offset(), interf, checkconstraints, CHECK);
} }
} }
@ -1169,14 +1169,14 @@ int klassItable::method_count_for_interface(Klass* interf) {
} }
void klassItable::initialize_itable_for_interface(int method_table_offset, KlassHandle interf_h, bool checkconstraints, TRAPS) { void klassItable::initialize_itable_for_interface(int method_table_offset, Klass* interf, bool checkconstraints, TRAPS) {
Array<Method*>* methods = InstanceKlass::cast(interf_h())->methods(); Array<Method*>* methods = InstanceKlass::cast(interf)->methods();
int nof_methods = methods->length(); int nof_methods = methods->length();
HandleMark hm; HandleMark hm;
assert(nof_methods > 0, "at least one method must exist for interface to be in vtable"); 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++) { for (int i = 0; i < nof_methods; i++) {
Method* m = methods->at(i); Method* m = methods->at(i);
methodHandle target; methodHandle target;
@ -1189,7 +1189,7 @@ void klassItable::initialize_itable_for_interface(int method_table_offset, Klass
// Entry does not resolve. Leave it empty for AbstractMethodError. // Entry does not resolve. Leave it empty for AbstractMethodError.
if (!(target == NULL) && !target->is_public()) { if (!(target == NULL) && !target->is_public()) {
// Stuff an IllegalAccessError throwing method in there instead. // 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()); initialize(Universe::throw_illegal_access_error());
} }
} else { } else {
@ -1215,7 +1215,7 @@ void klassItable::initialize_itable_for_interface(int method_table_offset, Klass
const char* loader1 = SystemDictionary::loader_name(method_holder_loader()); const char* loader1 = SystemDictionary::loader_name(method_holder_loader());
char* current = _klass->name()->as_C_string(); char* current = _klass->name()->as_C_string();
const char* loader2 = SystemDictionary::loader_name(interface_loader()); 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(); char* failed_type_name = failed_type_symbol->as_C_string();
size_t buflen = strlen(msg) + strlen(sig) + strlen(loader1) + size_t buflen = strlen(msg) + strlen(sig) + strlen(loader1) +
strlen(current) + strlen(loader2) + strlen(iface) + strlen(current) + strlen(loader2) + strlen(iface) +
@ -1231,14 +1231,14 @@ void klassItable::initialize_itable_for_interface(int method_table_offset, Klass
// ime may have moved during GC so recalculate address // ime may have moved during GC so recalculate address
int ime_num = m->itable_index(); int ime_num = m->itable_index();
assert(ime_num < ime_count, "oob"); 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)) { if (log_develop_is_enabled(Trace, itables)) {
ResourceMark rm(THREAD); ResourceMark rm(THREAD);
if (target() != NULL) { if (target() != NULL) {
outputStream* logst = Log(itables)::trace_stream(); outputStream* logst = Log(itables)::trace_stream();
char* sig = target()->name_and_sig_as_C_string(); char* sig = target()->name_and_sig_as_C_string();
logst->print("interface: %s, ime_num: %d, target: %s, method_holder: %s ", 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()); target()->method_holder()->internal_name());
logst->print("target_method flags: "); logst->print("target_method flags: ");
target()->print_linkage_flags(logst); target()->print_linkage_flags(logst);
@ -1408,7 +1408,7 @@ int klassItable::compute_itable_size(Array<Klass*>* transitive_interfaces) {
// Fill out offset table and interface klasses into the itable space // 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; if (klass->itable_length() == 0) return;
assert(!klass->is_interface(), "Should have zero length itable"); assert(!klass->is_interface(), "Should have zero length itable");
@ -1433,7 +1433,7 @@ void klassItable::setup_itable_offset_table(instanceKlassHandle klass) {
assert((oop*)(end) == (oop*)(ime + nof_methods), "wrong offset calculation (2)"); assert((oop*)(end) == (oop*)(ime + nof_methods), "wrong offset calculation (2)");
// Visit all interfaces and initialize itable offset table // 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); visit_all_interfaces(klass->transitive_interfaces(), &sic);
#ifdef ASSERT #ifdef ASSERT
@ -1476,7 +1476,7 @@ void klassVtable::verify(outputStream* st, bool forced) {
if (!forced && _verify_count == Universe::verify_count()) return; if (!forced && _verify_count == Universe::verify_count()) return;
_verify_count = Universe::verify_count(); _verify_count = Universe::verify_count();
#endif #endif
oop* end_of_obj = (oop*)_klass() + _klass()->size(); oop* end_of_obj = (oop*)_klass + _klass->size();
oop* end_of_vtable = (oop *)&table()[_length]; oop* end_of_vtable = (oop *)&table()[_length];
if (end_of_vtable > end_of_obj) { if (end_of_vtable > end_of_obj) {
fatal("klass %s: klass object too short (vtable extends beyond end)", fatal("klass %s: klass object too short (vtable extends beyond end)",
@ -1516,8 +1516,7 @@ void klassVtable::print() {
void vtableEntry::verify(klassVtable* vt, outputStream* st) { void vtableEntry::verify(klassVtable* vt, outputStream* st) {
NOT_PRODUCT(FlagSetting fs(IgnoreLockingAssertions, true)); NOT_PRODUCT(FlagSetting fs(IgnoreLockingAssertions, true));
KlassHandle vtklass_h = vt->klass(); Klass* vtklass = vt->klass();
Klass* vtklass = vtklass_h();
if (vtklass->is_instance_klass() && if (vtklass->is_instance_klass() &&
(InstanceKlass::cast(vtklass)->major_version() >= klassVtable::VTABLE_TRANSITIVE_OVERRIDE_VERSION)) { (InstanceKlass::cast(vtklass)->major_version() >= klassVtable::VTABLE_TRANSITIVE_OVERRIDE_VERSION)) {
assert(method() != NULL, "must have set method"); assert(method() != NULL, "must have set method");
@ -1525,7 +1524,7 @@ void vtableEntry::verify(klassVtable* vt, outputStream* st) {
if (method() != NULL) { if (method() != NULL) {
method()->verify(); method()->verify();
// we sub_type, because it could be a miranda method // 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 #ifndef PRODUCT
print(); print();
#endif #endif

View file

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -42,7 +42,7 @@
class vtableEntry; class vtableEntry;
class klassVtable : public ResourceObj { class klassVtable : public ResourceObj {
KlassHandle _klass; // my klass Klass* _klass; // my klass
int _tableOffset; // offset of start of vtable data within klass int _tableOffset; // offset of start of vtable data within klass
int _length; // length of vtable (number of entries) int _length; // length of vtable (number of entries)
#ifndef PRODUCT #ifndef PRODUCT
@ -57,13 +57,13 @@ class klassVtable : public ResourceObj {
}; };
public: public:
klassVtable(KlassHandle h_klass, void* base, int length) : _klass(h_klass) { klassVtable(Klass* klass, void* base, int length) : _klass(klass) {
_tableOffset = (address)base - (address)h_klass(); _length = length; _tableOffset = (address)base - (address)klass; _length = length;
} }
// accessors // accessors
vtableEntry* table() const { return (vtableEntry*)(address(_klass()) + _tableOffset); } vtableEntry* table() const { return (vtableEntry*)(address(_klass) + _tableOffset); }
KlassHandle klass() const { return _klass; } Klass* klass() const { return _klass; }
int length() const { return _length; } int length() const { return _length; }
inline Method* method_at(int i) const; inline Method* method_at(int i) const;
inline Method* unchecked_method_at(int i) const; inline Method* unchecked_method_at(int i) const;
@ -125,7 +125,7 @@ class klassVtable : public ResourceObj {
private: private:
void copy_vtable_to(vtableEntry* start); 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 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); void put_method_at(Method* m, int index);
static bool needs_new_vtable_entry(methodHandle m, static bool needs_new_vtable_entry(methodHandle m,
@ -290,14 +290,14 @@ class itableMethodEntry VALUE_OBJ_CLASS_SPEC {
// //
class klassItable : public ResourceObj { class klassItable : public ResourceObj {
private: private:
instanceKlassHandle _klass; // my klass InstanceKlass* _klass; // my klass
int _table_offset; // offset of start of itable data within klass (in words) 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_offset_table; // size of offset table (in itableOffset entries)
int _size_method_table; // size of methodtable (in itableMethodEntry 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: public:
klassItable(instanceKlassHandle klass); klassItable(InstanceKlass* klass);
itableOffsetEntry* offset_entry(int i) { assert(0 <= i && i <= _size_offset_table, "index out of bounds"); itableOffsetEntry* offset_entry(int i) { assert(0 <= i && i <= _size_offset_table, "index out of bounds");
return &((itableOffsetEntry*)vtable_start())[i]; } return &((itableOffsetEntry*)vtable_start())[i]; }
@ -329,7 +329,7 @@ class klassItable : public ResourceObj {
static int assign_itable_indices_for_interface(Klass* klass); static int assign_itable_indices_for_interface(Klass* klass);
static int method_count_for_interface(Klass* klass); static int method_count_for_interface(Klass* klass);
static int compute_itable_size(Array<Klass*>* transitive_interfaces); 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 // Resolving of method to index
static Method* method_for_itable_index(Klass* klass, int itable_index); static Method* method_for_itable_index(Klass* klass, int itable_index);
@ -337,7 +337,7 @@ class klassItable : public ResourceObj {
// Debugging/Statistics // Debugging/Statistics
static void print_statistics() PRODUCT_RETURN; static void print_statistics() PRODUCT_RETURN;
private: 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(); } intptr_t* method_start() const { return vtable_start() + _size_offset_table * itableOffsetEntry::size(); }
// Helper methods // Helper methods

View file

@ -173,7 +173,7 @@ char* Method::name_and_sig_as_C_string(Klass* klass, Symbol* method_name, Symbol
return buf; 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) // exception table holds quadruple entries of the form (beg_bci, end_bci, handler_bci, klass_index)
// access exception table // access exception table
ExceptionTable table(mh()); ExceptionTable table(mh());
@ -192,16 +192,15 @@ int Method::fast_exception_handler_bci_for(methodHandle mh, KlassHandle ex_klass
int klass_index = table.catch_type_index(i); int klass_index = table.catch_type_index(i);
if (klass_index == 0) { if (klass_index == 0) {
return handler_bci; return handler_bci;
} else if (ex_klass.is_null()) { } else if (ex_klass == NULL) {
return handler_bci; return handler_bci;
} else { } else {
// we know the exception class => get the constraint class // we know the exception class => get the constraint class
// this may require loading of the constraint class; if verification // this may require loading of the constraint class; if verification
// fails or some other exception occurs, return handler_bci // fails or some other exception occurs, return handler_bci
Klass* k = pool->klass_at(klass_index, CHECK_(handler_bci)); Klass* k = pool->klass_at(klass_index, CHECK_(handler_bci));
KlassHandle klass = KlassHandle(THREAD, k); assert(k != NULL, "klass not loaded");
assert(klass.not_null(), "klass not loaded"); if (ex_klass->is_subtype_of(k)) {
if (ex_klass->is_subtype_of(klass())) {
return handler_bci; return handler_bci;
} }
} }
@ -1271,7 +1270,7 @@ methodHandle Method::make_method_handle_intrinsic(vmIntrinsics::ID iid,
ResourceMark rm; ResourceMark rm;
methodHandle empty; methodHandle empty;
KlassHandle holder = SystemDictionary::MethodHandle_klass(); InstanceKlass* holder = SystemDictionary::MethodHandle_klass();
Symbol* name = MethodHandles::signature_polymorphic_intrinsic_name(iid); Symbol* name = MethodHandles::signature_polymorphic_intrinsic_name(iid);
assert(iid == MethodHandles::signature_polymorphic_name_id(name), ""); assert(iid == MethodHandles::signature_polymorphic_name_id(name), "");
if (TraceMethodHandles) { if (TraceMethodHandles) {
@ -1289,7 +1288,7 @@ methodHandle Method::make_method_handle_intrinsic(vmIntrinsics::ID iid,
ConstantPool* cp_oop = ConstantPool::allocate(loader_data, cp_length, CHECK_(empty)); ConstantPool* cp_oop = ConstantPool::allocate(loader_data, cp_length, CHECK_(empty));
cp = constantPoolHandle(THREAD, cp_oop); 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_name, name);
cp->symbol_at_put(_imcp_invoke_signature, signature); cp->symbol_at_put(_imcp_invoke_signature, signature);
cp->set_has_preresolution(); cp->set_has_preresolution();

View file

@ -323,7 +323,7 @@ class Method : public Metadata {
// exception handler which caused the exception to be thrown, which // exception handler which caused the exception to be thrown, which
// is needed for proper retries. See, for example, // is needed for proper retries. See, for example,
// InterpreterRuntime::exception_handler_for_exception. // 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 // method data access
MethodData* method_data() const { MethodData* method_data() const {
@ -811,8 +811,7 @@ class Method : public Metadata {
static void print_jmethod_ids(ClassLoaderData* loader_data, outputStream* out) PRODUCT_RETURN; static void print_jmethod_ids(ClassLoaderData* loader_data, outputStream* out) PRODUCT_RETURN;
// Get this method's jmethodID -- allocate if it doesn't exist // Get this method's jmethodID -- allocate if it doesn't exist
jmethodID jmethod_id() { methodHandle this_h(this); jmethodID jmethod_id() { return InstanceKlass::get_jmethod_id(method_holder(), this); }
return InstanceKlass::get_jmethod_id(method_holder(), this_h); }
// Lookup the jmethodID for this method. Return NULL if not found. // Lookup the jmethodID for this method. Return NULL if not found.
// NOTE that this function can be called from a signal handler // NOTE that this function can be called from a signal handler

View file

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -46,26 +46,26 @@
#include "utilities/copy.hpp" #include "utilities/copy.hpp"
#include "utilities/macros.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(), assert(ObjArrayKlass::header_size() <= InstanceKlass::header_size(),
"array klasses must be same size as InstanceKlass"); "array klasses must be same size as InstanceKlass");
int size = ArrayKlass::static_size(ObjArrayKlass::header_size()); 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, 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. // Eagerly allocate the direct array supertype.
KlassHandle super_klass = KlassHandle(); Klass* super_klass = NULL;
if (!Universe::is_bootstrapping() || SystemDictionary::Object_klass_loaded()) { if (!Universe::is_bootstrapping() || SystemDictionary::Object_klass_loaded()) {
KlassHandle element_super (THREAD, element_klass->super()); Klass* element_super = element_klass->super();
if (element_super.not_null()) { if (element_super != NULL) {
// The element type has a direct super. E.g., String[] has direct super of Object[]. // 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()); super_klass = element_super->array_klass_or_null();
bool supers_exist = super_klass.not_null(); bool supers_exist = super_klass != NULL;
// Also, see if the element has secondary supertypes. // Also, see if the element has secondary supertypes.
// We need an array type for each. // We need an array type for each.
Array<Klass*>* element_supers = element_klass->secondary_supers(); Array<Klass*>* element_supers = element_klass->secondary_supers();
@ -78,34 +78,30 @@ Klass* ObjArrayKlass::allocate_objArray_klass(ClassLoaderData* loader_data,
} }
if (!supers_exist) { if (!supers_exist) {
// Oops. Not allocated yet. Back out, allocate it, and retry. // Oops. Not allocated yet. Back out, allocate it, and retry.
KlassHandle ek; Klass* ek = NULL;
{ {
MutexUnlocker mu(MultiArray_lock); MutexUnlocker mu(MultiArray_lock);
MutexUnlocker mc(Compile_lock); // for vtables MutexUnlocker mc(Compile_lock); // for vtables
Klass* sk = element_super->array_klass(CHECK_0); super_klass = element_super->array_klass(CHECK_0);
super_klass = KlassHandle(THREAD, sk);
for( int i = element_supers->length()-1; i >= 0; i-- ) { 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); elem_super->array_klass(CHECK_0);
} }
// Now retry from the beginning // Now retry from the beginning
Klass* klass_oop = element_klass->array_klass(n, CHECK_0); ek = 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);
} // re-lock } // re-lock
return ek(); return ek;
} }
} else { } else {
// The element type is already Object. Object[] has direct super of Object. // 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. // Create type name for klass.
Symbol* name = NULL; Symbol* name = NULL;
if (!element_klass->is_instance_klass() || 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); ResourceMark rm(THREAD);
char *name_str = element_klass->name()->as_C_string(); char *name_str = element_klass->name()->as_C_string();
@ -124,7 +120,7 @@ Klass* ObjArrayKlass::allocate_objArray_klass(ClassLoaderData* loader_data,
new_str[idx++] = '\0'; new_str[idx++] = '\0';
name = SymbolTable::new_permanent_symbol(new_str, CHECK_0); name = SymbolTable::new_permanent_symbol(new_str, CHECK_0);
if (element_klass->is_instance_klass()) { if (element_klass->is_instance_klass()) {
InstanceKlass* ik = InstanceKlass::cast(element_klass()); InstanceKlass* ik = InstanceKlass::cast(element_klass);
ik->set_array_name(name); ik->set_array_name(name);
} }
} }
@ -146,9 +142,9 @@ Klass* ObjArrayKlass::allocate_objArray_klass(ClassLoaderData* loader_data,
return oak; 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_dimension(n);
this->set_element_klass(element_klass()); this->set_element_klass(element_klass);
// decrement refcount because object arrays are not explicitly freed. The // decrement refcount because object arrays are not explicitly freed. The
// InstanceKlass array_name() keeps the name counted while the klass is // InstanceKlass array_name() keeps the name counted while the klass is
// loaded. // loaded.
@ -156,9 +152,9 @@ ObjArrayKlass::ObjArrayKlass(int n, KlassHandle element_klass, Symbol* name) : A
Klass* bk; Klass* bk;
if (element_klass->is_objArray_klass()) { if (element_klass->is_objArray_klass()) {
bk = ObjArrayKlass::cast(element_klass())->bottom_klass(); bk = ObjArrayKlass::cast(element_klass)->bottom_klass();
} else { } else {
bk = element_klass(); bk = element_klass;
} }
assert(bk != NULL && (bk->is_instance_klass() || bk->is_typeArray_klass()), "invalid bottom klass"); assert(bk != NULL && (bk->is_instance_klass() || bk->is_typeArray_klass()), "invalid bottom klass");
this->set_bottom_klass(bk); this->set_bottom_klass(bk);
@ -178,8 +174,7 @@ objArrayOop ObjArrayKlass::allocate(int length, TRAPS) {
if (length >= 0) { if (length >= 0) {
if (length <= arrayOopDesc::max_array_length(T_OBJECT)) { if (length <= arrayOopDesc::max_array_length(T_OBJECT)) {
int size = objArrayOopDesc::object_size(length); int size = objArrayOopDesc::object_size(length);
KlassHandle h_k(THREAD, this); return (objArrayOop)CollectedHeap::array_allocate(this, size, length, THREAD);
return (objArrayOop)CollectedHeap::array_allocate(h_k, size, length, THREAD);
} else { } else {
report_java_out_of_memory("Requested array size exceeds VM limit"); report_java_out_of_memory("Requested array size exceeds VM limit");
JvmtiExport::post_array_size_exhausted(); JvmtiExport::post_array_size_exhausted();
@ -196,14 +191,14 @@ oop ObjArrayKlass::multi_allocate(int rank, jint* sizes, TRAPS) {
int length = *sizes; int length = *sizes;
// Call to lower_dimension uses this pointer, so most be called before a // Call to lower_dimension uses this pointer, so most be called before a
// possible GC // possible GC
KlassHandle h_lower_dimension(THREAD, lower_dimension()); Klass* ld_klass = lower_dimension();
// If length < 0 allocate will throw an exception. // If length < 0 allocate will throw an exception.
objArrayOop array = allocate(length, CHECK_NULL); objArrayOop array = allocate(length, CHECK_NULL);
objArrayHandle h_array (THREAD, array); objArrayHandle h_array (THREAD, array);
if (rank > 1) { if (rank > 1) {
if (length != 0) { if (length != 0) {
for (int index = 0; index < length; index++) { 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); oop sub_array = ak->multi_allocate(rank-1, &sizes[1], CHECK_NULL);
h_array->obj_at_put(index, sub_array); h_array->obj_at_put(index, sub_array);
} }

View file

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -39,8 +39,8 @@ class ObjArrayKlass : public ArrayKlass {
Klass* _bottom_klass; // The one-dimensional type (InstanceKlass or TypeArrayKlass) Klass* _bottom_klass; // The one-dimensional type (InstanceKlass or TypeArrayKlass)
// Constructor // Constructor
ObjArrayKlass(int n, KlassHandle element_klass, Symbol* name); ObjArrayKlass(int n, Klass* element_klass, Symbol* name);
static ObjArrayKlass* allocate(ClassLoaderData* loader_data, int n, KlassHandle klass_handle, Symbol* name, TRAPS); static ObjArrayKlass* allocate(ClassLoaderData* loader_data, int n, Klass* k, Symbol* name, TRAPS);
public: public:
// For dummy objects // For dummy objects
ObjArrayKlass() {} ObjArrayKlass() {}
@ -69,7 +69,7 @@ class ObjArrayKlass : public ArrayKlass {
// Allocation // Allocation
static Klass* allocate_objArray_klass(ClassLoaderData* loader_data, 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); objArrayOop allocate(int length, TRAPS);
oop multi_allocate(int rank, jint* sizes, TRAPS); oop multi_allocate(int rank, jint* sizes, TRAPS);

View file

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -102,13 +102,12 @@ typeArrayOop TypeArrayKlass::allocate_common(int length, bool do_zero, TRAPS) {
if (length >= 0) { if (length >= 0) {
if (length <= max_length()) { if (length <= max_length()) {
size_t size = typeArrayOopDesc::object_size(layout_helper(), length); size_t size = typeArrayOopDesc::object_size(layout_helper(), length);
KlassHandle h_k(THREAD, this);
typeArrayOop t; typeArrayOop t;
CollectedHeap* ch = Universe::heap(); CollectedHeap* ch = Universe::heap();
if (do_zero) { 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 { } 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; return t;
} else { } else {

View file

@ -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. * Copyright (c) 2012 Red Hat, Inc.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
@ -386,8 +386,8 @@ JNI_ENTRY(jclass, jni_FindClass(JNIEnv *env, const char *name))
Handle loader; Handle loader;
Handle protection_domain; Handle protection_domain;
// Find calling class // Find calling class
instanceKlassHandle k (THREAD, thread->security_get_caller_class(0)); Klass* k = thread->security_get_caller_class(0);
if (k.not_null()) { if (k != NULL) {
loader = Handle(THREAD, k->class_loader()); loader = Handle(THREAD, k->class_loader());
// Special handling to make sure JNI_OnLoad and JNI_OnUnload are executed // Special handling to make sure JNI_OnLoad and JNI_OnUnload are executed
// in the correct class context. // in the correct class context.
@ -455,12 +455,11 @@ JNI_ENTRY(jmethodID, jni_FromReflectedMethod(JNIEnv *env, jobject method))
mirror = java_lang_reflect_Method::clazz(reflected); mirror = java_lang_reflect_Method::clazz(reflected);
slot = java_lang_reflect_Method::slot(reflected); slot = java_lang_reflect_Method::slot(reflected);
} }
Klass* k = java_lang_Class::as_Klass(mirror); Klass* k1 = java_lang_Class::as_Klass(mirror);
KlassHandle k1(THREAD, k);
// Make sure class is initialized before handing id's out to methods // Make sure class is initialized before handing id's out to methods
k1()->initialize(CHECK_NULL); k1->initialize(CHECK_NULL);
Method* m = InstanceKlass::cast(k1())->method_with_idnum(slot); Method* m = InstanceKlass::cast(k1)->method_with_idnum(slot);
ret = m==NULL? NULL : m->jmethod_id(); // return NULL if reflected method deleted ret = m==NULL? NULL : m->jmethod_id(); // return NULL if reflected method deleted
return ret; return ret;
JNI_END JNI_END
@ -479,18 +478,17 @@ JNI_ENTRY(jfieldID, jni_FromReflectedField(JNIEnv *env, jobject field))
// field is a handle to a java.lang.reflect.Field object // field is a handle to a java.lang.reflect.Field object
oop reflected = JNIHandles::resolve_non_null(field); oop reflected = JNIHandles::resolve_non_null(field);
oop mirror = java_lang_reflect_Field::clazz(reflected); 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 slot = java_lang_reflect_Field::slot(reflected);
int modifiers = java_lang_reflect_Field::modifiers(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 // 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 // First check if this is a static field
if (modifiers & JVM_ACC_STATIC) { if (modifiers & JVM_ACC_STATIC) {
intptr_t offset = InstanceKlass::cast(k1())->field_offset( slot ); intptr_t offset = InstanceKlass::cast(k1)->field_offset( slot );
JNIid* id = InstanceKlass::cast(k1())->jni_id_for(offset); JNIid* id = InstanceKlass::cast(k1)->jni_id_for(offset);
assert(id != NULL, "corrupt Field object"); assert(id != NULL, "corrupt Field object");
debug_only(id->set_is_static_field_id();) 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* // A jfieldID for a static field is a JNIid specifying the field holder and the offset within the Klass*
@ -501,9 +499,9 @@ JNI_ENTRY(jfieldID, jni_FromReflectedField(JNIEnv *env, jobject field))
// The slot is the index of the field description in the field-array // The slot is the index of the field description in the field-array
// The jfieldID is the offset of the field within the object // The jfieldID is the offset of the field within the object
// It may also have hash bits for k, if VerifyJNIFields is turned on. // It may also have hash bits for k, if VerifyJNIFields is turned on.
intptr_t offset = InstanceKlass::cast(k1())->field_offset( slot ); intptr_t offset = InstanceKlass::cast(k1)->field_offset( slot );
assert(InstanceKlass::cast(k1())->contains_field_offset(offset), "stay within object"); assert(InstanceKlass::cast(k1)->contains_field_offset(offset), "stay within object");
ret = jfieldIDWorkaround::to_instance_jfieldID(k1(), offset); ret = jfieldIDWorkaround::to_instance_jfieldID(k1, offset);
return ret; return ret;
JNI_END JNI_END
@ -677,8 +675,7 @@ JNI_ENTRY_NO_PRESERVE(void, jni_ExceptionDescribe(JNIEnv *env))
JavaValue result(T_VOID); JavaValue result(T_VOID);
JavaCalls::call_virtual(&result, JavaCalls::call_virtual(&result,
ex, ex,
KlassHandle(THREAD, SystemDictionary::Throwable_klass(),
SystemDictionary::Throwable_klass()),
vmSymbols::printStackTrace_name(), vmSymbols::printStackTrace_name(),
vmSymbols::void_method_signature(), vmSymbols::void_method_signature(),
THREAD); THREAD);
@ -1156,11 +1153,9 @@ static void jni_invoke_nonstatic(JNIEnv *env, JavaValue* result, jobject receive
} }
} else { } else {
// interface call // interface call
KlassHandle h_holder(THREAD, holder);
int itbl_index = m->itable_index(); int itbl_index = m->itable_index();
Klass* k = h_recv->klass(); 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 void jni_invoke_nonstatic(JNIEnv *env, JavaValue* result, jobject receive
static instanceOop alloc_object(jclass clazz, TRAPS) { 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) { if (k == NULL) {
ResourceMark rm(THREAD); ResourceMark rm(THREAD);
THROW_(vmSymbols::java_lang_InstantiationException(), NULL); THROW_(vmSymbols::java_lang_InstantiationException(), NULL);
} }
k()->check_valid_for_instantiation(false, CHECK_NULL); k->check_valid_for_instantiation(false, CHECK_NULL);
InstanceKlass::cast(k())->initialize(CHECK_NULL); k->initialize(CHECK_NULL);
instanceOop ih = InstanceKlass::cast(k())->allocate_instance(THREAD); instanceOop ih = InstanceKlass::cast(k)->allocate_instance(THREAD);
return ih; return ih;
} }
@ -1338,26 +1333,25 @@ static jmethodID get_method_id(JNIEnv *env, jclass clazz, const char *name_str,
THROW_MSG_0(vmSymbols::java_lang_NoSuchMethodError(), name_str); THROW_MSG_0(vmSymbols::java_lang_NoSuchMethodError(), name_str);
} }
KlassHandle klass(THREAD, Klass* klass = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(clazz));
java_lang_Class::as_Klass(JNIHandles::resolve_non_null(clazz)));
// Make sure class is linked and initialized before handing id's out to // Make sure class is linked and initialized before handing id's out to
// Method*s. // Method*s.
klass()->initialize(CHECK_NULL); klass->initialize(CHECK_NULL);
Method* m; Method* m;
if (name == vmSymbols::object_initializer_name() || if (name == vmSymbols::object_initializer_name() ||
name == vmSymbols::class_initializer_name()) { name == vmSymbols::class_initializer_name()) {
// Never search superclasses for constructors // Never search superclasses for constructors
if (klass->is_instance_klass()) { if (klass->is_instance_klass()) {
m = InstanceKlass::cast(klass())->find_method(name, signature); m = InstanceKlass::cast(klass)->find_method(name, signature);
} else { } else {
m = NULL; m = NULL;
} }
} else { } else {
m = klass->lookup_method(name, signature); m = klass->lookup_method(name, signature);
if (m == NULL && klass->is_instance_klass()) { 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)) { if (m == NULL || (m->is_static() != is_static)) {
@ -1879,8 +1873,8 @@ JNI_ENTRY(ResultType, \
JavaValue jvalue(Tag); \ JavaValue jvalue(Tag); \
JNI_ArgumentPusherVaArg ap(methodID, args); \ JNI_ArgumentPusherVaArg ap(methodID, args); \
/* Make sure class is initialized before trying to invoke its method */ \ /* Make sure class is initialized before trying to invoke its method */ \
KlassHandle k(THREAD, java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls))); \ Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); \
k()->initialize(CHECK_0); \ k->initialize(CHECK_0); \
jni_invoke_static(env, &jvalue, NULL, JNI_STATIC, methodID, &ap, CHECK_0); \ jni_invoke_static(env, &jvalue, NULL, JNI_STATIC, methodID, &ap, CHECK_0); \
va_end(args); \ va_end(args); \
ret = jvalue.get_##ResultType(); \ ret = jvalue.get_##ResultType(); \
@ -2037,20 +2031,19 @@ JNI_ENTRY(jfieldID, jni_GetFieldID(JNIEnv *env, jclass clazz,
if (fieldname == NULL || signame == NULL) { if (fieldname == NULL || signame == NULL) {
THROW_MSG_0(vmSymbols::java_lang_NoSuchFieldError(), (char*) name); THROW_MSG_0(vmSymbols::java_lang_NoSuchFieldError(), (char*) name);
} }
KlassHandle k(THREAD, Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(clazz));
java_lang_Class::as_Klass(JNIHandles::resolve_non_null(clazz)));
// Make sure class is initialized before handing id's out to fields // Make sure class is initialized before handing id's out to fields
k()->initialize(CHECK_NULL); k->initialize(CHECK_NULL);
fieldDescriptor fd; fieldDescriptor fd;
if (!k()->is_instance_klass() || if (!k->is_instance_klass() ||
!InstanceKlass::cast(k())->find_field(fieldname, signame, false, &fd)) { !InstanceKlass::cast(k)->find_field(fieldname, signame, false, &fd)) {
THROW_MSG_0(vmSymbols::java_lang_NoSuchFieldError(), (char*) name); 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 // 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. // 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; return ret;
JNI_END JNI_END
@ -2292,14 +2285,13 @@ JNI_ENTRY(jfieldID, jni_GetStaticFieldID(JNIEnv *env, jclass clazz,
if (fieldname == NULL || signame == NULL) { if (fieldname == NULL || signame == NULL) {
THROW_MSG_0(vmSymbols::java_lang_NoSuchFieldError(), (char*) name); THROW_MSG_0(vmSymbols::java_lang_NoSuchFieldError(), (char*) name);
} }
KlassHandle k(THREAD, Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(clazz));
java_lang_Class::as_Klass(JNIHandles::resolve_non_null(clazz)));
// Make sure class is initialized before handing id's out to static fields // Make sure class is initialized before handing id's out to static fields
k()->initialize(CHECK_NULL); k->initialize(CHECK_NULL);
fieldDescriptor fd; fieldDescriptor fd;
if (!k()->is_instance_klass() || if (!k->is_instance_klass() ||
!InstanceKlass::cast(k())->find_field(fieldname, signame, true, &fd)) { !InstanceKlass::cast(k)->find_field(fieldname, signame, true, &fd)) {
THROW_MSG_0(vmSymbols::java_lang_NoSuchFieldError(), (char*) name); THROW_MSG_0(vmSymbols::java_lang_NoSuchFieldError(), (char*) name);
} }
@ -2603,11 +2595,10 @@ JNI_ENTRY(jobjectArray, jni_NewObjectArray(JNIEnv *env, jsize length, jclass ele
HOTSPOT_JNI_NEWOBJECTARRAY_ENTRY(env, length, elementClass, initialElement); HOTSPOT_JNI_NEWOBJECTARRAY_ENTRY(env, length, elementClass, initialElement);
jobjectArray ret = NULL; jobjectArray ret = NULL;
DT_RETURN_MARK(NewObjectArray, jobjectArray, (const jobjectArray&)ret); DT_RETURN_MARK(NewObjectArray, jobjectArray, (const jobjectArray&)ret);
KlassHandle ek(THREAD, java_lang_Class::as_Klass(JNIHandles::resolve_non_null(elementClass))); Klass* ek = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(elementClass));
Klass* ako = ek()->array_klass(CHECK_NULL); Klass* ak = ek->array_klass(CHECK_NULL);
KlassHandle ak = KlassHandle(THREAD, ako); ObjArrayKlass::cast(ak)->initialize(CHECK_NULL);
ObjArrayKlass::cast(ak())->initialize(CHECK_NULL); objArrayOop result = ObjArrayKlass::cast(ak)->allocate(length, CHECK_NULL);
objArrayOop result = ObjArrayKlass::cast(ak())->allocate(length, CHECK_NULL);
oop initial_value = JNIHandles::resolve(initialElement); oop initial_value = JNIHandles::resolve(initialElement);
if (initial_value != NULL) { // array already initialized with NULL if (initial_value != NULL) { // array already initialized with NULL
for (int index = 0; index < length; index++) { for (int index = 0; index < length; index++) {
@ -2936,8 +2927,7 @@ DEFINE_SETSCALARARRAYREGION(T_DOUBLE, jdouble, Double, double
// is not native. Ask JVM TI what prefixes have been specified. Then check // 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 // to see if the native method is now wrapped with the prefixes. See the
// SetNativeMethodPrefix(es) functions in the JVM TI Spec for details. // SetNativeMethodPrefix(es) functions in the JVM TI Spec for details.
static Method* find_prefixed_native(KlassHandle k, static Method* find_prefixed_native(Klass* k, Symbol* name, Symbol* signature, TRAPS) {
Symbol* name, Symbol* signature, TRAPS) {
#if INCLUDE_JVMTI #if INCLUDE_JVMTI
ResourceMark rm(THREAD); ResourceMark rm(THREAD);
Method* method; Method* method;
@ -2958,7 +2948,7 @@ static Method* find_prefixed_native(KlassHandle k,
if (trial_name == NULL) { if (trial_name == NULL) {
continue; // no such symbol, so this prefix wasn't used, try the next prefix 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) { if (method == NULL) {
continue; // signature doesn't match, try the next prefix continue; // signature doesn't match, try the next prefix
} }
@ -2974,13 +2964,13 @@ static Method* find_prefixed_native(KlassHandle k,
return NULL; // not found return NULL; // not found
} }
static bool register_native(KlassHandle k, Symbol* name, Symbol* signature, address entry, TRAPS) { static bool register_native(Klass* k, Symbol* name, Symbol* signature, address entry, TRAPS) {
Method* method = k()->lookup_method(name, signature); Method* method = k->lookup_method(name, signature);
if (method == NULL) { if (method == NULL) {
ResourceMark rm; ResourceMark rm;
stringStream st; stringStream st;
st.print("Method %s name or signature does not match", 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); THROW_MSG_(vmSymbols::java_lang_NoSuchMethodError(), st.as_string(), false);
} }
if (!method->is_native()) { if (!method->is_native()) {
@ -2990,7 +2980,7 @@ static bool register_native(KlassHandle k, Symbol* name, Symbol* signature, addr
ResourceMark rm; ResourceMark rm;
stringStream st; stringStream st;
st.print("Method %s is not declared as native", 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); THROW_MSG_(vmSymbols::java_lang_NoSuchMethodError(), st.as_string(), false);
} }
} }
@ -3021,7 +3011,7 @@ JNI_ENTRY(jint, jni_RegisterNatives(JNIEnv *env, jclass clazz,
jint ret = 0; jint ret = 0;
DT_RETURN_MARK(RegisterNatives, jint, (const jint&)ret); 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++) { for (int index = 0; index < nMethods; index++) {
const char* meth_name = methods[index].name; const char* meth_name = methods[index].name;
@ -3037,12 +3027,12 @@ JNI_ENTRY(jint, jni_RegisterNatives(JNIEnv *env, jclass clazz,
if (name == NULL || signature == NULL) { if (name == NULL || signature == NULL) {
ResourceMark rm; ResourceMark rm;
stringStream st; 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 // Must return negative value on failure
THROW_MSG_(vmSymbols::java_lang_NoSuchMethodError(), st.as_string(), -1); 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); (address) methods[index].fnPtr, THREAD);
if (!res) { if (!res) {
ret = -1; ret = -1;

View file

@ -341,7 +341,7 @@ static void set_property(Handle props, const char* key, const char* value, TRAPS
Handle value_str = java_lang_String::create_from_platform_dependent_str((value != NULL ? value : ""), CHECK); Handle value_str = java_lang_String::create_from_platform_dependent_str((value != NULL ? value : ""), CHECK);
JavaCalls::call_virtual(&r, JavaCalls::call_virtual(&r,
props, props,
KlassHandle(THREAD, SystemDictionary::Properties_klass()), SystemDictionary::Properties_klass(),
vmSymbols::put_name(), vmSymbols::put_name(),
vmSymbols::object_object_object_signature(), vmSymbols::object_object_object_signature(),
key_str, key_str,
@ -621,7 +621,7 @@ JVM_END
JVM_ENTRY(jobject, JVM_Clone(JNIEnv* env, jobject handle)) JVM_ENTRY(jobject, JVM_Clone(JNIEnv* env, jobject handle))
JVMWrapper("JVM_Clone"); JVMWrapper("JVM_Clone");
Handle obj(THREAD, JNIHandles::resolve_non_null(handle)); Handle obj(THREAD, JNIHandles::resolve_non_null(handle));
const KlassHandle klass (THREAD, obj->klass()); Klass* klass = obj->klass();
JvmtiVMObjectAllocEventCollector oam; JvmtiVMObjectAllocEventCollector oam;
#ifdef ASSERT #ifdef ASSERT
@ -997,9 +997,7 @@ JVM_ENTRY(jclass, JVM_FindLoadedClass(JNIEnv *env, jobject loader, jstring name)
if (k == NULL) { if (k == NULL) {
// If the class is not already loaded, try to see if it's in the shared // If the class is not already loaded, try to see if it's in the shared
// archive for the current classloader (h_loader). // archive for the current classloader (h_loader).
instanceKlassHandle ik = SystemDictionaryShared::find_or_load_shared_class( k = SystemDictionaryShared::find_or_load_shared_class(klass_name, h_loader, CHECK_NULL);
klass_name, h_loader, CHECK_NULL);
k = ik();
} }
#endif #endif
return (k == NULL) ? NULL : return (k == NULL) ? NULL :
@ -1077,11 +1075,11 @@ JVM_ENTRY(jobjectArray, JVM_GetClassInterfaces(JNIEnv *env, jclass cls))
return (jobjectArray) JNIHandles::make_local(env, r); 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 // Figure size of result array
int size; int size;
if (klass->is_instance_klass()) { if (klass->is_instance_klass()) {
size = InstanceKlass::cast(klass())->local_interfaces()->length(); size = InstanceKlass::cast(klass)->local_interfaces()->length();
} else { } else {
assert(klass->is_objArray_klass() || klass->is_typeArray_klass(), "Illegal mirror klass"); assert(klass->is_objArray_klass() || klass->is_typeArray_klass(), "Illegal mirror klass");
size = 2; size = 2;
@ -1094,7 +1092,7 @@ JVM_ENTRY(jobjectArray, JVM_GetClassInterfaces(JNIEnv *env, jclass cls))
if (klass->is_instance_klass()) { if (klass->is_instance_klass()) {
// Regular instance klass, fill in all local interfaces // Regular instance klass, fill in all local interfaces
for (int index = 0; index < size; index++) { 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()); result->obj_at_put(index, k->java_mirror());
} }
} else { } else {
@ -1178,7 +1176,7 @@ JVM_ENTRY(jobject, JVM_GetProtectionDomain(JNIEnv *env, jclass cls))
JVM_END 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 // If there is a security manager and protection domain, check the access
// in the protection domain, otherwise it is authorized. // in the protection domain, otherwise it is authorized.
if (java_lang_System::has_security_manager()) { if (java_lang_System::has_security_manager()) {
@ -1218,7 +1216,7 @@ oop create_dummy_access_control_context(TRAPS) {
Handle obj = pd_klass->allocate_instance_handle(CHECK_NULL); Handle obj = pd_klass->allocate_instance_handle(CHECK_NULL);
// Call constructor ProtectionDomain(null, null); // Call constructor ProtectionDomain(null, null);
JavaValue result(T_VOID); 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::object_initializer_name(),
vmSymbols::codesource_permissioncollection_signature(), vmSymbols::codesource_permissioncollection_signature(),
Handle(), Handle(), CHECK_NULL); Handle(), Handle(), CHECK_NULL);
@ -1249,7 +1247,7 @@ JVM_ENTRY(jobject, JVM_DoPrivileged(JNIEnv *env, jclass cls, jobject action, job
} }
Method* method = vfst.method(); Method* method = vfst.method();
instanceKlassHandle klass (THREAD, method->method_holder()); InstanceKlass* klass = method->method_holder();
// Check that action object understands "Object run()" // Check that action object understands "Object run()"
Handle h_context; Handle h_context;
@ -1452,7 +1450,7 @@ JVM_ENTRY(jobjectArray, JVM_GetDeclaredClasses(JNIEnv *env, jclass ofClass))
return (jobjectArray)JNIHandles::make_local(env, result); 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); InnerClassesIterator iter(k);
if (iter.length() == 0) { if (iter.length() == 0) {
@ -1479,9 +1477,9 @@ JVM_ENTRY(jobjectArray, JVM_GetDeclaredClasses(JNIEnv *env, jclass ofClass))
// before attempting to find the class. // before attempting to find the class.
if (cp->klass_name_at_matches(k, ooff)) { if (cp->klass_name_at_matches(k, ooff)) {
Klass* outer_klass = cp->klass_at(ooff, CHECK_NULL); 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); 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 // Throws an exception if outer klass has not declared k as
// an inner klass // an inner klass
@ -1532,7 +1530,7 @@ JVM_ENTRY(jstring, JVM_GetSimpleBinaryName(JNIEnv *env, jclass cls))
!java_lang_Class::as_Klass(mirror)->is_instance_klass()) { !java_lang_Class::as_Klass(mirror)->is_instance_klass()) {
return NULL; 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; int ooff = 0, noff = 0;
if (InstanceKlass::find_inner_classes_attr(k, &ooff, &noff, THREAD)) { if (InstanceKlass::find_inner_classes_attr(k, &ooff, &noff, THREAD)) {
if (noff != 0) { if (noff != 0) {
@ -1590,19 +1588,19 @@ static bool jvm_get_field_common(jobject field, fieldDescriptor& fd, TRAPS) {
int slot = java_lang_reflect_Field::slot(reflected); int slot = java_lang_reflect_Field::slot(reflected);
int modifiers = java_lang_reflect_Field::modifiers(reflected); int modifiers = java_lang_reflect_Field::modifiers(reflected);
KlassHandle kh(THREAD, k); InstanceKlass* ik = InstanceKlass::cast(k);
intptr_t offset = InstanceKlass::cast(kh())->field_offset(slot); intptr_t offset = ik->field_offset(slot);
if (modifiers & JVM_ACC_STATIC) { if (modifiers & JVM_ACC_STATIC) {
// for static fields we only look in the current class // 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"); assert(false, "cannot find static field");
return false; return false;
} }
} else { } else {
// for instance fields we start with the current class and work // for instance fields we start with the current class and work
// our way up through the superclass chain // 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"); assert(false, "cannot find instance field");
return false; return false;
} }
@ -1757,7 +1755,7 @@ JVM_ENTRY(jobjectArray, JVM_GetClassDeclaredFields(JNIEnv *env, jclass ofClass,
return (jobjectArray) JNIHandles::make_local(env, res); 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()); constantPoolHandle cp(THREAD, k->constants());
// Ensure class is linked // Ensure class is linked
@ -1768,7 +1766,7 @@ JVM_ENTRY(jobjectArray, JVM_GetClassDeclaredFields(JNIEnv *env, jclass ofClass,
if (publicOnly) { if (publicOnly) {
num_fields = 0; 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; if (fs.access_flags().is_public()) ++num_fields;
} }
} else { } else {
@ -1782,7 +1780,7 @@ JVM_ENTRY(jobjectArray, JVM_GetClassDeclaredFields(JNIEnv *env, jclass ofClass,
fieldDescriptor fd; fieldDescriptor fd;
for (JavaFieldStream fs(k); !fs.done(); fs.next()) { for (JavaFieldStream fs(k); !fs.done(); fs.next()) {
if (!publicOnly || fs.access_flags().is_public()) { 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); oop field = Reflection::new_field(&fd, CHECK_NULL);
result->obj_at_put(out_idx, field); result->obj_at_put(out_idx, field);
++out_idx; ++out_idx;
@ -1817,7 +1815,7 @@ static jobjectArray get_class_declared_methods_helper(
return (jobjectArray) JNIHandles::make_local(env, res); 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 // Ensure class is linked
k->link_class(CHECK_NULL); k->link_class(CHECK_NULL);
@ -1913,7 +1911,7 @@ JVM_ENTRY(jobject, JVM_GetClassConstantPool(JNIEnv *env, jclass cls))
if (!java_lang_Class::is_primitive(JNIHandles::resolve_non_null(cls))) { if (!java_lang_Class::is_primitive(JNIHandles::resolve_non_null(cls))) {
Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls));
if (k->is_instance_klass()) { if (k->is_instance_klass()) {
instanceKlassHandle k_h(THREAD, k); InstanceKlass* k_h = InstanceKlass::cast(k);
Handle jcp = reflect_ConstantPool::create(CHECK_NULL); Handle jcp = reflect_ConstantPool::create(CHECK_NULL);
reflect_ConstantPool::set_cp(jcp(), k_h->constants()); reflect_ConstantPool::set_cp(jcp(), k_h->constants());
return JNIHandles::make_local(jcp()); return JNIHandles::make_local(jcp());
@ -1975,7 +1973,7 @@ static jobject get_method_at_helper(constantPoolHandle cp, jint index, bool forc
k_o = ConstantPool::klass_at_if_loaded(cp, klass_ref); k_o = ConstantPool::klass_at_if_loaded(cp, klass_ref);
if (k_o == NULL) return NULL; 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* name = cp->uncached_name_ref_at(index);
Symbol* sig = cp->uncached_signature_ref_at(index); Symbol* sig = cp->uncached_signature_ref_at(index);
methodHandle m (THREAD, k->find_method(name, sig)); methodHandle m (THREAD, k->find_method(name, sig));
@ -2026,7 +2024,7 @@ static jobject get_field_at_helper(constantPoolHandle cp, jint index, bool force
k_o = ConstantPool::klass_at_if_loaded(cp, klass_ref); k_o = ConstantPool::klass_at_if_loaded(cp, klass_ref);
if (k_o == NULL) return NULL; 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* name = cp->uncached_name_ref_at(index);
Symbol* sig = cp->uncached_signature_ref_at(index); Symbol* sig = cp->uncached_signature_ref_at(index);
fieldDescriptor fd; fieldDescriptor fd;
@ -2616,7 +2614,8 @@ JVM_ENTRY(jint, JVM_GetCPFieldModifiers(JNIEnv *env, jclass cls, int cp_index, j
case JVM_CONSTANT_Fieldref: { case JVM_CONSTANT_Fieldref: {
Symbol* name = cp->uncached_name_ref_at(cp_index); Symbol* name = cp->uncached_name_ref_at(cp_index);
Symbol* signature = cp->uncached_signature_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) { if (fs.name() == name && fs.signature() == signature) {
return fs.access_flags().as_short() & JVM_RECOGNIZED_FIELD_MODIFIERS; return fs.access_flags().as_short() & JVM_RECOGNIZED_FIELD_MODIFIERS;
} }
@ -2770,7 +2769,7 @@ static void thread_entry(JavaThread* thread, TRAPS) {
JavaValue result(T_VOID); JavaValue result(T_VOID);
JavaCalls::call_virtual(&result, JavaCalls::call_virtual(&result,
obj, obj,
KlassHandle(THREAD, SystemDictionary::Thread_klass()), SystemDictionary::Thread_klass(),
vmSymbols::run_method_name(), vmSymbols::run_method_name(),
vmSymbols::void_method_signature(), vmSymbols::void_method_signature(),
THREAD); THREAD);
@ -3226,7 +3225,7 @@ JVM_ENTRY(jobjectArray, JVM_GetClassContext(JNIEnv *env))
} }
// Collect method holders // Collect method holders
GrowableArray<KlassHandle>* klass_array = new GrowableArray<KlassHandle>(); GrowableArray<Klass*>* klass_array = new GrowableArray<Klass*>();
for (; !vfst.at_end(); vfst.security_next()) { for (; !vfst.at_end(); vfst.security_next()) {
Method* m = vfst.method(); Method* m = vfst.method();
// Native frames are not returned // Native frames are not returned
@ -3593,12 +3592,11 @@ jclass find_class_from_class_loader(JNIEnv* env, Symbol* name, jboolean init,
// if there is no security manager in 3-arg Class.forName(). // 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); 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 // Check if we should initialize the class
if (init && klass_handle->is_instance_klass()) { if (init && klass->is_instance_klass()) {
klass_handle->initialize(CHECK_NULL); 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 @@ JVM_ENTRY(jobjectArray, JVM_GetEnclosingMethodInfo(JNIEnv *env, jclass ofClass))
if (!k->is_instance_klass()) { if (!k->is_instance_klass()) {
return NULL; return NULL;
} }
instanceKlassHandle ik_h(THREAD, k); InstanceKlass* ik = InstanceKlass::cast(k);
int encl_method_class_idx = ik_h->enclosing_method_class_index(); int encl_method_class_idx = ik->enclosing_method_class_index();
if (encl_method_class_idx == 0) { if (encl_method_class_idx == 0) {
return NULL; return NULL;
} }
objArrayOop dest_o = oopFactory::new_objArray(SystemDictionary::Object_klass(), 3, CHECK_NULL); objArrayOop dest_o = oopFactory::new_objArray(SystemDictionary::Object_klass(), 3, CHECK_NULL);
objArrayHandle dest(THREAD, dest_o); 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()); 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) { if (encl_method_method_idx != 0) {
Symbol* sym = ik_h->constants()->symbol_at( Symbol* sym = ik->constants()->symbol_at(
extract_low_short_from_int( 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); Handle str = java_lang_String::create_from_symbol(sym, CHECK_NULL);
dest->obj_at_put(1, str()); dest->obj_at_put(1, str());
sym = ik_h->constants()->symbol_at( sym = ik->constants()->symbol_at(
extract_high_short_from_int( 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); str = java_lang_String::create_from_symbol(sym, CHECK_NULL);
dest->obj_at_put(2, str()); dest->obj_at_put(2, str());
} }
@ -3799,8 +3797,8 @@ JVM_ENTRY(jobjectArray, JVM_GetVmArguments(JNIEnv *env))
int num_flags = Arguments::num_jvm_flags(); int num_flags = Arguments::num_jvm_flags();
int num_args = Arguments::num_jvm_args(); int num_args = Arguments::num_jvm_args();
instanceKlassHandle ik (THREAD, SystemDictionary::String_klass()); InstanceKlass* ik = SystemDictionary::String_klass();
objArrayOop r = oopFactory::new_objArray(ik(), num_args + num_flags, CHECK_NULL); objArrayOop r = oopFactory::new_objArray(ik, num_args + num_flags, CHECK_NULL);
objArrayHandle result_h(THREAD, r); objArrayHandle result_h(THREAD, r);
int index = 0; int index = 0;

View file

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -40,20 +40,20 @@
// JVMSpec| field_info fields[fields_count]; // JVMSpec| field_info fields[fields_count];
void JvmtiClassFileReconstituter::write_field_infos() { void JvmtiClassFileReconstituter::write_field_infos() {
HandleMark hm(thread()); HandleMark hm(thread());
Array<AnnotationArray*>* fields_anno = ikh()->fields_annotations(); Array<AnnotationArray*>* fields_anno = ik()->fields_annotations();
Array<AnnotationArray*>* fields_type_anno = ikh()->fields_type_annotations(); Array<AnnotationArray*>* fields_type_anno = ik()->fields_type_annotations();
// Compute the real number of Java fields // 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); 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(); AccessFlags access_flags = fs.access_flags();
int name_index = fs.name_index(); int name_index = fs.name_index();
int signature_index = fs.signature_index(); int signature_index = fs.signature_index();
int initial_value_index = fs.initval_index(); int initial_value_index = fs.initval_index();
guarantee(name_index != 0 && signature_index != 0, "bad constant pool index for field"); 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(); int generic_signature_index = fs.generic_signature_index();
AnnotationArray* anno = fields_anno == NULL ? NULL : fields_anno->at(fs.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()); AnnotationArray* type_anno = fields_type_anno == NULL ? NULL : fields_type_anno->at(fs.index());
@ -278,11 +278,11 @@ void JvmtiClassFileReconstituter::write_exceptions_attribute(ConstMethod* const_
// JVMSpec| u2 sourcefile_index; // JVMSpec| u2 sourcefile_index;
// JVMSpec| } // JVMSpec| }
void JvmtiClassFileReconstituter::write_source_file_attribute() { 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_attribute_name_index("SourceFile");
write_u4(2); // always length 2 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 // Write SourceDebugExtension attribute
@ -292,12 +292,12 @@ void JvmtiClassFileReconstituter::write_source_file_attribute() {
// JSR45| u1 debug_extension[attribute_length]; // JSR45| u1 debug_extension[attribute_length];
// JSR45| } // JSR45| }
void JvmtiClassFileReconstituter::write_source_debug_extension_attribute() { 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"); write_attribute_name_index("SourceDebugExtension");
int len = (int)strlen(ikh()->source_debug_extension()); int len = (int)strlen(ik()->source_debug_extension());
write_u4(len); write_u4(len);
u1* ext = (u1*)ikh()->source_debug_extension(); u1* ext = (u1*)ik()->source_debug_extension();
for (int i=0; i<len; i++) { for (int i=0; i<len; i++) {
write_u1(ext[i]); write_u1(ext[i]);
} }
@ -317,7 +317,7 @@ void JvmtiClassFileReconstituter::write_signature_attribute(u2 generic_signature
// Compute the number of entries in the InnerClasses attribute // Compute the number of entries in the InnerClasses attribute
u2 JvmtiClassFileReconstituter::inner_classes_attribute_length() { u2 JvmtiClassFileReconstituter::inner_classes_attribute_length() {
InnerClassesIterator iter(ikh()); InnerClassesIterator iter(ik());
return iter.length(); return iter.length();
} }
@ -387,7 +387,7 @@ void JvmtiClassFileReconstituter::write_bootstrapmethod_attribute() {
// JVMSpec| } classes[number_of_classes]; // JVMSpec| } classes[number_of_classes];
// JVMSpec| } // JVMSpec| }
void JvmtiClassFileReconstituter::write_inner_classes_attribute(int length) { void JvmtiClassFileReconstituter::write_inner_classes_attribute(int length) {
InnerClassesIterator iter(ikh()); InnerClassesIterator iter(ik());
guarantee(iter.length() != 0 && iter.length() == length, guarantee(iter.length() != 0 && iter.length() == length,
"caller must check"); "caller must check");
u2 entry_count = length / InstanceKlass::inner_class_next_offset; u2 entry_count = length / InstanceKlass::inner_class_next_offset;
@ -618,18 +618,18 @@ void JvmtiClassFileReconstituter::write_method_info(const methodHandle& method)
// JVMSpec| attribute_info attributes[attributes_count]; // JVMSpec| attribute_info attributes[attributes_count];
void JvmtiClassFileReconstituter::write_class_attributes() { void JvmtiClassFileReconstituter::write_class_attributes() {
u2 inner_classes_length = inner_classes_attribute_length(); u2 inner_classes_length = inner_classes_attribute_length();
Symbol* generic_signature = ikh()->generic_signature(); Symbol* generic_signature = ik()->generic_signature();
AnnotationArray* anno = ikh()->class_annotations(); AnnotationArray* anno = ik()->class_annotations();
AnnotationArray* type_anno = ikh()->class_type_annotations(); AnnotationArray* type_anno = ik()->class_type_annotations();
int attr_count = 0; int attr_count = 0;
if (generic_signature != NULL) { if (generic_signature != NULL) {
++attr_count; ++attr_count;
} }
if (ikh()->source_file_name() != NULL) { if (ik()->source_file_name() != NULL) {
++attr_count; ++attr_count;
} }
if (ikh()->source_debug_extension() != NULL) { if (ik()->source_debug_extension() != NULL) {
++attr_count; ++attr_count;
} }
if (inner_classes_length > 0) { if (inner_classes_length > 0) {
@ -650,10 +650,10 @@ void JvmtiClassFileReconstituter::write_class_attributes() {
if (generic_signature != NULL) { if (generic_signature != NULL) {
write_signature_attribute(symbol_to_cpool_index(generic_signature)); 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(); write_source_file_attribute();
} }
if (ikh()->source_debug_extension() != NULL) { if (ik()->source_debug_extension() != NULL) {
write_source_debug_extension_attribute(); write_source_debug_extension_attribute();
} }
if (inner_classes_length > 0) { if (inner_classes_length > 0) {
@ -675,7 +675,7 @@ void JvmtiClassFileReconstituter::write_class_attributes() {
// JVMSpec| method_info methods[methods_count]; // JVMSpec| method_info methods[methods_count];
void JvmtiClassFileReconstituter::write_method_infos() { void JvmtiClassFileReconstituter::write_method_infos() {
HandleMark hm(thread()); HandleMark hm(thread());
Array<Method*>* methods = ikh()->methods(); Array<Method*>* methods = ik()->methods();
int num_methods = methods->length(); int num_methods = methods->length();
int num_overpass = 0; int num_overpass = 0;
@ -697,7 +697,7 @@ void JvmtiClassFileReconstituter::write_method_infos() {
// invert the method order mapping // invert the method order mapping
for (index = 0; index < num_methods; index++) { 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, assert(original_index >= 0 && original_index < num_methods,
"invalid original method index"); "invalid original method index");
method_order.at_put(original_index, index); method_order.at_put(original_index, index);
@ -727,8 +727,8 @@ void JvmtiClassFileReconstituter::write_class_file_format() {
// JVMSpec| u2 minor_version; // JVMSpec| u2 minor_version;
// JVMSpec| u2 major_version; // JVMSpec| u2 major_version;
write_u2(ikh()->minor_version()); write_u2(ik()->minor_version());
u2 major = ikh()->major_version(); u2 major = ik()->major_version();
write_u2(major); write_u2(major);
// JVMSpec| u2 constant_pool_count; // JVMSpec| u2 constant_pool_count;
@ -737,24 +737,24 @@ void JvmtiClassFileReconstituter::write_class_file_format() {
copy_cpool_bytes(writeable_address(cpool_size())); copy_cpool_bytes(writeable_address(cpool_size()));
// JVMSpec| u2 access_flags; // 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 this_class;
// JVMSpec| u2 super_class; // JVMSpec| u2 super_class;
write_u2(class_symbol_to_cpool_index(ikh()->name())); write_u2(class_symbol_to_cpool_index(ik()->name()));
Klass* super_class = ikh()->super(); Klass* super_class = ik()->super();
write_u2(super_class == NULL? 0 : // zero for java.lang.Object write_u2(super_class == NULL? 0 : // zero for java.lang.Object
class_symbol_to_cpool_index(super_class->name())); class_symbol_to_cpool_index(super_class->name()));
// JVMSpec| u2 interfaces_count; // JVMSpec| u2 interfaces_count;
// JVMSpec| u2 interfaces[interfaces_count]; // JVMSpec| u2 interfaces[interfaces_count];
Array<Klass*>* interfaces = ikh()->local_interfaces(); Array<Klass*>* interfaces = ik()->local_interfaces();
int num_interfaces = interfaces->length(); int num_interfaces = interfaces->length();
write_u2(num_interfaces); write_u2(num_interfaces);
for (int index = 0; index < num_interfaces; index++) { for (int index = 0; index < num_interfaces; index++) {
HandleMark hm(thread()); HandleMark hm(thread());
instanceKlassHandle iikh(thread(), interfaces->at(index)); InstanceKlass* iik = InstanceKlass::cast(interfaces->at(index));
write_u2(class_symbol_to_cpool_index(iikh->name())); write_u2(class_symbol_to_cpool_index(iik->name()));
} }
// JVMSpec| u2 fields_count; // JVMSpec| u2 fields_count;

View file

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -34,11 +34,11 @@ class JvmtiConstantPoolReconstituter : public StackObj {
SymbolHashMap* _symmap; SymbolHashMap* _symmap;
SymbolHashMap* _classmap; SymbolHashMap* _classmap;
constantPoolHandle _cpool; constantPoolHandle _cpool;
instanceKlassHandle _ikh; InstanceKlass* _ik;
jvmtiError _err; jvmtiError _err;
protected: protected:
instanceKlassHandle ikh() { return _ikh; }; InstanceKlass* ik() { return _ik; };
constantPoolHandle cpool() { return _cpool; }; constantPoolHandle cpool() { return _cpool; };
u2 symbol_to_cpool_index(Symbol* sym) { u2 symbol_to_cpool_index(Symbol* sym) {
@ -52,10 +52,10 @@ class JvmtiConstantPoolReconstituter : public StackObj {
public: public:
// Calls to this constructor must be proceeded by a ResourceMark // Calls to this constructor must be proceeded by a ResourceMark
// and a HandleMark // and a HandleMark
JvmtiConstantPoolReconstituter(instanceKlassHandle ikh){ JvmtiConstantPoolReconstituter(InstanceKlass* ik){
set_error(JVMTI_ERROR_NONE); set_error(JVMTI_ERROR_NONE);
_ikh = ikh; _ik = ik;
_cpool = constantPoolHandle(Thread::current(), ikh->constants()); _cpool = constantPoolHandle(Thread::current(), ik->constants());
_symmap = new SymbolHashMap(); _symmap = new SymbolHashMap();
_classmap = new SymbolHashMap(); _classmap = new SymbolHashMap();
_cpool_size = _cpool->hash_entries_to(_symmap, _classmap); _cpool_size = _cpool->hash_entries_to(_symmap, _classmap);
@ -138,8 +138,8 @@ class JvmtiClassFileReconstituter : public JvmtiConstantPoolReconstituter {
public: public:
// Calls to this constructor must be proceeded by a ResourceMark // Calls to this constructor must be proceeded by a ResourceMark
// and a HandleMark // and a HandleMark
JvmtiClassFileReconstituter(instanceKlassHandle ikh) : JvmtiClassFileReconstituter(InstanceKlass* ik) :
JvmtiConstantPoolReconstituter(ikh) { JvmtiConstantPoolReconstituter(ik) {
_buffer_size = initial_buffer_size; _buffer_size = initial_buffer_size;
_buffer = _buffer_ptr = NEW_RESOURCE_ARRAY(u1, _buffer_size); _buffer = _buffer_ptr = NEW_RESOURCE_ARRAY(u1, _buffer_size);
_thread = Thread::current(); _thread = Thread::current();

View file

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -400,21 +400,20 @@ JvmtiEnv::RetransformClasses(jint class_count, const jclass* classes) {
return JVMTI_ERROR_UNMODIFIABLE_CLASS; return JVMTI_ERROR_UNMODIFIABLE_CLASS;
} }
Klass* k_oop = java_lang_Class::as_Klass(k_mirror); Klass* klass = java_lang_Class::as_Klass(k_mirror);
KlassHandle klass(current_thread, k_oop);
jint status = klass->jvmti_class_status(); jint status = klass->jvmti_class_status();
if (status & (JVMTI_CLASS_STATUS_ERROR)) { if (status & (JVMTI_CLASS_STATUS_ERROR)) {
return JVMTI_ERROR_INVALID_CLASS; return JVMTI_ERROR_INVALID_CLASS;
} }
instanceKlassHandle ikh(current_thread, k_oop); InstanceKlass* ik = InstanceKlass::cast(klass);
if (ikh->get_cached_class_file_bytes() == NULL) { if (ik->get_cached_class_file_bytes() == NULL) {
// Not cached, we need to reconstitute the class file from the // Not cached, we need to reconstitute the class file from the
// VM representation. We don't attach the reconstituted class // VM representation. We don't attach the reconstituted class
// bytes to the InstanceKlass here because they have not been // bytes to the InstanceKlass here because they have not been
// validated and we're not at a safepoint. // validated and we're not at a safepoint.
JvmtiClassFileReconstituter reconstituter(ikh); JvmtiClassFileReconstituter reconstituter(ik);
if (reconstituter.get_error() != JVMTI_ERROR_NONE) { if (reconstituter.get_error() != JVMTI_ERROR_NONE) {
return reconstituter.get_error(); return reconstituter.get_error();
} }
@ -424,8 +423,8 @@ JvmtiEnv::RetransformClasses(jint class_count, const jclass* classes) {
reconstituter.class_file_bytes(); reconstituter.class_file_bytes();
} else { } else {
// it is cached, get it from the cache // it is cached, get it from the cache
class_definitions[index].class_byte_count = ikh->get_cached_class_file_len(); class_definitions[index].class_byte_count = ik->get_cached_class_file_len();
class_definitions[index].class_bytes = ikh->get_cached_class_file_bytes(); class_definitions[index].class_bytes = ik->get_cached_class_file_bytes();
} }
class_definitions[index].klass = jcls; class_definitions[index].klass = jcls;
} }
@ -667,8 +666,6 @@ JvmtiEnv::AddToSystemClassLoaderSearch(const char* segment) {
return JVMTI_ERROR_INTERNAL; return JVMTI_ERROR_INTERNAL;
} }
instanceKlassHandle loader_ik(THREAD, loader->klass());
// Invoke the appendToClassPathForInstrumentation method - if the method // Invoke the appendToClassPathForInstrumentation method - if the method
// is not found it means the loader doesn't support adding to the class path // is not found it means the loader doesn't support adding to the class path
// in the live phase. // in the live phase.
@ -676,7 +673,7 @@ JvmtiEnv::AddToSystemClassLoaderSearch(const char* segment) {
JavaValue res(T_VOID); JavaValue res(T_VOID);
JavaCalls::call_special(&res, JavaCalls::call_special(&res,
loader, loader,
loader_ik, loader->klass(),
vmSymbols::appendToClassPathForInstrumentation_name(), vmSymbols::appendToClassPathForInstrumentation_name(),
vmSymbols::appendToClassPathForInstrumentation_signature(), vmSymbols::appendToClassPathForInstrumentation_signature(),
path, path,
@ -1781,7 +1778,7 @@ JvmtiEnv::ForceEarlyReturnVoid(JavaThread* java_thread) {
jvmtiError jvmtiError
JvmtiEnv::FollowReferences(jint heap_filter, jclass klass, jobject initial_object, const jvmtiHeapCallbacks* callbacks, const void* user_data) { JvmtiEnv::FollowReferences(jint heap_filter, jclass klass, jobject initial_object, const jvmtiHeapCallbacks* callbacks, const void* user_data) {
// check klass if provided // check klass if provided
Klass* k_oop = NULL; Klass* k = NULL;
if (klass != NULL) { if (klass != NULL) {
oop k_mirror = JNIHandles::resolve_external_guard(klass); oop k_mirror = JNIHandles::resolve_external_guard(klass);
if (k_mirror == NULL) { if (k_mirror == NULL) {
@ -1790,18 +1787,17 @@ JvmtiEnv::FollowReferences(jint heap_filter, jclass klass, jobject initial_objec
if (java_lang_Class::is_primitive(k_mirror)) { if (java_lang_Class::is_primitive(k_mirror)) {
return JVMTI_ERROR_NONE; return JVMTI_ERROR_NONE;
} }
k_oop = java_lang_Class::as_Klass(k_mirror); k = java_lang_Class::as_Klass(k_mirror);
if (k_oop == NULL) { if (klass == NULL) {
return JVMTI_ERROR_INVALID_CLASS; return JVMTI_ERROR_INVALID_CLASS;
} }
} }
Thread *thread = Thread::current(); Thread *thread = Thread::current();
HandleMark hm(thread); HandleMark hm(thread);
KlassHandle kh (thread, k_oop);
TraceTime t("FollowReferences", TRACETIME_LOG(Debug, jvmti, objecttagging)); 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; return JVMTI_ERROR_NONE;
} /* end FollowReferences */ } /* end FollowReferences */
@ -1812,7 +1808,7 @@ JvmtiEnv::FollowReferences(jint heap_filter, jclass klass, jobject initial_objec
jvmtiError jvmtiError
JvmtiEnv::IterateThroughHeap(jint heap_filter, jclass klass, const jvmtiHeapCallbacks* callbacks, const void* user_data) { JvmtiEnv::IterateThroughHeap(jint heap_filter, jclass klass, const jvmtiHeapCallbacks* callbacks, const void* user_data) {
// check klass if provided // check klass if provided
Klass* k_oop = NULL; Klass* k = NULL;
if (klass != NULL) { if (klass != NULL) {
oop k_mirror = JNIHandles::resolve_external_guard(klass); oop k_mirror = JNIHandles::resolve_external_guard(klass);
if (k_mirror == NULL) { if (k_mirror == NULL) {
@ -1821,18 +1817,14 @@ JvmtiEnv::IterateThroughHeap(jint heap_filter, jclass klass, const jvmtiHeapCall
if (java_lang_Class::is_primitive(k_mirror)) { if (java_lang_Class::is_primitive(k_mirror)) {
return JVMTI_ERROR_NONE; return JVMTI_ERROR_NONE;
} }
k_oop = java_lang_Class::as_Klass(k_mirror); k = java_lang_Class::as_Klass(k_mirror);
if (k_oop == NULL) { if (k == NULL) {
return JVMTI_ERROR_INVALID_CLASS; 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)); 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; return JVMTI_ERROR_NONE;
} /* end IterateThroughHeap */ } /* end IterateThroughHeap */
@ -1909,7 +1901,7 @@ JvmtiEnv::IterateOverHeap(jvmtiHeapObjectFilter object_filter, jvmtiHeapObjectCa
TraceTime t("IterateOverHeap", TRACETIME_LOG(Debug, jvmti, objecttagging)); TraceTime t("IterateOverHeap", TRACETIME_LOG(Debug, jvmti, objecttagging));
Thread *thread = Thread::current(); Thread *thread = Thread::current();
HandleMark hm(thread); 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; return JVMTI_ERROR_NONE;
} /* end IterateOverHeap */ } /* end IterateOverHeap */
@ -1923,13 +1915,10 @@ JvmtiEnv::IterateOverInstancesOfClass(oop k_mirror, jvmtiHeapObjectFilter object
// DO PRIMITIVE CLASS PROCESSING // DO PRIMITIVE CLASS PROCESSING
return JVMTI_ERROR_NONE; return JVMTI_ERROR_NONE;
} }
Klass* k_oop = java_lang_Class::as_Klass(k_mirror); Klass* klass = java_lang_Class::as_Klass(k_mirror);
if (k_oop == NULL) { if (klass == NULL) {
return JVMTI_ERROR_INVALID_CLASS; 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)); TraceTime t("IterateOverInstancesOfClass", TRACETIME_LOG(Debug, jvmti, objecttagging));
JvmtiTagMap::tag_map_for(this)->iterate_over_heap(object_filter, klass, heap_object_callback, user_data); JvmtiTagMap::tag_map_for(this)->iterate_over_heap(object_filter, klass, heap_object_callback, user_data);
return JVMTI_ERROR_NONE; return JVMTI_ERROR_NONE;
@ -2408,9 +2397,9 @@ JvmtiEnv::GetClassMethods(oop k_mirror, jint* method_count_ptr, jmethodID** meth
*methods_ptr = (jmethodID*) jvmtiMalloc(0 * sizeof(jmethodID)); *methods_ptr = (jmethodID*) jvmtiMalloc(0 * sizeof(jmethodID));
return JVMTI_ERROR_NONE; return JVMTI_ERROR_NONE;
} }
instanceKlassHandle instanceK_h(current_thread, k); InstanceKlass* ik = InstanceKlass::cast(k);
// Allocate the result and fill it in // 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)); jmethodID* result_list = (jmethodID*)jvmtiMalloc(result_length * sizeof(jmethodID));
int index; int index;
bool jmethodids_found = true; bool jmethodids_found = true;
@ -2419,8 +2408,8 @@ JvmtiEnv::GetClassMethods(oop k_mirror, jint* method_count_ptr, jmethodID** meth
// Use the original method ordering indices stored in the class, so we can emit // Use the original method ordering indices stored in the class, so we can emit
// jmethodIDs in the order they appeared in the class file // jmethodIDs in the order they appeared in the class file
for (index = 0; index < result_length; index++) { for (index = 0; index < result_length; index++) {
Method* m = instanceK_h->methods()->at(index); Method* m = ik->methods()->at(index);
int original_index = instanceK_h->method_ordering()->at(index); int original_index = ik->method_ordering()->at(index);
assert(original_index >= 0 && original_index < result_length, "invalid original method index"); assert(original_index >= 0 && original_index < result_length, "invalid original method index");
jmethodID id; jmethodID id;
if (jmethodids_found) { if (jmethodids_found) {
@ -2429,7 +2418,7 @@ JvmtiEnv::GetClassMethods(oop k_mirror, jint* method_count_ptr, jmethodID** meth
// If we find an uninitialized value, make sure there is // If we find an uninitialized value, make sure there is
// enough space for all the uninitialized values we might // enough space for all the uninitialized values we might
// find. // find.
instanceK_h->ensure_space_for_methodids(index); ik->ensure_space_for_methodids(index);
jmethodids_found = false; jmethodids_found = false;
id = m->jmethod_id(); id = m->jmethod_id();
} }
@ -2441,7 +2430,7 @@ JvmtiEnv::GetClassMethods(oop k_mirror, jint* method_count_ptr, jmethodID** meth
} else { } else {
// otherwise just copy in any order // otherwise just copy in any order
for (index = 0; index < result_length; index++) { for (index = 0; index < result_length; index++) {
Method* m = instanceK_h->methods()->at(index); Method* m = ik->methods()->at(index);
jmethodID id; jmethodID id;
if (jmethodids_found) { if (jmethodids_found) {
id = m->find_jmethod_id_or_null(); id = m->find_jmethod_id_or_null();
@ -2449,7 +2438,7 @@ JvmtiEnv::GetClassMethods(oop k_mirror, jint* method_count_ptr, jmethodID** meth
// If we find an uninitialized value, make sure there is // If we find an uninitialized value, make sure there is
// enough space for all the uninitialized values we might // enough space for all the uninitialized values we might
// find. // find.
instanceK_h->ensure_space_for_methodids(index); ik->ensure_space_for_methodids(index);
jmethodids_found = false; jmethodids_found = false;
id = m->jmethod_id(); id = m->jmethod_id();
} }
@ -2494,11 +2483,11 @@ JvmtiEnv::GetClassFields(oop k_mirror, jint* field_count_ptr, jfieldID** fields_
} }
instanceKlassHandle instanceK_h(current_thread, k); InstanceKlass* ik = InstanceKlass::cast(k);
int result_count = 0; int result_count = 0;
// First, count the fields. // First, count the fields.
FilteredFieldStream flds(instanceK_h, true, true); FilteredFieldStream flds(ik, true, true);
result_count = flds.field_count(); result_count = flds.field_count();
// Allocate the result and fill it in // Allocate the result and fill it in
@ -2507,9 +2496,9 @@ JvmtiEnv::GetClassFields(oop k_mirror, jint* field_count_ptr, jfieldID** fields_
// this is the reverse order of what FieldStream hands out. // this is the reverse order of what FieldStream hands out.
int id_index = (result_count - 1); 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( result_list[id_index--] = jfieldIDWorkaround::to_jfieldID(
instanceK_h, src_st.offset(), ik, src_st.offset(),
src_st.access_flags().is_static()); src_st.access_flags().is_static());
} }
assert(id_index == -1, "just checking"); assert(id_index == -1, "just checking");
@ -2574,10 +2563,7 @@ JvmtiEnv::GetClassVersionNumbers(oop k_mirror, jint* minor_version_ptr, jint* ma
if (java_lang_Class::is_primitive(k_mirror)) { if (java_lang_Class::is_primitive(k_mirror)) {
return JVMTI_ERROR_ABSENT_INFORMATION; 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);
KlassHandle klass(thread, k_oop);
jint status = klass->jvmti_class_status(); jint status = klass->jvmti_class_status();
if (status & (JVMTI_CLASS_STATUS_ERROR)) { if (status & (JVMTI_CLASS_STATUS_ERROR)) {
@ -2587,7 +2573,7 @@ JvmtiEnv::GetClassVersionNumbers(oop k_mirror, jint* minor_version_ptr, jint* ma
return JVMTI_ERROR_ABSENT_INFORMATION; return JVMTI_ERROR_ABSENT_INFORMATION;
} }
instanceKlassHandle ik(thread, k_oop); InstanceKlass* ik = InstanceKlass::cast(klass);
*minor_version_ptr = ik->minor_version(); *minor_version_ptr = ik->minor_version();
*major_version_ptr = ik->major_version(); *major_version_ptr = ik->major_version();
@ -2605,11 +2591,9 @@ JvmtiEnv::GetConstantPool(oop k_mirror, jint* constant_pool_count_ptr, jint* con
return JVMTI_ERROR_ABSENT_INFORMATION; 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(); Thread *thread = Thread::current();
HandleMark hm(thread);
ResourceMark rm(thread); ResourceMark rm(thread);
KlassHandle klass(thread, k_oop);
jint status = klass->jvmti_class_status(); jint status = klass->jvmti_class_status();
if (status & (JVMTI_CLASS_STATUS_ERROR)) { if (status & (JVMTI_CLASS_STATUS_ERROR)) {
@ -2619,8 +2603,8 @@ JvmtiEnv::GetConstantPool(oop k_mirror, jint* constant_pool_count_ptr, jint* con
return JVMTI_ERROR_ABSENT_INFORMATION; return JVMTI_ERROR_ABSENT_INFORMATION;
} }
instanceKlassHandle ikh(thread, k_oop); InstanceKlass* ik = InstanceKlass::cast(klass);
JvmtiConstantPoolReconstituter reconstituter(ikh); JvmtiConstantPoolReconstituter reconstituter(ik);
if (reconstituter.get_error() != JVMTI_ERROR_NONE) { if (reconstituter.get_error() != JVMTI_ERROR_NONE) {
return reconstituter.get_error(); return reconstituter.get_error();
} }
@ -2639,7 +2623,7 @@ JvmtiEnv::GetConstantPool(oop k_mirror, jint* constant_pool_count_ptr, jint* con
return reconstituter.get_error(); return reconstituter.get_error();
} }
constantPoolHandle constants(thread, ikh->constants()); constantPoolHandle constants(thread, ik->constants());
*constant_pool_count_ptr = constants->length(); *constant_pool_count_ptr = constants->length();
*constant_pool_byte_count_ptr = cpool_size; *constant_pool_byte_count_ptr = cpool_size;
*constant_pool_bytes_ptr = cpool_bytes; *constant_pool_bytes_ptr = cpool_bytes;

View file

@ -1366,13 +1366,13 @@ JvmtiEnvBase::check_top_frame(JavaThread* current_thread, JavaThread* java_threa
if (tos == atos && jobj != NULL) { // NULL reference is allowed if (tos == atos && jobj != NULL) { // NULL reference is allowed
Handle ob_h(current_thread, JNIHandles::resolve_external_guard(jobj)); Handle ob_h(current_thread, JNIHandles::resolve_external_guard(jobj));
NULL_CHECK(ob_h, JVMTI_ERROR_INVALID_OBJECT); NULL_CHECK(ob_h, JVMTI_ERROR_INVALID_OBJECT);
KlassHandle ob_kh = KlassHandle(current_thread, ob_h()->klass()); Klass* ob_k = ob_h()->klass();
NULL_CHECK(ob_kh, JVMTI_ERROR_INVALID_OBJECT); NULL_CHECK(ob_k, JVMTI_ERROR_INVALID_OBJECT);
// Method return type signature. // Method return type signature.
char* ty_sign = 1 + strchr(signature->as_C_string(), ')'); 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; return JVMTI_ERROR_TYPE_MISMATCH;
} }
*ret_ob_h = ob_h; *ret_ob_h = ob_h;

Some files were not shown because too many files have changed in this diff Show more