diff --git a/compiler/src/jdk.internal.vm.compiler/src/org/graalvm/compiler/nodes/extended/CaptureStateBeginNode.java b/compiler/src/jdk.internal.vm.compiler/src/org/graalvm/compiler/nodes/extended/CaptureStateBeginNode.java index 8f8628cc952b..6d6c40ac2cda 100644 --- a/compiler/src/jdk.internal.vm.compiler/src/org/graalvm/compiler/nodes/extended/CaptureStateBeginNode.java +++ b/compiler/src/jdk.internal.vm.compiler/src/org/graalvm/compiler/nodes/extended/CaptureStateBeginNode.java @@ -30,10 +30,14 @@ import org.graalvm.compiler.graph.Node; import org.graalvm.compiler.graph.NodeClass; +import org.graalvm.compiler.graph.iterators.NodePredicates; import org.graalvm.compiler.nodeinfo.NodeInfo; import org.graalvm.compiler.nodes.AbstractBeginNode; import org.graalvm.compiler.nodes.BeginNode; import org.graalvm.compiler.nodes.BeginStateSplitNode; +import org.graalvm.compiler.nodes.LoopExitNode; +import org.graalvm.compiler.nodes.MemoryProxyNode; +import org.graalvm.compiler.nodes.ValueProxyNode; import org.graalvm.compiler.nodes.spi.Canonicalizable; import org.graalvm.compiler.nodes.spi.CanonicalizerTool; @@ -61,4 +65,17 @@ public Node canonical(CanonicalizerTool tool) { } return this; } + + @Override + public boolean verify() { + if (predecessor() instanceof LoopExitNode loopExit) { + /* + * Must guarantee only value and memory proxies are attached to the loop exit. Anything + * else should be attached to this node + */ + assert loopExit.usages().stream().allMatch(NodePredicates.isA(ValueProxyNode.class).or(MemoryProxyNode.class)) : String.format("LoopExit has disallowed usages %s", loopExit); + } + + return super.verify(); + } } diff --git a/compiler/src/jdk.internal.vm.compiler/src/org/graalvm/compiler/phases/common/ConditionalEliminationPhase.java b/compiler/src/jdk.internal.vm.compiler/src/org/graalvm/compiler/phases/common/ConditionalEliminationPhase.java index ba51c94cec6b..873a1a470842 100644 --- a/compiler/src/jdk.internal.vm.compiler/src/org/graalvm/compiler/phases/common/ConditionalEliminationPhase.java +++ b/compiler/src/jdk.internal.vm.compiler/src/org/graalvm/compiler/phases/common/ConditionalEliminationPhase.java @@ -85,6 +85,7 @@ import org.graalvm.compiler.nodes.calc.IntegerEqualsNode; import org.graalvm.compiler.nodes.cfg.ControlFlowGraph; import org.graalvm.compiler.nodes.cfg.HIRBlock; +import org.graalvm.compiler.nodes.extended.CaptureStateBeginNode; import org.graalvm.compiler.nodes.extended.GuardingNode; import org.graalvm.compiler.nodes.extended.IntegerSwitchNode; import org.graalvm.compiler.nodes.extended.LoadHubNode; @@ -226,11 +227,46 @@ public static class MoveGuardsUpwards implements ControlFlowGraph.RecursiveVisit HIRBlock anchorBlock; + /** + * Guards cannot be moved above CaptureStateBeginNodes in order to ensure deoptimizations + * are always attached to valid FrameStates. + */ + private static boolean disallowUpwardGuardMovement(HIRBlock b) { + return b.getBeginNode() instanceof CaptureStateBeginNode; + } + @Override @SuppressWarnings("try") public HIRBlock enter(HIRBlock b) { HIRBlock oldAnchorBlock = anchorBlock; - if (b.getDominator() == null || b.getDominator().getPostdominator() != b) { + /* + * The goal of this pass is to move guards upward while not introducing the guards on + * new paths. At all points the anchorBlock must set so the following two invariants + * hold: + * + * (1) The anchorBlock dominates the current block. + * + * (2) The current block post-dominates the anchorBlock. + * + * Note blocks are traversed in dominator tree order. + * + * anchorBlock must be set to the current block if: + * + * (1) The current block does not have a dominator (i.e., this is the start of a new + * dominator tree walk). + * + * (2) The immediate dominator of current block is not post-dominated by this block. Due + * to using a dominator tree traversal, this is equivalent to ensuring the current block + * post-dominates the anchorBlock. + * + * (3) Guards are not allowed to move above this block. The can happen when dominator + * blocks can have invalid FrameStates, such as when the block start is a + * CaptureStateBeginNode. + */ + boolean updateAnchorBlock = b.getDominator() == null || + b.getDominator().getPostdominator() != b || + disallowUpwardGuardMovement(b); + if (updateAnchorBlock) { // New anchor. anchorBlock = b; } @@ -271,52 +307,51 @@ public HIRBlock enter(HIRBlock b) { * successors are loop exits, even of potentially different loops. Thus, we need * to ensure we see all possible loop exits involved for all loops. */ - LoopExitNode trueSuccLex = trueSuccessor instanceof LoopExitNode ? (LoopExitNode) trueSuccessor : null; - LoopExitNode falseSuccLex = falseSuccessor instanceof LoopExitNode ? (LoopExitNode) falseSuccessor : null; EconomicSet allLoopsAllExits = null; - if (trueSuccLex != null) { + if (trueSuccessor instanceof LoopExitNode successor) { if (allLoopsAllExits == null) { allLoopsAllExits = EconomicSet.create(); } - allLoopsAllExits.addAll(trueSuccLex.loopBegin().loopExits()); - allLoopsAllExits.remove(trueSuccLex); + allLoopsAllExits.addAll(successor.loopBegin().loopExits()); + allLoopsAllExits.remove(successor); } - if (falseSuccLex != null) { + if (falseSuccessor instanceof LoopExitNode successor) { if (allLoopsAllExits == null) { allLoopsAllExits = EconomicSet.create(); } - allLoopsAllExits.addAll(falseSuccLex.loopBegin().loopExits()); - allLoopsAllExits.remove(falseSuccLex); + allLoopsAllExits.addAll(successor.loopBegin().loopExits()); + allLoopsAllExits.remove(successor); } if (allLoopsAllExits == null || allLoopsAllExits.isEmpty()) { - for (GuardNode guard : falseSuccessor.guards().snapshot()) { - GuardNode otherGuard = trueGuards.get(guard.getCondition()); - if (otherGuard != null && guard.isNegated() == otherGuard.isNegated()) { - Speculation speculation = otherGuard.getSpeculation(); + for (GuardNode falseGuard : falseSuccessor.guards().snapshot()) { + GuardNode trueGuard = trueGuards.get(falseGuard.getCondition()); + if (trueGuard != null && falseGuard.isNegated() == trueGuard.isNegated()) { + Speculation speculation = trueGuard.getSpeculation(); if (speculation == null) { - speculation = guard.getSpeculation(); - } else if (guard.getSpeculation() != null && guard.getSpeculation() != speculation) { + speculation = falseGuard.getSpeculation(); + } else if (falseGuard.getSpeculation() != null && falseGuard.getSpeculation() != speculation) { // Cannot optimize due to different speculations. continue; } - try (DebugCloseable closeable = guard.withNodeSourcePosition()) { - StructuredGraph graph = guard.graph(); - GuardNode newlyCreatedGuard = new GuardNode(guard.getCondition(), anchorBlock.getBeginNode(), guard.getReason(), guard.getAction(), guard.isNegated(), speculation, - guard.getNoDeoptSuccessorPosition()); + try (DebugCloseable closeable = falseGuard.withNodeSourcePosition()) { + StructuredGraph graph = falseGuard.graph(); + GuardNode newlyCreatedGuard = new GuardNode(falseGuard.getCondition(), anchorBlock.getBeginNode(), falseGuard.getReason(), falseGuard.getAction(), + falseGuard.isNegated(), speculation, + falseGuard.getNoDeoptSuccessorPosition()); GuardNode newGuard = node.graph().unique(newlyCreatedGuard); - if (otherGuard.isAlive()) { + if (trueGuard.isAlive()) { if (trueSuccessor instanceof LoopExitNode && beginNode.graph().isBeforeStage(StageFlag.VALUE_PROXY_REMOVAL)) { - otherGuard.replaceAndDelete(ProxyNode.forGuard(newGuard, (LoopExitNode) trueSuccessor)); + trueGuard.replaceAndDelete(ProxyNode.forGuard(newGuard, (LoopExitNode) trueSuccessor)); } else { - otherGuard.replaceAndDelete(newGuard); + trueGuard.replaceAndDelete(newGuard); } } if (falseSuccessor instanceof LoopExitNode && beginNode.graph().isBeforeStage(StageFlag.VALUE_PROXY_REMOVAL)) { - guard.replaceAndDelete(ProxyNode.forGuard(newGuard, (LoopExitNode) falseSuccessor)); + falseGuard.replaceAndDelete(ProxyNode.forGuard(newGuard, (LoopExitNode) falseSuccessor)); } else { - guard.replaceAndDelete(newGuard); + falseGuard.replaceAndDelete(newGuard); } - graph.getOptimizationLog().report(ConditionalEliminationPhase.class, "GuardCombination", guard); + graph.getOptimizationLog().report(ConditionalEliminationPhase.class, "GuardCombination", falseGuard); } } } diff --git a/compiler/src/jdk.internal.vm.compiler/src/org/graalvm/compiler/phases/common/SnippetFrameStateAssignment.java b/compiler/src/jdk.internal.vm.compiler/src/org/graalvm/compiler/phases/common/SnippetFrameStateAssignment.java index 215c6694a683..6eef3eed53af 100644 --- a/compiler/src/jdk.internal.vm.compiler/src/org/graalvm/compiler/phases/common/SnippetFrameStateAssignment.java +++ b/compiler/src/jdk.internal.vm.compiler/src/org/graalvm/compiler/phases/common/SnippetFrameStateAssignment.java @@ -184,43 +184,43 @@ protected NodeStateAssignment merge(AbstractMergeNode merge, List_macos-.tar.gz + ``` -2. Unzip the archive. +3. Unzip the archive. ```shell tar -xzf graalvm-jdk-_macos-.tar.gz ``` Alternatively, open the file in Finder. - > Note: If you are using macOS Catalina and later you may need to remove the quarantine attribute: - ```shell - sudo xattr -r -d com.apple.quarantine /path/to/graalvm - ``` -3. Move the downloaded package to its proper location, the `/Library/Java/JavaVirtualMachines` directory. Since this is a system directory, `sudo` is required: +4. Move the downloaded package to its proper location, the `/Library/Java/JavaVirtualMachines` directory. Since this is a system directory, `sudo` is required: ```shell sudo mv graalvm-jdk-_macos- /Library/Java/JavaVirtualMachines ``` To verify if the move is successful and to get a list of all installed JDKs, run `/usr/libexec/java_home -V`. -4. There can be multiple JDKs installed on the machine. The next step is to configure the runtime environment: +5. There can be multiple JDKs installed on the machine. The next step is to configure the runtime environment: - Set the `JAVA_HOME` environment variable to resolve to the GraalVM installation directory: ```shell export JAVA_HOME=/Library/Java/JavaVirtualMachines//Contents/Home @@ -41,7 +42,7 @@ Follow these steps to install GraalVM: export PATH=/Library/Java/JavaVirtualMachines//Contents/Home/bin:$PATH ``` -5. To check whether the installation was successful, run the `java -version` command. +6. To check whether the installation was successful, run the `java -version` command. Optionally, you can specify GraalVM as the default JRE or JDK installation in your Java IDE. diff --git a/docs/getting-started/graalvm-enterprise/macos.md b/docs/getting-started/graalvm-enterprise/macos.md index 7eac17b38909..06039b6bc26e 100644 --- a/docs/getting-started/graalvm-enterprise/macos.md +++ b/docs/getting-started/graalvm-enterprise/macos.md @@ -11,26 +11,26 @@ Note that in macOS, the JDK installation path is: _/Library/Java/JavaVirtualMach Follow these steps to install Oracle GraalVM: -1. Navigate to [Oracle Java Downloads](https://www.oracle.com/java/technologies/downloads/). -Select the preferred Oracle GraalVM version, **21** for the Java version, **macOS** for the operating system, and the architecture. Start downloading. +1. Navigate to [Oracle Java Downloads](https://www.oracle.com/java/technologies/downloads/). Select the preferred Oracle GraalVM version, **21** for the Java version, **macOS** for the operating system, and the architecture. Start downloading. -2. Unzip the archive: +2. Remove the quarantine attribute (required for macOS Catalina and later): + ```shell + sudo xattr -r -d com.apple.quarantine graalvm-jdk-_macos-.tar.gz + ``` + +3. Unzip the archive: ```shell tar -xzf graalvm-jdk-_macos-.tar.gz ``` Alternatively, open the file in the Finder. - > Note: If you are using macOS Catalina and later you may need to remove the quarantine attribute: - ```shell - sudo xattr -r -d com.apple.quarantine /path/to/graalvm - ``` -3. Move the downloaded package to its proper location, the _/Library/Java/JavaVirtualMachines_ directory. Since this is a system directory, `sudo` is required: +4. Move the downloaded package to its proper location, the _/Library/Java/JavaVirtualMachines_ directory. Since this is a system directory, `sudo` is required: ```shell sudo mv graalvm-jdk-_macos- /Library/Java/JavaVirtualMachines ``` To verify if the move is successful and to get a list of all installed JDKs, run `/usr/libexec/java_home -V`. -4. There can be multiple JDKs installed on the machine. The next step is to configure the runtime environment: +5. There can be multiple JDKs installed on the machine. The next step is to configure the runtime environment: - Set the `JAVA_HOME` environment variable to resolve to the installation directory: ```shell export JAVA_HOME=/Library/Java/JavaVirtualMachines//Contents/Home @@ -39,7 +39,7 @@ Select the preferred Oracle GraalVM version, **21** for the Java version, **macO ```shell export PATH=/Library/Java/JavaVirtualMachines//Contents/Home/bin:$PATH ``` -5. To check whether the installation was successful, run the `java -version` command. +6. To check whether the installation was successful, run the `java -version` command. Optionally, you can specify Oracle GraalVM as the default JRE or JDK installation in your Java IDE. diff --git a/docs/reference-manual/java-on-truffle/README.md b/docs/reference-manual/java-on-truffle/README.md index 28d07286ec76..f38c9e39faac 100644 --- a/docs/reference-manual/java-on-truffle/README.md +++ b/docs/reference-manual/java-on-truffle/README.md @@ -39,15 +39,17 @@ You can download a standalone based on Oracle GraalVM or GraalVM Community Editi * [Windows x64](https://gds.oracle.com/api/20220101/artifacts/04F488A062484081E0631818000A781E/content) 2. Unzip the archive: - ```shell - tar -xzf .tar.gz - ``` - Alternatively, open the file in the Finder. - > Note: If you are using macOS Catalina and later you may need to remove the quarantine attribute: + + > Note: If you are using macOS Catalina and later you may need to remove the quarantine attribute: ```shell sudo xattr -r -d com.apple.quarantine .tar.gz ``` - + + Extact: + ```shell + tar -xzf .tar.gz + ``` + 3. A standalone comes with a JVM in addition to its native launcher. Check the version to see the Java on Truffle runtime is active: ```shell ./path/to/bin/java -truffle --version diff --git a/docs/reference-manual/llvm/README.md b/docs/reference-manual/llvm/README.md index c5768de828d4..c02f5c6bde2f 100644 --- a/docs/reference-manual/llvm/README.md +++ b/docs/reference-manual/llvm/README.md @@ -32,14 +32,16 @@ You can download a standalone based on Oracle GraalVM or GraalVM Community Editi * [Windows x64](https://gds.oracle.com/api/20220101/artifacts/04F556B005683A58E0631818000A322D/content) 2. Unzip the archive: - ```shell - tar -xzf .tar.gz - ``` - Alternatively, open the file in the Finder. - > Note: If you are using macOS Catalina and later you may need to remove the quarantine attribute: + + > Note: If you are using macOS Catalina and later you may need to remove the quarantine attribute: ```shell sudo xattr -r -d com.apple.quarantine .tar.gz ``` + + Extact: + ```shell + tar -xzf .tar.gz + ``` 3. A standalone comes with a JVM in addition to its native launcher. Check the version to see GraalVM LLVM runtime is active: ```shell diff --git a/docs/reference-manual/wasm/README.md b/docs/reference-manual/wasm/README.md index 525f125bace4..16108df1b4b6 100644 --- a/docs/reference-manual/wasm/README.md +++ b/docs/reference-manual/wasm/README.md @@ -31,15 +31,17 @@ You can download a standalone based on Oracle GraalVM or GraalVM Community Editi * [Windows x64](https://gds.oracle.com/api/20220101/artifacts/05013E46CB6293C6E0631818000A2314/content) 2. Unzip the archive: - ```shell - tar -xzf .tar.gz - ``` - Alternatively, open the file in the Finder. - > Note: If you are using macOS Catalina and later you may need to remove the quarantine attribute: + + > Note: If you are using macOS Catalina and later you may need to remove the quarantine attribute: ```shell sudo xattr -r -d com.apple.quarantine .tar.gz ``` + Extact: + ```shell + tar -xzf .tar.gz + ``` + 3. A standalone comes with a JVM in addition to its native launcher. Check the version to see GraalVM WebAssembly runtime is active: ```bash ./path/to/bin/wasm --version diff --git a/sdk/mx.sdk/mx_sdk_vm_impl.py b/sdk/mx.sdk/mx_sdk_vm_impl.py index d3e3ab81a146..03f6c35089e9 100644 --- a/sdk/mx.sdk/mx_sdk_vm_impl.py +++ b/sdk/mx.sdk/mx_sdk_vm_impl.py @@ -3516,7 +3516,6 @@ def register_main_dist(dist, label): main_dists[label].append(debuginfo_dist.name) _final_graalvm_distribution = get_final_graalvm_distribution() - register_main_dist(_final_graalvm_distribution, 'graalvm') # Add the macros if SubstrateVM is in stage1, as images could be created later with an installable Native Image with_svm = has_component('svm', stage1=True) @@ -3615,16 +3614,17 @@ def register_main_dist(dist, label): native_image_resources_filelist_project = NativeImageResourcesFileList(None, ni_resources_components, dir_name, deps) register_project(native_image_resources_filelist_project) - # Create installables - # installable_names = [] + # Register main distribution + register_main_dist(_final_graalvm_distribution, 'graalvm') + + # Register installables for components in installables.values(): main_component = _get_main_component(components) installable_component = GraalVmInstallableComponent(main_component, extra_components=[c for c in components if c != main_component]) register_main_dist(installable_component, 'graalvm_installables') - # Create standalones + # Register standalones needs_java_standalone_jimage = False - # standalone_names = [] for components in installables.values(): main_component = _get_main_component(components) svm_support = _get_svm_support() @@ -3648,7 +3648,7 @@ def register_main_dist(dist, label): for library_config in _get_library_configs(main_component): if isinstance(library_config, mx_sdk.LanguageLibraryConfig) and library_config.launchers: - # Create dedicated NativeLibraryLauncherProject for JVM Standalones, which can find the JVM + # Register dedicated NativeLibraryLauncherProject for JVM Standalones, which can find the JVM jvm_standalone_launcher_project = NativeLibraryLauncherProject(main_component, library_config, jvm_standalone=java_standalone, defaultBuild=False) register_project(jvm_standalone_launcher_project) diff --git a/truffle/mx.truffle/suite.py b/truffle/mx.truffle/suite.py index f364c95ad84b..f1aae0ce293a 100644 --- a/truffle/mx.truffle/suite.py +++ b/truffle/mx.truffle/suite.py @@ -2017,7 +2017,7 @@ ], "exports" : [ # Qualified exports. - "org.graalvm.shadowed.com.ibm.icu.lang to org.graalvm.js, org.graalvm.py", + "org.graalvm.shadowed.com.ibm.icu.lang to com.oracle.truffle.regex, org.graalvm.js, org.graalvm.py", "org.graalvm.shadowed.com.ibm.icu.math to org.graalvm.js, org.graalvm.py", "org.graalvm.shadowed.com.ibm.icu.number to org.graalvm.js, org.graalvm.py", "org.graalvm.shadowed.com.ibm.icu.text to org.graalvm.js, org.graalvm.py", diff --git a/wasm/README.md b/wasm/README.md index 690ae9b32e49..9713e10c94b3 100644 --- a/wasm/README.md +++ b/wasm/README.md @@ -313,15 +313,17 @@ You can download a standalone based on Oracle GraalVM or GraalVM Community Editi 1. Navigate to the [latest GraalVM release on GitHub](https://github.com/graalvm/graalvm-ce-builds/releases) and download the Wasm standalone for your operating system. 2. Unzip the archive: - ```shell - tar -xzf .tar.gz - ``` - Alternatively, open the file in the Finder. - > Note: If you are using macOS Catalina and later you may need to remove the quarantine attribute: + + > Note: If you are using macOS Catalina and later you may need to remove the quarantine attribute: ```shell sudo xattr -r -d com.apple.quarantine .tar.gz ``` + Extact: + ```shell + tar -xzf .tar.gz + ``` + 3. A standalone comes with a JVM in addition to its native launcher. Check the version to see GraalWasm is active: ```bash ./path/to/bin/wasm --version