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.bugs Subject: bug#67005: 30.0.50; improve nadivce/comp/trampoline handling Date: Tue, 21 Nov 2023 06:07:27 -0500 Message-ID: References: <874jhv9921.fsf@sappc2.fritz.box> <875y24zrt1.fsf@sappc2.fritz.box> <87ttpmwuxi.fsf@sappc2.fritz.box> <877cmct4a1.fsf@sappc2.fritz.box> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="37183"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: Jens Schmidt , 67005@debbugs.gnu.org To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Nov 21 12:08:22 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1r5OcA-0009P2-EV for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 21 Nov 2023 12:08:22 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r5Obq-0004JU-Aq; Tue, 21 Nov 2023 06:08:02 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r5Obo-0004HO-5M for bug-gnu-emacs@gnu.org; Tue, 21 Nov 2023 06:08:00 -0500 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r5Obn-0000Oh-TU for bug-gnu-emacs@gnu.org; Tue, 21 Nov 2023 06:07:59 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1r5Obq-0004bb-60 for bug-gnu-emacs@gnu.org; Tue, 21 Nov 2023 06:08:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Andrea Corallo Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 21 Nov 2023 11:08:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 67005 X-GNU-PR-Package: emacs Original-Received: via spool by 67005-submit@debbugs.gnu.org id=B67005.170056486517681 (code B ref 67005); Tue, 21 Nov 2023 11:08:02 +0000 Original-Received: (at 67005) by debbugs.gnu.org; 21 Nov 2023 11:07:45 +0000 Original-Received: from localhost ([127.0.0.1]:55242 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r5ObY-0004b6-VV for submit@debbugs.gnu.org; Tue, 21 Nov 2023 06:07:45 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:34738) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r5ObU-0004ap-6s for 67005@debbugs.gnu.org; Tue, 21 Nov 2023 06:07:43 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r5ObK-0000LH-US; Tue, 21 Nov 2023 06:07:30 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:Date:References:In-Reply-To:Subject:To: From; bh=m3P4ZQrrQ23Fnb/xe+S0Cm52xiiX//ocO5Y905ggLKs=; b=emXV/1Ok0FNqAqfcP5lE JmV6G46kHF5ZxchDBflGd0pgzwQSY/sscnRuWH1U2aZs5zAwdXuwMfQKY4MRVaFMI2nxx83BritkF uBsa+JJj76PK4g51rDXuaCMXwqi1qE+NWpmIuUuoh5HDMce4hmW0pry1wRNqss+K3lXQ12sW1KAyR xikn/RIYWXw69ezltdJUDwd4yPX71OAa/bSWDkMqOfekXn/faBzeHIYaStqOzzDe+h6TeQwGx5zAV Drf6vdCC8s9rIFyN0hSR6uGiOaz9aw5q56IEDpVxt7NCJSGEytqzX/Inikah9u9aQlswxaWH4KC55 P3sKq8iaqSovHQ==; Original-Received: from acorallo by fencepost.gnu.org with local (Exim 4.90_1) (envelope-from ) id 1r5ObI-0002Ph-1R; Tue, 21 Nov 2023 06:07:30 -0500 In-Reply-To: (Stefan Monnier's message of "Mon, 20 Nov 2023 22:35:55 -0500") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:274708 Archived-At: Stefan Monnier writes: >> (defcustom native-comp-never-optimize-functions >> - '(eval >> - ;; The following two are mandatory for Emacs to be working >> - ;; correctly (see comment in `advice--add-function'). DO NOT >> - ;; REMOVE. >> - macroexpand rename-buffer) >> + ;; Do not include functions `macroexpand' or `rename-buffer' as >> + ;; default values here. Despite the previous "DO NOT REMOVE" >> + ;; warnings these are no longer needed. See also the comment on >> + ;; `advice--add-function' and bug#67005. FIXME: But do include >> + ;; `eval' as temporary (?) remedy for bug#67141. >> + '(eval) >> "Primitive functions to exclude from trampoline optimization. > > I'm not sure I like the idea of keeping the whole history in comments. > I suggest you try and trim it down to the part that seems likely > to reoccur, like "We used to list those functions that were advised > during preload but we now prefer to disallow them in `advice-add`". > >> In `addvice--add-function' I wanted to at least preserve the comment >> from my initial patch (see attachment to >> https://yhetil.org/emacs-bugs/874jhv9921.fsf@sappc2.fritz.box/). I >> think it might help historical research if for that removal there is >> something that a "git blame" could be hooked onto. > > `C-x v h` is your friend. It was weird in the fist place to put the > trampoline stuff there (e.g. it's specific to functions stored in symbols so > it would have been more logical to put it into `advice-add` instead), so > it doesn't seem very likely that this will re-occur. > >> <<>>" >> + ;; Actively disallow function advices (here) and advices in general >> + ;; on primitives (in `comp--install-trampoline') during bootstrap >> + ;; for the following reasons: >> + ;; - Advices in Emacs' core are generally considered bad style. >> + ;; - `Snarf-documentation' looses docstrings of advised dumped >> + ;; functions (bug#66032#20). >> + ;; - Native compilation does not generate trampolines for advised >> + ;; primitives while loadup.el executes. > > I don't think this last point is true/relevant, is it? > IIUC it would use a "normal funcall", which doesn't need a trampoline. > >> ;; TODO: >> ;; - record the advice location, to display in describe-function. >> - ;; - change all defadvice in lisp/**/*.el. >> - ;; - obsolete advice.el. >> + (when purify-flag >> + (error "Invalid pre-dump advice on %s" symbol)) >> (let* ((f (symbol-function symbol)) >> >> What do you think? > > Beside the comments about the comments, it's a +1 from me. I agree with all the comments made by Stefan, with those implemented +1 for me as well. Thanks Andrea