mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-22 16:14:10 -08:00
Prevent inlining of JSBody code in some complex cases
This commit is contained in:
parent
148c07336c
commit
e5c85dd3bd
|
@ -44,7 +44,7 @@ final class JSBodyInlineUtil {
|
||||||
|
|
||||||
ComplexityCounter complexityCounter = new ComplexityCounter();
|
ComplexityCounter complexityCounter = new ComplexityCounter();
|
||||||
expression.visit(complexityCounter);
|
expression.visit(complexityCounter);
|
||||||
if (complexityCounter.getComplexity() > COMPLEXITY_THRESHOLD) {
|
if (complexityCounter.hasUnsupportedConstructs || complexityCounter.getComplexity() > COMPLEXITY_THRESHOLD) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,6 +86,7 @@ final class JSBodyInlineUtil {
|
||||||
|
|
||||||
static class ComplexityCounter implements NodeVisitor {
|
static class ComplexityCounter implements NodeVisitor {
|
||||||
private int complexity;
|
private int complexity;
|
||||||
|
boolean hasUnsupportedConstructs;
|
||||||
|
|
||||||
public int getComplexity() {
|
public int getComplexity() {
|
||||||
return complexity;
|
return complexity;
|
||||||
|
@ -94,6 +95,13 @@ final class JSBodyInlineUtil {
|
||||||
@Override
|
@Override
|
||||||
public boolean visit(AstNode node) {
|
public boolean visit(AstNode node) {
|
||||||
++complexity;
|
++complexity;
|
||||||
|
switch (node.getType()) {
|
||||||
|
case Token.FUNCTION:
|
||||||
|
case Token.OBJECTLIT:
|
||||||
|
case Token.ARRAYLIT:
|
||||||
|
hasUnsupportedConstructs = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user