src/cpu/x86/vm/assembler_x86.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File 6829193 Sdiff src/cpu/x86/vm

src/cpu/x86/vm/assembler_x86.cpp

Print this page


   1 /*
   2  * Copyright 1997-2009 Sun Microsystems, Inc.  All Rights Reserved.
   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  *
  19  * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
  20  * CA 95054 USA or visit www.sun.com if you need additional information or
  21  * have any questions.
  22  *


6476 }
6477 
6478 // Note: load_unsigned_short used to be called load_unsigned_word.
6479 int MacroAssembler::load_unsigned_short(Register dst, Address src) {
6480   // According to Intel Doc. AP-526, "Zero-Extension of Short", p.16,
6481   // and "3.9 Partial Register Penalties", p. 22).
6482   int off;
6483   if (LP64_ONLY(true ||) VM_Version::is_P6() || src.uses(dst)) {
6484     off = offset();
6485     movzwl(dst, src); // movzxw
6486   } else {
6487     xorl(dst, dst);
6488     off = offset();
6489     movw(dst, src);
6490   }
6491   return off;
6492 }
6493 
6494 void MacroAssembler::load_sized_value(Register dst, Address src,
6495                                       int size_in_bytes, bool is_signed) {
6496   switch (size_in_bytes ^ (is_signed ? -1 : 0)) {
6497 #ifndef _LP64
6498   // For case 8, caller is responsible for manually loading
6499   // the second word into another register.
6500   case ~8:  // fall through:
6501   case  8:  movl(                dst, src ); break;
6502 #else
6503   case ~8:  // fall through:
6504   case  8:  movq(                dst, src ); break;
6505 #endif
6506   case ~4:  // fall through:
6507   case  4:  movl(                dst, src ); break;
6508   case ~2:  load_signed_short(   dst, src ); break;
6509   case  2:  load_unsigned_short( dst, src ); break;
6510   case ~1:  load_signed_byte(    dst, src ); break;
6511   case  1:  load_unsigned_byte(  dst, src ); break;
6512   default:  ShouldNotReachHere();
6513   }
6514 }
6515 
6516 void MacroAssembler::mov32(AddressLiteral dst, Register src) {
6517   if (reachable(dst)) {
6518     movl(as_Address(dst), src);
6519   } else {
6520     lea(rscratch1, dst);
6521     movl(Address(rscratch1, 0), src);
6522   }
6523 }
6524 
6525 void MacroAssembler::mov32(Register dst, AddressLiteral src) {
6526   if (reachable(src)) {
6527     movl(dst, as_Address(src));
6528   } else {
6529     lea(rscratch1, src);
6530     movl(dst, Address(rscratch1, 0));
6531   }


7689 // registers on entry:
7690 //  - rax ('check' register): required MethodType
7691 //  - rcx: method handle
7692 //  - rdx, rsi, or ?: killable temp
7693 void MacroAssembler::check_method_handle_type(Register mtype_reg, Register mh_reg,
7694                                               Register temp_reg,
7695                                               Label& wrong_method_type) {
7696   if (UseCompressedOops)  unimplemented();  // field accesses must decode
7697   // compare method type against that of the receiver
7698   cmpptr(mtype_reg, Address(mh_reg, delayed_value(java_dyn_MethodHandle::type_offset_in_bytes, temp_reg)));
7699   jcc(Assembler::notEqual, wrong_method_type);
7700 }
7701 
7702 
7703 // A method handle has a "vmslots" field which gives the size of its
7704 // argument list in JVM stack slots.  This field is either located directly
7705 // in every method handle, or else is indirectly accessed through the
7706 // method handle's MethodType.  This macro hides the distinction.
7707 void MacroAssembler::load_method_handle_vmslots(Register vmslots_reg, Register mh_reg,
7708                                                 Register temp_reg) {

7709   if (UseCompressedOops)  unimplemented();  // field accesses must decode
7710   // load mh.type.form.vmslots
7711   if (java_dyn_MethodHandle::vmslots_offset_in_bytes() != 0) {
7712     // hoist vmslots into every mh to avoid dependent load chain
7713     movl(vmslots_reg, Address(mh_reg, delayed_value(java_dyn_MethodHandle::vmslots_offset_in_bytes, temp_reg)));
7714   } else {
7715     Register temp2_reg = vmslots_reg;
7716     movptr(temp2_reg, Address(mh_reg,    delayed_value(java_dyn_MethodHandle::type_offset_in_bytes, temp_reg)));
7717     movptr(temp2_reg, Address(temp2_reg, delayed_value(java_dyn_MethodType::form_offset_in_bytes, temp_reg)));
7718     movl(vmslots_reg, Address(temp2_reg, delayed_value(java_dyn_MethodTypeForm::vmslots_offset_in_bytes, temp_reg)));
7719   }
7720 }
7721 
7722 
7723 // registers on entry:
7724 //  - rcx: method handle
7725 //  - rdx: killable temp (interpreted only)
7726 //  - rax: killable temp (compiled only)
7727 void MacroAssembler::jump_to_method_handle_entry(Register mh_reg, Register temp_reg) {
7728   assert(mh_reg == rcx, "caller must put MH object in rcx");


   1 /*
   2  * Copyright 1997-2010 Sun Microsystems, Inc.  All Rights Reserved.
   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  *
  19  * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
  20  * CA 95054 USA or visit www.sun.com if you need additional information or
  21  * have any questions.
  22  *


6476 }
6477 
6478 // Note: load_unsigned_short used to be called load_unsigned_word.
6479 int MacroAssembler::load_unsigned_short(Register dst, Address src) {
6480   // According to Intel Doc. AP-526, "Zero-Extension of Short", p.16,
6481   // and "3.9 Partial Register Penalties", p. 22).
6482   int off;
6483   if (LP64_ONLY(true ||) VM_Version::is_P6() || src.uses(dst)) {
6484     off = offset();
6485     movzwl(dst, src); // movzxw
6486   } else {
6487     xorl(dst, dst);
6488     off = offset();
6489     movw(dst, src);
6490   }
6491   return off;
6492 }
6493 
6494 void MacroAssembler::load_sized_value(Register dst, Address src,
6495                                       int size_in_bytes, bool is_signed) {
6496   switch (size_in_bytes) {
6497 #ifndef _LP64
6498   // For case 8, caller is responsible for manually loading
6499   // the second word into another register.
6500   case  8: movl(dst, src); break;

6501 #else
6502   case  8: movq(dst, src); break;

6503 #endif
6504   case  4: movl(dst, src); break;
6505   case  2: is_signed ? load_signed_short(dst, src) : load_unsigned_short(dst, src); break;
6506   case  1: is_signed ? load_signed_byte( dst, src) : load_unsigned_byte( dst, src); break;



6507   default: ShouldNotReachHere();
6508   }
6509 }
6510 
6511 void MacroAssembler::mov32(AddressLiteral dst, Register src) {
6512   if (reachable(dst)) {
6513     movl(as_Address(dst), src);
6514   } else {
6515     lea(rscratch1, dst);
6516     movl(Address(rscratch1, 0), src);
6517   }
6518 }
6519 
6520 void MacroAssembler::mov32(Register dst, AddressLiteral src) {
6521   if (reachable(src)) {
6522     movl(dst, as_Address(src));
6523   } else {
6524     lea(rscratch1, src);
6525     movl(dst, Address(rscratch1, 0));
6526   }


7684 // registers on entry:
7685 //  - rax ('check' register): required MethodType
7686 //  - rcx: method handle
7687 //  - rdx, rsi, or ?: killable temp
7688 void MacroAssembler::check_method_handle_type(Register mtype_reg, Register mh_reg,
7689                                               Register temp_reg,
7690                                               Label& wrong_method_type) {
7691   if (UseCompressedOops)  unimplemented();  // field accesses must decode
7692   // compare method type against that of the receiver
7693   cmpptr(mtype_reg, Address(mh_reg, delayed_value(java_dyn_MethodHandle::type_offset_in_bytes, temp_reg)));
7694   jcc(Assembler::notEqual, wrong_method_type);
7695 }
7696 
7697 
7698 // A method handle has a "vmslots" field which gives the size of its
7699 // argument list in JVM stack slots.  This field is either located directly
7700 // in every method handle, or else is indirectly accessed through the
7701 // method handle's MethodType.  This macro hides the distinction.
7702 void MacroAssembler::load_method_handle_vmslots(Register vmslots_reg, Register mh_reg,
7703                                                 Register temp_reg) {
7704   assert_different_registers(vmslots_reg, mh_reg, temp_reg);
7705   if (UseCompressedOops)  unimplemented();  // field accesses must decode
7706   // load mh.type.form.vmslots
7707   if (java_dyn_MethodHandle::vmslots_offset_in_bytes() != 0) {
7708     // hoist vmslots into every mh to avoid dependent load chain
7709     movl(vmslots_reg, Address(mh_reg, delayed_value(java_dyn_MethodHandle::vmslots_offset_in_bytes, temp_reg)));
7710   } else {
7711     Register temp2_reg = vmslots_reg;
7712     movptr(temp2_reg, Address(mh_reg,    delayed_value(java_dyn_MethodHandle::type_offset_in_bytes, temp_reg)));
7713     movptr(temp2_reg, Address(temp2_reg, delayed_value(java_dyn_MethodType::form_offset_in_bytes, temp_reg)));
7714     movl(vmslots_reg, Address(temp2_reg, delayed_value(java_dyn_MethodTypeForm::vmslots_offset_in_bytes, temp_reg)));
7715   }
7716 }
7717 
7718 
7719 // registers on entry:
7720 //  - rcx: method handle
7721 //  - rdx: killable temp (interpreted only)
7722 //  - rax: killable temp (compiled only)
7723 void MacroAssembler::jump_to_method_handle_entry(Register mh_reg, Register temp_reg) {
7724   assert(mh_reg == rcx, "caller must put MH object in rcx");


src/cpu/x86/vm/assembler_x86.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File