11
11
12
12
import com .oracle .truffle .api .exception .AbstractTruffleException ;
13
13
import com .oracle .truffle .api .profiles .ConditionProfile ;
14
+ import com .oracle .truffle .api .CompilerDirectives ;
14
15
import org .truffleruby .RubyLanguage ;
15
16
import com .oracle .truffle .api .TruffleSafepoint ;
16
17
import org .truffleruby .core .exception .ExceptionOperations ;
17
18
import org .truffleruby .language .RubyContextSourceNode ;
18
19
import org .truffleruby .language .RubyNode ;
19
20
import org .truffleruby .language .control .RetryException ;
20
21
import org .truffleruby .language .control .TerminationException ;
21
- import org .truffleruby .language .methods .ExceptionTranslatingNode ;
22
22
23
23
import com .oracle .truffle .api .CompilerAsserts ;
24
24
import com .oracle .truffle .api .CompilerDirectives .TruffleBoundary ;
28
28
import com .oracle .truffle .api .nodes .ExplodeLoop ;
29
29
import com .oracle .truffle .api .nodes .ExplodeLoop .LoopExplosionKind ;
30
30
import com .oracle .truffle .api .profiles .BranchProfile ;
31
+ import org .truffleruby .language .methods .TranslateExceptionNode ;
31
32
import org .truffleruby .language .threadlocal .ThreadLocalGlobals ;
32
33
33
34
public class TryNode extends RubyContextSourceNode {
34
35
35
- @ Child private ExceptionTranslatingNode tryPart ;
36
+ @ Child private RubyNode tryPart ;
36
37
@ Children private final RescueNode [] rescueParts ;
37
38
@ Child private RubyNode elsePart ;
39
+ @ Child private TranslateExceptionNode translateExceptionNode ;
38
40
private final boolean canOmitBacktrace ;
39
41
40
42
private final BranchProfile terminationProfile = BranchProfile .create ();
@@ -44,7 +46,7 @@ public class TryNode extends RubyContextSourceNode {
44
46
private final ConditionProfile raiseExceptionProfile = ConditionProfile .create ();
45
47
46
48
public TryNode (
47
- ExceptionTranslatingNode tryPart ,
49
+ RubyNode tryPart ,
48
50
RescueNode [] rescueParts ,
49
51
RubyNode elsePart ,
50
52
boolean canOmitBacktrace ) {
@@ -76,6 +78,12 @@ public Object execute(VirtualFrame frame) {
76
78
} catch (ControlFlowException exception ) {
77
79
controlFlowProfile .enter ();
78
80
throw exception ;
81
+ } catch (Throwable t ) {
82
+ if (translateExceptionNode == null ) {
83
+ CompilerDirectives .transferToInterpreterAndInvalidate ();
84
+ translateExceptionNode = insert (TranslateExceptionNode .create ());
85
+ }
86
+ throw translateExceptionNode .executeTranslation (t );
79
87
}
80
88
81
89
if (elsePart != null ) {
0 commit comments