summaryrefslogtreecommitdiff
path: root/gcc/jit/docs/intro/tutorial04.rst
diff options
context:
space:
mode:
authordmalcolm <dmalcolm@138bc75d-0d04-0410-961f-82ee72b054a4>2014-12-01 17:40:03 +0000
committerdmalcolm <dmalcolm@138bc75d-0d04-0410-961f-82ee72b054a4>2014-12-01 17:40:03 +0000
commitdd6bd36536d87e00077591b0b15e080509fee731 (patch)
treef16b19ca2feb631733943e067ce5d2a3f52f9b23 /gcc/jit/docs/intro/tutorial04.rst
parentce67b8a6dc52db0eb2e120c0dedc2118683a82e5 (diff)
downloadgcc-dd6bd36536d87e00077591b0b15e080509fee731.tar.gz
PR jit/63854: Fix leaks in toyvm.c
gcc/jit/ChangeLog: PR jit/63854 * docs/examples/tut04-toyvm/toyvm.c (toyvm_compiled_function): New typedef. (toyvm_compiled_func) Rename to... (toyvm_compiled_code) ...this. (struct toyvm_compiled_function): New struct. (toyvm_function_compile): Return a toyvm_compiled_function * rather than a toyvm_compiled_func, so that the caller can fully clean things up. Free "funcname". (test_script): Update for change to toyvm_function_compile. Clean up the toyvm_compiled_function. (main): Likewise. (docs/intro/tutorial04.rst): Update to reflect the above changes, and to better spell out the lifetime of the compiled code. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@218234 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/jit/docs/intro/tutorial04.rst')
-rw-r--r--gcc/jit/docs/intro/tutorial04.rst11
1 files changed, 10 insertions, 1 deletions
diff --git a/gcc/jit/docs/intro/tutorial04.rst b/gcc/jit/docs/intro/tutorial04.rst
index cafdddb2aef..3aac6703b4c 100644
--- a/gcc/jit/docs/intro/tutorial04.rst
+++ b/gcc/jit/docs/intro/tutorial04.rst
@@ -101,6 +101,15 @@ then directly executed in-process:
:end-before: enum opcode
:language: c
+The lifetime of the code is tied to that of a :c:type:`gcc_jit_result *`.
+We'll handle this by bundling them up in a structure, so that we can
+clean them up together by calling :c:func:`gcc_jit_result_release`:
+
+ .. literalinclude:: ../examples/tut04-toyvm/toyvm.c
+ :start-after: /* A struct to hold the compilation results. */
+ :end-before: /* The main compilation hook. */
+ :language: c
+
Our compiler isn't very sophisticated; it takes the implementation of
each opcode above, and maps it directly to the operations supported by
the libgccjit API.
@@ -155,7 +164,7 @@ a block, implementing pushing and popping values:
.. literalinclude:: ../examples/tut04-toyvm/toyvm.c
:start-after: /* Stack manipulation. */
- :end-before: /* The main compilation hook. */
+ :end-before: /* A struct to hold the compilation results. */
:language: c
We will support single-stepping through the generated code in the