Re: RFR: 8314488: Compile the JDK as C++17 [v3]

2023-12-19 Thread Julian Waters
> Compile the JDK as C++17, enabling the use of all C++17 language features

Julian Waters has updated the pull request with a new target base due to a 
merge or a rebase. The incremental webrev excludes the unrelated changes 
brought in by the merge/rebase. The pull request contains seven additional 
commits since the last revision:

 - Compiler versions in toolchain.m4
 - Merge branch 'openjdk:master' into patch-7
 - Merge branch 'openjdk:master' into patch-7
 - Revert vm_version_linux_riscv.cpp
 - vm_version_linux_riscv.cpp
 - allocation.cpp
 - 8310260

-

Changes:
  - all: https://git.openjdk.org/jdk/pull/14988/files
  - new: https://git.openjdk.org/jdk/pull/14988/files/a1f21bbd..477f6b94

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=jdk&pr=14988&range=02
 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=14988&range=01-02

  Stats: 2377 lines in 158 files changed: 1669 ins; 268 del; 440 mod
  Patch: https://git.openjdk.org/jdk/pull/14988.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/14988/head:pull/14988

PR: https://git.openjdk.org/jdk/pull/14988


RFR: 8317376: Minor improvements to the 'this' escape analyzer

2023-12-19 Thread Archie Cobbs
Please review several fixes and improvements to the `this-escape` lint warning 
analyzer.

The goal here is to apply some relatively simple logical fixes that improve the 
precision and accuracy of the analyzer, and capture the remaining low-hanging 
fruit so we can consider the analyzer relatively complete with respect to 
what's feasible with its current design.

Although the changes are small from a logical point of view, they generate a 
fairly large patch due to impact of refactoring (sorry!). Most of the patch 
derives from the first two changes listed below.

The changes are summarized here:

 1. Generalize how we categorize references

The `Ref` class hierarchy models the various ways in which, at any point during 
the execution of a constructor or some other method/constructor that it 
invokes, there can be live references to the original object under construction 
lying around. We then look for places where one of these `Ref`'s might be 
passed to a subclass method. In other words, the analyzer keeps track of these 
references and watches what happens to them as the code executes so it can 
catch them trying to "escape".

Previously the `Ref` categories were:
* `ThisRef` - The current instance of the (non-static) method or constructor 
being analyzed
* `OuterRef` - The current outer instance of the (non-static) method or 
constructor being analyzed
* `VarRef` - A local variable or method parameter currently in scope
* `ExprRef` - An object reference sitting on top of the Java execution stack
* `YieldRef` - The current switch expression's yield value(s)
* `ReturnRef` - The current method's return value(s)

For each of those types, we further classified the "indirection" of the 
reference, i.e., whether the reference was direct (from the thing itself) or 
indirect (from something the thing referenced).

The problem with that hierarchy is that we could only track outer instance 
references that happened to be associated with the current instance. So we 
might know that `this` had an outer instance reference, but if we said `var x = 
this` we wouldn't know that `x` had an outer instance reference.

In other words, we should be treating "via an outer instance" as just another 
flavor of indirection along with "direct" and "indirect".

As a result, with this patch the `OuterRef` class goes away and a new 
`Indirection` enum has been created, with values `DIRECT`, `INDIRECT`, and 
`OUTER`.

 2. Track the types of all references

By keeping track of the actual type of each reference (as opposed to just 
looking at its compile-time type), we can make more precise calculations. We 
weren't doing this before.

For example consider this class:

public class Leaker {

public Leaker() {
Runnable r = new Runnable() {
public void run() {
Leaker.this.mightLeak();
}
};
r.run();   // there is a leak here
}

protected void mightLeak() {
// a subclass could override this method
}
}

Previously we would not have detected a 'this' escape because we wouldn't have 
known that variable `r` is a `Leaker$1`, which allows us to deduce that 
`r.run()` is actually `Leaker$1.run()` (which we can analyze) instead of just 
`Runnable.run()` (which we can't).

Because of this change, some `Ref` types that were previously singletons are no 
longer singletons. For example, now there can be more than one `ReturnRef` in 
scope at any time, representing different possible types for the method's 
return value.

 3. Handling of non-public outer instances

To eliminate some false positives, we no longer warn if a leak happens solely 
due to a "non-public" outer instance.

For example, consider this code:

public class Test {

public Test() {
System.out.println(new Inner());
}   

private class Inner {
Object getMyOuter() {
return Test.this;
}
}
}

The outer `Test` instance associated with objects of type `Test.Inner` is 
considered "non-public" because it's not directly accessible to the outside 
world (because `Test.Inner` is a private class). So while it's true that 
instances of `Test.Inner` retain a reference to their enclosing instance, an 
unrelated method like `System.out.println()` wouldn't know how to access them. 
The only way a `Test.Inner` could leak its outer instance to such a method is 
if it did so (perhaps indirectly) through some entrée that the method "knows 
about". Of course, that's possible, but absent any further analysis (which 
could be added in the future), the cost/reward trade-off doesn't seem worth 
generating a warning here.

This is an area for future research. In other words: when a `Ref` is passed to 
unknown code, when is it worth complaining about a leak, and when should we 
just be silent? Previously we always complained, but now that we have more 
information about references (namely, their types) we can be a little more 
discriminating.

In any case, th

Integrated: 8322309: Fix an inconsistancy in spacing style in spec.gmk.template

2023-12-19 Thread Frederic Thevenet
On Mon, 18 Dec 2023 17:06:51 GMT, Frederic Thevenet  
wrote:

> [JDK-8320763](https://bugs.openjdk.org/browse/JDK-8320763) fixed the 
> consistency of spaces around the assignment operators in spec.gmk.in (as it 
> was called then).
> Unfortunately [JDK-8321374](https://bugs.openjdk.org/browse/JDK-8321374) 
> re-introduced one such inconsistency and so this follow-up aims to fix this.

This pull request has now been integrated.

Changeset: 3bc5679c
Author:Frederic Thevenet 
Committer: Severin Gehwolf 
URL:   
https://git.openjdk.org/jdk/commit/3bc5679cab03936005be02e7b8140d549396d5e2
Stats: 1 line in 1 file changed: 0 ins; 0 del; 1 mod

8322309: Fix an inconsistancy in spacing style in spec.gmk.template

Reviewed-by: sgehwolf, erikj

-

PR: https://git.openjdk.org/jdk/pull/17149


Re: RFR: 8322309: Fix an inconsistancy in spacing style in spec.gmk.template

2023-12-19 Thread Erik Joelsson
On Mon, 18 Dec 2023 17:06:51 GMT, Frederic Thevenet  
wrote:

> [JDK-8320763](https://bugs.openjdk.org/browse/JDK-8320763) fixed the 
> consistency of spaces around the assignment operators in spec.gmk.in (as it 
> was called then).
> Unfortunately [JDK-8321374](https://bugs.openjdk.org/browse/JDK-8321374) 
> re-introduced one such inconsistency and so this follow-up aims to fix this.

Marked as reviewed by erikj (Reviewer).

-

PR Review: https://git.openjdk.org/jdk/pull/17149#pullrequestreview-1788900164


Re: RFR: 8322309: Fix an inconsistancy in spacing style in spec.gmk.template

2023-12-19 Thread Severin Gehwolf
On Mon, 18 Dec 2023 17:06:51 GMT, Frederic Thevenet  
wrote:

> [JDK-8320763](https://bugs.openjdk.org/browse/JDK-8320763) fixed the 
> consistency of spaces around the assignment operators in spec.gmk.in (as it 
> was called then).
> Unfortunately [JDK-8321374](https://bugs.openjdk.org/browse/JDK-8321374) 
> re-introduced one such inconsistency and so this follow-up aims to fix this.

Looks good (and trivial).

-

Marked as reviewed by sgehwolf (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/17149#pullrequestreview-1788823609