Thu, 16 May 2013 19:52:39 +0200
8012359: Increase code coverage in Joni
Reviewed-by: jlaskey, lagergren
1.1 --- a/make/build.xml Thu May 16 13:44:25 2013 +0200 1.2 +++ b/make/build.xml Thu May 16 19:52:39 2013 +0200 1.3 @@ -305,6 +305,8 @@ 1.4 <include name="**/codegen/*Test.class"/> 1.5 <include name="**/parser/*Test.class"/> 1.6 <include name="**/runtime/*Test.class"/> 1.7 + <include name="**/runtime/regexp/*Test.class"/> 1.8 + <include name="**/runtime/regexp/joni/*Test.class"/> 1.9 <include name="**/framework/*Test.class"/> 1.10 </fileset> 1.11
2.1 --- a/src/jdk/nashorn/internal/runtime/regexp/DefaultRegExp.java Thu May 16 13:44:25 2013 +0200 2.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 2.3 @@ -1,163 +0,0 @@ 2.4 -/* 2.5 - * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. 2.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 2.7 - * 2.8 - * This code is free software; you can redistribute it and/or modify it 2.9 - * under the terms of the GNU General Public License version 2 only, as 2.10 - * published by the Free Software Foundation. Oracle designates this 2.11 - * particular file as subject to the "Classpath" exception as provided 2.12 - * by Oracle in the LICENSE file that accompanied this code. 2.13 - * 2.14 - * This code is distributed in the hope that it will be useful, but WITHOUT 2.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 2.16 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 2.17 - * version 2 for more details (a copy is included in the LICENSE file that 2.18 - * accompanied this code). 2.19 - * 2.20 - * You should have received a copy of the GNU General Public License version 2.21 - * 2 along with this work; if not, write to the Free Software Foundation, 2.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2.23 - * 2.24 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2.25 - * or visit www.oracle.com if you need additional information or have any 2.26 - * questions. 2.27 - */ 2.28 - 2.29 -package jdk.nashorn.internal.runtime.regexp; 2.30 - 2.31 -import jdk.nashorn.internal.runtime.ParserException; 2.32 - 2.33 -import static java.util.regex.Pattern.CASE_INSENSITIVE; 2.34 -import static java.util.regex.Pattern.MULTILINE; 2.35 -import static java.util.regex.Pattern.UNICODE_CASE; 2.36 - 2.37 -import java.util.regex.Matcher; 2.38 -import java.util.regex.Pattern; 2.39 -import java.util.regex.PatternSyntaxException; 2.40 - 2.41 -/** 2.42 - * Default regular expression implementation based on java.util.regex package. 2.43 - * 2.44 - * Note that this class is not thread-safe as it stores the current match result 2.45 - * and the string being matched in instance fields. 2.46 - */ 2.47 -public class DefaultRegExp extends RegExp { 2.48 - 2.49 - /** Java regexp pattern to use for match. We compile to one of these */ 2.50 - private Pattern pattern; 2.51 - 2.52 - /** The matcher */ 2.53 - private RegExpMatcher matcher; 2.54 - 2.55 - /** 2.56 - * Construct a Regular expression from the given {@code source} and {@code flags} strings. 2.57 - * 2.58 - * @param source RegExp source string 2.59 - * @param flags RegExp flag string 2.60 - * @throws ParserException if flags is invalid or source string has syntax error. 2.61 - */ 2.62 - public DefaultRegExp(final String source, final String flags) throws ParserException { 2.63 - super(source, flags); 2.64 - 2.65 - int intFlags = 0; 2.66 - 2.67 - if (isIgnoreCase()) { 2.68 - intFlags |= CASE_INSENSITIVE | UNICODE_CASE; 2.69 - } 2.70 - if (isMultiline()) { 2.71 - intFlags |= MULTILINE; 2.72 - } 2.73 - 2.74 - try { 2.75 - RegExpScanner parsed; 2.76 - 2.77 - try { 2.78 - parsed = RegExpScanner.scan(source); 2.79 - } catch (final PatternSyntaxException e) { 2.80 - // refine the exception with a better syntax error, if this 2.81 - // passes, just rethrow what we have 2.82 - Pattern.compile(source, intFlags); 2.83 - throw e; 2.84 - } 2.85 - 2.86 - if (parsed != null) { 2.87 - this.pattern = Pattern.compile(parsed.getJavaPattern(), intFlags); 2.88 - this.groupsInNegativeLookahead = parsed.getGroupsInNegativeLookahead(); 2.89 - } 2.90 - } catch (final PatternSyntaxException e2) { 2.91 - throwParserException("syntax", e2.getMessage()); 2.92 - } 2.93 - } 2.94 - 2.95 - @Override 2.96 - public RegExpMatcher match(final String str) { 2.97 - if (pattern == null) { 2.98 - return null; // never matches or similar, e.g. a[] 2.99 - } 2.100 - 2.101 - RegExpMatcher currentMatcher = this.matcher; 2.102 - 2.103 - if (currentMatcher == null || matcher.getInput() != str) { 2.104 - currentMatcher = new DefaultMatcher(str); 2.105 - this.matcher = currentMatcher; 2.106 - } 2.107 - 2.108 - return currentMatcher; 2.109 - } 2.110 - 2.111 - class DefaultMatcher implements RegExpMatcher { 2.112 - final String input; 2.113 - final Matcher defaultMatcher; 2.114 - 2.115 - DefaultMatcher(final String input) { 2.116 - this.input = input; 2.117 - this.defaultMatcher = pattern.matcher(input); 2.118 - } 2.119 - 2.120 - @Override 2.121 - public boolean search(final int start) { 2.122 - return defaultMatcher.find(start); 2.123 - } 2.124 - 2.125 - @Override 2.126 - public String getInput() { 2.127 - return input; 2.128 - } 2.129 - 2.130 - @Override 2.131 - public int start() { 2.132 - return defaultMatcher.start(); 2.133 - } 2.134 - 2.135 - @Override 2.136 - public int start(final int group) { 2.137 - return defaultMatcher.start(group); 2.138 - } 2.139 - 2.140 - @Override 2.141 - public int end() { 2.142 - return defaultMatcher.end(); 2.143 - } 2.144 - 2.145 - @Override 2.146 - public int end(final int group) { 2.147 - return defaultMatcher.end(group); 2.148 - } 2.149 - 2.150 - @Override 2.151 - public String group() { 2.152 - return defaultMatcher.group(); 2.153 - } 2.154 - 2.155 - @Override 2.156 - public String group(final int group) { 2.157 - return defaultMatcher.group(group); 2.158 - } 2.159 - 2.160 - @Override 2.161 - public int groupCount() { 2.162 - return defaultMatcher.groupCount(); 2.163 - } 2.164 - } 2.165 - 2.166 -}
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 3.2 +++ b/src/jdk/nashorn/internal/runtime/regexp/JdkRegExp.java Thu May 16 19:52:39 2013 +0200 3.3 @@ -0,0 +1,163 @@ 3.4 +/* 3.5 + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. 3.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3.7 + * 3.8 + * This code is free software; you can redistribute it and/or modify it 3.9 + * under the terms of the GNU General Public License version 2 only, as 3.10 + * published by the Free Software Foundation. Oracle designates this 3.11 + * particular file as subject to the "Classpath" exception as provided 3.12 + * by Oracle in the LICENSE file that accompanied this code. 3.13 + * 3.14 + * This code is distributed in the hope that it will be useful, but WITHOUT 3.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 3.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 3.17 + * version 2 for more details (a copy is included in the LICENSE file that 3.18 + * accompanied this code). 3.19 + * 3.20 + * You should have received a copy of the GNU General Public License version 3.21 + * 2 along with this work; if not, write to the Free Software Foundation, 3.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 3.23 + * 3.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 3.25 + * or visit www.oracle.com if you need additional information or have any 3.26 + * questions. 3.27 + */ 3.28 + 3.29 +package jdk.nashorn.internal.runtime.regexp; 3.30 + 3.31 +import jdk.nashorn.internal.runtime.ParserException; 3.32 + 3.33 +import static java.util.regex.Pattern.CASE_INSENSITIVE; 3.34 +import static java.util.regex.Pattern.MULTILINE; 3.35 +import static java.util.regex.Pattern.UNICODE_CASE; 3.36 + 3.37 +import java.util.regex.Matcher; 3.38 +import java.util.regex.Pattern; 3.39 +import java.util.regex.PatternSyntaxException; 3.40 + 3.41 +/** 3.42 + * Default regular expression implementation based on java.util.regex package. 3.43 + * 3.44 + * Note that this class is not thread-safe as it stores the current match result 3.45 + * and the string being matched in instance fields. 3.46 + */ 3.47 +public class JdkRegExp extends RegExp { 3.48 + 3.49 + /** Java regexp pattern to use for match. We compile to one of these */ 3.50 + private Pattern pattern; 3.51 + 3.52 + /** The matcher */ 3.53 + private RegExpMatcher matcher; 3.54 + 3.55 + /** 3.56 + * Construct a Regular expression from the given {@code source} and {@code flags} strings. 3.57 + * 3.58 + * @param source RegExp source string 3.59 + * @param flags RegExp flag string 3.60 + * @throws ParserException if flags is invalid or source string has syntax error. 3.61 + */ 3.62 + public JdkRegExp(final String source, final String flags) throws ParserException { 3.63 + super(source, flags); 3.64 + 3.65 + int intFlags = 0; 3.66 + 3.67 + if (isIgnoreCase()) { 3.68 + intFlags |= CASE_INSENSITIVE | UNICODE_CASE; 3.69 + } 3.70 + if (isMultiline()) { 3.71 + intFlags |= MULTILINE; 3.72 + } 3.73 + 3.74 + try { 3.75 + RegExpScanner parsed; 3.76 + 3.77 + try { 3.78 + parsed = RegExpScanner.scan(source); 3.79 + } catch (final PatternSyntaxException e) { 3.80 + // refine the exception with a better syntax error, if this 3.81 + // passes, just rethrow what we have 3.82 + Pattern.compile(source, intFlags); 3.83 + throw e; 3.84 + } 3.85 + 3.86 + if (parsed != null) { 3.87 + this.pattern = Pattern.compile(parsed.getJavaPattern(), intFlags); 3.88 + this.groupsInNegativeLookahead = parsed.getGroupsInNegativeLookahead(); 3.89 + } 3.90 + } catch (final PatternSyntaxException e2) { 3.91 + throwParserException("syntax", e2.getMessage()); 3.92 + } 3.93 + } 3.94 + 3.95 + @Override 3.96 + public RegExpMatcher match(final String str) { 3.97 + if (pattern == null) { 3.98 + return null; // never matches or similar, e.g. a[] 3.99 + } 3.100 + 3.101 + RegExpMatcher currentMatcher = this.matcher; 3.102 + 3.103 + if (currentMatcher == null || matcher.getInput() != str) { 3.104 + currentMatcher = new DefaultMatcher(str); 3.105 + this.matcher = currentMatcher; 3.106 + } 3.107 + 3.108 + return currentMatcher; 3.109 + } 3.110 + 3.111 + class DefaultMatcher implements RegExpMatcher { 3.112 + final String input; 3.113 + final Matcher defaultMatcher; 3.114 + 3.115 + DefaultMatcher(final String input) { 3.116 + this.input = input; 3.117 + this.defaultMatcher = pattern.matcher(input); 3.118 + } 3.119 + 3.120 + @Override 3.121 + public boolean search(final int start) { 3.122 + return defaultMatcher.find(start); 3.123 + } 3.124 + 3.125 + @Override 3.126 + public String getInput() { 3.127 + return input; 3.128 + } 3.129 + 3.130 + @Override 3.131 + public int start() { 3.132 + return defaultMatcher.start(); 3.133 + } 3.134 + 3.135 + @Override 3.136 + public int start(final int group) { 3.137 + return defaultMatcher.start(group); 3.138 + } 3.139 + 3.140 + @Override 3.141 + public int end() { 3.142 + return defaultMatcher.end(); 3.143 + } 3.144 + 3.145 + @Override 3.146 + public int end(final int group) { 3.147 + return defaultMatcher.end(group); 3.148 + } 3.149 + 3.150 + @Override 3.151 + public String group() { 3.152 + return defaultMatcher.group(); 3.153 + } 3.154 + 3.155 + @Override 3.156 + public String group(final int group) { 3.157 + return defaultMatcher.group(group); 3.158 + } 3.159 + 3.160 + @Override 3.161 + public int groupCount() { 3.162 + return defaultMatcher.groupCount(); 3.163 + } 3.164 + } 3.165 + 3.166 +}
4.1 --- a/src/jdk/nashorn/internal/runtime/regexp/JoniRegExp.java Thu May 16 13:44:25 2013 +0200 4.2 +++ b/src/jdk/nashorn/internal/runtime/regexp/JoniRegExp.java Thu May 16 19:52:39 2013 +0200 4.3 @@ -113,7 +113,7 @@ 4.4 public static class Factory extends RegExpFactory { 4.5 4.6 @Override 4.7 - protected RegExp compile(final String pattern, final String flags) throws ParserException { 4.8 + public RegExp compile(final String pattern, final String flags) throws ParserException { 4.9 return new JoniRegExp(pattern, flags); 4.10 } 4.11
5.1 --- a/src/jdk/nashorn/internal/runtime/regexp/RegExpFactory.java Thu May 16 13:44:25 2013 +0200 5.2 +++ b/src/jdk/nashorn/internal/runtime/regexp/RegExpFactory.java Thu May 16 19:52:39 2013 +0200 5.3 @@ -29,7 +29,7 @@ 5.4 import jdk.nashorn.internal.runtime.options.Options; 5.5 5.6 /** 5.7 - * Factory class for regular expressions. This class creates instances of {@link DefaultRegExp}. 5.8 + * Factory class for regular expressions. This class creates instances of {@link JdkRegExp}. 5.9 * An alternative factory can be installed using the {@code nashorn.regexp.impl} system property. 5.10 */ 5.11 public class RegExpFactory { 5.12 @@ -62,8 +62,8 @@ 5.13 * @return new RegExp 5.14 * @throws ParserException if flags is invalid or pattern string has syntax error. 5.15 */ 5.16 - protected RegExp compile(final String pattern, final String flags) throws ParserException { 5.17 - return new DefaultRegExp(pattern, flags); 5.18 + public RegExp compile(final String pattern, final String flags) throws ParserException { 5.19 + return new JdkRegExp(pattern, flags); 5.20 } 5.21 5.22 /**
6.1 --- a/src/jdk/nashorn/internal/runtime/regexp/joni/Analyser.java Thu May 16 13:44:25 2013 +0200 6.2 +++ b/src/jdk/nashorn/internal/runtime/regexp/joni/Analyser.java Thu May 16 19:52:39 2013 +0200 6.3 @@ -21,10 +21,7 @@ 6.4 6.5 import static jdk.nashorn.internal.runtime.regexp.joni.BitStatus.bsAll; 6.6 import static jdk.nashorn.internal.runtime.regexp.joni.BitStatus.bsAt; 6.7 -import static jdk.nashorn.internal.runtime.regexp.joni.BitStatus.bsClear; 6.8 import static jdk.nashorn.internal.runtime.regexp.joni.BitStatus.bsOnAt; 6.9 -import static jdk.nashorn.internal.runtime.regexp.joni.BitStatus.bsOnAtSimple; 6.10 -import static jdk.nashorn.internal.runtime.regexp.joni.Option.isCaptureGroup; 6.11 import static jdk.nashorn.internal.runtime.regexp.joni.Option.isFindCondition; 6.12 import static jdk.nashorn.internal.runtime.regexp.joni.Option.isIgnoreCase; 6.13 import static jdk.nashorn.internal.runtime.regexp.joni.Option.isMultiline; 6.14 @@ -36,8 +33,6 @@ 6.15 import jdk.nashorn.internal.runtime.regexp.joni.ast.AnchorNode; 6.16 import jdk.nashorn.internal.runtime.regexp.joni.ast.BackRefNode; 6.17 import jdk.nashorn.internal.runtime.regexp.joni.ast.CClassNode; 6.18 -import jdk.nashorn.internal.runtime.regexp.joni.ast.CTypeNode; 6.19 -import jdk.nashorn.internal.runtime.regexp.joni.ast.CallNode; 6.20 import jdk.nashorn.internal.runtime.regexp.joni.ast.ConsAltNode; 6.21 import jdk.nashorn.internal.runtime.regexp.joni.ast.EncloseNode; 6.22 import jdk.nashorn.internal.runtime.regexp.joni.ast.Node; 6.23 @@ -49,9 +44,7 @@ 6.24 import jdk.nashorn.internal.runtime.regexp.joni.constants.RegexState; 6.25 import jdk.nashorn.internal.runtime.regexp.joni.constants.StackPopLevel; 6.26 import jdk.nashorn.internal.runtime.regexp.joni.constants.TargetInfo; 6.27 -import jdk.nashorn.internal.runtime.regexp.joni.encoding.CharacterType; 6.28 import jdk.nashorn.internal.runtime.regexp.joni.encoding.ObjPtr; 6.29 -import jdk.nashorn.internal.runtime.regexp.joni.encoding.Ptr; 6.30 6.31 final class Analyser extends Parser { 6.32 6.33 @@ -74,38 +67,9 @@ 6.34 //regex.repeatRangeAlloc = 0; 6.35 regex.repeatRangeLo = null; 6.36 regex.repeatRangeHi = null; 6.37 - regex.numCombExpCheck = 0; 6.38 - 6.39 - if (Config.USE_COMBINATION_EXPLOSION_CHECK) regex.numCombExpCheck = 0; 6.40 6.41 parse(); 6.42 6.43 - if (Config.USE_NAMED_GROUP) { 6.44 - /* mixed use named group and no-named group */ 6.45 - if (env.numNamed > 0 && syntax.captureOnlyNamedGroup() && !isCaptureGroup(regex.options)) { 6.46 - if (env.numNamed != env.numMem) { 6.47 - root = disableNoNameGroupCapture(root); 6.48 - } else { 6.49 - numberedRefCheck(root); 6.50 - } 6.51 - } 6.52 - } // USE_NAMED_GROUP 6.53 - 6.54 - if (Config.USE_NAMED_GROUP) { 6.55 - if (env.numCall > 0) { 6.56 - env.unsetAddrList = new UnsetAddrList(env.numCall); 6.57 - setupSubExpCall(root); 6.58 - // r != 0 ??? 6.59 - subexpRecursiveCheckTrav(root); 6.60 - // r < 0 -< err, FOUND_CALLED_NODE = 1 6.61 - subexpInfRecursiveCheckTrav(root); 6.62 - // r != 0 recursion infinite ??? 6.63 - regex.numCall = env.numCall; 6.64 - } else { 6.65 - regex.numCall = 0; 6.66 - } 6.67 - } // USE_NAMED_GROUP 6.68 - 6.69 if (Config.DEBUG_PARSE_TREE_RAW && Config.DEBUG_PARSE_TREE) { 6.70 Config.log.println("<RAW TREE>"); 6.71 Config.log.println(root + "\n"); 6.72 @@ -129,27 +93,6 @@ 6.73 regex.btMemEnd |= regex.captureHistory; 6.74 } 6.75 6.76 - if (Config.USE_COMBINATION_EXPLOSION_CHECK) { 6.77 - if (env.backrefedMem == 0 || (Config.USE_SUBEXP_CALL && env.numCall == 0)) { 6.78 - setupCombExpCheck(root, 0); 6.79 - 6.80 - if (Config.USE_SUBEXP_CALL && env.hasRecursion) { 6.81 - env.numCombExpCheck = 0; 6.82 - } else { // USE_SUBEXP_CALL 6.83 - if (env.combExpMaxRegNum > 0) { 6.84 - for (int i=1; i<env.combExpMaxRegNum; i++) { 6.85 - if (bsAt(env.backrefedMem, i)) { 6.86 - env.numCombExpCheck = 0; 6.87 - break; 6.88 - } 6.89 - } 6.90 - } 6.91 - } 6.92 - 6.93 - } // USE_SUBEXP_CALL 6.94 - regex.numCombExpCheck = env.numCombExpCheck; 6.95 - } // USE_COMBINATION_EXPLOSION_CHECK 6.96 - 6.97 regex.clearOptimizeInfo(); 6.98 6.99 if (!Config.DONT_OPTIMIZE) setOptimizedInfoFromTree(root); 6.100 @@ -167,7 +110,6 @@ 6.101 } 6.102 6.103 if (Config.DEBUG_COMPILE) { 6.104 - if (Config.USE_NAMED_GROUP) Config.log.print(regex.nameTableToString()); 6.105 Config.log.println("stack used: " + regex.stackNeeded); 6.106 if (Config.USE_STRING_TEMPLATES) Config.log.print("templates: " + regex.templateNum + "\n"); 6.107 Config.log.println(new ByteCodePrinter(regex).byteCodeListToString()); 6.108 @@ -177,157 +119,6 @@ 6.109 regex.state = RegexState.NORMAL; 6.110 } 6.111 6.112 - private void noNameDisableMapFor_cosAlt(Node node, int[]map, Ptr counter) { 6.113 - ConsAltNode can = (ConsAltNode)node; 6.114 - do { 6.115 - can.setCar(noNameDisableMap(can.car, map, counter)); 6.116 - } while ((can = can.cdr) != null); 6.117 - } 6.118 - 6.119 - private void noNameDisableMapFor_quantifier(Node node, int[]map, Ptr counter) { 6.120 - QuantifierNode qn = (QuantifierNode)node; 6.121 - Node target = qn.target; 6.122 - Node old = target; 6.123 - target = noNameDisableMap(target, map, counter); 6.124 - 6.125 - if (target != old) { 6.126 - qn.setTarget(target); 6.127 - if (target.getType() == NodeType.QTFR) qn.reduceNestedQuantifier((QuantifierNode)target); 6.128 - } 6.129 - } 6.130 - 6.131 - private Node noNameDisableMapFor_enclose(Node node, int[]map, Ptr counter) { 6.132 - EncloseNode en = (EncloseNode)node; 6.133 - if (en.type == EncloseType.MEMORY) { 6.134 - if (en.isNamedGroup()) { 6.135 - counter.p++; 6.136 - map[en.regNum] = counter.p; 6.137 - en.regNum = counter.p; 6.138 - //en.target = noNameDisableMap(en.target, map, counter); 6.139 - en.setTarget(noNameDisableMap(en.target, map, counter)); // ??? 6.140 - } else { 6.141 - node = en.target; 6.142 - en.target = null; // remove first enclose: /(a)(?<b>c)/ 6.143 - node = noNameDisableMap(node, map, counter); 6.144 - } 6.145 - } else { 6.146 - //en.target = noNameDisableMap(en.target, map, counter); 6.147 - en.setTarget(noNameDisableMap(en.target, map, counter)); // ??? 6.148 - } 6.149 - return node; 6.150 - } 6.151 - 6.152 - private void noNameDisableMapFor_anchor(Node node, int[]map, Ptr counter) { 6.153 - AnchorNode an = (AnchorNode)node; 6.154 - switch (an.type) { 6.155 - case AnchorNode.PREC_READ: 6.156 - case AnchorNode.PREC_READ_NOT: 6.157 - case AnchorNode.LOOK_BEHIND: 6.158 - case AnchorNode.LOOK_BEHIND_NOT: 6.159 - an.setTarget(noNameDisableMap(an.target, map, counter)); 6.160 - } 6.161 - } 6.162 - 6.163 - private Node noNameDisableMap(Node node, int[]map, Ptr counter) { 6.164 - switch (node.getType()) { 6.165 - case NodeType.LIST: 6.166 - case NodeType.ALT: 6.167 - noNameDisableMapFor_cosAlt(node, map, counter); 6.168 - break; 6.169 - case NodeType.QTFR: 6.170 - noNameDisableMapFor_quantifier(node, map, counter); 6.171 - break; 6.172 - case NodeType.ENCLOSE: 6.173 - node = noNameDisableMapFor_enclose(node, map, counter); 6.174 - break; 6.175 - case NodeType.ANCHOR: 6.176 - noNameDisableMapFor_anchor(node, map, counter); 6.177 - break; 6.178 - } // switch 6.179 - return node; 6.180 - } 6.181 - 6.182 - private void renumberByMap(Node node, int[]map) { 6.183 - switch (node.getType()) { 6.184 - case NodeType.LIST: 6.185 - case NodeType.ALT: 6.186 - ConsAltNode can = (ConsAltNode)node; 6.187 - do { 6.188 - renumberByMap(can.car, map); 6.189 - } while ((can = can.cdr) != null); 6.190 - break; 6.191 - 6.192 - case NodeType.QTFR: 6.193 - renumberByMap(((QuantifierNode)node).target, map); 6.194 - break; 6.195 - 6.196 - case NodeType.ENCLOSE: 6.197 - renumberByMap(((EncloseNode)node).target, map); 6.198 - break; 6.199 - 6.200 - case NodeType.BREF: 6.201 - ((BackRefNode)node).renumber(map); 6.202 - break; 6.203 - } // switch 6.204 - } 6.205 - 6.206 - protected final void numberedRefCheck(Node node) { 6.207 - switch (node.getType()) { 6.208 - case NodeType.LIST: 6.209 - case NodeType.ALT: 6.210 - ConsAltNode can = (ConsAltNode)node; 6.211 - do { 6.212 - numberedRefCheck(can.car); 6.213 - } while ((can = can.cdr) != null); 6.214 - break; 6.215 - 6.216 - case NodeType.QTFR: 6.217 - numberedRefCheck(((QuantifierNode)node).target); 6.218 - break; 6.219 - 6.220 - case NodeType.ENCLOSE: 6.221 - numberedRefCheck(((EncloseNode)node).target); 6.222 - break; 6.223 - 6.224 - case NodeType.BREF: 6.225 - BackRefNode br = (BackRefNode)node; 6.226 - if (!br.isNameRef()) newValueException(ERR_NUMBERED_BACKREF_OR_CALL_NOT_ALLOWED); 6.227 - break; 6.228 - } // switch 6.229 - } 6.230 - 6.231 - protected final Node disableNoNameGroupCapture(Node root) { 6.232 - int[]map = new int[env.numMem + 1]; 6.233 - 6.234 - for (int i=1; i<=env.numMem; i++) map[i] = 0; 6.235 - 6.236 - root = noNameDisableMap(root, map, new Ptr(0)); 6.237 - renumberByMap(root, map); 6.238 - 6.239 - for (int i=1, pos=1; i<=env.numMem; i++) { 6.240 - if (map[i] > 0) { 6.241 - env.memNodes[pos] = env.memNodes[i]; 6.242 - pos++; 6.243 - } 6.244 - } 6.245 - 6.246 - int loc = env.captureHistory; 6.247 - env.captureHistory = bsClear(); 6.248 - 6.249 - for (int i=1; i<=Config.MAX_CAPTURE_HISTORY_GROUP; i++) { 6.250 - if (bsAt(loc, i)) { 6.251 - env.captureHistory = bsOnAtSimple(env.captureHistory, map[i]); 6.252 - } 6.253 - } 6.254 - 6.255 - env.numMem = env.numNamed; 6.256 - regex.numMem = env.numNamed; 6.257 - 6.258 - regex.renumberNameTable(map); 6.259 - 6.260 - return root; 6.261 - } 6.262 - 6.263 private void swap(Node a, Node b) { 6.264 a.swap(b); 6.265 6.266 @@ -352,17 +143,6 @@ 6.267 } while ((can = can.cdr) != null); 6.268 break; 6.269 6.270 - case NodeType.CALL: 6.271 - if (Config.USE_SUBEXP_CALL) { 6.272 - CallNode cn = (CallNode)node; 6.273 - if (cn.isRecursion()) { 6.274 - return TargetInfo.IS_EMPTY_REC; /* tiny version */ 6.275 - } else { 6.276 - info = quantifiersMemoryInfo(cn.target); 6.277 - } 6.278 - } // USE_SUBEXP_CALL 6.279 - break; 6.280 - 6.281 case NodeType.QTFR: 6.282 QuantifierNode qn = (QuantifierNode)node; 6.283 if (qn.upper != 0) { 6.284 @@ -417,18 +197,6 @@ 6.285 } 6.286 break; 6.287 6.288 - case NodeType.CALL: 6.289 - if (Config.USE_SUBEXP_CALL) { 6.290 - CallNode cn = (CallNode)node; 6.291 - if (cn.isRecursion()) { 6.292 - EncloseNode en = (EncloseNode)cn.target; 6.293 - if (en.isMinFixed()) min = en.minLength; 6.294 - } else { 6.295 - min = getMinMatchLength(cn.target); 6.296 - } 6.297 - } // USE_SUBEXP_CALL 6.298 - break; 6.299 - 6.300 case NodeType.LIST: 6.301 ConsAltNode can = (ConsAltNode)node; 6.302 do { 6.303 @@ -474,15 +242,13 @@ 6.304 EncloseNode en = (EncloseNode)node; 6.305 switch (en.type) { 6.306 case EncloseType.MEMORY: 6.307 - if (Config.USE_SUBEXP_CALL) { 6.308 - if (en.isMinFixed()) { 6.309 - min = en.minLength; 6.310 - } else { 6.311 - min = getMinMatchLength(en.target); 6.312 - en.minLength = min; 6.313 - en.setMinFixed(); 6.314 - } 6.315 - } // USE_SUBEXP_CALL 6.316 + if (en.isMinFixed()) { 6.317 + min = en.minLength; 6.318 + } else { 6.319 + min = getMinMatchLength(en.target); 6.320 + en.minLength = min; 6.321 + en.setMinFixed(); 6.322 + } 6.323 break; 6.324 6.325 case EncloseType.OPTION: 6.326 @@ -547,17 +313,6 @@ 6.327 } 6.328 break; 6.329 6.330 - case NodeType.CALL: 6.331 - if (Config.USE_SUBEXP_CALL) { 6.332 - CallNode cn = (CallNode)node; 6.333 - if (!cn.isRecursion()) { 6.334 - max = getMaxMatchLength(cn.target); 6.335 - } else { 6.336 - max = MinMaxLen.INFINITE_DISTANCE; 6.337 - } 6.338 - } // USE_SUBEXP_CALL 6.339 - break; 6.340 - 6.341 case NodeType.QTFR: 6.342 QuantifierNode qn = (QuantifierNode)node; 6.343 if (qn.upper != 0) { 6.344 @@ -576,15 +331,13 @@ 6.345 EncloseNode en = (EncloseNode)node; 6.346 switch (en.type) { 6.347 case EncloseType.MEMORY: 6.348 - if (Config.USE_SUBEXP_CALL) { 6.349 - if (en.isMaxFixed()) { 6.350 - max = en.maxLength; 6.351 - } else { 6.352 - max = getMaxMatchLength(en.target); 6.353 - en.maxLength = max; 6.354 - en.setMaxFixed(); 6.355 - } 6.356 - } // USE_SUBEXP_CALL 6.357 + if (en.isMaxFixed()) { 6.358 + max = en.maxLength; 6.359 + } else { 6.360 + max = getMaxMatchLength(en.target); 6.361 + en.maxLength = max; 6.362 + en.setMaxFixed(); 6.363 + } 6.364 break; 6.365 6.366 case EncloseType.OPTION: 6.367 @@ -663,17 +416,6 @@ 6.368 } 6.369 break; 6.370 6.371 - case NodeType.CALL: 6.372 - if (Config.USE_SUBEXP_CALL) { 6.373 - CallNode cn = (CallNode)node; 6.374 - if (!cn.isRecursion()) { 6.375 - len = getCharLengthTree(cn.target, level); 6.376 - } else { 6.377 - returnCode = GET_CHAR_LEN_VARLEN; 6.378 - } 6.379 - } // USE_SUBEXP_CALL 6.380 - break; 6.381 - 6.382 case NodeType.CTYPE: 6.383 len = 1; 6.384 6.385 @@ -686,17 +428,15 @@ 6.386 EncloseNode en = (EncloseNode)node; 6.387 switch(en.type) { 6.388 case EncloseType.MEMORY: 6.389 - if (Config.USE_SUBEXP_CALL) { 6.390 - if (en.isCLenFixed()) { 6.391 - len = en.charLength; 6.392 - } else { 6.393 - len = getCharLengthTree(en.target, level); 6.394 - if (returnCode == 0) { 6.395 - en.charLength = len; 6.396 - en.setCLenFixed(); 6.397 - } 6.398 + if (en.isCLenFixed()) { 6.399 + len = en.charLength; 6.400 + } else { 6.401 + len = getCharLengthTree(en.target, level); 6.402 + if (returnCode == 0) { 6.403 + en.charLength = len; 6.404 + en.setCLenFixed(); 6.405 } 6.406 - } // USE_SUBEXP_CALL 6.407 + } 6.408 break; 6.409 6.410 case EncloseType.OPTION: 6.411 @@ -727,10 +467,6 @@ 6.412 switch(x.getType()) { 6.413 case NodeType.CTYPE: 6.414 switch(yType) { 6.415 - case NodeType.CTYPE: 6.416 - CTypeNode cny = (CTypeNode)y; 6.417 - CTypeNode cnx = (CTypeNode)x; 6.418 - return cny.ctype == cnx.ctype && cny.not != cnx.not; 6.419 6.420 case NodeType.CCLASS: 6.421 // !swap:! 6.422 @@ -756,37 +492,6 @@ 6.423 CClassNode xc = (CClassNode)x; 6.424 6.425 switch(yType) { 6.426 - case NodeType.CTYPE: 6.427 - switch(((CTypeNode)y).ctype) { 6.428 - case CharacterType.WORD: 6.429 - if (!((CTypeNode)y).not) { 6.430 - if (xc.mbuf == null && !xc.isNot()) { 6.431 - for (int i=0; i<BitSet.SINGLE_BYTE_SIZE; i++) { 6.432 - if (xc.bs.at(i)) { 6.433 - if (EncodingHelper.isWord(i)) return false; 6.434 - } 6.435 - } 6.436 - return true; 6.437 - } 6.438 - return false; 6.439 - } else { 6.440 - for (int i=0; i<BitSet.SINGLE_BYTE_SIZE; i++) { 6.441 - if (!EncodingHelper.isWord(i)) { 6.442 - if (!xc.isNot()) { 6.443 - if (xc.bs.at(i)) return false; 6.444 - } else { 6.445 - if (!xc.bs.at(i)) return false; 6.446 - } 6.447 - } 6.448 - } 6.449 - return true; 6.450 - } 6.451 - // break; not reached 6.452 - 6.453 - default: 6.454 - break; 6.455 - } // inner switch 6.456 - break; 6.457 6.458 case NodeType.CCLASS: 6.459 CClassNode yc = (CClassNode)y; 6.460 @@ -820,17 +525,6 @@ 6.461 if (xs.length() == 0) break; 6.462 6.463 switch (yType) { 6.464 - case NodeType.CTYPE: 6.465 - CTypeNode cy = ((CTypeNode)y); 6.466 - switch (cy.ctype) { 6.467 - case CharacterType.WORD: 6.468 - return !cy.not; 6.469 - 6.470 - default: 6.471 - break; 6.472 - 6.473 - } // inner switch 6.474 - break; 6.475 6.476 case NodeType.CCLASS: 6.477 CClassNode cc = (CClassNode)y; 6.478 @@ -873,9 +567,6 @@ 6.479 case NodeType.CANY: 6.480 break; 6.481 6.482 - case NodeType.CALL: 6.483 - break; // if (Config.USE_SUBEXP_CALL) 6.484 - 6.485 case NodeType.CTYPE: 6.486 case NodeType.CCLASS: 6.487 if (!exact) n = node; 6.488 @@ -977,316 +668,6 @@ 6.489 return invalid; 6.490 } 6.491 6.492 - private static final int RECURSION_EXIST = 1; 6.493 - private static final int RECURSION_INFINITE = 2; 6.494 - private int subexpInfRecursiveCheck(Node node, boolean head) { 6.495 - int r = 0; 6.496 - 6.497 - switch (node.getType()) { 6.498 - case NodeType.LIST: 6.499 - int min; 6.500 - ConsAltNode x = (ConsAltNode)node; 6.501 - do { 6.502 - int ret = subexpInfRecursiveCheck(x.car, head); 6.503 - if (ret == RECURSION_INFINITE) return ret; 6.504 - r |= ret; 6.505 - if (head) { 6.506 - min = getMinMatchLength(x.car); 6.507 - if (min != 0) head = false; 6.508 - } 6.509 - } while ((x = x.cdr) != null); 6.510 - break; 6.511 - 6.512 - case NodeType.ALT: 6.513 - ConsAltNode can = (ConsAltNode)node; 6.514 - r = RECURSION_EXIST; 6.515 - do { 6.516 - int ret = subexpInfRecursiveCheck(can.car, head); 6.517 - if (ret == RECURSION_INFINITE) return ret; 6.518 - r &= ret; 6.519 - } while ((can = can.cdr) != null); 6.520 - break; 6.521 - 6.522 - case NodeType.QTFR: 6.523 - QuantifierNode qn = (QuantifierNode)node; 6.524 - r = subexpInfRecursiveCheck(qn.target, head); 6.525 - if (r == RECURSION_EXIST) { 6.526 - if (qn.lower == 0) r = 0; 6.527 - } 6.528 - break; 6.529 - 6.530 - case NodeType.ANCHOR: 6.531 - AnchorNode an = (AnchorNode)node; 6.532 - switch (an.type) { 6.533 - case AnchorType.PREC_READ: 6.534 - case AnchorType.PREC_READ_NOT: 6.535 - case AnchorType.LOOK_BEHIND: 6.536 - case AnchorType.LOOK_BEHIND_NOT: 6.537 - r = subexpInfRecursiveCheck(an.target, head); 6.538 - break; 6.539 - } // inner switch 6.540 - break; 6.541 - 6.542 - case NodeType.CALL: 6.543 - r = subexpInfRecursiveCheck(((CallNode)node).target, head); 6.544 - break; 6.545 - 6.546 - case NodeType.ENCLOSE: 6.547 - EncloseNode en = (EncloseNode)node; 6.548 - if (en.isMark2()) { 6.549 - return 0; 6.550 - } else if (en.isMark1()) { 6.551 - return !head ? RECURSION_EXIST : RECURSION_INFINITE; 6.552 - // throw exception here ??? 6.553 - } else { 6.554 - en.setMark2(); 6.555 - r = subexpInfRecursiveCheck(en.target, head); 6.556 - en.clearMark2(); 6.557 - } 6.558 - break; 6.559 - 6.560 - default: 6.561 - break; 6.562 - } // switch 6.563 - return r; 6.564 - } 6.565 - 6.566 - protected final int subexpInfRecursiveCheckTrav(Node node) { 6.567 - int r = 0; 6.568 - 6.569 - switch (node.getType()) { 6.570 - case NodeType.LIST: 6.571 - case NodeType.ALT: 6.572 - ConsAltNode can = (ConsAltNode)node; 6.573 - do { 6.574 - r = subexpInfRecursiveCheckTrav(can.car); 6.575 - } while (r == 0 && (can = can.cdr) != null); 6.576 - break; 6.577 - 6.578 - case NodeType.QTFR: 6.579 - r = subexpInfRecursiveCheckTrav(((QuantifierNode)node).target); 6.580 - break; 6.581 - 6.582 - case NodeType.ANCHOR: 6.583 - AnchorNode an = (AnchorNode)node; 6.584 - switch (an.type) { 6.585 - case AnchorType.PREC_READ: 6.586 - case AnchorType.PREC_READ_NOT: 6.587 - case AnchorType.LOOK_BEHIND: 6.588 - case AnchorType.LOOK_BEHIND_NOT: 6.589 - r = subexpInfRecursiveCheckTrav(an.target); 6.590 - break; 6.591 - } // inner switch 6.592 - break; 6.593 - 6.594 - case NodeType.ENCLOSE: 6.595 - EncloseNode en = (EncloseNode)node; 6.596 - if (en.isRecursion()) { 6.597 - en.setMark1(); 6.598 - r = subexpInfRecursiveCheck(en.target, true); 6.599 - if (r > 0) newValueException(ERR_NEVER_ENDING_RECURSION); 6.600 - en.clearMark1(); 6.601 - } 6.602 - r = subexpInfRecursiveCheckTrav(en.target); 6.603 - break; 6.604 - 6.605 - default: 6.606 - break; 6.607 - } // switch 6.608 - 6.609 - return r; 6.610 - } 6.611 - 6.612 - private int subexpRecursiveCheck(Node node) { 6.613 - int r = 0; 6.614 - 6.615 - switch (node.getType()) { 6.616 - case NodeType.LIST: 6.617 - case NodeType.ALT: 6.618 - ConsAltNode can = (ConsAltNode)node; 6.619 - do { 6.620 - r |= subexpRecursiveCheck(can.car); 6.621 - } while ((can = can.cdr) != null); 6.622 - break; 6.623 - 6.624 - case NodeType.QTFR: 6.625 - r = subexpRecursiveCheck(((QuantifierNode)node).target); 6.626 - break; 6.627 - 6.628 - case NodeType.ANCHOR: 6.629 - AnchorNode an = (AnchorNode)node; 6.630 - switch (an.type) { 6.631 - case AnchorType.PREC_READ: 6.632 - case AnchorType.PREC_READ_NOT: 6.633 - case AnchorType.LOOK_BEHIND: 6.634 - case AnchorType.LOOK_BEHIND_NOT: 6.635 - r = subexpRecursiveCheck(an.target); 6.636 - break; 6.637 - } // inner switch 6.638 - break; 6.639 - 6.640 - case NodeType.CALL: 6.641 - CallNode cn = (CallNode)node; 6.642 - r = subexpRecursiveCheck(cn.target); 6.643 - if (r != 0) cn.setRecursion(); 6.644 - break; 6.645 - 6.646 - case NodeType.ENCLOSE: 6.647 - EncloseNode en = (EncloseNode)node; 6.648 - if (en.isMark2()) { 6.649 - return 0; 6.650 - } else if (en.isMark1()) { 6.651 - return 1; /* recursion */ 6.652 - } else { 6.653 - en.setMark2(); 6.654 - r = subexpRecursiveCheck(en.target); 6.655 - en.clearMark2(); 6.656 - } 6.657 - break; 6.658 - 6.659 - default: 6.660 - break; 6.661 - } // switch 6.662 - 6.663 - return r; 6.664 - } 6.665 - 6.666 - private static final int FOUND_CALLED_NODE = 1; 6.667 - protected final int subexpRecursiveCheckTrav(Node node) { 6.668 - int r = 0; 6.669 - 6.670 - switch (node.getType()) { 6.671 - case NodeType.LIST: 6.672 - case NodeType.ALT: 6.673 - ConsAltNode can = (ConsAltNode)node; 6.674 - do { 6.675 - int ret = subexpRecursiveCheckTrav(can.car); 6.676 - if (ret == FOUND_CALLED_NODE) { 6.677 - r = FOUND_CALLED_NODE; 6.678 - } 6.679 - // else if (ret < 0) return ret; ??? 6.680 - } while ((can = can.cdr) != null); 6.681 - break; 6.682 - 6.683 - case NodeType.QTFR: 6.684 - QuantifierNode qn = (QuantifierNode)node; 6.685 - r = subexpRecursiveCheckTrav(qn.target); 6.686 - if (qn.upper == 0) { 6.687 - if (r == FOUND_CALLED_NODE) qn.isRefered = true; 6.688 - } 6.689 - break; 6.690 - 6.691 - case NodeType.ANCHOR: 6.692 - AnchorNode an = (AnchorNode)node; 6.693 - switch (an.type) { 6.694 - case AnchorType.PREC_READ: 6.695 - case AnchorType.PREC_READ_NOT: 6.696 - case AnchorType.LOOK_BEHIND: 6.697 - case AnchorType.LOOK_BEHIND_NOT: 6.698 - r = subexpRecursiveCheckTrav(an.target); 6.699 - break; 6.700 - } // inner switch 6.701 - break; 6.702 - 6.703 - case NodeType.ENCLOSE: 6.704 - EncloseNode en = (EncloseNode)node; 6.705 - if (!en.isRecursion()) { 6.706 - if (en.isCalled()) { 6.707 - en.setMark1(); 6.708 - r = subexpRecursiveCheck(en.target); 6.709 - if (r != 0) en.setRecursion(); 6.710 - en.clearMark1(); 6.711 - } 6.712 - } 6.713 - r = subexpRecursiveCheckTrav(en.target); 6.714 - if (en.isCalled()) r |= FOUND_CALLED_NODE; 6.715 - break; 6.716 - 6.717 - default: 6.718 - break; 6.719 - } // switch 6.720 - 6.721 - return r; 6.722 - } 6.723 - 6.724 - private void setCallAttr(CallNode cn) { 6.725 - cn.target = env.memNodes[cn.groupNum]; // no setTarget in call nodes! 6.726 - if (cn.target == null) newValueException(ERR_UNDEFINED_NAME_REFERENCE, cn.nameP, cn.nameEnd); 6.727 - 6.728 - ((EncloseNode)cn.target).setCalled(); 6.729 - env.btMemStart = BitStatus.bsOnAt(env.btMemStart, cn.groupNum); 6.730 - cn.unsetAddrList = env.unsetAddrList; 6.731 - } 6.732 - 6.733 - protected final void setupSubExpCall(Node node) { 6.734 - 6.735 - switch(node.getType()) { 6.736 - case NodeType.LIST: 6.737 - ConsAltNode ln = (ConsAltNode)node; 6.738 - do { 6.739 - setupSubExpCall(ln.car); 6.740 - } while ((ln = ln.cdr) != null); 6.741 - break; 6.742 - 6.743 - case NodeType.ALT: 6.744 - ConsAltNode can = (ConsAltNode)node; 6.745 - do { 6.746 - setupSubExpCall(can.car); 6.747 - } while ((can = can.cdr) != null); 6.748 - break; 6.749 - 6.750 - case NodeType.QTFR: 6.751 - setupSubExpCall(((QuantifierNode)node).target); 6.752 - break; 6.753 - 6.754 - case NodeType.ENCLOSE: 6.755 - setupSubExpCall(((EncloseNode)node).target); 6.756 - break; 6.757 - 6.758 - case NodeType.CALL: 6.759 - CallNode cn = (CallNode)node; 6.760 - 6.761 - if (cn.groupNum != 0) { 6.762 - int gNum = cn.groupNum; 6.763 - 6.764 - if (Config.USE_NAMED_GROUP) { 6.765 - if (env.numNamed > 0 && syntax.captureOnlyNamedGroup() && !isCaptureGroup(env.option)) { 6.766 - newValueException(ERR_NUMBERED_BACKREF_OR_CALL_NOT_ALLOWED); 6.767 - } 6.768 - } // USE_NAMED_GROUP 6.769 - if (gNum > env.numMem) newValueException(ERR_UNDEFINED_GROUP_REFERENCE, cn.nameP, cn.nameEnd); 6.770 - setCallAttr(cn); 6.771 - } else { 6.772 - if (Config.USE_NAMED_GROUP) { 6.773 - NameEntry ne = regex.nameToGroupNumbers(cn.name, cn.nameP, cn.nameEnd); 6.774 - 6.775 - if (ne == null) { 6.776 - newValueException(ERR_UNDEFINED_NAME_REFERENCE, cn.nameP, cn.nameEnd); 6.777 - } else if (ne.backNum > 1) { 6.778 - newValueException(ERR_MULTIPLEX_DEFINITION_NAME_CALL, cn.nameP, cn.nameEnd); 6.779 - } else { 6.780 - cn.groupNum = ne.backRef1; // ne.backNum == 1 ? ne.backRef1 : ne.backRefs[0]; // ??? need to check ? 6.781 - setCallAttr(cn); 6.782 - } 6.783 - } 6.784 - } 6.785 - break; 6.786 - 6.787 - case NodeType.ANCHOR: 6.788 - AnchorNode an = (AnchorNode)node; 6.789 - switch (an.type) { 6.790 - case AnchorType.PREC_READ: 6.791 - case AnchorType.PREC_READ_NOT: 6.792 - case AnchorType.LOOK_BEHIND: 6.793 - case AnchorType.LOOK_BEHIND_NOT: 6.794 - setupSubExpCall(an.target); 6.795 - break; 6.796 - } 6.797 - break; 6.798 - 6.799 - } // switch 6.800 - } 6.801 - 6.802 /* divide different length alternatives in look-behind. 6.803 (?<=A|B) ==> (?<=A)|(?<=B) 6.804 (?<!A|B) ==> (?<!A)(?<!B) 6.805 @@ -1523,125 +904,6 @@ 6.806 return xnode; 6.807 } 6.808 6.809 - private static final int CEC_THRES_NUM_BIG_REPEAT = 512; 6.810 - private static final int CEC_INFINITE_NUM = 0x7fffffff; 6.811 - 6.812 - private static final int CEC_IN_INFINITE_REPEAT = (1<<0); 6.813 - private static final int CEC_IN_FINITE_REPEAT = (1<<1); 6.814 - private static final int CEC_CONT_BIG_REPEAT = (1<<2); 6.815 - 6.816 - protected final int setupCombExpCheck(Node node, int state) { 6.817 - int r = state; 6.818 - int ret; 6.819 - 6.820 - switch (node.getType()) { 6.821 - case NodeType.LIST: 6.822 - ConsAltNode ln = (ConsAltNode)node; 6.823 - 6.824 - do { 6.825 - r = setupCombExpCheck(ln.car, r); 6.826 - //prev = ((ConsAltNode)node).car; 6.827 - } while (r >= 0 && (ln = ln.cdr) != null); 6.828 - break; 6.829 - 6.830 - case NodeType.ALT: 6.831 - ConsAltNode an = (ConsAltNode)node; 6.832 - do { 6.833 - ret = setupCombExpCheck(an.car, state); 6.834 - r |= ret; 6.835 - } while (ret >= 0 && (an = an.cdr) != null); 6.836 - break; 6.837 - 6.838 - case NodeType.QTFR: 6.839 - QuantifierNode qn = (QuantifierNode)node; 6.840 - int childState = state; 6.841 - int addState = 0; 6.842 - int varNum; 6.843 - 6.844 - if (!isRepeatInfinite(qn.upper)) { 6.845 - if (qn.upper > 1) { 6.846 - /* {0,1}, {1,1} are allowed */ 6.847 - childState |= CEC_IN_FINITE_REPEAT; 6.848 - 6.849 - /* check (a*){n,m}, (a+){n,m} => (a*){n,n}, (a+){n,n} */ 6.850 - if (env.backrefedMem == 0) { 6.851 - if (qn.target.getType() == NodeType.ENCLOSE) { 6.852 - EncloseNode en = (EncloseNode)qn.target; 6.853 - if (en.type == EncloseType.MEMORY) { 6.854 - if (en.target.getType() == NodeType.QTFR) { 6.855 - QuantifierNode q = (QuantifierNode)en.target; 6.856 - if (isRepeatInfinite(q.upper) && q.greedy == qn.greedy) { 6.857 - qn.upper = qn.lower == 0 ? 1 : qn.lower; 6.858 - if (qn.upper == 1) childState = state; 6.859 - } 6.860 - } 6.861 - } 6.862 - } 6.863 - } 6.864 - } 6.865 - } 6.866 - 6.867 - if ((state & CEC_IN_FINITE_REPEAT) != 0) { 6.868 - qn.combExpCheckNum = -1; 6.869 - } else { 6.870 - if (isRepeatInfinite(qn.upper)) { 6.871 - varNum = CEC_INFINITE_NUM; 6.872 - childState |= CEC_IN_INFINITE_REPEAT; 6.873 - } else { 6.874 - varNum = qn.upper - qn.lower; 6.875 - } 6.876 - 6.877 - if (varNum >= CEC_THRES_NUM_BIG_REPEAT) addState |= CEC_CONT_BIG_REPEAT; 6.878 - 6.879 - if (((state & CEC_IN_INFINITE_REPEAT) != 0 && varNum != 0) || 6.880 - ((state & CEC_CONT_BIG_REPEAT) != 0 && varNum >= CEC_THRES_NUM_BIG_REPEAT)) { 6.881 - if (qn.combExpCheckNum == 0) { 6.882 - env.numCombExpCheck++; 6.883 - qn.combExpCheckNum = env.numCombExpCheck; 6.884 - if (env.currMaxRegNum > env.combExpMaxRegNum) { 6.885 - env.combExpMaxRegNum = env.currMaxRegNum; 6.886 - } 6.887 - } 6.888 - } 6.889 - } 6.890 - r = setupCombExpCheck(qn.target, childState); 6.891 - r |= addState; 6.892 - break; 6.893 - 6.894 - case NodeType.ENCLOSE: 6.895 - EncloseNode en = (EncloseNode)node; 6.896 - switch( en.type) { 6.897 - case EncloseNode.MEMORY: 6.898 - if (env.currMaxRegNum < en.regNum) { 6.899 - env.currMaxRegNum = en.regNum; 6.900 - } 6.901 - r = setupCombExpCheck(en.target, state); 6.902 - break; 6.903 - 6.904 - default: 6.905 - r = setupCombExpCheck(en.target, state); 6.906 - } // inner switch 6.907 - break; 6.908 - 6.909 - case NodeType.CALL: 6.910 - if (Config.USE_SUBEXP_CALL) { 6.911 - CallNode cn = (CallNode)node; 6.912 - if (cn.isRecursion()) { 6.913 - env.hasRecursion = true; 6.914 - } else { 6.915 - r = setupCombExpCheck(cn.target, state); 6.916 - } 6.917 - } // USE_SUBEXP_CALL 6.918 - break; 6.919 - 6.920 - default: 6.921 - break; 6.922 - 6.923 - } // switch 6.924 - 6.925 - return r; 6.926 - } 6.927 - 6.928 private static final int IN_ALT = (1<<0); 6.929 private static final int IN_NOT = (1<<1); 6.930 private static final int IN_REPEAT = (1<<2); 6.931 @@ -1691,20 +953,12 @@ 6.932 case NodeType.CANY: 6.933 break; 6.934 6.935 - case NodeType.CALL: // if (Config.USE_SUBEXP_CALL) ? 6.936 - break; 6.937 - 6.938 case NodeType.BREF: 6.939 BackRefNode br = (BackRefNode)node; 6.940 for (int i=0; i<br.backNum; i++) { 6.941 if (br.back[i] > env.numMem) newValueException(ERR_INVALID_BACKREF); 6.942 env.backrefedMem = bsOnAt(env.backrefedMem, br.back[i]); 6.943 env.btMemStart = bsOnAt(env.btMemStart, br.back[i]); 6.944 - if (Config.USE_BACKREF_WITH_LEVEL) { 6.945 - if (br.isNestLevel()) { 6.946 - env.btMemEnd = bsOnAt(env.btMemEnd, br.back[i]); 6.947 - } 6.948 - } // USE_BACKREF_AT_LEVEL 6.949 ((EncloseNode)env.memNodes[br.back[i]]).setMemBackrefed(); 6.950 } 6.951 break; 6.952 @@ -1916,37 +1170,6 @@ 6.953 break; 6.954 } 6.955 6.956 - case NodeType.CTYPE: { 6.957 - int min; 6.958 - int max = 1; 6.959 - if (max == 1) { 6.960 - min = 1; 6.961 - CTypeNode cn = (CTypeNode)node; 6.962 - 6.963 - switch (cn.ctype) { 6.964 - case CharacterType.WORD: 6.965 - if (cn.not) { 6.966 - for (int i=0; i<BitSet.SINGLE_BYTE_SIZE; i++) { 6.967 - if (!EncodingHelper.isWord(i)) { 6.968 - opt.map.addChar(i); 6.969 - } 6.970 - } 6.971 - } else { 6.972 - for (int i=0; i<BitSet.SINGLE_BYTE_SIZE; i++) { 6.973 - if (EncodingHelper.isWord(i)) { 6.974 - opt.map.addChar(i); 6.975 - } 6.976 - } 6.977 - } 6.978 - break; 6.979 - } // inner switch 6.980 - } else { 6.981 - min = 1; 6.982 - } 6.983 - opt.length.set(min, max); 6.984 - break; 6.985 - } 6.986 - 6.987 case NodeType.CANY: { 6.988 opt.length.set(1, 1); 6.989 break; 6.990 @@ -2008,20 +1231,6 @@ 6.991 break; 6.992 } 6.993 6.994 - case NodeType.CALL: { 6.995 - if (Config.USE_SUBEXP_CALL) { 6.996 - CallNode cn = (CallNode)node; 6.997 - if (cn.isRecursion()) { 6.998 - opt.length.set(0, MinMaxLen.INFINITE_DISTANCE); 6.999 - } else { 6.1000 - int safe = oenv.options; 6.1001 - oenv.options = ((EncloseNode)cn.target).option; 6.1002 - optimizeNodeLeft(cn.target, opt, oenv); 6.1003 - oenv.options = safe; 6.1004 - } 6.1005 - } // USE_SUBEXP_CALL 6.1006 - break; 6.1007 - } 6.1008 6.1009 case NodeType.QTFR: { 6.1010 NodeOptInfo nopt = new NodeOptInfo(); 6.1011 @@ -2081,7 +1290,7 @@ 6.1012 break; 6.1013 6.1014 case EncloseType.MEMORY: 6.1015 - if (Config.USE_SUBEXP_CALL && ++en.optCount > MAX_NODE_OPT_INFO_REF_COUNT) { 6.1016 + if (++en.optCount > MAX_NODE_OPT_INFO_REF_COUNT) { 6.1017 int min = 0; 6.1018 int max = MinMaxLen.INFINITE_DISTANCE; 6.1019 if (en.isMinFixed()) min = en.minLength;
7.1 --- a/src/jdk/nashorn/internal/runtime/regexp/joni/ArrayCompiler.java Thu May 16 13:44:25 2013 +0200 7.2 +++ b/src/jdk/nashorn/internal/runtime/regexp/joni/ArrayCompiler.java Thu May 16 19:52:39 2013 +0200 7.3 @@ -28,8 +28,6 @@ 7.4 import jdk.nashorn.internal.runtime.regexp.joni.ast.AnchorNode; 7.5 import jdk.nashorn.internal.runtime.regexp.joni.ast.BackRefNode; 7.6 import jdk.nashorn.internal.runtime.regexp.joni.ast.CClassNode; 7.7 -import jdk.nashorn.internal.runtime.regexp.joni.ast.CTypeNode; 7.8 -import jdk.nashorn.internal.runtime.regexp.joni.ast.CallNode; 7.9 import jdk.nashorn.internal.runtime.regexp.joni.ast.ConsAltNode; 7.10 import jdk.nashorn.internal.runtime.regexp.joni.ast.EncloseNode; 7.11 import jdk.nashorn.internal.runtime.regexp.joni.ast.Node; 7.12 @@ -71,11 +69,6 @@ 7.13 regex.templates = templates; 7.14 regex.templateNum = templateNum; 7.15 regex.factory = MatcherFactory.DEFAULT; 7.16 - 7.17 - if (Config.USE_SUBEXP_CALL && analyser.env.unsetAddrList != null) { 7.18 - analyser.env.unsetAddrList.fix(regex); 7.19 - analyser.env.unsetAddrList = null; 7.20 - } 7.21 } 7.22 7.23 @Override 7.24 @@ -119,7 +112,7 @@ 7.25 return isNeedStrLenOpExact(op); 7.26 } 7.27 7.28 - private int selectStrOpcode(int mbLength, int strLength, boolean ignoreCase) { 7.29 + private int selectStrOpcode(int strLength, boolean ignoreCase) { 7.30 int op; 7.31 7.32 if (ignoreCase) { 7.33 @@ -128,31 +121,14 @@ 7.34 default:op = OPCode.EXACTN_IC; break; 7.35 } // switch 7.36 } else { 7.37 - switch (mbLength) { 7.38 - case 1: 7.39 - switch (strLength) { 7.40 - case 1: op = OPCode.EXACT1; break; 7.41 - case 2: op = OPCode.EXACT2; break; 7.42 - case 3: op = OPCode.EXACT3; break; 7.43 - case 4: op = OPCode.EXACT4; break; 7.44 - case 5: op = OPCode.EXACT5; break; 7.45 - default:op = OPCode.EXACTN; break; 7.46 - } // inner switch 7.47 - break; 7.48 - case 2: 7.49 - switch (strLength) { 7.50 - case 1: op = OPCode.EXACTMB2N1; break; 7.51 - case 2: op = OPCode.EXACTMB2N2; break; 7.52 - case 3: op = OPCode.EXACTMB2N3; break; 7.53 - default:op = OPCode.EXACTMB2N; break; 7.54 - } // inner switch 7.55 - break; 7.56 - case 3: 7.57 - op = OPCode.EXACTMB3N; 7.58 - break; 7.59 - default: 7.60 - op = OPCode.EXACTMBN; 7.61 - } // switch 7.62 + switch (strLength) { 7.63 + case 1: op = OPCode.EXACT1; break; 7.64 + case 2: op = OPCode.EXACT2; break; 7.65 + case 3: op = OPCode.EXACT3; break; 7.66 + case 4: op = OPCode.EXACT4; break; 7.67 + case 5: op = OPCode.EXACT5; break; 7.68 + default:op = OPCode.EXACTN; break; 7.69 + } // inner switch 7.70 } 7.71 return op; 7.72 } 7.73 @@ -185,8 +161,8 @@ 7.74 } 7.75 } 7.76 7.77 - private int addCompileStringlength(char[] chars, int p, int mbLength, int strLength, boolean ignoreCase) { 7.78 - int op = selectStrOpcode(mbLength, strLength, ignoreCase); 7.79 + private int addCompileStringlength(char[] chars, int p, int strLength, boolean ignoreCase) { 7.80 + int op = selectStrOpcode(strLength, ignoreCase); 7.81 int len = OPSize.OPCODE; 7.82 7.83 if (Config.USE_STRING_TEMPLATES && opTemplated(op)) { 7.84 @@ -194,25 +170,21 @@ 7.85 len += OPSize.LENGTH + OPSize.INDEX + OPSize.INDEX; 7.86 } else { 7.87 if (isNeedStrLenOpExact(op)) len += OPSize.LENGTH; 7.88 - len += mbLength * strLength; 7.89 + len += strLength; 7.90 } 7.91 if (op == OPCode.EXACTMBN) len += OPSize.LENGTH; 7.92 return len; 7.93 } 7.94 7.95 @Override 7.96 - protected final void addCompileString(char[] chars, int p, int mbLength, int strLength, boolean ignoreCase) { 7.97 - int op = selectStrOpcode(mbLength, strLength, ignoreCase); 7.98 + protected final void addCompileString(char[] chars, int p, int strLength, boolean ignoreCase) { 7.99 + int op = selectStrOpcode(strLength, ignoreCase); 7.100 addOpcode(op); 7.101 7.102 - if (op == OPCode.EXACTMBN) addLength(mbLength); 7.103 + if (op == OPCode.EXACTMBN) addLength(1); 7.104 7.105 if (isNeedStrLenOpExact(op)) { 7.106 - if (op == OPCode.EXACTN_IC || op == OPCode.EXACTN_IC_SB) { 7.107 - addLength(mbLength * strLength); 7.108 - } else { 7.109 - addLength(strLength); 7.110 - } 7.111 + addLength(strLength); 7.112 } 7.113 7.114 if (Config.USE_STRING_TEMPLATES && opTemplated(op)) { 7.115 @@ -220,7 +192,7 @@ 7.116 addInt(p); 7.117 addTemplate(chars); 7.118 } else { 7.119 - addChars(chars, p, mbLength * strLength); 7.120 + addChars(chars, p, strLength); 7.121 } 7.122 } 7.123 7.124 @@ -242,14 +214,14 @@ 7.125 slen++; 7.126 p++; 7.127 } 7.128 - int r = addCompileStringlength(chars, prev, 1, slen, ambig); 7.129 + int r = addCompileStringlength(chars, prev, slen, ambig); 7.130 rlen += r; 7.131 return rlen; 7.132 } 7.133 7.134 private int compileLengthStringRawNode(StringNode sn) { 7.135 if (sn.length() <= 0) return 0; 7.136 - return addCompileStringlength(sn.chars, sn.p, 1 /*sb*/, sn.length(), false); 7.137 + return addCompileStringlength(sn.chars, sn.p, sn.length(), false); 7.138 } 7.139 7.140 private void addMultiByteCClass(CodeRangeBuffer mbuf) { 7.141 @@ -312,26 +284,6 @@ 7.142 } 7.143 7.144 @Override 7.145 - protected void compileCTypeNode(CTypeNode node) { 7.146 - CTypeNode cn = node; 7.147 - int op; 7.148 - switch (cn.ctype) { 7.149 - case CharacterType.WORD: 7.150 - if (cn.not) { 7.151 - op = OPCode.NOT_WORD; 7.152 - } else { 7.153 - op = OPCode.WORD; 7.154 - } 7.155 - break; 7.156 - 7.157 - default: 7.158 - newInternalException(ERR_PARSER_BUG); 7.159 - return; // not reached 7.160 - } // inner switch 7.161 - addOpcode(op); 7.162 - } 7.163 - 7.164 - @Override 7.165 protected void compileAnyCharNode() { 7.166 if (isMultiline(regex.options)) { 7.167 addOpcode(OPCode.ANYCHAR_ML); 7.168 @@ -341,30 +293,15 @@ 7.169 } 7.170 7.171 @Override 7.172 - protected void compileCallNode(CallNode node) { 7.173 - addOpcode(OPCode.CALL); 7.174 - node.unsetAddrList.add(codeLength, node.target); 7.175 - addAbsAddr(0); /*dummy addr.*/ 7.176 - } 7.177 - 7.178 - @Override 7.179 protected void compileBackrefNode(BackRefNode node) { 7.180 BackRefNode br = node; 7.181 - if (Config.USE_BACKREF_WITH_LEVEL && br.isNestLevel()) { 7.182 - addOpcode(OPCode.BACKREF_WITH_LEVEL); 7.183 - addOption(regex.options & Option.IGNORECASE); 7.184 - addLength(br.nestLevel); 7.185 - // !goto add_bacref_mems;! 7.186 - addLength(br.backNum); 7.187 - for (int i=br.backNum-1; i>=0; i--) addMemNum(br.back[i]); 7.188 - return; 7.189 - } else { // USE_BACKREF_AT_LEVEL 7.190 - if (br.backNum == 1) { 7.191 - if (isIgnoreCase(regex.options)) { 7.192 - addOpcode(OPCode.BACKREFN_IC); 7.193 - addMemNum(br.back[0]); 7.194 - } else { 7.195 - switch (br.back[0]) { 7.196 + // USE_BACKREF_AT_LEVEL 7.197 + if (br.backNum == 1) { 7.198 + if (isIgnoreCase(regex.options)) { 7.199 + addOpcode(OPCode.BACKREFN_IC); 7.200 + addMemNum(br.back[0]); 7.201 + } else { 7.202 + switch (br.back[0]) { 7.203 case 1: 7.204 addOpcode(OPCode.BACKREF1); 7.205 break; 7.206 @@ -375,18 +312,17 @@ 7.207 addOpcode(OPCode.BACKREFN); 7.208 addOpcode(br.back[0]); 7.209 break; 7.210 - } // switch 7.211 - } 7.212 + } // switch 7.213 + } 7.214 + } else { 7.215 + if (isIgnoreCase(regex.options)) { 7.216 + addOpcode(OPCode.BACKREF_MULTI_IC); 7.217 } else { 7.218 - if (isIgnoreCase(regex.options)) { 7.219 - addOpcode(OPCode.BACKREF_MULTI_IC); 7.220 - } else { 7.221 - addOpcode(OPCode.BACKREF_MULTI); 7.222 - } 7.223 - // !add_bacref_mems:! 7.224 - addLength(br.backNum); 7.225 - for (int i=br.backNum-1; i>=0; i--) addMemNum(br.back[i]); 7.226 + addOpcode(OPCode.BACKREF_MULTI); 7.227 } 7.228 + // !add_bacref_mems:! 7.229 + addLength(br.backNum); 7.230 + for (int i=br.backNum-1; i>=0; i--) addMemNum(br.back[i]); 7.231 } 7.232 } 7.233 7.234 @@ -419,7 +355,7 @@ 7.235 7.236 compileTreeEmptyCheck(qn.target, emptyInfo); 7.237 7.238 - if ((Config.USE_SUBEXP_CALL && regex.numCall > 0) || qn.isInRepeat()) { 7.239 + if (qn.isInRepeat()) { 7.240 addOpcode(qn.greedy ? OPCode.REPEAT_INC_SG : OPCode.REPEAT_INC_NG_SG); 7.241 } else { 7.242 addOpcode(qn.greedy ? OPCode.REPEAT_INC : OPCode.REPEAT_INC_NG); 7.243 @@ -434,193 +370,6 @@ 7.244 return ckn > 0; 7.245 } 7.246 7.247 - private int compileCECLengthQuantifierNode(QuantifierNode qn) { 7.248 - boolean infinite = isRepeatInfinite(qn.upper); 7.249 - int emptyInfo = qn.targetEmptyInfo; 7.250 - 7.251 - int tlen = compileLengthTree(qn.target); 7.252 - int ckn = regex.numCombExpCheck > 0 ? qn.combExpCheckNum : 0; 7.253 - int cklen = cknOn(ckn) ? OPSize.STATE_CHECK_NUM : 0; 7.254 - 7.255 - /* anychar repeat */ 7.256 - if (qn.target.getType() == NodeType.CANY) { 7.257 - if (qn.greedy && infinite) { 7.258 - if (qn.nextHeadExact != null && !cknOn(ckn)) { 7.259 - return OPSize.ANYCHAR_STAR_PEEK_NEXT + tlen * qn.lower + cklen; 7.260 - } else { 7.261 - return OPSize.ANYCHAR_STAR + tlen * qn.lower + cklen; 7.262 - } 7.263 - } 7.264 - } 7.265 - 7.266 - int modTLen; 7.267 - if (emptyInfo != 0) { 7.268 - modTLen = tlen + (OPSize.NULL_CHECK_START + OPSize.NULL_CHECK_END); 7.269 - } else { 7.270 - modTLen = tlen; 7.271 - } 7.272 - 7.273 - int len; 7.274 - if (infinite && qn.lower <= 1) { 7.275 - if (qn.greedy) { 7.276 - if (qn.lower == 1) { 7.277 - len = OPSize.JUMP; 7.278 - } else { 7.279 - len = 0; 7.280 - } 7.281 - len += OPSize.PUSH + cklen + modTLen + OPSize.JUMP; 7.282 - } else { 7.283 - if (qn.lower == 0) { 7.284 - len = OPSize.JUMP; 7.285 - } else { 7.286 - len = 0; 7.287 - } 7.288 - len += modTLen + OPSize.PUSH + cklen; 7.289 - } 7.290 - } else if (qn.upper == 0) { 7.291 - if (qn.isRefered) { /* /(?<n>..){0}/ */ 7.292 - len = OPSize.JUMP + tlen; 7.293 - } else { 7.294 - len = 0; 7.295 - } 7.296 - } else if (qn.upper == 1 && qn.greedy) { 7.297 - if (qn.lower == 0) { 7.298 - if (cknOn(ckn)) { 7.299 - len = OPSize.STATE_CHECK_PUSH + tlen; 7.300 - } else { 7.301 - len = OPSize.PUSH + tlen; 7.302 - } 7.303 - } else { 7.304 - len = tlen; 7.305 - } 7.306 - } else if (!qn.greedy && qn.upper == 1 && qn.lower == 0) { /* '??' */ 7.307 - len = OPSize.PUSH + cklen + OPSize.JUMP + tlen; 7.308 - } else { 7.309 - len = OPSize.REPEAT_INC + modTLen + OPSize.OPCODE + OPSize.RELADDR + OPSize.MEMNUM; 7.310 - 7.311 - if (cknOn(ckn)) { 7.312 - len += OPSize.STATE_CHECK; 7.313 - } 7.314 - } 7.315 - return len; 7.316 - } 7.317 - 7.318 - @Override 7.319 - protected void compileCECQuantifierNode(QuantifierNode qn) { 7.320 - boolean infinite = isRepeatInfinite(qn.upper); 7.321 - int emptyInfo = qn.targetEmptyInfo; 7.322 - 7.323 - int tlen = compileLengthTree(qn.target); 7.324 - 7.325 - int ckn = regex.numCombExpCheck > 0 ? qn.combExpCheckNum : 0; 7.326 - 7.327 - if (qn.isAnyCharStar()) { 7.328 - compileTreeNTimes(qn.target, qn.lower); 7.329 - if (qn.nextHeadExact != null && !cknOn(ckn)) { 7.330 - if (isMultiline(regex.options)) { 7.331 - addOpcode(OPCode.ANYCHAR_ML_STAR_PEEK_NEXT); 7.332 - } else { 7.333 - addOpcode(OPCode.ANYCHAR_STAR_PEEK_NEXT); 7.334 - } 7.335 - if (cknOn(ckn)) { 7.336 - addStateCheckNum(ckn); 7.337 - } 7.338 - StringNode sn = (StringNode)qn.nextHeadExact; 7.339 - addChars(sn.chars, sn.p, 1); 7.340 - return; 7.341 - } else { 7.342 - if (isMultiline(regex.options)) { 7.343 - if (cknOn(ckn)) { 7.344 - addOpcode(OPCode.STATE_CHECK_ANYCHAR_ML_STAR); 7.345 - } else { 7.346 - addOpcode(OPCode.ANYCHAR_ML_STAR); 7.347 - } 7.348 - } else { 7.349 - if (cknOn(ckn)) { 7.350 - addOpcode(OPCode.STATE_CHECK_ANYCHAR_STAR); 7.351 - } else { 7.352 - addOpcode(OPCode.ANYCHAR_STAR); 7.353 - } 7.354 - } 7.355 - if (cknOn(ckn)) { 7.356 - addStateCheckNum(ckn); 7.357 - } 7.358 - return; 7.359 - } 7.360 - } 7.361 - 7.362 - int modTLen; 7.363 - if (emptyInfo != 0) { 7.364 - modTLen = tlen + (OPSize.NULL_CHECK_START + OPSize.NULL_CHECK_END); 7.365 - } else { 7.366 - modTLen = tlen; 7.367 - } 7.368 - if (infinite && qn.lower <= 1) { 7.369 - if (qn.greedy) { 7.370 - if (qn.lower == 1) { 7.371 - addOpcodeRelAddr(OPCode.JUMP, cknOn(ckn) ? OPSize.STATE_CHECK_PUSH : 7.372 - OPSize.PUSH); 7.373 - } 7.374 - if (cknOn(ckn)) { 7.375 - addOpcode(OPCode.STATE_CHECK_PUSH); 7.376 - addStateCheckNum(ckn); 7.377 - addRelAddr(modTLen + OPSize.JUMP); 7.378 - } else { 7.379 - addOpcodeRelAddr(OPCode.PUSH, modTLen + OPSize.JUMP); 7.380 - } 7.381 - compileTreeEmptyCheck(qn.target, emptyInfo); 7.382 - addOpcodeRelAddr(OPCode.JUMP, -(modTLen + OPSize.JUMP + (cknOn(ckn) ? 7.383 - OPSize.STATE_CHECK_PUSH : 7.384 - OPSize.PUSH))); 7.385 - } else { 7.386 - if (qn.lower == 0) { 7.387 - addOpcodeRelAddr(OPCode.JUMP, modTLen); 7.388 - } 7.389 - compileTreeEmptyCheck(qn.target, emptyInfo); 7.390 - if (cknOn(ckn)) { 7.391 - addOpcode(OPCode.STATE_CHECK_PUSH_OR_JUMP); 7.392 - addStateCheckNum(ckn); 7.393 - addRelAddr(-(modTLen + OPSize.STATE_CHECK_PUSH_OR_JUMP)); 7.394 - } else { 7.395 - addOpcodeRelAddr(OPCode.PUSH, -(modTLen + OPSize.PUSH)); 7.396 - } 7.397 - } 7.398 - } else if (qn.upper == 0) { 7.399 - if (qn.isRefered) { /* /(?<n>..){0}/ */ 7.400 - addOpcodeRelAddr(OPCode.JUMP, tlen); 7.401 - compileTree(qn.target); 7.402 - } // else r=0 ??? 7.403 - } else if (qn.upper == 1 && qn.greedy) { 7.404 - if (qn.lower == 0) { 7.405 - if (cknOn(ckn)) { 7.406 - addOpcode(OPCode.STATE_CHECK_PUSH); 7.407 - addStateCheckNum(ckn); 7.408 - addRelAddr(tlen); 7.409 - } else { 7.410 - addOpcodeRelAddr(OPCode.PUSH, tlen); 7.411 - } 7.412 - } 7.413 - compileTree(qn.target); 7.414 - } else if (!qn.greedy && qn.upper == 1 && qn.lower == 0){ /* '??' */ 7.415 - if (cknOn(ckn)) { 7.416 - addOpcode(OPCode.STATE_CHECK_PUSH); 7.417 - addStateCheckNum(ckn); 7.418 - addRelAddr(OPSize.JUMP); 7.419 - } else { 7.420 - addOpcodeRelAddr(OPCode.PUSH, OPSize.JUMP); 7.421 - } 7.422 - 7.423 - addOpcodeRelAddr(OPCode.JUMP, tlen); 7.424 - compileTree(qn.target); 7.425 - } else { 7.426 - compileRangeRepeatNode(qn, modTLen, emptyInfo); 7.427 - if (cknOn(ckn)) { 7.428 - addOpcode(OPCode.STATE_CHECK); 7.429 - addStateCheckNum(ckn); 7.430 - } 7.431 - } 7.432 - } 7.433 - 7.434 private int compileNonCECLengthQuantifierNode(QuantifierNode qn) { 7.435 boolean infinite = isRepeatInfinite(qn.upper); 7.436 int emptyInfo = qn.targetEmptyInfo; 7.437 @@ -821,21 +570,12 @@ 7.438 int len; 7.439 switch (node.type) { 7.440 case EncloseType.MEMORY: 7.441 - if (Config.USE_SUBEXP_CALL && node.isCalled()) { 7.442 - len = OPSize.MEMORY_START_PUSH + tlen + OPSize.CALL + OPSize.JUMP + OPSize.RETURN; 7.443 - if (bsAt(regex.btMemEnd, node.regNum)) { 7.444 - len += node.isRecursion() ? OPSize.MEMORY_END_PUSH_REC : OPSize.MEMORY_END_PUSH; 7.445 - } else { 7.446 - len += node.isRecursion() ? OPSize.MEMORY_END_REC : OPSize.MEMORY_END; 7.447 - } 7.448 - } else { // USE_SUBEXP_CALL 7.449 - if (bsAt(regex.btMemStart, node.regNum)) { 7.450 - len = OPSize.MEMORY_START_PUSH; 7.451 - } else { 7.452 - len = OPSize.MEMORY_START; 7.453 - } 7.454 - len += tlen + (bsAt(regex.btMemEnd, node.regNum) ? OPSize.MEMORY_END_PUSH : OPSize.MEMORY_END); 7.455 + if (bsAt(regex.btMemStart, node.regNum)) { 7.456 + len = OPSize.MEMORY_START_PUSH; 7.457 + } else { 7.458 + len = OPSize.MEMORY_START; 7.459 } 7.460 + len += tlen + (bsAt(regex.btMemEnd, node.regNum) ? OPSize.MEMORY_END_PUSH : OPSize.MEMORY_END); 7.461 break; 7.462 7.463 case EncloseType.STOP_BACKTRACK: 7.464 @@ -860,23 +600,6 @@ 7.465 int len; 7.466 switch (node.type) { 7.467 case EncloseType.MEMORY: 7.468 - if (Config.USE_SUBEXP_CALL) { 7.469 - if (node.isCalled()) { 7.470 - addOpcode(OPCode.CALL); 7.471 - node.callAddr = codeLength + OPSize.ABSADDR + OPSize.JUMP; 7.472 - node.setAddrFixed(); 7.473 - addAbsAddr(node.callAddr); 7.474 - len = compileLengthTree(node.target); 7.475 - len += OPSize.MEMORY_START_PUSH + OPSize.RETURN; 7.476 - if (bsAt(regex.btMemEnd, node.regNum)) { 7.477 - len += node.isRecursion() ? OPSize.MEMORY_END_PUSH_REC : OPSize.MEMORY_END_PUSH; 7.478 - } else { 7.479 - len += node.isRecursion() ? OPSize.MEMORY_END_REC : OPSize.MEMORY_END; 7.480 - } 7.481 - addOpcodeRelAddr(OPCode.JUMP, len); 7.482 - } 7.483 - } // USE_SUBEXP_CALL 7.484 - 7.485 if (bsAt(regex.btMemStart, node.regNum)) { 7.486 addOpcode(OPCode.MEMORY_START_PUSH); 7.487 } else { 7.488 @@ -886,22 +609,12 @@ 7.489 addMemNum(node.regNum); 7.490 compileTree(node.target); 7.491 7.492 - if (Config.USE_SUBEXP_CALL && node.isCalled()) { 7.493 - if (bsAt(regex.btMemEnd, node.regNum)) { 7.494 - addOpcode(node.isRecursion() ? OPCode.MEMORY_END_PUSH_REC : OPCode.MEMORY_END_PUSH); 7.495 - } else { 7.496 - addOpcode(node.isRecursion() ? OPCode.MEMORY_END_REC : OPCode.MEMORY_END); 7.497 - } 7.498 - addMemNum(node.regNum); 7.499 - addOpcode(OPCode.RETURN); 7.500 - } else { // USE_SUBEXP_CALL 7.501 - if (bsAt(regex.btMemEnd, node.regNum)) { 7.502 - addOpcode(OPCode.MEMORY_END_PUSH); 7.503 - } else { 7.504 - addOpcode(OPCode.MEMORY_END); 7.505 - } 7.506 - addMemNum(node.regNum); 7.507 + if (bsAt(regex.btMemEnd, node.regNum)) { 7.508 + addOpcode(OPCode.MEMORY_END_PUSH); 7.509 + } else { 7.510 + addOpcode(OPCode.MEMORY_END); 7.511 } 7.512 + addMemNum(node.regNum); 7.513 break; 7.514 7.515 case EncloseType.STOP_BACKTRACK: 7.516 @@ -1078,32 +791,17 @@ 7.517 case NodeType.BREF: 7.518 BackRefNode br = (BackRefNode)node; 7.519 7.520 - if (Config.USE_BACKREF_WITH_LEVEL && br.isNestLevel()) { 7.521 - len = OPSize.OPCODE + OPSize.OPTION + OPSize.LENGTH + 7.522 - OPSize.LENGTH + (OPSize.MEMNUM * br.backNum); 7.523 - } else { // USE_BACKREF_AT_LEVEL 7.524 - if (br.backNum == 1) { 7.525 - len = ((!isIgnoreCase(regex.options) && br.back[0] <= 2) 7.526 - ? OPSize.OPCODE : (OPSize.OPCODE + OPSize.MEMNUM)); 7.527 - } else { 7.528 - len = OPSize.OPCODE + OPSize.LENGTH + (OPSize.MEMNUM * br.backNum); 7.529 - } 7.530 + // USE_BACKREF_AT_LEVEL 7.531 + if (br.backNum == 1) { 7.532 + len = ((!isIgnoreCase(regex.options) && br.back[0] <= 2) 7.533 + ? OPSize.OPCODE : (OPSize.OPCODE + OPSize.MEMNUM)); 7.534 + } else { 7.535 + len = OPSize.OPCODE + OPSize.LENGTH + (OPSize.MEMNUM * br.backNum); 7.536 } 7.537 break; 7.538 7.539 - case NodeType.CALL: 7.540 - if (Config.USE_SUBEXP_CALL) { 7.541 - len = OPSize.CALL; 7.542 - break; 7.543 - } // USE_SUBEXP_CALL 7.544 - break; 7.545 - 7.546 case NodeType.QTFR: 7.547 - if (Config.USE_COMBINATION_EXPLOSION_CHECK) { 7.548 - len = compileCECLengthQuantifierNode((QuantifierNode)node); 7.549 - } else { 7.550 - len = compileNonCECLengthQuantifierNode((QuantifierNode)node); 7.551 - } 7.552 + len = compileNonCECLengthQuantifierNode((QuantifierNode)node); 7.553 break; 7.554 7.555 case NodeType.ENCLOSE:
8.1 --- a/src/jdk/nashorn/internal/runtime/regexp/joni/AsmCompiler.java Thu May 16 13:44:25 2013 +0200 8.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 8.3 @@ -1,109 +0,0 @@ 8.4 -/* 8.5 - * Permission is hereby granted, free of charge, to any person obtaining a copy of 8.6 - * this software and associated documentation files (the "Software"), to deal in 8.7 - * the Software without restriction, including without limitation the rights to 8.8 - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 8.9 - * of the Software, and to permit persons to whom the Software is furnished to do 8.10 - * so, subject to the following conditions: 8.11 - * 8.12 - * The above copyright notice and this permission notice shall be included in all 8.13 - * copies or substantial portions of the Software. 8.14 - * 8.15 - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 8.16 - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 8.17 - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 8.18 - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 8.19 - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 8.20 - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 8.21 - * SOFTWARE. 8.22 - */ 8.23 -package jdk.nashorn.internal.runtime.regexp.joni; 8.24 - 8.25 -import jdk.nashorn.internal.runtime.regexp.joni.ast.AnchorNode; 8.26 -import jdk.nashorn.internal.runtime.regexp.joni.ast.BackRefNode; 8.27 -import jdk.nashorn.internal.runtime.regexp.joni.ast.CClassNode; 8.28 -import jdk.nashorn.internal.runtime.regexp.joni.ast.CTypeNode; 8.29 -import jdk.nashorn.internal.runtime.regexp.joni.ast.CallNode; 8.30 -import jdk.nashorn.internal.runtime.regexp.joni.ast.ConsAltNode; 8.31 -import jdk.nashorn.internal.runtime.regexp.joni.ast.EncloseNode; 8.32 -import jdk.nashorn.internal.runtime.regexp.joni.ast.QuantifierNode; 8.33 - 8.34 -final class AsmCompiler extends AsmCompilerSupport { 8.35 - 8.36 - public AsmCompiler(Analyser analyser) { 8.37 - super(analyser); 8.38 - } 8.39 - 8.40 - @Override 8.41 - protected void prepare() { 8.42 - REG_NUM++; 8.43 - prepareMachine(); 8.44 - prepareMachineInit(); 8.45 - prepareMachineMatch(); 8.46 - 8.47 - prepareFactory(); 8.48 - prepareFactoryInit(); 8.49 - } 8.50 - 8.51 - @Override 8.52 - protected void finish() { 8.53 - setupFactoryInit(); 8.54 - 8.55 - setupMachineInit(); 8.56 - setupMachineMatch(); 8.57 - 8.58 - setupClasses(); 8.59 - } 8.60 - 8.61 - @Override 8.62 - protected void compileAltNode(ConsAltNode node) { 8.63 - } 8.64 - 8.65 - @Override 8.66 - protected void addCompileString(char[] chars, int p, int mbLength, int strLength, boolean ignoreCase) { 8.67 - String template = installTemplate(chars, p, strLength); 8.68 - } 8.69 - 8.70 - @Override 8.71 - protected void compileCClassNode(CClassNode node) { 8.72 - if (node.bs != null) { 8.73 - String bitsetName = installBitSet(node.bs.bits); 8.74 - } 8.75 - } 8.76 - 8.77 - @Override 8.78 - protected void compileCTypeNode(CTypeNode node) { 8.79 - } 8.80 - 8.81 - @Override 8.82 - protected void compileAnyCharNode() { 8.83 - } 8.84 - 8.85 - @Override 8.86 - protected void compileBackrefNode(BackRefNode node) { 8.87 - } 8.88 - 8.89 - @Override 8.90 - protected void compileCallNode(CallNode node) { 8.91 - } 8.92 - 8.93 - @Override 8.94 - protected void compileCECQuantifierNode(QuantifierNode node) { 8.95 - } 8.96 - 8.97 - @Override 8.98 - protected void compileNonCECQuantifierNode(QuantifierNode node) { 8.99 - } 8.100 - 8.101 - @Override 8.102 - protected void compileOptionNode(EncloseNode node) { 8.103 - } 8.104 - 8.105 - @Override 8.106 - protected void compileEncloseNode(EncloseNode node) { 8.107 - } 8.108 - 8.109 - @Override 8.110 - protected void compileAnchorNode(AnchorNode node) { 8.111 - } 8.112 -}
9.1 --- a/src/jdk/nashorn/internal/runtime/regexp/joni/AsmCompilerSupport.java Thu May 16 13:44:25 2013 +0200 9.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 9.3 @@ -1,267 +0,0 @@ 9.4 -/* 9.5 - * Permission is hereby granted, free of charge, to any person obtaining a copy of 9.6 - * this software and associated documentation files (the "Software"), to deal in 9.7 - * the Software without restriction, including without limitation the rights to 9.8 - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 9.9 - * of the Software, and to permit persons to whom the Software is furnished to do 9.10 - * so, subject to the following conditions: 9.11 - * 9.12 - * The above copyright notice and this permission notice shall be included in all 9.13 - * copies or substantial portions of the Software. 9.14 - * 9.15 - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 9.16 - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 9.17 - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 9.18 - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 9.19 - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 9.20 - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 9.21 - * SOFTWARE. 9.22 - */ 9.23 -package jdk.nashorn.internal.runtime.regexp.joni; 9.24 - 9.25 -import java.io.FileOutputStream; 9.26 -import java.io.IOException; 9.27 - 9.28 -import jdk.nashorn.internal.runtime.regexp.joni.constants.AsmConstants; 9.29 -import jdk.internal.org.objectweb.asm.ClassWriter; 9.30 -import jdk.internal.org.objectweb.asm.MethodVisitor; 9.31 -import jdk.internal.org.objectweb.asm.Opcodes; 9.32 - 9.33 -abstract class AsmCompilerSupport extends Compiler implements Opcodes, AsmConstants { 9.34 - protected ClassWriter factory; // matcher allocator, also bit set, code rage and string template container 9.35 - protected MethodVisitor factoryInit;// factory constructor 9.36 - protected String factoryName; 9.37 - 9.38 - protected ClassWriter machine; // matcher 9.39 - protected MethodVisitor machineInit;// matcher constructor 9.40 - protected MethodVisitor match; // actual matcher implementation (the matchAt method) 9.41 - protected String machineName; 9.42 - 9.43 - // we will? try to manage visitMaxs ourselves for efficiency 9.44 - protected int maxStack = 1; 9.45 - protected int maxVars = LAST_INDEX; 9.46 - 9.47 - // for field generation 9.48 - protected int bitsets, ranges, templates; 9.49 - 9.50 - // simple class name postfix scheme for now 9.51 - static int REG_NUM = 0; 9.52 - 9.53 - // dummy class loader for now 9.54 - private static final class DummyClassLoader extends ClassLoader { 9.55 - public Class<?> defineClass(String name, byte[] bytes) { 9.56 - return super.defineClass(name, bytes, 0, bytes.length); 9.57 - } 9.58 - }; 9.59 - 9.60 - private static final DummyClassLoader loader = new DummyClassLoader(); 9.61 - 9.62 - AsmCompilerSupport(Analyser analyser) { 9.63 - super(analyser); 9.64 - } 9.65 - 9.66 - protected final void prepareFactory() { 9.67 - factory = new ClassWriter(ClassWriter.COMPUTE_MAXS); 9.68 - factoryName = "jdk/nashorn/internal/runtime/regexp/joni/MatcherFactory" + REG_NUM; 9.69 - 9.70 - factory.visit(V1_4, ACC_PUBLIC + ACC_FINAL, factoryName, null, "jdk/nashorn/internal/runtime/regexp/joni/MatcherFactory", null); 9.71 - 9.72 - MethodVisitor create = factory.visitMethod(ACC_SYNTHETIC, "create", "(Lorg/joni/Regex;[BII)Lorg/joni/Matcher;", null, null); 9.73 - create.visitTypeInsn(NEW, machineName); 9.74 - create.visitInsn(DUP); // instance 9.75 - create.visitVarInsn(ALOAD, 1); // Regex 9.76 - create.visitVarInsn(ALOAD, 2); // bytes[] 9.77 - create.visitVarInsn(ILOAD, 3); // p 9.78 - create.visitVarInsn(ILOAD, 4); // end 9.79 - create.visitMethodInsn(INVOKESPECIAL, machineName, "<init>", "(Lorg/joni/Regex;[BII)V"); 9.80 - create.visitInsn(ARETURN); 9.81 - create.visitMaxs(0, 0); 9.82 - //create.visitMaxs(6, 5); 9.83 - create.visitEnd(); 9.84 - } 9.85 - 9.86 - protected final void prepareFactoryInit() { 9.87 - factoryInit = factory.visitMethod(ACC_PUBLIC, "<init>", "()V", null, null); 9.88 - factoryInit.visitVarInsn(ALOAD, 0); 9.89 - factoryInit.visitMethodInsn(INVOKESPECIAL, "jdk/nashorn/internal/runtime/regexp/joni/MatcherFactory", "<init>", "()V"); 9.90 - } 9.91 - 9.92 - protected final void setupFactoryInit() { 9.93 - factoryInit.visitInsn(RETURN); 9.94 - factoryInit.visitMaxs(0, 0); 9.95 - //init.visitMaxs(1, 1); 9.96 - factoryInit.visitEnd(); 9.97 - } 9.98 - 9.99 - protected final void prepareMachine() { 9.100 - machine = new ClassWriter(ClassWriter.COMPUTE_MAXS); 9.101 - machineName = "jdk/nashorn/internal/runtime/regexp/joni/NativeMachine" + REG_NUM; 9.102 - } 9.103 - 9.104 - protected final void prepareMachineInit() { 9.105 - machine.visit(V1_4, ACC_PUBLIC + ACC_FINAL, machineName, null, "jdk/nashorn/internal/runtime/regexp/joni/NativeMachine", null); 9.106 - machineInit = machine.visitMethod(ACC_PROTECTED, "<init>", "(Lorg/joni/Regex;[BII)V", null, null); 9.107 - machineInit.visitVarInsn(ALOAD, THIS); // this 9.108 - machineInit.visitVarInsn(ALOAD, 1); // Regex 9.109 - machineInit.visitVarInsn(ALOAD, 2); // bytes[] 9.110 - machineInit.visitVarInsn(ILOAD, 3); // p 9.111 - machineInit.visitVarInsn(ILOAD, 4); // end 9.112 - machineInit.visitMethodInsn(INVOKESPECIAL, "jdk/nashorn/internal/runtime/regexp/joni/NativeMachine", "<init>", "(Lorg/joni/Regex;[BII)V"); 9.113 - } 9.114 - 9.115 - protected final void setupMachineInit() { 9.116 - if (bitsets + ranges + templates > 0) { // ok, some of these are in use, we'd like to cache the factory 9.117 - machine.visitField(ACC_PRIVATE + ACC_FINAL, "factory", "L" + factoryName + ";", null, null); 9.118 - machineInit.visitVarInsn(ALOAD, THIS); // this 9.119 - machineInit.visitVarInsn(ALOAD, 1); // this, Regex 9.120 - machineInit.visitFieldInsn(GETFIELD, "jdk/nashorn/internal/runtime/regexp/joni/Regex", "factory", "Lorg/joni/MatcherFactory;"); // this, factory 9.121 - machineInit.visitTypeInsn(CHECKCAST, factoryName); 9.122 - machineInit.visitFieldInsn(PUTFIELD, machineName, "factory", "L" + factoryName + ";"); // [] 9.123 - } 9.124 - 9.125 - machineInit.visitInsn(RETURN); 9.126 - machineInit.visitMaxs(0, 0); 9.127 - //init.visitMaxs(5, 5); 9.128 - machineInit.visitEnd(); 9.129 - } 9.130 - 9.131 - protected final void prepareMachineMatch() { 9.132 - match = machine.visitMethod(ACC_SYNTHETIC, "matchAt", "(III)I", null, null); 9.133 - move(S, SSTART); // s = sstart 9.134 - load("bytes", "[B"); // 9.135 - astore(BYTES); // byte[]bytes = this.bytes 9.136 - } 9.137 - 9.138 - protected final void setupMachineMatch() { 9.139 - match.visitInsn(ICONST_M1); 9.140 - match.visitInsn(IRETURN); 9.141 - 9.142 - match.visitMaxs(maxStack, maxVars); 9.143 - match.visitEnd(); 9.144 - } 9.145 - 9.146 - protected final void setupClasses() { 9.147 - byte[]factoryCode = factory.toByteArray(); 9.148 - byte[]machineCode = machine.toByteArray(); 9.149 - 9.150 - if (Config.DEBUG_ASM) { 9.151 - try { 9.152 - FileOutputStream fos; 9.153 - fos = new FileOutputStream(factoryName.substring(factoryName.lastIndexOf('/') + 1) + ".class"); 9.154 - fos.write(factoryCode); 9.155 - fos.close(); 9.156 - fos = new FileOutputStream(machineName.substring(machineName.lastIndexOf('/') + 1) + ".class"); 9.157 - fos.write(machineCode); 9.158 - fos.close(); 9.159 - } catch (IOException ioe) { 9.160 - ioe.printStackTrace(Config.err); 9.161 - } 9.162 - } 9.163 - 9.164 - loader.defineClass(machineName.replace('/', '.'), machineCode); 9.165 - Class<?> cls = loader.defineClass(factoryName.replace('/', '.'), factoryCode); 9.166 - try { 9.167 - regex.factory = (MatcherFactory)cls.newInstance(); 9.168 - } catch(Exception e) { 9.169 - e.printStackTrace(Config.err); 9.170 - } 9.171 - } 9.172 - 9.173 - protected final void aload(int var) { 9.174 - match.visitVarInsn(ALOAD, var); 9.175 - } 9.176 - 9.177 - protected final void astore(int var) { 9.178 - match.visitVarInsn(ASTORE, var); 9.179 - } 9.180 - 9.181 - protected final void loadThis() { 9.182 - match.visitVarInsn(ALOAD, THIS); 9.183 - } 9.184 - 9.185 - protected final void load(int var) { 9.186 - match.visitVarInsn(ILOAD, var); 9.187 - } 9.188 - 9.189 - protected final void store(int var) { 9.190 - match.visitVarInsn(ISTORE, var); 9.191 - } 9.192 - 9.193 - protected final void move(int to, int from) { 9.194 - load(from); 9.195 - store(to); 9.196 - } 9.197 - 9.198 - protected final void load(String field, String singature) { 9.199 - loadThis(); 9.200 - match.visitFieldInsn(GETFIELD, machineName, field, singature); 9.201 - } 9.202 - 9.203 - protected final void load(String field) { 9.204 - load(field, "I"); 9.205 - } 9.206 - 9.207 - protected final void store(String field, String singature) { 9.208 - loadThis(); 9.209 - match.visitFieldInsn(PUTFIELD, machineName, field, singature); 9.210 - } 9.211 - 9.212 - protected final void store(String field) { 9.213 - store(field, "I"); 9.214 - } 9.215 - 9.216 - protected final String installTemplate(char[] arr, int p, int length) { 9.217 - String templateName = TEMPLATE + ++templates; 9.218 - installArray(templateName, arr, p, length); 9.219 - return templateName; 9.220 - } 9.221 - 9.222 - protected final String installCodeRange(int[]arr) { 9.223 - String coreRangeName = CODERANGE + ++ranges; 9.224 - installArray(coreRangeName, arr); 9.225 - return coreRangeName; 9.226 - } 9.227 - 9.228 - protected final String installBitSet(int[]arr) { 9.229 - String bitsetName = BITSET + ++bitsets; 9.230 - installArray(bitsetName, arr); 9.231 - return bitsetName; 9.232 - } 9.233 - 9.234 - private void installArray(String name, int[]arr) { 9.235 - factory.visitField(ACC_PRIVATE + ACC_FINAL, name, "[I", null, null); 9.236 - factoryInit.visitVarInsn(ALOAD, THIS); // this; 9.237 - loadInt(factoryInit, arr.length); // this, length 9.238 - factoryInit.visitIntInsn(NEWARRAY, T_INT); // this, arr 9.239 - for (int i=0;i < arr.length; i++) buildArray(i, arr[i], IASTORE); 9.240 - factoryInit.visitFieldInsn(PUTFIELD, factoryName, name, "[I"); 9.241 - } 9.242 - 9.243 - private void installArray(String name, char[]arr, int p, int length) { 9.244 - factory.visitField(ACC_PRIVATE + ACC_FINAL, name, "[B", null, null); 9.245 - factoryInit.visitVarInsn(ALOAD, THIS); // this; 9.246 - loadInt(factoryInit, arr.length); // this, length 9.247 - factoryInit.visitIntInsn(NEWARRAY, T_BYTE); // this, arr 9.248 - for (int i=p, j=0; i < p + length; i++, j++) buildArray(j, arr[i] & 0xff, BASTORE); 9.249 - factoryInit.visitFieldInsn(PUTFIELD, factoryName, name, "[B"); 9.250 - } 9.251 - 9.252 - private void buildArray(int index, int value, int type) { 9.253 - factoryInit.visitInsn(DUP); // ... arr, arr 9.254 - loadInt(factoryInit, index); // ... arr, arr, index 9.255 - loadInt(factoryInit, value); // ... arr, arr, index, value 9.256 - factoryInit.visitInsn(type); // ... arr 9.257 - } 9.258 - 9.259 - private void loadInt(MethodVisitor mv, int value) { 9.260 - if (value >= -1 && value <= 5) { 9.261 - mv.visitInsn(value + ICONST_0); // ICONST_0 == 3 9.262 - } else if (value >= 6 && value <= 127 || value >= -128 && value <= -2) { 9.263 - mv.visitIntInsn(BIPUSH, value); 9.264 - } else if (value >= 128 && value <= 32767 || value >= -32768 && value <= -129) { 9.265 - mv.visitIntInsn(SIPUSH, value); 9.266 - } else { 9.267 - mv.visitLdcInsn(new Integer(value)); 9.268 - } 9.269 - } 9.270 -}
10.1 --- a/src/jdk/nashorn/internal/runtime/regexp/joni/BitSet.java Thu May 16 13:44:25 2013 +0200 10.2 +++ b/src/jdk/nashorn/internal/runtime/regexp/joni/BitSet.java Thu May 16 19:52:39 2013 +0200 10.3 @@ -51,10 +51,6 @@ 10.4 bits[pos >>> ROOM_SHIFT] &= ~bit(pos); 10.5 } 10.6 10.7 - public void invert(int pos) { 10.8 - bits[pos >>> ROOM_SHIFT] ^= bit(pos); 10.9 - } 10.10 - 10.11 public void clear() { 10.12 for (int i=0; i<BITSET_SIZE; i++) bits[i]=0; 10.13 } 10.14 @@ -70,10 +66,6 @@ 10.15 for (int i=from; i<=to && i < SINGLE_BYTE_SIZE; i++) set(i); 10.16 } 10.17 10.18 - public void setAll() { 10.19 - for (int i=0; i<BITSET_SIZE; i++) bits[i] = ~0; 10.20 - } 10.21 - 10.22 public void invert() { 10.23 for (int i=0; i<BITSET_SIZE; i++) bits[i] = ~bits[i]; 10.24 }
11.1 --- a/src/jdk/nashorn/internal/runtime/regexp/joni/BitStatus.java Thu May 16 13:44:25 2013 +0200 11.2 +++ b/src/jdk/nashorn/internal/runtime/regexp/joni/BitStatus.java Thu May 16 19:52:39 2013 +0200 11.3 @@ -25,12 +25,15 @@ 11.4 public static int bsClear() { 11.5 return 0; 11.6 } 11.7 + 11.8 public static int bsAll() { 11.9 return -1; 11.10 } 11.11 + 11.12 public static boolean bsAt(int stats, int n) { 11.13 return (n < BIT_STATUS_BITS_NUM ? stats & (1 << n) : (stats & 1)) != 0; 11.14 } 11.15 + 11.16 public static int bsOnAt(int stats, int n) { 11.17 if (n < BIT_STATUS_BITS_NUM) { 11.18 stats |= (1 << n); 11.19 @@ -39,10 +42,6 @@ 11.20 } 11.21 return stats; 11.22 } 11.23 - public static int bsOnAtSimple(int stats, int n) { 11.24 - if (n < BIT_STATUS_BITS_NUM) stats |= (1 << n); 11.25 - return stats; 11.26 - } 11.27 11.28 public static int bsOnOff(int v, int f, boolean negative) { 11.29 if (negative) {
12.1 --- a/src/jdk/nashorn/internal/runtime/regexp/joni/ByteCodeMachine.java Thu May 16 13:44:25 2013 +0200 12.2 +++ b/src/jdk/nashorn/internal/runtime/regexp/joni/ByteCodeMachine.java Thu May 16 19:52:39 2013 +0200 12.3 @@ -53,56 +53,6 @@ 12.4 this.code = regex.code; 12.5 } 12.6 12.7 - protected int stkp; // a temporary 12.8 - private boolean makeCaptureHistoryTree(CaptureTreeNode node) { 12.9 - //CaptureTreeNode child; 12.10 - int k = stkp; 12.11 - //int k = kp; 12.12 - 12.13 - while (k < stk) { 12.14 - StackEntry e = stack[k]; 12.15 - if (e.type == MEM_START) { 12.16 - int n = e.getMemNum(); 12.17 - if (n <= Config.MAX_CAPTURE_HISTORY_GROUP && bsAt(regex.captureHistory, n)) { 12.18 - CaptureTreeNode child = new CaptureTreeNode(); 12.19 - child.group = n; 12.20 - child.beg = e.getMemPStr() - str; 12.21 - node.addChild(child); 12.22 - stkp = k + 1; 12.23 - if (makeCaptureHistoryTree(child)) return true; 12.24 - 12.25 - k = stkp; 12.26 - child.end = e.getMemPStr() - str; 12.27 - } 12.28 - } else if (e.type == MEM_END) { 12.29 - if (e.getMemNum() == node.group) { 12.30 - node.end = e.getMemPStr() - str; 12.31 - stkp = k; 12.32 - return false; 12.33 - } 12.34 - } 12.35 - } 12.36 - return true; /* 1: root node ending. */ 12.37 - } 12.38 - 12.39 - private void checkCaptureHistory(Region region) { 12.40 - CaptureTreeNode node; 12.41 - if (region.historyRoot == null) { 12.42 - node = region.historyRoot = new CaptureTreeNode(); 12.43 - } else { 12.44 - node = region.historyRoot; 12.45 - node.clear(); 12.46 - } 12.47 - 12.48 - // was clear ??? 12.49 - node.group = 0; 12.50 - node.beg = sstart - str; 12.51 - node.end = s - str; 12.52 - 12.53 - stkp = 0; 12.54 - makeCaptureHistoryTree(region.historyRoot); 12.55 - } 12.56 - 12.57 private boolean stringCmpIC(int caseFlodFlag, int s1, IntHolder ps2, int mbLen, int textEnd) { 12.58 12.59 int s2 = ps2.value; 12.60 @@ -175,13 +125,6 @@ 12.61 case OPCode.EXACT5: opExact5(); continue; 12.62 case OPCode.EXACTN: opExactN(); continue; 12.63 12.64 - case OPCode.EXACTMB2N1: opExactMB2N1(); break; 12.65 - case OPCode.EXACTMB2N2: opExactMB2N2(); continue; 12.66 - case OPCode.EXACTMB2N3: opExactMB2N3(); continue; 12.67 - case OPCode.EXACTMB2N: opExactMB2N(); continue; 12.68 - case OPCode.EXACTMB3N: opExactMB3N(); continue; 12.69 - case OPCode.EXACTMBN: opExactMBN(); continue; 12.70 - 12.71 case OPCode.EXACT1_IC: opExact1IC(); break; 12.72 case OPCode.EXACTN_IC: opExactNIC(); continue; 12.73 12.74 @@ -199,8 +142,6 @@ 12.75 case OPCode.ANYCHAR_ML_STAR: opAnyCharMLStar(); break; 12.76 case OPCode.ANYCHAR_STAR_PEEK_NEXT: opAnyCharStarPeekNext(); break; 12.77 case OPCode.ANYCHAR_ML_STAR_PEEK_NEXT: opAnyCharMLStarPeekNext(); break; 12.78 - case OPCode.STATE_CHECK_ANYCHAR_STAR: opStateCheckAnyCharStar(); break; 12.79 - case OPCode.STATE_CHECK_ANYCHAR_ML_STAR:opStateCheckAnyCharMLStar();break; 12.80 12.81 case OPCode.WORD: opWord(); break; 12.82 case OPCode.NOT_WORD: opNotWord(); break; 12.83 @@ -239,11 +180,6 @@ 12.84 case OPCode.JUMP: opJump(); continue; 12.85 case OPCode.PUSH: opPush(); continue; 12.86 12.87 - // CEC 12.88 - case OPCode.STATE_CHECK_PUSH: opStateCheckPush(); continue; 12.89 - case OPCode.STATE_CHECK_PUSH_OR_JUMP: opStateCheckPushOrJump(); continue; 12.90 - case OPCode.STATE_CHECK: opStateCheck(); continue; 12.91 - 12.92 case OPCode.POP: opPop(); continue; 12.93 case OPCode.PUSH_OR_JUMP_EXACT1: opPushOrJumpExact1(); continue; 12.94 case OPCode.PUSH_IF_PEEK_NEXT: opPushIfPeekNext(); continue; 12.95 @@ -266,10 +202,6 @@ 12.96 case OPCode.PUSH_LOOK_BEHIND_NOT: opPushLookBehindNot(); continue; 12.97 case OPCode.FAIL_LOOK_BEHIND_NOT: opFailLookBehindNot(); continue; 12.98 12.99 - // USE_SUBEXP_CALL 12.100 - case OPCode.CALL: opCall(); continue; 12.101 - case OPCode.RETURN: opReturn(); continue; 12.102 - 12.103 case OPCode.FINISH: 12.104 return finish(); 12.105 12.106 @@ -322,9 +254,6 @@ 12.107 12.108 } 12.109 12.110 - if (Config.USE_CAPTURE_HISTORY) { 12.111 - if (regex.captureHistory != 0) checkCaptureHistory(region); 12.112 - } 12.113 } else { 12.114 msaBegin = sstart - str; 12.115 msaEnd = s - str; 12.116 @@ -437,125 +366,6 @@ 12.117 sprev = s - 1; 12.118 } 12.119 12.120 - private void opExactMB2N1() { 12.121 - if (s + 2 > range) {opFail(); return;} 12.122 - if (code[ip] != chars[s]) {opFail(); return;} 12.123 - ip++; s++; 12.124 - if (code[ip] != chars[s]) {opFail(); return;} 12.125 - ip++; s++; 12.126 - sprev = sbegin; // break; 12.127 - } 12.128 - 12.129 - private void opExactMB2N2() { 12.130 - if (s + 4 > range) {opFail(); return;} 12.131 - if (code[ip] != chars[s]) {opFail(); return;} 12.132 - ip++; s++; 12.133 - if (code[ip] != chars[s]) {opFail(); return;} 12.134 - ip++; s++; 12.135 - sprev = s; 12.136 - if (code[ip] != chars[s]) {opFail(); return;} 12.137 - ip++; s++; 12.138 - if (code[ip] != chars[s]) {opFail(); return;} 12.139 - ip++; s++; 12.140 - } 12.141 - 12.142 - private void opExactMB2N3() { 12.143 - if (s + 6 > range) {opFail(); return;} 12.144 - if (code[ip] != chars[s]) {opFail(); return;} 12.145 - ip++; s++; 12.146 - if (code[ip] != chars[s]) {opFail(); return;} 12.147 - ip++; s++; 12.148 - if (code[ip] != chars[s]) {opFail(); return;} 12.149 - ip++; s++; 12.150 - if (code[ip] != chars[s]) {opFail(); return;} 12.151 - ip++; s++; 12.152 - sprev = s; 12.153 - if (code[ip] != chars[s]) {opFail(); return;} 12.154 - ip++; s++; 12.155 - if (code[ip] != chars[s]) {opFail(); return;} 12.156 - ip++; s++; 12.157 - } 12.158 - 12.159 - private void opExactMB2N() { 12.160 - int tlen = code[ip++]; 12.161 - if (s + tlen * 2 > range) {opFail(); return;} 12.162 - 12.163 - if (Config.USE_STRING_TEMPLATES) { 12.164 - char[] bs = regex.templates[code[ip++]]; 12.165 - int ps = code[ip++]; 12.166 - 12.167 - while(tlen-- > 0) { 12.168 - if (bs[ps] != chars[s]) {opFail(); return;} 12.169 - ps++; s++; 12.170 - if (bs[ps] != chars[s]) {opFail(); return;} 12.171 - ps++; s++; 12.172 - } 12.173 - } else { 12.174 - while(tlen-- > 0) { 12.175 - if (code[ip] != chars[s]) {opFail(); return;} 12.176 - ip++; s++; 12.177 - if (code[ip] != chars[s]) {opFail(); return;} 12.178 - ip++; s++; 12.179 - } 12.180 - } 12.181 - sprev = s - 2; 12.182 - } 12.183 - 12.184 - private void opExactMB3N() { 12.185 - int tlen = code[ip++]; 12.186 - if (s + tlen * 3 > range) {opFail(); return;} 12.187 - 12.188 - if (Config.USE_STRING_TEMPLATES) { 12.189 - char[] bs = regex.templates[code[ip++]]; 12.190 - int ps = code[ip++]; 12.191 - 12.192 - while (tlen-- > 0) { 12.193 - if (bs[ps] != chars[s]) {opFail(); return;} 12.194 - ps++; s++; 12.195 - if (bs[ps] != chars[s]) {opFail(); return;} 12.196 - ps++; s++; 12.197 - if (bs[ps] != chars[s]) {opFail(); return;} 12.198 - ps++; s++; 12.199 - } 12.200 - } else { 12.201 - while (tlen-- > 0) { 12.202 - if (code[ip] != chars[s]) {opFail(); return;} 12.203 - ip++; s++; 12.204 - if (code[ip] != chars[s]) {opFail(); return;} 12.205 - ip++; s++; 12.206 - if (code[ip] != chars[s]) {opFail(); return;} 12.207 - ip++; s++; 12.208 - } 12.209 - } 12.210 - 12.211 - sprev = s - 3; 12.212 - } 12.213 - 12.214 - private void opExactMBN() { 12.215 - int tlen = code[ip++]; /* mb-len */ 12.216 - int tlen2= code[ip++]; /* string len */ 12.217 - 12.218 - tlen2 *= tlen; 12.219 - if (s + tlen2 > range) {opFail(); return;} 12.220 - 12.221 - if (Config.USE_STRING_TEMPLATES) { 12.222 - char[] bs = regex.templates[code[ip++]]; 12.223 - int ps = code[ip++]; 12.224 - 12.225 - while (tlen2-- > 0) { 12.226 - if (bs[ps] != chars[s]) {opFail(); return;} 12.227 - ps++; s++; 12.228 - } 12.229 - } else { 12.230 - while (tlen2-- > 0) { 12.231 - if (code[ip] != chars[s]) {opFail(); return;} 12.232 - ip++; s++; 12.233 - } 12.234 - } 12.235 - 12.236 - sprev = s - tlen; 12.237 - } 12.238 - 12.239 private void opExact1IC() { 12.240 if (s >= range || code[ip] != Character.toLowerCase(chars[s++])) {opFail(); return;} 12.241 ip++; 12.242 @@ -748,34 +558,6 @@ 12.243 sprev = sbegin; // break; 12.244 } 12.245 12.246 - // CEC 12.247 - private void opStateCheckAnyCharStar() { 12.248 - int mem = code[ip++]; 12.249 - final char[] chars = this.chars; 12.250 - 12.251 - while (s < range) { 12.252 - if (stateCheckVal(s, mem)) {opFail(); return;} 12.253 - pushAltWithStateCheck(ip, s, sprev, mem); 12.254 - if (chars[s] == EncodingHelper.NEW_LINE) {opFail(); return;} 12.255 - sprev = s; 12.256 - s++; 12.257 - } 12.258 - sprev = sbegin; // break; 12.259 - } 12.260 - 12.261 - // CEC 12.262 - private void opStateCheckAnyCharMLStar() { 12.263 - int mem = code[ip++]; 12.264 - 12.265 - while (s < range) { 12.266 - if (stateCheckVal(s, mem)) {opFail(); return;} 12.267 - pushAltWithStateCheck(ip, s, sprev, mem); 12.268 - sprev = s; 12.269 - s++; 12.270 - } 12.271 - sprev = sbegin; // break; 12.272 - } 12.273 - 12.274 private void opWord() { 12.275 if (s >= range || !EncodingHelper.isWord(chars[s])) {opFail(); return;} 12.276 s++; 12.277 @@ -1223,33 +1005,6 @@ 12.278 pushAlt(ip + addr, s, sprev); 12.279 } 12.280 12.281 - // CEC 12.282 - private void opStateCheckPush() { 12.283 - int mem = code[ip++]; 12.284 - if (stateCheckVal(s, mem)) {opFail(); return;} 12.285 - int addr = code[ip++]; 12.286 - pushAltWithStateCheck(ip + addr, s, sprev, mem); 12.287 - } 12.288 - 12.289 - // CEC 12.290 - private void opStateCheckPushOrJump() { 12.291 - int mem = code[ip++]; 12.292 - int addr= code[ip++]; 12.293 - 12.294 - if (stateCheckVal(s, mem)) { 12.295 - ip += addr; 12.296 - } else { 12.297 - pushAltWithStateCheck(ip + addr, s, sprev, mem); 12.298 - } 12.299 - } 12.300 - 12.301 - // CEC 12.302 - private void opStateCheck() { 12.303 - int mem = code[ip++]; 12.304 - if (stateCheckVal(s, mem)) {opFail(); return;} 12.305 - pushStateCheck(s, mem); 12.306 - } 12.307 - 12.308 private void opPop() { 12.309 popOne(); 12.310 } 12.311 @@ -1425,17 +1180,6 @@ 12.312 opFail(); 12.313 } 12.314 12.315 - private void opCall() { 12.316 - int addr = code[ip++]; 12.317 - pushCallFrame(ip); 12.318 - ip = addr; // absolute address 12.319 - } 12.320 - 12.321 - private void opReturn() { 12.322 - ip = sreturn(); 12.323 - pushReturn(); 12.324 - } 12.325 - 12.326 private void opFail() { 12.327 if (stack == null) { 12.328 ip = regex.codeLength - 1; 12.329 @@ -1447,13 +1191,6 @@ 12.330 ip = e.getStatePCode(); 12.331 s = e.getStatePStr(); 12.332 sprev = e.getStatePStrPrev(); 12.333 - 12.334 - if (Config.USE_COMBINATION_EXPLOSION_CHECK) { 12.335 - if (e.getStateCheck() != 0) { 12.336 - e.type = STATE_CHECK_MARK; 12.337 - stk++; 12.338 - } 12.339 - } 12.340 } 12.341 12.342 private int finish() {
13.1 --- a/src/jdk/nashorn/internal/runtime/regexp/joni/ByteCodePrinter.java Thu May 16 13:44:25 2013 +0200 13.2 +++ b/src/jdk/nashorn/internal/runtime/regexp/joni/ByteCodePrinter.java Thu May 16 19:52:39 2013 +0200 13.3 @@ -34,6 +34,239 @@ 13.4 int operantCount; 13.5 WarnCallback warnings; 13.6 13.7 + private final static String OpCodeNames[] = new String[] { 13.8 + "finish", /*OP_FINISH*/ 13.9 + "end", /*OP_END*/ 13.10 + "exact1", /*OP_EXACT1*/ 13.11 + "exact2", /*OP_EXACT2*/ 13.12 + "exact3", /*OP_EXACT3*/ 13.13 + "exact4", /*OP_EXACT4*/ 13.14 + "exact5", /*OP_EXACT5*/ 13.15 + "exactn", /*OP_EXACTN*/ 13.16 + "exactmb2-n1", /*OP_EXACTMB2N1*/ 13.17 + "exactmb2-n2", /*OP_EXACTMB2N2*/ 13.18 + "exactmb2-n3", /*OP_EXACTMB2N3*/ 13.19 + "exactmb2-n", /*OP_EXACTMB2N*/ 13.20 + "exactmb3n", /*OP_EXACTMB3N*/ 13.21 + "exactmbn", /*OP_EXACTMBN*/ 13.22 + "exact1-ic", /*OP_EXACT1_IC*/ 13.23 + "exactn-ic", /*OP_EXACTN_IC*/ 13.24 + "cclass", /*OP_CCLASS*/ 13.25 + "cclass-mb", /*OP_CCLASS_MB*/ 13.26 + "cclass-mix", /*OP_CCLASS_MIX*/ 13.27 + "cclass-not", /*OP_CCLASS_NOT*/ 13.28 + "cclass-mb-not", /*OP_CCLASS_MB_NOT*/ 13.29 + "cclass-mix-not", /*OP_CCLASS_MIX_NOT*/ 13.30 + "cclass-node", /*OP_CCLASS_NODE*/ 13.31 + "anychar", /*OP_ANYCHAR*/ 13.32 + "anychar-ml", /*OP_ANYCHAR_ML*/ 13.33 + "anychar*", /*OP_ANYCHAR_STAR*/ 13.34 + "anychar-ml*", /*OP_ANYCHAR_ML_STAR*/ 13.35 + "anychar*-peek-next", /*OP_ANYCHAR_STAR_PEEK_NEXT*/ 13.36 + "anychar-ml*-peek-next", /*OP_ANYCHAR_ML_STAR_PEEK_NEXT*/ 13.37 + "word", /*OP_WORD*/ 13.38 + "not-word", /*OP_NOT_WORD*/ 13.39 + "word-bound", /*OP_WORD_BOUND*/ 13.40 + "not-word-bound", /*OP_NOT_WORD_BOUND*/ 13.41 + "word-begin", /*OP_WORD_BEGIN*/ 13.42 + "word-end", /*OP_WORD_END*/ 13.43 + "begin-buf", /*OP_BEGIN_BUF*/ 13.44 + "end-buf", /*OP_END_BUF*/ 13.45 + "begin-line", /*OP_BEGIN_LINE*/ 13.46 + "end-line", /*OP_END_LINE*/ 13.47 + "semi-end-buf", /*OP_SEMI_END_BUF*/ 13.48 + "begin-position", /*OP_BEGIN_POSITION*/ 13.49 + "backref1", /*OP_BACKREF1*/ 13.50 + "backref2", /*OP_BACKREF2*/ 13.51 + "backrefn", /*OP_BACKREFN*/ 13.52 + "backrefn-ic", /*OP_BACKREFN_IC*/ 13.53 + "backref_multi", /*OP_BACKREF_MULTI*/ 13.54 + "backref_multi-ic", /*OP_BACKREF_MULTI_IC*/ 13.55 + "backref_at_level", /*OP_BACKREF_AT_LEVEL*/ 13.56 + "mem-start", /*OP_MEMORY_START*/ 13.57 + "mem-start-push", /*OP_MEMORY_START_PUSH*/ 13.58 + "mem-end-push", /*OP_MEMORY_END_PUSH*/ 13.59 + "mem-end-push-rec", /*OP_MEMORY_END_PUSH_REC*/ 13.60 + "mem-end", /*OP_MEMORY_END*/ 13.61 + "mem-end-rec", /*OP_MEMORY_END_REC*/ 13.62 + "fail", /*OP_FAIL*/ 13.63 + "jump", /*OP_JUMP*/ 13.64 + "push", /*OP_PUSH*/ 13.65 + "pop", /*OP_POP*/ 13.66 + "push-or-jump-e1", /*OP_PUSH_OR_JUMP_EXACT1*/ 13.67 + "push-if-peek-next", /*OP_PUSH_IF_PEEK_NEXT*/ 13.68 + "repeat", /*OP_REPEAT*/ 13.69 + "repeat-ng", /*OP_REPEAT_NG*/ 13.70 + "repeat-inc", /*OP_REPEAT_INC*/ 13.71 + "repeat-inc-ng", /*OP_REPEAT_INC_NG*/ 13.72 + "repeat-inc-sg", /*OP_REPEAT_INC_SG*/ 13.73 + "repeat-inc-ng-sg", /*OP_REPEAT_INC_NG_SG*/ 13.74 + "null-check-start", /*OP_NULL_CHECK_START*/ 13.75 + "null-check-end", /*OP_NULL_CHECK_END*/ 13.76 + "null-check-end-memst", /*OP_NULL_CHECK_END_MEMST*/ 13.77 + "null-check-end-memst-push", /*OP_NULL_CHECK_END_MEMST_PUSH*/ 13.78 + "push-pos", /*OP_PUSH_POS*/ 13.79 + "pop-pos", /*OP_POP_POS*/ 13.80 + "push-pos-not", /*OP_PUSH_POS_NOT*/ 13.81 + "fail-pos", /*OP_FAIL_POS*/ 13.82 + "push-stop-bt", /*OP_PUSH_STOP_BT*/ 13.83 + "pop-stop-bt", /*OP_POP_STOP_BT*/ 13.84 + "look-behind", /*OP_LOOK_BEHIND*/ 13.85 + "push-look-behind-not", /*OP_PUSH_LOOK_BEHIND_NOT*/ 13.86 + "fail-look-behind-not", /*OP_FAIL_LOOK_BEHIND_NOT*/ 13.87 + "call", /*OP_CALL*/ 13.88 + "return", /*OP_RETURN*/ 13.89 + "state-check-push", /*OP_STATE_CHECK_PUSH*/ 13.90 + "state-check-push-or-jump", /*OP_STATE_CHECK_PUSH_OR_JUMP*/ 13.91 + "state-check", /*OP_STATE_CHECK*/ 13.92 + "state-check-anychar*", /*OP_STATE_CHECK_ANYCHAR_STAR*/ 13.93 + "state-check-anychar-ml*", /*OP_STATE_CHECK_ANYCHAR_ML_STAR*/ 13.94 + "set-option-push", /*OP_SET_OPTION_PUSH*/ 13.95 + "set-option", /*OP_SET_OPTION*/ 13.96 + 13.97 + // single byte versions 13.98 + "anychar-sb", /*OP_ANYCHAR*/ 13.99 + "anychar-ml-sb", /*OP_ANYCHAR_ML*/ 13.100 + "anychar*-sb", /*OP_ANYCHAR_STAR*/ 13.101 + "anychar-ml*-sb", /*OP_ANYCHAR_ML_STAR*/ 13.102 + "anychar*-peek-next-sb", /*OP_ANYCHAR_STAR_PEEK_NEXT*/ 13.103 + "anychar-ml*-peek-next-sb", /*OP_ANYCHAR_ML_STAR_PEEK_NEXT*/ 13.104 + "state-check-anychar*-sb", /*OP_STATE_CHECK_ANYCHAR_STAR*/ 13.105 + "state-check-anychar-ml*-sb", /*OP_STATE_CHECK_ANYCHAR_ML_STAR*/ 13.106 + 13.107 + "cclass-sb", /*OP_CCLASS*/ 13.108 + "cclass-not-sb", /*OP_CCLASS_NOT*/ 13.109 + 13.110 + "word-sb", /*OP_WORD*/ 13.111 + "not-word-sb", /*OP_NOT_WORD*/ 13.112 + "word-bound-sb", /*OP_WORD_BOUND*/ 13.113 + "not-word-bound-sb", /*OP_NOT_WORD_BOUND*/ 13.114 + "word-begin-sb", /*OP_WORD_BEGIN*/ 13.115 + "word-end-sb", /*OP_WORD_END*/ 13.116 + 13.117 + "look-behind-sb", /*OP_LOOK_BEHIND*/ 13.118 + 13.119 + "exact1-ic-sb", /*OP_EXACT1_IC*/ 13.120 + "exactn-ic-sb", /*OP_EXACTN_IC*/ 13.121 + 13.122 + }; 13.123 + 13.124 + private final static int OpCodeArgTypes[] = new int[] { 13.125 + Arguments.NON, /*OP_FINISH*/ 13.126 + Arguments.NON, /*OP_END*/ 13.127 + Arguments.SPECIAL, /*OP_EXACT1*/ 13.128 + Arguments.SPECIAL, /*OP_EXACT2*/ 13.129 + Arguments.SPECIAL, /*OP_EXACT3*/ 13.130 + Arguments.SPECIAL, /*OP_EXACT4*/ 13.131 + Arguments.SPECIAL, /*OP_EXACT5*/ 13.132 + Arguments.SPECIAL, /*OP_EXACTN*/ 13.133 + Arguments.SPECIAL, /*OP_EXACTMB2N1*/ 13.134 + Arguments.SPECIAL, /*OP_EXACTMB2N2*/ 13.135 + Arguments.SPECIAL, /*OP_EXACTMB2N3*/ 13.136 + Arguments.SPECIAL, /*OP_EXACTMB2N*/ 13.137 + Arguments.SPECIAL, /*OP_EXACTMB3N*/ 13.138 + Arguments.SPECIAL, /*OP_EXACTMBN*/ 13.139 + Arguments.SPECIAL, /*OP_EXACT1_IC*/ 13.140 + Arguments.SPECIAL, /*OP_EXACTN_IC*/ 13.141 + Arguments.SPECIAL, /*OP_CCLASS*/ 13.142 + Arguments.SPECIAL, /*OP_CCLASS_MB*/ 13.143 + Arguments.SPECIAL, /*OP_CCLASS_MIX*/ 13.144 + Arguments.SPECIAL, /*OP_CCLASS_NOT*/ 13.145 + Arguments.SPECIAL, /*OP_CCLASS_MB_NOT*/ 13.146 + Arguments.SPECIAL, /*OP_CCLASS_MIX_NOT*/ 13.147 + Arguments.SPECIAL, /*OP_CCLASS_NODE*/ 13.148 + Arguments.NON, /*OP_ANYCHAR*/ 13.149 + Arguments.NON, /*OP_ANYCHAR_ML*/ 13.150 + Arguments.NON, /*OP_ANYCHAR_STAR*/ 13.151 + Arguments.NON, /*OP_ANYCHAR_ML_STAR*/ 13.152 + Arguments.SPECIAL, /*OP_ANYCHAR_STAR_PEEK_NEXT*/ 13.153 + Arguments.SPECIAL, /*OP_ANYCHAR_ML_STAR_PEEK_NEXT*/ 13.154 + Arguments.NON, /*OP_WORD*/ 13.155 + Arguments.NON, /*OP_NOT_WORD*/ 13.156 + Arguments.NON, /*OP_WORD_BOUND*/ 13.157 + Arguments.NON, /*OP_NOT_WORD_BOUND*/ 13.158 + Arguments.NON, /*OP_WORD_BEGIN*/ 13.159 + Arguments.NON, /*OP_WORD_END*/ 13.160 + Arguments.NON, /*OP_BEGIN_BUF*/ 13.161 + Arguments.NON, /*OP_END_BUF*/ 13.162 + Arguments.NON, /*OP_BEGIN_LINE*/ 13.163 + Arguments.NON, /*OP_END_LINE*/ 13.164 + Arguments.NON, /*OP_SEMI_END_BUF*/ 13.165 + Arguments.NON, /*OP_BEGIN_POSITION*/ 13.166 + Arguments.NON, /*OP_BACKREF1*/ 13.167 + Arguments.NON, /*OP_BACKREF2*/ 13.168 + Arguments.MEMNUM, /*OP_BACKREFN*/ 13.169 + Arguments.SPECIAL, /*OP_BACKREFN_IC*/ 13.170 + Arguments.SPECIAL, /*OP_BACKREF_MULTI*/ 13.171 + Arguments.SPECIAL, /*OP_BACKREF_MULTI_IC*/ 13.172 + Arguments.SPECIAL, /*OP_BACKREF_AT_LEVEL*/ 13.173 + Arguments.MEMNUM, /*OP_MEMORY_START*/ 13.174 + Arguments.MEMNUM, /*OP_MEMORY_START_PUSH*/ 13.175 + Arguments.MEMNUM, /*OP_MEMORY_END_PUSH*/ 13.176 + Arguments.MEMNUM, /*OP_MEMORY_END_PUSH_REC*/ 13.177 + Arguments.MEMNUM, /*OP_MEMORY_END*/ 13.178 + Arguments.MEMNUM, /*OP_MEMORY_END_REC*/ 13.179 + Arguments.NON, /*OP_FAIL*/ 13.180 + Arguments.RELADDR, /*OP_JUMP*/ 13.181 + Arguments.RELADDR, /*OP_PUSH*/ 13.182 + Arguments.NON, /*OP_POP*/ 13.183 + Arguments.SPECIAL, /*OP_PUSH_OR_JUMP_EXACT1*/ 13.184 + Arguments.SPECIAL, /*OP_PUSH_IF_PEEK_NEXT*/ 13.185 + Arguments.SPECIAL, /*OP_REPEAT*/ 13.186 + Arguments.SPECIAL, /*OP_REPEAT_NG*/ 13.187 + Arguments.MEMNUM, /*OP_REPEAT_INC*/ 13.188 + Arguments.MEMNUM, /*OP_REPEAT_INC_NG*/ 13.189 + Arguments.MEMNUM, /*OP_REPEAT_INC_SG*/ 13.190 + Arguments.MEMNUM, /*OP_REPEAT_INC_NG_SG*/ 13.191 + Arguments.MEMNUM, /*OP_NULL_CHECK_START*/ 13.192 + Arguments.MEMNUM, /*OP_NULL_CHECK_END*/ 13.193 + Arguments.MEMNUM, /*OP_NULL_CHECK_END_MEMST*/ 13.194 + Arguments.MEMNUM, /*OP_NULL_CHECK_END_MEMST_PUSH*/ 13.195 + Arguments.NON, /*OP_PUSH_POS*/ 13.196 + Arguments.NON, /*OP_POP_POS*/ 13.197 + Arguments.RELADDR, /*OP_PUSH_POS_NOT*/ 13.198 + Arguments.NON, /*OP_FAIL_POS*/ 13.199 + Arguments.NON, /*OP_PUSH_STOP_BT*/ 13.200 + Arguments.NON, /*OP_POP_STOP_BT*/ 13.201 + Arguments.SPECIAL, /*OP_LOOK_BEHIND*/ 13.202 + Arguments.SPECIAL, /*OP_PUSH_LOOK_BEHIND_NOT*/ 13.203 + Arguments.NON, /*OP_FAIL_LOOK_BEHIND_NOT*/ 13.204 + Arguments.ABSADDR, /*OP_CALL*/ 13.205 + Arguments.NON, /*OP_RETURN*/ 13.206 + Arguments.SPECIAL, /*OP_STATE_CHECK_PUSH*/ 13.207 + Arguments.SPECIAL, /*OP_STATE_CHECK_PUSH_OR_JUMP*/ 13.208 + Arguments.STATE_CHECK, /*OP_STATE_CHECK*/ 13.209 + Arguments.STATE_CHECK, /*OP_STATE_CHECK_ANYCHAR_STAR*/ 13.210 + Arguments.STATE_CHECK, /*OP_STATE_CHECK_ANYCHAR_ML_STAR*/ 13.211 + Arguments.OPTION, /*OP_SET_OPTION_PUSH*/ 13.212 + Arguments.OPTION, /*OP_SET_OPTION*/ 13.213 + 13.214 + // single byte versions 13.215 + Arguments.NON, /*OP_ANYCHAR*/ 13.216 + Arguments.NON, /*OP_ANYCHAR_ML*/ 13.217 + Arguments.NON, /*OP_ANYCHAR_STAR*/ 13.218 + Arguments.NON, /*OP_ANYCHAR_ML_STAR*/ 13.219 + Arguments.SPECIAL, /*OP_ANYCHAR_STAR_PEEK_NEXT*/ 13.220 + Arguments.SPECIAL, /*OP_ANYCHAR_ML_STAR_PEEK_NEXT*/ 13.221 + Arguments.STATE_CHECK, /*OP_STATE_CHECK_ANYCHAR_STAR*/ 13.222 + Arguments.STATE_CHECK, /*OP_STATE_CHECK_ANYCHAR_ML_STAR*/ 13.223 + 13.224 + Arguments.SPECIAL, /*OP_CCLASS*/ 13.225 + Arguments.SPECIAL, /*OP_CCLASS_NOT*/ 13.226 + 13.227 + Arguments.NON, /*OP_WORD*/ 13.228 + Arguments.NON, /*OP_NOT_WORD*/ 13.229 + Arguments.NON, /*OP_WORD_BOUND*/ 13.230 + Arguments.NON, /*OP_NOT_WORD_BOUND*/ 13.231 + Arguments.NON, /*OP_WORD_BEGIN*/ 13.232 + Arguments.NON, /*OP_WORD_END*/ 13.233 + 13.234 + Arguments.SPECIAL, /*OP_LOOK_BEHIND*/ 13.235 + 13.236 + Arguments.SPECIAL, /*OP_EXACT1_IC*/ 13.237 + Arguments.SPECIAL, /*OP_EXACTN_IC*/ 13.238 + }; 13.239 + 13.240 public ByteCodePrinter(Regex regex) { 13.241 code = regex.code; 13.242 codeLength = regex.codeLength; 13.243 @@ -76,8 +309,8 @@ 13.244 CClassNode cc; 13.245 int tm, idx; 13.246 13.247 - sb.append("[" + OPCode.OpCodeNames[code[bp]]); 13.248 - int argType = OPCode.OpCodeArgTypes[code[bp]]; 13.249 + sb.append("[" + OpCodeNames[code[bp]]); 13.250 + int argType = OpCodeArgTypes[code[bp]]; 13.251 int ip = bp; 13.252 if (argType != Arguments.SPECIAL) { 13.253 bp++;
14.1 --- a/src/jdk/nashorn/internal/runtime/regexp/joni/CaptureTreeNode.java Thu May 16 13:44:25 2013 +0200 14.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 14.3 @@ -1,74 +0,0 @@ 14.4 -/* 14.5 - * Permission is hereby granted, free of charge, to any person obtaining a copy of 14.6 - * this software and associated documentation files (the "Software"), to deal in 14.7 - * the Software without restriction, including without limitation the rights to 14.8 - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 14.9 - * of the Software, and to permit persons to whom the Software is furnished to do 14.10 - * so, subject to the following conditions: 14.11 - * 14.12 - * The above copyright notice and this permission notice shall be included in all 14.13 - * copies or substantial portions of the Software. 14.14 - * 14.15 - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14.16 - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 14.17 - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 14.18 - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 14.19 - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 14.20 - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 14.21 - * SOFTWARE. 14.22 - */ 14.23 -package jdk.nashorn.internal.runtime.regexp.joni; 14.24 - 14.25 -public class CaptureTreeNode { 14.26 - 14.27 - 14.28 - int group; 14.29 - int beg; 14.30 - int end; 14.31 - // int allocated; 14.32 - int numChildren; 14.33 - CaptureTreeNode[]children; 14.34 - 14.35 - CaptureTreeNode() { 14.36 - beg = Region.REGION_NOTPOS; 14.37 - end = Region.REGION_NOTPOS; 14.38 - group = -1; 14.39 - } 14.40 - 14.41 - static final int HISTORY_TREE_INIT_ALLOC_SIZE = 8; 14.42 - void addChild(CaptureTreeNode child) { 14.43 - if (children == null) { 14.44 - children = new CaptureTreeNode[HISTORY_TREE_INIT_ALLOC_SIZE]; 14.45 - } else if (numChildren >= children.length) { 14.46 - CaptureTreeNode[]tmp = new CaptureTreeNode[children.length << 1]; 14.47 - System.arraycopy(children, 0, tmp, 0, children.length); 14.48 - children = tmp; 14.49 - } 14.50 - 14.51 - children[numChildren] = child; 14.52 - numChildren++; 14.53 - } 14.54 - 14.55 - void clear() { 14.56 - for (int i=0; i<numChildren; i++) { 14.57 - children[i] = null; // ??? 14.58 - } 14.59 - numChildren = 0; 14.60 - beg = end = Region.REGION_NOTPOS; 14.61 - group = -1; 14.62 - } 14.63 - 14.64 - CaptureTreeNode cloneTree() { 14.65 - CaptureTreeNode clone = new CaptureTreeNode(); 14.66 - clone.beg = beg; 14.67 - clone.end = end; 14.68 - 14.69 - for (int i=0; i<numChildren; i++) { 14.70 - CaptureTreeNode child = children[i].cloneTree(); 14.71 - clone.addChild(child); 14.72 - } 14.73 - return clone; 14.74 - } 14.75 - 14.76 - 14.77 -}
15.1 --- a/src/jdk/nashorn/internal/runtime/regexp/joni/Compiler.java Thu May 16 13:44:25 2013 +0200 15.2 +++ b/src/jdk/nashorn/internal/runtime/regexp/joni/Compiler.java Thu May 16 19:52:39 2013 +0200 15.3 @@ -22,8 +22,6 @@ 15.4 import jdk.nashorn.internal.runtime.regexp.joni.ast.AnchorNode; 15.5 import jdk.nashorn.internal.runtime.regexp.joni.ast.BackRefNode; 15.6 import jdk.nashorn.internal.runtime.regexp.joni.ast.CClassNode; 15.7 -import jdk.nashorn.internal.runtime.regexp.joni.ast.CTypeNode; 15.8 -import jdk.nashorn.internal.runtime.regexp.joni.ast.CallNode; 15.9 import jdk.nashorn.internal.runtime.regexp.joni.ast.ConsAltNode; 15.10 import jdk.nashorn.internal.runtime.regexp.joni.ast.EncloseNode; 15.11 import jdk.nashorn.internal.runtime.regexp.joni.ast.Node; 15.12 @@ -56,7 +54,7 @@ 15.13 15.14 private void compileStringRawNode(StringNode sn) { 15.15 if (sn.length() <= 0) return; 15.16 - addCompileString(sn.chars, sn.p, 1 /*sb*/, sn.length(), false); 15.17 + addCompileString(sn.chars, sn.p, sn.length(), false); 15.18 } 15.19 15.20 private void compileStringNode(StringNode node) { 15.21 @@ -76,17 +74,14 @@ 15.22 slen++; 15.23 p++; 15.24 } 15.25 - addCompileString(chars, prev, 1, slen, ambig); 15.26 + addCompileString(chars, prev, slen, ambig); 15.27 } 15.28 15.29 - protected abstract void addCompileString(char[] chars, int p, int mbLength, int strLength, boolean ignoreCase); 15.30 + protected abstract void addCompileString(char[] chars, int p, int strLength, boolean ignoreCase); 15.31 15.32 protected abstract void compileCClassNode(CClassNode node); 15.33 - protected abstract void compileCTypeNode(CTypeNode node); 15.34 protected abstract void compileAnyCharNode(); 15.35 - protected abstract void compileCallNode(CallNode node); 15.36 protected abstract void compileBackrefNode(BackRefNode node); 15.37 - protected abstract void compileCECQuantifierNode(QuantifierNode node); 15.38 protected abstract void compileNonCECQuantifierNode(QuantifierNode node); 15.39 protected abstract void compileOptionNode(EncloseNode node); 15.40 protected abstract void compileEncloseNode(EncloseNode node); 15.41 @@ -118,10 +113,6 @@ 15.42 compileCClassNode((CClassNode)node); 15.43 break; 15.44 15.45 - case NodeType.CTYPE: 15.46 - compileCTypeNode((CTypeNode)node); 15.47 - break; 15.48 - 15.49 case NodeType.CANY: 15.50 compileAnyCharNode(); 15.51 break; 15.52 @@ -130,19 +121,8 @@ 15.53 compileBackrefNode((BackRefNode)node); 15.54 break; 15.55 15.56 - case NodeType.CALL: 15.57 - if (Config.USE_SUBEXP_CALL) { 15.58 - compileCallNode((CallNode)node); 15.59 - break; 15.60 - } // USE_SUBEXP_CALL 15.61 - break; 15.62 - 15.63 case NodeType.QTFR: 15.64 - if (Config.USE_COMBINATION_EXPLOSION_CHECK) { 15.65 - compileCECQuantifierNode((QuantifierNode)node); 15.66 - } else { 15.67 - compileNonCECQuantifierNode((QuantifierNode)node); 15.68 - } 15.69 + compileNonCECQuantifierNode((QuantifierNode)node); 15.70 break; 15.71 15.72 case NodeType.ENCLOSE:
16.1 --- a/src/jdk/nashorn/internal/runtime/regexp/joni/Config.java Thu May 16 13:44:25 2013 +0200 16.2 +++ b/src/jdk/nashorn/internal/runtime/regexp/joni/Config.java Thu May 16 19:52:39 2013 +0200 16.3 @@ -31,10 +31,6 @@ 16.4 final int ENC_CASE_FOLD_DEFAULT = ENC_CASE_FOLD_MIN; 16.5 final boolean USE_CRNL_AS_LINE_TERMINATOR = false; 16.6 16.7 - final boolean USE_NAMED_GROUP = true; 16.8 - final boolean USE_SUBEXP_CALL = true; 16.9 - final boolean USE_BACKREF_WITH_LEVEL = true; /* \k<name+n>, \k<name-n> */ 16.10 - 16.11 final boolean USE_MONOMANIAC_CHECK_CAPTURES_IN_ENDLESS_REPEAT = true; /* /(?:()|())*\2/ */ 16.12 final boolean USE_NEWLINE_AT_END_OF_STRING_HAS_EMPTY_LINE = true; /* /\n$/ =~ "\n" */ 16.13 final boolean USE_WARNING_REDUNDANT_NESTED_REPEAT_OPERATOR = false; 16.14 @@ -42,12 +38,10 @@ 16.15 final boolean CASE_FOLD_IS_APPLIED_INSIDE_NEGATIVE_CCLASS = true; 16.16 16.17 final boolean USE_MATCH_RANGE_MUST_BE_INSIDE_OF_SPECIFIED_RANGE = false; 16.18 - final boolean USE_CAPTURE_HISTORY = false; 16.19 final boolean USE_VARIABLE_META_CHARS = true; 16.20 final boolean USE_WORD_BEGIN_END = true; /* "\<": word-begin, "\>": word-end */ 16.21 - final boolean USE_POSIX_API_REGION_OPTION = true; /* needed for POSIX API support */ 16.22 + final boolean USE_POSIX_API_REGION_OPTION = false; /* needed for POSIX API support */ 16.23 final boolean USE_FIND_LONGEST_SEARCH_ALL_OF_RANGE = true; 16.24 - final boolean USE_COMBINATION_EXPLOSION_CHECK = false; 16.25 16.26 final int NREGION = 10; 16.27 final int MAX_BACKREF_NUM = 1000; 16.28 @@ -73,13 +67,6 @@ 16.29 16.30 final boolean USE_STRING_TEMPLATES = true; // use embeded string templates in Regex object as byte arrays instead of compiling them into int bytecode array 16.31 16.32 - 16.33 - final int MAX_CAPTURE_HISTORY_GROUP = 31; 16.34 - 16.35 - 16.36 - final int CHECK_STRING_THRESHOLD_LEN = 7; 16.37 - final int CHECK_BUFF_MAX_SIZE = 0x4000; 16.38 - 16.39 final boolean NON_UNICODE_SDW = true; 16.40 16.41 16.42 @@ -95,6 +82,4 @@ 16.43 final boolean DEBUG_COMPILE_BYTE_CODE_INFO = DEBUG_ALL; 16.44 final boolean DEBUG_SEARCH = DEBUG_ALL; 16.45 final boolean DEBUG_MATCH = DEBUG_ALL; 16.46 - final boolean DEBUG_ASM = true; 16.47 - final boolean DEBUG_ASM_EXEC = true; 16.48 }
17.1 --- a/src/jdk/nashorn/internal/runtime/regexp/joni/EncodingHelper.java Thu May 16 13:44:25 2013 +0200 17.2 +++ b/src/jdk/nashorn/internal/runtime/regexp/joni/EncodingHelper.java Thu May 16 19:52:39 2013 +0200 17.3 @@ -95,20 +95,6 @@ 17.4 return s; 17.5 } 17.6 17.7 - /* onigenc_with_ascii_strncmp */ 17.8 - public static int strNCmp(char[] chars1, int p1, int end, char[] chars2, int p2, int n) { 17.9 - while (n-- > 0) { 17.10 - if (p1 >= end) return chars2[p2]; 17.11 - int c = chars1[p1]; 17.12 - int x = chars2[p2] - c; 17.13 - if (x != 0) return x; 17.14 - 17.15 - p2++; 17.16 - p1++; 17.17 - } 17.18 - return 0; 17.19 - } 17.20 - 17.21 public static int mbcToCode(byte[] bytes, int p, int end) { 17.22 int code = 0; 17.23 for (int i = p; i < end; i++) {
18.1 --- a/src/jdk/nashorn/internal/runtime/regexp/joni/Lexer.java Thu May 16 13:44:25 2013 +0200 18.2 +++ b/src/jdk/nashorn/internal/runtime/regexp/joni/Lexer.java Thu May 16 19:52:39 2013 +0200 18.3 @@ -27,10 +27,7 @@ 18.4 import jdk.nashorn.internal.runtime.regexp.joni.constants.MetaChar; 18.5 import jdk.nashorn.internal.runtime.regexp.joni.constants.TokenType; 18.6 import jdk.nashorn.internal.runtime.regexp.joni.encoding.CharacterType; 18.7 -import jdk.nashorn.internal.runtime.regexp.joni.encoding.PosixBracket; 18.8 -import jdk.nashorn.internal.runtime.regexp.joni.encoding.Ptr; 18.9 import jdk.nashorn.internal.runtime.regexp.joni.exception.ErrorMessages; 18.10 -import jdk.nashorn.internal.runtime.regexp.joni.exception.JOniException; 18.11 18.12 class Lexer extends ScannerSupport { 18.13 protected final ScanEnvironment env; 18.14 @@ -215,198 +212,6 @@ 18.15 \k<-num+n>, \k<-num-n> 18.16 */ 18.17 18.18 - // value implicit (rnameEnd) 18.19 - private boolean fetchNameWithLevel(int startCode, Ptr rbackNum, Ptr rlevel) { 18.20 - int src = p; 18.21 - boolean existLevel = false; 18.22 - int isNum = 0; 18.23 - int sign = 1; 18.24 - 18.25 - int endCode = nameEndCodePoint(startCode); 18.26 - int pnumHead = p; 18.27 - int nameEnd = stop; 18.28 - 18.29 - String err = null; 18.30 - if (!left()) { 18.31 - newValueException(ERR_EMPTY_GROUP_NAME); 18.32 - } else { 18.33 - fetch(); 18.34 - if (c == endCode) newValueException(ERR_EMPTY_GROUP_NAME); 18.35 - if (Character.isDigit(c)) { 18.36 - isNum = 1; 18.37 - } else if (c == '-') { 18.38 - isNum = 2; 18.39 - sign = -1; 18.40 - pnumHead = p; 18.41 - } else if (!EncodingHelper.isWord(c)) { 18.42 - err = ERR_INVALID_GROUP_NAME; 18.43 - } 18.44 - } 18.45 - 18.46 - while (left()) { 18.47 - nameEnd = p; 18.48 - fetch(); 18.49 - if (c == endCode || c == ')' || c == '+' || c == '-') { 18.50 - if (isNum == 2) err = ERR_INVALID_GROUP_NAME; 18.51 - break; 18.52 - } 18.53 - 18.54 - if (isNum != 0) { 18.55 - if (EncodingHelper.isDigit(c)) { 18.56 - isNum = 1; 18.57 - } else { 18.58 - err = ERR_INVALID_GROUP_NAME; 18.59 - // isNum = 0; 18.60 - } 18.61 - } else if (!EncodingHelper.isWord(c)) { 18.62 - err = ERR_INVALID_CHAR_IN_GROUP_NAME; 18.63 - } 18.64 - } 18.65 - 18.66 - boolean isEndCode = false; 18.67 - if (err == null && c != endCode) { 18.68 - if (c == '+' || c == '-') { 18.69 - int flag = c == '-' ? -1 : 1; 18.70 - 18.71 - fetch(); 18.72 - if (!EncodingHelper.isDigit(c)) newValueException(ERR_INVALID_GROUP_NAME, src, stop); 18.73 - unfetch(); 18.74 - int level = scanUnsignedNumber(); 18.75 - if (level < 0) newValueException(ERR_TOO_BIG_NUMBER); 18.76 - rlevel.p = level * flag; 18.77 - existLevel = true; 18.78 - 18.79 - fetch(); 18.80 - isEndCode = c == endCode; 18.81 - } 18.82 - 18.83 - if (!isEndCode) { 18.84 - err = ERR_INVALID_GROUP_NAME; 18.85 - nameEnd = stop; 18.86 - } 18.87 - } 18.88 - 18.89 - if (err == null) { 18.90 - if (isNum != 0) { 18.91 - mark(); 18.92 - p = pnumHead; 18.93 - int backNum = scanUnsignedNumber(); 18.94 - restore(); 18.95 - if (backNum < 0) { 18.96 - newValueException(ERR_TOO_BIG_NUMBER); 18.97 - } else if (backNum == 0) { 18.98 - newValueException(ERR_INVALID_GROUP_NAME, src, stop); 18.99 - } 18.100 - rbackNum.p = backNum * sign; 18.101 - } 18.102 - value = nameEnd; 18.103 - return existLevel; 18.104 - } else { 18.105 - newValueException(ERR_INVALID_GROUP_NAME, src, nameEnd); 18.106 - return false; // not reached 18.107 - } 18.108 - } 18.109 - 18.110 - // USE_NAMED_GROUP 18.111 - // ref: 0 -> define name (don't allow number name) 18.112 - // 1 -> reference name (allow number name) 18.113 - private int fetchNameForNamedGroup(int startCode, boolean ref) { 18.114 - int src = p; 18.115 - value = 0; 18.116 - 18.117 - int isNum = 0; 18.118 - int sign = 1; 18.119 - 18.120 - int endCode = nameEndCodePoint(startCode); 18.121 - int pnumHead = p; 18.122 - int nameEnd = stop; 18.123 - 18.124 - String err = null; 18.125 - if (!left()) { 18.126 - newValueException(ERR_EMPTY_GROUP_NAME); 18.127 - } else { 18.128 - fetch(); 18.129 - if (c == endCode) newValueException(ERR_EMPTY_GROUP_NAME); 18.130 - if (EncodingHelper.isDigit(c)) { 18.131 - if (ref) { 18.132 - isNum = 1; 18.133 - } else { 18.134 - err = ERR_INVALID_GROUP_NAME; 18.135 - // isNum = 0; 18.136 - } 18.137 - } else if (c == '-') { 18.138 - if (ref) { 18.139 - isNum = 2; 18.140 - sign = -1; 18.141 - pnumHead = p; 18.142 - } else { 18.143 - err = ERR_INVALID_GROUP_NAME; 18.144 - // isNum = 0; 18.145 - } 18.146 - } else if (!EncodingHelper.isWord(c)) { 18.147 - err = ERR_INVALID_CHAR_IN_GROUP_NAME; 18.148 - } 18.149 - } 18.150 - 18.151 - if (err == null) { 18.152 - while (left()) { 18.153 - nameEnd = p; 18.154 - fetch(); 18.155 - if (c == endCode || c == ')') { 18.156 - if (isNum == 2) err = ERR_INVALID_GROUP_NAME; 18.157 - break; 18.158 - } 18.159 - 18.160 - if (isNum != 0) { 18.161 - if (EncodingHelper.isDigit(c)) { 18.162 - isNum = 1; 18.163 - } else { 18.164 - if (!EncodingHelper.isWord(c)) { 18.165 - err = ERR_INVALID_CHAR_IN_GROUP_NAME; 18.166 - } else { 18.167 - err = ERR_INVALID_GROUP_NAME; 18.168 - } 18.169 - // isNum = 0; 18.170 - } 18.171 - } else { 18.172 - if (!EncodingHelper.isWord(c)) { 18.173 - err = ERR_INVALID_CHAR_IN_GROUP_NAME; 18.174 - } 18.175 - } 18.176 - } 18.177 - 18.178 - if (c != endCode) { 18.179 - err = ERR_INVALID_GROUP_NAME; 18.180 - nameEnd = stop; 18.181 - } 18.182 - 18.183 - int backNum = 0; 18.184 - if (isNum != 0) { 18.185 - mark(); 18.186 - p = pnumHead; 18.187 - backNum = scanUnsignedNumber(); 18.188 - restore(); 18.189 - if (backNum < 0) { 18.190 - newValueException(ERR_TOO_BIG_NUMBER); 18.191 - } else if (backNum == 0) { 18.192 - newValueException(ERR_INVALID_GROUP_NAME, src, nameEnd); 18.193 - } 18.194 - backNum *= sign; 18.195 - } 18.196 - value = nameEnd; 18.197 - return backNum; 18.198 - } else { 18.199 - while (left()) { 18.200 - nameEnd = p; 18.201 - fetch(); 18.202 - if (c == endCode || c == ')') break; 18.203 - } 18.204 - if (!left()) nameEnd = stop; 18.205 - newValueException(err, src, nameEnd); 18.206 - return 0; // not reached 18.207 - } 18.208 - } 18.209 - 18.210 // #else USE_NAMED_GROUP 18.211 // make it return nameEnd! 18.212 private final int fetchNameForNoNamedGroup(int startCode, boolean ref) { 18.213 @@ -472,11 +277,7 @@ 18.214 } 18.215 18.216 protected final int fetchName(int startCode, boolean ref) { 18.217 - if (Config.USE_NAMED_GROUP) { 18.218 - return fetchNameForNamedGroup(startCode, ref); 18.219 - } else { 18.220 - return fetchNameForNoNamedGroup(startCode, ref); 18.221 - } 18.222 + return fetchNameForNoNamedGroup(startCode, ref); 18.223 } 18.224 18.225 private boolean strExistCheckWithEsc(int[]s, int n, int bad) { 18.226 @@ -519,26 +320,6 @@ 18.227 token.setPropNot(flag); 18.228 } 18.229 18.230 - private void fetchTokenInCCFor_p() { 18.231 - int c2 = peek(); // !!! migrate to peekIs 18.232 - if (c2 == '{' && syntax.op2EscPBraceCharProperty()) { 18.233 - inc(); 18.234 - token.type = TokenType.CHAR_PROPERTY; 18.235 - token.setPropNot(c == 'P'); 18.236 - 18.237 - if (syntax.op2EscPBraceCircumflexNot()) { 18.238 - c2 = fetchTo(); 18.239 - if (c2 == '^') { 18.240 - token.setPropNot(!token.getPropNot()); 18.241 - } else { 18.242 - unfetch(); 18.243 - } 18.244 - } 18.245 - } else { 18.246 - syntaxWarn(Warnings.INVALID_UNICODE_PROPERTY, (char)c); 18.247 - } 18.248 - } 18.249 - 18.250 private void fetchTokenInCCFor_x() { 18.251 if (!left()) return; 18.252 int last = p; 18.253 @@ -604,30 +385,6 @@ 18.254 } 18.255 } 18.256 18.257 - private void fetchTokenInCCFor_posixBracket() { 18.258 - if (syntax.opPosixBracket() && peekIs(':')) { 18.259 - token.backP = p; /* point at '[' is readed */ 18.260 - inc(); 18.261 - if (strExistCheckWithEsc(send, send.length, ']')) { 18.262 - token.type = TokenType.POSIX_BRACKET_OPEN; 18.263 - } else { 18.264 - unfetch(); 18.265 - // remove duplication, goto cc_in_cc; 18.266 - if (syntax.op2CClassSetOp()) { 18.267 - token.type = TokenType.CC_CC_OPEN; 18.268 - } else { 18.269 - env.ccEscWarn("["); 18.270 - } 18.271 - } 18.272 - } else { // cc_in_cc: 18.273 - if (syntax.op2CClassSetOp()) { 18.274 - token.type = TokenType.CC_CC_OPEN; 18.275 - } else { 18.276 - env.ccEscWarn("["); 18.277 - } 18.278 - } 18.279 - } 18.280 - 18.281 private void fetchTokenInCCFor_and() { 18.282 if (syntax.op2CClassSetOp() && left() && peekIs('&')) { 18.283 inc(); 18.284 @@ -683,10 +440,6 @@ 18.285 case 'H': 18.286 if (syntax.op2EscHXDigit()) fetchTokenInCCFor_charType(true, CharacterType.XDIGIT); 18.287 break; 18.288 - case 'p': 18.289 - case 'P': 18.290 - fetchTokenInCCFor_p(); 18.291 - break; 18.292 case 'x': 18.293 fetchTokenInCCFor_x(); 18.294 break; 18.295 @@ -714,18 +467,12 @@ 18.296 break; 18.297 } // switch 18.298 18.299 - } else if (c == '[') { 18.300 - fetchTokenInCCFor_posixBracket(); 18.301 } else if (c == '&') { 18.302 fetchTokenInCCFor_and(); 18.303 } 18.304 return token.type; 18.305 } 18.306 18.307 - protected final int backrefRelToAbs(int relNo) { 18.308 - return env.numMem + 1 + relNo; 18.309 - } 18.310 - 18.311 private void fetchTokenFor_repeat(int lower, int upper) { 18.312 token.type = TokenType.OP_REPEAT; 18.313 token.setRepeatLower(lower); 18.314 @@ -815,7 +562,6 @@ 18.315 token.setBackrefNum(1); 18.316 token.setBackrefRef1(num); 18.317 token.setBackrefByName(false); 18.318 - if (Config.USE_BACKREF_WITH_LEVEL) token.setBackrefExistLevel(false); 18.319 return; 18.320 } 18.321 18.322 @@ -845,76 +591,6 @@ 18.323 } 18.324 } 18.325 18.326 - private void fetchTokenFor_namedBackref() { 18.327 - if (syntax.op2EscKNamedBackref()) { 18.328 - if (left()) { 18.329 - fetch(); 18.330 - if (c =='<' || c == '\'') { 18.331 - int last = p; 18.332 - int backNum; 18.333 - if (Config.USE_BACKREF_WITH_LEVEL) { 18.334 - Ptr rbackNum = new Ptr(); 18.335 - Ptr rlevel = new Ptr(); 18.336 - token.setBackrefExistLevel(fetchNameWithLevel(c, rbackNum, rlevel)); 18.337 - token.setBackrefLevel(rlevel.p); 18.338 - backNum = rbackNum.p; 18.339 - } else { 18.340 - backNum = fetchName(c, true); 18.341 - } // USE_BACKREF_AT_LEVEL 18.342 - int nameEnd = value; // set by fetchNameWithLevel/fetchName 18.343 - 18.344 - if (backNum != 0) { 18.345 - if (backNum < 0) { 18.346 - backNum = backrefRelToAbs(backNum); 18.347 - if (backNum <= 0) newValueException(ERR_INVALID_BACKREF); 18.348 - } 18.349 - 18.350 - if (syntax.strictCheckBackref() && (backNum > env.numMem || env.memNodes == null)) { 18.351 - newValueException(ERR_INVALID_BACKREF); 18.352 - } 18.353 - token.type = TokenType.BACKREF; 18.354 - token.setBackrefByName(false); 18.355 - token.setBackrefNum(1); 18.356 - token.setBackrefRef1(backNum); 18.357 - } else { 18.358 - NameEntry e = env.reg.nameToGroupNumbers(chars, last, nameEnd); 18.359 - if (e == null) newValueException(ERR_UNDEFINED_NAME_REFERENCE, last, nameEnd); 18.360 - 18.361 - if (syntax.strictCheckBackref()) { 18.362 - if (e.backNum == 1) { 18.363 - if (e.backRef1 > env.numMem || 18.364 - env.memNodes == null || 18.365 - env.memNodes[e.backRef1] == null) newValueException(ERR_INVALID_BACKREF); 18.366 - } else { 18.367 - for (int i=0; i<e.backNum; i++) { 18.368 - if (e.backRefs[i] > env.numMem || 18.369 - env.memNodes == null || 18.370 - env.memNodes[e.backRefs[i]] == null) newValueException(ERR_INVALID_BACKREF); 18.371 - } 18.372 - } 18.373 - } 18.374 - 18.375 - token.type = TokenType.BACKREF; 18.376 - token.setBackrefByName(true); 18.377 - 18.378 - if (e.backNum == 1) { 18.379 - token.setBackrefNum(1); 18.380 - token.setBackrefRef1(e.backRef1); 18.381 - } else { 18.382 - token.setBackrefNum(e.backNum); 18.383 - token.setBackrefRefs(e.backRefs); 18.384 - } 18.385 - } 18.386 - } else { 18.387 - unfetch(); 18.388 - syntaxWarn(Warnings.INVALID_BACKREFERENCE); 18.389 - } 18.390 - } else { 18.391 - syntaxWarn(Warnings.INVALID_BACKREFERENCE); 18.392 - } 18.393 - } 18.394 - } 18.395 - 18.396 private void fetchTokenFor_subexpCall() { 18.397 if (syntax.op2EscGSubexpCall()) { 18.398 if (left()) { 18.399 @@ -937,25 +613,6 @@ 18.400 } 18.401 } 18.402 18.403 - private void fetchTokenFor_charProperty() { 18.404 - if (peekIs('{') && syntax.op2EscPBraceCharProperty()) { 18.405 - inc(); 18.406 - token.type = TokenType.CHAR_PROPERTY; 18.407 - token.setPropNot(c == 'P'); 18.408 - 18.409 - if (syntax.op2EscPBraceCircumflexNot()) { 18.410 - fetch(); 18.411 - if (c == '^') { 18.412 - token.setPropNot(!token.getPropNot()); 18.413 - } else { 18.414 - unfetch(); 18.415 - } 18.416 - } 18.417 - } else { 18.418 - syntaxWarn(Warnings.INVALID_UNICODE_PROPERTY, (char)c); 18.419 - } 18.420 - } 18.421 - 18.422 private void fetchTokenFor_metaChars() { 18.423 if (c == syntax.metaCharTable.anyChar) { 18.424 token.type = TokenType.ANYCHAR; 18.425 @@ -1091,19 +748,6 @@ 18.426 case '0': 18.427 fetchTokenFor_zero(); 18.428 break; 18.429 - case 'k': 18.430 - if (Config.USE_NAMED_GROUP) fetchTokenFor_namedBackref(); 18.431 - break; 18.432 - case 'g': 18.433 - if (Config.USE_SUBEXP_CALL) fetchTokenFor_subexpCall(); 18.434 - break; 18.435 - case 'Q': 18.436 - if (syntax.op2EscCapitalQQuote()) token.type = TokenType.QUOTE_OPEN; 18.437 - break; 18.438 - case 'p': 18.439 - case 'P': 18.440 - fetchTokenFor_charProperty(); 18.441 - break; 18.442 18.443 default: 18.444 unfetch(); 18.445 @@ -1244,24 +888,6 @@ 18.446 } 18.447 } 18.448 18.449 - protected final int fetchCharPropertyToCType() { 18.450 - mark(); 18.451 - 18.452 - while (left()) { 18.453 - int last = p; 18.454 - fetch(); 18.455 - if (c == '}') { 18.456 - String name = new String(chars, _p, last - _p); 18.457 - return PosixBracket.propertyNameToCType(name); 18.458 - } else if (c == '(' || c == ')' || c == '{' || c == '|') { 18.459 - String name = new String(chars, _p, last - _p); 18.460 - throw new JOniException(ERR_INVALID_CHAR_PROPERTY_NAME.replaceAll("%n", name)); 18.461 - } 18.462 - } 18.463 - newInternalException(ERR_PARSER_BUG); 18.464 - return 0; // not reached 18.465 - } 18.466 - 18.467 protected final void syntaxWarn(String message, char c) { 18.468 syntaxWarn(message.replace("<%n>", Character.toString(c))); 18.469 }
19.1 --- a/src/jdk/nashorn/internal/runtime/regexp/joni/Matcher.java Thu May 16 13:44:25 2013 +0200 19.2 +++ b/src/jdk/nashorn/internal/runtime/regexp/joni/Matcher.java Thu May 16 19:52:39 2013 +0200 19.3 @@ -58,17 +58,10 @@ 19.4 // main matching method 19.5 protected abstract int matchAt(int range, int sstart, int sprev); 19.6 19.7 - protected abstract void stateCheckBuffInit(int strLength, int offset, int stateNum); 19.8 - protected abstract void stateCheckBuffClear(); 19.9 - 19.10 public final Region getRegion() { 19.11 return msaRegion; 19.12 } 19.13 19.14 - public final Region getEagerRegion() { 19.15 - return msaRegion != null ? msaRegion : new Region(msaBegin, msaEnd); 19.16 - } 19.17 - 19.18 public final int getBegin() { 19.19 return msaBegin; 19.20 } 19.21 @@ -86,11 +79,6 @@ 19.22 public final int match(int at, int range, int option) { 19.23 msaInit(option, at); 19.24 19.25 - if (Config.USE_COMBINATION_EXPLOSION_CHECK) { 19.26 - int offset = at = str; 19.27 - stateCheckBuffInit(end - str, offset, regex.numCombExpCheck); // move it to construction? 19.28 - } // USE_COMBINATION_EXPLOSION_CHECK 19.29 - 19.30 int prev = EncodingHelper.prevCharHead(str, at); 19.31 19.32 if (Config.USE_MATCH_RANGE_MUST_BE_INSIDE_OF_SPECIFIED_RANGE) { 19.33 @@ -377,8 +365,6 @@ 19.34 prev = -1; 19.35 msaInit(option, start); 19.36 19.37 - if (Config.USE_COMBINATION_EXPLOSION_CHECK) stateCheckBuffClear(); 19.38 - 19.39 if (matchCheck(end, s, prev)) return match(s); 19.40 return mismatch(); 19.41 } 19.42 @@ -393,10 +379,6 @@ 19.43 } 19.44 19.45 msaInit(option, origStart); 19.46 - if (Config.USE_COMBINATION_EXPLOSION_CHECK) { 19.47 - int offset = Math.min(start, range) - str; 19.48 - stateCheckBuffInit(end - str, offset, regex.numCombExpCheck); 19.49 - } 19.50 19.51 s = start; 19.52 if (range > start) { /* forward search */
20.1 --- a/src/jdk/nashorn/internal/runtime/regexp/joni/NameEntry.java Thu May 16 13:44:25 2013 +0200 20.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 20.3 @@ -1,97 +0,0 @@ 20.4 -/* 20.5 - * Permission is hereby granted, free of charge, to any person obtaining a copy of 20.6 - * this software and associated documentation files (the "Software"), to deal in 20.7 - * the Software without restriction, including without limitation the rights to 20.8 - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 20.9 - * of the Software, and to permit persons to whom the Software is furnished to do 20.10 - * so, subject to the following conditions: 20.11 - * 20.12 - * The above copyright notice and this permission notice shall be included in all 20.13 - * copies or substantial portions of the Software. 20.14 - * 20.15 - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20.16 - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20.17 - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20.18 - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20.19 - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20.20 - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20.21 - * SOFTWARE. 20.22 - */ 20.23 -package jdk.nashorn.internal.runtime.regexp.joni; 20.24 - 20.25 -public final class NameEntry { 20.26 - static final int INIT_NAME_BACKREFS_ALLOC_NUM = 8; 20.27 - 20.28 - public final char[] name; 20.29 - public final int nameP; 20.30 - public final int nameEnd; 20.31 - 20.32 - int backNum; 20.33 - int backRef1; 20.34 - int backRefs[]; 20.35 - 20.36 - public NameEntry(char[] chars, int p, int end) { 20.37 - name = chars; 20.38 - nameP = p; 20.39 - nameEnd = end; 20.40 - } 20.41 - 20.42 - public int[] getBackRefs() { 20.43 - switch (backNum) { 20.44 - case 0: 20.45 - return new int[]{}; 20.46 - case 1: 20.47 - return new int[]{backRef1}; 20.48 - default: 20.49 - int[]result = new int[backNum]; 20.50 - System.arraycopy(backRefs, 0, result, 0, backNum); 20.51 - return result; 20.52 - } 20.53 - } 20.54 - 20.55 - private void alloc() { 20.56 - backRefs = new int[INIT_NAME_BACKREFS_ALLOC_NUM]; 20.57 - } 20.58 - 20.59 - private void ensureSize() { 20.60 - if (backNum > backRefs.length) { 20.61 - int[]tmp = new int[backRefs.length << 1]; 20.62 - System.arraycopy(backRefs, 0, tmp, 0, backRefs.length); 20.63 - backRefs = tmp; 20.64 - } 20.65 - } 20.66 - 20.67 - public void addBackref(int backRef) { 20.68 - backNum++; 20.69 - 20.70 - switch (backNum) { 20.71 - case 1: 20.72 - backRef1 = backRef; 20.73 - break; 20.74 - case 2: 20.75 - alloc(); 20.76 - backRefs[0] = backRef1; 20.77 - backRefs[1] = backRef; 20.78 - break; 20.79 - default: 20.80 - ensureSize(); 20.81 - backRefs[backNum - 1] = backRef; 20.82 - } 20.83 - } 20.84 - 20.85 - public String toString() { 20.86 - StringBuilder buff = new StringBuilder(new String(name, nameP, nameEnd - nameP) + " "); 20.87 - if (backNum == 0) { 20.88 - buff.append("-"); 20.89 - } else if (backNum == 1){ 20.90 - buff.append(backRef1); 20.91 - } else { 20.92 - for (int i=0; i<backNum; i++){ 20.93 - if (i > 0) buff.append(", "); 20.94 - buff.append(backRefs[i]); 20.95 - } 20.96 - } 20.97 - return buff.toString(); 20.98 - } 20.99 - 20.100 -}
21.1 --- a/src/jdk/nashorn/internal/runtime/regexp/joni/NativeMachine.java Thu May 16 13:44:25 2013 +0200 21.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 21.3 @@ -1,27 +0,0 @@ 21.4 -/* 21.5 - * Permission is hereby granted, free of charge, to any person obtaining a copy of 21.6 - * this software and associated documentation files (the "Software"), to deal in 21.7 - * the Software without restriction, including without limitation the rights to 21.8 - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 21.9 - * of the Software, and to permit persons to whom the Software is furnished to do 21.10 - * so, subject to the following conditions: 21.11 - * 21.12 - * The above copyright notice and this permission notice shall be included in all 21.13 - * copies or substantial portions of the Software. 21.14 - * 21.15 - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21.16 - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21.17 - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21.18 - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21.19 - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21.20 - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21.21 - * SOFTWARE. 21.22 - */ 21.23 -package jdk.nashorn.internal.runtime.regexp.joni; 21.24 - 21.25 -public abstract class NativeMachine extends Matcher { 21.26 - 21.27 - protected NativeMachine(Regex regex, char[] chars, int p, int end) { 21.28 - super(regex, chars, p, end); 21.29 - } 21.30 -}
22.1 --- a/src/jdk/nashorn/internal/runtime/regexp/joni/Parser.java Thu May 16 13:44:25 2013 +0200 22.2 +++ b/src/jdk/nashorn/internal/runtime/regexp/joni/Parser.java Thu May 16 19:52:39 2013 +0200 22.3 @@ -19,20 +19,15 @@ 22.4 */ 22.5 package jdk.nashorn.internal.runtime.regexp.joni; 22.6 22.7 -import static jdk.nashorn.internal.runtime.regexp.joni.BitStatus.bsOnAtSimple; 22.8 import static jdk.nashorn.internal.runtime.regexp.joni.BitStatus.bsOnOff; 22.9 import static jdk.nashorn.internal.runtime.regexp.joni.Option.isDontCaptureGroup; 22.10 import static jdk.nashorn.internal.runtime.regexp.joni.Option.isIgnoreCase; 22.11 22.12 import jdk.nashorn.internal.runtime.regexp.joni.encoding.CharacterType; 22.13 -import jdk.nashorn.internal.runtime.regexp.joni.encoding.PosixBracket; 22.14 -import jdk.nashorn.internal.runtime.regexp.joni.encoding.Ptr; 22.15 import jdk.nashorn.internal.runtime.regexp.joni.ast.AnchorNode; 22.16 import jdk.nashorn.internal.runtime.regexp.joni.ast.AnyCharNode; 22.17 import jdk.nashorn.internal.runtime.regexp.joni.ast.BackRefNode; 22.18 import jdk.nashorn.internal.runtime.regexp.joni.ast.CClassNode; 22.19 -import jdk.nashorn.internal.runtime.regexp.joni.ast.CTypeNode; 22.20 -import jdk.nashorn.internal.runtime.regexp.joni.ast.CallNode; 22.21 import jdk.nashorn.internal.runtime.regexp.joni.ast.ConsAltNode; 22.22 import jdk.nashorn.internal.runtime.regexp.joni.ast.EncloseNode; 22.23 import jdk.nashorn.internal.runtime.regexp.joni.ast.Node; 22.24 @@ -66,65 +61,6 @@ 22.25 return root; 22.26 } 22.27 22.28 - private static final int POSIX_BRACKET_NAME_MIN_LEN = 4; 22.29 - private static final int POSIX_BRACKET_CHECK_LIMIT_LENGTH = 20; 22.30 - private static final char BRACKET_END[] = ":]".toCharArray(); 22.31 - private boolean parsePosixBracket(CClassNode cc) { 22.32 - mark(); 22.33 - 22.34 - boolean not; 22.35 - if (peekIs('^')) { 22.36 - inc(); 22.37 - not = true; 22.38 - } else { 22.39 - not = false; 22.40 - } 22.41 - if (stop - p >= POSIX_BRACKET_NAME_MIN_LEN + 3) { // else goto not_posix_bracket 22.42 - char[][] pbs = PosixBracket.PBSNamesLower; 22.43 - for (int i=0; i<pbs.length; i++) { 22.44 - char[] name = pbs[i]; 22.45 - // hash lookup here ? 22.46 - if (EncodingHelper.strNCmp(chars, p, stop, name, 0, name.length) == 0) { 22.47 - p += name.length; 22.48 - if (EncodingHelper.strNCmp(chars, p, stop, BRACKET_END, 0, BRACKET_END.length) != 0) { 22.49 - newSyntaxException(ERR_INVALID_POSIX_BRACKET_TYPE); 22.50 - } 22.51 - cc.addCType(PosixBracket.PBSValues[i], not, env, this); 22.52 - inc(); 22.53 - inc(); 22.54 - return false; 22.55 - } 22.56 - } 22.57 - 22.58 - } 22.59 - 22.60 - // not_posix_bracket: 22.61 - c = 0; 22.62 - int i= 0; 22.63 - while (left() && ((c=peek()) != ':') && c != ']') { 22.64 - inc(); 22.65 - if (++i > POSIX_BRACKET_CHECK_LIMIT_LENGTH) break; 22.66 - } 22.67 - 22.68 - if (c == ':' && left()) { 22.69 - inc(); 22.70 - if (left()) { 22.71 - fetch(); 22.72 - if (c == ']') newSyntaxException(ERR_INVALID_POSIX_BRACKET_TYPE); 22.73 - } 22.74 - } 22.75 - restore(); 22.76 - return true; /* 1: is not POSIX bracket, but no error. */ 22.77 - } 22.78 - 22.79 - private CClassNode parseCharProperty() { 22.80 - int ctype = fetchCharPropertyToCType(); 22.81 - CClassNode n = new CClassNode(); 22.82 - n.addCType(ctype, false, env, this); 22.83 - if (token.getPropNot()) n.setNot(); 22.84 - return n; 22.85 - } 22.86 - 22.87 private boolean codeExistCheck(int code, boolean ignoreEscaped) { 22.88 mark(); 22.89 22.90 @@ -225,29 +161,11 @@ 22.91 parseCharClassValEntry(cc, arg); // val_entry:, val_entry2 22.92 break; 22.93 22.94 - case POSIX_BRACKET_OPEN: 22.95 - if (parsePosixBracket(cc)) { /* true: is not POSIX bracket */ 22.96 - env.ccEscWarn("["); 22.97 - p = token.backP; 22.98 - arg.v = token.getC(); 22.99 - arg.vIsRaw = false; 22.100 - parseCharClassValEntry(cc, arg); // goto val_entry 22.101 - break; 22.102 - } 22.103 - cc.nextStateClass(arg, env); // goto next_class 22.104 - break; 22.105 - 22.106 case CHAR_TYPE: 22.107 cc.addCType(token.getPropCType(), token.getPropNot(), env, this); 22.108 cc.nextStateClass(arg, env); // next_class: 22.109 break; 22.110 22.111 - case CHAR_PROPERTY: 22.112 - int ctype = fetchCharPropertyToCType(); 22.113 - cc.addCType(ctype, token.getPropNot(), env, this); 22.114 - cc.nextStateClass(arg, env); // goto next_class 22.115 - break; 22.116 - 22.117 case CC_RANGE: 22.118 if (arg.state == CCSTATE.VALUE) { 22.119 fetchTokenInCC(); 22.120 @@ -413,15 +331,6 @@ 22.121 node = new EncloseNode(EncloseType.STOP_BACKTRACK); // node_new_enclose 22.122 break; 22.123 case '\'': 22.124 - if (Config.USE_NAMED_GROUP) { 22.125 - if (syntax.op2QMarkLtNamedGroup()) { 22.126 - listCapture = false; // goto named_group1 22.127 - node = parseEncloseNamedGroup2(listCapture); 22.128 - break; 22.129 - } else { 22.130 - newSyntaxException(ERR_UNDEFINED_GROUP_OPTION); 22.131 - } 22.132 - } // USE_NAMED_GROUP 22.133 break; 22.134 case '<': /* look behind (?<=...), (?<!...) */ 22.135 fetch(); 22.136 @@ -430,36 +339,12 @@ 22.137 } else if (c == '!') { 22.138 node = new AnchorNode(AnchorType.LOOK_BEHIND_NOT); 22.139 } else { 22.140 - if (Config.USE_NAMED_GROUP) { 22.141 - if (syntax.op2QMarkLtNamedGroup()) { 22.142 - unfetch(); 22.143 - c = '<'; 22.144 - 22.145 - listCapture = false; // named_group1: 22.146 - node = parseEncloseNamedGroup2(listCapture); // named_group2: 22.147 - break; 22.148 - } else { 22.149 - newSyntaxException(ERR_UNDEFINED_GROUP_OPTION); 22.150 - } 22.151 - 22.152 - } else { // USE_NAMED_GROUP 22.153 - newSyntaxException(ERR_UNDEFINED_GROUP_OPTION); 22.154 - } // USE_NAMED_GROUP 22.155 + newSyntaxException(ERR_UNDEFINED_GROUP_OPTION); 22.156 } 22.157 break; 22.158 case '@': 22.159 if (syntax.op2AtMarkCaptureHistory()) { 22.160 - if (Config.USE_NAMED_GROUP) { 22.161 - if (syntax.op2QMarkLtNamedGroup()) { 22.162 - fetch(); 22.163 - if (c == '<' || c == '\'') { 22.164 - listCapture = true; 22.165 - node = parseEncloseNamedGroup2(listCapture); // goto named_group2 /* (?@<name>...) */ 22.166 - } 22.167 - unfetch(); 22.168 - } 22.169 - } // USE_NAMED_GROUP 22.170 - EncloseNode en = new EncloseNode(env.option, false); // node_new_enclose_memory 22.171 + EncloseNode en = new EncloseNode(); // node_new_enclose_memory 22.172 int num = env.addMemEntry(); 22.173 if (num >= BitStatus.BIT_STATUS_BITS_NUM) newValueException(ERR_GROUP_NUMBER_OVER_FOR_CAPTURE_HISTORY); 22.174 en.regNum = num; 22.175 @@ -546,7 +431,7 @@ 22.176 returnCode = 1; /* group */ 22.177 return node; 22.178 } 22.179 - EncloseNode en = new EncloseNode(env.option, false); // node_new_enclose_memory 22.180 + EncloseNode en = new EncloseNode(); // node_new_enclose_memory 22.181 int num = env.addMemEntry(); 22.182 en.regNum = num; 22.183 node = en; 22.184 @@ -570,48 +455,6 @@ 22.185 return node; // ?? 22.186 } 22.187 22.188 - private Node parseEncloseNamedGroup2(boolean listCapture) { 22.189 - int nm = p; 22.190 - int num = fetchName(c, false); 22.191 - int nameEnd = value; 22.192 - num = env.addMemEntry(); 22.193 - if (listCapture && num >= BitStatus.BIT_STATUS_BITS_NUM) newValueException(ERR_GROUP_NUMBER_OVER_FOR_CAPTURE_HISTORY); 22.194 - 22.195 - regex.nameAdd(chars, nm, nameEnd, num, syntax); 22.196 - EncloseNode en = new EncloseNode(env.option, true); // node_new_enclose_memory 22.197 - en.regNum = num; 22.198 - 22.199 - Node node = en; 22.200 - 22.201 - if (listCapture) env.captureHistory = bsOnAtSimple(env.captureHistory, num); 22.202 - env.numNamed++; 22.203 - return node; 22.204 - } 22.205 - 22.206 - private int findStrPosition(int[]s, int n, int from, int to, Ptr nextChar) { 22.207 - int x; 22.208 - int q; 22.209 - int p = from; 22.210 - int i = 0; 22.211 - while (p < to) { 22.212 - x = chars[p]; 22.213 - q = p + 1; 22.214 - if (x == s[0]) { 22.215 - for (i=1; i<n && q<to; i++) { 22.216 - x = chars[q]; 22.217 - if (x != s[i]) break; 22.218 - q++; 22.219 - } 22.220 - if (i >= n) { 22.221 - if (chars[nextChar.p] != 0) nextChar.p = q; // we may need zero term semantics... 22.222 - return p; 22.223 - } 22.224 - } 22.225 - p = q; 22.226 - } 22.227 - return -1; 22.228 - } 22.229 - 22.230 private Node parseExp(TokenType term) { 22.231 if (token.type == term) return StringNode.EMPTY; // goto end_of_token 22.232 22.233 @@ -656,16 +499,6 @@ 22.234 node = new StringNode(buf, 0, 1); 22.235 break; 22.236 22.237 - case QUOTE_OPEN: 22.238 - int[] endOp = new int[] {syntax.metaCharTable.esc, 'E'}; 22.239 - int qstart = p; 22.240 - Ptr nextChar = new Ptr(); 22.241 - int qend = findStrPosition(endOp, endOp.length, qstart, stop, nextChar); 22.242 - if (qend == -1) nextChar.p = qend = stop; 22.243 - node = new StringNode(chars, qstart, qend); 22.244 - p = nextChar.p; 22.245 - break; 22.246 - 22.247 case CHAR_TYPE: 22.248 switch(token.getPropCType()) { 22.249 case CharacterType.D: 22.250 @@ -679,10 +512,6 @@ 22.251 } 22.252 break; 22.253 22.254 - case CharacterType.WORD: 22.255 - node = new CTypeNode(token.getPropCType(), token.getPropNot()); 22.256 - break; 22.257 - 22.258 case CharacterType.SPACE: 22.259 case CharacterType.DIGIT: 22.260 case CharacterType.XDIGIT: 22.261 @@ -699,10 +528,6 @@ 22.262 } // inner switch 22.263 break; 22.264 22.265 - case CHAR_PROPERTY: 22.266 - node = parseCharProperty(); 22.267 - break; 22.268 - 22.269 case CC_CC_OPEN: 22.270 CClassNode cc = parseCharClass(); 22.271 node = cc; 22.272 @@ -735,20 +560,6 @@ 22.273 token.getBackrefExistLevel(), // #ifdef USE_BACKREF_AT_LEVEL 22.274 token.getBackrefLevel(), // ... 22.275 env); 22.276 - 22.277 - break; 22.278 - 22.279 - case CALL: 22.280 - if (Config.USE_SUBEXP_CALL) { 22.281 - int gNum = token.getCallGNum(); 22.282 - 22.283 - if (gNum < 0) { 22.284 - gNum = backrefRelToAbs(gNum); 22.285 - if (gNum <= 0) newValueException(ERR_INVALID_BACKREF); 22.286 - } 22.287 - node = new CallNode(chars, token.getCallNameP(), token.getCallNameEnd(), gNum); 22.288 - env.numCall++; 22.289 - } // USE_SUBEXP_CALL 22.290 break; 22.291 22.292 case ANCHOR:
23.1 --- a/src/jdk/nashorn/internal/runtime/regexp/joni/Regex.java Thu May 16 13:44:25 2013 +0200 23.2 +++ b/src/jdk/nashorn/internal/runtime/regexp/joni/Regex.java Thu May 16 19:52:39 2013 +0200 23.3 @@ -23,9 +23,11 @@ 23.4 import static jdk.nashorn.internal.runtime.regexp.joni.Option.isCaptureGroup; 23.5 import static jdk.nashorn.internal.runtime.regexp.joni.Option.isDontCaptureGroup; 23.6 23.7 +import java.nio.file.Files; 23.8 import java.util.HashMap; 23.9 import java.util.Iterator; 23.10 23.11 +import jdk.nashorn.internal.runtime.regexp.joni.ast.Node; 23.12 import jdk.nashorn.internal.runtime.regexp.joni.constants.AnchorType; 23.13 import jdk.nashorn.internal.runtime.regexp.joni.constants.RegexState; 23.14 import jdk.nashorn.internal.runtime.regexp.joni.exception.ErrorMessages; 23.15 @@ -44,7 +46,6 @@ 23.16 int numMem; /* used memory(...) num counted from 1 */ 23.17 int numRepeat; /* OP_REPEAT/OP_REPEAT_NG id-counter */ 23.18 int numNullCheck; /* OP_NULL_CHECK_START/END id counter */ 23.19 - int numCombExpCheck; /* combination explosion check */ 23.20 int numCall; /* number of subexp call */ 23.21 int captureHistory; /* (?@...) flag (1-31) */ 23.22 int btMemStart; /* need backtrack flag */ 23.23 @@ -57,7 +58,7 @@ 23.24 23.25 WarnCallback warnings; 23.26 MatcherFactory factory; 23.27 - private Analyser analyser; 23.28 + protected Analyser analyser; 23.29 23.30 int options; 23.31 int userOptions; 23.32 @@ -65,8 +66,6 @@ 23.33 //final Syntax syntax; 23.34 final int caseFoldFlag; 23.35 23.36 - HashMap<String,NameEntry> nameTable; // named entries 23.37 - 23.38 /* optimization info (string search, char-map and anchors) */ 23.39 SearchAlgorithm searchAlgorithm; /* optimize flag */ 23.40 int thresholdLength; /* search str-length for apply optimize */ 23.41 @@ -172,112 +171,6 @@ 23.42 return numMem; 23.43 } 23.44 23.45 - public int numberOfCaptureHistories() { 23.46 - if (Config.USE_CAPTURE_HISTORY) { 23.47 - int n = 0; 23.48 - for (int i=0; i<=Config.MAX_CAPTURE_HISTORY_GROUP; i++) { 23.49 - if (bsAt(captureHistory, i)) n++; 23.50 - } 23.51 - return n; 23.52 - } else { 23.53 - return 0; 23.54 - } 23.55 - } 23.56 - 23.57 - String nameTableToString() { 23.58 - StringBuilder sb = new StringBuilder(); 23.59 - 23.60 - if (nameTable != null) { 23.61 - sb.append("name table\n"); 23.62 - for (NameEntry ne : nameTable.values()) { 23.63 - sb.append(" " + ne + "\n"); 23.64 - } 23.65 - sb.append("\n"); 23.66 - } 23.67 - return sb.toString(); 23.68 - } 23.69 - 23.70 - NameEntry nameFind(char[] name, int nameP, int nameEnd) { 23.71 - if (nameTable != null) return nameTable.get(new String(name, nameP, nameEnd - nameP)); 23.72 - return null; 23.73 - } 23.74 - 23.75 - void renumberNameTable(int[]map) { 23.76 - if (nameTable != null) { 23.77 - for (NameEntry e : nameTable.values()) { 23.78 - if (e.backNum > 1) { 23.79 - for (int i=0; i<e.backNum; i++) { 23.80 - e.backRefs[i] = map[e.backRefs[i]]; 23.81 - } 23.82 - } else if (e.backNum == 1) { 23.83 - e.backRef1 = map[e.backRef1]; 23.84 - } 23.85 - } 23.86 - } 23.87 - } 23.88 - 23.89 - public int numberOfNames() { 23.90 - return nameTable == null ? 0 : nameTable.size(); 23.91 - } 23.92 - 23.93 - void nameAdd(char[] name, int nameP, int nameEnd, int backRef, Syntax syntax) { 23.94 - if (nameEnd - nameP <= 0) throw new ValueException(ErrorMessages.ERR_EMPTY_GROUP_NAME); 23.95 - 23.96 - NameEntry e = null; 23.97 - if (nameTable == null) { 23.98 - nameTable = new HashMap<String,NameEntry>(); // 13, oni defaults to 5 23.99 - } else { 23.100 - e = nameFind(name, nameP, nameEnd); 23.101 - } 23.102 - 23.103 - if (e == null) { 23.104 - // dup the name here as oni does ?, what for ? (it has to manage it, we don't) 23.105 - e = new NameEntry(name, nameP, nameEnd); 23.106 - nameTable.put(new String(name, nameP, nameEnd - nameP), e); 23.107 - } else if (e.backNum >= 1 && !syntax.allowMultiplexDefinitionName()) { 23.108 - throw new ValueException(ErrorMessages.ERR_MULTIPLEX_DEFINED_NAME, new String(name, nameP, nameEnd - nameP)); 23.109 - } 23.110 - 23.111 - e.addBackref(backRef); 23.112 - } 23.113 - 23.114 - NameEntry nameToGroupNumbers(char[] name, int nameP, int nameEnd) { 23.115 - return nameFind(name, nameP, nameEnd); 23.116 - } 23.117 - 23.118 - public int nameToBackrefNumber(char[] name, int nameP, int nameEnd, Region region) { 23.119 - NameEntry e = nameToGroupNumbers(name, nameP, nameEnd); 23.120 - if (e == null) throw new ValueException(ErrorMessages.ERR_UNDEFINED_NAME_REFERENCE, 23.121 - new String(name, nameP, nameEnd - nameP)); 23.122 - 23.123 - switch(e.backNum) { 23.124 - case 0: 23.125 - throw new InternalException(ErrorMessages.ERR_PARSER_BUG); 23.126 - case 1: 23.127 - return e.backRef1; 23.128 - default: 23.129 - if (region != null) { 23.130 - for (int i = e.backNum - 1; i >= 0; i--) { 23.131 - if (region.beg[e.backRefs[i]] != Region.REGION_NOTPOS) return e.backRefs[i]; 23.132 - } 23.133 - } 23.134 - return e.backRefs[e.backNum - 1]; 23.135 - } 23.136 - } 23.137 - 23.138 - public Iterator<NameEntry> namedBackrefIterator() { 23.139 - return nameTable.values().iterator(); 23.140 - } 23.141 - 23.142 - public boolean noNameGroupIsActive(Syntax syntax) { 23.143 - if (isDontCaptureGroup(options)) return false; 23.144 - 23.145 - if (Config.USE_NAMED_GROUP) { 23.146 - if (numberOfNames() > 0 && syntax.captureOnlyNamedGroup() && !isCaptureGroup(options)) return false; 23.147 - } 23.148 - return true; 23.149 - } 23.150 - 23.151 /* set skip map for Boyer-Moor search */ 23.152 void setupBMSkipMap() { 23.153 char[] chars = exact; 23.154 @@ -353,16 +246,6 @@ 23.155 exactP = exactEnd = 0; 23.156 } 23.157 23.158 - public String encStringToString(byte[]bytes, int p, int end) { 23.159 - StringBuilder sb = new StringBuilder("\nPATTERN: /"); 23.160 - 23.161 - while (p < end) { 23.162 - sb.append(new String(new byte[]{bytes[p]})); 23.163 - p++; 23.164 - } 23.165 - return sb.append("/").toString(); 23.166 - } 23.167 - 23.168 public String optimizeInfoToString() { 23.169 String s = ""; 23.170 s += "optimize: " + searchAlgorithm.getName() + "\n"; 23.171 @@ -410,19 +293,13 @@ 23.172 return options; 23.173 } 23.174 23.175 - public void setUserOptions(int options) { 23.176 - this.userOptions = options; 23.177 + public String dumpTree() { 23.178 + return analyser == null ? null : analyser.root.toString(); 23.179 } 23.180 23.181 - public int getUserOptions() { 23.182 - return userOptions; 23.183 + public String dumpByteCode() { 23.184 + compile(); 23.185 + return new ByteCodePrinter(this).byteCodeListToString(); 23.186 } 23.187 23.188 - public void setUserObject(Object object) { 23.189 - this.userObject = object; 23.190 - } 23.191 - 23.192 - public Object getUserObject() { 23.193 - return userObject; 23.194 - } 23.195 }
24.1 --- a/src/jdk/nashorn/internal/runtime/regexp/joni/Region.java Thu May 16 13:44:25 2013 +0200 24.2 +++ b/src/jdk/nashorn/internal/runtime/regexp/joni/Region.java Thu May 16 19:52:39 2013 +0200 24.3 @@ -25,7 +25,6 @@ 24.4 public final int numRegs; 24.5 public final int[]beg; 24.6 public final int[]end; 24.7 - public CaptureTreeNode historyRoot; 24.8 24.9 public Region(int num) { 24.10 this.numRegs = num; 24.11 @@ -33,20 +32,6 @@ 24.12 this.end = new int[num]; 24.13 } 24.14 24.15 - public Region(int begin, int end) { 24.16 - this.numRegs = 1; 24.17 - this.beg = new int[]{begin}; 24.18 - this.end = new int[]{end}; 24.19 - } 24.20 - 24.21 - public Region clone() { 24.22 - Region region = new Region(numRegs); 24.23 - System.arraycopy(beg, 0, region.beg, 0, beg.length); 24.24 - System.arraycopy(end, 0, region.end, 0, end.length); 24.25 - if (historyRoot != null) region.historyRoot = historyRoot.cloneTree(); 24.26 - return region; 24.27 - } 24.28 - 24.29 public String toString() { 24.30 StringBuilder sb = new StringBuilder(); 24.31 sb.append("Region: \n"); 24.32 @@ -54,10 +39,6 @@ 24.33 return sb.toString(); 24.34 } 24.35 24.36 - CaptureTreeNode getCaptureTree() { 24.37 - return historyRoot; 24.38 - } 24.39 - 24.40 void clear() { 24.41 for (int i=0; i<beg.length; i++) { 24.42 beg[i] = end[i] = REGION_NOTPOS;
25.1 --- a/src/jdk/nashorn/internal/runtime/regexp/joni/ScanEnvironment.java Thu May 16 13:44:25 2013 +0200 25.2 +++ b/src/jdk/nashorn/internal/runtime/regexp/joni/ScanEnvironment.java Thu May 16 19:52:39 2013 +0200 25.3 @@ -40,16 +40,10 @@ 25.4 final public Regex reg; 25.5 25.6 int numCall; 25.7 - UnsetAddrList unsetAddrList; // USE_SUBEXP_CALL 25.8 public int numMem; 25.9 25.10 - int numNamed; // USE_NAMED_GROUP 25.11 - 25.12 public Node memNodes[]; 25.13 25.14 - // USE_COMBINATION_EXPLOSION_CHECK 25.15 - int numCombExpCheck; 25.16 - int combExpMaxRegNum; 25.17 int currMaxRegNum; 25.18 boolean hasRecursion; 25.19 25.20 @@ -69,12 +63,8 @@ 25.21 numCall = 0; 25.22 numMem = 0; 25.23 25.24 - numNamed = 0; 25.25 - 25.26 memNodes = null; 25.27 25.28 - numCombExpCheck = 0; 25.29 - combExpMaxRegNum = 0; 25.30 currMaxRegNum = 0; 25.31 hasRecursion = false; 25.32 }
26.1 --- a/src/jdk/nashorn/internal/runtime/regexp/joni/ScannerSupport.java Thu May 16 13:44:25 2013 +0200 26.2 +++ b/src/jdk/nashorn/internal/runtime/regexp/joni/ScannerSupport.java Thu May 16 19:52:39 2013 +0200 26.3 @@ -37,6 +37,8 @@ 26.4 private final int end; // pattern end position for reset() support 26.5 protected int _p; // used by mark()/restore() to mark positions 26.6 26.7 + private final static int INT_SIGN_BIT = 1 << 31; 26.8 + 26.9 protected ScannerSupport(char[] chars, int p, int end) { 26.10 this.chars = chars; 26.11 this.begin = p; 26.12 @@ -53,8 +55,6 @@ 26.13 return end; 26.14 } 26.15 26.16 - private final int INT_SIGN_BIT = 1 << 31; 26.17 - 26.18 protected final int scanUnsignedNumber() { 26.19 int last = c; 26.20 int num = 0; // long ???
27.1 --- a/src/jdk/nashorn/internal/runtime/regexp/joni/StackMachine.java Thu May 16 13:44:25 2013 +0200 27.2 +++ b/src/jdk/nashorn/internal/runtime/regexp/joni/StackMachine.java Thu May 16 19:52:39 2013 +0200 27.3 @@ -22,7 +22,6 @@ 27.4 import static jdk.nashorn.internal.runtime.regexp.joni.BitStatus.bsAt; 27.5 27.6 import java.lang.ref.WeakReference; 27.7 -import java.util.Arrays; 27.8 27.9 import jdk.nashorn.internal.runtime.regexp.joni.constants.StackPopLevel; 27.10 import jdk.nashorn.internal.runtime.regexp.joni.constants.StackType; 27.11 @@ -36,10 +35,6 @@ 27.12 protected final int[]repeatStk; 27.13 protected final int memStartStk, memEndStk; 27.14 27.15 - // CEC 27.16 - protected byte[] stateCheckBuff; // move to int[] ? 27.17 - int stateCheckBuffSize; 27.18 - 27.19 protected StackMachine(Regex regex, char[] chars, int p , int end) { 27.20 super(regex, chars, p, end); 27.21 27.22 @@ -104,67 +99,12 @@ 27.23 stk++; 27.24 } 27.25 27.26 - // CEC 27.27 - 27.28 - // STATE_CHECK_POS 27.29 - private int stateCheckPos(int s, int snum) { 27.30 - return (s - str) * regex.numCombExpCheck + (snum - 1); 27.31 - } 27.32 - 27.33 - // STATE_CHECK_VAL 27.34 - protected final boolean stateCheckVal(int s, int snum) { 27.35 - if (stateCheckBuff != null) { 27.36 - int x = stateCheckPos(s, snum); 27.37 - return (stateCheckBuff[x / 8] & (1 << (x % 8))) != 0; 27.38 - } 27.39 - return false; 27.40 - } 27.41 - 27.42 - // ELSE_IF_STATE_CHECK_MARK 27.43 - private void stateCheckMark() { 27.44 - StackEntry e = stack[stk]; 27.45 - int x = stateCheckPos(e.getStatePStr(), e.getStateCheck()); 27.46 - stateCheckBuff[x / 8] |= (1 << (x % 8)); 27.47 - } 27.48 - 27.49 - // STATE_CHECK_BUFF_INIT 27.50 - private static final int STATE_CHECK_BUFF_MALLOC_THRESHOLD_SIZE = 16; 27.51 - protected final void stateCheckBuffInit(int strLength, int offset, int stateNum) { 27.52 - if (stateNum > 0 && strLength >= Config.CHECK_STRING_THRESHOLD_LEN) { 27.53 - int size = ((strLength + 1) * stateNum + 7) >>> 3; 27.54 - offset = (offset * stateNum) >>> 3; 27.55 - 27.56 - if (size > 0 && offset < size && size < Config.CHECK_BUFF_MAX_SIZE) { 27.57 - if (size >= STATE_CHECK_BUFF_MALLOC_THRESHOLD_SIZE) { 27.58 - stateCheckBuff = new byte[size]; 27.59 - } else { 27.60 - // same impl, reduce... 27.61 - stateCheckBuff = new byte[size]; 27.62 - } 27.63 - Arrays.fill(stateCheckBuff, offset, (size - offset), (byte)0); 27.64 - stateCheckBuffSize = size; 27.65 - } else { 27.66 - stateCheckBuff = null; // reduce 27.67 - stateCheckBuffSize = 0; 27.68 - } 27.69 - } else { 27.70 - stateCheckBuff = null; // reduce 27.71 - stateCheckBuffSize = 0; 27.72 - } 27.73 - } 27.74 - 27.75 - protected final void stateCheckBuffClear() { 27.76 - stateCheckBuff = null; 27.77 - stateCheckBuffSize = 0; 27.78 - } 27.79 - 27.80 private void push(int type, int pat, int s, int prev) { 27.81 StackEntry e = ensure1(); 27.82 e.type = type; 27.83 e.setStatePCode(pat); 27.84 e.setStatePStr(s); 27.85 e.setStatePStrPrev(prev); 27.86 - if (Config.USE_COMBINATION_EXPLOSION_CHECK) e.setStateCheck(0); 27.87 stk++; 27.88 } 27.89 27.90 @@ -172,30 +112,9 @@ 27.91 StackEntry e = stack[stk]; 27.92 e.type = type; 27.93 e.setStatePCode(pat); 27.94 - if (Config.USE_COMBINATION_EXPLOSION_CHECK) e.setStateCheck(0); 27.95 stk++; 27.96 } 27.97 27.98 - protected final void pushAltWithStateCheck(int pat, int s, int sprev, int snum) { 27.99 - StackEntry e = ensure1(); 27.100 - e.type = ALT; 27.101 - e.setStatePCode(pat); 27.102 - e.setStatePStr(s); 27.103 - e.setStatePStrPrev(sprev); 27.104 - if (Config.USE_COMBINATION_EXPLOSION_CHECK) e.setStateCheck(stateCheckBuff != null ? snum : 0); 27.105 - stk++; 27.106 - } 27.107 - 27.108 - protected final void pushStateCheck(int s, int snum) { 27.109 - if (stateCheckBuff != null) { 27.110 - StackEntry e = ensure1(); 27.111 - e.type = STATE_CHECK_MARK; 27.112 - e.setStatePStr(s); 27.113 - e.setStateCheck(snum); 27.114 - stk++; 27.115 - } 27.116 - } 27.117 - 27.118 protected final void pushAlt(int pat, int s, int prev) { 27.119 push(ALT, pat, s, prev); 27.120 } 27.121 @@ -294,19 +213,6 @@ 27.122 stk++; 27.123 } 27.124 27.125 - protected final void pushCallFrame(int pat) { 27.126 - StackEntry e = ensure1(); 27.127 - e.type = CALL_FRAME; 27.128 - e.setCallFrameRetAddr(pat); 27.129 - stk++; 27.130 - } 27.131 - 27.132 - protected final void pushReturn() { 27.133 - StackEntry e = ensure1(); 27.134 - e.type = RETURN; 27.135 - stk++; 27.136 - } 27.137 - 27.138 // stack debug routines here 27.139 // ... 27.140 27.141 @@ -331,8 +237,6 @@ 27.142 27.143 if ((e.type & MASK_POP_USED) != 0) { 27.144 return e; 27.145 - } else if (Config.USE_COMBINATION_EXPLOSION_CHECK) { 27.146 - if (e.type == STATE_CHECK_MARK) stateCheckMark(); 27.147 } 27.148 } 27.149 } 27.150 @@ -346,8 +250,6 @@ 27.151 } else if (e.type == MEM_START) { 27.152 repeatStk[memStartStk + e.getMemNum()] = e.getMemStart(); 27.153 repeatStk[memEndStk + e.getMemNum()] = e.getMemEnd(); 27.154 - } else if (Config.USE_COMBINATION_EXPLOSION_CHECK) { 27.155 - if (e.type == STATE_CHECK_MARK) stateCheckMark(); 27.156 } 27.157 } 27.158 } 27.159 @@ -368,8 +270,6 @@ 27.160 } else if (e.type == MEM_END) { 27.161 repeatStk[memStartStk + e.getMemNum()] = e.getMemStart(); 27.162 repeatStk[memEndStk + e.getMemNum()] = e.getMemEnd(); 27.163 - } else if (Config.USE_COMBINATION_EXPLOSION_CHECK) { 27.164 - if (e.type == STATE_CHECK_MARK) stateCheckMark(); 27.165 } 27.166 } 27.167 } 27.168 @@ -391,8 +291,6 @@ 27.169 } else if (e.type == MEM_END){ 27.170 repeatStk[memStartStk + e.getMemNum()] = e.getMemStart(); 27.171 repeatStk[memEndStk + e.getMemNum()] = e.getMemStart(); 27.172 - } else if (Config.USE_COMBINATION_EXPLOSION_CHECK) { 27.173 - if (e.type == STATE_CHECK_MARK) stateCheckMark(); 27.174 } 27.175 } 27.176 } 27.177 @@ -414,8 +312,6 @@ 27.178 } else if (e.type == MEM_END) { 27.179 repeatStk[memStartStk + e.getMemNum()] = e.getMemStart(); 27.180 repeatStk[memEndStk + e.getMemNum()] = e.getMemEnd(); 27.181 - } else if (Config.USE_COMBINATION_EXPLOSION_CHECK) { 27.182 - if (e.type == STATE_CHECK_MARK) stateCheckMark(); 27.183 } 27.184 } 27.185 }
28.1 --- a/src/jdk/nashorn/internal/runtime/regexp/joni/Syntax.java Thu May 16 13:44:25 2013 +0200 28.2 +++ b/src/jdk/nashorn/internal/runtime/regexp/joni/Syntax.java Thu May 16 19:52:39 2013 +0200 28.3 @@ -609,7 +609,7 @@ 28.4 OP_ESC_CONTROL_CHARS | OP_ESC_C_CONTROL | OP_ESC_X_HEX2) 28.5 & ~OP_ESC_LTGT_WORD_BEGIN_END ), 28.6 28.7 - ( OP2_QMARK_GROUP_EFFECT | OP2_CCLASS_SET_OP | 28.8 + ( OP2_QMARK_GROUP_EFFECT | 28.9 OP2_ESC_V_VTAB | OP2_ESC_U_HEX4 ), 28.10 28.11 ( GNU_REGEX_BV | DIFFERENT_LEN_ALT_LOOK_BEHIND ),
29.1 --- a/src/jdk/nashorn/internal/runtime/regexp/joni/UnsetAddrList.java Thu May 16 13:44:25 2013 +0200 29.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 29.3 @@ -1,69 +0,0 @@ 29.4 -/* 29.5 - * Permission is hereby granted, free of charge, to any person obtaining a copy of 29.6 - * this software and associated documentation files (the "Software"), to deal in 29.7 - * the Software without restriction, including without limitation the rights to 29.8 - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 29.9 - * of the Software, and to permit persons to whom the Software is furnished to do 29.10 - * so, subject to the following conditions: 29.11 - * 29.12 - * The above copyright notice and this permission notice shall be included in all 29.13 - * copies or substantial portions of the Software. 29.14 - * 29.15 - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 29.16 - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 29.17 - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 29.18 - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 29.19 - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 29.20 - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 29.21 - * SOFTWARE. 29.22 - */ 29.23 -package jdk.nashorn.internal.runtime.regexp.joni; 29.24 - 29.25 -import jdk.nashorn.internal.runtime.regexp.joni.ast.EncloseNode; 29.26 -import jdk.nashorn.internal.runtime.regexp.joni.ast.Node; 29.27 -import jdk.nashorn.internal.runtime.regexp.joni.exception.ErrorMessages; 29.28 -import jdk.nashorn.internal.runtime.regexp.joni.exception.InternalException; 29.29 - 29.30 -public final class UnsetAddrList { 29.31 - int num; 29.32 - Node[]targets; 29.33 - int[]offsets; 29.34 - 29.35 - public UnsetAddrList(int size) { 29.36 - targets = new Node[size]; 29.37 - offsets = new int[size]; 29.38 - } 29.39 - 29.40 - public void add(int offset, Node node) { 29.41 - if (num >= offsets.length) { 29.42 - Node []ttmp = new Node[targets.length << 1]; 29.43 - System.arraycopy(targets, 0, ttmp, 0, num); 29.44 - targets = ttmp; 29.45 - int[]otmp = new int[offsets.length << 1]; 29.46 - System.arraycopy(offsets, 0, otmp, 0, num); 29.47 - offsets = otmp; 29.48 - } 29.49 - targets[num] = node; 29.50 - offsets[num] = offset; 29.51 - 29.52 - num++; 29.53 - } 29.54 - 29.55 - public void fix(Regex regex) { 29.56 - for (int i=0; i<num; i++) { 29.57 - EncloseNode en = (EncloseNode)targets[i]; 29.58 - if (!en.isAddrFixed()) new InternalException(ErrorMessages.ERR_PARSER_BUG); 29.59 - regex.code[offsets[i]] = en.callAddr; // is this safe ? 29.60 - } 29.61 - } 29.62 - 29.63 - public String toString() { 29.64 - StringBuilder value = new StringBuilder(); 29.65 - if (num > 0) { 29.66 - for (int i=0; i<num; i++) { 29.67 - value.append("offset + " + offsets[i] + " target: " + targets[i].getAddressName()); 29.68 - } 29.69 - } 29.70 - return value.toString(); 29.71 - } 29.72 -}
30.1 --- a/src/jdk/nashorn/internal/runtime/regexp/joni/ast/CClassNode.java Thu May 16 13:44:25 2013 +0200 30.2 +++ b/src/jdk/nashorn/internal/runtime/regexp/joni/ast/CClassNode.java Thu May 16 19:52:39 2013 +0200 30.3 @@ -22,7 +22,6 @@ 30.4 import jdk.nashorn.internal.runtime.regexp.joni.*; 30.5 import jdk.nashorn.internal.runtime.regexp.joni.constants.CCSTATE; 30.6 import jdk.nashorn.internal.runtime.regexp.joni.constants.CCVALTYPE; 30.7 -import jdk.nashorn.internal.runtime.regexp.joni.encoding.AsciiTables; 30.8 import jdk.nashorn.internal.runtime.regexp.joni.encoding.CharacterType; 30.9 import jdk.nashorn.internal.runtime.regexp.joni.encoding.IntHolder; 30.10 import jdk.nashorn.internal.runtime.regexp.joni.exception.ErrorMessages; 30.11 @@ -40,6 +39,41 @@ 30.12 30.13 private int ctype; // for hashing purposes 30.14 30.15 + private final static short AsciiCtypeTable[] = { 30.16 + 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 30.17 + 0x4008, 0x420c, 0x4209, 0x4208, 0x4208, 0x4208, 0x4008, 0x4008, 30.18 + 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 30.19 + 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 30.20 + 0x4284, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 30.21 + 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 30.22 + 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, 30.23 + 0x78b0, 0x78b0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 30.24 + 0x41a0, 0x7ca2, 0x7ca2, 0x7ca2, 0x7ca2, 0x7ca2, 0x7ca2, 0x74a2, 30.25 + 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 30.26 + 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 30.27 + 0x74a2, 0x74a2, 0x74a2, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x51a0, 30.28 + 0x41a0, 0x78e2, 0x78e2, 0x78e2, 0x78e2, 0x78e2, 0x78e2, 0x70e2, 30.29 + 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 30.30 + 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 30.31 + 0x70e2, 0x70e2, 0x70e2, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x4008, 30.32 + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 30.33 + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 30.34 + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 30.35 + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 30.36 + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 30.37 + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 30.38 + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 30.39 + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 30.40 + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 30.41 + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 30.42 + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 30.43 + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 30.44 + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 30.45 + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 30.46 + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 30.47 + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 30.48 + }; 30.49 + 30.50 // node_new_cclass 30.51 public CClassNode() {} 30.52 30.53 @@ -330,13 +364,13 @@ 30.54 if (not) { 30.55 for (int c = 0; c < BitSet.SINGLE_BYTE_SIZE; c++) { 30.56 // if (!ASCIIEncoding.INSTANCE.isCodeCType(c, ctype)) bs.set(c); 30.57 - if ((AsciiTables.AsciiCtypeTable[c] & (1 << ctype)) == 0) bs.set(c); 30.58 + if ((AsciiCtypeTable[c] & (1 << ctype)) == 0) bs.set(c); 30.59 } 30.60 addAllMultiByteRange(); 30.61 } else { 30.62 for (int c = 0; c < BitSet.SINGLE_BYTE_SIZE; c++) { 30.63 // if (ASCIIEncoding.INSTANCE.isCodeCType(c, ctype)) bs.set(c); 30.64 - if ((AsciiTables.AsciiCtypeTable[c] & (1 << ctype)) != 0) bs.set(c); 30.65 + if ((AsciiCtypeTable[c] & (1 << ctype)) != 0) bs.set(c); 30.66 } 30.67 } 30.68 return;
31.1 --- a/src/jdk/nashorn/internal/runtime/regexp/joni/ast/CTypeNode.java Thu May 16 13:44:25 2013 +0200 31.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 31.3 @@ -1,50 +0,0 @@ 31.4 -/* 31.5 - * Permission is hereby granted, free of charge, to any person obtaining a copy of 31.6 - * this software and associated documentation files (the "Software"), to deal in 31.7 - * the Software without restriction, including without limitation the rights to 31.8 - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 31.9 - * of the Software, and to permit persons to whom the Software is furnished to do 31.10 - * so, subject to the following conditions: 31.11 - * 31.12 - * The above copyright notice and this permission notice shall be included in all 31.13 - * copies or substantial portions of the Software. 31.14 - * 31.15 - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 31.16 - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 31.17 - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 31.18 - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 31.19 - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 31.20 - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 31.21 - * SOFTWARE. 31.22 - */ 31.23 -package jdk.nashorn.internal.runtime.regexp.joni.ast; 31.24 - 31.25 -public final class CTypeNode extends Node { 31.26 - public int ctype; 31.27 - public boolean not; 31.28 - 31.29 - public CTypeNode(int type, boolean not) { 31.30 - this.ctype= type; 31.31 - this.not = not; 31.32 - } 31.33 - 31.34 - @Override 31.35 - public int getType() { 31.36 - return CTYPE; 31.37 - } 31.38 - 31.39 - @Override 31.40 - public String getName() { 31.41 - return "Character Type"; 31.42 - } 31.43 - 31.44 - @Override 31.45 - public String toString(int level) { 31.46 - StringBuilder value = new StringBuilder(); 31.47 - value.append("\n ctype: " + ctype); 31.48 - value.append("\n not: " + not); 31.49 - 31.50 - return value.toString(); 31.51 - } 31.52 - 31.53 -}
32.1 --- a/src/jdk/nashorn/internal/runtime/regexp/joni/ast/CallNode.java Thu May 16 13:44:25 2013 +0200 32.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 32.3 @@ -1,86 +0,0 @@ 32.4 -/* 32.5 - * Permission is hereby granted, free of charge, to any person obtaining a copy of 32.6 - * this software and associated documentation files (the "Software"), to deal in 32.7 - * the Software without restriction, including without limitation the rights to 32.8 - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 32.9 - * of the Software, and to permit persons to whom the Software is furnished to do 32.10 - * so, subject to the following conditions: 32.11 - * 32.12 - * The above copyright notice and this permission notice shall be included in all 32.13 - * copies or substantial portions of the Software. 32.14 - * 32.15 - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 32.16 - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 32.17 - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 32.18 - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 32.19 - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 32.20 - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 32.21 - * SOFTWARE. 32.22 - */ 32.23 -package jdk.nashorn.internal.runtime.regexp.joni.ast; 32.24 - 32.25 -import java.util.Set; 32.26 - 32.27 -import jdk.nashorn.internal.runtime.regexp.joni.UnsetAddrList; 32.28 -import jdk.nashorn.internal.runtime.regexp.joni.WarnCallback; 32.29 - 32.30 -public final class CallNode extends StateNode { 32.31 - public char[] name; 32.32 - public int nameP; 32.33 - public int nameEnd; 32.34 - 32.35 - public int groupNum; 32.36 - public Node target; // is it an EncloseNode always ? 32.37 - public UnsetAddrList unsetAddrList; 32.38 - 32.39 - public CallNode(char[] name, int nameP, int nameEnd, int gnum) { 32.40 - this.name = name; 32.41 - this.nameP = nameP; 32.42 - this.nameEnd = nameEnd; 32.43 - this.groupNum = gnum; /* call by number if gnum != 0 */ 32.44 - } 32.45 - 32.46 - @Override 32.47 - public int getType() { 32.48 - return CALL; 32.49 - } 32.50 - 32.51 - @Override 32.52 - protected void setChild(Node newChild) { 32.53 - target = newChild; 32.54 - } 32.55 - 32.56 - @Override 32.57 - protected Node getChild() { 32.58 - return target; 32.59 - } 32.60 - 32.61 - public void setTarget(Node tgt) { 32.62 - target = tgt; 32.63 - tgt.parent = this; 32.64 - } 32.65 - 32.66 - @Override 32.67 - public String getName() { 32.68 - return "Call"; 32.69 - } 32.70 - 32.71 - @Override 32.72 - public void verifyTree(Set<Node> set, WarnCallback warnings) { 32.73 - if (target == null || target.parent == this) 32.74 - warnings.warn(this.getAddressName() + " doesn't point to a target or the target has been stolen"); 32.75 - // do not recurse here 32.76 - } 32.77 - 32.78 - @Override 32.79 - public String toString(int level) { 32.80 - StringBuilder value = new StringBuilder(super.toString(level)); 32.81 - value.append("\n name: " + new String(name, nameP, nameEnd - nameP)); 32.82 - value.append("\n groupNum: " + groupNum); 32.83 - value.append("\n target: " + pad(target.getAddressName(), level + 1)); 32.84 - value.append("\n unsetAddrList: " + pad(unsetAddrList, level + 1)); 32.85 - 32.86 - return value.toString(); 32.87 - } 32.88 - 32.89 -}
33.1 --- a/src/jdk/nashorn/internal/runtime/regexp/joni/ast/EncloseNode.java Thu May 16 13:44:25 2013 +0200 33.2 +++ b/src/jdk/nashorn/internal/runtime/regexp/joni/ast/EncloseNode.java Thu May 16 19:52:39 2013 +0200 33.3 @@ -25,7 +25,7 @@ 33.4 33.5 public final class EncloseNode extends StateNode implements EncloseType { 33.6 33.7 - public int type; // enclose type 33.8 + public final int type; // enclose type 33.9 public int regNum; 33.10 public int option; 33.11 public Node target; /* EncloseNode : ENCLOSE_MEMORY */ 33.12 @@ -42,10 +42,8 @@ 33.13 } 33.14 33.15 // node_new_enclose_memory 33.16 - public EncloseNode(int option, boolean isNamed) { 33.17 + public EncloseNode() { 33.18 this(MEMORY); 33.19 - if (isNamed) setNamedGroup(); 33.20 - if (Config.USE_SUBEXP_CALL) this.option = option; 33.21 } 33.22 33.23 // node_new_option 33.24 @@ -104,46 +102,14 @@ 33.25 return types.toString(); 33.26 } 33.27 33.28 - public void setEncloseStatus(int flag) { 33.29 - state |= flag; 33.30 - } 33.31 - 33.32 - public void clearEncloseStatus(int flag) { 33.33 - state &= ~flag; 33.34 - } 33.35 - 33.36 - public void clearMemory() { 33.37 - type &= ~MEMORY; 33.38 - } 33.39 - 33.40 - public void setMemory() { 33.41 - type |= MEMORY; 33.42 - } 33.43 - 33.44 public boolean isMemory() { 33.45 return (type & MEMORY) != 0; 33.46 } 33.47 33.48 - public void clearOption() { 33.49 - type &= ~OPTION; 33.50 - } 33.51 - 33.52 - public void setOption() { 33.53 - type |= OPTION; 33.54 - } 33.55 - 33.56 public boolean isOption() { 33.57 return (type & OPTION) != 0; 33.58 } 33.59 33.60 - public void clearStopBacktrack() { 33.61 - type &= ~STOP_BACKTRACK; 33.62 - } 33.63 - 33.64 - public void setStopBacktrack() { 33.65 - type |= STOP_BACKTRACK; 33.66 - } 33.67 - 33.68 public boolean isStopBacktrack() { 33.69 return (type & STOP_BACKTRACK) != 0; 33.70 }
34.1 --- a/src/jdk/nashorn/internal/runtime/regexp/joni/ast/QuantifierNode.java Thu May 16 13:44:25 2013 +0200 34.2 +++ b/src/jdk/nashorn/internal/runtime/regexp/joni/ast/QuantifierNode.java Thu May 16 19:52:39 2013 +0200 34.3 @@ -21,9 +21,10 @@ 34.4 34.5 import jdk.nashorn.internal.runtime.regexp.joni.Config; 34.6 import jdk.nashorn.internal.runtime.regexp.joni.ScanEnvironment; 34.7 -import jdk.nashorn.internal.runtime.regexp.joni.constants.Reduce; 34.8 import jdk.nashorn.internal.runtime.regexp.joni.constants.TargetInfo; 34.9 34.10 +import static jdk.nashorn.internal.runtime.regexp.joni.ast.QuantifierNode.ReduceType.*; 34.11 + 34.12 public final class QuantifierNode extends StateNode { 34.13 34.14 public Node target; 34.15 @@ -37,8 +38,33 @@ 34.16 public Node nextHeadExact; 34.17 public boolean isRefered; /* include called node. don't eliminate even if {0} */ 34.18 34.19 - // USE_COMBINATION_EXPLOSION_CHECK 34.20 - public int combExpCheckNum; /* 1,2,3...: check, 0: no check */ 34.21 + enum ReduceType { 34.22 + ASIS, /* as is */ 34.23 + DEL, /* delete parent */ 34.24 + A, /* to '*' */ 34.25 + AQ, /* to '*?' */ 34.26 + QQ, /* to '??' */ 34.27 + P_QQ, /* to '+)??' */ 34.28 + PQ_Q, /* to '+?)?' */ 34.29 + } 34.30 + 34.31 + private final static ReduceType[][] REDUCE_TABLE = { 34.32 + {DEL, A, A, QQ, AQ, ASIS}, /* '?' */ 34.33 + {DEL, DEL, DEL, P_QQ, P_QQ, DEL}, /* '*' */ 34.34 + {A, A, DEL, ASIS, P_QQ, DEL}, /* '+' */ 34.35 + {DEL, AQ, AQ, DEL, AQ, AQ}, /* '??' */ 34.36 + {DEL, DEL, DEL, DEL, DEL, DEL}, /* '*?' */ 34.37 + {ASIS, PQ_Q, DEL, AQ, AQ, DEL} /* '+?' */ 34.38 + }; 34.39 + 34.40 + private final static String PopularQStr[] = new String[] { 34.41 + "?", "*", "+", "??", "*?", "+?" 34.42 + }; 34.43 + 34.44 + private final static String ReduceQStr[]= new String[] { 34.45 + "", "", "*", "*?", "??", "+ and ??", "+? and ?" 34.46 + }; 34.47 + 34.48 34.49 public QuantifierNode(int lower, int upper, boolean byNumber) { 34.50 this.lower = lower; 34.51 @@ -92,7 +118,6 @@ 34.52 value.append("\n headExact: " + pad(headExact, level + 1)); 34.53 value.append("\n nextHeadExact: " + pad(nextHeadExact, level + 1)); 34.54 value.append("\n isRefered: " + isRefered); 34.55 - value.append("\n combExpCheckNum: " + combExpCheckNum); 34.56 34.57 return value.toString(); 34.58 } 34.59 @@ -134,7 +159,6 @@ 34.60 headExact = other.headExact; 34.61 nextHeadExact = other.nextHeadExact; 34.62 isRefered = other.isRefered; 34.63 - combExpCheckNum = other.combExpCheckNum; 34.64 } 34.65 34.66 public void reduceNestedQuantifier(QuantifierNode other) { 34.67 @@ -143,7 +167,7 @@ 34.68 34.69 if (pnum < 0 || cnum < 0) return; 34.70 34.71 - switch(Reduce.REDUCE_TABLE[cnum][pnum]) { 34.72 + switch(REDUCE_TABLE[cnum][pnum]) { 34.73 case DEL: 34.74 // no need to set the parent here... 34.75 // swap ? 34.76 @@ -226,7 +250,7 @@ 34.77 34.78 if (Config.USE_WARNING_REDUNDANT_NESTED_REPEAT_OPERATOR) { 34.79 if (!isByNumber() && !qnt.isByNumber() && env.syntax.warnReduntantNestedRepeat()) { 34.80 - switch(Reduce.REDUCE_TABLE[targetQNum][nestQNum]) { 34.81 + switch(REDUCE_TABLE[targetQNum][nestQNum]) { 34.82 case ASIS: 34.83 break; 34.84 34.85 @@ -237,9 +261,9 @@ 34.86 34.87 default: 34.88 env.reg.getWarnings().warn(new String(chars, p, end) + 34.89 - " nested repeat operator " + Reduce.PopularQStr[targetQNum] + 34.90 - " and " + Reduce.PopularQStr[nestQNum] + " was replaced with '" + 34.91 - Reduce.ReduceQStr[Reduce.REDUCE_TABLE[targetQNum][nestQNum].ordinal()] + "'"); 34.92 + " nested repeat operator " + PopularQStr[targetQNum] + 34.93 + " and " + PopularQStr[nestQNum] + " was replaced with '" + 34.94 + ReduceQStr[REDUCE_TABLE[targetQNum][nestQNum].ordinal()] + "'"); 34.95 } 34.96 } 34.97 } // USE_WARNING_REDUNDANT_NESTED_REPEAT_OPERATOR
35.1 --- a/src/jdk/nashorn/internal/runtime/regexp/joni/ast/StateNode.java Thu May 16 13:44:25 2013 +0200 35.2 +++ b/src/jdk/nashorn/internal/runtime/regexp/joni/ast/StateNode.java Thu May 16 19:52:39 2013 +0200 35.3 @@ -40,7 +40,6 @@ 35.4 if (isRecursion()) states.append("RECURSION "); 35.5 if (isCalled()) states.append("CALLED "); 35.6 if (isAddrFixed()) states.append("ADDR_FIXED "); 35.7 - if (isNamedGroup()) states.append("NAMED_GROUP "); 35.8 if (isNameRef()) states.append("NAME_REF "); 35.9 if (isInRepeat()) states.append("IN_REPEAT "); 35.10 if (isNestLevel()) states.append("NEST_LEVEL "); 35.11 @@ -57,10 +56,6 @@ 35.12 state |= NST_MIN_FIXED; 35.13 } 35.14 35.15 - public void clearMinFixed() { 35.16 - state &= ~NST_MIN_FIXED; 35.17 - } 35.18 - 35.19 public boolean isMaxFixed() { 35.20 return (state & NST_MAX_FIXED) != 0; 35.21 } 35.22 @@ -69,10 +64,6 @@ 35.23 state |= NST_MAX_FIXED; 35.24 } 35.25 35.26 - public void clearMaxFixed() { 35.27 - state &= ~NST_MAX_FIXED; 35.28 - } 35.29 - 35.30 public boolean isCLenFixed() { 35.31 return (state & NST_CLEN_FIXED) != 0; 35.32 } 35.33 @@ -81,10 +72,6 @@ 35.34 state |= NST_CLEN_FIXED; 35.35 } 35.36 35.37 - public void clearCLenFixed() { 35.38 - state &= ~NST_CLEN_FIXED; 35.39 - } 35.40 - 35.41 public boolean isMark1() { 35.42 return (state & NST_MARK1) != 0; 35.43 } 35.44 @@ -93,10 +80,6 @@ 35.45 state |= NST_MARK1; 35.46 } 35.47 35.48 - public void clearMark1() { 35.49 - state &= ~NST_MARK1; 35.50 - } 35.51 - 35.52 public boolean isMark2() { 35.53 return (state & NST_MARK2) != 0; 35.54 } 35.55 @@ -117,10 +100,6 @@ 35.56 state |= NST_MEM_BACKREFED; 35.57 } 35.58 35.59 - public void clearMemBackrefed() { 35.60 - state &= ~NST_MEM_BACKREFED; 35.61 - } 35.62 - 35.63 public boolean isStopBtSimpleRepeat() { 35.64 return (state & NST_STOP_BT_SIMPLE_REPEAT) != 0; 35.65 } 35.66 @@ -129,10 +108,6 @@ 35.67 state |= NST_STOP_BT_SIMPLE_REPEAT; 35.68 } 35.69 35.70 - public void clearStopBtSimpleRepeat() { 35.71 - state &= ~NST_STOP_BT_SIMPLE_REPEAT; 35.72 - } 35.73 - 35.74 public boolean isRecursion() { 35.75 return (state & NST_RECURSION) != 0; 35.76 } 35.77 @@ -141,10 +116,6 @@ 35.78 state |= NST_RECURSION; 35.79 } 35.80 35.81 - public void clearRecursion() { 35.82 - state &= ~NST_RECURSION; 35.83 - } 35.84 - 35.85 public boolean isCalled() { 35.86 return (state & NST_CALLED) != 0; 35.87 } 35.88 @@ -153,10 +124,6 @@ 35.89 state |= NST_CALLED; 35.90 } 35.91 35.92 - public void clearCAlled() { 35.93 - state &= ~NST_CALLED; 35.94 - } 35.95 - 35.96 public boolean isAddrFixed() { 35.97 return (state & NST_ADDR_FIXED) != 0; 35.98 } 35.99 @@ -165,22 +132,6 @@ 35.100 state |= NST_ADDR_FIXED; 35.101 } 35.102 35.103 - public void clearAddrFixed() { 35.104 - state &= ~NST_ADDR_FIXED; 35.105 - } 35.106 - 35.107 - public boolean isNamedGroup() { 35.108 - return (state & NST_NAMED_GROUP) != 0; 35.109 - } 35.110 - 35.111 - public void setNamedGroup() { 35.112 - state |= NST_NAMED_GROUP; 35.113 - } 35.114 - 35.115 - public void clearNamedGroup() { 35.116 - state &= ~NST_NAMED_GROUP; 35.117 - } 35.118 - 35.119 public boolean isNameRef() { 35.120 return (state & NST_NAME_REF) != 0; 35.121 } 35.122 @@ -189,10 +140,6 @@ 35.123 state |= NST_NAME_REF; 35.124 } 35.125 35.126 - public void clearNameRef() { 35.127 - state &= ~NST_NAME_REF; 35.128 - } 35.129 - 35.130 public boolean isInRepeat() { 35.131 return (state & NST_IN_REPEAT) != 0; 35.132 } 35.133 @@ -201,10 +148,6 @@ 35.134 state |= NST_IN_REPEAT; 35.135 } 35.136 35.137 - public void clearInRepeat() { 35.138 - state &= ~NST_IN_REPEAT; 35.139 - } 35.140 - 35.141 public boolean isNestLevel() { 35.142 return (state & NST_NEST_LEVEL) != 0; 35.143 } 35.144 @@ -213,10 +156,6 @@ 35.145 state |= NST_NEST_LEVEL; 35.146 } 35.147 35.148 - public void clearNestLevel() { 35.149 - state &= ~NST_NEST_LEVEL; 35.150 - } 35.151 - 35.152 public boolean isByNumber() { 35.153 return (state & NST_BY_NUMBER) != 0; 35.154 } 35.155 @@ -225,8 +164,4 @@ 35.156 state |= NST_BY_NUMBER; 35.157 } 35.158 35.159 - public void clearByNumber() { 35.160 - state &= ~NST_BY_NUMBER; 35.161 - } 35.162 - 35.163 }
36.1 --- a/src/jdk/nashorn/internal/runtime/regexp/joni/bench/AbstractBench.java Thu May 16 13:44:25 2013 +0200 36.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 36.3 @@ -1,49 +0,0 @@ 36.4 -package jdk.nashorn.internal.runtime.regexp.joni.bench; 36.5 - 36.6 -import jdk.nashorn.internal.runtime.regexp.joni.Option; 36.7 -import jdk.nashorn.internal.runtime.regexp.joni.Regex; 36.8 -import jdk.nashorn.internal.runtime.regexp.joni.Syntax; 36.9 - 36.10 -public abstract class AbstractBench { 36.11 - protected void bench(String _reg, String _str, int warmup, int times) throws Exception { 36.12 - char[] reg = _reg.toCharArray(); 36.13 - char[] str = _str.toCharArray(); 36.14 - 36.15 - Regex p = new Regex(reg,0,reg.length,Option.DEFAULT,Syntax.DEFAULT); 36.16 - 36.17 - System.err.println("::: /" + _reg + "/ =~ \"" + _str + "\", " + warmup + " * " + times + " times"); 36.18 - 36.19 - for(int j=0;j<warmup;j++) { 36.20 - long before = System.currentTimeMillis(); 36.21 - for(int i = 0; i < times; i++) { 36.22 - p.matcher(str, 0, str.length).search(0, str.length, Option.NONE); 36.23 - } 36.24 - long time = System.currentTimeMillis() - before; 36.25 - System.err.println(": " + time + "ms"); 36.26 - } 36.27 - } 36.28 - 36.29 - protected void benchBestOf(String _reg, String _str, int warmup, int times) throws Exception { 36.30 - char[] reg = _reg.toCharArray(); 36.31 - char[] str = _str.toCharArray(); 36.32 - 36.33 - Regex p = new Regex(reg,0,reg.length,Option.DEFAULT,Syntax.DEFAULT); 36.34 - 36.35 - System.err.println("::: /" + _reg + "/ =~ \"" + _str + "\", " + warmup + " * " + times + " times"); 36.36 - 36.37 - long best = Long.MAX_VALUE; 36.38 - 36.39 - for(int j=0;j<warmup;j++) { 36.40 - long before = System.currentTimeMillis(); 36.41 - for(int i = 0; i < times; i++) { 36.42 - p.matcher(str, 0, str.length).search(0, str.length, Option.NONE); 36.43 - } 36.44 - long time = System.currentTimeMillis() - before; 36.45 - if(time < best) { 36.46 - best = time; 36.47 - } 36.48 - System.err.print("."); 36.49 - } 36.50 - System.err.println(": " + best + "ms"); 36.51 - } 36.52 -}
37.1 --- a/src/jdk/nashorn/internal/runtime/regexp/joni/bench/BenchGreedyBacktrack.java Thu May 16 13:44:25 2013 +0200 37.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 37.3 @@ -1,7 +0,0 @@ 37.4 -package jdk.nashorn.internal.runtime.regexp.joni.bench; 37.5 - 37.6 -public class BenchGreedyBacktrack extends AbstractBench { 37.7 - public static void main(String[] args) throws Exception { 37.8 - new BenchGreedyBacktrack().bench(".*_p","_petstore_session_id=1b341ffe23b5298676d535fcabd3d0d7; path=/",10,1000000); 37.9 - } 37.10 -}
38.1 --- a/src/jdk/nashorn/internal/runtime/regexp/joni/bench/BenchRailsRegs.java Thu May 16 13:44:25 2013 +0200 38.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 38.3 @@ -1,31 +0,0 @@ 38.4 -package jdk.nashorn.internal.runtime.regexp.joni.bench; 38.5 - 38.6 -public class BenchRailsRegs extends AbstractBench { 38.7 - public static void main(String[] args) throws Exception { 38.8 - final String[][] regexps = {{"a.*?[b-z]{2,4}aaaaaa","afdgdsgderaabxxaaaaaaaaaaaaaaaaaaaaaaaa"}, 38.9 - {"://","/shop/viewCategory.shtml?category=DOGS"}, 38.10 - {"^\\w+\\://[^/]+(/.*|$)$","/shop/viewCategory.shtml?category=DOGS"}, 38.11 - {"\\A/?\\Z","/shop/viewCategory.shtml"}, 38.12 - {"\\A/shop/signonForm\\.shtml/?\\Z","/shop/viewCategory.shtml"}, 38.13 - {"\\A/shop/newAccountForm\\.shtml/?\\Z","/shop/viewCategory.shtml"}, 38.14 - {"\\A/shop/newAccount\\.shtml/?\\Z","/shop/viewCategory.shtml"}, 38.15 - {"\\A/shop/viewCart\\.shtml/?\\Z","/shop/viewCategory.shtml"}, 38.16 - {"\\A/shop/index\\.shtml/?\\Z","/shop/viewCategory.shtml"}, 38.17 - {"\\A/shop/viewCategory\\.shtml/?\\Z","/shop/viewCategory.shtml"}, 38.18 - {"\\A(?:::)?([A-Z]\\w*(?:::[A-Z]\\w*)*)\\z","CategoriesController"}, 38.19 - {"\\Ainsert","SELECT * FROM sessions WHERE (session_id = '1b341ffe23b5298676d535fcabd3d0d7') LIMIT 1"}, 38.20 - {"\\A\\(?\\s*(select|show)","SELECT * FROM sessions WHERE (session_id = '1b341ffe23b5298676d535fcabd3d0d7') LIMIT 1"}, 38.21 - {".*?\n","1b341ffe23b5298676d535fcabd3d0d7"}, 38.22 - {"^find_(all_by|by)_([_a-zA-Z]\\w*)$","find_by_string_id"}, 38.23 - {"\\.rjs$","categories/show.rhtml"}, 38.24 - {"^[-a-z]+://","petstore.css"}, 38.25 - {"^get$",""}, 38.26 - {"^post$",""}, 38.27 - {"^[^:]+","www.example.com"}, 38.28 - {"(=|\\?|_before_type_cast)$", "updated_on"}, 38.29 - {"^(.*?)=(.*?);","_petstore_session_id=1b341ffe23b5298676d535fcabd3d0d7; path=/"}}; 38.30 - for(String[] reg : regexps) { 38.31 - new BenchRailsRegs().benchBestOf(reg[0],reg[1],10,1000000); 38.32 - } 38.33 - } 38.34 -}
39.1 --- a/src/jdk/nashorn/internal/runtime/regexp/joni/bench/BenchSeveralRegexps.java Thu May 16 13:44:25 2013 +0200 39.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 39.3 @@ -1,17 +0,0 @@ 39.4 -package jdk.nashorn.internal.runtime.regexp.joni.bench; 39.5 - 39.6 -public class BenchSeveralRegexps extends AbstractBench { 39.7 - public static void main(String[] args) throws Exception { 39.8 - int BASE = 1000000; 39.9 - 39.10 - new BenchSeveralRegexps().benchBestOf("a"," a",10,4*BASE); 39.11 - 39.12 - new BenchSeveralRegexps().benchBestOf(".*?=","_petstore_session_id=1b341ffe23b5298676d535fcabd3d0d7; path=/",10,BASE); 39.13 - 39.14 - new BenchSeveralRegexps().benchBestOf("^(.*?)=(.*?);","_petstore_session_id=1b341ffe23b5298676d535fcabd3d0d7; path=/",10,BASE); 39.15 - 39.16 - new BenchSeveralRegexps().benchBestOf(".*_p","_petstore_session_id=1b341ffe23b5298676d535fcabd3d0d7; path=/",10,4*BASE); 39.17 - 39.18 - new BenchSeveralRegexps().benchBestOf(".*=","_petstore_session_id=1b341ffe23b5298676d535fcabd3d0d7; path=/",10,4*BASE); 39.19 - } 39.20 -}
40.1 --- a/src/jdk/nashorn/internal/runtime/regexp/joni/constants/OPCode.java Thu May 16 13:44:25 2013 +0200 40.2 +++ b/src/jdk/nashorn/internal/runtime/regexp/joni/constants/OPCode.java Thu May 16 19:52:39 2013 +0200 40.3 @@ -19,8 +19,6 @@ 40.4 */ 40.5 package jdk.nashorn.internal.runtime.regexp.joni.constants; 40.6 40.7 -import jdk.nashorn.internal.runtime.regexp.joni.Config; 40.8 - 40.9 public interface OPCode { 40.10 final int FINISH = 0; /* matching process terminator (no more alternative) */ 40.11 final int END = 1; /* pattern code terminator (success end) */ 40.12 @@ -151,237 +149,4 @@ 40.13 final int EXACT1_IC_SB = 105; /* single byte, N = 1, ignore case */ 40.14 final int EXACTN_IC_SB = 106; /* single byte, ignore case */ 40.15 40.16 - 40.17 - public final String OpCodeNames[] = Config.DEBUG_COMPILE ? new String[] { 40.18 - "finish", /*OP_FINISH*/ 40.19 - "end", /*OP_END*/ 40.20 - "exact1", /*OP_EXACT1*/ 40.21 - "exact2", /*OP_EXACT2*/ 40.22 - "exact3", /*OP_EXACT3*/ 40.23 - "exact4", /*OP_EXACT4*/ 40.24 - "exact5", /*OP_EXACT5*/ 40.25 - "exactn", /*OP_EXACTN*/ 40.26 - "exactmb2-n1", /*OP_EXACTMB2N1*/ 40.27 - "exactmb2-n2", /*OP_EXACTMB2N2*/ 40.28 - "exactmb2-n3", /*OP_EXACTMB2N3*/ 40.29 - "exactmb2-n", /*OP_EXACTMB2N*/ 40.30 - "exactmb3n", /*OP_EXACTMB3N*/ 40.31 - "exactmbn", /*OP_EXACTMBN*/ 40.32 - "exact1-ic", /*OP_EXACT1_IC*/ 40.33 - "exactn-ic", /*OP_EXACTN_IC*/ 40.34 - "cclass", /*OP_CCLASS*/ 40.35 - "cclass-mb", /*OP_CCLASS_MB*/ 40.36 - "cclass-mix", /*OP_CCLASS_MIX*/ 40.37 - "cclass-not", /*OP_CCLASS_NOT*/ 40.38 - "cclass-mb-not", /*OP_CCLASS_MB_NOT*/ 40.39 - "cclass-mix-not", /*OP_CCLASS_MIX_NOT*/ 40.40 - "cclass-node", /*OP_CCLASS_NODE*/ 40.41 - "anychar", /*OP_ANYCHAR*/ 40.42 - "anychar-ml", /*OP_ANYCHAR_ML*/ 40.43 - "anychar*", /*OP_ANYCHAR_STAR*/ 40.44 - "anychar-ml*", /*OP_ANYCHAR_ML_STAR*/ 40.45 - "anychar*-peek-next", /*OP_ANYCHAR_STAR_PEEK_NEXT*/ 40.46 - "anychar-ml*-peek-next", /*OP_ANYCHAR_ML_STAR_PEEK_NEXT*/ 40.47 - "word", /*OP_WORD*/ 40.48 - "not-word", /*OP_NOT_WORD*/ 40.49 - "word-bound", /*OP_WORD_BOUND*/ 40.50 - "not-word-bound", /*OP_NOT_WORD_BOUND*/ 40.51 - "word-begin", /*OP_WORD_BEGIN*/ 40.52 - "word-end", /*OP_WORD_END*/ 40.53 - "begin-buf", /*OP_BEGIN_BUF*/ 40.54 - "end-buf", /*OP_END_BUF*/ 40.55 - "begin-line", /*OP_BEGIN_LINE*/ 40.56 - "end-line", /*OP_END_LINE*/ 40.57 - "semi-end-buf", /*OP_SEMI_END_BUF*/ 40.58 - "begin-position", /*OP_BEGIN_POSITION*/ 40.59 - "backref1", /*OP_BACKREF1*/ 40.60 - "backref2", /*OP_BACKREF2*/ 40.61 - "backrefn", /*OP_BACKREFN*/ 40.62 - "backrefn-ic", /*OP_BACKREFN_IC*/ 40.63 - "backref_multi", /*OP_BACKREF_MULTI*/ 40.64 - "backref_multi-ic", /*OP_BACKREF_MULTI_IC*/ 40.65 - "backref_at_level", /*OP_BACKREF_AT_LEVEL*/ 40.66 - "mem-start", /*OP_MEMORY_START*/ 40.67 - "mem-start-push", /*OP_MEMORY_START_PUSH*/ 40.68 - "mem-end-push", /*OP_MEMORY_END_PUSH*/ 40.69 - "mem-end-push-rec", /*OP_MEMORY_END_PUSH_REC*/ 40.70 - "mem-end", /*OP_MEMORY_END*/ 40.71 - "mem-end-rec", /*OP_MEMORY_END_REC*/ 40.72 - "fail", /*OP_FAIL*/ 40.73 - "jump", /*OP_JUMP*/ 40.74 - "push", /*OP_PUSH*/ 40.75 - "pop", /*OP_POP*/ 40.76 - "push-or-jump-e1", /*OP_PUSH_OR_JUMP_EXACT1*/ 40.77 - "push-if-peek-next", /*OP_PUSH_IF_PEEK_NEXT*/ 40.78 - "repeat", /*OP_REPEAT*/ 40.79 - "repeat-ng", /*OP_REPEAT_NG*/ 40.80 - "repeat-inc", /*OP_REPEAT_INC*/ 40.81 - "repeat-inc-ng", /*OP_REPEAT_INC_NG*/ 40.82 - "repeat-inc-sg", /*OP_REPEAT_INC_SG*/ 40.83 - "repeat-inc-ng-sg", /*OP_REPEAT_INC_NG_SG*/ 40.84 - "null-check-start", /*OP_NULL_CHECK_START*/ 40.85 - "null-check-end", /*OP_NULL_CHECK_END*/ 40.86 - "null-check-end-memst", /*OP_NULL_CHECK_END_MEMST*/ 40.87 - "null-check-end-memst-push", /*OP_NULL_CHECK_END_MEMST_PUSH*/ 40.88 - "push-pos", /*OP_PUSH_POS*/ 40.89 - "pop-pos", /*OP_POP_POS*/ 40.90 - "push-pos-not", /*OP_PUSH_POS_NOT*/ 40.91 - "fail-pos", /*OP_FAIL_POS*/ 40.92 - "push-stop-bt", /*OP_PUSH_STOP_BT*/ 40.93 - "pop-stop-bt", /*OP_POP_STOP_BT*/ 40.94 - "look-behind", /*OP_LOOK_BEHIND*/ 40.95 - "push-look-behind-not", /*OP_PUSH_LOOK_BEHIND_NOT*/ 40.96 - "fail-look-behind-not", /*OP_FAIL_LOOK_BEHIND_NOT*/ 40.97 - "call", /*OP_CALL*/ 40.98 - "return", /*OP_RETURN*/ 40.99 - "state-check-push", /*OP_STATE_CHECK_PUSH*/ 40.100 - "state-check-push-or-jump", /*OP_STATE_CHECK_PUSH_OR_JUMP*/ 40.101 - "state-check", /*OP_STATE_CHECK*/ 40.102 - "state-check-anychar*", /*OP_STATE_CHECK_ANYCHAR_STAR*/ 40.103 - "state-check-anychar-ml*", /*OP_STATE_CHECK_ANYCHAR_ML_STAR*/ 40.104 - "set-option-push", /*OP_SET_OPTION_PUSH*/ 40.105 - "set-option", /*OP_SET_OPTION*/ 40.106 - 40.107 - // single byte versions 40.108 - "anychar-sb", /*OP_ANYCHAR*/ 40.109 - "anychar-ml-sb", /*OP_ANYCHAR_ML*/ 40.110 - "anychar*-sb", /*OP_ANYCHAR_STAR*/ 40.111 - "anychar-ml*-sb", /*OP_ANYCHAR_ML_STAR*/ 40.112 - "anychar*-peek-next-sb", /*OP_ANYCHAR_STAR_PEEK_NEXT*/ 40.113 - "anychar-ml*-peek-next-sb", /*OP_ANYCHAR_ML_STAR_PEEK_NEXT*/ 40.114 - "state-check-anychar*-sb", /*OP_STATE_CHECK_ANYCHAR_STAR*/ 40.115 - "state-check-anychar-ml*-sb", /*OP_STATE_CHECK_ANYCHAR_ML_STAR*/ 40.116 - 40.117 - "cclass-sb", /*OP_CCLASS*/ 40.118 - "cclass-not-sb", /*OP_CCLASS_NOT*/ 40.119 - 40.120 - "word-sb", /*OP_WORD*/ 40.121 - "not-word-sb", /*OP_NOT_WORD*/ 40.122 - "word-bound-sb", /*OP_WORD_BOUND*/ 40.123 - "not-word-bound-sb", /*OP_NOT_WORD_BOUND*/ 40.124 - "word-begin-sb", /*OP_WORD_BEGIN*/ 40.125 - "word-end-sb", /*OP_WORD_END*/ 40.126 - 40.127 - "look-behind-sb", /*OP_LOOK_BEHIND*/ 40.128 - 40.129 - "exact1-ic-sb", /*OP_EXACT1_IC*/ 40.130 - "exactn-ic-sb", /*OP_EXACTN_IC*/ 40.131 - 40.132 - } : null; 40.133 - 40.134 - public final int OpCodeArgTypes[] = Config.DEBUG_COMPILE ? new int[] { 40.135 - Arguments.NON, /*OP_FINISH*/ 40.136 - Arguments.NON, /*OP_END*/ 40.137 - Arguments.SPECIAL, /*OP_EXACT1*/ 40.138 - Arguments.SPECIAL, /*OP_EXACT2*/ 40.139 - Arguments.SPECIAL, /*OP_EXACT3*/ 40.140 - Arguments.SPECIAL, /*OP_EXACT4*/ 40.141 - Arguments.SPECIAL, /*OP_EXACT5*/ 40.142 - Arguments.SPECIAL, /*OP_EXACTN*/ 40.143 - Arguments.SPECIAL, /*OP_EXACTMB2N1*/ 40.144 - Arguments.SPECIAL, /*OP_EXACTMB2N2*/ 40.145 - Arguments.SPECIAL, /*OP_EXACTMB2N3*/ 40.146 - Arguments.SPECIAL, /*OP_EXACTMB2N*/ 40.147 - Arguments.SPECIAL, /*OP_EXACTMB3N*/ 40.148 - Arguments.SPECIAL, /*OP_EXACTMBN*/ 40.149 - Arguments.SPECIAL, /*OP_EXACT1_IC*/ 40.150 - Arguments.SPECIAL, /*OP_EXACTN_IC*/ 40.151 - Arguments.SPECIAL, /*OP_CCLASS*/ 40.152 - Arguments.SPECIAL, /*OP_CCLASS_MB*/ 40.153 - Arguments.SPECIAL, /*OP_CCLASS_MIX*/ 40.154 - Arguments.SPECIAL, /*OP_CCLASS_NOT*/ 40.155 - Arguments.SPECIAL, /*OP_CCLASS_MB_NOT*/ 40.156 - Arguments.SPECIAL, /*OP_CCLASS_MIX_NOT*/ 40.157 - Arguments.SPECIAL, /*OP_CCLASS_NODE*/ 40.158 - Arguments.NON, /*OP_ANYCHAR*/ 40.159 - Arguments.NON, /*OP_ANYCHAR_ML*/ 40.160 - Arguments.NON, /*OP_ANYCHAR_STAR*/ 40.161 - Arguments.NON, /*OP_ANYCHAR_ML_STAR*/ 40.162 - Arguments.SPECIAL, /*OP_ANYCHAR_STAR_PEEK_NEXT*/ 40.163 - Arguments.SPECIAL, /*OP_ANYCHAR_ML_STAR_PEEK_NEXT*/ 40.164 - Arguments.NON, /*OP_WORD*/ 40.165 - Arguments.NON, /*OP_NOT_WORD*/ 40.166 - Arguments.NON, /*OP_WORD_BOUND*/ 40.167 - Arguments.NON, /*OP_NOT_WORD_BOUND*/ 40.168 - Arguments.NON, /*OP_WORD_BEGIN*/ 40.169 - Arguments.NON, /*OP_WORD_END*/ 40.170 - Arguments.NON, /*OP_BEGIN_BUF*/ 40.171 - Arguments.NON, /*OP_END_BUF*/ 40.172 - Arguments.NON, /*OP_BEGIN_LINE*/ 40.173 - Arguments.NON, /*OP_END_LINE*/ 40.174 - Arguments.NON, /*OP_SEMI_END_BUF*/ 40.175 - Arguments.NON, /*OP_BEGIN_POSITION*/ 40.176 - Arguments.NON, /*OP_BACKREF1*/ 40.177 - Arguments.NON, /*OP_BACKREF2*/ 40.178 - Arguments.MEMNUM, /*OP_BACKREFN*/ 40.179 - Arguments.SPECIAL, /*OP_BACKREFN_IC*/ 40.180 - Arguments.SPECIAL, /*OP_BACKREF_MULTI*/ 40.181 - Arguments.SPECIAL, /*OP_BACKREF_MULTI_IC*/ 40.182 - Arguments.SPECIAL, /*OP_BACKREF_AT_LEVEL*/ 40.183 - Arguments.MEMNUM, /*OP_MEMORY_START*/ 40.184 - Arguments.MEMNUM, /*OP_MEMORY_START_PUSH*/ 40.185 - Arguments.MEMNUM, /*OP_MEMORY_END_PUSH*/ 40.186 - Arguments.MEMNUM, /*OP_MEMORY_END_PUSH_REC*/ 40.187 - Arguments.MEMNUM, /*OP_MEMORY_END*/ 40.188 - Arguments.MEMNUM, /*OP_MEMORY_END_REC*/ 40.189 - Arguments.NON, /*OP_FAIL*/ 40.190 - Arguments.RELADDR, /*OP_JUMP*/ 40.191 - Arguments.RELADDR, /*OP_PUSH*/ 40.192 - Arguments.NON, /*OP_POP*/ 40.193 - Arguments.SPECIAL, /*OP_PUSH_OR_JUMP_EXACT1*/ 40.194 - Arguments.SPECIAL, /*OP_PUSH_IF_PEEK_NEXT*/ 40.195 - Arguments.SPECIAL, /*OP_REPEAT*/ 40.196 - Arguments.SPECIAL, /*OP_REPEAT_NG*/ 40.197 - Arguments.MEMNUM, /*OP_REPEAT_INC*/ 40.198 - Arguments.MEMNUM, /*OP_REPEAT_INC_NG*/ 40.199 - Arguments.MEMNUM, /*OP_REPEAT_INC_SG*/ 40.200 - Arguments.MEMNUM, /*OP_REPEAT_INC_NG_SG*/ 40.201 - Arguments.MEMNUM, /*OP_NULL_CHECK_START*/ 40.202 - Arguments.MEMNUM, /*OP_NULL_CHECK_END*/ 40.203 - Arguments.MEMNUM, /*OP_NULL_CHECK_END_MEMST*/ 40.204 - Arguments.MEMNUM, /*OP_NULL_CHECK_END_MEMST_PUSH*/ 40.205 - Arguments.NON, /*OP_PUSH_POS*/ 40.206 - Arguments.NON, /*OP_POP_POS*/ 40.207 - Arguments.RELADDR, /*OP_PUSH_POS_NOT*/ 40.208 - Arguments.NON, /*OP_FAIL_POS*/ 40.209 - Arguments.NON, /*OP_PUSH_STOP_BT*/ 40.210 - Arguments.NON, /*OP_POP_STOP_BT*/ 40.211 - Arguments.SPECIAL, /*OP_LOOK_BEHIND*/ 40.212 - Arguments.SPECIAL, /*OP_PUSH_LOOK_BEHIND_NOT*/ 40.213 - Arguments.NON, /*OP_FAIL_LOOK_BEHIND_NOT*/ 40.214 - Arguments.ABSADDR, /*OP_CALL*/ 40.215 - Arguments.NON, /*OP_RETURN*/ 40.216 - Arguments.SPECIAL, /*OP_STATE_CHECK_PUSH*/ 40.217 - Arguments.SPECIAL, /*OP_STATE_CHECK_PUSH_OR_JUMP*/ 40.218 - Arguments.STATE_CHECK, /*OP_STATE_CHECK*/ 40.219 - Arguments.STATE_CHECK, /*OP_STATE_CHECK_ANYCHAR_STAR*/ 40.220 - Arguments.STATE_CHECK, /*OP_STATE_CHECK_ANYCHAR_ML_STAR*/ 40.221 - Arguments.OPTION, /*OP_SET_OPTION_PUSH*/ 40.222 - Arguments.OPTION, /*OP_SET_OPTION*/ 40.223 - 40.224 - // single byte versions 40.225 - Arguments.NON, /*OP_ANYCHAR*/ 40.226 - Arguments.NON, /*OP_ANYCHAR_ML*/ 40.227 - Arguments.NON, /*OP_ANYCHAR_STAR*/ 40.228 - Arguments.NON, /*OP_ANYCHAR_ML_STAR*/ 40.229 - Arguments.SPECIAL, /*OP_ANYCHAR_STAR_PEEK_NEXT*/ 40.230 - Arguments.SPECIAL, /*OP_ANYCHAR_ML_STAR_PEEK_NEXT*/ 40.231 - Arguments.STATE_CHECK, /*OP_STATE_CHECK_ANYCHAR_STAR*/ 40.232 - Arguments.STATE_CHECK, /*OP_STATE_CHECK_ANYCHAR_ML_STAR*/ 40.233 - 40.234 - Arguments.SPECIAL, /*OP_CCLASS*/ 40.235 - Arguments.SPECIAL, /*OP_CCLASS_NOT*/ 40.236 - 40.237 - Arguments.NON, /*OP_WORD*/ 40.238 - Arguments.NON, /*OP_NOT_WORD*/ 40.239 - Arguments.NON, /*OP_WORD_BOUND*/ 40.240 - Arguments.NON, /*OP_NOT_WORD_BOUND*/ 40.241 - Arguments.NON, /*OP_WORD_BEGIN*/ 40.242 - Arguments.NON, /*OP_WORD_END*/ 40.243 - 40.244 - Arguments.SPECIAL, /*OP_LOOK_BEHIND*/ 40.245 - 40.246 - Arguments.SPECIAL, /*OP_EXACT1_IC*/ 40.247 - Arguments.SPECIAL, /*OP_EXACTN_IC*/ 40.248 - } : null; 40.249 }
41.1 --- a/src/jdk/nashorn/internal/runtime/regexp/joni/constants/Reduce.java Thu May 16 13:44:25 2013 +0200 41.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 41.3 @@ -1,61 +0,0 @@ 41.4 -/* 41.5 - * Permission is hereby granted, free of charge, to any person obtaining a copy of 41.6 - * this software and associated documentation files (the "Software"), to deal in 41.7 - * the Software without restriction, including without limitation the rights to 41.8 - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 41.9 - * of the Software, and to permit persons to whom the Software is furnished to do 41.10 - * so, subject to the following conditions: 41.11 - * 41.12 - * The above copyright notice and this permission notice shall be included in all 41.13 - * copies or substantial portions of the Software. 41.14 - * 41.15 - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 41.16 - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 41.17 - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 41.18 - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 41.19 - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 41.20 - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 41.21 - * SOFTWARE. 41.22 - */ 41.23 -package jdk.nashorn.internal.runtime.regexp.joni.constants; 41.24 - 41.25 -import static jdk.nashorn.internal.runtime.regexp.joni.constants.Reduce.ReduceType.A; 41.26 -import static jdk.nashorn.internal.runtime.regexp.joni.constants.Reduce.ReduceType.AQ; 41.27 -import static jdk.nashorn.internal.runtime.regexp.joni.constants.Reduce.ReduceType.ASIS; 41.28 -import static jdk.nashorn.internal.runtime.regexp.joni.constants.Reduce.ReduceType.DEL; 41.29 -import static jdk.nashorn.internal.runtime.regexp.joni.constants.Reduce.ReduceType.PQ_Q; 41.30 -import static jdk.nashorn.internal.runtime.regexp.joni.constants.Reduce.ReduceType.P_QQ; 41.31 -import static jdk.nashorn.internal.runtime.regexp.joni.constants.Reduce.ReduceType.QQ; 41.32 - 41.33 -public interface Reduce { 41.34 - 41.35 - enum ReduceType { 41.36 - ASIS, /* as is */ 41.37 - DEL, /* delete parent */ 41.38 - A, /* to '*' */ 41.39 - AQ, /* to '*?' */ 41.40 - QQ, /* to '??' */ 41.41 - P_QQ, /* to '+)??' */ 41.42 - PQ_Q, /* to '+?)?' */ 41.43 - } 41.44 - 41.45 - final ReduceType[][]REDUCE_TABLE = { 41.46 - {DEL, A, A, QQ, AQ, ASIS}, /* '?' */ 41.47 - {DEL, DEL, DEL, P_QQ, P_QQ, DEL}, /* '*' */ 41.48 - {A, A, DEL, ASIS, P_QQ, DEL}, /* '+' */ 41.49 - {DEL, AQ, AQ, DEL, AQ, AQ}, /* '??' */ 41.50 - {DEL, DEL, DEL, DEL, DEL, DEL}, /* '*?' */ 41.51 - {ASIS, PQ_Q, DEL, AQ, AQ, DEL} /* '+?' */ 41.52 - }; 41.53 - 41.54 - 41.55 - final String PopularQStr[] = new String[] { 41.56 - "?", "*", "+", "??", "*?", "+?" 41.57 - }; 41.58 - 41.59 - String ReduceQStr[]= new String[] { 41.60 - "", "", "*", "*?", "??", "+ and ??", "+? and ?" 41.61 - }; 41.62 - 41.63 -} 41.64 -
42.1 --- a/src/jdk/nashorn/internal/runtime/regexp/joni/encoding/AsciiTables.java Thu May 16 13:44:25 2013 +0200 42.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 42.3 @@ -1,157 +0,0 @@ 42.4 -/* 42.5 - * Permission is hereby granted, free of charge, to any person obtaining a copy of 42.6 - * this software and associated documentation files (the "Software"), to deal in 42.7 - * the Software without restriction, including without limitation the rights to 42.8 - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 42.9 - * of the Software, and to permit persons to whom the Software is furnished to do 42.10 - * so, subject to the following conditions: 42.11 - * 42.12 - * The above copyright notice and this permission notice shall be included in all 42.13 - * copies or substantial portions of the Software. 42.14 - * 42.15 - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 42.16 - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 42.17 - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 42.18 - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 42.19 - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 42.20 - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 42.21 - * SOFTWARE. 42.22 - */ 42.23 -package jdk.nashorn.internal.runtime.regexp.joni.encoding; 42.24 - 42.25 -public class AsciiTables { 42.26 - 42.27 - public static final short AsciiCtypeTable[] = { 42.28 - 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 42.29 - 0x4008, 0x420c, 0x4209, 0x4208, 0x4208, 0x4208, 0x4008, 0x4008, 42.30 - 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 42.31 - 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 42.32 - 0x4284, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 42.33 - 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 42.34 - 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, 42.35 - 0x78b0, 0x78b0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 42.36 - 0x41a0, 0x7ca2, 0x7ca2, 0x7ca2, 0x7ca2, 0x7ca2, 0x7ca2, 0x74a2, 42.37 - 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 42.38 - 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 42.39 - 0x74a2, 0x74a2, 0x74a2, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x51a0, 42.40 - 0x41a0, 0x78e2, 0x78e2, 0x78e2, 0x78e2, 0x78e2, 0x78e2, 0x70e2, 42.41 - 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 42.42 - 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 42.43 - 0x70e2, 0x70e2, 0x70e2, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x4008, 42.44 - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 42.45 - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 42.46 - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 42.47 - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 42.48 - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 42.49 - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 42.50 - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 42.51 - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 42.52 - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 42.53 - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 42.54 - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 42.55 - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 42.56 - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 42.57 - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 42.58 - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 42.59 - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 42.60 - }; 42.61 - 42.62 - public static final byte ToLowerCaseTable[] = { 42.63 - (byte)'\000', (byte)'\001', (byte)'\002', (byte)'\003', (byte)'\004', (byte)'\005', (byte)'\006', (byte)'\007', 42.64 - (byte)'\010', (byte)'\011', (byte)'\012', (byte)'\013', (byte)'\014', (byte)'\015', (byte)'\016', (byte)'\017', 42.65 - (byte)'\020', (byte)'\021', (byte)'\022', (byte)'\023', (byte)'\024', (byte)'\025', (byte)'\026', (byte)'\027', 42.66 - (byte)'\030', (byte)'\031', (byte)'\032', (byte)'\033', (byte)'\034', (byte)'\035', (byte)'\036', (byte)'\037', 42.67 - (byte)'\040', (byte)'\041', (byte)'\042', (byte)'\043', (byte)'\044', (byte)'\045', (byte)'\046', (byte)'\047', 42.68 - (byte)'\050', (byte)'\051', (byte)'\052', (byte)'\053', (byte)'\054', (byte)'\055', (byte)'\056', (byte)'\057', 42.69 - (byte)'\060', (byte)'\061', (byte)'\062', (byte)'\063', (byte)'\064', (byte)'\065', (byte)'\066', (byte)'\067', 42.70 - (byte)'\070', (byte)'\071', (byte)'\072', (byte)'\073', (byte)'\074', (byte)'\075', (byte)'\076', (byte)'\077', 42.71 - (byte)'\100', (byte)'\141', (byte)'\142', (byte)'\143', (byte)'\144', (byte)'\145', (byte)'\146', (byte)'\147', 42.72 - (byte)'\150', (byte)'\151', (byte)'\152', (byte)'\153', (byte)'\154', (byte)'\155', (byte)'\156', (byte)'\157', 42.73 - (byte)'\160', (byte)'\161', (byte)'\162', (byte)'\163', (byte)'\164', (byte)'\165', (byte)'\166', (byte)'\167', 42.74 - (byte)'\170', (byte)'\171', (byte)'\172', (byte)'\133', (byte)'\134', (byte)'\135', (byte)'\136', (byte)'\137', 42.75 - (byte)'\140', (byte)'\141', (byte)'\142', (byte)'\143', (byte)'\144', (byte)'\145', (byte)'\146', (byte)'\147', 42.76 - (byte)'\150', (byte)'\151', (byte)'\152', (byte)'\153', (byte)'\154', (byte)'\155', (byte)'\156', (byte)'\157', 42.77 - (byte)'\160', (byte)'\161', (byte)'\162', (byte)'\163', (byte)'\164', (byte)'\165', (byte)'\166', (byte)'\167', 42.78 - (byte)'\170', (byte)'\171', (byte)'\172', (byte)'\173', (byte)'\174', (byte)'\175', (byte)'\176', (byte)'\177', 42.79 - (byte)'\200', (byte)'\201', (byte)'\202', (byte)'\203', (byte)'\204', (byte)'\205', (byte)'\206', (byte)'\207', 42.80 - (byte)'\210', (byte)'\211', (byte)'\212', (byte)'\213', (byte)'\214', (byte)'\215', (byte)'\216', (byte)'\217', 42.81 - (byte)'\220', (byte)'\221', (byte)'\222', (byte)'\223', (byte)'\224', (byte)'\225', (byte)'\226', (byte)'\227', 42.82 - (byte)'\230', (byte)'\231', (byte)'\232', (byte)'\233', (byte)'\234', (byte)'\235', (byte)'\236', (byte)'\237', 42.83 - (byte)'\240', (byte)'\241', (byte)'\242', (byte)'\243', (byte)'\244', (byte)'\245', (byte)'\246', (byte)'\247', 42.84 - (byte)'\250', (byte)'\251', (byte)'\252', (byte)'\253', (byte)'\254', (byte)'\255', (byte)'\256', (byte)'\257', 42.85 - (byte)'\260', (byte)'\261', (byte)'\262', (byte)'\263', (byte)'\264', (byte)'\265', (byte)'\266', (byte)'\267', 42.86 - (byte)'\270', (byte)'\271', (byte)'\272', (byte)'\273', (byte)'\274', (byte)'\275', (byte)'\276', (byte)'\277', 42.87 - (byte)'\300', (byte)'\301', (byte)'\302', (byte)'\303', (byte)'\304', (byte)'\305', (byte)'\306', (byte)'\307', 42.88 - (byte)'\310', (byte)'\311', (byte)'\312', (byte)'\313', (byte)'\314', (byte)'\315', (byte)'\316', (byte)'\317', 42.89 - (byte)'\320', (byte)'\321', (byte)'\322', (byte)'\323', (byte)'\324', (byte)'\325', (byte)'\326', (byte)'\327', 42.90 - (byte)'\330', (byte)'\331', (byte)'\332', (byte)'\333', (byte)'\334', (byte)'\335', (byte)'\336', (byte)'\337', 42.91 - (byte)'\340', (byte)'\341', (byte)'\342', (byte)'\343', (byte)'\344', (byte)'\345', (byte)'\346', (byte)'\347', 42.92 - (byte)'\350', (byte)'\351', (byte)'\352', (byte)'\353', (byte)'\354', (byte)'\355', (byte)'\356', (byte)'\357', 42.93 - (byte)'\360', (byte)'\361', (byte)'\362', (byte)'\363', (byte)'\364', (byte)'\365', (byte)'\366', (byte)'\367', 42.94 - (byte)'\370', (byte)'\371', (byte)'\372', (byte)'\373', (byte)'\374', (byte)'\375', (byte)'\376', (byte)'\377', 42.95 - }; 42.96 - 42.97 - public static final byte ToUpperCaseTable[] = { 42.98 - (byte)'\000', (byte)'\001', (byte)'\002', (byte)'\003', (byte)'\004', (byte)'\005', (byte)'\006', (byte)'\007', 42.99 - (byte)'\010', (byte)'\011', (byte)'\012', (byte)'\013', (byte)'\014', (byte)'\015', (byte)'\016', (byte)'\017', 42.100 - (byte)'\020', (byte)'\021', (byte)'\022', (byte)'\023', (byte)'\024', (byte)'\025', (byte)'\026', (byte)'\027', 42.101 - (byte)'\030', (byte)'\031', (byte)'\032', (byte)'\033', (byte)'\034', (byte)'\035', (byte)'\036', (byte)'\037', 42.102 - (byte)'\040', (byte)'\041', (byte)'\042', (byte)'\043', (byte)'\044', (byte)'\045', (byte)'\046', (byte)'\047', 42.103 - (byte)'\050', (byte)'\051', (byte)'\052', (byte)'\053', (byte)'\054', (byte)'\055', (byte)'\056', (byte)'\057', 42.104 - (byte)'\060', (byte)'\061', (byte)'\062', (byte)'\063', (byte)'\064', (byte)'\065', (byte)'\066', (byte)'\067', 42.105 - (byte)'\070', (byte)'\071', (byte)'\072', (byte)'\073', (byte)'\074', (byte)'\075', (byte)'\076', (byte)'\077', 42.106 - (byte)'\100', (byte)'\101', (byte)'\102', (byte)'\103', (byte)'\104', (byte)'\105', (byte)'\106', (byte)'\107', 42.107 - (byte)'\110', (byte)'\111', (byte)'\112', (byte)'\113', (byte)'\114', (byte)'\115', (byte)'\116', (byte)'\117', 42.108 - (byte)'\120', (byte)'\121', (byte)'\122', (byte)'\123', (byte)'\124', (byte)'\125', (byte)'\126', (byte)'\127', 42.109 - (byte)'\130', (byte)'\131', (byte)'\132', (byte)'\133', (byte)'\134', (byte)'\135', (byte)'\136', (byte)'\137', 42.110 - (byte)'\140', (byte)'\101', (byte)'\102', (byte)'\103', (byte)'\104', (byte)'\105', (byte)'\106', (byte)'\107', 42.111 - (byte)'\110', (byte)'\111', (byte)'\112', (byte)'\113', (byte)'\114', (byte)'\115', (byte)'\116', (byte)'\117', 42.112 - (byte)'\120', (byte)'\121', (byte)'\122', (byte)'\123', (byte)'\124', (byte)'\125', (byte)'\126', (byte)'\127', 42.113 - (byte)'\130', (byte)'\131', (byte)'\132', (byte)'\173', (byte)'\174', (byte)'\175', (byte)'\176', (byte)'\177', 42.114 - (byte)'\200', (byte)'\201', (byte)'\202', (byte)'\203', (byte)'\204', (byte)'\205', (byte)'\206', (byte)'\207', 42.115 - (byte)'\210', (byte)'\211', (byte)'\212', (byte)'\213', (byte)'\214', (byte)'\215', (byte)'\216', (byte)'\217', 42.116 - (byte)'\220', (byte)'\221', (byte)'\222', (byte)'\223', (byte)'\224', (byte)'\225', (byte)'\226', (byte)'\227', 42.117 - (byte)'\230', (byte)'\231', (byte)'\232', (byte)'\233', (byte)'\234', (byte)'\235', (byte)'\236', (byte)'\237', 42.118 - (byte)'\240', (byte)'\241', (byte)'\242', (byte)'\243', (byte)'\244', (byte)'\245', (byte)'\246', (byte)'\247', 42.119 - (byte)'\250', (byte)'\251', (byte)'\252', (byte)'\253', (byte)'\254', (byte)'\255', (byte)'\256', (byte)'\257', 42.120 - (byte)'\260', (byte)'\261', (byte)'\262', (byte)'\263', (byte)'\264', (byte)'\265', (byte)'\266', (byte)'\267', 42.121 - (byte)'\270', (byte)'\271', (byte)'\272', (byte)'\273', (byte)'\274', (byte)'\275', (byte)'\276', (byte)'\277', 42.122 - (byte)'\300', (byte)'\301', (byte)'\302', (byte)'\303', (byte)'\304', (byte)'\305', (byte)'\306', (byte)'\307', 42.123 - (byte)'\310', (byte)'\311', (byte)'\312', (byte)'\313', (byte)'\314', (byte)'\315', (byte)'\316', (byte)'\317', 42.124 - (byte)'\320', (byte)'\321', (byte)'\322', (byte)'\323', (byte)'\324', (byte)'\325', (byte)'\326', (byte)'\327', 42.125 - (byte)'\330', (byte)'\331', (byte)'\332', (byte)'\333', (byte)'\334', (byte)'\335', (byte)'\336', (byte)'\337', 42.126 - (byte)'\340', (byte)'\341', (byte)'\342', (byte)'\343', (byte)'\344', (byte)'\345', (byte)'\346', (byte)'\347', 42.127 - (byte)'\350', (byte)'\351', (byte)'\352', (byte)'\353', (byte)'\354', (byte)'\355', (byte)'\356', (byte)'\357', 42.128 - (byte)'\360', (byte)'\361', (byte)'\362', (byte)'\363', (byte)'\364', (byte)'\365', (byte)'\366', (byte)'\367', 42.129 - (byte)'\370', (byte)'\371', (byte)'\372', (byte)'\373', (byte)'\374', (byte)'\375', (byte)'\376', (byte)'\377', 42.130 - }; 42.131 - 42.132 - public static final int LowerMap[][] = { 42.133 - {0x41, 0x61}, 42.134 - {0x42, 0x62}, 42.135 - {0x43, 0x63}, 42.136 - {0x44, 0x64}, 42.137 - {0x45, 0x65}, 42.138 - {0x46, 0x66}, 42.139 - {0x47, 0x67}, 42.140 - {0x48, 0x68}, 42.141 - {0x49, 0x69}, 42.142 - {0x4a, 0x6a}, 42.143 - {0x4b, 0x6b}, 42.144 - {0x4c, 0x6c}, 42.145 - {0x4d, 0x6d}, 42.146 - {0x4e, 0x6e}, 42.147 - {0x4f, 0x6f}, 42.148 - {0x50, 0x70}, 42.149 - {0x51, 0x71}, 42.150 - {0x52, 0x72}, 42.151 - {0x53, 0x73}, 42.152 - {0x54, 0x74}, 42.153 - {0x55, 0x75}, 42.154 - {0x56, 0x76}, 42.155 - {0x57, 0x77}, 42.156 - {0x58, 0x78}, 42.157 - {0x59, 0x79}, 42.158 - {0x5a, 0x7a} 42.159 - }; 42.160 -}
43.1 --- a/src/jdk/nashorn/internal/runtime/regexp/joni/encoding/ObjPtr.java Thu May 16 13:44:25 2013 +0200 43.2 +++ b/src/jdk/nashorn/internal/runtime/regexp/joni/encoding/ObjPtr.java Thu May 16 19:52:39 2013 +0200 43.3 @@ -30,6 +30,5 @@ 43.4 43.5 public T p; 43.6 43.7 - static final ObjPtr<Void> NULL = new ObjPtr<Void>(); 43.8 } 43.9
44.1 --- a/src/jdk/nashorn/internal/runtime/regexp/joni/encoding/PosixBracket.java Thu May 16 13:44:25 2013 +0200 44.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 44.3 @@ -1,77 +0,0 @@ 44.4 -/* 44.5 - * Permission is hereby granted, free of charge, to any person obtaining a copy of 44.6 - * this software and associated documentation files (the "Software"), to deal in 44.7 - * the Software without restriction, including without limitation the rights to 44.8 - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 44.9 - * of the Software, and to permit persons to whom the Software is furnished to do 44.10 - * so, subject to the following conditions: 44.11 - * 44.12 - * The above copyright notice and this permission notice shall be included in all 44.13 - * copies or substantial portions of the Software. 44.14 - * 44.15 - * THE SOFTWARE IS PROVIDED "AS IS".toCharArray(), WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 44.16 - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 44.17 - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 44.18 - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 44.19 - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 44.20 - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 44.21 - * SOFTWARE. 44.22 - */ 44.23 -package jdk.nashorn.internal.runtime.regexp.joni.encoding; 44.24 - 44.25 -import jdk.nashorn.internal.runtime.regexp.joni.exception.ErrorMessages; 44.26 -import jdk.nashorn.internal.runtime.regexp.joni.exception.JOniException; 44.27 - 44.28 -import java.util.HashMap; 44.29 - 44.30 -public class PosixBracket { 44.31 - 44.32 - public static final char[][] PBSNamesLower = { 44.33 - "alnum".toCharArray(), 44.34 - "alpha".toCharArray(), 44.35 - "blank".toCharArray(), 44.36 - "cntrl".toCharArray(), 44.37 - "digit".toCharArray(), 44.38 - "graph".toCharArray(), 44.39 - "lower".toCharArray(), 44.40 - "print".toCharArray(), 44.41 - "punct".toCharArray(), 44.42 - "space".toCharArray(), 44.43 - "upper".toCharArray(), 44.44 - "xdigit".toCharArray(), 44.45 - "ascii".toCharArray(), 44.46 - "word".toCharArray() 44.47 - }; 44.48 - 44.49 - public static final int PBSValues[] = { 44.50 - CharacterType.ALNUM, 44.51 - CharacterType.ALPHA, 44.52 - CharacterType.BLANK, 44.53 - CharacterType.CNTRL, 44.54 - CharacterType.DIGIT, 44.55 - CharacterType.GRAPH, 44.56 - CharacterType.LOWER, 44.57 - CharacterType.PRINT, 44.58 - CharacterType.PUNCT, 44.59 - CharacterType.SPACE, 44.60 - CharacterType.UPPER, 44.61 - CharacterType.XDIGIT, 44.62 - CharacterType.ASCII, 44.63 - CharacterType.WORD, 44.64 - }; 44.65 - 44.66 - public static int propertyNameToCType(String name) { 44.67 - name = name.toLowerCase(); 44.68 - if (!PBSTableUpper.containsKey(name)) { 44.69 - throw new JOniException(ErrorMessages.ERR_INVALID_CHAR_PROPERTY_NAME.replaceAll("%n", name)); 44.70 - } 44.71 - return PBSTableUpper.get(name); 44.72 - } 44.73 - 44.74 - private static final HashMap<String,Integer> PBSTableUpper = new HashMap<String,Integer>(); 44.75 - 44.76 - static { 44.77 - for (int i=0; i<PBSValues.length; i++) PBSTableUpper.put(new String(PBSNamesLower[i]), PBSValues[i]); 44.78 - } 44.79 - 44.80 -}
45.1 --- a/src/jdk/nashorn/internal/runtime/regexp/joni/encoding/Ptr.java Thu May 16 13:44:25 2013 +0200 45.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 45.3 @@ -1,35 +0,0 @@ 45.4 -/* 45.5 - * Permission is hereby granted, free of charge, to any person obtaining a copy of 45.6 - * this software and associated documentation files (the "Software"), to deal in 45.7 - * the Software without restriction, including without limitation the rights to 45.8 - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 45.9 - * of the Software, and to permit persons to whom the Software is furnished to do 45.10 - * so, subject to the following conditions: 45.11 - * 45.12 - * The above copyright notice and this permission notice shall be included in all 45.13 - * copies or substantial portions of the Software. 45.14 - * 45.15 - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 45.16 - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 45.17 - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 45.18 - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 45.19 - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 45.20 - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 45.21 - * SOFTWARE. 45.22 - */ 45.23 -package jdk.nashorn.internal.runtime.regexp.joni.encoding; 45.24 - 45.25 -public final class Ptr { 45.26 - public Ptr() { 45.27 - this(0); 45.28 - } 45.29 - 45.30 - public Ptr(int p) { 45.31 - this.p = p; 45.32 - } 45.33 - 45.34 - public int p; 45.35 - 45.36 - public static final Ptr NULL = new Ptr(0); 45.37 -} 45.38 -
46.1 --- a/src/jdk/nashorn/internal/runtime/regexp/joni/exception/ErrorMessages.java Thu May 16 13:44:25 2013 +0200 46.2 +++ b/src/jdk/nashorn/internal/runtime/regexp/joni/exception/ErrorMessages.java Thu May 16 19:52:39 2013 +0200 46.3 @@ -22,28 +22,16 @@ 46.4 import jdk.nashorn.internal.runtime.regexp.joni.Config; 46.5 46.6 public interface ErrorMessages { 46.7 - final String MISMATCH = "mismatch"; 46.8 - final String NO_SUPPORT_CONFIG = "no support in this configuration"; 46.9 46.10 /* from jcodings */ 46.11 - final String ERR_INVALID_CHAR_PROPERTY_NAME = "invalid character property name <%n>"; 46.12 final String ERR_INVALID_CODE_POINT_VALUE = "invalid code point value"; 46.13 final String ERR_TOO_BIG_WIDE_CHAR_VALUE = "too big wide-char value"; 46.14 final String ERR_TOO_LONG_WIDE_CHAR_VALUE = "too long wide-char value"; 46.15 46.16 /* internal error */ 46.17 - final String ERR_MEMORY = "fail to memory allocation"; 46.18 - final String ERR_MATCH_STACK_LIMIT_OVER = "match-stack limit over"; 46.19 - final String ERR_TYPE_BUG = "undefined type (bug)"; 46.20 final String ERR_PARSER_BUG = "internal parser error (bug)"; 46.21 - final String ERR_STACK_BUG = "stack error (bug)"; 46.22 final String ERR_UNDEFINED_BYTECODE = "undefined bytecode (bug)"; 46.23 final String ERR_UNEXPECTED_BYTECODE = "unexpected bytecode (bug)"; 46.24 - final String ERR_DEFAULT_ENCODING_IS_NOT_SETTED = "default multibyte-encoding is not setted"; 46.25 - final String ERR_SPECIFIED_ENCODING_CANT_CONVERT_TO_WIDE_CHAR = "can't convert to wide-char on specified multibyte-encoding"; 46.26 - 46.27 - /* general error */ 46.28 - final String ERR_INVALID_ARGUMENT = "invalid argument"; 46.29 46.30 /* syntax error */ 46.31 final String ERR_END_PATTERN_AT_LEFT_BRACE = "end pattern at left brace"; 46.32 @@ -56,11 +44,9 @@ 46.33 final String ERR_META_CODE_SYNTAX = "invalid meta-code syntax"; 46.34 final String ERR_CONTROL_CODE_SYNTAX = "invalid control-code syntax"; 46.35 final String ERR_CHAR_CLASS_VALUE_AT_END_OF_RANGE = "char-class value at end of range"; 46.36 - final String ERR_CHAR_CLASS_VALUE_AT_START_OF_RANGE = "char-class value at start of range"; 46.37 final String ERR_UNMATCHED_RANGE_SPECIFIER_IN_CHAR_CLASS = "unmatched range specifier in char-class"; 46.38 final String ERR_TARGET_OF_REPEAT_OPERATOR_NOT_SPECIFIED = "target of repeat operator is not specified"; 46.39 final String ERR_TARGET_OF_REPEAT_OPERATOR_INVALID = "target of repeat operator is invalid"; 46.40 - final String ERR_NESTED_REPEAT_OPERATOR = "nested repeat operator"; 46.41 final String ERR_UNMATCHED_CLOSE_PARENTHESIS = "unmatched close parenthesis"; 46.42 final String ERR_END_PATTERN_WITH_UNMATCHED_PARENTHESIS = "end pattern with unmatched parenthesis"; 46.43 final String ERR_END_PATTERN_IN_GROUP = "end pattern in group"; 46.44 @@ -74,25 +60,14 @@ 46.45 final String ERR_TOO_BIG_NUMBER_FOR_REPEAT_RANGE = "too big number for repeat range"; 46.46 final String ERR_UPPER_SMALLER_THAN_LOWER_IN_REPEAT_RANGE = "upper is smaller than lower in repeat range"; 46.47 final String ERR_EMPTY_RANGE_IN_CHAR_CLASS = "empty range in char class"; 46.48 - final String ERR_MISMATCH_CODE_LENGTH_IN_CLASS_RANGE = "mismatch multibyte code length in char-class range"; 46.49 final String ERR_TOO_MANY_MULTI_BYTE_RANGES = "too many multibyte code ranges are specified"; 46.50 final String ERR_TOO_SHORT_MULTI_BYTE_STRING = "too short multibyte code string"; 46.51 - final String ERR_TOO_BIG_BACKREF_NUMBER = "too big backref number"; 46.52 - final String ERR_INVALID_BACKREF = Config.USE_NAMED_GROUP ? "invalid backref number/name" : "invalid backref number"; 46.53 + final String ERR_INVALID_BACKREF = "invalid backref number"; 46.54 final String ERR_NUMBERED_BACKREF_OR_CALL_NOT_ALLOWED = "numbered backref/call is not allowed. (use name)"; 46.55 - final String ERR_INVALID_WIDE_CHAR_VALUE = "invalid wide-char value"; 46.56 final String ERR_EMPTY_GROUP_NAME = "group name is empty"; 46.57 final String ERR_INVALID_GROUP_NAME = "invalid group name <%n>"; 46.58 - final String ERR_INVALID_CHAR_IN_GROUP_NAME = Config.USE_NAMED_GROUP ? "invalid char in group name <%n>" : "invalid char in group number <%n>"; 46.59 - final String ERR_UNDEFINED_NAME_REFERENCE = "undefined name <%n> reference"; 46.60 - final String ERR_UNDEFINED_GROUP_REFERENCE = "undefined group <%n> reference"; 46.61 - final String ERR_MULTIPLEX_DEFINED_NAME = "multiplex defined name <%n>"; 46.62 - final String ERR_MULTIPLEX_DEFINITION_NAME_CALL = "multiplex definition name <%n> call"; 46.63 - final String ERR_NEVER_ENDING_RECURSION = "never ending recursion"; 46.64 + final String ERR_INVALID_CHAR_IN_GROUP_NAME = "invalid char in group number <%n>"; 46.65 final String ERR_GROUP_NUMBER_OVER_FOR_CAPTURE_HISTORY = "group number is too big for capture history"; 46.66 - final String ERR_NOT_SUPPORTED_ENCODING_COMBINATION = "not supported encoding combination"; 46.67 final String ERR_INVALID_COMBINATION_OF_OPTIONS = "invalid combination of options"; 46.68 - final String ERR_OVER_THREAD_PASS_LIMIT_COUNT = "over thread pass limit count"; 46.69 - final String ERR_TOO_BIG_SB_CHAR_VALUE = "too big singlebyte char value"; 46.70 46.71 }
47.1 --- a/src/jdk/nashorn/internal/runtime/regexp/joni/exception/ValueException.java Thu May 16 13:44:25 2013 +0200 47.2 +++ b/src/jdk/nashorn/internal/runtime/regexp/joni/exception/ValueException.java Thu May 16 19:52:39 2013 +0200 47.3 @@ -30,8 +30,4 @@ 47.4 super(message.replaceAll("%n", str)); 47.5 } 47.6 47.7 - public ValueException(String message, byte[]bytes, int p, int end) { 47.8 - this(message, new String(bytes, p, end - p)); 47.9 - } 47.10 - 47.11 }
48.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 48.2 +++ b/test/src/jdk/nashorn/internal/runtime/regexp/JdkRegExpTest.java Thu May 16 19:52:39 2013 +0200 48.3 @@ -0,0 +1,61 @@ 48.4 +/* 48.5 + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. 48.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 48.7 + * 48.8 + * This code is free software; you can redistribute it and/or modify it 48.9 + * under the terms of the GNU General Public License version 2 only, as 48.10 + * published by the Free Software Foundation. Oracle designates this 48.11 + * particular file as subject to the "Classpath" exception as provided 48.12 + * by Oracle in the LICENSE file that accompanied this code. 48.13 + * 48.14 + * This code is distributed in the hope that it will be useful, but WITHOUT 48.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 48.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 48.17 + * version 2 for more details (a copy is included in the LICENSE file that 48.18 + * accompanied this code). 48.19 + * 48.20 + * You should have received a copy of the GNU General Public License version 48.21 + * 2 along with this work; if not, write to the Free Software Foundation, 48.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 48.23 + * 48.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 48.25 + * or visit www.oracle.com if you need additional information or have any 48.26 + * questions. 48.27 + */ 48.28 + 48.29 +package jdk.nashorn.internal.runtime.regexp; 48.30 + 48.31 +import static org.testng.Assert.assertEquals; 48.32 +import static org.testng.Assert.assertNotNull; 48.33 +import static org.testng.Assert.assertTrue; 48.34 + 48.35 +import jdk.nashorn.internal.runtime.ParserException; 48.36 +import org.testng.annotations.Test; 48.37 + 48.38 +/** 48.39 + * Basic tests for the JDK based RegExp implementation. 48.40 + * 48.41 + * @test 48.42 + * @run testng jdk.nashorn.internal.runtime.regexp.JdkRegExpTest 48.43 + */ 48.44 +public class JdkRegExpTest { 48.45 + 48.46 + /** 48.47 + * Compile a regular expression using the JDK implementation 48.48 + */ 48.49 + @Test 48.50 + public void testMatcher() { 48.51 + RegExp regexp = new RegExpFactory().compile("f(o)o", ""); 48.52 + RegExpMatcher matcher = regexp.match("foo"); 48.53 + assertNotNull(matcher); 48.54 + assertTrue(matcher.search(0)); 48.55 + assertEquals(matcher.getInput(), "foo"); 48.56 + assertEquals(matcher.groupCount(), 1); 48.57 + assertEquals(matcher.group(), "foo"); 48.58 + assertEquals(matcher.start(), 0); 48.59 + assertEquals(matcher.end(), 3); 48.60 + assertEquals(matcher.group(1), "o"); 48.61 + assertEquals(matcher.start(1), 1); 48.62 + assertEquals(matcher.end(1), 2); 48.63 + } 48.64 +}
49.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 49.2 +++ b/test/src/jdk/nashorn/internal/runtime/regexp/joni/JoniTest.java Thu May 16 19:52:39 2013 +0200 49.3 @@ -0,0 +1,52 @@ 49.4 +/* 49.5 + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. 49.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 49.7 + * 49.8 + * This code is free software; you can redistribute it and/or modify it 49.9 + * under the terms of the GNU General Public License version 2 only, as 49.10 + * published by the Free Software Foundation. Oracle designates this 49.11 + * particular file as subject to the "Classpath" exception as provided 49.12 + * by Oracle in the LICENSE file that accompanied this code. 49.13 + * 49.14 + * This code is distributed in the hope that it will be useful, but WITHOUT 49.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 49.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 49.17 + * version 2 for more details (a copy is included in the LICENSE file that 49.18 + * accompanied this code). 49.19 + * 49.20 + * You should have received a copy of the GNU General Public License version 49.21 + * 2 along with this work; if not, write to the Free Software Foundation, 49.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 49.23 + * 49.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 49.25 + * or visit www.oracle.com if you need additional information or have any 49.26 + * questions. 49.27 + */ 49.28 + 49.29 +package jdk.nashorn.internal.runtime.regexp.joni; 49.30 + 49.31 +import static org.testng.Assert.assertEquals; 49.32 +import static org.testng.Assert.assertTrue; 49.33 + 49.34 +import org.testng.annotations.Test; 49.35 + 49.36 +/** 49.37 + * Joni coverage tests 49.38 + * 49.39 + * @test 49.40 + * @run testng jdk.nashorn.internal.runtime.regexp.joni.JoniTest 49.41 + */ 49.42 +public class JoniTest { 49.43 + 49.44 + @Test 49.45 + public void testDump() { 49.46 + new Regex("^a{3,}(.*)[z]++\\s\\1x$").dumpTree(); 49.47 + new Regex("^a{3,}(.*)[z]++\\s\\1x$").dumpByteCode(); 49.48 + new Regex("(abc){4,}{2,5}").dumpTree(); 49.49 + new Regex("(abc){4,}{2,5}").dumpByteCode(); 49.50 + new Regex("aaa|aa|bbbb|ccc").dumpTree(); 49.51 + new Regex("aaa|aa|bbbb|ccc").dumpByteCode(); 49.52 + new Regex("(?:ZFVR.(\\d+\\.\\d+))|(?:(?:Sversbk|TenaCnenqvfb|Vprjrnfry).(\\d+\\.\\d+))|(?:Bcren.(\\d+\\.\\d+))|(?:NccyrJroXvg.(\\d+(?:\\.\\d+)?))").dumpTree(); 49.53 + new Regex("(?:ZFVR.(\\d+\\.\\d+))|(?:(?:Sversbk|TenaCnenqvfb|Vprjrnfry).(\\d+\\.\\d+))|(?:Bcren.(\\d+\\.\\d+))|(?:NccyrJroXvg.(\\d+(?:\\.\\d+)?))").dumpByteCode(); 49.54 + } 49.55 +}