@Retention(value=CLASS) @Target(value=METHOD) public @interface NonIdempotent
NonIdempotentmust be methods that may cause side effects but may not always cause the same side effects for repeated invocations with the same parameters. From this follows that an non-idempotent method may return different results for consecutive invocations 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.