Skip to content

Commit 6536d13

Browse files
committed
[GR-15847] Ged rid of some deopt loops in our unittests
PullRequest: graalpython/550
2 parents 78ecc87 + 9f686d7 commit 6536d13

File tree

2 files changed

+46
-4
lines changed

2 files changed

+46
-4
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/WeakRefModuleBuiltins.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@
4444
import java.lang.ref.ReferenceQueue;
4545
import java.util.List;
4646

47-
import com.oracle.graal.python.PythonLanguage;
4847
import com.oracle.graal.python.builtins.Builtin;
4948
import com.oracle.graal.python.builtins.CoreFunctions;
5049
import com.oracle.graal.python.builtins.PythonBuiltinClassType;
@@ -184,8 +183,8 @@ private ReferenceQueue<Object> getWeakReferenceQueue() {
184183
ReferenceQueue<Object> queue = (ReferenceQueue<Object>) queueObject;
185184
return queue;
186185
} else {
187-
CompilerDirectives.transferToInterpreter();
188-
if (PythonLanguage.getContextRef().get().getCore().isInitialized()) {
186+
if (getContext().getCore().isInitialized()) {
187+
CompilerDirectives.transferToInterpreter();
189188
throw new IllegalStateException("the weak reference queue was modified!");
190189
} else {
191190
// returning a null reference queue is fine, it just means

mx.graalpython/mx_graalpython.py

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import shutil
3232
import sys
3333
import tempfile
34+
import time
3435
from argparse import ArgumentParser
3536

3637
import mx
@@ -147,7 +148,9 @@ def do_run_python(args, extra_vm_args=None, env=None, jdk=None, **kwargs):
147148
def punittest(args):
148149
if '--regex' not in args:
149150
args += ['--regex', r'(graal\.python)|(com\.oracle\.truffle\.tck\.tests)']
150-
args += ["-Dgraal.TraceTruffleCompilation=true", "-Dgraal.TruffleCompilationExceptionsAreFatal=false", "-Dgraal.TrufflePerformanceWarningsAreFatal=false"]
151+
args += ["-Dgraal.TruffleCompilationExceptionsAreFatal=false",
152+
"-Dgraal.TruffleCompilationExceptionsArePrinted=true",
153+
"-Dgraal.TrufflePerformanceWarningsAreFatal=false"]
151154
mx_unittest.unittest(args)
152155

153156

@@ -1019,12 +1022,52 @@ def python_coverage(args):
10191022
mx.command_function("jacocoreport")(["--omit-excluded", "--format=html"])
10201023

10211024

1025+
def python_build_watch(args):
1026+
"""
1027+
Watch the suite and on any changes to .class, .jar, .h, or .c files rebuild.
1028+
By default, rebuilds only the archives and non-Java projects.
1029+
"""
1030+
parser = ArgumentParser(prog='mx python-build-watch')
1031+
parser.add_argument('--full', action='store_true', help='Run a full mx build', required=False)
1032+
parser.add_argument('--graalvm', action='store_true', help='Build a graalvm', required=False)
1033+
parser.add_argument('--no-java', action='store_true', help='Build only archives and native projects [default]', required=False)
1034+
args = parser.parse_args(args)
1035+
if sum([args.full, args.graalvm, args.no_java]) > 1:
1036+
mx.abort("Only one of --full, --graalvm, --no-java can be specified")
1037+
while True:
1038+
out = mx.OutputCapture()
1039+
mx.run([
1040+
"inotifywait", "-q", "-e", "close_write,moved_to", "-r", "--format=%f",
1041+
"--exclude", ".*\\.py$",
1042+
"@%s" % os.path.join(SUITE.dir, ".git"),
1043+
SUITE.dir
1044+
], out=out)
1045+
changed_file = out.data.strip()
1046+
mx.logv(changed_file)
1047+
suffixes = [".c", ".h", ".class", ".jar"]
1048+
if args.full:
1049+
suffixes.append(".java")
1050+
elif args.graalvm:
1051+
suffixes.extend([".java", ".py"])
1052+
if any(changed_file.endswith(ext) for ext in [".c", ".h", ".class", ".jar"]):
1053+
mx.log("Build needed ...")
1054+
time.sleep(2)
1055+
if args.full:
1056+
mx.command_function("build")()
1057+
elif args.graalvm:
1058+
mx.log(python_gvm())
1059+
else:
1060+
nativebuild([])
1061+
break
1062+
1063+
10221064
# ----------------------------------------------------------------------------------------------------------------------
10231065
#
10241066
# register the suite commands (if any)
10251067
#
10261068
# ----------------------------------------------------------------------------------------------------------------------
10271069
mx.update_commands(SUITE, {
1070+
'python-build-watch': [python_build_watch, ''],
10281071
'python': [python, '[Python args|@VM options]'],
10291072
'python3': [python, '[Python args|@VM options]'],
10301073
'deploy-binary-if-master': [deploy_binary_if_master, ''],

0 commit comments

Comments
 (0)