Mercurial > hg > truffle
annotate src/share/vm/runtime/stubCodeGenerator.cpp @ 1764:14197af1010e
Merge
author | never |
---|---|
date | Fri, 27 Aug 2010 17:35:08 -0700 |
parents | 126ea7725993 |
children | f95d63e2154a |
rev | line source |
---|---|
0 | 1 /* |
1644
2a47bd84841f
6965184: possible races in make_not_entrant_or_zombie
never
parents:
1552
diff
changeset
|
2 * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. |
0 | 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 * | |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
196
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
196
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
196
diff
changeset
|
21 * questions. |
0 | 22 * |
23 */ | |
24 | |
25 #include "incls/_precompiled.incl" | |
26 #include "incls/_stubCodeGenerator.cpp.incl" | |
27 | |
28 | |
29 // Implementation of StubCodeDesc | |
30 | |
31 StubCodeDesc* StubCodeDesc::_list = NULL; | |
32 int StubCodeDesc::_count = 0; | |
33 | |
34 | |
35 StubCodeDesc* StubCodeDesc::desc_for(address pc) { | |
36 StubCodeDesc* p = _list; | |
37 while (p != NULL && !p->contains(pc)) p = p->_next; | |
38 // p == NULL || p->contains(pc) | |
39 return p; | |
40 } | |
41 | |
42 | |
43 StubCodeDesc* StubCodeDesc::desc_for_index(int index) { | |
44 StubCodeDesc* p = _list; | |
45 while (p != NULL && p->index() != index) p = p->_next; | |
46 return p; | |
47 } | |
48 | |
49 | |
50 const char* StubCodeDesc::name_for(address pc) { | |
51 StubCodeDesc* p = desc_for(pc); | |
52 return p == NULL ? NULL : p->name(); | |
53 } | |
54 | |
55 | |
1681
126ea7725993
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
1644
diff
changeset
|
56 void StubCodeDesc::print_on(outputStream* st) const { |
126ea7725993
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
1644
diff
changeset
|
57 st->print(group()); |
126ea7725993
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
1644
diff
changeset
|
58 st->print("::"); |
126ea7725993
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
1644
diff
changeset
|
59 st->print(name()); |
126ea7725993
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
1644
diff
changeset
|
60 st->print(" [" INTPTR_FORMAT ", " INTPTR_FORMAT "[ (%d bytes)", begin(), end(), size_in_bytes()); |
0 | 61 } |
62 | |
63 // Implementation of StubCodeGenerator | |
64 | |
65 StubCodeGenerator::StubCodeGenerator(CodeBuffer* code) { | |
66 _masm = new MacroAssembler(code); | |
67 _first_stub = _last_stub = NULL; | |
68 } | |
69 | |
70 extern "C" { | |
71 static int compare_cdesc(const void* void_a, const void* void_b) { | |
72 int ai = (*((StubCodeDesc**) void_a))->index(); | |
73 int bi = (*((StubCodeDesc**) void_b))->index(); | |
74 return ai - bi; | |
75 } | |
76 } | |
77 | |
78 StubCodeGenerator::~StubCodeGenerator() { | |
79 if (PrintStubCode) { | |
80 CodeBuffer* cbuf = _masm->code(); | |
81 CodeBlob* blob = CodeCache::find_blob_unsafe(cbuf->insts()->start()); | |
82 if (blob != NULL) { | |
83 blob->set_comments(cbuf->comments()); | |
84 } | |
85 bool saw_first = false; | |
86 StubCodeDesc* toprint[1000]; | |
87 int toprint_len = 0; | |
88 for (StubCodeDesc* cdesc = _last_stub; cdesc != NULL; cdesc = cdesc->_next) { | |
89 toprint[toprint_len++] = cdesc; | |
90 if (cdesc == _first_stub) { saw_first = true; break; } | |
91 } | |
92 assert(saw_first, "must get both first & last"); | |
93 // Print in reverse order: | |
94 qsort(toprint, toprint_len, sizeof(toprint[0]), compare_cdesc); | |
95 for (int i = 0; i < toprint_len; i++) { | |
96 StubCodeDesc* cdesc = toprint[i]; | |
97 cdesc->print(); | |
98 tty->cr(); | |
99 Disassembler::decode(cdesc->begin(), cdesc->end()); | |
100 tty->cr(); | |
101 } | |
102 } | |
103 } | |
104 | |
105 | |
106 void StubCodeGenerator::stub_prolog(StubCodeDesc* cdesc) { | |
107 // default implementation - do nothing | |
108 } | |
109 | |
110 | |
111 void StubCodeGenerator::stub_epilog(StubCodeDesc* cdesc) { | |
112 // default implementation - record the cdesc | |
113 if (_first_stub == NULL) _first_stub = cdesc; | |
114 _last_stub = cdesc; | |
115 } | |
116 | |
117 | |
118 // Implementation of CodeMark | |
119 | |
120 StubCodeMark::StubCodeMark(StubCodeGenerator* cgen, const char* group, const char* name) { | |
121 _cgen = cgen; | |
122 _cdesc = new StubCodeDesc(group, name, _cgen->assembler()->pc()); | |
123 _cgen->stub_prolog(_cdesc); | |
124 // define the stub's beginning (= entry point) to be after the prolog: | |
125 _cdesc->set_begin(_cgen->assembler()->pc()); | |
126 } | |
127 | |
128 StubCodeMark::~StubCodeMark() { | |
129 _cgen->assembler()->flush(); | |
130 _cdesc->set_end(_cgen->assembler()->pc()); | |
131 assert(StubCodeDesc::_list == _cdesc, "expected order on list"); | |
132 _cgen->stub_epilog(_cdesc); | |
133 Forte::register_stub(_cdesc->name(), _cdesc->begin(), _cdesc->end()); | |
134 | |
135 if (JvmtiExport::should_post_dynamic_code_generated()) { | |
136 JvmtiExport::post_dynamic_code_generated(_cdesc->name(), _cdesc->begin(), _cdesc->end()); | |
137 } | |
138 } |