# HG changeset patch # User Roland Schatz # Date 1413365954 -7200 # Node ID a38357f170c0db9863e7712a7eb60f7fe56f8346 # Parent f861021b49b8960274aa924b79e68ead4abdbced Make data section patching extensible. diff -r f861021b49b8 -r a38357f170c0 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/data/DataSection.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/data/DataSection.java Wed Oct 15 11:04:45 2014 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/data/DataSection.java Wed Oct 15 11:39:14 2014 +0200 @@ -70,9 +70,7 @@ if (existingPos == null) { size = NumUtil.roundUp(size, d.getAlignment()); size += d.getSize(target); - if (d instanceof PatchedData) { - patchCount++; - } + patchCount += PatchedData.getPatchCount(d); dataMap.put(d, externalDataList.size()); } externalDataList.add(dataPatch); @@ -100,10 +98,13 @@ buffer.position(index); DataSectionReference reference = new DataSectionReference(index); - if (d instanceof PatchedData) { - // record patch location - patches[patchIndex++] = new DataPatch(index, d, true); + + // record patch locations + Iterator it = PatchedData.getPatches(d, index).iterator(); + while (it.hasNext()) { + patches[patchIndex++] = it.next(); } + dataPatch.data = reference; index += d.getSize(target); diff -r f861021b49b8 -r a38357f170c0 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/data/PatchedData.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/data/PatchedData.java Wed Oct 15 11:04:45 2014 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/data/PatchedData.java Wed Oct 15 11:39:14 2014 +0200 @@ -22,7 +22,10 @@ */ package com.oracle.graal.hotspot.data; +import java.util.stream.*; + import com.oracle.graal.api.code.CompilationResult.Data; +import com.oracle.graal.api.code.CompilationResult.DataPatch; /** * Represents a data item that needs to be patched. @@ -32,4 +35,28 @@ protected PatchedData(int alignment) { super(alignment); } + + public int getPatchCount() { + return 1; + } + + public Stream getPatches(int offset) { + return Stream.of(new DataPatch(offset, this, true)); + } + + public static int getPatchCount(Data data) { + if (data instanceof PatchedData) { + return ((PatchedData) data).getPatchCount(); + } else { + return 0; + } + } + + public static Stream getPatches(Data data, int offset) { + if (data instanceof PatchedData) { + return ((PatchedData) data).getPatches(offset); + } else { + return Stream.empty(); + } + } }