8223904: Improve Nashorn matching jdk8u252-b09 jdk8u252-ga

Fri, 15 Nov 2019 19:10:43 +0100

author
hannesw
date
Fri, 15 Nov 2019 19:10:43 +0100
changeset 2549
2f5ad880fd33
parent 2548
2e03a91e04b9
child 2550
cd5f24c9b01f
child 2553
a805f6863c1c

8223904: Improve Nashorn matching
Reviewed-by: jlaskey, sundar, mschoene, rhalade

src/jdk/nashorn/internal/runtime/regexp/joni/Parser.java file | annotate | diff | comparison | revisions
src/jdk/nashorn/internal/runtime/regexp/joni/ast/StringNode.java file | annotate | diff | comparison | revisions
     1.1 --- a/src/jdk/nashorn/internal/runtime/regexp/joni/Parser.java	Wed Nov 06 17:13:21 2019 +0100
     1.2 +++ b/src/jdk/nashorn/internal/runtime/regexp/joni/Parser.java	Fri Nov 15 19:10:43 2019 +0100
     1.3 @@ -452,7 +452,7 @@
     1.4      private Node parseExp(final TokenType term) {
     1.5          if (token.type == term)
     1.6           {
     1.7 -            return StringNode.EMPTY; // goto end_of_token
     1.8 +            return StringNode.createEmpty(); // goto end_of_token
     1.9          }
    1.10  
    1.11          Node node = null;
    1.12 @@ -461,7 +461,7 @@
    1.13          switch(token.type) {
    1.14          case ALT:
    1.15          case EOT:
    1.16 -            return StringNode.EMPTY; // end_of_token:, node_new_empty
    1.17 +            return StringNode.createEmpty(); // end_of_token:, node_new_empty
    1.18  
    1.19          case SUBEXP_OPEN:
    1.20              node = parseEnclose(TokenType.SUBEXP_CLOSE);
    1.21 @@ -569,7 +569,7 @@
    1.22                  if (syntax.contextInvalidRepeatOps()) {
    1.23                      throw new SyntaxException(ERR_TARGET_OF_REPEAT_OPERATOR_NOT_SPECIFIED);
    1.24                  }
    1.25 -                node = StringNode.EMPTY; // node_new_empty
    1.26 +                node = StringNode.createEmpty(); // node_new_empty
    1.27              } else {
    1.28                  return parseExpTkByte(group); // goto tk_byte
    1.29              }
     2.1 --- a/src/jdk/nashorn/internal/runtime/regexp/joni/ast/StringNode.java	Wed Nov 06 17:13:21 2019 +0100
     2.2 +++ b/src/jdk/nashorn/internal/runtime/regexp/joni/ast/StringNode.java	Fri Nov 15 19:10:43 2019 +0100
     2.3 @@ -27,7 +27,6 @@
     2.4  
     2.5      private static final int NODE_STR_MARGIN = 16;
     2.6      private static final int NODE_STR_BUF_SIZE = 24;
     2.7 -    public static final StringNode EMPTY = new StringNode(null, Integer.MAX_VALUE, Integer.MAX_VALUE);
     2.8  
     2.9      public char[] chars;
    2.10      public int p;
    2.11 @@ -36,7 +35,13 @@
    2.12      public int flag;
    2.13  
    2.14      public StringNode() {
    2.15 -        this.chars = new char[NODE_STR_BUF_SIZE];
    2.16 +        this(NODE_STR_BUF_SIZE);
    2.17 +    }
    2.18 +
    2.19 +    private StringNode(int size) {
    2.20 +        this.chars = new char[size];
    2.21 +        this.p = 0;
    2.22 +        this.end = 0;
    2.23      }
    2.24  
    2.25      public StringNode(final char[] chars, final int p, final int end) {
    2.26 @@ -51,6 +56,13 @@
    2.27          chars[end++] = c;
    2.28      }
    2.29  
    2.30 +    /**
    2.31 +     * Create a new empty StringNode.
    2.32 +     */
    2.33 +    public static StringNode createEmpty() {
    2.34 +        return new StringNode(0);
    2.35 +    }
    2.36 +
    2.37      /* Ensure there is ahead bytes available in node's buffer
    2.38       * (assumes that the node is not shared)
    2.39       */

mercurial