annotate src/share/vm/asm/assembler.inline.hpp @ 100:c7c777385a15

6667042: PrintAssembly option does not work without special plugin Summary: remove old private plugin interface, simplify, rework old plugin to use unchanged Gnu sources Reviewed-by: kvn, rasbold
author jrose
date Wed, 02 Apr 2008 12:09:59 -0700
parents a61af66fc99e
children c18cbe5936b8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
2 * Copyright 1997-2006 Sun Microsystems, Inc. All Rights Reserved.
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
a61af66fc99e Initial load
duke
parents:
diff changeset
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
a61af66fc99e Initial load
duke
parents:
diff changeset
20 * CA 95054 USA or visit www.sun.com if you need additional information or
a61af66fc99e Initial load
duke
parents:
diff changeset
21 * have any questions.
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
a61af66fc99e Initial load
duke
parents:
diff changeset
25 inline void AbstractAssembler::sync() {
a61af66fc99e Initial load
duke
parents:
diff changeset
26 CodeSection* cs = code_section();
a61af66fc99e Initial load
duke
parents:
diff changeset
27 guarantee(cs->start() == _code_begin, "must not shift code buffer");
a61af66fc99e Initial load
duke
parents:
diff changeset
28 cs->set_end(_code_pos);
a61af66fc99e Initial load
duke
parents:
diff changeset
29 }
a61af66fc99e Initial load
duke
parents:
diff changeset
30
a61af66fc99e Initial load
duke
parents:
diff changeset
31 inline void AbstractAssembler::emit_byte(int x) {
a61af66fc99e Initial load
duke
parents:
diff changeset
32 assert(isByte(x), "not a byte");
a61af66fc99e Initial load
duke
parents:
diff changeset
33 *(unsigned char*)_code_pos = (unsigned char)x;
a61af66fc99e Initial load
duke
parents:
diff changeset
34 _code_pos += sizeof(unsigned char);
a61af66fc99e Initial load
duke
parents:
diff changeset
35 sync();
a61af66fc99e Initial load
duke
parents:
diff changeset
36 }
a61af66fc99e Initial load
duke
parents:
diff changeset
37
a61af66fc99e Initial load
duke
parents:
diff changeset
38
a61af66fc99e Initial load
duke
parents:
diff changeset
39 inline void AbstractAssembler::emit_word(int x) {
a61af66fc99e Initial load
duke
parents:
diff changeset
40 *(short*)_code_pos = (short)x;
a61af66fc99e Initial load
duke
parents:
diff changeset
41 _code_pos += sizeof(short);
a61af66fc99e Initial load
duke
parents:
diff changeset
42 sync();
a61af66fc99e Initial load
duke
parents:
diff changeset
43 }
a61af66fc99e Initial load
duke
parents:
diff changeset
44
a61af66fc99e Initial load
duke
parents:
diff changeset
45
a61af66fc99e Initial load
duke
parents:
diff changeset
46 inline void AbstractAssembler::emit_long(jint x) {
a61af66fc99e Initial load
duke
parents:
diff changeset
47 *(jint*)_code_pos = x;
a61af66fc99e Initial load
duke
parents:
diff changeset
48 _code_pos += sizeof(jint);
a61af66fc99e Initial load
duke
parents:
diff changeset
49 sync();
a61af66fc99e Initial load
duke
parents:
diff changeset
50 }
a61af66fc99e Initial load
duke
parents:
diff changeset
51
a61af66fc99e Initial load
duke
parents:
diff changeset
52 inline void AbstractAssembler::emit_address(address x) {
a61af66fc99e Initial load
duke
parents:
diff changeset
53 *(address*)_code_pos = x;
a61af66fc99e Initial load
duke
parents:
diff changeset
54 _code_pos += sizeof(address);
a61af66fc99e Initial load
duke
parents:
diff changeset
55 sync();
a61af66fc99e Initial load
duke
parents:
diff changeset
56 }
a61af66fc99e Initial load
duke
parents:
diff changeset
57
a61af66fc99e Initial load
duke
parents:
diff changeset
58 inline address AbstractAssembler::inst_mark() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
59 return code_section()->mark();
a61af66fc99e Initial load
duke
parents:
diff changeset
60 }
a61af66fc99e Initial load
duke
parents:
diff changeset
61
a61af66fc99e Initial load
duke
parents:
diff changeset
62
a61af66fc99e Initial load
duke
parents:
diff changeset
63 inline void AbstractAssembler::set_inst_mark() {
a61af66fc99e Initial load
duke
parents:
diff changeset
64 code_section()->set_mark();
a61af66fc99e Initial load
duke
parents:
diff changeset
65 }
a61af66fc99e Initial load
duke
parents:
diff changeset
66
a61af66fc99e Initial load
duke
parents:
diff changeset
67
a61af66fc99e Initial load
duke
parents:
diff changeset
68 inline void AbstractAssembler::clear_inst_mark() {
a61af66fc99e Initial load
duke
parents:
diff changeset
69 code_section()->clear_mark();
a61af66fc99e Initial load
duke
parents:
diff changeset
70 }
a61af66fc99e Initial load
duke
parents:
diff changeset
71
a61af66fc99e Initial load
duke
parents:
diff changeset
72
a61af66fc99e Initial load
duke
parents:
diff changeset
73 inline void AbstractAssembler::relocate(RelocationHolder const& rspec, int format) {
a61af66fc99e Initial load
duke
parents:
diff changeset
74 assert(!pd_check_instruction_mark()
a61af66fc99e Initial load
duke
parents:
diff changeset
75 || inst_mark() == NULL || inst_mark() == _code_pos,
a61af66fc99e Initial load
duke
parents:
diff changeset
76 "call relocate() between instructions");
a61af66fc99e Initial load
duke
parents:
diff changeset
77 code_section()->relocate(_code_pos, rspec, format);
a61af66fc99e Initial load
duke
parents:
diff changeset
78 }
a61af66fc99e Initial load
duke
parents:
diff changeset
79
a61af66fc99e Initial load
duke
parents:
diff changeset
80
a61af66fc99e Initial load
duke
parents:
diff changeset
81 inline CodeBuffer* AbstractAssembler::code() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
82 return code_section()->outer();
a61af66fc99e Initial load
duke
parents:
diff changeset
83 }
a61af66fc99e Initial load
duke
parents:
diff changeset
84
a61af66fc99e Initial load
duke
parents:
diff changeset
85 inline int AbstractAssembler::sect() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
86 return code_section()->index();
a61af66fc99e Initial load
duke
parents:
diff changeset
87 }
a61af66fc99e Initial load
duke
parents:
diff changeset
88
a61af66fc99e Initial load
duke
parents:
diff changeset
89 inline int AbstractAssembler::locator() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
90 return CodeBuffer::locator(offset(), sect());
a61af66fc99e Initial load
duke
parents:
diff changeset
91 }
a61af66fc99e Initial load
duke
parents:
diff changeset
92
a61af66fc99e Initial load
duke
parents:
diff changeset
93 inline address AbstractAssembler::target(Label& L) {
a61af66fc99e Initial load
duke
parents:
diff changeset
94 return code_section()->target(L, pc());
a61af66fc99e Initial load
duke
parents:
diff changeset
95 }
a61af66fc99e Initial load
duke
parents:
diff changeset
96
a61af66fc99e Initial load
duke
parents:
diff changeset
97 inline int Label::loc_pos() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
98 return CodeBuffer::locator_pos(loc());
a61af66fc99e Initial load
duke
parents:
diff changeset
99 }
a61af66fc99e Initial load
duke
parents:
diff changeset
100
a61af66fc99e Initial load
duke
parents:
diff changeset
101 inline int Label::loc_sect() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
102 return CodeBuffer::locator_sect(loc());
a61af66fc99e Initial load
duke
parents:
diff changeset
103 }
a61af66fc99e Initial load
duke
parents:
diff changeset
104
a61af66fc99e Initial load
duke
parents:
diff changeset
105 inline void Label::bind_loc(int pos, int sect) {
a61af66fc99e Initial load
duke
parents:
diff changeset
106 bind_loc(CodeBuffer::locator(pos, sect));
a61af66fc99e Initial load
duke
parents:
diff changeset
107 }
a61af66fc99e Initial load
duke
parents:
diff changeset
108
a61af66fc99e Initial load
duke
parents:
diff changeset
109 address AbstractAssembler::address_constant(Label& L) {
a61af66fc99e Initial load
duke
parents:
diff changeset
110 address c = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
111 address ptr = start_a_const(sizeof(c), sizeof(c));
a61af66fc99e Initial load
duke
parents:
diff changeset
112 if (ptr != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
113 relocate(Relocation::spec_simple(relocInfo::internal_word_type));
a61af66fc99e Initial load
duke
parents:
diff changeset
114 *(address*)ptr = c = code_section()->target(L, ptr);
a61af66fc99e Initial load
duke
parents:
diff changeset
115 _code_pos = ptr + sizeof(c);
a61af66fc99e Initial load
duke
parents:
diff changeset
116 end_a_const();
a61af66fc99e Initial load
duke
parents:
diff changeset
117 }
a61af66fc99e Initial load
duke
parents:
diff changeset
118 return ptr;
a61af66fc99e Initial load
duke
parents:
diff changeset
119 }
a61af66fc99e Initial load
duke
parents:
diff changeset
120
a61af66fc99e Initial load
duke
parents:
diff changeset
121 address AbstractAssembler::address_table_constant(GrowableArray<Label*> labels) {
a61af66fc99e Initial load
duke
parents:
diff changeset
122 int addressSize = sizeof(address);
a61af66fc99e Initial load
duke
parents:
diff changeset
123 int sizeLabel = addressSize * labels.length();
a61af66fc99e Initial load
duke
parents:
diff changeset
124 address ptr = start_a_const(sizeLabel, addressSize);
a61af66fc99e Initial load
duke
parents:
diff changeset
125
a61af66fc99e Initial load
duke
parents:
diff changeset
126 if (ptr != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
127 address *labelLoc = (address*)ptr;
a61af66fc99e Initial load
duke
parents:
diff changeset
128 for (int i=0; i < labels.length(); i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
129 emit_address(code_section()->target(*labels.at(i), (address)&labelLoc[i]));
a61af66fc99e Initial load
duke
parents:
diff changeset
130 code_section()->relocate((address)&labelLoc[i], relocInfo::internal_word_type);
a61af66fc99e Initial load
duke
parents:
diff changeset
131 }
a61af66fc99e Initial load
duke
parents:
diff changeset
132 end_a_const();
a61af66fc99e Initial load
duke
parents:
diff changeset
133 }
a61af66fc99e Initial load
duke
parents:
diff changeset
134 return ptr;
a61af66fc99e Initial load
duke
parents:
diff changeset
135 }