equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2001, 2017, 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. |
111 /* the PerfMemory class manages creation, destruction, |
111 /* the PerfMemory class manages creation, destruction, |
112 * and allocation of the PerfData region. |
112 * and allocation of the PerfData region. |
113 */ |
113 */ |
114 class PerfMemory : AllStatic { |
114 class PerfMemory : AllStatic { |
115 friend class VMStructs; |
115 friend class VMStructs; |
|
116 friend class PerfMemoryTest; |
116 private: |
117 private: |
117 static char* _start; |
118 static char* _start; |
118 static char* _end; |
119 static char* _end; |
119 static char* _top; |
120 static char* _top; |
120 static size_t _capacity; |
121 static size_t _capacity; |
121 static PerfDataPrologue* _prologue; |
122 static PerfDataPrologue* _prologue; |
122 static jint _initialized; |
123 static jint _initialized; |
|
124 static bool _destroyed; |
123 |
125 |
124 static void create_memory_region(size_t sizep); |
126 static void create_memory_region(size_t sizep); |
125 static void delete_memory_region(); |
127 static void delete_memory_region(); |
126 |
128 |
127 public: |
129 public: |
133 static char* alloc(size_t size); |
135 static char* alloc(size_t size); |
134 static char* start() { return _start; } |
136 static char* start() { return _start; } |
135 static char* end() { return _end; } |
137 static char* end() { return _end; } |
136 static size_t used() { return (size_t) (_top - _start); } |
138 static size_t used() { return (size_t) (_top - _start); } |
137 static size_t capacity() { return _capacity; } |
139 static size_t capacity() { return _capacity; } |
138 static bool is_initialized() { return _initialized != 0; } |
140 static bool is_initialized(); |
|
141 static bool is_destroyed() { return _destroyed; } |
|
142 static bool is_usable() { return is_initialized() && !is_destroyed(); } |
139 static bool contains(char* addr) { |
143 static bool contains(char* addr) { |
140 return ((_start != NULL) && (addr >= _start) && (addr < _end)); |
144 return ((_start != NULL) && (addr >= _start) && (addr < _end)); |
141 } |
145 } |
142 static void mark_updated(); |
146 static void mark_updated(); |
143 |
147 |