Skip to content

Commit 4da2c35

Browse files
committed
transfer try/catch and line number info to the fragments
1 parent f63cafa commit 4da2c35

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

src/vm/jvm/runtime/org/perl6/nqp/jast2bc/AutosplitMethodWriter.java

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1249,8 +1249,8 @@ private void emitFragment(int fno, int begin, int end) {
12491249
for (int i = 0; i < exitPts.length; i++)
12501250
exitTrampolineLabels.put(exitPts[i], new Label());
12511251

1252-
Label[] insnLabels = new Label[end - begin];
1253-
for (int i = 0; i < end - begin; i++)
1252+
Label[] insnLabels = new Label[end - begin + 1];
1253+
for (int i = 0; i < end - begin + 1; i++)
12541254
insnLabels[i] = new Label();
12551255

12561256
// common entry code
@@ -1268,6 +1268,18 @@ private void emitFragment(int fno, int begin, int end) {
12681268
int stash = nlocal;
12691269
int scratch = nlocal+1;
12701270

1271+
// emit salient tryblocks
1272+
for (TryCatchBlockNode tcbn : (List<TryCatchBlockNode>) tryCatchBlocks) {
1273+
int nstart = Math.max(begin, insnMap.get(tcbn.start));
1274+
int nend = Math.min(end, insnMap.get(tcbn.end));
1275+
int nhndlr = insnMap.get(tcbn.handler);
1276+
if (nstart >= nend) continue;
1277+
1278+
v.visitTryCatchBlock(insnLabels[nstart - begin], insnLabels[nend - begin],
1279+
exitTrampolineLabels.containsKey(nhndlr) ? exitTrampolineLabels.get(nhndlr) : insnLabels[nhndlr - begin],
1280+
tcbn.type);
1281+
}
1282+
12711283
// uncommon entry code
12721284
for (int ept : entryPts) {
12731285
v.visitLabel(entryTrampolineLabels[jumpNoMap[ept]-firstj]);
@@ -1288,10 +1300,19 @@ private void emitFragment(int fno, int begin, int end) {
12881300
for (int iix = begin; iix < end; iix++) {
12891301
emitFragmentInsn(v, iix, begin, insnLabels, exitTrampolineLabels, spilledUTypes);
12901302
}
1303+
v.visitLabel(insnLabels[end - begin]);
12911304

12921305
if (exitTrampolineLabels.containsKey(end))
12931306
v.visitJumpInsn(Opcodes.GOTO, exitTrampolineLabels.get(end));
12941307

1308+
int lineno = -1;
1309+
for (int i = begin; i < end; i++) {
1310+
if (lineNumbers[i] != lineno) {
1311+
lineno = lineNumbers[i];
1312+
v.visitLineNumber(lineno, insnLabels[i-begin]);
1313+
}
1314+
}
1315+
12951316
Label commonExitLabel = new Label();
12961317

12971318
// uncommon exit code

0 commit comments

Comments
 (0)