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"); |