SOMns
SOMns copied to clipboard
IfTrueIfFalseMessageNode for dynamic sends not restricted to boolean
The MessageSendNode appears to specialize based on its selector. The problem with the detecting specialization based on selector occurs when a class overrides the method.
For example, take the following program:
class Test usingPlatform: platform = Value ()(
public ifTrue: a ifFalse: b = (
'Skipping' print .
)
public main: args = ( ifTrue: 1 ifFalse: 2. ^ 0 )
)
SOMns currently attempts to specialize the implicit message sent from main:
as a specialized/IfTrueIfFalseMessageNode, which results in the error:
com.oracle.truffle.api.dsl.UnsupportedSpecializationException:
Unexpected values provided for IfTrueIfFalseInlinedLiteralsNode@75983e18:
[a Test], [SObjectWithoutFields]
To resolve this issue, we need to add logic that checks more than just the selector of the message - in this case, the specialized node should only be used when the receiver is an instance of the SBlock
object.
In this case we are merely missing a receiver type constraint for our primitive replacement.
Here we would need to set the receiver type. Probably to Boolean.class
.
The infrastructure is there. It only needs to be used correctly.
First step to solve the issue would be to add a test, demonstrating the issue.
Afterwards, setting the receiverType
in the @Primitive
annotation, as linked above, should be simple.
The test should ideally exercise all possibilities of things going wrong.