diff options
author | Ian Rogers <irogers@google.com> | 2013-09-06 13:10:04 -0700 |
---|---|---|
committer | Ian Rogers <irogers@google.com> | 2013-09-09 08:33:36 -0700 |
commit | 02ed4c04468ca5f5540c5b704ac3e2f30eb9e8f4 (patch) | |
tree | fd568452f4ae81868087e9a5f6c04a9051d0ef83 | |
parent | 28c2300d9a85f4e7288fb5d94280332f923b4df3 (diff) | |
download | android_art-02ed4c04468ca5f5540c5b704ac3e2f30eb9e8f4.tar.gz android_art-02ed4c04468ca5f5540c5b704ac3e2f30eb9e8f4.tar.bz2 android_art-02ed4c04468ca5f5540c5b704ac3e2f30eb9e8f4.zip |
Move disassembler out of runtime.
Bug: 9877500.
Change-Id: Ica6d9f5ecfd20c86e5230a2213827bd78cd29a29
-rw-r--r-- | Android.mk | 1 | ||||
-rw-r--r-- | compiler/dex/arena_allocator.cc | 1 | ||||
-rw-r--r-- | compiler/dex/dex_to_dex_compiler.cc | 1 | ||||
-rw-r--r-- | compiler/dex/portable/mir_to_gbc.cc | 4 | ||||
-rw-r--r-- | compiler/dex/quick/mir_to_lir.cc | 1 | ||||
-rw-r--r-- | compiler/jni/quick/jni_compiler.cc | 6 | ||||
-rw-r--r-- | compiler/llvm/compiler_llvm.cc | 1 | ||||
-rw-r--r-- | disassembler/Android.mk | 120 | ||||
-rw-r--r-- | disassembler/disassembler.cc (renamed from runtime/disassembler.cc) | 0 | ||||
-rw-r--r-- | disassembler/disassembler.h (renamed from runtime/disassembler.h) | 6 | ||||
-rw-r--r-- | disassembler/disassembler_arm.cc (renamed from runtime/disassembler_arm.cc) | 0 | ||||
-rw-r--r-- | disassembler/disassembler_arm.h (renamed from runtime/disassembler_arm.h) | 6 | ||||
-rw-r--r-- | disassembler/disassembler_mips.cc (renamed from runtime/disassembler_mips.cc) | 0 | ||||
-rw-r--r-- | disassembler/disassembler_mips.h (renamed from runtime/disassembler_mips.h) | 6 | ||||
-rw-r--r-- | disassembler/disassembler_x86.cc (renamed from runtime/disassembler_x86.cc) | 0 | ||||
-rw-r--r-- | disassembler/disassembler_x86.h (renamed from runtime/disassembler_x86.h) | 6 | ||||
-rw-r--r-- | oatdump/Android.mk | 8 | ||||
-rw-r--r-- | runtime/Android.mk | 4 | ||||
-rw-r--r-- | runtime/thread-inl.h | 13 | ||||
-rw-r--r-- | runtime/thread.h | 13 |
20 files changed, 157 insertions, 40 deletions
diff --git a/Android.mk b/Android.mk index 46a7c1ec3e..0b4b2316fd 100644 --- a/Android.mk +++ b/Android.mk @@ -85,6 +85,7 @@ ifneq ($(art_dont_bother),true) include $(art_path)/runtime/Android.mk include $(art_path)/compiler/Android.mk include $(art_path)/dex2oat/Android.mk +include $(art_path)/disassembler/Android.mk include $(art_path)/oatdump/Android.mk include $(art_path)/dalvikvm/Android.mk include $(art_path)/jdwpspy/Android.mk diff --git a/compiler/dex/arena_allocator.cc b/compiler/dex/arena_allocator.cc index 36393e7387..5a91d27ef5 100644 --- a/compiler/dex/arena_allocator.cc +++ b/compiler/dex/arena_allocator.cc @@ -19,6 +19,7 @@ #include "arena_allocator.h" #include "base/logging.h" #include "base/mutex.h" +#include "thread-inl.h" namespace art { diff --git a/compiler/dex/dex_to_dex_compiler.cc b/compiler/dex/dex_to_dex_compiler.cc index 4a724b109a..ffd7905dfe 100644 --- a/compiler/dex/dex_to_dex_compiler.cc +++ b/compiler/dex/dex_to_dex_compiler.cc @@ -24,6 +24,7 @@ #include "mirror/art_method-inl.h" #include "mirror/class-inl.h" #include "mirror/dex_cache.h" +#include "thread-inl.h" namespace art { namespace optimizer { diff --git a/compiler/dex/portable/mir_to_gbc.cc b/compiler/dex/portable/mir_to_gbc.cc index 2cf55e7ea5..df10f7eda0 100644 --- a/compiler/dex/portable/mir_to_gbc.cc +++ b/compiler/dex/portable/mir_to_gbc.cc @@ -30,10 +30,10 @@ #include "dex/compiler_internals.h" #include "dex/dataflow_iterator-inl.h" #include "dex/frontend.h" -#include "mir_to_gbc.h" - #include "llvm/llvm_compilation_unit.h" #include "llvm/utils_llvm.h" +#include "mir_to_gbc.h" +#include "thread-inl.h" const char* kLabelFormat = "%c0x%x_%d"; const char kInvalidBlock = 0xff; diff --git a/compiler/dex/quick/mir_to_lir.cc b/compiler/dex/quick/mir_to_lir.cc index 7c79f59853..22dd6dadb9 100644 --- a/compiler/dex/quick/mir_to_lir.cc +++ b/compiler/dex/quick/mir_to_lir.cc @@ -18,6 +18,7 @@ #include "dex/dataflow_iterator-inl.h" #include "mir_to_lir-inl.h" #include "object_utils.h" +#include "thread-inl.h" namespace art { diff --git a/compiler/jni/quick/jni_compiler.cc b/compiler/jni/quick/jni_compiler.cc index 1417fb9e40..b6b15f94eb 100644 --- a/compiler/jni/quick/jni_compiler.cc +++ b/compiler/jni/quick/jni_compiler.cc @@ -24,7 +24,6 @@ #include "compiled_method.h" #include "dex_file-inl.h" #include "driver/compiler_driver.h" -#include "disassembler.h" #include "entrypoints/quick/quick_entrypoints.h" #include "jni_internal.h" #include "utils/assembler.h" @@ -85,7 +84,6 @@ CompiledMethod* ArtJniCompileMethodInternal(CompilerDriver& compiler, // Assembler that holds generated instructions UniquePtr<Assembler> jni_asm(Assembler::Create(instruction_set)); - bool should_disassemble = false; // Offsets into data structures // TODO: if cross compiling these offsets are for the host not the target @@ -366,10 +364,6 @@ CompiledMethod* ArtJniCompileMethodInternal(CompilerDriver& compiler, std::vector<uint8_t> managed_code(cs); MemoryRegion code(&managed_code[0], managed_code.size()); __ FinalizeInstructions(code); - if (should_disassemble) { - UniquePtr<Disassembler> disassembler(Disassembler::Create(instruction_set)); - disassembler->Dump(LOG(INFO), &managed_code[0], &managed_code[managed_code.size()]); - } return new CompiledMethod(compiler, instruction_set, managed_code, diff --git a/compiler/llvm/compiler_llvm.cc b/compiler/llvm/compiler_llvm.cc index 83b0c75e04..0df3c476fc 100644 --- a/compiler/llvm/compiler_llvm.cc +++ b/compiler/llvm/compiler_llvm.cc @@ -26,6 +26,7 @@ #include "ir_builder.h" #include "jni/portable/jni_compiler.h" #include "llvm_compilation_unit.h" +#include "thread-inl.h" #include "utils_llvm.h" #include "verifier/method_verifier.h" diff --git a/disassembler/Android.mk b/disassembler/Android.mk new file mode 100644 index 0000000000..f8001a4524 --- /dev/null +++ b/disassembler/Android.mk @@ -0,0 +1,120 @@ +# +# 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. +# + +LOCAL_PATH := $(call my-dir) + +include art/build/Android.common.mk + +LIBART_DISASSEMBLER_SRC_FILES := \ + disassembler.cc \ + disassembler_arm.cc \ + disassembler_mips.cc \ + disassembler_x86.cc + +# $(1): target or host +# $(2): ndebug or debug +define build-libart-disassembler + ifneq ($(1),target) + ifneq ($(1),host) + $$(error expected target or host for argument 1, received $(1)) + endif + endif + ifneq ($(2),ndebug) + ifneq ($(2),debug) + $$(error expected ndebug or debug for argument 2, received $(2)) + endif + endif + + art_target_or_host := $(1) + art_ndebug_or_debug := $(2) + + include $(CLEAR_VARS) + ifeq ($$(art_target_or_host),target) + include external/stlport/libstlport.mk + else + LOCAL_IS_HOST_MODULE := true + endif + LOCAL_CPP_EXTENSION := $(ART_CPP_EXTENSION) + ifeq ($$(art_ndebug_or_debug),ndebug) + LOCAL_MODULE := libart-disassembler + else # debug + LOCAL_MODULE := libartd-disassembler + endif + + LOCAL_MODULE_TAGS := optional + LOCAL_MODULE_CLASS := SHARED_LIBRARIES + + LOCAL_SRC_FILES := $$(LIBART_DISASSEMBLER_SRC_FILES) + + GENERATED_SRC_DIR := $$(call intermediates-dir-for,$$(LOCAL_MODULE_CLASS),$$(LOCAL_MODULE),$$(LOCAL_IS_HOST_MODULE),) + + ifeq ($$(art_target_or_host),target) + LOCAL_CLANG := $(ART_TARGET_CLANG) + LOCAL_CFLAGS += $(ART_TARGET_CFLAGS) + else # host + LOCAL_CLANG := $(ART_HOST_CLANG) + LOCAL_CFLAGS += $(ART_HOST_CFLAGS) + endif + + LOCAL_SHARED_LIBRARIES += liblog + ifeq ($$(art_ndebug_or_debug),debug) + ifeq ($$(art_target_or_host),target) + LOCAL_CFLAGS += $(ART_TARGET_DEBUG_CFLAGS) + else # host + LOCAL_CFLAGS += $(ART_HOST_DEBUG_CFLAGS) + endif + LOCAL_SHARED_LIBRARIES += libartd + else + ifeq ($$(art_target_or_host),target) + LOCAL_CFLAGS += $(ART_TARGET_NON_DEBUG_CFLAGS) + else # host + LOCAL_CFLAGS += $(ART_HOST_NON_DEBUG_CFLAGS) + endif + LOCAL_SHARED_LIBRARIES += libart + endif + + LOCAL_C_INCLUDES += $(ART_C_INCLUDES) art/runtime + + LOCAL_ADDITIONAL_DEPENDENCIES := art/build/Android.common.mk + LOCAL_ADDITIONAL_DEPENDENCIES += $(LOCAL_PATH)/Android.mk + ifeq ($$(art_target_or_host),target) + LOCAL_SHARED_LIBRARIES += libcutils + include $(LLVM_GEN_INTRINSICS_MK) + include $(LLVM_DEVICE_BUILD_MK) + include $(BUILD_SHARED_LIBRARY) + else # host + LOCAL_STATIC_LIBRARIES += libcutils + include $(LLVM_GEN_INTRINSICS_MK) + include $(LLVM_HOST_BUILD_MK) + include $(BUILD_HOST_SHARED_LIBRARY) + endif +endef + +ifeq ($(ART_BUILD_TARGET_NDEBUG),true) + $(eval $(call build-libart-disassembler,target,ndebug)) +endif +ifeq ($(ART_BUILD_TARGET_DEBUG),true) + $(eval $(call build-libart-disassembler,target,debug)) +endif +ifeq ($(WITH_HOST_DALVIK),true) + # 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-libart-disassembler,host,ndebug)) + endif + ifeq ($(ART_BUILD_DEBUG),true) + $(eval $(call build-libart-disassembler,host,debug)) + endif +endif diff --git a/runtime/disassembler.cc b/disassembler/disassembler.cc index 067083510b..067083510b 100644 --- a/runtime/disassembler.cc +++ b/disassembler/disassembler.cc diff --git a/runtime/disassembler.h b/disassembler/disassembler.h index 805ff4d079..7547ab722b 100644 --- a/runtime/disassembler.h +++ b/disassembler/disassembler.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_RUNTIME_DISASSEMBLER_H_ -#define ART_RUNTIME_DISASSEMBLER_H_ +#ifndef ART_DISASSEMBLER_DISASSEMBLER_H_ +#define ART_DISASSEMBLER_DISASSEMBLER_H_ #include <stdint.h> @@ -45,4 +45,4 @@ class Disassembler { } // namespace art -#endif // ART_RUNTIME_DISASSEMBLER_H_ +#endif // ART_DISASSEMBLER_DISASSEMBLER_H_ diff --git a/runtime/disassembler_arm.cc b/disassembler/disassembler_arm.cc index 879d3ac71c..879d3ac71c 100644 --- a/runtime/disassembler_arm.cc +++ b/disassembler/disassembler_arm.cc diff --git a/runtime/disassembler_arm.h b/disassembler/disassembler_arm.h index cab9150108..2e699ffe88 100644 --- a/runtime/disassembler_arm.h +++ b/disassembler/disassembler_arm.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_RUNTIME_DISASSEMBLER_ARM_H_ -#define ART_RUNTIME_DISASSEMBLER_ARM_H_ +#ifndef ART_DISASSEMBLER_DISASSEMBLER_ARM_H_ +#define ART_DISASSEMBLER_DISASSEMBLER_ARM_H_ #include <vector> @@ -48,4 +48,4 @@ class DisassemblerArm : public Disassembler { } // namespace arm } // namespace art -#endif // ART_RUNTIME_DISASSEMBLER_ARM_H_ +#endif // ART_DISASSEMBLER_DISASSEMBLER_ARM_H_ diff --git a/runtime/disassembler_mips.cc b/disassembler/disassembler_mips.cc index 25bbae68ef..25bbae68ef 100644 --- a/runtime/disassembler_mips.cc +++ b/disassembler/disassembler_mips.cc diff --git a/runtime/disassembler_mips.h b/disassembler/disassembler_mips.h index e248503963..d3862676a0 100644 --- a/runtime/disassembler_mips.h +++ b/disassembler/disassembler_mips.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_RUNTIME_DISASSEMBLER_MIPS_H_ -#define ART_RUNTIME_DISASSEMBLER_MIPS_H_ +#ifndef ART_DISASSEMBLER_DISASSEMBLER_MIPS_H_ +#define ART_DISASSEMBLER_DISASSEMBLER_MIPS_H_ #include <vector> @@ -37,4 +37,4 @@ class DisassemblerMips : public Disassembler { } // namespace mips } // namespace art -#endif // ART_RUNTIME_DISASSEMBLER_MIPS_H_ +#endif // ART_DISASSEMBLER_DISASSEMBLER_MIPS_H_ diff --git a/runtime/disassembler_x86.cc b/disassembler/disassembler_x86.cc index e5cdb7b297..e5cdb7b297 100644 --- a/runtime/disassembler_x86.cc +++ b/disassembler/disassembler_x86.cc diff --git a/runtime/disassembler_x86.h b/disassembler/disassembler_x86.h index ff4322c8b8..9adaff7048 100644 --- a/runtime/disassembler_x86.h +++ b/disassembler/disassembler_x86.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_RUNTIME_DISASSEMBLER_X86_H_ -#define ART_RUNTIME_DISASSEMBLER_X86_H_ +#ifndef ART_DISASSEMBLER_DISASSEMBLER_X86_H_ +#define ART_DISASSEMBLER_DISASSEMBLER_X86_H_ #include "disassembler.h" @@ -35,4 +35,4 @@ class DisassemblerX86 : public Disassembler { } // namespace x86 } // namespace art -#endif // ART_RUNTIME_DISASSEMBLER_X86_H_ +#endif // ART_DISASSEMBLER_DISASSEMBLER_X86_H_ diff --git a/oatdump/Android.mk b/oatdump/Android.mk index a63b229846..7cee00e182 100644 --- a/oatdump/Android.mk +++ b/oatdump/Android.mk @@ -22,17 +22,17 @@ OATDUMP_SRC_FILES := \ include art/build/Android.executable.mk ifeq ($(ART_BUILD_TARGET_NDEBUG),true) - $(eval $(call build-art-executable,oatdump,$(OATDUMP_SRC_FILES),libcutils,,target,ndebug)) + $(eval $(call build-art-executable,oatdump,$(OATDUMP_SRC_FILES),libcutils libart-disassembler,art/disassembler,target,ndebug)) endif ifeq ($(ART_BUILD_TARGET_DEBUG),true) - $(eval $(call build-art-executable,oatdump,$(OATDUMP_SRC_FILES),libcutils,,target,debug)) + $(eval $(call build-art-executable,oatdump,$(OATDUMP_SRC_FILES),libcutils libartd-disassembler,art/disassembler,target,debug)) endif ifeq ($(WITH_HOST_DALVIK),true) 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),libart-disassembler,art/disassembler,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),libartd-disassembler,art/disassembler,host,debug)) endif endif diff --git a/runtime/Android.mk b/runtime/Android.mk index a8d505e1f5..b04cd6ae0b 100644 --- a/runtime/Android.mk +++ b/runtime/Android.mk @@ -38,10 +38,6 @@ LIBART_COMMON_SRC_FILES := \ dex_file.cc \ dex_file_verifier.cc \ dex_instruction.cc \ - disassembler.cc \ - disassembler_arm.cc \ - disassembler_mips.cc \ - disassembler_x86.cc \ elf_file.cc \ gc/allocator/dlmalloc.cc \ gc/accounting/card_table.cc \ diff --git a/runtime/thread-inl.h b/runtime/thread-inl.h index c22f2cd921..4552062319 100644 --- a/runtime/thread-inl.h +++ b/runtime/thread-inl.h @@ -19,11 +19,24 @@ #include "thread.h" +#include <pthread.h> + #include "base/mutex-inl.h" #include "cutils/atomic-inline.h" namespace art { +inline Thread* Thread::Current() { + // We rely on Thread::Current returning NULL for a detached thread, so it's not obvious + // that we can replace this with a direct %fs access on x86. + if (!is_started_) { + return NULL; + } else { + void* thread = pthread_getspecific(Thread::pthread_key_self_); + return reinterpret_cast<Thread*>(thread); + } +} + inline ThreadState Thread::SetState(ThreadState new_state) { // Cannot use this code to change into Runnable as changing to Runnable should fail if // old_state_and_flags.suspend_request is true. diff --git a/runtime/thread.h b/runtime/thread.h index 40e3f5fbb2..f5f8f563fa 100644 --- a/runtime/thread.h +++ b/runtime/thread.h @@ -17,8 +17,6 @@ #ifndef ART_RUNTIME_THREAD_H_ #define ART_RUNTIME_THREAD_H_ -#include <pthread.h> - #include <bitset> #include <deque> #include <iosfwd> @@ -104,16 +102,7 @@ class PACKED(4) Thread { // Reset internal state of child thread after fork. void InitAfterFork(); - static Thread* Current() { - // We rely on Thread::Current returning NULL for a detached thread, so it's not obvious - // that we can replace this with a direct %fs access on x86. - if (!is_started_) { - return NULL; - } else { - void* thread = pthread_getspecific(Thread::pthread_key_self_); - return reinterpret_cast<Thread*>(thread); - } - } + static Thread* Current(); static Thread* FromManagedThread(const ScopedObjectAccessUnchecked& ts, mirror::Object* thread_peer) |