# HG changeset patch # User Christian Wimmer # Date 1442365991 25200 # Node ID a7c7901367ed43fb0e2e2b5781382755179ccd06 # Parent c345ad3a1cbb33587482209d5a0b106948c06f4e# Parent 118f9560e0ea904530d591e9c81440694d28fc43 Merge diff -r c345ad3a1cbb -r a7c7901367ed jvmci/jdk.internal.jvmci.code/src/jdk/internal/jvmci/code/DataSection.java --- a/jvmci/jdk.internal.jvmci.code/src/jdk/internal/jvmci/code/DataSection.java Wed Sep 16 01:04:47 2015 +0200 +++ b/jvmci/jdk.internal.jvmci.code/src/jdk/internal/jvmci/code/DataSection.java Tue Sep 15 18:13:11 2015 -0700 @@ -176,11 +176,27 @@ */ public DataSectionReference insertData(Data data) { assert !finalLayout; - if (data.ref == null) { - data.ref = new DataSectionReference(); + synchronized (data) { + if (data.ref == null) { + data.ref = new DataSectionReference(); + dataItems.add(data); + } + return data.ref; + } + } + + /** + * Transfers all {@link Data} from the provided other {@link DataSection} to this + * {@link DataSection}, and empties the other section. + */ + public void addAll(DataSection other) { + assert !finalLayout && !other.finalLayout; + + for (Data data : other.dataItems) { + assert data.ref != null; dataItems.add(data); } - return data.ref; + other.dataItems.clear(); } /** @@ -195,14 +211,16 @@ dataItems.sort((a, b) -> a.alignment - b.alignment); int position = 0; + int alignment = 1; for (Data d : dataItems) { - sectionAlignment = lcm(sectionAlignment, d.alignment); + alignment = lcm(alignment, d.alignment); position = align(position, d.alignment); d.ref.setOffset(position); position += d.size; } + sectionAlignment = alignment; sectionSize = position; }