From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 47495 invoked by alias); 13 Oct 2015 13:32:12 -0000 Mailing-List: contact jit-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Subscribe: Sender: jit-owner@gcc.gnu.org Received: (qmail 47423 invoked by uid 89); 13 Oct 2015 13:32:12 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Checked: by ClamAV 0.98.7 on sourceware.org X-Virus-Found: No X-Spam-SWARE-Status: No, score=0.4 required=5.0 tests=AWL,BAYES_50,KAM_LAZY_DOMAIN_SECURITY,T_RP_MATCHES_RCVD autolearn=no version=3.3.2 X-Spam-Status: No, score=0.4 required=5.0 tests=AWL,BAYES_50,KAM_LAZY_DOMAIN_SECURITY,T_RP_MATCHES_RCVD autolearn=no version=3.3.2 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on sourceware.org X-Spam-Level: X-HELO: ovh.starynkevitch.net Date: Thu, 01 Jan 2015 00:00:00 -0000 From: Basile Starynkevitch To: jit@gcc.gnu.org Subject: client data for GCCJIT objects? Message-ID: <20151013133204.GA7100@ovh.starynkevitch.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-SW-Source: 2015-q4/txt/msg00002.txt.bz2 Hello All, It would be nice if some client data could be attached to each GCCJIT object. Or at least, within libgccjit++.h, to be able to use gccjit::object as some key either for std::map or for std::unordered_map (so either an ordered relation on their internal address, or an equality test with some hashing). Then a user compilation context could associate application data with GCCJIT objects. This is quite useful: an application JIT translating some bytecode or AST would keep an association between GCCJIT objects and application values (think of s-exprs for GUILE) and create GCCJIT objects only if none is associated to some application value... In C, on could dream of a function giving, from some GCCJIT object, its unique index in the "recording" class. // get the object of some given index in the context gcc_jit_object* gcc_jit_get_object_from_index(gcc_jit_context* ctx, unsigned index); // get the positive index of some object, or 0 if NULL is given unsigned gcc_jit_object_index(gcc_jit_object*obj); I would be very happy to have dynamic upcasts, e.g. // check that an object is a field, otherwise return NULL gcc_jit_field* gcc_jit_object_to_field(gcc_jit_object* obj); Comments are welcome. I could supply a patch if explained how to do such things... Regards. -- Basile STARYNKEVITCH http://starynkevitch.net/Basile/ email: basilestarynkevitchnet mobile: +33 6 8501 2359 8, rue de la Faiencerie, 92340 Bourg La Reine, France *** opinions {are only mine, sont seulement les miennes} ***