Upgrading petroleum residues and heavy oils