From 881641f83461b5fc23ab25d1efa08b7a760a3363 Mon Sep 17 00:00:00 2001 From: Aleksandar Prokopec Date: Thu, 7 Jun 2012 14:26:35 +0200 Subject: Add the first iteration of the `util.hashing` package. Move `MurmurHash3` to `util.hashing`. Make the `class` private and retain a public companion `object`, and put the `MurmurHash3.Hashing` implementations for various types in the companion. Add a method which composes `ByteswapHashing` with some other hashing. Rename `hashOf` to `hash`. Fix chi-square test in a test-case. Review by @jsuereth. Moved a failing test that seems to use some other library version to pending. --- test/pending/specialized/SI-5005.check | 33 +++++++++++++++++++++++++++++++ test/pending/specialized/SI-5005.scala | 36 ++++++++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+) create mode 100644 test/pending/specialized/SI-5005.check create mode 100644 test/pending/specialized/SI-5005.scala (limited to 'test/pending') diff --git a/test/pending/specialized/SI-5005.check b/test/pending/specialized/SI-5005.check new file mode 100644 index 0000000000..81e8342dad --- /dev/null +++ b/test/pending/specialized/SI-5005.check @@ -0,0 +1,33 @@ +[[syntax trees at end of specialize]] // newSource1 +package { + class C2[@specialized(scala.Boolean) U >: Nothing <: Any] extends Object { + def (): C2[U] = { + C2.super.(); + () + }; + def apply(x: U): U = x; + def apply$mcZ$sp(x: Boolean): Boolean = C2.this.apply(x.asInstanceOf[U]()).asInstanceOf[Boolean]() + }; + class B extends Object { + def (): B = { + B.super.(); + () + }; + new C2$mcZ$sp().apply$mcZ$sp(true) + }; + class C2$mcZ$sp extends C2[Boolean] { + def (): C2$mcZ$sp = { + C2$mcZ$sp.super.(); + () + }; + @inline final override def apply(x: Boolean): Boolean = C2$mcZ$sp.this.apply$mcZ$sp(x); + @inline final override def apply$mcZ$sp(x: Boolean): Boolean = x + } +} + +[log inliner] Analyzing C2.apply count 0 with 1 blocks +[log inliner] C2.apply blocks before inlining: 1 (2) after: 1 (2) +[log inliner] Analyzing C2.apply$mcZ$sp count 0 with 1 blocks +[log inliner] C2.apply$mcZ$sp blocks before inlining: 1 (8) after: 1 (8) +[log inliner] Not inlining into apply because it is marked @inline. +[log inliner] Not inlining into apply$mcZ$sp because it is marked @inline. diff --git a/test/pending/specialized/SI-5005.scala b/test/pending/specialized/SI-5005.scala new file mode 100644 index 0000000000..280bf0aa2d --- /dev/null +++ b/test/pending/specialized/SI-5005.scala @@ -0,0 +1,36 @@ +import scala.tools.partest._ +import java.io._ + + + +// I think this may be due to a bug in partest where it uses some other version +// of the scala-library.jar - _hashCode is in line 202 currently, not 212! +// +// [partest] testing: [...]/files/specialized/SI-5005.scala [FAILED] +// [partest] java.lang.NoClassDefFoundError: scala/util/MurmurHash3$ +// [partest] java.lang.NoClassDefFoundError: scala/util/MurmurHash3$ +// [partest] at scala.runtime.ScalaRunTime$._hashCode(ScalaRunTime.scala:212) +object Test extends DirectTest { + + override def extraSettings: String = "-usejavacp -Xprint:spec -optimize -Ylog:inliner -d " + testOutput.path + + override def code = """ + class C2[@specialized(Boolean) U]() { + @inline final def apply(x: U): U = x + } + + class B { + (new C2[Boolean]())(true) + } + """ + + override def show(): Unit = { + // redirect err to out, for inliner log + val prevErr = System.err + System.setErr(System.out) + compile() + System.setErr(prevErr) + } + + override def isDebug = false // so we don't get the newSettings warning +} -- cgit v1.2.3