Class AssumedValue<T>

java.lang.Object
com.oracle.truffle.api.utilities.AssumedValue<T>

public class AssumedValue<T> extends Object
A value that the compiler can assume is constant, but can be changed by invalidation.

Compiled code that uses the value will be invalidated each time the value changes, so you should take care to only change values infrequently, or to monitor the number of times the value has changed and at some point to replace the value with something more generic so that it does not have to be changed and code does not have to keep being recompiled.

Since:
0.8 or earlier
  • Constructor Details

    • AssumedValue

      public AssumedValue(T initialValue)
      Since:
      0.8 or earlier
    • AssumedValue

      public AssumedValue(String name, T initialValue)
      Since:
      0.8 or earlier
  • Method Details

    • get

      public T get()
      Get the current value, updating it if it has been set(T). The compiler may be able to make this method return a constant value, but still accommodate mutation.
      Since:
      0.8 or earlier
    • set

      public void set(T newValue)
      Set a new value, which will be picked up the next time get() is called.
      Since:
      0.8 or earlier