Re: RFR: 8332111: [BACKOUT] A way to align already compiled methods with compiler directives

2024-05-14 Thread Dmitry Chuyko
On Mon, 13 May 2024 21:08:08 GMT, Evgeny Astigeevich  
wrote:

>> Backout of [JDK-8309271](https://bugs.openjdk.org/browse/JDK-8309271) which 
>> has known bugs, possible bugs and performance issues. REDO work is tracked 
>> by [JDK-8331749](https://bugs.openjdk.org/browse/JDK-8331749).
>> 
>> Found bugs:
>> - When refreshing `CompilerDirectivesAddDCmd::execute` will call 
>> `DirectivesStack::hasMatchingDirectives(mh, true)` which only considers the 
>> compiler directive which is on the top of the directives stack. As more than 
>> one directive can be added, `CompilerDirectivesAddDCmd::execute` will not 
>> behave as expected.
>> - A Java method with old directives might be in the compilation queue. A 
>> request to recompile it with new directives will be ignored.
>> 
>> There are other concerns: bugs and performance issues.
>> 
>> Possible bugs:
>> - `has_matching_directives` might not be cleared. A nmethod might get into 
>> the unloading state before `CodeCache::recompile_marked_directives_matches`. 
>> If the nmethod has been used to mark a Java method and it is the only 
>> nmethod, there will be no nmethod in CodeCache to reach the Java method to 
>> clear the mark.
>> - A Java method might have been compiled with new directives before 
>> `CodeCache::recompile_marked_directives_matches`. 
>> `CodeCache::recompile_marked_directives_matches` will recompile it again.
>> - JIT compiler might be compiling a Java method with old directives. A 
>> request to recompile it with new directives will be ignored.
>> 
>> Performance issues:
>> - Usually directives are updated for a small number of Java methods. If 
>> CodeCache has thousands of nmethods, 
>> `CodeCache::recompile_marked_directives_matches` will be traversing nmethods 
>> most of which don't need recompilation.
>> 
>> The backout is not clean because of removal of `CompiledMethod`.
>> 
>> Tested with release and fastdebug builds: tier1  and tier2 passed.
>
> What if instead of backing out we will use an experimental JVM flag: 
> `XX:+CompilerDirectivesRefreshSupport`?

> I agree with this backout. Thank you @eastig for explaining your point. We 
> have about 3 weeks before RDP1 and it is better we have less issues before 
> that. Let redo implementation in next release taking into account the issues 
> you found and have more time for testing.

OK. I hope it takes less time to get back into the source tree than it did 
initially.

-

PR Comment: https://git.openjdk.org/jdk/pull/19215#issuecomment-2109874596


Re: RFR: 8332111: [BACKOUT] A way to align already compiled methods with compiler directives

2024-05-13 Thread Dmitry Chuyko
On Mon, 13 May 2024 14:21:35 GMT, Evgeny Astigeevich  
wrote:

> > Are there any high severity problems caused by the original PR? Especially 
> > not in the new functionality. Minor issues could be probably addressed 
> > without backing out the entire functionality.
> 
> 
> 
> Yes, there are:
> 
> 
> 
> > 1. Usually directives are updated for a small number of Java methods. If 
> > CodeCache has thousands of nmethods, 
> > CodeCache::recompile_marked_directives_matches will be traversing nmethods 
> > most of which don't need recompilation.
> 
> > 2. has_matching_directives might not be cleared. 
> 
> > 3. A Java method is not recompiled as requested.
> 
> 

So there are cases when new functionality doesn't work as expected (I don't see 
any other users impacted). Why not file bugs for those cases and estimate their 
impact?

-

PR Comment: https://git.openjdk.org/jdk/pull/19215#issuecomment-210980


Re: RFR: 8332111: [BACKOUT] A way to align already compiled methods with compiler directives

2024-05-13 Thread Dmitry Chuyko
On Mon, 13 May 2024 13:03:26 GMT, Evgeny Astigeevich  
wrote:

> Backout of [JDK-8309271](https://bugs.openjdk.org/browse/JDK-8309271) which 
> has known bugs, possible bugs and performance issues. REDO work is tracked by 
> [JDK-8331749](https://bugs.openjdk.org/browse/JDK-8331749).
> 
> Found bugs:
> - When refreshing `CompilerDirectivesAddDCmd::execute` will call 
> `DirectivesStack::hasMatchingDirectives(mh, true)` which only considers the 
> compiler directive which is on the top of the directives stack. As more than 
> one directive can be added, `CompilerDirectivesAddDCmd::execute` will not 
> behave as expected.
> - A Java method with old directives might be in the compilation queue. A 
> request to recompile it with new directives will be ignored.
> 
> There are other concerns: bugs and performance issues.
> 
> Possible bugs:
> - `has_matching_directives` might not be cleared. A nmethod might get into 
> the unloading state before `CodeCache::recompile_marked_directives_matches`. 
> If the nmethod has been used to mark a Java method and it is the only 
> nmethod, there will be no nmethod in CodeCache to reach the Java method to 
> clear the mark.
> - A Java method might have been compiled with new directives before 
> `CodeCache::recompile_marked_directives_matches`. 
> `CodeCache::recompile_marked_directives_matches` will recompile it again.
> - JIT compiler might be compiling a Java method with old directives. A 
> request to recompile it with new directives will be ignored.
> 
> Performance issues:
> - Usually directives are updated for a small number of Java methods. If 
> CodeCache has thousands of nmethods, 
> `CodeCache::recompile_marked_directives_matches` will be traversing nmethods 
> most of which don't need recompilation.
> 
> The backout is not clean because of removal of `CompiledMethod`.
> 
> Tested with release and fastdebug builds: tier1  and tier2 passed.

Are there any high severity problems caused by the original PR? Especially not 
in the new functionality. Minor issues could be probably addressed without 
backing out the entire functionality.

-

PR Comment: https://git.openjdk.org/jdk/pull/19215#issuecomment-2107638223


Integrated: 8309271: A way to align already compiled methods with compiler directives

2024-03-14 Thread Dmitry Chuyko
On Wed, 24 May 2023 00:38:27 GMT, Dmitry Chuyko  wrote:

> Compiler Control (https://openjdk.org/jeps/165) provides method-context 
> dependent control of the JVM compilers (C1 and C2). The active directive 
> stack is built from the directive files passed with the 
> `-XX:CompilerDirectivesFile` diagnostic command-line option and the 
> Compiler.add_directives diagnostic command. It is also possible to clear all 
> directives or remove the top from the stack.
> 
> A matching directive will be applied at method compilation time when such 
> compilation is started. If directives are added or changed, but compilation 
> does not start, then the state of compiled methods doesn't correspond to the 
> rules. This is not an error, and it happens in long running applications when 
> directives are added or removed after compilation of methods that could be 
> matched. For example, the user decides that C2 compilation needs to be 
> disabled for some method due to a compiler bug, issues such a directive but 
> this does not affect the application behavior. In such case, the target 
> application needs to be restarted, and such an operation can have high costs 
> and risks. Another goal is testing/debugging compilers.
> 
> It would be convenient to optionally reconcile at least existing matching 
> nmethods to the current stack of compiler directives (so bypass inlined 
> methods).
> 
> Natural way to eliminate the discrepancy between the result of compilation 
> and the broken rule is to discard the compilation result, i.e. 
> deoptimization. Prior to that we can try to re-compile the method letting 
> compile broker to perform it taking new directives stack into account. 
> Re-compilation helps to prevent hot methods from execution in the interpreter.
> 
> A new flag `-r` has beed introduced for some directives related to compile 
> commands: `Compiler.add_directives`, `Compiler.remove_directives`, 
> `Compiler.clear_directives`. The default behavior has not changed (no flag). 
> If the new flag is present, the command scans already compiled methods and 
> puts methods that have any active non-default matching compiler directives to 
> re-compilation if possible, otherwise marks them for deoptimization. There is 
> currently no distinction which directives are found. In particular, this 
> means that if there are rules for inlining into some method, it will be 
> refreshed. On the other hand, if there are rules for a method and it was 
> inlined, top-level methods won't be refreshed, but this can be achieved by 
> having rules for them.
> 
> In addition, a new diagnostic command `Compiler.replace_directives`, has been 
> added for ...

This pull request has now been integrated.

Changeset: c879627d
Author:Dmitry Chuyko 
URL:   
https://git.openjdk.org/jdk/commit/c879627dbd7e9295d44f19ef237edb5de10805d5
Stats: 381 lines in 15 files changed: 348 ins; 3 del; 30 mod

8309271: A way to align already compiled methods with compiler directives

Reviewed-by: apangin, sspitsyn, tholenstein

-

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


Re: RFR: 8309271: A way to align already compiled methods with compiler directives [v32]

2024-03-14 Thread Dmitry Chuyko
> Compiler Control (https://openjdk.org/jeps/165) provides method-context 
> dependent control of the JVM compilers (C1 and C2). The active directive 
> stack is built from the directive files passed with the 
> `-XX:CompilerDirectivesFile` diagnostic command-line option and the 
> Compiler.add_directives diagnostic command. It is also possible to clear all 
> directives or remove the top from the stack.
> 
> A matching directive will be applied at method compilation time when such 
> compilation is started. If directives are added or changed, but compilation 
> does not start, then the state of compiled methods doesn't correspond to the 
> rules. This is not an error, and it happens in long running applications when 
> directives are added or removed after compilation of methods that could be 
> matched. For example, the user decides that C2 compilation needs to be 
> disabled for some method due to a compiler bug, issues such a directive but 
> this does not affect the application behavior. In such case, the target 
> application needs to be restarted, and such an operation can have high costs 
> and risks. Another goal is testing/debugging compilers.
> 
> It would be convenient to optionally reconcile at least existing matching 
> nmethods to the current stack of compiler directives (so bypass inlined 
> methods).
> 
> Natural way to eliminate the discrepancy between the result of compilation 
> and the broken rule is to discard the compilation result, i.e. 
> deoptimization. Prior to that we can try to re-compile the method letting 
> compile broker to perform it taking new directives stack into account. 
> Re-compilation helps to prevent hot methods from execution in the interpreter.
> 
> A new flag `-r` has beed introduced for some directives related to compile 
> commands: `Compiler.add_directives`, `Compiler.remove_directives`, 
> `Compiler.clear_directives`. The default behavior has not changed (no flag). 
> If the new flag is present, the command scans already compiled methods and 
> puts methods that have any active non-default matching compiler directives to 
> re-compilation if possible, otherwise marks them for deoptimization. There is 
> currently no distinction which directives are found. In particular, this 
> means that if there are rules for inlining into some method, it will be 
> refreshed. On the other hand, if there are rules for a method and it was 
> inlined, top-level methods won't be refreshed, but this can be achieved by 
> having rules for them.
> 
> In addition, a new diagnostic command `Compiler.replace_directives`, has been 
> added for ...

Dmitry Chuyko has updated the pull request with a new target base due to a 
merge or a rebase. The pull request now contains 50 commits:

 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - No dots in -r descriptions
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Resolved master conflicts
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - ... and 40 more: https://git.openjdk.org/jdk/compare/49ce85fa...eb4ed2ea

-

Changes: https://git.openjdk.org/jdk/pull/14111/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=14111&range=31
  Stats: 381 lines in 15 files changed: 348 ins; 3 del; 30 mod
  Patch: https://git.openjdk.org/jdk/pull/14111.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/14111/head:pull/14111

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


Re: RFR: 8309271: A way to align already compiled methods with compiler directives [v31]

2024-03-14 Thread Dmitry Chuyko
On Wed, 13 Mar 2024 17:31:32 GMT, Dmitry Chuyko  wrote:

>> Compiler Control (https://openjdk.org/jeps/165) provides method-context 
>> dependent control of the JVM compilers (C1 and C2). The active directive 
>> stack is built from the directive files passed with the 
>> `-XX:CompilerDirectivesFile` diagnostic command-line option and the 
>> Compiler.add_directives diagnostic command. It is also possible to clear all 
>> directives or remove the top from the stack.
>> 
>> A matching directive will be applied at method compilation time when such 
>> compilation is started. If directives are added or changed, but compilation 
>> does not start, then the state of compiled methods doesn't correspond to the 
>> rules. This is not an error, and it happens in long running applications 
>> when directives are added or removed after compilation of methods that could 
>> be matched. For example, the user decides that C2 compilation needs to be 
>> disabled for some method due to a compiler bug, issues such a directive but 
>> this does not affect the application behavior. In such case, the target 
>> application needs to be restarted, and such an operation can have high costs 
>> and risks. Another goal is testing/debugging compilers.
>> 
>> It would be convenient to optionally reconcile at least existing matching 
>> nmethods to the current stack of compiler directives (so bypass inlined 
>> methods).
>> 
>> Natural way to eliminate the discrepancy between the result of compilation 
>> and the broken rule is to discard the compilation result, i.e. 
>> deoptimization. Prior to that we can try to re-compile the method letting 
>> compile broker to perform it taking new directives stack into account. 
>> Re-compilation helps to prevent hot methods from execution in the 
>> interpreter.
>> 
>> A new flag `-r` has beed introduced for some directives related to compile 
>> commands: `Compiler.add_directives`, `Compiler.remove_directives`, 
>> `Compiler.clear_directives`. The default behavior has not changed (no flag). 
>> If the new flag is present, the command scans already compiled methods and 
>> puts methods that have any active non-default matching compiler directives 
>> to re-compilation if possible, otherwise marks them for deoptimization. 
>> There is currently no distinction which directives are found. In particular, 
>> this means that if there are rules for inlining into some method, it will be 
>> refreshed. On the other hand, if there are rules for a method and it was 
>> inlined, top-level methods won't be refreshed, but this can be achieved by 
>> having rules for them.
>> 
>> In addition, a new diagnostic command `Compiler.replace_directives...
>
> Dmitry Chuyko has updated the pull request incrementally with one additional 
> commit since the last revision:
> 
>   No dots in -r descriptions

Thank you, Seguei and Tobias.

-

PR Comment: https://git.openjdk.org/jdk/pull/14111#issuecomment-1996995661


Re: RFR: 8309271: A way to align already compiled methods with compiler directives [v29]

2024-03-13 Thread Dmitry Chuyko
On Wed, 13 Mar 2024 07:48:35 GMT, Serguei Spitsyn  wrote:

>> Dmitry Chuyko has updated the pull request with a new target base due to a 
>> merge or a rebase. The pull request now contains 47 commits:
>> 
>>  - Resolved master conflicts
>>  - Merge branch 'openjdk:master' into compiler-directives-force-update
>>  - Merge branch 'openjdk:master' into compiler-directives-force-update
>>  - Merge branch 'openjdk:master' into compiler-directives-force-update
>>  - Merge branch 'openjdk:master' into compiler-directives-force-update
>>  - Merge branch 'openjdk:master' into compiler-directives-force-update
>>  - Merge branch 'openjdk:master' into compiler-directives-force-update
>>  - Merge branch 'openjdk:master' into compiler-directives-force-update
>>  - Merge branch 'openjdk:master' into compiler-directives-force-update
>>  - Merge branch 'openjdk:master' into compiler-directives-force-update
>>  - ... and 37 more: https://git.openjdk.org/jdk/compare/782206bc...ff39ac12
>
> src/hotspot/share/services/diagnosticCommand.cpp line 928:
> 
>> 926:DCmdWithParser(output, heap),
>> 927:   _filename("filename", "Name of the directives file", "STRING", true),
>> 928:   _refresh("-r", "Refresh affected methods.", "BOOLEAN", false, 
>> "false") {
> 
> Nit: The dot is not needed at the end, I think. The same applies to lines: 
> 945, 970 and 987.

Thanks, the dots were removed.

-

PR Review Comment: https://git.openjdk.org/jdk/pull/14111#discussion_r1523664980


Re: RFR: 8309271: A way to align already compiled methods with compiler directives [v31]

2024-03-13 Thread Dmitry Chuyko
> Compiler Control (https://openjdk.org/jeps/165) provides method-context 
> dependent control of the JVM compilers (C1 and C2). The active directive 
> stack is built from the directive files passed with the 
> `-XX:CompilerDirectivesFile` diagnostic command-line option and the 
> Compiler.add_directives diagnostic command. It is also possible to clear all 
> directives or remove the top from the stack.
> 
> A matching directive will be applied at method compilation time when such 
> compilation is started. If directives are added or changed, but compilation 
> does not start, then the state of compiled methods doesn't correspond to the 
> rules. This is not an error, and it happens in long running applications when 
> directives are added or removed after compilation of methods that could be 
> matched. For example, the user decides that C2 compilation needs to be 
> disabled for some method due to a compiler bug, issues such a directive but 
> this does not affect the application behavior. In such case, the target 
> application needs to be restarted, and such an operation can have high costs 
> and risks. Another goal is testing/debugging compilers.
> 
> It would be convenient to optionally reconcile at least existing matching 
> nmethods to the current stack of compiler directives (so bypass inlined 
> methods).
> 
> Natural way to eliminate the discrepancy between the result of compilation 
> and the broken rule is to discard the compilation result, i.e. 
> deoptimization. Prior to that we can try to re-compile the method letting 
> compile broker to perform it taking new directives stack into account. 
> Re-compilation helps to prevent hot methods from execution in the interpreter.
> 
> A new flag `-r` has beed introduced for some directives related to compile 
> commands: `Compiler.add_directives`, `Compiler.remove_directives`, 
> `Compiler.clear_directives`. The default behavior has not changed (no flag). 
> If the new flag is present, the command scans already compiled methods and 
> puts methods that have any active non-default matching compiler directives to 
> re-compilation if possible, otherwise marks them for deoptimization. There is 
> currently no distinction which directives are found. In particular, this 
> means that if there are rules for inlining into some method, it will be 
> refreshed. On the other hand, if there are rules for a method and it was 
> inlined, top-level methods won't be refreshed, but this can be achieved by 
> having rules for them.
> 
> In addition, a new diagnostic command `Compiler.replace_directives`, has been 
> added for ...

Dmitry Chuyko has updated the pull request incrementally with one additional 
commit since the last revision:

  No dots in -r descriptions

-

Changes:
  - all: https://git.openjdk.org/jdk/pull/14111/files
  - new: https://git.openjdk.org/jdk/pull/14111/files/22b42347..36c30367

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=jdk&pr=14111&range=30
 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=14111&range=29-30

  Stats: 4 lines in 1 file changed: 0 ins; 0 del; 4 mod
  Patch: https://git.openjdk.org/jdk/pull/14111.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/14111/head:pull/14111

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


Re: RFR: 8309271: A way to align already compiled methods with compiler directives [v30]

2024-03-13 Thread Dmitry Chuyko
> Compiler Control (https://openjdk.org/jeps/165) provides method-context 
> dependent control of the JVM compilers (C1 and C2). The active directive 
> stack is built from the directive files passed with the 
> `-XX:CompilerDirectivesFile` diagnostic command-line option and the 
> Compiler.add_directives diagnostic command. It is also possible to clear all 
> directives or remove the top from the stack.
> 
> A matching directive will be applied at method compilation time when such 
> compilation is started. If directives are added or changed, but compilation 
> does not start, then the state of compiled methods doesn't correspond to the 
> rules. This is not an error, and it happens in long running applications when 
> directives are added or removed after compilation of methods that could be 
> matched. For example, the user decides that C2 compilation needs to be 
> disabled for some method due to a compiler bug, issues such a directive but 
> this does not affect the application behavior. In such case, the target 
> application needs to be restarted, and such an operation can have high costs 
> and risks. Another goal is testing/debugging compilers.
> 
> It would be convenient to optionally reconcile at least existing matching 
> nmethods to the current stack of compiler directives (so bypass inlined 
> methods).
> 
> Natural way to eliminate the discrepancy between the result of compilation 
> and the broken rule is to discard the compilation result, i.e. 
> deoptimization. Prior to that we can try to re-compile the method letting 
> compile broker to perform it taking new directives stack into account. 
> Re-compilation helps to prevent hot methods from execution in the interpreter.
> 
> A new flag `-r` has beed introduced for some directives related to compile 
> commands: `Compiler.add_directives`, `Compiler.remove_directives`, 
> `Compiler.clear_directives`. The default behavior has not changed (no flag). 
> If the new flag is present, the command scans already compiled methods and 
> puts methods that have any active non-default matching compiler directives to 
> re-compilation if possible, otherwise marks them for deoptimization. There is 
> currently no distinction which directives are found. In particular, this 
> means that if there are rules for inlining into some method, it will be 
> refreshed. On the other hand, if there are rules for a method and it was 
> inlined, top-level methods won't be refreshed, but this can be achieved by 
> having rules for them.
> 
> In addition, a new diagnostic command `Compiler.replace_directives`, has been 
> added for ...

Dmitry Chuyko has updated the pull request with a new target base due to a 
merge or a rebase. The pull request now contains 48 commits:

 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Resolved master conflicts
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - ... and 38 more: https://git.openjdk.org/jdk/compare/5cae7d20...22b42347

-

Changes: https://git.openjdk.org/jdk/pull/14111/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=14111&range=29
  Stats: 381 lines in 15 files changed: 348 ins; 3 del; 30 mod
  Patch: https://git.openjdk.org/jdk/pull/14111.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/14111/head:pull/14111

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


Re: RFR: 8309271: A way to align already compiled methods with compiler directives [v29]

2024-03-13 Thread Dmitry Chuyko
On Wed, 13 Mar 2024 07:43:35 GMT, Serguei Spitsyn  wrote:

>> Dmitry Chuyko has updated the pull request with a new target base due to a 
>> merge or a rebase. The pull request now contains 47 commits:
>> 
>>  - Resolved master conflicts
>>  - Merge branch 'openjdk:master' into compiler-directives-force-update
>>  - Merge branch 'openjdk:master' into compiler-directives-force-update
>>  - Merge branch 'openjdk:master' into compiler-directives-force-update
>>  - Merge branch 'openjdk:master' into compiler-directives-force-update
>>  - Merge branch 'openjdk:master' into compiler-directives-force-update
>>  - Merge branch 'openjdk:master' into compiler-directives-force-update
>>  - Merge branch 'openjdk:master' into compiler-directives-force-update
>>  - Merge branch 'openjdk:master' into compiler-directives-force-update
>>  - Merge branch 'openjdk:master' into compiler-directives-force-update
>>  - ... and 37 more: https://git.openjdk.org/jdk/compare/782206bc...ff39ac12
>
> src/hotspot/share/ci/ciEnv.cpp line 1144:
> 
>> 1142: 
>> 1143:   if (entry_bci == InvocationEntryBci) {
>> 1144: if (TieredCompilation) {
> 
> Just a naive question. Why this check has been removed?

We want to let replacement of C2 method version by another C2 version of the 
same method in both tired and non-tired mode, which was not allowed

-

PR Review Comment: https://git.openjdk.org/jdk/pull/14111#discussion_r1523618332


Re: RFR: 8309271: A way to align already compiled methods with compiler directives [v29]

2024-03-12 Thread Dmitry Chuyko
> Compiler Control (https://openjdk.org/jeps/165) provides method-context 
> dependent control of the JVM compilers (C1 and C2). The active directive 
> stack is built from the directive files passed with the 
> `-XX:CompilerDirectivesFile` diagnostic command-line option and the 
> Compiler.add_directives diagnostic command. It is also possible to clear all 
> directives or remove the top from the stack.
> 
> A matching directive will be applied at method compilation time when such 
> compilation is started. If directives are added or changed, but compilation 
> does not start, then the state of compiled methods doesn't correspond to the 
> rules. This is not an error, and it happens in long running applications when 
> directives are added or removed after compilation of methods that could be 
> matched. For example, the user decides that C2 compilation needs to be 
> disabled for some method due to a compiler bug, issues such a directive but 
> this does not affect the application behavior. In such case, the target 
> application needs to be restarted, and such an operation can have high costs 
> and risks. Another goal is testing/debugging compilers.
> 
> It would be convenient to optionally reconcile at least existing matching 
> nmethods to the current stack of compiler directives (so bypass inlined 
> methods).
> 
> Natural way to eliminate the discrepancy between the result of compilation 
> and the broken rule is to discard the compilation result, i.e. 
> deoptimization. Prior to that we can try to re-compile the method letting 
> compile broker to perform it taking new directives stack into account. 
> Re-compilation helps to prevent hot methods from execution in the interpreter.
> 
> A new flag `-r` has beed introduced for some directives related to compile 
> commands: `Compiler.add_directives`, `Compiler.remove_directives`, 
> `Compiler.clear_directives`. The default behavior has not changed (no flag). 
> If the new flag is present, the command scans already compiled methods and 
> puts methods that have any active non-default matching compiler directives to 
> re-compilation if possible, otherwise marks them for deoptimization. There is 
> currently no distinction which directives are found. In particular, this 
> means that if there are rules for inlining into some method, it will be 
> refreshed. On the other hand, if there are rules for a method and it was 
> inlined, top-level methods won't be refreshed, but this can be achieved by 
> having rules for them.
> 
> In addition, a new diagnostic command `Compiler.replace_directives`, has been 
> added for ...

Dmitry Chuyko has updated the pull request with a new target base due to a 
merge or a rebase. The pull request now contains 47 commits:

 - Resolved master conflicts
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - ... and 37 more: https://git.openjdk.org/jdk/compare/782206bc...ff39ac12

-

Changes: https://git.openjdk.org/jdk/pull/14111/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=14111&range=28
  Stats: 381 lines in 15 files changed: 348 ins; 3 del; 30 mod
  Patch: https://git.openjdk.org/jdk/pull/14111.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/14111/head:pull/14111

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


Re: RFR: 8309271: A way to align already compiled methods with compiler directives [v28]

2024-03-04 Thread Dmitry Chuyko
> Compiler Control (https://openjdk.org/jeps/165) provides method-context 
> dependent control of the JVM compilers (C1 and C2). The active directive 
> stack is built from the directive files passed with the 
> `-XX:CompilerDirectivesFile` diagnostic command-line option and the 
> Compiler.add_directives diagnostic command. It is also possible to clear all 
> directives or remove the top from the stack.
> 
> A matching directive will be applied at method compilation time when such 
> compilation is started. If directives are added or changed, but compilation 
> does not start, then the state of compiled methods doesn't correspond to the 
> rules. This is not an error, and it happens in long running applications when 
> directives are added or removed after compilation of methods that could be 
> matched. For example, the user decides that C2 compilation needs to be 
> disabled for some method due to a compiler bug, issues such a directive but 
> this does not affect the application behavior. In such case, the target 
> application needs to be restarted, and such an operation can have high costs 
> and risks. Another goal is testing/debugging compilers.
> 
> It would be convenient to optionally reconcile at least existing matching 
> nmethods to the current stack of compiler directives (so bypass inlined 
> methods).
> 
> Natural way to eliminate the discrepancy between the result of compilation 
> and the broken rule is to discard the compilation result, i.e. 
> deoptimization. Prior to that we can try to re-compile the method letting 
> compile broker to perform it taking new directives stack into account. 
> Re-compilation helps to prevent hot methods from execution in the interpreter.
> 
> A new flag `-r` has beed introduced for some directives related to compile 
> commands: `Compiler.add_directives`, `Compiler.remove_directives`, 
> `Compiler.clear_directives`. The default behavior has not changed (no flag). 
> If the new flag is present, the command scans already compiled methods and 
> puts methods that have any active non-default matching compiler directives to 
> re-compilation if possible, otherwise marks them for deoptimization. There is 
> currently no distinction which directives are found. In particular, this 
> means that if there are rules for inlining into some method, it will be 
> refreshed. On the other hand, if there are rules for a method and it was 
> inlined, top-level methods won't be refreshed, but this can be achieved by 
> having rules for them.
> 
> In addition, a new diagnostic command `Compiler.replace_directives`, has been 
> added for ...

Dmitry Chuyko has updated the pull request with a new target base due to a 
merge or a rebase. The pull request now contains 46 commits:

 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Deopt osr, cleanups
 - ... and 36 more: https://git.openjdk.org/jdk/compare/59529a92...a4578277

-

Changes: https://git.openjdk.org/jdk/pull/14111/files
 Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=14111&range=27
  Stats: 381 lines in 15 files changed: 348 ins; 3 del; 30 mod
  Patch: https://git.openjdk.org/jdk/pull/14111.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/14111/head:pull/14111

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


Re: RFR: 8309271: A way to align already compiled methods with compiler directives [v27]

2024-02-28 Thread Dmitry Chuyko
> Compiler Control (https://openjdk.org/jeps/165) provides method-context 
> dependent control of the JVM compilers (C1 and C2). The active directive 
> stack is built from the directive files passed with the 
> `-XX:CompilerDirectivesFile` diagnostic command-line option and the 
> Compiler.add_directives diagnostic command. It is also possible to clear all 
> directives or remove the top from the stack.
> 
> A matching directive will be applied at method compilation time when such 
> compilation is started. If directives are added or changed, but compilation 
> does not start, then the state of compiled methods doesn't correspond to the 
> rules. This is not an error, and it happens in long running applications when 
> directives are added or removed after compilation of methods that could be 
> matched. For example, the user decides that C2 compilation needs to be 
> disabled for some method due to a compiler bug, issues such a directive but 
> this does not affect the application behavior. In such case, the target 
> application needs to be restarted, and such an operation can have high costs 
> and risks. Another goal is testing/debugging compilers.
> 
> It would be convenient to optionally reconcile at least existing matching 
> nmethods to the current stack of compiler directives (so bypass inlined 
> methods).
> 
> Natural way to eliminate the discrepancy between the result of compilation 
> and the broken rule is to discard the compilation result, i.e. 
> deoptimization. Prior to that we can try to re-compile the method letting 
> compile broker to perform it taking new directives stack into account. 
> Re-compilation helps to prevent hot methods from execution in the interpreter.
> 
> A new flag `-r` has beed introduced for some directives related to compile 
> commands: `Compiler.add_directives`, `Compiler.remove_directives`, 
> `Compiler.clear_directives`. The default behavior has not changed (no flag). 
> If the new flag is present, the command scans already compiled methods and 
> puts methods that have any active non-default matching compiler directives to 
> re-compilation if possible, otherwise marks them for deoptimization. There is 
> currently no distinction which directives are found. In particular, this 
> means that if there are rules for inlining into some method, it will be 
> refreshed. On the other hand, if there are rules for a method and it was 
> inlined, top-level methods won't be refreshed, but this can be achieved by 
> having rules for them.
> 
> In addition, a new diagnostic command `Compiler.replace_directives`, has been 
> added for ...

Dmitry Chuyko has updated the pull request with a new target base due to a 
merge or a rebase. The pull request now contains 45 commits:

 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Deopt osr, cleanups
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - ... and 35 more: https://git.openjdk.org/jdk/compare/be2b92bd...9f1ea65d

-

Changes: https://git.openjdk.org/jdk/pull/14111/files
 Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=14111&range=26
  Stats: 381 lines in 15 files changed: 348 ins; 3 del; 30 mod
  Patch: https://git.openjdk.org/jdk/pull/14111.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/14111/head:pull/14111

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


Re: RFR: 8309271: A way to align already compiled methods with compiler directives [v26]

2024-02-26 Thread Dmitry Chuyko
On Sat, 24 Feb 2024 11:22:17 GMT, Dmitry Chuyko  wrote:

>> Compiler Control (https://openjdk.org/jeps/165) provides method-context 
>> dependent control of the JVM compilers (C1 and C2). The active directive 
>> stack is built from the directive files passed with the 
>> `-XX:CompilerDirectivesFile` diagnostic command-line option and the 
>> Compiler.add_directives diagnostic command. It is also possible to clear all 
>> directives or remove the top from the stack.
>> 
>> A matching directive will be applied at method compilation time when such 
>> compilation is started. If directives are added or changed, but compilation 
>> does not start, then the state of compiled methods doesn't correspond to the 
>> rules. This is not an error, and it happens in long running applications 
>> when directives are added or removed after compilation of methods that could 
>> be matched. For example, the user decides that C2 compilation needs to be 
>> disabled for some method due to a compiler bug, issues such a directive but 
>> this does not affect the application behavior. In such case, the target 
>> application needs to be restarted, and such an operation can have high costs 
>> and risks. Another goal is testing/debugging compilers.
>> 
>> It would be convenient to optionally reconcile at least existing matching 
>> nmethods to the current stack of compiler directives (so bypass inlined 
>> methods).
>> 
>> Natural way to eliminate the discrepancy between the result of compilation 
>> and the broken rule is to discard the compilation result, i.e. 
>> deoptimization. Prior to that we can try to re-compile the method letting 
>> compile broker to perform it taking new directives stack into account. 
>> Re-compilation helps to prevent hot methods from execution in the 
>> interpreter.
>> 
>> A new flag `-r` has beed introduced for some directives related to compile 
>> commands: `Compiler.add_directives`, `Compiler.remove_directives`, 
>> `Compiler.clear_directives`. The default behavior has not changed (no flag). 
>> If the new flag is present, the command scans already compiled methods and 
>> puts methods that have any active non-default matching compiler directives 
>> to re-compilation if possible, otherwise marks them for deoptimization. 
>> There is currently no distinction which directives are found. In particular, 
>> this means that if there are rules for inlining into some method, it will be 
>> refreshed. On the other hand, if there are rules for a method and it was 
>> inlined, top-level methods won't be refreshed, but this can be achieved by 
>> having rules for them.
>> 
>> In addition, a new diagnostic command `Compiler.replace_directives...
>
> Dmitry Chuyko has updated the pull request with a new target base due to a 
> merge or a rebase. The pull request now contains 44 commits:
> 
>  - Merge branch 'openjdk:master' into compiler-directives-force-update
>  - Merge branch 'openjdk:master' into compiler-directives-force-update
>  - Merge branch 'openjdk:master' into compiler-directives-force-update
>  - Merge branch 'openjdk:master' into compiler-directives-force-update
>  - Merge branch 'openjdk:master' into compiler-directives-force-update
>  - Merge branch 'openjdk:master' into compiler-directives-force-update
>  - Merge branch 'openjdk:master' into compiler-directives-force-update
>  - Deopt osr, cleanups
>  - Merge branch 'openjdk:master' into compiler-directives-force-update
>  - Merge branch 'openjdk:master' into compiler-directives-force-update
>  - ... and 34 more: https://git.openjdk.org/jdk/compare/d10f277b...6d639ace

As this is an extension of the existing compiler control mechanism.

-

PR Comment: https://git.openjdk.org/jdk/pull/14111#issuecomment-1965157823


Re: RFR: 8309271: A way to align already compiled methods with compiler directives [v26]

2024-02-24 Thread Dmitry Chuyko
> Compiler Control (https://openjdk.org/jeps/165) provides method-context 
> dependent control of the JVM compilers (C1 and C2). The active directive 
> stack is built from the directive files passed with the 
> `-XX:CompilerDirectivesFile` diagnostic command-line option and the 
> Compiler.add_directives diagnostic command. It is also possible to clear all 
> directives or remove the top from the stack.
> 
> A matching directive will be applied at method compilation time when such 
> compilation is started. If directives are added or changed, but compilation 
> does not start, then the state of compiled methods doesn't correspond to the 
> rules. This is not an error, and it happens in long running applications when 
> directives are added or removed after compilation of methods that could be 
> matched. For example, the user decides that C2 compilation needs to be 
> disabled for some method due to a compiler bug, issues such a directive but 
> this does not affect the application behavior. In such case, the target 
> application needs to be restarted, and such an operation can have high costs 
> and risks. Another goal is testing/debugging compilers.
> 
> It would be convenient to optionally reconcile at least existing matching 
> nmethods to the current stack of compiler directives (so bypass inlined 
> methods).
> 
> Natural way to eliminate the discrepancy between the result of compilation 
> and the broken rule is to discard the compilation result, i.e. 
> deoptimization. Prior to that we can try to re-compile the method letting 
> compile broker to perform it taking new directives stack into account. 
> Re-compilation helps to prevent hot methods from execution in the interpreter.
> 
> A new flag `-r` has beed introduced for some directives related to compile 
> commands: `Compiler.add_directives`, `Compiler.remove_directives`, 
> `Compiler.clear_directives`. The default behavior has not changed (no flag). 
> If the new flag is present, the command scans already compiled methods and 
> puts methods that have any active non-default matching compiler directives to 
> re-compilation if possible, otherwise marks them for deoptimization. There is 
> currently no distinction which directives are found. In particular, this 
> means that if there are rules for inlining into some method, it will be 
> refreshed. On the other hand, if there are rules for a method and it was 
> inlined, top-level methods won't be refreshed, but this can be achieved by 
> having rules for them.
> 
> In addition, a new diagnostic command `Compiler.replace_directives`, has been 
> added for ...

Dmitry Chuyko has updated the pull request with a new target base due to a 
merge or a rebase. The pull request now contains 44 commits:

 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Deopt osr, cleanups
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - ... and 34 more: https://git.openjdk.org/jdk/compare/d10f277b...6d639ace

-

Changes: https://git.openjdk.org/jdk/pull/14111/files
 Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=14111&range=25
  Stats: 381 lines in 15 files changed: 348 ins; 3 del; 30 mod
  Patch: https://git.openjdk.org/jdk/pull/14111.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/14111/head:pull/14111

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


Re: RFR: 8309271: A way to align already compiled methods with compiler directives [v25]

2024-02-13 Thread Dmitry Chuyko
On Wed, 31 Jan 2024 21:12:19 GMT, Dmitry Chuyko  wrote:

>> Compiler Control (https://openjdk.org/jeps/165) provides method-context 
>> dependent control of the JVM compilers (C1 and C2). The active directive 
>> stack is built from the directive files passed with the 
>> `-XX:CompilerDirectivesFile` diagnostic command-line option and the 
>> Compiler.add_directives diagnostic command. It is also possible to clear all 
>> directives or remove the top from the stack.
>> 
>> A matching directive will be applied at method compilation time when such 
>> compilation is started. If directives are added or changed, but compilation 
>> does not start, then the state of compiled methods doesn't correspond to the 
>> rules. This is not an error, and it happens in long running applications 
>> when directives are added or removed after compilation of methods that could 
>> be matched. For example, the user decides that C2 compilation needs to be 
>> disabled for some method due to a compiler bug, issues such a directive but 
>> this does not affect the application behavior. In such case, the target 
>> application needs to be restarted, and such an operation can have high costs 
>> and risks. Another goal is testing/debugging compilers.
>> 
>> It would be convenient to optionally reconcile at least existing matching 
>> nmethods to the current stack of compiler directives (so bypass inlined 
>> methods).
>> 
>> Natural way to eliminate the discrepancy between the result of compilation 
>> and the broken rule is to discard the compilation result, i.e. 
>> deoptimization. Prior to that we can try to re-compile the method letting 
>> compile broker to perform it taking new directives stack into account. 
>> Re-compilation helps to prevent hot methods from execution in the 
>> interpreter.
>> 
>> A new flag `-r` has beed introduced for some directives related to compile 
>> commands: `Compiler.add_directives`, `Compiler.remove_directives`, 
>> `Compiler.clear_directives`. The default behavior has not changed (no flag). 
>> If the new flag is present, the command scans already compiled methods and 
>> puts methods that have any active non-default matching compiler directives 
>> to re-compilation if possible, otherwise marks them for deoptimization. 
>> There is currently no distinction which directives are found. In particular, 
>> this means that if there are rules for inlining into some method, it will be 
>> refreshed. On the other hand, if there are rules for a method and it was 
>> inlined, top-level methods won't be refreshed, but this can be achieved by 
>> having rules for them.
>> 
>> In addition, a new diagnostic command `Compiler.replace_directives...
>
> Dmitry Chuyko has updated the pull request with a new target base due to a 
> merge or a rebase. The pull request now contains 43 commits:
> 
>  - Merge branch 'openjdk:master' into compiler-directives-force-update
>  - Merge branch 'openjdk:master' into compiler-directives-force-update
>  - Merge branch 'openjdk:master' into compiler-directives-force-update
>  - Merge branch 'openjdk:master' into compiler-directives-force-update
>  - Merge branch 'openjdk:master' into compiler-directives-force-update
>  - Merge branch 'openjdk:master' into compiler-directives-force-update
>  - Deopt osr, cleanups
>  - Merge branch 'openjdk:master' into compiler-directives-force-update
>  - Merge branch 'openjdk:master' into compiler-directives-force-update
>  - Merge branch 'openjdk:master' into compiler-directives-force-update
>  - ... and 33 more: https://git.openjdk.org/jdk/compare/5b9b176c...ea0322cd

@sspitsyn Can I please have someone from serviceability group take a look at 
this? Comments from Paul and Andrei have been addressed a while ago.

-

PR Comment: https://git.openjdk.org/jdk/pull/14111#issuecomment-1942717023


Re: RFR: 8309271: A way to align already compiled methods with compiler directives [v25]

2024-01-31 Thread Dmitry Chuyko
> Compiler Control (https://openjdk.org/jeps/165) provides method-context 
> dependent control of the JVM compilers (C1 and C2). The active directive 
> stack is built from the directive files passed with the 
> `-XX:CompilerDirectivesFile` diagnostic command-line option and the 
> Compiler.add_directives diagnostic command. It is also possible to clear all 
> directives or remove the top from the stack.
> 
> A matching directive will be applied at method compilation time when such 
> compilation is started. If directives are added or changed, but compilation 
> does not start, then the state of compiled methods doesn't correspond to the 
> rules. This is not an error, and it happens in long running applications when 
> directives are added or removed after compilation of methods that could be 
> matched. For example, the user decides that C2 compilation needs to be 
> disabled for some method due to a compiler bug, issues such a directive but 
> this does not affect the application behavior. In such case, the target 
> application needs to be restarted, and such an operation can have high costs 
> and risks. Another goal is testing/debugging compilers.
> 
> It would be convenient to optionally reconcile at least existing matching 
> nmethods to the current stack of compiler directives (so bypass inlined 
> methods).
> 
> Natural way to eliminate the discrepancy between the result of compilation 
> and the broken rule is to discard the compilation result, i.e. 
> deoptimization. Prior to that we can try to re-compile the method letting 
> compile broker to perform it taking new directives stack into account. 
> Re-compilation helps to prevent hot methods from execution in the interpreter.
> 
> A new flag `-r` has beed introduced for some directives related to compile 
> commands: `Compiler.add_directives`, `Compiler.remove_directives`, 
> `Compiler.clear_directives`. The default behavior has not changed (no flag). 
> If the new flag is present, the command scans already compiled methods and 
> puts methods that have any active non-default matching compiler directives to 
> re-compilation if possible, otherwise marks them for deoptimization. There is 
> currently no distinction which directives are found. In particular, this 
> means that if there are rules for inlining into some method, it will be 
> refreshed. On the other hand, if there are rules for a method and it was 
> inlined, top-level methods won't be refreshed, but this can be achieved by 
> having rules for them.
> 
> In addition, a new diagnostic command `Compiler.replace_directives`, has been 
> added for ...

Dmitry Chuyko has updated the pull request with a new target base due to a 
merge or a rebase. The pull request now contains 43 commits:

 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Deopt osr, cleanups
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - ... and 33 more: https://git.openjdk.org/jdk/compare/5b9b176c...ea0322cd

-

Changes: https://git.openjdk.org/jdk/pull/14111/files
 Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=14111&range=24
  Stats: 381 lines in 15 files changed: 348 ins; 3 del; 30 mod
  Patch: https://git.openjdk.org/jdk/pull/14111.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/14111/head:pull/14111

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


Re: RFR: 8309271: A way to align already compiled methods with compiler directives [v24]

2024-01-25 Thread Dmitry Chuyko
> Compiler Control (https://openjdk.org/jeps/165) provides method-context 
> dependent control of the JVM compilers (C1 and C2). The active directive 
> stack is built from the directive files passed with the 
> `-XX:CompilerDirectivesFile` diagnostic command-line option and the 
> Compiler.add_directives diagnostic command. It is also possible to clear all 
> directives or remove the top from the stack.
> 
> A matching directive will be applied at method compilation time when such 
> compilation is started. If directives are added or changed, but compilation 
> does not start, then the state of compiled methods doesn't correspond to the 
> rules. This is not an error, and it happens in long running applications when 
> directives are added or removed after compilation of methods that could be 
> matched. For example, the user decides that C2 compilation needs to be 
> disabled for some method due to a compiler bug, issues such a directive but 
> this does not affect the application behavior. In such case, the target 
> application needs to be restarted, and such an operation can have high costs 
> and risks. Another goal is testing/debugging compilers.
> 
> It would be convenient to optionally reconcile at least existing matching 
> nmethods to the current stack of compiler directives (so bypass inlined 
> methods).
> 
> Natural way to eliminate the discrepancy between the result of compilation 
> and the broken rule is to discard the compilation result, i.e. 
> deoptimization. Prior to that we can try to re-compile the method letting 
> compile broker to perform it taking new directives stack into account. 
> Re-compilation helps to prevent hot methods from execution in the interpreter.
> 
> A new flag `-r` has beed introduced for some directives related to compile 
> commands: `Compiler.add_directives`, `Compiler.remove_directives`, 
> `Compiler.clear_directives`. The default behavior has not changed (no flag). 
> If the new flag is present, the command scans already compiled methods and 
> puts methods that have any active non-default matching compiler directives to 
> re-compilation if possible, otherwise marks them for deoptimization. There is 
> currently no distinction which directives are found. In particular, this 
> means that if there are rules for inlining into some method, it will be 
> refreshed. On the other hand, if there are rules for a method and it was 
> inlined, top-level methods won't be refreshed, but this can be achieved by 
> having rules for them.
> 
> In addition, a new diagnostic command `Compiler.replace_directives`, has been 
> added for ...

Dmitry Chuyko has updated the pull request with a new target base due to a 
merge or a rebase. The pull request now contains 42 commits:

 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Deopt osr, cleanups
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - ... and 32 more: https://git.openjdk.org/jdk/compare/7a798d3c...0c8f11bc

-

Changes: https://git.openjdk.org/jdk/pull/14111/files
 Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=14111&range=23
  Stats: 381 lines in 15 files changed: 348 ins; 3 del; 30 mod
  Patch: https://git.openjdk.org/jdk/pull/14111.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/14111/head:pull/14111

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


Re: RFR: 8309271: A way to align already compiled methods with compiler directives [v23]

2024-01-18 Thread Dmitry Chuyko
> Compiler Control (https://openjdk.org/jeps/165) provides method-context 
> dependent control of the JVM compilers (C1 and C2). The active directive 
> stack is built from the directive files passed with the 
> `-XX:CompilerDirectivesFile` diagnostic command-line option and the 
> Compiler.add_directives diagnostic command. It is also possible to clear all 
> directives or remove the top from the stack.
> 
> A matching directive will be applied at method compilation time when such 
> compilation is started. If directives are added or changed, but compilation 
> does not start, then the state of compiled methods doesn't correspond to the 
> rules. This is not an error, and it happens in long running applications when 
> directives are added or removed after compilation of methods that could be 
> matched. For example, the user decides that C2 compilation needs to be 
> disabled for some method due to a compiler bug, issues such a directive but 
> this does not affect the application behavior. In such case, the target 
> application needs to be restarted, and such an operation can have high costs 
> and risks. Another goal is testing/debugging compilers.
> 
> It would be convenient to optionally reconcile at least existing matching 
> nmethods to the current stack of compiler directives (so bypass inlined 
> methods).
> 
> Natural way to eliminate the discrepancy between the result of compilation 
> and the broken rule is to discard the compilation result, i.e. 
> deoptimization. Prior to that we can try to re-compile the method letting 
> compile broker to perform it taking new directives stack into account. 
> Re-compilation helps to prevent hot methods from execution in the interpreter.
> 
> A new flag `-r` has beed introduced for some directives related to compile 
> commands: `Compiler.add_directives`, `Compiler.remove_directives`, 
> `Compiler.clear_directives`. The default behavior has not changed (no flag). 
> If the new flag is present, the command scans already compiled methods and 
> puts methods that have any active non-default matching compiler directives to 
> re-compilation if possible, otherwise marks them for deoptimization. There is 
> currently no distinction which directives are found. In particular, this 
> means that if there are rules for inlining into some method, it will be 
> refreshed. On the other hand, if there are rules for a method and it was 
> inlined, top-level methods won't be refreshed, but this can be achieved by 
> having rules for them.
> 
> In addition, a new diagnostic command `Compiler.replace_directives`, has been 
> added for ...

Dmitry Chuyko has updated the pull request with a new target base due to a 
merge or a rebase. The pull request now contains 41 commits:

 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Deopt osr, cleanups
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - ... and 31 more: https://git.openjdk.org/jdk/compare/81df265e...b2261505

-

Changes: https://git.openjdk.org/jdk/pull/14111/files
 Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=14111&range=22
  Stats: 381 lines in 15 files changed: 348 ins; 3 del; 30 mod
  Patch: https://git.openjdk.org/jdk/pull/14111.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/14111/head:pull/14111

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


Re: RFR: 8309271: A way to align already compiled methods with compiler directives [v22]

2024-01-18 Thread Dmitry Chuyko
> Compiler Control (https://openjdk.org/jeps/165) provides method-context 
> dependent control of the JVM compilers (C1 and C2). The active directive 
> stack is built from the directive files passed with the 
> `-XX:CompilerDirectivesFile` diagnostic command-line option and the 
> Compiler.add_directives diagnostic command. It is also possible to clear all 
> directives or remove the top from the stack.
> 
> A matching directive will be applied at method compilation time when such 
> compilation is started. If directives are added or changed, but compilation 
> does not start, then the state of compiled methods doesn't correspond to the 
> rules. This is not an error, and it happens in long running applications when 
> directives are added or removed after compilation of methods that could be 
> matched. For example, the user decides that C2 compilation needs to be 
> disabled for some method due to a compiler bug, issues such a directive but 
> this does not affect the application behavior. In such case, the target 
> application needs to be restarted, and such an operation can have high costs 
> and risks. Another goal is testing/debugging compilers.
> 
> It would be convenient to optionally reconcile at least existing matching 
> nmethods to the current stack of compiler directives (so bypass inlined 
> methods).
> 
> Natural way to eliminate the discrepancy between the result of compilation 
> and the broken rule is to discard the compilation result, i.e. 
> deoptimization. Prior to that we can try to re-compile the method letting 
> compile broker to perform it taking new directives stack into account. 
> Re-compilation helps to prevent hot methods from execution in the interpreter.
> 
> A new flag `-r` has beed introduced for some directives related to compile 
> commands: `Compiler.add_directives`, `Compiler.remove_directives`, 
> `Compiler.clear_directives`. The default behavior has not changed (no flag). 
> If the new flag is present, the command scans already compiled methods and 
> puts methods that have any active non-default matching compiler directives to 
> re-compilation if possible, otherwise marks them for deoptimization. There is 
> currently no distinction which directives are found. In particular, this 
> means that if there are rules for inlining into some method, it will be 
> refreshed. On the other hand, if there are rules for a method and it was 
> inlined, top-level methods won't be refreshed, but this can be achieved by 
> having rules for them.
> 
> In addition, a new diagnostic command `Compiler.replace_directives`, has been 
> added for ...

Dmitry Chuyko has updated the pull request with a new target base due to a 
merge or a rebase. The pull request now contains 40 commits:

 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Deopt osr, cleanups
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - ... and 30 more: https://git.openjdk.org/jdk/compare/a2b117ae...d4bc29c9

-

Changes: https://git.openjdk.org/jdk/pull/14111/files
 Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=14111&range=21
  Stats: 381 lines in 15 files changed: 348 ins; 3 del; 30 mod
  Patch: https://git.openjdk.org/jdk/pull/14111.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/14111/head:pull/14111

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


Re: RFR: 8309271: A way to align already compiled methods with compiler directives [v21]

2024-01-11 Thread Dmitry Chuyko
> Compiler Control (https://openjdk.org/jeps/165) provides method-context 
> dependent control of the JVM compilers (C1 and C2). The active directive 
> stack is built from the directive files passed with the 
> `-XX:CompilerDirectivesFile` diagnostic command-line option and the 
> Compiler.add_directives diagnostic command. It is also possible to clear all 
> directives or remove the top from the stack.
> 
> A matching directive will be applied at method compilation time when such 
> compilation is started. If directives are added or changed, but compilation 
> does not start, then the state of compiled methods doesn't correspond to the 
> rules. This is not an error, and it happens in long running applications when 
> directives are added or removed after compilation of methods that could be 
> matched. For example, the user decides that C2 compilation needs to be 
> disabled for some method due to a compiler bug, issues such a directive but 
> this does not affect the application behavior. In such case, the target 
> application needs to be restarted, and such an operation can have high costs 
> and risks. Another goal is testing/debugging compilers.
> 
> It would be convenient to optionally reconcile at least existing matching 
> nmethods to the current stack of compiler directives (so bypass inlined 
> methods).
> 
> Natural way to eliminate the discrepancy between the result of compilation 
> and the broken rule is to discard the compilation result, i.e. 
> deoptimization. Prior to that we can try to re-compile the method letting 
> compile broker to perform it taking new directives stack into account. 
> Re-compilation helps to prevent hot methods from execution in the interpreter.
> 
> A new flag `-r` has beed introduced for some directives related to compile 
> commands: `Compiler.add_directives`, `Compiler.remove_directives`, 
> `Compiler.clear_directives`. The default behavior has not changed (no flag). 
> If the new flag is present, the command scans already compiled methods and 
> puts methods that have any active non-default matching compiler directives to 
> re-compilation if possible, otherwise marks them for deoptimization. There is 
> currently no distinction which directives are found. In particular, this 
> means that if there are rules for inlining into some method, it will be 
> refreshed. On the other hand, if there are rules for a method and it was 
> inlined, top-level methods won't be refreshed, but this can be achieved by 
> having rules for them.
> 
> In addition, a new diagnostic command `Compiler.replace_directives`, has been 
> added for ...

Dmitry Chuyko has updated the pull request with a new target base due to a 
merge or a rebase. The pull request now contains 39 commits:

 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Deopt osr, cleanups
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - ... and 29 more: https://git.openjdk.org/jdk/compare/c2e77e2f...d1aec993

-

Changes: https://git.openjdk.org/jdk/pull/14111/files
 Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=14111&range=20
  Stats: 381 lines in 15 files changed: 348 ins; 3 del; 30 mod
  Patch: https://git.openjdk.org/jdk/pull/14111.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/14111/head:pull/14111

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


Re: RFR: 8309271: A way to align already compiled methods with compiler directives [v20]

2024-01-04 Thread Dmitry Chuyko
> Compiler Control (https://openjdk.org/jeps/165) provides method-context 
> dependent control of the JVM compilers (C1 and C2). The active directive 
> stack is built from the directive files passed with the 
> `-XX:CompilerDirectivesFile` diagnostic command-line option and the 
> Compiler.add_directives diagnostic command. It is also possible to clear all 
> directives or remove the top from the stack.
> 
> A matching directive will be applied at method compilation time when such 
> compilation is started. If directives are added or changed, but compilation 
> does not start, then the state of compiled methods doesn't correspond to the 
> rules. This is not an error, and it happens in long running applications when 
> directives are added or removed after compilation of methods that could be 
> matched. For example, the user decides that C2 compilation needs to be 
> disabled for some method due to a compiler bug, issues such a directive but 
> this does not affect the application behavior. In such case, the target 
> application needs to be restarted, and such an operation can have high costs 
> and risks. Another goal is testing/debugging compilers.
> 
> It would be convenient to optionally reconcile at least existing matching 
> nmethods to the current stack of compiler directives (so bypass inlined 
> methods).
> 
> Natural way to eliminate the discrepancy between the result of compilation 
> and the broken rule is to discard the compilation result, i.e. 
> deoptimization. Prior to that we can try to re-compile the method letting 
> compile broker to perform it taking new directives stack into account. 
> Re-compilation helps to prevent hot methods from execution in the interpreter.
> 
> A new flag `-r` has beed introduced for some directives related to compile 
> commands: `Compiler.add_directives`, `Compiler.remove_directives`, 
> `Compiler.clear_directives`. The default behavior has not changed (no flag). 
> If the new flag is present, the command scans already compiled methods and 
> puts methods that have any active non-default matching compiler directives to 
> re-compilation if possible, otherwise marks them for deoptimization. There is 
> currently no distinction which directives are found. In particular, this 
> means that if there are rules for inlining into some method, it will be 
> refreshed. On the other hand, if there are rules for a method and it was 
> inlined, top-level methods won't be refreshed, but this can be achieved by 
> having rules for them.
> 
> In addition, a new diagnostic command `Compiler.replace_directives`, has been 
> added for ...

Dmitry Chuyko has updated the pull request with a new target base due to a 
merge or a rebase. The pull request now contains 38 commits:

 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Deopt osr, cleanups
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - ... and 28 more: https://git.openjdk.org/jdk/compare/27d5f5c2...691ea329

-

Changes: https://git.openjdk.org/jdk/pull/14111/files
 Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=14111&range=19
  Stats: 381 lines in 15 files changed: 348 ins; 3 del; 30 mod
  Patch: https://git.openjdk.org/jdk/pull/14111.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/14111/head:pull/14111

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


Re: RFR: 8309271: A way to align already compiled methods with compiler directives [v15]

2023-12-22 Thread Dmitry Chuyko
On Wed, 20 Dec 2023 02:57:29 GMT, Andrei Pangin  wrote:

>> Dmitry Chuyko has updated the pull request with a new target base due to a 
>> merge or a rebase. The pull request now contains 33 commits:
>> 
>>  - Merge branch 'openjdk:master' into compiler-directives-force-update
>>  - Merge branch 'openjdk:master' into compiler-directives-force-update
>>  - Merge branch 'openjdk:master' into compiler-directives-force-update
>>  - Merge branch 'openjdk:master' into compiler-directives-force-update
>>  - Merge branch 'openjdk:master' into compiler-directives-force-update
>>  - Merge branch 'openjdk:master' into compiler-directives-force-update
>>  - Merge branch 'openjdk:master' into compiler-directives-force-update
>>  - Merge branch 'openjdk:master' into compiler-directives-force-update
>>  - Merge branch 'openjdk:master' into compiler-directives-force-update
>>  - Merge branch 'openjdk:master' into compiler-directives-force-update
>>  - ... and 23 more: https://git.openjdk.org/jdk/compare/fde5b168...44d680cd
>
> src/hotspot/share/code/codeCache.cpp line 1409:
> 
>> 1407:   while(iter.next()) {
>> 1408: CompiledMethod* nm = iter.method();
>> 1409: methodHandle mh(thread, nm->method());
> 
> If there are two CompiledMethods for the same Java method, will it be 
> scheduled for recompilation twice? Related question: if `nm` is an OSR 
> method, does it make sense to go directly for deoptimization rather than 
> compiling a non-OSR version?

If there are multiple method versions, it will be recompiled several times. The 
alternative is too keep some additional information which may complicate the 
code. OSRs is a good catch, I changed their handling to deopt.

-

PR Review Comment: https://git.openjdk.org/jdk/pull/14111#discussion_r1434887812


Re: RFR: 8309271: A way to align already compiled methods with compiler directives [v19]

2023-12-22 Thread Dmitry Chuyko
> Compiler Control (https://openjdk.org/jeps/165) provides method-context 
> dependent control of the JVM compilers (C1 and C2). The active directive 
> stack is built from the directive files passed with the 
> `-XX:CompilerDirectivesFile` diagnostic command-line option and the 
> Compiler.add_directives diagnostic command. It is also possible to clear all 
> directives or remove the top from the stack.
> 
> A matching directive will be applied at method compilation time when such 
> compilation is started. If directives are added or changed, but compilation 
> does not start, then the state of compiled methods doesn't correspond to the 
> rules. This is not an error, and it happens in long running applications when 
> directives are added or removed after compilation of methods that could be 
> matched. For example, the user decides that C2 compilation needs to be 
> disabled for some method due to a compiler bug, issues such a directive but 
> this does not affect the application behavior. In such case, the target 
> application needs to be restarted, and such an operation can have high costs 
> and risks. Another goal is testing/debugging compilers.
> 
> It would be convenient to optionally reconcile at least existing matching 
> nmethods to the current stack of compiler directives (so bypass inlined 
> methods).
> 
> Natural way to eliminate the discrepancy between the result of compilation 
> and the broken rule is to discard the compilation result, i.e. 
> deoptimization. Prior to that we can try to re-compile the method letting 
> compile broker to perform it taking new directives stack into account. 
> Re-compilation helps to prevent hot methods from execution in the interpreter.
> 
> A new flag `-r` has beed introduced for some directives related to compile 
> commands: `Compiler.add_directives`, `Compiler.remove_directives`, 
> `Compiler.clear_directives`. The default behavior has not changed (no flag). 
> If the new flag is present, the command scans already compiled methods and 
> puts methods that have any active non-default matching compiler directives to 
> re-compilation if possible, otherwise marks them for deoptimization. There is 
> currently no distinction which directives are found. In particular, this 
> means that if there are rules for inlining into some method, it will be 
> refreshed. On the other hand, if there are rules for a method and it was 
> inlined, top-level methods won't be refreshed, but this can be achieved by 
> having rules for them.
> 
> In addition, a new diagnostic command `Compiler.replace_directives`, has been 
> added for ...

Dmitry Chuyko has updated the pull request incrementally with one additional 
commit since the last revision:

  Deopt osr, cleanups

-

Changes:
  - all: https://git.openjdk.org/jdk/pull/14111/files
  - new: https://git.openjdk.org/jdk/pull/14111/files/b348ebed..d75daf64

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=jdk&pr=14111&range=18
 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=14111&range=17-18

  Stats: 41 lines in 4 files changed: 15 ins; 6 del; 20 mod
  Patch: https://git.openjdk.org/jdk/pull/14111.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/14111/head:pull/14111

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


Re: RFR: 8309271: A way to align already compiled methods with compiler directives [v15]

2023-12-22 Thread Dmitry Chuyko
On Wed, 20 Dec 2023 02:40:40 GMT, Andrei Pangin  wrote:

>> Dmitry Chuyko has updated the pull request with a new target base due to a 
>> merge or a rebase. The pull request now contains 33 commits:
>> 
>>  - Merge branch 'openjdk:master' into compiler-directives-force-update
>>  - Merge branch 'openjdk:master' into compiler-directives-force-update
>>  - Merge branch 'openjdk:master' into compiler-directives-force-update
>>  - Merge branch 'openjdk:master' into compiler-directives-force-update
>>  - Merge branch 'openjdk:master' into compiler-directives-force-update
>>  - Merge branch 'openjdk:master' into compiler-directives-force-update
>>  - Merge branch 'openjdk:master' into compiler-directives-force-update
>>  - Merge branch 'openjdk:master' into compiler-directives-force-update
>>  - Merge branch 'openjdk:master' into compiler-directives-force-update
>>  - Merge branch 'openjdk:master' into compiler-directives-force-update
>>  - ... and 23 more: https://git.openjdk.org/jdk/compare/fde5b168...44d680cd
>
> src/hotspot/share/code/codeCache.cpp line 1413:
> 
>> 1411:   ResourceMark rm;
>> 1412:   // Try the max level and let the directives be applied during 
>> the compilation.
>> 1413:   int complevel = CompLevel::CompLevel_full_optimization;
> 
> Should the highest level depend on the configuration instead of the 
> hard-coded constant? Perhaps, needs to be `highest_compile_level()`

Yes, changed to use `highest_compile_level()`.

> src/hotspot/share/compiler/compilerDirectives.cpp line 750:
> 
>> 748:   if (!dir->is_default_directive() && dir->match(method)) {
>> 749: match_found = true;
>> 750: break;
> 
> `match_found` is redundant: for better readability, you may just return true. 
> Curly braces around MutexLocker won't be needed either.

Thanks, that's indeed simpler.

> src/hotspot/share/oops/method.hpp line 820:
> 
>> 818:   // Clear the flags related to compiler directives that were set by 
>> the compilerBroker,
>> 819:   // because the directives can be updated.
>> 820:   void clear_method_flags() {
> 
> The function name is a bit misleading - it clears only flags related to 
> directives.

Changed to `clear_directive_flags`.

> src/hotspot/share/oops/methodFlags.hpp line 61:
> 
>> 59:status(has_loops_flag_init , 1 << 14) /* The loop flag has 
>> been initialized */ \
>> 60:status(on_stack_flag   , 1 << 15) /* RedefineClasses 
>> support to keep Metadata from being cleaned */ \
>> 61:status(has_matching_directives , 1 << 16) /* The method has 
>> matching directives */ \
> 
> It's worth noting that the flag is temporary and is valid only during DCmd 
> execution.

Good point, updated the comment. This btw means that in another places this 
flag can be reused.

-

PR Review Comment: https://git.openjdk.org/jdk/pull/14111#discussion_r1434883459
PR Review Comment: https://git.openjdk.org/jdk/pull/14111#discussion_r1434884163
PR Review Comment: https://git.openjdk.org/jdk/pull/14111#discussion_r1434884612
PR Review Comment: https://git.openjdk.org/jdk/pull/14111#discussion_r1434885291


Re: RFR: 8309271: A way to align already compiled methods with compiler directives [v18]

2023-12-21 Thread Dmitry Chuyko
> Compiler Control (https://openjdk.org/jeps/165) provides method-context 
> dependent control of the JVM compilers (C1 and C2). The active directive 
> stack is built from the directive files passed with the 
> `-XX:CompilerDirectivesFile` diagnostic command-line option and the 
> Compiler.add_directives diagnostic command. It is also possible to clear all 
> directives or remove the top from the stack.
> 
> A matching directive will be applied at method compilation time when such 
> compilation is started. If directives are added or changed, but compilation 
> does not start, then the state of compiled methods doesn't correspond to the 
> rules. This is not an error, and it happens in long running applications when 
> directives are added or removed after compilation of methods that could be 
> matched. For example, the user decides that C2 compilation needs to be 
> disabled for some method due to a compiler bug, issues such a directive but 
> this does not affect the application behavior. In such case, the target 
> application needs to be restarted, and such an operation can have high costs 
> and risks. Another goal is testing/debugging compilers.
> 
> It would be convenient to optionally reconcile at least existing matching 
> nmethods to the current stack of compiler directives (so bypass inlined 
> methods).
> 
> Natural way to eliminate the discrepancy between the result of compilation 
> and the broken rule is to discard the compilation result, i.e. 
> deoptimization. Prior to that we can try to re-compile the method letting 
> compile broker to perform it taking new directives stack into account. 
> Re-compilation helps to prevent hot methods from execution in the interpreter.
> 
> A new flag `-r` has beed introduced for some directives related to compile 
> commands: `Compiler.add_directives`, `Compiler.remove_directives`, 
> `Compiler.clear_directives`. The default behavior has not changed (no flag). 
> If the new flag is present, the command scans already compiled methods and 
> puts methods that have any active non-default matching compiler directives to 
> re-compilation if possible, otherwise marks them for deoptimization. There is 
> currently no distinction which directives are found. In particular, this 
> means that if there are rules for inlining into some method, it will be 
> refreshed. On the other hand, if there are rules for a method and it was 
> inlined, top-level methods won't be refreshed, but this can be achieved by 
> having rules for them.
> 
> In addition, a new diagnostic command `Compiler.replace_directives`, has been 
> added for ...

Dmitry Chuyko has updated the pull request with a new target base due to a 
merge or a rebase. The pull request now contains 36 commits:

 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - ... and 26 more: https://git.openjdk.org/jdk/compare/6de23bf3...b348ebed

-

Changes: https://git.openjdk.org/jdk/pull/14111/files
 Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=14111&range=17
  Stats: 372 lines in 15 files changed: 339 ins; 3 del; 30 mod
  Patch: https://git.openjdk.org/jdk/pull/14111.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/14111/head:pull/14111

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


Re: RFR: 8309271: A way to align already compiled methods with compiler directives [v17]

2023-12-21 Thread Dmitry Chuyko
> Compiler Control (https://openjdk.org/jeps/165) provides method-context 
> dependent control of the JVM compilers (C1 and C2). The active directive 
> stack is built from the directive files passed with the 
> `-XX:CompilerDirectivesFile` diagnostic command-line option and the 
> Compiler.add_directives diagnostic command. It is also possible to clear all 
> directives or remove the top from the stack.
> 
> A matching directive will be applied at method compilation time when such 
> compilation is started. If directives are added or changed, but compilation 
> does not start, then the state of compiled methods doesn't correspond to the 
> rules. This is not an error, and it happens in long running applications when 
> directives are added or removed after compilation of methods that could be 
> matched. For example, the user decides that C2 compilation needs to be 
> disabled for some method due to a compiler bug, issues such a directive but 
> this does not affect the application behavior. In such case, the target 
> application needs to be restarted, and such an operation can have high costs 
> and risks. Another goal is testing/debugging compilers.
> 
> It would be convenient to optionally reconcile at least existing matching 
> nmethods to the current stack of compiler directives (so bypass inlined 
> methods).
> 
> Natural way to eliminate the discrepancy between the result of compilation 
> and the broken rule is to discard the compilation result, i.e. 
> deoptimization. Prior to that we can try to re-compile the method letting 
> compile broker to perform it taking new directives stack into account. 
> Re-compilation helps to prevent hot methods from execution in the interpreter.
> 
> A new flag `-r` has beed introduced for some directives related to compile 
> commands: `Compiler.add_directives`, `Compiler.remove_directives`, 
> `Compiler.clear_directives`. The default behavior has not changed (no flag). 
> If the new flag is present, the command scans already compiled methods and 
> puts methods that have any active non-default matching compiler directives to 
> re-compilation if possible, otherwise marks them for deoptimization. There is 
> currently no distinction which directives are found. In particular, this 
> means that if there are rules for inlining into some method, it will be 
> refreshed. On the other hand, if there are rules for a method and it was 
> inlined, top-level methods won't be refreshed, but this can be achieved by 
> having rules for them.
> 
> In addition, a new diagnostic command `Compiler.replace_directives`, has been 
> added for ...

Dmitry Chuyko has updated the pull request with a new target base due to a 
merge or a rebase. The pull request now contains 35 commits:

 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - ... and 25 more: https://git.openjdk.org/jdk/compare/aff659aa...fbedf276

-

Changes: https://git.openjdk.org/jdk/pull/14111/files
 Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=14111&range=16
  Stats: 372 lines in 15 files changed: 339 ins; 3 del; 30 mod
  Patch: https://git.openjdk.org/jdk/pull/14111.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/14111/head:pull/14111

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


Re: RFR: 8309271: A way to align already compiled methods with compiler directives [v16]

2023-12-20 Thread Dmitry Chuyko
> Compiler Control (https://openjdk.org/jeps/165) provides method-context 
> dependent control of the JVM compilers (C1 and C2). The active directive 
> stack is built from the directive files passed with the 
> `-XX:CompilerDirectivesFile` diagnostic command-line option and the 
> Compiler.add_directives diagnostic command. It is also possible to clear all 
> directives or remove the top from the stack.
> 
> A matching directive will be applied at method compilation time when such 
> compilation is started. If directives are added or changed, but compilation 
> does not start, then the state of compiled methods doesn't correspond to the 
> rules. This is not an error, and it happens in long running applications when 
> directives are added or removed after compilation of methods that could be 
> matched. For example, the user decides that C2 compilation needs to be 
> disabled for some method due to a compiler bug, issues such a directive but 
> this does not affect the application behavior. In such case, the target 
> application needs to be restarted, and such an operation can have high costs 
> and risks. Another goal is testing/debugging compilers.
> 
> It would be convenient to optionally reconcile at least existing matching 
> nmethods to the current stack of compiler directives (so bypass inlined 
> methods).
> 
> Natural way to eliminate the discrepancy between the result of compilation 
> and the broken rule is to discard the compilation result, i.e. 
> deoptimization. Prior to that we can try to re-compile the method letting 
> compile broker to perform it taking new directives stack into account. 
> Re-compilation helps to prevent hot methods from execution in the interpreter.
> 
> A new flag `-r` has beed introduced for some directives related to compile 
> commands: `Compiler.add_directives`, `Compiler.remove_directives`, 
> `Compiler.clear_directives`. The default behavior has not changed (no flag). 
> If the new flag is present, the command scans already compiled methods and 
> puts methods that have any active non-default matching compiler directives to 
> re-compilation if possible, otherwise marks them for deoptimization. There is 
> currently no distinction which directives are found. In particular, this 
> means that if there are rules for inlining into some method, it will be 
> refreshed. On the other hand, if there are rules for a method and it was 
> inlined, top-level methods won't be refreshed, but this can be achieved by 
> having rules for them.
> 
> In addition, a new diagnostic command `Compiler.replace_directives`, has been 
> added for ...

Dmitry Chuyko has updated the pull request with a new target base due to a 
merge or a rebase. The pull request now contains 34 commits:

 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - ... and 24 more: https://git.openjdk.org/jdk/compare/14dab319...e337e56b

-

Changes: https://git.openjdk.org/jdk/pull/14111/files
 Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=14111&range=15
  Stats: 372 lines in 15 files changed: 339 ins; 3 del; 30 mod
  Patch: https://git.openjdk.org/jdk/pull/14111.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/14111/head:pull/14111

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


Re: RFR: 8309271: A way to align already compiled methods with compiler directives [v15]

2023-12-14 Thread Dmitry Chuyko
> Compiler Control (https://openjdk.org/jeps/165) provides method-context 
> dependent control of the JVM compilers (C1 and C2). The active directive 
> stack is built from the directive files passed with the 
> `-XX:CompilerDirectivesFile` diagnostic command-line option and the 
> Compiler.add_directives diagnostic command. It is also possible to clear all 
> directives or remove the top from the stack.
> 
> A matching directive will be applied at method compilation time when such 
> compilation is started. If directives are added or changed, but compilation 
> does not start, then the state of compiled methods doesn't correspond to the 
> rules. This is not an error, and it happens in long running applications when 
> directives are added or removed after compilation of methods that could be 
> matched. For example, the user decides that C2 compilation needs to be 
> disabled for some method due to a compiler bug, issues such a directive but 
> this does not affect the application behavior. In such case, the target 
> application needs to be restarted, and such an operation can have high costs 
> and risks. Another goal is testing/debugging compilers.
> 
> It would be convenient to optionally reconcile at least existing matching 
> nmethods to the current stack of compiler directives (so bypass inlined 
> methods).
> 
> Natural way to eliminate the discrepancy between the result of compilation 
> and the broken rule is to discard the compilation result, i.e. 
> deoptimization. Prior to that we can try to re-compile the method letting 
> compile broker to perform it taking new directives stack into account. 
> Re-compilation helps to prevent hot methods from execution in the interpreter.
> 
> A new flag `-r` has beed introduced for some directives related to compile 
> commands: `Compiler.add_directives`, `Compiler.remove_directives`, 
> `Compiler.clear_directives`. The default behavior has not changed (no flag). 
> If the new flag is present, the command scans already compiled methods and 
> puts methods that have any active non-default matching compiler directives to 
> re-compilation if possible, otherwise marks them for deoptimization. There is 
> currently no distinction which directives are found. In particular, this 
> means that if there are rules for inlining into some method, it will be 
> refreshed. On the other hand, if there are rules for a method and it was 
> inlined, top-level methods won't be refreshed, but this can be achieved by 
> having rules for them.
> 
> In addition, a new diagnostic command `Compiler.replace_directives`, has been 
> added for ...

Dmitry Chuyko has updated the pull request with a new target base due to a 
merge or a rebase. The pull request now contains 33 commits:

 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - ... and 23 more: https://git.openjdk.org/jdk/compare/fde5b168...44d680cd

-

Changes: https://git.openjdk.org/jdk/pull/14111/files
 Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=14111&range=14
  Stats: 372 lines in 15 files changed: 339 ins; 3 del; 30 mod
  Patch: https://git.openjdk.org/jdk/pull/14111.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/14111/head:pull/14111

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


Re: RFR: 8309271: A way to align already compiled methods with compiler directives [v14]

2023-12-11 Thread Dmitry Chuyko
> Compiler Control (https://openjdk.org/jeps/165) provides method-context 
> dependent control of the JVM compilers (C1 and C2). The active directive 
> stack is built from the directive files passed with the 
> `-XX:CompilerDirectivesFile` diagnostic command-line option and the 
> Compiler.add_directives diagnostic command. It is also possible to clear all 
> directives or remove the top from the stack.
> 
> A matching directive will be applied at method compilation time when such 
> compilation is started. If directives are added or changed, but compilation 
> does not start, then the state of compiled methods doesn't correspond to the 
> rules. This is not an error, and it happens in long running applications when 
> directives are added or removed after compilation of methods that could be 
> matched. For example, the user decides that C2 compilation needs to be 
> disabled for some method due to a compiler bug, issues such a directive but 
> this does not affect the application behavior. In such case, the target 
> application needs to be restarted, and such an operation can have high costs 
> and risks. Another goal is testing/debugging compilers.
> 
> It would be convenient to optionally reconcile at least existing matching 
> nmethods to the current stack of compiler directives (so bypass inlined 
> methods).
> 
> Natural way to eliminate the discrepancy between the result of compilation 
> and the broken rule is to discard the compilation result, i.e. 
> deoptimization. Prior to that we can try to re-compile the method letting 
> compile broker to perform it taking new directives stack into account. 
> Re-compilation helps to prevent hot methods from execution in the interpreter.
> 
> A new flag `-r` has beed introduced for some directives related to compile 
> commands: `Compiler.add_directives`, `Compiler.remove_directives`, 
> `Compiler.clear_directives`. The default behavior has not changed (no flag). 
> If the new flag is present, the command scans already compiled methods and 
> puts methods that have any active non-default matching compiler directives to 
> re-compilation if possible, otherwise marks them for deoptimization. There is 
> currently no distinction which directives are found. In particular, this 
> means that if there are rules for inlining into some method, it will be 
> refreshed. On the other hand, if there are rules for a method and it was 
> inlined, top-level methods won't be refreshed, but this can be achieved by 
> having rules for them.
> 
> In addition, a new diagnostic command `Compiler.replace_directives`, has been 
> added for ...

Dmitry Chuyko has updated the pull request with a new target base due to a 
merge or a rebase. The pull request now contains 32 commits:

 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - jcheck
 - ... and 22 more: https://git.openjdk.org/jdk/compare/ce4b257f...8b8b30ae

-

Changes: https://git.openjdk.org/jdk/pull/14111/files
 Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=14111&range=13
  Stats: 372 lines in 15 files changed: 339 ins; 3 del; 30 mod
  Patch: https://git.openjdk.org/jdk/pull/14111.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/14111/head:pull/14111

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


Re: RFR: 8309271: A way to align already compiled methods with compiler directives [v13]

2023-12-08 Thread Dmitry Chuyko
> Compiler Control (https://openjdk.org/jeps/165) provides method-context 
> dependent control of the JVM compilers (C1 and C2). The active directive 
> stack is built from the directive files passed with the 
> `-XX:CompilerDirectivesFile` diagnostic command-line option and the 
> Compiler.add_directives diagnostic command. It is also possible to clear all 
> directives or remove the top from the stack.
> 
> A matching directive will be applied at method compilation time when such 
> compilation is started. If directives are added or changed, but compilation 
> does not start, then the state of compiled methods doesn't correspond to the 
> rules. This is not an error, and it happens in long running applications when 
> directives are added or removed after compilation of methods that could be 
> matched. For example, the user decides that C2 compilation needs to be 
> disabled for some method due to a compiler bug, issues such a directive but 
> this does not affect the application behavior. In such case, the target 
> application needs to be restarted, and such an operation can have high costs 
> and risks. Another goal is testing/debugging compilers.
> 
> It would be convenient to optionally reconcile at least existing matching 
> nmethods to the current stack of compiler directives (so bypass inlined 
> methods).
> 
> Natural way to eliminate the discrepancy between the result of compilation 
> and the broken rule is to discard the compilation result, i.e. 
> deoptimization. Prior to that we can try to re-compile the method letting 
> compile broker to perform it taking new directives stack into account. 
> Re-compilation helps to prevent hot methods from execution in the interpreter.
> 
> A new flag `-r` has beed introduced for some directives related to compile 
> commands: `Compiler.add_directives`, `Compiler.remove_directives`, 
> `Compiler.clear_directives`. The default behavior has not changed (no flag). 
> If the new flag is present, the command scans already compiled methods and 
> puts methods that have any active non-default matching compiler directives to 
> re-compilation if possible, otherwise marks them for deoptimization. There is 
> currently no distinction which directives are found. In particular, this 
> means that if there are rules for inlining into some method, it will be 
> refreshed. On the other hand, if there are rules for a method and it was 
> inlined, top-level methods won't be refreshed, but this can be achieved by 
> having rules for them.
> 
> In addition, a new diagnostic command `Compiler.replace_directives`, has been 
> added for ...

Dmitry Chuyko has updated the pull request with a new target base due to a 
merge or a rebase. The pull request now contains 31 commits:

 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - jcheck
 - Unnecessary import
 - ... and 21 more: https://git.openjdk.org/jdk/compare/701bc3bb...1a01cf1c

-

Changes: https://git.openjdk.org/jdk/pull/14111/files
 Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=14111&range=12
  Stats: 372 lines in 15 files changed: 339 ins; 3 del; 30 mod
  Patch: https://git.openjdk.org/jdk/pull/14111.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/14111/head:pull/14111

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


Re: RFR: 8309271: A way to align already compiled methods with compiler directives [v12]

2023-12-07 Thread Dmitry Chuyko
> Compiler Control (https://openjdk.org/jeps/165) provides method-context 
> dependent control of the JVM compilers (C1 and C2). The active directive 
> stack is built from the directive files passed with the 
> `-XX:CompilerDirectivesFile` diagnostic command-line option and the 
> Compiler.add_directives diagnostic command. It is also possible to clear all 
> directives or remove the top from the stack.
> 
> A matching directive will be applied at method compilation time when such 
> compilation is started. If directives are added or changed, but compilation 
> does not start, then the state of compiled methods doesn't correspond to the 
> rules. This is not an error, and it happens in long running applications when 
> directives are added or removed after compilation of methods that could be 
> matched. For example, the user decides that C2 compilation needs to be 
> disabled for some method due to a compiler bug, issues such a directive but 
> this does not affect the application behavior. In such case, the target 
> application needs to be restarted, and such an operation can have high costs 
> and risks. Another goal is testing/debugging compilers.
> 
> It would be convenient to optionally reconcile at least existing matching 
> nmethods to the current stack of compiler directives (so bypass inlined 
> methods).
> 
> Natural way to eliminate the discrepancy between the result of compilation 
> and the broken rule is to discard the compilation result, i.e. 
> deoptimization. Prior to that we can try to re-compile the method letting 
> compile broker to perform it taking new directives stack into account. 
> Re-compilation helps to prevent hot methods from execution in the interpreter.
> 
> A new flag `-r` has beed introduced for some directives related to compile 
> commands: `Compiler.add_directives`, `Compiler.remove_directives`, 
> `Compiler.clear_directives`. The default behavior has not changed (no flag). 
> If the new flag is present, the command scans already compiled methods and 
> puts methods that have any active non-default matching compiler directives to 
> re-compilation if possible, otherwise marks them for deoptimization. There is 
> currently no distinction which directives are found. In particular, this 
> means that if there are rules for inlining into some method, it will be 
> refreshed. On the other hand, if there are rules for a method and it was 
> inlined, top-level methods won't be refreshed, but this can be achieved by 
> having rules for them.
> 
> In addition, a new diagnostic command `Compiler.replace_directives`, has been 
> added for ...

Dmitry Chuyko has updated the pull request with a new target base due to a 
merge or a rebase. The pull request now contains 30 commits:

 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - jcheck
 - Unnecessary import
 - force_update->refresh
 - ... and 20 more: https://git.openjdk.org/jdk/compare/a7f60164...21fe715e

-

Changes: https://git.openjdk.org/jdk/pull/14111/files
 Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=14111&range=11
  Stats: 372 lines in 15 files changed: 339 ins; 3 del; 30 mod
  Patch: https://git.openjdk.org/jdk/pull/14111.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/14111/head:pull/14111

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


Re: RFR: 8309271: A way to align already compiled methods with compiler directives [v11]

2023-11-24 Thread Dmitry Chuyko
> Compiler Control (https://openjdk.org/jeps/165) provides method-context 
> dependent control of the JVM compilers (C1 and C2). The active directive 
> stack is built from the directive files passed with the 
> `-XX:CompilerDirectivesFile` diagnostic command-line option and the 
> Compiler.add_directives diagnostic command. It is also possible to clear all 
> directives or remove the top from the stack.
> 
> A matching directive will be applied at method compilation time when such 
> compilation is started. If directives are added or changed, but compilation 
> does not start, then the state of compiled methods doesn't correspond to the 
> rules. This is not an error, and it happens in long running applications when 
> directives are added or removed after compilation of methods that could be 
> matched. For example, the user decides that C2 compilation needs to be 
> disabled for some method due to a compiler bug, issues such a directive but 
> this does not affect the application behavior. In such case, the target 
> application needs to be restarted, and such an operation can have high costs 
> and risks. Another goal is testing/debugging compilers.
> 
> It would be convenient to optionally reconcile at least existing matching 
> nmethods to the current stack of compiler directives (so bypass inlined 
> methods).
> 
> Natural way to eliminate the discrepancy between the result of compilation 
> and the broken rule is to discard the compilation result, i.e. 
> deoptimization. Prior to that we can try to re-compile the method letting 
> compile broker to perform it taking new directives stack into account. 
> Re-compilation helps to prevent hot methods from execution in the interpreter.
> 
> A new flag `-r` has beed introduced for some directives related to compile 
> commands: `Compiler.add_directives`, `Compiler.remove_directives`, 
> `Compiler.clear_directives`. The default behavior has not changed (no flag). 
> If the new flag is present, the command scans already compiled methods and 
> puts methods that have any active non-default matching compiler directives to 
> re-compilation if possible, otherwise marks them for deoptimization. There is 
> currently no distinction which directives are found. In particular, this 
> means that if there are rules for inlining into some method, it will be 
> refreshed. On the other hand, if there are rules for a method and it was 
> inlined, top-level methods won't be refreshed, but this can be achieved by 
> having rules for them.
> 
> In addition, a new diagnostic command `Compiler.replace_directives`, has been 
> added for ...

Dmitry Chuyko has updated the pull request with a new target base due to a 
merge or a rebase. The pull request now contains 29 commits:

 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - jcheck
 - Unnecessary import
 - force_update->refresh
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - ... and 19 more: https://git.openjdk.org/jdk/compare/0c9a61c1...c0d887af

-

Changes: https://git.openjdk.org/jdk/pull/14111/files
 Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=14111&range=10
  Stats: 372 lines in 15 files changed: 339 ins; 3 del; 30 mod
  Patch: https://git.openjdk.org/jdk/pull/14111.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/14111/head:pull/14111

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


Re: RFR: 8309271: A way to align already compiled methods with compiler directives [v10]

2023-11-15 Thread Dmitry Chuyko
> Compiler Control (https://openjdk.org/jeps/165) provides method-context 
> dependent control of the JVM compilers (C1 and C2). The active directive 
> stack is built from the directive files passed with the 
> `-XX:CompilerDirectivesFile` diagnostic command-line option and the 
> Compiler.add_directives diagnostic command. It is also possible to clear all 
> directives or remove the top from the stack.
> 
> A matching directive will be applied at method compilation time when such 
> compilation is started. If directives are added or changed, but compilation 
> does not start, then the state of compiled methods doesn't correspond to the 
> rules. This is not an error, and it happens in long running applications when 
> directives are added or removed after compilation of methods that could be 
> matched. For example, the user decides that C2 compilation needs to be 
> disabled for some method due to a compiler bug, issues such a directive but 
> this does not affect the application behavior. In such case, the target 
> application needs to be restarted, and such an operation can have high costs 
> and risks. Another goal is testing/debugging compilers.
> 
> It would be convenient to optionally reconcile at least existing matching 
> nmethods to the current stack of compiler directives (so bypass inlined 
> methods).
> 
> Natural way to eliminate the discrepancy between the result of compilation 
> and the broken rule is to discard the compilation result, i.e. 
> deoptimization. Prior to that we can try to re-compile the method letting 
> compile broker to perform it taking new directives stack into account. 
> Re-compilation helps to prevent hot methods from execution in the interpreter.
> 
> A new flag `-r` has beed introduced for some directives related to compile 
> commands: `Compiler.add_directives`, `Compiler.remove_directives`, 
> `Compiler.clear_directives`. The default behavior has not changed (no flag). 
> If the new flag is present, the command scans already compiled methods and 
> puts methods that have any active non-default matching compiler directives to 
> re-compilation if possible, otherwise marks them for deoptimization. There is 
> currently no distinction which directives are found. In particular, this 
> means that if there are rules for inlining into some method, it will be 
> refreshed. On the other hand, if there are rules for a method and it was 
> inlined, top-level methods won't be refreshed, but this can be achieved by 
> having rules for them.
> 
> In addition, a new diagnostic command `Compiler.replace_directives`, has been 
> added for ...

Dmitry Chuyko has updated the pull request with a new target base due to a 
merge or a rebase. The pull request now contains 28 commits:

 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - jcheck
 - Unnecessary import
 - force_update->refresh
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Use only top directive for add/remove; better mutex rank definition; texts
 - ... and 18 more: https://git.openjdk.org/jdk/compare/2e34a2eb...37c50c74

-

Changes: https://git.openjdk.org/jdk/pull/14111/files
 Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=14111&range=09
  Stats: 372 lines in 15 files changed: 339 ins; 3 del; 30 mod
  Patch: https://git.openjdk.org/jdk/pull/14111.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/14111/head:pull/14111

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


Re: RFR: 8309271: A way to align already compiled methods with compiler directives [v9]

2023-10-11 Thread Dmitry Chuyko
> Compiler Control (https://openjdk.org/jeps/165) provides method-context 
> dependent control of the JVM compilers (C1 and C2). The active directive 
> stack is built from the directive files passed with the 
> `-XX:CompilerDirectivesFile` diagnostic command-line option and the 
> Compiler.add_directives diagnostic command. It is also possible to clear all 
> directives or remove the top from the stack.
> 
> A matching directive will be applied at method compilation time when such 
> compilation is started. If directives are added or changed, but compilation 
> does not start, then the state of compiled methods doesn't correspond to the 
> rules. This is not an error, and it happens in long running applications when 
> directives are added or removed after compilation of methods that could be 
> matched. For example, the user decides that C2 compilation needs to be 
> disabled for some method due to a compiler bug, issues such a directive but 
> this does not affect the application behavior. In such case, the target 
> application needs to be restarted, and such an operation can have high costs 
> and risks. Another goal is testing/debugging compilers.
> 
> It would be convenient to optionally reconcile at least existing matching 
> nmethods to the current stack of compiler directives (so bypass inlined 
> methods).
> 
> Natural way to eliminate the discrepancy between the result of compilation 
> and the broken rule is to discard the compilation result, i.e. 
> deoptimization. Prior to that we can try to re-compile the method letting 
> compile broker to perform it taking new directives stack into account. 
> Re-compilation helps to prevent hot methods from execution in the interpreter.
> 
> A new flag `-r` has beed introduced for some directives related to compile 
> commands: `Compiler.add_directives`, `Compiler.remove_directives`, 
> `Compiler.clear_directives`. The default behavior has not changed (no flag). 
> If the new flag is present, the command scans already compiled methods and 
> puts methods that have any active non-default matching compiler directives to 
> re-compilation if possible, otherwise marks them for deoptimization. There is 
> currently no distinction which directives are found. In particular, this 
> means that if there are rules for inlining into some method, it will be 
> refreshed. On the other hand, if there are rules for a method and it was 
> inlined, top-level methods won't be refreshed, but this can be achieved by 
> having rules for them.
> 
> In addition, a new diagnostic command `Compiler.replace_directives`, has been 
> added for ...

Dmitry Chuyko has updated the pull request with a new target base due to a 
merge or a rebase. The pull request now contains 27 commits:

 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - jcheck
 - Unnecessary import
 - force_update->refresh
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Use only top directive for add/remove; better mutex rank definition; texts
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - ... and 17 more: https://git.openjdk.org/jdk/compare/731fb4ee...d7cb519a

-

Changes: https://git.openjdk.org/jdk/pull/14111/files
 Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=14111&range=08
  Stats: 372 lines in 15 files changed: 339 ins; 3 del; 30 mod
  Patch: https://git.openjdk.org/jdk/pull/14111.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/14111/head:pull/14111

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


Re: RFR: 8309271: A way to align already compiled methods with compiler directives [v8]

2023-09-28 Thread Dmitry Chuyko
> Compiler Control (https://openjdk.org/jeps/165) provides method-context 
> dependent control of the JVM compilers (C1 and C2). The active directive 
> stack is built from the directive files passed with the 
> `-XX:CompilerDirectivesFile` diagnostic command-line option and the 
> Compiler.add_directives diagnostic command. It is also possible to clear all 
> directives or remove the top from the stack.
> 
> A matching directive will be applied at method compilation time when such 
> compilation is started. If directives are added or changed, but compilation 
> does not start, then the state of compiled methods doesn't correspond to the 
> rules. This is not an error, and it happens in long running applications when 
> directives are added or removed after compilation of methods that could be 
> matched. For example, the user decides that C2 compilation needs to be 
> disabled for some method due to a compiler bug, issues such a directive but 
> this does not affect the application behavior. In such case, the target 
> application needs to be restarted, and such an operation can have high costs 
> and risks. Another goal is testing/debugging compilers.
> 
> It would be convenient to optionally reconcile at least existing matching 
> nmethods to the current stack of compiler directives (so bypass inlined 
> methods).
> 
> Natural way to eliminate the discrepancy between the result of compilation 
> and the broken rule is to discard the compilation result, i.e. 
> deoptimization. Prior to that we can try to re-compile the method letting 
> compile broker to perform it taking new directives stack into account. 
> Re-compilation helps to prevent hot methods from execution in the interpreter.
> 
> A new flag `-r` has beed introduced for some directives related to compile 
> commands: `Compiler.add_directives`, `Compiler.remove_directives`, 
> `Compiler.clear_directives`. The default behavior has not changed (no flag). 
> If the new flag is present, the command scans already compiled methods and 
> puts methods that have any active non-default matching compiler directives to 
> re-compilation if possible, otherwise marks them for deoptimization. There is 
> currently no distinction which directives are found. In particular, this 
> means that if there are rules for inlining into some method, it will be 
> refreshed. On the other hand, if there are rules for a method and it was 
> inlined, top-level methods won't be refreshed, but this can be achieved by 
> having rules for them.
> 
> In addition, a new diagnostic command `Compiler.replace_directives`, has been 
> added for ...

Dmitry Chuyko has updated the pull request with a new target base due to a 
merge or a rebase. The pull request now contains 26 commits:

 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - jcheck
 - Unnecessary import
 - force_update->refresh
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Use only top directive for add/remove; better mutex rank definition; texts
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - ... and 16 more: https://git.openjdk.org/jdk/compare/fc989986...d95d2609

-

Changes: https://git.openjdk.org/jdk/pull/14111/files
 Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=14111&range=07
  Stats: 372 lines in 15 files changed: 339 ins; 3 del; 30 mod
  Patch: https://git.openjdk.org/jdk/pull/14111.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/14111/head:pull/14111

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


Re: RFR: 8309271: A way to align already compiled methods with compiler directives [v7]

2023-09-27 Thread Dmitry Chuyko
> Compiler Control (https://openjdk.org/jeps/165) provides method-context 
> dependent control of the JVM compilers (C1 and C2). The active directive 
> stack is built from the directive files passed with the 
> `-XX:CompilerDirectivesFile` diagnostic command-line option and the 
> Compiler.add_directives diagnostic command. It is also possible to clear all 
> directives or remove the top from the stack.
> 
> A matching directive will be applied at method compilation time when such 
> compilation is started. If directives are added or changed, but compilation 
> does not start, then the state of compiled methods doesn't correspond to the 
> rules. This is not an error, and it happens in long running applications when 
> directives are added or removed after compilation of methods that could be 
> matched. For example, the user decides that C2 compilation needs to be 
> disabled for some method due to a compiler bug, issues such a directive but 
> this does not affect the application behavior. In such case, the target 
> application needs to be restarted, and such an operation can have high costs 
> and risks. Another goal is testing/debugging compilers.
> 
> It would be convenient to optionally reconcile at least existing matching 
> nmethods to the current stack of compiler directives (so bypass inlined 
> methods).
> 
> Natural way to eliminate the discrepancy between the result of compilation 
> and the broken rule is to discard the compilation result, i.e. 
> deoptimization. Prior to that we can try to re-compile the method letting 
> compile broker to perform it taking new directives stack into account. 
> Re-compilation helps to prevent hot methods from execution in the interpreter.
> 
> A new flag `-r` has beed introduced for some directives related to compile 
> commands: `Compiler.add_directives`, `Compiler.remove_directives`, 
> `Compiler.clear_directives`. The default behavior has not changed (no flag). 
> If the new flag is present, the command scans already compiled methods and 
> puts methods that have any active non-default matching compiler directives to 
> re-compilation if possible, otherwise marks them for deoptimization. There is 
> currently no distinction which directives are found. In particular, this 
> means that if there are rules for inlining into some method, it will be 
> refreshed. On the other hand, if there are rules for a method and it was 
> inlined, top-level methods won't be refreshed, but this can be achieved by 
> having rules for them.
> 
> In addition, a new diagnostic command `Compiler.replace_directives`, has been 
> added for ...

Dmitry Chuyko has updated the pull request with a new target base due to a 
merge or a rebase. The pull request now contains 25 commits:

 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - jcheck
 - Unnecessary import
 - force_update->refresh
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Use only top directive for add/remove; better mutex rank definition; texts
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Safe handling of non-java methods
 - ... and 15 more: https://git.openjdk.org/jdk/compare/750da001...e451f509

-

Changes: https://git.openjdk.org/jdk/pull/14111/files
 Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=14111&range=06
  Stats: 372 lines in 15 files changed: 339 ins; 3 del; 30 mod
  Patch: https://git.openjdk.org/jdk/pull/14111.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/14111/head:pull/14111

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


Re: RFR: 8309271: A way to align already compiled methods with compiler directives [v6]

2023-08-31 Thread Dmitry Chuyko
> Compiler Control (https://openjdk.org/jeps/165) provides method-context 
> dependent control of the JVM compilers (C1 and C2). The active directive 
> stack is built from the directive files passed with the 
> `-XX:CompilerDirectivesFile` diagnostic command-line option and the 
> Compiler.add_directives diagnostic command. It is also possible to clear all 
> directives or remove the top from the stack.
> 
> A matching directive will be applied at method compilation time when such 
> compilation is started. If directives are added or changed, but compilation 
> does not start, then the state of compiled methods doesn't correspond to the 
> rules. This is not an error, and it happens in long running applications when 
> directives are added or removed after compilation of methods that could be 
> matched. For example, the user decides that C2 compilation needs to be 
> disabled for some method due to a compiler bug, issues such a directive but 
> this does not affect the application behavior. In such case, the target 
> application needs to be restarted, and such an operation can have high costs 
> and risks. Another goal is testing/debugging compilers.
> 
> It would be convenient to optionally reconcile at least existing matching 
> nmethods to the current stack of compiler directives (so bypass inlined 
> methods).
> 
> Natural way to eliminate the discrepancy between the result of compilation 
> and the broken rule is to discard the compilation result, i.e. 
> deoptimization. Prior to that we can try to re-compile the method letting 
> compile broker to perform it taking new directives stack into account. 
> Re-compilation helps to prevent hot methods from execution in the interpreter.
> 
> A new flag `-r` has beed introduced for some directives related to compile 
> commands: `Compiler.add_directives`, `Compiler.remove_directives`, 
> `Compiler.clear_directives`. The default behavior has not changed (no flag). 
> If the new flag is present, the command scans already compiled methods and 
> puts methods that have any active non-default matching compiler directives to 
> re-compilation if possible, otherwise marks them for deoptimization. There is 
> currently no distinction which directives are found. In particular, this 
> means that if there are rules for inlining into some method, it will be 
> refreshed. On the other hand, if there are rules for a method and it was 
> inlined, top-level methods won't be refreshed, but this can be achieved by 
> having rules for them.
> 
> In addition, a new diagnostic command `Compiler.replace_directives`, has been 
> added for ...

Dmitry Chuyko has updated the pull request with a new target base due to a 
merge or a rebase. The pull request now contains 24 commits:

 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - jcheck
 - Unnecessary import
 - force_update->refresh
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Use only top directive for add/remove; better mutex rank definition; texts
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Safe handling of non-java methods
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - ... and 14 more: https://git.openjdk.org/jdk/compare/145d8bc1...b4eb6de0

-

Changes: https://git.openjdk.org/jdk/pull/14111/files
 Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=14111&range=05
  Stats: 372 lines in 15 files changed: 339 ins; 3 del; 30 mod
  Patch: https://git.openjdk.org/jdk/pull/14111.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/14111/head:pull/14111

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


Re: RFR: 8309271: A way to align already compiled methods with compiler directives [v5]

2023-08-24 Thread Dmitry Chuyko
> Compiler Control (https://openjdk.org/jeps/165) provides method-context 
> dependent control of the JVM compilers (C1 and C2). The active directive 
> stack is built from the directive files passed with the 
> `-XX:CompilerDirectivesFile` diagnostic command-line option and the 
> Compiler.add_directives diagnostic command. It is also possible to clear all 
> directives or remove the top from the stack.
> 
> A matching directive will be applied at method compilation time when such 
> compilation is started. If directives are added or changed, but compilation 
> does not start, then the state of compiled methods doesn't correspond to the 
> rules. This is not an error, and it happens in long running applications when 
> directives are added or removed after compilation of methods that could be 
> matched. For example, the user decides that C2 compilation needs to be 
> disabled for some method due to a compiler bug, issues such a directive but 
> this does not affect the application behavior. In such case, the target 
> application needs to be restarted, and such an operation can have high costs 
> and risks. Another goal is testing/debugging compilers.
> 
> It would be convenient to optionally reconcile at least existing matching 
> nmethods to the current stack of compiler directives (so bypass inlined 
> methods).
> 
> Natural way to eliminate the discrepancy between the result of compilation 
> and the broken rule is to discard the compilation result, i.e. 
> deoptimization. Prior to that we can try to re-compile the method letting 
> compile broker to perform it taking new directives stack into account. 
> Re-compilation helps to prevent hot methods from execution in the interpreter.
> 
> A new flag `-r` has beed introduced for some directives related to compile 
> commands: `Compiler.add_directives`, `Compiler.remove_directives`, 
> `Compiler.clear_directives`. The default behavior has not changed (no flag). 
> If the new flag is present, the command scans already compiled methods and 
> puts methods that have any active non-default matching compiler directives to 
> re-compilation if possible, otherwise marks them for deoptimization. There is 
> currently no distinction which directives are found. In particular, this 
> means that if there are rules for inlining into some method, it will be 
> refreshed. On the other hand, if there are rules for a method and it was 
> inlined, top-level methods won't be refreshed, but this can be achieved by 
> having rules for them.
> 
> In addition, a new diagnostic command `Compiler.replace_directives`, has been 
> added for ...

Dmitry Chuyko has updated the pull request with a new target base due to a 
merge or a rebase. The pull request now contains 23 commits:

 - jcheck
 - Unnecessary import
 - force_update->refresh
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Use only top directive for add/remove; better mutex rank definition; texts
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Safe handling of non-java methods
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Renamed -d to -r, clear not compilable flags when directives change, 
original test restored, new test added
 - ... and 13 more: https://git.openjdk.org/jdk/compare/de0e46c2...e361b4fc

-

Changes: https://git.openjdk.org/jdk/pull/14111/files
 Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=14111&range=04
  Stats: 372 lines in 15 files changed: 339 ins; 3 del; 30 mod
  Patch: https://git.openjdk.org/jdk/pull/14111.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/14111/head:pull/14111

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


Re: RFR: 8309271: A way to align already compiled methods with compiler directives [v5]

2023-08-24 Thread Dmitry Chuyko
On Mon, 12 Jun 2023 12:00:48 GMT, Andrei Pangin  wrote:

>> Dmitry Chuyko has updated the pull request with a new target base due to a 
>> merge or a rebase. The pull request now contains 23 commits:
>> 
>>  - jcheck
>>  - Unnecessary import
>>  - force_update->refresh
>>  - Merge branch 'openjdk:master' into compiler-directives-force-update
>>  - Use only top directive for add/remove; better mutex rank definition; texts
>>  - Merge branch 'openjdk:master' into compiler-directives-force-update
>>  - Merge branch 'openjdk:master' into compiler-directives-force-update
>>  - Safe handling of non-java methods
>>  - Merge branch 'openjdk:master' into compiler-directives-force-update
>>  - Renamed -d to -r, clear not compilable flags when directives change, 
>> original test restored, new test added
>>  - ... and 13 more: https://git.openjdk.org/jdk/compare/de0e46c2...e361b4fc
>
> src/hotspot/share/runtime/mutexLocker.cpp line 274:
> 
>> 272:   MUTEX_DEFN(MethodCompileQueue_lock , PaddedMonitor, 
>> safepoint);
>> 273:   MUTEX_DEFN(CompileStatistics_lock  , PaddedMutex  , 
>> safepoint);
>> 274:   MUTEX_DEFN(DirectivesStack_lock, PaddedMutex  , 
>> nosafepoint-3);
> 
> A comment explaining the rank change would be helpful.

Changed the definition to use another macro and relative ranking.

> src/hotspot/share/services/diagnosticCommand.cpp line 890:
> 
>> 888:DCmdWithParser(output, heap),
>> 889:   _filename("filename", "Name of the directives file", "STRING", true),
>> 890:   _force_deopt("-d", "Force deoptimization of affected methods.", 
>> "BOOLEAN", false, "false") {
> 
> I agree with Paul a generic alternative like `refresh` would be better.

Changed the flag, description and names to 'refresh', 'r'.

> src/hotspot/share/services/diagnosticCommand.cpp line 946:
> 
>> 944: DeoptimizationScope deopt_scope;
>> 945: CodeCache::mark_for_deoptimization_directives_matches(&deopt_scope);
>> 946: DirectivesStack::pop(1);
> 
> Why deoptimizing methods from the whole stack if we change only the topmost 
> list?

Agree, now only top directive is involved for add/remove.

> src/hotspot/share/services/diagnosticCommand.hpp line 734:
> 
>> 732: };
>> 733: 
>> 734: class CompilerDirectivesReplaceDCmd : public DCmdWithParser {
> 
> Introducing a new command probably isn't worth it, given the same 
> functionality can be achieved with existing commands. Furthermore, it's not 
> obvious whether "replace" should mean remove+add or clear+add.

'replace' is 'clear'+'add' (we don't have indexes and don't mention top 
element). Additional command is made to avoid double refreshing when '-r' is 
provided. It is more robust as we don't know when methods affected 'clear' are 
finally compiled.

-

PR Review Comment: https://git.openjdk.org/jdk/pull/14111#discussion_r1304026590
PR Review Comment: https://git.openjdk.org/jdk/pull/14111#discussion_r1304088822
PR Review Comment: https://git.openjdk.org/jdk/pull/14111#discussion_r1304028173
PR Review Comment: https://git.openjdk.org/jdk/pull/14111#discussion_r1302901891


Re: RFR: 8309271: A way to align already compiled methods with compiler directives [v4]

2023-07-25 Thread Dmitry Chuyko
> Compiler Control (https://openjdk.org/jeps/165) provides method-context 
> dependent control of the JVM compilers (C1 and C2). The active directive 
> stack is built from the directive files passed with the 
> `-XX:CompilerDirectivesFile` diagnostic command-line option and the 
> Compiler.add_directives diagnostic command. It is also possible to clear all 
> directives or remove the top from the stack.
> 
> A matching directive will be applied at method compilation time when such 
> compilation is started. If directives are added or changed, but compilation 
> does not start, then the state of compiled methods doesn't correspond to the 
> rules. This is not an error, and it happens in long running applications when 
> directives are added or removed after compilation of methods that could be 
> matched. For example, the user decides that C2 compilation needs to be 
> disabled for some method due to a compiler bug, issues such a directive but 
> this does not affect the application behavior. In such case, the target 
> application needs to be restarted, and such an operation can have high costs 
> and risks. Another goal is testing/debugging compilers.
> 
> It would be convenient to optionally reconcile at least existing matching 
> nmethods to the current stack of compiler directives. Methods in general are 
> often inlined, and this information is hard to track down.
> 
> Natural way to eliminate the discrepancy between the result of compilation 
> and the broken rule is to discard the compilation result, i.e. 
> deoptimization. Obviously there is a performance penalty, so it should be 
> applied with care. Hot code will most likely be recompiled soon, as nothing 
> happens to its hotness.
> 
> A new flag '`-d`' has beed introduced for some directives related to compile 
> commands: `Compiler.add_directives`, `Compiler.remove_directives`, 
> `Compiler.clear_directives`. The default behavior has not changed (no flag). 
> If the new flag is present, the command scans already compiled methods and 
> marks for deoptimization those methods that have any active non-default 
> matching compiler directives. There is currently no distinction which 
> directives are found. In particular, this means that if there are rules for 
> inlining into some method, it will be deoptimized. On the other hand, if 
> there are rules for a method and it was inlined, top-level methods won't be 
> deoptimized, but this can be achieved by having rules for them.
> 
> In addition, a new diagnistic command `Compiler.replace_directives`, has been 
> added for convenience. It's like a combinatio...

Dmitry Chuyko has updated the pull request incrementally with one additional 
commit since the last revision:

  jcheck fix

-

Changes:
  - all: https://git.openjdk.org/jdk/pull/14111/files
  - new: https://git.openjdk.org/jdk/pull/14111/files/40de84af..2d8cf4e9

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

  Stats: 1 line in 1 file changed: 0 ins; 0 del; 1 mod
  Patch: https://git.openjdk.org/jdk/pull/14111.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/14111/head:pull/14111

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


Re: RFR: 8309271: A way to align already compiled methods with compiler directives [v3]

2023-07-25 Thread Dmitry Chuyko
> Compiler Control (https://openjdk.org/jeps/165) provides method-context 
> dependent control of the JVM compilers (C1 and C2). The active directive 
> stack is built from the directive files passed with the 
> `-XX:CompilerDirectivesFile` diagnostic command-line option and the 
> Compiler.add_directives diagnostic command. It is also possible to clear all 
> directives or remove the top from the stack.
> 
> A matching directive will be applied at method compilation time when such 
> compilation is started. If directives are added or changed, but compilation 
> does not start, then the state of compiled methods doesn't correspond to the 
> rules. This is not an error, and it happens in long running applications when 
> directives are added or removed after compilation of methods that could be 
> matched. For example, the user decides that C2 compilation needs to be 
> disabled for some method due to a compiler bug, issues such a directive but 
> this does not affect the application behavior. In such case, the target 
> application needs to be restarted, and such an operation can have high costs 
> and risks. Another goal is testing/debugging compilers.
> 
> It would be convenient to optionally reconcile at least existing matching 
> nmethods to the current stack of compiler directives. Methods in general are 
> often inlined, and this information is hard to track down.
> 
> Natural way to eliminate the discrepancy between the result of compilation 
> and the broken rule is to discard the compilation result, i.e. 
> deoptimization. Obviously there is a performance penalty, so it should be 
> applied with care. Hot code will most likely be recompiled soon, as nothing 
> happens to its hotness.
> 
> A new flag '`-d`' has beed introduced for some directives related to compile 
> commands: `Compiler.add_directives`, `Compiler.remove_directives`, 
> `Compiler.clear_directives`. The default behavior has not changed (no flag). 
> If the new flag is present, the command scans already compiled methods and 
> marks for deoptimization those methods that have any active non-default 
> matching compiler directives. There is currently no distinction which 
> directives are found. In particular, this means that if there are rules for 
> inlining into some method, it will be deoptimized. On the other hand, if 
> there are rules for a method and it was inlined, top-level methods won't be 
> deoptimized, but this can be achieved by having rules for them.
> 
> In addition, a new diagnistic command `Compiler.replace_directives`, has been 
> added for convenience. It's like a combinatio...

Dmitry Chuyko has updated the pull request with a new target base due to a 
merge or a rebase. The pull request now contains ten commits:

 - Merge master
 - Recompilation instead of deoptimization
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Formatting
 - Formatting
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Correct arguments info for new commands
 - Update through de-optimization

-

Changes: https://git.openjdk.org/jdk/pull/14111/files
 Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=14111&range=02
  Stats: 267 lines in 14 files changed: 224 ins; 2 del; 41 mod
  Patch: https://git.openjdk.org/jdk/pull/14111.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/14111/head:pull/14111

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


Re: RFR: 8309271: A way to align already compiled methods with compiler directives [v2]

2023-07-25 Thread Dmitry Chuyko
> Compiler Control (https://openjdk.org/jeps/165) provides method-context 
> dependent control of the JVM compilers (C1 and C2). The active directive 
> stack is built from the directive files passed with the 
> `-XX:CompilerDirectivesFile` diagnostic command-line option and the 
> Compiler.add_directives diagnostic command. It is also possible to clear all 
> directives or remove the top from the stack.
> 
> A matching directive will be applied at method compilation time when such 
> compilation is started. If directives are added or changed, but compilation 
> does not start, then the state of compiled methods doesn't correspond to the 
> rules. This is not an error, and it happens in long running applications when 
> directives are added or removed after compilation of methods that could be 
> matched. For example, the user decides that C2 compilation needs to be 
> disabled for some method due to a compiler bug, issues such a directive but 
> this does not affect the application behavior. In such case, the target 
> application needs to be restarted, and such an operation can have high costs 
> and risks. Another goal is testing/debugging compilers.
> 
> It would be convenient to optionally reconcile at least existing matching 
> nmethods to the current stack of compiler directives. Methods in general are 
> often inlined, and this information is hard to track down.
> 
> Natural way to eliminate the discrepancy between the result of compilation 
> and the broken rule is to discard the compilation result, i.e. 
> deoptimization. Obviously there is a performance penalty, so it should be 
> applied with care. Hot code will most likely be recompiled soon, as nothing 
> happens to its hotness.
> 
> A new flag '`-d`' has beed introduced for some directives related to compile 
> commands: `Compiler.add_directives`, `Compiler.remove_directives`, 
> `Compiler.clear_directives`. The default behavior has not changed (no flag). 
> If the new flag is present, the command scans already compiled methods and 
> marks for deoptimization those methods that have any active non-default 
> matching compiler directives. There is currently no distinction which 
> directives are found. In particular, this means that if there are rules for 
> inlining into some method, it will be deoptimized. On the other hand, if 
> there are rules for a method and it was inlined, top-level methods won't be 
> deoptimized, but this can be achieved by having rules for them.
> 
> In addition, a new diagnistic command `Compiler.replace_directives`, has been 
> added for convenience. It's like a combinatio...

Dmitry Chuyko has updated the pull request incrementally with one additional 
commit since the last revision:

  Recompilation instead of deoptimization

-

Changes:
  - all: https://git.openjdk.org/jdk/pull/14111/files
  - new: https://git.openjdk.org/jdk/pull/14111/files/7f9badf8..d0bcf852

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

  Stats: 87 lines in 9 files changed: 38 ins; 10 del; 39 mod
  Patch: https://git.openjdk.org/jdk/pull/14111.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/14111/head:pull/14111

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


RFR: 8309271: A way to align already compiled methods with compiler directives

2023-06-01 Thread Dmitry Chuyko
Compiler Control (https://openjdk.org/jeps/165) provides method-context 
dependent control of the JVM compilers (C1 and C2). The active directive stack 
is built from the directive files passed with the `-XX:CompilerDirectivesFile` 
diagnostic command-line option and the Compiler.add_directives diagnostic 
command. It is also possible to clear all directives or remove the top from the 
stack.

A matching directive will be applied at method compilation time when such 
compilation is started. If directives are added or changed, but compilation 
does not start, then the state of compiled methods doesn't correspond to the 
rules. This is not an error, and it happens in long running applications when 
directives are added or removed after compilation of methods that could be 
matched. For example, the user decides that C2 compilation needs to be disabled 
for some method due to a compiler bug, issues such a directive but this does 
not affect the application behavior. In such case, the target application needs 
to be restarted, and such an operation can have high costs and risks. Another 
goal is testing/debugging compilers.

It would be convenient to optionally reconcile at least existing matching 
nmethods to the current stack of compiler directives. Methods in general are 
often inlined, and this information is hard to track down.

Natural way to eliminate the discrepancy between the result of compilation and 
the broken rule is to discard the compilation result, i.e. deoptimization. 
Obviously there is a performance penalty, so it should be applied with care. 
Hot code will most likely be recompiled soon, as nothing happens to its hotness.

A new flag '`-d`' has beed introduced for some directives related to compile 
commands: `Compiler.add_directives`, `Compiler.remove_directives`, 
`Compiler.clear_directives`. The default behavior has not changed (no flag). If 
the new flag is present, the command scans already compiled methods and marks 
for deoptimization those methods that have any active non-default matching 
compiler directives. There is currently no distinction which directives are 
found. In particular, this means that if there are rules for inlining into some 
method, it will be deoptimized. On the other hand, if there are rules for a 
method and it was inlined, top-level methods won't be deoptimized, but this can 
be achieved by having rules for them.

In addition, a new diagnistic command `Compiler.replace_directives`, has been 
added for convenience. It's like a combination of `Compiler.clear_directives` 
and `Compiler.add_directives`. It supports the same new optional '-d' flag that 
marks both cleared and added methods for deoptimization.

The behavior of the '-d' flag is implemented in the new 
`CodeCache::mark_for_deoptimization_directives_matches` and 
`DirectivesStack::hasMatchingDirectives` methods.

`CompilerDirectivesDCMDTest` now checks add, remove and replace commands in two 
modes (default and '-d') and checks that '-d' flag causes deoptimization.

An alternative approach to the '-d' flag could be to have a special diagnostic 
command for deoptimization. It will get a list of method patterns and reuse the 
matcher, however this is not so trivial. Overall usage and effects will be 
similar but this is one more file format. The user will also need to monitor or 
query active directives in advance, e.g. to deoptimize all mentioned methods 
after clearing all directives.

An alternative approach for selection of deoptimized methods could be to track 
down all inlining dependencies. This may be similar to searching references to 
old methods, but it requires scanning all code blobs, which looks too expensive.

An alternative naming for the flag is welcome. The obvious '-f' ('force') 
unfortunately has a conflict. Other verbs can be 'update', 'refresh' or 
'apply'. Deoptimization is just what's done to reconcile the state. It could be 
something else, like first compiling with a different compiler and then 
switching to that version. Although in the latter case, triggered compilation 
would be an essential detail.

-

Commit messages:
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Formatting
 - Formatting
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Merge branch 'openjdk:master' into compiler-directives-force-update
 - Correct arguments info for new commands
 - Update through de-optimization

Changes: https://git.openjdk.org/jdk/pull/14111/files
 Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=14111&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8309271
  Stats: 214 lines in 9 files changed: 194 ins; 0 del; 20 mod
  Patch: https://git.openjdk.org/jdk/pull/14111.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/14111/head:pull/14111

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