develooper Front page | perl.perl5.changes | Postings from March 2018

[perl.git] branch blead updated. v5.27.9-122-g814eedc877

From:
Tony Cook
Date:
March 7, 2018 03:23
Subject:
[perl.git] branch blead updated. v5.27.9-122-g814eedc877
Message ID:
E1etPfz-0002jm-Ub@git.dc.perl.space
In perl.git, the branch blead has been updated

<https://perl5.git.perl.org/perl.git/commitdiff/814eedc877a5aa1dbba0047735733e9491aa94a4?hp=4d169ec9e2a0eb93170198ffad69a892f91dd199>

- Log -----------------------------------------------------------------
commit 814eedc877a5aa1dbba0047735733e9491aa94a4
Author: Daniel Dragan <bulk88@hotmail.com>
Date:   Thu Mar 1 16:41:59 2018 -0500

    rmv/de-dup static const char array "strings"
    
    MSVC due to a bug doesn't merge identicals between .o'es or discard these
    vars and their contents.
    
    MEM_WRAP_CHECK_2 has never been used outside of core according to cpan grep
    MEM_WRAP_CHECK_2 was removed on the "have PERL_MALLOC_WRAP" branch in
    commit fabdb6c0879 "pre-likely cleanup" without explination, probably bc
    it was unused. But MEM_WRAP_CHECK_2 was still left on the "no
    PERL_MALLOC_WRAP" branch, so remove it from the "no" side for tidyness
    since it was a mistake to leave it there if it was removed from the "yes"
    side of the #ifdef.
    
    Add MEM_WRAP_CHECK_s API, letter "s" means argument is string or static.
    This lets us get rid of the "%s" argument passed to Perl_croak_nocontext at
    a couple call sites since we fully control the next and only argument and
    its guaranteed to be a string literal. This allows merging of 2
    "Out of memory during array extend" c strings by linker now.
    
    Also change the 2 op.h messages into macros which become string literals
    at their call sites instead of "read char * from a global char **" which
    was going on before.
    
    VC 2003 32b perl527.dll section size before
      .text name
       DE503 virtual size
      .rdata name
       4B621 virtual size
    
    after
      .text name
       DE503 virtual size
      .rdata name
       4B5D1 virtual size

-----------------------------------------------------------------------

Summary of changes:
 av.c     | 12 ++----------
 doop.c   |  6 +++---
 handy.h  |  7 ++++++-
 op.h     | 14 +++++++-------
 pp.c     |  2 +-
 pp_hot.c |  4 +---
 6 files changed, 20 insertions(+), 25 deletions(-)

diff --git a/av.c b/av.c
index f6ffea627b..918844c376 100644
--- a/av.c
+++ b/av.c
@@ -140,17 +140,13 @@ Perl_av_extend_guts(pTHX_ AV *av, SSize_t key, SSize_t *maxp, SV ***allocp,
                             ? SSize_t_MAX : key + newmax;
 	      resize:
 		{
-#ifdef PERL_MALLOC_WRAP /* Duplicated in pp_hot.c */
-		    static const char oom_array_extend[] =
-			"Out of memory during array extend";
-#endif
                     /* it should really be newmax+1 here, but if newmax
                      * happens to equal SSize_t_MAX, then newmax+1 is
                      * undefined. This means technically we croak one
                      * index lower than we should in theory; in practice
                      * its unlikely the system has SSize_t_MAX/sizeof(SV*)
                      * bytes to spare! */
-		    MEM_WRAP_CHECK_1(newmax, SV*, oom_array_extend);
+		    MEM_WRAP_CHECK_s(newmax, SV*, "Out of memory during array extend");
 		}
 #ifdef STRESS_REALLOC
 		{
@@ -176,12 +172,8 @@ Perl_av_extend_guts(pTHX_ AV *av, SSize_t key, SSize_t *maxp, SV ***allocp,
 	    else {
 		newmax = key < 3 ? 3 : key;
 		{
-#ifdef PERL_MALLOC_WRAP /* Duplicated in pp_hot.c */
-		    static const char oom_array_extend[] =
-			"Out of memory during array extend";
-#endif
                     /* see comment above about newmax+1*/
-		    MEM_WRAP_CHECK_1(newmax, SV*, oom_array_extend);
+		    MEM_WRAP_CHECK_s(newmax, SV*, "Out of memory during array extend");
 		}
 		Newx(*allocp, newmax+1, SV*);
 		ary = *allocp + 1;
diff --git a/doop.c b/doop.c
index 54c7bb6ee4..54e35f10a6 100644
--- a/doop.c
+++ b/doop.c
@@ -1098,19 +1098,19 @@ Perl_do_vop(pTHX_ I32 optype, SV *sv, SV *left, SV *right)
     if (left_utf8 || right_utf8) {
         if (left_utf8) {
             if (right_utf8 || rightlen > leftlen) {
-                Perl_croak(aTHX_ fatal_above_ff_msg, PL_op_desc[optype]);
+                Perl_croak(aTHX_ FATAL_ABOVE_FF_MSG, PL_op_desc[optype]);
             }
             len = rightlen;
         }
         else if (right_utf8) {
             if (leftlen > rightlen) {
-                Perl_croak(aTHX_ fatal_above_ff_msg, PL_op_desc[optype]);
+                Perl_croak(aTHX_ FATAL_ABOVE_FF_MSG, PL_op_desc[optype]);
             }
             len = leftlen;
         }
 
         Perl_ck_warner_d(aTHX_ packWARN(WARN_DEPRECATED),
-                               deprecated_above_ff_msg, PL_op_desc[optype]);
+                               DEPRECATED_ABOVE_FF_MSG, PL_op_desc[optype]);
     }
     else {  /* Neither is UTF-8 */
         len = MIN(leftlen, rightlen);
diff --git a/handy.h b/handy.h
index 7fe1cf6caa..f5c07fde2d 100644
--- a/handy.h
+++ b/handy.h
@@ -2317,6 +2317,11 @@ PoisonWith(0xEF) for catching access to freed memory.
 	(void)(UNLIKELY(_MEM_WRAP_WILL_WRAP(n,t)) \
 	&& (Perl_croak_nocontext("%s",(a)),0))
 
+/* "a" arg must be a string literal */
+#  define MEM_WRAP_CHECK_s(n,t,a) \
+	(void)(UNLIKELY(_MEM_WRAP_WILL_WRAP(n,t)) \
+	&& (Perl_croak_nocontext("" a ""),0))
+
 #define MEM_WRAP_CHECK_(n,t) MEM_WRAP_CHECK(n,t),
 
 #define PERL_STRLEN_ROUNDUP(n) ((void)(((n) > MEM_SIZE_MAX - 2 * PERL_STRLEN_ROUNDUP_QUANTUM) ? (croak_memory_wrap(),0) : 0), _PERL_STRLEN_ROUNDUP_UNCHECKED(n))
@@ -2324,7 +2329,7 @@ PoisonWith(0xEF) for catching access to freed memory.
 
 #define MEM_WRAP_CHECK(n,t)
 #define MEM_WRAP_CHECK_1(n,t,a)
-#define MEM_WRAP_CHECK_2(n,t,a,b)
+#define MEM_WRAP_CHECK_s(n,t,a)
 #define MEM_WRAP_CHECK_(n,t)
 
 #define PERL_STRLEN_ROUNDUP(n) _PERL_STRLEN_ROUNDUP_UNCHECKED(n)
diff --git a/op.h b/op.h
index fc66e14a76..bfdebaa961 100644
--- a/op.h
+++ b/op.h
@@ -1109,13 +1109,13 @@ C<sib> is non-null. For a higher-level interface, see C<L</op_sibling_splice>>.
 #define MDEREF_SHIFT           7
 
 #if defined(PERL_IN_DOOP_C) || defined(PERL_IN_PP_C)
-static const char * const fatal_above_ff_msg
-    = "Use of strings with code points over 0xFF as arguments to "
-      "%s operator is not allowed";
-static const char * const deprecated_above_ff_msg
-    = "Use of strings with code points over 0xFF as arguments to "
-      "%s operator is deprecated. This will be a fatal error in "
-      "Perl 5.32";
+#   define FATAL_ABOVE_FF_MSG                                       \
+      "Use of strings with code points over 0xFF as arguments to "  \
+      "%s operator is not allowed"
+#  define DEPRECATED_ABOVE_FF_MSG                                   \
+      "Use of strings with code points over 0xFF as arguments to "  \
+      "%s operator is deprecated. This will be a fatal error in "   \
+      "Perl 5.32"
 #endif
 
 
diff --git a/pp.c b/pp.c
index 9a9ad3e1f8..5524131658 100644
--- a/pp.c
+++ b/pp.c
@@ -2530,7 +2530,7 @@ S_scomplement(pTHX_ SV *targ, SV *sv)
 
 	if (SvUTF8(TARG)) {
             if (len && ! utf8_to_bytes(tmps, &len)) {
-                Perl_croak(aTHX_ fatal_above_ff_msg, PL_op_desc[PL_op->op_type]);
+                Perl_croak(aTHX_ FATAL_ABOVE_FF_MSG, PL_op_desc[PL_op->op_type]);
             }
             SvCUR(TARG) = len;
             SvUTF8_off(TARG);
diff --git a/pp_hot.c b/pp_hot.c
index 1cdc90aa27..ae81e940df 100644
--- a/pp_hot.c
+++ b/pp_hot.c
@@ -5320,9 +5320,7 @@ PP(pp_aelem)
 	 else if (SvNOK(elemsv))
 	      elem = (IV)SvNV(elemsv);
 	 if (elem > 0) {
-	      static const char oom_array_extend[] =
-		"Out of memory during array extend"; /* Duplicated in av.c */
-	      MEM_WRAP_CHECK_1(elem,SV*,oom_array_extend);
+	      MEM_WRAP_CHECK_s(elem,SV*,"Out of memory during array extend");
 	 }
 #endif
 	if (!svp || !*svp) {

-- 
Perl5 Master Repository



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About