diff --git a/src/main/java/de/hsrm/compiler/Klang/visitors/GenASM.java b/src/main/java/de/hsrm/compiler/Klang/visitors/GenASM.java index 7848143..5fe6401 100644 --- a/src/main/java/de/hsrm/compiler/Klang/visitors/GenASM.java +++ b/src/main/java/de/hsrm/compiler/Klang/visitors/GenASM.java @@ -660,17 +660,17 @@ public class GenASM implements Visitor { asm.sub("q", "$8", "%rsp"); } - e.block.welcome(this); - // I need to clear the stack here so that the top most element is the old rbp that - // ret uses to return to the caller but code that gets generated here will never be - // reached since the block node is guaranteed to contain a return node that results - // in a ret command being executed before this code would be reached. - // As a workaround (and a dirty, dirty hack) I indicate to the return node visitor - // how many bytes need to be cleared from the stack. + // ret uses to return to the caller but code that gets generated after visiting the + // function body will never be reached since the block node is guaranteed to + // contain a return node that results in a ret command being executed before this + // code would be reached. As a workaround (and a dirty, dirty hack) I indicate + // to the return node visitor how many bytes need to be cleared from the stack. var wasStackPadded = (registerParameters.size() + e.localVariables.length) % 2 != 0; bytesToClearFromTheStack = 8L * (registerParameters.size() + e.localVariables.length + (wasStackPadded ? 1 : 0)); + e.block.welcome(this); + return null; }