Mercurial > hg > truffle
annotate src/share/vm/runtime/stubCodeGenerator.cpp @ 4681:84e7d6690293
added bytecode name to deoptimization details
author | Christian Haeubl <christian.haeubl@oracle.com> |
---|---|
date | Thu, 23 Feb 2012 16:57:05 -0800 |
parents | a9b8b43b115f |
children | cd3d6a6b95d9 |
rev | line source |
---|---|
0 | 1 /* |
2426
1d1603768966
7010070: Update all 2010 Oracle-changed OpenJDK files to have the proper copyright dates - second pass
trims
parents:
2192
diff
changeset
|
2 * Copyright (c) 1997, 2011, 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 | |
1972 | 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 | |
2192
b92c45f2bc75
7016023: Enable building ARM and PPC from src/closed repository
bobv
parents:
1972
diff
changeset
|
39 #ifdef TARGET_ARCH_arm |
b92c45f2bc75
7016023: Enable building ARM and PPC from src/closed repository
bobv
parents:
1972
diff
changeset
|
40 # include "assembler_arm.inline.hpp" |
b92c45f2bc75
7016023: Enable building ARM and PPC from src/closed repository
bobv
parents:
1972
diff
changeset
|
41 #endif |
b92c45f2bc75
7016023: Enable building ARM and PPC from src/closed repository
bobv
parents:
1972
diff
changeset
|
42 #ifdef TARGET_ARCH_ppc |
b92c45f2bc75
7016023: Enable building ARM and PPC from src/closed repository
bobv
parents:
1972
diff
changeset
|
43 # include "assembler_ppc.inline.hpp" |
b92c45f2bc75
7016023: Enable building ARM and PPC from src/closed repository
bobv
parents:
1972
diff
changeset
|
44 #endif |
0 | 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 | |
1681
126ea7725993
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
1644
diff
changeset
|
74 void StubCodeDesc::print_on(outputStream* st) const { |
126ea7725993
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
1644
diff
changeset
|
75 st->print(group()); |
126ea7725993
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
1644
diff
changeset
|
76 st->print("::"); |
126ea7725993
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
1644
diff
changeset
|
77 st->print(name()); |
126ea7725993
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
1644
diff
changeset
|
78 st->print(" [" INTPTR_FORMAT ", " INTPTR_FORMAT "[ (%d bytes)", begin(), end(), size_in_bytes()); |
0 | 79 } |
80 | |
81 // Implementation of StubCodeGenerator | |
82 | |
3449
a9b8b43b115f
7052219: JSR 292: Crash in ~BufferBlob::MethodHandles adapters
never
parents:
2426
diff
changeset
|
83 StubCodeGenerator::StubCodeGenerator(CodeBuffer* code, bool print_code) { |
0 | 84 _masm = new MacroAssembler(code); |
85 _first_stub = _last_stub = NULL; | |
3449
a9b8b43b115f
7052219: JSR 292: Crash in ~BufferBlob::MethodHandles adapters
never
parents:
2426
diff
changeset
|
86 _print_code = print_code; |
0 | 87 } |
88 | |
89 extern "C" { | |
90 static int compare_cdesc(const void* void_a, const void* void_b) { | |
91 int ai = (*((StubCodeDesc**) void_a))->index(); | |
92 int bi = (*((StubCodeDesc**) void_b))->index(); | |
93 return ai - bi; | |
94 } | |
95 } | |
96 | |
97 StubCodeGenerator::~StubCodeGenerator() { | |
3449
a9b8b43b115f
7052219: JSR 292: Crash in ~BufferBlob::MethodHandles adapters
never
parents:
2426
diff
changeset
|
98 if (PrintStubCode || _print_code) { |
0 | 99 CodeBuffer* cbuf = _masm->code(); |
100 CodeBlob* blob = CodeCache::find_blob_unsafe(cbuf->insts()->start()); | |
101 if (blob != NULL) { | |
102 blob->set_comments(cbuf->comments()); | |
103 } | |
104 bool saw_first = false; | |
105 StubCodeDesc* toprint[1000]; | |
106 int toprint_len = 0; | |
107 for (StubCodeDesc* cdesc = _last_stub; cdesc != NULL; cdesc = cdesc->_next) { | |
108 toprint[toprint_len++] = cdesc; | |
109 if (cdesc == _first_stub) { saw_first = true; break; } | |
110 } | |
111 assert(saw_first, "must get both first & last"); | |
112 // Print in reverse order: | |
113 qsort(toprint, toprint_len, sizeof(toprint[0]), compare_cdesc); | |
114 for (int i = 0; i < toprint_len; i++) { | |
115 StubCodeDesc* cdesc = toprint[i]; | |
116 cdesc->print(); | |
117 tty->cr(); | |
118 Disassembler::decode(cdesc->begin(), cdesc->end()); | |
119 tty->cr(); | |
120 } | |
121 } | |
122 } | |
123 | |
124 | |
125 void StubCodeGenerator::stub_prolog(StubCodeDesc* cdesc) { | |
126 // default implementation - do nothing | |
127 } | |
128 | |
129 | |
130 void StubCodeGenerator::stub_epilog(StubCodeDesc* cdesc) { | |
131 // default implementation - record the cdesc | |
132 if (_first_stub == NULL) _first_stub = cdesc; | |
133 _last_stub = cdesc; | |
134 } | |
135 | |
136 | |
137 // Implementation of CodeMark | |
138 | |
139 StubCodeMark::StubCodeMark(StubCodeGenerator* cgen, const char* group, const char* name) { | |
140 _cgen = cgen; | |
141 _cdesc = new StubCodeDesc(group, name, _cgen->assembler()->pc()); | |
142 _cgen->stub_prolog(_cdesc); | |
143 // define the stub's beginning (= entry point) to be after the prolog: | |
144 _cdesc->set_begin(_cgen->assembler()->pc()); | |
145 } | |
146 | |
147 StubCodeMark::~StubCodeMark() { | |
148 _cgen->assembler()->flush(); | |
149 _cdesc->set_end(_cgen->assembler()->pc()); | |
150 assert(StubCodeDesc::_list == _cdesc, "expected order on list"); | |
151 _cgen->stub_epilog(_cdesc); | |
152 Forte::register_stub(_cdesc->name(), _cdesc->begin(), _cdesc->end()); | |
153 | |
154 if (JvmtiExport::should_post_dynamic_code_generated()) { | |
155 JvmtiExport::post_dynamic_code_generated(_cdesc->name(), _cdesc->begin(), _cdesc->end()); | |
156 } | |
157 } |