Skip to content

8294293: Remove unused _width and _newlines field in outputStream #10411

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from

Conversation

jdksjolen
Copy link
Contributor

@jdksjolen jdksjolen commented Sep 23, 2022

  1. _width is unused so I deleted it
  2. _newlines was used in one place, and only to check if any new lines had been seen. I removed _newlines and instead used update_position's unused return value to indicate whether any newlines has been seen. This required expanding the call of xmlTextStream::write in defaultStream.

This removes some cruft from outputStream and saves us 8 bytes on the size of outputStream.

I also noted that _position isn't number of chars into a line, but rather a "visual position". It's a bit surprising, which is why I added this comment. This can be seen in the \t case in update_position.


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

  • JDK-8294293: Remove unused _width and _newlines field in outputStream

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk pull/10411/head:pull/10411
$ git checkout pull/10411

Update a local copy of the PR:
$ git checkout pull/10411
$ git pull https://git.openjdk.org/jdk pull/10411/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 10411

View PR using the GUI difftool:
$ git pr show -t 10411

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/10411.diff

@bridgekeeper
Copy link

bridgekeeper bot commented Sep 23, 2022

👋 Welcome back jsjolen! 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.

@openjdk openjdk bot added the rfr Pull request is ready for review label Sep 23, 2022
@openjdk
Copy link

openjdk bot commented Sep 23, 2022

@jdksjolen The following label will be automatically applied to this pull request:

  • hotspot

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk bot added the hotspot hotspot-dev@openjdk.org label Sep 23, 2022
@mlbridge
Copy link

mlbridge bot commented Sep 23, 2022

Webrevs

Copy link
Contributor

@robehn robehn 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, thanks!

@@ -86,7 +86,6 @@ class outputStream : public ResourceObj {
void move_to(int col, int slop = 6, int min_space = 2);

// sizing
int width() const { return _width; }
int position() const { return _position; }
julong count() const { return _precount + _position; }
void set_count(julong count) { _precount = count - _position; }
Copy link
Contributor

Choose a reason for hiding this comment

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

These julong should probably be uint64_t.
But it may cause some more changes, e.g. _file_end in CompileLog should then also probably also be uint64_t.
We can look at that in another RFE.

@openjdk
Copy link

openjdk bot commented Sep 26, 2022

@jdksjolen 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:

8294293: Remove unused _width and _newlines field in outputStream

Reviewed-by: rehn, dholmes

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 104 new commits pushed to the master branch:

  • 94e14da: 8294057: Parallel: Tighten ParallelCompactData::initialize_region_data
  • 1ea0d6b: 8292301: [REDO v2] C2 crash when allocating array of size too large
  • c13e0ef: 8292848: AWT_Mixing and TrayIcon tests fail on el8 with hard-coded isOel7
  • 79ccc79: 8293613: need to properly handle and hide tmp VTMS transitions
  • 5e1e449: 8290920: sspi_bridge.dll not built if BUILD_CRYPTO is false
  • d827fd8: 8294430: RISC-V: Small refactoring for movptr_with_offset
  • 9d76ac8: 8292158: AES-CTR cipher state corruption with AVX-512
  • e5b65c4: 8290482: Update JNI Specification of DestroyJavaVM for better alignment with JLS, JVMS, and Java SE API Specifications
  • f8d9fa8: 8294483: Remove vmTestbase/nsk/jvmti/GetThreadState tests.
  • 6ad151d: 8293143: Workaround for JDK-8292217 when doing "step over" of bytecode with unresolved cp reference
  • ... and 94 more: https://git.openjdk.org/jdk/compare/bb422f5c14745bf29bc2cb741f819a17c8400543...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.

As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@robehn, @dholmes-ora) but any other Committer may sponsor as well.

➡️ To flag this PR as ready for integration with the above commit message, type /integrate in a new comment. (Afterwards, your sponsor types /sponsor in a new comment to perform the integration).

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Sep 26, 2022
Copy link
Member

@dholmes-ora dholmes-ora left a comment

Choose a reason for hiding this comment

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

Generally seems okay but a couple of queries.

Thanks.

@@ -29,6 +29,7 @@
#include "runtime/timer.hpp"
#include "utilities/globalDefinitions.hpp"
#include "utilities/macros.hpp"
#include <cstdint>
Copy link
Member

Choose a reason for hiding this comment

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

This std header doesn't seem to be used anywhere else in hotspot code - why do we need it here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch, it's been removed.

// print to output stream. It can be redirected by a vfprintf hook
jio_print(s, len);
}

// print to log file
if (has_log_file()) {
int nl0 = _newlines;
xmlTextStream::write(s, len);
Copy link
Member

Choose a reason for hiding this comment

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

xmlTextStream::write seems to be unused after this change.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It does seem that way. The outputStream::write method is the function which all subclasses of outputStream implements, so we shouldn't remove this function without removing xmlTextStream. That's probably a separate RFE, and perhaps not desirable as it'd require merging the class into defaultStream.

Copy link
Member

Choose a reason for hiding this comment

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

I'm confused by this part of the change. How can the original code call xmlTextStream::write without an instance of xmlTextStream to apply it to???

Copy link
Contributor Author

Choose a reason for hiding this comment

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

defaultStream inherits from xmlTextStream and defaultStream::write exists, so this specifies to call the superclass method, and not its own method. In long form: this->xmlTextStream::write (haven't attempted to compile)

Copy link
Member

Choose a reason for hiding this comment

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

Ah! Thanks - I had missed this code was in defaultStream. It seems a bit klunky to break encapsulation and effectively inline the super write() call so that we can get access to whether a newline was seen - but monitoring _newlines across the write call is at least as bad. I guess this is the problem of trying to have a flushable stream extend a non-flushable superclass - you somehow need to see inside the write to know if there were newlines. The new code at least saves the need for the field.

Copy link
Member

@dholmes-ora dholmes-ora left a comment

Choose a reason for hiding this comment

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

Okay this seems reasonable.

Thanks.

// print to output stream. It can be redirected by a vfprintf hook
jio_print(s, len);
}

// print to log file
if (has_log_file()) {
int nl0 = _newlines;
xmlTextStream::write(s, len);
Copy link
Member

Choose a reason for hiding this comment

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

Ah! Thanks - I had missed this code was in defaultStream. It seems a bit klunky to break encapsulation and effectively inline the super write() call so that we can get access to whether a newline was seen - but monitoring _newlines across the write call is at least as bad. I guess this is the problem of trying to have a flushable stream extend a non-flushable superclass - you somehow need to see inside the write to know if there were newlines. The new code at least saves the need for the field.

@jdksjolen
Copy link
Contributor Author

/integrate

@openjdk openjdk bot added the sponsor Pull request is ready to be sponsored label Sep 28, 2022
@openjdk
Copy link

openjdk bot commented Sep 28, 2022

@jdksjolen
Your change (at version 11977a5) is now ready to be sponsored by a Committer.

@coleenp
Copy link
Contributor

coleenp commented Sep 30, 2022

/sponsor

@openjdk
Copy link

openjdk bot commented Sep 30, 2022

Going to push as commit 052a924.
Since your change was applied there have been 139 commits pushed to the master branch:

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Sep 30, 2022
@openjdk openjdk bot closed this Sep 30, 2022
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review sponsor Pull request is ready to be sponsored labels Sep 30, 2022
@openjdk
Copy link

openjdk bot commented Sep 30, 2022

@coleenp @jdksjolen Pushed as commit 052a924.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hotspot hotspot-dev@openjdk.org integrated Pull request has been integrated
Development

Successfully merging this pull request may close these issues.

4 participants