bison-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 08/13] java: style: avoid useless initializers


From: Akim Demaille
Subject: Re: [PATCH 08/13] java: style: avoid useless initializers
Date: Mon, 10 Feb 2020 08:02:17 +0100


> Le 5 févr. 2020 à 18:05, Akim Demaille <address@hidden> a écrit :
> 
> Instead of
> 
>      /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
>       STATE-NUM.  */
>      private static final byte yypact_[] = yypact_init ();
>      private static final byte[] yypact_init ()
>      {
>        return new byte[]
>        {
>          25,    -7,    -8,    37,    -8,    40,    -8,    20,    -8,    61,
>          -8,    -8,     3,     9,    51,    -8,    -8,    -2,    -2,    -2,
>          -2,    -2,    -2,    -8,    -8,    -8,     1,    66,    66,     3,
>           3,     3
>        };
>      }
> 
> generate
> 
>    /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
>       STATE-NUM.  */
>      private static final byte[] yypact_ =
>      {
>          25,    -7,    -8,    37,    -8,    40,    -8,    20,    -8,    61,
>          -8,    -8,     3,     9,    51,    -8,    -8,    -2,    -2,    -2,
>          -2,    -2,    -2,    -8,    -8,    -8,     1,    66,    66,     3,
>           3,     3
>      };
> 
> I have no idea what motivated the previous approach.

and I should have looked, I would have understood...

So I'm installing this.

commit ed1eedbbcb6b7f071372a4e1bb648ffcc2338254
Author: Akim Demaille <address@hidden>
Date:   Mon Feb 10 07:24:51 2020 +0100

    java: revert "style: avoid useless initializers"
    
    This reverts commit ebab1ffca8a728158051481795ae798231cfd93d.
    This commit removed "useless" initializers, going from
    
        /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
           STATE-NUM.  */
        private static final byte yypact_[] = yypact_init ();
        private static final byte[] yypact_init ()
        {
          return new byte[]
          {
            25,    -7,    -8,    37,    -8,    40,    -8,    20,    -8,    61,
            -8,    -8,     3,     9,    51,    -8,    -8,    -2,    -2,    -2,
            -2,    -2,    -2,    -8,    -8,    -8,     1,    66,    66,     3,
             3,     3
          };
        }
    
    to
    
        /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
           STATE-NUM.  */
        private static final byte[] yypact_ =
        {
            25,    -7,    -8,    37,    -8,    40,    -8,    20,    -8,    61,
            -8,    -8,     3,     9,    51,    -8,    -8,    -2,    -2,    -2,
            -2,    -2,    -2,    -8,    -8,    -8,     1,    66,    66,     3,
             3,     3
        };
    
    But it turns out that this was on purpose, to work around the 64KB
    limitation in JVM methods.  It was introduced on the 2008-11-10 by
    Di-an Jan in 09ccae9b18a7c09ebf7bb8df2a18c8c4a6def248: "Work around
    Java's ``code too large'' problem for parser tables".  See
    https://lists.gnu.org/r/help-bison/2008-11/msg00004.html.  A real
    test, where we would hit the JVM limitation, would be nice.
    
    To avoid further regressions, add comments.

diff --git a/data/skeletons/java.m4 b/data/skeletons/java.m4
index 920f34bc..984fd3ea 100644
--- a/data/skeletons/java.m4
+++ b/data/skeletons/java.m4
@@ -106,13 +106,20 @@ m4_define([b4_null], [null])
 
 # b4_typed_parser_table_define(TYPE, NAME, DATA, COMMENT)
 # -------------------------------------------------------
+# We use intermediate functions (e.g., yypact_init) to work around the
+# 64KB limit for JVM methods.  See
+# https://lists.gnu.org/r/help-bison/2008-11/msg00004.html.
 m4_define([b4_typed_parser_table_define],
 [m4_ifval([$4], [b4_comment([$4])
   ])dnl
-[private static final ]$1[[] yy$2_ =
+[private static final ]$1[[] yy$2_ = yy$2_init ();
+  private static final ]$1[[] yy$2_init ()
   {
+    return new ]$1[[]
+    {
   ]$3[
-  };]])
+    };
+  }]])
 
 
 # b4_integral_parser_table_define(NAME, DATA, COMMENT)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]