Skip to content

Shared backend #251

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 56 commits into from
Dec 17, 2014
Merged

Shared backend #251

merged 56 commits into from
Dec 17, 2014

Conversation

DarkDimius
Copy link
Contributor

Can compile hello world, can compile patterns and tailrec methods. Can compile array operations. Can compile both classes and objects.

@DarkDimius
Copy link
Contributor Author

Just for fun:

dark@lamppc17 ~/workspace/dotty/tests/pos (shared-backend) $ time scalac HelloWorld.scala

real    0m1.546s
user    0m4.674s
sys 0m0.317s
dark@lamppc17 ~/workspace/dotty/tests/pos (shared-backend) $ time dotc HelloWorld.scala
warning: encountered F-bounded higher-kinded type parameters for type scala$collection$generic$GenMapFactory$$CC; assuming they are invariant
warning: encountered F-bounded higher-kinded type parameters for type scala$collection$generic$MapFactory$$CC; assuming they are invariant
warning: encountered F-bounded higher-kinded type parameters for type scala$collection$generic$GenSetFactory$$CC; assuming they are invariant
warning: encountered F-bounded higher-kinded type parameters for type scala$collection$generic$SetFactory$$CC; assuming they are invariant
warning: encountered F-bounded higher-kinded type parameters for type scala$collection$generic$ImmutableMapFactory$$CC; assuming they are invariant
warning: encountered F-bounded higher-kinded type parameters for type scala$collection$generic$ImmutableSetFactory$$CC; assuming they are invariant
6 warnings found

real    0m1.422s
user    0m3.931s
sys 0m0.346s

and bytecode is the same

diff --git a/HelloWorld$.class b/HelloWorld$.class
index d2b517a..bf3b04f 100644
--- a/HelloWorld$.class
+++ b/HelloWorld$.class
@@ -11,6 +11,13 @@ public final class HelloWorld$ {
 ##: invokespecial ###                 // Method "<init>":()V
 ##: return

+  public HelloWorld$();
+    descriptor: ()V
+    Code:
+##: invokespecial ###                 // Method java/lang/Object."<init>":()V
+##: putstatic     ###                 // Field MODULE$:LHelloWorld$;
+##: return
+
   public void main(java.lang.String[]);
     descriptor: ([Ljava/lang/String;)V
     Code:
@@ -18,11 +25,4 @@ public final class HelloWorld$ {
 ##: ldc           ###                 // String hello world
 ##: invokevirtual ###                 // Method scala/Predef$.println:(Ljava/lang/Object;)V
 ##: return
-
-  private HelloWorld$();
-    descriptor: ()V
-    Code:
-##: invokespecial ###                 // Method java/lang/Object."<init>":()V
-##: putstatic     ###                 // Field MODULE$:LHelloWorld$;
-##: return
 }

@DarkDimius
Copy link
Contributor Author

Status update: Arrays and <label> DefDefs are supported(can compile while cycles, patterns, and tailrec methods).
SeqLiterals and Closures aren't handled.

And there are some errors that I see why applying Identity tranformer that just collects information:

./src/dotty/tools/dotc/core/Uniques.scala:25: error: wrong number of parameters for ($this: dotty.tools.dotc.core.Uniques$(dotty.tools.dotc.core.Uniques), tp: dotty.tools.dotc.core.Types.dotty$tools$dotc$core$Types$$Type)Unit(
  dotty.tools.dotc.core.Uniques
.recordCaching); expected: 2
    if (monitored) recordCaching(tp)

It seems that we have a phase that did FullParametrization but didn't transform actual calls. I guess this is PrivateToStatic that has a transformApply that assumes that fun is a Select while it can also be an Ident. Will get to root of it soon.

@@ -61,7 +64,8 @@ class Compiler {
List(new LambdaLift,
new Flatten,
new RestoreScopes),
List(new PrivateToStatic)
List(/*new PrivateToStatic,*/ new CollectEntryPoints, new LabelDefs),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did we try to fuse with previous group ending in RestoreScopes?

@odersky
Copy link
Contributor

odersky commented Dec 12, 2014

I only checked the patches to previously existing files in detail, and did a quick browse over the backend code. It would be good if somebody who knows the backend could comment. But I agree we should not wait for a long time for it to happen.

Except for the remarks I added, LGTM as far as I am concerned.

@DarkDimius
Copy link
Contributor Author

I've created several issues to track what stops backend from working on other phases: #289 and #288
There's also seems to be a bug in the backend itself that manifests itself late in asm by IndexOutOfBounds exception. It seems that I break the stack somehow. I'll need to track this down.

In the meanwhile I've enabled quite a few tests that compile to bytecode without errors.

@DarkDimius
Copy link
Contributor Author

I haven't actually changed any backend code here for a week already, all changes are in phases. So I propose to merge.

DarkDimius added a commit that referenced this pull request Dec 17, 2014
@DarkDimius DarkDimius merged commit a68980c into scala:master Dec 17, 2014
@samuelgruetter
Copy link
Contributor

Since this PR, it's not possible any more to compile dotty with Java 7; Java 8 is needed. I guess this is intended and not considered a problem, right?

@odersky
Copy link
Contributor

odersky commented Dec 18, 2014

On Thu, Dec 18, 2014 at 5:23 PM, Samuel Gruetter [email protected]
wrote:

Since this PR, it's not possible any more to compile dotty with Java 7;
Java 8 is needed. I guess this is intended and not considered a problem,
right?

Yes, it's inevitable. We said from the start we'd be Java 8 only.

  • Martin


Reply to this email directly or view it on GitHub
#251 (comment).

Martin Odersky
EPFL

@allanrenucci allanrenucci deleted the shared-backend branch December 14, 2017 19:24
tgodzik added a commit to tgodzik/scala3 that referenced this pull request Apr 29, 2025
Backport "Constructor proxy is restricted if class is protected" to 3.3 LTS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants