8169481: StackOverflowError on start when parsing PAC file to autodetect Proxy settings

Reviewed-by: jlaskey, sundar
This commit is contained in:
Hannes Wallnöfer 2017-02-02 18:23:28 +01:00
parent b659f6d8f4
commit 9d1a6b4fa0
3 changed files with 1051 additions and 2 deletions

View File

@ -77,6 +77,7 @@ final class WeighNodes extends NodeOperatorVisitor<LexicalContext> {
static final long CALL_WEIGHT = 10;
static final long CATCH_WEIGHT = 10;
static final long COMPARE_WEIGHT = 6;
static final long CONST_WEIGHT = 2;
static final long CONTINUE_WEIGHT = 1;
static final long IF_WEIGHT = 2;
static final long LITERAL_WEIGHT = 10;
@ -185,7 +186,7 @@ final class WeighNodes extends NodeOperatorVisitor<LexicalContext> {
@Override
public Node leaveIdentNode(final IdentNode identNode) {
weight += ACCESS_WEIGHT + identNode.getName().length() * 2;
weight += ACCESS_WEIGHT;
return identNode;
}
@ -210,6 +211,11 @@ final class WeighNodes extends NodeOperatorVisitor<LexicalContext> {
@SuppressWarnings("rawtypes")
@Override
public boolean enterLiteralNode(final LiteralNode literalNode) {
if (literalNode instanceof LiteralNode.PrimitiveLiteralNode) {
weight += CONST_WEIGHT;
return false;
}
weight += LITERAL_WEIGHT;
if (literalNode instanceof ArrayLiteralNode) {

View File

@ -31,7 +31,7 @@
var str = "";
// large code to force splitting
for (i = 0; i < 1000; ++i)
for (i = 0; i < 2000; ++i)
str +="o = new Object()\n";
str +="g()";

File diff suppressed because it is too large Load Diff