src/os_cpu/linux_x86/vm/linux_x86_64.ad

Sat, 01 Dec 2007 00:00:00 +0000

author
duke
date
Sat, 01 Dec 2007 00:00:00 +0000
changeset 435
a61af66fc99e
child 1907
c18cbe5936b8
permissions
-rw-r--r--

Initial load

duke@435 1 //
duke@435 2 // Copyright 2003-2006 Sun Microsystems, Inc. All Rights Reserved.
duke@435 3 // DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@435 4 //
duke@435 5 // This code is free software; you can redistribute it and/or modify it
duke@435 6 // under the terms of the GNU General Public License version 2 only, as
duke@435 7 // published by the Free Software Foundation.
duke@435 8 //
duke@435 9 // This code is distributed in the hope that it will be useful, but WITHOUT
duke@435 10 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@435 11 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@435 12 // version 2 for more details (a copy is included in the LICENSE file that
duke@435 13 // accompanied this code).
duke@435 14 //
duke@435 15 // You should have received a copy of the GNU General Public License version
duke@435 16 // 2 along with this work; if not, write to the Free Software Foundation,
duke@435 17 // Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@435 18 //
duke@435 19 // Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
duke@435 20 // CA 95054 USA or visit www.sun.com if you need additional information or
duke@435 21 // have any questions.
duke@435 22 //
duke@435 23 //
duke@435 24
duke@435 25 // AMD64 Linux Architecture Description File
duke@435 26
duke@435 27 //----------OS-DEPENDENT ENCODING BLOCK----------------------------------------
duke@435 28 // This block specifies the encoding classes used by the compiler to
duke@435 29 // output byte streams. Encoding classes generate functions which are
duke@435 30 // called by Machine Instruction Nodes in order to generate the bit
duke@435 31 // encoding of the instruction. Operands specify their base encoding
duke@435 32 // interface with the interface keyword. There are currently
duke@435 33 // supported four interfaces, REG_INTER, CONST_INTER, MEMORY_INTER, &
duke@435 34 // COND_INTER. REG_INTER causes an operand to generate a function
duke@435 35 // which returns its register number when queried. CONST_INTER causes
duke@435 36 // an operand to generate a function which returns the value of the
duke@435 37 // constant when queried. MEMORY_INTER causes an operand to generate
duke@435 38 // four functions which return the Base Register, the Index Register,
duke@435 39 // the Scale Value, and the Offset Value of the operand when queried.
duke@435 40 // COND_INTER causes an operand to generate six functions which return
duke@435 41 // the encoding code (ie - encoding bits for the instruction)
duke@435 42 // associated with each basic boolean condition for a conditional
duke@435 43 // instruction. Instructions specify two basic values for encoding.
duke@435 44 // They use the ins_encode keyword to specify their encoding class
duke@435 45 // (which must be one of the class names specified in the encoding
duke@435 46 // block), and they use the opcode keyword to specify, in order, their
duke@435 47 // primary, secondary, and tertiary opcode. Only the opcode sections
duke@435 48 // which a particular instruction needs for encoding need to be
duke@435 49 // specified.
duke@435 50 encode %{
duke@435 51 // Build emit functions for each basic byte or larger field in the intel
duke@435 52 // encoding scheme (opcode, rm, sib, immediate), and call them from C++
duke@435 53 // code in the enc_class source block. Emit functions will live in the
duke@435 54 // main source block for now. In future, we can generalize this by
duke@435 55 // adding a syntax that specifies the sizes of fields in an order,
duke@435 56 // so that the adlc can build the emit functions automagically
duke@435 57
duke@435 58 enc_class Java_To_Runtime(method meth)
duke@435 59 %{
duke@435 60 // No relocation needed
duke@435 61
duke@435 62 // movq r10, <meth>
duke@435 63 emit_opcode(cbuf, Assembler::REX_WB);
duke@435 64 emit_opcode(cbuf, 0xB8 | (R10_enc - 8));
duke@435 65 emit_d64(cbuf, (int64_t) $meth$$method);
duke@435 66
duke@435 67 // call (r10)
duke@435 68 emit_opcode(cbuf, Assembler::REX_B);
duke@435 69 emit_opcode(cbuf, 0xFF);
duke@435 70 emit_opcode(cbuf, 0xD0 | (R10_enc - 8));
duke@435 71 %}
duke@435 72
duke@435 73 enc_class linux_breakpoint
duke@435 74 %{
duke@435 75 MacroAssembler* masm = new MacroAssembler(&cbuf);
duke@435 76 masm->call(RuntimeAddress(CAST_FROM_FN_PTR(address, os::breakpoint)));
duke@435 77 %}
duke@435 78
duke@435 79 enc_class call_epilog
duke@435 80 %{
duke@435 81 if (VerifyStackAtCalls) {
duke@435 82 // Check that stack depth is unchanged: find majik cookie on stack
duke@435 83 int framesize =
duke@435 84 ra_->reg2offset_unchecked(OptoReg::add(ra_->_matcher._old_SP, -3*VMRegImpl::slots_per_word));
duke@435 85 if (framesize) {
duke@435 86 if (framesize < 0x80) {
duke@435 87 emit_opcode(cbuf, Assembler::REX_W);
duke@435 88 emit_opcode(cbuf, 0x81); // cmpq [rsp+0],0xbadb1ood
duke@435 89 emit_d8(cbuf, 0x7C);
duke@435 90 emit_d8(cbuf, 0x24);
duke@435 91 emit_d8(cbuf, framesize); // Find majik cookie from ESP
duke@435 92 emit_d32(cbuf, 0xbadb100d);
duke@435 93 } else {
duke@435 94 emit_opcode(cbuf, Assembler::REX_W);
duke@435 95 emit_opcode(cbuf, 0x81); // cmpq [rsp+0],0xbadb1ood
duke@435 96 emit_d8(cbuf, 0xBC);
duke@435 97 emit_d8(cbuf, 0x24);
duke@435 98 emit_d32(cbuf, framesize); // Find majik cookie from ESP
duke@435 99 emit_d32(cbuf, 0xbadb100d);
duke@435 100 }
duke@435 101 }
duke@435 102 // jmp EQ around INT3
duke@435 103 // QQQ TODO
duke@435 104 const int jump_around = 5; // size of call to breakpoint, 1 for CC
duke@435 105 emit_opcode(cbuf, 0x74);
duke@435 106 emit_d8(cbuf, jump_around);
duke@435 107 // QQQ temporary
duke@435 108 emit_break(cbuf);
duke@435 109 // Die if stack mismatch
duke@435 110 // emit_opcode(cbuf,0xCC);
duke@435 111 }
duke@435 112 %}
duke@435 113
duke@435 114 %}
duke@435 115
duke@435 116 // INSTRUCTIONS -- Platform dependent
duke@435 117
duke@435 118 //----------OS and Locking Instructions----------------------------------------
duke@435 119
duke@435 120 // This name is KNOWN by the ADLC and cannot be changed.
duke@435 121 // The ADLC forces a 'TypeRawPtr::BOTTOM' output type
duke@435 122 // for this guy.
duke@435 123 instruct tlsLoadP(r15_RegP dst)
duke@435 124 %{
duke@435 125 match(Set dst (ThreadLocal));
duke@435 126 effect(DEF dst);
duke@435 127
duke@435 128 size(0);
duke@435 129 format %{ "# TLS is in R15" %}
duke@435 130 ins_encode( /*empty encoding*/ );
duke@435 131 ins_pipe(ialu_reg_reg);
duke@435 132 %}
duke@435 133
duke@435 134 // Die now
duke@435 135 instruct ShouldNotReachHere()
duke@435 136 %{
duke@435 137 match(Halt);
duke@435 138
duke@435 139 // Use the following format syntax
duke@435 140 format %{ "int3\t# ShouldNotReachHere" %}
duke@435 141 // QQQ TODO for now call breakpoint
duke@435 142 // opcode(0xCC);
duke@435 143 // ins_encode(Opc);
duke@435 144 ins_encode(linux_breakpoint);
duke@435 145 ins_pipe(pipe_slow);
duke@435 146 %}
duke@435 147
duke@435 148
duke@435 149 // Platform dependent source
duke@435 150
duke@435 151 source
duke@435 152 %{
duke@435 153
duke@435 154 int MachCallRuntimeNode::ret_addr_offset() {
duke@435 155 return 13; // movq r10,#addr; callq (r10)
duke@435 156 }
duke@435 157
duke@435 158 // emit an interrupt that is caught by the debugger
duke@435 159 void emit_break(CodeBuffer& cbuf) {
duke@435 160 // Debugger doesn't really catch this but best we can do so far QQQ
duke@435 161 MacroAssembler* masm = new MacroAssembler(&cbuf);
duke@435 162 masm->call(RuntimeAddress(CAST_FROM_FN_PTR(address, os::breakpoint)));
duke@435 163 }
duke@435 164
duke@435 165 void MachBreakpointNode::emit(CodeBuffer& cbuf, PhaseRegAlloc* ra_) const {
duke@435 166 emit_break(cbuf);
duke@435 167 }
duke@435 168
duke@435 169 uint MachBreakpointNode::size(PhaseRegAlloc* ra_) const {
duke@435 170 return 5;
duke@435 171 }
duke@435 172
duke@435 173 %}

mercurial