diff options
author | Grzegorz Kossakowski <grzegorz.kossakowski@gmail.com> | 2013-04-25 14:41:57 -0700 |
---|---|---|
committer | Grzegorz Kossakowski <grzegorz.kossakowski@gmail.com> | 2013-04-25 14:41:57 -0700 |
commit | f33af58f3b6538398da6974275099fb18560e92d (patch) | |
tree | 807dad296a097f10b4d241cba9a3276c5a922b73 | |
parent | 8f58457ee0a60575469cb226d46fc621cb66abc7 (diff) | |
parent | b50e6b4bbe174768021f75c63f0d750ebfa9f2a5 (diff) | |
download | scala-f33af58f3b6538398da6974275099fb18560e92d.tar.gz scala-f33af58f3b6538398da6974275099fb18560e92d.tar.bz2 scala-f33af58f3b6538398da6974275099fb18560e92d.zip |
Merge pull request #2451 from magarciaEPFL/backendish4
check added instruction to ASM MethodNode
-rw-r--r-- | src/asm/scala/tools/asm/tree/InsnList.java | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/asm/scala/tools/asm/tree/InsnList.java b/src/asm/scala/tools/asm/tree/InsnList.java index 55d83c2e8b..b1e2d97c6f 100644 --- a/src/asm/scala/tools/asm/tree/InsnList.java +++ b/src/asm/scala/tools/asm/tree/InsnList.java @@ -244,6 +244,14 @@ public class InsnList { * {@link InsnList}</i>. */ public void add(final AbstractInsnNode insn) { + if(insn.prev != null || insn.next != null) { + // Adding an instruction that still refers to others (in the same or another InsnList) leads to hard to debug bugs. + // Initially everything may look ok (e.g. iteration follows `next` thus a stale `prev` isn't noticed). + // However, a stale link brings the doubly-linked into disarray e.g. upon removing an element, + // which results in the `next` of a stale `prev` being updated, among other failure scenarios. + // Better fail early. + throw new RuntimeException("Instruction " + insn + " already belongs to some InsnList."); + } ++size; if (last == null) { first = insn; |