diff --git a/build.sbt b/build.sbt index 6d6989da..e0512ad7 100644 --- a/build.sbt +++ b/build.sbt @@ -252,6 +252,9 @@ lazy val mcas = crossProject(JVMPlatform, JSPlatform) // there is no backward compat for `choam-mcas`: ProblemFilters.exclude[DirectMissingMethodProblem]("dev.tauri.choam.internal.mcas.Descriptor.versionCas"), ProblemFilters.exclude[ReversedMissingMethodProblem]("dev.tauri.choam.internal.mcas.AbstractDescriptor.hwdIterator"), + ProblemFilters.exclude[DirectMissingMethodProblem]("dev.tauri.choam.internal.mcas.LogEntry.cleanForGc"), + ProblemFilters.exclude[DirectMissingMethodProblem]("dev.tauri.choam.internal.mcas.WdLike.cleanForGc"), + ProblemFilters.exclude[ReversedMissingMethodProblem]("dev.tauri.choam.internal.mcas.WdLike.wasFinalized"), ), ) diff --git a/mcas/jvm/src/main/scala/dev/tauri/choam/internal/mcas/WdLike.scala b/mcas/jvm/src/main/scala/dev/tauri/choam/internal/mcas/WdLike.scala index 80dc6942..ae3dab58 100644 --- a/mcas/jvm/src/main/scala/dev/tauri/choam/internal/mcas/WdLike.scala +++ b/mcas/jvm/src/main/scala/dev/tauri/choam/internal/mcas/WdLike.scala @@ -26,7 +26,7 @@ sealed trait WdLike[A] extends Hamt.HasKey[MemoryLocation[A]] { def ov: A def nv: A val oldVersion: Long - def cleanForGc(wasSuccessful: Boolean, sentinel: A): Unit + def wasFinalized(wasSuccessful: Boolean, sentinel: A): Unit final override def key: MemoryLocation[A] = this.address @@ -42,7 +42,7 @@ final class LogEntry[A] private ( // formerly called HWD require(Version.isValid(oldVersion)) - final override def cleanForGc(wasSuccessful: Boolean, sentinel: A): Unit = + final override def wasFinalized(wasSuccessful: Boolean, sentinel: A): Unit = () private[choam] final def cast[B]: LogEntry[B] = diff --git a/mcas/jvm/src/main/scala/dev/tauri/choam/internal/mcas/emcas/EmcasDescriptor.scala b/mcas/jvm/src/main/scala/dev/tauri/choam/internal/mcas/emcas/EmcasDescriptor.scala index 6824d93b..9054d556 100644 --- a/mcas/jvm/src/main/scala/dev/tauri/choam/internal/mcas/emcas/EmcasDescriptor.scala +++ b/mcas/jvm/src/main/scala/dev/tauri/choam/internal/mcas/emcas/EmcasDescriptor.scala @@ -130,11 +130,7 @@ private[mcas] final class EmcasDescriptor private[this] ( this.getOrInitFallback(fb) } - // we can clean up to help the GC - // (even if we have to retry with - // the fallback, we already copied - // the array): - this.cleanWordsForGc(EmcasStatus.isSuccessful(finalResult)) + this.wasFinalized(EmcasStatus.isSuccessful(finalResult)) } private[emcas] final def fallback: EmcasDescriptor = { diff --git a/mcas/jvm/src/main/scala/dev/tauri/choam/internal/mcas/emcas/EmcasDescriptorBase.java b/mcas/jvm/src/main/scala/dev/tauri/choam/internal/mcas/emcas/EmcasDescriptorBase.java index d924291d..cb4025e0 100644 --- a/mcas/jvm/src/main/scala/dev/tauri/choam/internal/mcas/emcas/EmcasDescriptorBase.java +++ b/mcas/jvm/src/main/scala/dev/tauri/choam/internal/mcas/emcas/EmcasDescriptorBase.java @@ -105,9 +105,13 @@ final EmcasDescriptor getOrInitFallback(EmcasDescriptor candidate) { } } - final void cleanWordsForGc(boolean wasSuccessful) { - // We're the only ones cleaning, so - // `_words` is never `null` here: + final void wasFinalized(boolean wasSuccessful) { + // We can clean up to help the GC + // (even if we have to retry with + // the fallback, we already copied + // the array). We're the only ones + // cleaning up, so `_words` is never + // `null` here: WdLike[] words = this.getWordsO(); int len = words.length; VarHandle.releaseFence(); @@ -124,7 +128,7 @@ final void cleanWordsForGc(boolean wasSuccessful) { @SuppressWarnings("unchecked") WdLike wd = (WdLike) words[idx]; WORDS_ARR.setOpaque(words, idx, (WdLike) null); - wd.cleanForGc(wasSuccessful, sentinel); + wd.wasFinalized(wasSuccessful, sentinel); } } } diff --git a/mcas/jvm/src/main/scala/dev/tauri/choam/internal/mcas/emcas/EmcasWordDescBase.java b/mcas/jvm/src/main/scala/dev/tauri/choam/internal/mcas/emcas/EmcasWordDescBase.java index ef951e07..27a301f7 100644 --- a/mcas/jvm/src/main/scala/dev/tauri/choam/internal/mcas/emcas/EmcasWordDescBase.java +++ b/mcas/jvm/src/main/scala/dev/tauri/choam/internal/mcas/emcas/EmcasWordDescBase.java @@ -53,7 +53,7 @@ public final A nv() { return this.getNvP(); } - public final void cleanForGc(boolean wasSuccessful, A sentinel) { + public final void wasFinalized(boolean wasSuccessful, A sentinel) { if (wasSuccessful) { OV.setOpaque(this, sentinel); } else {