Merge "Implemented first version of java/dex fuzz testing script."
diff --git a/Android.mk b/Android.mk
index 3740ed8..cc18660 100644
--- a/Android.mk
+++ b/Android.mk
@@ -82,8 +82,6 @@
include $(art_path)/tools/dexfuzz/Android.mk
include $(art_path)/libart_fake/Android.mk
-
-# ART_HOST_DEPENDENCIES depends on Android.executable.mk above for ART_HOST_EXECUTABLES
ART_HOST_DEPENDENCIES := \
$(ART_HOST_EXECUTABLES) \
$(ART_HOST_DEX_DEPENDENCIES) \
diff --git a/build/Android.common.mk b/build/Android.common.mk
index 6befec5..b0fa124 100644
--- a/build/Android.common.mk
+++ b/build/Android.common.mk
@@ -26,7 +26,6 @@
# Mac OS doesn't support low-4GB allocation in a 64-bit process. So we won't be able to create
# our heaps.
ART_HOST_SUPPORTED_ARCH := x86
- ART_MULTILIB_OVERRIDE_host := 32
endif
ART_COVERAGE := false
@@ -59,27 +58,19 @@
ifneq ($(filter %64,$(TARGET_ARCH)),)
ART_PHONY_TEST_TARGET_SUFFIX := 64
2ND_ART_PHONY_TEST_TARGET_SUFFIX := 32
- ART_TARGET_ARCH_32 := $(TARGET_2ND_ARCH)
- ART_TARGET_ARCH_64 := $(TARGET_ARCH)
else
# TODO: ???
$(warning Do not know what to do with this multi-target configuration!)
ART_PHONY_TEST_TARGET_SUFFIX := 32
2ND_ART_PHONY_TEST_TARGET_SUFFIX :=
- ART_TARGET_ARCH_32 := $(TARGET_ARCH)
- ART_TARGET_ARCH_64 :=
endif
else
ifneq ($(filter %64,$(TARGET_ARCH)),)
ART_PHONY_TEST_TARGET_SUFFIX := 64
2ND_ART_PHONY_TEST_TARGET_SUFFIX :=
- ART_TARGET_ARCH_32 :=
- ART_TARGET_ARCH_64 := $(TARGET_ARCH)
else
ART_PHONY_TEST_TARGET_SUFFIX := 32
2ND_ART_PHONY_TEST_TARGET_SUFFIX :=
- ART_TARGET_ARCH_32 := $(TARGET_ARCH)
- ART_TARGET_ARCH_64 :=
endif
endif
@@ -88,23 +79,17 @@
ifeq ($(HOST_PREFER_32_BIT),true)
ART_PHONY_TEST_HOST_SUFFIX := 32
2ND_ART_PHONY_TEST_HOST_SUFFIX :=
- ART_HOST_ARCH_32 := x86
- ART_HOST_ARCH_64 :=
ART_HOST_ARCH := x86
2ND_ART_HOST_ARCH :=
2ND_HOST_ARCH :=
- ART_HOST_LIBRARY_PATH := $(HOST_LIBRARY_PATH)
ART_HOST_OUT_SHARED_LIBRARIES := $(2ND_HOST_OUT_SHARED_LIBRARIES)
2ND_ART_HOST_OUT_SHARED_LIBRARIES :=
else
ART_PHONY_TEST_HOST_SUFFIX := 64
2ND_ART_PHONY_TEST_HOST_SUFFIX := 32
- ART_HOST_ARCH_32 := x86
- ART_HOST_ARCH_64 := x86_64
ART_HOST_ARCH := x86_64
2ND_ART_HOST_ARCH := x86
2ND_HOST_ARCH := x86
- ART_HOST_LIBRARY_PATH := $(HOST_LIBRARY_PATH)
ART_HOST_OUT_SHARED_LIBRARIES := $(HOST_OUT_SHARED_LIBRARIES)
2ND_ART_HOST_OUT_SHARED_LIBRARIES := $(2ND_HOST_OUT_SHARED_LIBRARIES)
endif
diff --git a/build/Android.common_build.mk b/build/Android.common_build.mk
index 7edc1cc..4c82506 100644
--- a/build/Android.common_build.mk
+++ b/build/Android.common_build.mk
@@ -18,7 +18,6 @@
ART_ANDROID_COMMON_BUILD_MK = true
include art/build/Android.common.mk
-include art/build/Android.common_utils.mk
# These can be overridden via the environment or by editing to
# enable/disable certain build configuration.
@@ -34,26 +33,6 @@
ART_BUILD_HOST_NDEBUG ?= true
ART_BUILD_HOST_DEBUG ?= true
-# Set this to change what opt level ART is built at.
-ART_DEBUG_OPT_FLAG ?= -O2
-ART_NDEBUG_OPT_FLAG ?= -O3
-
-# Enable the static builds only for checkbuilds.
-ifneq (,$(filter checkbuild,$(MAKECMDGOALS)))
- ART_BUILD_HOST_STATIC ?= true
-else
- ART_BUILD_HOST_STATIC ?= false
-endif
-
-# Asan does not support static linkage
-ifdef SANITIZE_HOST
- ART_BUILD_HOST_STATIC := false
-endif
-
-ifneq ($(HOST_OS),linux)
- ART_BUILD_HOST_STATIC := false
-endif
-
ifeq ($(ART_BUILD_TARGET_NDEBUG),false)
$(info Disabling ART_BUILD_TARGET_NDEBUG)
endif
@@ -66,375 +45,31 @@
ifeq ($(ART_BUILD_HOST_DEBUG),false)
$(info Disabling ART_BUILD_HOST_DEBUG)
endif
-ifeq ($(ART_BUILD_HOST_STATIC),true)
-$(info Enabling ART_BUILD_HOST_STATIC)
-endif
-
-ifeq ($(ART_TEST_DEBUG_GC),true)
- ART_DEFAULT_GC_TYPE := SS
- ART_USE_TLAB := true
-endif
-
-#
-# Used to change the default GC. Valid values are CMS, SS, GSS. The default is CMS.
-#
-ART_DEFAULT_GC_TYPE ?= CMS
-art_default_gc_type_cflags := -DART_DEFAULT_GC_TYPE_IS_$(ART_DEFAULT_GC_TYPE)
-
-ART_HOST_CLANG := true
-ART_TARGET_CLANG := true
ART_CPP_EXTENSION := .cc
-ART_C_INCLUDES := \
- external/icu/icu4c/source/common \
- external/lz4/lib \
- external/valgrind/include \
- external/valgrind \
- external/vixl/src \
- external/zlib \
-
-# We optimize Thread::Current() with a direct TLS access. This requires access to a private
-# Bionic header.
-# Note: technically we only need this on device, but this avoids the duplication of the includes.
-ART_C_INCLUDES += bionic/libc/private
-
-art_cflags :=
-
-# Warn about thread safety violations with clang.
-art_cflags += -Wthread-safety -Wthread-safety-negative
-
-# Warn if switch fallthroughs aren't annotated.
-art_cflags += -Wimplicit-fallthrough
-
-# Enable float equality warnings.
-art_cflags += -Wfloat-equal
-
-# Enable warning of converting ints to void*.
-art_cflags += -Wint-to-void-pointer-cast
-
-# Enable warning of wrong unused annotations.
-art_cflags += -Wused-but-marked-unused
-
-# Enable warning for deprecated language features.
-art_cflags += -Wdeprecated
-
-# Enable warning for unreachable break & return.
-art_cflags += -Wunreachable-code-break -Wunreachable-code-return
-
-# Bug: http://b/29823425 Disable -Wconstant-conversion and
-# -Wundefined-var-template for Clang update to r271374
-art_cflags += -Wno-constant-conversion -Wno-undefined-var-template
-
-# Enable missing-noreturn only on non-Mac. As lots of things are not implemented for Apple, it's
-# a pain.
-ifneq ($(HOST_OS),darwin)
- art_cflags += -Wmissing-noreturn
-endif
-
-# Base set of cflags used by all things ART.
-art_cflags += \
- -fno-rtti \
- -ggdb3 \
- -Wall \
- -Werror \
- -Wextra \
- -Wstrict-aliasing \
- -fstrict-aliasing \
- -Wunreachable-code \
- -Wredundant-decls \
- -Wshadow \
- -Wunused \
- -fvisibility=protected \
- $(art_default_gc_type_cflags)
-
-# The architectures the compiled tools are able to run on. Setting this to 'all' will cause all
-# architectures to be included.
-ART_TARGET_CODEGEN_ARCHS ?= svelte
-ART_HOST_CODEGEN_ARCHS ?= all
-
-ifeq ($(ART_TARGET_CODEGEN_ARCHS),all)
- ART_TARGET_CODEGEN_ARCHS := $(sort $(ART_TARGET_SUPPORTED_ARCH) $(ART_HOST_SUPPORTED_ARCH))
-else
- ifeq ($(ART_TARGET_CODEGEN_ARCHS),svelte)
- ART_TARGET_CODEGEN_ARCHS := $(sort $(ART_TARGET_ARCH_64) $(ART_TARGET_ARCH_32))
- endif
-endif
-ifeq ($(ART_HOST_CODEGEN_ARCHS),all)
- ART_HOST_CODEGEN_ARCHS := $(sort $(ART_TARGET_SUPPORTED_ARCH) $(ART_HOST_SUPPORTED_ARCH))
-else
- ifeq ($(ART_HOST_CODEGEN_ARCHS),svelte)
- ART_HOST_CODEGEN_ARCHS := $(sort $(ART_TARGET_CODEGEN_ARCHS) $(ART_HOST_ARCH_64) $(ART_HOST_ARCH_32))
- endif
-endif
-
-ifneq (,$(filter arm64,$(ART_TARGET_CODEGEN_ARCHS)))
- ART_TARGET_CODEGEN_ARCHS += arm
-endif
-ifneq (,$(filter mips64,$(ART_TARGET_CODEGEN_ARCHS)))
- ART_TARGET_CODEGEN_ARCHS += mips
-endif
-ifneq (,$(filter x86_64,$(ART_TARGET_CODEGEN_ARCHS)))
- ART_TARGET_CODEGEN_ARCHS += x86
-endif
-ART_TARGET_CODEGEN_ARCHS := $(sort $(ART_TARGET_CODEGEN_ARCHS))
-ifneq (,$(filter arm64,$(ART_HOST_CODEGEN_ARCHS)))
- ART_HOST_CODEGEN_ARCHS += arm
-endif
-ifneq (,$(filter mips64,$(ART_HOST_CODEGEN_ARCHS)))
- ART_HOST_CODEGEN_ARCHS += mips
-endif
-ifneq (,$(filter x86_64,$(ART_HOST_CODEGEN_ARCHS)))
- ART_HOST_CODEGEN_ARCHS += x86
-endif
-ART_HOST_CODEGEN_ARCHS := $(sort $(ART_HOST_CODEGEN_ARCHS))
-
-# Base set of cflags used by target build only
-art_target_cflags := \
- $(foreach target_arch,$(strip $(ART_TARGET_CODEGEN_ARCHS)), -DART_ENABLE_CODEGEN_$(target_arch))
-# Base set of cflags used by host build only
-art_host_cflags := \
- $(foreach host_arch,$(strip $(ART_HOST_CODEGEN_ARCHS)), -DART_ENABLE_CODEGEN_$(host_arch))
-
-# Base set of asflags used by all things ART.
-art_asflags :=
-
-# Missing declarations: too many at the moment, as we use "extern" quite a bit.
-# -Wmissing-declarations \
-
-
-
-ifdef ART_IMT_SIZE
- art_cflags += -DIMT_SIZE=$(ART_IMT_SIZE)
-else
- # Default is 43
- art_cflags += -DIMT_SIZE=43
-endif
-
-ifeq ($(ART_HEAP_POISONING),true)
- art_cflags += -DART_HEAP_POISONING=1
- art_asflags += -DART_HEAP_POISONING=1
-endif
-
-#
-# Used to change the read barrier type. Valid values are BAKER, BROOKS, TABLELOOKUP.
-# The default is BAKER.
-#
-ART_READ_BARRIER_TYPE ?= BAKER
-
-ifeq ($(ART_USE_READ_BARRIER),true)
- art_cflags += -DART_USE_READ_BARRIER=1
- art_cflags += -DART_READ_BARRIER_TYPE_IS_$(ART_READ_BARRIER_TYPE)=1
- art_asflags += -DART_USE_READ_BARRIER=1
- art_asflags += -DART_READ_BARRIER_TYPE_IS_$(ART_READ_BARRIER_TYPE)=1
-
- # Temporarily override -fstack-protector-strong with -fstack-protector to avoid a major
- # slowdown with the read barrier config. b/26744236.
- art_cflags += -fstack-protector
-endif
-
-ifeq ($(ART_USE_TLAB),true)
- art_cflags += -DART_USE_TLAB=1
-endif
-
-# Are additional statically-linked ART host binaries (dex2oats,
-# oatdumps, etc.) getting built?
-ifeq ($(ART_BUILD_HOST_STATIC),true)
- art_cflags += -DART_BUILD_HOST_STATIC=1
-endif
-
-# Temporary flag allowing to disable recent changes in oat file management.
-ifneq ($(ART_ENABLE_VDEX),false)
- art_cflags += -DART_ENABLE_VDEX
-endif
-
-# Cflags for non-debug ART and ART tools.
-art_non_debug_cflags := \
- $(ART_NDEBUG_OPT_FLAG)
-
-# Cflags for debug ART and ART tools.
-art_debug_cflags := \
- $(ART_DEBUG_OPT_FLAG) \
- -DDYNAMIC_ANNOTATIONS_ENABLED=1 \
- -DVIXL_DEBUG \
- -UNDEBUG
-
-# Assembler flags for non-debug ART and ART tools.
-art_non_debug_asflags :=
-
-# Assembler flags for debug ART and ART tools.
-art_debug_asflags := -UNDEBUG
-
-art_host_non_debug_cflags := $(art_non_debug_cflags)
-art_target_non_debug_cflags := $(art_non_debug_cflags)
-
-###
-# Frame size
-###
-
-# Size of the stack-overflow gap.
-ART_STACK_OVERFLOW_GAP_arm := 8192
-ART_STACK_OVERFLOW_GAP_arm64 := 8192
-ART_STACK_OVERFLOW_GAP_mips := 16384
-ART_STACK_OVERFLOW_GAP_mips64 := 16384
-ART_STACK_OVERFLOW_GAP_x86 := 8192
-ART_STACK_OVERFLOW_GAP_x86_64 := 8192
-ART_COMMON_STACK_OVERFLOW_DEFINES := \
- -DART_STACK_OVERFLOW_GAP_arm=$(ART_STACK_OVERFLOW_GAP_arm) \
- -DART_STACK_OVERFLOW_GAP_arm64=$(ART_STACK_OVERFLOW_GAP_arm64) \
- -DART_STACK_OVERFLOW_GAP_mips=$(ART_STACK_OVERFLOW_GAP_mips) \
- -DART_STACK_OVERFLOW_GAP_mips64=$(ART_STACK_OVERFLOW_GAP_mips64) \
- -DART_STACK_OVERFLOW_GAP_x86=$(ART_STACK_OVERFLOW_GAP_x86) \
- -DART_STACK_OVERFLOW_GAP_x86_64=$(ART_STACK_OVERFLOW_GAP_x86_64) \
-
-# Keep these as small as possible. We have separate values as we have some host vs target
-# specific code (and previously GCC vs Clang).
-ART_HOST_FRAME_SIZE_LIMIT := 1736
-ART_TARGET_FRAME_SIZE_LIMIT := 1736
-
-# Frame size adaptations for instrumented builds.
-ifdef SANITIZE_TARGET
- ART_TARGET_FRAME_SIZE_LIMIT := 6400
-endif
-
-# Add frame-size checks for non-debug builds.
-ifeq ($(HOST_OS),linux)
- ifneq ($(ART_COVERAGE),true)
- ifneq ($(NATIVE_COVERAGE),true)
- art_host_non_debug_cflags += -Wframe-larger-than=$(ART_HOST_FRAME_SIZE_LIMIT)
- art_target_non_debug_cflags += -Wframe-larger-than=$(ART_TARGET_FRAME_SIZE_LIMIT)
- endif
- endif
-endif
-
-
-ART_HOST_CFLAGS := $(art_cflags)
-ART_TARGET_CFLAGS := $(art_cflags)
-
-ART_HOST_ASFLAGS := $(art_asflags)
-ART_TARGET_ASFLAGS := $(art_asflags)
-
-# Bug: 15446488. We don't omit the frame pointer to work around
-# clang/libunwind bugs that cause SEGVs in run-test-004-ThreadStress.
-ART_HOST_CFLAGS += -fno-omit-frame-pointer
-
ifndef LIBART_IMG_HOST_BASE_ADDRESS
$(error LIBART_IMG_HOST_BASE_ADDRESS unset)
endif
-ART_HOST_CFLAGS += -DART_BASE_ADDRESS=$(LIBART_IMG_HOST_BASE_ADDRESS)
-ART_HOST_CFLAGS += $(art_host_cflags)
-
-ART_HOST_CFLAGS += -DART_FRAME_SIZE_LIMIT=$(ART_HOST_FRAME_SIZE_LIMIT) \
- $(ART_COMMON_STACK_OVERFLOW_DEFINES)
-
ifndef LIBART_IMG_TARGET_BASE_ADDRESS
$(error LIBART_IMG_TARGET_BASE_ADDRESS unset)
endif
-ART_TARGET_CFLAGS += -DART_TARGET \
- -DART_BASE_ADDRESS=$(LIBART_IMG_TARGET_BASE_ADDRESS) \
-
-ART_TARGET_CFLAGS += -DART_FRAME_SIZE_LIMIT=$(ART_TARGET_FRAME_SIZE_LIMIT) \
- $(ART_COMMON_STACK_OVERFLOW_DEFINES)
-
-ifeq ($(ART_TARGET_LINUX),true)
-# Setting ART_TARGET_LINUX to true compiles art/ assuming that the target device
-# will be running linux rather than android.
-ART_TARGET_CFLAGS += -DART_TARGET_LINUX
-else
-# The ART_TARGET_ANDROID macro is passed to target builds, which check
-# against it instead of against __ANDROID__ (which is provided by target
-# toolchains).
-ART_TARGET_CFLAGS += -DART_TARGET_ANDROID
-endif
-
-ART_TARGET_CFLAGS += $(art_target_cflags)
-
-ART_HOST_NON_DEBUG_CFLAGS := $(art_host_non_debug_cflags)
-ART_TARGET_NON_DEBUG_CFLAGS := $(art_target_non_debug_cflags)
-ART_HOST_DEBUG_CFLAGS := $(art_debug_cflags)
-ART_TARGET_DEBUG_CFLAGS := $(art_debug_cflags)
-
-ART_HOST_NON_DEBUG_ASFLAGS := $(art_non_debug_asflags)
-ART_TARGET_NON_DEBUG_ASFLAGS := $(art_non_debug_asflags)
-ART_HOST_DEBUG_ASFLAGS := $(art_debug_asflags)
-ART_TARGET_DEBUG_ASFLAGS := $(art_debug_asflags)
-
-ifndef LIBART_IMG_HOST_MIN_BASE_ADDRESS_DELTA
- LIBART_IMG_HOST_MIN_BASE_ADDRESS_DELTA=-0x1000000
-endif
-ifndef LIBART_IMG_HOST_MAX_BASE_ADDRESS_DELTA
- LIBART_IMG_HOST_MAX_BASE_ADDRESS_DELTA=0x1000000
-endif
-ART_HOST_CFLAGS += -DART_BASE_ADDRESS_MIN_DELTA=$(LIBART_IMG_HOST_MIN_BASE_ADDRESS_DELTA)
-ART_HOST_CFLAGS += -DART_BASE_ADDRESS_MAX_DELTA=$(LIBART_IMG_HOST_MAX_BASE_ADDRESS_DELTA)
-
-ifndef LIBART_IMG_TARGET_MIN_BASE_ADDRESS_DELTA
- LIBART_IMG_TARGET_MIN_BASE_ADDRESS_DELTA=-0x1000000
-endif
-ifndef LIBART_IMG_TARGET_MAX_BASE_ADDRESS_DELTA
- LIBART_IMG_TARGET_MAX_BASE_ADDRESS_DELTA=0x1000000
-endif
-ART_TARGET_CFLAGS += -DART_BASE_ADDRESS_MIN_DELTA=$(LIBART_IMG_TARGET_MIN_BASE_ADDRESS_DELTA)
-ART_TARGET_CFLAGS += -DART_BASE_ADDRESS_MAX_DELTA=$(LIBART_IMG_TARGET_MAX_BASE_ADDRESS_DELTA)
-
-# To use oprofile_android --callgraph, uncomment this and recompile with "mmm art -B -j16"
-# ART_TARGET_CFLAGS += -fno-omit-frame-pointer -marm -mapcs
-
-# Clear locals now they've served their purpose.
-art_cflags :=
-art_asflags :=
-art_host_cflags :=
-art_target_cflags :=
-art_debug_cflags :=
-art_non_debug_cflags :=
-art_debug_asflags :=
-art_non_debug_asflags :=
-art_host_non_debug_cflags :=
-art_target_non_debug_cflags :=
-art_default_gc_type_cflags :=
-
-ART_TARGET_LDFLAGS :=
-
-# $(1): ndebug_or_debug
-define set-target-local-cflags-vars
- LOCAL_CFLAGS += $(ART_TARGET_CFLAGS)
- LOCAL_ASFLAGS += $(ART_TARGET_ASFLAGS)
- LOCAL_LDFLAGS += $(ART_TARGET_LDFLAGS)
- art_target_cflags_ndebug_or_debug := $(1)
- ifeq ($$(art_target_cflags_ndebug_or_debug),debug)
- LOCAL_CFLAGS += $(ART_TARGET_DEBUG_CFLAGS)
- LOCAL_ASFLAGS += $(ART_TARGET_DEBUG_ASFLAGS)
- else
- LOCAL_CFLAGS += $(ART_TARGET_NON_DEBUG_CFLAGS)
- LOCAL_ASFLAGS += $(ART_TARGET_NON_DEBUG_ASFLAGS)
- endif
-
- # Clear locally used variables.
- art_target_cflags_ndebug_or_debug :=
-endef
-
# Support for disabling certain builds.
ART_BUILD_TARGET := false
ART_BUILD_HOST := false
-ART_BUILD_NDEBUG := false
-ART_BUILD_DEBUG := false
ifeq ($(ART_BUILD_TARGET_NDEBUG),true)
ART_BUILD_TARGET := true
- ART_BUILD_NDEBUG := true
endif
ifeq ($(ART_BUILD_TARGET_DEBUG),true)
ART_BUILD_TARGET := true
- ART_BUILD_DEBUG := true
endif
ifeq ($(ART_BUILD_HOST_NDEBUG),true)
ART_BUILD_HOST := true
- ART_BUILD_NDEBUG := true
endif
ifeq ($(ART_BUILD_HOST_DEBUG),true)
ART_BUILD_HOST := true
- ART_BUILD_DEBUG := true
endif
endif # ART_ANDROID_COMMON_BUILD_MK
diff --git a/build/Android.common_test.mk b/build/Android.common_test.mk
index 8124ca3..449502c 100644
--- a/build/Android.common_test.mk
+++ b/build/Android.common_test.mk
@@ -26,10 +26,6 @@
ART_HOST_TEST_DIR := /tmp/$(USER)/test-art-$(shell echo $$PPID)
endif
-# We need to set a define for the nativetest dir so that common_runtime_test will know the right
-# path. (The problem is being a 32b test on 64b device, which is still located in nativetest64).
-ART_TARGET_CFLAGS += -DART_TARGET_NATIVETEST_DIR=${ART_TARGET_NATIVETEST_DIR}
-
# List of known broken tests that we won't attempt to execute. The test name must be the full
# rule name such as test-art-host-oat-optimizing-HelloWorld64.
ART_TEST_KNOWN_BROKEN :=
diff --git a/build/Android.common_utils.mk b/build/Android.common_utils.mk
deleted file mode 100644
index 8069c3a..0000000
--- a/build/Android.common_utils.mk
+++ /dev/null
@@ -1,26 +0,0 @@
-#
-# Copyright (C) 2014 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.
-#
-
-ifndef ART_ANDROID_COMMON_UTILS_MK
-ART_ANDROID_COMMON_UTILS_MK = true
-
-#
-# Convert a string into an uppercase string.
-#
-# $(1): a string which should be made uppercase
-art-string-to-uppercase = $(shell echo $(1) | tr '[:lower:]' '[:upper:]')
-
-endif # ART_ANDROID_COMMON_UTILS_MK
diff --git a/build/Android.executable.mk b/build/Android.executable.mk
deleted file mode 100644
index f38a14d..0000000
--- a/build/Android.executable.mk
+++ /dev/null
@@ -1,251 +0,0 @@
-#
-# Copyright (C) 2011 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.
-#
-
-include art/build/Android.common_build.mk
-
-ART_EXECUTABLES_CFLAGS :=
-
-# $(1): executable ("d" will be appended for debug version, "s" will be appended for static version)
-# $(2): source
-# $(3): extra shared libraries
-# $(4): extra include directories
-# $(5): target or host
-# $(6): ndebug or debug
-# $(7): value for LOCAL_MULTILIB (empty means default)
-# $(8): static or shared (empty means shared, applies only for host)
-define build-art-executable
- ifneq ($(5),target)
- ifneq ($(5),host)
- $$(error expected target or host for argument 5, received $(5))
- endif
- endif
- ifneq ($(6),ndebug)
- ifneq ($(6),debug)
- $$(error expected ndebug or debug for argument 6, received $(6))
- endif
- endif
-
- art_executable := $(1)
- art_source := $(2)
- art_libraries := $(3)
- art_c_includes := $(4)
- art_target_or_host := $(5)
- art_ndebug_or_debug := $(6)
- art_multilib := $(7)
- art_static_or_shared := $(8)
- art_out_binary_name :=
-
- include $(CLEAR_VARS)
- LOCAL_CPP_EXTENSION := $(ART_CPP_EXTENSION)
- LOCAL_MODULE_TAGS := optional
- LOCAL_SRC_FILES := $$(art_source)
- LOCAL_C_INCLUDES += $(ART_C_INCLUDES) art/runtime art/cmdline $$(art_c_includes)
-
- ifeq ($$(art_static_or_shared),static)
- LOCAL_STATIC_LIBRARIES += $$(art_libraries)
- else
- LOCAL_SHARED_LIBRARIES += $$(art_libraries)
- endif
-
- ifeq ($$(art_ndebug_or_debug),ndebug)
- LOCAL_MODULE := $$(art_executable)
- else #debug
- LOCAL_MODULE := $$(art_executable)d
- endif
-
- ifeq ($$(art_static_or_shared),static)
- LOCAL_MODULE := $$(LOCAL_MODULE)s
- endif
-
- LOCAL_CFLAGS := $(ART_EXECUTABLES_CFLAGS)
- # Mac OS linker doesn't understand --export-dynamic.
- ifneq ($$(HOST_OS)-$$(art_target_or_host),darwin-host)
- LOCAL_LDFLAGS := -Wl,--export-dynamic
- endif
-
- ifeq ($$(art_target_or_host),target)
- LOCAL_CLANG := $(ART_TARGET_CLANG)
- $(call set-target-local-cflags-vars,$(6))
- LOCAL_SHARED_LIBRARIES += libdl
- else # host
- LOCAL_CLANG := $(ART_HOST_CLANG)
- LOCAL_CFLAGS += $(ART_HOST_CFLAGS)
- LOCAL_ASFLAGS += $(ART_HOST_ASFLAGS)
- ifeq ($$(art_ndebug_or_debug),debug)
- LOCAL_CFLAGS += $(ART_HOST_DEBUG_CFLAGS)
- LOCAL_ASFLAGS += $(ART_HOST_DEBUG_ASFLAGS)
- else
- LOCAL_CFLAGS += $(ART_HOST_NON_DEBUG_CFLAGS)
- LOCAL_ASFLAGS += $(ART_HOST_NON_DEBUG_ASFLAGS)
- endif
- LOCAL_LDLIBS += -lpthread -ldl
- ifeq ($$(art_static_or_shared),static)
- LOCAL_LDFLAGS += -static
- # We need this because GC stress mode makes use of _Unwind_GetIP and _Unwind_Backtrace and
- # the symbols are also defined in libgcc_eh.a(unwind-dw2.o)
- # TODO: Having this is not ideal as it might obscure errors. Try to get rid of it.
- LOCAL_LDFLAGS += -z muldefs
- ifeq ($$(HOST_OS),linux)
- LOCAL_LDLIBS += -lrt -lncurses -ltinfo
- endif
- ifeq ($$(HOST_OS),darwin)
- LOCAL_LDLIBS += -lncurses -ltinfo
- endif
- endif
-
- endif
-
- # If dynamically linked add libart by default. Statically linked executables
- # needs to specify it in art_libraries to ensure proper ordering.
- ifeq ($$(art_ndebug_or_debug),ndebug)
- ifneq ($$(art_static_or_shared),static)
- LOCAL_SHARED_LIBRARIES += libart
- endif
- else # debug
- ifneq ($$(art_static_or_shared),static)
- LOCAL_SHARED_LIBRARIES += libartd
- endif
- endif
-
- LOCAL_ADDITIONAL_DEPENDENCIES := art/build/Android.common_build.mk
- LOCAL_ADDITIONAL_DEPENDENCIES += art/build/Android.common_utils.mk
- LOCAL_ADDITIONAL_DEPENDENCIES += art/build/Android.executable.mk
-
- ifeq ($$(art_target_or_host),target)
- LOCAL_MODULE_TARGET_ARCH := $(ART_SUPPORTED_ARCH)
- endif
-
- ifdef ART_MULTILIB_OVERRIDE_$$(art_target_or_host)
- art_multilib := $$(ART_MULTILIB_OVERRIDE_$$(art_target_or_host))
- endif
-
- LOCAL_MULTILIB := $$(art_multilib)
- art_out_binary_name := $$(LOCAL_MODULE)
-
- # If multilib=both (potentially building both 32-bit and 64-bit), need to provide stem.
- ifeq ($$(art_multilib),both)
- # Set up a 32-bit/64-bit stem if we are building both binaries.
- # In this case, the 32-bit binary has an additional 32-bit suffix.
- LOCAL_MODULE_STEM_32 := $$(LOCAL_MODULE)32
- LOCAL_MODULE_STEM_64 := $$(LOCAL_MODULE)
-
- # Remember the binary names so we can add them to the global art executables list later.
- art_out_binary_name := $$(LOCAL_MODULE_STEM_32) $$(LOCAL_MODULE_STEM_64)
-
- # For single-architecture targets, remove any binary name suffixes.
- ifeq ($$(art_target_or_host),target)
- ifeq (,$(TARGET_2ND_ARCH))
- LOCAL_MODULE_STEM_32 := $$(LOCAL_MODULE)
- art_out_binary_name := $$(LOCAL_MODULE)
- endif
- endif
-
- # For single-architecture hosts, remove any binary name suffixes.
- ifeq ($$(art_target_or_host),host)
- ifeq (,$(HOST_2ND_ARCH))
- LOCAL_MODULE_STEM_32 := $$(LOCAL_MODULE)
- art_out_binary_name := $$(LOCAL_MODULE)
- endif
- endif
- endif
-
- LOCAL_NATIVE_COVERAGE := $(ART_COVERAGE)
-
- ifeq ($$(art_target_or_host),target)
- include $(BUILD_EXECUTABLE)
- else # host
- LOCAL_IS_HOST_MODULE := true
- include $(BUILD_HOST_EXECUTABLE)
- endif
-
- # Clear out local variables now that we're done with them.
- art_executable :=
- art_source :=
- art_libraries :=
- art_c_includes :=
- art_target_or_host :=
- art_ndebug_or_debug :=
- art_multilib :=
- art_static_or_shared :=
- art_out_binary_name :=
-
-endef
-
-#
-# Build many art executables from multiple variations (debug/ndebug, host/target, 32/64bit).
-# By default only either 32-bit or 64-bit is built (but not both -- see multilib arg).
-# All other variations are gated by ANDROID_BUILD_(TARGET|HOST)_[N]DEBUG.
-# The result must be eval-uated.
-#
-# $(1): executable name
-# $(2): source files
-# $(3): library dependencies (common); debug prefix is added on as necessary automatically.
-# $(4): library dependencies (target only)
-# $(5): library dependencies (host only)
-# $(6): extra include directories
-# $(7): multilib (default: empty), valid values: {,32,64,both})
-# $(8): host prefer 32-bit: {true, false} (default: false). If argument
-# `multilib` is explicitly set to 64, ignore the "host prefer 32-bit"
-# setting and only build a 64-bit executable on host.
-define build-art-multi-executable
- $(foreach debug_flavor,ndebug debug,
- $(foreach target_flavor,host target,
- art-multi-binary-name := $(1)
- art-multi-source-files := $(2)
- art-multi-lib-dependencies := $(3)
- art-multi-lib-dependencies-target := $(4)
- art-multi-lib-dependencies-host := $(5)
- art-multi-include-extra := $(6)
- art-multi-multilib := $(7)
- art-multi-host-prefer-32-bit := $(8)
-
- # Add either -host or -target specific lib dependencies to the lib dependencies.
- art-multi-lib-dependencies += $$(art-multi-lib-dependencies-$(target_flavor))
-
- # Replace libart- prefix with libartd- for debug flavor.
- ifeq ($(debug_flavor),debug)
- art-multi-lib-dependencies := $$(subst libart-,libartd-,$$(art-multi-lib-dependencies))
- endif
-
- # Build the env guard var name, e.g. ART_BUILD_HOST_NDEBUG.
- art-multi-env-guard := $$(call art-string-to-uppercase,ART_BUILD_$(target_flavor)_$(debug_flavor))
-
- ifeq ($(target_flavor),host)
- ifeq ($$(art-multi-host-prefer-32-bit),true)
- ifneq ($$(art-multi-multilib),64)
- art-multi-multilib := 32
- endif
- endif
- endif
-
- # Build the art executable only if the corresponding env guard was set.
- ifeq ($$($$(art-multi-env-guard)),true)
- $$(eval $$(call build-art-executable,$$(art-multi-binary-name),$$(art-multi-source-files),$$(art-multi-lib-dependencies),$$(art-multi-include-extra),$(target_flavor),$(debug_flavor),$$(art-multi-multilib)))
- endif
-
- # Clear locals now they've served their purpose.
- art-multi-binary-name :=
- art-multi-source-files :=
- art-multi-lib-dependencies :=
- art-multi-lib-dependencies-target :=
- art-multi-lib-dependencies-host :=
- art-multi-include-extra :=
- art-multi-multilib :=
- art-multi-host-prefer-32-bit :=
- art-multi-env-guard :=
- )
- )
-endef
diff --git a/build/Android.gtest.mk b/build/Android.gtest.mk
index c70f005..07ff611 100644
--- a/build/Android.gtest.mk
+++ b/build/Android.gtest.mk
@@ -223,8 +223,6 @@
$(ART_TEST_LIST_host_$(2ND_ART_HOST_ARCH)_$(m)))
endif
-ART_TEST_CFLAGS :=
-
# Variables holding collections of gtest pre-requisits used to run a number of gtests.
ART_TEST_HOST_GTEST$(ART_PHONY_TEST_HOST_SUFFIX)_RULES :=
ART_TEST_HOST_GTEST$(2ND_ART_PHONY_TEST_HOST_SUFFIX)_RULES :=
@@ -572,7 +570,6 @@
RUNTIME_GTEST_HOST_SRC_FILES :=
COMPILER_GTEST_TARGET_SRC_FILES :=
COMPILER_GTEST_HOST_SRC_FILES :=
-ART_TEST_CFLAGS :=
ART_TEST_HOST_GTEST$(ART_PHONY_TEST_HOST_SUFFIX)_RULES :=
ART_TEST_HOST_GTEST$(2ND_ART_PHONY_TEST_HOST_SUFFIX)_RULES :=
ART_TEST_HOST_GTEST_RULES :=
diff --git a/compiler/dex/dex_to_dex_compiler.cc b/compiler/dex/dex_to_dex_compiler.cc
index 3ce786e..c902d28 100644
--- a/compiler/dex/dex_to_dex_compiler.cc
+++ b/compiler/dex/dex_to_dex_compiler.cc
@@ -90,7 +90,7 @@
// Compiles a virtual method invocation into a quick virtual method invocation.
// The method index is replaced by the vtable index where the corresponding
- // AbstractMethod can be found. Therefore, this does not involve any resolution
+ // Executable can be found. Therefore, this does not involve any resolution
// at runtime.
// Since the method index is encoded with 16 bits, we can replace it only if the
// vtable index can be encoded with 16 bits too.
diff --git a/compiler/image_writer.cc b/compiler/image_writer.cc
index 3e6658e..cdb57a9 100644
--- a/compiler/image_writer.cc
+++ b/compiler/image_writer.cc
@@ -48,12 +48,12 @@
#include "intern_table.h"
#include "linear_alloc.h"
#include "lock_word.h"
-#include "mirror/abstract_method.h"
#include "mirror/array-inl.h"
#include "mirror/class-inl.h"
#include "mirror/class_loader.h"
#include "mirror/dex_cache.h"
#include "mirror/dex_cache-inl.h"
+#include "mirror/executable.h"
#include "mirror/method.h"
#include "mirror/object-inl.h"
#include "mirror/object_array-inl.h"
@@ -1989,8 +1989,8 @@
} else {
if (klass == mirror::Method::StaticClass() || klass == mirror::Constructor::StaticClass()) {
// Need to go update the ArtMethod.
- auto* dest = down_cast<mirror::AbstractMethod*>(copy);
- auto* src = down_cast<mirror::AbstractMethod*>(orig);
+ auto* dest = down_cast<mirror::Executable*>(copy);
+ auto* src = down_cast<mirror::Executable*>(orig);
ArtMethod* src_method = src->GetArtMethod();
dest->SetArtMethod(GetImageMethodAddress(src_method));
} else if (!klass->IsArrayClass()) {
diff --git a/compiler/oat_writer.cc b/compiler/oat_writer.cc
index d629c0c..9045817 100644
--- a/compiler/oat_writer.cc
+++ b/compiler/oat_writer.cc
@@ -55,6 +55,7 @@
#include "utils/dex_cache_arrays_layout-inl.h"
#include "vdex_file.h"
#include "verifier/method_verifier.h"
+#include "verifier/verifier_deps.h"
#include "zip_archive.h"
namespace art {
@@ -297,6 +298,7 @@
dex_files_(nullptr),
vdex_size_(0u),
vdex_dex_files_offset_(0u),
+ vdex_verifier_deps_offset_(0u),
oat_size_(0u),
bss_size_(0u),
oat_data_offset_(0u),
@@ -307,6 +309,8 @@
size_oat_header_(0),
size_oat_header_key_value_store_(0),
size_dex_file_(0),
+ size_verifier_deps_(0),
+ size_verifier_deps_alignment_(0),
size_interpreter_to_interpreter_bridge_(0),
size_interpreter_to_compiled_code_bridge_(0),
size_jni_dlsym_lookup_(0),
@@ -476,11 +480,6 @@
!OpenDexFiles(vdex_file, verify, &dex_files_map, &dex_files)) {
return false;
}
-
- // VDEX is finalized. Seek to the beginning of the file and write the header.
- if (!WriteVdexHeader(vdex_out.get())) {
- return false;
- }
} else {
// Write DEX files into OAT, mmap and open them.
if (!WriteDexFiles(oat_rodata, vdex_file) ||
@@ -1595,6 +1594,52 @@
return true;
}
+bool OatWriter::WriteVerifierDeps(OutputStream* vdex_out, verifier::VerifierDeps* verifier_deps) {
+ if (!kIsVdexEnabled) {
+ return true;
+ }
+
+ if (verifier_deps == nullptr) {
+ // Nothing to write. Record the offset, but no need
+ // for alignment.
+ vdex_verifier_deps_offset_ = vdex_size_;
+ return true;
+ }
+
+ size_t initial_offset = vdex_size_;
+ size_t start_offset = RoundUp(initial_offset, 4u);
+
+ vdex_size_ = start_offset;
+ vdex_verifier_deps_offset_ = vdex_size_;
+ size_verifier_deps_alignment_ = start_offset - initial_offset;
+
+ off_t actual_offset = vdex_out->Seek(start_offset, kSeekSet);
+ if (actual_offset != static_cast<off_t>(start_offset)) {
+ PLOG(ERROR) << "Failed to seek to verifier deps section. Actual: " << actual_offset
+ << " Expected: " << start_offset
+ << " Output: " << vdex_out->GetLocation();
+ return false;
+ }
+
+ std::vector<uint8_t> buffer;
+ verifier_deps->Encode(&buffer);
+
+ if (!vdex_out->WriteFully(buffer.data(), buffer.size())) {
+ PLOG(ERROR) << "Failed to write verifier deps."
+ << " File: " << vdex_out->GetLocation();
+ return false;
+ }
+ if (!vdex_out->Flush()) {
+ PLOG(ERROR) << "Failed to flush stream after writing verifier deps."
+ << " File: " << vdex_out->GetLocation();
+ return false;
+ }
+
+ size_verifier_deps_ = buffer.size();
+ vdex_size_ += size_verifier_deps_;
+ return true;
+}
+
bool OatWriter::WriteCode(OutputStream* out) {
CHECK(write_state_ == WriteState::kWriteText);
@@ -1638,6 +1683,8 @@
DO_STAT(size_oat_header_);
DO_STAT(size_oat_header_key_value_store_);
DO_STAT(size_dex_file_);
+ DO_STAT(size_verifier_deps_);
+ DO_STAT(size_verifier_deps_alignment_);
DO_STAT(size_interpreter_to_interpreter_bridge_);
DO_STAT(size_interpreter_to_compiled_code_bridge_);
DO_STAT(size_jni_dlsym_lookup_);
@@ -2341,6 +2388,9 @@
}
bool OatWriter::WriteVdexHeader(OutputStream* vdex_out) {
+ if (!kIsVdexEnabled) {
+ return true;
+ }
off_t actual_offset = vdex_out->Seek(0, kSeekSet);
if (actual_offset != 0) {
PLOG(ERROR) << "Failed to seek to the beginning of vdex file. Actual: " << actual_offset
@@ -2348,12 +2398,24 @@
return false;
}
- VdexFile::Header vdex_header;
+ DCHECK_NE(vdex_dex_files_offset_, 0u);
+ DCHECK_NE(vdex_verifier_deps_offset_, 0u);
+
+ size_t dex_section_size = vdex_verifier_deps_offset_ - vdex_dex_files_offset_;
+ size_t verifier_deps_section_size = vdex_size_ - vdex_verifier_deps_offset_;
+
+ VdexFile::Header vdex_header(dex_section_size, verifier_deps_section_size);
if (!vdex_out->WriteFully(&vdex_header, sizeof(VdexFile::Header))) {
PLOG(ERROR) << "Failed to write vdex header. File: " << vdex_out->GetLocation();
return false;
}
+ if (!vdex_out->Flush()) {
+ PLOG(ERROR) << "Failed to flush stream after writing to vdex file."
+ << " File: " << vdex_out->GetLocation();
+ return false;
+ }
+
return true;
}
diff --git a/compiler/oat_writer.h b/compiler/oat_writer.h
index dd7d699..670accb 100644
--- a/compiler/oat_writer.h
+++ b/compiler/oat_writer.h
@@ -50,6 +50,10 @@
class MultiOatRelativePatcher;
} // namespace linker
+namespace verifier {
+ class VerifierDeps;
+} // namespace verifier
+
// OatHeader variable length with count of D OatDexFiles
//
// OatDexFile[0] one variable sized OatDexFile with offsets to Dex and OatClasses
@@ -149,6 +153,9 @@
bool verify,
/*out*/ std::unique_ptr<MemMap>* opened_dex_files_map,
/*out*/ std::vector<std::unique_ptr<const DexFile>>* opened_dex_files);
+ bool WriteVerifierDeps(OutputStream* vdex_out, verifier::VerifierDeps* verifier_deps);
+ bool WriteVdexHeader(OutputStream* vdex_out);
+
// Prepare layout of remaining data.
void PrepareLayout(const CompilerDriver* compiler,
ImageWriter* image_writer,
@@ -232,8 +239,6 @@
// with a given DexMethodVisitor.
bool VisitDexMethods(DexMethodVisitor* visitor);
- bool WriteVdexHeader(OutputStream* vdex_out);
-
bool WriteDexFiles(OutputStream* out, File* file);
bool WriteDexFile(OutputStream* out, File* file, OatDexFile* oat_dex_file);
bool SeekToDexFile(OutputStream* out, File* file, OatDexFile* oat_dex_file);
@@ -311,6 +316,9 @@
// Offset of section holding Dex files inside Vdex.
size_t vdex_dex_files_offset_;
+ // Offset of section holding VerifierDeps inside Vdex.
+ size_t vdex_verifier_deps_offset_;
+
// Size required for Oat data structures.
size_t oat_size_;
@@ -341,6 +349,8 @@
uint32_t size_oat_header_;
uint32_t size_oat_header_key_value_store_;
uint32_t size_dex_file_;
+ uint32_t size_verifier_deps_;
+ uint32_t size_verifier_deps_alignment_;
uint32_t size_interpreter_to_interpreter_bridge_;
uint32_t size_interpreter_to_compiled_code_bridge_;
uint32_t size_jni_dlsym_lookup_;
diff --git a/dex2oat/dex2oat.cc b/dex2oat/dex2oat.cc
index d99d2d6..245653d 100644
--- a/dex2oat/dex2oat.cc
+++ b/dex2oat/dex2oat.cc
@@ -64,6 +64,8 @@
#include "interpreter/unstarted_runtime.h"
#include "jit/offline_profiling_info.h"
#include "leb128.h"
+#include "linker/buffered_output_stream.h"
+#include "linker/file_output_stream.h"
#include "linker/multi_oat_relative_patcher.h"
#include "mirror/class-inl.h"
#include "mirror/class_loader.h"
@@ -1753,6 +1755,28 @@
}
}
+ {
+ TimingLogger::ScopedTiming t2("dex2oat Write VDEX", timings_);
+ DCHECK(IsBootImage() || oat_files_.size() == 1u);
+ DCHECK_EQ(IsBootImage(), verifier_deps_ == nullptr);
+ for (size_t i = 0, size = oat_files_.size(); i != size; ++i) {
+ File* vdex_file = vdex_files_[i].get();
+ std::unique_ptr<BufferedOutputStream> vdex_out(
+ MakeUnique<BufferedOutputStream>(MakeUnique<FileOutputStream>(vdex_file)));
+
+ if (!oat_writers_[i]->WriteVerifierDeps(vdex_out.get(), verifier_deps_.get())) {
+ LOG(ERROR) << "Failed to write verifier dependencies into VDEX " << vdex_file->GetPath();
+ return false;
+ }
+
+ // VDEX finalized, seek back to the beginning and write the header.
+ if (!oat_writers_[i]->WriteVdexHeader(vdex_out.get())) {
+ LOG(ERROR) << "Failed to write vdex header into VDEX " << vdex_file->GetPath();
+ return false;
+ }
+ }
+ }
+
linker::MultiOatRelativePatcher patcher(instruction_set_, instruction_set_features_.get());
{
TimingLogger::ScopedTiming t2("dex2oat Write ELF", timings_);
@@ -2604,6 +2628,7 @@
std::vector<std::unique_ptr<ElfWriter>> elf_writers_;
std::vector<std::unique_ptr<OatWriter>> oat_writers_;
std::vector<OutputStream*> rodata_;
+ std::vector<std::unique_ptr<OutputStream>> vdex_out_;
std::unique_ptr<ImageWriter> image_writer_;
std::unique_ptr<CompilerDriver> driver_;
diff --git a/patchoat/patchoat.cc b/patchoat/patchoat.cc
index 5240011..1af3660 100644
--- a/patchoat/patchoat.cc
+++ b/patchoat/patchoat.cc
@@ -37,8 +37,8 @@
#include "elf_file_impl.h"
#include "gc/space/image_space.h"
#include "image-inl.h"
-#include "mirror/abstract_method.h"
#include "mirror/dex_cache.h"
+#include "mirror/executable.h"
#include "mirror/object-inl.h"
#include "mirror/method.h"
#include "mirror/reference.h"
@@ -770,8 +770,8 @@
} else if (object->GetClass() == mirror::Method::StaticClass() ||
object->GetClass() == mirror::Constructor::StaticClass()) {
// Need to go update the ArtMethod.
- auto* dest = down_cast<mirror::AbstractMethod*>(copy);
- auto* src = down_cast<mirror::AbstractMethod*>(object);
+ auto* dest = down_cast<mirror::Executable*>(copy);
+ auto* src = down_cast<mirror::Executable*>(object);
dest->SetArtMethod(RelocatedAddressOfPointer(src->GetArtMethod()));
}
}
diff --git a/profman/profman.cc b/profman/profman.cc
index a5fefa7..7722e80 100644
--- a/profman/profman.cc
+++ b/profman/profman.cc
@@ -280,18 +280,11 @@
for (size_t i = 0; i < dex_locations_.size(); ++i) {
std::string error_msg;
std::vector<std::unique_ptr<const DexFile>> dex_files_for_location;
- std::unique_ptr<ZipArchive> zip_archive(ZipArchive::OpenFromFd(apks_fd_[i],
- dex_locations_[i].c_str(),
- &error_msg));
- if (zip_archive == nullptr) {
- LOG(WARNING) << "OpenFromFd failed for '" << dex_locations_[i] << "' " << error_msg;
- continue;
- }
- if (DexFile::OpenFromZip(*zip_archive,
- dex_locations_[i],
- kVerifyChecksum,
- &error_msg,
- &dex_files_for_location)) {
+ if (DexFile::OpenZip(apks_fd_[i],
+ dex_locations_[i],
+ kVerifyChecksum,
+ &error_msg,
+ &dex_files_for_location)) {
} else {
LOG(WARNING) << "OpenFromZip failed for '" << dex_locations_[i] << "' " << error_msg;
continue;
diff --git a/runtime/Android.bp b/runtime/Android.bp
index 8c17653..6234a84 100644
--- a/runtime/Android.bp
+++ b/runtime/Android.bp
@@ -120,10 +120,10 @@
"linear_alloc.cc",
"mem_map.cc",
"memory_region.cc",
- "mirror/abstract_method.cc",
"mirror/array.cc",
"mirror/class.cc",
"mirror/dex_cache.cc",
+ "mirror/executable.cc",
"mirror/field.cc",
"mirror/method.cc",
"mirror/object.cc",
@@ -151,9 +151,9 @@
"native/java_lang_VMClassLoader.cc",
"native/java_lang_ref_FinalizerReference.cc",
"native/java_lang_ref_Reference.cc",
- "native/java_lang_reflect_AbstractMethod.cc",
"native/java_lang_reflect_Array.cc",
"native/java_lang_reflect_Constructor.cc",
+ "native/java_lang_reflect_Executable.cc",
"native/java_lang_reflect_Field.cc",
"native/java_lang_reflect_Method.cc",
"native/java_lang_reflect_Parameter.cc",
diff --git a/runtime/art_method.cc b/runtime/art_method.cc
index fd6c37a..193bea1 100644
--- a/runtime/art_method.cc
+++ b/runtime/art_method.cc
@@ -34,8 +34,8 @@
#include "jit/jit_code_cache.h"
#include "jit/profiling_info.h"
#include "jni_internal.h"
-#include "mirror/abstract_method.h"
#include "mirror/class-inl.h"
+#include "mirror/executable.h"
#include "mirror/object_array-inl.h"
#include "mirror/object-inl.h"
#include "mirror/string.h"
@@ -52,9 +52,9 @@
ArtMethod* ArtMethod::FromReflectedMethod(const ScopedObjectAccessAlreadyRunnable& soa,
jobject jlr_method) {
- auto* abstract_method = soa.Decode<mirror::AbstractMethod*>(jlr_method);
- DCHECK(abstract_method != nullptr);
- return abstract_method->GetArtMethod();
+ auto* executable = soa.Decode<mirror::Executable*>(jlr_method);
+ DCHECK(executable != nullptr);
+ return executable->GetArtMethod();
}
mirror::String* ArtMethod::GetNameAsString(Thread* self) {
diff --git a/runtime/class_linker_test.cc b/runtime/class_linker_test.cc
index 5e0ee6f..7023081 100644
--- a/runtime/class_linker_test.cc
+++ b/runtime/class_linker_test.cc
@@ -28,7 +28,6 @@
#include "experimental_flags.h"
#include "entrypoints/entrypoint_utils-inl.h"
#include "gc/heap.h"
-#include "mirror/abstract_method.h"
#include "mirror/accessible_object.h"
#include "mirror/class-inl.h"
#include "mirror/dex_cache.h"
@@ -697,24 +696,18 @@
struct ExecutableOffsets : public CheckOffsets<mirror::Executable> {
ExecutableOffsets() : CheckOffsets<mirror::Executable>(
false, "Ljava/lang/reflect/Executable;") {
+ addOffset(OFFSETOF_MEMBER(mirror::Executable, access_flags_), "accessFlags");
+ addOffset(OFFSETOF_MEMBER(mirror::Executable, art_method_), "artMethod");
+ addOffset(OFFSETOF_MEMBER(mirror::Executable, declaring_class_), "declaringClass");
+ addOffset(OFFSETOF_MEMBER(mirror::Executable, declaring_class_of_overridden_method_),
+ "declaringClassOfOverriddenMethod");
+ addOffset(OFFSETOF_MEMBER(mirror::Executable, dex_method_index_), "dexMethodIndex");
addOffset(OFFSETOF_MEMBER(mirror::Executable, has_real_parameter_data_),
"hasRealParameterData");
addOffset(OFFSETOF_MEMBER(mirror::Executable, parameters_), "parameters");
};
};
-struct AbstractMethodOffsets : public CheckOffsets<mirror::AbstractMethod> {
- AbstractMethodOffsets() : CheckOffsets<mirror::AbstractMethod>(
- false, "Ljava/lang/reflect/AbstractMethod;") {
- addOffset(OFFSETOF_MEMBER(mirror::AbstractMethod, access_flags_), "accessFlags");
- addOffset(OFFSETOF_MEMBER(mirror::AbstractMethod, art_method_), "artMethod");
- addOffset(OFFSETOF_MEMBER(mirror::AbstractMethod, declaring_class_), "declaringClass");
- addOffset(OFFSETOF_MEMBER(mirror::AbstractMethod, declaring_class_of_overridden_method_),
- "declaringClassOfOverriddenMethod");
- addOffset(OFFSETOF_MEMBER(mirror::AbstractMethod, dex_method_index_), "dexMethodIndex");
- };
-};
-
// C++ fields must exactly match the fields in the Java classes. If this fails,
// reorder the fields in the C++ class. Managed class fields are ordered by
// ClassLinker::LinkFields.
@@ -733,7 +726,6 @@
EXPECT_TRUE(AccessibleObjectOffsets().Check());
EXPECT_TRUE(FieldOffsets().Check());
EXPECT_TRUE(ExecutableOffsets().Check());
- EXPECT_TRUE(AbstractMethodOffsets().Check());
}
TEST_F(ClassLinkerTest, FindClassNonexistent) {
@@ -1269,7 +1261,6 @@
old_dex_file->Size(),
location->ToModifiedUtf8(),
0u,
- nullptr,
nullptr));
{
WriterMutexLock mu(soa.Self(), *class_linker->DexLock());
diff --git a/runtime/dex_file.cc b/runtime/dex_file.cc
index 03223b0..70b7f87 100644
--- a/runtime/dex_file.cc
+++ b/runtime/dex_file.cc
@@ -52,6 +52,10 @@
namespace art {
+static constexpr OatDexFile* kNoOatDexFile = nullptr;
+
+const char* DexFile::kClassesDex = "classes.dex";
+
const uint8_t DexFile::kDexMagic[] = { 'd', 'e', 'x', '\n' };
const uint8_t DexFile::kDexMagicVersions[DexFile::kNumDexVersions][DexFile::kDexVersionLen] = {
{'0', '3', '5', '\0'},
@@ -118,64 +122,6 @@
return false;
}
-bool DexFile::Open(const char* filename,
- const char* location,
- bool verify_checksum,
- std::string* error_msg,
- std::vector<std::unique_ptr<const DexFile>>* dex_files) {
- ScopedTrace trace(std::string("Open dex file ") + location);
- DCHECK(dex_files != nullptr) << "DexFile::Open: out-param is nullptr";
- uint32_t magic;
- File fd = OpenAndReadMagic(filename, &magic, error_msg);
- if (fd.Fd() == -1) {
- DCHECK(!error_msg->empty());
- return false;
- }
- if (IsZipMagic(magic)) {
- return DexFile::OpenZip(fd.Release(), location, verify_checksum, error_msg, dex_files);
- }
- if (IsDexMagic(magic)) {
- std::unique_ptr<const DexFile> dex_file(DexFile::OpenFile(fd.Release(),
- location,
- /* verify */ true,
- verify_checksum,
- error_msg));
- if (dex_file.get() != nullptr) {
- dex_files->push_back(std::move(dex_file));
- return true;
- } else {
- return false;
- }
- }
- *error_msg = StringPrintf("Expected valid zip or dex file: '%s'", filename);
- return false;
-}
-
-static bool ContainsClassesDex(int fd, const char* filename) {
- std::string error_msg;
- std::unique_ptr<ZipArchive> zip_archive(ZipArchive::OpenFromFd(fd, filename, &error_msg));
- if (zip_archive.get() == nullptr) {
- return false;
- }
- std::unique_ptr<ZipEntry> zip_entry(zip_archive->Find(DexFile::kClassesDex, &error_msg));
- return (zip_entry.get() != nullptr);
-}
-
-bool DexFile::MaybeDex(const char* filename) {
- uint32_t magic;
- std::string error_msg;
- File fd = OpenAndReadMagic(filename, &magic, &error_msg);
- if (fd.Fd() == -1) {
- return false;
- }
- if (IsZipMagic(magic)) {
- return ContainsClassesDex(fd.Release(), filename);
- } else if (IsDexMagic(magic)) {
- return true;
- }
- return false;
-}
-
int DexFile::GetPermissions() const {
if (mem_map_.get() == nullptr) {
return 0;
@@ -206,7 +152,9 @@
}
}
-std::unique_ptr<const DexFile> DexFile::Open(const uint8_t* base, size_t size,
+
+std::unique_ptr<const DexFile> DexFile::Open(const uint8_t* base,
+ size_t size,
const std::string& location,
uint32_t location_checksum,
const OatDexFile* oat_dex_file,
@@ -214,118 +162,78 @@
bool verify_checksum,
std::string* error_msg) {
ScopedTrace trace(std::string("Open dex file from RAM ") + location);
- std::unique_ptr<const DexFile> dex_file = OpenMemory(base,
- size,
- location,
- location_checksum,
- nullptr,
- oat_dex_file,
- error_msg);
- if (dex_file == nullptr) {
- return nullptr;
- }
-
- if (verify && !DexFileVerifier::Verify(dex_file.get(),
- dex_file->Begin(),
- dex_file->Size(),
- location.c_str(),
- verify_checksum,
- error_msg)) {
- return nullptr;
- }
- return dex_file;
+ return OpenCommon(base,
+ size,
+ location,
+ location_checksum,
+ oat_dex_file,
+ verify,
+ verify_checksum,
+ error_msg);
}
std::unique_ptr<const DexFile> DexFile::Open(const std::string& location,
uint32_t location_checksum,
- std::unique_ptr<MemMap> mem_map,
+ std::unique_ptr<MemMap> map,
bool verify,
bool verify_checksum,
std::string* error_msg) {
ScopedTrace trace(std::string("Open dex file from mapped-memory ") + location);
- std::unique_ptr<const DexFile> dex_file = OpenMemory(location,
- location_checksum,
- std::move(mem_map),
- error_msg);
- if (dex_file == nullptr) {
- return nullptr;
- }
-
- if (verify && !DexFileVerifier::Verify(dex_file.get(),
- dex_file->Begin(),
- dex_file->Size(),
- location.c_str(),
- verify_checksum,
- error_msg)) {
- return nullptr;
+ CHECK(map.get() != nullptr);
+ std::unique_ptr<DexFile> dex_file = OpenCommon(map->Begin(),
+ map->Size(),
+ location,
+ location_checksum,
+ kNoOatDexFile,
+ verify,
+ verify_checksum,
+ error_msg);
+ if (dex_file != nullptr) {
+ dex_file->mem_map_.reset(map.release());
}
return dex_file;
}
-std::unique_ptr<const DexFile> DexFile::OpenFile(int fd,
- const char* location,
- bool verify,
- bool verify_checksum,
- std::string* error_msg) {
- ScopedTrace trace(std::string("Open dex file ") + location);
- CHECK(location != nullptr);
- std::unique_ptr<MemMap> map;
- {
- File delayed_close(fd, /* check_usage */ false);
- struct stat sbuf;
- memset(&sbuf, 0, sizeof(sbuf));
- if (fstat(fd, &sbuf) == -1) {
- *error_msg = StringPrintf("DexFile: fstat '%s' failed: %s", location, strerror(errno));
- return nullptr;
- }
- if (S_ISDIR(sbuf.st_mode)) {
- *error_msg = StringPrintf("Attempt to mmap directory '%s'", location);
- return nullptr;
- }
- size_t length = sbuf.st_size;
- map.reset(MemMap::MapFile(length,
- PROT_READ,
- MAP_PRIVATE,
- fd,
- 0,
- /*low_4gb*/false,
- location,
- error_msg));
- if (map == nullptr) {
- DCHECK(!error_msg->empty());
- return nullptr;
+bool DexFile::Open(const char* filename,
+ const std::string& location,
+ bool verify_checksum,
+ std::string* error_msg,
+ std::vector<std::unique_ptr<const DexFile>>* dex_files) {
+ ScopedTrace trace(std::string("Open dex file ") + std::string(location));
+ DCHECK(dex_files != nullptr) << "DexFile::Open: out-param is nullptr";
+ uint32_t magic;
+ File fd = OpenAndReadMagic(filename, &magic, error_msg);
+ if (fd.Fd() == -1) {
+ DCHECK(!error_msg->empty());
+ return false;
+ }
+ if (IsZipMagic(magic)) {
+ return DexFile::OpenZip(fd.Release(), location, verify_checksum, error_msg, dex_files);
+ }
+ if (IsDexMagic(magic)) {
+ std::unique_ptr<const DexFile> dex_file(DexFile::OpenFile(fd.Release(),
+ location,
+ /* verify */ true,
+ verify_checksum,
+ error_msg));
+ if (dex_file.get() != nullptr) {
+ dex_files->push_back(std::move(dex_file));
+ return true;
+ } else {
+ return false;
}
}
-
- if (map->Size() < sizeof(DexFile::Header)) {
- *error_msg = StringPrintf(
- "DexFile: failed to open dex file '%s' that is too short to have a header", location);
- return nullptr;
- }
-
- const Header* dex_header = reinterpret_cast<const Header*>(map->Begin());
-
- std::unique_ptr<const DexFile> dex_file(OpenMemory(location,
- dex_header->checksum_,
- std::move(map),
- error_msg));
- if (dex_file.get() == nullptr) {
- *error_msg = StringPrintf("Failed to open dex file '%s' from memory: %s", location,
- error_msg->c_str());
- return nullptr;
- }
-
- if (verify && !DexFileVerifier::Verify(dex_file.get(), dex_file->Begin(), dex_file->Size(),
- location,
- verify_checksum,
- error_msg)) {
- return nullptr;
- }
-
- return dex_file;
+ *error_msg = StringPrintf("Expected valid zip or dex file: '%s'", filename);
+ return false;
}
-const char* DexFile::kClassesDex = "classes.dex";
+std::unique_ptr<const DexFile> DexFile::OpenDex(int fd,
+ const std::string& location,
+ bool verify_checksum,
+ std::string* error_msg) {
+ ScopedTrace trace("Open dex file " + std::string(location));
+ return OpenFile(fd, location, true /* verify */, verify_checksum, error_msg);
+}
bool DexFile::OpenZip(int fd,
const std::string& location,
@@ -339,28 +247,79 @@
DCHECK(!error_msg->empty());
return false;
}
- return DexFile::OpenFromZip(*zip_archive, location, verify_checksum, error_msg, dex_files);
+ return DexFile::OpenAllDexFilesFromZip(*zip_archive,
+ location,
+ verify_checksum,
+ error_msg,
+ dex_files);
}
-std::unique_ptr<const DexFile> DexFile::OpenMemory(const std::string& location,
- uint32_t location_checksum,
- std::unique_ptr<MemMap> mem_map,
- std::string* error_msg) {
- return OpenMemory(mem_map->Begin(),
- mem_map->Size(),
- location,
- location_checksum,
- std::move(mem_map),
- nullptr,
- error_msg);
+std::unique_ptr<const DexFile> DexFile::OpenFile(int fd,
+ const std::string& location,
+ bool verify,
+ bool verify_checksum,
+ std::string* error_msg) {
+ ScopedTrace trace(std::string("Open dex file ") + std::string(location));
+ CHECK(!location.empty());
+ std::unique_ptr<MemMap> map;
+ {
+ File delayed_close(fd, /* check_usage */ false);
+ struct stat sbuf;
+ memset(&sbuf, 0, sizeof(sbuf));
+ if (fstat(fd, &sbuf) == -1) {
+ *error_msg = StringPrintf("DexFile: fstat '%s' failed: %s", location.c_str(),
+ strerror(errno));
+ return nullptr;
+ }
+ if (S_ISDIR(sbuf.st_mode)) {
+ *error_msg = StringPrintf("Attempt to mmap directory '%s'", location.c_str());
+ return nullptr;
+ }
+ size_t length = sbuf.st_size;
+ map.reset(MemMap::MapFile(length,
+ PROT_READ,
+ MAP_PRIVATE,
+ fd,
+ 0,
+ /*low_4gb*/false,
+ location.c_str(),
+ error_msg));
+ if (map == nullptr) {
+ DCHECK(!error_msg->empty());
+ return nullptr;
+ }
+ }
+
+ if (map->Size() < sizeof(DexFile::Header)) {
+ *error_msg = StringPrintf(
+ "DexFile: failed to open dex file '%s' that is too short to have a header",
+ location.c_str());
+ return nullptr;
+ }
+
+ const Header* dex_header = reinterpret_cast<const Header*>(map->Begin());
+
+ std::unique_ptr<DexFile> dex_file = OpenCommon(map->Begin(),
+ map->Size(),
+ location,
+ dex_header->checksum_,
+ kNoOatDexFile,
+ verify,
+ verify_checksum,
+ error_msg);
+ if (dex_file != nullptr) {
+ dex_file->mem_map_.reset(map.release());
+ }
+
+ return dex_file;
}
-std::unique_ptr<const DexFile> DexFile::Open(const ZipArchive& zip_archive,
- const char* entry_name,
- const std::string& location,
- bool verify_checksum,
- std::string* error_msg,
- ZipOpenErrorCode* error_code) {
+std::unique_ptr<const DexFile> DexFile::OpenOneDexFileFromZip(const ZipArchive& zip_archive,
+ const char* entry_name,
+ const std::string& location,
+ bool verify_checksum,
+ std::string* error_msg,
+ ZipOpenErrorCode* error_code) {
ScopedTrace trace("Dex file open from Zip Archive " + std::string(location));
CHECK(!location.empty());
std::unique_ptr<ZipEntry> zip_entry(zip_archive.Find(entry_name, error_msg));
@@ -380,15 +339,18 @@
*error_code = ZipOpenErrorCode::kExtractToMemoryError;
return nullptr;
}
- std::unique_ptr<const DexFile> dex_file(OpenMemory(location,
- zip_entry->GetCrc32(),
- std::move(map),
- error_msg));
- if (dex_file == nullptr) {
- *error_msg = StringPrintf("Failed to open dex file '%s' from memory: %s", location.c_str(),
- error_msg->c_str());
- *error_code = ZipOpenErrorCode::kDexFileError;
- return nullptr;
+ VerifyResult verify_result;
+ std::unique_ptr<DexFile> dex_file = OpenCommon(map->Begin(),
+ map->Size(),
+ location,
+ zip_entry->GetCrc32(),
+ kNoOatDexFile,
+ /* verify */ true,
+ verify_checksum,
+ error_msg,
+ &verify_result);
+ if (dex_file != nullptr) {
+ dex_file->mem_map_.reset(map.release());
}
if (!dex_file->DisableWrite()) {
*error_msg = StringPrintf("Failed to make dex file '%s' read only", location.c_str());
@@ -396,10 +358,7 @@
return nullptr;
}
CHECK(dex_file->IsReadOnly()) << location;
- if (!DexFileVerifier::Verify(dex_file.get(), dex_file->Begin(), dex_file->Size(),
- location.c_str(),
- verify_checksum,
- error_msg)) {
+ if (verify_result != VerifyResult::kVerifySucceeded) {
*error_code = ZipOpenErrorCode::kVerifyError;
return nullptr;
}
@@ -413,16 +372,20 @@
// seems an excessive number.
static constexpr size_t kWarnOnManyDexFilesThreshold = 100;
-bool DexFile::OpenFromZip(const ZipArchive& zip_archive,
- const std::string& location,
- bool verify_checksum,
- std::string* error_msg,
- std::vector<std::unique_ptr<const DexFile>>* dex_files) {
+bool DexFile::OpenAllDexFilesFromZip(const ZipArchive& zip_archive,
+ const std::string& location,
+ bool verify_checksum,
+ std::string* error_msg,
+ std::vector<std::unique_ptr<const DexFile>>* dex_files) {
ScopedTrace trace("Dex file open from Zip " + std::string(location));
DCHECK(dex_files != nullptr) << "DexFile::OpenFromZip: out-param is nullptr";
ZipOpenErrorCode error_code;
- std::unique_ptr<const DexFile> dex_file(
- Open(zip_archive, kClassesDex, location, verify_checksum, error_msg, &error_code));
+ std::unique_ptr<const DexFile> dex_file(OpenOneDexFileFromZip(zip_archive,
+ kClassesDex,
+ location,
+ verify_checksum,
+ error_msg,
+ &error_code));
if (dex_file.get() == nullptr) {
return false;
} else {
@@ -437,8 +400,12 @@
for (size_t i = 1; ; ++i) {
std::string name = GetMultiDexClassesDexName(i);
std::string fake_location = GetMultiDexLocation(i, location.c_str());
- std::unique_ptr<const DexFile> next_dex_file(
- Open(zip_archive, name.c_str(), fake_location, verify_checksum, error_msg, &error_code));
+ std::unique_ptr<const DexFile> next_dex_file(OpenOneDexFileFromZip(zip_archive,
+ name.c_str(),
+ fake_location,
+ verify_checksum,
+ error_msg,
+ &error_code));
if (next_dex_file.get() == nullptr) {
if (error_code != ZipOpenErrorCode::kEntryNotFound) {
LOG(WARNING) << error_msg;
@@ -464,35 +431,55 @@
}
}
-
-std::unique_ptr<const DexFile> DexFile::OpenMemory(const uint8_t* base,
- size_t size,
- const std::string& location,
- uint32_t location_checksum,
- std::unique_ptr<MemMap> mem_map,
- const OatDexFile* oat_dex_file,
- std::string* error_msg) {
- DCHECK(base != nullptr);
- DCHECK_NE(size, 0U);
- CHECK_ALIGNED(base, 4); // various dex file structures must be word aligned
- std::unique_ptr<DexFile> dex_file(
- new DexFile(base, size, location, location_checksum, std::move(mem_map), oat_dex_file));
+std::unique_ptr<DexFile> DexFile::OpenCommon(const uint8_t* base,
+ size_t size,
+ const std::string& location,
+ uint32_t location_checksum,
+ const OatDexFile* oat_dex_file,
+ bool verify,
+ bool verify_checksum,
+ std::string* error_msg,
+ VerifyResult* verify_result) {
+ std::unique_ptr<DexFile> dex_file(new DexFile(base,
+ size,
+ location,
+ location_checksum,
+ oat_dex_file));
+ if (dex_file == nullptr) {
+ *error_msg = StringPrintf("Failed to open dex file '%s' from memory: %s", location.c_str(),
+ error_msg->c_str());
+ return nullptr;
+ }
if (!dex_file->Init(error_msg)) {
dex_file.reset();
+ return nullptr;
}
- return std::unique_ptr<const DexFile>(dex_file.release());
+ if (verify && !DexFileVerifier::Verify(dex_file.get(),
+ dex_file->Begin(),
+ dex_file->Size(),
+ location.c_str(),
+ verify_checksum,
+ error_msg)) {
+ if (verify_result != nullptr) {
+ *verify_result = VerifyResult::kVerifyFailed;
+ }
+ return nullptr;
+ }
+ if (verify_result != nullptr) {
+ *verify_result = VerifyResult::kVerifySucceeded;
+ }
+ return dex_file;
}
-DexFile::DexFile(const uint8_t* base, size_t size,
+DexFile::DexFile(const uint8_t* base,
+ size_t size,
const std::string& location,
uint32_t location_checksum,
- std::unique_ptr<MemMap> mem_map,
const OatDexFile* oat_dex_file)
: begin_(base),
size_(size),
location_(location),
location_checksum_(location_checksum),
- mem_map_(std::move(mem_map)),
header_(reinterpret_cast<const Header*>(base)),
string_ids_(reinterpret_cast<const StringId*>(base + header_->string_ids_off_)),
type_ids_(reinterpret_cast<const TypeId*>(base + header_->type_ids_off_)),
diff --git a/runtime/dex_file.h b/runtime/dex_file.h
index 97c2596..14bde09 100644
--- a/runtime/dex_file.h
+++ b/runtime/dex_file.h
@@ -397,15 +397,9 @@
// Return true if the checksum could be found, false otherwise.
static bool GetChecksum(const char* filename, uint32_t* checksum, std::string* error_msg);
- // Opens .dex files found in the container, guessing the container format based on file extension.
- static bool Open(const char* filename,
- const char* location,
- bool verify_checksum,
- std::string* error_msg,
- std::vector<std::unique_ptr<const DexFile>>* dex_files);
-
// Opens .dex file, backed by existing memory
- static std::unique_ptr<const DexFile> Open(const uint8_t* base, size_t size,
+ static std::unique_ptr<const DexFile> Open(const uint8_t* base,
+ size_t size,
const std::string& location,
uint32_t location_checksum,
const OatDexFile* oat_dex_file,
@@ -421,16 +415,25 @@
bool verify_checksum,
std::string* error_msg);
- // Checks whether the given file has the dex magic, or is a zip file with a classes.dex entry.
- // If this function returns false, Open will not succeed. The inverse is not true, however.
- static bool MaybeDex(const char* filename);
+ // Opens all .dex files found in the file, guessing the container format based on file extension.
+ static bool Open(const char* filename,
+ const std::string& location,
+ bool verify_checksum,
+ std::string* error_msg,
+ std::vector<std::unique_ptr<const DexFile>>* dex_files);
- // Open all classesXXX.dex files from a zip archive.
- static bool OpenFromZip(const ZipArchive& zip_archive,
- const std::string& location,
- bool verify_checksum,
- std::string* error_msg,
- std::vector<std::unique_ptr<const DexFile>>* dex_files);
+ // Open a single dex file from an fd.
+ static std::unique_ptr<const DexFile> OpenDex(int fd,
+ const std::string& location,
+ bool verify_checksum,
+ std::string* error_msg);
+
+ // Opens dex files from within a .jar, .zip, or .apk file
+ static bool OpenZip(int fd,
+ const std::string& location,
+ bool verify_checksum,
+ std::string* error_msg,
+ std::vector<std::unique_ptr<const DexFile>>* dex_files);
// Closes a .dex file.
virtual ~DexFile();
@@ -1011,20 +1014,12 @@
static uint64_t ReadUnsignedLong(const uint8_t* ptr, int zwidth, bool fill_on_right);
private:
- // Opens a .dex file
static std::unique_ptr<const DexFile> OpenFile(int fd,
- const char* location,
+ const std::string& location,
bool verify,
bool verify_checksum,
std::string* error_msg);
- // Opens dex files from within a .jar, .zip, or .apk file
- static bool OpenZip(int fd,
- const std::string& location,
- bool verify_checksum,
- std::string* error_msg,
- std::vector<std::unique_ptr<const DexFile>>* dex_files);
-
enum class ZipOpenErrorCode { // private
kNoError,
kEntryNotFound,
@@ -1034,34 +1029,41 @@
kVerifyError
};
+ // Open all classesXXX.dex files from a zip archive.
+ static bool OpenAllDexFilesFromZip(const ZipArchive& zip_archive,
+ const std::string& location,
+ bool verify_checksum,
+ std::string* error_msg,
+ std::vector<std::unique_ptr<const DexFile>>* dex_files);
+
// Opens .dex file from the entry_name in a zip archive. error_code is undefined when non-null
// return.
- static std::unique_ptr<const DexFile> Open(const ZipArchive& zip_archive,
- const char* entry_name,
+ static std::unique_ptr<const DexFile> OpenOneDexFileFromZip(const ZipArchive& zip_archive,
+ const char* entry_name,
+ const std::string& location,
+ bool verify_checksum,
+ std::string* error_msg,
+ ZipOpenErrorCode* error_code);
+
+ enum class VerifyResult { // private
+ kVerifySucceeded,
+ kVerifyFailed
+ };
+
+ static std::unique_ptr<DexFile> OpenCommon(const uint8_t* base,
+ size_t size,
const std::string& location,
+ uint32_t location_checksum,
+ const OatDexFile* oat_dex_file,
+ bool verify,
bool verify_checksum,
std::string* error_msg,
- ZipOpenErrorCode* error_code);
+ VerifyResult* verify_result = nullptr);
- // Opens a .dex file at the given address backed by a MemMap
- static std::unique_ptr<const DexFile> OpenMemory(const std::string& location,
- uint32_t location_checksum,
- std::unique_ptr<MemMap> mem_map,
- std::string* error_msg);
-
- // Opens a .dex file at the given address, optionally backed by a MemMap
- static std::unique_ptr<const DexFile> OpenMemory(const uint8_t* dex_file,
- size_t size,
- const std::string& location,
- uint32_t location_checksum,
- std::unique_ptr<MemMap> mem_map,
- const OatDexFile* oat_dex_file,
- std::string* error_msg);
-
- DexFile(const uint8_t* base, size_t size,
+ DexFile(const uint8_t* base,
+ size_t size,
const std::string& location,
uint32_t location_checksum,
- std::unique_ptr<MemMap> mem_map,
const OatDexFile* oat_dex_file);
// Top-level initializer that calls other Init methods.
diff --git a/runtime/dex_file_verifier_test.cc b/runtime/dex_file_verifier_test.cc
index 71c0ad9..5939ef3 100644
--- a/runtime/dex_file_verifier_test.cc
+++ b/runtime/dex_file_verifier_test.cc
@@ -123,7 +123,7 @@
class DexFileVerifierTest : public CommonRuntimeTest {
protected:
DexFile* GetDexFile(const uint8_t* dex_bytes, size_t length) {
- return new DexFile(dex_bytes, length, "tmp", 0, nullptr, nullptr);
+ return new DexFile(dex_bytes, length, "tmp", 0, nullptr);
}
void VerifyModification(const char* dex_file_base64_content,
diff --git a/runtime/jni_internal.cc b/runtime/jni_internal.cc
index a434442..d9cb1c6 100644
--- a/runtime/jni_internal.cc
+++ b/runtime/jni_internal.cc
@@ -375,7 +375,7 @@
CHECK_NON_NULL_ARGUMENT(mid);
ScopedObjectAccess soa(env);
ArtMethod* m = soa.DecodeMethod(mid);
- mirror::AbstractMethod* method;
+ mirror::Executable* method;
DCHECK_EQ(Runtime::Current()->GetClassLinker()->GetImagePointerSize(), kRuntimePointerSize);
DCHECK(!Runtime::Current()->IsActiveTransaction());
if (m->IsConstructor()) {
diff --git a/runtime/mirror/abstract_method.h b/runtime/mirror/abstract_method.h
deleted file mode 100644
index 9c20613..0000000
--- a/runtime/mirror/abstract_method.h
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * 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.
- */
-
-#ifndef ART_RUNTIME_MIRROR_ABSTRACT_METHOD_H_
-#define ART_RUNTIME_MIRROR_ABSTRACT_METHOD_H_
-
-#include "executable.h"
-#include "gc_root.h"
-#include "object.h"
-#include "object_callbacks.h"
-#include "read_barrier_option.h"
-
-namespace art {
-
-struct AbstractMethodOffsets;
-class ArtMethod;
-
-namespace mirror {
-
-// C++ mirror of java.lang.reflect.AbstractMethod.
-class MANAGED AbstractMethod : public Executable {
- public:
- // Called from Constructor::CreateFromArtMethod, Method::CreateFromArtMethod.
- template <PointerSize kPointerSize, bool kTransactionActive>
- bool CreateFromArtMethod(ArtMethod* method) REQUIRES_SHARED(Locks::mutator_lock_)
- REQUIRES(!Roles::uninterruptible_);
-
- ArtMethod* GetArtMethod() REQUIRES_SHARED(Locks::mutator_lock_);
- // Only used by the image writer.
- template <bool kTransactionActive = false>
- void SetArtMethod(ArtMethod* method) REQUIRES_SHARED(Locks::mutator_lock_);
- mirror::Class* GetDeclaringClass() REQUIRES_SHARED(Locks::mutator_lock_);
-
- private:
- static MemberOffset ArtMethodOffset() {
- return MemberOffset(OFFSETOF_MEMBER(AbstractMethod, art_method_));
- }
- static MemberOffset DeclaringClassOffset() {
- return MemberOffset(OFFSETOF_MEMBER(AbstractMethod, declaring_class_));
- }
- static MemberOffset DeclaringClassOfOverriddenMethodOffset() {
- return MemberOffset(OFFSETOF_MEMBER(AbstractMethod, declaring_class_of_overridden_method_));
- }
- static MemberOffset AccessFlagsOffset() {
- return MemberOffset(OFFSETOF_MEMBER(AbstractMethod, access_flags_));
- }
- static MemberOffset DexMethodIndexOffset() {
- return MemberOffset(OFFSETOF_MEMBER(AbstractMethod, dex_method_index_));
- }
-
- HeapReference<mirror::Class> declaring_class_;
- HeapReference<mirror::Class> declaring_class_of_overridden_method_;
- uint64_t art_method_;
- uint32_t access_flags_;
- uint32_t dex_method_index_;
-
- friend struct art::AbstractMethodOffsets; // for verifying offset information
- DISALLOW_IMPLICIT_CONSTRUCTORS(AbstractMethod);
-};
-
-} // namespace mirror
-} // namespace art
-
-#endif // ART_RUNTIME_MIRROR_ABSTRACT_METHOD_H_
diff --git a/runtime/mirror/abstract_method.cc b/runtime/mirror/executable.cc
similarity index 70%
rename from runtime/mirror/abstract_method.cc
rename to runtime/mirror/executable.cc
index b4dce58..33ebd81 100644
--- a/runtime/mirror/abstract_method.cc
+++ b/runtime/mirror/executable.cc
@@ -14,15 +14,14 @@
* limitations under the License.
*/
-#include "abstract_method.h"
-
#include "art_method-inl.h"
+#include "executable.h"
namespace art {
namespace mirror {
template <PointerSize kPointerSize, bool kTransactionActive>
-bool AbstractMethod::CreateFromArtMethod(ArtMethod* method) {
+bool Executable::CreateFromArtMethod(ArtMethod* method) {
auto* interface_method = method->GetInterfaceMethodIfProxy(kPointerSize);
SetArtMethod<kTransactionActive>(method);
SetFieldObject<kTransactionActive>(DeclaringClassOffset(), method->GetDeclaringClass());
@@ -33,28 +32,28 @@
return true;
}
-template bool AbstractMethod::CreateFromArtMethod<PointerSize::k32, false>(
+template bool Executable::CreateFromArtMethod<PointerSize::k32, false>(
ArtMethod* method);
-template bool AbstractMethod::CreateFromArtMethod<PointerSize::k32, true>(
+template bool Executable::CreateFromArtMethod<PointerSize::k32, true>(
ArtMethod* method);
-template bool AbstractMethod::CreateFromArtMethod<PointerSize::k64, false>(
+template bool Executable::CreateFromArtMethod<PointerSize::k64, false>(
ArtMethod* method);
-template bool AbstractMethod::CreateFromArtMethod<PointerSize::k64, true>(
+template bool Executable::CreateFromArtMethod<PointerSize::k64, true>(
ArtMethod* method);
-ArtMethod* AbstractMethod::GetArtMethod() {
+ArtMethod* Executable::GetArtMethod() {
return reinterpret_cast<ArtMethod*>(GetField64(ArtMethodOffset()));
}
template <bool kTransactionActive>
-void AbstractMethod::SetArtMethod(ArtMethod* method) {
+void Executable::SetArtMethod(ArtMethod* method) {
SetField64<kTransactionActive>(ArtMethodOffset(), reinterpret_cast<uint64_t>(method));
}
-template void AbstractMethod::SetArtMethod<false>(ArtMethod* method);
-template void AbstractMethod::SetArtMethod<true>(ArtMethod* method);
+template void Executable::SetArtMethod<false>(ArtMethod* method);
+template void Executable::SetArtMethod<true>(ArtMethod* method);
-mirror::Class* AbstractMethod::GetDeclaringClass() {
+mirror::Class* Executable::GetDeclaringClass() {
return GetFieldObject<mirror::Class>(DeclaringClassOffset());
}
diff --git a/runtime/mirror/executable.h b/runtime/mirror/executable.h
index 232fce8..6c465f6 100644
--- a/runtime/mirror/executable.h
+++ b/runtime/mirror/executable.h
@@ -32,9 +32,42 @@
// C++ mirror of java.lang.reflect.Executable.
class MANAGED Executable : public AccessibleObject {
+ public:
+ // Called from Constructor::CreateFromArtMethod, Method::CreateFromArtMethod.
+ template <PointerSize kPointerSize, bool kTransactionActive>
+ bool CreateFromArtMethod(ArtMethod* method) REQUIRES_SHARED(Locks::mutator_lock_)
+ REQUIRES(!Roles::uninterruptible_);
+
+ ArtMethod* GetArtMethod() REQUIRES_SHARED(Locks::mutator_lock_);
+ // Only used by the image writer.
+ template <bool kTransactionActive = false>
+ void SetArtMethod(ArtMethod* method) REQUIRES_SHARED(Locks::mutator_lock_);
+ mirror::Class* GetDeclaringClass() REQUIRES_SHARED(Locks::mutator_lock_);
+
private:
uint16_t has_real_parameter_data_;
+ HeapReference<mirror::Class> declaring_class_;
+ HeapReference<mirror::Class> declaring_class_of_overridden_method_;
HeapReference<mirror::Array> parameters_;
+ uint64_t art_method_;
+ uint32_t access_flags_;
+ uint32_t dex_method_index_;
+
+ static MemberOffset ArtMethodOffset() {
+ return MemberOffset(OFFSETOF_MEMBER(Executable, art_method_));
+ }
+ static MemberOffset DeclaringClassOffset() {
+ return MemberOffset(OFFSETOF_MEMBER(Executable, declaring_class_));
+ }
+ static MemberOffset DeclaringClassOfOverriddenMethodOffset() {
+ return MemberOffset(OFFSETOF_MEMBER(Executable, declaring_class_of_overridden_method_));
+ }
+ static MemberOffset AccessFlagsOffset() {
+ return MemberOffset(OFFSETOF_MEMBER(Executable, access_flags_));
+ }
+ static MemberOffset DexMethodIndexOffset() {
+ return MemberOffset(OFFSETOF_MEMBER(Executable, dex_method_index_));
+ }
friend struct art::ExecutableOffsets; // for verifying offset information
DISALLOW_IMPLICIT_CONSTRUCTORS(Executable);
diff --git a/runtime/mirror/method.cc b/runtime/mirror/method.cc
index ef16719..71bac7e 100644
--- a/runtime/mirror/method.cc
+++ b/runtime/mirror/method.cc
@@ -56,7 +56,7 @@
DCHECK(!method->IsConstructor()) << PrettyMethod(method);
auto* ret = down_cast<Method*>(StaticClass()->AllocObject(self));
if (LIKELY(ret != nullptr)) {
- static_cast<AbstractMethod*>(ret)->
+ static_cast<Executable*>(ret)->
CreateFromArtMethod<kPointerSize, kTransactionActive>(method);
}
return ret;
@@ -108,7 +108,7 @@
DCHECK(method->IsConstructor()) << PrettyMethod(method);
auto* ret = down_cast<Constructor*>(StaticClass()->AllocObject(self));
if (LIKELY(ret != nullptr)) {
- static_cast<AbstractMethod*>(ret)->
+ static_cast<Executable*>(ret)->
CreateFromArtMethod<kPointerSize, kTransactionActive>(method);
}
return ret;
diff --git a/runtime/mirror/method.h b/runtime/mirror/method.h
index 6881991..205ea7a 100644
--- a/runtime/mirror/method.h
+++ b/runtime/mirror/method.h
@@ -17,8 +17,8 @@
#ifndef ART_RUNTIME_MIRROR_METHOD_H_
#define ART_RUNTIME_MIRROR_METHOD_H_
-#include "abstract_method.h"
#include "gc_root.h"
+#include "executable.h"
namespace art {
namespace mirror {
@@ -26,7 +26,7 @@
class Class;
// C++ mirror of java.lang.reflect.Method.
-class MANAGED Method : public AbstractMethod {
+class MANAGED Method : public Executable {
public:
template <PointerSize kPointerSize, bool kTransactionActive>
static Method* CreateFromArtMethod(Thread* self, ArtMethod* method)
@@ -58,7 +58,7 @@
};
// C++ mirror of java.lang.reflect.Constructor.
-class MANAGED Constructor: public AbstractMethod {
+class MANAGED Constructor: public Executable {
public:
template <PointerSize kPointerSize, bool kTransactionActive>
static Constructor* CreateFromArtMethod(Thread* self, ArtMethod* method)
diff --git a/runtime/native/java_lang_reflect_AbstractMethod.cc b/runtime/native/java_lang_reflect_Executable.cc
similarity index 77%
rename from runtime/native/java_lang_reflect_AbstractMethod.cc
rename to runtime/native/java_lang_reflect_Executable.cc
index 254f8db..8fcf6ac 100644
--- a/runtime/native/java_lang_reflect_AbstractMethod.cc
+++ b/runtime/native/java_lang_reflect_Executable.cc
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-#include "java_lang_reflect_AbstractMethod.h"
+#include "java_lang_reflect_Executable.h"
#include "art_method-inl.h"
#include "dex_file_annotations.h"
@@ -28,7 +28,7 @@
namespace art {
-static jobjectArray AbstractMethod_getDeclaredAnnotations(JNIEnv* env, jobject javaMethod) {
+static jobjectArray Executable_getDeclaredAnnotationsNative(JNIEnv* env, jobject javaMethod) {
ScopedFastNativeObjectAccess soa(env);
ArtMethod* method = ArtMethod::FromReflectedMethod(soa, javaMethod);
if (method->GetDeclaringClass()->IsProxyClass()) {
@@ -42,7 +42,7 @@
return soa.AddLocalReference<jobjectArray>(annotations::GetAnnotationsForMethod(method));
}
-static jobject AbstractMethod_getAnnotationNative(JNIEnv* env,
+static jobject Executable_getAnnotationNative(JNIEnv* env,
jobject javaMethod,
jclass annotationType) {
ScopedFastNativeObjectAccess soa(env);
@@ -56,7 +56,7 @@
}
}
-static jobjectArray AbstractMethod_getSignatureAnnotation(JNIEnv* env, jobject javaMethod) {
+static jobjectArray Executable_getSignatureAnnotation(JNIEnv* env, jobject javaMethod) {
ScopedFastNativeObjectAccess soa(env);
ArtMethod* method = ArtMethod::FromReflectedMethod(soa, javaMethod);
if (method->GetDeclaringClass()->IsProxyClass()) {
@@ -67,7 +67,7 @@
}
-static jobjectArray AbstractMethod_getParameterAnnotationsNative(JNIEnv* env, jobject javaMethod) {
+static jobjectArray Executable_getParameterAnnotationsNative(JNIEnv* env, jobject javaMethod) {
ScopedFastNativeObjectAccess soa(env);
ArtMethod* method = ArtMethod::FromReflectedMethod(soa, javaMethod);
if (method->IsProxyMethod()) {
@@ -77,7 +77,7 @@
}
}
-static jboolean AbstractMethod_isAnnotationPresentNative(JNIEnv* env,
+static jboolean Executable_isAnnotationPresentNative(JNIEnv* env,
jobject javaMethod,
jclass annotationType) {
ScopedFastNativeObjectAccess soa(env);
@@ -91,17 +91,17 @@
}
static JNINativeMethod gMethods[] = {
- NATIVE_METHOD(AbstractMethod, getAnnotationNative,
+ NATIVE_METHOD(Executable, getAnnotationNative,
"!(Ljava/lang/Class;)Ljava/lang/annotation/Annotation;"),
- NATIVE_METHOD(AbstractMethod, getDeclaredAnnotations, "!()[Ljava/lang/annotation/Annotation;"),
- NATIVE_METHOD(AbstractMethod, getParameterAnnotationsNative,
+ NATIVE_METHOD(Executable, getDeclaredAnnotationsNative, "!()[Ljava/lang/annotation/Annotation;"),
+ NATIVE_METHOD(Executable, getParameterAnnotationsNative,
"!()[[Ljava/lang/annotation/Annotation;"),
- NATIVE_METHOD(AbstractMethod, getSignatureAnnotation, "!()[Ljava/lang/String;"),
- NATIVE_METHOD(AbstractMethod, isAnnotationPresentNative, "!(Ljava/lang/Class;)Z"),
+ NATIVE_METHOD(Executable, getSignatureAnnotation, "!()[Ljava/lang/String;"),
+ NATIVE_METHOD(Executable, isAnnotationPresentNative, "!(Ljava/lang/Class;)Z"),
};
-void register_java_lang_reflect_AbstractMethod(JNIEnv* env) {
- REGISTER_NATIVE_METHODS("java/lang/reflect/AbstractMethod");
+void register_java_lang_reflect_Executable(JNIEnv* env) {
+ REGISTER_NATIVE_METHODS("java/lang/reflect/Executable");
}
} // namespace art
diff --git a/runtime/native/java_lang_reflect_AbstractMethod.h b/runtime/native/java_lang_reflect_Executable.h
similarity index 72%
rename from runtime/native/java_lang_reflect_AbstractMethod.h
rename to runtime/native/java_lang_reflect_Executable.h
index 222e5a0..0cfed62 100644
--- a/runtime/native/java_lang_reflect_AbstractMethod.h
+++ b/runtime/native/java_lang_reflect_Executable.h
@@ -14,15 +14,15 @@
* limitations under the License.
*/
-#ifndef ART_RUNTIME_NATIVE_JAVA_LANG_REFLECT_ABSTRACTMETHOD_H_
-#define ART_RUNTIME_NATIVE_JAVA_LANG_REFLECT_ABSTRACTMETHOD_H_
+#ifndef ART_RUNTIME_NATIVE_JAVA_LANG_REFLECT_EXECUTABLE_H_
+#define ART_RUNTIME_NATIVE_JAVA_LANG_REFLECT_EXECUTABLE_H_
#include <jni.h>
namespace art {
-void register_java_lang_reflect_AbstractMethod(JNIEnv* env);
+void register_java_lang_reflect_Executable(JNIEnv* env);
} // namespace art
-#endif // ART_RUNTIME_NATIVE_JAVA_LANG_REFLECT_ABSTRACTMETHOD_H_
+#endif // ART_RUNTIME_NATIVE_JAVA_LANG_REFLECT_EXECUTABLE_H_
diff --git a/runtime/reflection.cc b/runtime/reflection.cc
index 67e3fe8..c69e98c 100644
--- a/runtime/reflection.cc
+++ b/runtime/reflection.cc
@@ -24,8 +24,8 @@
#include "dex_file-inl.h"
#include "indirect_reference_table-inl.h"
#include "jni_internal.h"
-#include "mirror/abstract_method.h"
#include "mirror/class-inl.h"
+#include "mirror/executable.h"
#include "mirror/object_array-inl.h"
#include "nth_caller_visitor.h"
#include "scoped_thread_state_change.h"
@@ -578,9 +578,9 @@
return nullptr;
}
- auto* abstract_method = soa.Decode<mirror::AbstractMethod*>(javaMethod);
- const bool accessible = abstract_method->IsAccessible();
- ArtMethod* m = abstract_method->GetArtMethod();
+ auto* executable = soa.Decode<mirror::Executable*>(javaMethod);
+ const bool accessible = executable->IsAccessible();
+ ArtMethod* m = executable->GetArtMethod();
mirror::Class* declaring_class = m->GetDeclaringClass();
if (UNLIKELY(!declaring_class->IsInitialized())) {
diff --git a/runtime/runtime.cc b/runtime/runtime.cc
index f144b98..15e3b1c 100644
--- a/runtime/runtime.cc
+++ b/runtime/runtime.cc
@@ -108,9 +108,9 @@
#include "native/java_lang_VMClassLoader.h"
#include "native/java_lang_ref_FinalizerReference.h"
#include "native/java_lang_ref_Reference.h"
-#include "native/java_lang_reflect_AbstractMethod.h"
#include "native/java_lang_reflect_Array.h"
#include "native/java_lang_reflect_Constructor.h"
+#include "native/java_lang_reflect_Executable.h"
#include "native/java_lang_reflect_Field.h"
#include "native/java_lang_reflect_Method.h"
#include "native/java_lang_reflect_Parameter.h"
@@ -1378,9 +1378,9 @@
register_java_lang_DexCache(env);
register_java_lang_Object(env);
register_java_lang_ref_FinalizerReference(env);
- register_java_lang_reflect_AbstractMethod(env);
register_java_lang_reflect_Array(env);
register_java_lang_reflect_Constructor(env);
+ register_java_lang_reflect_Executable(env);
register_java_lang_reflect_Field(env);
register_java_lang_reflect_Method(env);
register_java_lang_reflect_Parameter(env);
diff --git a/runtime/vdex_file.cc b/runtime/vdex_file.cc
index a71578b..9fbf875 100644
--- a/runtime/vdex_file.cc
+++ b/runtime/vdex_file.cc
@@ -34,7 +34,9 @@
return (memcmp(version_, kVdexVersion, sizeof(kVdexVersion)) == 0);
}
-VdexFile::Header::Header() {
+VdexFile::Header::Header(uint32_t dex_size, uint32_t verifier_deps_size)
+ : dex_size_(dex_size),
+ verifier_deps_size_(verifier_deps_size) {
memcpy(magic_, kVdexMagic, sizeof(kVdexMagic));
memcpy(version_, kVdexVersion, sizeof(kVdexVersion));
DCHECK(IsMagicValid());
diff --git a/runtime/vdex_file.h b/runtime/vdex_file.h
index 9215e52..6bea153 100644
--- a/runtime/vdex_file.h
+++ b/runtime/vdex_file.h
@@ -42,17 +42,22 @@
public:
struct Header {
public:
- Header();
+ Header(uint32_t dex_size, uint32_t verifier_deps_size);
bool IsMagicValid() const;
bool IsVersionValid() const;
+ uint32_t GetDexSize() const { return dex_size_; }
+ uint32_t GetVerifierDepsSize() const { return verifier_deps_size_; }
+
private:
static constexpr uint8_t kVdexMagic[] = { 'v', 'd', 'e', 'x' };
static constexpr uint8_t kVdexVersion[] = { '0', '0', '0', '\0' };
uint8_t magic_[4];
uint8_t version_[4];
+ uint32_t dex_size_;
+ uint32_t verifier_deps_size_;
};
static VdexFile* Open(const std::string& vdex_filename,
diff --git a/runtime/verifier/method_verifier.cc b/runtime/verifier/method_verifier.cc
index f1d3189..abd741c 100644
--- a/runtime/verifier/method_verifier.cc
+++ b/runtime/verifier/method_verifier.cc
@@ -3284,7 +3284,7 @@
}
break;
// Note: the following instructions encode offsets derived from class linking.
- // As such they use Class*/Field*/AbstractMethod* as these offsets only have
+ // As such they use Class*/Field*/Executable* as these offsets only have
// meaning if the class linking and resolution were successful.
case Instruction::IGET_QUICK:
VerifyQuickFieldAccess<FieldAccessType::kAccGet>(inst, reg_types_.Integer(), true);
diff --git a/runtime/well_known_classes.cc b/runtime/well_known_classes.cc
index 5f5fbc8..16c7f77 100644
--- a/runtime/well_known_classes.cc
+++ b/runtime/well_known_classes.cc
@@ -48,8 +48,8 @@
jclass WellKnownClasses::java_lang_NoClassDefFoundError;
jclass WellKnownClasses::java_lang_Object;
jclass WellKnownClasses::java_lang_OutOfMemoryError;
-jclass WellKnownClasses::java_lang_reflect_AbstractMethod;
jclass WellKnownClasses::java_lang_reflect_Constructor;
+jclass WellKnownClasses::java_lang_reflect_Executable;
jclass WellKnownClasses::java_lang_reflect_Field;
jclass WellKnownClasses::java_lang_reflect_Method;
jclass WellKnownClasses::java_lang_reflect_Proxy;
@@ -154,7 +154,7 @@
jfieldID WellKnownClasses::java_lang_Throwable_stackTrace;
jfieldID WellKnownClasses::java_lang_Throwable_stackState;
jfieldID WellKnownClasses::java_lang_Throwable_suppressedExceptions;
-jfieldID WellKnownClasses::java_lang_reflect_AbstractMethod_artMethod;
+jfieldID WellKnownClasses::java_lang_reflect_Executable_artMethod;
jfieldID WellKnownClasses::java_lang_reflect_Proxy_h;
jfieldID WellKnownClasses::java_nio_DirectByteBuffer_capacity;
jfieldID WellKnownClasses::java_nio_DirectByteBuffer_effectiveDirectAddress;
@@ -237,8 +237,8 @@
java_lang_ExceptionInInitializerError = CacheClass(env, "java/lang/ExceptionInInitializerError");
java_lang_IllegalAccessError = CacheClass(env, "java/lang/IllegalAccessError");
java_lang_NoClassDefFoundError = CacheClass(env, "java/lang/NoClassDefFoundError");
- java_lang_reflect_AbstractMethod = CacheClass(env, "java/lang/reflect/AbstractMethod");
java_lang_reflect_Constructor = CacheClass(env, "java/lang/reflect/Constructor");
+ java_lang_reflect_Executable = CacheClass(env, "java/lang/reflect/Executable");
java_lang_reflect_Field = CacheClass(env, "java/lang/reflect/Field");
java_lang_reflect_Method = CacheClass(env, "java/lang/reflect/Method");
java_lang_reflect_Proxy = CacheClass(env, "java/lang/reflect/Proxy");
@@ -362,7 +362,7 @@
java_lang_Throwable_stackTrace = CacheField(env, java_lang_Throwable, false, "stackTrace", "[Ljava/lang/StackTraceElement;");
java_lang_Throwable_stackState = CacheField(env, java_lang_Throwable, false, "backtrace", "Ljava/lang/Object;");
java_lang_Throwable_suppressedExceptions = CacheField(env, java_lang_Throwable, false, "suppressedExceptions", "Ljava/util/List;");
- java_lang_reflect_AbstractMethod_artMethod = CacheField(env, java_lang_reflect_AbstractMethod, false, "artMethod", "J");
+ java_lang_reflect_Executable_artMethod = CacheField(env, java_lang_reflect_Executable, false, "artMethod", "J");
java_lang_reflect_Proxy_h = CacheField(env, java_lang_reflect_Proxy, false, "h", "Ljava/lang/reflect/InvocationHandler;");
java_nio_DirectByteBuffer_capacity = CacheField(env, java_nio_DirectByteBuffer, false, "capacity", "I");
java_nio_DirectByteBuffer_effectiveDirectAddress = CacheField(env, java_nio_DirectByteBuffer, false, "address", "J");
diff --git a/runtime/well_known_classes.h b/runtime/well_known_classes.h
index ce710ff..b4d179c 100644
--- a/runtime/well_known_classes.h
+++ b/runtime/well_known_classes.h
@@ -59,8 +59,8 @@
static jclass java_lang_NoClassDefFoundError;
static jclass java_lang_Object;
static jclass java_lang_OutOfMemoryError;
- static jclass java_lang_reflect_AbstractMethod;
static jclass java_lang_reflect_Constructor;
+ static jclass java_lang_reflect_Executable;
static jclass java_lang_reflect_Field;
static jclass java_lang_reflect_Method;
static jclass java_lang_reflect_Proxy;
@@ -148,7 +148,7 @@
static jfieldID dalvik_system_DexPathList_dexElements;
static jfieldID dalvik_system_DexPathList__Element_dexFile;
static jfieldID dalvik_system_PathClassLoader_pathList;
- static jfieldID java_lang_reflect_AbstractMethod_artMethod;
+ static jfieldID java_lang_reflect_Executable_artMethod;
static jfieldID java_lang_reflect_Proxy_h;
static jfieldID java_lang_Thread_daemon;
static jfieldID java_lang_Thread_group;
diff --git a/test/031-class-attributes/src/ClassAttrs.java b/test/031-class-attributes/src/ClassAttrs.java
index 346e13d..39e69a3 100644
--- a/test/031-class-attributes/src/ClassAttrs.java
+++ b/test/031-class-attributes/src/ClassAttrs.java
@@ -1,9 +1,9 @@
import otherpackage.OtherPackageClass;
import java.io.Serializable;
-import java.lang.reflect.AbstractMethod;
import java.lang.reflect.AccessibleObject;
import java.lang.reflect.Constructor;
+import java.lang.reflect.Executable;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
@@ -223,7 +223,7 @@
try {
Class<?> c = obj.getClass();
if (c == Method.class || c == Constructor.class) {
- c = AbstractMethod.class;
+ c = Executable.class;
}
method = c.getDeclaredMethod("getSignatureAttribute");
method.setAccessible(true);
diff --git a/tools/libcore_failures_concurrent_collector.txt b/tools/libcore_failures_concurrent_collector.txt
index 95f0c2d..0e289a6 100644
--- a/tools/libcore_failures_concurrent_collector.txt
+++ b/tools/libcore_failures_concurrent_collector.txt
@@ -10,11 +10,4 @@
*/
[
-{
- description: "Assertion failing on the concurrent collector configuration.",
- result: EXEC_FAILED,
- names: ["jsr166.LinkedTransferQueueTest#testTransfer2",
- "jsr166.LinkedTransferQueueTest#testWaitingConsumer"],
- bug: 25883050
-}
]