8082782: vm crash on StressRedefineWithoutBytecodeCorruption fails with assert(((Metadata*)obj)->is_valid()) failed: obj is valid

Walk compile task for Method* to not deallocate, store methods in methodHandle while compile task is being taken off compile queue

Reviewed-by: dcubed, sspitsyn
This commit is contained in:
Coleen Phillimore 2015-07-23 15:17:58 -04:00
parent d7f565d9eb
commit ea406828ce
3 changed files with 28 additions and 2 deletions

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1999, 2015, 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
@ -345,6 +345,14 @@ void CompileTask::mark_on_stack() {
} }
} }
// RedefineClasses support
void CompileTask::metadata_do(void f(Metadata*)) {
f(method());
if (hot_method() != NULL && hot_method() != method()) {
f(hot_method());
}
}
// ------------------------------------------------------------------ // ------------------------------------------------------------------
// CompileTask::print_line_on_error // CompileTask::print_line_on_error
// //
@ -660,6 +668,11 @@ void CompileQueue::free_all() {
* Get the next CompileTask from a CompileQueue * Get the next CompileTask from a CompileQueue
*/ */
CompileTask* CompileQueue::get() { CompileTask* CompileQueue::get() {
// save methods from RedefineClasses across safepoint
// across MethodCompileQueue_lock below.
methodHandle save_method;
methodHandle save_hot_method;
MutexLocker locker(MethodCompileQueue_lock); MutexLocker locker(MethodCompileQueue_lock);
// If _first is NULL we have no more compile jobs. There are two reasons for // If _first is NULL we have no more compile jobs. There are two reasons for
// having no compile jobs: First, we compiled everything we wanted. Second, // having no compile jobs: First, we compiled everything we wanted. Second,
@ -693,6 +706,12 @@ CompileTask* CompileQueue::get() {
No_Safepoint_Verifier nsv; No_Safepoint_Verifier nsv;
task = CompilationPolicy::policy()->select_task(this); task = CompilationPolicy::policy()->select_task(this);
} }
// Save method pointers across unlock safepoint. The task is removed from
// the compilation queue, which is walked during RedefineClasses.
save_method = methodHandle(task->method());
save_hot_method = methodHandle(task->hot_method());
remove(task); remove(task);
purge_stale_tasks(); // may temporarily release MCQ lock purge_stale_tasks(); // may temporarily release MCQ lock
return task; return task;

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1999, 2015, 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
@ -80,6 +80,7 @@ class CompileTask : public CHeapObj<mtCompiler> {
int compile_id() const { return _compile_id; } int compile_id() const { return _compile_id; }
Method* method() const { return _method; } Method* method() const { return _method; }
Method* hot_method() const { return _hot_method; }
int osr_bci() const { return _osr_bci; } int osr_bci() const { return _osr_bci; }
bool is_complete() const { return _is_complete; } bool is_complete() const { return _is_complete; }
bool is_blocking() const { return _is_blocking; } bool is_blocking() const { return _is_blocking; }
@ -108,6 +109,9 @@ class CompileTask : public CHeapObj<mtCompiler> {
bool is_free() const { return _is_free; } bool is_free() const { return _is_free; }
void set_is_free(bool val) { _is_free = val; } void set_is_free(bool val) { _is_free = val; }
// RedefineClasses support
void metadata_do(void f(Metadata*));
private: private:
static void print_compilation_impl(outputStream* st, Method* method, int compile_id, int comp_level, static void print_compilation_impl(outputStream* st, Method* method, int compile_id, int comp_level,
bool is_osr_method = false, int osr_bci = -1, bool is_blocking = false, bool is_osr_method = false, int osr_bci = -1, bool is_blocking = false,

View File

@ -2739,6 +2739,9 @@ void JavaThread::metadata_do(void f(Metadata*)) {
if (ct->env() != NULL) { if (ct->env() != NULL) {
ct->env()->metadata_do(f); ct->env()->metadata_do(f);
} }
if (ct->task() != NULL) {
ct->task()->metadata_do(f);
}
} }
} }