Skip to content

Commit 6dc8666

Browse files
committedJun 11, 2014
Add NonReplicating connections.
1 parent 011bed4 commit 6dc8666

File tree

6 files changed

+50
-7
lines changed

6 files changed

+50
-7
lines changed
 
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
* This file is part of the Jikes RVM project (http://jikesrvm.org).
3+
*
4+
* This file is licensed to You under the Eclipse Public License (EPL);
5+
* You may not use this file except in compliance with the License. You
6+
* may obtain a copy of the License at
7+
*
8+
* http://www.opensource.org/licenses/eclipse-1.0.php
9+
*
10+
* See the COPYRIGHT.txt file distributed with this work for information
11+
* regarding copyright ownership.
12+
*/
13+
package org.vmmagic.pragma;
14+
15+
import java.lang.annotation.Retention;
16+
import java.lang.annotation.Target;
17+
import java.lang.annotation.RetentionPolicy;
18+
import java.lang.annotation.ElementType;
19+
20+
/**
21+
* Use this annotation to mark methods for which all allocation must never be in
22+
* a MirrorGC replicated space because the allocated objects are written to
23+
* directly bypassing write barriers
24+
*/
25+
@Retention(RetentionPolicy.RUNTIME)
26+
@Target(ElementType.METHOD)
27+
public @interface NonReplicatingAllocation { }

‎rvm/src/org/jikesrvm/CommandLineArgs.java

+5-7
Original file line numberDiff line numberDiff line change
@@ -825,25 +825,21 @@ private static final class ArgReader {
825825
// reallocation really soon.
826826
int buflen = 512;
827827

828-
byte[] buf; // gets freed with the class instance.
829-
830-
ArgReader() {
831-
buf = new byte[buflen];
832-
}
833-
834828
/** Read argument # @param i
835829
* Assume arguments are encoded in the platform's
836830
* "default character set". */
837831
@SuppressWarnings({"deprecation"})
832+
@NonReplicatingAllocation
838833
String getArg(int i) {
839834
int cnt;
835+
byte[] buf = new byte[buflen]; // buf needs to allocated in Non replicated space to ensure correctness
840836
for (; ;) {
841837
cnt = sysArg(i, buf);
842838
if (cnt >= 0) {
843839
break;
844840
}
845841
buflen += 1024;
846-
buf = new byte[buflen];
842+
buf = new byte[buflen]; // buf needs to allocated in Non replicated space to ensure correctness
847843
}
848844
if (VM.VerifyAssertions) VM._assert(cnt != -1);
849845
/*
@@ -868,7 +864,9 @@ String getArg(int i) {
868864
return new String(buf, 0, 0, cnt);
869865
}
870866

867+
@NonReplicatingAllocation
871868
int numArgs() {
869+
byte[] buf = new byte[buflen]; // buf needs to allocated in Non replicated space to ensure correctness
872870
return sysArg(-1, buf);
873871
}
874872
}

‎rvm/src/org/jikesrvm/classloader/AnnotatedElement.java

+8
Original file line numberDiff line numberDiff line change
@@ -380,4 +380,12 @@ public final boolean hasNonMovingAnnotation() {
380380
public final boolean hasNonMovingAllocationAnnotation() {
381381
return isAnnotationDeclared(TypeReference.NonMovingAllocation);
382382
}
383+
384+
/**
385+
* Return true if this element has a NonReplicatingAllocation annotation.
386+
* @see org.vmmagic.pragma.NonReplicatingAllocation
387+
*/
388+
public final boolean hasNonReplicatingAllocationAnnotation() {
389+
return isAnnotationDeclared(TypeReference.NonReplicatingAllocation);
390+
}
383391
}

‎rvm/src/org/jikesrvm/classloader/RVMMethod.java

+7
Original file line numberDiff line numberDiff line change
@@ -677,6 +677,13 @@ public boolean isNonMovingAllocation() {
677677
return hasNonMovingAllocationAnnotation();
678678
}
679679

680+
/**
681+
* Should all allocation from this method go to a non-replicated space?
682+
*/
683+
public boolean isNonReplicatingAllocation() {
684+
return hasNonReplicatingAllocationAnnotation();
685+
}
686+
680687
//------------------------------------------------------------------//
681688
// Section 2. //
682689
// The following are available after the declaring class has been //

‎rvm/src/org/jikesrvm/classloader/TypeReference.java

+1
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ public final class TypeReference {
172172
public static final TypeReference Untraced = findOrCreate(org.vmmagic.pragma.Untraced.class);
173173
public static final TypeReference NonMoving = findOrCreate(org.vmmagic.pragma.NonMoving.class);
174174
public static final TypeReference NonMovingAllocation = findOrCreate(org.vmmagic.pragma.NonMovingAllocation.class);
175+
public static final TypeReference NonReplicatingAllocation = findOrCreate(org.vmmagic.pragma.NonReplicatingAllocation.class);
175176
public static final TypeReference BaselineNoRegisters = findOrCreate(org.vmmagic.pragma.BaselineNoRegisters.class);
176177
public static final TypeReference BaselineSaveLSRegisters = findOrCreate(org.vmmagic.pragma.BaselineSaveLSRegisters.class);
177178
public static final TypeReference ReferenceFieldsVary = findOrCreate(org.vmmagic.pragma.ReferenceFieldsVary.class);

‎rvm/src/org/jikesrvm/compilers/baseline/EdgeCounts.java

+2
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import org.jikesrvm.classloader.NormalMethod;
2626
import org.jikesrvm.runtime.Magic;
2727
import org.vmmagic.pragma.Entrypoint;
28+
import org.vmmagic.pragma.NonReplicatingAllocation;
2829

2930
/**
3031
* A repository of edge counters for bytecode-level edge conditional branches.
@@ -93,6 +94,7 @@ public static synchronized void allocateCounters(NormalMethod m, int numEntries)
9394
allocateCounters(m.getId(), numEntries);
9495
}
9596

97+
@NonReplicatingAllocation
9698
private static synchronized void allocateCounters(int id, int numEntries) {
9799
if (data == null) {
98100
data = new int[id + 500][];

0 commit comments

Comments
 (0)
Please sign in to comment.