comparison src/cpu/x86/vm/x86_64.ad @ 4950:9b8ce46870df

7145346: VerifyStackAtCalls is broken Summary: Replace call_epilog() encoding with macroassembler use. Moved duplicated code to x86.ad. Fixed return_addr() definition. Reviewed-by: never
author kvn
date Thu, 16 Feb 2012 17:12:49 -0800
parents fd8114661503
children 61b82be3b1ff
comparison
equal deleted inserted replaced
4949:ad3b47344802 4950:9b8ce46870df
1 // 1 //
2 // Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved. 2 // Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
3 // DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 // DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 // 4 //
5 // This code is free software; you can redistribute it and/or modify it 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 6 // under the terms of the GNU General Public License version 2 only, as
7 // published by the Free Software Foundation. 7 // published by the Free Software Foundation.
607 int CallDynamicJavaDirectNode::compute_padding(int current_offset) const 607 int CallDynamicJavaDirectNode::compute_padding(int current_offset) const
608 { 608 {
609 current_offset += 11; // skip movq instruction + call opcode byte 609 current_offset += 11; // skip movq instruction + call opcode byte
610 return round_to(current_offset, alignment_required()) - current_offset; 610 return round_to(current_offset, alignment_required()) - current_offset;
611 } 611 }
612
613 #ifndef PRODUCT
614 void MachBreakpointNode::format(PhaseRegAlloc*, outputStream* st) const
615 {
616 st->print("INT3");
617 }
618 #endif
619 612
620 // EMIT_RM() 613 // EMIT_RM()
621 void emit_rm(CodeBuffer &cbuf, int f1, int f2, int f3) { 614 void emit_rm(CodeBuffer &cbuf, int f1, int f2, int f3) {
622 unsigned char c = (unsigned char) ((f1 << 6) | (f2 << 3) | f3); 615 unsigned char c = (unsigned char) ((f1 << 6) | (f2 << 3) | f3);
623 cbuf.insts()->emit_int8(c); 616 cbuf.insts()->emit_int8(c);
1528 return implementation(NULL, ra_, true, NULL); 1521 return implementation(NULL, ra_, true, NULL);
1529 } 1522 }
1530 1523
1531 //============================================================================= 1524 //=============================================================================
1532 #ifndef PRODUCT 1525 #ifndef PRODUCT
1533 void MachNopNode::format(PhaseRegAlloc*, outputStream* st) const
1534 {
1535 st->print("nop \t# %d bytes pad for loops and calls", _count);
1536 }
1537 #endif
1538
1539 void MachNopNode::emit(CodeBuffer &cbuf, PhaseRegAlloc*) const
1540 {
1541 MacroAssembler _masm(&cbuf);
1542 __ nop(_count);
1543 }
1544
1545 uint MachNopNode::size(PhaseRegAlloc*) const
1546 {
1547 return _count;
1548 }
1549
1550
1551 //=============================================================================
1552 #ifndef PRODUCT
1553 void BoxLockNode::format(PhaseRegAlloc* ra_, outputStream* st) const 1526 void BoxLockNode::format(PhaseRegAlloc* ra_, outputStream* st) const
1554 { 1527 {
1555 int offset = ra_->reg2offset(in_RegMask(0).find_first_elem()); 1528 int offset = ra_->reg2offset(in_RegMask(0).find_first_elem());
1556 int reg = ra_->get_reg_first(this); 1529 int reg = ra_->get_reg_first(this);
1557 st->print("leaq %s, [rsp + #%d]\t# box lock", 1530 st->print("leaq %s, [rsp + #%d]\t# box lock",
2251 // CALL directly to the runtime 2224 // CALL directly to the runtime
2252 emit_d32_reloc(cbuf, 2225 emit_d32_reloc(cbuf,
2253 (int) ($meth$$method - ((intptr_t) cbuf.insts_end()) - 4), 2226 (int) ($meth$$method - ((intptr_t) cbuf.insts_end()) - 4),
2254 runtime_call_Relocation::spec(), 2227 runtime_call_Relocation::spec(),
2255 RELOC_DISP32); 2228 RELOC_DISP32);
2256 %}
2257
2258 enc_class preserve_SP %{
2259 debug_only(int off0 = cbuf.insts_size());
2260 MacroAssembler _masm(&cbuf);
2261 // RBP is preserved across all calls, even compiled calls.
2262 // Use it to preserve RSP in places where the callee might change the SP.
2263 __ movptr(rbp_mh_SP_save, rsp);
2264 debug_only(int off1 = cbuf.insts_size());
2265 assert(off1 - off0 == preserve_SP_size(), "correct size prediction");
2266 %}
2267
2268 enc_class restore_SP %{
2269 MacroAssembler _masm(&cbuf);
2270 __ movptr(rsp, rbp_mh_SP_save);
2271 %} 2229 %}
2272 2230
2273 enc_class Java_Static_Call(method meth) 2231 enc_class Java_Static_Call(method meth)
2274 %{ 2232 %{
2275 // JAVA STATIC CALL 2233 // JAVA STATIC CALL
3206 // representing the register number (i.e. - use a register name) or 3164 // representing the register number (i.e. - use a register name) or
3207 // stack slot. 3165 // stack slot.
3208 // Ret Addr is on stack in slot 0 if no locks or verification or alignment. 3166 // Ret Addr is on stack in slot 0 if no locks or verification or alignment.
3209 // Otherwise, it is above the locks and verification slot and alignment word 3167 // Otherwise, it is above the locks and verification slot and alignment word
3210 return_addr(STACK - 2 + 3168 return_addr(STACK - 2 +
3211 round_to(2 + 2 * VerifyStackAtCalls + 3169 round_to((Compile::current()->in_preserve_stack_slots() +
3212 Compile::current()->fixed_slots(), 3170 Compile::current()->fixed_slots()),
3213 WordsPerLong * 2)); 3171 stack_alignment_in_slots()));
3214 3172
3215 // Body of function which returns an integer array locating 3173 // Body of function which returns an integer array locating
3216 // arguments either in registers or in stack slots. Passed an array 3174 // arguments either in registers or in stack slots. Passed an array
3217 // of ideal registers called "sig" and a "length" count. Stack-slot 3175 // of ideal registers called "sig" and a "length" count. Stack-slot
3218 // offsets are based on outgoing arguments, i.e. a CALLER setting up 3176 // offsets are based on outgoing arguments, i.e. a CALLER setting up
11663 11621
11664 // use the following format syntax 11622 // use the following format syntax
11665 format %{ "jmp rethrow_stub" %} 11623 format %{ "jmp rethrow_stub" %}
11666 ins_encode(enc_rethrow); 11624 ins_encode(enc_rethrow);
11667 ins_pipe(pipe_jmp); 11625 ins_pipe(pipe_jmp);
11626 %}
11627
11628
11629 // ============================================================================
11630 // This name is KNOWN by the ADLC and cannot be changed.
11631 // The ADLC forces a 'TypeRawPtr::BOTTOM' output type
11632 // for this guy.
11633 instruct tlsLoadP(r15_RegP dst) %{
11634 match(Set dst (ThreadLocal));
11635 effect(DEF dst);
11636
11637 size(0);
11638 format %{ "# TLS is in R15" %}
11639 ins_encode( /*empty encoding*/ );
11640 ins_pipe(ialu_reg_reg);
11668 %} 11641 %}
11669 11642
11670 11643
11671 //----------PEEPHOLE RULES----------------------------------------------------- 11644 //----------PEEPHOLE RULES-----------------------------------------------------
11672 // These must follow all instruction definitions as they use the names 11645 // These must follow all instruction definitions as they use the names