Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
gluon-bot committed Oct 4, 2023
2 parents 5e44e7a + e4e0203 commit 99f0e04
Show file tree
Hide file tree
Showing 25 changed files with 322 additions and 139 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ The most-specific tag is unique and always points to the same image, while the l
docker pull --platform linux/aarch64 ghcr.io/graalvm/native-image-community:17
```

If you are looking for Oracle GraalVM container images, they are published in the [Oracle Container Registry](https://container-registry.oracle.com).
If you are looking for Oracle GraalVM container images, they are published in the [Oracle Container Registry](https://container-registry.oracle.com/ords/ocr/ba/graalvm).

### Learn More

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ permalink: /getting-started/container-images/

## Oracle GraalVM Container Images

Oracle GraalVM container images are available in [Oracle Container Registry (OCR)](https://container-registry.oracle.com) under the [GraalVM Free Terms and Conditions (GFTC) license](https://www.oracle.com/downloads/licenses/graal-free-license.html).
Oracle GraalVM container images are available in [Oracle Container Registry (OCR)](https://container-registry.oracle.com/ords/ocr/ba/graalvm) under the [GraalVM Free Terms and Conditions (GFTC) license](https://www.oracle.com/downloads/licenses/graal-free-license.html).

## Repositories

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ For self-contained executables, generated with GraalVM Native Image, containers

To support container-based development, there are several GraalVM container images available, depending on the platform, the architecture, the Java version, and the edition:

- Oracle GraalVM container images, available in [Oracle Container Registry (OCR)](https://container-registry.oracle.com) under the [GraalVM Free Terms and Conditions (GFTC) license](https://www.oracle.com/downloads/licenses/graal-free-license.html).
- Oracle GraalVM container images, available in [Oracle Container Registry (OCR)](https://container-registry.oracle.com/ords/ocr/ba/graalvm) under the [GraalVM Free Terms and Conditions (GFTC) license](https://www.oracle.com/downloads/licenses/graal-free-license.html).
- GraalVM Community Edition container images published in the [GitHub Container Registry](https://github.com/orgs/graalvm/packages).

This guide shows how to containerise a native executable for your Java application.
Expand Down
17 changes: 13 additions & 4 deletions java-benchmarks/mx.java-benchmarks/mx_java_benchmarks.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
import mx_benchmark
from mx_benchmark import ParserEntry
import mx_sdk_benchmark
from mx_sdk_benchmark import NativeImageBenchmarkMixin, NativeImageBundleBasedBenchmarkMixin
from mx_sdk_benchmark import NativeImageBundleBasedBenchmarkMixin
import mx_sdk_vm_impl

_suite = mx.suite('java-benchmarks')
Expand Down Expand Up @@ -455,7 +455,7 @@ def getScriptPath(self, config):
mx_benchmark.add_bm_suite(QuarkusHelloWorldWrkBenchmarkSuite())


class BaseMicronautBenchmarkSuite(BaseMicroserviceBenchmarkSuite):
class BaseMicronautBenchmarkSuite(BaseMicroserviceBenchmarkSuite, NativeImageBundleBasedBenchmarkMixin):
def get_application_startup_regex(self):
# Example of Micronaut startup log (there can be some formatting in between):
# "[main] INFO io.micronaut.runtime.Micronaut - Startup completed in 328ms. Server Running: <url>"
Expand All @@ -479,6 +479,15 @@ def extra_image_build_argument(self, benchmark, args):
def default_stages(self):
return ['instrument-image', 'instrument-run', 'image', 'run']

def uses_bundles(self):
return True

def createCommandLineArgs(self, benchmarks, bmSuiteArgs):
return self.create_bundle_command_line_args(benchmarks, bmSuiteArgs)

def extra_image_build_argument(self, _, args):
return super(BaseMicronautBenchmarkSuite, self).extra_image_build_argument(_, args) + self.create_bundle_image_build_arguments()

class BaseQuarkusRegistryBenchmark(BaseQuarkusBenchmarkSuite, mx_sdk_benchmark.BaseMicroserviceBenchmarkSuite):
"""
This benchmark is NOT yet fully functional - there is not load for measuring its runtime performance.
Expand Down Expand Up @@ -587,7 +596,7 @@ def extra_image_build_argument(self, benchmark, args):

class BaseShopCartBenchmarkSuite(BaseMicronautBenchmarkSuite):
def version(self):
return "0.3.7"
return "0.3.8"

def applicationDist(self):
return mx.library("SHOPCART_" + self.version(), True).get_path(True)
Expand Down Expand Up @@ -635,7 +644,7 @@ def rules(self, out, benchmarks, bmSuiteArgs):

class BaseMicronautHelloWorldBenchmarkSuite(BaseMicronautBenchmarkSuite):
def version(self):
return "1.0.4"
return "1.0.5"

def applicationDist(self):
return mx.library("MICRONAUT_HW_" + self.version(), True).get_path(True)
Expand Down
12 changes: 6 additions & 6 deletions java-benchmarks/mx.java-benchmarks/suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@
"packedResource": True,
},

"SHOPCART_0.3.7": {
"urls": ["https://lafo.ssw.uni-linz.ac.at/pub/graal-external-deps/shopcart-0.3.7.zip"],
"digest": "sha512:ccc1fd65cabf98e08a2e6483f4391e8e0c86d4d6ed236ee35ef2a5c5c7eae2b87eed758a647d26589f16298f90d80f322ff30586eccf41899266fe55c971153c",
"SHOPCART_0.3.8": {
"urls": ["https://lafo.ssw.uni-linz.ac.at/pub/graal-external-deps/shopcart-0.3.8.zip"],
"digest": "sha512:07eb59fae6a2245ef7dd628488e3c970336ba75c6a379899d222c418bb14d4b34019b25ce422e0f0e90cdd79c4ae7fc38f47c9c5a25d504e8a0f922fa28fa90a",
"packedResource": True,
},

Expand All @@ -49,9 +49,9 @@
"packedResource": True,
},

"MICRONAUT_HW_1.0.4": {
"urls": ["https://lafo.ssw.uni-linz.ac.at/pub/graal-external-deps/micronaut-hello-world-1.0.4.zip"],
"digest": "sha512:7efa10d79ac0812dc9bcd41e64a404cca83cd8de9cbad77539b4a9eb0e23a16144a9cafc2b39c9db39639010f3be97ed897394f41a7dae05ca9743b65adfd69a",
"MICRONAUT_HW_1.0.5": {
"urls": ["https://lafo.ssw.uni-linz.ac.at/pub/graal-external-deps/micronaut-hello-world-1.0.5.zip"],
"digest": "sha512:71b998f46784ec807de8e8b6cc9c55ee043171a4601ea5594f51d9d982b396c72bf59c0e426d3dbf44db9162cb34c73bfef9be48f57b79590777e6ff7081262c",
"packedResource": True,
},

Expand Down
8 changes: 4 additions & 4 deletions sdk/mx.sdk/suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,14 @@
"ignore_suite_commit_info": True,
"libraries" : {
"WRK_MULTIARCH": {
"urls": ["https://lafo.ssw.uni-linz.ac.at/pub/graal-external-deps/wrk-a211dd5-multiarch.tar.gz"],
"digest": "sha512:a7f7a7fd9bf8b87423a682ff1390a6ba87cc8dec43d41a3dcabb9a4fa5516b3d2e71f2384661a4248440c0ba4f2e27b8ef50d5dc123c5ae118866fa38254e23c",
"urls": ["https://lafo.ssw.uni-linz.ac.at/pub/graal-external-deps/wrk-a211dd5-multiarch-2.0.tar.gz"],
"digest": "sha512:b25a315ce50b446cb7f715ad93e718b937d2ed5c2be9ad0308935a7ccfca92f8d74aff403b5aff53fdedd0f71fd7beb08c6060b904f23fbd27ff6a40a1848770",
"packedResource": True,
"license": "Apache-2.0-wrk-a211dd5",
},
"WRK2_MULTIARCH": {
"urls": ["https://lafo.ssw.uni-linz.ac.at/pub/graal-external-deps/wrk2-multiarch.tar.gz"],
"digest": "sha512:597d64086e4d8126bea480ae5edc15b3b9ed649a4ad38c99c42968f25e260da351780921c5013200eddefcc5a4b715676df194d52ff04a5bfcec024cc6140530",
"urls": ["https://lafo.ssw.uni-linz.ac.at/pub/graal-external-deps/wrk2-multiarch-2.0.tar.gz"],
"digest": "sha512:94629a69ebf2d683c6ea6c61dc86729d121e70c30a25ec6daf8fd70b74f6ebb694a5973a3d3e2f9c624efa418b51a550868d6951de9d7277d2028e0c8078e4b4",
"packedResource": True,
"license": "Apache-2.0",
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ public final void writeDouble(double value) {
*/
public final void writeUTF(String string) throws IllegalArgumentException {
int len = string.length();
int utfLen = 0;
long utfLen = 0;
int c;
int count = 0;

Expand All @@ -220,12 +220,12 @@ public final void writeUTF(String string) throws IllegalArgumentException {
int headerSize;
if (utfLen > MAX_SHORT_LENGTH) {
headerSize = Integer.BYTES;
ensureBufferSize(headerSize, utfLen);
ensureBufferSize(headerSize, (int) utfLen);
tempDecodingBuffer[count++] = (byte) ((LARGE_STRING_TAG | (utfLen >>> 24)) & 0xff);
tempDecodingBuffer[count++] = (byte) ((utfLen >>> 16) & 0xFF);
} else {
headerSize = Short.BYTES;
ensureBufferSize(headerSize, utfLen);
ensureBufferSize(headerSize, (int) utfLen);
}
tempDecodingBuffer[count++] = (byte) ((utfLen >>> 8) & 0xFF);
tempDecodingBuffer[count++] = (byte) (utfLen & 0xFF);
Expand All @@ -252,7 +252,7 @@ public final void writeUTF(String string) throws IllegalArgumentException {
tempDecodingBuffer[count++] = (byte) (0x80 | (c & 0x3F));
}
}
write(tempDecodingBuffer, 0, headerSize + utfLen);
write(tempDecodingBuffer, 0, (int) (headerSize + utfLen));
}

/**
Expand Down
1 change: 0 additions & 1 deletion substratevm/mx.substratevm/macro-truffle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ Args = --features=com.oracle.svm.truffle.TruffleFeature \
--initialize-at-build-time=org.graalvm.jniutils \
--initialize-at-build-time=org.graalvm.nativebridge \
--initialize-at-build-time=org.graalvm.shadowed.org.json \
--initialize-at-build-time=com.oracle.truffle.tools.utils.json \
--initialize-at-build-time=org.graalvm.shadowed.org.jline,org.graalvm.shadowed.org.fusesource.jansi \
--initialize-at-run-time=sun.rmi \
--initialize-at-run-time=java.rmi \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.graalvm.nativeimage.Platforms;

import com.oracle.svm.core.Uninterruptible;
import com.oracle.svm.core.thread.PlatformThreads;

/**
* This file contains the VM-level events that Native Image supports on all JDK versions. The event
Expand Down Expand Up @@ -95,19 +96,19 @@ public String getName() {
@Uninterruptible(reason = "Prevent races with VM operations that start/stop recording.", callerMustBe = true)
public boolean shouldEmit() {
assert !hasDuration;
return shouldEmit0() && !SubstrateJVM.get().isExcluded(Thread.currentThread());
return shouldEmit0() && !JfrThreadLocal.isThreadExcluded(PlatformThreads.getCurrentThreadOrNull());
}

@Uninterruptible(reason = "Prevent races with VM operations that start/stop recording.", callerMustBe = true)
public boolean shouldEmit(Thread thread) {
assert !hasDuration;
return shouldEmit0() && !SubstrateJVM.get().isExcluded(thread);
return shouldEmit0() && !JfrThreadLocal.isThreadExcluded(thread);
}

@Uninterruptible(reason = "Prevent races with VM operations that start/stop recording.", callerMustBe = true)
public boolean shouldEmit(long durationTicks) {
assert hasDuration;
return shouldEmit0() && durationTicks >= SubstrateJVM.get().getThresholdTicks(this) && !SubstrateJVM.get().isExcluded(Thread.currentThread());
return shouldEmit0() && durationTicks >= SubstrateJVM.get().getThresholdTicks(this) && !JfrThreadLocal.isThreadExcluded(PlatformThreads.getCurrentThreadOrNull());
}

@Uninterruptible(reason = "Prevent races with VM operations that start/stop recording.", callerMustBe = true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ private static void flushToGlobalMemoryAndRetireBuffer(JfrBuffer buffer) {
* moment, only the current thread may be excluded/included. See GR-44616.
*/
public static void setExcluded(Thread thread, boolean excluded) {
if (thread == null || !thread.equals(Thread.currentThread())) {
if (thread == null || thread != PlatformThreads.getCurrentThreadOrNull()) {
return;
}
IsolateThread currentIsolateThread = CurrentIsolate.getCurrentThread();
Expand All @@ -247,7 +247,7 @@ public static void setExcluded(Thread thread, boolean excluded) {
* thread, see {@link PlatformThreads#ensureCurrentAssigned(String, ThreadGroup, boolean)} where
* a {@link Thread} object must be created before it can be assigned to the current thread. This
* may happen during shutdown in {@link JavaMainWrapper}. Therefore, this method must account
* for the case where {@link Thread#currentThread()} returns null.
* for the case where {@link PlatformThreads#getCurrentThreadOrNull()} returns null.
*/
@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)
public static boolean isThreadExcluded(Thread thread) {
Expand Down Expand Up @@ -286,7 +286,7 @@ public Target_jdk_jfr_internal_event_EventWriter newEventWriter() {
throw new OutOfMemoryError("OOME for thread local buffer");
}

Target_jdk_jfr_internal_event_EventWriter result = JfrEventWriterAccess.newEventWriter(buffer, isThreadExcluded(Thread.currentThread()));
Target_jdk_jfr_internal_event_EventWriter result = JfrEventWriterAccess.newEventWriter(buffer, isThreadExcluded(PlatformThreads.getCurrentThreadOrNull()));
javaEventWriter.set(result);
return result;
}
Expand Down Expand Up @@ -317,6 +317,11 @@ private static JfrBuffer reinstateJavaBuffer(JfrBuffer buffer) {
return buffer;
}

@Uninterruptible(reason = "Accesses a JFR buffer.")
public JfrBuffer getExistingJavaBuffer() {
return javaBuffer.get();
}

@Uninterruptible(reason = "Accesses a JFR buffer.")
public JfrBuffer getJavaBuffer() {
JfrBuffer buffer = javaBuffer.get();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -524,8 +524,13 @@ public void flush() {
@Uninterruptible(reason = "Accesses a native JFR buffer.")
public long commit(long nextPosition) {
assert nextPosition != 0 : "invariant";
JfrBuffer current = threadLocal.getJavaBuffer();
assert current.isNonNull() : "invariant";

JfrBuffer current = threadLocal.getExistingJavaBuffer();
if (current.isNull()) {
/* This is a commit for a recording session that is no longer active - ignore it. */
return nextPosition;
}

Pointer next = WordFactory.pointer(nextPosition);
assert next.aboveOrEqual(current.getCommittedPos()) : "invariant";
assert next.belowOrEqual(JfrBufferAccess.getDataEnd(current)) : "invariant";
Expand Down Expand Up @@ -697,15 +702,6 @@ public Object getConfiguration(Class<? extends Event> eventClass) {
return DynamicHub.fromClass(eventClass).getJfrEventConfiguration();
}

public void setExcluded(Thread thread, boolean excluded) {
JfrThreadLocal.setExcluded(thread, excluded);
}

@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)
public boolean isExcluded(Thread thread) {
return JfrThreadLocal.isThreadExcluded(thread);
}

private static class JfrBeginRecordingOperation extends JavaVMOperation {
JfrBeginRecordingOperation() {
super(VMOperationInfos.get(JfrBeginRecordingOperation.class, "JFR begin recording", SystemEffect.SAFEPOINT));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -435,19 +435,19 @@ public static boolean shouldRotateDisk() {
@Substitute
@TargetElement(onlyWith = JDK22OrLater.class)
public static void include(Thread thread) {
SubstrateJVM.get().setExcluded(thread, false);
JfrThreadLocal.setExcluded(thread, false);
}

@Substitute
@TargetElement(onlyWith = JDK22OrLater.class)
public static void exclude(Thread thread) {
SubstrateJVM.get().setExcluded(thread, true);
JfrThreadLocal.setExcluded(thread, true);
}

@Substitute
@TargetElement(onlyWith = JDK22OrLater.class)
public static boolean isExcluded(Thread thread) {
return SubstrateJVM.get().isExcluded(thread);
return JfrThreadLocal.isThreadExcluded(thread);
}

@Substitute
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -306,17 +306,17 @@ public boolean shouldRotateDisk() {

@Substitute
public void include(Thread thread) {
SubstrateJVM.get().setExcluded(thread, false);
JfrThreadLocal.setExcluded(thread, false);
}

@Substitute
public void exclude(Thread thread) {
SubstrateJVM.get().setExcluded(thread, true);
JfrThreadLocal.setExcluded(thread, true);
}

@Substitute
public boolean isExcluded(Thread thread) {
return SubstrateJVM.get().isExcluded(thread);
return JfrThreadLocal.isThreadExcluded(thread);
}

@Substitute
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,17 @@ static void setCurrentThread(Thread carrier, Thread thread) {
currentVThreadId.set(JavaThreads.getThreadId(thread));
}

@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)
public static Thread getCurrentThreadOrNull() {
Thread thread = PlatformThreads.currentThread.get();
if (thread == null) {
return null;
}

Target_java_lang_Thread tjlt = SubstrateUtil.cast(thread, Target_java_lang_Thread.class);
return (tjlt.vthread != null) ? tjlt.vthread : thread;
}

/** Returns the mounted virtual thread if one exists, otherwise null. */
@Uninterruptible(reason = CALLED_FROM_UNINTERRUPTIBLE_CODE, mayBeInlined = true)
public static Thread getVThread(Thread thread) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,9 +219,13 @@ static Thread currentCarrierThread() {
@Substitute
@TargetElement(name = "currentThread", onlyWith = ContinuationsSupported.class)
static Thread currentVThread() {
Thread thread = PlatformThreads.currentThread.get();
Target_java_lang_Thread tjlt = SubstrateUtil.cast(thread, Target_java_lang_Thread.class);
return (tjlt.vthread != null) ? tjlt.vthread : thread;
Thread thread = PlatformThreads.getCurrentThreadOrNull();
if (GraalDirectives.inIntrinsic()) {
ReplacementsUtil.dynamicAssert(thread != null, "Thread has not been set yet");
} else {
assert thread != null : "Thread has not been set yet";
}
return thread;
}

@SuppressWarnings("static-method")
Expand Down
Loading

0 comments on commit 99f0e04

Please sign in to comment.