author | bobv |
Wed, 02 Feb 2011 11:35:26 -0500 | |
changeset 8107 | 78e5bd944384 |
parent 7397 | 5b173b4ca846 |
child 8921 | 14bfe81f2a9d |
permissions | -rw-r--r-- |
1 | 1 |
/* |
5924
dc9d04930c82
6965184: possible races in make_not_entrant_or_zombie
never
parents:
5547
diff
changeset
|
2 |
* Copyright (c) 1997, 2010, 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:
670
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
670
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:
670
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
7397 | 25 |
#include "precompiled.hpp" |
26 |
#include "compiler/disassembler.hpp" |
|
27 |
#include "oops/oop.inline.hpp" |
|
28 |
#include "prims/forte.hpp" |
|
29 |
#include "runtime/stubCodeGenerator.hpp" |
|
30 |
#ifdef TARGET_ARCH_x86 |
|
31 |
# include "assembler_x86.inline.hpp" |
|
32 |
#endif |
|
33 |
#ifdef TARGET_ARCH_sparc |
|
34 |
# include "assembler_sparc.inline.hpp" |
|
35 |
#endif |
|
36 |
#ifdef TARGET_ARCH_zero |
|
37 |
# include "assembler_zero.inline.hpp" |
|
38 |
#endif |
|
8107
78e5bd944384
7016023: Enable building ARM and PPC from src/closed repository
bobv
parents:
7397
diff
changeset
|
39 |
#ifdef TARGET_ARCH_arm |
78e5bd944384
7016023: Enable building ARM and PPC from src/closed repository
bobv
parents:
7397
diff
changeset
|
40 |
# include "assembler_arm.inline.hpp" |
78e5bd944384
7016023: Enable building ARM and PPC from src/closed repository
bobv
parents:
7397
diff
changeset
|
41 |
#endif |
78e5bd944384
7016023: Enable building ARM and PPC from src/closed repository
bobv
parents:
7397
diff
changeset
|
42 |
#ifdef TARGET_ARCH_ppc |
78e5bd944384
7016023: Enable building ARM and PPC from src/closed repository
bobv
parents:
7397
diff
changeset
|
43 |
# include "assembler_ppc.inline.hpp" |
78e5bd944384
7016023: Enable building ARM and PPC from src/closed repository
bobv
parents:
7397
diff
changeset
|
44 |
#endif |
1 | 45 |
|
46 |
||
47 |
// Implementation of StubCodeDesc |
|
48 |
||
49 |
StubCodeDesc* StubCodeDesc::_list = NULL; |
|
50 |
int StubCodeDesc::_count = 0; |
|
51 |
||
52 |
||
53 |
StubCodeDesc* StubCodeDesc::desc_for(address pc) { |
|
54 |
StubCodeDesc* p = _list; |
|
55 |
while (p != NULL && !p->contains(pc)) p = p->_next; |
|
56 |
// p == NULL || p->contains(pc) |
|
57 |
return p; |
|
58 |
} |
|
59 |
||
60 |
||
61 |
StubCodeDesc* StubCodeDesc::desc_for_index(int index) { |
|
62 |
StubCodeDesc* p = _list; |
|
63 |
while (p != NULL && p->index() != index) p = p->_next; |
|
64 |
return p; |
|
65 |
} |
|
66 |
||
67 |
||
68 |
const char* StubCodeDesc::name_for(address pc) { |
|
69 |
StubCodeDesc* p = desc_for(pc); |
|
70 |
return p == NULL ? NULL : p->name(); |
|
71 |
} |
|
72 |
||
73 |
||
6176
4d9030fe341f
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
5924
diff
changeset
|
74 |
void StubCodeDesc::print_on(outputStream* st) const { |
4d9030fe341f
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
5924
diff
changeset
|
75 |
st->print(group()); |
4d9030fe341f
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
5924
diff
changeset
|
76 |
st->print("::"); |
4d9030fe341f
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
5924
diff
changeset
|
77 |
st->print(name()); |
4d9030fe341f
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
5924
diff
changeset
|
78 |
st->print(" [" INTPTR_FORMAT ", " INTPTR_FORMAT "[ (%d bytes)", begin(), end(), size_in_bytes()); |
1 | 79 |
} |
80 |
||
81 |
// Implementation of StubCodeGenerator |
|
82 |
||
83 |
StubCodeGenerator::StubCodeGenerator(CodeBuffer* code) { |
|
84 |
_masm = new MacroAssembler(code); |
|
85 |
_first_stub = _last_stub = NULL; |
|
86 |
} |
|
87 |
||
88 |
extern "C" { |
|
89 |
static int compare_cdesc(const void* void_a, const void* void_b) { |
|
90 |
int ai = (*((StubCodeDesc**) void_a))->index(); |
|
91 |
int bi = (*((StubCodeDesc**) void_b))->index(); |
|
92 |
return ai - bi; |
|
93 |
} |
|
94 |
} |
|
95 |
||
96 |
StubCodeGenerator::~StubCodeGenerator() { |
|
97 |
if (PrintStubCode) { |
|
98 |
CodeBuffer* cbuf = _masm->code(); |
|
99 |
CodeBlob* blob = CodeCache::find_blob_unsafe(cbuf->insts()->start()); |
|
100 |
if (blob != NULL) { |
|
101 |
blob->set_comments(cbuf->comments()); |
|
102 |
} |
|
103 |
bool saw_first = false; |
|
104 |
StubCodeDesc* toprint[1000]; |
|
105 |
int toprint_len = 0; |
|
106 |
for (StubCodeDesc* cdesc = _last_stub; cdesc != NULL; cdesc = cdesc->_next) { |
|
107 |
toprint[toprint_len++] = cdesc; |
|
108 |
if (cdesc == _first_stub) { saw_first = true; break; } |
|
109 |
} |
|
110 |
assert(saw_first, "must get both first & last"); |
|
111 |
// Print in reverse order: |
|
112 |
qsort(toprint, toprint_len, sizeof(toprint[0]), compare_cdesc); |
|
113 |
for (int i = 0; i < toprint_len; i++) { |
|
114 |
StubCodeDesc* cdesc = toprint[i]; |
|
115 |
cdesc->print(); |
|
116 |
tty->cr(); |
|
117 |
Disassembler::decode(cdesc->begin(), cdesc->end()); |
|
118 |
tty->cr(); |
|
119 |
} |
|
120 |
} |
|
121 |
} |
|
122 |
||
123 |
||
124 |
void StubCodeGenerator::stub_prolog(StubCodeDesc* cdesc) { |
|
125 |
// default implementation - do nothing |
|
126 |
} |
|
127 |
||
128 |
||
129 |
void StubCodeGenerator::stub_epilog(StubCodeDesc* cdesc) { |
|
130 |
// default implementation - record the cdesc |
|
131 |
if (_first_stub == NULL) _first_stub = cdesc; |
|
132 |
_last_stub = cdesc; |
|
133 |
} |
|
134 |
||
135 |
||
136 |
// Implementation of CodeMark |
|
137 |
||
138 |
StubCodeMark::StubCodeMark(StubCodeGenerator* cgen, const char* group, const char* name) { |
|
139 |
_cgen = cgen; |
|
140 |
_cdesc = new StubCodeDesc(group, name, _cgen->assembler()->pc()); |
|
141 |
_cgen->stub_prolog(_cdesc); |
|
142 |
// define the stub's beginning (= entry point) to be after the prolog: |
|
143 |
_cdesc->set_begin(_cgen->assembler()->pc()); |
|
144 |
} |
|
145 |
||
146 |
StubCodeMark::~StubCodeMark() { |
|
147 |
_cgen->assembler()->flush(); |
|
148 |
_cdesc->set_end(_cgen->assembler()->pc()); |
|
149 |
assert(StubCodeDesc::_list == _cdesc, "expected order on list"); |
|
150 |
_cgen->stub_epilog(_cdesc); |
|
151 |
Forte::register_stub(_cdesc->name(), _cdesc->begin(), _cdesc->end()); |
|
152 |
||
153 |
if (JvmtiExport::should_post_dynamic_code_generated()) { |
|
154 |
JvmtiExport::post_dynamic_code_generated(_cdesc->name(), _cdesc->begin(), _cdesc->end()); |
|
155 |
} |
|
156 |
} |