Re: RFR: 8301995: Move invokedynamic resolution information out of ConstantPoolCacheEntry [v6]

2023-03-17 Thread Andrey Turbanov
On Wed, 15 Mar 2023 18:45:00 GMT, Matias Saavedra Silva  
wrote:

>> The current structure used to store the resolution information for 
>> invokedynamic, ConstantPoolCacheEntry, is difficult to interpret due to its 
>> ambigious fields f1 and f2. This structure can hold information for fields, 
>> methods, and invokedynamics and each of its fields can hold different types 
>> of values depending on the entry. 
>> 
>> This enhancement proposes a new structure to exclusively contain 
>> invokedynamic information in a manner that is easy to interpret and easy to 
>> extend.  Resolved invokedynamic entries will be stored in an array in the 
>> constant pool cache and the operand of the invokedynamic bytecode will be 
>> rewritten to be the index into this array.
>> 
>> Any areas that previously accessed invokedynamic data from 
>> ConstantPoolCacheEntry will be replaced with accesses to this new array and 
>> structure. Verified with tier1-9 tests.
>> 
>> The PPC was provided by @reinrich and the RISCV port was provided by 
>> @DingliZhang and @zifeihan.
>> 
>> This change supports the following platforms: x86, aarch64, PPC, and RISCV
>
> Matias Saavedra Silva has updated the pull request incrementally with one 
> additional commit since the last revision:
> 
>   Fixed aarch64 interpreter mistake

src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/ResolvedIndyEntry.java 
line 49:

> 47: 
> 48: private static synchronized void initialize(TypeDataBase db) throws 
> WrongTypeException {
> 49: Type type= db.lookupType("ResolvedIndyEntry");

Suggestion:

Type type = db.lookupType("ResolvedIndyEntry");

-

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


Re: RFR: 8301995: Move invokedynamic resolution information out of ConstantPoolCacheEntry [v6]

2023-03-16 Thread Matias Saavedra Silva
On Thu, 16 Mar 2023 16:11:57 GMT, Richard Reingruber  wrote:

>> Matias Saavedra Silva has updated the pull request incrementally with one 
>> additional commit since the last revision:
>> 
>>   Fixed aarch64 interpreter mistake
>
> src/hotspot/cpu/aarch64/templateTable_aarch64.cpp line 2335:
> 
>> 2333: 
>> 2334:   __ load_resolved_indy_entry(cache, index);
>> 2335:   __ ldr(method, Address(cache, 
>> in_bytes(ResolvedIndyEntry::method_offset(;
> 
> Should this load have acquire semantics?
> Like [here in template 
> interpreter](https://github.com/openjdk/jdk/blob/2f23c80e0de44815d26a7d541701e16c9c1d32bc/src/hotspot/cpu/aarch64/interp_masm_aarch64.cpp#L239)
>  and [here for the zero 
> interpreter](https://github.com/openjdk/jdk/blob/2f23c80e0de44815d26a7d541701e16c9c1d32bc/src/hotspot/share/oops/cpCache.inline.hpp#L33)?
> 
> Call stack for zero interpreter is
> 
> ConstantPoolCacheEntry::indices_ord()
> ConstantPoolCacheEntry::bytecode_1()
> ConstantPoolCacheEntry::is_resolved(enum Bytecodes::Code)
> BytecodeInterpreter::run(interpreterState)

Yes, acquire semantics should be used here. Thank you for pointing this out!

-

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


Re: RFR: 8301995: Move invokedynamic resolution information out of ConstantPoolCacheEntry [v6]

2023-03-16 Thread Richard Reingruber
On Wed, 15 Mar 2023 18:45:00 GMT, Matias Saavedra Silva  
wrote:

>> The current structure used to store the resolution information for 
>> invokedynamic, ConstantPoolCacheEntry, is difficult to interpret due to its 
>> ambigious fields f1 and f2. This structure can hold information for fields, 
>> methods, and invokedynamics and each of its fields can hold different types 
>> of values depending on the entry. 
>> 
>> This enhancement proposes a new structure to exclusively contain 
>> invokedynamic information in a manner that is easy to interpret and easy to 
>> extend.  Resolved invokedynamic entries will be stored in an array in the 
>> constant pool cache and the operand of the invokedynamic bytecode will be 
>> rewritten to be the index into this array.
>> 
>> Any areas that previously accessed invokedynamic data from 
>> ConstantPoolCacheEntry will be replaced with accesses to this new array and 
>> structure. Verified with tier1-9 tests.
>> 
>> The PPC was provided by @reinrich and the RISCV port was provided by 
>> @DingliZhang and @zifeihan.
>> 
>> This change supports the following platforms: x86, aarch64, PPC, and RISCV
>
> Matias Saavedra Silva has updated the pull request incrementally with one 
> additional commit since the last revision:
> 
>   Fixed aarch64 interpreter mistake

src/hotspot/cpu/aarch64/templateTable_aarch64.cpp line 2335:

> 2333: 
> 2334:   __ load_resolved_indy_entry(cache, index);
> 2335:   __ ldr(method, Address(cache, 
> in_bytes(ResolvedIndyEntry::method_offset(;

Should this load have acquire semantics?
Like [here in template 
interpreter](https://github.com/openjdk/jdk/blob/2f23c80e0de44815d26a7d541701e16c9c1d32bc/src/hotspot/cpu/aarch64/interp_masm_aarch64.cpp#L239)
 and [here for the zero 
interpreter](https://github.com/openjdk/jdk/blob/2f23c80e0de44815d26a7d541701e16c9c1d32bc/src/hotspot/share/oops/cpCache.inline.hpp#L33)?

Call stack for zero interpreter is

ConstantPoolCacheEntry::indices_ord()
ConstantPoolCacheEntry::bytecode_1()
ConstantPoolCacheEntry::is_resolved(enum Bytecodes::Code)
BytecodeInterpreter::run(interpreterState)

-

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


Re: RFR: 8301995: Move invokedynamic resolution information out of ConstantPoolCacheEntry [v6]

2023-03-16 Thread Richard Reingruber
On Wed, 15 Mar 2023 18:45:00 GMT, Matias Saavedra Silva  
wrote:

>> The current structure used to store the resolution information for 
>> invokedynamic, ConstantPoolCacheEntry, is difficult to interpret due to its 
>> ambigious fields f1 and f2. This structure can hold information for fields, 
>> methods, and invokedynamics and each of its fields can hold different types 
>> of values depending on the entry. 
>> 
>> This enhancement proposes a new structure to exclusively contain 
>> invokedynamic information in a manner that is easy to interpret and easy to 
>> extend.  Resolved invokedynamic entries will be stored in an array in the 
>> constant pool cache and the operand of the invokedynamic bytecode will be 
>> rewritten to be the index into this array.
>> 
>> Any areas that previously accessed invokedynamic data from 
>> ConstantPoolCacheEntry will be replaced with accesses to this new array and 
>> structure. Verified with tier1-9 tests.
>> 
>> The PPC was provided by @reinrich and the RISCV port was provided by 
>> @DingliZhang and @zifeihan.
>> 
>> This change supports the following platforms: x86, aarch64, PPC, and RISCV
>
> Matias Saavedra Silva has updated the pull request incrementally with one 
> additional commit since the last revision:
> 
>   Fixed aarch64 interpreter mistake

src/hotspot/cpu/ppc/templateTable_ppc_64.cpp line 3398:

> 3396:   const Bytecodes::Code code = bytecode();
> 3397:   const bool is_invokeinterface  = code == Bytecodes::_invokeinterface;
> 3398:   const bool is_invokedynamic= code == false; // should not reach 
> here with invokedynamic

This is what I meant.

Suggestion:

  const bool is_invokedynamic= false; // should not reach here with 
invokedynamic


Thanks!

-

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


Re: RFR: 8301995: Move invokedynamic resolution information out of ConstantPoolCacheEntry [v6]

2023-03-16 Thread Richard Reingruber
On Thu, 16 Mar 2023 09:21:26 GMT, Martin Doerr  wrote:

>> Basically I kept the local variable as a name for the (now) constant value 
>> passed in the call at L3409.
>> 
>> The parameter cannot be eliminated since `load_invoke_cp_cache_entry()` is 
>> declared in a shared header.
>> 
>> I could replace the variable reference in the call with `false /* 
>> is_invokedynamic */` if you like that better. Personally I'd prefer the 
>> current version.
>
> I meant `code == false`. That was probably not intended.

Oh my ... Your are right of course.

-

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


Re: RFR: 8301995: Move invokedynamic resolution information out of ConstantPoolCacheEntry [v6]

2023-03-16 Thread Martin Doerr
On Thu, 16 Mar 2023 09:07:27 GMT, Richard Reingruber  wrote:

>> src/hotspot/cpu/ppc/templateTable_ppc_64.cpp line 3398:
>> 
>>> 3396:   const Bytecodes::Code code = bytecode();
>>> 3397:   const bool is_invokeinterface  = code == 
>>> Bytecodes::_invokeinterface;
>>> 3398:   const bool is_invokedynamic= code == false; // should not reach 
>>> here with invokedynamic
>> 
>> This looks strange! I guess you wanted to delete more?
>
> Basically I kept the local variable as a name for the (now) constant value 
> passed in the call at L3409.
> 
> The parameter cannot be eliminated since `load_invoke_cp_cache_entry()` is 
> declared in a shared header.
> 
> I could replace the variable reference in the call with `false /* 
> is_invokedynamic */` if you like that better. Personally I'd prefer the 
> current version.

I meant `code == false`. That was probably not intended.

-

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


Re: RFR: 8301995: Move invokedynamic resolution information out of ConstantPoolCacheEntry [v6]

2023-03-16 Thread Richard Reingruber
On Wed, 15 Mar 2023 19:04:41 GMT, Martin Doerr  wrote:

>> Matias Saavedra Silva has updated the pull request incrementally with one 
>> additional commit since the last revision:
>> 
>>   Fixed aarch64 interpreter mistake
>
> src/hotspot/cpu/ppc/templateTable_ppc_64.cpp line 3398:
> 
>> 3396:   const Bytecodes::Code code = bytecode();
>> 3397:   const bool is_invokeinterface  = code == Bytecodes::_invokeinterface;
>> 3398:   const bool is_invokedynamic= code == false; // should not reach 
>> here with invokedynamic
> 
> This looks strange! I guess you wanted to delete more?

Basically I kept the local variable as a name for the (now) constant value 
passed in the call at L3409.

The parameter cannot be eliminated since `load_invoke_cp_cache_entry()` is 
declared in a shared header.

I could replace the variable reference in the call with `false /* 
is_invokedynamic */` if you like that better. Personally I'd prefer the current 
version.

-

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


Re: RFR: 8301995: Move invokedynamic resolution information out of ConstantPoolCacheEntry [v6]

2023-03-15 Thread Martin Doerr
On Wed, 15 Mar 2023 18:45:00 GMT, Matias Saavedra Silva  
wrote:

>> The current structure used to store the resolution information for 
>> invokedynamic, ConstantPoolCacheEntry, is difficult to interpret due to its 
>> ambigious fields f1 and f2. This structure can hold information for fields, 
>> methods, and invokedynamics and each of its fields can hold different types 
>> of values depending on the entry. 
>> 
>> This enhancement proposes a new structure to exclusively contain 
>> invokedynamic information in a manner that is easy to interpret and easy to 
>> extend.  Resolved invokedynamic entries will be stored in an array in the 
>> constant pool cache and the operand of the invokedynamic bytecode will be 
>> rewritten to be the index into this array.
>> 
>> Any areas that previously accessed invokedynamic data from 
>> ConstantPoolCacheEntry will be replaced with accesses to this new array and 
>> structure. Verified with tier1-9 tests.
>> 
>> The PPC was provided by @reinrich and the RISCV port was provided by 
>> @DingliZhang and @zifeihan.
>> 
>> This change supports the following platforms: x86, aarch64, PPC, and RISCV
>
> Matias Saavedra Silva has updated the pull request incrementally with one 
> additional commit since the last revision:
> 
>   Fixed aarch64 interpreter mistake

src/hotspot/cpu/ppc/templateTable_ppc_64.cpp line 3398:

> 3396:   const Bytecodes::Code code = bytecode();
> 3397:   const bool is_invokeinterface  = code == Bytecodes::_invokeinterface;
> 3398:   const bool is_invokedynamic= code == false; // should not reach 
> here with invokedynamic

This looks strange! I guess you wanted to delete more?

-

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


Re: RFR: 8301995: Move invokedynamic resolution information out of ConstantPoolCacheEntry [v6]

2023-03-15 Thread Matias Saavedra Silva
> The current structure used to store the resolution information for 
> invokedynamic, ConstantPoolCacheEntry, is difficult to interpret due to its 
> ambigious fields f1 and f2. This structure can hold information for fields, 
> methods, and invokedynamics and each of its fields can hold different types 
> of values depending on the entry. 
> 
> This enhancement proposes a new structure to exclusively contain 
> invokedynamic information in a manner that is easy to interpret and easy to 
> extend.  Resolved invokedynamic entries will be stored in an array in the 
> constant pool cache and the operand of the invokedynamic bytecode will be 
> rewritten to be the index into this array.
> 
> Any areas that previously accessed invokedynamic data from 
> ConstantPoolCacheEntry will be replaced with accesses to this new array and 
> structure. Verified with tier1-9 tests.
> 
> The PPC was provided by @reinrich and the RISCV port was provided by 
> @DingliZhang and @zifeihan.
> 
> This change supports the following platforms: x86, aarch64, PPC, and RISCV

Matias Saavedra Silva has updated the pull request incrementally with one 
additional commit since the last revision:

  Fixed aarch64 interpreter mistake

-

Changes:
  - all: https://git.openjdk.org/jdk/pull/12778/files
  - new: https://git.openjdk.org/jdk/pull/12778/files/415e7116..9a3a63ae

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=jdk&pr=12778&range=05
 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=12778&range=04-05

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

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