This commit is contained in:
Lana Steuck 2017-02-02 21:56:00 +00:00
commit 68a60ffc92
4 changed files with 1056 additions and 3 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

@ -35,9 +35,13 @@ var File = Java.type("java.io.File");
var FilenameFilter = Java.type("java.io.FilenameFilter");
var SourceHelper = Java.type("jdk.nashorn.test.models.SourceHelper")
var skippedTests = {
"JDK-8169481.js": true // deep AST can cause stack overflow
};
// Filter out non .js files
var files = new File(__DIR__).listFiles(new FilenameFilter() {
accept: function(f, n) { return n.endsWith(".js") }
accept: function(f, n) { return n.endsWith(".js") && !(n in skippedTests) }
});
// load parser API

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