public void layoutConstants() { for (CompilationResult compilation : compilations.values()) { for (DataSection.Data data : compilation.getDataSection()) { if (data instanceof SubstrateDataBuilder.ObjectData) { JavaConstant constant = ((SubstrateDataBuilder.ObjectData) data).getConstant(); constantReasons.put(constant, compilation.getName()); } } dataSection.addAll(compilation.getDataSection()); } dataSection.close(); }
@Override protected void emit(ByteBuffer buffer, Patches patches) { int position = buffer.position(); if (getSize() == Integer.BYTES) { buffer.putInt(0); } else if (getSize() == Long.BYTES) { buffer.putLong(0L); } else { shouldNotReachHere("Unsupported object constant reference size: " + getSize()); } patches.registerPatch(position, constant); } }
@Override public Data createDataItem(Constant constant) { int size; if (constant instanceof VMConstant) { assert constant instanceof SubstrateObjectConstant : "should be only VMConstant"; return new ObjectData((SubstrateObjectConstant) constant); } else if (JavaConstant.isNull(constant)) { if (SubstrateObjectConstant.isCompressed((JavaConstant) constant)) { size = ConfigurationValues.getObjectLayout().getReferenceSize(); } else { size = FrameAccess.uncompressedReferenceSize(); } return ZeroData.create(size, size); } else if (constant instanceof SerializableConstant) { SerializableConstant s = (SerializableConstant) constant; return new SerializableData(s); } else { throw new JVMCIError(String.valueOf(constant)); } }
public void addConstantsToHeap() { for (DataSection.Data data : dataSection) { if (data instanceof SubstrateDataBuilder.ObjectData) { JavaConstant constant = ((SubstrateDataBuilder.ObjectData) data).getConstant(); addConstantToHeap(constant); } } for (CompilationResult compilationResult : compilations.values()) { for (DataPatch patch : compilationResult.getDataPatches()) { if (patch.reference instanceof ConstantReference) { addConstantToHeap(((ConstantReference) patch.reference).getConstant()); } } } }