unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Andrea Corallo <akrl@sdf.org>
To: "Nicolas Bértolo" <nicolasbertolo@gmail.com>
Cc: 41615@debbugs.gnu.org
Subject: bug#41615: [feature/native-comp] Dump prettier C code.
Date: Sun, 31 May 2020 11:37:50 +0000	[thread overview]
Message-ID: <xjfeer0l4hd.fsf@sdf.org> (raw)
In-Reply-To: <CAFnS-Omrf_FQykWJYSj9HoaVg0=_PvrAGGCZR5+RKwAB2ZSZUw@mail.gmail.com> ("Nicolas Bértolo"'s message of "Sat, 30 May 2020 19:20:13 -0300")

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

Nicolas Bértolo <nicolasbertolo@gmail.com> writes:

> I have reformatted the patches.
>
> Sorry for the inconveniences.
>
>
> From 0720ec7eb3dc552b018273cd68a5f7d6bb2fdb72 Mon Sep 17 00:00:00 2001
> From: =?UTF-8?q?Nicol=C3=A1s=20B=C3=A9rtolo?= <nicolasbertolo@gmail.com>
> Date: Wed, 20 May 2020 00:34:32 -0300
> Subject: [PATCH 1/2] Define static data using string literals.
>
> The purpose of this change is to dump prettier C files.
> This does not affect compilation times in my tests.
>
> * src/comp.c (emit_static_object): Define static objects using string
> literals, memcpy and bzero.
> ---
>  src/comp.c | 295 +++++++++++++++++++++++++++++++++++++++++++++++++----
>  1 file changed, 277 insertions(+), 18 deletions(-)

I like this considerably less :)

It introduces quite some complexity and the same advantage in
debuggability can be achieved with something like the attached 8 line
patch (untested).

Generally speaking I want to try to keep our back-end as simple as we
manage to.

On the subject of 'emit_static_object' the current situation is not
ideal.  But rather that working around the workaround I believe the right
thing to do is to improve GCC with a new entry point and keep the
current arrangement as a simple fallback.

I've already an half cooked GCC patch to allow for directly injecting
blobs, this should have more then one advantage.  Hopefully I manage to
start testing it today, I'm rather curious.

Andrea

-- 
akrl@sdf.org

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Emit-better-debug-comments-in-emit_static_object.patch --]
[-- Type: text/x-diff, Size: 1072 bytes --]

From 2154060e21c6d74d46cf274abaa716bec8fd2ac5 Mon Sep 17 00:00:00 2001
From: Andrea Corallo <akrl@sdf.org>
Date: Sun, 31 May 2020 12:22:46 +0100
Subject: [PATCH] * Emit better debug comments in emit_static_object

	* src/comp.c (emit_static_object): Do not truncate debug
	comments at the first NULL character.
---
 src/comp.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/comp.c b/src/comp.c
index d3bff1e4cf..179e97a551 100644
--- a/src/comp.c
+++ b/src/comp.c
@@ -2392,8 +2392,12 @@ emit_static_object (const char *name, Lisp_Object obj)
 				  0, NULL, 0);
   DECL_BLOCK (block, f);
 
-  /* NOTE this truncates if the data has some zero byte before termination.  */
-  gcc_jit_block_add_comment (block, NULL, p);
+  char *comment = memcpy (xmalloc (len), p, len);
+  for (ptrdiff_t i = 0; i < len - 1; i++)
+    if (!comment[i])
+      comment[i] = '\n';
+  gcc_jit_block_add_comment (block, NULL, comment);
+  xfree (comment);
 
   gcc_jit_lvalue *arr =
       gcc_jit_lvalue_access_field (data_struct, NULL, fields[1]);
-- 
2.17.1


  parent reply	other threads:[~2020-05-31 11:37 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-30 15:08 bug#41615: [feature/native-comp] Dump prettier C code Nicolas Bértolo
2020-05-30 22:20 ` Nicolas Bértolo
2020-05-31 10:45   ` Andrea Corallo
2020-05-31 15:42     ` Nicolas Bértolo
2020-05-31 11:37   ` Andrea Corallo [this message]
2020-05-31 15:48     ` Andrea Corallo
2020-05-31 15:54     ` Nicolas Bértolo
2020-05-31 16:57       ` Andrea Corallo
2020-05-31 17:26         ` Nicolas Bértolo
2020-05-31 18:11           ` Andrea Corallo
2020-05-31 19:38             ` Nicolas Bértolo
2020-05-31 20:00               ` Andrea Corallo
2020-05-31 20:18                 ` Andrea Corallo
2020-06-01  7:19               ` Andrea Corallo
2020-06-01 12:25                 ` Nicolas Bértolo
2020-06-01 20:28                   ` Andrea Corallo
2020-06-01 23:11                     ` Nicolas Bértolo
2020-06-04  9:52                       ` 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=xjfeer0l4hd.fsf@sdf.org \
    --to=akrl@sdf.org \
    --cc=41615@debbugs.gnu.org \
    --cc=nicolasbertolo@gmail.com \
    /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).