8138707: TestPromotionEventWithParallelScavenge.java crashes using undefined GC id.
authorbrutisso
Tue, 06 Oct 2015 14:27:03 +0200
changeset 33126 260ff671354b
parent 33125 bc61fce9bac3
child 33128 0d1360a45a3b
8138707: TestPromotionEventWithParallelScavenge.java crashes using undefined GC id. Reviewed-by: mgerdin, jwilhelm
hotspot/src/share/vm/gc/parallel/gcTaskManager.cpp
hotspot/src/share/vm/gc/parallel/gcTaskManager.hpp
hotspot/src/share/vm/gc/parallel/gcTaskThread.cpp
--- a/hotspot/src/share/vm/gc/parallel/gcTaskManager.cpp	Tue Oct 06 14:26:13 2015 +0200
+++ b/hotspot/src/share/vm/gc/parallel/gcTaskManager.cpp	Tue Oct 06 14:27:03 2015 +0200
@@ -26,6 +26,7 @@
 #include "gc/parallel/gcTaskManager.hpp"
 #include "gc/parallel/gcTaskThread.hpp"
 #include "gc/shared/adaptiveSizePolicy.hpp"
+#include "gc/shared/gcId.hpp"
 #include "memory/allocation.hpp"
 #include "memory/allocation.inline.hpp"
 #include "runtime/mutex.hpp"
@@ -61,33 +62,24 @@
   return result;
 };
 
-GCTask::GCTask() :
-  _kind(Kind::ordinary_task),
-  _affinity(GCTaskManager::sentinel_worker()){
-  initialize();
+GCTask::GCTask() {
+  initialize(Kind::ordinary_task, GCId::current());
 }
 
-GCTask::GCTask(Kind::kind kind) :
-  _kind(kind),
-  _affinity(GCTaskManager::sentinel_worker()) {
-  initialize();
+GCTask::GCTask(Kind::kind kind) {
+  initialize(kind, GCId::current());
 }
 
-GCTask::GCTask(uint affinity) :
-  _kind(Kind::ordinary_task),
-  _affinity(affinity) {
-  initialize();
+GCTask::GCTask(Kind::kind kind, uint gc_id) {
+  initialize(kind, gc_id);
 }
 
-GCTask::GCTask(Kind::kind kind, uint affinity) :
-  _kind(kind),
-  _affinity(affinity) {
-  initialize();
-}
-
-void GCTask::initialize() {
+void GCTask::initialize(Kind::kind kind, uint gc_id) {
+  _kind = kind;
+  _affinity = GCTaskManager::sentinel_worker();
   _older = NULL;
   _newer = NULL;
+  _gc_id = gc_id;
 }
 
 void GCTask::destruct() {
@@ -806,6 +798,10 @@
   }
 }
 
+// This task should never be performing GC work that require
+// a valid GC id.
+NoopGCTask::NoopGCTask() : GCTask(GCTask::Kind::noop_task, GCId::undefined()) { }
+
 void NoopGCTask::destruct() {
   // This has to know it's superclass structure, just like the constructor.
   this->GCTask::destruct();
--- a/hotspot/src/share/vm/gc/parallel/gcTaskManager.hpp	Tue Oct 06 14:26:13 2015 +0200
+++ b/hotspot/src/share/vm/gc/parallel/gcTaskManager.hpp	Tue Oct 06 14:27:03 2015 +0200
@@ -68,13 +68,16 @@
   };
 private:
   // Instance state.
-  const Kind::kind _kind;               // For runtime type checking.
-  const uint       _affinity;           // Which worker should run task.
+  Kind::kind       _kind;               // For runtime type checking.
+  uint             _affinity;           // Which worker should run task.
   GCTask*          _newer;              // Tasks are on doubly-linked ...
   GCTask*          _older;              // ... lists.
+  uint             _gc_id;              // GC Id to use for the thread that executes this task
 public:
   virtual char* name() { return (char *)"task"; }
 
+  uint gc_id() { return _gc_id; }
+
   // Abstract do_it method
   virtual void do_it(GCTaskManager* manager, uint which) = 0;
   // Accessors
@@ -116,17 +119,14 @@
   GCTask();
   //     A GCTask of a particular kind, usually barrier or noop.
   GCTask(Kind::kind kind);
-  //     An ordinary GCTask with an affinity.
-  GCTask(uint affinity);
-  //     A GCTask of a particular kind, with and affinity.
-  GCTask(Kind::kind kind, uint affinity);
+  GCTask(Kind::kind kind, uint gc_id);
   // We want a virtual destructor because virtual methods,
   // but since ResourceObj's don't have their destructors
   // called, we don't have one at all.  Instead we have
   // this method, which gets called by subclasses to clean up.
   virtual void destruct();
   // Methods.
-  void initialize();
+  void initialize(Kind::kind kind, uint gc_id);
 };
 
 // A doubly-linked list of GCTasks.
@@ -567,8 +567,7 @@
   }
 protected:
   // Constructor.
-  NoopGCTask() :
-    GCTask(GCTask::Kind::noop_task) { }
+  NoopGCTask();
   // Destructor-like method.
   void destruct();
 };
--- a/hotspot/src/share/vm/gc/parallel/gcTaskThread.cpp	Tue Oct 06 14:26:13 2015 +0200
+++ b/hotspot/src/share/vm/gc/parallel/gcTaskThread.cpp	Tue Oct 06 14:27:03 2015 +0200
@@ -26,6 +26,7 @@
 #include "precompiled.hpp"
 #include "gc/parallel/gcTaskManager.hpp"
 #include "gc/parallel/gcTaskThread.hpp"
+#include "gc/shared/gcId.hpp"
 #include "memory/allocation.hpp"
 #include "memory/allocation.inline.hpp"
 #include "memory/resourceArea.hpp"
@@ -124,6 +125,7 @@
     for (; /* break */; ) {
       // This will block until there is a task to be gotten.
       GCTask* task = manager()->get_task(which());
+      GCIdMark gc_id_mark(task->gc_id());
       // Record if this is an idle task for later use.
       bool is_idle_task = task->is_idle_task();
       // In case the update is costly