diff options
author | Paul Phillips <paulp@improving.org> | 2010-01-15 18:00:51 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2010-01-15 18:00:51 +0000 |
commit | 9bd9b9fcc1623ca3b6c98cb7ce12f31581750372 (patch) | |
tree | f3a12a4788db0879fa06666caf335dedf5c3357a /src/compiler/scala/tools/nsc/ast | |
parent | 3e1241caeca9af5b05922d38bed1b0480e6da56d (diff) | |
download | scala-9bd9b9fcc1623ca3b6c98cb7ce12f31581750372.tar.gz scala-9bd9b9fcc1623ca3b6c98cb7ce12f31581750372.tar.bz2 scala-9bd9b9fcc1623ca3b6c98cb7ce12f31581750372.zip |
Fix for #2365.
a soft reference around cached classes so they do not interfere with
garbage collection. There is a test case, but it is in pending because I
spent longer trying to get it to fail under partest than I did writing
the actual patch. If you would like to see the behavior which was
corrected, go to
test/pending/run/bug2365
and run that script with scalac built before and after this commit.
Review by dubochet.
Diffstat (limited to 'src/compiler/scala/tools/nsc/ast')
-rw-r--r-- | src/compiler/scala/tools/nsc/ast/TreeDSL.scala | 5 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/ast/TreeGen.scala | 3 |
2 files changed, 7 insertions, 1 deletions
diff --git a/src/compiler/scala/tools/nsc/ast/TreeDSL.scala b/src/compiler/scala/tools/nsc/ast/TreeDSL.scala index fb65f82740..a788015262 100644 --- a/src/compiler/scala/tools/nsc/ast/TreeDSL.scala +++ b/src/compiler/scala/tools/nsc/ast/TreeDSL.scala @@ -175,7 +175,10 @@ trait TreeDSL { if (target.tpe.typeSymbol == SomeClass) TRUE // is Some[_] else NOT(ID(target) DOT nme.isEmpty) // is Option[_] - def GET() = fn(ID(target), nme.get) + def IS_NULL() = REF(target) ANY_EQ NULL + def NOT_NULL() = REF(target) ANY_NE NULL + + def GET() = fn(REF(target), nme.get) // name of nth indexed argument to a method (first parameter list), defaults to 1st def ARG(idx: Int = 0) = Ident(target.paramss.head(idx)) diff --git a/src/compiler/scala/tools/nsc/ast/TreeGen.scala b/src/compiler/scala/tools/nsc/ast/TreeGen.scala index c5a8b93c88..7f2bcf99c5 100644 --- a/src/compiler/scala/tools/nsc/ast/TreeGen.scala +++ b/src/compiler/scala/tools/nsc/ast/TreeGen.scala @@ -228,6 +228,9 @@ abstract class TreeGen def mkOr(tree1: Tree, tree2: Tree): Tree = Apply(Select(tree1, Boolean_or), List(tree2)) + // wrap the given expression in a SoftReference so it can be gc-ed + def mkSoftRef(expr: Tree): Tree = New(TypeTree(SoftReferenceClass.tpe), List(List(expr))) + def mkCached(cvar: Symbol, expr: Tree): Tree = { val cvarRef = if (cvar.owner.isClass) Select(This(cvar.owner), cvar) else Ident(cvar) Block( |