-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Sharing GenBcode backend between scalac and dotty #4136
Closed
Closed
Changes from all commits
Commits
Show all changes
46 commits
Select commit
Hold shift + click to select a range
3d66b0d
Factoring out methods used in backend. No direct usages of global any…
DarkDimius 7537cb6
Reduced number of methods used in backend.
DarkDimius f15d62a
Factoring out definitions used in backend.
DarkDimius e081724
Starting to implement interfaces for scalac
DarkDimius 61fac46
Organise members of SymbolHelpers.
DarkDimius 31e1c55
Use name-based pattern matching in backend
DarkDimius 78acb5a
Make sure genIcode and genASM compile.
DarkDimius c93b3b4
Use name-based pattern matching for deconstructors, using same instan…
DarkDimius 7131476
Implement BackendInterface for scalac
DarkDimius 284915c
Start using ScalacBackendInterface.
DarkDimius 3c89b52
Fix initialization order problem.
DarkDimius 4c66397
ScalacBackend should now be functional.
DarkDimius 6783bec
Avoid initialization order problem
retronym de1efa9
Fixing bugs introduced while porting.
DarkDimius b1d096f
Adapt unit tests to use ScalacBackendInterface
DarkDimius 9986e7d
Scala requires compilation unit to generate fresh symbol
DarkDimius d37adac
It seems that for tests order of definitions inside Definitions matters.
DarkDimius 82d137f
Move in shared implementation between dotty and scalac.
DarkDimius 9300268
Workaround name-based pattern matching creating tuples for ValDefs.
DarkDimius 2d0104d
Fix error in BCodeBodyBuilder.
DarkDimius 20b3c04
Get rid of most of allocations in ScalacBackendInterface
DarkDimius 0b2e0c5
Fix several bugs introduced by capturing a sub pattern instead of per…
DarkDimius fa98eea
Make reading of source easier by giving a bit more structure.
DarkDimius fa67f6c
There's no support for early initialisers in dotty. Make initialisati…
DarkDimius f9b3cf1
Handle Dotty Idents
DarkDimius 0e1fec4
Handle dotty typeApply.
DarkDimius 084cc06
Refactor genArrayValue, so that array creation from elements could be…
DarkDimius 5b1ef8c
Minimal set of modifications to allow to support both dotty <label> D…
DarkDimius b8d14a1
A bit more abstraction on what are primitives and operations on them.
DarkDimius 2d22839
Remove allocations of Options also for Product1 extractors.
DarkDimius e6c183a
Handle Dotty Closures. Generate InvokeDynamic for them. Give a basis …
DarkDimius 77f2fad
Give types and positions to all symbols that backend creates.
DarkDimius d62f7bf
Address reviewers comments: less casts needed.
DarkDimius 0581a7c
Make difference between java private flag and scala private flag.
DarkDimius 61fb9a5
Use 2.11.5-SNAPSHOT for star until 2.11.5 is released.
DarkDimius 57274f8
Dotty specific: handle lading of This in types.
DarkDimius 1439f45
Uniform handling of scalac ArrayValue and JavaSeqLiteral in dotty.
DarkDimius 5215341
Handle Selects inside closures.
DarkDimius 0bbab5c
Initial generation of default methods.
DarkDimius 8628f92
snapshot scala
lrytz 2712a22
Merge pull request #1 from lrytz/sharedBackend
DarkDimius 658e2f6
Merge branch 'sharing-backend' of github.com:DarkDimius/scala into sh…
DarkDimius 9392c81
Handle dotty Idents by desugaring them into selects.
DarkDimius 3ec6c6f
SI-9003 Eagerly capture more potentially mutable binders
retronym cdaf6dc
Even more handling of primitives by trees.
DarkDimius beaa78b
Merge branch 'sharing-backend' of github.com:DarkDimius/scala into sh…
DarkDimius File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
478 changes: 243 additions & 235 deletions
478
src/compiler/scala/tools/nsc/backend/ScalaPrimitives.scala
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,8 @@ import scala.collection.mutable.ListBuffer | |
abstract class ICodeCheckers { | ||
val global: Global | ||
import global._ | ||
import Primitives._ | ||
import Opcodes._ | ||
|
||
/** <p> | ||
* This class performs a set of checks similar to what the bytecode | ||
|
@@ -520,49 +522,49 @@ abstract class ICodeCheckers { | |
case CALL_PRIMITIVE(primitive) => | ||
checkStack(instr.consumed) | ||
primitive match { | ||
case Negation(kind) => | ||
case Negation(kind: TypeKind) => | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do we need those type annotations? |
||
checkType(kind, BOOL, BYTE, CHAR, SHORT, INT, LONG, FLOAT, DOUBLE) | ||
checkType(popStack, kind) | ||
pushStack(kind) | ||
|
||
case Test(op, kind, zero) => | ||
case Test(op, kind: TypeKind, zero) => | ||
if (zero) checkType(popStack, kind) | ||
else checkBinop(kind) | ||
|
||
pushStack(BOOL) | ||
|
||
case Comparison(op, kind) => | ||
case Comparison(op, kind: TypeKind) => | ||
checkNumeric(kind) | ||
checkBinop(kind) | ||
pushStack(INT) | ||
|
||
case Arithmetic(op, kind) => | ||
case Arithmetic(op, kind: TypeKind) => | ||
checkNumeric(kind) | ||
if (op == NOT) | ||
checkType(popStack, kind) | ||
else | ||
checkBinop(kind) | ||
pushStack(kind) | ||
|
||
case Logical(op, kind) => | ||
case Logical(op, kind: TypeKind) => | ||
checkType(kind, BOOL, BYTE, CHAR, SHORT, INT, LONG) | ||
checkBinop(kind) | ||
pushStack(kind) | ||
|
||
case Shift(op, kind) => | ||
case Shift(op, kind: TypeKind) => | ||
checkType(kind, BYTE, CHAR, SHORT, INT, LONG) | ||
val (a, b) = popStack2 | ||
checkType(a, INT) | ||
checkType(b, kind) | ||
pushStack(kind) | ||
|
||
case Conversion(src, dst) => | ||
case Conversion(src: TypeKind, dst: TypeKind) => | ||
checkNumeric(src) | ||
checkNumeric(dst) | ||
checkType(popStack, src) | ||
pushStack(dst) | ||
|
||
case ArrayLength(kind) => | ||
case ArrayLength(kind: TypeKind) => | ||
popStack match { | ||
case ARRAY(elem) => checkType(elem, kind) | ||
case arr => icodeError(" array reference expected, but " + arr + " found") | ||
|
@@ -576,7 +578,7 @@ abstract class ICodeCheckers { | |
checkType(popStack, ConcatClass) | ||
pushStack(StringReference) | ||
|
||
case StringConcat(el) => | ||
case StringConcat(el: TypeKind) => | ||
checkType(popStack, el) | ||
checkType(popStack, ConcatClass) | ||
pushStack(ConcatClass) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,14 +22,15 @@ abstract class ICodes extends AnyRef | |
with Opcodes | ||
with TypeStacks | ||
with TypeKinds | ||
with ExceptionHandlers | ||
with Primitives | ||
with ExceptionHandlers | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is there a reason for this change? |
||
with Linearizers | ||
with Printers | ||
with Repository | ||
{ | ||
val global: Global | ||
import global.{ log, definitions, settings, perRunCaches, devWarning } | ||
import Primitives._ | ||
|
||
/** The ICode representation of classes */ | ||
val classes = perRunCaches.newMap[global.Symbol, IClass]() | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
when looking through the entire diff of this PR, there's 4 instances of
new ScalacBackendInterface
- one ought to be enough, no?