Questions: Bytecode Intermediate Representation and Virtual Machines

5 questions to test your understanding

Score: 0 / 5
Question 1 Multiple Choice

A JavaScript engine executes a function very slowly on the first hundred calls, but subsequent calls run at near-native speed. What mechanism best explains this pattern?

AThe engine downloaded an optimized native version of the function from a CDN after detecting slow performance
BThe JIT compiler identified the function as 'hot' through profiling and compiled it to native machine code, replacing the slower interpreted bytecode execution for future calls
CThe bytecode interpreter built up a lookup cache that maps each bytecode instruction to its result, eliminating recomputation
DThe garbage collector ran during early calls, freeing enough memory for the interpreter to run at full speed
Question 2 Multiple Choice

What is the primary design advantage of a stack-based VM bytecode architecture compared to a register-based one?

AStack-based VMs always execute programs faster because push/pop operations are cheaper than register reads
BStack-based bytecode is more compact and simpler to emit because instructions do not need to encode register operands — they implicitly operate on the top of the stack
CStack-based architectures are the only ones that support JIT compilation to native register-machine code
DRegister-based VMs cannot handle functions with more arguments than there are physical registers
Question 3 True / False

A pure bytecode interpreter typically runs programs 10–100× slower than native machine code because every instruction requires fetch-decode-dispatch overhead.

TTrue
FFalse
Question 4 True / False

Ahead-of-time compiled native code typically outperforms JIT-compiled bytecode because JIT compilation introduces unavoidable startup overhead.

TTrue
FFalse
Question 5 Short Answer

Explain why a JIT-compiled bytecode VM can sometimes produce better performance than statically compiled native code.

Think about your answer, then reveal below.