521 HotSpotResolvedJavaMethodImpl newMethod = new HotSpotResolvedJavaMethodImpl(this, metaspaceMethod);
522 methodCacheHashMap.put(metaspaceMethod, newMethod);
523 context.add(lookupResult);
524 return newMethod;
525 } else {
526 return lookupResult;
527 }
528 }
529
530 public int getVtableLength() {
531 HotSpotVMConfig config = config();
532 if (isInterface() || isArray()) {
533 /* Everything has the core vtable of java.lang.Object */
534 return config.baseVtableLength();
535 }
536 int result = UNSAFE.getInt(getMetaspaceKlass() + config.klassVtableLengthOffset) / (config.vtableEntrySize / config.heapWordSize);
537 assert result >= config.baseVtableLength() : UNSAFE.getInt(getMetaspaceKlass() + config.klassVtableLengthOffset) + " " + config.vtableEntrySize;
538 return result;
539 }
540
541 synchronized HotSpotResolvedJavaField createField(JavaType type, long offset, int rawFlags, int index) {
542 return new HotSpotResolvedJavaFieldImpl(this, type, offset, rawFlags, index);
543 }
544
545 @Override
546 public AssumptionResult<ResolvedJavaMethod> findUniqueConcreteMethod(ResolvedJavaMethod method) {
547 HotSpotResolvedJavaMethod hmethod = (HotSpotResolvedJavaMethod) method;
548 HotSpotResolvedObjectType declaredHolder = hmethod.getDeclaringClass();
549 /*
550 * Sometimes the receiver type in the graph hasn't stabilized to a subtype of declared
551 * holder, usually because of phis, so make sure that the type is related to the declared
552 * type before using it for lookup. Unlinked types should also be ignored because we can't
553 * resolve the proper method to invoke. Generally unlinked types in invokes should result in
554 * a deopt instead since they can't really be used if they aren't linked yet.
555 */
556 if (!declaredHolder.isAssignableFrom(this) || this.isArray() || this.equals(declaredHolder) || !isLinked() || isInterface()) {
557 ResolvedJavaMethod result = hmethod.uniqueConcreteMethod(declaredHolder);
558 if (result != null) {
559 return new AssumptionResult<>(result, new ConcreteMethod(method, declaredHolder, result));
560 }
561 return null;
|
521 HotSpotResolvedJavaMethodImpl newMethod = new HotSpotResolvedJavaMethodImpl(this, metaspaceMethod);
522 methodCacheHashMap.put(metaspaceMethod, newMethod);
523 context.add(lookupResult);
524 return newMethod;
525 } else {
526 return lookupResult;
527 }
528 }
529
530 public int getVtableLength() {
531 HotSpotVMConfig config = config();
532 if (isInterface() || isArray()) {
533 /* Everything has the core vtable of java.lang.Object */
534 return config.baseVtableLength();
535 }
536 int result = UNSAFE.getInt(getMetaspaceKlass() + config.klassVtableLengthOffset) / (config.vtableEntrySize / config.heapWordSize);
537 assert result >= config.baseVtableLength() : UNSAFE.getInt(getMetaspaceKlass() + config.klassVtableLengthOffset) + " " + config.vtableEntrySize;
538 return result;
539 }
540
541 HotSpotResolvedJavaField createField(JavaType type, long offset, int rawFlags, int index) {
542 return new HotSpotResolvedJavaFieldImpl(this, type, offset, rawFlags, index);
543 }
544
545 @Override
546 public AssumptionResult<ResolvedJavaMethod> findUniqueConcreteMethod(ResolvedJavaMethod method) {
547 HotSpotResolvedJavaMethod hmethod = (HotSpotResolvedJavaMethod) method;
548 HotSpotResolvedObjectType declaredHolder = hmethod.getDeclaringClass();
549 /*
550 * Sometimes the receiver type in the graph hasn't stabilized to a subtype of declared
551 * holder, usually because of phis, so make sure that the type is related to the declared
552 * type before using it for lookup. Unlinked types should also be ignored because we can't
553 * resolve the proper method to invoke. Generally unlinked types in invokes should result in
554 * a deopt instead since they can't really be used if they aren't linked yet.
555 */
556 if (!declaredHolder.isAssignableFrom(this) || this.isArray() || this.equals(declaredHolder) || !isLinked() || isInterface()) {
557 ResolvedJavaMethod result = hmethod.uniqueConcreteMethod(declaredHolder);
558 if (result != null) {
559 return new AssumptionResult<>(result, new ConcreteMethod(method, declaredHolder, result));
560 }
561 return null;
|