1 Client Code . Generated . libgccjit.so
3 . . JIT API . JIT "Frontend". (libbackend.a)
4 ....................................................................................
6 ──────────────────────────> . .
10 . . │ (error-checking).
12 . . ──> jit-recording.c
13 . . (record API calls)
16 <─────────────────────────── . .
19 V . . gcc_jit_context_compile .
20 ──────────────────────────> . .
21 . . │ start of recording::context::compile ()
23 . . │ start of playback::context::compile ()
24 . . │ (create tempdir) .
28 . . V───────────────────────> toplev::main (for now)
30 . . . . (various code)
33 . . . <───────────────── langhook:parse_file
35 . . . │ (jit_langhook_parse_file)
37 ..........................................│..................VVVVVVVVVVVVV...
38 . . . │ . No GC in here
39 . . . │ jit-playback.c
40 . . . │ (playback of API calls)
41 . . . ───────────────> creation of functions,
42 . . . . types, expression trees
43 . . . <──────────────── etc
44 . . . │(handle_locations: add locations to
45 . . . │ linemap and associate them with trees)
47 . . . │ . No GC in here
48 ..........................................│..................AAAAAAAAAAAAA...
49 . . . │ for each function
52 . . . ────────────> cgraph_finalize_function
56 . . . ──────────────────> (end of
57 . . . . │ langhook_parse_file)
59 . . . . (various code)
62 . . . <───────────────── langhook:write_globals
64 . . . │ (jit_langhook_write_globals)
67 . . . ──────────────────> finalize_compilation_unit
69 . . . . (the middle─end and backend)
71 . . <───────────────────────────── end of toplev::main
73 . . V───────────────────────> toplev::finalize
74 . . . . │ (purge internal state)
75 . . <──────────────────────── end of toplev::finalize
77 . . │ Convert assembler to DSO ("fake.so")
79 . . │ Load DSO (dlopen "fake.so")
83 . . │ end of playback::context::compile ()
85 . . │ playback::context dtor
87 . . │ Cleanup tempdir .
88 . . │ ("fake.so" is unlinked from the
89 . . │ filesystem at this point)
92 . . │ end of recording::context::compile ()
93 <─────────────────────────── . .
95 V . . gcc_jit_result_get_code .
96 ──────────────────────────> . .
97 . . │ dlsym () within loaded DSO
98 <─────────────────────────── . .
102 ───────────────> . . .
105 <─────────────── . . .
109 V . . gcc_jit_result_release .
110 ──────────────────────────> . .
111 . . │ dlclose () the loaded DSO
112 . . │ (code becomes uncallable)
113 <─────────────────────────── . .