diff options
author | Brian Carlstrom <bdc@google.com> | 2013-07-12 08:50:57 -0700 |
---|---|---|
committer | Brian Carlstrom <bdc@google.com> | 2013-07-12 08:50:57 -0700 |
commit | 1581766afea0b31de0ed0f9f677fc3b92a29daae (patch) | |
tree | 78793c270596134e5848dda3af66e674a7160017 | |
parent | 3d76933675895667f212500a65c9c7ea2b6209fc (diff) | |
parent | 51c2467e8771b56e25ae4f17f66522f979f57a7e (diff) | |
download | art-1581766afea0b31de0ed0f9f677fc3b92a29daae.zip art-1581766afea0b31de0ed0f9f677fc3b92a29daae.tar.gz art-1581766afea0b31de0ed0f9f677fc3b92a29daae.tar.bz2 |
resolved conflicts for merge of 51c2467e to dalvik-dev
Change-Id: Ia7a8785d3220df6feeb999bc70f6d1917cad8d75
52 files changed, 647 insertions, 685 deletions
diff --git a/build/Android.common.mk b/build/Android.common.mk index f6fd5c8..671ce5c 100644 --- a/build/Android.common.mk +++ b/build/Android.common.mk @@ -158,341 +158,6 @@ ifeq ($(ART_USE_PORTABLE_COMPILER),true) PARALLEL_ART_COMPILE_JOBS := -j8 endif -DEX2OAT_SRC_FILES := \ - src/dex2oat.cc - -OATDUMP_SRC_FILES := \ - src/oatdump.cc - -LIBART_COMMON_SRC_FILES := \ - src/atomic.cc.arm \ - src/barrier.cc \ - src/base/logging.cc \ - src/base/mutex.cc \ - src/base/stringpiece.cc \ - src/base/stringprintf.cc \ - src/base/timing_logger.cc \ - src/base/unix_file/fd_file.cc \ - src/base/unix_file/mapped_file.cc \ - src/base/unix_file/null_file.cc \ - src/base/unix_file/random_access_file_utils.cc \ - src/base/unix_file/string_file.cc \ - src/check_jni.cc \ - src/class_linker.cc \ - src/common_throws.cc \ - src/compiled_method.cc \ - src/compiler/driver/compiler_driver.cc \ - src/compiler/llvm/runtime_support_llvm.cc \ - src/compiler/stubs/portable/stubs.cc \ - src/compiler/stubs/quick/stubs.cc \ - src/debugger.cc \ - src/dex_file.cc \ - src/dex_file_verifier.cc \ - src/dex_instruction.cc \ - src/disassembler.cc \ - src/disassembler_arm.cc \ - src/disassembler_mips.cc \ - src/disassembler_x86.cc \ - src/elf_file.cc \ - src/file_output_stream.cc \ - src/gc/allocator/dlmalloc.cc \ - src/gc/accounting/card_table.cc \ - src/gc/accounting/heap_bitmap.cc \ - src/gc/accounting/mod_union_table.cc \ - src/gc/accounting/space_bitmap.cc \ - src/gc/collector/garbage_collector.cc \ - src/gc/collector/mark_sweep.cc \ - src/gc/collector/partial_mark_sweep.cc \ - src/gc/collector/sticky_mark_sweep.cc \ - src/gc/heap.cc \ - src/gc/space/dlmalloc_space.cc \ - src/gc/space/image_space.cc \ - src/gc/space/large_object_space.cc \ - src/gc/space/space.cc \ - src/hprof/hprof.cc \ - src/image.cc \ - src/image_writer.cc \ - src/indirect_reference_table.cc \ - src/instrumentation.cc \ - src/intern_table.cc \ - src/interpreter/interpreter.cc \ - src/jdwp/jdwp_event.cc \ - src/jdwp/jdwp_expand_buf.cc \ - src/jdwp/jdwp_handler.cc \ - src/jdwp/jdwp_main.cc \ - src/jdwp/jdwp_request.cc \ - src/jdwp/jdwp_socket.cc \ - src/jdwp/object_registry.cc \ - src/jni_internal.cc \ - src/jobject_comparator.cc \ - src/locks.cc \ - src/mem_map.cc \ - src/memory_region.cc \ - src/mirror/abstract_method.cc \ - src/mirror/array.cc \ - src/mirror/class.cc \ - src/mirror/dex_cache.cc \ - src/mirror/field.cc \ - src/mirror/object.cc \ - src/mirror/stack_trace_element.cc \ - src/mirror/string.cc \ - src/mirror/throwable.cc \ - src/monitor.cc \ - src/native/dalvik_system_DexFile.cc \ - src/native/dalvik_system_VMDebug.cc \ - src/native/dalvik_system_VMRuntime.cc \ - src/native/dalvik_system_VMStack.cc \ - src/native/dalvik_system_Zygote.cc \ - src/native/java_lang_Class.cc \ - src/native/java_lang_Object.cc \ - src/native/java_lang_Runtime.cc \ - src/native/java_lang_String.cc \ - src/native/java_lang_System.cc \ - src/native/java_lang_Thread.cc \ - src/native/java_lang_Throwable.cc \ - src/native/java_lang_VMClassLoader.cc \ - src/native/java_lang_reflect_Array.cc \ - src/native/java_lang_reflect_Constructor.cc \ - src/native/java_lang_reflect_Field.cc \ - src/native/java_lang_reflect_Method.cc \ - src/native/java_lang_reflect_Proxy.cc \ - src/native/java_util_concurrent_atomic_AtomicLong.cc \ - src/native/org_apache_harmony_dalvik_ddmc_DdmServer.cc \ - src/native/org_apache_harmony_dalvik_ddmc_DdmVmInternal.cc \ - src/native/sun_misc_Unsafe.cc \ - src/oat.cc \ - src/oat/utils/arm/assembler_arm.cc \ - src/oat/utils/arm/managed_register_arm.cc \ - src/oat/utils/assembler.cc \ - src/oat/utils/mips/assembler_mips.cc \ - src/oat/utils/mips/managed_register_mips.cc \ - src/oat/utils/x86/assembler_x86.cc \ - src/oat/utils/x86/managed_register_x86.cc \ - src/oat_file.cc \ - src/oat_writer.cc \ - src/offsets.cc \ - src/os_linux.cc \ - src/primitive.cc \ - src/reference_table.cc \ - src/reflection.cc \ - src/runtime.cc \ - src/runtime_support.cc \ - src/signal_catcher.cc \ - src/stack.cc \ - src/thread.cc \ - src/thread_list.cc \ - src/thread_pool.cc \ - src/throw_location.cc \ - src/trace.cc \ - src/utf.cc \ - src/utils.cc \ - src/vector_output_stream.cc \ - src/verifier/dex_gc_map.cc \ - src/verifier/instruction_flags.cc \ - src/verifier/method_verifier.cc \ - src/verifier/reg_type.cc \ - src/verifier/reg_type_cache.cc \ - src/verifier/register_line.cc \ - src/well_known_classes.cc \ - src/zip_archive.cc - -LIBART_COMMON_SRC_FILES += \ - src/oat/runtime/context.cc \ - src/oat/runtime/support_alloc.cc \ - src/oat/runtime/support_cast.cc \ - src/oat/runtime/support_deoptimize.cc \ - src/oat/runtime/support_dexcache.cc \ - src/oat/runtime/support_field.cc \ - src/oat/runtime/support_fillarray.cc \ - src/oat/runtime/support_instrumentation.cc \ - src/oat/runtime/support_invoke.cc \ - src/oat/runtime/support_jni.cc \ - src/oat/runtime/support_locks.cc \ - src/oat/runtime/support_math.cc \ - src/oat/runtime/support_proxy.cc \ - src/oat/runtime/support_stubs.cc \ - src/oat/runtime/support_thread.cc \ - src/oat/runtime/support_throw.cc \ - src/oat/runtime/support_interpreter.cc - -ifeq ($(ART_SEA_IR_MODE),true) -LIBART_COMMON_SRC_FILES += \ - src/compiler/sea_ir/sea.cc \ - src/compiler/sea_ir/instruction_tools.cc -endif - -LIBART_TARGET_SRC_FILES := \ - $(LIBART_COMMON_SRC_FILES) \ - src/base/logging_android.cc \ - src/jdwp/jdwp_adb.cc \ - src/monitor_android.cc \ - src/runtime_android.cc \ - src/thread_android.cc - -ifeq ($(TARGET_ARCH),arm) -LIBART_TARGET_SRC_FILES += \ - src/oat/runtime/arm/context_arm.cc.arm \ - src/oat/runtime/arm/oat_support_entrypoints_arm.cc \ - src/oat/runtime/arm/runtime_support_arm.S -else # TARGET_ARCH != arm -ifeq ($(TARGET_ARCH),x86) -LIBART_TARGET_SRC_FILES += \ - src/oat/runtime/x86/context_x86.cc \ - src/oat/runtime/x86/oat_support_entrypoints_x86.cc \ - src/oat/runtime/x86/runtime_support_x86.S -else # TARGET_ARCH != x86 -ifeq ($(TARGET_ARCH),mips) -LIBART_TARGET_SRC_FILES += \ - src/oat/runtime/mips/context_mips.cc \ - src/oat/runtime/mips/oat_support_entrypoints_mips.cc \ - src/oat/runtime/mips/runtime_support_mips.S -else # TARGET_ARCH != mips -$(error unsupported TARGET_ARCH=$(TARGET_ARCH)) -endif # TARGET_ARCH != mips -endif # TARGET_ARCH != x86 -endif # TARGET_ARCH != arm - -ifeq ($(TARGET_ARCH),arm) -LIBART_TARGET_SRC_FILES += src/thread_arm.cc -else # TARGET_ARCH != arm -ifeq ($(TARGET_ARCH),x86) -LIBART_TARGET_SRC_FILES += src/thread_x86.cc -else # TARGET_ARCH != x86 -ifeq ($(TARGET_ARCH),mips) -LIBART_TARGET_SRC_FILES += src/thread_mips.cc -else # TARGET_ARCH != mips -$(error unsupported TARGET_ARCH=$(TARGET_ARCH)) -endif # TARGET_ARCH != mips -endif # TARGET_ARCH != x86 -endif # TARGET_ARCH != arm - -LIBART_HOST_SRC_FILES := \ - $(LIBART_COMMON_SRC_FILES) \ - src/base/logging_linux.cc \ - src/monitor_linux.cc \ - src/runtime_linux.cc \ - src/thread_linux.cc - -ifeq ($(HOST_ARCH),x86) -LIBART_HOST_SRC_FILES += \ - src/oat/runtime/x86/context_x86.cc \ - src/oat/runtime/x86/oat_support_entrypoints_x86.cc \ - src/oat/runtime/x86/runtime_support_x86.S -else # HOST_ARCH != x86 -$(error unsupported HOST_ARCH=$(HOST_ARCH)) -endif # HOST_ARCH != x86 - -ifeq ($(HOST_ARCH),x86) -LIBART_HOST_SRC_FILES += src/thread_x86.cc -else # HOST_ARCH != x86 -$(error unsupported HOST_ARCH=$(HOST_ARCH)) -endif # HOST_ARCH != x86 - - -LIBART_ENUM_OPERATOR_OUT_HEADER_FILES := \ - src/base/mutex.h \ - src/compiler/dex/compiler_enums.h \ - src/dex_file.h \ - src/dex_instruction.h \ - src/gc/collector/gc_type.h \ - src/gc/space/space.h \ - src/gc/heap.h \ - src/indirect_reference_table.h \ - src/instruction_set.h \ - src/invoke_type.h \ - src/jdwp/jdwp.h \ - src/jdwp/jdwp_constants.h \ - src/locks.h \ - src/mirror/class.h \ - src/thread.h \ - src/thread_state.h \ - src/verifier/method_verifier.h - -LIBARTTEST_COMMON_SRC_FILES := \ - test/ReferenceMap/stack_walk_refmap_jni.cc \ - test/StackWalk/stack_walk_jni.cc - -TEST_COMMON_SRC_FILES := \ - src/barrier_test.cc \ - src/base/histogram_test.cc \ - src/base/mutex_test.cc \ - src/base/unix_file/fd_file_test.cc \ - src/base/unix_file/mapped_file_test.cc \ - src/base/unix_file/null_file_test.cc \ - src/base/unix_file/random_access_file_utils_test.cc \ - src/base/unix_file/string_file_test.cc \ - src/class_linker_test.cc \ - src/compiler/driver/compiler_driver_test.cc \ - src/compiler/jni/jni_compiler_test.cc \ - src/dex_file_test.cc \ - src/dex_instruction_visitor_test.cc \ - src/dex_method_iterator_test.cc \ - src/elf_writer_test.cc \ - src/exception_test.cc \ - src/gc/accounting/space_bitmap_test.cc \ - src/gc/heap_test.cc \ - src/gc/space/space_test.cc \ - src/gtest_test.cc \ - src/image_test.cc \ - src/indenter_test.cc \ - src/indirect_reference_table_test.cc \ - src/intern_table_test.cc \ - src/jni_internal_test.cc \ - src/mirror/dex_cache_test.cc \ - src/mirror/object_test.cc \ - src/oat/utils/arm/managed_register_arm_test.cc \ - src/oat/utils/x86/managed_register_x86_test.cc \ - src/oat_test.cc \ - src/output_stream_test.cc \ - src/reference_table_test.cc \ - src/runtime_support_test.cc \ - src/runtime_test.cc \ - src/thread_pool_test.cc \ - src/utils_test.cc \ - src/verifier/method_verifier_test.cc \ - src/verifier/reg_type_test.cc \ - src/zip_archive_test.cc - -TEST_TARGET_SRC_FILES := \ - $(TEST_COMMON_SRC_FILES) - -TEST_HOST_SRC_FILES := \ - $(TEST_COMMON_SRC_FILES) \ - src/oat/utils/x86/assembler_x86_test.cc - -# subdirectories of test/ which are used as inputs for gtests -TEST_DEX_DIRECTORIES := \ - AbstractMethod \ - AllFields \ - CreateMethodSignature \ - ExceptionHandle \ - Interfaces \ - Main \ - MyClass \ - MyClassNatives \ - Nested \ - NonStaticLeafMethods \ - ProtoCompare \ - ProtoCompare2 \ - StaticLeafMethods \ - Statics \ - StaticsFromCode \ - XandY - -# subdirectories of test/ which are used with test-art-target-oat -# Declare the simplest tests (Main, HelloWorld) first, the rest are alphabetical -TEST_OAT_DIRECTORIES := \ - Main \ - HelloWorld \ - \ - ParallelGC \ - ReferenceMap \ - StackWalk \ - ThreadStress - -# TODO: Enable when the StackWalk2 tests are passing -# StackWalk2 \ - ART_BUILD_TARGET := false ART_BUILD_HOST := false ART_BUILD_NDEBUG := false diff --git a/build/Android.executable.mk b/build/Android.executable.mk index 83a1706..e74645c 100644 --- a/build/Android.executable.mk +++ b/build/Android.executable.mk @@ -14,6 +14,12 @@ # limitations under the License. # +DEX2OAT_SRC_FILES := \ + src/dex2oat.cc + +OATDUMP_SRC_FILES := \ + src/oatdump.cc + ART_HOST_EXECUTABLES := ART_TARGET_EXECUTABLES := @@ -24,24 +30,26 @@ endif # $(1): executable ("d" will be appended for debug version) # $(2): source -# $(3): target or host -# $(4): ndebug or debug +# $(3): shared libraries +# $(4): target or host +# $(5): ndebug or debug define build-art-executable - ifneq ($(3),target) - ifneq ($(3),host) - $$(error expected target or host for argument 3, received $(3)) + ifneq ($(4),target) + ifneq ($(4),host) + $$(error expected target or host for argument 4, received $(4)) endif endif - ifneq ($(4),ndebug) - ifneq ($(4),debug) - $$(error expected ndebug or debug for argument 4, received $(4)) + ifneq ($(5),ndebug) + ifneq ($(5),debug) + $$(error expected ndebug or debug for argument 5, received $(5)) endif endif art_executable := $(1) art_source := $(2) - art_target_or_host := $(3) - art_ndebug_or_debug := $(4) + art_shared_libraries := $(3) + art_target_or_host := $(4) + art_ndebug_or_debug := $(5) include $(CLEAR_VARS) ifeq ($$(art_target_or_host),target) @@ -52,7 +60,7 @@ define build-art-executable LOCAL_MODULE_TAGS := optional LOCAL_SRC_FILES := $$(art_source) LOCAL_C_INCLUDES += $(ART_C_INCLUDES) - LOCAL_SHARED_LIBRARIES := libnativehelper + LOCAL_SHARED_LIBRARIES := $$(art_shared_libraries) # libnativehelper ifeq ($$(art_ndebug_or_debug),ndebug) LOCAL_MODULE := $$(art_executable) @@ -89,7 +97,8 @@ define build-art-executable LOCAL_SHARED_LIBRARIES += libstlport endif - LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/build/Android.executable.mk + LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/build/Android.common.mk + LOCAL_ADDITIONAL_DEPENDENCIES += $(LOCAL_PATH)/build/Android.executable.mk ifeq ($$(art_target_or_host),target) include $(BUILD_EXECUTABLE) @@ -102,25 +111,25 @@ define build-art-executable endef ifeq ($(ART_BUILD_TARGET_NDEBUG),true) - $(eval $(call build-art-executable,dex2oat,$(DEX2OAT_SRC_FILES),target,ndebug)) - $(eval $(call build-art-executable,oatdump,$(OATDUMP_SRC_FILES),target,ndebug)) + $(eval $(call build-art-executable,dex2oat,$(DEX2OAT_SRC_FILES),libart-compiler,target,ndebug)) + $(eval $(call build-art-executable,oatdump,$(OATDUMP_SRC_FILES),,target,ndebug)) endif ifeq ($(ART_BUILD_TARGET_DEBUG),true) - $(eval $(call build-art-executable,dex2oat,$(DEX2OAT_SRC_FILES),target,debug)) - $(eval $(call build-art-executable,oatdump,$(OATDUMP_SRC_FILES),target,debug)) + $(eval $(call build-art-executable,dex2oat,$(DEX2OAT_SRC_FILES),libartd-compiler,target,debug)) + $(eval $(call build-art-executable,oatdump,$(OATDUMP_SRC_FILES),,target,debug)) endif # We always build dex2oat and dependencies, even if the host build is otherwise disabled, since they are used to cross compile for the target. ifeq ($(ART_BUILD_NDEBUG),true) - $(eval $(call build-art-executable,dex2oat,$(DEX2OAT_SRC_FILES),host,ndebug)) + $(eval $(call build-art-executable,dex2oat,$(DEX2OAT_SRC_FILES),libart-compiler,host,ndebug)) endif ifeq ($(ART_BUILD_NDEBUG),true) - $(eval $(call build-art-executable,dex2oat,$(DEX2OAT_SRC_FILES),host,debug)) + $(eval $(call build-art-executable,dex2oat,$(DEX2OAT_SRC_FILES),libartd-compiler,host,debug)) endif ifeq ($(ART_BUILD_HOST_NDEBUG),true) - $(eval $(call build-art-executable,oatdump,$(OATDUMP_SRC_FILES),host,ndebug)) + $(eval $(call build-art-executable,oatdump,$(OATDUMP_SRC_FILES),,host,ndebug)) endif ifeq ($(ART_BUILD_HOST_DEBUG),true) - $(eval $(call build-art-executable,oatdump,$(OATDUMP_SRC_FILES),host,debug)) + $(eval $(call build-art-executable,oatdump,$(OATDUMP_SRC_FILES),,host,debug)) endif diff --git a/build/Android.gtest.mk b/build/Android.gtest.mk index f13c47e..8b65efd 100644 --- a/build/Android.gtest.mk +++ b/build/Android.gtest.mk @@ -14,6 +14,54 @@ # limitations under the License. # +TEST_COMMON_SRC_FILES := \ + src/barrier_test.cc \ + src/base/histogram_test.cc \ + src/base/mutex_test.cc \ + src/base/unix_file/fd_file_test.cc \ + src/base/unix_file/mapped_file_test.cc \ + src/base/unix_file/null_file_test.cc \ + src/base/unix_file/random_access_file_utils_test.cc \ + src/base/unix_file/string_file_test.cc \ + src/class_linker_test.cc \ + src/compiler/driver/compiler_driver_test.cc \ + src/compiler/elf_writer_test.cc \ + src/compiler/jni/jni_compiler_test.cc \ + src/dex_file_test.cc \ + src/dex_instruction_visitor_test.cc \ + src/dex_method_iterator_test.cc \ + src/exception_test.cc \ + src/gc/accounting/space_bitmap_test.cc \ + src/gc/heap_test.cc \ + src/gc/space/space_test.cc \ + src/gtest_test.cc \ + src/image_test.cc \ + src/indenter_test.cc \ + src/indirect_reference_table_test.cc \ + src/intern_table_test.cc \ + src/jni_internal_test.cc \ + src/mirror/dex_cache_test.cc \ + src/mirror/object_test.cc \ + src/oat/utils/arm/managed_register_arm_test.cc \ + src/oat/utils/x86/managed_register_x86_test.cc \ + src/oat_test.cc \ + src/output_stream_test.cc \ + src/reference_table_test.cc \ + src/runtime_support_test.cc \ + src/runtime_test.cc \ + src/thread_pool_test.cc \ + src/utils_test.cc \ + src/verifier/method_verifier_test.cc \ + src/verifier/reg_type_test.cc \ + src/zip_archive_test.cc + +TEST_TARGET_SRC_FILES := \ + $(TEST_COMMON_SRC_FILES) + +TEST_HOST_SRC_FILES := \ + $(TEST_COMMON_SRC_FILES) \ + src/oat/utils/x86/assembler_x86_test.cc + ART_HOST_TEST_EXECUTABLES := ART_TARGET_TEST_EXECUTABLES := ART_HOST_TEST_TARGETS := @@ -50,7 +98,9 @@ define build-art-test endif LOCAL_SRC_FILES := $$(art_gtest_filename) src/common_test.cc LOCAL_C_INCLUDES += $(ART_C_INCLUDES) - LOCAL_SHARED_LIBRARIES := libartd + LOCAL_SHARED_LIBRARIES := libartd-compiler libartd + LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/build/Android.common.mk + LOCAL_ADDITIONAL_DEPENDENCIES += $(LOCAL_PATH)/build/Android.gtest.mk # Mac OS linker doesn't understand --export-dynamic. ifneq ($(HOST_OS)-$$(art_target_or_host),darwin-host) diff --git a/build/Android.libart-compiler.mk b/build/Android.libart-compiler.mk index c226bbc..ce6edba 100644 --- a/build/Android.libart-compiler.mk +++ b/build/Android.libart-compiler.mk @@ -51,7 +51,7 @@ LIBART_COMPILER_SRC_FILES := \ src/compiler/dex/mir_graph.cc \ src/compiler/dex/vreg_analysis.cc \ src/compiler/dex/ssa_transformation.cc \ - src/compiler/dex/write_elf.cc \ + src/compiler/driver/compiler_driver.cc \ src/compiler/driver/dex_compilation_unit.cc \ src/compiler/jni/portable/jni_compiler.cc \ src/compiler/jni/quick/arm/calling_convention_arm.cc \ @@ -70,11 +70,14 @@ LIBART_COMPILER_SRC_FILES := \ src/compiler/llvm/runtime_support_builder_arm.cc \ src/compiler/llvm/runtime_support_builder_thumb2.cc \ src/compiler/llvm/runtime_support_builder_x86.cc \ - src/compiler/llvm/runtime_support_llvm.cc \ - src/elf_fixup.cc \ - src/elf_stripper.cc \ - src/elf_writer.cc \ - src/elf_writer_quick.cc + src/compiler/stubs/portable/stubs.cc \ + src/compiler/stubs/quick/stubs.cc \ + src/compiler/elf_fixup.cc \ + src/compiler/elf_stripper.cc \ + src/compiler/elf_writer.cc \ + src/compiler/elf_writer_quick.cc \ + src/compiler/image_writer.cc \ + src/compiler/oat_writer.cc ifeq ($(ART_SEA_IR_MODE),true) LIBART_COMPILER_SRC_FILES += \ @@ -84,7 +87,7 @@ endif LIBART_COMPILER_CFLAGS := ifeq ($(ART_USE_PORTABLE_COMPILER),true) - LIBART_COMPILER_SRC_FILES += src/elf_writer_mclinker.cc + LIBART_COMPILER_SRC_FILES += src/compiler/elf_writer_mclinker.cc LIBART_COMPILER_CFLAGS += -DART_USE_PORTABLE_COMPILER=1 endif @@ -162,6 +165,8 @@ define build-libart-compiler else # host LOCAL_LDLIBS := -ldl -lpthread endif + LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/build/Android.common.mk + LOCAL_ADDITIONAL_DEPENDENCIES += $(LOCAL_PATH)/build/Android.libart-compiler.mk ifeq ($$(art_target_or_host),target) LOCAL_SHARED_LIBRARIES += libcutils include $(LLVM_GEN_INTRINSICS_MK) diff --git a/build/Android.libart.mk b/build/Android.libart.mk index 74e9b21..2f17583 100644 --- a/build/Android.libart.mk +++ b/build/Android.libart.mk @@ -14,6 +14,245 @@ # limitations under the License. # +LIBART_COMMON_SRC_FILES := \ + src/atomic.cc.arm \ + src/barrier.cc \ + src/base/logging.cc \ + src/base/mutex.cc \ + src/base/stringpiece.cc \ + src/base/stringprintf.cc \ + src/base/timing_logger.cc \ + src/base/unix_file/fd_file.cc \ + src/base/unix_file/mapped_file.cc \ + src/base/unix_file/null_file.cc \ + src/base/unix_file/random_access_file_utils.cc \ + src/base/unix_file/string_file.cc \ + src/check_jni.cc \ + src/class_linker.cc \ + src/common_throws.cc \ + src/compiled_method.cc \ + src/debugger.cc \ + src/dex_file.cc \ + src/dex_file_verifier.cc \ + src/dex_instruction.cc \ + src/disassembler.cc \ + src/disassembler_arm.cc \ + src/disassembler_mips.cc \ + src/disassembler_x86.cc \ + src/elf_file.cc \ + src/file_output_stream.cc \ + src/gc/allocator/dlmalloc.cc \ + src/gc/accounting/card_table.cc \ + src/gc/accounting/heap_bitmap.cc \ + src/gc/accounting/mod_union_table.cc \ + src/gc/accounting/space_bitmap.cc \ + src/gc/collector/garbage_collector.cc \ + src/gc/collector/mark_sweep.cc \ + src/gc/collector/partial_mark_sweep.cc \ + src/gc/collector/sticky_mark_sweep.cc \ + src/gc/heap.cc \ + src/gc/space/dlmalloc_space.cc \ + src/gc/space/image_space.cc \ + src/gc/space/large_object_space.cc \ + src/gc/space/space.cc \ + src/hprof/hprof.cc \ + src/image.cc \ + src/indirect_reference_table.cc \ + src/instrumentation.cc \ + src/intern_table.cc \ + src/interpreter/interpreter.cc \ + src/jdwp/jdwp_event.cc \ + src/jdwp/jdwp_expand_buf.cc \ + src/jdwp/jdwp_handler.cc \ + src/jdwp/jdwp_main.cc \ + src/jdwp/jdwp_request.cc \ + src/jdwp/jdwp_socket.cc \ + src/jdwp/object_registry.cc \ + src/jni_internal.cc \ + src/jobject_comparator.cc \ + src/locks.cc \ + src/mem_map.cc \ + src/memory_region.cc \ + src/mirror/abstract_method.cc \ + src/mirror/array.cc \ + src/mirror/class.cc \ + src/mirror/dex_cache.cc \ + src/mirror/field.cc \ + src/mirror/object.cc \ + src/mirror/stack_trace_element.cc \ + src/mirror/string.cc \ + src/mirror/throwable.cc \ + src/monitor.cc \ + src/native/dalvik_system_DexFile.cc \ + src/native/dalvik_system_VMDebug.cc \ + src/native/dalvik_system_VMRuntime.cc \ + src/native/dalvik_system_VMStack.cc \ + src/native/dalvik_system_Zygote.cc \ + src/native/java_lang_Class.cc \ + src/native/java_lang_Object.cc \ + src/native/java_lang_Runtime.cc \ + src/native/java_lang_String.cc \ + src/native/java_lang_System.cc \ + src/native/java_lang_Thread.cc \ + src/native/java_lang_Throwable.cc \ + src/native/java_lang_VMClassLoader.cc \ + src/native/java_lang_reflect_Array.cc \ + src/native/java_lang_reflect_Constructor.cc \ + src/native/java_lang_reflect_Field.cc \ + src/native/java_lang_reflect_Method.cc \ + src/native/java_lang_reflect_Proxy.cc \ + src/native/java_util_concurrent_atomic_AtomicLong.cc \ + src/native/org_apache_harmony_dalvik_ddmc_DdmServer.cc \ + src/native/org_apache_harmony_dalvik_ddmc_DdmVmInternal.cc \ + src/native/sun_misc_Unsafe.cc \ + src/oat.cc \ + src/oat/utils/arm/assembler_arm.cc \ + src/oat/utils/arm/managed_register_arm.cc \ + src/oat/utils/assembler.cc \ + src/oat/utils/mips/assembler_mips.cc \ + src/oat/utils/mips/managed_register_mips.cc \ + src/oat/utils/x86/assembler_x86.cc \ + src/oat/utils/x86/managed_register_x86.cc \ + src/oat_file.cc \ + src/offsets.cc \ + src/os_linux.cc \ + src/primitive.cc \ + src/reference_table.cc \ + src/reflection.cc \ + src/runtime.cc \ + src/runtime_support.cc \ + src/runtime_support_llvm.cc \ + src/signal_catcher.cc \ + src/stack.cc \ + src/thread.cc \ + src/thread_list.cc \ + src/thread_pool.cc \ + src/throw_location.cc \ + src/trace.cc \ + src/utf.cc \ + src/utils.cc \ + src/vector_output_stream.cc \ + src/verifier/dex_gc_map.cc \ + src/verifier/instruction_flags.cc \ + src/verifier/method_verifier.cc \ + src/verifier/reg_type.cc \ + src/verifier/reg_type_cache.cc \ + src/verifier/register_line.cc \ + src/well_known_classes.cc \ + src/zip_archive.cc + +LIBART_COMMON_SRC_FILES += \ + src/oat/runtime/context.cc \ + src/oat/runtime/support_alloc.cc \ + src/oat/runtime/support_cast.cc \ + src/oat/runtime/support_deoptimize.cc \ + src/oat/runtime/support_dexcache.cc \ + src/oat/runtime/support_field.cc \ + src/oat/runtime/support_fillarray.cc \ + src/oat/runtime/support_instrumentation.cc \ + src/oat/runtime/support_invoke.cc \ + src/oat/runtime/support_jni.cc \ + src/oat/runtime/support_locks.cc \ + src/oat/runtime/support_math.cc \ + src/oat/runtime/support_proxy.cc \ + src/oat/runtime/support_stubs.cc \ + src/oat/runtime/support_thread.cc \ + src/oat/runtime/support_throw.cc \ + src/oat/runtime/support_interpreter.cc + +ifeq ($(ART_SEA_IR_MODE),true) +LIBART_COMMON_SRC_FILES += \ + src/compiler/sea_ir/sea.cc \ + src/compiler/sea_ir/instruction_tools.cc +endif + +LIBART_TARGET_SRC_FILES := \ + $(LIBART_COMMON_SRC_FILES) \ + src/base/logging_android.cc \ + src/jdwp/jdwp_adb.cc \ + src/monitor_android.cc \ + src/runtime_android.cc \ + src/thread_android.cc + +ifeq ($(TARGET_ARCH),arm) +LIBART_TARGET_SRC_FILES += \ + src/oat/runtime/arm/context_arm.cc.arm \ + src/oat/runtime/arm/oat_support_entrypoints_arm.cc \ + src/oat/runtime/arm/runtime_support_arm.S +else # TARGET_ARCH != arm +ifeq ($(TARGET_ARCH),x86) +LIBART_TARGET_SRC_FILES += \ + src/oat/runtime/x86/context_x86.cc \ + src/oat/runtime/x86/oat_support_entrypoints_x86.cc \ + src/oat/runtime/x86/runtime_support_x86.S +else # TARGET_ARCH != x86 +ifeq ($(TARGET_ARCH),mips) +LIBART_TARGET_SRC_FILES += \ + src/oat/runtime/mips/context_mips.cc \ + src/oat/runtime/mips/oat_support_entrypoints_mips.cc \ + src/oat/runtime/mips/runtime_support_mips.S +else # TARGET_ARCH != mips +$(error unsupported TARGET_ARCH=$(TARGET_ARCH)) +endif # TARGET_ARCH != mips +endif # TARGET_ARCH != x86 +endif # TARGET_ARCH != arm + +ifeq ($(TARGET_ARCH),arm) +LIBART_TARGET_SRC_FILES += src/thread_arm.cc +else # TARGET_ARCH != arm +ifeq ($(TARGET_ARCH),x86) +LIBART_TARGET_SRC_FILES += src/thread_x86.cc +else # TARGET_ARCH != x86 +ifeq ($(TARGET_ARCH),mips) +LIBART_TARGET_SRC_FILES += src/thread_mips.cc +else # TARGET_ARCH != mips +$(error unsupported TARGET_ARCH=$(TARGET_ARCH)) +endif # TARGET_ARCH != mips +endif # TARGET_ARCH != x86 +endif # TARGET_ARCH != arm + +LIBART_HOST_SRC_FILES := \ + $(LIBART_COMMON_SRC_FILES) \ + src/base/logging_linux.cc \ + src/monitor_linux.cc \ + src/runtime_linux.cc \ + src/thread_linux.cc + +ifeq ($(HOST_ARCH),x86) +LIBART_HOST_SRC_FILES += \ + src/oat/runtime/x86/context_x86.cc \ + src/oat/runtime/x86/oat_support_entrypoints_x86.cc \ + src/oat/runtime/x86/runtime_support_x86.S +else # HOST_ARCH != x86 +$(error unsupported HOST_ARCH=$(HOST_ARCH)) +endif # HOST_ARCH != x86 + +ifeq ($(HOST_ARCH),x86) +LIBART_HOST_SRC_FILES += src/thread_x86.cc +else # HOST_ARCH != x86 +$(error unsupported HOST_ARCH=$(HOST_ARCH)) +endif # HOST_ARCH != x86 + + +LIBART_ENUM_OPERATOR_OUT_HEADER_FILES := \ + src/base/mutex.h \ + src/compiler/dex/compiler_enums.h \ + src/dex_file.h \ + src/dex_instruction.h \ + src/gc/collector/gc_type.h \ + src/gc/space/space.h \ + src/gc/heap.h \ + src/indirect_reference_table.h \ + src/instruction_set.h \ + src/invoke_type.h \ + src/jdwp/jdwp.h \ + src/jdwp/jdwp_constants.h \ + src/locks.h \ + src/mirror/class.h \ + src/thread.h \ + src/thread_state.h \ + src/verifier/method_verifier.h + LIBART_CFLAGS := ifeq ($(ART_USE_PORTABLE_COMPILER),true) LIBART_CFLAGS += -DART_USE_PORTABLE_COMPILER=1 @@ -105,6 +344,8 @@ $$(ENUM_OPERATOR_OUT_GEN): $$(GENERATED_SRC_DIR)/%_operator_out.cc : art/%.h endif endif include $(LLVM_GEN_INTRINSICS_MK) + LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/build/Android.common.mk + LOCAL_ADDITIONAL_DEPENDENCIES += $(LOCAL_PATH)/build/Android.libart.mk ifeq ($$(art_target_or_host),target) include $(LLVM_DEVICE_BUILD_MK) include $(BUILD_SHARED_LIBRARY) diff --git a/build/Android.libarttest.mk b/build/Android.libarttest.mk index 50b9a10..64f8368 100644 --- a/build/Android.libarttest.mk +++ b/build/Android.libarttest.mk @@ -14,6 +14,10 @@ # limitations under the License. # +LIBARTTEST_COMMON_SRC_FILES := \ + test/ReferenceMap/stack_walk_refmap_jni.cc \ + test/StackWalk/stack_walk_jni.cc + # $(1): target or host define build-libarttest ifneq ($(1),target) @@ -37,6 +41,8 @@ define build-libarttest LOCAL_SRC_FILES := $(LIBARTTEST_COMMON_SRC_FILES) LOCAL_SHARED_LIBRARIES := libartd LOCAL_C_INCLUDES += $(ART_C_INCLUDES) + LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/build/Android.common.mk + LOCAL_ADDITIONAL_DEPENDENCIES += $(LOCAL_PATH)/build/Android.libarttest.mk ifeq ($$(art_target_or_host),target) LOCAL_CLANG := $(ART_TARGET_CLANG) LOCAL_CFLAGS := $(ART_TARGET_CFLAGS) $(ART_TARGET_DEBUG_CFLAGS) diff --git a/build/Android.oat.mk b/build/Android.oat.mk index 0e91b43..2471244 100644 --- a/build/Android.oat.mk +++ b/build/Android.oat.mk @@ -75,7 +75,9 @@ ifeq ($(ART_BUILD_HOST),true) include $(CLEAR_VARS) LOCAL_MODULE := core.art-host LOCAL_MODULE_TAGS := optional -LOCAL_ADDITIONAL_DEPENDENCIES := $(HOST_CORE_IMG_OUT) +LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/build/Android.common.mk +LOCAL_ADDITIONAL_DEPENDENCIES += $(LOCAL_PATH)/build/Android.oat.mk +LOCAL_ADDITIONAL_DEPENDENCIES += $(HOST_CORE_IMG_OUT) include $(BUILD_PHONY_PACKAGE) endif @@ -105,6 +107,8 @@ ifeq ($(ART_BUILD_TARGET_NDEBUG),true) include $(CLEAR_VARS) LOCAL_MODULE := boot.art LOCAL_MODULE_TAGS := optional -LOCAL_ADDITIONAL_DEPENDENCIES := $(TARGET_BOOT_IMG_OUT) $(TARGET_BOOT_OAT_OUT) +LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/build/Android.common.mk +LOCAL_ADDITIONAL_DEPENDENCIES += $(LOCAL_PATH)/build/Android.oat.mk +LOCAL_ADDITIONAL_DEPENDENCIES += $(TARGET_BOOT_IMG_OUT) $(TARGET_BOOT_OAT_OUT) include $(BUILD_PHONY_PACKAGE) endif diff --git a/build/Android.oattest.mk b/build/Android.oattest.mk index 36fd0fc..6ee8492 100644 --- a/build/Android.oattest.mk +++ b/build/Android.oattest.mk @@ -16,6 +16,39 @@ ######################################################################## +# subdirectories of test/ which are used as inputs for gtests +TEST_DEX_DIRECTORIES := \ + AbstractMethod \ + AllFields \ + CreateMethodSignature \ + ExceptionHandle \ + Interfaces \ + Main \ + MyClass \ + MyClassNatives \ + Nested \ + NonStaticLeafMethods \ + ProtoCompare \ + ProtoCompare2 \ + StaticLeafMethods \ + Statics \ + StaticsFromCode \ + XandY + +# subdirectories of test/ which are used with test-art-target-oat +# Declare the simplest tests (Main, HelloWorld) first, the rest are alphabetical +TEST_OAT_DIRECTORIES := \ + Main \ + HelloWorld \ + \ + ParallelGC \ + ReferenceMap \ + StackWalk \ + ThreadStress + +# TODO: Enable when the StackWalk2 tests are passing +# StackWalk2 \ + ART_TEST_TARGET_DEX_FILES := ART_TEST_HOST_DEX_FILES := @@ -33,6 +66,8 @@ define build-art-test-dex LOCAL_MODULE_PATH := $(3) LOCAL_DEX_PREOPT_IMAGE := $(TARGET_CORE_IMG_OUT) LOCAL_DEX_PREOPT := false + LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/build/Android.common.mk + LOCAL_ADDITIONAL_DEPENDENCIES += $(LOCAL_PATH)/build/Android.oattest.mk include $(BUILD_JAVA_LIBRARY) ART_TEST_TARGET_DEX_FILES += $(3)/$$(LOCAL_MODULE).jar endif @@ -45,6 +80,8 @@ define build-art-test-dex LOCAL_NO_STANDARD_LIBRARIES := true LOCAL_DEX_PREOPT_IMAGE := $(HOST_CORE_IMG_OUT) LOCAL_BUILD_HOST_DEX := true + LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/build/Android.common.mk + LOCAL_ADDITIONAL_DEPENDENCIES += $(LOCAL_PATH)/build/Android.oattest.mk include $(BUILD_HOST_JAVA_LIBRARY) ART_TEST_HOST_DEX_FILES += $$(LOCAL_MODULE_PATH)/$$(LOCAL_MODULE).jar endif diff --git a/src/class_reference.h b/src/class_reference.h new file mode 100644 index 0000000..c3be720 --- /dev/null +++ b/src/class_reference.h @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2013 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_SRC_CLASS_REFERENCE_H_ +#define ART_SRC_CLASS_REFERENCE_H_ + +#include <stdint.h> + +namespace art { + +class DexFile; + +// A class is uniquely located by its DexFile and the class_defs_ table index into that DexFile +typedef std::pair<const DexFile*, uint32_t> ClassReference; + +inline bool operator<(const ClassReference& lhs, const ClassReference& rhs) { + if (lhs.second < rhs.second) { + return true; + } else if (lhs.second > rhs.second) { + return false; + } else { + return (lhs.first < rhs.first); + } +} + +} // namespace art + +#endif // ART_SRC_CLASS_REFERENCE_H_ diff --git a/src/common_test.h b/src/common_test.h index 11bd4f0..f03b1f9 100644 --- a/src/common_test.h +++ b/src/common_test.h @@ -188,8 +188,8 @@ class CommonTest : public testing::Test { const mirror::DexCache* dex_cache = method->GetDeclaringClass()->GetDexCache(); const DexFile& dex_file = *dex_cache->GetDexFile(); compiled_method = - compiler_driver_->GetCompiledMethod(CompilerDriver::MethodReference(&dex_file, - method->GetDexMethodIndex())); + compiler_driver_->GetCompiledMethod(MethodReference(&dex_file, + method->GetDexMethodIndex())); #ifndef ART_LIGHT_MODE CHECK(compiled_method != NULL) << PrettyMethod(method); diff --git a/src/compiler/dex/dex_to_dex_compiler.cc b/src/compiler/dex/dex_to_dex_compiler.cc index 938de7a..734829a 100644 --- a/src/compiler/dex/dex_to_dex_compiler.cc +++ b/src/compiler/dex/dex_to_dex_compiler.cc @@ -250,7 +250,7 @@ void DexCompiler::CompileInvokeVirtual(Instruction* inst, return; } uint32_t method_idx = is_range ? inst->VRegB_3rc() : inst->VRegB_35c(); - CompilerDriver::MethodReference target_method(&GetDexFile(), method_idx); + MethodReference target_method(&GetDexFile(), method_idx); InvokeType invoke_type = kVirtual; InvokeType original_invoke_type = invoke_type; int vtable_idx; diff --git a/src/compiler/dex/mir_dataflow.cc b/src/compiler/dex/mir_dataflow.cc index c3680d6..6c152d2 100644 --- a/src/compiler/dex/mir_dataflow.cc +++ b/src/compiler/dex/mir_dataflow.cc @@ -1225,7 +1225,7 @@ bool MIRGraph::InvokeUsesMethodStar(MIR* mir) return false; } DexCompilationUnit m_unit(cu_); - CompilerDriver::MethodReference target_method(cu_->dex_file, mir->dalvikInsn.vB); + MethodReference target_method(cu_->dex_file, mir->dalvikInsn.vB); int vtable_idx; uintptr_t direct_code; uintptr_t direct_method; diff --git a/src/compiler/dex/quick/codegen_util.cc b/src/compiler/dex/quick/codegen_util.cc index ac2828c..766cdce 100644 --- a/src/compiler/dex/quick/codegen_util.cc +++ b/src/compiler/dex/quick/codegen_util.cc @@ -632,7 +632,7 @@ void Mir2Lir::CreateNativeGcMap() { max_native_offset = native_offset; } } - CompilerDriver::MethodReference method_ref(cu_->dex_file, cu_->method_idx); + MethodReference method_ref(cu_->dex_file, cu_->method_idx); const std::vector<uint8_t>* gc_map_raw = verifier::MethodVerifier::GetDexGcMap(method_ref); verifier::DexPcToReferenceMap dex_gc_map(&(*gc_map_raw)[4], gc_map_raw->size() - 4); // Compute native offset to references size. diff --git a/src/compiler/dex/quick/gen_common.cc b/src/compiler/dex/quick/gen_common.cc index 7aa71cf..2980acb 100644 --- a/src/compiler/dex/quick/gen_common.cc +++ b/src/compiler/dex/quick/gen_common.cc @@ -1077,7 +1077,7 @@ void Mir2Lir::GenCheckCast(uint32_t insn_idx, uint32_t type_idx, RegLocation rl_ // Note: currently type_known_final is unused, as optimizing will only improve the performance // of the exception throw path. DexCompilationUnit* cu = mir_graph_->GetCurrentDexCompilationUnit(); - const CompilerDriver::MethodReference mr(cu->GetDexFile(), cu->GetDexMethodIndex()); + const MethodReference mr(cu->GetDexFile(), cu->GetDexMethodIndex()); if (!needs_access_check && cu_->compiler_driver->IsSafeCast(mr, insn_idx)) { // Verifier type analysis proved this check cast would never cause an exception. return; diff --git a/src/compiler/dex/quick/gen_invoke.cc b/src/compiler/dex/quick/gen_invoke.cc index 4b12bb4..3bc7340 100644 --- a/src/compiler/dex/quick/gen_invoke.cc +++ b/src/compiler/dex/quick/gen_invoke.cc @@ -313,7 +313,7 @@ void Mir2Lir::FlushIns(RegLocation* ArgLocs, RegLocation rl_method) * emit the next instruction in static & direct invoke sequences. */ static int NextSDCallInsn(CompilationUnit* cu, CallInfo* info, - int state, const CompilerDriver::MethodReference& target_method, + int state, const MethodReference& target_method, uint32_t unused, uintptr_t direct_code, uintptr_t direct_method, InvokeType type) @@ -418,7 +418,7 @@ static int NextSDCallInsn(CompilationUnit* cu, CallInfo* info, * kArg1 here rather than the standard LoadArgRegs. */ static int NextVCallInsn(CompilationUnit* cu, CallInfo* info, - int state, const CompilerDriver::MethodReference& target_method, + int state, const MethodReference& target_method, uint32_t method_idx, uintptr_t unused, uintptr_t unused2, InvokeType unused3) { @@ -467,7 +467,7 @@ static int NextVCallInsn(CompilationUnit* cu, CallInfo* info, * which will locate the target and continue on via a tail call. */ static int NextInterfaceCallInsn(CompilationUnit* cu, CallInfo* info, int state, - const CompilerDriver::MethodReference& target_method, + const MethodReference& target_method, uint32_t unused, uintptr_t unused2, uintptr_t direct_method, InvokeType unused4) { @@ -535,7 +535,7 @@ static int NextInterfaceCallInsn(CompilationUnit* cu, CallInfo* info, int state, } static int NextInvokeInsnSP(CompilationUnit* cu, CallInfo* info, int trampoline, - int state, const CompilerDriver::MethodReference& target_method, + int state, const MethodReference& target_method, uint32_t method_idx) { Mir2Lir* cg = static_cast<Mir2Lir*>(cu->cg.get()); @@ -558,7 +558,7 @@ static int NextInvokeInsnSP(CompilationUnit* cu, CallInfo* info, int trampoline, static int NextStaticCallInsnSP(CompilationUnit* cu, CallInfo* info, int state, - const CompilerDriver::MethodReference& target_method, + const MethodReference& target_method, uint32_t method_idx, uintptr_t unused, uintptr_t unused2, InvokeType unused3) @@ -568,7 +568,7 @@ static int NextStaticCallInsnSP(CompilationUnit* cu, CallInfo* info, } static int NextDirectCallInsnSP(CompilationUnit* cu, CallInfo* info, int state, - const CompilerDriver::MethodReference& target_method, + const MethodReference& target_method, uint32_t method_idx, uintptr_t unused, uintptr_t unused2, InvokeType unused3) { @@ -577,7 +577,7 @@ static int NextDirectCallInsnSP(CompilationUnit* cu, CallInfo* info, int state, } static int NextSuperCallInsnSP(CompilationUnit* cu, CallInfo* info, int state, - const CompilerDriver::MethodReference& target_method, + const MethodReference& target_method, uint32_t method_idx, uintptr_t unused, uintptr_t unused2, InvokeType unused3) { @@ -586,7 +586,7 @@ static int NextSuperCallInsnSP(CompilationUnit* cu, CallInfo* info, int state, } static int NextVCallInsnSP(CompilationUnit* cu, CallInfo* info, int state, - const CompilerDriver::MethodReference& target_method, + const MethodReference& target_method, uint32_t method_idx, uintptr_t unused, uintptr_t unused2, InvokeType unused3) { @@ -596,7 +596,7 @@ static int NextVCallInsnSP(CompilationUnit* cu, CallInfo* info, int state, static int NextInterfaceCallInsnWithAccessCheck(CompilationUnit* cu, CallInfo* info, int state, - const CompilerDriver::MethodReference& target_method, + const MethodReference& target_method, uint32_t unused, uintptr_t unused2, uintptr_t unused3, InvokeType unused4) @@ -607,7 +607,7 @@ static int NextInterfaceCallInsnWithAccessCheck(CompilationUnit* cu, int Mir2Lir::LoadArgRegs(CallInfo* info, int call_state, NextCallInsn next_call_insn, - const CompilerDriver::MethodReference& target_method, + const MethodReference& target_method, uint32_t vtable_idx, uintptr_t direct_code, uintptr_t direct_method, InvokeType type, bool skip_this) { @@ -647,7 +647,7 @@ int Mir2Lir::LoadArgRegs(CallInfo* info, int call_state, */ int Mir2Lir::GenDalvikArgsNoRange(CallInfo* info, int call_state, LIR** pcrLabel, NextCallInsn next_call_insn, - const CompilerDriver::MethodReference& target_method, + const MethodReference& target_method, uint32_t vtable_idx, uintptr_t direct_code, uintptr_t direct_method, InvokeType type, bool skip_this) { @@ -747,7 +747,7 @@ int Mir2Lir::GenDalvikArgsNoRange(CallInfo* info, */ int Mir2Lir::GenDalvikArgsRange(CallInfo* info, int call_state, LIR** pcrLabel, NextCallInsn next_call_insn, - const CompilerDriver::MethodReference& target_method, + const MethodReference& target_method, uint32_t vtable_idx, uintptr_t direct_code, uintptr_t direct_method, InvokeType type, bool skip_this) { @@ -1373,7 +1373,7 @@ void Mir2Lir::GenInvoke(CallInfo* info) LockCallTemps(); DexCompilationUnit* cUnit = mir_graph_->GetCurrentDexCompilationUnit(); - CompilerDriver::MethodReference target_method(cUnit->GetDexFile(), info->index); + MethodReference target_method(cUnit->GetDexFile(), info->index); int vtable_idx; uintptr_t direct_code; uintptr_t direct_method; diff --git a/src/compiler/dex/quick/mir_to_lir.h b/src/compiler/dex/quick/mir_to_lir.h index 9eb4524..93098db 100644 --- a/src/compiler/dex/quick/mir_to_lir.h +++ b/src/compiler/dex/quick/mir_to_lir.h @@ -100,7 +100,7 @@ class MIRGraph; class Mir2Lir; typedef int (*NextCallInsn)(CompilationUnit*, CallInfo*, int, - const CompilerDriver::MethodReference& target_method, + const MethodReference& target_method, uint32_t method_idx, uintptr_t direct_code, uintptr_t direct_method, InvokeType type); @@ -467,13 +467,13 @@ class Mir2Lir : public Backend { void FlushIns(RegLocation* ArgLocs, RegLocation rl_method); int GenDalvikArgsNoRange(CallInfo* info, int call_state, LIR** pcrLabel, NextCallInsn next_call_insn, - const CompilerDriver::MethodReference& target_method, + const MethodReference& target_method, uint32_t vtable_idx, uintptr_t direct_code, uintptr_t direct_method, InvokeType type, bool skip_this); int GenDalvikArgsRange(CallInfo* info, int call_state, LIR** pcrLabel, NextCallInsn next_call_insn, - const CompilerDriver::MethodReference& target_method, + const MethodReference& target_method, uint32_t vtable_idx, uintptr_t direct_code, uintptr_t direct_method, InvokeType type, bool skip_this); @@ -495,7 +495,7 @@ class Mir2Lir : public Backend { bool GenIntrinsic(CallInfo* info); int LoadArgRegs(CallInfo* info, int call_state, NextCallInsn next_call_insn, - const CompilerDriver::MethodReference& target_method, + const MethodReference& target_method, uint32_t vtable_idx, uintptr_t direct_code, uintptr_t direct_method, InvokeType type, bool skip_this); diff --git a/src/compiler/dex/write_elf.cc b/src/compiler/dex/write_elf.cc deleted file mode 100644 index d9e45a9..0000000 --- a/src/compiler/dex/write_elf.cc +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (C) 2012 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 "elf_fixup.h" -#include "elf_stripper.h" -#include "os.h" - -#if defined(ART_USE_PORTABLE_COMPILER) -#include "elf_writer_mclinker.h" -#else -#include "elf_writer_quick.h" -#endif - -namespace art { -class CompilerDriver; -class DexFile; -} // namespace art - -extern "C" bool WriteElf(art::CompilerDriver& driver, - const std::string& android_root, - bool is_host, - const std::vector<const art::DexFile*>& dex_files, - std::vector<uint8_t>& oat_contents, - art::File* file) - SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { -#if defined(ART_USE_PORTABLE_COMPILER) - return art::ElfWriterMclinker::Create(file, oat_contents, dex_files, android_root, is_host, driver); -#else - return art::ElfWriterQuick::Create(file, oat_contents, dex_files, android_root, is_host, driver); -#endif -} -extern "C" bool FixupElf(art::File* file, uintptr_t oat_data_begin) { - return art::ElfFixup::Fixup(file, oat_data_begin); -} -extern "C" void GetOatElfInformation(art::File* file, - size_t& oat_loaded_size, - size_t& oat_data_offset) { - art::ElfWriter::GetOatElfInformation(file, oat_loaded_size, oat_data_offset); -} -extern "C" bool StripElf(art::File* file) { - return art::ElfStripper::Strip(file); -} diff --git a/src/compiler/driver/compiler_driver.cc b/src/compiler/driver/compiler_driver.cc index c8ccbe9..c876252 100644 --- a/src/compiler/driver/compiler_driver.cc +++ b/src/compiler/driver/compiler_driver.cc @@ -18,7 +18,6 @@ #include <vector> -#include <dlfcn.h> #include <unistd.h> #include "base/stl_util.h" @@ -48,8 +47,10 @@ #include "thread_pool.h" #include "verifier/method_verifier.h" -#if defined(__APPLE__) -#include <mach-o/dyld.h> +#if defined(ART_USE_PORTABLE_COMPILER) +#include "compiler/elf_writer_mclinker.h" +#else +#include "compiler/elf_writer_quick.h" #endif namespace art { @@ -281,48 +282,57 @@ class AOTCompilationStats { DISALLOW_COPY_AND_ASSIGN(AOTCompilationStats); }; -static std::string MakeCompilerSoName(CompilerBackend compiler_backend) { - - // Bad things happen if we pull in the libartd-compiler to a libart dex2oat or vice versa, - // because we end up with both libart and libartd in the same address space! - const char* suffix = (kIsDebugBuild ? "d" : ""); - - // Work out the filename for the compiler library. - std::string library_name(StringPrintf("art%s-compiler", suffix)); - std::string filename(StringPrintf(OS_SHARED_LIB_FORMAT_STR, library_name.c_str())); - -#if defined(__APPLE__) - // On Linux, dex2oat will have been built with an RPATH of $ORIGIN/../lib, so dlopen(3) will find - // the .so by itself. On Mac OS, there isn't really an equivalent, so we have to manually do the - // same work. - uint32_t executable_path_length = 0; - _NSGetExecutablePath(NULL, &executable_path_length); - std::string path(executable_path_length, static_cast<char>(0)); - CHECK_EQ(_NSGetExecutablePath(&path[0], &executable_path_length), 0); - - // Strip the "/dex2oat". - size_t last_slash = path.find_last_of('/'); - CHECK_NE(last_slash, std::string::npos) << path; - path.resize(last_slash); - - // Strip the "/bin". - last_slash = path.find_last_of('/'); - path.resize(last_slash); - - filename = path + "/lib/" + filename; -#endif - return filename; -} - -template<typename Fn> -static Fn FindFunction(const std::string& compiler_so_name, void* library, const char* name) { - Fn fn = reinterpret_cast<Fn>(dlsym(library, name)); - if (fn == NULL) { - LOG(FATAL) << "Couldn't find \"" << name << "\" in compiler library " << compiler_so_name << ": " << dlerror(); - } - VLOG(compiler) << "Found \"" << name << "\" at " << reinterpret_cast<void*>(fn); - return fn; -} +extern "C" void ArtInitCompilerContext(art::CompilerDriver& driver); +extern "C" void ArtInitQuickCompilerContext(art::CompilerDriver& compiler); + +extern "C" void ArtUnInitCompilerContext(art::CompilerDriver& driver); +extern "C" void ArtUnInitQuickCompilerContext(art::CompilerDriver& compiler); + +extern "C" art::CompiledMethod* ArtCompileMethod(art::CompilerDriver& driver, + const art::DexFile::CodeItem* code_item, + uint32_t access_flags, + art::InvokeType invoke_type, + uint32_t class_def_idx, + uint32_t method_idx, + jobject class_loader, + const art::DexFile& dex_file); +extern "C" art::CompiledMethod* ArtQuickCompileMethod(art::CompilerDriver& compiler, + const art::DexFile::CodeItem* code_item, + uint32_t access_flags, + art::InvokeType invoke_type, + uint32_t class_def_idx, + uint32_t method_idx, + jobject class_loader, + const art::DexFile& dex_file); + +extern "C" art::CompiledMethod* ArtCompileDEX(art::CompilerDriver& compiler, + const art::DexFile::CodeItem* code_item, + uint32_t access_flags, + art::InvokeType invoke_type, + uint32_t class_def_idx, + uint32_t method_idx, + jobject class_loader, + const art::DexFile& dex_file); + +extern "C" art::CompiledMethod* SeaIrCompileMethod(art::CompilerDriver& compiler, + const art::DexFile::CodeItem* code_item, + uint32_t access_flags, + art::InvokeType invoke_type, + uint32_t class_def_idx, + uint32_t method_idx, + jobject class_loader, + const art::DexFile& dex_file); + +extern "C" art::CompiledMethod* ArtLLVMJniCompileMethod(art::CompilerDriver& driver, + uint32_t access_flags, uint32_t method_idx, + const art::DexFile& dex_file); + +extern "C" art::CompiledMethod* ArtQuickJniCompileMethod(art::CompilerDriver& compiler, + uint32_t access_flags, uint32_t method_idx, + const art::DexFile& dex_file); + +extern "C" void compilerLLVMSetBitcodeFileName(art::CompilerDriver& driver, + std::string const& filename); CompilerDriver::CompilerDriver(CompilerBackend compiler_backend, InstructionSet instruction_set, bool image, DescriptorSet* image_classes, @@ -349,13 +359,6 @@ CompilerDriver::CompilerDriver(CompilerBackend compiler_backend, InstructionSet compiler_get_method_code_addr_(NULL), support_boot_image_fixup_(true) { - std::string compiler_so_name(MakeCompilerSoName(compiler_backend_)); - compiler_library_ = dlopen(compiler_so_name.c_str(), RTLD_LAZY); - if (compiler_library_ == NULL) { - LOG(FATAL) << "Couldn't find compiler library " << compiler_so_name << ": " << dlerror(); - } - VLOG(compiler) << "dlopen(\"" << compiler_so_name << "\", RTLD_LAZY) returned " << compiler_library_; - CHECK_PTHREAD_CALL(pthread_key_create, (&tls_key_, NULL), "compiler tls key"); // TODO: more work needed to combine initializations and allow per-method backend selection @@ -363,28 +366,28 @@ CompilerDriver::CompilerDriver(CompilerBackend compiler_backend, InstructionSet InitCompilerContextFn init_compiler_context; if (compiler_backend_ == kPortable){ // Initialize compiler_context_ - init_compiler_context = FindFunction<void (*)(CompilerDriver&)>(compiler_so_name, - compiler_library_, "ArtInitCompilerContext"); - compiler_ = FindFunction<CompilerFn>(compiler_so_name, compiler_library_, "ArtCompileMethod"); + init_compiler_context = reinterpret_cast<void (*)(CompilerDriver&)>(ArtInitCompilerContext); + compiler_ = reinterpret_cast<CompilerFn>(ArtCompileMethod); } else { - init_compiler_context = FindFunction<void (*)(CompilerDriver&)>(compiler_so_name, - compiler_library_, "ArtInitQuickCompilerContext"); - compiler_ = FindFunction<CompilerFn>(compiler_so_name, compiler_library_, "ArtQuickCompileMethod"); + init_compiler_context = reinterpret_cast<void (*)(CompilerDriver&)>(ArtInitQuickCompilerContext); + compiler_ = reinterpret_cast<CompilerFn>(ArtQuickCompileMethod); } - dex_to_dex_compiler_ = FindFunction<CompilerFn>(compiler_so_name, compiler_library_, "ArtCompileDEX"); + dex_to_dex_compiler_ = reinterpret_cast<CompilerFn>(ArtCompileDEX); +#ifdef ART_SEA_IR_MODE sea_ir_compiler_ = NULL; if (Runtime::Current()->IsSeaIRMode()) { - sea_ir_compiler_ = FindFunction<CompilerFn>(compiler_so_name, compiler_library_, "SeaIrCompileMethod"); + sea_ir_compiler_ = reinterpret_cast<CompilerFn>(SeaIrCompileMethod); } +#endif init_compiler_context(*this); if (compiler_backend_ == kPortable) { - jni_compiler_ = FindFunction<JniCompilerFn>(compiler_so_name, compiler_library_, "ArtLLVMJniCompileMethod"); + jni_compiler_ = reinterpret_cast<JniCompilerFn>(ArtLLVMJniCompileMethod); } else { - jni_compiler_ = FindFunction<JniCompilerFn>(compiler_so_name, compiler_library_, "ArtQuickJniCompileMethod"); + jni_compiler_ = reinterpret_cast<JniCompilerFn>(ArtQuickJniCompileMethod); } CHECK(!Runtime::Current()->IsStarted()); @@ -413,39 +416,15 @@ CompilerDriver::~CompilerDriver() { } CHECK_PTHREAD_CALL(pthread_key_delete, (tls_key_), "delete tls key"); typedef void (*UninitCompilerContextFn)(CompilerDriver&); - std::string compiler_so_name(MakeCompilerSoName(compiler_backend_)); UninitCompilerContextFn uninit_compiler_context; // Uninitialize compiler_context_ // TODO: rework to combine initialization/uninitialization if (compiler_backend_ == kPortable) { - uninit_compiler_context = FindFunction<void (*)(CompilerDriver&)>(compiler_so_name, - compiler_library_, "ArtUnInitCompilerContext"); + uninit_compiler_context = reinterpret_cast<void (*)(CompilerDriver&)>(ArtUnInitCompilerContext); } else { - uninit_compiler_context = FindFunction<void (*)(CompilerDriver&)>(compiler_so_name, - compiler_library_, "ArtUnInitQuickCompilerContext"); + uninit_compiler_context = reinterpret_cast<void (*)(CompilerDriver&)>(ArtUnInitQuickCompilerContext); } uninit_compiler_context(*this); -#if 0 - if (compiler_library_ != NULL) { - VLOG(compiler) << "dlclose(" << compiler_library_ << ")"; - /* - * FIXME: Temporary workaround - * Apparently, llvm is adding dctors to atexit, but if we unload - * the library here the code will no longer be around at exit time - * and we die a flaming death in __cxa_finalize(). Apparently, some - * dlclose() implementations will scan the atexit list on unload and - * handle any associated with the soon-to-be-unloaded library. - * However, this is not required by POSIX and we don't do it. - * See: http://b/issue?id=4998315 - * What's the right thing to do here? - * - * This has now been completely disabled because mclinker was - * closing stdout on exit, which was affecting both quick and - * portable. - */ - dlclose(compiler_library_); - } -#endif } CompilerTls* CompilerDriver::GetTls() { @@ -1217,9 +1196,8 @@ bool CompilerDriver::ComputeInvokeInfo(const DexCompilationUnit* mUnit, const ui if (kEnableVerifierBasedSharpening && (invoke_type == kVirtual || invoke_type == kInterface)) { // Did the verifier record a more precise invoke target based on its type information? - const CompilerDriver::MethodReference caller_method(mUnit->GetDexFile(), - mUnit->GetDexMethodIndex()); - const CompilerDriver::MethodReference* devirt_map_target = + const MethodReference caller_method(mUnit->GetDexFile(), mUnit->GetDexMethodIndex()); + const MethodReference* devirt_map_target = verifier::MethodVerifier::GetDevirtMap(caller_method, dex_pc); if (devirt_map_target != NULL) { mirror::DexCache* target_dex_cache = @@ -2138,7 +2116,7 @@ static void InitializeClass(const ParallelCompilationManager* manager, size_t cl } // Record the final class status if necessary. mirror::Class::Status status = klass->GetStatus(); - CompilerDriver::ClassReference ref(manager->GetDexFile(), class_def_index); + ClassReference ref(manager->GetDexFile(), class_def_index); CompiledClass* compiled_class = manager->GetCompiler()->GetCompiledClass(ref); if (compiled_class == NULL) { compiled_class = new CompiledClass(status); @@ -2287,21 +2265,16 @@ void CompilerDriver::CompileMethod(const DexFile::CodeItem* code_item, uint32_t dont_compile = false; } if (!dont_compile) { - bool use_sea = false; - - if (Runtime::Current()->IsSeaIRMode()) { - use_sea = true; - } + CompilerFn compiler = compiler_; +#ifdef ART_SEA_IR_MODE + bool use_sea = Runtime::Current()->IsSeaIRMode(); + use_sea &&= (std::string::npos != PrettyMethod(method_idx, dex_file).find("fibonacci")); if (use_sea) { - use_sea = (std::string::npos != PrettyMethod(method_idx, dex_file).find("fibonacci")); - } - if (!use_sea) { - compiled_method = (*compiler_)(*this, code_item, access_flags, invoke_type, class_def_idx, - method_idx, class_loader, dex_file); - } else { - compiled_method = (*sea_ir_compiler_)(*this, code_item, access_flags, invoke_type, class_def_idx, - method_idx, class_loader, dex_file); + compiler = sea_ir_compiler_; } +#endif + compiled_method = (*compiler)(*this, code_item, access_flags, invoke_type, class_def_idx, + method_idx, class_loader, dex_file); CHECK(compiled_method != NULL) << PrettyMethod(method_idx, dex_file); } else if (allow_dex_to_dex_compilation) { // TODO: add a mode to disable DEX-to-DEX compilation ? @@ -2365,8 +2338,7 @@ void CompilerDriver::SetBitcodeFileName(std::string const& filename) { typedef void (*SetBitcodeFileNameFn)(CompilerDriver&, std::string const&); SetBitcodeFileNameFn set_bitcode_file_name = - FindFunction<SetBitcodeFileNameFn>(MakeCompilerSoName(compiler_backend_), compiler_library_, - "compilerLLVMSetBitcodeFileName"); + reinterpret_cast<SetBitcodeFileNameFn>(compilerLLVMSetBitcodeFileName); set_bitcode_file_name(*this, filename); } @@ -2386,45 +2358,16 @@ bool CompilerDriver::RequiresConstructorBarrier(Thread* self, const DexFile* dex bool CompilerDriver::WriteElf(const std::string& android_root, bool is_host, - const std::vector<const DexFile*>& dex_files, + const std::vector<const art::DexFile*>& dex_files, std::vector<uint8_t>& oat_contents, - File* file) { - typedef bool (*WriteElfFn)(CompilerDriver&, - const std::string& android_root, - bool is_host, - const std::vector<const DexFile*>& dex_files, - std::vector<uint8_t>&, - File*); - WriteElfFn WriteElf = - FindFunction<WriteElfFn>(MakeCompilerSoName(compiler_backend_), compiler_library_, "WriteElf"); - Locks::mutator_lock_->AssertSharedHeld(Thread::Current()); - return WriteElf(*this, android_root, is_host, dex_files, oat_contents, file); -} - -bool CompilerDriver::FixupElf(File* file, uintptr_t oat_data_begin) const { - typedef bool (*FixupElfFn)(File*, uintptr_t oat_data_begin); - FixupElfFn FixupElf = - FindFunction<FixupElfFn>(MakeCompilerSoName(compiler_backend_), compiler_library_, "FixupElf"); - return FixupElf(file, oat_data_begin); -} - -void CompilerDriver::GetOatElfInformation(File* file, - size_t& oat_loaded_size, - size_t& oat_data_offset) const { - typedef bool (*GetOatElfInformationFn)(File*, size_t& oat_loaded_size, size_t& oat_data_offset); - GetOatElfInformationFn GetOatElfInformation = - FindFunction<GetOatElfInformationFn>(MakeCompilerSoName(compiler_backend_), compiler_library_, - "GetOatElfInformation"); - GetOatElfInformation(file, oat_loaded_size, oat_data_offset); -} - -bool CompilerDriver::StripElf(File* file) const { - typedef bool (*StripElfFn)(File*); - StripElfFn StripElf = - FindFunction<StripElfFn>(MakeCompilerSoName(compiler_backend_), compiler_library_, "StripElf"); - return StripElf(file); + art::File* file) + SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { +#if defined(ART_USE_PORTABLE_COMPILER) + return art::ElfWriterMclinker::Create(file, oat_contents, dex_files, android_root, is_host, *this); +#else + return art::ElfWriterQuick::Create(file, oat_contents, dex_files, android_root, is_host, *this); +#endif } - void CompilerDriver::InstructionSetToLLVMTarget(InstructionSet instruction_set, std::string& target_triple, std::string& target_cpu, diff --git a/src/compiler/driver/compiler_driver.h b/src/compiler/driver/compiler_driver.h index b37b74b..d37f494 100644 --- a/src/compiler/driver/compiler_driver.h +++ b/src/compiler/driver/compiler_driver.h @@ -22,11 +22,13 @@ #include <vector> #include "base/mutex.h" +#include "class_reference.h" #include "compiled_class.h" #include "compiled_method.h" #include "dex_file.h" #include "instruction_set.h" #include "invoke_type.h" +#include "method_reference.h" #include "oat_file.h" #include "runtime.h" #include "safe_map.h" @@ -114,30 +116,9 @@ class CompilerDriver { const std::vector<uint8_t>* CreateInterpreterToQuickEntry() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - // A class is uniquely located by its DexFile and the class_defs_ table index into that DexFile - typedef std::pair<const DexFile*, uint32_t> ClassReference; - CompiledClass* GetCompiledClass(ClassReference ref) const LOCKS_EXCLUDED(compiled_classes_lock_); - // A method is uniquely located by its DexFile and the method_ids_ table index into that DexFile - struct MethodReference { - MethodReference(const DexFile* file, uint32_t index) : dex_file(file), dex_method_index(index) { - } - const DexFile* dex_file; - uint32_t dex_method_index; - }; - - struct MethodReferenceComparator { - bool operator()(MethodReference mr1, MethodReference mr2) const { - if (mr1.dex_file == mr2.dex_file) { - return mr1.dex_method_index < mr2.dex_method_index; - } else { - return mr1.dex_file < mr2.dex_file; - } - } - }; - CompiledMethod* GetCompiledMethod(MethodReference ref) const LOCKS_EXCLUDED(compiled_methods_lock_); @@ -212,15 +193,11 @@ class CompilerDriver { } - // TODO: remove these Elf wrappers when libart links against LLVM (when separate compiler library is gone) bool WriteElf(const std::string& android_root, bool is_host, const std::vector<const DexFile*>& dex_files, std::vector<uint8_t>& oat_contents, File* file); - bool FixupElf(File* file, uintptr_t oat_data_begin) const; - void GetOatElfInformation(File* file, size_t& oat_loaded_size, size_t& oat_data_offset) const; - bool StripElf(File* file) const; // TODO: move to a common home for llvm helpers once quick/portable are merged static void InstructionSetToLLVMTarget(InstructionSet instruction_set, @@ -404,7 +381,9 @@ class CompilerDriver { uint32_t class_dex_idx, uint32_t method_idx, jobject class_loader, const DexFile& dex_file); CompilerFn compiler_; +#ifdef ART_SEA_IR_MODE CompilerFn sea_ir_compiler_; +#endif CompilerFn dex_to_dex_compiler_; @@ -429,16 +408,6 @@ class CompilerDriver { DISALLOW_COPY_AND_ASSIGN(CompilerDriver); }; -inline bool operator<(const CompilerDriver::ClassReference& lhs, const CompilerDriver::ClassReference& rhs) { - if (lhs.second < rhs.second) { - return true; - } else if (lhs.second > rhs.second) { - return false; - } else { - return (lhs.first < rhs.first); - } -} - } // namespace art #endif // ART_SRC_COMPILER_DRIVER_COMPILER_DRIVER_H_ diff --git a/src/elf_fixup.cc b/src/compiler/elf_fixup.cc index 127bc85..127bc85 100644 --- a/src/elf_fixup.cc +++ b/src/compiler/elf_fixup.cc diff --git a/src/elf_fixup.h b/src/compiler/elf_fixup.h index 79c45c1..79c45c1 100644 --- a/src/elf_fixup.h +++ b/src/compiler/elf_fixup.h diff --git a/src/elf_stripper.cc b/src/compiler/elf_stripper.cc index 7fc662c..7fc662c 100644 --- a/src/elf_stripper.cc +++ b/src/compiler/elf_stripper.cc diff --git a/src/elf_stripper.h b/src/compiler/elf_stripper.h index b202e6e..b202e6e 100644 --- a/src/elf_stripper.h +++ b/src/compiler/elf_stripper.h diff --git a/src/elf_writer.cc b/src/compiler/elf_writer.cc index 7592eb5..7592eb5 100644 --- a/src/elf_writer.cc +++ b/src/compiler/elf_writer.cc diff --git a/src/elf_writer.h b/src/compiler/elf_writer.h index 7392e67..7392e67 100644 --- a/src/elf_writer.h +++ b/src/compiler/elf_writer.h diff --git a/src/elf_writer_mclinker.cc b/src/compiler/elf_writer_mclinker.cc index e1d98f6..e1d98f6 100644 --- a/src/elf_writer_mclinker.cc +++ b/src/compiler/elf_writer_mclinker.cc diff --git a/src/elf_writer_mclinker.h b/src/compiler/elf_writer_mclinker.h index 21f23e1..21f23e1 100644 --- a/src/elf_writer_mclinker.h +++ b/src/compiler/elf_writer_mclinker.h diff --git a/src/elf_writer_quick.cc b/src/compiler/elf_writer_quick.cc index c3c5415..c3c5415 100644 --- a/src/elf_writer_quick.cc +++ b/src/compiler/elf_writer_quick.cc diff --git a/src/elf_writer_quick.h b/src/compiler/elf_writer_quick.h index a1a386b..a1a386b 100644 --- a/src/elf_writer_quick.h +++ b/src/compiler/elf_writer_quick.h diff --git a/src/elf_writer_test.cc b/src/compiler/elf_writer_test.cc index d4486d2..d4486d2 100644 --- a/src/elf_writer_test.cc +++ b/src/compiler/elf_writer_test.cc diff --git a/src/image_writer.cc b/src/compiler/image_writer.cc index f0b49be..8b84e12 100644 --- a/src/image_writer.cc +++ b/src/compiler/image_writer.cc @@ -25,6 +25,7 @@ #include "class_linker.h" #include "compiled_method.h" #include "compiler/driver/compiler_driver.h" +#include "compiler/elf_writer.h" #include "dex_file-inl.h" #include "gc/accounting/card_table-inl.h" #include "gc/accounting/heap_bitmap.h" @@ -115,7 +116,7 @@ bool ImageWriter::Write(const std::string& image_filename, Thread::Current()->TransitionFromSuspendedToRunnable(); size_t oat_loaded_size = 0; size_t oat_data_offset = 0; - compiler_driver_.GetOatElfInformation(oat_file.get(), oat_loaded_size, oat_data_offset); + ElfWriter::GetOatElfInformation(oat_file.get(), oat_loaded_size, oat_data_offset); CalculateNewObjectOffsets(oat_loaded_size, oat_data_offset); CopyAndFixupObjects(); PatchOatCodeAndMethods(); diff --git a/src/image_writer.h b/src/compiler/image_writer.h index b79cb2f..b79cb2f 100644 --- a/src/image_writer.h +++ b/src/compiler/image_writer.h diff --git a/src/compiler/jni/portable/jni_compiler.cc b/src/compiler/jni/portable/jni_compiler.cc index 2795d05..cd8158d 100644 --- a/src/compiler/jni/portable/jni_compiler.cc +++ b/src/compiler/jni/portable/jni_compiler.cc @@ -24,7 +24,7 @@ #include "compiler/llvm/compiler_llvm.h" #include "compiler/llvm/ir_builder.h" #include "compiler/llvm/llvm_compilation_unit.h" -#include "compiler/llvm/runtime_support_func.h" +#include "compiler/llvm/runtime_support_llvm_func.h" #include "compiler/llvm/utils_llvm.h" #include "dex_file-inl.h" #include "mirror/abstract_method.h" diff --git a/src/compiler/llvm/compiler_llvm.cc b/src/compiler/llvm/compiler_llvm.cc index dfd0e32..3af6687 100644 --- a/src/compiler/llvm/compiler_llvm.cc +++ b/src/compiler/llvm/compiler_llvm.cc @@ -152,8 +152,8 @@ CompileDexMethod(DexCompilationUnit* dex_compilation_unit, InvokeType invoke_typ cunit->Materialize(); - CompilerDriver::MethodReference mref(dex_compilation_unit->GetDexFile(), - dex_compilation_unit->GetDexMethodIndex()); + MethodReference mref(dex_compilation_unit->GetDexFile(), + dex_compilation_unit->GetDexMethodIndex()); return new CompiledMethod(compiler_driver_->GetInstructionSet(), cunit->GetElfObject(), *verifier::MethodVerifier::GetDexGcMap(mref), diff --git a/src/compiler/llvm/gbc_expander.cc b/src/compiler/llvm/gbc_expander.cc index bdf9aca..4702b37 100644 --- a/src/compiler/llvm/gbc_expander.cc +++ b/src/compiler/llvm/gbc_expander.cc @@ -19,6 +19,7 @@ #include "dex_file-inl.h" #include "intrinsic_helper.h" #include "ir_builder.h" +#include "method_reference.h" #include "mirror/abstract_method.h" #include "mirror/array.h" #include "mirror/string.h" @@ -776,8 +777,8 @@ llvm::Value* GBCExpanderPass::EmitInvoke(llvm::CallInst& call_inst) { art::InvokeType invoke_type = static_cast<art::InvokeType>(LV2UInt(call_inst.getArgOperand(0))); bool is_static = (invoke_type == art::kStatic); - art::CompilerDriver::MethodReference target_method(dex_compilation_unit_->GetDexFile(), - LV2UInt(call_inst.getArgOperand(1))); + art::MethodReference target_method(dex_compilation_unit_->GetDexFile(), + LV2UInt(call_inst.getArgOperand(1))); // Load *this* actual parameter llvm::Value* this_addr = (!is_static) ? call_inst.getArgOperand(3) : NULL; diff --git a/src/compiler/llvm/ir_builder.h b/src/compiler/llvm/ir_builder.h index 9d78fe6..eb88fca 100644 --- a/src/compiler/llvm/ir_builder.h +++ b/src/compiler/llvm/ir_builder.h @@ -22,7 +22,7 @@ #include "intrinsic_helper.h" #include "md_builder.h" #include "runtime_support_builder.h" -#include "runtime_support_func.h" +#include "runtime_support_llvm_func.h" #include <llvm/IR/Constants.h> #include <llvm/IR/DerivedTypes.h> diff --git a/src/compiler/llvm/llvm_compilation_unit.h b/src/compiler/llvm/llvm_compilation_unit.h index 857d924..a5d4e11 100644 --- a/src/compiler/llvm/llvm_compilation_unit.h +++ b/src/compiler/llvm/llvm_compilation_unit.h @@ -25,7 +25,7 @@ #include "instruction_set.h" #include "compiler/driver/dex_compilation_unit.h" #include "runtime_support_builder.h" -#include "runtime_support_func.h" +#include "runtime_support_llvm_func.h" #include "safe_map.h" #include <UniquePtr.h> diff --git a/src/compiler/llvm/runtime_support_builder.cc b/src/compiler/llvm/runtime_support_builder.cc index 2be2ddf..28405f6 100644 --- a/src/compiler/llvm/runtime_support_builder.cc +++ b/src/compiler/llvm/runtime_support_builder.cc @@ -48,7 +48,7 @@ RuntimeSupportBuilder::RuntimeSupportBuilder(::llvm::LLVMContext& context, runtime_support_func_decls_[runtime_support::ID] = fn; \ } while (0); -#include "runtime_support_func_list.h" +#include "runtime_support_llvm_func_list.h" RUNTIME_SUPPORT_FUNC_LIST(GET_RUNTIME_SUPPORT_FUNC_DECL) #undef RUNTIME_SUPPORT_FUNC_LIST #undef GET_RUNTIME_SUPPORT_FUNC_DECL diff --git a/src/compiler/llvm/runtime_support_builder.h b/src/compiler/llvm/runtime_support_builder.h index 04d72b8..267b406 100644 --- a/src/compiler/llvm/runtime_support_builder.h +++ b/src/compiler/llvm/runtime_support_builder.h @@ -19,7 +19,7 @@ #include "backend_types.h" #include "base/logging.h" -#include "runtime_support_func.h" +#include "runtime_support_llvm_func.h" #include <stdint.h> diff --git a/src/compiler/llvm/runtime_support_func.h b/src/compiler/llvm/runtime_support_llvm_func.h index 6dfa961..ac6f3b8 100644 --- a/src/compiler/llvm/runtime_support_func.h +++ b/src/compiler/llvm/runtime_support_llvm_func.h @@ -23,7 +23,7 @@ namespace runtime_support { enum RuntimeId { #define DEFINE_RUNTIME_SUPPORT_FUNC_ID(ID, NAME) ID, -#include "runtime_support_func_list.h" +#include "runtime_support_llvm_func_list.h" RUNTIME_SUPPORT_FUNC_LIST(DEFINE_RUNTIME_SUPPORT_FUNC_ID) #undef RUNTIME_SUPPORT_FUNC_LIST #undef DEFINE_RUNTIME_SUPPORT_FUNC_ID diff --git a/src/oat_writer.cc b/src/compiler/oat_writer.cc index 1d249d6..0bfa4ec 100644 --- a/src/oat_writer.cc +++ b/src/compiler/oat_writer.cc @@ -161,7 +161,7 @@ size_t OatWriter::InitOatClasses(size_t offset) { num_methods = num_direct_methods + num_virtual_methods; } - CompilerDriver::ClassReference class_ref = CompilerDriver::ClassReference(dex_file, class_def_index); + ClassReference class_ref(dex_file, class_def_index); CompiledClass* compiled_class = compiler_driver_->GetCompiledClass(class_ref); mirror::Class::Status status; if (compiled_class != NULL) { @@ -303,7 +303,7 @@ size_t OatWriter::InitOatCodeMethod(size_t offset, size_t oat_class_index, #endif CompiledMethod* compiled_method = - compiler_driver_->GetCompiledMethod(CompilerDriver::MethodReference(dex_file, method_idx)); + compiler_driver_->GetCompiledMethod(MethodReference(dex_file, method_idx)); if (compiled_method != NULL) { #if defined(ART_USE_PORTABLE_COMPILER) compiled_method->AddOatdataOffsetToCompliledCodeOffset( @@ -366,7 +366,7 @@ size_t OatWriter::InitOatCodeMethod(size_t offset, size_t oat_class_index, #if !defined(NDEBUG) // We expect GC maps except when the class hasn't been verified or the method is native - CompilerDriver::ClassReference class_ref = CompilerDriver::ClassReference(dex_file, class_def_index); + ClassReference class_ref(dex_file, class_def_index); CompiledClass* compiled_class = compiler_driver_->GetCompiledClass(class_ref); mirror::Class::Status status; if (compiled_class != NULL) { @@ -670,7 +670,7 @@ size_t OatWriter::WriteCodeMethod(OutputStream& out, size_t offset, size_t oat_c size_t class_def_method_index, bool is_static, uint32_t method_idx, const DexFile& dex_file) { const CompiledMethod* compiled_method = - compiler_driver_->GetCompiledMethod(CompilerDriver::MethodReference(&dex_file, method_idx)); + compiler_driver_->GetCompiledMethod(MethodReference(&dex_file, method_idx)); OatMethodOffsets method_offsets = oat_classes_[oat_class_index]->method_offsets_[class_def_method_index]; diff --git a/src/oat_writer.h b/src/compiler/oat_writer.h index b201d6b..b201d6b 100644 --- a/src/oat_writer.h +++ b/src/compiler/oat_writer.h diff --git a/src/dex2oat.cc b/src/dex2oat.cc index 6397f40..6c5ba52 100644 --- a/src/dex2oat.cc +++ b/src/dex2oat.cc @@ -30,17 +30,19 @@ #include "base/unix_file/fd_file.h" #include "class_linker.h" #include "compiler/driver/compiler_driver.h" +#include "compiler/elf_fixup.h" +#include "compiler/elf_stripper.h" +#include "compiler/image_writer.h" +#include "compiler/oat_writer.h" #include "dex_file-inl.h" #include "gc/space/image_space.h" #include "gc/space/space-inl.h" -#include "image_writer.h" #include "leb128.h" #include "mirror/abstract_method-inl.h" #include "mirror/class-inl.h" #include "mirror/class_loader.h" #include "mirror/object-inl.h" #include "mirror/object_array-inl.h" -#include "oat_writer.h" #include "object_utils.h" #include "os.h" #include "runtime.h" @@ -325,7 +327,7 @@ class Dex2Oat { PLOG(ERROR) << "Failed to open ELF file: " << oat_filename; return false; } - if (!compiler.FixupElf(oat_file.get(), oat_data_begin)) { + if (!ElfFixup::Fixup(oat_file.get(), oat_data_begin)) { LOG(ERROR) << "Failed to fixup ELF file " << oat_file->GetPath(); return false; } @@ -1044,7 +1046,7 @@ static int dex2oat(int argc, char** argv) { // Strip unneeded sections for target off_t seek_actual = lseek(oat_file->Fd(), 0, SEEK_SET); CHECK_EQ(0, seek_actual); - compiler->StripElf(oat_file.get()); + ElfStripper::Strip(oat_file.get()); // We wrote the oat file successfully, and want to keep it. LOG(INFO) << "Oat file written successfully (stripped): " << oat_location; diff --git a/src/image_test.cc b/src/image_test.cc index 9f86a1a..9ab1d74 100644 --- a/src/image_test.cc +++ b/src/image_test.cc @@ -18,11 +18,12 @@ #include <vector> #include "common_test.h" +#include "compiler/elf_fixup.h" +#include "compiler/image_writer.h" +#include "compiler/oat_writer.h" +#include "gc/space/image_space.h" #include "image.h" -#include "image_writer.h" -#include "oat_writer.h" #include "signal_catcher.h" -#include "gc/space/image_space.h" #include "UniquePtr.h" #include "utils.h" #include "vector_output_stream.h" @@ -72,7 +73,7 @@ TEST_F(ImageTest, WriteRead) { bool success_image = writer.Write(tmp_image.GetFilename(), requested_image_base, tmp_oat->GetPath(), tmp_oat->GetPath()); ASSERT_TRUE(success_image); - bool success_fixup = compiler_driver_->FixupElf(tmp_oat.get(), writer.GetOatDataBegin()); + bool success_fixup = ElfFixup::Fixup(tmp_oat.get(), writer.GetOatDataBegin()); ASSERT_TRUE(success_fixup); } diff --git a/src/method_reference.h b/src/method_reference.h new file mode 100644 index 0000000..ff8bf31 --- /dev/null +++ b/src/method_reference.h @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2013 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_SRC_METHOD_REFERENCE_H_ +#define ART_SRC_METHOD_REFERENCE_H_ + +namespace art { + +class DexFile; + +// A class is uniquely located by its DexFile and the class_defs_ table index into that DexFile +typedef std::pair<const DexFile*, uint32_t> ClassReference; + +// A method is uniquely located by its DexFile and the method_ids_ table index into that DexFile +struct MethodReference { + MethodReference(const DexFile* file, uint32_t index) : dex_file(file), dex_method_index(index) { + } + const DexFile* dex_file; + uint32_t dex_method_index; +}; + +struct MethodReferenceComparator { + bool operator()(MethodReference mr1, MethodReference mr2) const { + if (mr1.dex_file == mr2.dex_file) { + return mr1.dex_method_index < mr2.dex_method_index; + } else { + return mr1.dex_file < mr2.dex_file; + } + } +}; + +} // namespace art + +#endif // ART_SRC_METHOD_REFERENCE_H_ diff --git a/src/oat_test.cc b/src/oat_test.cc index 29e2891..f41a7ba 100644 --- a/src/oat_test.cc +++ b/src/oat_test.cc @@ -14,12 +14,12 @@ * limitations under the License. */ +#include "compiler/oat_writer.h" #include "mirror/abstract_method-inl.h" #include "mirror/class-inl.h" #include "mirror/object_array-inl.h" #include "mirror/object-inl.h" #include "oat_file.h" -#include "oat_writer.h" #include "vector_output_stream.h" #include "common_test.h" @@ -33,8 +33,8 @@ class OatTest : public CommonTest { const DexFile* dex_file) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { const CompiledMethod* compiled_method = - compiler_driver_->GetCompiledMethod(CompilerDriver::MethodReference(dex_file, - method->GetDexMethodIndex())); + compiler_driver_->GetCompiledMethod(MethodReference(dex_file, + method->GetDexMethodIndex())); if (compiled_method == NULL) { EXPECT_TRUE(oat_method.GetCode() == NULL) << PrettyMethod(method) << " " diff --git a/src/runtime.h b/src/runtime.h index 31b3a1b..97b7c25 100644 --- a/src/runtime.h +++ b/src/runtime.h @@ -133,9 +133,11 @@ class Runtime { return is_concurrent_gc_enabled_; } +#ifdef ART_SEA_IR_MODE bool IsSeaIRMode() const { return sea_ir_mode_; } +#endif void SetSeaIRMode(bool sea_ir_mode) { sea_ir_mode_ = sea_ir_mode; diff --git a/src/compiler/llvm/runtime_support_llvm.cc b/src/runtime_support_llvm.cc index bff13f9..cbdefe8 100644 --- a/src/compiler/llvm/runtime_support_llvm.cc +++ b/src/runtime_support_llvm.cc @@ -33,11 +33,10 @@ #include "object_utils.h" #include "reflection.h" #include "runtime_support.h" -#include "runtime_support_func_list.h" +#include "runtime_support_llvm_func_list.h" #include "scoped_thread_state_change.h" #include "thread.h" #include "thread_list.h" -#include "utils_llvm.h" #include "verifier/dex_gc_map.h" #include "verifier/method_verifier.h" #include "well_known_classes.h" diff --git a/src/compiler/llvm/runtime_support_llvm.h b/src/runtime_support_llvm.h index af99842..af99842 100644 --- a/src/compiler/llvm/runtime_support_llvm.h +++ b/src/runtime_support_llvm.h diff --git a/src/compiler/llvm/runtime_support_func_list.h b/src/runtime_support_llvm_func_list.h index a58b061..a58b061 100644 --- a/src/compiler/llvm/runtime_support_func_list.h +++ b/src/runtime_support_llvm_func_list.h diff --git a/src/verifier/method_verifier.cc b/src/verifier/method_verifier.cc index c0f1daa..5a70f2a 100644 --- a/src/verifier/method_verifier.cc +++ b/src/verifier/method_verifier.cc @@ -22,7 +22,6 @@ #include "base/mutex-inl.h" #include "base/stringpiece.h" #include "class_linker.h" -#include "compiler/driver/compiler_driver.h" #include "dex_file-inl.h" #include "dex_instruction-inl.h" #include "dex_instruction_visitor.h" @@ -426,7 +425,7 @@ std::ostream& MethodVerifier::Fail(VerifyError error) { // marked as rejected to prevent it from being compiled. case VERIFY_ERROR_BAD_CLASS_HARD: { if (Runtime::Current()->IsCompiler()) { - CompilerDriver::ClassReference ref(dex_file_, class_def_idx_); + ClassReference ref(dex_file_, class_def_idx_); AddRejectedClass(ref); } have_pending_hard_failure_ = true; @@ -1001,9 +1000,6 @@ bool MethodVerifier::VerifyCodeFlow() { return false; } - CompilerDriver::MethodReference ref(dex_file_, dex_method_idx_); - - /* Generate a register map and add it to the method. */ UniquePtr<const std::vector<uint8_t> > map(GenerateGcMap()); if (map.get() == NULL) { @@ -1013,6 +1009,7 @@ bool MethodVerifier::VerifyCodeFlow() { if (kIsDebugBuild) { VerifyGcMap(*map); } + MethodReference ref(dex_file_, dex_method_idx_); const std::vector<uint8_t>* dex_gc_map = CreateLengthPrefixedDexGcMap(*(map.get())); verifier::MethodVerifier::SetDexGcMap(ref, *dex_gc_map); @@ -3820,7 +3817,7 @@ MethodVerifier::PcToConcreteMethodMap* MethodVerifier::GenerateDevirtMap() { if (pc_to_concrete_method_map.get() == NULL) { pc_to_concrete_method_map.reset(new PcToConcreteMethodMap()); } - CompilerDriver::MethodReference concrete_ref( + MethodReference concrete_ref( concrete_method->GetDeclaringClass()->GetDexCache()->GetDexFile(), concrete_method->GetDexMethodIndex()); pc_to_concrete_method_map->Put(dex_pc, concrete_ref); @@ -3918,8 +3915,7 @@ void MethodVerifier::VerifyGcMap(const std::vector<uint8_t>& data) { } } -void MethodVerifier::SetDexGcMap(CompilerDriver::MethodReference ref, - const std::vector<uint8_t>& gc_map) { +void MethodVerifier::SetDexGcMap(MethodReference ref, const std::vector<uint8_t>& gc_map) { { WriterMutexLock mu(Thread::Current(), *dex_gc_maps_lock_); DexGcMapTable::iterator it = dex_gc_maps_->find(ref); @@ -3933,8 +3929,7 @@ void MethodVerifier::SetDexGcMap(CompilerDriver::MethodReference ref, } -void MethodVerifier::SetSafeCastMap(CompilerDriver::MethodReference ref, - const MethodSafeCastSet* cast_set) { +void MethodVerifier::SetSafeCastMap(MethodReference ref, const MethodSafeCastSet* cast_set) { MutexLock mu(Thread::Current(), *safecast_map_lock_); SafeCastMap::iterator it = safecast_map_->find(ref); if (it != safecast_map_->end()) { @@ -3946,7 +3941,7 @@ void MethodVerifier::SetSafeCastMap(CompilerDriver::MethodReference ref, CHECK(safecast_map_->find(ref) != safecast_map_->end()); } -bool MethodVerifier::IsSafeCast(CompilerDriver::MethodReference ref, uint32_t pc) { +bool MethodVerifier::IsSafeCast(MethodReference ref, uint32_t pc) { MutexLock mu(Thread::Current(), *safecast_map_lock_); SafeCastMap::const_iterator it = safecast_map_->find(ref); if (it == safecast_map_->end()) { @@ -3958,7 +3953,7 @@ bool MethodVerifier::IsSafeCast(CompilerDriver::MethodReference ref, uint32_t pc return cast_it != it->second->end(); } -const std::vector<uint8_t>* MethodVerifier::GetDexGcMap(CompilerDriver::MethodReference ref) { +const std::vector<uint8_t>* MethodVerifier::GetDexGcMap(MethodReference ref) { ReaderMutexLock mu(Thread::Current(), *dex_gc_maps_lock_); DexGcMapTable::const_iterator it = dex_gc_maps_->find(ref); if (it == dex_gc_maps_->end()) { @@ -3969,7 +3964,7 @@ const std::vector<uint8_t>* MethodVerifier::GetDexGcMap(CompilerDriver::MethodRe return it->second; } -void MethodVerifier::SetDevirtMap(CompilerDriver::MethodReference ref, +void MethodVerifier::SetDevirtMap(MethodReference ref, const PcToConcreteMethodMap* devirt_map) { WriterMutexLock mu(Thread::Current(), *devirt_maps_lock_); DevirtualizationMapTable::iterator it = devirt_maps_->find(ref); @@ -3982,7 +3977,7 @@ void MethodVerifier::SetDevirtMap(CompilerDriver::MethodReference ref, CHECK(devirt_maps_->find(ref) != devirt_maps_->end()); } -const CompilerDriver::MethodReference* MethodVerifier::GetDevirtMap(const CompilerDriver::MethodReference& ref, +const MethodReference* MethodVerifier::GetDevirtMap(const MethodReference& ref, uint32_t dex_pc) { ReaderMutexLock mu(Thread::Current(), *devirt_maps_lock_); DevirtualizationMapTable::const_iterator it = devirt_maps_->find(ref); @@ -4114,7 +4109,7 @@ void MethodVerifier::Shutdown() { verifier::RegTypeCache::ShutDown(); } -void MethodVerifier::AddRejectedClass(CompilerDriver::ClassReference ref) { +void MethodVerifier::AddRejectedClass(ClassReference ref) { { MutexLock mu(Thread::Current(), *rejected_classes_lock_); rejected_classes_->insert(ref); @@ -4122,7 +4117,7 @@ void MethodVerifier::AddRejectedClass(CompilerDriver::ClassReference ref) { CHECK(IsClassRejected(ref)); } -bool MethodVerifier::IsClassRejected(CompilerDriver::ClassReference ref) { +bool MethodVerifier::IsClassRejected(ClassReference ref) { MutexLock mu(Thread::Current(), *rejected_classes_lock_); return (rejected_classes_->find(ref) != rejected_classes_->end()); } diff --git a/src/verifier/method_verifier.h b/src/verifier/method_verifier.h index e90f9d9..ac0de9e 100644 --- a/src/verifier/method_verifier.h +++ b/src/verifier/method_verifier.h @@ -23,10 +23,11 @@ #include "base/casts.h" #include "base/macros.h" #include "base/stl_util.h" -#include "compiler/driver/compiler_driver.h" +#include "class_reference.h" #include "dex_file.h" #include "dex_instruction.h" #include "instruction_flags.h" +#include "method_reference.h" #include "mirror/object.h" #include "reg_type.h" #include "reg_type_cache-inl.h" @@ -184,17 +185,15 @@ class MethodVerifier { // information void Dump(std::ostream& os) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - static const std::vector<uint8_t>* GetDexGcMap(CompilerDriver::MethodReference ref) + static const std::vector<uint8_t>* GetDexGcMap(MethodReference ref) LOCKS_EXCLUDED(dex_gc_maps_lock_); - static const CompilerDriver::MethodReference* GetDevirtMap(const CompilerDriver::MethodReference& ref, - uint32_t dex_pc) + static const MethodReference* GetDevirtMap(const MethodReference& ref, uint32_t dex_pc) LOCKS_EXCLUDED(devirt_maps_lock_); // Returns true if the cast can statically be verified to be redundant // by using the check-cast elision peephole optimization in the verifier - static bool IsSafeCast(CompilerDriver::MethodReference ref, uint32_t pc) - LOCKS_EXCLUDED(safecast_map_lock_); + static bool IsSafeCast(MethodReference ref, uint32_t pc) LOCKS_EXCLUDED(safecast_map_lock_); // Fills 'monitor_enter_dex_pcs' with the dex pcs of the monitor-enter instructions corresponding // to the locks held at 'dex_pc' in method 'm'. @@ -217,7 +216,7 @@ class MethodVerifier { static void Init() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); static void Shutdown(); - static bool IsClassRejected(CompilerDriver::ClassReference ref) + static bool IsClassRejected(ClassReference ref) LOCKS_EXCLUDED(rejected_classes_lock_); bool CanLoadClasses() const { @@ -622,42 +621,42 @@ class MethodVerifier { InstructionFlags* CurrentInsnFlags(); // All the GC maps that the verifier has created - typedef SafeMap<const CompilerDriver::MethodReference, const std::vector<uint8_t>*, - CompilerDriver::MethodReferenceComparator> DexGcMapTable; + typedef SafeMap<const MethodReference, const std::vector<uint8_t>*, + MethodReferenceComparator> DexGcMapTable; static ReaderWriterMutex* dex_gc_maps_lock_ DEFAULT_MUTEX_ACQUIRED_AFTER; static DexGcMapTable* dex_gc_maps_ GUARDED_BY(dex_gc_maps_lock_); - static void SetDexGcMap(CompilerDriver::MethodReference ref, const std::vector<uint8_t>& dex_gc_map) + static void SetDexGcMap(MethodReference ref, const std::vector<uint8_t>& dex_gc_map) LOCKS_EXCLUDED(dex_gc_maps_lock_); // Cast elision types. typedef std::set<uint32_t> MethodSafeCastSet; - typedef SafeMap<const CompilerDriver::MethodReference, const MethodSafeCastSet*, - CompilerDriver::MethodReferenceComparator> SafeCastMap; + typedef SafeMap<const MethodReference, const MethodSafeCastSet*, + MethodReferenceComparator> SafeCastMap; MethodVerifier::MethodSafeCastSet* GenerateSafeCastSet() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - static void SetSafeCastMap(CompilerDriver::MethodReference ref, const MethodSafeCastSet* mscs); + static void SetSafeCastMap(MethodReference ref, const MethodSafeCastSet* mscs); LOCKS_EXCLUDED(safecast_map_lock_); static Mutex* safecast_map_lock_ DEFAULT_MUTEX_ACQUIRED_AFTER; static SafeCastMap* safecast_map_ GUARDED_BY(safecast_map_lock_); // Devirtualization map. - typedef SafeMap<const uint32_t, CompilerDriver::MethodReference> PcToConcreteMethodMap; - typedef SafeMap<const CompilerDriver::MethodReference, const PcToConcreteMethodMap*, - CompilerDriver::MethodReferenceComparator> DevirtualizationMapTable; + typedef SafeMap<const uint32_t, MethodReference> PcToConcreteMethodMap; + typedef SafeMap<const MethodReference, const PcToConcreteMethodMap*, + MethodReferenceComparator> DevirtualizationMapTable; MethodVerifier::PcToConcreteMethodMap* GenerateDevirtMap() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); static ReaderWriterMutex* devirt_maps_lock_ DEFAULT_MUTEX_ACQUIRED_AFTER; static DevirtualizationMapTable* devirt_maps_ GUARDED_BY(devirt_maps_lock_); - static void SetDevirtMap(CompilerDriver::MethodReference ref, + static void SetDevirtMap(MethodReference ref, const PcToConcreteMethodMap* pc_method_map) LOCKS_EXCLUDED(devirt_maps_lock_); - typedef std::set<CompilerDriver::ClassReference> RejectedClassesTable; + typedef std::set<ClassReference> RejectedClassesTable; static Mutex* rejected_classes_lock_ DEFAULT_MUTEX_ACQUIRED_AFTER; static RejectedClassesTable* rejected_classes_; - static void AddRejectedClass(CompilerDriver::ClassReference ref) + static void AddRejectedClass(ClassReference ref) LOCKS_EXCLUDED(rejected_classes_lock_); RegTypeCache reg_types_; |