unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Vibhav Pant <vibhavp@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: emacs-devel@gnu.org
Subject: Re: feature/jit-improved-type-punning 9d2a54bd8d: src/comp.c: Use libgccjit's bitcast API for type coercion, when available.
Date: Sun, 02 Oct 2022 21:54:49 +0530	[thread overview]
Message-ID: <a09ac76c7189a43355256501db9036708d863f59.camel@gmail.com> (raw)
In-Reply-To: <83pmffiwko.fsf@gnu.org>

[-- Attachment #1: Type: text/plain, Size: 1781 bytes --]

On Wed, 2022-09-28 at 14:10 +0300, Eli Zaretskii wrote:
> > From: Po Lu <luangruo@yahoo.com>
> > Cc: Vibhav Pant <vibhavp@gmail.com>
> > Date: Wed, 28 Sep 2022 08:22:36 +0800
> > 
> > BTW, I don't see any code that loads this function dynamically on
> > MS
> > Windows.  Isn't that needed?
> 
> They were present in the patch that was posted.
> 
> FWIW, I'd like to see some rationale for these changes.  Perhaps
> libgccjit experts would see it immediately without any explanations,
> but I'm not such an expert.  TIA.

Type coercion in earlier versions of libgccjit was quite limited, as it
only supported casting between pointer types and integers <->
booleans/floats. Because working with lisp tagged pointers involved
converting from a Lisp_Object (which is usually a Lisp_X*) to an
integer, comp_t contained a union {uintptr_t; void *} which we would
use to emit two (cast_ptr_to_int, cast_int_to_ptr) functions before
JITting Lisp code, which would in turn initialize a union with the
input parameter, and return the required field. Combined with a 15 x 15
lookup table for every type used while compiling Lisp, all type casting
would therefore consist of emitting a call to one of these functions.

This branch uses libgccjit's new API for bitcasting between types,
which lets us skip emitting this good chunk of helper code as part of
the JIT process. Working with/extracting Lisp_Object tags in JITed code
is semantically the equivalent of a simple reinterpret_cast operation,
potentially improving optimization (although I imagine almost all calls
to these helper functions are inlined, unless native-comp-speed is 0).

Best,
Vibhav

-- 
Vibhav Pant
vibhavp@gmail.com

GPG: 7ED1 D48C 513C A024 BE3A 785F E3FB 28CB 6AB5 9598


[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

  reply	other threads:[~2022-10-02 16:24 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <166430063807.1861.17209317756638644499@vcs2.savannah.gnu.org>
     [not found] ` <20220927174358.8443FC00A6E@vcs2.savannah.gnu.org>
2022-09-28  0:22   ` feature/jit-improved-type-punning 9d2a54bd8d: src/comp.c: Use libgccjit's bitcast API for type coercion, when available Po Lu
2022-09-28 11:10     ` Eli Zaretskii
2022-10-02 16:24       ` Vibhav Pant [this message]
2022-10-04 18:44       ` Andrea Corallo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a09ac76c7189a43355256501db9036708d863f59.camel@gmail.com \
    --to=vibhavp@gmail.com \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).