summaryrefslogtreecommitdiff
path: root/src/reflect/scala/reflect/runtime/JavaUniverseForce.scala
diff options
context:
space:
mode:
authorJason Zaugg <jzaugg@gmail.com>2015-05-16 21:02:56 +1000
committerJason Zaugg <jzaugg@gmail.com>2015-05-18 09:07:54 +1000
commit1d8c63277e97c57e12fa9864a2d238d4f54c10f0 (patch)
tree949d2125c97a74bdc0eee5d581684ff93f1f1a77 /src/reflect/scala/reflect/runtime/JavaUniverseForce.scala
parentafa2ff9f76123ab982dc5bb2f1110bb58e75c68c (diff)
downloadscala-1d8c63277e97c57e12fa9864a2d238d4f54c10f0.tar.gz
scala-1d8c63277e97c57e12fa9864a2d238d4f54c10f0.tar.bz2
scala-1d8c63277e97c57e12fa9864a2d238d4f54c10f0.zip
[indylambda] Enable caching for lambda deserialization
We add a static field to each class that defines lambdas that will hold a `ju.Map[String, MethodHandle]` to cache references to the constructors of the classes originally created by `LambdaMetafactory`. The cache is initially null, and created on the first deserialization. In case of a race between two threads deserializing the first lambda hosted by a class, the last one to finish will clobber the one-element cache of the first. This lack of strong guarantees mirrors the current policy in `LambdaDeserializer`. We should consider whether to strengthen the combinaed guarantee here. A useful benchmark would be those of the invokedynamic instruction, which allows multiple threads to call the boostrap method in parallel, but guarantees that if that happens, the results of all but one will be discarded: > If several threads simultaneously execute the bootstrap method for > the same dynamic call site, the Java Virtual Machine must choose > one returned call site object and install it visibly to all threads. We could meet this guarantee easily, albeit excessively, by synchronizing `$deserializeLambda$`. But a more fine grained approach is possible and desirable. A test is included that shows we are able to garbage collect classloaders of classes that have hosted lambda deserialization.
Diffstat (limited to 'src/reflect/scala/reflect/runtime/JavaUniverseForce.scala')
-rw-r--r--src/reflect/scala/reflect/runtime/JavaUniverseForce.scala2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/reflect/scala/reflect/runtime/JavaUniverseForce.scala b/src/reflect/scala/reflect/runtime/JavaUniverseForce.scala
index 8c03ee7ca3..ea213cadd9 100644
--- a/src/reflect/scala/reflect/runtime/JavaUniverseForce.scala
+++ b/src/reflect/scala/reflect/runtime/JavaUniverseForce.scala
@@ -255,6 +255,8 @@ trait JavaUniverseForce { self: runtime.JavaUniverse =>
definitions.JavaEnumClass
definitions.RemoteInterfaceClass
definitions.RemoteExceptionClass
+ definitions.JavaUtilMap
+ definitions.JavaUtilHashMap
definitions.ByNameParamClass
definitions.JavaRepeatedParamClass
definitions.RepeatedParamClass