Torelli theorem for stable curves