Author image Vickenty Fesunov
and 1 contributors


GCCJIT::Context - object-oriented wrapper around libgccjit bindings.


    use GCCJIT qw/:constants/;
    use GCCJIT::Context;

    my $ctxt = GCCJIT::Context->acquire();


This package provides an object-oriented wrapper around libgccjit. In addition to shorter method names, these wrappers handle the memory management tasks remained from libgccjit (which already is very simple).

Shorter names

All libgccjit functions are available as methods on corresponding object references.

    gcc_jit_context_get_type($ctxt, ...)



Memory management

In libgccjit context objects own all allocated memory: developer needs only to release context to free all allocated memory, and until then all pointers produced by the library are valid.

When using this wrapper context and result objects will be freed automatically when last reference to it is gone as usual.

Other objects, like types, functions and blocks will become invalid once context owning them is destroyed. If any methods are called on a invalidated object, a perl exception is thrown.


This package contain only one method:


creates new top-level libgccjit context.


Online documentation for GCCJIT library:

GCCJIT project wiki page:


Vickenty Fesunov <>


Copyright (C) 2015 by Vickenty Fesunov.

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <>.