src/share/vm/jfr/recorder/storage/jfrBuffer.cpp

changeset 9928
d2c2cd90513e
parent 9858
b985cbb00e68
equal deleted inserted replaced
9927:b273df69fbfe 9928:d2c2cd90513e
1 /* 1 /*
2 * Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved. 2 * Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 * 4 *
5 * This code is free software; you can redistribute it and/or modify it 5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as 6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
135 135
136 void JfrBuffer::clear_identity() { 136 void JfrBuffer::clear_identity() {
137 _identity = NULL; 137 _identity = NULL;
138 } 138 }
139 139
140 bool JfrBuffer::acquired_by(const void* id) const {
141 return identity() == id;
142 }
143
144 bool JfrBuffer::acquired_by_self() const {
145 return acquired_by(Thread::current());
146 }
147
140 #ifdef ASSERT 148 #ifdef ASSERT
141 static bool validate_to(const JfrBuffer* const to, size_t size) { 149 static bool validate_to(const JfrBuffer* const to, size_t size) {
142 assert(to != NULL, "invariant"); 150 assert(to != NULL, "invariant");
143 if (!JfrRecorder::is_shutting_down()) assert(to->acquired_by_self(), "invariant"); 151 if (!JfrRecorder::is_shutting_down()) assert(to->acquired_by_self(), "invariant");
144 assert(to->free_size() >= size, "invariant"); 152 assert(to->free_size() >= size, "invariant");
151 } 159 }
152 160
153 static bool validate_this(const JfrBuffer* const t, size_t size) { 161 static bool validate_this(const JfrBuffer* const t, size_t size) {
154 assert(t->top() + size <= t->pos(), "invariant"); 162 assert(t->top() + size <= t->pos(), "invariant");
155 return true; 163 return true;
156 }
157
158 bool JfrBuffer::acquired_by_self() const {
159 return identity() == Thread::current();
160 } 164 }
161 #endif // ASSERT 165 #endif // ASSERT
162 166
163 void JfrBuffer::move(JfrBuffer* const to, size_t size) { 167 void JfrBuffer::move(JfrBuffer* const to, size_t size) {
164 assert(validate_to(to, size), "invariant"); 168 assert(validate_to(to, size), "invariant");
182 set_pos(start()); 186 set_pos(start());
183 to->release(); 187 to->release();
184 set_concurrent_top(start()); 188 set_concurrent_top(start());
185 } 189 }
186 190
187 // flags
188 enum FLAG { 191 enum FLAG {
189 RETIRED = 1, 192 RETIRED = 1,
190 TRANSIENT = 2, 193 TRANSIENT = 2,
191 LEASE = 4 194 LEASE = 4
192 }; 195 };

mercurial