author | erikj |
Tue, 12 Sep 2017 19:03:39 +0200 | |
changeset 47216 | 71c04702a3d5 |
parent 36301 | hotspot/src/share/vm/runtime/stubCodeGenerator.hpp@cb578d8c6cba |
child 53244 | 9807daeb47c4 |
permissions | -rw-r--r-- |
1 | 1 |
/* |
31620
53be635ad49c
8087333: Optionally Pre-Generate the HotSpot Template Interpreter
bdelsart
parents:
22551
diff
changeset
|
2 |
* Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. |
1 | 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 |
* |
|
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
7397 | 25 |
#ifndef SHARE_VM_RUNTIME_STUBCODEGENERATOR_HPP |
26 |
#define SHARE_VM_RUNTIME_STUBCODEGENERATOR_HPP |
|
27 |
||
28 |
#include "asm/assembler.hpp" |
|
29 |
#include "memory/allocation.hpp" |
|
30 |
||
36074
11263906664c
8138922: StubCodeDesc constructor publishes partially-constructed objects on StubCodeDesc::_list
vlivanov
parents:
31620
diff
changeset
|
31 |
// All the basic framework for stub code generation/debugging/printing. |
1 | 32 |
|
33 |
||
34 |
// A StubCodeDesc describes a piece of generated code (usually stubs). |
|
35 |
// This information is mainly useful for debugging and printing. |
|
36 |
// Currently, code descriptors are simply chained in a linked list, |
|
37 |
// this may have to change if searching becomes too slow. |
|
38 |
||
13195 | 39 |
class StubCodeDesc: public CHeapObj<mtCode> { |
36074
11263906664c
8138922: StubCodeDesc constructor publishes partially-constructed objects on StubCodeDesc::_list
vlivanov
parents:
31620
diff
changeset
|
40 |
private: |
1 | 41 |
static StubCodeDesc* _list; // the list of all descriptors |
36074
11263906664c
8138922: StubCodeDesc constructor publishes partially-constructed objects on StubCodeDesc::_list
vlivanov
parents:
31620
diff
changeset
|
42 |
static bool _frozen; // determines whether _list modifications are allowed |
1 | 43 |
|
44 |
StubCodeDesc* _next; // the next element in the linked list |
|
45 |
const char* _group; // the group to which the stub code belongs |
|
46 |
const char* _name; // the name assigned to the stub code |
|
47 |
address _begin; // points to the first byte of the stub code (included) |
|
48 |
address _end; // points to the first byte after the stub code (excluded) |
|
49 |
||
50 |
void set_end(address end) { |
|
51 |
assert(_begin <= end, "begin & end not properly ordered"); |
|
52 |
_end = end; |
|
53 |
} |
|
54 |
||
55 |
void set_begin(address begin) { |
|
56 |
assert(begin >= _begin, "begin may not decrease"); |
|
57 |
assert(_end == NULL || begin <= _end, "begin & end not properly ordered"); |
|
58 |
_begin = begin; |
|
59 |
} |
|
60 |
||
61 |
friend class StubCodeMark; |
|
62 |
friend class StubCodeGenerator; |
|
63 |
||
64 |
public: |
|
36301
cb578d8c6cba
8149741: Don't refer to stub entry points by index in external_word relocations
vlivanov
parents:
36074
diff
changeset
|
65 |
static StubCodeDesc* first() { return _list; } |
cb578d8c6cba
8149741: Don't refer to stub entry points by index in external_word relocations
vlivanov
parents:
36074
diff
changeset
|
66 |
static StubCodeDesc* next(StubCodeDesc* desc) { return desc->_next; } |
cb578d8c6cba
8149741: Don't refer to stub entry points by index in external_word relocations
vlivanov
parents:
36074
diff
changeset
|
67 |
|
1 | 68 |
static StubCodeDesc* desc_for(address pc); // returns the code descriptor for the code containing pc or NULL |
69 |
static const char* name_for(address pc); // returns the name of the code containing pc or NULL |
|
70 |
||
31620
53be635ad49c
8087333: Optionally Pre-Generate the HotSpot Template Interpreter
bdelsart
parents:
22551
diff
changeset
|
71 |
StubCodeDesc(const char* group, const char* name, address begin, address end = NULL) { |
36074
11263906664c
8138922: StubCodeDesc constructor publishes partially-constructed objects on StubCodeDesc::_list
vlivanov
parents:
31620
diff
changeset
|
72 |
assert(!_frozen, "no modifications allowed"); |
1 | 73 |
assert(name != NULL, "no name specified"); |
74 |
_next = _list; |
|
75 |
_group = group; |
|
76 |
_name = name; |
|
77 |
_begin = begin; |
|
31620
53be635ad49c
8087333: Optionally Pre-Generate the HotSpot Template Interpreter
bdelsart
parents:
22551
diff
changeset
|
78 |
_end = end; |
1 | 79 |
_list = this; |
80 |
}; |
|
81 |
||
36074
11263906664c
8138922: StubCodeDesc constructor publishes partially-constructed objects on StubCodeDesc::_list
vlivanov
parents:
31620
diff
changeset
|
82 |
static void freeze(); |
11263906664c
8138922: StubCodeDesc constructor publishes partially-constructed objects on StubCodeDesc::_list
vlivanov
parents:
31620
diff
changeset
|
83 |
|
1 | 84 |
const char* group() const { return _group; } |
85 |
const char* name() const { return _name; } |
|
86 |
address begin() const { return _begin; } |
|
87 |
address end() const { return _end; } |
|
88 |
int size_in_bytes() const { return _end - _begin; } |
|
89 |
bool contains(address pc) const { return _begin <= pc && pc < _end; } |
|
6176
4d9030fe341f
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
5547
diff
changeset
|
90 |
void print_on(outputStream* st) const; |
4d9030fe341f
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
5547
diff
changeset
|
91 |
void print() const { print_on(tty); } |
1 | 92 |
}; |
93 |
||
94 |
// The base class for all stub-generating code generators. |
|
95 |
// Provides utility functions. |
|
96 |
||
97 |
class StubCodeGenerator: public StackObj { |
|
36301
cb578d8c6cba
8149741: Don't refer to stub entry points by index in external_word relocations
vlivanov
parents:
36074
diff
changeset
|
98 |
private: |
cb578d8c6cba
8149741: Don't refer to stub entry points by index in external_word relocations
vlivanov
parents:
36074
diff
changeset
|
99 |
bool _print_code; |
cb578d8c6cba
8149741: Don't refer to stub entry points by index in external_word relocations
vlivanov
parents:
36074
diff
changeset
|
100 |
|
1 | 101 |
protected: |
102 |
MacroAssembler* _masm; |
|
103 |
||
104 |
public: |
|
9980
a330de5dea17
7052219: JSR 292: Crash in ~BufferBlob::MethodHandles adapters
never
parents:
7397
diff
changeset
|
105 |
StubCodeGenerator(CodeBuffer* code, bool print_code = false); |
1 | 106 |
~StubCodeGenerator(); |
107 |
||
108 |
MacroAssembler* assembler() const { return _masm; } |
|
109 |
||
110 |
virtual void stub_prolog(StubCodeDesc* cdesc); // called by StubCodeMark constructor |
|
111 |
virtual void stub_epilog(StubCodeDesc* cdesc); // called by StubCodeMark destructor |
|
112 |
}; |
|
113 |
||
114 |
||
22551 | 115 |
// Stack-allocated helper class used to associate a stub code with a name. |
1 | 116 |
// All stub code generating functions that use a StubCodeMark will be registered |
117 |
// in the global StubCodeDesc list and the generated stub code can be identified |
|
118 |
// later via an address pointing into it. |
|
119 |
||
120 |
class StubCodeMark: public StackObj { |
|
36074
11263906664c
8138922: StubCodeDesc constructor publishes partially-constructed objects on StubCodeDesc::_list
vlivanov
parents:
31620
diff
changeset
|
121 |
private: |
1 | 122 |
StubCodeGenerator* _cgen; |
123 |
StubCodeDesc* _cdesc; |
|
124 |
||
125 |
public: |
|
126 |
StubCodeMark(StubCodeGenerator* cgen, const char* group, const char* name); |
|
127 |
~StubCodeMark(); |
|
128 |
||
129 |
}; |
|
7397 | 130 |
|
131 |
#endif // SHARE_VM_RUNTIME_STUBCODEGENERATOR_HPP |