]> granicus.if.org Git - python/commitdiff
Issue #9203: Computed gotos are now enabled by default on supported
authorAntoine Pitrou <solipsis@pitrou.net>
Fri, 13 Aug 2010 21:15:58 +0000 (21:15 +0000)
committerAntoine Pitrou <solipsis@pitrou.net>
Fri, 13 Aug 2010 21:15:58 +0000 (21:15 +0000)
compilers (which are detected by the configure script).  They can still
be disable selectively by specifying --without-computed-gotos.

Misc/NEWS
Python/ceval.c
configure
configure.in
pyconfig.h.in

index d7580fc79cf4edfe1724c7de50d23495e9f1fc84..28e03140dffc33d52b9745c307ae5a1f484803ec 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -12,6 +12,10 @@ What's New in Python 3.2 Alpha 2?
 Core and Builtins
 -----------------
 
+- Issue #9203: Computed gotos are now enabled by default on supported
+  compilers (which are detected by the configure script).  They can still
+  be disable selectively by specifying --without-computed-gotos.
+
 - Issue #9425: Create PyErr_WarnFormat() function, similar to PyErr_WarnEx()
   but use PyUnicode_FromFormatV() to format the warning message.
 
index 2d4b16a39a2726ac49b49f6a761091f457029861..c2c4e78f19e58220ebabdb9d5c2f02eac8dc4fb9 100644 (file)
@@ -840,11 +840,24 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
    -fno-crossjumping).
 */
 
-#if defined(USE_COMPUTED_GOTOS) && defined(DYNAMIC_EXECUTION_PROFILE)
+#ifdef DYNAMIC_EXECUTION_PROFILE
 #undef USE_COMPUTED_GOTOS
+#define USE_COMPUTED_GOTOS 0
+#endif
+
+#ifdef HAVE_COMPUTED_GOTOS
+    #ifndef USE_COMPUTED_GOTOS
+    #define USE_COMPUTED_GOTOS 1
+    #endif
+#else
+    #if defined(USE_COMPUTED_GOTOS) && USE_COMPUTED_GOTOS
+    #error "Computed gotos are not supported on this compiler."
+    #endif
+    #undef USE_COMPUTED_GOTOS
+    #define USE_COMPUTED_GOTOS 0
 #endif
 
-#ifdef USE_COMPUTED_GOTOS
+#if USE_COMPUTED_GOTOS
 /* Import the static jump table */
 #include "opcode_targets.h"
 
@@ -990,7 +1003,7 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
 
 */
 
-#if defined(DYNAMIC_EXECUTION_PROFILE) || defined(USE_COMPUTED_GOTOS)
+#if defined(DYNAMIC_EXECUTION_PROFILE) || USE_COMPUTED_GOTOS
 #define PREDICT(op)             if (0) goto PRED_##op
 #define PREDICTED(op)           PRED_##op:
 #define PREDICTED_WITH_ARG(op)  PRED_##op:
@@ -2838,7 +2851,7 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
             oparg = oparg<<16 | NEXTARG();
             goto dispatch_opcode;
 
-#ifdef USE_COMPUTED_GOTOS
+#if USE_COMPUTED_GOTOS
         _unknown_opcode:
 #endif
         default:
index d48e8dcb64b8848eebfba6c4340835ba067b02df..9c9b9747629ac502f66ccb85b8ad824f6e0a1b54 100755 (executable)
--- a/configure
+++ b/configure
@@ -1,5 +1,5 @@
 #! /bin/sh
-# From configure.in Revision: 82090 .
+# From configure.in Revision: 83580 .
 # Guess values for system-dependent variables and create Makefiles.
 # Generated by GNU Autoconf 2.65 for python 3.2.
 #
@@ -1421,8 +1421,9 @@ Optional Packages:
   --with-libm=STRING      math library
   --with-libc=STRING      C library
   --with-wide-unicode     Use 4-byte Unicode characters (default is 2 bytes)
-  --with-computed-gotos   Use computed gotos / threaded dispatch in evaluation
-                          loop (not available on all compilers)
+  --with(out)-computed-gotos
+                          Use computed gotos in evaluation loop (enabled by
+                          default on supported compilers)
 
 Some influential environment variables:
   CC          C compiler command
@@ -1929,11 +1930,11 @@ else
        cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 $ac_includes_default
-            enum { N = $2 / 2 - 1 };
 int
 main ()
 {
-static int test_array [1 - 2 * !(0 < ($ac_type) ((((($ac_type) 1 << N) << N) - 1) * 2 + 1))];
+static int test_array [1 - 2 * !(enum { N = $2 / 2 - 1 };
+            0 < ($ac_type) ((((($ac_type) 1 << N) << N) - 1) * 2 + 1))];
 test_array [0] = 0
 
   ;
@@ -1944,11 +1945,11 @@ if ac_fn_c_try_compile "$LINENO"; then :
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 $ac_includes_default
-               enum { N = $2 / 2 - 1 };
 int
 main ()
 {
-static int test_array [1 - 2 * !(($ac_type) ((((($ac_type) 1 << N) << N) - 1) * 2 + 1)
+static int test_array [1 - 2 * !(enum { N = $2 / 2 - 1 };
+               ($ac_type) ((((($ac_type) 1 << N) << N) - 1) * 2 + 1)
                 < ($ac_type) ((((($ac_type) 1 << N) << N) - 1) * 2 + 2))];
 test_array [0] = 0
 
@@ -9121,7 +9122,7 @@ fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $with_doc_strings" >&5
 $as_echo "$with_doc_strings" >&6; }
 
-# Check for Python-specific malloc support
+# Check if eval loop should use timestamp counter profiling
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for --with-tsc" >&5
 $as_echo_n "checking for --with-tsc... " >&6; }
 
@@ -13502,6 +13503,49 @@ $as_echo "#define HAVE_BROKEN_MBSTOWCS 1" >>confdefs.h
 
 fi
 
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC supports computed gotos" >&5
+$as_echo_n "checking whether $CC supports computed gotos... " >&6; }
+if test "${ac_cv_computed_gotos+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test "$cross_compiling" = yes; then :
+  ac_cv_computed_gotos=no
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int main(int argc, char **argv)
+{
+    static void *targets[1] = { &&LABEL1 };
+    goto LABEL2;
+LABEL1:
+    return 0;
+LABEL2:
+    goto *targets[0];
+    return 1;
+}
+
+_ACEOF
+if ac_fn_c_try_run "$LINENO"; then :
+  ac_cv_computed_gotos=yes
+else
+  ac_cv_computed_gotos=no
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+
+fi
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_computed_gotos" >&5
+$as_echo "$ac_cv_computed_gotos" >&6; }
+if test "$ac_cv_computed_gotos" = yes
+then
+
+$as_echo "#define HAVE_COMPUTED_GOTOS 1" >>confdefs.h
+
+fi
+
 # Check for --with-computed-gotos
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for --with-computed-gotos" >&5
 $as_echo_n "checking for --with-computed-gotos... " >&6; }
@@ -13509,21 +13553,28 @@ $as_echo_n "checking for --with-computed-gotos... " >&6; }
 # Check whether --with-computed-gotos was given.
 if test "${with_computed_gotos+set}" = set; then :
   withval=$with_computed_gotos;
-if test "$withval" != no
+if test "$withval" = yes
 then
 
 $as_echo "#define USE_COMPUTED_GOTOS 1" >>confdefs.h
 
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
 $as_echo "yes" >&6; }
-else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
 fi
-else
+if test "$withval" = no
+then
+
+$as_echo "#define USE_COMPUTED_GOTOS 0" >>confdefs.h
+
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
 $as_echo "no" >&6; }
 fi
 
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no value specified" >&5
+$as_echo "no value specified" >&6; }
+fi
+
 
 
 
@@ -14086,8 +14137,8 @@ esac
 
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 # Files that config.status was made for.
-config_files="$ac_config_files"
-config_headers="$ac_config_headers"
+config_files="`echo $ac_config_files`"
+config_headers="`echo $ac_config_headers`"
 
 _ACEOF
 
index 7d10e69e503ea97a16d9299e2d7f86e195350712..eb753bb93fa0d9ccf643cb1bc3eabcdf0b81fb78 100644 (file)
@@ -4124,20 +4124,50 @@ then
    wide chars that would be converted.])
 fi
 
+AC_MSG_CHECKING(whether $CC supports computed gotos)
+AC_CACHE_VAL(ac_cv_computed_gotos,
+AC_RUN_IFELSE([AC_LANG_SOURCE([[[
+int main(int argc, char **argv)
+{
+    static void *targets[1] = { &&LABEL1 };
+    goto LABEL2;
+LABEL1:
+    return 0;
+LABEL2:
+    goto *targets[0];
+    return 1;
+}
+]]])],
+[ac_cv_computed_gotos=yes],
+[ac_cv_computed_gotos=no],
+[ac_cv_computed_gotos=no]))
+AC_MSG_RESULT($ac_cv_computed_gotos)
+if test "$ac_cv_computed_gotos" = yes
+then
+  AC_DEFINE(HAVE_COMPUTED_GOTOS, 1,
+  [Define if the C compiler supports computed gotos.])
+fi
+
 # Check for --with-computed-gotos
 AC_MSG_CHECKING(for --with-computed-gotos)
 AC_ARG_WITH(computed-gotos,
-            AS_HELP_STRING([--with-computed-gotos],
-                           [Use computed gotos / threaded dispatch in evaluation loop (not available on all compilers)]),
+            AS_HELP_STRING([--with(out)-computed-gotos],
+                           [Use computed gotos in evaluation loop (enabled by default on supported compilers)]),
 [
-if test "$withval" != no
+if test "$withval" = yes
 then 
   AC_DEFINE(USE_COMPUTED_GOTOS, 1,
   [Define if you want to use computed gotos in ceval.c.]) 
   AC_MSG_RESULT(yes)
-else AC_MSG_RESULT(no)
-fi],
-[AC_MSG_RESULT(no)])
+fi
+if test "$withval" = no
+then 
+  AC_DEFINE(USE_COMPUTED_GOTOS, 0,
+  [Define if you want to use computed gotos in ceval.c.]) 
+  AC_MSG_RESULT(no)
+fi
+],
+[AC_MSG_RESULT(no value specified)])
 
 
 
index d3a87861e1e7c09b58dace27c1e3840eeaba4648..ae3f6e4e49eb3109ef560aaf9e0c0ce72683a80a 100644 (file)
 /* Define to 1 if you have the `clock' function. */
 #undef HAVE_CLOCK
 
+/* Define if the C compiler supports computed gotos. */
+#undef HAVE_COMPUTED_GOTOS
+
 /* Define to 1 if you have the `confstr' function. */
 #undef HAVE_CONFSTR
 
 /* Define to 1 if your <sys/time.h> declares `struct tm'. */
 #undef TM_IN_SYS_TIME
 
-/* Define if you want to use computed gotos in ceval.c. */
+/* Define to 0 if you don't want to use computed gotos in ceval.c. */
 #undef USE_COMPUTED_GOTOS
 
 /* Enable extensions on AIX 3, Interix.  */