1 /*
2 * Copyright (c) 1997, 2002, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
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
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 // The classes in this file provide a simple framework for the
26 // management of little pieces of machine code - or stubs -
27 // created on the fly and frequently discarded. In this frame-
28 // work stubs are stored in a queue.
29
30
31 // Stub serves as abstract base class. A concrete stub
32 // implementation is a subclass of Stub, implementing
33 // all (non-virtual!) functions required sketched out
34 // in the Stub class.
35 //
36 // A concrete stub layout may look like this (both data
37 // and code sections could be empty as well):
38 //
39 // ________
40 // stub -->| | <--+
41 // | data | |
42 // |________| |
43 // code_begin -->| | |
44 // | | |
189 void remove_first(); // remove the first stub in the queue
190 void remove_first(int n); // remove the first n stubs in the queue
191 void remove_all(); // remove all stubs in the queue
192
193 // Iteration
194 static void queues_do(void f(StubQueue* s)); // call f with each StubQueue
195 void stubs_do(void f(Stub* s)); // call f with all stubs
196 Stub* first() const { return number_of_stubs() > 0 ? stub_at(_queue_begin) : NULL; }
197 Stub* next(Stub* s) const { int i = index_of(s) + stub_size(s);
198 if (i == _buffer_limit) i = 0;
199 return (i == _queue_end) ? NULL : stub_at(i);
200 }
201
202 address stub_code_begin(Stub* s) const { return _stub_interface->code_begin(s); }
203 address stub_code_end(Stub* s) const { return _stub_interface->code_end(s); }
204
205 // Debugging/printing
206 void verify(); // verifies the stub queue
207 void print(); // prints information about the stub queue
208 };
|
1 /*
2 * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
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
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #ifndef SHARE_VM_CODE_STUBS_HPP
26 #define SHARE_VM_CODE_STUBS_HPP
27
28 #include "memory/allocation.hpp"
29 #ifdef TARGET_OS_FAMILY_linux
30 # include "os_linux.inline.hpp"
31 #endif
32 #ifdef TARGET_OS_FAMILY_solaris
33 # include "os_solaris.inline.hpp"
34 #endif
35 #ifdef TARGET_OS_FAMILY_windows
36 # include "os_windows.inline.hpp"
37 #endif
38
39 // The classes in this file provide a simple framework for the
40 // management of little pieces of machine code - or stubs -
41 // created on the fly and frequently discarded. In this frame-
42 // work stubs are stored in a queue.
43
44
45 // Stub serves as abstract base class. A concrete stub
46 // implementation is a subclass of Stub, implementing
47 // all (non-virtual!) functions required sketched out
48 // in the Stub class.
49 //
50 // A concrete stub layout may look like this (both data
51 // and code sections could be empty as well):
52 //
53 // ________
54 // stub -->| | <--+
55 // | data | |
56 // |________| |
57 // code_begin -->| | |
58 // | | |
203 void remove_first(); // remove the first stub in the queue
204 void remove_first(int n); // remove the first n stubs in the queue
205 void remove_all(); // remove all stubs in the queue
206
207 // Iteration
208 static void queues_do(void f(StubQueue* s)); // call f with each StubQueue
209 void stubs_do(void f(Stub* s)); // call f with all stubs
210 Stub* first() const { return number_of_stubs() > 0 ? stub_at(_queue_begin) : NULL; }
211 Stub* next(Stub* s) const { int i = index_of(s) + stub_size(s);
212 if (i == _buffer_limit) i = 0;
213 return (i == _queue_end) ? NULL : stub_at(i);
214 }
215
216 address stub_code_begin(Stub* s) const { return _stub_interface->code_begin(s); }
217 address stub_code_end(Stub* s) const { return _stub_interface->code_end(s); }
218
219 // Debugging/printing
220 void verify(); // verifies the stub queue
221 void print(); // prints information about the stub queue
222 };
223
224 #endif // SHARE_VM_CODE_STUBS_HPP
|