[Vm-dev] Reed Solomon plugins & performance slow down
Eliot Miranda
eliot.miranda at gmail.com
Sat Jun 5 23:39:04 UTC 2021
Hi Robert,
_,,,^..^,,,_ (phone)
> On Jun 4, 2021, at 11:52 AM, Robert Withers <robert.withers at pm.me> wrote:
>
> fieldSize := interpreterProxy stackIntegerValue: 1.
> coefficientsOop := interpreterProxy stackObjectValue: 0.
Since you check for isBytes: below you can use stackValue:. isBytes: can safely be passed any object, including immediates. So the stackObjectValue: call implies a redundant validation.
>
> (interpreterProxy isIntegerValue: fieldSize)
> ifFalse: [ ^interpreterProxy primitiveFailFor: PrimErrBadArgument ].
This is implicit. stackIntegerValue: fails if the object is not a SmallInteger (retiring zero) and otherwise answers its integerValue. So you should check if stackIntegerValue: fails since its return value will always answer true to isIntegerValue:
> (interpreterProxy isBytes: coefficientsOop)
> ifFalse: [ ^interpreterProxy primitiveFailFor: PrimErrBadArgument ].
I would write
fieldSize := interpreterProxy stackIntegerValue: 1.
coefficientsOop := interpreterProxy stackValue: 0.
(interpreterProxy failed not
and: [interpreterProxy isBytes: coefficientsOop])
ifFalse: [ ^interpreterProxy primitiveFailFor: PrimErrBadArgument ].
or
fieldSizeOop := interpreterProxy stackValue: 1.
coefficientsOop := interpreterProxy stackValue: 0.
((interpreterProxy isIntegerObject: fieldSizeOop)
and: [interpreterProxy isBytes: coefficientsOop])
ifFalse: [ ^interpreterProxy primitiveFailFor: PrimErrBadArgument ].
fieldSize := interpreterProxy integerValueOf: fieldSizeOop.
More information about the Vm-dev
mailing list