From beef9e09ca513405d81c6ac59b47bd2a728a80a1 Mon Sep 17 00:00:00 2001 From: Alexey Andreev Date: Thu, 31 Oct 2019 14:18:29 +0300 Subject: [PATCH] C: fix bug in exception handling --- .../teavm/backend/c/generate/CodeGenerationVisitor.java | 2 +- .../lowlevel/ExceptionHandlingShadowStackContributor.java | 8 ++------ 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/core/src/main/java/org/teavm/backend/c/generate/CodeGenerationVisitor.java b/core/src/main/java/org/teavm/backend/c/generate/CodeGenerationVisitor.java index 86e63668e..2abbefb24 100644 --- a/core/src/main/java/org/teavm/backend/c/generate/CodeGenerationVisitor.java +++ b/core/src/main/java/org/teavm/backend/c/generate/CodeGenerationVisitor.java @@ -499,7 +499,7 @@ public class CodeGenerationVisitor implements ExprVisitor, StatementVisitor { pushLocation(expr.getLocation()); - if (needsCallSiteId() && context.getCharacteristics().isManaged(expr.getMethod())) { + if (needsCallSiteId() && isManagedMethodCall(context.getCharacteristics(), expr.getMethod())) { needParenthesis = true; withCallSite(); } diff --git a/core/src/main/java/org/teavm/model/lowlevel/ExceptionHandlingShadowStackContributor.java b/core/src/main/java/org/teavm/model/lowlevel/ExceptionHandlingShadowStackContributor.java index 4979946f9..dcaa96414 100644 --- a/core/src/main/java/org/teavm/model/lowlevel/ExceptionHandlingShadowStackContributor.java +++ b/core/src/main/java/org/teavm/model/lowlevel/ExceptionHandlingShadowStackContributor.java @@ -283,17 +283,13 @@ public class ExceptionHandlingShadowStackContributor { || insn instanceof NullCheckInstruction || insn instanceof BoundCheckInstruction) { return true; } else if (insn instanceof InvokeInstruction) { - MethodReference method = ((InvokeInstruction) insn).getMethod(); - if (method.equals(FILL_STACK_TRACE)) { - return true; - } - return isManagedMethodCall(characteristics, method); + return isManagedMethodCall(characteristics, ((InvokeInstruction) insn).getMethod()); } return false; } public static boolean isManagedMethodCall(Characteristics characteristics, MethodReference method) { - if (characteristics.isManaged(method)) { + if (characteristics.isManaged(method) || method.equals(FILL_STACK_TRACE)) { return true; } return method.getClassName().equals(ExceptionHandling.class.getName())