Master the fundamental concepts of jvm internals through this focused micro-challenge.
You have read the whole brief, and the concepts above stay free on every task. Writing and running the code needs a plan.
Three hints are available for this task, revealed one at a time inside the code workspace so you can struggle productively before seeing them.
Every task includes starter code, theory, and hidden tests so you can implement and verify locally in the browser.
How it works\`-XX:+PrintCompilation\` prints one line each time HotSpot compiles a method. Reading that log connects bytecode behavior to real JIT decisions.
Typical fields:
A line like \`1234 4% 3 com.example.Hot::loop (50 bytes)\` means compile ID 4, C1 compile, level 3, for method \`loop\` of 50 bytecode bytes.
Pair with \`-XX:CompileThreshold\` to see how invocation counts influence promotion. Profiling builds on the same counters.
For example, run a tight loop one million times, watch \`PrintCompilation\` fire, then compare wall time before and after the compile line appears.
Correlate compile log timestamps with wall-clock improvements on the same method. A C2 compile that inlines a callee can remove more dispatch than the root method's bytecode size suggests.
This exercise asks you to document JVM flags and sample \`PrintCompilation\` output. You will explain how to read compile tiers from log lines and tie them to the tiered compilation model.
You will use the same mental model here when reading production interpreter source later in the track. Sketch one concrete input on paper, predict the outcome, then confirm with code. That discipline catches logic errors early and makes debugging far faster when you extend the implementation in follow-on tasks.
Write an analyzer for HotSpot's -XX:+PrintCompilation log. Parse each line's timestamp, compile id, attribute flags, tier, method, OSR bci, size and status. Match the made not entrant and made zombie lines back to the compile they invalidate. Then report what happened to every method: its tier path, the code currently running, OSR compiles, invalidations and skipped compiles.
cLoading…
% (OSR), s (synchronized), ! (has exception handlers), b (blocking) and n (native wrapper), each followed by spaces. A flag character counts only when it is followed by a space or another flag.::.made not entrant / made zombie invalidates the latest earlier compile with the same id and OSR-ness (the line is not a new compile);COMPILE SKIPPED: REASON records a failed compile;(static) is ignored;line N: unknown suffix "TEXT", but the compile still counts.Blank lines are ignored. A line that doesn't fit prints line N: unparseable (lines are numbered from 1, counting blank lines). An invalidation of an id that was never compiled prints line N: made not entrant for unknown compile id X (or made zombie).
cLoading…
between T0 and T1 ms uses the first and last parsed line's time, including invalidation lines, and is omitted if there are none.none when there are no such compiles.strcmp):
native wrapper;tiers joins the tiers of its non-OSR, non-skipped compiles with -> (none if empty). Then running tier T (id I) for the last such compile that is still valid, or interpreted;, OSR T@BCI ... if any, , K invalidated if any, and [synchronized] / [has exception handlers] if the flags ever appeared.invalidated: id I METHOD tier T[ OSR] (not entrant|zombie) and skipped: id I METHOD tier T: REASON.K unparseable line(s), if any.Input:
cLoading…
Output:
cLoading…
Hidden tests cover a zombie after not-entrant, an invalidated OSR compile, tiers 1 and 2 with the blocking flag, an unknown id, unknown suffixes, out-of-range tiers, blank and malformed lines, and a trailing (static) suffix.