Add jit-tempdir.{c|h}
[official-gcc.git] / gcc / jit / ChangeLog
blob9a95c79fef2df4894a1008abe389f62457719d01
1 2014-12-09  David Malcolm  <dmalcolm@redhat.com>
3         PR jit/64206
4         * Make-lang.in (jit_OBJS): Add jit/jit-tempdir.o.
5         * jit-common.h (gcc::jit::tempdir): New forward decl.
6         * jit-playback.c: Include jit-tempdir.h.
7         (gcc::jit::playback::context::context): Initialize m_tempdir.
8         (gcc::jit::playback::context::~context): Move tempdir
9         cleanup to new file jit-tempdir.c
10         (make_tempdir_path_template): Move to new file jit-tempdir.c.
11         (gcc::jit::playback::context::compile): Move tempdir creation
12         to new tempdir object in new file jit-tempdir.c.
13         (gcc::jit::playback::context::make_fake_args): Get path from
14         tempdir object rather than from member data.
15         (gcc::jit::playback::context::convert_to_dso): Likewise.
16         (gcc::jit::playback::context::dlopen_built_dso): Likewise.
17         (gcc::jit::playback::context::dump_generated_code): Likewise.
18         (gcc::jit::playback::context::get_path_c_file): New function.
19         (gcc::jit::playback::context::get_path_s_file): New function.
20         (gcc::jit::playback::context::get_path_so_file): New function.
21         * jit-playback.h (gcc::jit::playback::context::get_path_c_file):
22         New function.
23         (gcc::jit::playback::context::get_path_s_file): New function.
24         (gcc::jit::playback::context::get_path_so_file): New function.
25         (gcc::jit::playback::context): Move fields "m_path_template",
26         "m_path_tempdir", "m_path_c_file", "m_path_s_file",
27         "m_path_so_file" to new jit::tempdir class; add field "m_tempdir".
28         * jit-tempdir.c: New file.
29         * jit-tempdir.h: New file.
31 2014-12-09  David Malcolm  <dmalcolm@redhat.com>
33         * jit-playback.c (gcc::jit::playback::context::compile): Acquire the
34         mutex here, immediately before using toplev, and release it here, on
35         each exit path after acquisition.
36         (jit_mutex): Move this variable here, from jit-recording.c.
37         (gcc::jit::playback::context::acquire_mutex): New function, based on
38         code in jit-recording.c.
39         (gcc::jit::playback::context::release_mutex): Likewise.
40         * jit-playback.h (gcc::jit::playback::context::acquire_mutex): New
41         function.
42         (gcc::jit::playback::context::release_mutex): New function.
43         * jit-recording.c (jit_mutex): Move this variable to jit-playback.c.
44         (gcc::jit::recording::context::compile): Move mutex-handling from
45         here into jit-playback.c's gcc::jit::playback::context::compile.
46         * notes.txt: Update to show the new locations of ACQUIRE_MUTEX
47         and RELEASE_MUTEX.
49 2014-12-09  David Malcolm  <dmalcolm@redhat.com>
51         * jit-playback.c (gcc::jit::playback::context::compile): Move the
52         dlopen code into...
53         (gcc::jit::playback::context::dlopen_built_dso): ...this new
54         function.
55         * jit-playback.h (gcc::jit::playback::context::dlopen_built_dso):
56         New function.
58 2014-12-09  David Malcolm  <dmalcolm@redhat.com>
60         PR jit/64166
61         * docs/topics/contexts.rst (Debugging): Add description of
62         gcc_jit_context_enable_dump.
63         * docs/_build/texinfo/libgccjit.texi: Regenerate.
64         * jit-playback.c: Include context.h.
65         (class auto_argvec): New class.
66         (auto_argvec::~auto_argvec): New function.
67         (gcc::jit::playback::context::compile): Convert fake_args to be
68         an auto_argvec, so that it can contain dynamically-allocated
69         strings.   Construct a vec of all requested dumps, and pass it to
70         make_fake_args.  Extract requested dumps between the calls to
71         toplev::main and toplev::finalize.
72         (gcc::jit::playback::context::make_fake_args): Convert param
73         "argvec" to be a vec <char *>, and gain a "requested_dumps"
74         param.  Convert to dynamically-allocated arg strings by converting
75         ADD_ARG to take a copy of the arg, and add ADD_ARG_TAKE_OWNERSHIP
76         for args that are already a copy.  Add args for all requested dumps.
77         (gcc::jit::playback::context::extract_any_requested_dumps): New
78         function.
79         (gcc::jit::playback::context::read_dump_file): New function.
80         * jit-playback.h (gcc::jit::playback::context::make_fake_args):
81         Convert param "argvec" to be a vec <char *>, and gain a
82         "requested_dumps" param.
83         (gcc::jit::playback::context::extract_any_requested_dumps): New
84         function.
85         (gcc::jit::playback::context::read_dump_file): New function.
86         * jit-recording.c (gcc::jit::recording::context::enable_dump): New
87         function.
88         (gcc::jit::recording::context::get_all_requested_dumps): New
89         function.
90         * jit-recording.h (gcc::jit::recording::requested_dump): New
91         struct.
92         (gcc::jit::recording::context::enable_dump): New function.
93         (gcc::jit::recording::context::get_all_requested_dumps): New
94         function.
95         (gcc::jit::recording::context::m_requested_dumps): New field.
96         * libgccjit.c (gcc_jit_context_enable_dump): New API entrypoint.
97         * libgccjit.h (gcc_jit_context_enable_dump): New API entrypoint.
98         * libgccjit.map (gcc_jit_context_enable_dump): New API entrypoint.
100 2014-12-08  David Malcolm  <dmalcolm@redhat.com>
102         * libgccjit++.h: Indent the forward declarations of the classes to
103         show the inheritance hierarchy.
105 2014-12-08  David Malcolm  <dmalcolm@redhat.com>
107         * notes.txt: Show the beginning and ending of
108         recording::context::compile vs playback::context::compile.  Show
109         the creation and unlinking of the tempdir.  Show toplev::finalize.
110         Move "RELEASE MUTEX" to the correct location.  Show
111         gcc_jit_result_release, and indicate where the
112         dlopen/dlsym/dlclose occur.
114 2014-12-01  David Malcolm  <dmalcolm@redhat.com>
116         * docs/examples/tut02-square.c (main): Release the context
117         earlier, to show that this is possible.  Update error-handling
118         to avoid a double-release of the context, and to avoid
119         releasing a NULL result.
120         * docs/intro/tutorial02.rst: Discuss gcc_jit_context_release.
121         * docs/topics/functions.rst (GCC_JIT_FUNCTION_EXPORTED): Emphasize
122         * docs/topics/results.rst (gcc_jit_result): Mention that this
123         controls the lifetimes of machine code functions.
124         (gcc_jit_result_get_code): Spell out the requirements for this
125         to succeed, and the lifetime of the result.
126         (gcc_jit_result_release): Mention that this invalidates any code
127         that was obtained from the result.
128         * docs/_build/texinfo/libgccjit.texi: Regenerate.
130 2014-12-01  David Malcolm  <dmalcolm@redhat.com>
132         PR jit/64018
133         * docs/intro/tutorial02.rst: Spell out lifetime of generated code.
134         Add description of error-handling, taken in part from...
135         * docs/topics/contexts.rst (Error-handling): Expand, and move some
136         content to tutorial02.rst.
137         * docs/_build/texinfo/libgccjit.texi: Regenerate.
139 2014-12-01  David Malcolm  <dmalcolm@redhat.com>
141         PR jit/64020
142         * docs/topics/types.rst (Standard types) Add new enum values to
143         the table of enum gcc_jit_types: GCC_JIT_TYPE_COMPLEX_FLOAT,
144         GCC_JIT_TYPE_COMPLEX_DOUBLE, GCC_JIT_TYPE_COMPLEX_LONG_DOUBLE.
145         Widen the left-hand column so that
146         GCC_JIT_TYPE_COMPLEX_LONG_DOUBLE will fit.
147         * docs/_build/texinfo/libgccjit.texi: Regenerate.
149         * jit-builtins.c: Include stringpool.h and jit-playback.h.
150         Move everything out of the gcc::jit::recording namespace into
151         just gcc::jit.
152         (struct builtin_data): Add fields "fnclass", "attr", and
153         "implicit_p".
154         (DEF_BUILTIN): Update macro so populate the new fields.
155         (builtins_manager::builtins_manager): Update for move out of
156         recording namespace.  Initialize the m_attributes array.
157         (builtins_manager::get_builtin_function): Likewise.
158         (builtins_manager::get_builtin_function_by_id): New function.
159         (builtins_manager::make_builtin_function): Update for move out of
160         recording namespace.  Add fix for PR jit/64020 by detecting
161         specific builtin ids and having them ensure that builtins for
162         other ids are created as necessary.
163         (builtins_manager::get_type): Update for move out of recording
164         namespace.
165         (builtins_manager::make_type): Likewise.  Add some missing
166         #undefs.
167         (builtins_manager::make_primitive_type): Update for move out of
168         recording namespace.  Implement the three BT_COMPLEX_ cases and
169         BT_DOUBLE_PTR.
170         (builtins_manager::make_fn_type): Update for move out of recording
171         namespace.
172         (builtins_manager::make_ptr_type): Likewise.
173         (builtins_manager::finish_playback): New function.
174         (builtins_manager::get_class): New function.
175         (builtins_manager::implicit_p): New function.
176         (builtins_manager::get_attrs_tree): Two new functions.
177         (builtins_manager::make_attrs_tree): New function.
179         * jit-builtins.h: Move everything out of the gcc::jit::recording
180         namespace into just gcc::jit.
181         (enum built_in_attribute): New.
182         (builtins_manager::builtins_manager): Update decl for namespace
183         change.
184         (builtins_manager::get_builtin_function): Likewise.
185         (builtins_manager::get_class): New.
186         (builtins_manager::implicit_p): New.
187         (builtins_manager::get_attrs_tree): Two new functions.
188         (builtins_manager::make_attrs_tree): New function.
189         (builtins_manager::finish_playback): New.
190         (builtins_manager::get_builtin_function_by_id): New.
191         (builtins_manager::make_builtin_function): Update decl for
192         namespace change.
193         (builtins_manager::get_type): Likewise.
194         (builtins_manager::make_type): Likewise.
195         (builtins_manager::make_primitive_type): Likewise.
196         (builtins_manager::make_fn_type): Likewise.
197         (builtins_manager::make_ptr_type): Likewise.
198         (builtins_manager): Likewise for fields.  Add new field
199         "m_attributes".
201         * jit-common.h (NUM_GCC_JIT_TYPES): Update.
202         (builtins_manager): Update forward decl to reflect namespace
203         change.
205         * jit-playback.c: Include attribs.h and jit-builtins.h.
206         (gcc::jit::playback::context::get_tree_node_for_type): Add cases
207         for the new COMPLEX_ types.
208         (gcc::jit::playback::context::new_function): If creating a
209         builtin, set the DECL_BUILT_IN_CLASS and attributes on the fndecl,
210         and call set_builtin_decl.
211         (gcc::jit::playback::context::replay): If we have a
212         builtins_manager, call its finish_playback method when we're done.
214         * jit-playback.h:
215         (gcc::jit::playback::context::get_builtins_manager): New function.
217         * jit-recording.c
218         (gcc::jit::recording::context::get_builtins_manager): New function.
219         (gcc::jit::recording::get_builtin_function): Use
220         get_builtins_manager, in case we're a child context.
221         (gcc::jit::recording::memento_of_get_type::dereference): Add the
222         COMPLEX_ types.
223         (gcc::jit::recording::memento_of_get_type::is_int): Likewise.
224         (gcc::jit::recording::memento_of_get_type::is_float): Likewise.
225         (gcc::jit::recording::memento_of_get_type::is_bool): Likewise.
226         (get_type_strings): Likewise.
228         * jit-recording.h
229         (gcc::jit::recording::context::get_builtins_manager): New.
231         * libgccjit.h (enum gcc_jit_types): Add
232         GCC_JIT_TYPE_COMPLEX_FLOAT, GCC_JIT_TYPE_COMPLEX_DOUBLE,
233         GCC_JIT_TYPE_COMPLEX_LONG_DOUBLE.
235 2014-12-01  David Malcolm  <dmalcolm@redhat.com>
237         * jit-builtins.c
238         (gcc::jit::recording::builtins_manager::get_builtin_function):
239         Check for NULL return from make_builtin_function.
240         (gcc::jit::recording::builtins_manager::make_builtin_function):
241         Check for NULL return from get_type.
243 2014-12-01  David Malcolm  <dmalcolm@redhat.com>
245         * jit-playback.c (gcc::jit::playback::context::compile): Move DSO
246         creation code into...
247         (gcc::jit::playback::context::convert_to_dso): New function.
248         * jit-playback.h (gcc::jit::playback::context::convert_to_dso):
249         New function.
251 2014-12-01  David Malcolm  <dmalcolm@redhat.com>
253         * jit-playback.c (gcc::jit::playback::context::compile): Use an
254         auto_vec<const char *> rather than a const char *[20] for the
255         top-level argv, and move the logic to build it to...
256         (gcc::jit::playback::context::make_fake_args): New function.
257         * jit-playback.h (gcc::jit::playback::context::make_fake_args):
258         New function.
260 2014-12-01  David Malcolm  <dmalcolm@redhat.com>
262         * Make-lang.in (jit_OBJS): Add jit/jit-result.o.
263         * jit-playback.c: Include new header jit-result.h.
264         (gcc::jit::result::result): Move to new file jit-result.c.
265         (gcc::jit::result::~result): Likewise.
266         (gcc::jit::playback::result): Likewise.
267         * jit-recording.h (class gcc::jit::result): Move to new
268         header jit-result.h.
269         * jit-result.c: New file, to contain...
270         (gcc::jit::result::result): Move here from jit-playback.c,
271         removing erroneous "playback" namespace from comment.
272         (gcc::jit::result::~result): Likewise.
273         (gcc::jit::playback::result): Likewise.
274         * jit-result.h: New file, to contain...
275         (class gcc::jit::result): Move from jit-recording.h.
276         * libgccjit.c: Include jit-result.h.
277         (gcc_jit_result_get_code): Update comment to reflect move
278         of implementation.
279         (gcc_jit_result_release): Likewise.
281 2014-12-01  David Malcolm  <dmalcolm@redhat.com>
283         PR jit/63854
284         * docs/examples/tut04-toyvm/toyvm.c
285         (toyvm_compiled_function): New typedef.
286         (toyvm_compiled_func) Rename to...
287         (toyvm_compiled_code) ...this.
288         (struct toyvm_compiled_function): New struct.
289         (toyvm_function_compile): Return a toyvm_compiled_function *
290         rather than a toyvm_compiled_func, so that the caller can fully
291         clean things up.  Free "funcname".
292         (test_script): Update for change to toyvm_function_compile.
293         Clean up the toyvm_compiled_function.
294         (main): Likewise.
295         (docs/intro/tutorial04.rst): Update to reflect the above changes,
296         and to better spell out the lifetime of the compiled code.
298 2014-12-01  David Malcolm  <dmalcolm@redhat.com>
300         PR jit/63854
301         * jit-builtins.c
302         (gcc::jit::recording::builtins_manager::make_fn_type): Call the
303         context's new_function_type method, rather than directly creating
304         a function_type instance.
305         * jit-recording.c
306         (gcc::jit::recording::context::new_function_type): New method,
307         adapted from part of...
308         (gcc::jit::recording::context::new_function_ptr_type): ...this.
309         Update to call new_function_type.
310         * jit-recording.h
311         (gcc::jit::recording::context::new_function_type): New method.
313 2014-12-01  David Malcolm  <dmalcolm@redhat.com>
315         PR jit/63969
316         * jit-playback.c: Ensure that ctxt_progname is non-NULL.
318 2014-11-19  David Malcolm  <dmalcolm@redhat.com>
320         PR jit/63854
321         * jit-playback.c (gcc::jit::playback::compound_type::set_fields):
322         Convert param from const vec<playback::field *> & to
323         const auto_vec<playback::field *> *.
324         (gcc::jit::playback::context::new_function_type): Convert param
325         "param_types" from vec<type *> * to const auto_vec<type *> *.
326         (gcc::jit::playback::context::new_function): Convert param
327         "params" from vec<param *> * to const auto_vec<param *> *.
328         (gcc::jit::playback::context::build_call): Convert param "args"
329         from vec<rvalue *> to const auto_vec<rvalue *> *.
330         (gcc::jit::playback::context::new_call): Likewise.
331         (gcc::jit::playback::context::new_call_through_ptr): Likewise.
332         (wrapper_finalizer): New function.
333         (gcc::jit::playback::wrapper::operator new): Call the finalizer
334         variant of ggc_internal_cleared_alloc, supplying
335         wrapper_finalizer.
336         (gcc::jit::playback::function::finalizer): New.
337         (gcc::jit::playback::block::finalizer): New.
338         (gcc::jit::playback::source_file::finalizer): New.
339         (gcc::jit::playback::source_line::finalizer): New.
341         * jit-playback.h
342         (gcc::jit::playback::context::new_function_type): Convert param
343         "param_types" from vec<type *> * to const auto_vec<type *> *.
344         (gcc::jit::playback::context::new_function): Convert param
345         "params" from vec<param *> * to const auto_vec<param *> *.
346         (gcc::jit::playback::context::new_call): Convert param
347         "args" from vec<rvalue *> to const auto_vec<rvalue *> *.
348         (gcc::jit::playback::context::new_call_through_ptr): Likewise.
349         (gcc::jit::playback::context::build_call): Likewise.
350         (gcc::jit::playback::context): Convert fields "m_functions",
351         "m_source_files", "m_cached_locations" from vec to auto_vec.
352         (gcc::jit::playback::wrapper::finalizer): New virtual function.
353         (gcc::jit::playback::compound_type::set_fields): Convert param fro
354         const vec<playback::field *> & to
355         const auto_vec<playback::field *> *.
356         (gcc::jit::playback::function::finalizer): New.
357         (gcc::jit::playback::block::finalizer): New.
358         (gcc::jit::playback::source_file::finalizer): New.
359         (gcc::jit::playback::source_line::finalizer): New.
361         * jit-recording.c
362         (gcc::jit::recording::function_type::replay_into): Convert local
363         from a vec into an auto_vec.
364         (gcc::jit::recording::fields::replay_into): Likewise.
365         (gcc::jit::recording::function::replay_into): Likewise.
366         (gcc::jit::recording::call::replay_into): Likewise.
367         (gcc::jit::recording::call_through_ptr::replay_into): Likewise.
369         * jit-recording.h (gcc::jit::recording::context): Convert fields
370         "m_mementos", "m_compound_types", "m_functions" from vec<> to
371         auto_vec <>.
372         (gcc::jit::recording::function_type::get_param_types): Convert
373         return type from vec<type *> to const vec<type *> &.
374         (gcc::jit::recording::function_type): Convert field
375         "m_param_types" from a vec<> to an auto_vec<>.
376         (gcc::jit::recording::fields): Likewise for field "m_fields".
377         (gcc::jit::recording::function::get_params): Convert return type
378         from vec <param *> to const vec<param *> &.
379         (gcc::jit::recording::function): Convert fields "m_params",
380         "m_locals", "m_blocks" from vec<> to auto_vec<>.
381         (gcc::jit::recording::block): Likewise for field "m_statements".
382         vec<> to auto_vec<>.
383         (gcc::jit::recording::call): Likewise for field "m_args".
384         (gcc::jit::recording::call_through_ptr): Likewise.
386 2014-11-19  David Malcolm  <dmalcolm@redhat.com>
388         PR jit/63854
389         * jit-recording.c (recording::function::validate): Convert
390         "worklist" from vec<> to autovec<> to fix a leak.
392 2014-11-11  David Malcolm  <dmalcolm@redhat.com>
394         * ChangeLog.jit: New.
395         * ChangeLog: New.
396         * Make-lang.in: New.
397         * TODO.rst: New.
398         * config-lang.in: New.
399         * docs/Makefile: New.
400         * docs/_build/texinfo/Makefile: New.
401         * docs/_build/texinfo/factorial.png: New.
402         * docs/_build/texinfo/libgccjit.texi: New.
403         * docs/_build/texinfo/sum-of-squares.png: New.
404         * docs/conf.py: New.
405         * docs/examples/tut01-hello-world.c: New.
406         * docs/examples/tut02-square.c: New.
407         * docs/examples/tut03-sum-of-squares.c: New.
408         * docs/examples/tut04-toyvm/Makefile: New.
409         * docs/examples/tut04-toyvm/factorial.toy: New.
410         * docs/examples/tut04-toyvm/fibonacci.toy: New.
411         * docs/examples/tut04-toyvm/toyvm.c: New.
412         * docs/index.rst: New.
413         * docs/internals/index.rst: New.
414         * docs/intro/factorial.png: New.
415         * docs/intro/index.rst: New.
416         * docs/intro/sum-of-squares.png: New.
417         * docs/intro/tutorial01.rst: New.
418         * docs/intro/tutorial02.rst: New.
419         * docs/intro/tutorial03.rst: New.
420         * docs/intro/tutorial04.rst: New.
421         * docs/topics/contexts.rst: New.
422         * docs/topics/expressions.rst: New.
423         * docs/topics/functions.rst: New.
424         * docs/topics/index.rst: New.
425         * docs/topics/locations.rst: New.
426         * docs/topics/objects.rst: New.
427         * docs/topics/results.rst: New.
428         * docs/topics/types.rst: New.
429         * dummy-frontend.c: New.
430         * jit-builtins.c: New.
431         * jit-builtins.h: New.
432         * jit-common.h: New.
433         * jit-playback.c: New.
434         * jit-playback.h: New.
435         * jit-recording.c: New.
436         * jit-recording.h: New.
437         * libgccjit++.h: New.
438         * libgccjit.c: New.
439         * libgccjit.h: New.
440         * libgccjit.map: New.
441         * notes.txt: New.
443 2013-07-26  David Malcolm  <dmalcolm@redhat.com>
445         * Initial creation
447 Copyright (C) 2013-2014 Free Software Foundation, Inc.
449 Copying and distribution of this file, with or without modification,
450 are permitted in any medium without royalty provided the copyright
451 notice and this notice are preserved.