Skip to content

Commit

Permalink
[GR-21477] Make black listed runtime methods used by Truffle or Tools…
Browse files Browse the repository at this point in the history
… in SVM a failure in the gate.
  • Loading branch information
tzezula committed Mar 9, 2020
1 parent 492d008 commit f5d9bf1
Show file tree
Hide file tree
Showing 7 changed files with 83 additions and 37 deletions.
10 changes: 0 additions & 10 deletions substratevm/ci_includes/gate.hocon
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,6 @@ gate-svm-js: {
]
}

gate-svm-truffle-tck: {
run: [
${svm-cmd-gate} ["build,truffletck"]
]
}

builds += [
${oraclejdk8} ${svm-common-linux-gate} ${gate-svm-js} ${svm-capabilities-base} {
name: "gate-svm-js"
Expand Down Expand Up @@ -60,8 +54,4 @@ builds += [
${svm-cmd-gate} ["build,helloworld,svmjunit,maven"]
]
}
${oraclejdk8} ${svm-common-linux-gate} ${gate-svm-truffle-tck} ${svm-capabilities-base} {
name: "gate-svm-truffle-tck"
timelimit: "30:00"
}
]
24 changes: 0 additions & 24 deletions substratevm/mx.substratevm/mx_substratevm.py
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,6 @@ def __getattr__(self, name):
'js',
'build',
'benchmarktest',
'truffletck',
'relocations',
"nativeimagehelp"
])
Expand Down Expand Up @@ -490,29 +489,6 @@ def svm_gate_body(args, tasks):
'-H:MaxRuntimeCompileMethods=1500', '--run-args', testlib, '--very-verbose', '--enable-timing']
native_unittest(native_unittest_args)

with Task('Truffle TCK', tasks, tags=[GraalTags.truffletck]) as t:
if t:
junit_native_dir = join(svmbuild_dir(), platform_name(), 'junit')
mkpath(junit_native_dir)
junit_tmp_dir = tempfile.mkdtemp(dir=junit_native_dir)
try:
unittest_deps = []
unittest_file = join(junit_tmp_dir, 'truffletck.tests')
_run_tests([], lambda deps, vm_launcher, vm_args: unittest_deps.extend(deps), _VMLauncher('dummy_launcher', None, mx_compiler.jdk), ['@Test', '@Parameters'], unittest_file, [], [re.compile('com.oracle.truffle.tck.tests')], None, mx.suite('truffle'))
if not exists(unittest_file):
mx.abort('TCK tests not found.')
unittest_deps.append(mx.dependency('truffle:TRUFFLE_SL_TCK'))
vm_image_args = mx.get_runtime_jvm_args(unittest_deps, jdk=mx_compiler.jdk)
tests_image = native_image(vm_image_args + ['--macro:truffle',
'--features=com.oracle.truffle.tck.tests.TruffleTCKFeature',
'-H:Class=org.junit.runner.JUnitCore', '-H:IncludeResources=com/oracle/truffle/sl/tck/resources/.*',
'-H:MaxRuntimeCompileMethods=3000'])
with open(unittest_file) as f:
test_classes = [l.rstrip() for l in f.readlines()]
mx.run([tests_image, '-Dtck.inlineVerifierInstrument=false'] + test_classes)
finally:
remove_tree(junit_tmp_dir)

with Task('Relocations in generated object file on Linux', tasks, tags=[GraalTags.relocations]) as t:
if t:
if mx.get_os() == 'linux':
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import com.oracle.graal.pointsto.meta.AnalysisMethod;
import com.oracle.graal.pointsto.meta.AnalysisType;
import com.oracle.svm.core.SubstrateOptions;
import com.oracle.svm.core.annotate.AutomaticFeature;
import com.oracle.svm.core.annotate.Substitute;
import com.oracle.svm.core.annotate.TargetClass;
import com.oracle.svm.core.option.HostedOptionKey;
Expand Down Expand Up @@ -88,7 +87,6 @@
* packages by {@code -H:TruffleTCKPermissionsLanguagePackages} option. You also need to disable
* folding of {@code System.getSecurityManager} using {@code -H:-FoldSecurityManagerGetter} option.
*/
@AutomaticFeature
public class PermissionsFeature implements Feature {

private static final String CONFIG = "truffle-language-permissions-config.json";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,9 @@ public static class Options {
@Option(help = "Enforce that the Truffle runtime provides the only implementation of Frame")//
public static final HostedOptionKey<Boolean> TruffleCheckFrameImplementation = new HostedOptionKey<>(true);

@Option(help = "Fail if a method known as not suitable for partial evaluation is reachable for runtime compilation")//
public static final HostedOptionKey<Boolean> TruffleCheckBlackListedMethods = new HostedOptionKey<>(false);

@Option(help = "Inline trivial methods in Truffle graphs during native image generation")//
public static final HostedOptionKey<Boolean> TruffleInlineDuringParsing = new HostedOptionKey<>(true);
}
Expand Down Expand Up @@ -765,7 +768,9 @@ private static int blacklistViolationComparator(GraalFeature.CallTreeNode n1, Gr
public void beforeCompilation(BeforeCompilationAccess config) {
BeforeCompilationAccessImpl access = (BeforeCompilationAccessImpl) config;

if (GraalFeature.Options.PrintRuntimeCompileMethods.getValue() && blacklistViolations.size() > 0) {
boolean failBlackListViolations = Options.TruffleCheckBlackListedMethods.getValue();
boolean printBlackListViolations = GraalFeature.Options.PrintRuntimeCompileMethods.getValue() || failBlackListViolations;
if (printBlackListViolations && blacklistViolations.size() > 0) {
System.out.println();
System.out.println("=== Found " + blacklistViolations.size() + " compilation blacklist violations ===");
System.out.println();
Expand All @@ -777,6 +782,9 @@ public void beforeCompilation(BeforeCompilationAccess config) {
System.out.println(" " + cur.getSourceReference());
}
}
if (failBlackListViolations) {
throw VMError.shouldNotReachHere("Blacklisted methods are reachable for runtime compilation");
}
}

if (warnViolations.size() > 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -789,6 +789,7 @@ Class<? extends TruffleLanguage<?>> getLanguage() {

@SuppressWarnings("static-method")
@ExportMessage
@TruffleBoundary
Object toDisplayString(@SuppressWarnings("unused") boolean config) {
try {
return this.proxy.toString();
Expand Down
8 changes: 8 additions & 0 deletions vm/ci_includes/vm-native.hocon
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,12 @@ builds += [
timelimit: "35:00"
name: gate-vm-native-graalpython
}
${vm_java_8} ${svm-common-linux-amd64} ${gate_vm_linux} {
run: [
[export, "SVM_SUITE="${svm_suite}]
[mx, --dynamicimports, "$SVM_SUITE,/tools", --disable-polyglot, "--skip-libraries=true", "--force-bash-launchers=gu,native-image-configure", gate, --no-warning-as-error, --tags, "build,svm_truffle_tck"]
]
timelimit: "35:00"
name: gate-svm-truffle-tck
}
]
65 changes: 65 additions & 0 deletions vm/mx.vm/mx_vm_gate.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import mx_sdk_vm_impl

import functools
import re
from mx_gate import Task

from os import environ, listdir, remove
Expand All @@ -57,6 +58,7 @@ class VmGateTasks:
integration = 'integration'
tools = 'tools'
libgraal = 'libgraal'
svm_truffle_tck = 'svm_truffle_tck'
svm_truffle_tck_js = 'svm-truffle-tck-js'


Expand Down Expand Up @@ -134,6 +136,7 @@ def is_truffle_fallback(arg):
gate_sulong(tasks)
gate_ruby(tasks)
gate_python(tasks)
gate_svm_truffle_tck(tasks)
gate_svm_truffle_tck_js(tasks)

def graalvm_svm():
Expand Down Expand Up @@ -222,6 +225,7 @@ def _svm_truffle_tck(native_image, svm_suite, language_suite, language_id):
report_file = join(svmbuild, "language_permissions.log")
options = [
'--language:{}'.format(language_id),
'--features=com.oracle.svm.truffle.tck.PermissionsFeature',
'-H:ClassInitialization=:build_time',
'-H:+EnforceMaxRuntimeCompileMethods',
'-cp',
Expand Down Expand Up @@ -254,3 +258,64 @@ def gate_svm_truffle_tck_js(tasks):
native_image_context, svm = graalvm_svm()
with native_image_context(svm.IMAGE_ASSERTION_FLAGS) as native_image:
_svm_truffle_tck(native_image, svm.suite, js_suite, 'js')

def gate_svm_truffle_tck(tasks):
with Task('SVM Truffle TCK', tasks, tags=[VmGateTasks.svm_truffle_tck]) as t:
if t:
#Blacklist check in Truffle and tools
tools_suite = mx.suite('tools')
if not tools_suite:
mx.abort("Cannot resolve tools suite.")
native_image_context, svm = graalvm_svm()
for dist in svm.suite.dists:
if dist.name == 'SVM_TRUFFLE_TCK':
cp = dist.classpath_repr()
break
if not cp:
mx.abort("Cannot resolve: SVM_TRUFFLE_TCK distribution.")
with native_image_context(svm.IMAGE_ASSERTION_FLAGS) as native_image:
svmbuild = mkdtemp()
try:
options = [
'--macro:truffle',
'--tool:chromeinspector',
'--tool:coverage',
'--tool:profiler',
'--tool:profiler',
'--tool:agentscript',
'-H:Path={}'.format(svmbuild),
'-H:+TruffleCheckBlackListedMethods',
'-cp',
cp,
'com.oracle.svm.truffle.tck.MockMain'
]
native_image(options)
finally:
mx.rmtree(svmbuild)

#Truffle TCK on SVM
svmbuild = mkdtemp()
try:
import mx_compiler
unittest_deps = []
unittest_file = join(svmbuild, 'truffletck.tests')
mx_unittest._run_tests([], lambda deps, vm_launcher, vm_args: unittest_deps.extend(deps), mx_unittest._VMLauncher('dummy_launcher', None, mx_compiler.jdk), ['@Test', '@Parameters'], unittest_file, [], [re.compile('com.oracle.truffle.tck.tests')], None, mx.suite('truffle'))
if not exists(unittest_file):
mx.abort('TCK tests not found.')
unittest_deps.append(mx.dependency('truffle:TRUFFLE_SL_TCK'))
unittest_deps.append(mx.dependency('truffle:TRUFFLE_TCK_INSTRUMENTATION'))
vm_image_args = mx.get_runtime_jvm_args(unittest_deps, jdk=mx_compiler.jdk)
options = [
'--macro:truffle',
'--features=com.oracle.truffle.tck.tests.TruffleTCKFeature',
'-H:Path={}'.format(svmbuild),
'-H:Class=org.junit.runner.JUnitCore',
'-H:IncludeResources=com/oracle/truffle/sl/tck/resources/.*',
'-H:MaxRuntimeCompileMethods=3000'
]
tests_image = native_image(vm_image_args + options)
with open(unittest_file) as f:
test_classes = [l.rstrip() for l in f.readlines()]
mx.run([tests_image] + test_classes)
finally:
mx.rmtree(svmbuild)

0 comments on commit f5d9bf1

Please sign in to comment.