diff options
| -rw-r--r-- | compiler/dex/quick/dex_file_method_inliner.cc | 9 | ||||
| -rw-r--r-- | compiler/driver/compiler_driver-inl.h | 14 | ||||
| -rw-r--r-- | compiler/optimizing/licm.cc | 3 | ||||
| -rw-r--r-- | compiler/optimizing/nodes.cc | 8 | ||||
| -rw-r--r-- | compiler/optimizing/optimizing_compiler.cc | 56 | ||||
| -rw-r--r-- | runtime/art_method.cc | 19 | ||||
| -rw-r--r-- | runtime/class_linker.cc | 23 | ||||
| -rw-r--r-- | runtime/class_linker_test.cc | 4 | ||||
| -rw-r--r-- | runtime/dex_file.cc | 6 | ||||
| -rw-r--r-- | runtime/dex_file_test.cc | 1 | ||||
| -rw-r--r-- | runtime/mirror/object_test.cc | 15 | ||||
| -rwxr-xr-x | test/960-default-smali/build | 23 | ||||
| -rwxr-xr-x | test/961-default-iface-resolution-generated/build | 27 | ||||
| -rwxr-xr-x | test/962-iface-static/build | 21 | ||||
| -rwxr-xr-x | test/963-default-range-smali/build | 21 | ||||
| -rwxr-xr-x | test/964-default-iface-init-generated/build | 21 | ||||
| -rwxr-xr-x | test/etc/default-build | 107 | ||||
| -rwxr-xr-x | test/run-test | 4 |
18 files changed, 228 insertions, 154 deletions
diff --git a/compiler/dex/quick/dex_file_method_inliner.cc b/compiler/dex/quick/dex_file_method_inliner.cc index e1a2838f3e..eaf2408763 100644 --- a/compiler/dex/quick/dex_file_method_inliner.cc +++ b/compiler/dex/quick/dex_file_method_inliner.cc @@ -756,14 +756,7 @@ uint32_t DexFileMethodInliner::FindClassIndex(const DexFile* dex_file, IndexCach return *class_index; } - const DexFile::StringId* string_id = dex_file->FindStringId(kClassCacheNames[index]); - if (string_id == nullptr) { - *class_index = kIndexNotFound; - return *class_index; - } - uint32_t string_index = dex_file->GetIndexForStringId(*string_id); - - const DexFile::TypeId* type_id = dex_file->FindTypeId(string_index); + const DexFile::TypeId* type_id = dex_file->FindTypeId(kClassCacheNames[index]); if (type_id == nullptr) { *class_index = kIndexNotFound; return *class_index; diff --git a/compiler/driver/compiler_driver-inl.h b/compiler/driver/compiler_driver-inl.h index 1a7dbe3a9f..14ba81d193 100644 --- a/compiler/driver/compiler_driver-inl.h +++ b/compiler/driver/compiler_driver-inl.h @@ -187,15 +187,11 @@ inline std::pair<bool, bool> CompilerDriver::IsClassOfStaticMemberAvailableToRef // Search dex file for localized ssb index, may fail if member's class is a parent // of the class mentioned in the dex file and there is no dex cache entry. std::string temp; - const DexFile::StringId* string_id = - dex_file->FindStringId(resolved_member->GetDeclaringClass()->GetDescriptor(&temp)); - if (string_id != nullptr) { - const DexFile::TypeId* type_id = - dex_file->FindTypeId(dex_file->GetIndexForStringId(*string_id)); - if (type_id != nullptr) { - // medium path, needs check of static storage base being initialized - storage_idx = dex_file->GetIndexForTypeId(*type_id); - } + const DexFile::TypeId* type_id = + dex_file->FindTypeId(resolved_member->GetDeclaringClass()->GetDescriptor(&temp)); + if (type_id != nullptr) { + // medium path, needs check of static storage base being initialized + storage_idx = dex_file->GetIndexForTypeId(*type_id); } } if (storage_idx != DexFile::kDexNoIndex) { diff --git a/compiler/optimizing/licm.cc b/compiler/optimizing/licm.cc index 27442d487e..c38bbe3477 100644 --- a/compiler/optimizing/licm.cc +++ b/compiler/optimizing/licm.cc @@ -122,9 +122,6 @@ void LICM::Run() { if (instruction->NeedsEnvironment()) { UpdateLoopPhisIn(instruction->GetEnvironment(), loop_info); } - // Move instruction into the pre header. Note that this cannot move - // a throwing instruction out of its try block since these are hoisted - // only from the header block (and TryBoundary would start a new block). instruction->MoveBefore(pre_header->GetLastInstruction()); } else if (instruction->CanThrow()) { // If `instruction` can throw, we cannot move further instructions diff --git a/compiler/optimizing/nodes.cc b/compiler/optimizing/nodes.cc index f825e50fe1..8b28ff91d4 100644 --- a/compiler/optimizing/nodes.cc +++ b/compiler/optimizing/nodes.cc @@ -1140,14 +1140,6 @@ std::ostream& operator<<(std::ostream& os, const HInstruction::InstructionKind& } void HInstruction::MoveBefore(HInstruction* cursor) { - if (kIsDebugBuild && CanThrowIntoCatchBlock()) { - // Make sure we are not moving a throwing instruction out of its try block. - DCHECK(cursor->GetBlock()->IsTryBlock()); - const HTryBoundary& current_try = block_->GetTryCatchInformation()->GetTryEntry(); - const HTryBoundary& cursor_try = cursor->GetBlock()->GetTryCatchInformation()->GetTryEntry(); - DCHECK(cursor_try.HasSameExceptionHandlersAs(current_try)); - } - next_->previous_ = previous_; if (previous_ != nullptr) { previous_->next_ = next_; diff --git a/compiler/optimizing/optimizing_compiler.cc b/compiler/optimizing/optimizing_compiler.cc index 98acc34378..6632f95ebe 100644 --- a/compiler/optimizing/optimizing_compiler.cc +++ b/compiler/optimizing/optimizing_compiler.cc @@ -494,30 +494,42 @@ static void RunOptimizations(HGraph* graph, // TODO: Update passes incompatible with try/catch so we have the same // pipeline for all methods. - if (!graph->HasTryCatch()) { + if (graph->HasTryCatch()) { + HOptimization* optimizations2[] = { + side_effects, + gvn, + dce2, + // The codegen has a few assumptions that only the instruction simplifier + // can satisfy. For example, the code generator does not expect to see a + // HTypeConversion from a type to the same type. + simplify4, + }; + + RunOptimizations(optimizations2, arraysize(optimizations2), pass_observer); + } else { MaybeRunInliner(graph, codegen, driver, stats, dex_compilation_unit, pass_observer, handles); - } - HOptimization* optimizations2[] = { - // BooleanSimplifier depends on the InstructionSimplifier removing - // redundant suspend checks to recognize empty blocks. - boolean_simplify, - fold2, // TODO: if we don't inline we can also skip fold2. - side_effects, - gvn, - licm, - induction, - bce, - simplify3, - lse, - dce2, - // The codegen has a few assumptions that only the instruction simplifier - // can satisfy. For example, the code generator does not expect to see a - // HTypeConversion from a type to the same type. - simplify4, - }; - - RunOptimizations(optimizations2, arraysize(optimizations2), pass_observer); + HOptimization* optimizations2[] = { + // BooleanSimplifier depends on the InstructionSimplifier removing + // redundant suspend checks to recognize empty blocks. + boolean_simplify, + fold2, // TODO: if we don't inline we can also skip fold2. + side_effects, + gvn, + licm, + induction, + bce, + simplify3, + lse, + dce2, + // The codegen has a few assumptions that only the instruction simplifier + // can satisfy. For example, the code generator does not expect to see a + // HTypeConversion from a type to the same type. + simplify4, + }; + + RunOptimizations(optimizations2, arraysize(optimizations2), pass_observer); + } RunArchOptimizations(driver->GetInstructionSet(), graph, stats, pass_observer); } diff --git a/runtime/art_method.cc b/runtime/art_method.cc index fe0afa6ebf..3f17702fa4 100644 --- a/runtime/art_method.cc +++ b/runtime/art_method.cc @@ -163,18 +163,13 @@ uint32_t ArtMethod::FindDexMethodIndexInOtherDexFile(const DexFile& other_dexfil return dex_method_idx; } const char* mid_declaring_class_descriptor = dexfile->StringByTypeIdx(mid.class_idx_); - const DexFile::StringId* other_descriptor = - other_dexfile.FindStringId(mid_declaring_class_descriptor); - if (other_descriptor != nullptr) { - const DexFile::TypeId* other_type_id = - other_dexfile.FindTypeId(other_dexfile.GetIndexForStringId(*other_descriptor)); - if (other_type_id != nullptr) { - const DexFile::MethodId* other_mid = other_dexfile.FindMethodId( - *other_type_id, other_dexfile.GetStringId(name_and_sig_mid.name_idx_), - other_dexfile.GetProtoId(name_and_sig_mid.proto_idx_)); - if (other_mid != nullptr) { - return other_dexfile.GetIndexForMethodId(*other_mid); - } + const DexFile::TypeId* other_type_id = other_dexfile.FindTypeId(mid_declaring_class_descriptor); + if (other_type_id != nullptr) { + const DexFile::MethodId* other_mid = other_dexfile.FindMethodId( + *other_type_id, other_dexfile.GetStringId(name_and_sig_mid.name_idx_), + other_dexfile.GetProtoId(name_and_sig_mid.proto_idx_)); + if (other_mid != nullptr) { + return other_dexfile.GetIndexForMethodId(*other_mid); } } return DexFile::kDexNoIndex; diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc index 69d0799096..5de1cacba8 100644 --- a/runtime/class_linker.cc +++ b/runtime/class_linker.cc @@ -616,10 +616,7 @@ void ClassLinker::InitWithoutImage(std::vector<std::unique_ptr<const DexFile>> b // initialized. { const DexFile& dex_file = java_lang_Object->GetDexFile(); - const DexFile::StringId* void_string_id = dex_file.FindStringId("V"); - CHECK(void_string_id != nullptr); - uint32_t void_string_index = dex_file.GetIndexForStringId(*void_string_id); - const DexFile::TypeId* void_type_id = dex_file.FindTypeId(void_string_index); + const DexFile::TypeId* void_type_id = dex_file.FindTypeId("V"); CHECK(void_type_id != nullptr); uint16_t void_type_idx = dex_file.GetIndexForTypeId(*void_type_id); // Now we resolve void type so the dex cache contains it. We use java.lang.Object class @@ -2740,17 +2737,13 @@ mirror::Class* ClassLinker::LookupClassFromImage(const char* descriptor) { for (int32_t i = 0; i < dex_caches->GetLength(); ++i) { mirror::DexCache* dex_cache = dex_caches->Get(i); const DexFile* dex_file = dex_cache->GetDexFile(); - // Try binary searching the string/type index. - const DexFile::StringId* string_id = dex_file->FindStringId(descriptor); - if (string_id != nullptr) { - const DexFile::TypeId* type_id = - dex_file->FindTypeId(dex_file->GetIndexForStringId(*string_id)); - if (type_id != nullptr) { - uint16_t type_idx = dex_file->GetIndexForTypeId(*type_id); - mirror::Class* klass = dex_cache->GetResolvedType(type_idx); - if (klass != nullptr) { - return klass; - } + // Try binary searching the type index by descriptor. + const DexFile::TypeId* type_id = dex_file->FindTypeId(descriptor); + if (type_id != nullptr) { + uint16_t type_idx = dex_file->GetIndexForTypeId(*type_id); + mirror::Class* klass = dex_cache->GetResolvedType(type_idx); + if (klass != nullptr) { + return klass; } } } diff --git a/runtime/class_linker_test.cc b/runtime/class_linker_test.cc index 0926ce3f6a..04b890063d 100644 --- a/runtime/class_linker_test.cc +++ b/runtime/class_linker_test.cc @@ -1032,9 +1032,7 @@ TEST_F(ClassLinkerTest, ResolveVerifyAndClinit) { mirror::Class* klass = class_linker_->FindClass(soa.Self(), "LStaticsFromCode;", class_loader); ArtMethod* clinit = klass->FindClassInitializer(sizeof(void*)); ArtMethod* getS0 = klass->FindDirectMethod("getS0", "()Ljava/lang/Object;", sizeof(void*)); - const DexFile::StringId* string_id = dex_file->FindStringId("LStaticsFromCode;"); - ASSERT_TRUE(string_id != nullptr); - const DexFile::TypeId* type_id = dex_file->FindTypeId(dex_file->GetIndexForStringId(*string_id)); + const DexFile::TypeId* type_id = dex_file->FindTypeId("LStaticsFromCode;"); ASSERT_TRUE(type_id != nullptr); uint32_t type_idx = dex_file->GetIndexForTypeId(*type_id); mirror::Class* uninit = ResolveVerifyAndClinit(type_idx, clinit, soa.Self(), true, false); diff --git a/runtime/dex_file.cc b/runtime/dex_file.cc index b3ca6ac131..3a93aace83 100644 --- a/runtime/dex_file.cc +++ b/runtime/dex_file.cc @@ -738,11 +738,7 @@ bool DexFile::CreateTypeList(const StringPiece& signature, uint16_t* return_type } // TODO: avoid creating a std::string just to get a 0-terminated char array std::string descriptor(signature.data() + start_offset, offset - start_offset); - const DexFile::StringId* string_id = FindStringId(descriptor.c_str()); - if (string_id == nullptr) { - return false; - } - const DexFile::TypeId* type_id = FindTypeId(GetIndexForStringId(*string_id)); + const DexFile::TypeId* type_id = FindTypeId(descriptor.c_str()); if (type_id == nullptr) { return false; } diff --git a/runtime/dex_file_test.cc b/runtime/dex_file_test.cc index 90b35a3e04..0a167bb8f7 100644 --- a/runtime/dex_file_test.cc +++ b/runtime/dex_file_test.cc @@ -297,6 +297,7 @@ TEST_F(DexFileTest, FindTypeId) { ASSERT_TRUE(type_str_id != nullptr); uint32_t type_str_idx = java_lang_dex_file_->GetIndexForStringId(*type_str_id); const DexFile::TypeId* type_id = java_lang_dex_file_->FindTypeId(type_str_idx); + ASSERT_EQ(type_id, java_lang_dex_file_->FindTypeId(type_str)); ASSERT_TRUE(type_id != nullptr); EXPECT_EQ(java_lang_dex_file_->GetIndexForTypeId(*type_id), i); } diff --git a/runtime/mirror/object_test.cc b/runtime/mirror/object_test.cc index f5a04457e7..c1284a639f 100644 --- a/runtime/mirror/object_test.cc +++ b/runtime/mirror/object_test.cc @@ -307,10 +307,7 @@ TEST_F(ObjectTest, CheckAndAllocArrayFromCode) { ScopedObjectAccess soa(Thread::Current()); Class* java_util_Arrays = class_linker_->FindSystemClass(soa.Self(), "Ljava/util/Arrays;"); ArtMethod* sort = java_util_Arrays->FindDirectMethod("sort", "([I)V", sizeof(void*)); - const DexFile::StringId* string_id = java_lang_dex_file_->FindStringId("[I"); - ASSERT_TRUE(string_id != nullptr); - const DexFile::TypeId* type_id = java_lang_dex_file_->FindTypeId( - java_lang_dex_file_->GetIndexForStringId(*string_id)); + const DexFile::TypeId* type_id = java_lang_dex_file_->FindTypeId("[I"); ASSERT_TRUE(type_id != nullptr); uint32_t type_idx = java_lang_dex_file_->GetIndexForTypeId(*type_id); Object* array = CheckAndAllocArrayFromCodeInstrumented( @@ -367,16 +364,10 @@ TEST_F(ObjectTest, StaticFieldFromCode) { Handle<mirror::ClassLoader> loader(hs.NewHandle(soa.Decode<ClassLoader*>(class_loader))); Class* klass = class_linker_->FindClass(soa.Self(), "LStaticsFromCode;", loader); ArtMethod* clinit = klass->FindClassInitializer(sizeof(void*)); - const DexFile::StringId* klass_string_id = dex_file->FindStringId("LStaticsFromCode;"); - ASSERT_TRUE(klass_string_id != nullptr); - const DexFile::TypeId* klass_type_id = dex_file->FindTypeId( - dex_file->GetIndexForStringId(*klass_string_id)); + const DexFile::TypeId* klass_type_id = dex_file->FindTypeId("LStaticsFromCode;"); ASSERT_TRUE(klass_type_id != nullptr); - const DexFile::StringId* type_string_id = dex_file->FindStringId("Ljava/lang/Object;"); - ASSERT_TRUE(type_string_id != nullptr); - const DexFile::TypeId* type_type_id = dex_file->FindTypeId( - dex_file->GetIndexForStringId(*type_string_id)); + const DexFile::TypeId* type_type_id = dex_file->FindTypeId("Ljava/lang/Object;"); ASSERT_TRUE(type_type_id != nullptr); const DexFile::StringId* name_str_id = dex_file->FindStringId("s0"); diff --git a/test/960-default-smali/build b/test/960-default-smali/build index 06692f93b8..3946de3787 100755 --- a/test/960-default-smali/build +++ b/test/960-default-smali/build @@ -20,14 +20,23 @@ set -e # Generate the smali Main.smali file or fail ${ANDROID_BUILD_TOP}/art/test/utils/python/generate_smali_main.py ./smali -if [[ $@ == *"--jvm"* ]]; then - # Build the Java files if we are running a --jvm test +USES_JAVA="false" +if [[ $ARGS == *"--jvm"* ]]; then + USES_JAVA="true" +elif [[ "$USE_JACK" == "true" ]]; then + if $JACK -D jack.java.source.version=1.8 >& /dev/null; then + USES_JAVA="true" + else + echo "WARNING: Cannot use jack because it does not support JLS 1.8. Falling back to smali" >&2 + fi +fi + +if [[ "$USES_JAVA" == "true" ]]; then + # We are compiling java code, create it. mkdir -p src - mkdir -p classes ${ANDROID_BUILD_TOP}/art/tools/extract-embedded-java ./smali ./src - ${JAVAC} -implicit:none -d classes $(find src -name '*.java') + # Ignore the smali directory. + EXTRA_ARGS="--no-smali" fi -# Build the smali files and make a dex -${SMALI} -JXmx256m ${SMALI_ARGS} --output classes.dex $(find smali -name '*.smali') -zip "$TEST_NAME.jar" classes.dex +./default-build "$@" "$EXTRA_ARGS" --experimental default-methods diff --git a/test/961-default-iface-resolution-generated/build b/test/961-default-iface-resolution-generated/build index 5eb851fa68..03cc62459a 100755 --- a/test/961-default-iface-resolution-generated/build +++ b/test/961-default-iface-resolution-generated/build @@ -17,8 +17,6 @@ # make us exit on a failure set -e -mkdir -p ./smali - # We will be making more files than the ulimit is set to allow. Remove it temporarily. OLD_ULIMIT=`ulimit -S` ulimit -S unlimited @@ -28,20 +26,31 @@ restore_ulimit() { } trap 'restore_ulimit' ERR +mkdir -p ./smali + # Generate the smali files and expected.txt or fail ./util-src/generate_smali.py ./smali ./expected.txt -if [[ $@ == *"--jvm"* ]]; then - # Build the Java files if we are running a --jvm test +USES_JAVA="false" +if [[ $ARGS == *"--jvm"* ]]; then + USES_JAVA="true" +elif [[ $USE_JACK == "true" ]]; then + if "$JACK" -D jack.java.source.version=1.8 >& /dev/null; then + USES_JAVA="true" + else + echo "WARNING: Cannot use jack because it does not support JLS 1.8. Falling back to smali" >&2 + fi +fi + +if [[ "$USES_JAVA" == "true" ]]; then + # We are compiling java code, create it. mkdir -p src - mkdir -p classes ${ANDROID_BUILD_TOP}/art/tools/extract-embedded-java ./smali ./src - ${JAVAC} -implicit:none -d classes $(find src -name '*.java') + # Ignore the smali directory. + EXTRA_ARGS="--no-smali" fi -# Build the smali files and make a dex -${SMALI} -JXmx512m ${SMALI_ARGS} --output classes.dex $(find smali -name '*.smali') -zip $TEST_NAME.jar classes.dex +./default-build "$@" "$EXTRA_ARGS" --experimental default-methods # Reset the ulimit back to its initial value restore_ulimit diff --git a/test/962-iface-static/build b/test/962-iface-static/build index 06bb3bdfb8..24e2feb228 100755 --- a/test/962-iface-static/build +++ b/test/962-iface-static/build @@ -17,14 +17,23 @@ # make us exit on a failure set -e +USES_JAVA="false" if [[ $@ == *"--jvm"* ]]; then - # Build the Java files if we are running a --jvm test + USES_JAVA="true" +elif [[ "$USE_JACK" == "true" ]]; then + if $JACK -D jack.java.source.version=1.8 2>/dev/null; then + USES_JAVA="true" + else + echo "WARNING: Cannot use jack because it does not support JLS 1.8. Falling back to smali" >&2 + fi +fi + +if [[ "$USES_JAVA" == "true" ]]; then + # We are compiling java code, create it. mkdir -p src - mkdir -p classes ${ANDROID_BUILD_TOP}/art/tools/extract-embedded-java ./smali ./src - ${JAVAC} -implicit:none -d classes $(find src -name '*.java') + # Ignore the smali directory. + EXTRA_ARGS="--no-smali" fi -# Build the smali files and make a dex -${SMALI} -JXmx512m ${SMALI_ARGS} --output classes.dex $(find smali -name '*.smali') -zip $TEST_NAME.jar classes.dex +./default-build "$@" "$EXTRA_ARGS" --experimental default-methods diff --git a/test/963-default-range-smali/build b/test/963-default-range-smali/build index 06bb3bdfb8..24e2feb228 100755 --- a/test/963-default-range-smali/build +++ b/test/963-default-range-smali/build @@ -17,14 +17,23 @@ # make us exit on a failure set -e +USES_JAVA="false" if [[ $@ == *"--jvm"* ]]; then - # Build the Java files if we are running a --jvm test + USES_JAVA="true" +elif [[ "$USE_JACK" == "true" ]]; then + if $JACK -D jack.java.source.version=1.8 2>/dev/null; then + USES_JAVA="true" + else + echo "WARNING: Cannot use jack because it does not support JLS 1.8. Falling back to smali" >&2 + fi +fi + +if [[ "$USES_JAVA" == "true" ]]; then + # We are compiling java code, create it. mkdir -p src - mkdir -p classes ${ANDROID_BUILD_TOP}/art/tools/extract-embedded-java ./smali ./src - ${JAVAC} -implicit:none -d classes $(find src -name '*.java') + # Ignore the smali directory. + EXTRA_ARGS="--no-smali" fi -# Build the smali files and make a dex -${SMALI} -JXmx512m ${SMALI_ARGS} --output classes.dex $(find smali -name '*.smali') -zip $TEST_NAME.jar classes.dex +./default-build "$@" "$EXTRA_ARGS" --experimental default-methods diff --git a/test/964-default-iface-init-generated/build b/test/964-default-iface-init-generated/build index b0fbe4bf47..d916f1b8e9 100755 --- a/test/964-default-iface-init-generated/build +++ b/test/964-default-iface-init-generated/build @@ -29,17 +29,26 @@ trap 'restore_ulimit' ERR # Generate the smali files and expected.txt or fail ./util-src/generate_smali.py ./smali ./expected.txt +USES_JAVA="false" if [[ $@ == *"--jvm"* ]]; then - # Build the Java files if we are running a --jvm test + USES_JAVA="true" +elif [[ "$USE_JACK" == "true" ]]; then + if $JACK -D jack.java.source.version=1.8 2>/dev/null; then + USES_JAVA="true" + else + echo "WARNING: Cannot use jack because it does not support JLS 1.8. Falling back to smali" >&2 + fi +fi + +if [[ "$USES_JAVA" == "true" ]]; then + # We are compiling java code, create it. mkdir -p src - mkdir -p classes ${ANDROID_BUILD_TOP}/art/tools/extract-embedded-java ./smali ./src - ${JAVAC} -implicit:none -d classes $(find src -name '*.java') + # Ignore the smali directory. + EXTRA_ARGS="--no-smali" fi -# Build the smali files and make a dex -${SMALI} -JXmx512m ${SMALI_ARGS} --output classes.dex $(find smali -name '*.smali') -zip $TEST_NAME.jar classes.dex +./default-build "$@" "$EXTRA_ARGS" --experimental default-methods # Reset the ulimit back to its initial value restore_ulimit diff --git a/test/etc/default-build b/test/etc/default-build index 47432168de..7242428f1e 100755 --- a/test/etc/default-build +++ b/test/etc/default-build @@ -17,8 +17,45 @@ # Stop if something fails. set -e +# Set default values for directories. +if [ -d smali ]; then + HAS_SMALI=true +else + HAS_SMALI=false +fi + +if [ -d src ]; then + HAS_SRC=true +else + HAS_SRC=false +fi + +if [ -d src2 ]; then + HAS_SRC2=true +else + HAS_SRC2=false +fi + +if [ -d src-multidex ]; then + HAS_SRC_MULTIDEX=true +else + HAS_SRC_MULTIDEX=false +fi + +if [ -d src-ex ]; then + HAS_SRC_EX=true +else + HAS_SRC_EX=false +fi + DX_FLAGS="" SKIP_DX_MERGER="false" +EXPERIMENTAL="" + +# Setup experimental flag mappings in a bash associative array. +declare -A JACK_EXPERIMENTAL_ARGS +JACK_EXPERIMENTAL_ARGS["default-methods"]="-D jack.java.source.version=1.8" +JACK_EXPERIMENTAL_ARGS["lambdas"]="-D jack.java.source.version=1.8" while true; do if [ "x$1" = "x--dx-option" ]; then @@ -28,6 +65,25 @@ while true; do shift elif [ "x$1" = "x--jvm" ]; then shift + elif [ "x$1" = "x--no-src" ]; then + HAS_SRC=false + shift + elif [ "x$1" = "x--no-src2" ]; then + HAS_SRC2=false + shift + elif [ "x$1" = "x--no-src-multidex" ]; then + HAS_SRC_MULTIDEX=false + shift + elif [ "x$1" = "x--no-src-ex" ]; then + HAS_SRC_EX=false + shift + elif [ "x$1" = "x--no-smali" ]; then + HAS_SMALI=false + shift + elif [ "x$1" = "x--experimental" ]; then + shift + EXPERIMENTAL="${EXPERIMENTAL} $1" + shift elif expr "x$1" : "x--" >/dev/null 2>&1; then echo "unknown $0 option: $1" 1>&2 exit 1 @@ -36,17 +92,22 @@ while true; do fi done +# Add args from the experimental mappings. +for experiment in ${EXPERIMENTAL}; do + JACK_ARGS="${JACK_ARGS} ${JACK_EXPERIMENTAL_ARGS[${experiment}]}" +done + if [ -e classes.dex ]; then zip $TEST_NAME.jar classes.dex exit 0 fi -if ! [ -d src ] && ! [ -d src2 ]; then +if ! [ "${HAS_SRC}" = "true" ] && ! [ "${HAS_SRC2}" = "true" ]; then # No src directory? Then forget about trying to run dx. SKIP_DX_MERGER="true" fi -if [ -d src-multidex ]; then +if [ "${HAS_SRC_MULTIDEX}" = "true" ]; then # Jack does not support this configuration unless we specify how to partition the DEX file # with a .jpp file. USE_JACK="false" @@ -54,27 +115,29 @@ fi if [ ${USE_JACK} = "true" ]; then # Jack toolchain - if [ -d src ]; then - ${JACK} --output-jack src.jack src + if [ "${HAS_SRC}" = "true" ]; then + ${JACK} ${JACK_ARGS} --output-jack src.jack src imported_jack_files="--import src.jack" fi - if [ -d src2 ]; then - ${JACK} --output-jack src2.jack src2 + if [ "${HAS_SRC2}" = "true" ]; then + ${JACK} ${JACK_ARGS} --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 . + if [ "${HAS_SRC}" = "true" ] || [ "${HAS_SRC2}" = "true" ]; then + ${JACK} ${JACK_ARGS} ${imported_jack_files} -D jack.import.type.policy=keep-first --output-dex . + fi else # Legacy toolchain with javac+dx - if [ -d src ]; then + if [ "${HAS_SRC}" = "true" ]; then mkdir classes - ${JAVAC} -implicit:none -classpath src-multidex -d classes `find src -name '*.java'` + ${JAVAC} ${JAVAC_ARGS} -implicit:none -classpath src-multidex -d classes `find src -name '*.java'` fi - if [ -d src-multidex ]; then + if [ "${HAS_SRC_MULTIDEX}" = "true" ]; then mkdir classes2 ${JAVAC} -implicit:none -classpath src -d classes2 `find src-multidex -name '*.java'` if [ ${NEED_DEX} = "true" ]; then @@ -83,20 +146,22 @@ else fi fi - if [ -d src2 ]; then + if [ "${HAS_SRC2}" = "true" ]; then mkdir -p classes - ${JAVAC} -d classes `find src2 -name '*.java'` + ${JAVAC} ${JAVAC_ARGS} -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 + if [ "${HAS_SRC}" = "true" ] || [ "${HAS_SRC2}" = "true" ]; then + 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 fi -if [ -d smali ]; then +if [ "${HAS_SMALI}" = "true" ]; then # Compile Smali classes - ${SMALI} -JXmx256m ${SMALI_ARGS} --output smali_classes.dex `find smali -name '*.smali'` + ${SMALI} -JXmx512m ${SMALI_ARGS} --output smali_classes.dex `find smali -name '*.smali'` # Don't bother with dexmerger if we provide our own main function in a smali file. if [ ${SKIP_DX_MERGER} = "false" ]; then @@ -106,18 +171,18 @@ if [ -d smali ]; then fi fi -if [ -d src-ex ]; then +if [ ${HAS_SRC_EX} = "true" ]; then 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 + ${JACK}:src.jack ${JACK_ARGS} --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'` + ${JAVAC} ${JAVAC_ARGS} -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 @@ -133,7 +198,7 @@ if [ -d src-ex ]; then fi # Create a single jar with two dex files for multidex. -if [ -d src-multidex ]; then +if [ ${HAS_SRC_MULTIDEX} = "true" ]; then zip $TEST_NAME.jar classes.dex classes2.dex elif [ ${NEED_DEX} = "true" ]; then zip $TEST_NAME.jar classes.dex diff --git a/test/run-test b/test/run-test index 3442fcf67d..f2bbaa7747 100755 --- a/test/run-test +++ b/test/run-test @@ -85,7 +85,7 @@ 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" + export JACK_CLASSPATH="${OUT_DIR:-$ANDROID_BUILD_TOP/out}/host/common/obj/JAVA_LIBRARIES/core-libart-hostdex_intermediates/classes.jack" fi # If JILL_JAR is not set, assume it is located in the prebuilts directory. @@ -440,7 +440,7 @@ elif [ "$runtime" = "art" ]; then if [ "$target_mode" = "no" ]; then # 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 + export ANDROID_HOST_OUT=${OUT_DIR:-$ANDROID_BUILD_TOP/out/}host/linux-x86 fi guess_host_arch_name run_args="${run_args} --boot ${ANDROID_HOST_OUT}/framework/core${image_suffix}${pic_image_suffix}.art" |