< prev index next >

src/hotspot/share/gc/shenandoah/shenandoahEvacOOMHandler.cpp

Print this page
rev 59438 : 8245823: Shenandoah: inline/optimize ShenandoahEvacOOMScope

@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 2018, 2019, Red Hat, Inc. All rights reserved.
+ * Copyright (c) 2018, 2020, Red Hat, Inc. 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
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.

@@ -22,15 +22,12 @@
  *
  */
 
 #include "precompiled.hpp"
 
-#include "gc/shenandoah/shenandoahHeap.inline.hpp"
+#include "gc/shenandoah/shenandoahEvacOOMHandler.inline.hpp"
 #include "gc/shenandoah/shenandoahUtils.hpp"
-#include "gc/shenandoah/shenandoahEvacOOMHandler.hpp"
-#include "gc/shenandoah/shenandoahThreadLocalData.hpp"
-#include "runtime/atomic.hpp"
 #include "runtime/os.hpp"
 #include "runtime/thread.hpp"
 
 const jint ShenandoahEvacOOMHandler::OOM_MARKER_MASK = 0x80000000;
 

@@ -46,25 +43,13 @@
   // the thread-local oom_during_evac flag to indicate that any attempt
   // to evacuate should simply return the forwarding pointer instead (which is safe now).
   ShenandoahThreadLocalData::set_oom_during_evac(Thread::current(), true);
 }
 
-void ShenandoahEvacOOMHandler::enter_evacuation() {
+void ShenandoahEvacOOMHandler::register_thread_to_protocol(Thread* thr) {
   jint threads_in_evac = Atomic::load_acquire(&_threads_in_evac);
 
-  Thread* const thr = Thread::current();
-  uint8_t level = ShenandoahThreadLocalData::push_evac_oom_scope(thr);
-  if ((threads_in_evac & OOM_MARKER_MASK) != 0) {
-    wait_for_no_evac_threads();
-    return;
-  }
-
-  // Nesting case, this thread already registered
-  if (level > 0) {
-     return;
-  }
-
   assert(!ShenandoahThreadLocalData::is_oom_during_evac(Thread::current()), "TL oom-during-evac must not be set");
   while (true) {
     jint other = Atomic::cmpxchg(&_threads_in_evac, threads_in_evac, threads_in_evac + 1);
     if (other == threads_in_evac) {
       // Success: caller may safely enter evacuation

@@ -80,18 +65,11 @@
       threads_in_evac = other;
     }
   }
 }
 
-void ShenandoahEvacOOMHandler::leave_evacuation() {
-  Thread* const thr = Thread::current();
-  uint8_t level = ShenandoahThreadLocalData::pop_evac_oom_scope(thr);
-  // Not top level, just return
-  if (level > 1) {
-    return;
-  }
-
+void ShenandoahEvacOOMHandler::unregister_thread_to_protocol(Thread* thr) {
   if (!ShenandoahThreadLocalData::is_oom_during_evac(thr)) {
     assert((Atomic::load_acquire(&_threads_in_evac) & ~OOM_MARKER_MASK) > 0, "sanity");
     // NOTE: It's ok to simply decrement, even with mask set, because unmasked value is positive.
     Atomic::dec(&_threads_in_evac);
   } else {

@@ -124,13 +102,5 @@
 void ShenandoahEvacOOMHandler::clear() {
   assert(ShenandoahSafepoint::is_at_shenandoah_safepoint(), "must be at a safepoint");
   assert((Atomic::load_acquire(&_threads_in_evac) & ~OOM_MARKER_MASK) == 0, "sanity");
   Atomic::release_store_fence(&_threads_in_evac, (jint)0);
 }
-
-ShenandoahEvacOOMScope::ShenandoahEvacOOMScope() {
-  ShenandoahHeap::heap()->enter_evacuation();
-}
-
-ShenandoahEvacOOMScope::~ShenandoahEvacOOMScope() {
-  ShenandoahHeap::heap()->leave_evacuation();
-}
< prev index next >