Class Blackhole


  • public final class Blackhole
    extends java.lang.Object
    Black Hole.

    Black hole "consumes" the values, conceiving no information to JIT whether the value is actually used afterwards. This can save from the dead-code elimination of the computations resulting in the given values.

    • Field Summary

      Fields 
      Modifier and Type Field Description
      byte b1  
      byte b2  
      boolean bool1  
      boolean bool2  
      char c1  
      char c2  
      double d1  
      double d2  
      float f1  
      float f2  
      int i1  
      int i2  
      long l1  
      long l2  
      org.openjdk.jmh.infra.BlackholeL2 nullBait  
      java.lang.Object obj1  
      short s1  
      short s2  
      int tlr  
      int tlrMask  
    • Constructor Summary

      Constructors 
      Constructor Description
      Blackhole​(java.lang.String challengeResponse)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void consume​(boolean bool)
      Consume object.
      void consume​(byte b)
      Consume object.
      void consume​(char c)
      Consume object.
      void consume​(double d)
      Consume object.
      void consume​(float f)
      Consume object.
      void consume​(int i)
      Consume object.
      void consume​(long l)
      Consume object.
      void consume​(short s)
      Consume object.
      void consume​(java.lang.Object obj)
      Consume object.
      static void consumeCPU​(long tokens)
      Consume some amount of time tokens.
      void evaporate​(java.lang.String challengeResponse)
      Make any consumed data begone.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • b1

        public volatile byte b1
      • bool1

        public volatile boolean bool1
      • c1

        public volatile char c1
      • s1

        public volatile short s1
      • i1

        public volatile int i1
      • l1

        public volatile long l1
      • f1

        public volatile float f1
      • d1

        public volatile double d1
      • b2

        public byte b2
      • bool2

        public boolean bool2
      • c2

        public char c2
      • s2

        public short s2
      • i2

        public int i2
      • l2

        public long l2
      • f2

        public float f2
      • d2

        public double d2
      • obj1

        public volatile java.lang.Object obj1
      • nullBait

        public volatile org.openjdk.jmh.infra.BlackholeL2 nullBait
      • tlr

        public int tlr
      • tlrMask

        public volatile int tlrMask
    • Constructor Detail

      • Blackhole

        public Blackhole​(java.lang.String challengeResponse)
    • Method Detail

      • evaporate

        public void evaporate​(java.lang.String challengeResponse)
        Make any consumed data begone. WARNING: This method should only be called by the infrastructure code, in clearly understood cases. Even though it is public, it is not supposed to be called by users.
        Parameters:
        challengeResponse - arbitrary string
      • consume

        public final void consume​(java.lang.Object obj)
        Consume object. This call provides a side effect preventing JIT to eliminate dependent computations.
        Parameters:
        obj - object to consume.
      • consume

        public final void consume​(byte b)
        Consume object. This call provides a side effect preventing JIT to eliminate dependent computations.
        Parameters:
        b - object to consume.
      • consume

        public final void consume​(boolean bool)
        Consume object. This call provides a side effect preventing JIT to eliminate dependent computations.
        Parameters:
        bool - object to consume.
      • consume

        public final void consume​(char c)
        Consume object. This call provides a side effect preventing JIT to eliminate dependent computations.
        Parameters:
        c - object to consume.
      • consume

        public final void consume​(short s)
        Consume object. This call provides a side effect preventing JIT to eliminate dependent computations.
        Parameters:
        s - object to consume.
      • consume

        public final void consume​(int i)
        Consume object. This call provides a side effect preventing JIT to eliminate dependent computations.
        Parameters:
        i - object to consume.
      • consume

        public final void consume​(long l)
        Consume object. This call provides a side effect preventing JIT to eliminate dependent computations.
        Parameters:
        l - object to consume.
      • consume

        public final void consume​(float f)
        Consume object. This call provides a side effect preventing JIT to eliminate dependent computations.
        Parameters:
        f - object to consume.
      • consume

        public final void consume​(double d)
        Consume object. This call provides a side effect preventing JIT to eliminate dependent computations.
        Parameters:
        d - object to consume.
      • consumeCPU

        public static void consumeCPU​(long tokens)
        Consume some amount of time tokens. This method does the CPU work almost linear to the number of tokens. The token cost may vary from system to system, and may change in future. (Translation: it is as reliable as we can get, but not absolutely reliable). See JMH samples for the complete demo, and core benchmarks for the performance assessments.
        Parameters:
        tokens - CPU tokens to consume