Compute indexes for stack actions.