hotspot/src/share/vm/compiler/compileBroker.cpp
changeset 31981 9caa094a485f
parent 31775 98b4ded1e369
child 32391 01e2f5e916c7
--- a/hotspot/src/share/vm/compiler/compileBroker.cpp	Tue Jul 21 07:28:37 2015 -0700
+++ b/hotspot/src/share/vm/compiler/compileBroker.cpp	Thu Jul 23 15:17:58 2015 -0400
@@ -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.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -345,6 +345,14 @@
   }
 }
 
+// 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
 //
@@ -660,6 +668,11 @@
  * Get the next CompileTask from a CompileQueue
  */
 CompileTask* CompileQueue::get() {
+  // save methods from RedefineClasses across safepoint
+  // across MethodCompileQueue_lock below.
+  methodHandle save_method;
+  methodHandle save_hot_method;
+
   MutexLocker locker(MethodCompileQueue_lock);
   // 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,
@@ -693,6 +706,12 @@
     No_Safepoint_Verifier nsv;
     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);
   purge_stale_tasks(); // may temporarily release MCQ lock
   return task;