From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Andrea Corallo Newsgroups: gmane.emacs.devel Subject: Re: Correct byte compiler error/warning positions. The solution! Date: Wed, 15 Dec 2021 09:33:45 +0000 Message-ID: References: <838rx4s224.fsf@gnu.org> <834k7ss172.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="16750"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: Eli Zaretskii , emacs-devel@gnu.org To: Alan Mackenzie Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Wed Dec 15 10:35:01 2021 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mxQgf-00047h-6n for ged-emacs-devel@m.gmane-mx.org; Wed, 15 Dec 2021 10:35:01 +0100 Original-Received: from localhost ([::1]:42818 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mxQgd-0006Gg-Nz for ged-emacs-devel@m.gmane-mx.org; Wed, 15 Dec 2021 04:34:59 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:52250) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mxQfb-0005RO-NP for emacs-devel@gnu.org; Wed, 15 Dec 2021 04:33:57 -0500 Original-Received: from mx.sdf.org ([205.166.94.24]:64568) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mxQfX-00066X-Sw; Wed, 15 Dec 2021 04:33:54 -0500 Original-Received: from ma.sdf.org (ma.sdf.org [205.166.94.33]) by mx.sdf.org (8.15.2/8.14.5) with ESMTPS id 1BF9XjMu020951 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256 bits) verified NO); Wed, 15 Dec 2021 09:33:46 GMT In-Reply-To: (Alan Mackenzie's message of "Tue, 14 Dec 2021 14:29:31 +0000") Received-SPF: pass client-ip=205.166.94.24; envelope-from=akrl@sdf.org; helo=mx.sdf.org X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:281997 Archived-At: Alan Mackenzie writes: > Hello, Andrea. > > On Sat, Dec 04, 2021 at 19:22:02 +0000, Andrea Corallo wrote: >> Alan Mackenzie writes: > > [ .... ] > >> Hi Alan, > >> > For extending emit_EQ, I've got the following embryonic scheme: > >> > 1/- Import the C variable symbols_with_pos_enabled: > >> > gcc_jit_lvalue *syms_with_pos_enabled = >> > gcc_jit_context_new_global >> > (comp.ctxt, NULL, >> > GCC_JIT_GLOBAL_IMPORTED, >> > gcc_jit_get_type (comp.ctxt, GCC_JIT_TYPE_BOOL), >> > "symbols_with_pos_enabled"); > >> Yep something like. PS We already have 'comp.bool_type' to use. > > [ .... ] > >> > Can you let me know what you think of this approach, please? That is, >> > before I put a lot of work into it. Is it broadly a good way of doing >> > the job? > >> I think it could be a good idea but I believe there's no need to use >> macros here, we could have just functions return rvalues no? > > Yes, no macros needed. :-) > >> I'm not a big fan of C macros and I try not to use them whem possible. > > [ .... ] > > I have a problem at the moment, which could be a big problem. How do I > refer to a Lisp variable from jit generated code? > > In particular, I need read-access to symbols-with-pos-enabled, or more > precisely to globals.f_symbols_with_pos_enabled. > > The gcc jit product seems to go out of its way to make such access as > difficult as possible. There is a way to get an integer out of "C space" > into the jit mechanism, but this cannot be cast to a pointer type, and > there is no similar mechanism to get a pointer out of C space. In fact, > gcc jit seems to restrict the language it supports to the equivalent of > Pascal, and makes pointer arithmetic impossible. > > I tried declaring "globals" as a global variable to be imported into jit > space, but the loader doesn't know about "globals". > > So, how can I get access to globals.f_symbols_with_pos_enabled? > > Thanks in advance! Hi Alan, I think the way should be done is that one declare in the .eln a global variable as a (bool *), say 'f_symbols_with_pos_enabled_ref'. Then during eln load time we set into that the correct address of 'globals.f_symbols_with_pos_enabled' so it can be used as '*f_symbols_with_pos_enabled_ref' by the generated code. We do something very similar for the Emacs global var 'current_thread'. In the eln we have a global variable named "current_thread_reloc" where we store the address of 'current_thread'. You can see we set this value during eln load in 'load_comp_unit'. Just grep CURRENT_THREAD_RELOC_SYM and you should find the relevant pieces of code you are interested in. Best Regards Andrea