HOST_CORE_DEX_FILES := $(foreach jar,$(HOST_CORE_JARS), $(call intermediates-dir-for,JAVA_LIBRARIES,$(jar),t,COMMON)/javalib.jar)
TARGET_CORE_DEX_FILES := $(foreach jar,$(TARGET_CORE_JARS),$(call intermediates-dir-for,JAVA_LIBRARIES,$(jar), ,COMMON)/javalib.jar)
+
+# Classpath for Jack compilation: we only need core-libart.
+HOST_JACK_CLASSPATH := $(abspath $(call intermediates-dir-for,JAVA_LIBRARIES,core-libart-hostdex,t,COMMON)/classes.jack)
+TARGET_JACK_CLASSPATH := $(abspath $(call intermediates-dir-for,JAVA_LIBRARIES,core-libart, ,COMMON)/classes.jack)
endif # ART_ANDROID_COMMON_PATH_MK
rm classes/UnresClass.class
${JAVAC} -d classes `find src2 -name '*.java'`
-${DX} -JXmx256m --debug --dex --output=classes.dex classes
+if [ ${USE_JACK} = "true" ]; then
+ ${JILL} classes --output classes.jack
+ ${JACK} --import classes.jack --output-dex .
+else
+ ${DX} -JXmx256m --debug --dex --output=classes.dex classes
+ fi
zip $TEST_NAME.jar classes.dex
--- /dev/null
+#!/bin/bash
+#
+# Copyright (C) 2015 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# Stop if something fails.
+set -e
+
+# The test relies on DEX file produced by javac+dx so keep building with them for now
+# (see b/19467889)
+mkdir classes
+${JAVAC} -d classes `find src -name '*.java'`
+${DX} -JXmx256m --debug --dex --dump-to=classes.lst --output=classes.dex \
+ --dump-width=1000 ${DX_FLAGS} classes
+zip $TEST_NAME.jar classes.dex
--- /dev/null
+#!/bin/bash
+#
+# Copyright (C) 2015 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# Stop if something fails.
+set -e
+
+# The test relies on DEX file produced by javac+dx so keep building with them for now
+# (see b/19467889)
+mkdir classes
+${JAVAC} -d classes `find src -name '*.java'`
+${DX} -JXmx256m --debug --dex --dump-to=classes.lst --output=classes.dex \
+ --dump-width=1000 ${DX_FLAGS} classes
+zip $TEST_NAME.jar classes.dex
# ...but not at run time.
rm 'classes/android/test/anno/MissingAnnotation.class'
rm 'classes/android/test/anno/ClassWithInnerAnnotationClass$MissingInnerAnnotationClass.class'
-${DX} -JXmx256m --debug --dex --output=$TEST_NAME.jar classes
+
+if [ ${USE_JACK} = "true" ]; then
+ ${JILL} classes --output classes.jack
+ ${JACK} --import classes.jack --output-dex .
+else
+ ${DX} -JXmx256m --debug --dex --output=classes.dex classes
+fi
+
+zip $TEST_NAME.jar classes.dex
# Use classes that are compiled with ecj that exposes an invokeinterface
# issue when interfaces override methods in Object
-${DX} --debug --dex --dump-to=classes.lst --output=classes.dex classes
+if [ ${USE_JACK} = "true" ]; then
+ ${JILL} classes --output classes.jack
+ ${JACK} --import classes.jack --output-dex .
+else
+ ${DX} --debug --dex --dump-to=classes.lst --output=classes.dex classes
+fi
+
zip $TEST_NAME.jar classes.dex
gcc -Wall -Werror -o iface-gen iface-gen.c
./iface-gen
-mkdir classes
-${JAVAC} -d classes src/*.java
+if [ ${USE_JACK} = "true" ]; then
+ # Use the default Jack commands
+ ./default-build
+else
+ mkdir classes
+ ${JAVAC} -d classes src/*.java
-${DX} --debug --dex --dump-to=classes.lst --output=classes.dex classes
-zip $TEST_NAME.jar classes.dex
+ # dx needs more memory for that test so do not pass Xmx option here.
+ ${DX} --debug --dex --dump-to=classes.lst --output=classes.dex classes
+ zip $TEST_NAME.jar classes.dex
+fi
return s[0];
}
- public static void main(String[] args) {
- WeakReference<FinalizerTest> wimp = makeRef();
+ private static void printWeakReference(WeakReference<FinalizerTest> wimp) {
+ // Reference ft so we are sure the WeakReference cannot be cleared.
FinalizerTest keepLive = wimp.get();
-
System.out.println("wimp: " + wimpString(wimp));
+ }
+
+ public static void main(String[] args) {
+ WeakReference<FinalizerTest> wimp = makeRef();
+ printWeakReference(wimp);
/* this will try to collect and finalize ft */
- keepLive = null;
System.out.println("gc");
Runtime.getRuntime().gc();
printf("}\n") > fileName;
}'
-mkdir classes
-${JAVAC} -d classes src/*.java
+if [ ${USE_JACK} = "true" ]; then
+ ${JACK} --output-dex . src
+else
+ mkdir classes
+ ${JAVAC} -d classes src/*.java
+
+ ${DX} -JXmx500m --debug --dex --no-optimize --positions=none --no-locals --output=classes.dex classes
+fi
-${DX} -JXmx500m --debug --dex --no-optimize --positions=none --no-locals --output=classes.dex classes
zip $TEST_NAME.jar classes.dex
return;
}
- /*
- * Check the results of the last trip through. Everything in
- * "weak" should be matched in "strong", and the two should be
- * equivalent (object-wise, not just string-equality-wise).
- */
- for (int i = 0; i < MAX_DEPTH; i++) {
- if (strong[i] != weak[i].get()) {
- System.err.println("Deep: " + i + " strong=" + strong[i] +
- ", weak=" + weak[i].get());
- }
- }
+ checkStringReferences();
/*
* Wipe "strong", do a GC, see if "weak" got collected.
System.out.println("Deep: iters=" + iter / MAX_DEPTH);
}
+
+ /**
+ * Check the results of the last trip through. Everything in
+ * "weak" should be matched in "strong", and the two should be
+ * equivalent (object-wise, not just string-equality-wise).
+ *
+ * We do that check in a separate method to avoid retaining these
+ * String references in local DEX registers. In interpreter mode,
+ * they would retain these references until the end of the method
+ * or until they are updated to another value.
+ */
+ private static void checkStringReferences() {
+ for (int i = 0; i < MAX_DEPTH; i++) {
+ if (strong[i] != weak[i].get()) {
+ System.err.println("Deep: " + i + " strong=" + strong[i] +
+ ", weak=" + weak[i].get());
+ }
+ }
+ }
+
/**
* Recursively dive down, setting one or more local variables.
*
mkdir classes
${JAVAC} -source 1.4 -target 1.4 -d classes `find src -name '*.java'`
-# Suppress stderr to keep the inner class warnings out of the expected output.
-${DX} --debug --dex --dump-to=classes.lst --output=classes.dex --dump-width=1000 classes 2>/dev/null
+if [ ${USE_JACK} = "true" ]; then
+ ${JILL} classes --output classes.jack
+ ${JACK} --import classes.jack --output-dex .
+else
+ # Suppress stderr to keep the inner class warnings out of the expected output.
+ ${DX} --debug --dex --dump-to=classes.lst --output=classes.dex --dump-width=1000 classes 2>/dev/null
+fi
zip $TEST_NAME.jar classes.dex
printf("}\n") > fileName;
}'
+# The test relies on the error message produced by dx, not jack, so keep building with dx for now
+# (b/19467889).
mkdir classes
${JAVAC} -d classes `find src -name '*.java'`
${DX} -JXmx1024m --dex --no-optimize classes
-
set -e
mkdir classes
-${JAVAC} -d classes src/*.java
-${JASMIN} -d classes src/*.j
-${DX} --debug --dex --dump-to=classes.lst --output=classes.dex classes
+if [ ${USE_JACK} = "true" ]; then
+ ${JACK} --output-jack src.jack src
+
+ ${JASMIN} -d classes src/*.j
+ ${JILL} classes --output jasmin.jack
+
+ # We set jack.import.type.policy=keep-first to consider class definitions from jasmin first.
+ ${JACK} --import jasmin.jack --import src.jack -D jack.import.type.policy=keep-first --output-dex .
+else
+ ${JAVAC} -d classes src/*.java
+ ${JASMIN} -d classes src/*.j
+
+ ${DX} --debug --dex --dump-to=classes.lst --output=classes.dex classes
+fi
zip $TEST_NAME.jar classes.dex
${JAVAC} -d classes `find src -name '*.java'`
rm classes/TestException.class
-${DX} -JXmx256m --debug --dex --dump-to=classes.lst --output=classes.dex classes
+if [ ${USE_JACK} = "true" ]; then
+ ${JILL} classes --output classes.jack
+ ${JACK} --import classes.jack --output-dex .
+else
+ ${DX} -JXmx256m --debug --dex --dump-to=classes.lst --output=classes.dex classes
+fi
zip $TEST_NAME.jar classes.dex
# Stop if something fails.
set -e
-mkdir classes
-
# All except Main
+mkdir classes
${JAVAC} -d classes `find src -name '*.java'`
rm classes/Main.class
-${DX} -JXmx256m --debug --dex --dump-to=classes.lst --output=classes.dex classes
# Only Main
-${JAVAC} -d classes `find src -name '*.java'`
-rm classes/Second.class classes/FillerA.class classes/FillerB.class classes/Inf*.class
-${DX} -JXmx256m --debug --dex --dump-to=classes2.lst --output=classes2.dex classes
+mkdir classes2
+${JAVAC} -d classes2 `find src -name '*.java'`
+rm classes2/Second.class classes2/FillerA.class classes2/FillerB.class classes2/Inf*.class
+
+if [ ${USE_JACK} = "true" ]; then
+ # Create .jack files from classes generated with javac.
+ ${JILL} classes --output classes.jack
+ ${JILL} classes2 --output classes2.jack
+
+ # Create DEX files from .jack files.
+ ${JACK} --import classes.jack --output-dex .
+ mv classes.dex classes-1.dex
+ ${JACK} --import classes2.jack --output-dex .
+ mv classes.dex classes2.dex
+ mv classes-1.dex classes.dex
+else
+ # All except Main
+ ${DX} -JXmx256m --debug --dex --dump-to=classes.lst --output=classes.dex classes
+ # Only Main
+ ${DX} -JXmx256m --debug --dex --dump-to=classes2.lst --output=classes2.dex classes2
+fi
zip $TEST_NAME.jar classes.dex classes2.dex
}
// Allocate objects to definitely run GC before quitting.
- ArrayList<Object> l = new ArrayList<Object>();
- try {
- for (int i = 0; i < 100000; i++) {
- l.add(new ArrayList<Object>(i));
- }
- } catch (OutOfMemoryError oom) {
- }
- // Make the (outer) ArrayList unreachable. Note it may still
- // be reachable under an interpreter or a compiler without a
- // liveness analysis.
- l = null;
+ allocateObjectsToRunGc();
+
new ArrayList<Object>(50);
}
+ private static void allocateObjectsToRunGc() {
+ ArrayList<Object> l = new ArrayList<Object>();
+ try {
+ for (int i = 0; i < 100000; i++) {
+ l.add(new ArrayList<Object>(i));
+ }
+ } catch (OutOfMemoryError oom) {
+ }
+ }
+
private Main(CyclicBarrier startBarrier) {
this.startBarrier = startBarrier;
}
# mv NonInf.out classes/NonInf.class
# mv Main.class A.class A\$B.class A\$C.class classes/
-${DX} --debug --dex --dump-to=classes.lst --output=classes.dex classes
+if [ ${USE_JACK} = "true" ]; then
+ ${JILL} classes --output classes.jack
+ # Workaround b/19561685: disable sanity checks to produce a DEX file with invalid modifiers.
+ ${JACK} --sanity-checks off --import classes.jack --output-dex .
+else
+ ${DX} --debug --dex --dump-to=classes.lst --output=classes.dex classes
+fi
zip $TEST_NAME.jar classes.dex
# ...but not at run time.
rm 'classes/MissingClass.class'
rm 'classes/Main$MissingInnerClass.class'
-${DX} -JXmx256m --debug --dex --output=$TEST_NAME.jar classes
+
+if [ ${USE_JACK} = "true" ]; then
+ ${JILL} classes --output classes.jack
+ ${JACK} --import classes.jack --output-dex .
+else
+ ${DX} -JXmx256m --debug --dex --output=classes.dex classes
+fi
+zip $TEST_NAME.jar classes.dex
# Stop if something fails.
set -e
+# All except MirandaInterface
mkdir classes
-
-# All except Main
${JAVAC} -d classes `find src -name '*.java'`
rm classes/MirandaInterface.class
-${DX} -JXmx256m --debug --dex --dump-to=classes.lst --output=classes.dex classes
-# Only Main
-${JAVAC} -d classes `find src -name '*.java'`
-rm classes/Main.class classes/MirandaAbstract.class classes/MirandaClass*.class classes/MirandaInterface2*.class
-${DX} -JXmx256m --debug --dex --dump-to=classes2.lst --output=classes2.dex classes
+# Only MirandaInterface
+mkdir classes2
+${JAVAC} -d classes2 `find src -name '*.java'`
+rm classes2/Main.class classes2/MirandaAbstract.class classes2/MirandaClass*.class classes2/MirandaInterface2*.class
+
+if [ ${USE_JACK} = "true" ]; then
+ # Create .jack files from classes generated with javac.
+ ${JILL} classes --output classes.jack
+ ${JILL} classes2 --output classes2.jack
+
+ # Create DEX files from .jack files.
+ ${JACK} --import classes.jack --output-dex .
+ mv classes.dex classes-1.dex
+ ${JACK} --import classes2.jack --output-dex .
+ mv classes.dex classes2.dex
+ mv classes-1.dex classes.dex
+else
+ # All except Main
+ ${DX} -JXmx256m --debug --dex --dump-to=classes.lst --output=classes.dex classes
+ # Only Main
+ ${DX} -JXmx256m --debug --dex --dump-to=classes2.lst --output=classes2.dex classes2
+fi
zip $TEST_NAME.jar classes.dex classes2.dex
mkdir classes-ex
mv classes/Super.class classes-ex
-if [ ${NEED_DEX} = "true" ]; then
- ${DX} -JXmx256m --debug --dex --dump-to=classes.lst --output=classes.dex --dump-width=1000 classes
+if [ ${USE_JACK} = "true" ]; then
+ # Create .jack files from classes generated with javac.
+ ${JILL} classes --output classes.jack
+ ${JILL} classes-ex --output classes-ex.jack
+
+ # Create DEX files from .jack files.
+ ${JACK} --import classes.jack --output-dex .
zip $TEST_NAME.jar classes.dex
- ${DX} -JXmx256m --debug --dex --dump-to=classes-ex.lst --output=classes.dex --dump-width=1000 classes-ex
+ ${JACK} --import classes-ex.jack --output-dex .
zip ${TEST_NAME}-ex.jar classes.dex
+else
+ if [ ${NEED_DEX} = "true" ]; then
+ ${DX} -JXmx256m --debug --dex --dump-to=classes.lst --output=classes.dex --dump-width=1000 classes
+ zip $TEST_NAME.jar classes.dex
+ ${DX} -JXmx256m --debug --dex --dump-to=classes-ex.lst --output=classes.dex --dump-width=1000 classes-ex
+ zip ${TEST_NAME}-ex.jar classes.dex
+ fi
fi
# Stop if something fails.
set -e
-mkdir classes
-${JAVAC} -d classes `find src -name '*.java'`
-
-mkdir classes-ex
-${JAVAC} -d classes-ex `find src-ex -name '*.java'`
-
-if [ ${NEED_DEX} = "true" ]; then
- ${DX} -JXmx256m --debug --dex --dump-to=classes.lst --output=classes.dex --dump-width=1000 classes
+if [ ${USE_JACK} = "true" ]; then
+ ${JACK} --output-dex . src
zip $TEST_NAME.jar classes.dex
- ${DX} -JXmx256m --debug --dex --dump-to=classes-ex.lst --output=classes.dex --dump-width=1000 classes-ex
+
+ ${JACK} --output-dex . src-ex
zip ${TEST_NAME}-ex.jar classes.dex
+else
+ mkdir classes
+ ${JAVAC} -d classes `find src -name '*.java'`
+
+ mkdir classes-ex
+ ${JAVAC} -d classes-ex `find src-ex -name '*.java'`
+
+ if [ ${NEED_DEX} = "true" ]; then
+ ${DX} -JXmx256m --debug --dex --dump-to=classes.lst --output=classes.dex --dump-width=1000 classes
+ zip $TEST_NAME.jar classes.dex
+ ${DX} -JXmx256m --debug --dex --dump-to=classes-ex.lst --output=classes.dex --dump-width=1000 classes-ex
+ zip ${TEST_NAME}-ex.jar classes.dex
+ fi
fi
gcc -Wall -Werror -o classes-gen classes-gen.c
./classes-gen
-mkdir classes
-${JAVAC} -d classes src/*.java
+if [ ${USE_JACK} = "true" ]; then
+ # Use the default Jack commands
+ ./default-build
+else
+ mkdir classes
+ ${JAVAC} -d classes src/*.java
-${DX} --debug --dex --output=classes.dex classes
-zip $TEST_NAME.jar classes.dex
+ # dx needs more memory for that test so do not pass Xmx option here.
+ ${DX} --debug --dex --output=classes.dex classes
+ zip $TEST_NAME.jar classes.dex
+fi
--- /dev/null
+#!/bin/bash
+#
+# Copyright (C) 2015 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# Stop if something fails.
+set -e
+
+# The test relies on DEX file produced by javac+dx so keep building with them for now
+# (see b/19467889)
+mkdir classes
+${JAVAC} -d classes `find src -name '*.java'`
+${DX} -JXmx256m --debug --dex --dump-to=classes.lst --output=classes.dex \
+ --dump-width=1000 ${DX_FLAGS} classes
+zip $TEST_NAME.jar classes.dex
# Increase the file size limitation for classes.lst as the machine generated
# source file contains a lot of methods and is quite large.
-ulimit -S 4096
+
+# Jack generates big temp files so only apply ulimit for dx.
+if [ ${USE_JACK} = "false" ]; then
+ ulimit -S 4096
+fi
./default-build
TEST_ART_RUN_TEST_BUILD_RULES :=
# Dependencies for actually running a run-test.
-TEST_ART_RUN_TEST_DEPENDENCIES := $(DX) $(HOST_OUT_EXECUTABLES)/jasmin $(HOST_OUT_EXECUTABLES)/smali $(HOST_OUT_EXECUTABLES)/dexmerger
+TEST_ART_RUN_TEST_DEPENDENCIES := \
+ $(DX) \
+ $(HOST_OUT_EXECUTABLES)/jasmin \
+ $(HOST_OUT_EXECUTABLES)/smali \
+ $(HOST_OUT_EXECUTABLES)/dexmerger
+
+ifeq ($(ANDROID_COMPILE_WITH_JACK),true)
+ TEST_ART_RUN_TEST_DEPENDENCIES += \
+ $(JACK_JAR) \
+ $(JACK_LAUNCHER_JAR) \
+ $(JILL_JAR)
+endif
# Helper to create individual build targets for tests. Must be called with $(eval).
# $(1): the test number
define define-build-art-run-test
dmart_target := $(art_run_tests_dir)/art-run-tests/$(1)/touch
+ run_test_options = --build-only
+ ifeq ($(ANDROID_COMPILE_WITH_JACK),true)
+ run_test_options += --build-with-jack
+ else
+ run_test_options += --build-with-javac-dx
+ endif
+$$(dmart_target): PRIVATE_RUN_TEST_OPTIONS := $$(run_test_options)
$$(dmart_target): $(TEST_ART_RUN_TEST_DEPENDENCIES)
$(hide) rm -rf $$(dir $$@) && mkdir -p $$(dir $$@)
$(hide) DX=$(abspath $(DX)) JASMIN=$(abspath $(HOST_OUT_EXECUTABLES)/jasmin) \
SMALI=$(abspath $(HOST_OUT_EXECUTABLES)/smali) \
DXMERGER=$(abspath $(HOST_OUT_EXECUTABLES)/dexmerger) \
- $(LOCAL_PATH)/run-test --build-only --output-path $$(abspath $$(dir $$@)) $(1)
+ JACK=$(abspath $(JACK)) \
+ JACK_VM_COMMAND="$(JACK_VM) $(DEFAULT_JACK_VM_ARGS) $(JAVA_TMPDIR_ARG) -jar $(abspath $(JACK_LAUNCHER_JAR)) " \
+ JACK_CLASSPATH=$(TARGET_JACK_CLASSPATH) \
+ JACK_JAR=$(abspath $(JACK_JAR)) \
+ JILL_JAR=$(abspath $(JILL_JAR)) \
+ $(LOCAL_PATH)/run-test $$(PRIVATE_RUN_TEST_OPTIONS) --output-path $$(abspath $$(dir $$@)) $(1)
$(hide) touch $$@
TEST_ART_RUN_TEST_BUILD_RULES += $$(dmart_target)
dmart_target :=
+ run_test_options :=
endef
$(foreach test, $(TEST_ART_RUN_TESTS), $(eval $(call define-build-art-run-test,$(test))))
prereq_rule :=
test_groups :=
uc_host_or_target :=
+ jack_classpath :=
+ ifeq ($(ANDROID_COMPILE_WITH_JACK),true)
+ run_test_options += --build-with-jack
+ else
+ run_test_options += --build-with-javac-dx
+ endif
ifeq ($(ART_TEST_RUN_TEST_ALWAYS_CLEAN),true)
run_test_options += --always-clean
endif
test_groups := ART_RUN_TEST_HOST_RULES
run_test_options += --host
prereq_rule := $(ART_TEST_HOST_RUN_TEST_DEPENDENCIES)
+ jack_classpath := $(HOST_JACK_CLASSPATH)
else
ifeq ($(1),target)
uc_host_or_target := TARGET
test_groups := ART_RUN_TEST_TARGET_RULES
prereq_rule := test-art-target-sync
+ jack_classpath := $(TARGET_JACK_CLASSPATH)
else
$$(error found $(1) expected $(TARGET_TYPES))
endif
run_test_options := --android-root $(ART_TEST_ANDROID_ROOT) $$(run_test_options)
endif
$$(run_test_rule_name): PRIVATE_RUN_TEST_OPTIONS := $$(run_test_options)
+$$(run_test_rule_name): PRIVATE_JACK_CLASSPATH := $$(jack_classpath)
.PHONY: $$(run_test_rule_name)
-$$(run_test_rule_name): $(DX) $(HOST_OUT_EXECUTABLES)/jasmin $(HOST_OUT_EXECUTABLES)/smali $(HOST_OUT_EXECUTABLES)/dexmerger $(HOST_OUT_EXECUTABLES)/hprof-conv $$(prereq_rule)
+$$(run_test_rule_name): $(TEST_ART_RUN_TEST_DEPENDENCIES) $(HOST_OUT_EXECUTABLES)/hprof-conv $$(prereq_rule)
$(hide) $$(call ART_TEST_SKIP,$$@) && \
- DX=$(abspath $(DX)) JASMIN=$(abspath $(HOST_OUT_EXECUTABLES)/jasmin) \
+ DX=$(abspath $(DX)) \
+ JASMIN=$(abspath $(HOST_OUT_EXECUTABLES)/jasmin) \
SMALI=$(abspath $(HOST_OUT_EXECUTABLES)/smali) \
DXMERGER=$(abspath $(HOST_OUT_EXECUTABLES)/dexmerger) \
+ JACK=$(abspath $(JACK)) \
+ JACK_VM_COMMAND="$(JACK_VM) $(DEFAULT_JACK_VM_ARGS) $(JAVA_TMPDIR_ARG) -jar $(abspath $(JACK_LAUNCHER_JAR)) " \
+ JACK_CLASSPATH=$$(PRIVATE_JACK_CLASSPATH) \
+ JACK_JAR=$(abspath $(JACK_JAR)) \
+ JILL_JAR=$(abspath $(JILL_JAR)) \
art/test/run-test $$(PRIVATE_RUN_TEST_OPTIONS) $(12) \
&& $$(call ART_TEST_PASSED,$$@) || $$(call ART_TEST_FAILED,$$@)
$$(hide) (echo $(MAKECMDGOALS) | grep -q $$@ && \
run_test_options :=
run_test_rule_name :=
prereq_rule :=
+ jack_classpath :=
endef # define-test-art-run-test
$(foreach target, $(TARGET_TYPES), \
exit 0
fi
-if [ -d src ]; then
- mkdir classes
- ${JAVAC} -implicit:none -classpath src-multidex -d classes `find src -name '*.java'`
-fi
-
-if [ -d src2 ]; then
- mkdir -p classes
- ${JAVAC} -d classes `find src2 -name '*.java'`
-fi
-
if ! [ -d src ] && ! [ -d src2 ]; then
# No src directory? Then forget about trying to run dx.
SKIP_DX_MERGER="true"
fi
-if [ ${NEED_DEX} = "true" -a ${SKIP_DX_MERGER} = "false" ]; then
- ${DX} -JXmx256m --debug --dex --dump-to=classes.lst --output=classes.dex \
- --dump-width=1000 ${DX_FLAGS} classes
+if [ -d src-multidex ]; then
+ # Jack does not support this configuration unless we specify how to partition the DEX file
+ # with a .jpp file.
+ USE_JACK="false"
+fi
+
+if [ ${USE_JACK} = "true" ]; then
+ # Jack toolchain
+ if [ -d src ]; then
+ ${JACK} --output-jack src.jack src
+ imported_jack_files="--import src.jack"
+ fi
+
+ if [ -d src2 ]; then
+ ${JACK} --output-jack src2.jack src2
+ imported_jack_files="--import src2.jack ${imported_jack_files}"
+ fi
+
+ # Compile jack files into a DEX file. We set jack.import.type.policy=keep-first to consider
+ # class definitions from src2 first.
+ ${JACK} ${imported_jack_files} -D jack.import.type.policy=keep-first --output-dex .
+else
+ # Legacy toolchain with javac+dx
+ if [ -d src ]; then
+ mkdir classes
+ ${JAVAC} -implicit:none -classpath src-multidex -d classes `find src -name '*.java'`
+ fi
+
+ if [ -d src-multidex ]; then
+ mkdir classes2
+ ${JAVAC} -implicit:none -classpath src -d classes2 `find src-multidex -name '*.java'`
+ if [ ${NEED_DEX} = "true" ]; then
+ ${DX} -JXmx256m --debug --dex --dump-to=classes2.lst --output=classes2.dex \
+ --dump-width=1000 ${DX_FLAGS} classes2
+ fi
+ fi
+
+ if [ -d src2 ]; then
+ mkdir -p classes
+ ${JAVAC} -d classes `find src2 -name '*.java'`
+ fi
+
+ if [ ${NEED_DEX} = "true" -a ${SKIP_DX_MERGER} = "false" ]; then
+ ${DX} -JXmx256m --debug --dex --dump-to=classes.lst --output=classes.dex \
+ --dump-width=1000 ${DX_FLAGS} classes
+ fi
fi
if [ -d smali ]; then
fi
if [ -d src-ex ]; then
- mkdir classes-ex
- ${JAVAC} -d classes-ex -cp classes `find src-ex -name '*.java'`
- if [ ${NEED_DEX} = "true" ]; then
- ${DX} -JXmx256m --debug --dex --dump-to=classes-ex.lst --output=classes-ex.dex \
- --dump-width=1000 ${DX_FLAGS} classes-ex
-
- # quick shuffle so that the stored name is "classes.dex"
- mv classes.dex classes-1.dex
- mv classes-ex.dex classes.dex
- zip $TEST_NAME-ex.jar classes.dex
- mv classes.dex classes-ex.dex
- mv classes-1.dex classes.dex
+ if [ ${USE_JACK} = "true" ]; then
+ # Rename previous "classes.dex" so it is not overwritten.
+ mv classes.dex classes-1.dex
+ #TODO find another way to append src.jack to the jack classpath
+ ${JACK}:src.jack --output-dex . src-ex
+ zip $TEST_NAME-ex.jar classes.dex
+ # Restore previous "classes.dex" so it can be zipped.
+ mv classes-1.dex classes.dex
+ else
+ mkdir classes-ex
+ ${JAVAC} -d classes-ex -cp classes `find src-ex -name '*.java'`
+ if [ ${NEED_DEX} = "true" ]; then
+ ${DX} -JXmx256m --debug --dex --dump-to=classes-ex.lst --output=classes-ex.dex \
+ --dump-width=1000 ${DX_FLAGS} classes-ex
+
+ # quick shuffle so that the stored name is "classes.dex"
+ mv classes.dex classes-1.dex
+ mv classes-ex.dex classes.dex
+ zip $TEST_NAME-ex.jar classes.dex
+ mv classes.dex classes-ex.dex
+ mv classes-1.dex classes.dex
+ fi
fi
fi
# Create a single jar with two dex files for multidex.
if [ -d src-multidex ]; then
- mkdir classes2
- ${JAVAC} -implicit:none -classpath src -d classes2 `find src-multidex -name '*.java'`
- if [ ${NEED_DEX} = "true" ]; then
- ${DX} -JXmx256m --debug --dex --dump-to=classes2.lst --output=classes2.dex \
- --dump-width=1000 ${DX_FLAGS} classes2
- zip $TEST_NAME.jar classes.dex classes2.dex
- fi
+ zip $TEST_NAME.jar classes.dex classes2.dex
elif [ ${NEED_DEX} = "true" ]; then
zip $TEST_NAME.jar classes.dex
fi
export RUN="${progdir}/etc/run-test-jar"
export DEX_LOCATION=/data/run-test/${test_dir}
export NEED_DEX="true"
+export USE_JACK="false"
# If dx was not set by the environment variable, assume it is in the path.
if [ -z "$DX" ]; then
export DXMERGER="dexmerger"
fi
+# If jack was not set by the environment variable, assume it is in the path.
+if [ -z "$JACK" ]; then
+ export JACK="jack"
+fi
+
+# If the tree is compiled with Jack, build test with Jack by default.
+if [ "$ANDROID_COMPILE_WITH_JACK" = "true" ]; then
+ USE_JACK="true"
+fi
+
+# ANDROID_BUILD_TOP is not set in a build environment.
+if [ -z "$ANDROID_BUILD_TOP" ]; then
+ export ANDROID_BUILD_TOP=$oldwd
+fi
+
+# If JACK_VM_COMMAND is not set, assume it launches the prebuilt jack-launcher.
+if [ -z "$JACK_VM_COMMAND" ]; then
+ if [ ! -z "$TMPDIR" ]; then
+ jack_temp_dir="-Djava.io.tmpdir=$TMPDIR"
+ fi
+ export JACK_VM_COMMAND="java -Dfile.encoding=UTF-8 -Xms2560m -XX:+TieredCompilation $jack_temp_dir -jar $ANDROID_BUILD_TOP/prebuilts/sdk/tools/jack-launcher.jar"
+fi
+
+# If JACK_CLASSPATH is not set, assume it only contains core-libart.
+if [ -z "$JACK_CLASSPATH" ]; then
+ export JACK_CLASSPATH="$ANDROID_BUILD_TOP/out/host/common/obj/JAVA_LIBRARIES/core-libart-hostdex_intermediates/classes.jack"
+fi
+
+# If JACK_JAR is not set, assume it is located in the prebuilts directory.
+if [ -z "$JACK_JAR" ]; then
+ export JACK_JAR="$ANDROID_BUILD_TOP/prebuilts/sdk/tools/jack.jar"
+fi
+
+# If JILL_JAR is not set, assume it is located in the prebuilts directory.
+if [ -z "$JILL_JAR" ]; then
+ export JILL_JAR="$ANDROID_BUILD_TOP/prebuilts/sdk/tools/jill.jar"
+fi
+
+export JACK="$JACK -g -cp $JACK_CLASSPATH"
+export JILL="java -jar $JILL_JAR"
info="info.txt"
build="build"
runtime="jvm"
prebuild_mode="no"
NEED_DEX="false"
+ USE_JACK="false"
run_args="${run_args} --jvm"
shift
elif [ "x$1" = "x-O" ]; then
elif [ "x$1" = "x--build-only" ]; then
build_only="yes"
shift
+ elif [ "x$1" = "x--build-with-javac-dx" ]; then
+ USE_JACK="false"
+ shift
+ elif [ "x$1" = "x--build-with-jack" ]; then
+ USE_JACK="true"
+ shift
elif [ "x$1" = "x--output-path" ]; then
shift
tmp_dir=$1
fi
elif [ "$runtime" = "art" ]; then
if [ "$target_mode" = "no" ]; then
- # ANDROID_BUILD_TOP and ANDROID_HOST_OUT are not set in a build environment.
- if [ -z "$ANDROID_BUILD_TOP" ]; then
- export ANDROID_BUILD_TOP=$oldwd
- fi
+ # ANDROID_HOST_OUT is not set in a build environment.
if [ -z "$ANDROID_HOST_OUT" ]; then
export ANDROID_HOST_OUT=$ANDROID_BUILD_TOP/out/host/linux-x86
fi
echo " --debuggable Whether to compile Java code for a debugger."
echo " --gdb Run under gdb; incompatible with some tests."
echo " --build-only Build test files only (off by default)."
+ echo " --build-with-javac-dx Build test files with javac and dx (on by default)."
+ echo " --build-with-jack Build test files with jack and jill (off by default)."
echo " --interpreter Enable interpreter only mode (off by default)."
echo " --jit Enable jit (off by default)."
echo " --optimizing Enable optimizing compiler (default)."
# if Checker is not invoked and the test only runs the program.
build_args="${build_args} --dx-option --no-optimize"
+ # Jack does not necessarily generate the same DEX output than dx. Because these tests depend
+ # on a particular DEX output, keep building them with dx for now (b/19467889).
+ USE_JACK="false"
+
if [ "$runtime" = "art" -a "$image_suffix" = "-optimizing" -a "$target_mode" = "no" -a "$debuggable" = "no" ]; then
run_checker="yes"
run_args="${run_args} -Xcompiler-option --dump-cfg=$tmp_dir/$cfg_output \
fi
# To cause tests to fail fast, limit the file sizes created by dx, dex2oat and ART output to 2MB.
-file_size_limit=2048
+build_file_size_limit=2048
+run_file_size_limit=2048
if echo "$test_dir" | grep 089; then
- file_size_limit=5120
+ build_file_size_limit=5120
+ run_file_size_limit=5120
elif echo "$test_dir" | grep 083; then
- file_size_limit=5120
+ build_file_size_limit=5120
+ run_file_size_limit=5120
fi
-if ! ulimit -S "$file_size_limit"; then
- echo "ulimit file size setting failed"
+if [ ${USE_JACK} = "false" ]; then
+ # Set ulimit if we build with dx only, Jack can generate big temp files.
+ if ! ulimit -S "$build_file_size_limit"; then
+ echo "ulimit file size setting failed"
+ fi
fi
good="no"
build_exit="$?"
echo "build exit status: $build_exit" 1>&2
if [ "$build_exit" = '0' ]; then
+ if ! ulimit -S "$run_file_size_limit"; then
+ echo "ulimit file size setting failed"
+ fi
echo "${test_dir}: running..." 1>&2
"./${run}" $run_args "$@" 2>&1
run_exit="$?"
"./${build}" $build_args >"$build_output" 2>&1
build_exit="$?"
if [ "$build_exit" = '0' ]; then
+ if ! ulimit -S "$run_file_size_limit"; then
+ echo "ulimit file size setting failed"
+ fi
echo "${test_dir}: running..." 1>&2
"./${run}" $run_args "$@" >"$output" 2>&1
if [ "$run_checker" = "yes" ]; then
"./${build}" $build_args >"$build_output" 2>&1
build_exit="$?"
if [ "$build_exit" = '0' ]; then
+ if ! ulimit -S "$run_file_size_limit"; then
+ echo "ulimit file size setting failed"
+ fi
echo "${test_dir}: running..." 1>&2
"./${run}" $run_args "$@" >"$output" 2>&1
run_exit="$?"