Skip to content

Commit 2972f94

Browse files
author
duke
committedMay 31, 2024
Automatic merge of jdk:master into master
2 parents 34835c9 + e4fbb15 commit 2972f94

File tree

3 files changed

+18
-13
lines changed

3 files changed

+18
-13
lines changed
 

‎src/hotspot/share/services/heapDumper.cpp

+12-7
Original file line numberDiff line numberDiff line change
@@ -626,17 +626,21 @@ class DumpWriter : public AbstractDumpWriter {
626626
DumpWriter(const char* path, bool overwrite, AbstractCompressor* compressor);
627627
~DumpWriter();
628628
julong bytes_written() const override { return (julong) _bytes_written; }
629-
void set_bytes_written(julong bytes_written) { _bytes_written = bytes_written; }
630629
char const* error() const override { return _error; }
631630
void set_error(const char* error) { _error = (char*)error; }
632631
bool has_error() const { return _error != nullptr; }
633632
const char* get_file_path() const { return _writer->get_file_path(); }
634633
AbstractCompressor* compressor() { return _compressor; }
635-
void set_compressor(AbstractCompressor* p) { _compressor = p; }
636634
bool is_overwrite() const { return _writer->is_overwrite(); }
637-
int get_fd() const { return _writer->get_fd(); }
638635

639636
void flush() override;
637+
638+
private:
639+
// internals for DumpMerger
640+
friend class DumpMerger;
641+
void set_bytes_written(julong bytes_written) { _bytes_written = bytes_written; }
642+
int get_fd() const { return _writer->get_fd(); }
643+
void set_compressor(AbstractCompressor* p) { _compressor = p; }
640644
};
641645

642646
DumpWriter::DumpWriter(const char* path, bool overwrite, AbstractCompressor* compressor) :
@@ -2126,13 +2130,14 @@ void DumpMerger::merge_file(const char* path) {
21262130

21272131
jlong total = 0;
21282132
size_t cnt = 0;
2129-
char read_buf[4096];
2130-
while ((cnt = segment_fs.read(read_buf, 1, 4096)) != 0) {
2131-
_writer->write_raw(read_buf, cnt);
2133+
2134+
// Use _writer buffer for reading.
2135+
while ((cnt = segment_fs.read(_writer->buffer(), 1, _writer->buffer_size())) != 0) {
2136+
_writer->set_position(cnt);
2137+
_writer->flush();
21322138
total += cnt;
21332139
}
21342140

2135-
_writer->flush();
21362141
if (segment_fs.fileSize() != total) {
21372142
set_error("Merged heap dump is incomplete");
21382143
}

‎src/hotspot/share/services/heapDumperCompression.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved.
33
* Copyright (c) 2020 SAP SE. All rights reserved.
44
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
55
*
@@ -49,11 +49,11 @@ FileWriter::~FileWriter() {
4949
}
5050
}
5151

52-
char const* FileWriter::write_buf(char* buf, ssize_t size) {
52+
char const* FileWriter::write_buf(char* buf, size_t size) {
5353
assert(_fd >= 0, "Must be open");
5454
assert(size > 0, "Must write at least one byte");
5555

56-
if (!os::write(_fd, buf, (size_t)size)) {
56+
if (!os::write(_fd, buf, size)) {
5757
return os::strerror(errno);
5858
}
5959

‎src/hotspot/share/services/heapDumperCompression.hpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* Copyright (c) 2020 SAP SE. All rights reserved.
3-
* Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
3+
* Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved.
44
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
55
*
66
* This code is free software; you can redistribute it and/or modify it
@@ -54,7 +54,7 @@ class AbstractWriter : public CHeapObj<mtInternal> {
5454
virtual char const* open_writer() = 0;
5555

5656
// Does the write. Returns null on success and a static error message otherwise.
57-
virtual char const* write_buf(char* buf, ssize_t size) = 0;
57+
virtual char const* write_buf(char* buf, size_t size) = 0;
5858
};
5959

6060

@@ -74,7 +74,7 @@ class FileWriter : public AbstractWriter {
7474
virtual char const* open_writer();
7575

7676
// Does the write. Returns null on success and a static error message otherwise.
77-
virtual char const* write_buf(char* buf, ssize_t size);
77+
virtual char const* write_buf(char* buf, size_t size);
7878

7979
const char* get_file_path() { return _path; }
8080

0 commit comments

Comments
 (0)
Please sign in to comment.