Business Insights
  • Home
  • Crypto
  • Finance Expert
  • Business
  • Invest News
  • Investing
  • Trading
  • Forex
  • Videos
  • Economy
  • Tech
  • Contact

Archives

  • September 2025
  • August 2025
  • July 2025
  • June 2025
  • May 2025
  • April 2025
  • March 2025
  • February 2025
  • January 2025
  • December 2024
  • November 2024
  • October 2024
  • September 2024
  • August 2024
  • July 2024
  • June 2024
  • May 2024
  • April 2024
  • March 2024
  • February 2024
  • August 2023
  • January 2023
  • December 2021
  • July 2021
  • November 2019
  • October 2019
  • September 2019
  • August 2019
  • July 2019
  • June 2019
  • May 2019
  • April 2019
  • March 2019
  • February 2019
  • January 2019

Categories

  • Business
  • Crypto
  • Economy
  • Finance Expert
  • Forex
  • Invest News
  • Investing
  • Tech
  • Trading
  • Uncategorized
  • Videos
Apply Loan
Money Visa
Advertise Us
Money Visa
  • Home
  • Crypto
  • Finance Expert
  • Business
  • Invest News
  • Investing
  • Trading
  • Forex
  • Videos
  • Economy
  • Tech
  • Contact
Announcing the Trillion Dollar Security Initiative
  • Forex

Go Ethereum’s JIT-EVM | Ethereum Foundation Blog

  • September 7, 2025
  • Roubens Andy King
Total
0
Shares
0
0
0
Total
0
Shares
Share 0
Tweet 0
Pin it 0

The Ethereum Virtual machine is kind of different than most other Virtual Machines out there. In my previous post I already explained how it’s used and described some of its characteristics.

The Ethereum Virtual Machine (EVM) is a simple but powerful, Turing complete 256bit Virtual Machine that allows anyone to execute arbitrary EVM Byte Code.

The go-ethereum project contains two implementations of the EVM. A simple and straightforward byte-code VM and a more sophisticated JIT-VM. In this post I’m going to explain some of the differences between the two implementations and describe some of the characteristics of the JIT EVM and why it can be so much faster than the byte-code EVM.

Go-ethereum’s Byte Code Virtual Machine

The EVM’s internals are pretty simple; it has a single run loop which will attempt to execute the instruction at the current Program Counter (PC in short). Within this loop the Gas is calculated for each instruction, memory is expanded if necessary and executes the instruction if the preamble succeeds. This will continue on until the VM either finishes gracefully or returns with an error by throwing an exception (e.g. out-of-gas).

for op = contract[pc] {

    if !sufficientGas(op) {

        return error("insufficient gas for op:", or)

    }
    switch op {

    case ...:

        /* execute */

    case RETURN:

        return memory[stack[-1], stack[-2]]

    }

    pc++

}

At the end of the execution loop the program-counter gets increment to run the next instruction and continues to do so until it has finished.

The EVM has another way to change the program-counter through something called jump-instructions (JUMP & JUMPI). Instead of letting the program-counter increment (pc++) the EVM can also jump to arbitrary positions in the contract code. The EVM knows two jump instructions, a normal jump that reads as “jump to position X” and a conditional jump that read as “jump to position X if condition Y is true”. When either such a jump occurs it must always land on a jump-destination. If the program lands on an instruction other than a jump destination the program fails — in other words, for a jump to be valid it must always be followed by a jump-destination instruction if the condition yielded true.

Prior to running any Ethereum program the EVM iterates over the code and finds all possible jump-destinations, it then puts them in a map that can be referenced by the program-counter to find them. Each and every time the EVM encounters a jump-instructions the jump validity is checked.

As you can see the executing code is relatively easy and simply interpreted by the byte-code VM, we may conclude even that through its sheer simplicity it’s actually pretty dumb.

Welcome JIT VM

The JIT-EVM takes a different approach to running EVM byte-code and is by definition initially slower than the byte-code VM. Before the VM can run any code it must first compile the byte-code in to components that can be understood by the JIT VM.

The initialisation- and execution procedure is done in 3-steps:

  1. We check whether there’s a JIT program ready to be run using the hash of the code — H(C) is used as an identifier to identify the program;
  2. if a program was found we run the program and return the result;
  3. if no program was found we run the byte-code and we compile a JIT program in the background.

Initially I tried to check whether the JIT program had finished compiling and move the execution over to the JIT — this all happened during runtime in the same loop using Go’s atomic package — unfortunately it turned out to be slower than letting the byte-code VM run and use the JIT program for every sequential call after the compilation of the program had finished.

By compiling the byte-code in to logical pieces the JIT has the ability to analyse the code more precisely and optimise where and whenever necessary.

For example an incredible simple optimisation that I did was compiling several push operation in to a single instruction. Let’s take the CALL instruction; call requires 7 push instructions — i.e. gas, address, value, input-offset, input-size, return-offset and return-size — prior to executing it, and what I did instead of looping through these 7 instructions, executing them one by one, I’ve optimised this away by taking the 7 instructions and append the 7 values in to a single slice. Now, whenever the start of the 7 push instructions is executed, it instead executes the one optimised instruction by immediately appending the static slice to the VM stack. Now of course this only works for static values (i.e. push 0x10), but these are present in the code quite a lot.

I’ve also optimised the static jump instructions. Static jumps are jumps who always jump to the same position (i.e. push 0x1, jump) and never change under any circumstance. By determining which jumps are static we can pre-check whether a jump is valid and lies within the bounds of the contract and if so we create a new instructions that replaces both the push and jumpinstruction and is flagged as valid. This prevents the VM from having to do two instructions and it prevents it from having to check whether the jump is valid and doing an expensive hash-map lookup for valid jump position.

Next steps

Full stack and memory analysis would also fit nicely in this model where large chunks of code could fit in to single instructions. Further I’d like to add symbolic-execution and turn the JIT in to a proper JIT-VM. I think this would be a logical next step once programs get large enough to take advantage of these optimisations.

Conclusion

Our JIT-VM is a whole lot smarter than the byte-code VM, but is far from being completely done (if ever). There are many more clever tricks we could add with this structure, but simply aren’t realistic for the moment. The runtime is within the bounds of being “reasonable” speedy. May the need arise to further optimise the VM we have the tools to do so.

Further code-reading


Cross posted from – https://medium.com/@jeff.ethereum/go-ethereums-jit-evm-27ef88277520#.1ed9lj7dz

Total
0
Shares
Share 0
Tweet 0
Pin it 0
Roubens Andy King

Previous Article
Dow, S&P 500, Nasdaq futures gain after weak jobs report with key inflation data on deck
  • Investing

Dow, S&P 500, Nasdaq futures gain after weak jobs report with key inflation data on deck

  • September 7, 2025
  • Roubens Andy King
Read More
Next Article
Trump Family’s Collective Wealth Grows by .3 Billion Thanks to Crypto
  • Crypto

Trump Family’s Collective Wealth Grows by $1.3 Billion Thanks to Crypto

  • September 7, 2025
  • Roubens Andy King
Read More
You May Also Like
Bitcoin Whales Dump .7B In Largest Selloff Since 2022
Read More
  • Forex

Bitcoin Whales Dump $12.7B In Largest Selloff Since 2022

  • Roubens Andy King
  • September 7, 2025
Ripple Highlights 3 Key Drivers Behind Institutional Digital Asset Adoption Surge
Read More
  • Forex

Ripple Highlights 3 Key Drivers Behind Institutional Digital Asset Adoption Surge

  • Roubens Andy King
  • September 7, 2025
Bitcoin Price Weakens – Fresh Downside Risk If Bulls Fail Soon
Read More
  • Forex

Bitcoin Price Weakens – Fresh Downside Risk If Bulls Fail Soon

  • Roubens Andy King
  • September 7, 2025
Bitcoin Has a ‘Logical’ Bounce Zone at 0,000
Read More
  • Forex

Bitcoin Has a ‘Logical’ Bounce Zone at $100,000

  • Roubens Andy King
  • September 7, 2025
El Salvador Celebrates Four-Year Bitcoin Anniversary, but Results Are Mixed
Read More
  • Forex

El Salvador Celebrates Four-Year Bitcoin Anniversary, but Results Are Mixed

  • Roubens Andy King
  • September 7, 2025
Despite All-Time High ETH Prices, Network Revenue Drops 44% in August
Read More
  • Forex

Despite All-Time High ETH Prices, Network Revenue Drops 44% in August

  • Roubens Andy King
  • September 7, 2025
Bitcoin, Ethereum, And Dogecoin Dominate Social Buzz
Read More
  • Forex

Bitcoin, Ethereum, And Dogecoin Dominate Social Buzz

  • Roubens Andy King
  • September 7, 2025
The Ethereum Foundation welcomes Microsoft as the Premiere Sponsor of Devcon2, Shanghai 19-21 September, 2016
Read More
  • Forex

The Ethereum Foundation welcomes Microsoft as the Premiere Sponsor of Devcon2, Shanghai 19-21 September, 2016

  • Roubens Andy King
  • September 7, 2025

Recent Posts

  • Crypto Treasuries in for “Bumpy Ride” as NAV Premiums Drop
  • Bitcoin Whales Dump $12.7B In Largest Selloff Since 2022
  • Ethereum Price Warning – Bulls Losing Grip as Downside Risks Build
  • Ripple Highlights 3 Key Drivers Behind Institutional Digital Asset Adoption Surge
  • Kinto Tanks 81% After Announcing Its Blockchain Will Shut Down
Featured Posts
  • Crypto Treasuries in for “Bumpy Ride” as NAV Premiums Drop 1
    Crypto Treasuries in for “Bumpy Ride” as NAV Premiums Drop
    • September 7, 2025
  • Bitcoin Whales Dump .7B In Largest Selloff Since 2022 2
    Bitcoin Whales Dump $12.7B In Largest Selloff Since 2022
    • September 7, 2025
  • Ethereum Price Warning – Bulls Losing Grip as Downside Risks Build 3
    Ethereum Price Warning – Bulls Losing Grip as Downside Risks Build
    • September 7, 2025
  • Ripple Highlights 3 Key Drivers Behind Institutional Digital Asset Adoption Surge 4
    Ripple Highlights 3 Key Drivers Behind Institutional Digital Asset Adoption Surge
    • September 7, 2025
  • Kinto Tanks 81% After Announcing Its Blockchain Will Shut Down 5
    Kinto Tanks 81% After Announcing Its Blockchain Will Shut Down
    • September 7, 2025
Recent Posts
  • Bitcoin Price Weakens – Fresh Downside Risk If Bulls Fail Soon
    Bitcoin Price Weakens – Fresh Downside Risk If Bulls Fail Soon
    • September 7, 2025
  • Dow futures rise as recession fears grow while Wall Street awaits the one thing that could derail Fed rate cuts
    Dow futures rise as recession fears grow while Wall Street awaits the one thing that could derail Fed rate cuts
    • September 7, 2025
  • Security Alert – Geth suffers from a very low probable DoS attack vector – Update immediately
    Security Alert – Geth suffers from a very low probable DoS attack vector – Update immediately
    • September 7, 2025
Categories
  • Business (2,057)
  • Crypto (1,566)
  • Economy (120)
  • Finance Expert (1,687)
  • Forex (1,565)
  • Invest News (2,360)
  • Investing (1,490)
  • Tech (2,056)
  • Trading (2,024)
  • Uncategorized (2)
  • Videos (812)

Subscribe

Subscribe now to our newsletter

Money Visa
  • Privacy Policy
  • DMCA
  • Terms of Use
Money & Invest Advices

Input your search keywords and press Enter.