pharo-project / pharo-vm

This is the VM used by Pharo
http://pharo.org
Other
110 stars 67 forks source link

Remove StackInterpreter interruptPending instance variable #793

Closed jordanmontt closed 2 months ago

jordanmontt commented 2 months ago

The instance variable interruptPending from the StackInterpreter class is only used in this method and it's never initialized (see the file changed from this PR). When this code gets compiled to C we get the following.

/* StackInterpreter>>#checkForEventsMayContextSwitch: */
static sqInt NoDbgRegParms
checkForEventsMayContextSwitch(sqInt mayContextSwitch)

sqInt interruptPending;

/* more code ... */

    if (GIV(interruptPending)) {
        GIV(interruptPending) = 0;

        sema = unsignedLongAt((GIV(specialObjectsOop) + BaseHeaderSize) + ((sqInt) (((usqInt) TheInterruptSemaphore ) << (shiftForWord())) ));
        if ((sema != GIV(nilObj)) && (synchronousSignal(sema))) {
            switched = 1;
        }
    }

/* more code ... */

The variable get declared like this sqInt interruptPending; but it's never initialized. So, the conditional if (GIV(interruptPending)) will never be true as the variable was never initialized.

As the interruptPending variable is only used in that method and never initialized, I propose to delete that code snipped as it's never reached and it will never be true.