diff options
author | Jason Zaugg <jzaugg@gmail.com> | 2016-08-10 21:20:24 +1000 |
---|---|---|
committer | Jason Zaugg <jzaugg@gmail.com> | 2016-08-10 21:25:38 +1000 |
commit | 131402fd5fe8c064ef5cfffbe568507cbdf37990 (patch) | |
tree | ec3470addaf68356d7b5b8d6418de77ec753375a /src/compiler/scala/tools/nsc/backend/jvm | |
parent | 498a2ce7397b909c0bebf36affeb1ee5a1c03d6a (diff) | |
download | scala-131402fd5fe8c064ef5cfffbe568507cbdf37990.tar.gz scala-131402fd5fe8c064ef5cfffbe568507cbdf37990.tar.bz2 scala-131402fd5fe8c064ef5cfffbe568507cbdf37990.zip |
Cleanups after code review
- Remove unused references to "addTargetMethods"
- Require that `targetMethodMap` is provided
Diffstat (limited to 'src/compiler/scala/tools/nsc/backend/jvm')
3 files changed, 8 insertions, 21 deletions
diff --git a/src/compiler/scala/tools/nsc/backend/jvm/BTypes.scala b/src/compiler/scala/tools/nsc/backend/jvm/BTypes.scala index 0845e440d7..bff58b426e 100644 --- a/src/compiler/scala/tools/nsc/backend/jvm/BTypes.scala +++ b/src/compiler/scala/tools/nsc/backend/jvm/BTypes.scala @@ -124,12 +124,13 @@ abstract class BTypes { */ val indyLambdaImplMethods: mutable.AnyRefMap[InternalName, mutable.LinkedHashSet[asm.Handle]] = recordPerRunCache(mutable.AnyRefMap()) def addIndyLambdaImplMethod(hostClass: InternalName, handle: Seq[asm.Handle]): Unit = { - indyLambdaImplMethods.getOrElseUpdate(hostClass, mutable.LinkedHashSet()) ++= handle + if (handle.nonEmpty) + indyLambdaImplMethods.getOrElseUpdate(hostClass, mutable.LinkedHashSet()) ++= handle } - def getIndyLambdaImplMethods(hostClass: InternalName): List[asm.Handle] = { + def getIndyLambdaImplMethods(hostClass: InternalName): Iterable[asm.Handle] = { indyLambdaImplMethods.getOrNull(hostClass) match { case null => Nil - case xs => xs.toList.distinct + case xs => xs } } diff --git a/src/compiler/scala/tools/nsc/backend/jvm/CoreBTypes.scala b/src/compiler/scala/tools/nsc/backend/jvm/CoreBTypes.scala index 1dbb18722f..acb950929f 100644 --- a/src/compiler/scala/tools/nsc/backend/jvm/CoreBTypes.scala +++ b/src/compiler/scala/tools/nsc/backend/jvm/CoreBTypes.scala @@ -289,19 +289,6 @@ class CoreBTypes[BTFS <: BTypesFromSymbols[_ <: Global]](val bTypes: BTFS) { coreBTypes.jliCallSiteRef ).descriptor, /* itf = */ coreBTypes.srLambdaDeserialize.isInterface.get) - lazy val lambdaDeserializeAddTargets = - new scala.tools.asm.Handle(scala.tools.asm.Opcodes.H_INVOKESTATIC, - coreBTypes.srLambdaDeserialize.internalName, "bootstrapAddTargets", - MethodBType( - List( - coreBTypes.jliMethodHandlesLookupRef, - coreBTypes.StringRef, - coreBTypes.jliMethodTypeRef, - ArrayBType(coreBTypes.jliMethodHandleRef) - ), - coreBTypes.jliCallSiteRef - ).descriptor, - /* itf = */ coreBTypes.srLambdaDeserialize.isInterface.get) } /** diff --git a/src/compiler/scala/tools/nsc/backend/jvm/analysis/BackendUtils.scala b/src/compiler/scala/tools/nsc/backend/jvm/analysis/BackendUtils.scala index d85d85003d..e25b55e7ab 100644 --- a/src/compiler/scala/tools/nsc/backend/jvm/analysis/BackendUtils.scala +++ b/src/compiler/scala/tools/nsc/backend/jvm/analysis/BackendUtils.scala @@ -76,7 +76,7 @@ class BackendUtils[BT <: BTypes](val btypes: BT) { * host a static field in the enclosing class. This allows us to add this method to interfaces * that define lambdas in default methods. */ - def addLambdaDeserialize(classNode: ClassNode, implMethods: List[Handle]): Unit = { + def addLambdaDeserialize(classNode: ClassNode, implMethods: Iterable[Handle]): Unit = { val cw = classNode // Make sure to reference the ClassBTypes of all types that are used in the code generated @@ -87,13 +87,12 @@ class BackendUtils[BT <: BTypes](val btypes: BT) { val nilLookupDesc = MethodBType(Nil, jliMethodHandlesLookupRef).descriptor val serlamObjDesc = MethodBType(jliSerializedLambdaRef :: Nil, ObjectRef).descriptor - val addTargetMethodsObjDesc = MethodBType(ObjectRef :: Nil, UNIT).descriptor { val mv = cw.visitMethod(ACC_PRIVATE + ACC_STATIC + ACC_SYNTHETIC, "$deserializeLambda$", serlamObjDesc, null, null) mv.visitCode() mv.visitVarInsn(ALOAD, 0) - mv.visitInvokeDynamicInsn("lambdaDeserialize", serlamObjDesc, lambdaDeserializeBootstrapHandle, implMethods: _*) + mv.visitInvokeDynamicInsn("lambdaDeserialize", serlamObjDesc, lambdaDeserializeBootstrapHandle, implMethods.toArray: _*) mv.visitInsn(ARETURN) mv.visitEnd() } @@ -102,8 +101,8 @@ class BackendUtils[BT <: BTypes](val btypes: BT) { /** * Clone the instructions in `methodNode` into a new [[InsnList]], mapping labels according to * the `labelMap`. Returns the new instruction list and a map from old to new instructions, and - * a boolean indicating if the instruction list contains an instantiation of a serializable SAM - * type. + * a list of lambda implementation methods references by invokedynamic[LambdaMetafactory] for a + * serializable SAM types. */ def cloneInstructions(methodNode: MethodNode, labelMap: Map[LabelNode, LabelNode], keepLineNumbers: Boolean): (InsnList, Map[AbstractInsnNode, AbstractInsnNode], List[Handle]) = { val javaLabelMap = labelMap.asJava |