The supermarket chain and software company were two of the stock market’s best performers as indexes dropped sharply.