Skip to content

Commit

Permalink
Additional assert to make sure statements don't leave the stack dirty
Browse files Browse the repository at this point in the history
  • Loading branch information
srikanth-sankaran authored and akurtakov committed Mar 19, 2024
1 parent 75c73c9 commit 12eeab5
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,9 @@ public void generateCode(ClassFile classFile) {
if (this.statements != null) {
for (Statement stmt : this.statements) {
stmt.generateCode(this.scope, codeStream);
if (!this.compilationResult.hasErrors() && codeStream.stackDepth != 0) {
throw new AssertionError("Unexpected stack size change after statement"); //$NON-NLS-1$
}
}
}
// if a problem got reported during code gen, then trigger problem method creation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,9 @@ private void internalGenerateCode(ClassScope classScope, ClassFile classFile) {
if (this.statements != null) {
for (Statement statement : this.statements) {
statement.generateCode(this.scope, codeStream);
if (!this.compilationResult.hasErrors() && codeStream.stackDepth != 0) {
throw new AssertionError("Unexpected stack size change after statement"); //$NON-NLS-1$
}
}
}
// if a problem got reported during code gen, then trigger problem method creation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -901,8 +901,6 @@ private void addArgumentToRecipe(BlockScope blockScope, CodeStream codeStream, S
recipe.delete(0, recipe.length());
recipe.append(TypeConstants.STRING_CONCAT_MARKER_1);
args.add(blockScope.getJavaLangString());
// We popped 190 and adding 1 for the invokeDynamic
codeStream.stackDepth -= 189;
}
}
public void buildStringForConcatation(BlockScope blockScope, CodeStream codeStream, int typeID, StringBuilder recipe, List<TypeBinding> argTypes) {
Expand Down

0 comments on commit 12eeab5

Please sign in to comment.