Mercurial > hg > graal-jvmci-8
annotate src/share/vm/asm/assembler.cpp @ 7198:6ab62ad83507
8003195: AbstractAssembler should not store code pointers but use the CodeSection directly
Reviewed-by: twisti, kvn
Contributed-by: Bharadwaj Yadavalli <bharadwaj.yadavalli@oracle.com>
author | twisti |
---|---|
date | Fri, 30 Nov 2012 11:44:05 -0800 |
parents | 1acccb7c0b01 |
children | cd3d6a6b95d9 |
rev | line source |
---|---|
0 | 1 /* |
6842
b9a9ed0f8eeb
7197424: update copyright year to match last edit in jdk8 hotspot repository
mikael
parents:
6266
diff
changeset
|
2 * Copyright (c) 1997, 2012, 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:
1490
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1490
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:
1490
diff
changeset
|
21 * questions. |
0 | 22 * |
23 */ | |
24 | |
1972 | 25 #include "precompiled.hpp" |
26 #include "asm/assembler.hpp" | |
27 #include "asm/assembler.inline.hpp" | |
28 #include "asm/codeBuffer.hpp" | |
29 #include "runtime/icache.hpp" | |
30 #include "runtime/os.hpp" | |
31 #ifdef TARGET_ARCH_x86 | |
32 # include "assembler_x86.inline.hpp" | |
33 #endif | |
34 #ifdef TARGET_ARCH_sparc | |
35 # include "assembler_sparc.inline.hpp" | |
36 #endif | |
37 #ifdef TARGET_ARCH_zero | |
38 # include "assembler_zero.inline.hpp" | |
39 #endif | |
2192
b92c45f2bc75
7016023: Enable building ARM and PPC from src/closed repository
bobv
parents:
1972
diff
changeset
|
40 #ifdef TARGET_ARCH_arm |
b92c45f2bc75
7016023: Enable building ARM and PPC from src/closed repository
bobv
parents:
1972
diff
changeset
|
41 # include "assembler_arm.inline.hpp" |
b92c45f2bc75
7016023: Enable building ARM and PPC from src/closed repository
bobv
parents:
1972
diff
changeset
|
42 #endif |
b92c45f2bc75
7016023: Enable building ARM and PPC from src/closed repository
bobv
parents:
1972
diff
changeset
|
43 #ifdef TARGET_ARCH_ppc |
b92c45f2bc75
7016023: Enable building ARM and PPC from src/closed repository
bobv
parents:
1972
diff
changeset
|
44 # include "assembler_ppc.inline.hpp" |
b92c45f2bc75
7016023: Enable building ARM and PPC from src/closed repository
bobv
parents:
1972
diff
changeset
|
45 #endif |
0 | 46 |
47 | |
48 // Implementation of AbstractAssembler | |
49 // | |
50 // The AbstractAssembler is generating code into a CodeBuffer. To make code generation faster, | |
51 // the assembler keeps a copy of the code buffers boundaries & modifies them when | |
52 // emitting bytes rather than using the code buffers accessor functions all the time. | |
605 | 53 // The code buffer is updated via set_code_end(...) after emitting a whole instruction. |
0 | 54 |
55 AbstractAssembler::AbstractAssembler(CodeBuffer* code) { | |
56 if (code == NULL) return; | |
57 CodeSection* cs = code->insts(); | |
58 cs->clear_mark(); // new assembler kills old mark | |
7198
6ab62ad83507
8003195: AbstractAssembler should not store code pointers but use the CodeSection directly
twisti
parents:
7197
diff
changeset
|
59 if (cs->start() == NULL) { |
1490
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
844
diff
changeset
|
60 vm_exit_out_of_memory(0, err_msg("CodeCache: no room for %s", |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
844
diff
changeset
|
61 code->name())); |
0 | 62 } |
7198
6ab62ad83507
8003195: AbstractAssembler should not store code pointers but use the CodeSection directly
twisti
parents:
7197
diff
changeset
|
63 _code_section = cs; |
6ab62ad83507
8003195: AbstractAssembler should not store code pointers but use the CodeSection directly
twisti
parents:
7197
diff
changeset
|
64 _oop_recorder= code->oop_recorder(); |
6ab62ad83507
8003195: AbstractAssembler should not store code pointers but use the CodeSection directly
twisti
parents:
7197
diff
changeset
|
65 DEBUG_ONLY( _short_branch_delta = 0; ) |
0 | 66 } |
67 | |
68 void AbstractAssembler::set_code_section(CodeSection* cs) { | |
69 assert(cs->outer() == code_section()->outer(), "sanity"); | |
70 assert(cs->is_allocated(), "need to pre-allocate this section"); | |
71 cs->clear_mark(); // new assembly into this section kills old mark | |
72 _code_section = cs; | |
73 } | |
74 | |
75 // Inform CodeBuffer that incoming code and relocation will be for stubs | |
76 address AbstractAssembler::start_a_stub(int required_space) { | |
77 CodeBuffer* cb = code(); | |
78 CodeSection* cs = cb->stubs(); | |
79 assert(_code_section == cb->insts(), "not in insts?"); | |
80 if (cs->maybe_expand_to_ensure_remaining(required_space) | |
81 && cb->blob() == NULL) { | |
82 return NULL; | |
83 } | |
84 set_code_section(cs); | |
85 return pc(); | |
86 } | |
87 | |
88 // Inform CodeBuffer that incoming code and relocation will be code | |
89 // Should not be called if start_a_stub() returned NULL | |
90 void AbstractAssembler::end_a_stub() { | |
91 assert(_code_section == code()->stubs(), "not in stubs?"); | |
92 set_code_section(code()->insts()); | |
93 } | |
94 | |
95 // Inform CodeBuffer that incoming code and relocation will be for stubs | |
96 address AbstractAssembler::start_a_const(int required_space, int required_align) { | |
97 CodeBuffer* cb = code(); | |
98 CodeSection* cs = cb->consts(); | |
7197 | 99 assert(_code_section == cb->insts() || _code_section == cb->stubs(), "not in insts/stubs?"); |
0 | 100 address end = cs->end(); |
101 int pad = -(intptr_t)end & (required_align-1); | |
102 if (cs->maybe_expand_to_ensure_remaining(pad + required_space)) { | |
103 if (cb->blob() == NULL) return NULL; | |
104 end = cs->end(); // refresh pointer | |
105 } | |
106 if (pad > 0) { | |
107 while (--pad >= 0) { *end++ = 0; } | |
108 cs->set_end(end); | |
109 } | |
110 set_code_section(cs); | |
111 return end; | |
112 } | |
113 | |
114 // Inform CodeBuffer that incoming code and relocation will be code | |
7197 | 115 // in section cs (insts or stubs). |
116 void AbstractAssembler::end_a_const(CodeSection* cs) { | |
0 | 117 assert(_code_section == code()->consts(), "not in consts?"); |
7197 | 118 set_code_section(cs); |
0 | 119 } |
120 | |
121 void AbstractAssembler::flush() { | |
122 ICache::invalidate_range(addr_at(0), offset()); | |
123 } | |
124 | |
125 | |
126 void AbstractAssembler::a_byte(int x) { | |
127 emit_byte(x); | |
128 } | |
129 | |
130 | |
131 void AbstractAssembler::a_long(jint x) { | |
132 emit_long(x); | |
133 } | |
134 | |
135 // Labels refer to positions in the (to be) generated code. There are bound | |
136 // and unbound | |
137 // | |
138 // Bound labels refer to known positions in the already generated code. | |
139 // offset() is the position the label refers to. | |
140 // | |
141 // Unbound labels refer to unknown positions in the code to be generated; it | |
142 // may contain a list of unresolved displacements that refer to it | |
143 #ifndef PRODUCT | |
144 void AbstractAssembler::print(Label& L) { | |
145 if (L.is_bound()) { | |
146 tty->print_cr("bound label to %d|%d", L.loc_pos(), L.loc_sect()); | |
147 } else if (L.is_unbound()) { | |
148 L.print_instructions((MacroAssembler*)this); | |
149 } else { | |
150 tty->print_cr("label in inconsistent state (loc = %d)", L.loc()); | |
151 } | |
152 } | |
153 #endif // PRODUCT | |
154 | |
155 | |
156 void AbstractAssembler::bind(Label& L) { | |
157 if (L.is_bound()) { | |
158 // Assembler can bind a label more than once to the same place. | |
159 guarantee(L.loc() == locator(), "attempt to redefine label"); | |
160 return; | |
161 } | |
162 L.bind_loc(locator()); | |
163 L.patch_instructions((MacroAssembler*)this); | |
164 } | |
165 | |
166 void AbstractAssembler::generate_stack_overflow_check( int frame_size_in_bytes) { | |
167 if (UseStackBanging) { | |
168 // Each code entry causes one stack bang n pages down the stack where n | |
169 // is configurable by StackBangPages. The setting depends on the maximum | |
170 // depth of VM call stack or native before going back into java code, | |
171 // since only java code can raise a stack overflow exception using the | |
172 // stack banging mechanism. The VM and native code does not detect stack | |
173 // overflow. | |
174 // The code in JavaCalls::call() checks that there is at least n pages | |
175 // available, so all entry code needs to do is bang once for the end of | |
176 // this shadow zone. | |
177 // The entry code may need to bang additional pages if the framesize | |
178 // is greater than a page. | |
179 | |
180 const int page_size = os::vm_page_size(); | |
181 int bang_end = StackShadowPages*page_size; | |
182 | |
183 // This is how far the previous frame's stack banging extended. | |
184 const int bang_end_safe = bang_end; | |
185 | |
186 if (frame_size_in_bytes > page_size) { | |
187 bang_end += frame_size_in_bytes; | |
188 } | |
189 | |
190 int bang_offset = bang_end_safe; | |
191 while (bang_offset <= bang_end) { | |
192 // Need at least one stack bang at end of shadow zone. | |
193 bang_stack_with_offset(bang_offset); | |
194 bang_offset += page_size; | |
195 } | |
196 } // end (UseStackBanging) | |
197 } | |
198 | |
199 void Label::add_patch_at(CodeBuffer* cb, int branch_loc) { | |
200 assert(_loc == -1, "Label is unbound"); | |
201 if (_patch_index < PatchCacheSize) { | |
202 _patches[_patch_index] = branch_loc; | |
203 } else { | |
204 if (_patch_overflow == NULL) { | |
205 _patch_overflow = cb->create_patch_overflow(); | |
206 } | |
207 _patch_overflow->push(branch_loc); | |
208 } | |
209 ++_patch_index; | |
210 } | |
211 | |
212 void Label::patch_instructions(MacroAssembler* masm) { | |
213 assert(is_bound(), "Label is bound"); | |
214 CodeBuffer* cb = masm->code(); | |
215 int target_sect = CodeBuffer::locator_sect(loc()); | |
216 address target = cb->locator_address(loc()); | |
217 while (_patch_index > 0) { | |
218 --_patch_index; | |
219 int branch_loc; | |
220 if (_patch_index >= PatchCacheSize) { | |
221 branch_loc = _patch_overflow->pop(); | |
222 } else { | |
223 branch_loc = _patches[_patch_index]; | |
224 } | |
225 int branch_sect = CodeBuffer::locator_sect(branch_loc); | |
226 address branch = cb->locator_address(branch_loc); | |
227 if (branch_sect == CodeBuffer::SECT_CONSTS) { | |
228 // The thing to patch is a constant word. | |
229 *(address*)branch = target; | |
230 continue; | |
231 } | |
232 | |
233 #ifdef ASSERT | |
234 // Cross-section branches only work if the | |
235 // intermediate section boundaries are frozen. | |
236 if (target_sect != branch_sect) { | |
237 for (int n = MIN2(target_sect, branch_sect), | |
238 nlimit = (target_sect + branch_sect) - n; | |
239 n < nlimit; n++) { | |
240 CodeSection* cs = cb->code_section(n); | |
241 assert(cs->is_frozen(), "cross-section branch needs stable offsets"); | |
242 } | |
243 } | |
244 #endif //ASSERT | |
245 | |
246 // Push the target offset into the branch instruction. | |
247 masm->pd_patch_instruction(branch, target); | |
248 } | |
249 } | |
250 | |
622
56aae7be60d4
6812678: macro assembler needs delayed binding of a few constants (for 6655638)
jrose
parents:
605
diff
changeset
|
251 struct DelayedConstant { |
56aae7be60d4
6812678: macro assembler needs delayed binding of a few constants (for 6655638)
jrose
parents:
605
diff
changeset
|
252 typedef void (*value_fn_t)(); |
56aae7be60d4
6812678: macro assembler needs delayed binding of a few constants (for 6655638)
jrose
parents:
605
diff
changeset
|
253 BasicType type; |
56aae7be60d4
6812678: macro assembler needs delayed binding of a few constants (for 6655638)
jrose
parents:
605
diff
changeset
|
254 intptr_t value; |
56aae7be60d4
6812678: macro assembler needs delayed binding of a few constants (for 6655638)
jrose
parents:
605
diff
changeset
|
255 value_fn_t value_fn; |
56aae7be60d4
6812678: macro assembler needs delayed binding of a few constants (for 6655638)
jrose
parents:
605
diff
changeset
|
256 // This limit of 20 is generous for initial uses. |
56aae7be60d4
6812678: macro assembler needs delayed binding of a few constants (for 6655638)
jrose
parents:
605
diff
changeset
|
257 // The limit needs to be large enough to store the field offsets |
56aae7be60d4
6812678: macro assembler needs delayed binding of a few constants (for 6655638)
jrose
parents:
605
diff
changeset
|
258 // into classes which do not have statically fixed layouts. |
56aae7be60d4
6812678: macro assembler needs delayed binding of a few constants (for 6655638)
jrose
parents:
605
diff
changeset
|
259 // (Initial use is for method handle object offsets.) |
56aae7be60d4
6812678: macro assembler needs delayed binding of a few constants (for 6655638)
jrose
parents:
605
diff
changeset
|
260 // Look for uses of "delayed_value" in the source code |
56aae7be60d4
6812678: macro assembler needs delayed binding of a few constants (for 6655638)
jrose
parents:
605
diff
changeset
|
261 // and make sure this number is generous enough to handle all of them. |
56aae7be60d4
6812678: macro assembler needs delayed binding of a few constants (for 6655638)
jrose
parents:
605
diff
changeset
|
262 enum { DC_LIMIT = 20 }; |
56aae7be60d4
6812678: macro assembler needs delayed binding of a few constants (for 6655638)
jrose
parents:
605
diff
changeset
|
263 static DelayedConstant delayed_constants[DC_LIMIT]; |
56aae7be60d4
6812678: macro assembler needs delayed binding of a few constants (for 6655638)
jrose
parents:
605
diff
changeset
|
264 static DelayedConstant* add(BasicType type, value_fn_t value_fn); |
56aae7be60d4
6812678: macro assembler needs delayed binding of a few constants (for 6655638)
jrose
parents:
605
diff
changeset
|
265 bool match(BasicType t, value_fn_t cfn) { |
56aae7be60d4
6812678: macro assembler needs delayed binding of a few constants (for 6655638)
jrose
parents:
605
diff
changeset
|
266 return type == t && value_fn == cfn; |
56aae7be60d4
6812678: macro assembler needs delayed binding of a few constants (for 6655638)
jrose
parents:
605
diff
changeset
|
267 } |
56aae7be60d4
6812678: macro assembler needs delayed binding of a few constants (for 6655638)
jrose
parents:
605
diff
changeset
|
268 static void update_all(); |
56aae7be60d4
6812678: macro assembler needs delayed binding of a few constants (for 6655638)
jrose
parents:
605
diff
changeset
|
269 }; |
56aae7be60d4
6812678: macro assembler needs delayed binding of a few constants (for 6655638)
jrose
parents:
605
diff
changeset
|
270 |
56aae7be60d4
6812678: macro assembler needs delayed binding of a few constants (for 6655638)
jrose
parents:
605
diff
changeset
|
271 DelayedConstant DelayedConstant::delayed_constants[DC_LIMIT]; |
56aae7be60d4
6812678: macro assembler needs delayed binding of a few constants (for 6655638)
jrose
parents:
605
diff
changeset
|
272 // Default C structure initialization rules have the following effect here: |
56aae7be60d4
6812678: macro assembler needs delayed binding of a few constants (for 6655638)
jrose
parents:
605
diff
changeset
|
273 // = { { (BasicType)0, (intptr_t)NULL }, ... }; |
56aae7be60d4
6812678: macro assembler needs delayed binding of a few constants (for 6655638)
jrose
parents:
605
diff
changeset
|
274 |
56aae7be60d4
6812678: macro assembler needs delayed binding of a few constants (for 6655638)
jrose
parents:
605
diff
changeset
|
275 DelayedConstant* DelayedConstant::add(BasicType type, |
56aae7be60d4
6812678: macro assembler needs delayed binding of a few constants (for 6655638)
jrose
parents:
605
diff
changeset
|
276 DelayedConstant::value_fn_t cfn) { |
56aae7be60d4
6812678: macro assembler needs delayed binding of a few constants (for 6655638)
jrose
parents:
605
diff
changeset
|
277 for (int i = 0; i < DC_LIMIT; i++) { |
56aae7be60d4
6812678: macro assembler needs delayed binding of a few constants (for 6655638)
jrose
parents:
605
diff
changeset
|
278 DelayedConstant* dcon = &delayed_constants[i]; |
56aae7be60d4
6812678: macro assembler needs delayed binding of a few constants (for 6655638)
jrose
parents:
605
diff
changeset
|
279 if (dcon->match(type, cfn)) |
56aae7be60d4
6812678: macro assembler needs delayed binding of a few constants (for 6655638)
jrose
parents:
605
diff
changeset
|
280 return dcon; |
56aae7be60d4
6812678: macro assembler needs delayed binding of a few constants (for 6655638)
jrose
parents:
605
diff
changeset
|
281 if (dcon->value_fn == NULL) { |
56aae7be60d4
6812678: macro assembler needs delayed binding of a few constants (for 6655638)
jrose
parents:
605
diff
changeset
|
282 // (cmpxchg not because this is multi-threaded but because I'm paranoid) |
56aae7be60d4
6812678: macro assembler needs delayed binding of a few constants (for 6655638)
jrose
parents:
605
diff
changeset
|
283 if (Atomic::cmpxchg_ptr(CAST_FROM_FN_PTR(void*, cfn), &dcon->value_fn, NULL) == NULL) { |
56aae7be60d4
6812678: macro assembler needs delayed binding of a few constants (for 6655638)
jrose
parents:
605
diff
changeset
|
284 dcon->type = type; |
56aae7be60d4
6812678: macro assembler needs delayed binding of a few constants (for 6655638)
jrose
parents:
605
diff
changeset
|
285 return dcon; |
56aae7be60d4
6812678: macro assembler needs delayed binding of a few constants (for 6655638)
jrose
parents:
605
diff
changeset
|
286 } |
56aae7be60d4
6812678: macro assembler needs delayed binding of a few constants (for 6655638)
jrose
parents:
605
diff
changeset
|
287 } |
56aae7be60d4
6812678: macro assembler needs delayed binding of a few constants (for 6655638)
jrose
parents:
605
diff
changeset
|
288 } |
56aae7be60d4
6812678: macro assembler needs delayed binding of a few constants (for 6655638)
jrose
parents:
605
diff
changeset
|
289 // If this assert is hit (in pre-integration testing!) then re-evaluate |
56aae7be60d4
6812678: macro assembler needs delayed binding of a few constants (for 6655638)
jrose
parents:
605
diff
changeset
|
290 // the comment on the definition of DC_LIMIT. |
56aae7be60d4
6812678: macro assembler needs delayed binding of a few constants (for 6655638)
jrose
parents:
605
diff
changeset
|
291 guarantee(false, "too many delayed constants"); |
56aae7be60d4
6812678: macro assembler needs delayed binding of a few constants (for 6655638)
jrose
parents:
605
diff
changeset
|
292 return NULL; |
56aae7be60d4
6812678: macro assembler needs delayed binding of a few constants (for 6655638)
jrose
parents:
605
diff
changeset
|
293 } |
56aae7be60d4
6812678: macro assembler needs delayed binding of a few constants (for 6655638)
jrose
parents:
605
diff
changeset
|
294 |
56aae7be60d4
6812678: macro assembler needs delayed binding of a few constants (for 6655638)
jrose
parents:
605
diff
changeset
|
295 void DelayedConstant::update_all() { |
56aae7be60d4
6812678: macro assembler needs delayed binding of a few constants (for 6655638)
jrose
parents:
605
diff
changeset
|
296 for (int i = 0; i < DC_LIMIT; i++) { |
56aae7be60d4
6812678: macro assembler needs delayed binding of a few constants (for 6655638)
jrose
parents:
605
diff
changeset
|
297 DelayedConstant* dcon = &delayed_constants[i]; |
56aae7be60d4
6812678: macro assembler needs delayed binding of a few constants (for 6655638)
jrose
parents:
605
diff
changeset
|
298 if (dcon->value_fn != NULL && dcon->value == 0) { |
56aae7be60d4
6812678: macro assembler needs delayed binding of a few constants (for 6655638)
jrose
parents:
605
diff
changeset
|
299 typedef int (*int_fn_t)(); |
56aae7be60d4
6812678: macro assembler needs delayed binding of a few constants (for 6655638)
jrose
parents:
605
diff
changeset
|
300 typedef address (*address_fn_t)(); |
56aae7be60d4
6812678: macro assembler needs delayed binding of a few constants (for 6655638)
jrose
parents:
605
diff
changeset
|
301 switch (dcon->type) { |
56aae7be60d4
6812678: macro assembler needs delayed binding of a few constants (for 6655638)
jrose
parents:
605
diff
changeset
|
302 case T_INT: dcon->value = (intptr_t) ((int_fn_t) dcon->value_fn)(); break; |
56aae7be60d4
6812678: macro assembler needs delayed binding of a few constants (for 6655638)
jrose
parents:
605
diff
changeset
|
303 case T_ADDRESS: dcon->value = (intptr_t) ((address_fn_t)dcon->value_fn)(); break; |
56aae7be60d4
6812678: macro assembler needs delayed binding of a few constants (for 6655638)
jrose
parents:
605
diff
changeset
|
304 } |
56aae7be60d4
6812678: macro assembler needs delayed binding of a few constants (for 6655638)
jrose
parents:
605
diff
changeset
|
305 } |
56aae7be60d4
6812678: macro assembler needs delayed binding of a few constants (for 6655638)
jrose
parents:
605
diff
changeset
|
306 } |
56aae7be60d4
6812678: macro assembler needs delayed binding of a few constants (for 6655638)
jrose
parents:
605
diff
changeset
|
307 } |
56aae7be60d4
6812678: macro assembler needs delayed binding of a few constants (for 6655638)
jrose
parents:
605
diff
changeset
|
308 |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
4766
diff
changeset
|
309 RegisterOrConstant AbstractAssembler::delayed_value(int(*value_fn)(), Register tmp, int offset) { |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
4766
diff
changeset
|
310 intptr_t val = (intptr_t) (*value_fn)(); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
4766
diff
changeset
|
311 if (val != 0) return val + offset; |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
4766
diff
changeset
|
312 return delayed_value_impl(delayed_value_addr(value_fn), tmp, offset); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
4766
diff
changeset
|
313 } |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
4766
diff
changeset
|
314 RegisterOrConstant AbstractAssembler::delayed_value(address(*value_fn)(), Register tmp, int offset) { |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
4766
diff
changeset
|
315 intptr_t val = (intptr_t) (*value_fn)(); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
4766
diff
changeset
|
316 if (val != 0) return val + offset; |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
4766
diff
changeset
|
317 return delayed_value_impl(delayed_value_addr(value_fn), tmp, offset); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
4766
diff
changeset
|
318 } |
622
56aae7be60d4
6812678: macro assembler needs delayed binding of a few constants (for 6655638)
jrose
parents:
605
diff
changeset
|
319 intptr_t* AbstractAssembler::delayed_value_addr(int(*value_fn)()) { |
56aae7be60d4
6812678: macro assembler needs delayed binding of a few constants (for 6655638)
jrose
parents:
605
diff
changeset
|
320 DelayedConstant* dcon = DelayedConstant::add(T_INT, (DelayedConstant::value_fn_t) value_fn); |
56aae7be60d4
6812678: macro assembler needs delayed binding of a few constants (for 6655638)
jrose
parents:
605
diff
changeset
|
321 return &dcon->value; |
56aae7be60d4
6812678: macro assembler needs delayed binding of a few constants (for 6655638)
jrose
parents:
605
diff
changeset
|
322 } |
56aae7be60d4
6812678: macro assembler needs delayed binding of a few constants (for 6655638)
jrose
parents:
605
diff
changeset
|
323 intptr_t* AbstractAssembler::delayed_value_addr(address(*value_fn)()) { |
56aae7be60d4
6812678: macro assembler needs delayed binding of a few constants (for 6655638)
jrose
parents:
605
diff
changeset
|
324 DelayedConstant* dcon = DelayedConstant::add(T_ADDRESS, (DelayedConstant::value_fn_t) value_fn); |
56aae7be60d4
6812678: macro assembler needs delayed binding of a few constants (for 6655638)
jrose
parents:
605
diff
changeset
|
325 return &dcon->value; |
56aae7be60d4
6812678: macro assembler needs delayed binding of a few constants (for 6655638)
jrose
parents:
605
diff
changeset
|
326 } |
56aae7be60d4
6812678: macro assembler needs delayed binding of a few constants (for 6655638)
jrose
parents:
605
diff
changeset
|
327 void AbstractAssembler::update_delayed_values() { |
56aae7be60d4
6812678: macro assembler needs delayed binding of a few constants (for 6655638)
jrose
parents:
605
diff
changeset
|
328 DelayedConstant::update_all(); |
56aae7be60d4
6812678: macro assembler needs delayed binding of a few constants (for 6655638)
jrose
parents:
605
diff
changeset
|
329 } |
56aae7be60d4
6812678: macro assembler needs delayed binding of a few constants (for 6655638)
jrose
parents:
605
diff
changeset
|
330 |
56aae7be60d4
6812678: macro assembler needs delayed binding of a few constants (for 6655638)
jrose
parents:
605
diff
changeset
|
331 |
56aae7be60d4
6812678: macro assembler needs delayed binding of a few constants (for 6655638)
jrose
parents:
605
diff
changeset
|
332 |
0 | 333 |
334 void AbstractAssembler::block_comment(const char* comment) { | |
335 if (sect() == CodeBuffer::SECT_INSTS) { | |
336 code_section()->outer()->block_comment(offset(), comment); | |
337 } | |
338 } | |
339 | |
237
1fdb98a17101
6716785: implicit null checks not triggering with CompressedOops
coleenp
parents:
0
diff
changeset
|
340 bool MacroAssembler::needs_explicit_null_check(intptr_t offset) { |
1fdb98a17101
6716785: implicit null checks not triggering with CompressedOops
coleenp
parents:
0
diff
changeset
|
341 // Exception handler checks the nmethod's implicit null checks table |
1fdb98a17101
6716785: implicit null checks not triggering with CompressedOops
coleenp
parents:
0
diff
changeset
|
342 // only when this method returns false. |
642
660978a2a31a
6791178: Specialize for zero as the compressed oop vm heap base
kvn
parents:
622
diff
changeset
|
343 #ifdef _LP64 |
660978a2a31a
6791178: Specialize for zero as the compressed oop vm heap base
kvn
parents:
622
diff
changeset
|
344 if (UseCompressedOops && Universe::narrow_oop_base() != NULL) { |
660978a2a31a
6791178: Specialize for zero as the compressed oop vm heap base
kvn
parents:
622
diff
changeset
|
345 assert (Universe::heap() != NULL, "java heap should be initialized"); |
237
1fdb98a17101
6716785: implicit null checks not triggering with CompressedOops
coleenp
parents:
0
diff
changeset
|
346 // The first page after heap_base is unmapped and |
1fdb98a17101
6716785: implicit null checks not triggering with CompressedOops
coleenp
parents:
0
diff
changeset
|
347 // the 'offset' is equal to [heap_base + offset] for |
1fdb98a17101
6716785: implicit null checks not triggering with CompressedOops
coleenp
parents:
0
diff
changeset
|
348 // narrow oop implicit null checks. |
642
660978a2a31a
6791178: Specialize for zero as the compressed oop vm heap base
kvn
parents:
622
diff
changeset
|
349 uintptr_t base = (uintptr_t)Universe::narrow_oop_base(); |
660978a2a31a
6791178: Specialize for zero as the compressed oop vm heap base
kvn
parents:
622
diff
changeset
|
350 if ((uintptr_t)offset >= base) { |
237
1fdb98a17101
6716785: implicit null checks not triggering with CompressedOops
coleenp
parents:
0
diff
changeset
|
351 // Normalize offset for the next check. |
642
660978a2a31a
6791178: Specialize for zero as the compressed oop vm heap base
kvn
parents:
622
diff
changeset
|
352 offset = (intptr_t)(pointer_delta((void*)offset, (void*)base, 1)); |
237
1fdb98a17101
6716785: implicit null checks not triggering with CompressedOops
coleenp
parents:
0
diff
changeset
|
353 } |
1fdb98a17101
6716785: implicit null checks not triggering with CompressedOops
coleenp
parents:
0
diff
changeset
|
354 } |
642
660978a2a31a
6791178: Specialize for zero as the compressed oop vm heap base
kvn
parents:
622
diff
changeset
|
355 #endif |
237
1fdb98a17101
6716785: implicit null checks not triggering with CompressedOops
coleenp
parents:
0
diff
changeset
|
356 return offset < 0 || os::vm_page_size() <= offset; |
1fdb98a17101
6716785: implicit null checks not triggering with CompressedOops
coleenp
parents:
0
diff
changeset
|
357 } |
0 | 358 |
359 #ifndef PRODUCT | |
360 void Label::print_instructions(MacroAssembler* masm) const { | |
361 CodeBuffer* cb = masm->code(); | |
362 for (int i = 0; i < _patch_index; ++i) { | |
363 int branch_loc; | |
364 if (i >= PatchCacheSize) { | |
365 branch_loc = _patch_overflow->at(i - PatchCacheSize); | |
366 } else { | |
367 branch_loc = _patches[i]; | |
368 } | |
369 int branch_pos = CodeBuffer::locator_pos(branch_loc); | |
370 int branch_sect = CodeBuffer::locator_sect(branch_loc); | |
371 address branch = cb->locator_address(branch_loc); | |
372 tty->print_cr("unbound label"); | |
373 tty->print("@ %d|%d ", branch_pos, branch_sect); | |
374 if (branch_sect == CodeBuffer::SECT_CONSTS) { | |
375 tty->print_cr(PTR_FORMAT, *(address*)branch); | |
376 continue; | |
377 } | |
378 masm->pd_print_patched_instruction(branch); | |
379 tty->cr(); | |
380 } | |
381 } | |
382 #endif // ndef PRODUCT |