
package orc.run.porce;

import orc.error.runtime.HaltException;
import orc.run.porce.runtime.KilledException;

import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.profiles.BranchProfile;

public class TryOnException extends Expression {
    @Child
    protected Expression body;
    @Child
    protected Expression handler;
    
	private final BranchProfile catchProfile = BranchProfile.create();

    public TryOnException(final Expression body, final Expression handler) {
        this.body = body;
        this.handler = handler;
    }

    @Override
    public void executePorcEUnit(final VirtualFrame frame) {
        try {
            body.executePorcEUnit(frame);
        } catch (HaltException | KilledException e) {
    		catchProfile.enter();
            handler.executePorcEUnit(frame);
        }
    }

    public static TryOnException create(final Expression body, final Expression handler) {
        return new TryOnException(body, handler);
    }
}

@@ -351,17 +351,20 @@
 r;%0A    %0A
-%09
+    
 private 
@@ -383,17 +383,96 @@
 Profile 
-c
+haltCatchProfile = BranchProfile.create();%0A    private final BranchProfile killC
 atchProf
@@ -810,10 +810,113 @@
 ion 
-%7C 
+e) %7B%0A            haltCatchProfile.enter();%0A            handler.executePorcEUnit(frame);%0A        %7D catch (
 Kill
@@ -940,11 +940,21 @@
     
-%09%09c
+        killC
 atch

Remove multi-catch.