Re: RFR: 8288011: StringConcatFactory: Split application of stringifiers

2022-06-08 Thread Сергей Цыпанов
On Wed, 8 Jun 2022 10:20:37 GMT, Claes Redestad wrote: > To take optimal advantage of the pre-existing optimization for repeated > filters we could split the application of different types of stringifiers. > > The resulting difference in order of evaluation is not observable by > conventional

Re: RFR: 8287908: Use non-cloning reflection methods where acceptable [v2]

2022-06-08 Thread Сергей Цыпанов
> Instead of `Executable.getParameterTypes()` we could use > `Executable.getSharedParameterTypes()` in trusted code. Same is applicable > for `Executable.getExceptionTypes()`. Сергей Цыпанов has updated the pull request with a new target base due to a merge or a rebase. The increment

RFR: 8287908: Use non-cloning reflection methods where acceptable

2022-06-07 Thread Сергей Цыпанов
Instead of `Executable.getParameterTypes()` we could use `Executable.getSharedParameterTypes()` in trusted code. Same is applicable for `Executable.getExceptionTypes()`. - Commit messages: - 8287908: Use non-cloning reflection methods where acceptable Changes:

Integrated: 8287860: Revise usage of volatile in j.u.Locale

2022-06-07 Thread Сергей Цыпанов
On Mon, 6 Jun 2022 12:58:39 GMT, Сергей Цыпанов wrote: > - cached hash code of `Locale` and `Locale$LanguageRange` shouldn't be > volatile, even in case of race in the worst case it is recalculated at most > once per thread > - `defaultLocale` field is read multiple times in

Re: RFR: 8287860: Revise usage of volatile in j.u.Locale [v2]

2022-06-06 Thread Сергей Цыпанов
On Mon, 6 Jun 2022 17:31:15 GMT, Naoto Sato wrote: >> Сергей Цыпанов has updated the pull request incrementally with one >> additional commit since the last revision: >> >> 8287860: Mark hash fields with @Stable > > src/java.base/share/classes/java/util/Loc

Re: RFR: 8287860: Revise usage of volatile in j.u.Locale [v3]

2022-06-06 Thread Сергей Цыпанов
multiple times in `getISOLanguages()` > - `languageTag` is read twice in `toLanguageTag()` Сергей Цыпанов has updated the pull request incrementally with one additional commit since the last revision: 8287860: Rename local vars - Changes: - all: https://git.openjdk.java.net/jdk/pull/

Re: RFR: 8287860: Revise usage of volatile in j.u.Locale [v2]

2022-06-06 Thread Сергей Цыпанов
On Mon, 6 Jun 2022 13:34:27 GMT, liach wrote: >> These fields can only be written once besides the default values, but they >> don't have to be written in the static initializer or constructor. So when a >> non-zero hash code is written, it's cached as if it's a final field. For a >> zero

Re: RFR: 8287860: Revise usage of volatile in j.u.Locale [v2]

2022-06-06 Thread Сергей Цыпанов
multiple times in `getISOLanguages()` > - `languageTag` is read twice in `toLanguageTag()` Сергей Цыпанов has updated the pull request incrementally with one additional commit since the last revision: 8287860: Mark hash fields with @Stable - Changes: - all: https://git.openjdk.java.net/j

Re: RFR: 8287860: Revise usage of volatile in j.u.Locale

2022-06-06 Thread Сергей Цыпанов
On Mon, 6 Jun 2022 13:20:31 GMT, liach wrote: >> - cached hash code of `Locale` and `Locale$LanguageRange` shouldn't be >> volatile, even in case of race in the worst case it is recalculated at most >> once per thread >> - `defaultLocale` field is read multiple times in `initDefault()` >> -

RFR: 8287860: Revise usage of volatile in j.u.Locale

2022-06-06 Thread Сергей Цыпанов
- cached hash code of `Locale` and `Locale$LanguageRange` shouldn't be volatile, even in case of race in the worst case it is recalculated at most once per thread - `defaultLocale` field is read multiple times in `initDefault()` - `isoLanguages` is accessed multiple times in `getISOLanguages()`

Re: RFR: 8287442: Reduce list to array conversions in java.lang.invoke.MethodHandles [v2]

2022-06-02 Thread Сергей Цыпанов
On Thu, 2 Jun 2022 14:25:55 GMT, Daniel Fuchs wrote: >> src/java.base/share/classes/java/lang/invoke/MethodHandles.java line 5462: >> >>> 5460: Objects.requireNonNull(target); >>> 5461: Objects.requireNonNull(newTypes); >>> 5462: return dropArgumentsToMatch(target, skip,

Re: RFR: 8287442: Reduce list to array conversions in java.lang.invoke.MethodHandles [v2]

2022-06-02 Thread Сергей Цыпанов
On Fri, 27 May 2022 19:52:30 GMT, Claes Redestad wrote: >> In preparation of #8855 this PR refactors the conversions from `List` to >> array and array to `List`, reducing the number of conversions when calling >> `MethodHandles.dropArguments` in particular. This remove about ~5% of >>

Integrated: 8282662: Use List.of() factory method to reduce memory consumption

2022-06-01 Thread Сергей Цыпанов
On Mon, 7 Mar 2022 15:11:50 GMT, Сергей Цыпанов wrote: > `List.of()` along with `Set.of()` create unmodifiable `List/Set` but with > smaller footprint comparing to `Arrays.asList()` / `new HashSet()` when > called with vararg of size 0, 1, 2. > > In general replacement of

Re: RFR: 8282662: Use List.of() factory method to reduce memory consumption [v9]

2022-06-01 Thread Сергей Цыпанов
parameter types are never null > - interfaces used for proxy construction and returned from > `Class.getInterfaces()` are never null > - exceptions types of method signature are never null Сергей Цыпанов has updated the pull request incrementally with one additional commit since the

Re: RFR: 8282662: Use List.of() factory method to reduce memory consumption [v8]

2022-05-31 Thread Сергей Цыпанов
On Tue, 31 May 2022 19:33:15 GMT, Roger Riggs wrote: >> Сергей Цыпанов has updated the pull request with a new target base due to a >> merge or a rebase. The incremental webrev excludes the unrelated changes >> brought in by the merge/rebase. The pull request conta

Re: RFR: 8282662: Use List.of() factory method to reduce memory consumption [v8]

2022-05-31 Thread Сергей Цыпанов
parameter types are never null > - interfaces used for proxy construction and returned from > `Class.getInterfaces()` are never null > - exceptions types of method signature are never null Сергей Цыпанов has updated the pull request with a new target base due to a merge or a rebase. Th

Re: RFR: 8282662: Use List.of() factory method to reduce memory consumption [v7]

2022-05-31 Thread Сергей Цыпанов
parameter types are never null > - interfaces used for proxy construction and returned from > `Class.getInterfaces()` are never null > - exceptions types of method signature are never null Сергей Цыпанов has updated the pull request with a new target base due to a merge or a rebase. Th

Re: RFR: 8282662: Use List.of() factory method to reduce memory consumption [v6]

2022-05-26 Thread Сергей Цыпанов
parameter types are never null > - interfaces used for proxy construction and returned from > `Class.getInterfaces()` are never null > - exceptions types of method signature are never null Сергей Цыпанов has updated the pull request with a new target base due to a merge or a rebase. Th

Re: RFR: 8282662: Use List.of() factory method to reduce memory consumption [v5]

2022-05-18 Thread Сергей Цыпанов
parameter types are never null > - interfaces used for proxy construction and returned from > `Class.getInterfaces()` are never null > - exceptions types of method signature are never null Сергей Цыпанов has updated the pull request with a new target base due to a merge or a rebase. Th

Re: RFR: 8282662: Use List.of() factory method to reduce memory consumption [v3]

2022-05-18 Thread Сергей Цыпанов
On Mon, 16 May 2022 15:29:38 GMT, Сергей Цыпанов wrote: >> Even in the no exceptions case, the `exceptionTypes` array still has to be  >> allocated/copied by `Method.getExceptionTypes()`[^1] when the `ProxyMethod`  >> constructor[^2] is invoked. >> >> So if a

Re: RFR: 8282662: Use List.of() factory method to reduce memory consumption [v4]

2022-05-18 Thread Сергей Цыпанов
parameter types are never null > - interfaces used for proxy construction and returned from > `Class.getInterfaces()` are never null > - exceptions types of method signature are never null Сергей Цыпанов has updated the pull request with a new target base due to a merge or a

Re: RFR: 8282662: Use List.of() factory method to reduce memory consumption [v3]

2022-05-16 Thread Сергей Цыпанов
On Fri, 13 May 2022 13:36:52 GMT, ExE Boss wrote: > So if anything, the List.of(…) call should be moved into the ProxyMethod > constructor. And maybe the call to Method.getExceptionTypes() should be > changed to Method.getSharedExceptionTypes() Makes sense. Do you want me to do this within

Re: RFR: 8282662: Use List.of() factory method to reduce memory consumption [v3]

2022-05-13 Thread Сергей Цыпанов
On Fri, 13 May 2022 11:14:29 GMT, ExE Boss wrote: >> Сергей Цыпанов has updated the pull request incrementally with one >> additional commit since the last revision: >> >> 8282662: Revert dubious changes in MethodType > > src/java.base/share/classes/java/lang/re

Re: RFR: 8282662: Use List.of() factory method to reduce memory consumption [v3]

2022-05-13 Thread Сергей Цыпанов
On Fri, 13 May 2022 12:19:08 GMT, Сергей Цыпанов wrote: >> src/java.base/share/classes/java/lang/reflect/ProxyGenerator.java line 727: >> >>> 725: MethodVisitor mv = cw.visitMethod(accessFlags, >>> 726: method.

Re: RFR: 8282662: Use List.of() factory method to reduce memory consumption [v3]

2022-05-13 Thread Сергей Цыпанов
On Thu, 12 May 2022 14:14:38 GMT, Weijun Wang wrote: >> Сергей Цыпанов has updated the pull request incrementally with one >> additional commit since the last revision: >> >> 8282662: Revert dubious changes in MethodType > > src/java.base/share/

Integrated: 8282701: Use Class.getInterfaces(false) where possible to reduce allocation pressure

2022-05-10 Thread Сергей Цыпанов
On Sat, 5 Mar 2022 13:07:56 GMT, Сергей Цыпанов wrote: > `Class.getInterfaces(false)` does not clone underlying array and can be used > in cases when the returned array is only read from. This pull request has now been integrated. Changeset: 9073a98d Author:Sergey Tsypanov Com

Re: RFR: 8282701: Use Class.getInterfaces(false) where possible to reduce allocation pressure [v2]

2022-05-04 Thread Сергей Цыпанов
On Wed, 4 May 2022 09:46:00 GMT, Сергей Цыпанов wrote: >> `Class.getInterfaces(false)` does not clone underlying array and can be used >> in cases when the returned array is only read from. > > Сергей Цыпанов has updated the pull request incrementally with one addition

Re: RFR: 8282701: Use Class.getInterfaces(false) where possible to reduce allocation pressure [v2]

2022-05-04 Thread Сергей Цыпанов
> `Class.getInterfaces(false)` does not clone underlying array and can be used > in cases when the returned array is only read from. Сергей Цыпанов has updated the pull request incrementally with one additional commit since the last revision: 8282701: Revert some irrelevant c

Re: RFR: 8282701: Use Class.getInterfaces(false) where possible to reduce allocation pressure

2022-05-02 Thread Сергей Цыпанов
On Sat, 5 Mar 2022 13:07:56 GMT, Сергей Цыпанов wrote: > `Class.getInterfaces(false)` does not clone underlying array and can be used > in cases when the returned array is only read from. Let's wait a bit - PR: https://git.openjdk.java.net/jdk/pull/7714

Re: RFR: 8282662: Use List.of() factory method to reduce memory consumption [v3]

2022-04-26 Thread Сергей Цыпанов
On Thu, 10 Mar 2022 08:52:17 GMT, Сергей Цыпанов wrote: >> `List.of()` along with `Set.of()` create unmodifiable `List/Set` but with >> smaller footprint comparing to `Arrays.asList()` / `new HashSet()` when >> called with vararg of size 0, 1, 2. >> >> In general

Re: RFR: 8282662: Use List.of() factory method to reduce memory consumption [v3]

2022-03-29 Thread Сергей Цыпанов
On Sat, 26 Mar 2022 16:35:14 GMT, liach wrote: >> Сергей Цыпанов has updated the pull request incrementally with one >> additional commit since the last revision: >> >> 8282662: Revert dubious changes in MethodType > > Just curious, this issue asks to replace

Re: RFR: 8282662: Use List/Set.of() factory methods to reduce memory consumption [v3]

2022-03-26 Thread Сергей Цыпанов
On Thu, 10 Mar 2022 08:52:17 GMT, Сергей Цыпанов wrote: >> `List.of()` along with `Set.of()` create unmodifiable `List/Set` but with >> smaller footprint comparing to `Arrays.asList()` / `new HashSet()` when >> called with vararg of size 0, 1, 2. >> >> In general

Re: RFR: 8282662: Use List/Set.of() factory methods to reduce memory consumption [v2]

2022-03-10 Thread Сергей Цыпанов
On Wed, 9 Mar 2022 16:09:01 GMT, liach wrote: >> Сергей Цыпанов has updated the pull request incrementally with one >> additional commit since the last revision: >> >> 8282662: Revert dubious changes > > src/java.base/share/classes/java/lang/invoke/Metho

Re: RFR: 8282662: Use List/Set.of() factory methods to reduce memory consumption [v3]

2022-03-10 Thread Сергей Цыпанов
parameter types are never null > - interfaces used for proxy construction and returned from > `Class.getInterfaces()` are never null > - exceptions types of method signature are never null Сергей Цыпанов has updated the pull request incrementally with one additional commit since the la

Re: RFR: 8282662: Use List/Set.of() factory methods to reduce memory consumption [v2]

2022-03-09 Thread Сергей Цыпанов
On Tue, 8 Mar 2022 14:27:23 GMT, liach wrote: >> Сергей Цыпанов has updated the pull request incrementally with one >> additional commit since the last revision: >> >> 8282662: Revert dubious changes > > src/java.base/share/classes/java/nio/file/FileTreeI

Re: RFR: 8282662: Use List/Set.of() factory methods to reduce memory consumption [v2]

2022-03-09 Thread Сергей Цыпанов
On Tue, 8 Mar 2022 14:28:00 GMT, liach wrote: >> Сергей Цыпанов has updated the pull request incrementally with one >> additional commit since the last revision: >> >> 8282662: Revert dubious changes > > src/java.base/share/classes/sun/reflect/annotation/Ann

Re: RFR: 8282662: Use List/Set.of() factory methods to reduce memory consumption [v2]

2022-03-09 Thread Сергей Цыпанов
parameter types are never null > - interfaces used for proxy construction and returned from > `Class.getInterfaces()` are never null > - exceptions types of method signature are never null Сергей Цыпанов has updated the pull request incrementally with one additional commit since the la

Re: RFR: 8282662: Use List/Set.of() factory methods to reduce memory consumption

2022-03-08 Thread Сергей Цыпанов
On Mon, 7 Mar 2022 16:06:44 GMT, Claes Redestad wrote: > Notice list.of will have the downside of copying the input array when the > size is not small while arrays aslist does not. Is the tradeoff worth it? Good point, I see risky changes in this PR: - `ProxyGenerator` - `Proxy` - `MethodType`

RFR: 8282662: Use List/Set.of() factory methods to reduce memory consumption

2022-03-07 Thread Сергей Цыпанов
`List.of()` along with `Set.of()` create unmodifiable `List/Set` but with smaller footprint comparing to `Arrays.asList()` / `new HashSet()` when called with vararg of size 0, 1, 2. In general replacement of `Arrays.asList()` with `List.of()` is dubious as the latter is null-hostile, however

RFR: 8282701: Use Class.getInterfaces(false) where possible to reduce allocation pressure

2022-03-05 Thread Сергей Цыпанов
`Class.getInterfaces(false)` does not clone underlying array and can be used in cases when the returned array is only read from. - Commit messages: - 8282701: Use Class.getInterfaces(false) where possible to reduce allocation pressure Changes:

Re: RFR: 8279833: Loop optimization issue in String.encodeUTF8_UTF16 [v4]

2022-01-12 Thread Сергей Цыпанов
On Tue, 11 Jan 2022 13:53:58 GMT, Claes Redestad wrote: >> In `String.encodeUTF8_UTF16`, making the `char c` local to each loop helps >> the performance of the method by helping C2 optimize each individual loop >> better. >> >> Results on the updated micros: >> 19-b04: >> >> Benchmark

Withdrawn: 8278518: String(byte[], int, int, Charset) constructor and String.translateEscapes() miss bounds check elimination

2022-01-12 Thread Сергей Цыпанов
On Mon, 13 Dec 2021 09:39:55 GMT, Сергей Цыпанов wrote: > Originally this was spotted by by Amir Hadadi in > https://stackoverflow.com/questions/70272651/missing-bounds-checking-elimination-in-string-constructor > > It looks like in the following code in `String(byte[], int,

Re: RFR: 8278518: String(byte[], int, int, Charset) constructor and String.translateEscapes() miss bounds check elimination

2022-01-12 Thread Сергей Цыпанов
On Mon, 13 Dec 2021 09:39:55 GMT, Сергей Цыпанов wrote: > Originally this was spotted by by Amir Hadadi in > https://stackoverflow.com/questions/70272651/missing-bounds-checking-elimination-in-string-constructor > > It looks like in the following code in `String(byte[], int,

Integrated: 8278461: Use Executable.getSharedParameterTypes() instead of Executable.getParameterTypes() in trusted code

2022-01-12 Thread Сергей Цыпанов
On Thu, 9 Dec 2021 11:50:50 GMT, Сергей Цыпанов wrote: > `Executable.getParameterTypes()` creates a copy of underlying array which is > redundant in trusted code when we are sure the action is read-only. This pull request has now been integrated. Changeset: ece98d85 Author:Sergey Ts

Re: RFR: 8278461: Use Executable.getSharedParameterTypes() instead of Executable.getParameterTypes() in trusted code [v3]

2022-01-10 Thread Сергей Цыпанов
> `Executable.getParameterTypes()` creates a copy of underlying array which is > redundant in trusted code when we are sure the action is read-only. Сергей Цыпанов has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains two c

Re: RFR: 8278461: Use Executable.getSharedParameterTypes() instead of Executable.getParameterTypes() in trusted code [v2]

2022-01-10 Thread Сергей Цыпанов
> `Executable.getParameterTypes()` creates a copy of underlying array which is > redundant in trusted code when we are sure the action is read-only. Сергей Цыпанов has updated the pull request incrementally with one additional commit since the last revision: 8278461: Revert Exec

Re: RFR: 8278461: Use Executable.getSharedParameterTypes() instead of Executable.getParameterTypes() in trusted code [v2]

2022-01-10 Thread Сергей Цыпанов
On Mon, 10 Jan 2022 09:38:15 GMT, Сергей Цыпанов wrote: >> src/java.base/share/classes/java/lang/reflect/Executable.java line 313: >> >>> 311: // getParameterTypes(). >>> 312: if (!genericInfo) { >>> 313: return getSharedPara

Re: RFR: 8278461: Use Executable.getSharedParameterTypes() instead of Executable.getParameterTypes() in trusted code

2022-01-10 Thread Сергей Цыпанов
On Thu, 6 Jan 2022 16:45:09 GMT, Claes Redestad wrote: >> `Executable.getParameterTypes()` creates a copy of underlying array which is >> redundant in trusted code when we are sure the action is read-only. > > src/java.base/share/classes/java/lang/reflect/Executable.java line 317: > >> 315:

Re: RFR: 8278461: Use Executable.getSharedParameterTypes() instead of Executable.getParameterTypes() in trusted code

2022-01-10 Thread Сергей Цыпанов
On Thu, 6 Jan 2022 16:38:05 GMT, Claes Redestad wrote: >> `Executable.getParameterTypes()` creates a copy of underlying array which is >> redundant in trusted code when we are sure the action is read-only. > > src/java.base/share/classes/java/lang/reflect/Executable.java line 313: > >> 311:

Re: RFR: 8278461: Use Executable.getSharedParameterTypes() instead of Executable.getParameterTypes() in trusted code

2022-01-06 Thread Сергей Цыпанов
On Thu, 9 Dec 2021 11:50:50 GMT, Сергей Цыпанов wrote: > `Executable.getParameterTypes()` creates a copy of underlying array which is > redundant in trusted code when we are sure the action is read-only. Let's wait - PR: https://git.openjdk.java.net/jdk/pull/6782

Re: RFR: 8279283 - BufferedInputStream should override transferTo [v5]

2022-01-03 Thread Сергей Цыпанов
On Mon, 27 Dec 2021 13:43:12 GMT, Markus KARG wrote: >> Implementation of JDK-8279283 > > Markus KARG has updated the pull request incrementally with one additional > commit since the last revision: > > fixed missing BufferedInputStream Maybe we need to include into this patch the benchmark

Re: RFR: 8274811: Remove superfluous use of boxing in java.base

2021-12-27 Thread Сергей Цыпанов
On Sat, 27 Nov 2021 17:41:58 GMT, Andrey Turbanov wrote: >> Usages of primitive types should be preferred and makes code easier to read. >> Similar cleanups: >> 1. [JDK-8273168](https://bugs.openjdk.java.net/browse/JDK-8273168) >> java.desktop >> 2.

Re: RFR: 8274811: Remove superfluous use of boxing in java.base

2021-12-26 Thread Сергей Цыпанов
On Sat, 11 Sep 2021 12:11:50 GMT, Andrey Turbanov wrote: > Usages of primitive types should be preferred and makes code easier to read. > Similar cleanups: > 1. [JDK-8273168](https://bugs.openjdk.java.net/browse/JDK-8273168) > java.desktop > 2.

Integrated: 8277868: Use Comparable.compare() instead of surrogate code

2021-12-16 Thread Сергей Цыпанов
On Fri, 26 Nov 2021 12:46:59 GMT, Сергей Цыпанов wrote: > Instead of something like > > long x; > long y; > return (x < y) ? -1 : ((x == y) ? 0 : 1); > > we can use `return Long.compare(x, y);` > > All replacements are done with IDE. This pull request has n

Re: RFR: 8278518: String(byte[], int, int, Charset) constructor and String.translateEscapes() miss bounds check elimination

2021-12-15 Thread Сергей Цыпанов
On Tue, 14 Dec 2021 13:20:46 GMT, Alan Bateman wrote: >>> Originally this was spotted by by Amir Hadadi in >>> https://stackoverflow.com/questions/70272651/missing-bounds-checking-elimination-in-string-constructor >> >> Before anyone looks at this, can you confirm that the patch does not

Re: RFR: 8278518: String(byte[], int, int, Charset) constructor and String.translateEscapes() miss bounds check elimination

2021-12-14 Thread Сергей Цыпанов
On Tue, 14 Dec 2021 19:12:29 GMT, Mai Đặng Quân Anh wrote: > The problem, at first glance, seems to be that our compiled code is trying to > compute this mysterious number @merykitty how do you view it? 樂 - PR: https://git.openjdk.java.net/jdk/pull/6812

Re: RFR: 8278518: String(byte[], int, int, Charset) constructor and String.translateEscapes() misses bounds check elimination

2021-12-13 Thread Сергей Цыпанов
On Mon, 13 Dec 2021 09:55:36 GMT, Alan Bateman wrote: >> Originally this was spotted by by Amir Hadadi in >> https://stackoverflow.com/questions/70272651/missing-bounds-checking-elimination-in-string-constructor >> >> It looks like in the following code in `String(byte[], int, int, Charset)`

RFR: 8278518: String(byte[], int, int, Charset) constructor and String.translateEscapes() misses bounds check elimination

2021-12-13 Thread Сергей Цыпанов
Originally this was spotted by by Amir Hadadi in https://stackoverflow.com/questions/70272651/missing-bounds-checking-elimination-in-string-constructor It looks like in the following code in `String(byte[], int, int, Charset)` while (offset < sl) { int b1 = bytes[offset]; if (b1 >= 0) {

Re: RFR: 8277868: Use Comparable.compare() instead of surrogate code [v4]

2021-12-07 Thread Сергей Цыпанов
> Instead of something like > > long x; > long y; > return (x < y) ? -1 : ((x == y) ? 0 : 1); > > we can use `return Long.compare(x, y);` > > All replacements are done with IDE. Сергей Цыпанов has updated the pull request incrementally with two additional c

Re: RFR: 8277868: Use Comparable.compare() instead of surrogate code [v3]

2021-12-07 Thread Сергей Цыпанов
On Tue, 7 Dec 2021 12:01:27 GMT, Alexey Ivanov wrote: >> Сергей Цыпанов has updated the pull request incrementally with one >> additional commit since the last revision: >> >> 8277868: Inline local var > > src/java.base/share/classes/java/util/Calendar.java line

Re: RFR: 8277868: Use Comparable.compare() instead of surrogate code [v2]

2021-12-07 Thread Сергей Цыпанов
On Mon, 6 Dec 2021 17:48:37 GMT, Phil Race wrote: >> Сергей Цыпанов has updated the pull request incrementally with one >> additional commit since the last revision: >> >> 8277868: Use Integer.signum() in BasicTableUI > > src/java.desktop/share/classes/

Re: RFR: 8277868: Use Comparable.compare() instead of surrogate code [v3]

2021-12-07 Thread Сергей Цыпанов
> Instead of something like > > long x; > long y; > return (x < y) ? -1 : ((x == y) ? 0 : 1); > > we can use `return Long.compare(x, y);` > > All replacements are done with IDE. Сергей Цыпанов has updated the pull request incrementally with one additional

Re: RFR: 8277868: Use Comparable.compare() instead of surrogate code [v2]

2021-12-07 Thread Сергей Цыпанов
On Mon, 6 Dec 2021 17:46:22 GMT, Phil Race wrote: >> Сергей Цыпанов has updated the pull request incrementally with one >> additional commit since the last revision: >> >> 8277868: Use Integer.signum() in BasicTableUI > > src/java.desktop/share/classes/java

Integrated: 8276806: Use Objects.checkFromIndexSize where possible in java.base

2021-12-02 Thread Сергей Цыпанов
On Mon, 8 Nov 2021 14:25:10 GMT, Сергей Цыпанов wrote: > This is a follow-up for https://github.com/openjdk/jdk/pull/4507, looks like > there are some cases that were not covered. > > Also this is related to https://github.com/openjdk/jdk/pull/3615 This pull request has now bee

Re: RFR: 8277868: Use Comparable.compare() instead of surrogate code [v2]

2021-11-29 Thread Сергей Цыпанов
> Instead of something like > > long x; > long y; > return (x < y) ? -1 : ((x == y) ? 0 : 1); > > we can use `return Long.compare(x, y);` > > All replacements are done with IDE. Сергей Цыпанов has updated the pull request incrementally with one additional

Re: RFR: 8277868: Use Comparable.compare() instead of surrogate code [v2]

2021-11-29 Thread Сергей Цыпанов
On Sat, 27 Nov 2021 22:50:55 GMT, Michael Bien wrote: >> Сергей Цыпанов has updated the pull request incrementally with one >> additional commit since the last revision: >> >> 8277868: Use Integer.signum() in BasicTableUI > > src/java.desktop/share/

RFR: 8277868: Use Comparable.compare() instead of surrogate code

2021-11-26 Thread Сергей Цыпанов
Instead of something like long x; long y; return (x < y) ? -1 : ((x == y) ? 0 : 1); we can use `return Long.compare(x, y);` All replacements are done with IDE. - Commit messages: - 8277868: Use Comparable.compare() instead of surrogate code Changes:

Re: RFR: 8261847: performace of java.lang.Record::toString should be improved [v2]

2021-11-18 Thread Сергей Цыпанов
On Wed, 17 Nov 2021 22:00:30 GMT, Vicente Romero wrote: >> Please review this PR which aims to optimize the implementation of the >> `toString` method we provide for records. A benchmark comparing the >> implementation we are providing for records with lombok found out that >> lombok is much

Re: RFR: 8261847: performace of java.lang.Record::toString should be improved

2021-11-16 Thread Сергей Цыпанов
On Tue, 16 Nov 2021 05:24:38 GMT, Vicente Romero wrote: > Please review this PR which aims to optimize the implementation of the > `toString` method we provide for records. A benchmark comparing the > implementation we are providing for records with lombok found out that lombok > is much

Integrated: 8276926: Use String.valueOf() when initializing File.separator and File.pathSeparator

2021-11-10 Thread Сергей Цыпанов
On Wed, 10 Nov 2021 09:22:32 GMT, Сергей Цыпанов wrote: > Looking into `File.pathSeparator` I've found out that currently we initialize > it as > > public static final String separator = "" + separatorChar; > > Which after compilation turns into > >

Re: RFR: 8276926: Use String.valueOf() when initializing File.separator and File.pathSeparator

2021-11-10 Thread Сергей Цыпанов
On Wed, 10 Nov 2021 10:36:37 GMT, Michael Bien wrote: > it should compile into invokedynamic makeConcatWithConstants on later JDKs As far as I understand `StringConcatFactory` is not available on bootstrap stage and `StringBuilder` is used instead. See

RFR: 8276926: Use String.valueOf() when initializing File.separator and File.pathSeparator

2021-11-10 Thread Сергей Цыпанов
Looking into File.pathSeparator I've found out that currently we initialize them as public static final String separator = "" + separatorChar; Which after compilation turns into NEW java/lang/StringBuilder DUP INVOKESPECIAL java/lang/StringBuilder. ()V LDC "" INVOKEVIRTUAL

Re: RFR: 8276806: Use Objects.checkFromIndexSize where possible in java.base [v2]

2021-11-08 Thread Сергей Цыпанов
On Mon, 8 Nov 2021 14:52:59 GMT, Daniel Fuchs wrote: >> Сергей Цыпанов has updated the pull request incrementally with one >> additional commit since the last revision: >> >> 8276806: Use Objects.checkFromIndexSize where possible in java.base > > src/j

Re: RFR: 8276806: Use Objects.checkFromIndexSize where possible in java.base [v2]

2021-11-08 Thread Сергей Цыпанов
> This is a follow-up for https://github.com/openjdk/jdk/pull/4507, looks like > there are some cases that were not covered. > > Also this is related to https://github.com/openjdk/jdk/pull/3615 Сергей Цыпанов has updated the pull request incrementally with one additional commit si

RFR: 8276806: Use Objects.checkFromIndexSize where possible in java.base

2021-11-08 Thread Сергей Цыпанов
This is a follow-up for https://github.com/openjdk/jdk/pull/4507, looks like there are some cases that were not covered. Also this is related to https://github.com/openjdk/jdk/pull/3615 - Commit messages: - 8276806: Use Objects.checkFromIndexSize where possible in java.base

Integrated: 8275293: A change done with JDK-8268764 mismatches the java.rmi.server.ObjID.hashCode spec

2021-10-23 Thread Сергей Цыпанов
On Fri, 15 Oct 2021 07:17:52 GMT, Сергей Цыпанов wrote: > It looks like we cannot use `Long.hashCode(long)` for > `java.rmi.server.ObjID.hashCode()` due to specification: > https://docs.oracle.com/en/java/javase/17/docs/api/java.rmi/java/rmi/server/ObjID.html#hashCode(). This pull re

Re: RFR: 8275293: A change done with JDK-8268764 mismatches the java.rmi.server.ObjID.hashCode spec

2021-10-15 Thread Сергей Цыпанов
On Fri, 15 Oct 2021 11:43:53 GMT, Pavel Rappo wrote: >> It looks like we cannot use `Long.hashCode(long)` for >> `java.rmi.server.ObjID.hashCode()` due to specification: >> https://docs.oracle.com/en/java/javase/17/docs/api/java.rmi/java/rmi/server/ObjID.html#hashCode(). > > It's important to

Re: RFR: 8275293: A change done with JDK-8268764 mismatches the java.rmi.server.ObjID.hashCode spec

2021-10-15 Thread Сергей Цыпанов
On Fri, 15 Oct 2021 07:17:52 GMT, Сергей Цыпанов wrote: > It looks like we cannot use `Long.hashCode(long)` for > `java.rmi.server.ObjID.hashCode()` due to JavaDoc: > https://docs.oracle.com/en/java/javase/17/docs/api/java.rmi/java/rmi/server/ObjID.html#hashCode(). @stuart-

RFR: 8275293: A change done with JDK-8268764 mismatches the java.rmi.server.ObjID.hashCode spec

2021-10-15 Thread Сергей Цыпанов
It looks like we cannot use `Long.hashCode(long)` for `java.rmi.server.ObjID.hashCode()` due to JavaDoc: https://docs.oracle.com/en/java/javase/17/docs/api/java.rmi/java/rmi/server/ObjID.html#hashCode(). - Commit messages: - 8275293: A change done with JDK-8268764 mismatches the

Integrated: 8268764: Use Long.hashCode() instead of int-cast where applicable

2021-10-12 Thread Сергей Цыпанов
On Tue, 15 Jun 2021 12:15:11 GMT, Сергей Цыпанов wrote: > In some JDK classes there's still the following hashCode() implementation: > > long objNum; > > public int hashCode() { > return (int) objNum; > } > > This outdated expression should be repla

Re: RFR: JDK-8274686 : java.util.UUID#hashCode() should use Long.hashCode()

2021-10-10 Thread Сергей Цыпанов
On Wed, 6 Oct 2021 09:26:06 GMT, Peter Levart wrote: >> This is trivial fix of >> [JDK-8274686](https://bugs.java.com/bugdatabase/view_bug.do?bug_id=JDK-8274686) >> which replaces manually-computed `int`-based `long` hash-code. >> >> Because `Long#hashCode(long)` uses other hashing function

Re: RFR: 8274811: Remove superfluous use of boxing in java.base

2021-10-06 Thread Сергей Цыпанов
On Sat, 11 Sep 2021 12:11:50 GMT, Andrey Turbanov wrote: > Usages of primitive types should be preferred and makes code easier to read. > Similar cleanups: > 1. [JDK-8273168](https://bugs.openjdk.java.net/browse/JDK-8273168) > java.desktop > 2.

Integrated: 8274715: Implement forEach in Collections.CopiesList

2021-10-05 Thread Сергей Цыпанов
On Thu, 11 Feb 2021 13:28:49 GMT, Сергей Цыпанов wrote: > Originally was proposed by Zheka Kozlov here: > http://mail.openjdk.java.net/pipermail/core-libs-dev/2018-December/057192.html > > Just a tiny optimization: we can use for-i loop instead of > `Iterable.forEach()` w

Re: RFR: 8274715: Implement forEach in Collections.CopiesList [v2]

2021-10-05 Thread Сергей Цыпанов
On Tue, 5 Oct 2021 09:18:57 GMT, Сергей Цыпанов wrote: >> Originally was proposed by Zheka Kozlov here: >> http://mail.openjdk.java.net/pipermail/core-libs-dev/2018-December/057192.html >> >> Just a tiny optimization: we can use for-i loop instead of >> `Iterab

Re: RFR: 8274715: Implement forEach in Collections.CopiesList [v3]

2021-10-05 Thread Сергей Цыпанов
avgt 50 ≈ 10⁻⁴ > B/op > NCopiesBenchmarks.forEach:·gc.count50 avgt 50 ≈ 0 > counts > NCopiesBenchmarks.forEach 100 avgt 50 376.675 ± > 2.476 ns/op > NCopiesBenchmarks.forEach:·gc.alloc.rate 100

Re: RFR: JDK-8274686 : java.util.UUID#hashCode() should use Long.hashCode()

2021-10-05 Thread Сергей Цыпанов
On Mon, 4 Oct 2021 21:13:02 GMT, PROgrm_JARvis wrote: > This is trivial fix of > [JDK-8274686](https://bugs.java.com/bugdatabase/view_bug.do?bug_id=JDK-8274686) > which replaces manually-computed `int`-based `long` hash-code. > > Because `Long#hashCode(long)` uses other hashing function than

Re: RFR: JDK-8274686 : java.util.UUID#hashCode() should use Long.hashCode()

2021-10-05 Thread Сергей Цыпанов
On Mon, 4 Oct 2021 21:13:02 GMT, PROgrm_JARvis wrote: > This is trivial fix of > [JDK-8274686](https://bugs.java.com/bugdatabase/view_bug.do?bug_id=JDK-8274686) > which replaces manually-computed `int`-based `long` hash-code. > > Because `Long#hashCode(long)` uses other hashing function than

Re: RFR: 8274715: Implement forEach in Collections.CopiesList [v2]

2021-10-05 Thread Сергей Цыпанов
On Mon, 4 Oct 2021 16:51:27 GMT, Martin Buchholz wrote: >> Сергей Цыпанов has updated the pull request with a new target base due to a >> merge or a rebase. The incremental webrev excludes the unrelated changes >> brought in by the merge/rebase. The pull request contai

Re: RFR: 8274715: Implement forEach in Collections.CopiesList [v2]

2021-10-05 Thread Сергей Цыпанов
avgt 50 ≈ 10⁻⁴ > B/op > NCopiesBenchmarks.forEach:·gc.count50 avgt 50 ≈ 0 > counts > NCopiesBenchmarks.forEach 100 avgt 50 376.675 ± > 2.476 ns/op > NCopiesBenchmarks.forEach:·gc.alloc.rate 100

RFR: 8274715: Implement forEach in Collections.CopiesList

2021-10-04 Thread Сергей Цыпанов
Originally was proposed by Zheka Kozlov here: http://mail.openjdk.java.net/pipermail/core-libs-dev/2018-December/057192.html Just a tiny optimization: we can use for-i loop instead of `Iterable.forEach()` which is relying on iterator. Simple benchmark demonstrates slight improvement:

Optimization (?) of HashSet(Collection)

2021-10-04 Thread Сергей Цыпанов
Hello, in the code of HashSet(Collection) we have an optimization opportunity: public HashSet(Collection c) { map = new HashMap<>(Math.max((int) (c.size()/.75f) + 1, 16)); addAll(c); } instead of using addAll() inherited from j.u.Collection we can use c.forEach(this::add): public

Integrated: 8274276: Cache normalizedBase URL in URLClassPath.FileLoader

2021-09-28 Thread Сергей Цыпанов
On Fri, 24 Sep 2021 10:35:54 GMT, Сергей Цыпанов wrote: > Currently on each invocation of `URLClassPath.FileLoader.getResource()` > `normalizedBase` URL is recalculated using same final `baseURL` from parent > class. This can be avoided giving significant improvement in memory >

Re: RFR: 8274276: Cache normalizedBase URL in URLClassPath.FileLoader [v2]

2021-09-24 Thread Сергей Цыпанов
On Fri, 24 Sep 2021 11:14:00 GMT, Daniel Fuchs wrote: >> Сергей Цыпанов has updated the pull request incrementally with one >> additional commit since the last revision: >> >> 8274276: Make URLClassPath.Loader.getBaseURL() final > > This is calling an overidab

Re: RFR: 8274276: Cache normalizedBase URL in URLClassPath.FileLoader [v2]

2021-09-24 Thread Сергей Цыпанов
norm avgt 100 > 1634,314 ± 79,821B/op > URLClassPathBenchmark.getResource:·gc.churn.G1_Survivor_Space avgt 100 > 0,101 ± 0,097 MB/sec > URLClassPathBenchmark.getResource:·gc.churn.G1_Survivor_Space.norm avgt 100 > 0,345 ± 0,329B/op > URLClassPathBenchmark.getResourc

RFR: 8274276: Cache normalizedBase URL in URLClassPath.FileLoader

2021-09-24 Thread Сергей Цыпанов
Currently on each invocation of `URLClassPath.FileLoader.getResource()` `normalizedBase` URL is recalculated using same final `baseURL` from parent class. This can be avoided giving significant improvement in memory consumption. Consider the benchmark: @State(Scope.Benchmark)

Re: RFR: 8273656: Improve java.lang.invoke.MethodType.parameterList() and its usage

2021-09-22 Thread Сергей Цыпанов
On Wed, 22 Sep 2021 00:21:01 GMT, Claes Redestad wrote: >> Currently the method is implemented like >> >> public List> parameterList() { >> return Collections.unmodifiableList(Arrays.asList(ptypes.clone())); >> } >> >> This seems to be excessive, as three objects are allocated here. Instead

Re: RFR: 8268764: Use Long.hashCode() instead of int-cast where applicable [v4]

2021-09-16 Thread Сергей Цыпанов
On Thu, 1 Jul 2021 12:19:53 GMT, Сергей Цыпанов wrote: >> In some JDK classes there's still the following hashCode() implementation: >> >> long objNum; >> >> public int hashCode() { >> return (int) objNum; >> } >> >> This outdated

Integrated: 8273656: Improve java.lang.invoke.MethodType.parameterList() and its usage

2021-09-15 Thread Сергей Цыпанов
On Mon, 13 Sep 2021 11:06:15 GMT, Сергей Цыпанов wrote: > Currently the method is implemented like > > public List> parameterList() { > return Collections.unmodifiableList(Arrays.asList(ptypes.clone())); > } > > This seems to be excessive, as three objects are al

RFR: 8273656: Improve java.lang.invoke.MethodType.parameterList() and its usage

2021-09-13 Thread Сергей Цыпанов
Currently the method is implemented like public List> parameterList() { return Collections.unmodifiableList(Arrays.asList(ptypes.clone())); } This seems to be excessive, as three objects are allocated here. Instead we can use `List.of(ptypes)` which doesn't allocate anything for empty array

Integrated: 8273329: Remove redundant null check from String.getBytes(String charsetName)

2021-09-08 Thread Сергей Цыпанов
On Fri, 3 Sep 2021 13:22:54 GMT, Сергей Цыпанов wrote: > Current implementation looks like this: > > public byte[] getBytes(String charsetName) > throws UnsupportedEncodingException { > if (charsetName == null) throw new NullPointerException(); > return en

  1   2   3   4   >