Skip to content

Commit

Permalink
Simplify Netty unsafe build item configuration for the shaded JCTools…
Browse files Browse the repository at this point in the history
… queues

GraalVM now seems to have good heuristics to spot the classic Unsafe usage patterns.
I removed some UnsafeAccessedFieldBuildItem and added one for UnsafeRefArrayAccess as this class
has a problematic static field (REF_ELEMENT_SHIFT).

For there record I found about this while working on smallrye/smallrye-mutiny#1434
  • Loading branch information
jponge committed Jan 26, 2024
1 parent 3135afe commit ab39b18
Showing 1 changed file with 2 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -254,23 +254,8 @@ public List<UnsafeAccessedFieldBuildItem> unsafeAccessedFields() {
return Arrays.asList(
new UnsafeAccessedFieldBuildItem("sun.nio.ch.SelectorImpl", "selectedKeys"),
new UnsafeAccessedFieldBuildItem("sun.nio.ch.SelectorImpl", "publicSelectedKeys"),

new UnsafeAccessedFieldBuildItem(
"io.netty.util.internal.shaded.org.jctools.queues.MpscArrayQueueProducerIndexField", "producerIndex"),
new UnsafeAccessedFieldBuildItem(
"io.netty.util.internal.shaded.org.jctools.queues.MpscArrayQueueProducerLimitField", "producerLimit"),
new UnsafeAccessedFieldBuildItem(
"io.netty.util.internal.shaded.org.jctools.queues.MpscArrayQueueConsumerIndexField", "consumerIndex"),

new UnsafeAccessedFieldBuildItem(
"io.netty.util.internal.shaded.org.jctools.queues.BaseMpscLinkedArrayQueueProducerFields",
"producerIndex"),
new UnsafeAccessedFieldBuildItem(
"io.netty.util.internal.shaded.org.jctools.queues.BaseMpscLinkedArrayQueueColdProducerFields",
"producerLimit"),
new UnsafeAccessedFieldBuildItem(
"io.netty.util.internal.shaded.org.jctools.queues.BaseMpscLinkedArrayQueueConsumerFields",
"consumerIndex"));
new UnsafeAccessedFieldBuildItem("io.netty.util.internal.shaded.org.jctools.util.UnsafeRefArrayAccess",
"REF_ELEMENT_SHIFT"));
}

@BuildStep
Expand Down

0 comments on commit ab39b18

Please sign in to comment.