summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHubert Plociniczak <hubert.plociniczak@gmail.com>2012-08-02 18:30:38 +0200
committerHubert Plociniczak <hubert.plociniczak@gmail.com>2012-08-02 18:45:24 +0200
commitd1a95c878908ce1a7a041151930f8637c0d7d891 (patch)
tree7458a8a269df2ce41d1725cccc3310ad041bab23 /src
parent937da62be2834a646a31dbfb01527a82672f111e (diff)
downloadscala-d1a95c878908ce1a7a041151930f8637c0d7d891.tar.gz
scala-d1a95c878908ce1a7a041151930f8637c0d7d891.tar.bz2
scala-d1a95c878908ce1a7a041151930f8637c0d7d891.zip
Fixes SI-6172.
All the credit for fixing magical constants in the encoding algorithm goes to @magarciaEPFL. This time provided a test case that exercises GenASM.
Diffstat (limited to 'src')
-rw-r--r--src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala b/src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala
index f681de93b6..a804cc92d3 100644
--- a/src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala
+++ b/src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala
@@ -932,7 +932,6 @@ abstract class GenASM extends SubComponent with BytecodeWriters {
ca
}
- // TODO this method isn't exercised during bootstrapping. Open question: is it bug free?
private def arrEncode(sb: ScalaSigBytes): Array[String] = {
var strs: List[String] = Nil
val bSeven: Array[Byte] = sb.sevenBitsMayBeZero
@@ -941,14 +940,15 @@ abstract class GenASM extends SubComponent with BytecodeWriters {
var offset = 0
var encLength = 0
while(offset < bSeven.size) {
- val newEncLength = encLength.toLong + (if(bSeven(offset) == 0) 2 else 1)
- if(newEncLength > 65535) {
+ val deltaEncLength = (if(bSeven(offset) == 0) 2 else 1)
+ val newEncLength = encLength.toLong + deltaEncLength
+ if(newEncLength >= 65535) {
val ba = bSeven.slice(prevOffset, offset)
strs ::= new java.lang.String(ubytesToCharArray(ba))
encLength = 0
prevOffset = offset
} else {
- encLength += 1
+ encLength += deltaEncLength
offset += 1
}
}