[jruby-joni] 122/194: reduce stack frame size when combination explosion check is not used

Hideki Yamane henrich at moszumanska.debian.org
Thu Feb 1 12:04:33 UTC 2018


This is an automated email from the git hooks/post-receive script.

henrich pushed a commit to branch debian/sid
in repository jruby-joni.

commit 72fbb0b08dd447a0499c226a5e74104a60244d0e
Author: Marcin Mielzynski <lopx at gazeta.pl>
Date:   Mon Jan 8 20:27:53 2018 +0100

    reduce stack frame size when combination explosion check is not used
---
 src/org/joni/ByteCodeMachine.java |  2 +-
 src/org/joni/StackEntry.java      | 26 +++++++++++++++-----------
 src/org/joni/StackMachine.java    | 14 +++++++-------
 3 files changed, 23 insertions(+), 19 deletions(-)

diff --git a/src/org/joni/ByteCodeMachine.java b/src/org/joni/ByteCodeMachine.java
index bc18b0e..c0ede3d 100644
--- a/src/org/joni/ByteCodeMachine.java
+++ b/src/org/joni/ByteCodeMachine.java
@@ -1957,7 +1957,7 @@ class ByteCodeMachine extends StackMachine {
         pkeep = e.getPKeep();
 
         if (Config.USE_COMBINATION_EXPLOSION_CHECK) {
-            if (e.getStateCheck() != 0) {
+            if (((SCStackEntry)e).getStateCheck() != 0) {
                 e.type = STATE_CHECK_MARK;
                 stk++;
             }
diff --git a/src/org/joni/StackEntry.java b/src/org/joni/StackEntry.java
index 09ece1e..3ad2fc2 100644
--- a/src/org/joni/StackEntry.java
+++ b/src/org/joni/StackEntry.java
@@ -19,9 +19,9 @@
  */
 package org.joni;
 
-final class StackEntry {
+class StackEntry {
     int type;
-    private int E1, E2, E3, E4, E5;
+    private int E1, E2, E3, E4;
 
     // first union member
     /* byte code position */
@@ -49,19 +49,10 @@ final class StackEntry {
     void setPKeep(int pkeep) {
         E4 = pkeep;
     }
-
     int getPKeep() {
         return E4;
     }
 
-    void setStateCheck(int check) {
-        E5 = check;
-    }
-
-    int getStateCheck() {
-        return E5;
-    }
-
     // second union member
     /* for OP_REPEAT_INC, OP_REPEAT_INC_NG */
     void setRepeatCount(int count) {
@@ -171,6 +162,7 @@ final class StackEntry {
         return E3;
     }
 
+    /* absent position */
     void setAbsentStr(int pos) {
         E1 = pos;
     }
@@ -185,3 +177,15 @@ final class StackEntry {
         return E2;
     }
 }
+
+final class SCStackEntry extends StackEntry {
+    private int E5;
+
+    void setStateCheck(int check) {
+        E5 = check;
+    }
+
+    int getStateCheck() {
+        return E5;
+    }
+}
\ No newline at end of file
diff --git a/src/org/joni/StackMachine.java b/src/org/joni/StackMachine.java
index ae1fdd0..a198ef1 100644
--- a/src/org/joni/StackMachine.java
+++ b/src/org/joni/StackMachine.java
@@ -66,7 +66,7 @@ abstract class StackMachine extends Matcher implements StackType {
 
     private static StackEntry[] allocateStack() {
         StackEntry[]stack = new StackEntry[Config.INIT_MATCH_STACK_SIZE];
-        stack[0] = new StackEntry();
+        stack[0] = Config.USE_COMBINATION_EXPLOSION_CHECK ? new SCStackEntry() : new StackEntry();
         return stack;
     }
 
@@ -97,7 +97,7 @@ abstract class StackMachine extends Matcher implements StackType {
     private final StackEntry ensure1() {
         if (stk >= stack.length) doubleStack();
         StackEntry e = stack[stk];
-        if (e == null) stack[stk] = e = new StackEntry();
+        if (e == null) stack[stk] = e = Config.USE_COMBINATION_EXPLOSION_CHECK ? new SCStackEntry() : new StackEntry();
         return e;
     }
 
@@ -125,7 +125,7 @@ abstract class StackMachine extends Matcher implements StackType {
     // ELSE_IF_STATE_CHECK_MARK
     private void stateCheckMark() {
         StackEntry e = stack[stk];
-        int x = stateCheckPos(e.getStatePStr(), e.getStateCheck());
+        int x = stateCheckPos(e.getStatePStr(), ((SCStackEntry)e).getStateCheck());
         stateCheckBuff[x / 8] |= (1 << (x % 8));
     }
 
@@ -166,7 +166,7 @@ abstract class StackMachine extends Matcher implements StackType {
         e.setStatePCode(pat);
         e.setStatePStr(s);
         e.setStatePStrPrev(prev);
-        if (Config.USE_COMBINATION_EXPLOSION_CHECK) e.setStateCheck(0);
+        if (Config.USE_COMBINATION_EXPLOSION_CHECK) ((SCStackEntry)e).setStateCheck(0);
         e.setPKeep(pkeep);
         stk++;
     }
@@ -175,7 +175,7 @@ abstract class StackMachine extends Matcher implements StackType {
         StackEntry e = stack[stk];
         e.type = type;
         e.setStatePCode(pat);
-        if (Config.USE_COMBINATION_EXPLOSION_CHECK) e.setStateCheck(0);
+        if (Config.USE_COMBINATION_EXPLOSION_CHECK) ((SCStackEntry)e).setStateCheck(0);
         stk++;
     }
 
@@ -185,7 +185,7 @@ abstract class StackMachine extends Matcher implements StackType {
         e.setStatePCode(pat);
         e.setStatePStr(s);
         e.setStatePStrPrev(sprev);
-        if (Config.USE_COMBINATION_EXPLOSION_CHECK) e.setStateCheck(stateCheckBuff != null ? snum : 0);
+        if (Config.USE_COMBINATION_EXPLOSION_CHECK) ((SCStackEntry)e).setStateCheck(stateCheckBuff != null ? snum : 0);
         e.setPKeep(pkeep);
         stk++;
     }
@@ -195,7 +195,7 @@ abstract class StackMachine extends Matcher implements StackType {
             StackEntry e = ensure1();
             e.type = STATE_CHECK_MARK;
             e.setStatePStr(s);
-            e.setStateCheck(snum);
+            ((SCStackEntry)e).setStateCheck(snum);
             stk++;
         }
     }

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-java/jruby-joni.git



More information about the pkg-java-commits mailing list