67 68 case Assembler::arith_op: 69 #ifdef ASSERT 70 switch (Assembler::inv_op3(inst)) { 71 case Assembler::or_op3: 72 case Assembler::add_op3: 73 case Assembler::jmpl_op3: 74 break; 75 default: 76 ShouldNotReachHere(); 77 } 78 do_non_sethi:; 79 #endif 80 { 81 guarantee(Assembler::inv_immed(inst), "must have a simm13 field"); 82 int simm13 = Assembler::low10((intptr_t)x) + o; 83 guarantee(Assembler::is_simm13(simm13), "offset can't overflow simm13"); 84 inst &= ~Assembler::simm( -1, 13); 85 inst |= Assembler::simm(simm13, 13); 86 if (verify_only) { 87 assert(ip->long_at(0) == inst, "instructions must match"); 88 } else { 89 ip->set_long_at(0, inst); 90 } 91 } 92 break; 93 94 case Assembler::branch_op: 95 { 96 #ifdef _LP64 97 jint inst2; 98 guarantee(Assembler::inv_op2(inst)==Assembler::sethi_op2, "must be sethi"); 99 if (format() != 0) { 100 assert(type() == relocInfo::oop_type || type() == relocInfo::metadata_type, "only narrow oops or klasses case"); 101 jint np = type() == relocInfo::oop_type ? oopDesc::encode_heap_oop((oop)x) : Klass::encode_klass((Klass*)x); 102 inst &= ~Assembler::hi22(-1); 103 inst |= Assembler::hi22((intptr_t)np); 104 if (verify_only) { 105 assert(ip->long_at(0) == inst, "instructions must match"); 106 } else { 107 ip->set_long_at(0, inst); 108 } 109 inst2 = ip->long_at( NativeInstruction::nop_instruction_size ); 110 guarantee(Assembler::inv_op(inst2)==Assembler::arith_op, "arith op"); 111 if (verify_only) { 112 assert(ip->long_at(NativeInstruction::nop_instruction_size) == NativeInstruction::set_data32_simm13( inst2, (intptr_t)np), 113 "instructions must match"); 114 } else { 115 ip->set_long_at(NativeInstruction::nop_instruction_size, NativeInstruction::set_data32_simm13( inst2, (intptr_t)np)); 116 } 117 break; 118 } 119 if (verify_only) { 120 ip->verify_data64_sethi( ip->addr_at(0), (intptr_t)x ); 121 } else { 122 ip->set_data64_sethi( ip->addr_at(0), (intptr_t)x ); 123 } 124 #else 125 guarantee(Assembler::inv_op2(inst)==Assembler::sethi_op2, "must be sethi"); 126 inst &= ~Assembler::hi22( -1); 127 inst |= Assembler::hi22((intptr_t)x); 128 // (ignore offset; it doesn't play into the sethi) 129 if (verify_only) { 130 assert(ip->long_at(0) == inst, "instructions must match"); 131 } else { 132 ip->set_long_at(0, inst); 133 } 134 #endif 135 } 136 break; 137 138 default: 139 guarantee(false, "instruction must perform arithmetic or memory access"); 140 } 141 } 142 143 144 address Relocation::pd_call_destination(address orig_addr) { 145 intptr_t adj = 0; 146 if (orig_addr != NULL) { 147 // We just moved this call instruction from orig_addr to addr(). 148 // This means its target will appear to have grown by addr() - orig_addr. 149 adj = -( addr() - orig_addr ); 150 } | 67 68 case Assembler::arith_op: 69 #ifdef ASSERT 70 switch (Assembler::inv_op3(inst)) { 71 case Assembler::or_op3: 72 case Assembler::add_op3: 73 case Assembler::jmpl_op3: 74 break; 75 default: 76 ShouldNotReachHere(); 77 } 78 do_non_sethi:; 79 #endif 80 { 81 guarantee(Assembler::inv_immed(inst), "must have a simm13 field"); 82 int simm13 = Assembler::low10((intptr_t)x) + o; 83 guarantee(Assembler::is_simm13(simm13), "offset can't overflow simm13"); 84 inst &= ~Assembler::simm( -1, 13); 85 inst |= Assembler::simm(simm13, 13); 86 if (verify_only) { 87 guarantee(ip->long_at(0) == inst, "instructions must match"); 88 } else { 89 ip->set_long_at(0, inst); 90 } 91 } 92 break; 93 94 case Assembler::branch_op: 95 { 96 #ifdef _LP64 97 jint inst2; 98 guarantee(Assembler::inv_op2(inst)==Assembler::sethi_op2, "must be sethi"); 99 if (format() != 0) { 100 assert(type() == relocInfo::oop_type || type() == relocInfo::metadata_type, "only narrow oops or klasses case"); 101 jint np = type() == relocInfo::oop_type ? oopDesc::encode_heap_oop((oop)x) : Klass::encode_klass((Klass*)x); 102 inst &= ~Assembler::hi22(-1); 103 inst |= Assembler::hi22((intptr_t)np); 104 if (verify_only) { 105 guarantee(ip->long_at(0) == inst, "instructions must match"); 106 } else { 107 ip->set_long_at(0, inst); 108 } 109 inst2 = ip->long_at( NativeInstruction::nop_instruction_size ); 110 guarantee(Assembler::inv_op(inst2)==Assembler::arith_op, "arith op"); 111 if (verify_only) { 112 guarantee(ip->long_at(NativeInstruction::nop_instruction_size) == NativeInstruction::set_data32_simm13( inst2, (intptr_t)np), 113 "instructions must match"); 114 } else { 115 ip->set_long_at(NativeInstruction::nop_instruction_size, NativeInstruction::set_data32_simm13( inst2, (intptr_t)np)); 116 } 117 break; 118 } 119 if (verify_only) { 120 ip->verify_data64_sethi( ip->addr_at(0), (intptr_t)x ); 121 } else { 122 ip->set_data64_sethi( ip->addr_at(0), (intptr_t)x ); 123 } 124 #else 125 guarantee(Assembler::inv_op2(inst)==Assembler::sethi_op2, "must be sethi"); 126 inst &= ~Assembler::hi22( -1); 127 inst |= Assembler::hi22((intptr_t)x); 128 // (ignore offset; it doesn't play into the sethi) 129 if (verify_only) { 130 guarantee(ip->long_at(0) == inst, "instructions must match"); 131 } else { 132 ip->set_long_at(0, inst); 133 } 134 #endif 135 } 136 break; 137 138 default: 139 guarantee(false, "instruction must perform arithmetic or memory access"); 140 } 141 } 142 143 144 address Relocation::pd_call_destination(address orig_addr) { 145 intptr_t adj = 0; 146 if (orig_addr != NULL) { 147 // We just moved this call instruction from orig_addr to addr(). 148 // This means its target will appear to have grown by addr() - orig_addr. 149 adj = -( addr() - orig_addr ); 150 } |