small change in method dispatch that seems to impact bench results (#22564)

This commit is contained in:
Patrik Nordwall 2017-03-16 10:27:59 +01:00 committed by Johan Andrén
parent addbed15d7
commit 6414aaccbc
3 changed files with 14 additions and 16 deletions

View file

@ -74,8 +74,7 @@ object TraversalTestUtils {
val outlets: Array[OutPort], val outlets: Array[OutPort],
val matValue: Any, val matValue: Any,
val attributesAssignments: List[(AtomicModule[Shape, Any], Attributes)], val attributesAssignments: List[(AtomicModule[Shape, Any], Attributes)],
val islandAssignments: List[(AtomicModule[Shape, Any], Attributes, IslandTag)] val islandAssignments: List[(AtomicModule[Shape, Any], Attributes, IslandTag)]) {
) {
override def toString = { override def toString = {
outlets.iterator.zip(inlets.iterator).mkString("connections: ", ", ", "") outlets.iterator.zip(inlets.iterator).mkString("connections: ", ", ", "")
@ -152,7 +151,7 @@ object TraversalTestUtils {
val prev = matValueStack.removeLast() val prev = matValueStack.removeLast()
val result = transform(prev) val result = transform(prev)
matValueStack.addLast(result) matValueStack.addLast(result)
case compose: ComposeOp case compose: Compose
val second = matValueStack.removeLast() val second = matValueStack.removeLast()
val first = matValueStack.removeLast() val first = matValueStack.removeLast()
val result = compose(first, second) val result = compose(first, second)

View file

@ -475,7 +475,7 @@ case class PhasedFusingActorMaterializer(
val result = transform(prev) val result = transform(prev)
matValueStack.addLast(result) matValueStack.addLast(result)
if (Debug) println(s"TRFM: $matValueStack") if (Debug) println(s"TRFM: $matValueStack")
case compose: ComposeOp case compose: Compose
val second = matValueStack.removeLast() val second = matValueStack.removeLast()
val first = matValueStack.removeLast() val first = matValueStack.removeLast()
val result = compose(first, second) val result = compose(first, second)

View file

@ -121,15 +121,14 @@ case object PushNotUsed extends MaterializedValueOp
final case class Transform(mapper: AnyFunction1) extends MaterializedValueOp { final case class Transform(mapper: AnyFunction1) extends MaterializedValueOp {
def apply(arg: Any): Any = mapper.asInstanceOf[Any Any](arg) def apply(arg: Any): Any = mapper.asInstanceOf[Any Any](arg)
} }
trait ComposeOp extends MaterializedValueOp {
def apply(arg1: Any, arg2: Any): Any final case class Compose(composer: AnyFunction2, reverse: Boolean = false) extends MaterializedValueOp {
} def apply(arg1: Any, arg2: Any): Any = {
final case class Compose(composer: AnyFunction2) extends ComposeOp { if (reverse)
def apply(arg1: Any, arg2: Any): Any = composer.asInstanceOf[(Any, Any) Any](arg1, arg2) composer.asInstanceOf[(Any, Any) Any](arg2, arg1)
} else
/** An optimization which applies the arguments in reverse order */ composer.asInstanceOf[(Any, Any) Any](arg1, arg2)
final case class ComposeReversed(composer: AnyFunction2) extends ComposeOp { }
def apply(arg1: Any, arg2: Any): Any = composer.asInstanceOf[(Any, Any) Any](arg2, arg1)
} }
final case class PushAttributes(attributes: Attributes) extends Traversal final case class PushAttributes(attributes: Attributes) extends Traversal
@ -224,8 +223,8 @@ object TraversalBuilder {
case PushNotUsed prindent("push NotUsed") case PushNotUsed prindent("push NotUsed")
case Pop prindent("pop mat") case Pop prindent("pop mat")
case _: Transform prindent("transform mat") case _: Transform prindent("transform mat")
case _: Compose prindent("compose mat") case Compose(_, false) prindent("compose mat")
case _: ComposeReversed prindent("compose reversed mat") case Compose(_, true) prindent("compose reversed mat")
case PushAttributes(attr) prindent("push attr " + attr) case PushAttributes(attr) prindent("push attr " + attr)
case PopAttributes prindent("pop attr") case PopAttributes prindent("pop attr")
case EnterIsland(tag) prindent("enter island " + tag) case EnterIsland(tag) prindent("enter island " + tag)
@ -544,7 +543,7 @@ object LinearTraversalBuilder {
else if (matCompose eq Keep.none) else if (matCompose eq Keep.none)
t.concat(Pop).concat(Pop).concat(PushNotUsed) t.concat(Pop).concat(Pop).concat(PushNotUsed)
else else
t.concat(ComposeReversed(matCompose)) t.concat(Compose(matCompose, reverse = true))
} }
def fromBuilder( def fromBuilder(