MIME-Version: | 1.0 |
X-Spam-Status: | No, score=-3.227 tagged_above=-99.9 required=10 tests=[AWL=-2.006, BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, SPF_NEUTRAL=0.779] autolearn=no |
X-Me-Proxy: | <xmx:5t6UXo0gvmSRiM_6emyC6U5VahZW6QP_msyYQYcQTaqnQBRy-520ag> <xmx:5t6UXmOMUtEWNV9NlxiKqLL9TcQhD0Nr_Qo0cEMDrEGHK_Kth4s42A> <xmx:5t6UXuVJy7OnTESgfCWACaEJm09vcFBw9-fomOCeiJlvNokNCtsCsQ> <xmx:5t6UXjQxJV2anVl6Ms1ulO2b-edvTugyGsxb-dI2twRlG1p99AFI6A> |
X-Cpan.org: | This message routed through the cpan.org mail forwarding service. Please use PAUSE pause.perl.org to configure your delivery settings. |
X-Spam-Flag: | NO |
Content-Type: | multipart/mixed; boundary="=-=-=" |
Message-ID: | <87k12jt5p7.fsf@wibble.ilmari.org> |
X-Virus-Scanned: | Debian amavisd-new at bestpractical.com |
X-Spam-Score: | -3.227 |
Received: | from localhost (localhost [127.0.0.1]) by hipster.bestpractical.com (Postfix) with ESMTP id EACD724026D for <cpan-bug+XS-Parse-Sublike@hipster.bestpractical.com>; Mon, 13 Apr 2020 18:01:27 -0400 (EDT) |
Received: | from hipster.bestpractical.com ([127.0.0.1]) by localhost (hipster.bestpractical.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id TU8CVK+sZZhA for <cpan-bug+XS-Parse-Sublike@hipster.bestpractical.com>; Mon, 13 Apr 2020 18:01:26 -0400 (EDT) |
Received: | from xx1.develooper.com (xx1.develooper.com [147.75.38.233]) by hipster.bestpractical.com (Postfix) with ESMTPS id 941222401C8 for <bug-XS-Parse-Sublike@rt.cpan.org>; Mon, 13 Apr 2020 18:01:26 -0400 (EDT) |
Received: | from localhost (xx1.develooper.com [127.0.0.1]) by localhost (Postfix) with ESMTP id D85037C1B3 for <bug-XS-Parse-Sublike@rt.cpan.org>; Mon, 13 Apr 2020 15:01:25 -0700 (PDT) |
Received: | from xx1.develooper.com (xx1.develooper.com [127.0.0.1]) by localhost (Postfix) with SMTP id 0039E7CF42 for <bug-XS-Parse-Sublike@rt.cpan.org>; Mon, 13 Apr 2020 15:01:21 -0700 (PDT) |
Received: | from out3-smtp.messagingengine.com (out3-smtp.messagingengine.com [66.111.4.27]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by xx1.develooper.com (Postfix) with ESMTPS id 9121D7C1B3 for <bug-XS-Parse-Sublike@rt.cpan.org>; Mon, 13 Apr 2020 15:01:21 -0700 (PDT) |
Received: | from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.nyi.internal (Postfix) with ESMTP id C9E755C0117 for <bug-XS-Parse-Sublike@rt.cpan.org>; Mon, 13 Apr 2020 17:51:34 -0400 (EDT) |
Received: | from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Mon, 13 Apr 2020 17:51:34 -0400 |
Received: | from wibble.ilmari.org (wibble.ilmari.org [46.43.15.252]) by mail.messagingengine.com (Postfix) with ESMTPA id 2F5F73280067 for <bug-XS-Parse-Sublike@rt.cpan.org>; Mon, 13 Apr 2020 17:51:34 -0400 (EDT) |
Authentication-Results: | hipster.bestpractical.com (amavisd-new); dkim=pass header.i=@ilmari.org |
Authentication-Results: | hipster.bestpractical.com (amavisd-new); dkim=pass header.i=@messagingengine.com |
Delivered-To: | cpan-bug+XS-Parse-Sublike@hipster.bestpractical.com |
User-Agent: | Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) |
Subject: | [PATCH] Build op trees that more closely resemble what core does |
Return-Path: | <ilmari@ilmari.org> |
X-Me-Sender: | <xms:5t6UXusRI1Lw7fHEBB8Z7D9d98WbDGrlyNz8DKW9hKHv_iT3ThVXPg> |
X-RT-Mail-Extension: | xs-parse-sublike |
X-Original-To: | cpan-bug+XS-Parse-Sublike@hipster.bestpractical.com |
Dkim-Signature: | v=1; a=rsa-sha256; c=relaxed/relaxed; d=ilmari.org; h= from:to:subject:date:message-id:mime-version:content-type; s= fm1; bh=h6LLIlCmGOOX0U/r2geWoo/xqPzjIyh7YbPsELj0C8U=; b=XOF1wTvV 9drL8tQoPlOxQFp98eMY0Tig7s84x9UhPpH1EtIqwaWEstnPab82+59L32wqfYeD KKV+uD/Rd6Ugvt9mAKlpvR/m/O4TR5lkgTBmxbSrqsFBjNNO/r2XPR4T7hVbPgE9 CRH3gMKjXuA9akRHrTaOtJVVXInLXi+XJKusxkAueO+SOGbSh4KICLHv6x/9d2nf 5dTXu3ufT4xpGyqLgJbY0Qlqr7rIpZFIVXD2wrIA4OBTMAgYLc79ESfsJB4l1P9C s41AoIUEG+MXovwDy4jbVlMcqh/eNyP4pAYzhds7Osh+W8o0yRGuI78tDu7RVnoL ZtDxKbM7854P9A== |
Dkim-Signature: | v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-type:date:from:message-id :mime-version:subject:to:x-me-proxy:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm2; bh=h6LLIlCmGOOX0U/r2geWoo/xqPzjI yh7YbPsELj0C8U=; b=RfC1Rm/K9Tr+Y1aVJ/cKcltjalZl74pLFcRDccXIxR3nL DvrA6VIOskjp2MhUlNX8RjpIGRtK0kOtunuLIkl4T8Tr8+1g6flMGud0HOHW6BwP Y7tzEJXE4sAvKzxo4hNIinKapfawh0BUwEAOfkNwUuWMalru3CVcvzUHh7/ji7kw x+iTRkk+0uXXySQnhmAspFfSI71dJhYU16CWRt9C2tTLSRXUb0b9NcRHRF1EbyQE DjC7V0Hrvovta+u8SZJ6Se8/uN4KIe3+f3RjCzbLgUh9T6qjL6I/cPhGj1OQ0/nH hghzQxlfgmKJprds2weEMDq10ni5xG+DMKlS8EbvA== |
X-PMX-Spam: | Gauge=IIIIIIII, Probability=8%, Report=' HTML_00_01 0.05, HTML_00_10 0.05, MIME_TEXT_ONLY_MP_MIXED 0.05, BODYTEXTP_SIZE_3000_LESS 0, BODY_SIZE_3000_3999 0, BODY_SIZE_5000_LESS 0, BODY_SIZE_7000_LESS 0, DKIM_SIGNATURE 0, KNOWN_MTA_TFX 0, NO_CTA_URI_FOUND 0, NO_URI_FOUND 0, NO_URI_HTTPS 0, SPF_PASS 0, SXL_IP_TFX_WM 0, __BODY_NO_MAILTO 0, __CT 0, __CTYPE_HAS_BOUNDARY 0, __CTYPE_MULTIPART 0, __CTYPE_MULTIPART_MIXED 0, __DKIM_ALIGNS_2 0, __FROM_UTF_Q 0, __HAS_ATTACHMENT 0, __HAS_ATTACHMENT1 0, __HAS_FROM 0, __HAS_MSGID 0, __MIME_TEXT_ONLY 0, __MIME_TEXT_P 0, __MIME_TEXT_P1 0, __MIME_TEXT_P2 0, __MIME_VERSION 0, __NO_HTML_TAG_RAW 0, __PHISH_SPEAR_SUBJ_PREDICATE 0, __SANE_MSGID 0, __SUBJ_ALPHA_END 0, __TO_MALFORMED_2 0, __TO_NO_NAME 0, __URI_NO_MAILTO 0, __USER_AGENT 0, __blackholes.mail-abuse.org_ERROR , __zen.spamhaus.org_ERROR ' |
X-PMX-Perl: | Suspicious Attachment |
Date: | Mon, 13 Apr 2020 22:51:32 +0100 |
X-Spam-Level: | |
X-Greylist: | delayed 586 seconds by postgrey-1.34 at xx1.develooper.com; Mon, 13 Apr 2020 15:01:21 PDT |
X-PMX-Version: | 5.6.1.2065439, Antispam-Engine: 2.7.2.376379, Antispam-Data: 2019.11.28.70017 |
To: | bug-XS-Parse-Sublike@rt.cpan.org |
From: | ilmari@ilmari.org (Dagfinn Ilmari Mannsåker) |
X-Me-Proxy-Cause: | gggruggvucftvghtrhhoucdtuddrgeduhedrvdelgdduieegucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkfgggtgesmhdtreertd erjeenucfhrhhomhepihhlmhgrrhhisehilhhmrghrihdrohhrghculdffrghgfhhinhhn ucfklhhmrghrihcuofgrnhhnshonkhgvrhdmnecukfhppeegiedrgeefrdduhedrvdehvd enucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehilhhm rghrihesihhlmhgrrhhirdhorhhg |
X-RT-Interface: | |
Content-Length: | 0 |
content-type: | text/plain; charset="utf-8" |
X-RT-Original-Encoding: | ascii |
Content-Length: | 730 |
Hi Paul,
Out of curiosity I was looking at the B::Concise and B::Deparse output
for async subs, and noticed their signatures weren't recognised, and
that empty ones had a stub op that normal subs didn't.
After groveling around perly.y (and its history) for a bit, I came up
with the attached patch, which makes subs with signatures constructed by
'func' from t/func.xs have identical optrees to regular subs, both on
5.30 and blead.
- ilmari
--
- Twitter seems more influential [than blogs] in the 'gets reported in
the mainstream press' sense at least. - Matt McLeod
- That'd be because the content of a tweet is easier to condense down
to a mainstream media article. - Calle Dybedahl
Content-Type: | text/x-diff |
Content-Disposition: | inline; filename="0001-Build-op-trees-that-more-closely-resemble-what-core-.patch" |
Content-Length: | 2957 |
From 9a0a3615b966206ced303edeebaa185b6cbca80c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Dagfinn=20Ilmari=20Manns=C3=A5ker?= <ilmari@ilmari.org>
Date: Mon, 13 Apr 2020 22:19:08 +0100
Subject: [PATCH] Build op trees that more closely resemble what core does
This improves the deparseability of custom-built subs.
- Eliminate stub op if we have a signature and an empty body
- Append a nextstate at the end of the arg check blocks
- On 5.31.5 and later, wrap the whole arg-checking sequence in
a nulle-out ex-argcheck op.
---
hax/parse_subsignature.c.inc | 10 ++++++++--
lib/XS/Parse/Sublike.xs | 25 ++++++++++++++++++++++++-
2 files changed, 32 insertions(+), 3 deletions(-)
diff --git a/hax/parse_subsignature.c.inc b/hax/parse_subsignature.c.inc
index fa3274e..e42f2cb 100644
--- a/hax/parse_subsignature.c.inc
+++ b/hax/parse_subsignature.c.inc
@@ -205,10 +205,16 @@ endofelems:
OP *checkop = newUNOP_AUX(OP_ARGCHECK, 0, NULL, aux);
+ checkop = op_prepend_elem(OP_LINESEQ, newSTATEOP(0, NULL, NULL),
+ op_prepend_elem(OP_LINESEQ, checkop, elems));
+
+ /* a nextstate at the end handles context correctly for an empty
+ * sub body */
+ checkop = op_append_elem(OP_LINESEQ, checkop, newSTATEOP(0, NULL, NULL));
+
LEAVE;
- return op_prepend_elem(OP_LINESEQ, newSTATEOP(0, NULL, NULL),
- op_prepend_elem(OP_LINESEQ, checkop, elems));
+ return checkop;
}
#endif
diff --git a/lib/XS/Parse/Sublike.xs b/lib/XS/Parse/Sublike.xs
index 3d37ce7..40482cb 100644
--- a/lib/XS/Parse/Sublike.xs
+++ b/lib/XS/Parse/Sublike.xs
@@ -88,6 +88,21 @@ static int parse2(pTHX_ const struct XSParseSublikeHooks *hooksA, const struct X
sigop = op_prepend_elem(OP_LINESEQ, newSTATEOP(0, NULL, NULL),
newUNOP_AUX(OP_ARGCHECK, 0, NULL, aux));
+
+ /* a nextstate at the end handles context correctly for an empty
+ * sub body */
+ sigop = op_append_elem(OP_LINESEQ, sigop, newSTATEOP(0, NULL, NULL));
+
+#if HAVE_PERL_VERSION(5,31,5)
+ /* wrap the list of arg ops in a NULL aux op. This serves two
+ * purposes. First, it makes the arg list a separate subtree
+ * from the body of the sub, and secondly the null op may in
+ * future be upgraded to an OP_SIGNATURE when implemented. For
+ * now leave it as ex-argcheck
+ */
+ sigop = newUNOP_AUX(OP_ARGCHECK, 0, sigop, NULL);
+ op_null(sigop);
+#endif
}
else
#endif
@@ -111,8 +126,16 @@ static int parse2(pTHX_ const struct XSParseSublikeHooks *hooksA, const struct X
SvREFCNT_inc(PL_compcv);
#ifdef HAVE_PARSE_SUBSIGNATURE
- if(sigop)
+ if(sigop) {
+ /* parse_block() returns an empy block as a stub op.
+ * no need to keep that if we we have a signature.
+ */
+ if (ctx.body->op_type == OP_STUB) {
+ op_free(ctx.body);
+ ctx.body = NULL;
+ }
ctx.body = op_append_list(OP_LINESEQ, sigop, ctx.body);
+ }
#endif
if(PL_parser->error_count) {
--
2.20.1