mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-26 22:34:27 +02:00
6419370: 4/4 new jmethodID code has tiny holes in synchronization
Fix races in jmethodID cache and JNI itable index cache. Reviewed-by: ikrylov, acorn
This commit is contained in:
parent
9ed976194b
commit
2a4f284029
4 changed files with 204 additions and 53 deletions
|
@ -465,6 +465,10 @@ class instanceKlass: public Klass {
|
|||
// RedefineClasses() support for previous versions:
|
||||
void add_previous_version(instanceKlassHandle ikh, BitMap *emcp_methods,
|
||||
int emcp_method_count);
|
||||
// If the _previous_versions array is non-NULL, then this klass
|
||||
// has been redefined at least once even if we aren't currently
|
||||
// tracking a previous version.
|
||||
bool has_been_redefined() const { return _previous_versions != NULL; }
|
||||
bool has_previous_version() const;
|
||||
void init_previous_versions() {
|
||||
_previous_versions = NULL;
|
||||
|
@ -506,9 +510,14 @@ class instanceKlass: public Klass {
|
|||
void set_bootstrap_method(oop mh) { oop_store(&_bootstrap_method, mh); }
|
||||
|
||||
// jmethodID support
|
||||
static jmethodID get_jmethod_id(instanceKlassHandle ik_h, size_t idnum,
|
||||
jmethodID new_id, jmethodID* new_jmeths);
|
||||
static jmethodID jmethod_id_for_impl(instanceKlassHandle ik_h, methodHandle method_h);
|
||||
static jmethodID get_jmethod_id(instanceKlassHandle ik_h,
|
||||
methodHandle method_h);
|
||||
static jmethodID get_jmethod_id_fetch_or_update(instanceKlassHandle ik_h,
|
||||
size_t idnum, jmethodID new_id, jmethodID* new_jmeths,
|
||||
jmethodID* to_dealloc_id_p,
|
||||
jmethodID** to_dealloc_jmeths_p);
|
||||
static void get_jmethod_id_length_value(jmethodID* cache, size_t idnum,
|
||||
size_t *length_p, jmethodID* id_p);
|
||||
jmethodID jmethod_id_or_null(methodOop method);
|
||||
|
||||
// cached itable index support
|
||||
|
@ -754,6 +763,11 @@ private:
|
|||
void set_init_thread(Thread *thread) { _init_thread = thread; }
|
||||
|
||||
u2 idnum_allocated_count() const { return _idnum_allocated_count; }
|
||||
// The RedefineClasses() API can cause new method idnums to be needed
|
||||
// which will cause the caches to grow. Safety requires different
|
||||
// cache management logic if the caches can grow instead of just
|
||||
// going from NULL to non-NULL.
|
||||
bool idnum_can_increment() const { return has_been_redefined(); }
|
||||
jmethodID* methods_jmethod_ids_acquire() const
|
||||
{ return (jmethodID*)OrderAccess::load_ptr_acquire(&_methods_jmethod_ids); }
|
||||
void release_set_methods_jmethod_ids(jmethodID* jmeths)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue