From 54bcb6ffb170c99b8ce89930775a283ab3505278 Mon Sep 17 00:00:00 2001 From: Mat Booth Date: Fri, 30 Aug 2013 13:40:15 +0100 Subject: [PATCH] Patch so that generated action methods do not exceed the 65535 byte JVM method size limit. Supplied by eclipse-pdt project. - Drop rpm bug workaround scriptlet. --- java_cup.spec | 20 ++++--- javacup10k_split_do_action_method.diff | 74 ++++++++++++++++++++++++++ 2 files changed, 87 insertions(+), 7 deletions(-) create mode 100644 javacup10k_split_do_action_method.diff diff --git a/java_cup.spec b/java_cup.spec index 46892bf..d0732d3 100644 --- a/java_cup.spec +++ b/java_cup.spec @@ -34,7 +34,7 @@ Name: java_cup Version: 0.11a -Release: 13%{?dist} +Release: 14%{?dist} Epoch: 1 Summary: Java source interpreter License: MIT @@ -49,6 +49,10 @@ Source3: LICENSE.txt Patch0: %{name}-build.patch Patch1: java_cup-0.11a-manifest.patch +# Patch from eclipe-pdt to get around generated actions methods exceeding the 65535 bytes limit: +# http://git.eclipse.org/c/pdt/org.eclipse.pdt.git/tree/plugins/org.eclipse.php.core.parser/javacup10k_split_do_action_method.diff +Patch2: javacup10k_split_do_action_method.diff + BuildRequires: ant BuildRequires: java-devel BuildRequires: jpackage-utils >= 0:1.5 @@ -59,7 +63,6 @@ BuildRequires: java_cup >= 1:0.11a BuildRequires: zip Requires: java -Requires: jpackage-utils BuildArch: noarch @@ -82,6 +85,9 @@ Documentation for java_cup. %setup -q %patch0 -b .build %patch1 -p1 -b .manifest +pushd src +%patch2 -p1 -b .orig +popd cp %{SOURCE1} pom.xml cp %{SOURCE3} . @@ -135,16 +141,16 @@ cp -pr dist/javadoc/* %{buildroot}%{_javadocdir}/%{name} %files manual %doc manual.html LICENSE.txt -%pre javadoc -# workaround for rpm bug, can be removed in F-17 -[ $1 -gt 1 ] && [ -L %{_javadocdir}/%{name} ] && \ -rm -rf $(readlink -f %{_javadocdir}/%{name}) %{_javadocdir}/%{name} || : - %files javadoc %doc LICENSE.txt %{_javadocdir}/%{name} %changelog +* Fri Aug 30 2013 Mat Booth - 1:0.11a-14 +- Patch so that generated action methods do not exceed the 65535 byte JVM + method size limit. Supplied by eclipse-pdt project. +- Drop rpm bug workaround scriptlet. + * Sat Aug 03 2013 Fedora Release Engineering - 1:0.11a-13 - Rebuilt for https://fedoraproject.org/wiki/Fedora_20_Mass_Rebuild diff --git a/javacup10k_split_do_action_method.diff b/javacup10k_split_do_action_method.diff new file mode 100644 index 0000000..971c00e --- /dev/null +++ b/javacup10k_split_do_action_method.diff @@ -0,0 +1,74 @@ +# This patch splits the main do_action() method in order to solve the JVM memory limitation problem +# +--- java_cup_v10k.old/java_cup/emit.java 1999-07-24 15:51:33.000000000 +0300 ++++ java_cup_v10k/java_cup/emit.java 2009-01-21 11:12:13.000000000 +0200 +@@ -340,7 +340,7 @@ + out.println(" this.parser = parser;"); + out.println(" }"); + +- /* action method head */ ++ /* main action method head */ + out.println(); + out.println(" /** Method with the actual generated action code. */"); + out.println(" public final java_cup.runtime.Symbol " + +@@ -352,6 +352,38 @@ + out.println(" throws java.lang.Exception"); + out.println(" {"); + ++ /* split action code into several methods because of the JVM limitation of method size to 64KB */ ++ final int splitBase = 100; ++ for (int splitIdx = 0; splitIdx < production.number(); splitIdx += splitBase) { ++ if (splitIdx > 0) { ++ out.print(" else "); ++ } ++ if (splitIdx + splitBase < production.number()) { ++ out.println(" if (" + pre("act_num") + " < " + (splitIdx + splitBase) + ") {"); ++ } else { ++ out.println(" {"); ++ } ++ out.println(" return " + pre("do_action") + ((splitIdx + splitBase) / splitBase) + "("); ++ out.println(" " + pre("act_num, ") + pre("parser,") + pre("stack,") + pre("top") + ");"); ++ out.println(" }"); ++ } ++ out.println(" }"); ++ out.println(); ++ ++ for (int splitIdx = 0; splitIdx < production.number(); splitIdx += splitBase) { ++ ++ /* splitted action method head */ ++ out.println(); ++ out.println(" /** Method with the actual generated action code. */"); ++ out.println(" public final java_cup.runtime.Symbol " + ++ pre("do_action") + ((splitIdx + splitBase)/splitBase) + "("); ++ out.println(" int " + pre("act_num,")); ++ out.println(" java_cup.runtime.lr_parser " + pre("parser,")); ++ out.println(" java.util.Stack " + pre("stack,")); ++ out.println(" int " + pre("top)")); ++ out.println(" throws java.lang.Exception"); ++ out.println(" {"); ++ + /* declaration of result symbol */ + /* New declaration!! now return Symbol + 6/13/96 frankf */ +@@ -365,9 +397,9 @@ + out.println(" {"); + + /* emit action code for each production as a separate case */ +- for (Enumeration p = production.all(); p.hasMoreElements(); ) +- { +- prod = (production)p.nextElement(); ++ ++ for (int prodIdx = splitIdx; prodIdx < production.number() && prodIdx < splitIdx + splitBase; ++prodIdx) { ++ prod = (production)production.find(prodIdx); + + /* case label */ + out.println(" /*. . . . . . . . . . . . . . . . . . . .*/"); +@@ -471,6 +503,8 @@ + /* end of method */ + out.println(" }"); + ++ } ++ + /* end of class */ + out.println("}"); + out.println();