Technology, energy stocks drive S&P 500 to record high