1127 Value *SharkTopLevelBlock::get_direct_callee(ciMethod* method) { 1128 return builder()->CreateBitCast( 1129 builder()->CreateInlineMetadata(method, SharkType::Method_type()), 1130 SharkType::Method_type(), 1131 "callee"); 1132 } 1133 1134 Value *SharkTopLevelBlock::get_virtual_callee(SharkValue* receiver, 1135 int vtable_index) { 1136 Value *klass = builder()->CreateValueOfStructEntry( 1137 receiver->jobject_value(), 1138 in_ByteSize(oopDesc::klass_offset_in_bytes()), 1139 SharkType::oop_type(), 1140 "klass"); 1141 1142 return builder()->CreateLoad( 1143 builder()->CreateArrayAddress( 1144 klass, 1145 SharkType::Method_type(), 1146 vtableEntry::size_in_bytes(), 1147 InstanceKlass::vtable_start_offset(), 1148 LLVMValue::intptr_constant(vtable_index)), 1149 "callee"); 1150 } 1151 1152 Value* SharkTopLevelBlock::get_interface_callee(SharkValue *receiver, 1153 ciMethod* method) { 1154 BasicBlock *loop = function()->CreateBlock("loop"); 1155 BasicBlock *got_null = function()->CreateBlock("got_null"); 1156 BasicBlock *not_null = function()->CreateBlock("not_null"); 1157 BasicBlock *next = function()->CreateBlock("next"); 1158 BasicBlock *got_entry = function()->CreateBlock("got_entry"); 1159 1160 // Locate the receiver's itable 1161 Value *object_klass = builder()->CreateValueOfStructEntry( 1162 receiver->jobject_value(), in_ByteSize(oopDesc::klass_offset_in_bytes()), 1163 SharkType::klass_type(), 1164 "object_klass"); 1165 1166 Value *vtable_start = builder()->CreateAdd( 1167 builder()->CreatePtrToInt(object_klass, SharkType::intptr_type()), 1168 LLVMValue::intptr_constant( 1169 in_bytes(InstanceKlass::vtable_start_offset())), 1170 "vtable_start"); 1171 1172 Value *vtable_length = builder()->CreateValueOfStructEntry( 1173 object_klass, 1174 InstanceKlass::vtable_length_offset(), 1175 SharkType::jint_type(), 1176 "vtable_length"); 1177 vtable_length = 1178 builder()->CreateIntCast(vtable_length, SharkType::intptr_type(), false); 1179 1180 bool needs_aligning = HeapWordsPerLong > 1; 1181 Value *itable_start = builder()->CreateAdd( 1182 vtable_start, 1183 builder()->CreateShl( 1184 vtable_length, 1185 LLVMValue::intptr_constant(exact_log2(vtableEntry::size_in_bytes()))), 1186 needs_aligning ? "" : "itable_start"); 1187 if (needs_aligning) { 1188 itable_start = builder()->CreateAnd( 1189 builder()->CreateAdd( 1190 itable_start, LLVMValue::intptr_constant(BytesPerLong - 1)), 1191 LLVMValue::intptr_constant(~(BytesPerLong - 1)), 1192 "itable_start"); 1193 } 1194 | 1127 Value *SharkTopLevelBlock::get_direct_callee(ciMethod* method) { 1128 return builder()->CreateBitCast( 1129 builder()->CreateInlineMetadata(method, SharkType::Method_type()), 1130 SharkType::Method_type(), 1131 "callee"); 1132 } 1133 1134 Value *SharkTopLevelBlock::get_virtual_callee(SharkValue* receiver, 1135 int vtable_index) { 1136 Value *klass = builder()->CreateValueOfStructEntry( 1137 receiver->jobject_value(), 1138 in_ByteSize(oopDesc::klass_offset_in_bytes()), 1139 SharkType::oop_type(), 1140 "klass"); 1141 1142 return builder()->CreateLoad( 1143 builder()->CreateArrayAddress( 1144 klass, 1145 SharkType::Method_type(), 1146 vtableEntry::size_in_bytes(), 1147 Klass::vtable_start_offset(), 1148 LLVMValue::intptr_constant(vtable_index)), 1149 "callee"); 1150 } 1151 1152 Value* SharkTopLevelBlock::get_interface_callee(SharkValue *receiver, 1153 ciMethod* method) { 1154 BasicBlock *loop = function()->CreateBlock("loop"); 1155 BasicBlock *got_null = function()->CreateBlock("got_null"); 1156 BasicBlock *not_null = function()->CreateBlock("not_null"); 1157 BasicBlock *next = function()->CreateBlock("next"); 1158 BasicBlock *got_entry = function()->CreateBlock("got_entry"); 1159 1160 // Locate the receiver's itable 1161 Value *object_klass = builder()->CreateValueOfStructEntry( 1162 receiver->jobject_value(), in_ByteSize(oopDesc::klass_offset_in_bytes()), 1163 SharkType::klass_type(), 1164 "object_klass"); 1165 1166 Value *vtable_start = builder()->CreateAdd( 1167 builder()->CreatePtrToInt(object_klass, SharkType::intptr_type()), 1168 LLVMValue::intptr_constant( 1169 in_bytes(Klass::vtable_start_offset())), 1170 "vtable_start"); 1171 1172 Value *vtable_length = builder()->CreateValueOfStructEntry( 1173 object_klass, 1174 Klass::vtable_length_offset(), 1175 SharkType::jint_type(), 1176 "vtable_length"); 1177 vtable_length = 1178 builder()->CreateIntCast(vtable_length, SharkType::intptr_type(), false); 1179 1180 bool needs_aligning = HeapWordsPerLong > 1; 1181 Value *itable_start = builder()->CreateAdd( 1182 vtable_start, 1183 builder()->CreateShl( 1184 vtable_length, 1185 LLVMValue::intptr_constant(exact_log2(vtableEntry::size_in_bytes()))), 1186 needs_aligning ? "" : "itable_start"); 1187 if (needs_aligning) { 1188 itable_start = builder()->CreateAnd( 1189 builder()->CreateAdd( 1190 itable_start, LLVMValue::intptr_constant(BytesPerLong - 1)), 1191 LLVMValue::intptr_constant(~(BytesPerLong - 1)), 1192 "itable_start"); 1193 } 1194 |