Skip to content

Conversation

@calvinccheung
Copy link
Member

@calvinccheung calvinccheung commented Nov 2, 2020

Please review this simple fix by using the wide char version of strftime, i.e. wcsftime, to convert the timezone into a wide character string. After that, converting the wide character string back to multi-byte string before printing out the time and timezone.

Testing: ran the test case in the bug report manually on:

  • Windows with ja, zh-tw, and en locales;

  • Linux and Mac OS with en locale.


Progress

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change must be properly reviewed

Issue

  • JDK-8255239: The timezone of the hs_err_pid log file is corrupted in Japanese locale

Reviewers

Download

$ git fetch https://git.openjdk.java.net/jdk pull/1023/head:pull/1023
$ git checkout pull/1023

@calvinccheung
Copy link
Member Author

/label remove hotspot

@calvinccheung
Copy link
Member Author

/label add hotspot-runtime

@bridgekeeper
Copy link

bridgekeeper bot commented Nov 3, 2020

👋 Welcome back ccheung! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@calvinccheung calvinccheung marked this pull request as ready for review November 3, 2020 00:02
@openjdk openjdk bot added the rfr Pull request is ready for review label Nov 3, 2020
@openjdk
Copy link

openjdk bot commented Nov 3, 2020

@calvinccheung The hotspot label was not set.

@openjdk openjdk bot added the hotspot-runtime hotspot-runtime-dev@openjdk.org label Nov 3, 2020
@openjdk
Copy link

openjdk bot commented Nov 3, 2020

@calvinccheung
The hotspot-runtime label was successfully added.

@mlbridge
Copy link

mlbridge bot commented Nov 3, 2020

Webrevs

::strftime(buf, buflen, "%Z", &tz);
st->print("Time: %s %s", timestring, buf);
wchar_t w_buf[80];
size_t n = ::wcsftime(w_buf, 80, L"%Z", &tz);
Copy link
Member

@iklam iklam Nov 3, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to https://linux.die.net/man/3/wcsftime: "The Linux implementation of this interface may differ (consult the corresponding Linux manual page for details of Linux behavior), or the interface may not be implemented on Linux."

Also, the L"%Z" notation is Windows-specific.

Maybe we should use the new code only on Windows?

An alternative is to use the C++ standard library (std::wcsftime and std:: wcstombs). However, this part of std:: is not yet permitted -- see https://bugs.openjdk.java.net/browse/JDK-8208089

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After further investigation -- wcsftime is in C99. Also, we use it here only inside if (localtime_pd(&tloc, &tz) != NULL). I supposed any Linux distro that has a minimal of locale support to make that function return non-null would have a working implementation of wcsftime.

So I think this code is OK. The only change I request is to change L"%Z" to "%Z"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Upon even more investigation, I was completely wrong :-)

According https://en.cppreference.com/w/cpp/language/string_literal, the "L" prefix is for wchar_t string literals. So your code is correct.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@iklam Thanks for your review and making sure the change is ok.

@openjdk
Copy link

openjdk bot commented Nov 3, 2020

@calvinccheung This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8255239: The timezone of the hs_err_pid log file is corrupted in Japanese locale

Reviewed-by: iklam, minqi

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 69 new commits pushed to the master branch:

  • 6606e09: 8255380: (zipfs) ZipFileSystem::readExtra can fail if zipinfo-time is not set to false
  • 88ee973: 8254827: JVMCI: Enable it for Windows+AArch64
  • f64a15d: 8254315: Shenandoah: Concurrent weak reference processing
  • 83f3cf4: 8196087: java/awt/image/DrawImage/IncorrectUnmanagedImageRotatedClip.java fails
  • 134e22a: 8255606: Enable concurrent stack processing on x86_32 platforms
  • ca216ba: 8255810: Zero: build fails without JVMTI
  • d47336b: 8248320: Provide a unique accessible name for
  • 64a9811: 8255798: Remove dead headless code in CompileJavaModules.gmk
  • 364b0fe: 8255801: Race when building ct.sym build tools
  • f389a71: 8255737: Zero: DO_UPDATE_INSTRUCTION_COUNT should only update when relevant VM flags are set
  • ... and 59 more: https://git.openjdk.java.net/jdk/compare/36c150b199f59fc9f51ef0f78e5d20891e55a110...master

As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Nov 3, 2020
Copy link
Contributor

@yminqi yminqi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@calvinccheung
Copy link
Member Author

/integrate

@openjdk openjdk bot closed this Nov 3, 2020
@openjdk openjdk bot added integrated Pull request has been integrated and removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Nov 3, 2020
@openjdk
Copy link

openjdk bot commented Nov 3, 2020

@calvinccheung Since your change was applied there have been 69 commits pushed to the master branch:

  • 6606e09: 8255380: (zipfs) ZipFileSystem::readExtra can fail if zipinfo-time is not set to false
  • 88ee973: 8254827: JVMCI: Enable it for Windows+AArch64
  • f64a15d: 8254315: Shenandoah: Concurrent weak reference processing
  • 83f3cf4: 8196087: java/awt/image/DrawImage/IncorrectUnmanagedImageRotatedClip.java fails
  • 134e22a: 8255606: Enable concurrent stack processing on x86_32 platforms
  • ca216ba: 8255810: Zero: build fails without JVMTI
  • d47336b: 8248320: Provide a unique accessible name for
  • 64a9811: 8255798: Remove dead headless code in CompileJavaModules.gmk
  • 364b0fe: 8255801: Race when building ct.sym build tools
  • f389a71: 8255737: Zero: DO_UPDATE_INSTRUCTION_COUNT should only update when relevant VM flags are set
  • ... and 59 more: https://git.openjdk.java.net/jdk/compare/36c150b199f59fc9f51ef0f78e5d20891e55a110...master

Your commit was automatically rebased without conflicts.

Pushed as commit b46d73b.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

openjdk-notifier bot referenced this pull request Nov 3, 2020
@calvinccheung calvinccheung deleted the 8255239-timezone branch November 3, 2020 19:34
@yukikimmura
Copy link
Member

/backport jdk11u-dev

@openjdk
Copy link

openjdk bot commented Jan 31, 2022

@yukikimmura Unknown command backport - for a list of valid commands use /help.

fg1417 added a commit to fg1417/jdk that referenced this pull request Jul 12, 2024
…g to pointer

In the cases like:
```
  UNSAFE.putLong(address + off1 + 1030, lseed);
  UNSAFE.putLong(address + 1023, lseed);
  UNSAFE.putLong(address + off2 + 1001, lseed);
```

Unsafe intrinsifies direct memory access using a long as
the base address, generating a `CastX2P` node converting
long to pointer in C2. Then we get optoassembly code like:
```
  ldr  R10, [R15, openjdk#120]    # int ! Field: address
  ldr  R11, [R16, openjdk#136]    # int ! Field: off1
  ldr  R12, [R16, openjdk#144]    # int ! Field: off2
  add  R11, R11, R10
  mov R11, R11    # long -> ptr
  add  R12, R12, R10
  mov R10, R10    # long -> ptr
  add R11, R11, openjdk#1030    # ptr
  str  R17, [R11]    # int
  add R10, R10, openjdk#1023    # ptr
  str  R17, [R10]    # int
  mov R10, R12    # long -> ptr
  add R10, R10, openjdk#1001    # ptr
  str  R17, [R10]    # int
```

In aarch64, the conversion from long to pointer could be
a nop but C2 doesn't know it. On the existing code, we
do nothing for `mov dst src` only when `dst` == `src` [1],
then we have assembly:
```
  ldr    x10, [x15,openjdk#120]
  ldp    x11, x12, [x16,openjdk#136]
  add    x11, x11, x10
  add    x12, x12, x10
  add    x11, x11, #0x406
  str    x17, [x11]
  add    x10, x10, #0x3ff
  str    x17, [x10]
  mov    x10, x12  <--- extra register copy
  add    x10, x10, #0x3e9
  str    x17, [x10]
```

There is still one extra register copy, which we're trying
to remove in this patch.

This patch folds `CastX2P` into memory operands by introducing
`indirectX2P` and `indOffX2P`. We also create a new opclass
`iRegPorL2P` to remove extra copies from `CastX2P` in pointer
addition.

Tier 1~3 passed on aarch64. No obvious change in size
of libjvm.so

[1] https://github.com/openjdk/jdk/blob/5c612c230b0a852aed5fd36e58b82ebf2e1838af/src/hotspot/cpu/aarch64/aarch64.ad#L7906
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

hotspot-runtime hotspot-runtime-dev@openjdk.org integrated Pull request has been integrated

Development

Successfully merging this pull request may close these issues.

4 participants