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 Aug 29, 2023
2 parents 3d16803 + b959b4a commit 70cd55d
Show file tree
Hide file tree
Showing 34 changed files with 337 additions and 168 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,5 @@ visualizer/IdealGraphVisualizer/build/
visualizer/IdealGraphVisualizer/dist/
visualizer/IdealGraphVisualizer/nbplatform/
/.src-rev
*.interp
*.tokens
2 changes: 1 addition & 1 deletion compiler/mx.compiler/suite.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
suite = {
"mxversion": "6.27.1",
"mxversion": "6.44.1",
"name" : "compiler",
"sourceinprojectwhitelist" : [],

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,6 @@ public static <C> boolean findNextPhase(ListIterator<BasePhase<? super C>> it, C
* Removes the first instance of the given phase class, looking recursively into inner phase
* suites.
*/
@SuppressWarnings("unchecked")
public boolean removePhase(Class<? extends BasePhase<? super C>> phaseClass) {
ListIterator<BasePhase<? super C>> it = phases.listIterator();
while (it.hasNext()) {
Expand All @@ -206,6 +205,7 @@ public boolean removePhase(Class<? extends BasePhase<? super C>> phaseClass) {
it.remove();
return true;
} else if (phase instanceof PhaseSuite) {
@SuppressWarnings("unchecked")
PhaseSuite<C> innerSuite = (PhaseSuite<C>) phase;
if (innerSuite.removePhase(phaseClass)) {
if (innerSuite.phases.isEmpty()) {
Expand All @@ -221,7 +221,6 @@ public boolean removePhase(Class<? extends BasePhase<? super C>> phaseClass) {
/**
* Removes all phases in this suite that are assignable to {@code type}.
*/
@SuppressWarnings("unchecked")
public boolean removeSubTypePhases(Class<?> type) {
boolean hasRemovedSpeculativePhase = false;
ListIterator<BasePhase<? super C>> it = phases.listIterator();
Expand All @@ -231,6 +230,7 @@ public boolean removeSubTypePhases(Class<?> type) {
it.remove();
hasRemovedSpeculativePhase = true;
} else if (phase instanceof PhaseSuite) {
@SuppressWarnings("unchecked")
PhaseSuite<C> innerSuite = (PhaseSuite<C>) phase;
if (innerSuite.removeSubTypePhases(type)) {
if (innerSuite.phases.isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -321,17 +321,18 @@ protected boolean virtualize(ValueNode node, VirtualizerTool vt) {
/**
* This tries to canonicalize the node based on improved (replaced) inputs.
*/
@SuppressWarnings("unchecked")
private boolean processNodeWithScalarReplacedInputs(ValueNode node, FixedNode insertBefore, BlockT state, GraphEffectList effects) {
ValueNode canonicalizedValue = node;
if (node instanceof Canonicalizable.Unary<?>) {
@SuppressWarnings("unchecked")
Canonicalizable.Unary<ValueNode> canonicalizable = (Canonicalizable.Unary<ValueNode>) node;
ObjectState valueObj = getObjectState(state, canonicalizable.getValue());
ValueNode valueAlias = valueObj != null ? valueObj.getMaterializedValue() : getScalarAlias(canonicalizable.getValue());
if (valueAlias != canonicalizable.getValue()) {
canonicalizedValue = (ValueNode) canonicalizable.canonical(tool, valueAlias);
}
} else if (node instanceof Canonicalizable.Binary<?>) {
@SuppressWarnings("unchecked")
Canonicalizable.Binary<ValueNode> canonicalizable = (Canonicalizable.Binary<ValueNode>) node;
ObjectState xObj = getObjectState(state, canonicalizable.getX());
ValueNode xAlias = xObj != null ? xObj.getMaterializedValue() : getScalarAlias(canonicalizable.getX());
Expand Down
71 changes: 46 additions & 25 deletions sdk/mx.sdk/mx_sdk_shaded.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,12 @@ class ShadedLibraryProject(mx.JavaProject):
# a list of (re)source path patterns that should be excluded from the generated jar
"**/*.html",
],
"patch" : [
"patch" : {
# a list of (re)source path patterns that should be patched with regex substitutions
"pkg/name/my.properties" : {
"<pattern>" : "<replacement>",
},
],
},
}
The build task then runs a Java program to shade the library and generates a .jar file.
"""
Expand Down Expand Up @@ -162,14 +162,38 @@ def needsBuild(self, newestInput):
return True, f"{outDir} does not exist"

suite_py_ts = mx.TimeStampFile.newest([self.subject.suite.suite_py(), __file__])
if newestInput is None or newestInput.isOlderThan(suite_py_ts):
newestInput = suite_py_ts

for dep in proj.shaded_deps():
jarFilePath = dep.get_path(False)
srcFilePath = dep.get_source_path(False)

if srcFilePath is None:
return True, f'{dep} does not have a source path'

input_ts = mx.TimeStampFile.newest([jarFilePath, srcFilePath])
if input_ts is None or suite_py_ts.isNewerThan(input_ts):
input_ts = suite_py_ts
if input_ts is not None and newestInput.isOlderThan(input_ts):
newestInput = input_ts

return super().needsBuild(newestInput)

def _collect_files(self):
if self._javafiles is not None:
# already collected
return self

# collect project files first, then extend with shaded (re)sources
super()._collect_files()
javafiles = self._javafiles
non_javafiles = self._non_javafiles

proj = self.subject
binDir = proj.output_dir()
for dep in proj.shaded_deps():
srcFilePath = dep.get_source_path(True)
if srcFilePath is None:
continue

for zipFilePath, outDir in [(srcFilePath, proj.source_gen_dir())]:
try:
Expand All @@ -179,30 +203,27 @@ def needsBuild(self, newestInput):
continue

old_filename = zi.filename
if old_filename.endswith('.java'):
filepath = PurePosixPath(old_filename)
if any(glob_match(filepath, i) for i in proj.excluded_paths()):
continue
new_filename = proj.substitute_path(old_filename)
if old_filename != new_filename:
output_file = os.path.join(outDir, new_filename)
output_ts = mx.TimeStampFile(output_file)
if output_ts.isOlderThan(input_ts):
return True, f'{output_ts} is older than {input_ts}'
except FileNotFoundError:
return True, f"{zipFilePath} does not exist"

return super().needsBuild(newestInput)
filepath = PurePosixPath(old_filename)
if any(glob_match(filepath, i) for i in proj.excluded_paths()):
continue
if filepath.suffix not in ['.java', '.class'] and not any(glob_match(filepath, i) for i in proj.included_paths()):
continue

def prepare(self, daemons):
# delay prepare until build
self.daemons = daemons
new_filename = proj.substitute_path(old_filename)
src_gen_path = os.path.join(outDir, new_filename)
if filepath.suffix == '.java':
javafiles.setdefault(src_gen_path, os.path.join(binDir, new_filename[:-len('.java')] + '.class'))
else:
non_javafiles.setdefault(src_gen_path, os.path.join(binDir, new_filename))
except FileNotFoundError:
continue
return self

def build(self):
dist = self.subject
shadedDeps = dist.shaded_deps()
includedPaths = dist.included_paths()
patch = dist.shade.get('patch', [])
patch = dist.shade.get('patch', {})
excludedPaths = dist.excluded_paths()

binDir = dist.output_dir()
Expand All @@ -225,6 +246,9 @@ def build(self):
jarFilePath = dep.get_path(True)
srcFilePath = dep.get_source_path(True)

if srcFilePath is None:
mx.abort(f'Cannot shade {dep} without a source jar (missing sourceDigest?)')

for zipFilePath, outDir in [(jarFilePath, binDir), (srcFilePath, srcDir)]:
with zipfile.ZipFile(zipFilePath, 'r') as zf:
for zi in zf.infolist():
Expand Down Expand Up @@ -281,9 +305,6 @@ def build(self):
dst.write(contents)

# After generating (re)sources, run the normal Java build task.
if getattr(self, '_javafiles', None) == {}:
self._javafiles = None
super().prepare(self.daemons)
super().build()

def glob_match(path, pattern):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,15 @@ private static void install(IsolateThread thread) {
}

@Uninterruptible(reason = "Prevent VM operations that modify thread-local execution sampler state.")
private static void uninstall(IsolateThread thread) {
private void uninstall(IsolateThread thread) {
assert thread == CurrentIsolate.getCurrentThread() || VMOperation.isInProgressAtSafepoint();

if (ExecutionSamplerInstallation.isInstalled(thread)) {
/*
* Invalidate thread-local area. Once this value is set to null, the signal handler
* can't interrupt this thread anymore.
*/
storeIsolateThreadInNativeThreadLocal(WordFactory.nullPointer());
ExecutionSamplerInstallation.uninstalled(thread);
}
}
Expand Down
4 changes: 2 additions & 2 deletions sulong/mx.sulong/mx_sulong_gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@
@mx.command(_suite.name, 'create-asm-parser')
def create_asm_parser(args=None, out=None):
"""create the inline assembly parser using antlr"""
mx.suite("truffle").extensions.create_parser("com.oracle.truffle.llvm.asm.amd64", "com.oracle.truffle.llvm.asm.amd64", "InlineAssembly", COPYRIGHT_HEADER_BSD, args, out)
mx.suite("truffle").extensions.create_parser("com.oracle.truffle.llvm.asm.amd64", "com.oracle.truffle.llvm.asm.amd64", "InlineAssembly", args=args, out=out, shaded=True)


@mx.command(_suite.name, 'create-debugexpr-parser')
Expand All @@ -116,7 +116,7 @@ def create_debugexpr_parser(args=None, out=None):
mx.suite("truffle").extensions.create_parser(grammar_project="com.oracle.truffle.llvm.runtime",
grammar_package="com.oracle.truffle.llvm.runtime.debug.debugexpr.parser.antlr",
grammar_name="DebugExpression",
copyright_template=COPYRIGHT_HEADER_BSD, args=args, out=out)
args=args, out=out, shaded=True)


@mx.command(_suite.name, 'create-parsers')
Expand Down
2 changes: 1 addition & 1 deletion sulong/mx.sulong/native-image.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@

Requires = language:nfi language:antlr4

Args = --initialize-at-build-time=com.oracle.truffle.llvm,org.antlr.v4.runtime \
Args = --initialize-at-build-time=com.oracle.truffle.llvm \
-H:MaxRuntimeCompileMethods=10000 \
-H:+AddAllCharsets
8 changes: 3 additions & 5 deletions sulong/mx.sulong/suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@
"com.oracle.truffle.llvm.api",
"com.oracle.truffle.llvm.spi",
"com.oracle.truffle.llvm.nativemode.resources",
"truffle:ANTLR4",
"truffle:TRUFFLE_ANTLR4",
],
"requires" : [
"java.logging",
Expand Down Expand Up @@ -575,7 +575,7 @@
"sourceDirs" : ["src"],
"dependencies" : [
"com.oracle.truffle.llvm.runtime",
"truffle:ANTLR4",
"truffle:TRUFFLE_ANTLR4",
],
"checkstyle" : "com.oracle.truffle.llvm.runtime",
"javaCompliance" : "17+",
Expand Down Expand Up @@ -1621,9 +1621,7 @@
"truffle:TRUFFLE_NFI",
"SULONG_API",
"SULONG_NATIVE_RESOURCES",
],
"exclude" : [
"truffle:ANTLR4",
"truffle:TRUFFLE_ANTLR4",
],
"javaProperties" : {
"org.graalvm.language.llvm.home": "<sulong_home>",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@

// DO NOT MODIFY - generated from InlineAssembly.g4 using "mx create-asm-parser"

import org.antlr.v4.runtime.Lexer;
import org.antlr.v4.runtime.CharStream;
import org.antlr.v4.runtime.Token;
import org.antlr.v4.runtime.TokenStream;
import org.antlr.v4.runtime.*;
import org.antlr.v4.runtime.atn.*;
import org.antlr.v4.runtime.dfa.DFA;
import org.antlr.v4.runtime.misc.*;
import org.graalvm.shadowed.org.antlr.v4.runtime.Lexer;
import org.graalvm.shadowed.org.antlr.v4.runtime.CharStream;
import org.graalvm.shadowed.org.antlr.v4.runtime.Token;
import org.graalvm.shadowed.org.antlr.v4.runtime.TokenStream;
import org.graalvm.shadowed.org.antlr.v4.runtime.*;
import org.graalvm.shadowed.org.antlr.v4.runtime.atn.*;
import org.graalvm.shadowed.org.antlr.v4.runtime.dfa.DFA;
import org.graalvm.shadowed.org.antlr.v4.runtime.misc.*;

@SuppressWarnings({"all", "this-escape"})
public class InlineAssemblyLexer extends Lexer {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@

import com.oracle.truffle.llvm.runtime.nodes.func.LLVMInlineAssemblyRootNode;

import org.antlr.v4.runtime.atn.*;
import org.antlr.v4.runtime.dfa.DFA;
import org.antlr.v4.runtime.*;
import org.antlr.v4.runtime.misc.*;
import org.antlr.v4.runtime.tree.*;
import org.graalvm.shadowed.org.antlr.v4.runtime.atn.*;
import org.graalvm.shadowed.org.antlr.v4.runtime.dfa.DFA;
import org.graalvm.shadowed.org.antlr.v4.runtime.*;
import org.graalvm.shadowed.org.antlr.v4.runtime.misc.*;
import org.graalvm.shadowed.org.antlr.v4.runtime.tree.*;
import java.util.List;
import java.util.Iterator;
import java.util.ArrayList;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2019, 2020, Oracle and/or its affiliates.
* Copyright (c) 2019, 2023, Oracle and/or its affiliates.
*
* All rights reserved.
*
Expand Down Expand Up @@ -33,11 +33,11 @@
import com.oracle.truffle.llvm.runtime.debug.debugexpr.nodes.DebugExprNodeFactory;
import com.oracle.truffle.llvm.runtime.debug.debugexpr.parser.DebugExprException;
import com.oracle.truffle.llvm.runtime.nodes.api.LLVMExpressionNode;
import org.antlr.v4.runtime.BaseErrorListener;
import org.antlr.v4.runtime.CharStreams;
import org.antlr.v4.runtime.CommonTokenStream;
import org.antlr.v4.runtime.RecognitionException;
import org.antlr.v4.runtime.Recognizer;
import org.graalvm.shadowed.org.antlr.v4.runtime.BaseErrorListener;
import org.graalvm.shadowed.org.antlr.v4.runtime.CharStreams;
import org.graalvm.shadowed.org.antlr.v4.runtime.CommonTokenStream;
import org.graalvm.shadowed.org.antlr.v4.runtime.RecognitionException;
import org.graalvm.shadowed.org.antlr.v4.runtime.Recognizer;

public class DebugExprParser {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, 2021, Oracle and/or its affiliates.
* Copyright (c) 2016, 2023, Oracle and/or its affiliates.
*
* All rights reserved.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@

// DO NOT MODIFY - generated from DebugExpression.g4 using "mx create-parsers"

import org.antlr.v4.runtime.Lexer;
import org.antlr.v4.runtime.CharStream;
import org.antlr.v4.runtime.Token;
import org.antlr.v4.runtime.TokenStream;
import org.antlr.v4.runtime.*;
import org.antlr.v4.runtime.atn.*;
import org.antlr.v4.runtime.dfa.DFA;
import org.antlr.v4.runtime.misc.*;
import org.graalvm.shadowed.org.antlr.v4.runtime.Lexer;
import org.graalvm.shadowed.org.antlr.v4.runtime.CharStream;
import org.graalvm.shadowed.org.antlr.v4.runtime.Token;
import org.graalvm.shadowed.org.antlr.v4.runtime.TokenStream;
import org.graalvm.shadowed.org.antlr.v4.runtime.*;
import org.graalvm.shadowed.org.antlr.v4.runtime.atn.*;
import org.graalvm.shadowed.org.antlr.v4.runtime.dfa.DFA;
import org.graalvm.shadowed.org.antlr.v4.runtime.misc.*;

@SuppressWarnings({"all", "this-escape"})
public class DebugExpressionLexer extends Lexer {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@
import com.oracle.truffle.llvm.runtime.debug.debugexpr.parser.DebugExprType;
import com.oracle.truffle.llvm.runtime.nodes.api.LLVMExpressionNode;

import org.antlr.v4.runtime.atn.*;
import org.antlr.v4.runtime.dfa.DFA;
import org.antlr.v4.runtime.*;
import org.antlr.v4.runtime.misc.*;
import org.antlr.v4.runtime.tree.*;
import org.graalvm.shadowed.org.antlr.v4.runtime.atn.*;
import org.graalvm.shadowed.org.antlr.v4.runtime.dfa.DFA;
import org.graalvm.shadowed.org.antlr.v4.runtime.*;
import org.graalvm.shadowed.org.antlr.v4.runtime.misc.*;
import org.graalvm.shadowed.org.antlr.v4.runtime.tree.*;
import java.util.List;
import java.util.Iterator;
import java.util.ArrayList;
Expand Down
8 changes: 7 additions & 1 deletion truffle/external_repos/simplelanguage/language/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
<properties>
<antlr.version>4.12.0</antlr.version>
<jar.dir>${project.build.directory}/jars</jar.dir>
<test.argLine>--upgrade-module-path='${jar.dir}/truffle-api.jar' --add-opens org.graalvm.polylgot/org.graalvm.polyglot=ALL-UNNAMED --add-exports java.base/jdk.internal.module=ALL-UNNAMED</test.argLine>
<test.argLine>--upgrade-module-path='${jar.dir}/truffle-api.jar' --add-opens org.graalvm.polyglot/org.graalvm.polyglot=ALL-UNNAMED --add-exports java.base/jdk.internal.module=ALL-UNNAMED</test.argLine>
</properties>
<build>
<plugins>
Expand Down Expand Up @@ -140,6 +140,12 @@
<version>${graalvm.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.graalvm.shadowed</groupId>
<artifactId>antlr4</artifactId>
<version>${graalvm.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.graalvm.truffle</groupId>
<artifactId>truffle-tck</artifactId>
Expand Down
5 changes: 4 additions & 1 deletion truffle/mx.truffle/language-antlr4.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# This file contains support for building native images with antlr4 runtime dependency.

ImageClasspath = ${.}/antlr4.jar
# GR-48255: non-shaded antlr4.jar is still being used by FastR parser
ImageClasspath = ${.}/truffle-antlr4.jar:${.}/antlr4.jar

Args = --initialize-at-build-time=org.antlr.v4.runtime
Loading

0 comments on commit 70cd55d

Please sign in to comment.