Mercurial > hg > graal-compiler
changeset 17448:a38357f170c0
Make data section patching extensible.
author | Roland Schatz <roland.schatz@oracle.com> |
---|---|
date | Wed, 15 Oct 2014 11:39:14 +0200 |
parents | f861021b49b8 |
children | cca154b1bf91 |
files | graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/data/DataSection.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/data/PatchedData.java |
diffstat | 2 files changed, 34 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- 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<DataPatch> it = PatchedData.getPatches(d, index).iterator(); + while (it.hasNext()) { + patches[patchIndex++] = it.next(); } + dataPatch.data = reference; index += d.getSize(target);
--- 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<DataPatch> 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<DataPatch> getPatches(Data data, int offset) { + if (data instanceof PatchedData) { + return ((PatchedData) data).getPatches(offset); + } else { + return Stream.empty(); + } + } }