ExxonMobil scored a massive gain from the Republican tax overhaul.

The tax windfall helped Exxon's (XOM) net profits surge fivefold, the world's largest publicly traded oil company said on Friday.

Excluding the tax bonanza, Exxon's results left Wall Street wanting more. Adjusted earnings unexpectedly declined and revenue missed the mark by a wide margin. Exxon shares slumped about 5%.

One problem: Exxon isn't pumping as much oil as it used to following years of budget cuts forced by the crash in crude prices. The company's overall production dropped 3% in 2017.

Exxon said the federal tax law enacted by President Trump in December gave the company a non-cash earnings gain of $5.9 billion. That's because the corporate tax rate has been lowered from 35% to 21%. Like other companies, the reduced rate allowed Exxon to write down the amount of money it owed Uncle Sam in the future, known as deferred income taxes.

Exxon was not hurt by the part of the tax law that forced companies to bring foreign profits back to the United States. The company said it generally paid taxes on these overseas profits at around 35% anyway, allowing it to avoid a repatriation tax hit.

Related: America does export energy. It imports a lot more

CEO Darren Woods said the tax overhaul "strengthens our commitment to further grow our business" in the United States.

Exxon promised this week to invest more than $50 billion in the U.S. over the next five years, a move that the company said will create "thousands of jobs" and boost the economy.

Specifically, Exxon said it plans to invest "billions of dollars to increase oil production in the Permian Basin" of West Texas and New Mexico, expand existing operations, enhance infrastructure and build new manufacturing sites.

Woods said the investment is "supported by the improved business climate created by tax reform."

However, Exxon did not indicate whether its $50 billion U.S. investment target represents an increase from its previous plan.

Consider that the five-year goal mirrors the roughly $50 billion Exxon spent in the United States between 2012 and 2016, according to filings.

That's because pumping oil and natural gas can be extremely expensive, forcing major companies to spend heavily just to keep their output steady.

Exxon had been expected to shift its resources back to America after the energy company was late to the U.S. shale oil boom because it focused on overseas projects instead.

Exxon said it wants to triple production in the fast-growing Permian Basin shale oil field.