This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
make RC-stack-aware: unwrap pp_not()
authorDavid Mitchell <davem@iabyn.com>
Mon, 2 Jan 2023 18:23:03 +0000 (18:23 +0000)
committerDavid Mitchell <davem@iabyn.com>
Wed, 16 Aug 2023 16:16:59 +0000 (17:16 +0100)
Remove the temporary wrapper from pp_not() and update it to directly
work in a refcounted-stack environment.

This is mainly a proof of concept to check that rpp_tryAMAGICun_MG() and
its underlying Perl_try_amagic_un() work ok.

pp.c

diff --git a/pp.c b/pp.c
index 9daab3b..2650183 100644 (file)
--- a/pp.c
+++ b/pp.c
@@ -2592,14 +2592,11 @@ PP_wrapped(pp_negate, 1, 0)
     return NORMAL;
 }
 
-PP_wrapped(pp_not, 2, 0)
+PP(pp_not)
 {
-    dSP;
-    SV *sv;
-
-    tryAMAGICun_MG(not_amg, 0);
-    sv = *PL_stack_sp;
-    *PL_stack_sp = boolSV(!SvTRUE_nomg_NN(sv));
+    if (rpp_try_AMAGIC_1(not_amg, 0))
+        return NORMAL;
+    rpp_replace_1_1(boolSV(!SvTRUE_nomg_NN(*PL_stack_sp)));
     return NORMAL;
 }