author | mr |
Tue, 29 Oct 2019 13:52:04 -0700 | |
changeset 58850 | f4290bf1cc21 |
parent 54960 | e46fe26d7f77 |
permissions | -rw-r--r-- |
1 | 1 |
/* |
54807 | 2 |
* Copyright (c) 1997, 2019, 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" |
14626
0cf4eccf130f
8003240: x86: move MacroAssembler into separate file
twisti
parents:
9980
diff
changeset
|
26 |
#include "asm/macroAssembler.hpp" |
0cf4eccf130f
8003240: x86: move MacroAssembler into separate file
twisti
parents:
9980
diff
changeset
|
27 |
#include "asm/macroAssembler.inline.hpp" |
0cf4eccf130f
8003240: x86: move MacroAssembler into separate file
twisti
parents:
9980
diff
changeset
|
28 |
#include "code/codeCache.hpp" |
7397 | 29 |
#include "compiler/disassembler.hpp" |
30 |
#include "oops/oop.inline.hpp" |
|
31 |
#include "prims/forte.hpp" |
|
32 |
#include "runtime/stubCodeGenerator.hpp" |
|
1 | 33 |
|
34 |
||
35 |
// Implementation of StubCodeDesc |
|
36 |
||
37 |
StubCodeDesc* StubCodeDesc::_list = NULL; |
|
36074
11263906664c
8138922: StubCodeDesc constructor publishes partially-constructed objects on StubCodeDesc::_list
vlivanov
parents:
31620
diff
changeset
|
38 |
bool StubCodeDesc::_frozen = false; |
1 | 39 |
|
40 |
StubCodeDesc* StubCodeDesc::desc_for(address pc) { |
|
41 |
StubCodeDesc* p = _list; |
|
36301
cb578d8c6cba
8149741: Don't refer to stub entry points by index in external_word relocations
vlivanov
parents:
36074
diff
changeset
|
42 |
while (p != NULL && !p->contains(pc)) { |
cb578d8c6cba
8149741: Don't refer to stub entry points by index in external_word relocations
vlivanov
parents:
36074
diff
changeset
|
43 |
p = p->_next; |
cb578d8c6cba
8149741: Don't refer to stub entry points by index in external_word relocations
vlivanov
parents:
36074
diff
changeset
|
44 |
} |
1 | 45 |
return p; |
46 |
} |
|
47 |
||
48 |
const char* StubCodeDesc::name_for(address pc) { |
|
49 |
StubCodeDesc* p = desc_for(pc); |
|
50 |
return p == NULL ? NULL : p->name(); |
|
51 |
} |
|
52 |
||
53 |
||
36074
11263906664c
8138922: StubCodeDesc constructor publishes partially-constructed objects on StubCodeDesc::_list
vlivanov
parents:
31620
diff
changeset
|
54 |
void StubCodeDesc::freeze() { |
11263906664c
8138922: StubCodeDesc constructor publishes partially-constructed objects on StubCodeDesc::_list
vlivanov
parents:
31620
diff
changeset
|
55 |
assert(!_frozen, "repeated freeze operation"); |
11263906664c
8138922: StubCodeDesc constructor publishes partially-constructed objects on StubCodeDesc::_list
vlivanov
parents:
31620
diff
changeset
|
56 |
_frozen = true; |
11263906664c
8138922: StubCodeDesc constructor publishes partially-constructed objects on StubCodeDesc::_list
vlivanov
parents:
31620
diff
changeset
|
57 |
} |
11263906664c
8138922: StubCodeDesc constructor publishes partially-constructed objects on StubCodeDesc::_list
vlivanov
parents:
31620
diff
changeset
|
58 |
|
6176
4d9030fe341f
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
5924
diff
changeset
|
59 |
void StubCodeDesc::print_on(outputStream* st) const { |
24424
2658d7834c6e
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
22234
diff
changeset
|
60 |
st->print("%s", group()); |
6176
4d9030fe341f
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
5924
diff
changeset
|
61 |
st->print("::"); |
24424
2658d7834c6e
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
22234
diff
changeset
|
62 |
st->print("%s", name()); |
54960
e46fe26d7f77
8213084: Rework and enhance Print[Opto]Assembly output
lucy
parents:
54807
diff
changeset
|
63 |
st->print(" [" INTPTR_FORMAT ", " INTPTR_FORMAT "] (%d bytes)", p2i(begin()), p2i(end()), size_in_bytes()); |
1 | 64 |
} |
65 |
||
54807 | 66 |
void StubCodeDesc::print() const { print_on(tty); } |
67 |
||
1 | 68 |
// Implementation of StubCodeGenerator |
69 |
||
9980
a330de5dea17
7052219: JSR 292: Crash in ~BufferBlob::MethodHandles adapters
never
parents:
8921
diff
changeset
|
70 |
StubCodeGenerator::StubCodeGenerator(CodeBuffer* code, bool print_code) { |
36301
cb578d8c6cba
8149741: Don't refer to stub entry points by index in external_word relocations
vlivanov
parents:
36074
diff
changeset
|
71 |
_masm = new MacroAssembler(code ); |
cb578d8c6cba
8149741: Don't refer to stub entry points by index in external_word relocations
vlivanov
parents:
36074
diff
changeset
|
72 |
_print_code = PrintStubCode || print_code; |
1 | 73 |
} |
74 |
||
75 |
StubCodeGenerator::~StubCodeGenerator() { |
|
50528
1fd4844371bb
8204680: Disassembly does not display code strings in stubs
aph
parents:
47216
diff
changeset
|
76 |
if (PRODUCT_ONLY(_print_code) NOT_PRODUCT(true)) { |
1 | 77 |
CodeBuffer* cbuf = _masm->code(); |
78 |
CodeBlob* blob = CodeCache::find_blob_unsafe(cbuf->insts()->start()); |
|
79 |
if (blob != NULL) { |
|
16368
713209c45a82
8008555: Debugging code in compiled method sometimes leaks memory
roland
parents:
14626
diff
changeset
|
80 |
blob->set_strings(cbuf->strings()); |
1 | 81 |
} |
82 |
} |
|
83 |
} |
|
84 |
||
85 |
void StubCodeGenerator::stub_prolog(StubCodeDesc* cdesc) { |
|
86 |
// default implementation - do nothing |
|
87 |
} |
|
88 |
||
89 |
void StubCodeGenerator::stub_epilog(StubCodeDesc* cdesc) { |
|
36301
cb578d8c6cba
8149741: Don't refer to stub entry points by index in external_word relocations
vlivanov
parents:
36074
diff
changeset
|
90 |
if (_print_code) { |
50528
1fd4844371bb
8204680: Disassembly does not display code strings in stubs
aph
parents:
47216
diff
changeset
|
91 |
CodeStrings cs; |
1fd4844371bb
8204680: Disassembly does not display code strings in stubs
aph
parents:
47216
diff
changeset
|
92 |
ptrdiff_t offset = 0; |
1fd4844371bb
8204680: Disassembly does not display code strings in stubs
aph
parents:
47216
diff
changeset
|
93 |
#ifndef PRODUCT |
1fd4844371bb
8204680: Disassembly does not display code strings in stubs
aph
parents:
47216
diff
changeset
|
94 |
// Find the code strings in the outer CodeBuffer. |
1fd4844371bb
8204680: Disassembly does not display code strings in stubs
aph
parents:
47216
diff
changeset
|
95 |
CodeBuffer *outer_cbuf = _masm->code_section()->outer(); |
1fd4844371bb
8204680: Disassembly does not display code strings in stubs
aph
parents:
47216
diff
changeset
|
96 |
cs = outer_cbuf->strings(); |
1fd4844371bb
8204680: Disassembly does not display code strings in stubs
aph
parents:
47216
diff
changeset
|
97 |
// The offset from the start of the outer CodeBuffer to the start |
1fd4844371bb
8204680: Disassembly does not display code strings in stubs
aph
parents:
47216
diff
changeset
|
98 |
// of this stub. |
1fd4844371bb
8204680: Disassembly does not display code strings in stubs
aph
parents:
47216
diff
changeset
|
99 |
offset = cdesc->begin() - outer_cbuf->insts()->start(); |
1fd4844371bb
8204680: Disassembly does not display code strings in stubs
aph
parents:
47216
diff
changeset
|
100 |
#endif |
54960
e46fe26d7f77
8213084: Rework and enhance Print[Opto]Assembly output
lucy
parents:
54807
diff
changeset
|
101 |
ttyLocker ttyl; |
e46fe26d7f77
8213084: Rework and enhance Print[Opto]Assembly output
lucy
parents:
54807
diff
changeset
|
102 |
tty->print_cr("- - - [BEGIN] - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -"); |
e46fe26d7f77
8213084: Rework and enhance Print[Opto]Assembly output
lucy
parents:
54807
diff
changeset
|
103 |
cdesc->print_on(tty); |
36301
cb578d8c6cba
8149741: Don't refer to stub entry points by index in external_word relocations
vlivanov
parents:
36074
diff
changeset
|
104 |
tty->cr(); |
54960
e46fe26d7f77
8213084: Rework and enhance Print[Opto]Assembly output
lucy
parents:
54807
diff
changeset
|
105 |
Disassembler::decode(cdesc->begin(), cdesc->end(), tty, cs /*, offset */); |
e46fe26d7f77
8213084: Rework and enhance Print[Opto]Assembly output
lucy
parents:
54807
diff
changeset
|
106 |
tty->print_cr("- - - [END] - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -"); |
36301
cb578d8c6cba
8149741: Don't refer to stub entry points by index in external_word relocations
vlivanov
parents:
36074
diff
changeset
|
107 |
tty->cr(); |
cb578d8c6cba
8149741: Don't refer to stub entry points by index in external_word relocations
vlivanov
parents:
36074
diff
changeset
|
108 |
} |
1 | 109 |
} |
110 |
||
111 |
||
112 |
// Implementation of CodeMark |
|
113 |
||
114 |
StubCodeMark::StubCodeMark(StubCodeGenerator* cgen, const char* group, const char* name) { |
|
115 |
_cgen = cgen; |
|
116 |
_cdesc = new StubCodeDesc(group, name, _cgen->assembler()->pc()); |
|
117 |
_cgen->stub_prolog(_cdesc); |
|
118 |
// define the stub's beginning (= entry point) to be after the prolog: |
|
119 |
_cdesc->set_begin(_cgen->assembler()->pc()); |
|
120 |
} |
|
121 |
||
122 |
StubCodeMark::~StubCodeMark() { |
|
123 |
_cgen->assembler()->flush(); |
|
124 |
_cdesc->set_end(_cgen->assembler()->pc()); |
|
125 |
assert(StubCodeDesc::_list == _cdesc, "expected order on list"); |
|
126 |
_cgen->stub_epilog(_cdesc); |
|
127 |
Forte::register_stub(_cdesc->name(), _cdesc->begin(), _cdesc->end()); |
|
128 |
||
129 |
if (JvmtiExport::should_post_dynamic_code_generated()) { |
|
130 |
JvmtiExport::post_dynamic_code_generated(_cdesc->name(), _cdesc->begin(), _cdesc->end()); |
|
131 |
} |
|
132 |
} |