diff options
author | Adriaan Moors <adriaan.moors@epfl.ch> | 2012-08-07 23:49:18 -0700 |
---|---|---|
committer | Adriaan Moors <adriaan.moors@epfl.ch> | 2012-08-07 23:49:18 -0700 |
commit | 45d045f8e3d7006890c5a3a187b8b2fc262ad5c7 (patch) | |
tree | b35728feeebcc08451733ebc0995a65de785f3fd /test/files | |
parent | c957bf808352364467243875b84b1b7d103caace (diff) | |
parent | 4caa766e85b6ee2b1629450df9a18bb76380ee12 (diff) | |
download | scala-45d045f8e3d7006890c5a3a187b8b2fc262ad5c7.tar.gz scala-45d045f8e3d7006890c5a3a187b8b2fc262ad5c7.tar.bz2 scala-45d045f8e3d7006890c5a3a187b8b2fc262ad5c7.zip |
Merge pull request #1085 from gkossakowski/inline-in-constructors
Enable inlining in constructors.
Diffstat (limited to 'test/files')
5 files changed, 39 insertions, 0 deletions
diff --git a/test/files/instrumented/inline-in-constructors.check b/test/files/instrumented/inline-in-constructors.check new file mode 100644 index 0000000000..c6c9ae4e15 --- /dev/null +++ b/test/files/instrumented/inline-in-constructors.check @@ -0,0 +1,3 @@ +Method call statistics: + 1 instrumented/Bar.<init>(Z)V + 1 instrumented/Foo.<init>(I)V diff --git a/test/files/instrumented/inline-in-constructors.flags b/test/files/instrumented/inline-in-constructors.flags new file mode 100644 index 0000000000..c9b68d70dc --- /dev/null +++ b/test/files/instrumented/inline-in-constructors.flags @@ -0,0 +1 @@ +-optimise diff --git a/test/files/instrumented/inline-in-constructors/assert_1.scala b/test/files/instrumented/inline-in-constructors/assert_1.scala new file mode 100644 index 0000000000..a03757b89c --- /dev/null +++ b/test/files/instrumented/inline-in-constructors/assert_1.scala @@ -0,0 +1,13 @@ +package instrumented + +object MyPredef { + @inline + final def assert(assertion: Boolean, message: => Any) { + if (!assertion) + throw new java.lang.AssertionError("assertion failed: " + message) + } +} + +class Foo(x: Int) { + MyPredef.assert(x > 0, "not positive: " + x) +} diff --git a/test/files/instrumented/inline-in-constructors/bar_2.scala b/test/files/instrumented/inline-in-constructors/bar_2.scala new file mode 100644 index 0000000000..418dac5a67 --- /dev/null +++ b/test/files/instrumented/inline-in-constructors/bar_2.scala @@ -0,0 +1,7 @@ +package instrumented + +/** Class that uses assert compiled in previous compiler run so we check if + inlining in constructors works across different compilation runs */ +class Bar(x: Boolean) { + MyPredef.assert(x, "not true: " + x) +} diff --git a/test/files/instrumented/inline-in-constructors/test_3.scala b/test/files/instrumented/inline-in-constructors/test_3.scala new file mode 100644 index 0000000000..c4d4cc5f37 --- /dev/null +++ b/test/files/instrumented/inline-in-constructors/test_3.scala @@ -0,0 +1,15 @@ +import scala.tools.partest.instrumented.Instrumentation._ +import instrumented._ + +object Test { + def main(args: Array[String]) { + // force predef initialization before profiling + Predef + MyPredef + startProfiling() + val a = new Foo(2) + val b = new Bar(true) + stopProfiling() + printStatistics() + } +} |