Skip to content

Conversation

@lrytz
Copy link
Member

@lrytz lrytz commented May 24, 2015

Re-submission of #4516, but target 2.11.x

Early review feedback integrated (in new commits).

Tracks nullness of values using an ASM analyzer.

Tracking nullness requires alias tracking for local variables and
stack values. For example, after an instance call, local variables
that point to the same object as the receiver are treated not-null.
@scala-jenkins scala-jenkins added this to the 2.11.7 milestone May 24, 2015
lrytz added 4 commits May 25, 2015 13:40
When inlining an instance call, the inliner has to ensure that a NPE
is still thrown if the receiver object is null. By using the nullness
analysis, we can avoid emitting this code in case the receiver object
is known to be not-null.
Address feedback in  scala#4516 / 57b8da4. Save allocations of
NullnessValue - there's only 4 possible instances. Also save tuple
allocations in InstructionStackEffect.
@lrytz lrytz force-pushed the opt/nullness-2.11 branch from 825b14c to 460e10c Compare May 25, 2015 11:41
@lrytz
Copy link
Member Author

lrytz commented May 26, 2015

Review by @retronym. I looked through the test failures of the -Ybackend:GenBCode -Yopt:l:classpath -Ydelambdafy:method build, they are all unrelated to this change: the same failures already appear before this change.

I will submit fixes to this build separately, there are several reasons it regressed. The main one is that since a40ee59, the -optimize compiler flag no longer forces GenASM, so more tests are actually executed under -Ybackend:GenBCode.

@retronym retronym self-assigned this May 26, 2015
@lrytz
Copy link
Member Author

lrytz commented Jun 1, 2015

  • TODO: add a command line switch to disable nullness analysis in the inliner

@lrytz
Copy link
Member Author

lrytz commented Jun 3, 2015

  • TODO: test aliasing analyzer for CHECKCAST and INSTANCEOF

Copy link
Member

Choose a reason for hiding this comment

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

typo "Extendsions"

@lrytz
Copy link
Member Author

lrytz commented Jun 4, 2015

pushed two more commits

Copy link
Member

Choose a reason for hiding this comment

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

I can't see anything in the JVM spec that prohibits reassignment of the this parameter, (even thought Javac and Scalac would never emit such code.)

Copy link
Member

Choose a reason for hiding this comment

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

2.6.1 Local Variables
...
The Java Virtual Machine uses local variables to pass parameters on method invocation. On class method invocation, any parameters are passed in consecutive local variables starting from local variable 0. On instance method invocation, local variable 0 is always used to pass a reference to the object on which the instance method is being invoked (this in the Java programming language). Any parameters are subsequently passed in consecutive local variables starting from local variable 1.

astore Store reference into local variable
...
The index is an unsigned byte that must be an index into the local variable array of the current frame (§2.6)

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks, that's a good point. The code here is correct because only sets the initial value of the local variable 0. If it is re-assigned within a method, its nullness will be updated in the frame after the store instruction.

@retronym
Copy link
Member

retronym commented Jun 7, 2015

LGTM

retronym added a commit that referenced this pull request Jun 7, 2015
@retronym retronym merged commit 6d0a498 into scala:2.11.x Jun 7, 2015
@lrytz lrytz deleted the opt/nullness-2.11 branch June 8, 2015 12:06
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