1.1 --- a/src/cpu/x86/vm/assembler_x86.cpp Fri Aug 31 16:39:35 2012 -0700 1.2 +++ b/src/cpu/x86/vm/assembler_x86.cpp Sat Sep 01 13:25:18 2012 -0400 1.3 @@ -57,6 +57,7 @@ 1.4 _target = target; 1.5 switch (rtype) { 1.6 case relocInfo::oop_type: 1.7 + case relocInfo::metadata_type: 1.8 // Oops are a special case. Normally they would be their own section 1.9 // but in cases like icBuffer they are literals in the code stream that 1.10 // we don't have a section for. We use none so that we get a literal address 1.11 @@ -154,10 +155,10 @@ 1.12 // Convert the raw encoding form into the form expected by the constructor for 1.13 // Address. An index of 4 (rsp) corresponds to having no index, so convert 1.14 // that to noreg for the Address constructor. 1.15 -Address Address::make_raw(int base, int index, int scale, int disp, bool disp_is_oop) { 1.16 +Address Address::make_raw(int base, int index, int scale, int disp, relocInfo::relocType disp_reloc) { 1.17 RelocationHolder rspec; 1.18 - if (disp_is_oop) { 1.19 - rspec = Relocation::spec_simple(relocInfo::oop_type); 1.20 + if (disp_reloc != relocInfo::none) { 1.21 + rspec = Relocation::spec_simple(disp_reloc); 1.22 } 1.23 bool valid_index = index != rsp->encoding(); 1.24 if (valid_index) { 1.25 @@ -270,17 +271,6 @@ 1.26 } 1.27 } 1.28 1.29 -void Assembler::emit_arith(int op1, int op2, Register dst, jobject obj) { 1.30 - LP64_ONLY(ShouldNotReachHere()); 1.31 - assert(isByte(op1) && isByte(op2), "wrong opcode"); 1.32 - assert((op1 & 0x01) == 1, "should be 32bit operation"); 1.33 - assert((op1 & 0x02) == 0, "sign-extension bit should not be set"); 1.34 - InstructionMark im(this); 1.35 - emit_byte(op1); 1.36 - emit_byte(op2 | encode(dst)); 1.37 - emit_data((intptr_t)obj, relocInfo::oop_type, 0); 1.38 -} 1.39 - 1.40 1.41 void Assembler::emit_arith(int op1, int op2, Register dst, Register src) { 1.42 assert(isByte(op1) && isByte(op2), "wrong opcode"); 1.43 @@ -5572,6 +5562,14 @@ 1.44 increment(rsp, number_of_arguments * wordSize); 1.45 } 1.46 1.47 +void MacroAssembler::cmpklass(Address src1, Metadata* obj) { 1.48 + cmp_literal32(src1, (int32_t)obj, metadata_Relocation::spec_for_immediate()); 1.49 +} 1.50 + 1.51 +void MacroAssembler::cmpklass(Register src1, Metadata* obj) { 1.52 + cmp_literal32(src1, (int32_t)obj, metadata_Relocation::spec_for_immediate()); 1.53 +} 1.54 + 1.55 void MacroAssembler::cmpoop(Address src1, jobject obj) { 1.56 cmp_literal32(src1, (int32_t)obj, oop_Relocation::spec_for_immediate()); 1.57 } 1.58 @@ -5753,6 +5751,14 @@ 1.59 mov_literal32(dst, (int32_t)obj, oop_Relocation::spec_for_immediate()); 1.60 } 1.61 1.62 +void MacroAssembler::mov_metadata(Register dst, Metadata* obj) { 1.63 + mov_literal32(dst, (int32_t)obj, metadata_Relocation::spec_for_immediate()); 1.64 +} 1.65 + 1.66 +void MacroAssembler::mov_metadata(Address dst, Metadata* obj) { 1.67 + mov_literal32(dst, (int32_t)obj, metadata_Relocation::spec_for_immediate()); 1.68 +} 1.69 + 1.70 void MacroAssembler::movptr(Register dst, AddressLiteral src) { 1.71 if (src.is_lval()) { 1.72 mov_literal32(dst, (intptr_t)src.target(), src.rspec()); 1.73 @@ -5804,6 +5810,9 @@ 1.74 push_literal32((int32_t)obj, oop_Relocation::spec_for_immediate()); 1.75 } 1.76 1.77 +void MacroAssembler::pushklass(Metadata* obj) { 1.78 + push_literal32((int32_t)obj, metadata_Relocation::spec_for_immediate()); 1.79 +} 1.80 1.81 void MacroAssembler::pushptr(AddressLiteral src) { 1.82 if (src.is_lval()) { 1.83 @@ -5856,13 +5865,13 @@ 1.84 if (os::message_box(msg, "Execution stopped, print registers?")) { 1.85 print_state32(rdi, rsi, rbp, rsp, rbx, rdx, rcx, rax, eip); 1.86 BREAKPOINT; 1.87 - assert(false, "start up GDB"); 1.88 } 1.89 } else { 1.90 ttyLocker ttyl; 1.91 ::tty->print_cr("=============== DEBUG MESSAGE: %s ================\n", msg); 1.92 + } 1.93 + // Don't assert holding the ttyLock 1.94 assert(false, err_msg("DEBUG MESSAGE: %s", msg)); 1.95 - } 1.96 ThreadStateTransition::transition(thread, _thread_in_vm, saved_state); 1.97 } 1.98 1.99 @@ -6280,6 +6289,15 @@ 1.100 movq(dst, rscratch1); 1.101 } 1.102 1.103 +void MacroAssembler::mov_metadata(Register dst, Metadata* obj) { 1.104 + mov_literal64(dst, (intptr_t)obj, metadata_Relocation::spec_for_immediate()); 1.105 +} 1.106 + 1.107 +void MacroAssembler::mov_metadata(Address dst, Metadata* obj) { 1.108 + mov_literal64(rscratch1, (intptr_t)obj, metadata_Relocation::spec_for_immediate()); 1.109 + movq(dst, rscratch1); 1.110 +} 1.111 + 1.112 void MacroAssembler::movptr(Register dst, AddressLiteral src) { 1.113 if (src.is_lval()) { 1.114 mov_literal64(dst, (intptr_t)src.target(), src.rspec()); 1.115 @@ -6321,6 +6339,11 @@ 1.116 push(rscratch1); 1.117 } 1.118 1.119 +void MacroAssembler::pushklass(Metadata* obj) { 1.120 + mov_metadata(rscratch1, obj); 1.121 + push(rscratch1); 1.122 +} 1.123 + 1.124 void MacroAssembler::pushptr(AddressLiteral src) { 1.125 lea(rscratch1, src); 1.126 if (src.is_lval()) { 1.127 @@ -6655,6 +6678,12 @@ 1.128 } 1.129 } 1.130 1.131 +void MacroAssembler::ic_call(address entry) { 1.132 + RelocationHolder rh = virtual_call_Relocation::spec(pc()); 1.133 + movptr(rax, (intptr_t)Universe::non_oop_word()); 1.134 + call(AddressLiteral(entry, rh)); 1.135 +} 1.136 + 1.137 // Implementation of call_VM versions 1.138 1.139 void MacroAssembler::call_VM(Register oop_result, 1.140 @@ -6923,9 +6952,7 @@ 1.141 1.142 // get oop result if there is one and reset the value in the thread 1.143 if (oop_result->is_valid()) { 1.144 - movptr(oop_result, Address(java_thread, JavaThread::vm_result_offset())); 1.145 - movptr(Address(java_thread, JavaThread::vm_result_offset()), NULL_WORD); 1.146 - verify_oop(oop_result, "broken oop in call_VM_base"); 1.147 + get_vm_result(oop_result, java_thread); 1.148 } 1.149 } 1.150 1.151 @@ -7016,6 +7043,17 @@ 1.152 MacroAssembler::call_VM_leaf_base(entry_point, 4); 1.153 } 1.154 1.155 +void MacroAssembler::get_vm_result(Register oop_result, Register java_thread) { 1.156 + movptr(oop_result, Address(java_thread, JavaThread::vm_result_offset())); 1.157 + movptr(Address(java_thread, JavaThread::vm_result_offset()), NULL_WORD); 1.158 + verify_oop(oop_result, "broken oop in call_VM_base"); 1.159 +} 1.160 + 1.161 +void MacroAssembler::get_vm_result_2(Register metadata_result, Register java_thread) { 1.162 + movptr(metadata_result, Address(java_thread, JavaThread::vm_result_2_offset())); 1.163 + movptr(Address(java_thread, JavaThread::vm_result_2_offset()), NULL_WORD); 1.164 +} 1.165 + 1.166 void MacroAssembler::check_and_handle_earlyret(Register java_thread) { 1.167 } 1.168 1.169 @@ -9097,20 +9135,20 @@ 1.170 "caller must use same register for non-constant itable index as for method"); 1.171 1.172 // Compute start of first itableOffsetEntry (which is at the end of the vtable) 1.173 - int vtable_base = instanceKlass::vtable_start_offset() * wordSize; 1.174 + int vtable_base = InstanceKlass::vtable_start_offset() * wordSize; 1.175 int itentry_off = itableMethodEntry::method_offset_in_bytes(); 1.176 int scan_step = itableOffsetEntry::size() * wordSize; 1.177 int vte_size = vtableEntry::size() * wordSize; 1.178 Address::ScaleFactor times_vte_scale = Address::times_ptr; 1.179 assert(vte_size == wordSize, "else adjust times_vte_scale"); 1.180 1.181 - movl(scan_temp, Address(recv_klass, instanceKlass::vtable_length_offset() * wordSize)); 1.182 + movl(scan_temp, Address(recv_klass, InstanceKlass::vtable_length_offset() * wordSize)); 1.183 1.184 // %%% Could store the aligned, prescaled offset in the klassoop. 1.185 lea(scan_temp, Address(recv_klass, scan_temp, times_vte_scale, vtable_base)); 1.186 if (HeapWordsPerLong > 1) { 1.187 // Round up to align_object_offset boundary 1.188 - // see code for instanceKlass::start_of_itable! 1.189 + // see code for InstanceKlass::start_of_itable! 1.190 round_to(scan_temp, BytesPerLong); 1.191 } 1.192 1.193 @@ -9160,7 +9198,7 @@ 1.194 void MacroAssembler::lookup_virtual_method(Register recv_klass, 1.195 RegisterOrConstant vtable_index, 1.196 Register method_result) { 1.197 - const int base = instanceKlass::vtable_start_offset() * wordSize; 1.198 + const int base = InstanceKlass::vtable_start_offset() * wordSize; 1.199 assert(vtableEntry::size() * wordSize == wordSize, "else adjust the scaling in the code below"); 1.200 Address vtable_entry_addr(recv_klass, 1.201 vtable_index, Address::times_ptr, 1.202 @@ -9335,33 +9373,19 @@ 1.203 // We will consult the secondary-super array. 1.204 movptr(rdi, secondary_supers_addr); 1.205 // Load the array length. (Positive movl does right thing on LP64.) 1.206 - movl(rcx, Address(rdi, arrayOopDesc::length_offset_in_bytes())); 1.207 + movl(rcx, Address(rdi, Array<Klass*>::length_offset_in_bytes())); 1.208 // Skip to start of data. 1.209 - addptr(rdi, arrayOopDesc::base_offset_in_bytes(T_OBJECT)); 1.210 + addptr(rdi, Array<Klass*>::base_offset_in_bytes()); 1.211 1.212 // Scan RCX words at [RDI] for an occurrence of RAX. 1.213 // Set NZ/Z based on last compare. 1.214 // Z flag value will not be set by 'repne' if RCX == 0 since 'repne' does 1.215 // not change flags (only scas instruction which is repeated sets flags). 1.216 // Set Z = 0 (not equal) before 'repne' to indicate that class was not found. 1.217 -#ifdef _LP64 1.218 - // This part is tricky, as values in supers array could be 32 or 64 bit wide 1.219 - // and we store values in objArrays always encoded, thus we need to encode 1.220 - // the value of rax before repne. Note that rax is dead after the repne. 1.221 - if (UseCompressedOops) { 1.222 - encode_heap_oop_not_null(rax); // Changes flags. 1.223 - // The superclass is never null; it would be a basic system error if a null 1.224 - // pointer were to sneak in here. Note that we have already loaded the 1.225 - // Klass::super_check_offset from the super_klass in the fast path, 1.226 - // so if there is a null in that register, we are already in the afterlife. 1.227 - testl(rax,rax); // Set Z = 0 1.228 - repne_scanl(); 1.229 - } else 1.230 -#endif // _LP64 1.231 - { 1.232 + 1.233 testptr(rax,rax); // Set Z = 0 1.234 repne_scan(); 1.235 - } 1.236 + 1.237 // Unspill the temp. registers: 1.238 if (pushed_rdi) pop(rdi); 1.239 if (pushed_rcx) pop(rcx); 1.240 @@ -9907,7 +9931,7 @@ 1.241 1.242 void MacroAssembler::load_klass(Register dst, Register src) { 1.243 #ifdef _LP64 1.244 - if (UseCompressedOops) { 1.245 + if (UseCompressedKlassPointers) { 1.246 movl(dst, Address(src, oopDesc::klass_offset_in_bytes())); 1.247 decode_heap_oop_not_null(dst); 1.248 } else 1.249 @@ -9917,7 +9941,7 @@ 1.250 1.251 void MacroAssembler::load_prototype_header(Register dst, Register src) { 1.252 #ifdef _LP64 1.253 - if (UseCompressedOops) { 1.254 + if (UseCompressedKlassPointers) { 1.255 assert (Universe::heap() != NULL, "java heap should be initialized"); 1.256 movl(dst, Address(src, oopDesc::klass_offset_in_bytes())); 1.257 if (Universe::narrow_oop_shift() != 0) { 1.258 @@ -9942,7 +9966,7 @@ 1.259 1.260 void MacroAssembler::store_klass(Register dst, Register src) { 1.261 #ifdef _LP64 1.262 - if (UseCompressedOops) { 1.263 + if (UseCompressedKlassPointers) { 1.264 encode_heap_oop_not_null(src); 1.265 movl(Address(dst, oopDesc::klass_offset_in_bytes()), src); 1.266 } else 1.267 @@ -9952,6 +9976,7 @@ 1.268 1.269 void MacroAssembler::load_heap_oop(Register dst, Address src) { 1.270 #ifdef _LP64 1.271 + // FIXME: Must change all places where we try to load the klass. 1.272 if (UseCompressedOops) { 1.273 movl(dst, src); 1.274 decode_heap_oop(dst); 1.275 @@ -10016,7 +10041,7 @@ 1.276 1.277 #ifdef _LP64 1.278 void MacroAssembler::store_klass_gap(Register dst, Register src) { 1.279 - if (UseCompressedOops) { 1.280 + if (UseCompressedKlassPointers) { 1.281 // Store to klass gap in destination 1.282 movl(Address(dst, oopDesc::klass_gap_offset_in_bytes()), src); 1.283 }