pharo-project / pharo-vm

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

Remove StackInterpreter interruptPending instance variable #793

Closed jordanmontt closed 6 months ago

jordanmontt commented 6 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.