8003557: NPG: Klass* const k should be const Klass* k

With NPG, const KlassOop klass which is in fact a definition converted to Klass* const, which is not the original intention. The right usage is converting them to const Klass*.

Reviewed-by: coleenp, kvn
This commit is contained in:
Yumin Qi 2013-05-10 08:27:30 -07:00 committed by Yumin Qi
parent 8d3d80dbc9
commit c6aa9c656f
20 changed files with 62 additions and 64 deletions

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1999, 2013, 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
@ -1261,7 +1261,7 @@ JRT_LEAF(int, Runtime1::arraycopy(oopDesc* src, int src_pos, oopDesc* dst, int d
if (length == 0) return ac_ok; if (length == 0) return ac_ok;
if (src->is_typeArray()) { if (src->is_typeArray()) {
Klass* const klass_oop = src->klass(); Klass* klass_oop = src->klass();
if (klass_oop != dst->klass()) return ac_failed; if (klass_oop != dst->klass()) return ac_failed;
TypeArrayKlass* klass = TypeArrayKlass::cast(klass_oop); TypeArrayKlass* klass = TypeArrayKlass::cast(klass_oop);
const int l2es = klass->log2_element_size(); const int l2es = klass->log2_element_size();

View file

@ -362,7 +362,7 @@ void TypeOrigin::print_on(outputStream* str) const {
} }
#endif #endif
void ErrorContext::details(outputStream* ss, Method* method) const { void ErrorContext::details(outputStream* ss, const Method* method) const {
if (is_valid()) { if (is_valid()) {
ss->print_cr(""); ss->print_cr("");
ss->print_cr("Exception Details:"); ss->print_cr("Exception Details:");
@ -435,7 +435,7 @@ void ErrorContext::reason_details(outputStream* ss) const {
ss->print_cr(""); ss->print_cr("");
} }
void ErrorContext::location_details(outputStream* ss, Method* method) const { void ErrorContext::location_details(outputStream* ss, const Method* method) const {
if (_bci != -1 && method != NULL) { if (_bci != -1 && method != NULL) {
streamIndentor si(ss); streamIndentor si(ss);
const char* bytecode_name = "<invalid>"; const char* bytecode_name = "<invalid>";
@ -470,7 +470,7 @@ void ErrorContext::frame_details(outputStream* ss) const {
} }
} }
void ErrorContext::bytecode_details(outputStream* ss, Method* method) const { void ErrorContext::bytecode_details(outputStream* ss, const Method* method) const {
if (method != NULL) { if (method != NULL) {
streamIndentor si(ss); streamIndentor si(ss);
ss->indent().print_cr("Bytecode:"); ss->indent().print_cr("Bytecode:");
@ -479,7 +479,7 @@ void ErrorContext::bytecode_details(outputStream* ss, Method* method) const {
} }
} }
void ErrorContext::handler_details(outputStream* ss, Method* method) const { void ErrorContext::handler_details(outputStream* ss, const Method* method) const {
if (method != NULL) { if (method != NULL) {
streamIndentor si(ss); streamIndentor si(ss);
ExceptionTable table(method); ExceptionTable table(method);
@ -494,7 +494,7 @@ void ErrorContext::handler_details(outputStream* ss, Method* method) const {
} }
} }
void ErrorContext::stackmap_details(outputStream* ss, Method* method) const { void ErrorContext::stackmap_details(outputStream* ss, const Method* method) const {
if (method != NULL && method->has_stackmap_table()) { if (method != NULL && method->has_stackmap_table()) {
streamIndentor si(ss); streamIndentor si(ss);
ss->indent().print_cr("Stackmap Table:"); ss->indent().print_cr("Stackmap Table:");

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1998, 2013, 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
@ -224,7 +224,7 @@ class ErrorContext VALUE_OBJ_CLASS_SPEC {
_expected.reset_frame(); _expected.reset_frame();
} }
void details(outputStream* ss, Method* method) const; void details(outputStream* ss, const Method* method) const;
#ifdef ASSERT #ifdef ASSERT
void print_on(outputStream* str) const { void print_on(outputStream* str) const {
@ -237,12 +237,12 @@ class ErrorContext VALUE_OBJ_CLASS_SPEC {
#endif #endif
private: private:
void location_details(outputStream* ss, Method* method) const; void location_details(outputStream* ss, const Method* method) const;
void reason_details(outputStream* ss) const; void reason_details(outputStream* ss) const;
void frame_details(outputStream* ss) const; void frame_details(outputStream* ss) const;
void bytecode_details(outputStream* ss, Method* method) const; void bytecode_details(outputStream* ss, const Method* method) const;
void handler_details(outputStream* ss, Method* method) const; void handler_details(outputStream* ss, const Method* method) const;
void stackmap_details(outputStream* ss, Method* method) const; void stackmap_details(outputStream* ss, const Method* method) const;
}; };
// A new instance of this class is created for each class being verified // A new instance of this class is created for each class being verified

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2005, 2013, 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
@ -213,7 +213,7 @@ void StealMarkingTask::do_it(GCTaskManager* manager, uint which) {
int random_seed = 17; int random_seed = 17;
do { do {
while (ParCompactionManager::steal_objarray(which, &random_seed, task)) { while (ParCompactionManager::steal_objarray(which, &random_seed, task)) {
ObjArrayKlass* const k = (ObjArrayKlass*)task.obj()->klass(); ObjArrayKlass* k = (ObjArrayKlass*)task.obj()->klass();
k->oop_follow_contents(cm, task.obj(), task.index()); k->oop_follow_contents(cm, task.obj(), task.index());
cm->follow_marking_stacks(); cm->follow_marking_stacks();
} }

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2005, 2013, 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
@ -187,11 +187,8 @@ void ParCompactionManager::follow_marking_stacks() {
// Process ObjArrays one at a time to avoid marking stack bloat. // Process ObjArrays one at a time to avoid marking stack bloat.
ObjArrayTask task; ObjArrayTask task;
if (_objarray_stack.pop_overflow(task)) { if (_objarray_stack.pop_overflow(task) || _objarray_stack.pop_local(task)) {
ObjArrayKlass* const k = (ObjArrayKlass*)task.obj()->klass(); ObjArrayKlass* k = (ObjArrayKlass*)task.obj()->klass();
k->oop_follow_contents(this, task.obj(), task.index());
} else if (_objarray_stack.pop_local(task)) {
ObjArrayKlass* const k = (ObjArrayKlass*)task.obj()->klass();
k->oop_follow_contents(this, task.obj(), task.index()); k->oop_follow_contents(this, task.obj(), task.index());
} }
} while (!marking_stacks_empty()); } while (!marking_stacks_empty());

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1997, 2013, 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
@ -95,7 +95,7 @@ void MarkSweep::follow_stack() {
// Process ObjArrays one at a time to avoid marking stack bloat. // Process ObjArrays one at a time to avoid marking stack bloat.
if (!_objarray_stack.is_empty()) { if (!_objarray_stack.is_empty()) {
ObjArrayTask task = _objarray_stack.pop(); ObjArrayTask task = _objarray_stack.pop();
ObjArrayKlass* const k = (ObjArrayKlass*)task.obj()->klass(); ObjArrayKlass* k = (ObjArrayKlass*)task.obj()->klass();
k->oop_follow_contents(task.obj(), task.index()); k->oop_follow_contents(task.obj(), task.index());
} }
} while (!_marking_stack.is_empty() || !_objarray_stack.is_empty()); } while (!_marking_stack.is_empty() || !_objarray_stack.is_empty());

View file

@ -154,12 +154,12 @@ KlassInfoTable::~KlassInfoTable() {
} }
} }
uint KlassInfoTable::hash(Klass* p) { uint KlassInfoTable::hash(const Klass* p) {
assert(p->is_metadata(), "all klasses are metadata"); assert(p->is_metadata(), "all klasses are metadata");
return (uint)(((uintptr_t)p - (uintptr_t)_ref) >> 2); return (uint)(((uintptr_t)p - (uintptr_t)_ref) >> 2);
} }
KlassInfoEntry* KlassInfoTable::lookup(Klass* const k) { KlassInfoEntry* KlassInfoTable::lookup(Klass* k) {
uint idx = hash(k) % _size; uint idx = hash(k) % _size;
assert(_buckets != NULL, "Allocation failure should have been caught"); assert(_buckets != NULL, "Allocation failure should have been caught");
KlassInfoEntry* e = _buckets[idx].lookup(k); KlassInfoEntry* e = _buckets[idx].lookup(k);

View file

@ -189,15 +189,15 @@ class KlassInfoEntry: public CHeapObj<mtInternal> {
KlassInfoEntry(Klass* k, KlassInfoEntry* next) : KlassInfoEntry(Klass* k, KlassInfoEntry* next) :
_klass(k), _instance_count(0), _instance_words(0), _next(next), _index(-1) _klass(k), _instance_count(0), _instance_words(0), _next(next), _index(-1)
{} {}
KlassInfoEntry* next() { return _next; } KlassInfoEntry* next() const { return _next; }
bool is_equal(Klass* k) { return k == _klass; } bool is_equal(const Klass* k) { return k == _klass; }
Klass* klass() { return _klass; } Klass* klass() const { return _klass; }
long count() { return _instance_count; } long count() const { return _instance_count; }
void set_count(long ct) { _instance_count = ct; } void set_count(long ct) { _instance_count = ct; }
size_t words() { return _instance_words; } size_t words() const { return _instance_words; }
void set_words(size_t wds) { _instance_words = wds; } void set_words(size_t wds) { _instance_words = wds; }
void set_index(long index) { _index = index; } void set_index(long index) { _index = index; }
long index() { return _index; } long index() const { return _index; }
int compare(KlassInfoEntry* e1, KlassInfoEntry* e2); int compare(KlassInfoEntry* e1, KlassInfoEntry* e2);
void print_on(outputStream* st) const; void print_on(outputStream* st) const;
const char* name() const; const char* name() const;
@ -215,7 +215,7 @@ class KlassInfoBucket: public CHeapObj<mtInternal> {
KlassInfoEntry* list() { return _list; } KlassInfoEntry* list() { return _list; }
void set_list(KlassInfoEntry* l) { _list = l; } void set_list(KlassInfoEntry* l) { _list = l; }
public: public:
KlassInfoEntry* lookup(Klass* const k); KlassInfoEntry* lookup(Klass* k);
void initialize() { _list = NULL; } void initialize() { _list = NULL; }
void empty(); void empty();
void iterate(KlassInfoClosure* cic); void iterate(KlassInfoClosure* cic);
@ -231,8 +231,8 @@ class KlassInfoTable: public StackObj {
HeapWord* _ref; HeapWord* _ref;
KlassInfoBucket* _buckets; KlassInfoBucket* _buckets;
uint hash(Klass* p); uint hash(const Klass* p);
KlassInfoEntry* lookup(Klass* const k); // allocates if not found! KlassInfoEntry* lookup(Klass* k); // allocates if not found!
class AllClassesFinder : public KlassClosure { class AllClassesFinder : public KlassClosure {
KlassInfoTable *_table; KlassInfoTable *_table;

View file

@ -1425,7 +1425,7 @@ ActiveMethodOopsCache::~ActiveMethodOopsCache() {
} }
void ActiveMethodOopsCache::add_previous_version(Method* const method) { void ActiveMethodOopsCache::add_previous_version(Method* method) {
assert(Thread::current()->is_VM_thread(), assert(Thread::current()->is_VM_thread(),
"only VMThread can add previous versions"); "only VMThread can add previous versions");
@ -1464,16 +1464,17 @@ void ActiveMethodOopsCache::add_previous_version(Method* const method) {
MetadataFactory::free_metadata(method->method_holder()->class_loader_data(), method); MetadataFactory::free_metadata(method->method_holder()->class_loader_data(), method);
} else { } else {
// RC_TRACE macro has an embedded ResourceMark // RC_TRACE macro has an embedded ResourceMark
RC_TRACE(0x00000400, ("add: %s(%s): previous cached method @%d is alive", RC_TRACE(0x00000400,
("add: %s(%s): previous cached method @%d is alive",
method->name()->as_C_string(), method->signature()->as_C_string(), i)); method->name()->as_C_string(), method->signature()->as_C_string(), i));
} }
} }
} // end add_previous_version() } // end add_previous_version()
bool ActiveMethodOopsCache::is_same_method(Method* const method) const { bool ActiveMethodOopsCache::is_same_method(const Method* method) const {
InstanceKlass* ik = InstanceKlass::cast(klass()); InstanceKlass* ik = InstanceKlass::cast(klass());
Method* check_method = ik->method_with_idnum(method_idnum()); const Method* check_method = ik->method_with_idnum(method_idnum());
assert(check_method != NULL, "sanity check"); assert(check_method != NULL, "sanity check");
if (check_method == method) { if (check_method == method) {
// done with the easy case // done with the easy case

View file

@ -90,8 +90,8 @@ class ActiveMethodOopsCache : public CommonMethodOopCache {
ActiveMethodOopsCache() { _prev_methods = NULL; } ActiveMethodOopsCache() { _prev_methods = NULL; }
~ActiveMethodOopsCache(); ~ActiveMethodOopsCache();
void add_previous_version(Method* const method); void add_previous_version(Method* method);
bool is_same_method(Method* const method) const; bool is_same_method(const Method* method) const;
}; };

View file

@ -354,7 +354,7 @@ class ConstantPool : public Metadata {
Symbol* klass_name_at(int which); // Returns the name, w/o resolving. Symbol* klass_name_at(int which); // Returns the name, w/o resolving.
Klass* resolved_klass_at(int which) { // Used by Compiler Klass* resolved_klass_at(int which) const { // Used by Compiler
guarantee(tag_at(which).is_klass(), "Corrupted constant pool"); guarantee(tag_at(which).is_klass(), "Corrupted constant pool");
// Must do an acquire here in case another thread resolved the klass // Must do an acquire here in case another thread resolved the klass
// behind our back, lest we later load stale values thru the oop. // behind our back, lest we later load stale values thru the oop.

View file

@ -2724,7 +2724,7 @@ void InstanceKlass::remove_osr_nmethod(nmethod* n) {
OsrList_lock->unlock(); OsrList_lock->unlock();
} }
nmethod* InstanceKlass::lookup_osr_nmethod(Method* const m, int bci, int comp_level, bool match_level) const { nmethod* InstanceKlass::lookup_osr_nmethod(const Method* m, int bci, int comp_level, bool match_level) const {
// This is a short non-blocking critical region, so the no safepoint check is ok. // This is a short non-blocking critical region, so the no safepoint check is ok.
OsrList_lock->lock_without_safepoint_check(); OsrList_lock->lock_without_safepoint_check();
nmethod* osr = osr_nmethods_head(); nmethod* osr = osr_nmethods_head();

View file

@ -739,7 +739,7 @@ class InstanceKlass: public Klass {
void set_osr_nmethods_head(nmethod* h) { _osr_nmethods_head = h; }; void set_osr_nmethods_head(nmethod* h) { _osr_nmethods_head = h; };
void add_osr_nmethod(nmethod* n); void add_osr_nmethod(nmethod* n);
void remove_osr_nmethod(nmethod* n); void remove_osr_nmethod(nmethod* n);
nmethod* lookup_osr_nmethod(Method* const m, int bci, int level, bool match_level) const; nmethod* lookup_osr_nmethod(const Method* m, int bci, int level, bool match_level) const;
// Breakpoint support (see methods on Method* for details) // Breakpoint support (see methods on Method* for details)
BreakpointInfo* breakpoints() const { return _breakpoints; }; BreakpointInfo* breakpoints() const { return _breakpoints; };

View file

@ -50,7 +50,7 @@ void Klass::set_name(Symbol* n) {
if (_name != NULL) _name->increment_refcount(); if (_name != NULL) _name->increment_refcount();
} }
bool Klass::is_subclass_of(Klass* k) const { bool Klass::is_subclass_of(const Klass* k) const {
// Run up the super chain and check // Run up the super chain and check
if (this == k) return true; if (this == k) return true;

View file

@ -395,7 +395,7 @@ class Klass : public Metadata {
virtual klassVtable* vtable() const { return NULL; } virtual klassVtable* vtable() const { return NULL; }
// subclass check // subclass check
bool is_subclass_of(Klass* k) const; bool is_subclass_of(const Klass* k) const;
// subtype check: true if is_subclass_of, or if k is interface and receiver implements it // subtype check: true if is_subclass_of, or if k is interface and receiver implements it
bool is_subtype_of(Klass* k) const { bool is_subtype_of(Klass* k) const {
juint off = k->super_check_offset(); juint off = k->super_check_offset();

View file

@ -1581,7 +1581,7 @@ int Method::backedge_count() {
} }
int Method::highest_comp_level() const { int Method::highest_comp_level() const {
MethodData* mdo = method_data(); const MethodData* mdo = method_data();
if (mdo != NULL) { if (mdo != NULL) {
return mdo->highest_comp_level(); return mdo->highest_comp_level();
} else { } else {
@ -1590,7 +1590,7 @@ int Method::highest_comp_level() const {
} }
int Method::highest_osr_comp_level() const { int Method::highest_osr_comp_level() const {
MethodData* mdo = method_data(); const MethodData* mdo = method_data();
if (mdo != NULL) { if (mdo != NULL) {
return mdo->highest_osr_comp_level(); return mdo->highest_osr_comp_level();
} else { } else {

View file

@ -996,7 +996,7 @@ class ExceptionTable : public StackObj {
u2 _length; u2 _length;
public: public:
ExceptionTable(Method* m) { ExceptionTable(const Method* m) {
if (m->has_exception_handler()) { if (m->has_exception_handler()) {
_table = m->exception_table_start(); _table = m->exception_table_start();
_length = m->exception_table_length(); _length = m->exception_table_length();

View file

@ -1338,9 +1338,9 @@ public:
void set_would_profile(bool p) { _would_profile = p; } void set_would_profile(bool p) { _would_profile = p; }
bool would_profile() const { return _would_profile; } bool would_profile() const { return _would_profile; }
int highest_comp_level() { return _highest_comp_level; } int highest_comp_level() const { return _highest_comp_level; }
void set_highest_comp_level(int level) { _highest_comp_level = level; } void set_highest_comp_level(int level) { _highest_comp_level = level; }
int highest_osr_comp_level() { return _highest_osr_comp_level; } int highest_osr_comp_level() const { return _highest_osr_comp_level; }
void set_highest_osr_comp_level(int level) { _highest_osr_comp_level = level; } void set_highest_osr_comp_level(int level) { _highest_osr_comp_level = level; }
int num_loops() const { return _num_loops; } int num_loops() const { return _num_loops; }

View file

@ -1710,7 +1710,7 @@ JVM_ENTRY(jobjectArray, JVM_GetMethodParameters(JNIEnv *env, jobject method))
for (int i = 0; i < num_params; i++) { for (int i = 0; i < num_params; i++) {
MethodParametersElement* params = mh->method_parameters_start(); MethodParametersElement* params = mh->method_parameters_start();
// For a 0 index, give a NULL symbol // For a 0 index, give a NULL symbol
Symbol* const sym = 0 != params[i].name_cp_index ? Symbol* sym = 0 != params[i].name_cp_index ?
mh->constants()->symbol_at(params[i].name_cp_index) : NULL; mh->constants()->symbol_at(params[i].name_cp_index) : NULL;
int flags = params[i].flags; int flags = params[i].flags;
oop param = Reflection::new_parameter(reflected_method, i, sym, oop param = Reflection::new_parameter(reflected_method, i, sym,

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2013, 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
@ -2857,7 +2857,7 @@ inline bool VM_HeapWalkOperation::iterate_over_class(oop java_class) {
// references from the constant pool // references from the constant pool
{ {
ConstantPool* const pool = ik->constants(); ConstantPool* pool = ik->constants();
for (int i = 1; i < pool->length(); i++) { for (int i = 1; i < pool->length(); i++) {
constantTag tag = pool->tag_at(i).value(); constantTag tag = pool->tag_at(i).value();
if (tag.is_string() || tag.is_klass()) { if (tag.is_string() || tag.is_klass()) {