The gains have solidified Apple’s position as the most valuable company in the world.