summaryrefslogtreecommitdiff
path: root/src/compiler
diff options
context:
space:
mode:
authorIulian Dragos <jaguarul@gmail.com>2010-03-23 16:29:38 +0000
committerIulian Dragos <jaguarul@gmail.com>2010-03-23 16:29:38 +0000
commit011377a2c73aee41673544479ee5db85fe143917 (patch)
tree246e3ec0764a362c126f55c148258a2db55bca31 /src/compiler
parent5b394541a253a5bfbc4cab52f7547c63cac47ebf (diff)
downloadscala-011377a2c73aee41673544479ee5db85fe143917.tar.gz
scala-011377a2c73aee41673544479ee5db85fe143917.tar.bz2
scala-011377a2c73aee41673544479ee5db85fe143917.zip
Closed #3195. Review by extempore.
Diffstat (limited to 'src/compiler')
-rw-r--r--src/compiler/scala/tools/nsc/backend/icode/GenICode.scala59
1 files changed, 23 insertions, 36 deletions
diff --git a/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala b/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala
index 77e14139ba..138cb5008d 100644
--- a/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala
+++ b/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala
@@ -1402,48 +1402,35 @@ abstract class GenICode extends SubComponent {
if (isNull(l))
// null == expr -> expr eq null
genLoad(r, ctx, ANY_REF_CLASS).bb emitOnly CZJUMP(thenCtx.bb, elseCtx.bb, EQ, ANY_REF_CLASS)
- else {
+ else if (isNull(r)) {
+ // expr == null -> expr eq null
+ genLoad(l, ctx, ANY_REF_CLASS).bb emitOnly CZJUMP(thenCtx.bb, elseCtx.bb, EQ, ANY_REF_CLASS)
+ } else {
val eqEqTempLocal = getTempLocal
var ctx1 = genLoad(l, ctx, ANY_REF_CLASS)
// dicey refactor section
lazy val nonNullCtx = ctx1.newBlock
- if (isNull(r)) {
- // expr == null -> if (l eq null) true else l.equals(null)
- ctx1.bb.emitOnly(
- DUP(ANY_REF_CLASS),
- STORE_LOCAL(eqEqTempLocal) setPos l.pos,
- CZJUMP(thenCtx.bb, nonNullCtx.bb, EQ, ANY_REF_CLASS)
- )
- nonNullCtx.bb.emitOnly(
- LOAD_LOCAL(eqEqTempLocal) setPos l.pos,
- CONSTANT(Constant(null)) setPos r.pos,
- CALL_METHOD(Object_equals, Dynamic),
- CZJUMP(thenCtx.bb, elseCtx.bb, NE, BOOL)
- )
- }
- else {
- // l == r -> if (l eq null) r eq null else l.equals(r)
- ctx1 = genLoad(r, ctx1, ANY_REF_CLASS)
- val nullCtx = ctx1.newBlock
-
- ctx1.bb.emitOnly(
- STORE_LOCAL(eqEqTempLocal) setPos l.pos,
- DUP(ANY_REF_CLASS),
- CZJUMP(nullCtx.bb, nonNullCtx.bb, EQ, ANY_REF_CLASS)
- )
- nullCtx.bb.emitOnly(
- DROP(ANY_REF_CLASS) setPos l.pos, // type of AnyRef
- LOAD_LOCAL(eqEqTempLocal),
- CZJUMP(thenCtx.bb, elseCtx.bb, EQ, ANY_REF_CLASS)
- )
- nonNullCtx.bb.emitOnly(
- LOAD_LOCAL(eqEqTempLocal) setPos l.pos,
- CALL_METHOD(Object_equals, Dynamic),
- CZJUMP(thenCtx.bb, elseCtx.bb, NE, BOOL)
- )
- }
+ // l == r -> if (l eq null) r eq null else l.equals(r)
+ ctx1 = genLoad(r, ctx1, ANY_REF_CLASS)
+ val nullCtx = ctx1.newBlock
+
+ ctx1.bb.emitOnly(
+ STORE_LOCAL(eqEqTempLocal) setPos l.pos,
+ DUP(ANY_REF_CLASS),
+ CZJUMP(nullCtx.bb, nonNullCtx.bb, EQ, ANY_REF_CLASS)
+ )
+ nullCtx.bb.emitOnly(
+ DROP(ANY_REF_CLASS) setPos l.pos, // type of AnyRef
+ LOAD_LOCAL(eqEqTempLocal),
+ CZJUMP(thenCtx.bb, elseCtx.bb, EQ, ANY_REF_CLASS)
+ )
+ nonNullCtx.bb.emitOnly(
+ LOAD_LOCAL(eqEqTempLocal) setPos l.pos,
+ CALL_METHOD(Object_equals, Dynamic),
+ CZJUMP(thenCtx.bb, elseCtx.bb, NE, BOOL)
+ )
}
}
}