Skip to content

Commit

Permalink
Minor refactorings and preparations.
Browse files Browse the repository at this point in the history
  • Loading branch information
christianhaeubl committed Dec 17, 2019
1 parent ccc91b7 commit 3176659
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,11 @@ public final ByteBuffer toByteBuffer(ByteBuffer buffer) {
return buffer;
}

public final byte[] toArray() {
byte[] result = new byte[TypeConversion.asS4(getBytesWritten())];
return toArray(result);
}

@Override
public final void putS1(long value) {
long offset = writeOffset(Byte.BYTES);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import org.graalvm.nativeimage.Platforms;

import com.oracle.svm.core.annotate.AutomaticFeature;
import com.oracle.svm.core.annotate.Uninterruptible;
import com.oracle.svm.core.annotate.UnknownObjectField;
import com.oracle.svm.core.meta.SharedField;

Expand Down Expand Up @@ -58,12 +59,14 @@ public static void setData(Object[] staticObjectFields, byte[] staticPrimitiveFi
support.staticPrimitiveFields = staticPrimitiveFields;
}

@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)
public static Object[] getStaticObjectFields() {
Object[] result = ImageSingletons.lookup(StaticFieldsSupport.class).staticObjectFields;
assert result != null;
return result;
}

@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)
public static byte[] getStaticPrimitiveFields() {
byte[] result = ImageSingletons.lookup(StaticFieldsSupport.class).staticPrimitiveFields;
assert result != null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,14 @@ public static <T extends WordBase> T getWord(NonmovableArray<T> array, int index
@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)
public static <T extends PointerBase> T addressOf(NonmovableArray<?> array, int index) {
assert index >= 0 && index <= lengthOf(array);
return (T) ((Pointer) array).add(readArrayBase(array) + (index << readElementShift(array)));
return (T) getArrayBase(array).add(index << readElementShift(array));
}

/** Reads the value at the given index in an object array. */
@SuppressWarnings("unchecked")
@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)
public static <T extends Pointer> T getArrayBase(NonmovableArray<?> array) {
return (T) ((Pointer) array).add(readArrayBase(array));
}

/** Reads the value at the given index in an object array. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,15 @@
import com.oracle.svm.core.annotate.Alias;
import com.oracle.svm.core.annotate.Substitute;
import com.oracle.svm.core.annotate.TargetClass;
import com.oracle.svm.core.annotate.Uninterruptible;

@TargetClass(CEntryPointLiteral.class)
final class Target_org_graalvm_nativeimage_c_function_CEntryPointLiteral {

@Alias protected CFunctionPointer functionPointer;

@Substitute
@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)
public CFunctionPointer getFunctionPointer() {
return functionPointer;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import org.graalvm.nativeimage.hosted.Feature;

import com.oracle.svm.core.annotate.AutomaticFeature;
import com.oracle.svm.core.annotate.Uninterruptible;
import com.oracle.svm.core.annotate.UnknownObjectField;
import com.oracle.svm.core.c.NonmovableArray;
import com.oracle.svm.core.c.NonmovableArrays;
Expand All @@ -47,6 +48,7 @@ public void setData(NonmovableArray<Byte> referenceMapEncoding) {
this.referenceMapEncoding = NonmovableArrays.getHostedArray(referenceMapEncoding);
}

@Uninterruptible(reason = "Called from uninterruptible code.")
public static NonmovableArray<Byte> getReferenceMapEncoding() {
return NonmovableArrays.fromImageHeap(ImageSingletons.lookup(DynamicHubSupport.class).referenceMapEncoding);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,11 @@
import org.graalvm.nativeimage.Platform;
import org.graalvm.nativeimage.Platforms;

import com.oracle.svm.core.annotate.Uninterruptible;
import com.oracle.svm.core.annotate.UnknownObjectField;
import com.oracle.svm.core.annotate.UnknownPrimitiveField;
import com.oracle.svm.core.c.NonmovableArray;
import com.oracle.svm.core.c.NonmovableArrays;

public class VMThreadLocalMTSupport {
@UnknownPrimitiveField public int vmThreadSize = -1;
Expand All @@ -38,4 +41,18 @@ public class VMThreadLocalMTSupport {
@Platforms(Platform.HOSTED_ONLY.class)
public VMThreadLocalMTSupport() {
}

@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)
public NonmovableArray<Byte> getThreadLocalsReferenceMap() {
assert vmThreadReferenceMapEncoding != null;
return NonmovableArrays.fromImageHeap(vmThreadReferenceMapEncoding);
}

@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)
public int getThreadLocalsReferenceMapIndex() {
long result = vmThreadReferenceMapIndex;
assert result >= 0;
assert (int) result == result;
return (int) result;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ public static RuntimeException unimplemented() {
throw new UnsupportedOperationException("unimplemented");
}

public static RuntimeException unimplemented(String msg) {
throw new UnsupportedOperationException(msg);
}

public static RuntimeException unsupportedFeature(String msg) {
throw new HostedError("UNSUPPORTED FEATURE: " + msg);
}
Expand Down

0 comments on commit 3176659

Please sign in to comment.