develooper Front page | perl.perl5.porters | Postings from August 2011

[perl #97942] [PATCH] Add -DO option to disable optimizations and disable constant folding and the peephole optimizer when used.

Thread Previous
From:
Gerard Goossen
Date:
August 28, 2011 07:49
Subject:
[perl #97942] [PATCH] Add -DO option to disable optimizations and disable constant folding and the peephole optimizer when used.
Message ID:
rt-3.6.HEAD-31297-1314542928-150.97942-75-0@perl.org
# New Ticket Created by  Gerard Goossen 
# Please include the string:  [perl #97942]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org:443/rt3/Ticket/Display.html?id=97942 >



This is a bug report for perl from gerard@ggoossen.net,
generated with the help of perlbug 1.39 running under perl 5.15.2.

>From aa47563c38380baa2e72acca68124d8b796a4b9e Mon Sep 17 00:00:00 2001
From: Gerard Goossen <gerard@ggoossen.net>
Date: Sat, 27 Aug 2011 16:48:38 +0200
Subject: [PATCH] Add -DO option to disable optimizations and disable constant
 folding and the peephole optimizer when used.

Running the tests with PERL5OPT_TEST=-DOq reveals the following
problems:
- overloaded <> causes strange error
- deref type detection in derefed lvalue subs goes wrong.
- constant expressions produce modifiable temporaries instead of
  read-only constants
- for (revert @a) does no longer alias the elements of @a
- warnings about uninitialized values miss some variable names
- limits $[ assignments which are possible
- problem with line numbers in coresubs errors
---
 op.c            |    4 ++++
 perl.c          |    5 +++--
 perl.h          |    8 +++++++-
 pod/perlrun.pod |    1 +
 4 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/op.c b/op.c
index 73dccf8..c292b7b 100644
--- a/op.c
+++ b/op.c
@@ -2948,6 +2948,8 @@ S_fold_constants(pTHX_ register OP *o)
 	break;
     }
 
+    DEBUG_O( goto nope );
+
     if (PL_parser && PL_parser->error_count)
 	goto nope;		/* Don't try to run w/ errors */
 
@@ -9726,6 +9728,8 @@ Perl_rpeep(pTHX_ register OP *o)
     int defer_base = 0;
     int defer_ix = -1;
 
+    DEBUG_O( return );
+
     if (!o || o->op_opt)
 	return;
     ENTER;
diff --git a/perl.c b/perl.c
index 9ebb3d2..a5bbf41 100644
--- a/perl.c
+++ b/perl.c
@@ -2949,7 +2949,8 @@ Perl_get_debug_opts(pTHX_ const char **s, bool givehelp)
       "  A  Consistency checks on internal structures\n"
       "  q  quiet - currently only suppresses the 'EXECUTING' message\n"
       "  M  trace smart match resolution\n"
-      "  B  dump suBroutine definitions, including special Blocks like BEGIN\n",
+      "  B  dump suBroutine definitions, including special Blocks like BEGIN\n"
+      "  O  Disable optimizations\n",
       NULL
     };
     int i = 0;
@@ -2958,7 +2959,7 @@ Perl_get_debug_opts(pTHX_ const char **s, bool givehelp)
 
     if (isALPHA(**s)) {
 	/* if adding extra options, remember to update DEBUG_MASK */
-	static const char debopts[] = "psltocPmfrxuUHXDSTRJvCAqMB";
+	static const char debopts[] = "psltocPmfrxuUHXDSTRJvCAqMBO";
 
 	for (; isALNUM(**s); (*s)++) {
 	    const char * const d = strchr(debopts,**s);
diff --git a/perl.h b/perl.h
index 30bee51..86e0b96 100644
--- a/perl.h
+++ b/perl.h
@@ -3675,7 +3675,8 @@ Gid_t getegid (void);
 #define DEBUG_q_FLAG		0x00800000 /*8388608 */
 #define DEBUG_M_FLAG		0x01000000 /*16777216*/
 #define DEBUG_B_FLAG		0x02000000 /*33554432*/
-#define DEBUG_MASK		0x03FEEFFF /* mask of all the standard flags */
+#define DEBUG_O_FLAG		0x04000000 /*67108864*/
+#define DEBUG_MASK		0x07FEEFFF /* mask of all the standard flags */
 
 #define DEBUG_DB_RECURSE_FLAG	0x40000000
 #define DEBUG_TOP_FLAG		0x80000000 /* XXX what's this for ??? Signal
@@ -3706,6 +3707,7 @@ Gid_t getegid (void);
 #  define DEBUG_q_TEST_ (PL_debug & DEBUG_q_FLAG)
 #  define DEBUG_M_TEST_ (PL_debug & DEBUG_M_FLAG)
 #  define DEBUG_B_TEST_ (PL_debug & DEBUG_B_FLAG)
+#  define DEBUG_O_TEST_ (PL_debug & DEBUG_O_FLAG)
 #  define DEBUG_Xv_TEST_ (DEBUG_X_TEST_ && DEBUG_v_TEST_)
 #  define DEBUG_Uv_TEST_ (DEBUG_U_TEST_ && DEBUG_v_TEST_)
 #  define DEBUG_Pv_TEST_ (DEBUG_P_TEST_ && DEBUG_v_TEST_)
@@ -3737,6 +3739,7 @@ Gid_t getegid (void);
 #  define DEBUG_q_TEST DEBUG_q_TEST_
 #  define DEBUG_M_TEST DEBUG_M_TEST_
 #  define DEBUG_B_TEST DEBUG_B_TEST_
+#  define DEBUG_O_TEST DEBUG_O_TEST_
 #  define DEBUG_Xv_TEST DEBUG_Xv_TEST_
 #  define DEBUG_Uv_TEST DEBUG_Uv_TEST_
 #  define DEBUG_Pv_TEST DEBUG_Pv_TEST_
@@ -3787,6 +3790,7 @@ Gid_t getegid (void);
 #  define DEBUG_q(a) DEBUG__(DEBUG_q_TEST, a)
 #  define DEBUG_M(a) DEBUG__(DEBUG_M_TEST, a)
 #  define DEBUG_B(a) DEBUG__(DEBUG_B_TEST, a)
+#  define DEBUG_O(a) DEBUG__(DEBUG_O_TEST, a)
 
 #else /* DEBUGGING */
 
@@ -3815,6 +3819,7 @@ Gid_t getegid (void);
 #  define DEBUG_q_TEST (0)
 #  define DEBUG_M_TEST (0)
 #  define DEBUG_B_TEST (0)
+#  define DEBUG_O_TEST (0)
 #  define DEBUG_Xv_TEST (0)
 #  define DEBUG_Uv_TEST (0)
 #  define DEBUG_Pv_TEST (0)
@@ -3845,6 +3850,7 @@ Gid_t getegid (void);
 #  define DEBUG_q(a)
 #  define DEBUG_M(a)
 #  define DEBUG_B(a)
+#  define DEBUG_O(a)
 #  define DEBUG_Xv(a)
 #  define DEBUG_Uv(a)
 #  define DEBUG_Pv(a)
diff --git a/pod/perlrun.pod b/pod/perlrun.pod
index 22f50cc..d257d71 100644
--- a/pod/perlrun.pod
+++ b/pod/perlrun.pod
@@ -412,6 +412,7 @@ B<-D14> is equivalent to B<-Dtls>):
  16777216  M  trace smart match resolution
  33554432  B  dump suBroutine definitions, including special Blocks
               like BEGIN
+ 67108864  O  Disable optimizations
 
 All these flags require B<-DDEBUGGING> when you compile the Perl
 executable (but see C<:opd> in L<Devel::Peek> or L<re/'debug' mode>
-- 
1.7.5.4

---
Flags:
    category=core
    severity=low
---
Site configuration information for perl 5.15.2:

Configured by gerard at Sun Aug 28 16:17:23 CEST 2011.

Summary of my perl5 (revision 5 version 15 subversion 2) configuration:
  Commit id: c0c395809b8aa0c7e04dcad158a717b895d61c51
  Platform:
    osname=linux, osvers=3.0.0-1-686-pae, archname=i686-linux-thread-multi
    uname='linux zeus 3.0.0-1-686-pae #1 smp sun jul 24 14:27:32 utc 2011 i686 gnulinux '
    config_args='-des -Dusethreads -Dnoextensions= -Doptimize=-O3 -g3 -DDEBUGGING -Dusedevel -Dprefix=/home/gerard/perl/inst/blead-codegen'
    hint=recommended, useposix=true, d_sigaction=define
    useithreads=define, usemultiplicity=define
    useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
    use64bitint=undef, use64bitall=undef, uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='cc', ccflags ='-D_REENTRANT -D_GNU_SOURCE -DDEBUGGING -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
    optimize='-O3 -g3',
    cppflags='-D_REENTRANT -D_GNU_SOURCE -DDEBUGGING -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include'
    ccversion='', gccversion='4.6.1', gccosandvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
    ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
    alignbytes=4, prototype=define
  Linker and Libraries:
    ld='cc', ldflags =' -fstack-protector -L/usr/local/lib'
    libpth=/usr/local/lib /lib /usr/lib /usr/lib/i386-linux-gnu /usr/lib64
    libs=-lnsl -ldb -ldl -lm -lcrypt -lutil -lpthread -lc
    perllibs=-lnsl -ldl -lm -lcrypt -lutil -lpthread -lc
    libc=, so=so, useshrplib=false, libperl=libperl.a
    gnulibc_version='2.13'
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E'
    cccdlflags='-fPIC', lddlflags='-shared -O3 -g3 -L/usr/local/lib -fstack-protector'

Locally applied patches:
    

---
@INC for perl 5.15.2:
    lib
    /home/gerard/perl/inst/blead-codegen/lib/site_perl/5.15.2/i686-linux-thread-multi
    /home/gerard/perl/inst/blead-codegen/lib/site_perl/5.15.2
    /home/gerard/perl/inst/blead-codegen/lib/5.15.2/i686-linux-thread-multi
    /home/gerard/perl/inst/blead-codegen/lib/5.15.2
    /home/gerard/perl/inst/blead-codegen/lib/site_perl
    .

---
Environment for perl 5.15.2:
    HOME=/home/gerard
    LANG=en_US.UTF-8
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/home/gerard/bin:/usr/local/bin:/usr/bin:/bin:/usr/games
    PERL_BADLANG (unset)
    SHELL=/bin/bash


Thread Previous


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