Mercurial > hg > truffle
annotate src/share/vm/c1/c1_LIRAssembler.cpp @ 11722:ff05c78a7f64
use time passed to decide what methods to compile or inline
author | Christian Wirth <christian.wirth@oracle.com> |
---|---|
date | Thu, 19 Sep 2013 10:36:56 +0200 |
parents | e522a00b91aa |
children | cefad50507d8 |
rev | line source |
---|---|
0 | 1 /* |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6616
diff
changeset
|
2 * Copyright (c) 2000, 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:
1378
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1378
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:
1378
diff
changeset
|
21 * questions. |
0 | 22 * |
23 */ | |
24 | |
1972 | 25 #include "precompiled.hpp" |
26 #include "c1/c1_Compilation.hpp" | |
27 #include "c1/c1_Instruction.hpp" | |
28 #include "c1/c1_InstructionPrinter.hpp" | |
29 #include "c1/c1_LIRAssembler.hpp" | |
30 #include "c1/c1_MacroAssembler.hpp" | |
31 #include "c1/c1_ValueStack.hpp" | |
32 #include "ci/ciInstance.hpp" | |
33 #ifdef TARGET_ARCH_x86 | |
34 # include "nativeInst_x86.hpp" | |
35 # include "vmreg_x86.inline.hpp" | |
36 #endif | |
37 #ifdef TARGET_ARCH_sparc | |
38 # include "nativeInst_sparc.hpp" | |
39 # include "vmreg_sparc.inline.hpp" | |
40 #endif | |
41 #ifdef TARGET_ARCH_zero | |
42 # include "nativeInst_zero.hpp" | |
43 # include "vmreg_zero.inline.hpp" | |
44 #endif | |
2192
b92c45f2bc75
7016023: Enable building ARM and PPC from src/closed repository
bobv
parents:
2089
diff
changeset
|
45 #ifdef TARGET_ARCH_arm |
b92c45f2bc75
7016023: Enable building ARM and PPC from src/closed repository
bobv
parents:
2089
diff
changeset
|
46 # include "nativeInst_arm.hpp" |
b92c45f2bc75
7016023: Enable building ARM and PPC from src/closed repository
bobv
parents:
2089
diff
changeset
|
47 # include "vmreg_arm.inline.hpp" |
b92c45f2bc75
7016023: Enable building ARM and PPC from src/closed repository
bobv
parents:
2089
diff
changeset
|
48 #endif |
b92c45f2bc75
7016023: Enable building ARM and PPC from src/closed repository
bobv
parents:
2089
diff
changeset
|
49 #ifdef TARGET_ARCH_ppc |
b92c45f2bc75
7016023: Enable building ARM and PPC from src/closed repository
bobv
parents:
2089
diff
changeset
|
50 # include "nativeInst_ppc.hpp" |
b92c45f2bc75
7016023: Enable building ARM and PPC from src/closed repository
bobv
parents:
2089
diff
changeset
|
51 # include "vmreg_ppc.inline.hpp" |
b92c45f2bc75
7016023: Enable building ARM and PPC from src/closed repository
bobv
parents:
2089
diff
changeset
|
52 #endif |
0 | 53 |
54 | |
55 void LIR_Assembler::patching_epilog(PatchingStub* patch, LIR_PatchCode patch_code, Register obj, CodeEmitInfo* info) { | |
56 // we must have enough patching space so that call can be inserted | |
57 while ((intx) _masm->pc() - (intx) patch->pc_start() < NativeCall::instruction_size) { | |
58 _masm->nop(); | |
59 } | |
60 patch->install(_masm, patch_code, obj, info); | |
61 append_patching_stub(patch); | |
62 | |
63 #ifdef ASSERT | |
1819 | 64 Bytecodes::Code code = info->scope()->method()->java_code_at_bci(info->stack()->bci()); |
0 | 65 if (patch->id() == PatchingStub::access_field_id) { |
66 switch (code) { | |
67 case Bytecodes::_putstatic: | |
68 case Bytecodes::_getstatic: | |
69 case Bytecodes::_putfield: | |
70 case Bytecodes::_getfield: | |
71 break; | |
72 default: | |
73 ShouldNotReachHere(); | |
74 } | |
75 } else if (patch->id() == PatchingStub::load_klass_id) { | |
76 switch (code) { | |
77 case Bytecodes::_new: | |
78 case Bytecodes::_anewarray: | |
79 case Bytecodes::_multianewarray: | |
80 case Bytecodes::_instanceof: | |
81 case Bytecodes::_checkcast: | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6616
diff
changeset
|
82 break; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6616
diff
changeset
|
83 default: |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6616
diff
changeset
|
84 ShouldNotReachHere(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6616
diff
changeset
|
85 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6616
diff
changeset
|
86 } else if (patch->id() == PatchingStub::load_mirror_id) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6616
diff
changeset
|
87 switch (code) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6616
diff
changeset
|
88 case Bytecodes::_putstatic: |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6616
diff
changeset
|
89 case Bytecodes::_getstatic: |
0 | 90 case Bytecodes::_ldc: |
91 case Bytecodes::_ldc_w: | |
92 break; | |
93 default: | |
94 ShouldNotReachHere(); | |
95 } | |
96 } else { | |
97 ShouldNotReachHere(); | |
98 } | |
99 #endif | |
100 } | |
101 | |
102 | |
103 //--------------------------------------------------------------- | |
104 | |
105 | |
106 LIR_Assembler::LIR_Assembler(Compilation* c): | |
107 _compilation(c) | |
108 , _masm(c->masm()) | |
342 | 109 , _bs(Universe::heap()->barrier_set()) |
0 | 110 , _frame_map(c->frame_map()) |
111 , _current_block(NULL) | |
112 , _pending_non_safepoint(NULL) | |
113 , _pending_non_safepoint_offset(0) | |
114 { | |
115 _slow_case_stubs = new CodeStubList(); | |
116 } | |
117 | |
118 | |
119 LIR_Assembler::~LIR_Assembler() { | |
120 } | |
121 | |
122 | |
123 void LIR_Assembler::append_patching_stub(PatchingStub* stub) { | |
124 _slow_case_stubs->append(stub); | |
125 } | |
126 | |
127 | |
128 void LIR_Assembler::check_codespace() { | |
129 CodeSection* cs = _masm->code_section(); | |
3896
b346f13112d8
7085279: C1 overflows code buffer with VerifyOops and CompressedOops
iveresov
parents:
2468
diff
changeset
|
130 if (cs->remaining() < (int)(NOT_LP64(1*K)LP64_ONLY(2*K))) { |
0 | 131 BAILOUT("CodeBuffer overflow"); |
132 } | |
133 } | |
134 | |
135 | |
136 void LIR_Assembler::emit_code_stub(CodeStub* stub) { | |
137 _slow_case_stubs->append(stub); | |
138 } | |
139 | |
140 void LIR_Assembler::emit_stubs(CodeStubList* stub_list) { | |
141 for (int m = 0; m < stub_list->length(); m++) { | |
142 CodeStub* s = (*stub_list)[m]; | |
143 | |
144 check_codespace(); | |
145 CHECK_BAILOUT(); | |
146 | |
147 #ifndef PRODUCT | |
148 if (CommentedAssembly) { | |
149 stringStream st; | |
150 s->print_name(&st); | |
151 st.print(" slow case"); | |
152 _masm->block_comment(st.as_string()); | |
153 } | |
154 #endif | |
155 s->emit_code(this); | |
156 #ifdef ASSERT | |
157 s->assert_no_unbound_labels(); | |
158 #endif | |
159 } | |
160 } | |
161 | |
162 | |
163 void LIR_Assembler::emit_slow_case_stubs() { | |
164 emit_stubs(_slow_case_stubs); | |
165 } | |
166 | |
167 | |
168 bool LIR_Assembler::needs_icache(ciMethod* method) const { | |
169 return !method->is_static(); | |
170 } | |
171 | |
172 | |
173 int LIR_Assembler::code_offset() const { | |
174 return _masm->offset(); | |
175 } | |
176 | |
177 | |
178 address LIR_Assembler::pc() const { | |
179 return _masm->pc(); | |
180 } | |
181 | |
182 | |
183 void LIR_Assembler::emit_exception_entries(ExceptionInfoList* info_list) { | |
184 for (int i = 0; i < info_list->length(); i++) { | |
185 XHandlers* handlers = info_list->at(i)->exception_handlers(); | |
186 | |
187 for (int j = 0; j < handlers->length(); j++) { | |
188 XHandler* handler = handlers->handler_at(j); | |
189 assert(handler->lir_op_id() != -1, "handler not processed by LinearScan"); | |
190 assert(handler->entry_code() == NULL || | |
191 handler->entry_code()->instructions_list()->last()->code() == lir_branch || | |
192 handler->entry_code()->instructions_list()->last()->code() == lir_delay_slot, "last operation must be branch"); | |
193 | |
194 if (handler->entry_pco() == -1) { | |
195 // entry code not emitted yet | |
196 if (handler->entry_code() != NULL && handler->entry_code()->instructions_list()->length() > 1) { | |
197 handler->set_entry_pco(code_offset()); | |
198 if (CommentedAssembly) { | |
199 _masm->block_comment("Exception adapter block"); | |
200 } | |
201 emit_lir_list(handler->entry_code()); | |
202 } else { | |
203 handler->set_entry_pco(handler->entry_block()->exception_handler_pco()); | |
204 } | |
205 | |
206 assert(handler->entry_pco() != -1, "must be set now"); | |
207 } | |
208 } | |
209 } | |
210 } | |
211 | |
212 | |
213 void LIR_Assembler::emit_code(BlockList* hir) { | |
214 if (PrintLIR) { | |
215 print_LIR(hir); | |
216 } | |
217 | |
218 int n = hir->length(); | |
219 for (int i = 0; i < n; i++) { | |
220 emit_block(hir->at(i)); | |
221 CHECK_BAILOUT(); | |
222 } | |
223 | |
224 flush_debug_info(code_offset()); | |
225 | |
226 DEBUG_ONLY(check_no_unbound_labels()); | |
227 } | |
228 | |
229 | |
230 void LIR_Assembler::emit_block(BlockBegin* block) { | |
231 if (block->is_set(BlockBegin::backward_branch_target_flag)) { | |
232 align_backward_branch_target(); | |
233 } | |
234 | |
235 // if this block is the start of an exception handler, record the | |
236 // PC offset of the first instruction for later construction of | |
237 // the ExceptionHandlerTable | |
238 if (block->is_set(BlockBegin::exception_entry_flag)) { | |
239 block->set_exception_handler_pco(code_offset()); | |
240 } | |
241 | |
242 #ifndef PRODUCT | |
243 if (PrintLIRWithAssembly) { | |
244 // don't print Phi's | |
245 InstructionPrinter ip(false); | |
246 block->print(ip); | |
247 } | |
248 #endif /* PRODUCT */ | |
249 | |
250 assert(block->lir() != NULL, "must have LIR"); | |
304 | 251 X86_ONLY(assert(_masm->rsp_offset() == 0, "frame size should be fixed")); |
0 | 252 |
253 #ifndef PRODUCT | |
254 if (CommentedAssembly) { | |
255 stringStream st; | |
1819 | 256 st.print_cr(" block B%d [%d, %d]", block->block_id(), block->bci(), block->end()->printable_bci()); |
0 | 257 _masm->block_comment(st.as_string()); |
258 } | |
259 #endif | |
260 | |
261 emit_lir_list(block->lir()); | |
262 | |
304 | 263 X86_ONLY(assert(_masm->rsp_offset() == 0, "frame size should be fixed")); |
0 | 264 } |
265 | |
266 | |
267 void LIR_Assembler::emit_lir_list(LIR_List* list) { | |
268 peephole(list); | |
269 | |
270 int n = list->length(); | |
271 for (int i = 0; i < n; i++) { | |
272 LIR_Op* op = list->at(i); | |
273 | |
274 check_codespace(); | |
275 CHECK_BAILOUT(); | |
276 | |
277 #ifndef PRODUCT | |
278 if (CommentedAssembly) { | |
279 // Don't record out every op since that's too verbose. Print | |
280 // branches since they include block and stub names. Also print | |
281 // patching moves since they generate funny looking code. | |
282 if (op->code() == lir_branch || | |
283 (op->code() == lir_move && op->as_Op1()->patch_code() != lir_patch_none)) { | |
284 stringStream st; | |
285 op->print_on(&st); | |
286 _masm->block_comment(st.as_string()); | |
287 } | |
288 } | |
289 if (PrintLIRWithAssembly) { | |
290 // print out the LIR operation followed by the resulting assembly | |
291 list->at(i)->print(); tty->cr(); | |
292 } | |
293 #endif /* PRODUCT */ | |
294 | |
295 op->emit_code(this); | |
296 | |
297 if (compilation()->debug_info_recorder()->recording_non_safepoints()) { | |
298 process_debug_info(op); | |
299 } | |
300 | |
301 #ifndef PRODUCT | |
302 if (PrintLIRWithAssembly) { | |
303 _masm->code()->decode(); | |
304 } | |
305 #endif /* PRODUCT */ | |
306 } | |
307 } | |
308 | |
309 #ifdef ASSERT | |
310 void LIR_Assembler::check_no_unbound_labels() { | |
311 CHECK_BAILOUT(); | |
312 | |
313 for (int i = 0; i < _branch_target_blocks.length() - 1; i++) { | |
314 if (!_branch_target_blocks.at(i)->label()->is_bound()) { | |
315 tty->print_cr("label of block B%d is not bound", _branch_target_blocks.at(i)->block_id()); | |
316 assert(false, "unbound label"); | |
317 } | |
318 } | |
319 } | |
320 #endif | |
321 | |
322 //----------------------------------debug info-------------------------------- | |
323 | |
324 | |
325 void LIR_Assembler::add_debug_info_for_branch(CodeEmitInfo* info) { | |
326 _masm->code_section()->relocate(pc(), relocInfo::poll_type); | |
327 int pc_offset = code_offset(); | |
328 flush_debug_info(pc_offset); | |
329 info->record_debug_info(compilation()->debug_info_recorder(), pc_offset); | |
330 if (info->exception_handlers() != NULL) { | |
331 compilation()->add_exception_handlers_for_pco(pc_offset, info->exception_handlers()); | |
332 } | |
333 } | |
334 | |
335 | |
1564 | 336 void LIR_Assembler::add_call_info(int pc_offset, CodeEmitInfo* cinfo) { |
0 | 337 flush_debug_info(pc_offset); |
1564 | 338 cinfo->record_debug_info(compilation()->debug_info_recorder(), pc_offset); |
0 | 339 if (cinfo->exception_handlers() != NULL) { |
340 compilation()->add_exception_handlers_for_pco(pc_offset, cinfo->exception_handlers()); | |
341 } | |
342 } | |
343 | |
344 static ValueStack* debug_info(Instruction* ins) { | |
345 StateSplit* ss = ins->as_StateSplit(); | |
346 if (ss != NULL) return ss->state(); | |
1819 | 347 return ins->state_before(); |
0 | 348 } |
349 | |
350 void LIR_Assembler::process_debug_info(LIR_Op* op) { | |
351 Instruction* src = op->source(); | |
352 if (src == NULL) return; | |
353 int pc_offset = code_offset(); | |
354 if (_pending_non_safepoint == src) { | |
355 _pending_non_safepoint_offset = pc_offset; | |
356 return; | |
357 } | |
358 ValueStack* vstack = debug_info(src); | |
359 if (vstack == NULL) return; | |
360 if (_pending_non_safepoint != NULL) { | |
361 // Got some old debug info. Get rid of it. | |
1819 | 362 if (debug_info(_pending_non_safepoint) == vstack) { |
0 | 363 _pending_non_safepoint_offset = pc_offset; |
364 return; | |
365 } | |
366 if (_pending_non_safepoint_offset < pc_offset) { | |
367 record_non_safepoint_debug_info(); | |
368 } | |
369 _pending_non_safepoint = NULL; | |
370 } | |
371 // Remember the debug info. | |
372 if (pc_offset > compilation()->debug_info_recorder()->last_pc_offset()) { | |
373 _pending_non_safepoint = src; | |
374 _pending_non_safepoint_offset = pc_offset; | |
375 } | |
376 } | |
377 | |
378 // Index caller states in s, where 0 is the oldest, 1 its callee, etc. | |
379 // Return NULL if n is too large. | |
380 // Returns the caller_bci for the next-younger state, also. | |
381 static ValueStack* nth_oldest(ValueStack* s, int n, int& bci_result) { | |
382 ValueStack* t = s; | |
383 for (int i = 0; i < n; i++) { | |
384 if (t == NULL) break; | |
385 t = t->caller_state(); | |
386 } | |
387 if (t == NULL) return NULL; | |
388 for (;;) { | |
389 ValueStack* tc = t->caller_state(); | |
390 if (tc == NULL) return s; | |
391 t = tc; | |
1819 | 392 bci_result = tc->bci(); |
0 | 393 s = s->caller_state(); |
394 } | |
395 } | |
396 | |
397 void LIR_Assembler::record_non_safepoint_debug_info() { | |
398 int pc_offset = _pending_non_safepoint_offset; | |
399 ValueStack* vstack = debug_info(_pending_non_safepoint); | |
1819 | 400 int bci = vstack->bci(); |
0 | 401 |
402 DebugInformationRecorder* debug_info = compilation()->debug_info_recorder(); | |
403 assert(debug_info->recording_non_safepoints(), "sanity"); | |
404 | |
405 debug_info->add_non_safepoint(pc_offset); | |
406 | |
407 // Visit scopes from oldest to youngest. | |
408 for (int n = 0; ; n++) { | |
409 int s_bci = bci; | |
410 ValueStack* s = nth_oldest(vstack, n, s_bci); | |
411 if (s == NULL) break; | |
412 IRScope* scope = s->scope(); | |
900
9987d9d5eb0e
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
380
diff
changeset
|
413 //Always pass false for reexecute since these ScopeDescs are never used for deopt |
4583
597bc897257d
Made DebugInformationRecorder::describe_scope() take both a methodHandle _and_ a ciMethod* parameter to avoid creating handles in scopes where it is not allowed.
Doug Simon <doug.simon@oracle.com>
parents:
4578
diff
changeset
|
414 methodHandle null_mh; |
597bc897257d
Made DebugInformationRecorder::describe_scope() take both a methodHandle _and_ a ciMethod* parameter to avoid creating handles in scopes where it is not allowed.
Doug Simon <doug.simon@oracle.com>
parents:
4578
diff
changeset
|
415 debug_info->describe_scope(pc_offset, null_mh, scope->method(), s->bci(), false/*reexecute*/); |
0 | 416 } |
417 | |
418 debug_info->end_non_safepoint(pc_offset); | |
419 } | |
420 | |
421 | |
422 void LIR_Assembler::add_debug_info_for_null_check_here(CodeEmitInfo* cinfo) { | |
423 add_debug_info_for_null_check(code_offset(), cinfo); | |
424 } | |
425 | |
426 void LIR_Assembler::add_debug_info_for_null_check(int pc_offset, CodeEmitInfo* cinfo) { | |
427 ImplicitNullCheckStub* stub = new ImplicitNullCheckStub(pc_offset, cinfo); | |
428 emit_code_stub(stub); | |
429 } | |
430 | |
431 void LIR_Assembler::add_debug_info_for_div0_here(CodeEmitInfo* info) { | |
432 add_debug_info_for_div0(code_offset(), info); | |
433 } | |
434 | |
435 void LIR_Assembler::add_debug_info_for_div0(int pc_offset, CodeEmitInfo* cinfo) { | |
436 DivByZeroStub* stub = new DivByZeroStub(pc_offset, cinfo); | |
437 emit_code_stub(stub); | |
438 } | |
439 | |
440 void LIR_Assembler::emit_rtcall(LIR_OpRTCall* op) { | |
441 rt_call(op->result_opr(), op->addr(), op->arguments(), op->tmp(), op->info()); | |
442 } | |
443 | |
444 | |
445 void LIR_Assembler::emit_call(LIR_OpJavaCall* op) { | |
446 verify_oop_map(op->info()); | |
447 | |
448 if (os::is_MP()) { | |
449 // must align calls sites, otherwise they can't be updated atomically on MP hardware | |
450 align_call(op->code()); | |
451 } | |
452 | |
453 // emit the static call stub stuff out of line | |
454 emit_static_call_stub(); | |
455 | |
456 switch (op->code()) { | |
457 case lir_static_call: | |
6616
7a302948f5a4
7192167: JSR 292: C1 has old broken code which needs to be removed
twisti
parents:
6084
diff
changeset
|
458 case lir_dynamic_call: |
1295 | 459 call(op, relocInfo::static_call_type); |
0 | 460 break; |
461 case lir_optvirtual_call: | |
1295 | 462 call(op, relocInfo::opt_virtual_call_type); |
0 | 463 break; |
464 case lir_icvirtual_call: | |
1295 | 465 ic_call(op); |
0 | 466 break; |
467 case lir_virtual_call: | |
1295 | 468 vtable_call(op); |
0 | 469 break; |
6616
7a302948f5a4
7192167: JSR 292: C1 has old broken code which needs to be removed
twisti
parents:
6084
diff
changeset
|
470 default: |
7a302948f5a4
7192167: JSR 292: C1 has old broken code which needs to be removed
twisti
parents:
6084
diff
changeset
|
471 fatal(err_msg_res("unexpected op code: %s", op->name())); |
7a302948f5a4
7192167: JSR 292: C1 has old broken code which needs to be removed
twisti
parents:
6084
diff
changeset
|
472 break; |
0 | 473 } |
1295 | 474 |
1691
4a665be40fd3
6975855: don't emit deopt MH handler in C1 if not required
twisti
parents:
1579
diff
changeset
|
475 // JSR 292 |
4a665be40fd3
6975855: don't emit deopt MH handler in C1 if not required
twisti
parents:
1579
diff
changeset
|
476 // Record if this method has MethodHandle invokes. |
4a665be40fd3
6975855: don't emit deopt MH handler in C1 if not required
twisti
parents:
1579
diff
changeset
|
477 if (op->is_method_handle_invoke()) { |
4a665be40fd3
6975855: don't emit deopt MH handler in C1 if not required
twisti
parents:
1579
diff
changeset
|
478 compilation()->set_has_method_handle_invokes(true); |
4a665be40fd3
6975855: don't emit deopt MH handler in C1 if not required
twisti
parents:
1579
diff
changeset
|
479 } |
4a665be40fd3
6975855: don't emit deopt MH handler in C1 if not required
twisti
parents:
1579
diff
changeset
|
480 |
304 | 481 #if defined(X86) && defined(TIERED) |
0 | 482 // C2 leave fpu stack dirty clean it |
483 if (UseSSE < 2) { | |
484 int i; | |
485 for ( i = 1; i <= 7 ; i++ ) { | |
486 ffree(i); | |
487 } | |
488 if (!op->result_opr()->is_float_kind()) { | |
489 ffree(0); | |
490 } | |
491 } | |
304 | 492 #endif // X86 && TIERED |
0 | 493 } |
494 | |
495 | |
496 void LIR_Assembler::emit_opLabel(LIR_OpLabel* op) { | |
497 _masm->bind (*(op->label())); | |
498 } | |
499 | |
500 | |
501 void LIR_Assembler::emit_op1(LIR_Op1* op) { | |
502 switch (op->code()) { | |
503 case lir_move: | |
504 if (op->move_kind() == lir_move_volatile) { | |
505 assert(op->patch_code() == lir_patch_none, "can't patch volatiles"); | |
506 volatile_move_op(op->in_opr(), op->result_opr(), op->type(), op->info()); | |
507 } else { | |
508 move_op(op->in_opr(), op->result_opr(), op->type(), | |
2002 | 509 op->patch_code(), op->info(), op->pop_fpu_stack(), |
510 op->move_kind() == lir_move_unaligned, | |
511 op->move_kind() == lir_move_wide); | |
0 | 512 } |
513 break; | |
514 | |
515 case lir_prefetchr: | |
516 prefetchr(op->in_opr()); | |
517 break; | |
518 | |
519 case lir_prefetchw: | |
520 prefetchw(op->in_opr()); | |
521 break; | |
522 | |
523 case lir_roundfp: { | |
524 LIR_OpRoundFP* round_op = op->as_OpRoundFP(); | |
525 roundfp_op(round_op->in_opr(), round_op->tmp(), round_op->result_opr(), round_op->pop_fpu_stack()); | |
526 break; | |
527 } | |
528 | |
529 case lir_return: | |
530 return_op(op->in_opr()); | |
531 break; | |
532 | |
533 case lir_safepoint: | |
534 if (compilation()->debug_info_recorder()->last_pc_offset() == code_offset()) { | |
535 _masm->nop(); | |
536 } | |
537 safepoint_poll(op->in_opr(), op->info()); | |
538 break; | |
539 | |
540 case lir_fxch: | |
541 fxch(op->in_opr()->as_jint()); | |
542 break; | |
543 | |
544 case lir_fld: | |
545 fld(op->in_opr()->as_jint()); | |
546 break; | |
547 | |
548 case lir_ffree: | |
549 ffree(op->in_opr()->as_jint()); | |
550 break; | |
551 | |
552 case lir_branch: | |
553 break; | |
554 | |
555 case lir_push: | |
556 push(op->in_opr()); | |
557 break; | |
558 | |
559 case lir_pop: | |
560 pop(op->in_opr()); | |
561 break; | |
562 | |
563 case lir_neg: | |
564 negate(op->in_opr(), op->result_opr()); | |
565 break; | |
566 | |
567 case lir_leal: | |
568 leal(op->in_opr(), op->result_opr()); | |
569 break; | |
570 | |
571 case lir_null_check: | |
572 if (GenerateCompilerNullChecks) { | |
573 add_debug_info_for_null_check_here(op->info()); | |
574 | |
575 if (op->in_opr()->is_single_cpu()) { | |
576 _masm->null_check(op->in_opr()->as_register()); | |
577 } else { | |
578 Unimplemented(); | |
579 } | |
580 } | |
581 break; | |
582 | |
583 case lir_monaddr: | |
584 monitor_address(op->in_opr()->as_constant_ptr()->as_jint(), op->result_opr()); | |
585 break; | |
586 | |
1783 | 587 #ifdef SPARC |
588 case lir_pack64: | |
589 pack64(op->in_opr(), op->result_opr()); | |
590 break; | |
591 | |
592 case lir_unpack64: | |
593 unpack64(op->in_opr(), op->result_opr()); | |
594 break; | |
595 #endif | |
596 | |
1378
9f5b60a14736
6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents:
1301
diff
changeset
|
597 case lir_unwind: |
9f5b60a14736
6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents:
1301
diff
changeset
|
598 unwind_op(op->in_opr()); |
9f5b60a14736
6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents:
1301
diff
changeset
|
599 break; |
9f5b60a14736
6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents:
1301
diff
changeset
|
600 |
0 | 601 default: |
602 Unimplemented(); | |
603 break; | |
604 } | |
605 } | |
606 | |
607 | |
608 void LIR_Assembler::emit_op0(LIR_Op0* op) { | |
609 switch (op->code()) { | |
610 case lir_word_align: { | |
611 while (code_offset() % BytesPerWord != 0) { | |
612 _masm->nop(); | |
613 } | |
614 break; | |
615 } | |
616 | |
617 case lir_nop: | |
618 assert(op->info() == NULL, "not supported"); | |
619 _masm->nop(); | |
620 break; | |
621 | |
622 case lir_label: | |
623 Unimplemented(); | |
624 break; | |
625 | |
626 case lir_build_frame: | |
627 build_frame(); | |
628 break; | |
629 | |
630 case lir_std_entry: | |
631 // init offsets | |
632 offsets()->set_value(CodeOffsets::OSR_Entry, _masm->offset()); | |
633 _masm->align(CodeEntryAlignment); | |
634 if (needs_icache(compilation()->method())) { | |
635 check_icache(); | |
636 } | |
637 offsets()->set_value(CodeOffsets::Verified_Entry, _masm->offset()); | |
638 _masm->verified_entry(); | |
639 build_frame(); | |
640 offsets()->set_value(CodeOffsets::Frame_Complete, _masm->offset()); | |
641 break; | |
642 | |
643 case lir_osr_entry: | |
644 offsets()->set_value(CodeOffsets::OSR_Entry, _masm->offset()); | |
645 osr_entry(); | |
646 break; | |
647 | |
648 case lir_24bit_FPU: | |
649 set_24bit_FPU(); | |
650 break; | |
651 | |
652 case lir_reset_FPU: | |
653 reset_FPU(); | |
654 break; | |
655 | |
656 case lir_breakpoint: | |
657 breakpoint(); | |
658 break; | |
659 | |
660 case lir_fpop_raw: | |
661 fpop(); | |
662 break; | |
663 | |
664 case lir_membar: | |
665 membar(); | |
666 break; | |
667 | |
668 case lir_membar_acquire: | |
669 membar_acquire(); | |
670 break; | |
671 | |
672 case lir_membar_release: | |
673 membar_release(); | |
674 break; | |
675 | |
4966
701a83c86f28
7120481: storeStore barrier in constructor with final field
jiangli
parents:
3896
diff
changeset
|
676 case lir_membar_loadload: |
701a83c86f28
7120481: storeStore barrier in constructor with final field
jiangli
parents:
3896
diff
changeset
|
677 membar_loadload(); |
701a83c86f28
7120481: storeStore barrier in constructor with final field
jiangli
parents:
3896
diff
changeset
|
678 break; |
701a83c86f28
7120481: storeStore barrier in constructor with final field
jiangli
parents:
3896
diff
changeset
|
679 |
701a83c86f28
7120481: storeStore barrier in constructor with final field
jiangli
parents:
3896
diff
changeset
|
680 case lir_membar_storestore: |
701a83c86f28
7120481: storeStore barrier in constructor with final field
jiangli
parents:
3896
diff
changeset
|
681 membar_storestore(); |
701a83c86f28
7120481: storeStore barrier in constructor with final field
jiangli
parents:
3896
diff
changeset
|
682 break; |
701a83c86f28
7120481: storeStore barrier in constructor with final field
jiangli
parents:
3896
diff
changeset
|
683 |
701a83c86f28
7120481: storeStore barrier in constructor with final field
jiangli
parents:
3896
diff
changeset
|
684 case lir_membar_loadstore: |
701a83c86f28
7120481: storeStore barrier in constructor with final field
jiangli
parents:
3896
diff
changeset
|
685 membar_loadstore(); |
701a83c86f28
7120481: storeStore barrier in constructor with final field
jiangli
parents:
3896
diff
changeset
|
686 break; |
701a83c86f28
7120481: storeStore barrier in constructor with final field
jiangli
parents:
3896
diff
changeset
|
687 |
701a83c86f28
7120481: storeStore barrier in constructor with final field
jiangli
parents:
3896
diff
changeset
|
688 case lir_membar_storeload: |
701a83c86f28
7120481: storeStore barrier in constructor with final field
jiangli
parents:
3896
diff
changeset
|
689 membar_storeload(); |
701a83c86f28
7120481: storeStore barrier in constructor with final field
jiangli
parents:
3896
diff
changeset
|
690 break; |
701a83c86f28
7120481: storeStore barrier in constructor with final field
jiangli
parents:
3896
diff
changeset
|
691 |
0 | 692 case lir_get_thread: |
693 get_thread(op->result_opr()); | |
694 break; | |
695 | |
696 default: | |
697 ShouldNotReachHere(); | |
698 break; | |
699 } | |
700 } | |
701 | |
702 | |
703 void LIR_Assembler::emit_op2(LIR_Op2* op) { | |
704 switch (op->code()) { | |
705 case lir_cmp: | |
706 if (op->info() != NULL) { | |
707 assert(op->in_opr1()->is_address() || op->in_opr2()->is_address(), | |
708 "shouldn't be codeemitinfo for non-address operands"); | |
709 add_debug_info_for_null_check_here(op->info()); // exception possible | |
710 } | |
711 comp_op(op->condition(), op->in_opr1(), op->in_opr2(), op); | |
712 break; | |
713 | |
714 case lir_cmp_l2i: | |
715 case lir_cmp_fd2i: | |
716 case lir_ucmp_fd2i: | |
717 comp_fl2i(op->code(), op->in_opr1(), op->in_opr2(), op->result_opr(), op); | |
718 break; | |
719 | |
720 case lir_cmove: | |
2089
037c727f35fb
7009231: C1: Incorrect CAS code for longs on SPARC 32bit
iveresov
parents:
2002
diff
changeset
|
721 cmove(op->condition(), op->in_opr1(), op->in_opr2(), op->result_opr(), op->type()); |
0 | 722 break; |
723 | |
724 case lir_shl: | |
725 case lir_shr: | |
726 case lir_ushr: | |
727 if (op->in_opr2()->is_constant()) { | |
728 shift_op(op->code(), op->in_opr1(), op->in_opr2()->as_constant_ptr()->as_jint(), op->result_opr()); | |
729 } else { | |
6084
6759698e3140
7133857: exp() and pow() should use the x87 ISA on x86
roland
parents:
4966
diff
changeset
|
730 shift_op(op->code(), op->in_opr1(), op->in_opr2(), op->result_opr(), op->tmp1_opr()); |
0 | 731 } |
732 break; | |
733 | |
734 case lir_add: | |
735 case lir_sub: | |
736 case lir_mul: | |
737 case lir_mul_strictfp: | |
738 case lir_div: | |
739 case lir_div_strictfp: | |
740 case lir_rem: | |
741 assert(op->fpu_pop_count() < 2, ""); | |
742 arith_op( | |
743 op->code(), | |
744 op->in_opr1(), | |
745 op->in_opr2(), | |
746 op->result_opr(), | |
747 op->info(), | |
748 op->fpu_pop_count() == 1); | |
749 break; | |
750 | |
751 case lir_abs: | |
752 case lir_sqrt: | |
753 case lir_sin: | |
754 case lir_tan: | |
755 case lir_cos: | |
756 case lir_log: | |
757 case lir_log10: | |
6084
6759698e3140
7133857: exp() and pow() should use the x87 ISA on x86
roland
parents:
4966
diff
changeset
|
758 case lir_exp: |
6759698e3140
7133857: exp() and pow() should use the x87 ISA on x86
roland
parents:
4966
diff
changeset
|
759 case lir_pow: |
0 | 760 intrinsic_op(op->code(), op->in_opr1(), op->in_opr2(), op->result_opr(), op); |
761 break; | |
762 | |
763 case lir_logic_and: | |
764 case lir_logic_or: | |
765 case lir_logic_xor: | |
766 logic_op( | |
767 op->code(), | |
768 op->in_opr1(), | |
769 op->in_opr2(), | |
770 op->result_opr()); | |
771 break; | |
772 | |
773 case lir_throw: | |
1378
9f5b60a14736
6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents:
1301
diff
changeset
|
774 throw_op(op->in_opr1(), op->in_opr2(), op->info()); |
0 | 775 break; |
776 | |
6795
7eca5de9e0b6
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
6725
diff
changeset
|
777 case lir_xadd: |
7eca5de9e0b6
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
6725
diff
changeset
|
778 case lir_xchg: |
7eca5de9e0b6
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
6725
diff
changeset
|
779 atomic_op(op->code(), op->in_opr1(), op->in_opr2(), op->result_opr(), op->tmp1_opr()); |
7eca5de9e0b6
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
6725
diff
changeset
|
780 break; |
7eca5de9e0b6
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
6725
diff
changeset
|
781 |
0 | 782 default: |
783 Unimplemented(); | |
784 break; | |
785 } | |
786 } | |
787 | |
788 | |
789 void LIR_Assembler::build_frame() { | |
790 _masm->build_frame(initial_frame_size_in_bytes()); | |
791 } | |
792 | |
793 | |
794 void LIR_Assembler::roundfp_op(LIR_Opr src, LIR_Opr tmp, LIR_Opr dest, bool pop_fpu_stack) { | |
795 assert((src->is_single_fpu() && dest->is_single_stack()) || | |
796 (src->is_double_fpu() && dest->is_double_stack()), | |
797 "round_fp: rounds register -> stack location"); | |
798 | |
799 reg2stack (src, dest, src->type(), pop_fpu_stack); | |
800 } | |
801 | |
802 | |
2002 | 803 void LIR_Assembler::move_op(LIR_Opr src, LIR_Opr dest, BasicType type, LIR_PatchCode patch_code, CodeEmitInfo* info, bool pop_fpu_stack, bool unaligned, bool wide) { |
0 | 804 if (src->is_register()) { |
805 if (dest->is_register()) { | |
806 assert(patch_code == lir_patch_none && info == NULL, "no patching and info allowed here"); | |
807 reg2reg(src, dest); | |
808 } else if (dest->is_stack()) { | |
809 assert(patch_code == lir_patch_none && info == NULL, "no patching and info allowed here"); | |
810 reg2stack(src, dest, type, pop_fpu_stack); | |
811 } else if (dest->is_address()) { | |
2002 | 812 reg2mem(src, dest, type, patch_code, info, pop_fpu_stack, wide, unaligned); |
0 | 813 } else { |
814 ShouldNotReachHere(); | |
815 } | |
816 | |
817 } else if (src->is_stack()) { | |
818 assert(patch_code == lir_patch_none && info == NULL, "no patching and info allowed here"); | |
819 if (dest->is_register()) { | |
820 stack2reg(src, dest, type); | |
821 } else if (dest->is_stack()) { | |
822 stack2stack(src, dest, type); | |
823 } else { | |
824 ShouldNotReachHere(); | |
825 } | |
826 | |
827 } else if (src->is_constant()) { | |
828 if (dest->is_register()) { | |
829 const2reg(src, dest, patch_code, info); // patching is possible | |
830 } else if (dest->is_stack()) { | |
831 assert(patch_code == lir_patch_none && info == NULL, "no patching and info allowed here"); | |
832 const2stack(src, dest); | |
833 } else if (dest->is_address()) { | |
834 assert(patch_code == lir_patch_none, "no patching allowed here"); | |
2002 | 835 const2mem(src, dest, type, info, wide); |
0 | 836 } else { |
837 ShouldNotReachHere(); | |
838 } | |
839 | |
840 } else if (src->is_address()) { | |
2002 | 841 mem2reg(src, dest, type, patch_code, info, wide, unaligned); |
0 | 842 |
843 } else { | |
844 ShouldNotReachHere(); | |
845 } | |
846 } | |
847 | |
848 | |
849 void LIR_Assembler::verify_oop_map(CodeEmitInfo* info) { | |
850 #ifndef PRODUCT | |
851 if (VerifyOopMaps || VerifyOops) { | |
852 bool v = VerifyOops; | |
853 VerifyOops = true; | |
854 OopMapStream s(info->oop_map()); | |
855 while (!s.is_done()) { | |
856 OopMapValue v = s.current(); | |
857 if (v.is_oop()) { | |
858 VMReg r = v.reg(); | |
859 if (!r->is_stack()) { | |
860 stringStream st; | |
861 st.print("bad oop %s at %d", r->as_Register()->name(), _masm->offset()); | |
862 #ifdef SPARC | |
863 _masm->_verify_oop(r->as_Register(), strdup(st.as_string()), __FILE__, __LINE__); | |
864 #else | |
865 _masm->verify_oop(r->as_Register()); | |
866 #endif | |
867 } else { | |
868 _masm->verify_stack_oop(r->reg2stack() * VMRegImpl::stack_slot_size); | |
869 } | |
870 } | |
2451
87ce328c6a21
6528013: C1 CTW failure with -XX:+VerifyOops assert(allocates2(pc),"")
never
parents:
2192
diff
changeset
|
871 check_codespace(); |
87ce328c6a21
6528013: C1 CTW failure with -XX:+VerifyOops assert(allocates2(pc),"")
never
parents:
2192
diff
changeset
|
872 CHECK_BAILOUT(); |
87ce328c6a21
6528013: C1 CTW failure with -XX:+VerifyOops assert(allocates2(pc),"")
never
parents:
2192
diff
changeset
|
873 |
0 | 874 s.next(); |
875 } | |
876 VerifyOops = v; | |
877 } | |
878 #endif | |
879 } |