Skip to content
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

8261393: [lworld] Adopt primitive' as the modifier in declaration of identity free classes in lieu of inline` #328

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -29,12 +29,12 @@
import static java.lang.annotation.ElementType.*;

/**
* A class annotated {@code @__inline__} is an inline class.
* This is a temporary workaround to enable use of inline types
* in editors and IDEs that do not yet understand the 'inline' modifier.
* @since 1.12
* A class annotated {@code @__primitive__} is a primitive class.
* This is a temporary workaround to enable use of primitive classes
* in editors and IDEs that do not yet understand the 'primitive' modifier.
* @since 1.16
*/
@Retention(RetentionPolicy.SOURCE)
@Target(value={ElementType.TYPE, ElementType.TYPE_USE})
public @interface __inline__ {
public @interface __primitive__ {
}
@@ -2675,7 +2675,7 @@ JCStatement parseStatementAsBlock() {
case CONTINUE: case SEMI: case ELSE: case FINALLY: case CATCH:
case ASSERT:
return List.of(parseSimpleStatement());
case VALUE:
case PRIMITIVE:
case MONKEYS_AT:
case FINAL: {
dc = token.comment(CommentStyle.JAVADOC);
@@ -3210,7 +3210,7 @@ protected JCModifiers modifiersOpt(JCModifiers partial) {
case FINAL : flag = Flags.FINAL; break;
case ABSTRACT : flag = Flags.ABSTRACT; break;
case NATIVE : flag = Flags.NATIVE; break;
case VALUE : flag = Flags.VALUE; break;
case PRIMITIVE : flag = Flags.VALUE; break;
case VOLATILE : flag = Flags.VOLATILE; break;
case SYNCHRONIZED: flag = Flags.SYNCHRONIZED; break;
case STRICTFP : flag = Flags.STRICTFP; break;
@@ -3243,7 +3243,7 @@ protected JCModifiers modifiersOpt(JCModifiers partial) {
if (flags == 0 && annotations.isEmpty())
pos = ann.pos;
final Name name = TreeInfo.name(ann.annotationType);
if (name == names.__inline__ || name == names.java_lang___inline__) {
if (name == names.__primitive__ || name == names.java_lang___primitive__) {
flag = Flags.VALUE;
} else {
annotations.append(ann);
@@ -3458,9 +3458,9 @@ JCVariableDecl variableDeclaratorRest(int pos, JCModifiers mods, JCExpression ty
return result;
}

// Does the given token signal an inline modifier ? If yes, suitably reclassify token.
// Does the given token signal a primitive modifier ? If yes, suitably reclassify token.
Token recastToken(Token token) {
if (token.kind != IDENTIFIER || token.name() != names.inline) {
if (token.kind != IDENTIFIER || token.name() != names.primitive) {
return token;
}
if (peekToken(t->t == PRIVATE ||
@@ -3489,7 +3489,7 @@ Token recastToken(Token token) {
t == ENUM ||
t == IDENTIFIER)) { // new value Comparable() {}
checkSourceLevel(Feature.INLINE_TYPES);
return new Token(VALUE, token.pos, token.endPos, token.comments);
return new Token(PRIMITIVE, token.pos, token.endPos, token.comments);
}
return token;
}
@@ -141,7 +141,7 @@ TokenKind lookupKind(String name) {
THROWS("throws"),
TRANSIENT("transient"),
TRY("try"),
VALUE(), // a phantom token never returned by the scanner, but can result from a reclassification by the parser.
PRIMITIVE(), // a phantom token never returned by the scanner, but can result from a reclassification by the parser.
VOID("void", Tag.NAMED),
VOLATILE("volatile"),
WHILE("while"),
@@ -246,8 +246,8 @@ public String toString() {
return "token.double";
case ERROR:
return "token.bad-symbol";
case VALUE:
return "value";
case PRIMITIVE:
return "primitive";
case EOF:
return "token.end-of-input";
case DOT: case COMMA: case SEMI: case LPAREN: case RPAREN:
@@ -100,7 +100,7 @@ public static Names instance(Context context) {
public final Name serialVersionUID;
public final Name toString;
public final Name value;
public final Name inline;
public final Name primitive;
public final Name valueOf;
public final Name values;
public final Name readResolve;
@@ -113,8 +113,8 @@ public static Names instance(Context context) {
public final Name java_lang_Enum;
public final Name java_lang_Object;
public final Name java_lang_System;
public final Name __inline__;
public final Name java_lang___inline__;
public final Name __primitive__;
public final Name java_lang___primitive__;
public final Name java_lang_IdentityObject;

// names of builtin classes
@@ -285,7 +285,7 @@ public Names(Context context) {
serialVersionUID = fromString("serialVersionUID");
toString = fromString("toString");
value = fromString("value");
inline = fromString("inline");
primitive = fromString("primitive");
valueOf = fromString("valueOf");
values = fromString("values");
readResolve = fromString("readResolve");
@@ -299,8 +299,8 @@ public Names(Context context) {
java_lang_Enum = fromString("java.lang.Enum");
java_lang_Object = fromString("java.lang.Object");
java_lang_System = fromString("java.lang.System");
__inline__ = fromString("__inline__");
java_lang___inline__ = fromString("java.lang.__inline__");
__primitive__ = fromString("__primitive__");
java_lang___primitive__ = fromString("java.lang.__primitive__");
java_lang_IdentityObject = fromString("java.lang.IdentityObject");

// names of builtin classes
@@ -230,7 +230,7 @@ public void report(JCDiagnostic diagnostic) {
PUBLIC(TokenKind.PUBLIC, XDECL1 | XMODIFIER), // public
TRANSIENT(TokenKind.TRANSIENT, XDECL1 | XMODIFIER), // transient
VOLATILE(TokenKind.VOLATILE, XDECL1 | XMODIFIER), // volatile
VALUE(TokenKind.VALUE, 0),
PRIMITIVE(TokenKind.PRIMITIVE, 0),

// Declarations and type parameters (thus expressions)
EXTENDS(TokenKind.EXTENDS, XEXPR|XDECL), // extends
@@ -23,7 +23,7 @@

package compiler.valhalla.inlinetypes;

public final inline class MyValue1 extends MyAbstract {
public final primitive class MyValue1 extends MyAbstract {
static int s;
static final long sf = InlineTypeTest.rL;
final int x;
@@ -23,7 +23,7 @@

package compiler.valhalla.inlinetypes;

final inline class MyValue2Inline {
final primitive class MyValue2Inline {
final double d;
final long l;

@@ -57,7 +57,7 @@ public static MyValue2Inline createWithFieldsInline(double d, long l) {
}
}

public final inline class MyValue2 extends MyAbstract {
public final primitive class MyValue2 extends MyAbstract {
final int x;
final byte y;
final MyValue2Inline v;
@@ -26,7 +26,7 @@
import jdk.test.lib.Asserts;
import jdk.test.lib.Utils;

final inline class MyValue3Inline {
final primitive class MyValue3Inline {
final float f7;
final double f8;

@@ -62,7 +62,7 @@ public static MyValue3Inline createWithFieldsInline(float f7, double f8) {

// Inline type definition to stress test return of an inline type in registers
// (uses all registers of calling convention on x86_64)
public final inline class MyValue3 extends MyAbstract {
public final primitive class MyValue3 extends MyAbstract {
final char c;
final byte bb;
final short s;
@@ -24,7 +24,7 @@
package compiler.valhalla.inlinetypes;

// Inline type definition with too many fields to return in registers
final inline class MyValue4 extends MyAbstract {
final primitive class MyValue4 extends MyAbstract {
final MyValue3 v1;
final MyValue3 v2;

@@ -23,7 +23,7 @@

package compiler.valhalla.inlinetypes;

public final inline class MyValueEmpty extends MyAbstract {
public final primitive class MyValueEmpty extends MyAbstract {
public long hash() { return 0; }

public MyValueEmpty copy(MyValueEmpty other) { return other; }
@@ -23,7 +23,7 @@

package compiler.valhalla.inlinetypes;

public inline class Point {
public primitive class Point {
int x = 4;
int y = 7;
}
@@ -23,7 +23,7 @@

package compiler.valhalla.inlinetypes;

public inline class Rectangle {
public primitive class Rectangle {
Point p0 = new Point();
Point p1 = new Point();
}
}
@@ -21,7 +21,7 @@
* questions.
*/

final inline class SimpleInlineType {
final primitive class SimpleInlineType {
final int x;

private SimpleInlineType() {
@@ -33,7 +33,7 @@
import jdk.test.lib.process.OutputAnalyzer;
import jdk.test.lib.process.ProcessTools;

final inline class MyValue1 {
final primitive class MyValue1 {
public final int x = 0;
}

@@ -49,7 +49,7 @@
long val = Integer.MAX_VALUE;
}

static inline class ManyOops {
static primitive class ManyOops {
MyObject o1 = new MyObject();
MyObject o2 = new MyObject();
MyObject o3 = new MyObject();
@@ -1865,7 +1865,7 @@ public void test79_verifier(boolean warmup) {
Asserts.assertEquals(result, i);
}

inline static class NotFlattenable {
primitive static class NotFlattenable {
private final Object o1 = null;
private final Object o2 = null;
private final Object o3 = null;
@@ -2162,7 +2162,7 @@ public void test90_verifier(boolean warmup) {
Asserts.assertEQ(test90(), true);
}

inline static final class Test91Value {
primitive static final class Test91Value {
public final int f0;
public final int f1;
public final int f2;
@@ -3014,7 +3014,7 @@ public void test130_verifier(boolean warmup) {
Asserts.assertEquals(empty, MyValueEmpty.default);
}

static inline class EmptyContainer {
static primitive class EmptyContainer {
MyValueEmpty empty = MyValueEmpty.default;
}

@@ -786,12 +786,12 @@ public void test36_verifier(boolean warmup) {
}

// Test correct loading of flattened fields
inline class Test37Value2 {
primitive class Test37Value2 {
final int x = 0;
final int y = 0;
}

inline class Test37Value1 {
primitive class Test37Value1 {
final double d = 0;
final float f = 0;
final Test37Value2 v = new Test37Value2();
@@ -809,7 +809,7 @@ public void test37_verifier(boolean warmup) {
}

// Test elimination of inline type allocations without a unique CheckCastPP
inline class Test38Value {
primitive class Test38Value {
public int i;
public Test38Value(int i) { this.i = i; }
}
@@ -836,7 +836,7 @@ public void test38_verifier(boolean warmup) {
}

// Tests split if with inline type Phi users
static inline class Test39Value {
static primitive class Test39Value {
public int iFld1;
public int iFld2;

@@ -47,7 +47,7 @@
public MyInterface hash(MyInterface arg);
}

inline final class TestValue1 implements MyInterface {
primitive final class TestValue1 implements MyInterface {
final int x;

public TestValue1(int x) {
@@ -59,7 +59,7 @@ public TestValue1 hash(MyInterface arg) {
}
}

inline final class TestValue2 implements MyInterface {
primitive final class TestValue2 implements MyInterface {
final int x;

public TestValue2(int x) {
@@ -54,7 +54,7 @@
* compiler.valhalla.inlinetypes.TestBufferTearing
*/

inline class MyValue {
primitive class MyValue {
int x;
int y;

@@ -106,7 +106,7 @@ public void test1_verifier(boolean warmup) {
Asserts.assertEQ(r2, 0x1234567812345678L);
}

static inline class SimpleValue2 {
static primitive class SimpleValue2 {
final int value;
SimpleValue2(int value) {
this.value = value;
@@ -207,7 +207,7 @@ public void test6_verifier(boolean warmup) {
}

// Test 1st level sub-element access to non-flattened field
static inline class Big {
static primitive class Big {
long l0,l1,l2,l3,l4,l5,l6,l7,l8,l9,l10,l11,l12,l13,l14,l15,l16,l17,l18,l19 ;

Big(long n) {
@@ -240,7 +240,7 @@ void check(long n, int i) {
}
}

static inline class TestValue {
static primitive class TestValue {
int i;
Big big;

@@ -288,7 +288,7 @@ public void test8_verifier(boolean warmup) {
// (read/write are not performed, pre-allocated instance is used for reads)
// Most tests check that error conditions are still correctly handled
// (OOB, null pointer)
static inline class EmptyType {}
static primitive class EmptyType {}

@Test(compLevel=C1)
public EmptyType test9() {