summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLukas Rytz <lukas.rytz@gmail.com>2015-09-14 11:45:21 +0200
committerLukas Rytz <lukas.rytz@gmail.com>2015-09-17 22:05:04 +0200
commit382015824cfb3d1af2eb0dc3065b305e93185577 (patch)
treeb74cb719f9ef46a6d0ee52718c1a52930036e1af
parent4129a03ecc2f953e8b79ec1a2a545a96efb057b4 (diff)
downloadscala-382015824cfb3d1af2eb0dc3065b305e93185577.tar.gz
scala-382015824cfb3d1af2eb0dc3065b305e93185577.tar.bz2
scala-382015824cfb3d1af2eb0dc3065b305e93185577.zip
Remove stack values from aliasing set when being dropped
When entering an exception handler, all values are dropped from the stack (and the exception value is pushed). The ASM analyzer handles this by invoking `firstHandlerInstructionFrame.clearStack()`. To ensure consistent aliasing sets, we need to remove the dropped values from aliasing sets.
-rw-r--r--src/compiler/scala/tools/nsc/backend/jvm/analysis/AliasingFrame.scala15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/compiler/scala/tools/nsc/backend/jvm/analysis/AliasingFrame.scala b/src/compiler/scala/tools/nsc/backend/jvm/analysis/AliasingFrame.scala
index 7bbe1e2a49..6ae6eddfef 100644
--- a/src/compiler/scala/tools/nsc/backend/jvm/analysis/AliasingFrame.scala
+++ b/src/compiler/scala/tools/nsc/backend/jvm/analysis/AliasingFrame.scala
@@ -205,6 +205,21 @@ class AliasingFrame[V <: Value](nLocals: Int, nStack: Int) extends Frame[V](nLoc
}
/**
+ * When entering an exception handler, all values are dropped from the stack (and the exception
+ * value is pushed). The ASM analyzer invokes `firstHandlerInstructionFrame.clearStack()`. To
+ * ensure consistent aliasing sets, we need to remove the dropped values from aliasing sets.
+ */
+ override def clearStack(): Unit = {
+ var i = getLocals
+ val end = i + getStackSize
+ while (i < end) {
+ removeAlias(i)
+ i += 1
+ }
+ super.clearStack()
+ }
+
+ /**
* Merge the AliasingFrame `other` into this AliasingFrame.
*
* Aliases that are common in both frames are kept. Example: