diff options
| -rw-r--r-- | dex2oat/dex2oat.cc | 2 | ||||
| -rw-r--r-- | runtime/vdex_file.h | 8 | ||||
| -rwxr-xr-x | test/674-vdex-uncompress/build | 19 | ||||
| -rw-r--r-- | test/674-vdex-uncompress/expected.txt | 2 | ||||
| -rw-r--r-- | test/674-vdex-uncompress/info.txt | 2 | ||||
| -rw-r--r-- | test/674-vdex-uncompress/run | 17 | ||||
| -rw-r--r-- | test/674-vdex-uncompress/src/Main.java | 37 |
7 files changed, 82 insertions, 5 deletions
diff --git a/dex2oat/dex2oat.cc b/dex2oat/dex2oat.cc index a836d75a72..8555abf9fd 100644 --- a/dex2oat/dex2oat.cc +++ b/dex2oat/dex2oat.cc @@ -2404,7 +2404,7 @@ class Dex2Oat FINAL { bool AddDexFileSources() { TimingLogger::ScopedTiming t2("AddDexFileSources", timings_); - if (input_vdex_file_ != nullptr) { + if (input_vdex_file_ != nullptr && input_vdex_file_->HasDexSection()) { DCHECK_EQ(oat_writers_.size(), 1u); const std::string& name = zip_location_.empty() ? dex_locations_[0] : zip_location_; DCHECK(!name.empty()); diff --git a/runtime/vdex_file.h b/runtime/vdex_file.h index 4e45128420..202380de8f 100644 --- a/runtime/vdex_file.h +++ b/runtime/vdex_file.h @@ -218,6 +218,10 @@ class VdexFile { ArrayRef<const uint8_t> GetQuickenedInfoOf(const DexFile& dex_file, uint32_t dex_method_idx) const; + bool HasDexSection() const { + return GetHeader().GetDexSize() != 0; + } + private: uint32_t GetQuickeningInfoTableOffset(const uint8_t* source_dex_begin) const; @@ -235,10 +239,6 @@ class VdexFile { uint32_t num_method_ids, const ArrayRef<const uint8_t>& quickening_info) const; - bool HasDexSection() const { - return GetHeader().GetDexSize() != 0; - } - bool ContainsDexFile(const DexFile& dex_file) const; const uint8_t* DexBegin() const { diff --git a/test/674-vdex-uncompress/build b/test/674-vdex-uncompress/build new file mode 100755 index 0000000000..7b1804d3e0 --- /dev/null +++ b/test/674-vdex-uncompress/build @@ -0,0 +1,19 @@ +#!/bin/bash +# +# Copyright 2018 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. + +# Uncompress and align the dex files so that dex2oat will not copy the dex +# code to the .vdex file. +./default-build "$@" --zip-compression-method store --zip-align 4 diff --git a/test/674-vdex-uncompress/expected.txt b/test/674-vdex-uncompress/expected.txt new file mode 100644 index 0000000000..d0f61f692c --- /dev/null +++ b/test/674-vdex-uncompress/expected.txt @@ -0,0 +1,2 @@ +In foo +In foo diff --git a/test/674-vdex-uncompress/info.txt b/test/674-vdex-uncompress/info.txt new file mode 100644 index 0000000000..6aa6f7b0d5 --- /dev/null +++ b/test/674-vdex-uncompress/info.txt @@ -0,0 +1,2 @@ +Test that dex2oat can compile an APK that has uncompressed dex files, +and where --input-vdex is passed. diff --git a/test/674-vdex-uncompress/run b/test/674-vdex-uncompress/run new file mode 100644 index 0000000000..edf699f842 --- /dev/null +++ b/test/674-vdex-uncompress/run @@ -0,0 +1,17 @@ +#!/bin/bash +# +# Copyright (C) 2018 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. + +exec ${RUN} -Xcompiler-option --compiler-filter=verify --vdex "${@}" diff --git a/test/674-vdex-uncompress/src/Main.java b/test/674-vdex-uncompress/src/Main.java new file mode 100644 index 0000000000..0a25b564fe --- /dev/null +++ b/test/674-vdex-uncompress/src/Main.java @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2018 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. + */ + +public class Main { + Main() { + // Will be quickened with RETURN_VOID_NO_BARRIER. + } + + public static void main(String[] args) { + Main m = new Main(); + Object o = m; + // The call and field accesses will be quickened. + m.foo(m.a); + + // The checkcast will be quickened. + m.foo(((Main)o).a); + } + + int a; + void foo(int a) { + System.out.println("In foo"); + } +} + |