hg: valhalla/valhalla: [lworld] Add support for __WithField operator

Srikanth srikanth.adayapalam at oracle.com
Tue Mar 6 13:14:20 UTC 2018



On Tuesday 06 March 2018 06:33 PM, srikanth.adayapalam at oracle.com wrote:
> Changeset: 75ebb75d0d60
> Author:    sadayapalam
> Date:      2018-03-06 18:28 +0530
> URL:       http://hg.openjdk.java.net/valhalla/valhalla/rev/75ebb75d0d60
>
> [lworld] Add support for __WithField operator

Notes:

This changeset implements a new __WithField operator as discussed here:
http://mail.openjdk.java.net/pipermail/valhalla-dev/2018-February/003866.html 
<http://mail.openjdk.java.net/pipermail/valhalla-dev/2018-February/003866.html,>
http://mail.openjdk.java.net/pipermail/valhalla-dev/2018-February/003869.html 
<http://mail.openjdk.java.net/pipermail/valhalla-dev/2018-February/003869.html,>
http://mail.openjdk.java.net/pipermail/valhalla-dev/2018-February/003871.html 
<http://mail.openjdk.java.net/pipermail/valhalla-dev/2018-February/003871.html,>

Basically, the syntax of the operator is:

__WithField(possiblyEmptyOrArbitrarilyComplexPrefixExpression.field, 
arbitrarilyComplexExpression)

field is expected to be instance field and 
possiblyEmptyOrArbitrarilyComplexPrefixExpression's type should be a 
value class. arbitrarilyComplexExpression should be assignable to the 
field and the overall
expression's type is identical to 
possiblyEmptyOrArbitrarilyComplexPrefixExpression's type.

This expression can be used only from the same nest as the concerned 
value class and is lowered into withfield bytecode without much 
ceremony/fanfare

There is no implicit write back semantics - the expression above must be 
assigned expressly by the programmer to a writeable handle of suitable 
type. (No assignment to this - at least not yet)

Please note, I have ATM ignored some of more fancier syntax suggestions 
(updates to multiple fields in one go), code generation suggestions 
(lowering using indy) that have been proposed by some folks.

IMO, job#1 is to enable the prototyping for the purposes of performance 
characterization - fancier things can be consider post that - and 
particularly after such schemes have been studied and commented upon by 
the experts.

Next steps:

     - This change set has been reasonably but not exhaustively tested. 
I will be testing and fixing any issues uncovered in the coming days.
     - Rip out the old field assignment based updates to value instance 
fields.
     - Fix the one failing test in langtools suite 
(langtools/tools/javac/tree/TreePosTest.java) - This is not a 
functionality related failure - only tree positions are not updated 
properly for the new AST node for withfield.

Thanks!
Srikanth




>
> ! src/jdk.compiler/share/classes/com/sun/source/tree/Tree.java
> ! src/jdk.compiler/share/classes/com/sun/source/tree/TreeVisitor.java
> + src/jdk.compiler/share/classes/com/sun/source/tree/WithFieldTree.java
> ! src/jdk.compiler/share/classes/com/sun/source/util/SimpleTreeVisitor.java
> ! src/jdk.compiler/share/classes/com/sun/source/util/TreeScanner.java
> ! src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java
> ! src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Lower.java
> ! src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TransTypes.java
> ! src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/CRTable.java
> ! src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Gen.java
> ! src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java
> ! src/jdk.compiler/share/classes/com/sun/tools/javac/parser/Tokens.java
> ! src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties
> ! src/jdk.compiler/share/classes/com/sun/tools/javac/tree/JCTree.java
> ! src/jdk.compiler/share/classes/com/sun/tools/javac/tree/Pretty.java
> ! src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeCopier.java
> ! src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeMaker.java
> ! src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeScanner.java
> ! src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeTranslator.java
> ! src/jdk.jshell/share/classes/jdk/jshell/CompletenessAnalyzer.java
> + test/langtools/tools/javac/diags/examples/ValueInstanceFieldExpectedHere.java
> ! test/langtools/tools/javac/valhalla/lworld-values/WithFieldNegativeTests.java
> ! test/langtools/tools/javac/valhalla/lworld-values/WithFieldNegativeTests.out
> + test/langtools/tools/javac/valhalla/lworld-values/WithFieldOfExplicitSelector.java
> + test/langtools/tools/javac/valhalla/lworld-values/WithFieldOfImplicitThis.java
> + test/langtools/tools/javac/valhalla/lworld-values/WithFieldOperatorTest.java
> + test/langtools/tools/javac/valhalla/lworld-values/WithFieldOperatorTest.out
>



More information about the valhalla-dev mailing list