@Retention(value=CLASS) @Target(value=METHOD) public @interface Idempotent
Idempotentmust be methods that may cause side effects but will always cause the same side effects for repeated invocations with the same parameters. From this follows that an idempotent method must return the same result after it was executed once for each consecutive execution given the same parameters.
Truffle DSL uses this property to execute
guards where all bound
methods are idempotent once on the slow-path, during specialization, and never on the fast-path.
By default, all methods that do not bind dynamic parameters are interpreted as idempotent for
compatibility reasons. The DSL emits warnings whenever a method should be annotated either with
NonIdempotent. Note that guards that bind dynamic parameters will
never be idempotent in the fast-path, so the DSL will not require annotations for such guards.
Examples for non-idempotent methods are:
ContextLocal.get()if the language uses a context policy
ContextLocal.get()if the language uses context policy
Note that usages may assume that the current language instance never changes for a given Node. Therefore it is safe to assume language reference accesses idempotent.