SOMns icon indicating copy to clipboard operation
SOMns copied to clipboard

IfTrueIfFalseMessageNode for dynamic sends not restricted to boolean

Open ghost opened this issue 6 years ago • 2 comments

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.

ghost avatar Feb 01 '18 21:02 ghost

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.

smarr avatar Feb 01 '18 21:02 smarr

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.

smarr avatar Feb 01 '18 21:02 smarr