From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Lynn Winebarger Newsgroups: gmane.emacs.devel Subject: Re: Ideal performance of ELisp Date: Tue, 16 Aug 2022 12:46:25 -0400 Message-ID: References: <83mtceupbx.fsf@gnu.org> <83lerxvfnu.fsf@gnu.org> <838rnxvdcq.fsf@gnu.org> <83r11ptksn.fsf@gnu.org> <83a68dti6w.fsf@gnu.org> <874jykzvx9.fsf@yahoo.com> <83fsi4sttn.fsf@gnu.org> <838rnws5c7.fsf@gnu.org> <838rntocb8.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="33741"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Eli Zaretskii , Po Lu , Alan Mackenzie , emacs-devel , Yuan Fu To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue Aug 16 18:48:21 2022 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 1oNzjo-0008ZK-Qd for ged-emacs-devel@m.gmane-mx.org; Tue, 16 Aug 2022 18:48:20 +0200 Original-Received: from localhost ([::1]:40986 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oNzjk-0003Fp-VV for ged-emacs-devel@m.gmane-mx.org; Tue, 16 Aug 2022 12:48:16 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:54932) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oNziC-0002RK-Hi for emacs-devel@gnu.org; Tue, 16 Aug 2022 12:46:41 -0400 Original-Received: from mail-pf1-x42c.google.com ([2607:f8b0:4864:20::42c]:35534) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oNziA-0003KZ-6B; Tue, 16 Aug 2022 12:46:39 -0400 Original-Received: by mail-pf1-x42c.google.com with SMTP id p125so9813088pfp.2; Tue, 16 Aug 2022 09:46:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc; bh=2Ra5jTX/kwML8heOkcJX7IaSFH/kfrbYi4mS46MpmQI=; b=DQkgACeaZLMEJFDVoLkWuqpB7nw4UOtGqwmlgTmvF133CvoP8Oo8Ifm/pAAh9xRmB3 7/1TOlbaEYMvyWmd8odvtyg+2AVztibQhZVdXRfeuG6cpEJv7Yblaa5MxDhzV3FMal3g ORfOBwrfjcIYOnYLBgmaxywcUkRlySeWwAjzCVFokghPDSTZGbmpRINefteJhZWRTRaX mjFZx7vDgakLf5MONPzRUyv9baTVPwRZj0KozTuCTnSUZ87Q3hJanVuvXPZUpkGKt27S MTQxXhX5NY7zo0WNBX/+OgfQCgXdBQPPl+D6LiCCJ+MwQH/2L2Zt6PdF09yXDWxgLC5o tFMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc; bh=2Ra5jTX/kwML8heOkcJX7IaSFH/kfrbYi4mS46MpmQI=; b=FvJT3Q4lH/FJctOVlKwglr6LBSvWbsM9z5gmxZuLSGXOI3oFR60yhtxVLg1nwXJVHq LbU62ojcO5ZNX8A7Yi5/mWPJRKHPamk1SLFctbaXV/2Gth5K4jsZLduwQxS/1JiEW7A1 VNbcBiJeBf1PusplKV5MXozFhmV7qNV+qaxd7It2cyawYxMDg2gQiBCvb7NIDkEe5jyU /fug+nPW6OBIpTB3G8/yq1jjzkygLn9eOKFxUZt3ZED+eu3R1ga3o9bTRCGenPEby/7J 9RRvMOJ1aKrhVrfh9oC2YXDcCyKvUJDPFIG2C9V4Fl/pi7h5eJ5jnegFPXn2Sg0/SvG1 Blew== X-Gm-Message-State: ACgBeo1UR9TxHrNxT4OP0H8aZnPhb1R6jO3507tUKfdnvQ+cQuSFd1aJ /8QAiYLJ4NgAsDbImIwe8TmsrxpGs/4ILNXv9kQ= X-Google-Smtp-Source: AA6agR5Gq7orxMEBem83tH3SVeyhR/LsxgP+78m6X7rCDcPwyDF1ay57vD7fnmOnG/PJ08Wbtze66HNwzH7dLGir4ZE= X-Received: by 2002:a63:1342:0:b0:422:5e7a:2a8f with SMTP id 2-20020a631342000000b004225e7a2a8fmr16652214pgt.425.1660668396536; Tue, 16 Aug 2022 09:46:36 -0700 (PDT) In-Reply-To: Received-SPF: pass client-ip=2607:f8b0:4864:20::42c; envelope-from=owinebar@gmail.com; helo=mail-pf1-x42c.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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:293509 Archived-At: On Sat, Aug 13, 2022 at 10:56 AM Lynn Winebarger wrote= : > > On Sat, Aug 13, 2022, 10:07 AM Stefan Monnier = wrote: >> >> >> > Once the VM supports proper tail recursion, it's straightforward to >> >> > generate automata that never perform a function call, at least not = as part >> >> > of the recognizer. >> >> >> >> It was straightforward beforehand as well (using a `while` loop inste= ad >> >> of recursion). And if you do use recursion, then it's not very much >> >> simpler with `lexical-binding` than without because you still have to >> >> take into account the possibility that the function gets redefined >> >> during your recursion :-( >> >> >> > >> > I think you're mistaking self-tail recursion for tail recursion. >> >> No, I was simply restricting the discussion to the case you mention of >> "generat[ing an] automata", in which case you usually have enough >> control over the generated code to use a `while` loop if desired. > > > It's true you can avoid funcall dispatch overhead that way, but unless I'= m missing something you are stuck with the overhead of the while loop plus = whatever conditional branching mechanism you would use for dispatching to a= state label, as opposed to simply jumping to the contents of a register. = I'm not 100% on whether there's an ELisp construct that the byte compiler c= an turn into byte code that uses a table of labels for conditional dispatch= the way a switch statement may be implemented in C. > BTW, I was being serious - if there's a way to write a simple jump to do case-dispatching for that trampolining while loop, I'd definitely look at making semantic produce such automata so the native compiler, in particular, could optimize the result properly. Plug for inline LAP versus "C-like DSL" - At least then you could generate bytecode that jumps to calculated offsets, by constructing a hash table of symbol values to byte-code labels only available at assembly time? Lynn