From d0474b84cb2dca90e8d3223e61e10a5df81ca890 Mon Sep 17 00:00:00 2001 From: liu fengyun Date: Sun, 17 Sep 2017 12:13:42 +0200 Subject: [PATCH 1/3] add dummy fields to trees to test cache locality --- compiler/src/dotty/tools/dotc/ast/Trees.scala | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/compiler/src/dotty/tools/dotc/ast/Trees.scala b/compiler/src/dotty/tools/dotc/ast/Trees.scala index 40aea19da8f6..9dd01e2b9801 100644 --- a/compiler/src/dotty/tools/dotc/ast/Trees.scala +++ b/compiler/src/dotty/tools/dotc/ast/Trees.scala @@ -80,6 +80,23 @@ object Trees { private[this] var myTpe: T = _ + var x1: Int = _ + var x2: Int = _ + var x3: Int = _ + var x4: Int = _ + var x5: Int = _ + var x6: Int = _ + var x7: Int = _ + var x8: Int = _ + var x9: Int = _ + var x10: Int = _ + var x11: Int = _ + var x12: Int = _ + var x13: Int = _ + var x14: Int = _ + var x15: Int = _ + var x16: Int = _ + /** Destructively set the type of the tree. This should be called only when it is known that * it is safe under sharing to do so. One use-case is in the withType method below * which implements copy-on-write. Another use-case is in method interpolateAndAdapt in Typer, From daa2e0b02ea53e2d09f30a07b6bb4d782e4f64e9 Mon Sep 17 00:00:00 2001 From: liu fengyun Date: Sun, 17 Sep 2017 14:50:05 +0200 Subject: [PATCH 2/3] make sure dummy fields are allocated --- compiler/src/dotty/tools/dotc/ast/Trees.scala | 5 +++-- .../tools/dotc/printing/RefinedPrinter.scala | 22 +++++++++++++++++++ 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/compiler/src/dotty/tools/dotc/ast/Trees.scala b/compiler/src/dotty/tools/dotc/ast/Trees.scala index 9dd01e2b9801..b40d264912fa 100644 --- a/compiler/src/dotty/tools/dotc/ast/Trees.scala +++ b/compiler/src/dotty/tools/dotc/ast/Trees.scala @@ -78,8 +78,6 @@ object Trees { /** The type constructor at the root of the tree */ type ThisTree[T >: Untyped] <: Tree[T] - private[this] var myTpe: T = _ - var x1: Int = _ var x2: Int = _ var x3: Int = _ @@ -88,6 +86,9 @@ object Trees { var x6: Int = _ var x7: Int = _ var x8: Int = _ + + private[this] var myTpe: T = _ + var x9: Int = _ var x10: Int = _ var x11: Int = _ diff --git a/compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala b/compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala index 49da2dc136ee..c41ae0d103a8 100644 --- a/compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala +++ b/compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala @@ -575,8 +575,30 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) { tree.fallbackToText(this) } + def toTextDummy(tree: Tree): Text = { + "x1 = " ~ tree.x1.toString ~ "\n" ~ + "x2 = " ~ tree.x2.toString ~ "\n" ~ + "x3 = " ~ tree.x3.toString ~ "\n" ~ + "x4 = " ~ tree.x4.toString ~ "\n" ~ + "x5 = " ~ tree.x5.toString ~ "\n" ~ + "x6 = " ~ tree.x6.toString ~ "\n" ~ + "x7 = " ~ tree.x7.toString ~ "\n" ~ + "x8 = " ~ tree.x8.toString ~ "\n" ~ + "x9 = " ~ tree.x9.toString ~ "\n" ~ + "x10 = " ~ tree.x10.toString ~ "\n" ~ + "x11 = " ~ tree.x11.toString ~ "\n" ~ + "x12 = " ~ tree.x12.toString ~ "\n" ~ + "x13 = " ~ tree.x13.toString ~ "\n" ~ + "x14 = " ~ tree.x14.toString ~ "\n" ~ + "x15 = " ~ tree.x15.toString ~ "\n" ~ + "x16 = " ~ tree.x16.toString ~ "\n" + } + var txt = toTextCore(tree) + if (ctx.settings.verbose.value) + txt = txt ~ "\n" ~ toTextDummy(tree) + def suppressTypes = tree.isType || tree.isDef || // don't print types of types or defs homogenizedView && ctx.mode.is(Mode.Pattern) From 28902fca81955bdbf802cbea6bb40b6913bfe6d9 Mon Sep 17 00:00:00 2001 From: liu fengyun Date: Sun, 17 Sep 2017 22:35:47 +0200 Subject: [PATCH 3/3] pad 64 bytes before myTpe --- compiler/src/dotty/tools/dotc/ast/Trees.scala | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/compiler/src/dotty/tools/dotc/ast/Trees.scala b/compiler/src/dotty/tools/dotc/ast/Trees.scala index b40d264912fa..d812708adc1c 100644 --- a/compiler/src/dotty/tools/dotc/ast/Trees.scala +++ b/compiler/src/dotty/tools/dotc/ast/Trees.scala @@ -86,9 +86,6 @@ object Trees { var x6: Int = _ var x7: Int = _ var x8: Int = _ - - private[this] var myTpe: T = _ - var x9: Int = _ var x10: Int = _ var x11: Int = _ @@ -98,6 +95,9 @@ object Trees { var x15: Int = _ var x16: Int = _ + + private[this] var myTpe: T = _ + /** Destructively set the type of the tree. This should be called only when it is known that * it is safe under sharing to do so. One use-case is in the withType method below * which implements copy-on-write. Another use-case is in method interpolateAndAdapt in Typer,