@Override public long getMemorySize(JavaConstant constant) { if (constant.getJavaKind() == JavaKind.Object) { HotSpotResolvedObjectType lookupJavaType = lookupJavaType(constant); if (lookupJavaType == null) { return 0; } else { if (lookupJavaType.isArray()) { // TODO(tw): Add compressed pointer support. int length = Array.getLength(((HotSpotObjectConstantImpl) constant).object()); ResolvedJavaType elementType = lookupJavaType.getComponentType(); JavaKind elementKind = elementType.getJavaKind(); final int headerSize = getArrayBaseOffset(elementKind); TargetDescription target = runtime.getHostJVMCIBackend().getTarget(); int sizeOfElement = getArrayIndexScale(elementKind); int alignment = target.wordSize; int log2ElementSize = CodeUtil.log2(sizeOfElement); return computeArrayAllocationSize(length, alignment, headerSize, log2ElementSize); } return lookupJavaType.instanceSize(); } } else { return constant.getJavaKind().getByteCount(); } }
private ParameterNode[] createParameters(GraphKit kit, Class<?>[] args) { ParameterNode[] params = new ParameterNode[args.length]; ResolvedJavaType accessingClass = providers.getMetaAccess().lookupJavaType(getClass()); for (int i = 0; i < args.length; i++) { ResolvedJavaType type = providers.getMetaAccess().lookupJavaType(args[i]).resolve(accessingClass); Stamp stamp; if (type.getJavaKind().getStackKind() == JavaKind.Object) { stamp = StampFactory.declared(type); } else { stamp = StampFactory.forKind(type.getJavaKind()); } ParameterNode param = kit.unique(new ParameterNode(i, stamp)); params[i] = param; } return params; }