src/hotspot/share/jfr/recorder/repository/jfrChunkWriter.cpp
author mgronlun
Sat, 24 Aug 2019 14:30:27 +0200
branchJEP-349-branch
changeset 57870 00860d9caf4d
parent 57360 5d043a159d5c
child 57882 562f598d303c
permissions -rw-r--r--
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
50113
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
     1
/*
54263
3cabb47758c9 8217362: Emergency dump does not work when disk=false is set
mgronlun
parents: 53897
diff changeset
     2
 * Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved.
50113
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
     4
 *
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
     7
 * published by the Free Software Foundation.
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
     8
 *
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    13
 * accompanied this code).
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    14
 *
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    18
 *
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    21
 * questions.
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    22
 *
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    23
 */
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    24
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    25
#include "precompiled.hpp"
57360
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
    26
#include "jfr/recorder/repository/jfrChunk.hpp"
50113
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    27
#include "jfr/recorder/repository/jfrChunkWriter.hpp"
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    28
#include "jfr/recorder/service/jfrOptionSet.hpp"
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    29
#include "jfr/utilities/jfrTime.hpp"
57360
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
    30
#include "jfr/utilities/jfrTimeConverter.hpp"
50113
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    31
#include "jfr/utilities/jfrTypes.hpp"
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    32
#include "runtime/mutexLocker.hpp"
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    33
#include "runtime/os.hpp"
50117
fb66b2959eaf 8203251: Non-PCH build failed after JDK-8199712 (Flight Recorder)
shade
parents: 50113
diff changeset
    34
#include "runtime/os.inline.hpp"
50113
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    35
57360
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
    36
static const int64_t MAGIC_OFFSET = 0;
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
    37
static const int64_t MAGIC_LEN = 4;
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
    38
static const int64_t VERSION_OFFSET = MAGIC_LEN;
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
    39
static const int64_t SIZE_OFFSET = 8;
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
    40
static const int64_t SLOT_SIZE = 8;
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
    41
static const int64_t CHECKPOINT_OFFSET = SIZE_OFFSET + SLOT_SIZE;
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
    42
static const int64_t METADATA_OFFSET = CHECKPOINT_OFFSET + SLOT_SIZE;
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
    43
static const int64_t START_NANOS_OFFSET = METADATA_OFFSET + SLOT_SIZE;
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
    44
static const int64_t DURATION_NANOS_OFFSET = START_NANOS_OFFSET + SLOT_SIZE;
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
    45
static const int64_t START_TICKS_OFFSET = DURATION_NANOS_OFFSET + SLOT_SIZE;
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
    46
static const int64_t CPU_FREQUENCY_OFFSET = START_TICKS_OFFSET + SLOT_SIZE;
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
    47
static const int64_t GENERATION_OFFSET = CPU_FREQUENCY_OFFSET + SLOT_SIZE;
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
    48
static const int64_t CAPABILITY_OFFSET = GENERATION_OFFSET + 2;
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
    49
static const int64_t HEADER_SIZE = CAPABILITY_OFFSET + 2;
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
    50
static const int64_t RESERVE_SIZE = GENERATION_OFFSET - (4 * SIZE_OFFSET);
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
    51
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
    52
static const u1 COMPLETE = 0;
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
    53
static const u1 GUARD = 0xff;
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
    54
static const u1 PAD = 0;
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
    55
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
    56
typedef NoOwnershipAdapter JfrHeadBuffer; // stack local array as buffer
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
    57
typedef StreamWriterHost<JfrHeadBuffer, StackObj> JfrBufferedHeadWriter;
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
    58
typedef WriterHost<BigEndianEncoder, BigEndianEncoder, JfrBufferedHeadWriter> JfrHeadWriterBase;
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
    59
50113
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    60
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    61
static fio_fd open_chunk(const char* path) {
54263
3cabb47758c9 8217362: Emergency dump does not work when disk=false is set
mgronlun
parents: 53897
diff changeset
    62
  return path != NULL ? os::open(path, O_CREAT | O_RDWR, S_IREAD | S_IWRITE) : invalid_fd;
50113
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    63
}
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    64
57870
00860d9caf4d New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents: 57360
diff changeset
    65
#ifdef ASSERT
00860d9caf4d New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents: 57360
diff changeset
    66
static void assert_writer_position(JfrChunkWriter* writer, int64_t offset) {
00860d9caf4d New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents: 57360
diff changeset
    67
  assert(writer != NULL, "invariant");
00860d9caf4d New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents: 57360
diff changeset
    68
  assert(offset == writer->current_offset(), "invariant");
00860d9caf4d New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents: 57360
diff changeset
    69
}
00860d9caf4d New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents: 57360
diff changeset
    70
#endif
00860d9caf4d New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents: 57360
diff changeset
    71
57360
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
    72
class JfrChunkHeadWriter : public StackObj {
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
    73
 private:
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
    74
  JfrChunkWriter* _writer;
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
    75
  JfrChunk* _chunk;
57870
00860d9caf4d New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents: 57360
diff changeset
    76
 public:
57360
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
    77
  void write_magic() {
57870
00860d9caf4d New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents: 57360
diff changeset
    78
    _writer->bytes(_chunk->magic(), MAGIC_LEN);
57360
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
    79
  }
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
    80
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
    81
  void write_version() {
57870
00860d9caf4d New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents: 57360
diff changeset
    82
    _writer->be_write(_chunk->major_version());
00860d9caf4d New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents: 57360
diff changeset
    83
    _writer->be_write(_chunk->minor_version());
57360
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
    84
  }
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
    85
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
    86
  void write_size(int64_t size) {
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
    87
    _writer->be_write(size);
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
    88
  }
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
    89
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
    90
  void write_checkpoint() {
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
    91
    _writer->be_write(_chunk->last_checkpoint_offset());
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
    92
  }
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
    93
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
    94
  void write_metadata() {
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
    95
    _writer->be_write(_chunk->last_metadata_offset());
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
    96
  }
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
    97
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
    98
  void write_time(bool finalize) {
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
    99
    if (finalize) {
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
   100
      _writer->be_write(_chunk->previous_start_nanos());
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
   101
      _writer->be_write(_chunk->last_chunk_duration());
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
   102
      _writer->be_write(_chunk->previous_start_ticks());
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
   103
      return;
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
   104
    }
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
   105
    _writer->be_write(_chunk->start_nanos());
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
   106
    _writer->be_write(_chunk->duration());
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
   107
    _writer->be_write(_chunk->start_ticks());
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
   108
  }
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
   109
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
   110
  void write_cpu_frequency() {
57870
00860d9caf4d New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents: 57360
diff changeset
   111
    _writer->be_write(_chunk->cpu_frequency());
57360
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
   112
  }
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
   113
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
   114
  void write_generation(bool finalize) {
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
   115
    _writer->be_write(finalize ? COMPLETE : _chunk->generation());
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
   116
    _writer->be_write(PAD);
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
   117
  }
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
   118
57870
00860d9caf4d New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents: 57360
diff changeset
   119
  void write_next_generation() {
00860d9caf4d New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents: 57360
diff changeset
   120
    _writer->be_write(_chunk->next_generation());
00860d9caf4d New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents: 57360
diff changeset
   121
    _writer->be_write(PAD);
00860d9caf4d New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents: 57360
diff changeset
   122
  }
00860d9caf4d New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents: 57360
diff changeset
   123
57360
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
   124
  void write_guard() {
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
   125
    _writer->be_write(GUARD);
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
   126
    _writer->be_write(PAD);
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
   127
  }
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
   128
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
   129
  void write_guard_flush() {
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
   130
    write_guard();
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
   131
    _writer->flush();
50113
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   132
  }
57360
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
   133
57870
00860d9caf4d New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents: 57360
diff changeset
   134
  void write_capabilities() {
00860d9caf4d New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents: 57360
diff changeset
   135
    _writer->be_write(_chunk->capabilities());
57360
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
   136
  }
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
   137
57870
00860d9caf4d New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents: 57360
diff changeset
   138
  void write_size_to_generation(int64_t size, bool finalize) {
57360
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
   139
    write_size(size);
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
   140
    write_checkpoint();
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
   141
    write_metadata();
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
   142
    write_time(finalize);
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
   143
    write_cpu_frequency();
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
   144
    write_generation(finalize);
57870
00860d9caf4d New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents: 57360
diff changeset
   145
  }
00860d9caf4d New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents: 57360
diff changeset
   146
00860d9caf4d New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents: 57360
diff changeset
   147
  void flush(int64_t size, bool finalize) {
00860d9caf4d New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents: 57360
diff changeset
   148
    assert(_writer->is_valid(), "invariant");
00860d9caf4d New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents: 57360
diff changeset
   149
    assert(_chunk != NULL, "invariant");
00860d9caf4d New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents: 57360
diff changeset
   150
    DEBUG_ONLY(assert_writer_position(_writer, SIZE_OFFSET);)
00860d9caf4d New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents: 57360
diff changeset
   151
    write_size_to_generation(size, finalize);
57360
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
   152
    // no need to write capabilities
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
   153
    _writer->seek(size); // implicit flush
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
   154
  }
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
   155
57870
00860d9caf4d New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents: 57360
diff changeset
   156
  void initialize() {
00860d9caf4d New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents: 57360
diff changeset
   157
    assert(_writer->is_valid(), "invariant");
00860d9caf4d New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents: 57360
diff changeset
   158
    assert(_chunk != NULL, "invariant");
00860d9caf4d New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents: 57360
diff changeset
   159
    DEBUG_ONLY(assert_writer_position(_writer, 0);)
00860d9caf4d New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents: 57360
diff changeset
   160
    write_magic();
00860d9caf4d New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents: 57360
diff changeset
   161
    write_version();
00860d9caf4d New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents: 57360
diff changeset
   162
    write_size_to_generation(HEADER_SIZE, false);
00860d9caf4d New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents: 57360
diff changeset
   163
    write_capabilities();
00860d9caf4d New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents: 57360
diff changeset
   164
    DEBUG_ONLY(assert_writer_position(_writer, HEADER_SIZE);)
00860d9caf4d New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents: 57360
diff changeset
   165
    _writer->flush();
00860d9caf4d New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents: 57360
diff changeset
   166
  }
00860d9caf4d New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents: 57360
diff changeset
   167
00860d9caf4d New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents: 57360
diff changeset
   168
  JfrChunkHeadWriter(JfrChunkWriter* writer, int64_t offset, bool head = true) : _writer(writer), _chunk(writer->_chunk) {
57360
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
   169
    assert(_writer != NULL, "invariant");
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
   170
    assert(_writer->is_valid(), "invariant");
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
   171
    assert(_chunk != NULL, "invariant");
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
   172
    if (0 == _writer->current_offset()) {
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
   173
      assert(HEADER_SIZE == offset, "invariant");
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
   174
      initialize();
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
   175
    } else {
57870
00860d9caf4d New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents: 57360
diff changeset
   176
      if (head) {
00860d9caf4d New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents: 57360
diff changeset
   177
        _writer->seek(GENERATION_OFFSET);
00860d9caf4d New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents: 57360
diff changeset
   178
        write_guard();
00860d9caf4d New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents: 57360
diff changeset
   179
        _writer->seek(offset);
00860d9caf4d New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents: 57360
diff changeset
   180
      }
57360
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
   181
    }
57870
00860d9caf4d New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents: 57360
diff changeset
   182
    DEBUG_ONLY(assert_writer_position(_writer, offset);)
57360
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
   183
  }
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
   184
};
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
   185
57870
00860d9caf4d New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents: 57360
diff changeset
   186
static void write_checkpoint_header(JfrChunkWriter& cw, int64_t event_offset, bool flushpoint) {
00860d9caf4d New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents: 57360
diff changeset
   187
  const int64_t delta = cw.last_checkpoint_offset() == 0 ? 0 : cw.last_checkpoint_offset() - event_offset;
00860d9caf4d New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents: 57360
diff changeset
   188
  cw.reserve(sizeof(u4));
00860d9caf4d New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents: 57360
diff changeset
   189
  cw.write<u8>(EVENT_CHECKPOINT);
00860d9caf4d New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents: 57360
diff changeset
   190
  cw.write<u8>(JfrTicks::now().value());
00860d9caf4d New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents: 57360
diff changeset
   191
  cw.write<u8>(0); // duration
00860d9caf4d New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents: 57360
diff changeset
   192
  cw.write<u8>(delta); // to previous checkpoint
00860d9caf4d New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents: 57360
diff changeset
   193
  cw.write<bool>(flushpoint);
00860d9caf4d New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents: 57360
diff changeset
   194
  cw.write<u4>(1); // pool count
00860d9caf4d New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents: 57360
diff changeset
   195
  cw.write<u8>(TYPE_CHUNKHEADER);
00860d9caf4d New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents: 57360
diff changeset
   196
  cw.write<u4>(1); // count
00860d9caf4d New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents: 57360
diff changeset
   197
  cw.write<u8>(1); // key
00860d9caf4d New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents: 57360
diff changeset
   198
  cw.write<u4>(HEADER_SIZE); // length of byte array
00860d9caf4d New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents: 57360
diff changeset
   199
}
00860d9caf4d New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents: 57360
diff changeset
   200
00860d9caf4d New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents: 57360
diff changeset
   201
int64_t JfrChunkWriter::write_chunk_header_checkpoint(bool flushpoint) {
00860d9caf4d New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents: 57360
diff changeset
   202
  assert(this->has_valid_fd(), "invariant");
00860d9caf4d New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents: 57360
diff changeset
   203
  const int64_t event_size_offset = current_offset();
00860d9caf4d New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents: 57360
diff changeset
   204
  write_checkpoint_header(*this, event_size_offset, flushpoint);
00860d9caf4d New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents: 57360
diff changeset
   205
  const int64_t start_offset = current_offset();
00860d9caf4d New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents: 57360
diff changeset
   206
  JfrChunkHeadWriter head(this, start_offset, false);
00860d9caf4d New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents: 57360
diff changeset
   207
  head.write_magic();
00860d9caf4d New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents: 57360
diff changeset
   208
  head.write_version();
00860d9caf4d New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents: 57360
diff changeset
   209
  const int64_t size_offset = reserve(sizeof(int64_t));
00860d9caf4d New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents: 57360
diff changeset
   210
  be_write(event_size_offset); // last checkpoint offset will be this checkpoint
00860d9caf4d New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents: 57360
diff changeset
   211
  head.write_metadata();
00860d9caf4d New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents: 57360
diff changeset
   212
  head.write_time(false);
00860d9caf4d New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents: 57360
diff changeset
   213
  head.write_cpu_frequency();
00860d9caf4d New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents: 57360
diff changeset
   214
  head.write_next_generation();
00860d9caf4d New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents: 57360
diff changeset
   215
  head.write_capabilities();
00860d9caf4d New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents: 57360
diff changeset
   216
  assert(current_offset() - start_offset == HEADER_SIZE, "invariant");
00860d9caf4d New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents: 57360
diff changeset
   217
  const u4 checkpoint_size = current_offset() - event_size_offset;
00860d9caf4d New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents: 57360
diff changeset
   218
  write_padded_at_offset<u4>(checkpoint_size, event_size_offset);
00860d9caf4d New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents: 57360
diff changeset
   219
  set_last_checkpoint_offset(event_size_offset);
00860d9caf4d New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents: 57360
diff changeset
   220
  const size_t sz_written = size_written();
00860d9caf4d New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents: 57360
diff changeset
   221
  write_be_at_offset(sz_written, size_offset);
00860d9caf4d New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents: 57360
diff changeset
   222
  return sz_written;
00860d9caf4d New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents: 57360
diff changeset
   223
}
00860d9caf4d New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents: 57360
diff changeset
   224
00860d9caf4d New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents: 57360
diff changeset
   225
int64_t JfrChunkWriter::flushpoint(bool flushpoint) {
00860d9caf4d New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents: 57360
diff changeset
   226
  assert(_chunk != NULL, "invariant");
00860d9caf4d New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents: 57360
diff changeset
   227
  if (flushpoint) {
00860d9caf4d New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents: 57360
diff changeset
   228
    _chunk->update();
00860d9caf4d New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents: 57360
diff changeset
   229
  }
00860d9caf4d New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents: 57360
diff changeset
   230
  const int64_t sz_written = write_chunk_header_checkpoint(flushpoint);
00860d9caf4d New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents: 57360
diff changeset
   231
  assert(size_written() == sz_written, "invariant");
00860d9caf4d New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents: 57360
diff changeset
   232
  JfrChunkHeadWriter head(this, SIZE_OFFSET);
00860d9caf4d New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents: 57360
diff changeset
   233
  head.flush(sz_written, !flushpoint);
00860d9caf4d New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents: 57360
diff changeset
   234
  return sz_written;
00860d9caf4d New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents: 57360
diff changeset
   235
}
00860d9caf4d New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents: 57360
diff changeset
   236
57360
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
   237
JfrChunkWriter::JfrChunkWriter() : JfrChunkWriterBase(NULL), _chunk(new JfrChunk()) {}
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
   238
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
   239
JfrChunkWriter::~JfrChunkWriter() {
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
   240
  assert(_chunk != NULL, "invariant");
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
   241
  delete _chunk;
50113
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   242
}
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   243
57360
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
   244
void JfrChunkWriter::set_path(const char* path) {
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
   245
  assert(_chunk != NULL, "invariant");
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
   246
  _chunk->set_path(path);
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
   247
}
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
   248
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
   249
void JfrChunkWriter::time_stamp_chunk_now() {
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
   250
  assert(_chunk != NULL, "invariant");
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
   251
  _chunk->update_time_to_now();
50113
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   252
}
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   253
53897
0abec72a3ac2 8217647: JFR: recordings on 32-bit systems unreadable
bulasevich
parents: 50117
diff changeset
   254
int64_t JfrChunkWriter::size_written() const {
50113
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   255
  return this->is_valid() ? this->current_offset() : 0;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   256
}
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   257
57360
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
   258
int64_t JfrChunkWriter::last_checkpoint_offset() const {
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
   259
  assert(_chunk != NULL, "invariant");
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
   260
  return _chunk->last_checkpoint_offset();
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
   261
}
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
   262
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
   263
int64_t JfrChunkWriter::current_chunk_start_nanos() const {
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
   264
  assert(_chunk != NULL, "invariant");
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
   265
  return this->is_valid() ? _chunk->start_nanos() : invalid_time;
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
   266
}
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
   267
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
   268
void JfrChunkWriter::set_last_checkpoint_offset(int64_t offset) {
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
   269
  assert(_chunk != NULL, "invariant");
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
   270
  _chunk->set_last_checkpoint_offset(offset);
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
   271
}
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
   272
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
   273
bool JfrChunkWriter::is_initial_flushpoint_for_chunk() const {
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
   274
  assert(_chunk != NULL, "invariant");
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
   275
  assert(_chunk->is_started(), "invariant");
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
   276
  assert(!_chunk->is_finished(), "invariant");
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
   277
  return _chunk->is_initial_flush();
50113
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   278
}
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   279
57360
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
   280
void JfrChunkWriter::set_last_metadata_offset(int64_t offset) {
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
   281
  assert(_chunk != NULL, "invariant");
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
   282
  _chunk->set_last_metadata_offset(offset);
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
   283
}
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
   284
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
   285
bool JfrChunkWriter::has_metadata() const {
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
   286
  assert(_chunk != NULL, "invariant");
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
   287
  return _chunk->has_metadata();
50113
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   288
}
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   289
57360
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
   290
bool JfrChunkWriter::open() {
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
   291
  assert(_chunk != NULL, "invariant");
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
   292
  JfrChunkWriterBase::reset(open_chunk(_chunk->path()));
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
   293
  const bool is_open = this->has_valid_fd();
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
   294
  if (is_open) {
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
   295
    assert(0 == this->current_offset(), "invariant");
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
   296
    _chunk->reset();
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
   297
    JfrChunkHeadWriter head(this, HEADER_SIZE);
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
   298
  }
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
   299
  return is_open;
50113
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   300
}
57360
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
   301
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
   302
int64_t JfrChunkWriter::close() {
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
   303
  assert(this->has_valid_fd(), "invariant");
57870
00860d9caf4d New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents: 57360
diff changeset
   304
  const int64_t size_written = flushpoint(false);
57360
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
   305
  this->close_fd();
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
   306
  assert(!this->is_valid(), "invariant");
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
   307
  return size_written;
5d043a159d5c Preview
egahlin
parents: 54263
diff changeset
   308
}