aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/backend/sjs/JSCodeGen.scala
diff options
context:
space:
mode:
authorSébastien Doeraene <sjrdoeraene@gmail.com>2016-03-23 11:51:25 +0100
committerDmitry Petrashko <dmitry.petrashko@gmail.com>2016-04-18 14:44:23 +0200
commit27deb1e0d41a4dfc24a4cac8a311c30471d454e5 (patch)
treeef9001d9b1bf141f4e4887d1525315f8d20e404b /src/dotty/tools/backend/sjs/JSCodeGen.scala
parent88baa04f2bc6b89d3e65226973d7b72fdf715095 (diff)
downloaddotty-27deb1e0d41a4dfc24a4cac8a311c30471d454e5.tar.gz
dotty-27deb1e0d41a4dfc24a4cac8a311c30471d454e5.tar.bz2
dotty-27deb1e0d41a4dfc24a4cac8a311c30471d454e5.zip
Fix #1167: Remove the magic from Arrays.newRefArray.
Previously, the method `Arrays.newRefArray` was one of the only 3 methods that are kept generic after erasure. This commit removes this magic, by making it take an actual `j.l.Class[T]` as parameter. Moreover, the methods `newXArray` all receive an actual body, implemented on top of Java reflection, which means that a back-end does not *have to* special-case those methods for correctness. It might still be required for performance, though, depending on the back-end. The JVM back-end is made non-optimal in this commit, precisely because it does not specialize that method anymore. Doing so requires modifying the fork of scalac that we use, which should be done separately. The JS back-end is adapted simply by doing nothing at all on any of the newXArray methods. It will normally call the user-space implementations which use reflection. The Scala.js optimizer will inline and intrinsify the reflective calls, producing optimal code, at the end of the day.
Diffstat (limited to 'src/dotty/tools/backend/sjs/JSCodeGen.scala')
-rw-r--r--src/dotty/tools/backend/sjs/JSCodeGen.scala20
1 files changed, 0 insertions, 20 deletions
diff --git a/src/dotty/tools/backend/sjs/JSCodeGen.scala b/src/dotty/tools/backend/sjs/JSCodeGen.scala
index 70c5af1e7..401e01784 100644
--- a/src/dotty/tools/backend/sjs/JSCodeGen.scala
+++ b/src/dotty/tools/backend/sjs/JSCodeGen.scala
@@ -1036,8 +1036,6 @@ class JSCodeGen()(implicit ctx: Context) {
genStringConcat(tree, receiver, args)
else if (code == HASH)
genScalaHash(tree, receiver)
- else if (isArrayNew(code))
- genArrayNew(tree, code)
else if (isArrayOp(code))
genArrayOp(tree, code)
else if (code == SYNCHRONIZED)
@@ -1409,24 +1407,6 @@ class JSCodeGen()(implicit ctx: Context) {
List(genExpr(receiver)))
}
- /** Gen JS code for a new array operation. */
- private def genArrayNew(tree: Tree, code: Int): js.Tree = {
- import scala.tools.nsc.backend.ScalaPrimitives._
-
- implicit val pos: Position = tree.pos
-
- val Apply(fun, args) = tree
- val genLength = genExpr(args.head)
-
- toIRType(tree.tpe) match {
- case arrayType: jstpe.ArrayType =>
- js.NewArray(arrayType, List(genLength))
-
- case irTpe =>
- throw new FatalError(s"ArrayNew $tree must have an array type but was $irTpe")
- }
- }
-
/** Gen JS code for an array operation (get, set or length) */
private def genArrayOp(tree: Tree, code: Int): js.Tree = {
import scala.tools.nsc.backend.ScalaPrimitives._