diff options
Diffstat (limited to 'tools/cpp-define-generator')
38 files changed, 654 insertions, 977 deletions
diff --git a/tools/cpp-define-generator/Android.bp b/tools/cpp-define-generator/Android.bp index 23cc917f1d..027f128561 100644 --- a/tools/cpp-define-generator/Android.bp +++ b/tools/cpp-define-generator/Android.bp @@ -14,16 +14,11 @@ // limitations under the License. // -// Build a "data" binary which will hold all the symbol values that will be parsed by the other scripts. -// -// Builds are for host only, target-specific define generation is possibly but is trickier and would need extra tooling. -// -// In the future we may wish to parameterize this on (32,64)x(read_barrier,no_read_barrier). - -cc_binary { // Do not use art_cc_binary because HOST_PREFER_32_BIT is incompatible with genrule. - name: "cpp-define-generator-data", +// This produces human-readable asm_defines.s with the embedded compile-time constants. +cc_object { + name: "asm_defines.s", host_supported: true, - device_supported: false, + device_supported: true, defaults: [ "art_debug_defaults", "art_defaults", @@ -33,20 +28,36 @@ cc_binary { // Do not use art_cc_binary because HOST_PREFER_32_BIT is incompatib "art/libdexfile", "art/libartbase", "art/runtime", + "system/core/base/include", ], - srcs: ["main.cc"], - shared_libs: [ - "libbase", - ], + // Produce text file rather than binary. + cflags: ["-S"], + srcs: ["asm_defines.cc"], } -// Note: See $OUT_DIR/soong/build.ninja -// For the exact filename that this generates to run make command on just -// this rule later. -genrule { +// This extracts the compile-time constants from asm_defines.s and creates the header. +cc_genrule { name: "cpp-define-generator-asm-support", - out: ["asm_support_gen.h"], - tools: ["cpp-define-generator-data"], - tool_files: ["verify-asm-support"], - cmd: "$(location verify-asm-support) --quiet \"$(location cpp-define-generator-data)\" \"$(out)\"", + host_supported: true, + device_supported: true, + srcs: [":asm_defines.s"], + out: ["asm_defines.h"], + tool_files: ["make_header.py"], + cmd: "$(location make_header.py) \"$(in)\" > \"$(out)\"", +} + +cc_library_headers { + name: "cpp-define-generator-definitions", + host_supported: true, + export_include_dirs: ["."], +} + +python_binary_host { + name: "cpp-define-generator-test", + main: "make_header_test.py", + srcs: [ + "make_header.py", + "make_header_test.py", + ], + test_suites: ["general-tests"], } diff --git a/tools/cpp-define-generator/art_method.def b/tools/cpp-define-generator/art_method.def new file mode 100644 index 0000000000..21859dc9ce --- /dev/null +++ b/tools/cpp-define-generator/art_method.def @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2018 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#if ASM_DEFINE_INCLUDE_DEPENDENCIES +#include "art_method.h" +#endif + +ASM_DEFINE(ART_METHOD_ACCESS_FLAGS_OFFSET, + art::ArtMethod::AccessFlagsOffset().Int32Value()) +ASM_DEFINE(ART_METHOD_DECLARING_CLASS_OFFSET, + art::ArtMethod::DeclaringClassOffset().Int32Value()) +ASM_DEFINE(ART_METHOD_JNI_OFFSET_32, + art::ArtMethod::EntryPointFromJniOffset(art::PointerSize::k32).Int32Value()) +ASM_DEFINE(ART_METHOD_JNI_OFFSET_64, + art::ArtMethod::EntryPointFromJniOffset(art::PointerSize::k64).Int32Value()) +ASM_DEFINE(ART_METHOD_QUICK_CODE_OFFSET_32, + art::ArtMethod::EntryPointFromQuickCompiledCodeOffset(art::PointerSize::k32).Int32Value()) +ASM_DEFINE(ART_METHOD_QUICK_CODE_OFFSET_64, + art::ArtMethod::EntryPointFromQuickCompiledCodeOffset(art::PointerSize::k64).Int32Value()) diff --git a/tools/cpp-define-generator/asm_defines.cc b/tools/cpp-define-generator/asm_defines.cc new file mode 100644 index 0000000000..b79e1ae26e --- /dev/null +++ b/tools/cpp-define-generator/asm_defines.cc @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2018 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// +// This file is used to generate #defines for use in assembly source code. +// +// The content of this file will be used to compile an object file +// (generated as human readable assembly text file, not as binary). +// This text file will then be post-processed by a python script to find +// and extract the constants and generate the final asm_defines.h header. +// + +// We use "asm volatile" to generate text that will stand out in the +// compiler generated intermediate assembly file (eg. ">>FOO 42 0<<"). +// We emit all values as 64-bit integers (which we will printed as text). +// We also store a flag which specifies whether the constant is negative. +// Note that "asm volatile" must be inside a method to please the compiler. +#define ASM_DEFINE(NAME, EXPR) \ +void AsmDefineHelperFor_##NAME() { \ + asm volatile("\n.ascii \">>" #NAME " %0 %1<<\"" \ + :: "i" (static_cast<int64_t>(EXPR)), "i" ((EXPR) < 0 ? 1 : 0)); \ +} +#include "asm_defines.def" diff --git a/tools/cpp-define-generator/constant_jit.def b/tools/cpp-define-generator/asm_defines.def index 5fa5194d00..7a77e8ebe3 100644 --- a/tools/cpp-define-generator/constant_jit.def +++ b/tools/cpp-define-generator/asm_defines.def @@ -1,5 +1,5 @@ /* - * Copyright (C) 2016 The Android Open Source Project + * Copyright (C) 2018 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,16 +14,19 @@ * limitations under the License. */ -// Constants within jit.h. - -#if defined(DEFINE_INCLUDE_DEPENDENCIES) -#include "jit/jit.h" // art::kSuspendRequest, etc. +#if !defined(ASM_DEFINE_INCLUDE_DEPENDENCIES) +#define ASM_DEFINE_INCLUDE_DEPENDENCIES 1 #endif -#define DEFINE_JIT_CONSTANT(macro_name, type, expr) \ - DEFINE_EXPR(JIT_ ## macro_name, type, (expr)) - -DEFINE_JIT_CONSTANT(CHECK_OSR, int16_t, art::jit::kJitCheckForOSR) -DEFINE_JIT_CONSTANT(HOTNESS_DISABLE, int16_t, art::jit::kJitHotnessDisabled) - -#undef DEFINE_JIT_CONSTANT +#include "globals.def" +#include "art_method.def" +#include "lockword.def" +#include "mirror_array.def" +#include "mirror_class.def" +#include "mirror_dex_cache.def" +#include "mirror_object.def" +#include "mirror_string.def" +#include "rosalloc.def" +#include "runtime.def" +#include "shadow_frame.def" +#include "thread.def" diff --git a/tools/cpp-define-generator/common_undef.def b/tools/cpp-define-generator/common_undef.def deleted file mode 100644 index c44aba7c3b..0000000000 --- a/tools/cpp-define-generator/common_undef.def +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (C) 2016 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. - */ - -#ifdef DEFINE_OFFSET_EXPR_STANDARD_DEFINITION -#undef DEFINE_OFFSET_EXPR_STANDARD_DEFINITION -#undef DEFINE_OFFSET_EXPR -#endif diff --git a/tools/cpp-define-generator/constant_class.def b/tools/cpp-define-generator/constant_class.def deleted file mode 100644 index 1310103ab7..0000000000 --- a/tools/cpp-define-generator/constant_class.def +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (C) 2016 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. - */ - -#if defined(DEFINE_INCLUDE_DEPENDENCIES) -#include "base/bit_utils.h" // MostSignificantBit -#include "dex/modifiers.h" // kAccClassIsFinalizable -#endif - -#define DEFINE_FLAG_OFFSET(type_name, field_name, expr) \ - DEFINE_EXPR(type_name ## _ ## field_name, uint32_t, (expr)) - -DEFINE_FLAG_OFFSET(ACCESS_FLAGS, CLASS_IS_FINALIZABLE, art::kAccClassIsFinalizable) -DEFINE_FLAG_OFFSET(ACCESS_FLAGS, CLASS_IS_INTERFACE, art::kAccInterface) -// TODO: We should really have a BitPosition which also checks it's a power of 2. -DEFINE_FLAG_OFFSET(ACCESS_FLAGS, CLASS_IS_FINALIZABLE_BIT, art::MostSignificantBit(art::kAccClassIsFinalizable)) - -#undef DEFINE_FLAG_OFFSET diff --git a/tools/cpp-define-generator/constant_dexcache.def b/tools/cpp-define-generator/constant_dexcache.def deleted file mode 100644 index 743ebb7453..0000000000 --- a/tools/cpp-define-generator/constant_dexcache.def +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (C) 2016 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. - */ - -#if defined(DEFINE_INCLUDE_DEPENDENCIES) -#include "mirror/dex_cache.h" // art::mirror::DexCache, StringDexCachePair -#endif - -DEFINE_EXPR(STRING_DEX_CACHE_ELEMENT_SIZE_SHIFT, int32_t, - art::WhichPowerOf2(sizeof(art::mirror::StringDexCachePair))) -DEFINE_EXPR(STRING_DEX_CACHE_SIZE_MINUS_ONE, int32_t, - art::mirror::DexCache::kDexCacheStringCacheSize - 1) -DEFINE_EXPR(STRING_DEX_CACHE_HASH_BITS, int32_t, - art::LeastSignificantBit(art::mirror::DexCache::kDexCacheStringCacheSize)) -DEFINE_EXPR(STRING_DEX_CACHE_ELEMENT_SIZE, int32_t, - sizeof(art::mirror::StringDexCachePair)) -DEFINE_EXPR(METHOD_DEX_CACHE_SIZE_MINUS_ONE, int32_t, - art::mirror::DexCache::kDexCacheMethodCacheSize - 1) -DEFINE_EXPR(METHOD_DEX_CACHE_HASH_BITS, int32_t, - art::LeastSignificantBit(art::mirror::DexCache::kDexCacheMethodCacheSize)) diff --git a/tools/cpp-define-generator/constant_globals.def b/tools/cpp-define-generator/constant_globals.def deleted file mode 100644 index d0d6350f80..0000000000 --- a/tools/cpp-define-generator/constant_globals.def +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (C) 2016 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. - */ - -// Export global values. - -#if defined(DEFINE_INCLUDE_DEPENDENCIES) -#include <atomic> // std::memory_order_relaxed -#include "base/globals.h" // art::kObjectAlignment -#include "dex/modifiers.h" -#endif - -DEFINE_EXPR(STD_MEMORY_ORDER_RELAXED, int32_t, std::memory_order_relaxed) - -#define DEFINE_OBJECT_EXPR(macro_name, type, constant_field_name) \ - DEFINE_EXPR(OBJECT_ ## macro_name, type, constant_field_name) - -DEFINE_OBJECT_EXPR(ALIGNMENT_MASK, size_t, art::kObjectAlignment - 1) -DEFINE_OBJECT_EXPR(ALIGNMENT_MASK_TOGGLED, uint32_t, ~static_cast<uint32_t>(art::kObjectAlignment - 1)) -DEFINE_OBJECT_EXPR(ALIGNMENT_MASK_TOGGLED64, uint64_t, ~static_cast<uint64_t>(art::kObjectAlignment - 1)) - -DEFINE_EXPR(ACC_OBSOLETE_METHOD, int32_t, art::kAccObsoleteMethod) -DEFINE_EXPR(ACC_OBSOLETE_METHOD_SHIFT, int32_t, art::WhichPowerOf2(art::kAccObsoleteMethod)) - -#undef DEFINE_OBJECT_EXPR - diff --git a/tools/cpp-define-generator/constant_heap.def b/tools/cpp-define-generator/constant_heap.def deleted file mode 100644 index dc76736505..0000000000 --- a/tools/cpp-define-generator/constant_heap.def +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (C) 2016 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. - */ - -// Export heap values. - -#if defined(DEFINE_INCLUDE_DEPENDENCIES) -#include "gc/heap.h" -#endif - -// Size of references to the heap on the stack. -DEFINE_EXPR(MIN_LARGE_OBJECT_THRESHOLD, size_t, art::gc::Heap::kMinLargeObjectThreshold) - diff --git a/tools/cpp-define-generator/constant_lockword.def b/tools/cpp-define-generator/constant_lockword.def deleted file mode 100644 index 977d1ca12d..0000000000 --- a/tools/cpp-define-generator/constant_lockword.def +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (C) 2016 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. - */ - -// Export lockword values. - -#if defined(DEFINE_INCLUDE_DEPENDENCIES) -#include "lock_word.h" // art::LockWord -#endif - -#define DEFINE_LOCK_WORD_EXPR(macro_name, type, constant_field_name) \ - DEFINE_EXPR(LOCK_WORD_ ## macro_name, type, art::LockWord::constant_field_name) - -// FIXME: The naming is inconsistent, the `Shifted` -> `_SHIFTED` suffix is sometimes missing. -DEFINE_LOCK_WORD_EXPR(STATE_SHIFT, int32_t, kStateShift) -DEFINE_LOCK_WORD_EXPR(STATE_MASK_SHIFTED, uint32_t, kStateMaskShifted) -DEFINE_LOCK_WORD_EXPR(READ_BARRIER_STATE_SHIFT, int32_t, kReadBarrierStateShift) -DEFINE_LOCK_WORD_EXPR(READ_BARRIER_STATE_MASK, uint32_t, kReadBarrierStateMaskShifted) -DEFINE_LOCK_WORD_EXPR(READ_BARRIER_STATE_MASK_TOGGLED, uint32_t, kReadBarrierStateMaskShiftedToggled) -DEFINE_LOCK_WORD_EXPR(THIN_LOCK_COUNT_SIZE, int32_t, kThinLockCountSize) -DEFINE_LOCK_WORD_EXPR(THIN_LOCK_COUNT_SHIFT, int32_t, kThinLockCountShift) -DEFINE_LOCK_WORD_EXPR(THIN_LOCK_COUNT_MASK_SHIFTED, uint32_t, kThinLockCountMaskShifted) -DEFINE_LOCK_WORD_EXPR(THIN_LOCK_COUNT_ONE, uint32_t, kThinLockCountOne) -DEFINE_LOCK_WORD_EXPR(THIN_LOCK_OWNER_MASK_SHIFTED, uint32_t, kThinLockOwnerMaskShifted) - -DEFINE_LOCK_WORD_EXPR(STATE_FORWARDING_ADDRESS, uint32_t, kStateForwardingAddress) -DEFINE_LOCK_WORD_EXPR(STATE_FORWARDING_ADDRESS_OVERFLOW, uint32_t, kStateForwardingAddressOverflow) -DEFINE_LOCK_WORD_EXPR(STATE_FORWARDING_ADDRESS_SHIFT, uint32_t, kForwardingAddressShift) - -DEFINE_LOCK_WORD_EXPR(GC_STATE_MASK_SHIFTED, uint32_t, kGCStateMaskShifted) -DEFINE_LOCK_WORD_EXPR(GC_STATE_MASK_SHIFTED_TOGGLED, uint32_t, kGCStateMaskShiftedToggled) -DEFINE_LOCK_WORD_EXPR(GC_STATE_SIZE, int32_t, kGCStateSize) -DEFINE_LOCK_WORD_EXPR(GC_STATE_SHIFT, int32_t, kGCStateShift) - -DEFINE_LOCK_WORD_EXPR(MARK_BIT_SHIFT, int32_t, kMarkBitStateShift) -DEFINE_LOCK_WORD_EXPR(MARK_BIT_MASK_SHIFTED, uint32_t, kMarkBitStateMaskShifted) - -#undef DEFINE_LOCK_WORD_EXPR - diff --git a/tools/cpp-define-generator/constant_reference.def b/tools/cpp-define-generator/constant_reference.def deleted file mode 100644 index d312f76e0a..0000000000 --- a/tools/cpp-define-generator/constant_reference.def +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (C) 2016 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. - */ - -#if defined(DEFINE_INCLUDE_DEPENDENCIES) -#include "mirror/object.h" // mirror::Object -#include "stack.h" // StackReference -#include "mirror/object_reference.h" // mirror::CompressedReference -#include "base/bit_utils.h" // WhichPowerOf2 -#endif - -// Size of references to the heap on the stack. -DEFINE_EXPR(STACK_REFERENCE_SIZE, size_t, sizeof(art::StackReference<art::mirror::Object>)) -// Size of heap references -DEFINE_EXPR(COMPRESSED_REFERENCE_SIZE, size_t, sizeof(art::mirror::CompressedReference<art::mirror::Object>)) -DEFINE_EXPR(COMPRESSED_REFERENCE_SIZE_SHIFT, size_t, art::WhichPowerOf2(sizeof(art::mirror::CompressedReference<art::mirror::Object>))) - -#undef DEFINE_REFERENCE_OFFSET diff --git a/tools/cpp-define-generator/constant_rosalloc.def b/tools/cpp-define-generator/constant_rosalloc.def deleted file mode 100644 index 2007cef5ad..0000000000 --- a/tools/cpp-define-generator/constant_rosalloc.def +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (C) 2016 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. - */ - -// Constants within RosAlloc. - -#if defined(DEFINE_INCLUDE_DEPENDENCIES) -#include "gc/allocator/rosalloc.h" // art::gc::allocator::RosAlloc -#endif - -#define DEFINE_ROSALLOC_CONSTANT(macro_name, type, expr) \ - DEFINE_EXPR(ROSALLOC_ ## macro_name, type, (expr)) - -DEFINE_ROSALLOC_CONSTANT(MAX_THREAD_LOCAL_BRACKET_SIZE, int32_t, art::gc::allocator::RosAlloc::kMaxThreadLocalBracketSize) -DEFINE_ROSALLOC_CONSTANT(BRACKET_QUANTUM_SIZE_SHIFT, int32_t, art::gc::allocator::RosAlloc::kThreadLocalBracketQuantumSizeShift) -// TODO: This should be a BitUtils helper, e.g. BitMaskFromSize or something like that. -DEFINE_ROSALLOC_CONSTANT(BRACKET_QUANTUM_SIZE_MASK, int32_t, static_cast<int32_t>(art::gc::allocator::RosAlloc::kThreadLocalBracketQuantumSize - 1)) -DEFINE_ROSALLOC_CONSTANT(BRACKET_QUANTUM_SIZE_MASK_TOGGLED32,\ - uint32_t, ~static_cast<uint32_t>(art::gc::allocator::RosAlloc::kThreadLocalBracketQuantumSize - 1)) -DEFINE_ROSALLOC_CONSTANT(BRACKET_QUANTUM_SIZE_MASK_TOGGLED64,\ - uint64_t, ~static_cast<uint64_t>(art::gc::allocator::RosAlloc::kThreadLocalBracketQuantumSize - 1)) -DEFINE_ROSALLOC_CONSTANT(RUN_FREE_LIST_OFFSET, int32_t, art::gc::allocator::RosAlloc::RunFreeListOffset()) -DEFINE_ROSALLOC_CONSTANT(RUN_FREE_LIST_HEAD_OFFSET, int32_t, art::gc::allocator::RosAlloc::RunFreeListHeadOffset()) -DEFINE_ROSALLOC_CONSTANT(RUN_FREE_LIST_SIZE_OFFSET, int32_t, art::gc::allocator::RosAlloc::RunFreeListSizeOffset()) -DEFINE_ROSALLOC_CONSTANT(SLOT_NEXT_OFFSET, int32_t, art::gc::allocator::RosAlloc::RunSlotNextOffset()) - - -#undef DEFINE_ROSALLOC_CONSTANT diff --git a/tools/cpp-define-generator/constant_thread.def b/tools/cpp-define-generator/constant_thread.def deleted file mode 100644 index 1364b558ec..0000000000 --- a/tools/cpp-define-generator/constant_thread.def +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (C) 2016 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. - */ - -// Constants within thread.h. - -#if defined(DEFINE_INCLUDE_DEPENDENCIES) -#include "thread.h" // art::kSuspendRequest, etc. -#endif - -#define DEFINE_THREAD_CONSTANT(macro_name, type, expr) \ - DEFINE_EXPR(THREAD_ ## macro_name, type, (expr)) - -DEFINE_THREAD_CONSTANT(SUSPEND_REQUEST, int32_t, art::kSuspendRequest) -DEFINE_THREAD_CONSTANT(CHECKPOINT_REQUEST, int32_t, art::kCheckpointRequest) -DEFINE_THREAD_CONSTANT(EMPTY_CHECKPOINT_REQUEST, int32_t, art::kEmptyCheckpointRequest) -DEFINE_THREAD_CONSTANT(SUSPEND_OR_CHECKPOINT_REQUEST, int32_t, art::kSuspendRequest | art::kCheckpointRequest | art::kEmptyCheckpointRequest) - -#undef DEFINE_THREAD_CONSTANT diff --git a/tools/cpp-define-generator/generate-asm-support b/tools/cpp-define-generator/generate-asm-support deleted file mode 100755 index fcdf72fda9..0000000000 --- a/tools/cpp-define-generator/generate-asm-support +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash - -# Generates asm_support_gen.h -# - This must be run after a build since it uses cpp-define-generator-data - -[[ -z ${ANDROID_BUILD_TOP+x} ]] && (echo "Run source build/envsetup.sh first" >&2 && exit 1) - -cpp-define-generator-data > ${ANDROID_BUILD_TOP}/art/runtime/generated/asm_support_gen.h diff --git a/tools/cpp-define-generator/globals.def b/tools/cpp-define-generator/globals.def new file mode 100644 index 0000000000..10542622ac --- /dev/null +++ b/tools/cpp-define-generator/globals.def @@ -0,0 +1,72 @@ +/* + * Copyright (C) 2018 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#if ASM_DEFINE_INCLUDE_DEPENDENCIES +#include "base/bit_utils.h" +#include "base/callee_save_type.h" +#include "base/enums.h" +#include "base/globals.h" +#include "dex/modifiers.h" +#include "gc/accounting/card_table.h" +#include "gc/heap.h" +#include "interpreter/mterp/mterp.h" +#include "jit/jit.h" +#include "mirror/object.h" +#include "mirror/object_reference.h" +#include "runtime_globals.h" +#include "stack.h" +#endif + +ASM_DEFINE(ACCESS_FLAGS_CLASS_IS_FINALIZABLE, + art::kAccClassIsFinalizable) +ASM_DEFINE(ACCESS_FLAGS_CLASS_IS_FINALIZABLE_BIT, + art::MostSignificantBit(art::kAccClassIsFinalizable)) +ASM_DEFINE(ACCESS_FLAGS_CLASS_IS_INTERFACE, + art::kAccInterface) +ASM_DEFINE(ACC_OBSOLETE_METHOD, + art::kAccObsoleteMethod) +ASM_DEFINE(ACC_OBSOLETE_METHOD_SHIFT, + art::WhichPowerOf2(art::kAccObsoleteMethod)) +ASM_DEFINE(CARD_TABLE_CARD_SHIFT, + art::gc::accounting::CardTable::kCardShift) +ASM_DEFINE(COMPRESSED_REFERENCE_SIZE, + sizeof(art::mirror::CompressedReference<art::mirror::Object>)) +ASM_DEFINE(COMPRESSED_REFERENCE_SIZE_SHIFT, + art::WhichPowerOf2(sizeof(art::mirror::CompressedReference<art::mirror::Object>))) +ASM_DEFINE(JIT_CHECK_OSR, + art::jit::kJitCheckForOSR) +ASM_DEFINE(JIT_HOTNESS_DISABLE, + art::jit::kJitHotnessDisabled) +ASM_DEFINE(MIN_LARGE_OBJECT_THRESHOLD, + art::gc::Heap::kMinLargeObjectThreshold) +ASM_DEFINE(MTERP_HANDLER_SIZE, + art::interpreter::kMterpHandlerSize) +ASM_DEFINE(MTERP_HANDLER_SIZE_LOG2, + art::WhichPowerOf2(art::interpreter::kMterpHandlerSize)) +ASM_DEFINE(OBJECT_ALIGNMENT_MASK, + art::kObjectAlignment - 1) +ASM_DEFINE(OBJECT_ALIGNMENT_MASK_TOGGLED, + ~static_cast<uint32_t>(art::kObjectAlignment - 1)) +ASM_DEFINE(OBJECT_ALIGNMENT_MASK_TOGGLED64, + ~static_cast<uint64_t>(art::kObjectAlignment - 1)) +ASM_DEFINE(POINTER_SIZE, + static_cast<size_t>(art::kRuntimePointerSize)) +ASM_DEFINE(POINTER_SIZE_SHIFT, + art::WhichPowerOf2(static_cast<size_t>(art::kRuntimePointerSize))) +ASM_DEFINE(STACK_REFERENCE_SIZE, + sizeof(art::StackReference<art::mirror::Object>)) +ASM_DEFINE(STD_MEMORY_ORDER_RELAXED, + std::memory_order_relaxed) diff --git a/tools/cpp-define-generator/lockword.def b/tools/cpp-define-generator/lockword.def new file mode 100644 index 0000000000..a170c15f8b --- /dev/null +++ b/tools/cpp-define-generator/lockword.def @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2018 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#if ASM_DEFINE_INCLUDE_DEPENDENCIES +#include "lock_word.h" +#endif + +ASM_DEFINE(LOCK_WORD_GC_STATE_MASK_SHIFTED, + art::LockWord::kGCStateMaskShifted) +ASM_DEFINE(LOCK_WORD_GC_STATE_MASK_SHIFTED_TOGGLED, + art::LockWord::kGCStateMaskShiftedToggled) +ASM_DEFINE(LOCK_WORD_GC_STATE_SHIFT, + art::LockWord::kGCStateShift) +ASM_DEFINE(LOCK_WORD_GC_STATE_SIZE, + art::LockWord::kGCStateSize) +ASM_DEFINE(LOCK_WORD_MARK_BIT_MASK_SHIFTED, + art::LockWord::kMarkBitStateMaskShifted) +ASM_DEFINE(LOCK_WORD_MARK_BIT_SHIFT, + art::LockWord::kMarkBitStateShift) +ASM_DEFINE(LOCK_WORD_READ_BARRIER_STATE_MASK, + art::LockWord::kReadBarrierStateMaskShifted) +ASM_DEFINE(LOCK_WORD_READ_BARRIER_STATE_MASK_TOGGLED, + art::LockWord::kReadBarrierStateMaskShiftedToggled) +ASM_DEFINE(LOCK_WORD_READ_BARRIER_STATE_SHIFT, + art::LockWord::kReadBarrierStateShift) +ASM_DEFINE(LOCK_WORD_STATE_FORWARDING_ADDRESS, + art::LockWord::kStateForwardingAddress) +ASM_DEFINE(LOCK_WORD_STATE_FORWARDING_ADDRESS_OVERFLOW, + art::LockWord::kStateForwardingAddressOverflow) +ASM_DEFINE(LOCK_WORD_STATE_FORWARDING_ADDRESS_SHIFT, + art::LockWord::kForwardingAddressShift) +ASM_DEFINE(LOCK_WORD_STATE_MASK_SHIFTED, + art::LockWord::kStateMaskShifted) +ASM_DEFINE(LOCK_WORD_STATE_SHIFT, + art::LockWord::kStateShift) +ASM_DEFINE(LOCK_WORD_THIN_LOCK_COUNT_MASK_SHIFTED, + art::LockWord::kThinLockCountMaskShifted) +ASM_DEFINE(LOCK_WORD_THIN_LOCK_COUNT_ONE, + art::LockWord::kThinLockCountOne) +ASM_DEFINE(LOCK_WORD_THIN_LOCK_COUNT_SHIFT, + art::LockWord::kThinLockCountShift) +ASM_DEFINE(LOCK_WORD_THIN_LOCK_COUNT_SIZE, + art::LockWord::kThinLockCountSize) +ASM_DEFINE(LOCK_WORD_THIN_LOCK_OWNER_MASK_SHIFTED, + art::LockWord::kThinLockOwnerMaskShifted) diff --git a/tools/cpp-define-generator/main.cc b/tools/cpp-define-generator/main.cc deleted file mode 100644 index 7c515be12f..0000000000 --- a/tools/cpp-define-generator/main.cc +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Copyright (C) 2016 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 <algorithm> -#include <ios> -#include <iostream> -#include <sstream> -#include <string> -#include <type_traits> - -// Art Offset file dependencies -#define DEFINE_INCLUDE_DEPENDENCIES -#include "offsets_all.def" - -std::string to_upper(std::string input) { - std::transform(input.begin(), input.end(), input.begin(), ::toupper); - return input; -} - -template <typename T, typename = void> -typename std::enable_if<!std::is_signed<T>::value, std::string>::type -pretty_format(T value) { - // Print most values as hex. - std::stringstream ss; - ss << std::showbase << std::hex << value; - return ss.str(); -} - -template <typename T, typename = void> -typename std::enable_if<std::is_signed<T>::value, std::string>::type -pretty_format(T value) { - // Print "signed" values as decimal so that the negativity doesn't get lost. - std::stringstream ss; - - // For negative values add a (). Omit it from positive values for conciseness. - if (value < 0) { - ss << "("; - } - - ss << value; - - if (value < 0) { - ss << ")"; - } - return ss.str(); -} - -template <typename T> -void cpp_define(const std::string& name, T value) { - std::cout << "#define " << name << " " << pretty_format(value) << std::endl; -} - -template <typename T> -void emit_check_eq(T value, const std::string& expr) { - std::cout << "DEFINE_CHECK_EQ(" << value << ", (" << expr << "))" << std::endl; -} - -const char *kFileHeader = /* // NOLINT [readability/multiline_string] [5] */ R"L1C3NS3( -/* - * Copyright (C) 2016 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ART_RUNTIME_GENERATED_ASM_SUPPORT_GEN_H_ -#define ART_RUNTIME_GENERATED_ASM_SUPPORT_GEN_H_ - -// This file has been auto-generated by cpp-define-generator; do not edit directly. -)L1C3NS3"; // NOLINT [readability/multiline_string] [5] - -const char *kFileFooter = /* // NOLINT [readability/multiline_string] [5] */ R"F00T3R( -#endif // ART_RUNTIME_GENERATED_ASM_SUPPORT_GEN_H_ -)F00T3R"; // NOLINT [readability/multiline_string] [5] - -#define MACROIZE(holder_type, field_name) to_upper(#holder_type "_" #field_name "_OFFSET") - -int main() { - std::cout << kFileHeader << std::endl; - - std::string z = ""; - - // Print every constant expression to stdout as a #define or a CHECK_EQ -#define DEFINE_EXPR(macro_name, field_type, expr) \ - cpp_define(to_upper(#macro_name), static_cast<field_type>(expr)); \ - emit_check_eq(z + "static_cast<" #field_type ">(" + to_upper(#macro_name) + ")", \ - "static_cast<" #field_type ">(" #expr ")"); -#include "offsets_all.def" - - std::cout << kFileFooter << std::endl; - return 0; -} diff --git a/tools/cpp-define-generator/make_header.py b/tools/cpp-define-generator/make_header.py new file mode 100755 index 0000000000..1b13923b50 --- /dev/null +++ b/tools/cpp-define-generator/make_header.py @@ -0,0 +1,56 @@ +#!/usr/bin/env python +# +# Copyright (C) 2018 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# This script looks through compiled object file (stored human readable text), +# and looks for the compile-time constants (added through custom "asm" block). +# For example: .ascii ">>OBJECT_ALIGNMENT_MASK $7 $0<<" +# +# It will transform each such line to #define which is usabe in assembly code. +# For example: #define OBJECT_ALIGNMENT_MASK 0x7 +# +# Usage: make_header.py out/soong/.intermediates/.../asm_defines.o +# + +import argparse +import re +import sys + +def convert(input): + """Find all defines in the compiler generated assembly and convert them to #define pragmas""" + + asm_define_re = re.compile(r'">>(\w+) (?:\$|#)([-0-9]+) (?:\$|#)(0|1)<<"') + asm_defines = asm_define_re.findall(input) + if not asm_defines: + raise RuntimeError("Failed to find any asm defines in the input") + + # Convert the found constants to #define pragmas. + # In case the C++ compiler decides to reorder the AsmDefinesFor_${name} functions, + # we don't want the order of the .h file to change from one compilation to another. + # Sorting ensures deterministic order of the #defines. + output = [] + for name, value, negative_value in sorted(asm_defines): + value = int(value) + if value < 0 and negative_value == "0": + # Overflow - uint64_t constant was pretty printed as negative value. + value += 2 ** 64 # Python will use arbitrary precision arithmetic. + output.append("#define {0} {1:#x}".format(name, value)) + return "\n".join(output) + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument('input', help="Object file as text") + args = parser.parse_args() + print(convert(open(args.input, "r").read())) diff --git a/tools/cpp-define-generator/make_header_test.py b/tools/cpp-define-generator/make_header_test.py new file mode 100755 index 0000000000..a484285e5c --- /dev/null +++ b/tools/cpp-define-generator/make_header_test.py @@ -0,0 +1,49 @@ +#!/usr/bin/env python +# +# Copyright (C) 2018 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import unittest +import make_header + +test_input = r''' +// Check that the various other assembly lines are ignored. +.globl _Z49AsmDefineHelperFor_MIRROR_OBJECT_LOCK_WORD_OFFSETv +.type _Z49AsmDefineHelperFor_MIRROR_OBJECT_LOCK_WORD_OFFSETv,%function +.ascii ">>MIRROR_OBJECT_LOCK_WORD_OFFSET #4 #0<<" +bx lr + +// Check large positive 32-bit constant. +.ascii ">>OBJECT_ALIGNMENT_MASK_TOGGLED #4294967288 #0<<" + +// Check large positive 64-bit constant (it overflows into negative value). +.ascii ">>OBJECT_ALIGNMENT_MASK_TOGGLED64 #-8 #0<<" + +// Check negative constant. +.ascii ">>JIT_CHECK_OSR #-1 #1<<" +''' + +test_output = r''' +#define JIT_CHECK_OSR -0x1 +#define MIRROR_OBJECT_LOCK_WORD_OFFSET 0x4 +#define OBJECT_ALIGNMENT_MASK_TOGGLED 0xfffffff8 +#define OBJECT_ALIGNMENT_MASK_TOGGLED64 0xfffffffffffffff8 +''' + +class CppDefineGeneratorTest(unittest.TestCase): + def test_convert(self): + self.assertEqual(test_output.strip(), make_header.convert(test_input)) + +if __name__ == '__main__': + unittest.main() diff --git a/tools/cpp-define-generator/mirror_array.def b/tools/cpp-define-generator/mirror_array.def new file mode 100644 index 0000000000..f600b41237 --- /dev/null +++ b/tools/cpp-define-generator/mirror_array.def @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2018 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#if ASM_DEFINE_INCLUDE_DEPENDENCIES +#include "mirror/array.h" +#endif + +ASM_DEFINE(MIRROR_ARRAY_LENGTH_OFFSET, + art::mirror::Array::LengthOffset().Int32Value()) +ASM_DEFINE(MIRROR_BOOLEAN_ARRAY_DATA_OFFSET, + art::mirror::Array::DataOffset(sizeof(uint8_t)).Int32Value()) +ASM_DEFINE(MIRROR_BYTE_ARRAY_DATA_OFFSET, + art::mirror::Array::DataOffset(sizeof(int8_t)).Int32Value()) +ASM_DEFINE(MIRROR_CHAR_ARRAY_DATA_OFFSET, + art::mirror::Array::DataOffset(sizeof(uint16_t)).Int32Value()) +ASM_DEFINE(MIRROR_INT_ARRAY_DATA_OFFSET, + art::mirror::Array::DataOffset(sizeof(int32_t)).Int32Value()) +ASM_DEFINE(MIRROR_LONG_ARRAY_DATA_OFFSET, + art::mirror::Array::DataOffset(sizeof(uint64_t)).Int32Value()) +ASM_DEFINE(MIRROR_OBJECT_ARRAY_COMPONENT_SIZE, + sizeof(art::mirror::HeapReference<art::mirror::Object>)) +ASM_DEFINE(MIRROR_OBJECT_ARRAY_DATA_OFFSET, + art::mirror::Array::DataOffset(sizeof(art::mirror::HeapReference<art::mirror::Object>)).Int32Value()) +ASM_DEFINE(MIRROR_SHORT_ARRAY_DATA_OFFSET, + art::mirror::Array::DataOffset(sizeof(int16_t)).Int32Value()) +ASM_DEFINE(MIRROR_WIDE_ARRAY_DATA_OFFSET, + art::mirror::Array::DataOffset(sizeof(uint64_t)).Int32Value()) diff --git a/tools/cpp-define-generator/mirror_class.def b/tools/cpp-define-generator/mirror_class.def new file mode 100644 index 0000000000..c15ae92ece --- /dev/null +++ b/tools/cpp-define-generator/mirror_class.def @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2018 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#if ASM_DEFINE_INCLUDE_DEPENDENCIES +#include "mirror/class.h" +#endif + +ASM_DEFINE(MIRROR_CLASS_ACCESS_FLAGS_OFFSET, + art::mirror::Class::AccessFlagsOffset().Int32Value()) +ASM_DEFINE(MIRROR_CLASS_COMPONENT_TYPE_OFFSET, + art::mirror::Class::ComponentTypeOffset().Int32Value()) +ASM_DEFINE(MIRROR_CLASS_DEX_CACHE_OFFSET, + art::mirror::Class::DexCacheOffset().Int32Value()) +ASM_DEFINE(MIRROR_CLASS_IF_TABLE_OFFSET, + art::mirror::Class::IfTableOffset().Int32Value()) +ASM_DEFINE(MIRROR_CLASS_OBJECT_PRIMITIVE_TYPE_OFFSET, + art::mirror::Class::PrimitiveTypeOffset().Int32Value()) +ASM_DEFINE(MIRROR_CLASS_OBJECT_SIZE_ALLOC_FAST_PATH_OFFSET, + art::mirror::Class::ObjectSizeAllocFastPathOffset().Int32Value()) +ASM_DEFINE(MIRROR_CLASS_OBJECT_SIZE_OFFSET, + art::mirror::Class::ObjectSizeOffset().Int32Value()) +ASM_DEFINE(MIRROR_CLASS_STATUS_OFFSET, + art::mirror::Class::StatusOffset().Int32Value()) +ASM_DEFINE(PRIMITIVE_TYPE_SIZE_SHIFT_SHIFT, + art::mirror::Class::kPrimitiveTypeSizeShiftShift) diff --git a/tools/cpp-define-generator/mirror_dex_cache.def b/tools/cpp-define-generator/mirror_dex_cache.def new file mode 100644 index 0000000000..5272e86846 --- /dev/null +++ b/tools/cpp-define-generator/mirror_dex_cache.def @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2018 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#if ASM_DEFINE_INCLUDE_DEPENDENCIES +#include "mirror/dex_cache.h" +#endif + +ASM_DEFINE(METHOD_DEX_CACHE_SIZE_MINUS_ONE, + art::mirror::DexCache::kDexCacheMethodCacheSize - 1) +ASM_DEFINE(MIRROR_DEX_CACHE_RESOLVED_METHODS_OFFSET, + art::mirror::DexCache::ResolvedMethodsOffset().Int32Value()) +ASM_DEFINE(STRING_DEX_CACHE_ELEMENT_SIZE, + sizeof(art::mirror::StringDexCachePair)) +ASM_DEFINE(STRING_DEX_CACHE_ELEMENT_SIZE_SHIFT, + art::WhichPowerOf2(sizeof(art::mirror::StringDexCachePair))) +ASM_DEFINE(STRING_DEX_CACHE_HASH_BITS, + art::LeastSignificantBit(art::mirror::DexCache::kDexCacheStringCacheSize)) +ASM_DEFINE(STRING_DEX_CACHE_SIZE_MINUS_ONE, + art::mirror::DexCache::kDexCacheStringCacheSize - 1) +ASM_DEFINE(METHOD_DEX_CACHE_HASH_BITS, + art::LeastSignificantBit(art::mirror::DexCache::kDexCacheMethodCacheSize)) diff --git a/tools/cpp-define-generator/common.def b/tools/cpp-define-generator/mirror_object.def index 76c64c97c2..facb037c97 100644 --- a/tools/cpp-define-generator/common.def +++ b/tools/cpp-define-generator/mirror_object.def @@ -1,5 +1,5 @@ /* - * Copyright (C) 2016 The Android Open Source Project + * Copyright (C) 2018 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,11 +14,13 @@ * limitations under the License. */ -// Convenience macro to define an offset expression. - -#ifndef DEFINE_OFFSET_EXPR -#define DEFINE_OFFSET_EXPR(holder_type, field_name, field_type, expr) \ - DEFINE_EXPR(holder_type ## _ ## field_name ## _OFFSET, field_type, expr) -#define DEFINE_OFFSET_EXPR_STANDARD_DEFINITION +#if ASM_DEFINE_INCLUDE_DEPENDENCIES +#include "mirror/object.h" #endif +ASM_DEFINE(MIRROR_OBJECT_CLASS_OFFSET, + art::mirror::Object::ClassOffset().Int32Value()) +ASM_DEFINE(MIRROR_OBJECT_HEADER_SIZE, + sizeof(art::mirror::Object)) +ASM_DEFINE(MIRROR_OBJECT_LOCK_WORD_OFFSET, + art::mirror::Object::MonitorOffset().Int32Value()) diff --git a/tools/cpp-define-generator/constant_card_table.def b/tools/cpp-define-generator/mirror_string.def index ae3e8f399f..3632b96d5c 100644 --- a/tools/cpp-define-generator/constant_card_table.def +++ b/tools/cpp-define-generator/mirror_string.def @@ -1,5 +1,5 @@ /* - * Copyright (C) 2017 The Android Open Source Project + * Copyright (C) 2018 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,12 +14,13 @@ * limitations under the License. */ -// Export heap values. - -#if defined(DEFINE_INCLUDE_DEPENDENCIES) -#include "gc/accounting/card_table.h" +#if ASM_DEFINE_INCLUDE_DEPENDENCIES +#include "mirror/string.h" #endif -// Size of references to the heap on the stack. -DEFINE_EXPR(CARD_TABLE_CARD_SHIFT, size_t, art::gc::accounting::CardTable::kCardShift) - +ASM_DEFINE(MIRROR_STRING_COUNT_OFFSET, + art::mirror::String::CountOffset().Int32Value()) +ASM_DEFINE(MIRROR_STRING_VALUE_OFFSET, + art::mirror::String::ValueOffset().Int32Value()) +ASM_DEFINE(STRING_COMPRESSION_FEATURE, + art::mirror::kUseStringCompression) diff --git a/tools/cpp-define-generator/offset_art_method.def b/tools/cpp-define-generator/offset_art_method.def deleted file mode 100644 index e6a0907759..0000000000 --- a/tools/cpp-define-generator/offset_art_method.def +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (C) 2016 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. - */ - -// Offsets within art::ArtMethod. - -#if defined(DEFINE_INCLUDE_DEPENDENCIES) -#include "art_method.h" // art::ArtMethod -#include "base/enums.h" // PointerSize -#include "mirror/dex_cache.h" // art::DexCache -#endif - -#define DEFINE_ART_METHOD_OFFSET_SIZED(field_name, method_name) \ - DEFINE_EXPR(ART_METHOD_ ## field_name ## _OFFSET_32, int32_t, art::ArtMethod::method_name##Offset(art::PointerSize::k32).Int32Value()) \ - DEFINE_EXPR(ART_METHOD_ ## field_name ## _OFFSET_64, int32_t, art::ArtMethod::method_name##Offset(art::PointerSize::k64).Int32Value()) - -#define DEFINE_ART_METHOD_OFFSET(field_name, method_name) \ - DEFINE_EXPR(ART_METHOD_ ## field_name ## _OFFSET, int32_t, art::ArtMethod::method_name##Offset().Int32Value()) - -#define DEFINE_DECLARING_CLASS_OFFSET(field_name, method_name) \ - DEFINE_EXPR(DECLARING_CLASS_ ## field_name ## _OFFSET, int32_t, art::mirror::Class::method_name##Offset().Int32Value()) - -// New macro suffix Method Name (of the Offset method) -DEFINE_ART_METHOD_OFFSET_SIZED(JNI, EntryPointFromJni) -DEFINE_ART_METHOD_OFFSET_SIZED(QUICK_CODE, EntryPointFromQuickCompiledCode) -DEFINE_ART_METHOD_OFFSET(DECLARING_CLASS, DeclaringClass) -DEFINE_ART_METHOD_OFFSET(ACCESS_FLAGS, AccessFlags) - -#undef DEFINE_ART_METHOD_OFFSET -#undef DEFINE_ART_METHOD_OFFSET_32 -#undef DEFINE_DECLARING_CLASS_OFFSET diff --git a/tools/cpp-define-generator/offset_mirror_class.def b/tools/cpp-define-generator/offset_mirror_class.def deleted file mode 100644 index 9b7bfce0c0..0000000000 --- a/tools/cpp-define-generator/offset_mirror_class.def +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (C) 2017 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. - */ - -// Offsets within java.lang.Class (mirror::Class). - -#if defined(DEFINE_INCLUDE_DEPENDENCIES) -#include "mirror/class.h" // art::mirror::Object -#endif - -#include "common.def" // DEFINE_OFFSET_EXPR - -#define DEFINE_MIRROR_CLASS_OFFSET(field_name, method_name) \ - DEFINE_OFFSET_EXPR(MIRROR_CLASS, field_name, int32_t, art::mirror::Class::method_name##Offset().Int32Value()) - -// New macro suffix Method Name (of the Offset method) -DEFINE_MIRROR_CLASS_OFFSET(DEX_CACHE, DexCache) - -#undef DEFINE_MIRROR_CLASS_OFFSET -#include "common_undef.def" // undef DEFINE_OFFSET_EXPR diff --git a/tools/cpp-define-generator/offset_mirror_dex_cache.def b/tools/cpp-define-generator/offset_mirror_dex_cache.def deleted file mode 100644 index 8f008bb631..0000000000 --- a/tools/cpp-define-generator/offset_mirror_dex_cache.def +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (C) 2017 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. - */ - -// Offsets within java.lang.DexCache (mirror::DexCache). - -#if defined(DEFINE_INCLUDE_DEPENDENCIES) -#include "mirror/class.h" // art::mirror::Object -#endif - -#include "common.def" // DEFINE_OFFSET_EXPR - -#define DEFINE_MIRROR_DEX_CACHE_OFFSET(field_name, method_name) \ - DEFINE_OFFSET_EXPR(MIRROR_DEX_CACHE, field_name, int32_t, art::mirror::DexCache::method_name##Offset().Int32Value()) - -// New macro suffix Method Name (of the Offset method) -DEFINE_MIRROR_DEX_CACHE_OFFSET(RESOLVED_METHODS, ResolvedMethods) - -#undef DEFINE_MIRROR_CLASS_OFFSET -#include "common_undef.def" // undef DEFINE_OFFSET_EXPR diff --git a/tools/cpp-define-generator/offset_mirror_object.def b/tools/cpp-define-generator/offset_mirror_object.def deleted file mode 100644 index 9b99634e6e..0000000000 --- a/tools/cpp-define-generator/offset_mirror_object.def +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (C) 2016 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. - */ - -// Offsets within java.lang.Object (mirror::Object). - -#if defined(DEFINE_INCLUDE_DEPENDENCIES) -#include "mirror/object.h" // art::mirror::Object -#endif - -#include "common.def" // DEFINE_OFFSET_EXPR - -#define DEFINE_MIRROR_OBJECT_OFFSET(field_name, method_name) \ - DEFINE_OFFSET_EXPR(MIRROR_OBJECT, field_name, int32_t, art::mirror::Object::method_name##Offset().Int32Value()) - -// New macro suffix Method Name (of the Offset method) -DEFINE_MIRROR_OBJECT_OFFSET(CLASS, Class) -DEFINE_MIRROR_OBJECT_OFFSET(LOCK_WORD, Monitor) - -#undef DEFINE_MIRROR_OBJECT_OFFSET -#include "common_undef.def" // undef DEFINE_OFFSET_EXPR diff --git a/tools/cpp-define-generator/offset_runtime.def b/tools/cpp-define-generator/offset_runtime.def deleted file mode 100644 index 1d5ce7dd49..0000000000 --- a/tools/cpp-define-generator/offset_runtime.def +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (C) 2016 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. - */ - -// Offsets within ShadowFrame. - -#if defined(DEFINE_INCLUDE_DEPENDENCIES) -#include "base/callee_save_type.h" // art::CalleeSaveType -#include "runtime.h" // art::Runtime -#endif - -#include "common.def" // DEFINE_OFFSET_EXPR - -// Note: these callee save methods loads require read barriers. - -#define DEFINE_RUNTIME_CALLEE_SAVE_OFFSET(field_name, constant_name) \ - DEFINE_OFFSET_EXPR(Runtime, \ - field_name ## _METHOD, \ - size_t, \ - art::Runtime::GetCalleeSaveMethodOffset(constant_name)) - - // Macro substring Constant name -// Offset of field Runtime::callee_save_methods_[kSaveAllCalleeSaves] -DEFINE_RUNTIME_CALLEE_SAVE_OFFSET(SAVE_ALL_CALLEE_SAVES, art::CalleeSaveType::kSaveAllCalleeSaves) -// Offset of field Runtime::callee_save_methods_[kSaveRefsOnly] -DEFINE_RUNTIME_CALLEE_SAVE_OFFSET(SAVE_REFS_ONLY, art::CalleeSaveType::kSaveRefsOnly) -// Offset of field Runtime::callee_save_methods_[kSaveRefsAndArgs] -DEFINE_RUNTIME_CALLEE_SAVE_OFFSET(SAVE_REFS_AND_ARGS, art::CalleeSaveType::kSaveRefsAndArgs) -// Offset of field Runtime::callee_save_methods_[kSaveEverything] -DEFINE_RUNTIME_CALLEE_SAVE_OFFSET(SAVE_EVERYTHING, art::CalleeSaveType::kSaveEverything) -// Offset of field Runtime::callee_save_methods_[kSaveEverythingForClinit] -DEFINE_RUNTIME_CALLEE_SAVE_OFFSET(SAVE_EVERYTHING_FOR_CLINIT, art::CalleeSaveType::kSaveEverythingForClinit) -// Offset of field Runtime::callee_save_methods_[kSaveEverythingForSuspendCheck] -DEFINE_RUNTIME_CALLEE_SAVE_OFFSET(SAVE_EVERYTHING_FOR_SUSPEND_CHECK, art::CalleeSaveType::kSaveEverythingForSuspendCheck) - -#undef DEFINE_RUNTIME_CALLEE_SAVE_OFFSET -#include "common_undef.def" // undef DEFINE_OFFSET_EXPR diff --git a/tools/cpp-define-generator/offset_shadow_frame.def b/tools/cpp-define-generator/offset_shadow_frame.def deleted file mode 100644 index b49a3400d3..0000000000 --- a/tools/cpp-define-generator/offset_shadow_frame.def +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (C) 2016 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. - */ - -// Offsets within ShadowFrame. - -#if defined(DEFINE_INCLUDE_DEPENDENCIES) -#include "stack.h" // art::ShadowFrame -#endif - -#include "common.def" // DEFINE_OFFSET_EXPR - -#define DEFINE_SHADOW_FRAME_OFFSET(field_name, method_name) \ - DEFINE_OFFSET_EXPR(ShadowFrame, field_name, int32_t, art::ShadowFrame::method_name##Offset()) - -// New macro suffix Method Name (of the Offset method) -DEFINE_SHADOW_FRAME_OFFSET(LINK, Link) -DEFINE_SHADOW_FRAME_OFFSET(METHOD, Method) -DEFINE_SHADOW_FRAME_OFFSET(RESULT_REGISTER, ResultRegister) -DEFINE_SHADOW_FRAME_OFFSET(DEX_PC_PTR, DexPCPtr) -DEFINE_SHADOW_FRAME_OFFSET(CODE_ITEM, CodeItem) -DEFINE_SHADOW_FRAME_OFFSET(LOCK_COUNT_DATA, LockCountData) -DEFINE_SHADOW_FRAME_OFFSET(NUMBER_OF_VREGS, NumberOfVRegs) -DEFINE_SHADOW_FRAME_OFFSET(DEX_PC, DexPC) -DEFINE_SHADOW_FRAME_OFFSET(CACHED_HOTNESS_COUNTDOWN, CachedHotnessCountdown) -DEFINE_SHADOW_FRAME_OFFSET(VREGS, VRegs) - -#undef DEFINE_SHADOW_FRAME_OFFSET -#include "common_undef.def" // undef DEFINE_OFFSET_EXPR diff --git a/tools/cpp-define-generator/offset_thread.def b/tools/cpp-define-generator/offset_thread.def deleted file mode 100644 index 6f94d38870..0000000000 --- a/tools/cpp-define-generator/offset_thread.def +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (C) 2016 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. - */ - -// Offsets within ShadowFrame. - -#if defined(DEFINE_INCLUDE_DEPENDENCIES) -#include "base/enums.h" // PointerSize -#include "stack.h" // art::ShadowFrame -#endif - -#include "common.def" // DEFINE_OFFSET_EXPR - -#define DEFINE_THREAD_OFFSET(field_name, method_name) \ - DEFINE_OFFSET_EXPR(Thread, field_name, int32_t, art::Thread::method_name##Offset<art::kRuntimePointerSize>().Int32Value()) - -// New macro suffix Method Name (of the Offset method) -DEFINE_THREAD_OFFSET(FLAGS, ThreadFlags) -DEFINE_THREAD_OFFSET(ID, ThinLockId) -DEFINE_THREAD_OFFSET(IS_GC_MARKING, IsGcMarking) -DEFINE_THREAD_OFFSET(CARD_TABLE, CardTable) - -// TODO: The rest of the offsets -// are dependent on __SIZEOF_POINTER__ - -#undef DEFINE_THREAD_OFFSET - -#include "common_undef.def" // undef DEFINE_OFFSET_EXPR diff --git a/tools/cpp-define-generator/offsets_all.def b/tools/cpp-define-generator/offsets_all.def deleted file mode 100644 index 31587d8d62..0000000000 --- a/tools/cpp-define-generator/offsets_all.def +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (C) 2016 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. - */ - -// Includes every single offset file in art. -// Useful for processing every single offset together. - -// Usage: -// #define DEFINE_INCLUDE_DEPENDENCIES -// #include "offsets_all.def" -// to automatically include each def file's header dependencies. -// -// Afterwards, -// #define DEFINE_EXPR(define_name, field_type, expr) ... -// #include "offsets_all.def" -// to process each offset however one wants. -#if defined(DEFINE_INCLUDE_DEPENDENCIES) -#define DEFINE_EXPR(define_name, field_type, expr) -#endif - -#if !defined(DEFINE_EXPR) -#error "Either DEFINE_INCLUDE_DEPENDENCIES or DEFINE_EXPR must be defined" -#endif - -#include "constant_reference.def" -#include "offset_runtime.def" -// TODO: rest of THREAD_ offsets (depends on __SIZEOF__POINTER__). -#include "offset_thread.def" -// TODO: SHADOW_FRAME depends on __SIZEOF__POINTER__ -// #include "offset_shadow_frame.def" -// TODO: MIRROR_OBJECT_HEADER_SIZE (depends on #ifdef read barrier) -#include "offset_mirror_class.def" -#include "offset_mirror_dex_cache.def" -#include "offset_mirror_object.def" -#include "constant_class.def" -// TODO: MIRROR_*_ARRAY offsets (depends on header size) -// TODO: MIRROR_STRING offsets (depends on header size) -#include "offset_art_method.def" -#include "constant_dexcache.def" -#include "constant_card_table.def" -#include "constant_heap.def" -#include "constant_lockword.def" -#include "constant_globals.def" -#include "constant_rosalloc.def" -#include "constant_thread.def" -#include "constant_jit.def" - -// TODO: MIRROR_OBJECT_HEADER_SIZE #ifdef depends on read barriers -// TODO: Array offsets (depends on MIRROR_OBJECT_HEADER_SIZE) - -#if defined(DEFINE_INCLUDE_DEPENDENCIES) -#undef DEFINE_EXPR -#undef DEFINE_INCLUDE_DEPENDENCIES -#endif - - diff --git a/tools/cpp-define-generator/presubmit-check-files-up-to-date b/tools/cpp-define-generator/presubmit-check-files-up-to-date deleted file mode 100755 index 0301a3e679..0000000000 --- a/tools/cpp-define-generator/presubmit-check-files-up-to-date +++ /dev/null @@ -1,71 +0,0 @@ -#!/bin/bash -# -# Copyright (C) 2017 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. - -# --------------------------------------------------------------------------- - -# Generates asm_support_gen.h into a temporary location. -# Then verifies it is the same as our local stored copy. - -GEN_TOOL=cpp-define-generator-data - -if ! which "$GEN_TOOL"; then - if [[ -z $ANDROID_BUILD_TOP ]]; then - echo "ERROR: Can't find '$GEN_TOOL' in \$PATH. Perhaps try 'source build/envsetup.sh' ?" >&2 - else - echo "ERROR: Can't find '$GEN_TOOL' in \$PATH. Perhaps try 'make $GEN_TOOL' ?" >&2 - fi - exit 1 -fi - -####################### -####################### - -PREUPLOAD_COMMIT_COPY="$(mktemp ${TMPDIR:-/tmp}/tmp.XXXXXX)" -BUILD_COPY="$(mktemp ${TMPDIR:-/tmp}/tmp.XXXXXX)" - -function finish() { - # Delete temp files. - [[ -f "$PREUPLOAD_COMMIT_COPY" ]] && rm "$PREUPLOAD_COMMIT_COPY" - [[ -f "$BUILD_COPY" ]] && rm "$BUILD_COPY" -} -trap finish EXIT - -DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -ART_DIR="$( cd "$DIR/../.." && pwd )" -ASM_SUPPORT_GEN_CHECKED_IN_COPY="runtime/generated/asm_support_gen.h" - -# Repo upload hook runs inside of the top-level git directory. -# If we run this script manually, be in the right place for git. -cd "$ART_DIR" - -if [[ -z $PREUPLOAD_COMMIT ]]; then - echo "WARNING: Not running as a pre-upload hook. Assuming commit to check = 'HEAD'" - PREUPLOAD_COMMIT=HEAD -fi - -# Get version we are about to push into git. -git show "$PREUPLOAD_COMMIT:$ASM_SUPPORT_GEN_CHECKED_IN_COPY" > "$PREUPLOAD_COMMIT_COPY" || exit 1 -# Get version that our build would have made. -"$GEN_TOOL" > "$BUILD_COPY" || exit 1 - -if ! diff "$PREUPLOAD_COMMIT_COPY" "$BUILD_COPY"; then - echo "asm-support: ERROR: Checked-in copy of '$ASM_SUPPORT_GEN_CHECKED_IN_COPY' " >&2 - echo " has diverged from the build copy." >&2 - echo " Please re-run the 'generate-asm-support' command to resync the header." >&2 - exit 1 -fi - -# Success. Print nothing to avoid spamming users. diff --git a/tools/cpp-define-generator/rosalloc.def b/tools/cpp-define-generator/rosalloc.def new file mode 100644 index 0000000000..eb8d8f2954 --- /dev/null +++ b/tools/cpp-define-generator/rosalloc.def @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2018 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#if ASM_DEFINE_INCLUDE_DEPENDENCIES +#include "gc/allocator/rosalloc.h" +#endif + +ASM_DEFINE(ROSALLOC_BRACKET_QUANTUM_SIZE_MASK, + art::gc::allocator::RosAlloc::kThreadLocalBracketQuantumSize - 1) +ASM_DEFINE(ROSALLOC_BRACKET_QUANTUM_SIZE_MASK_TOGGLED32, + ~static_cast<uint32_t>(art::gc::allocator::RosAlloc::kThreadLocalBracketQuantumSize - 1)) +ASM_DEFINE(ROSALLOC_BRACKET_QUANTUM_SIZE_MASK_TOGGLED64, + ~static_cast<uint64_t>(art::gc::allocator::RosAlloc::kThreadLocalBracketQuantumSize - 1)) +ASM_DEFINE(ROSALLOC_BRACKET_QUANTUM_SIZE_SHIFT, + art::gc::allocator::RosAlloc::kThreadLocalBracketQuantumSizeShift) +ASM_DEFINE(ROSALLOC_MAX_THREAD_LOCAL_BRACKET_SIZE, + art::gc::allocator::RosAlloc::kMaxThreadLocalBracketSize) +ASM_DEFINE(ROSALLOC_RUN_FREE_LIST_HEAD_OFFSET, + art::gc::allocator::RosAlloc::RunFreeListHeadOffset()) +ASM_DEFINE(ROSALLOC_RUN_FREE_LIST_OFFSET, + art::gc::allocator::RosAlloc::RunFreeListOffset()) +ASM_DEFINE(ROSALLOC_RUN_FREE_LIST_SIZE_OFFSET, + art::gc::allocator::RosAlloc::RunFreeListSizeOffset()) +ASM_DEFINE(ROSALLOC_SLOT_NEXT_OFFSET, + art::gc::allocator::RosAlloc::RunSlotNextOffset()) diff --git a/tools/cpp-define-generator/runtime.def b/tools/cpp-define-generator/runtime.def new file mode 100644 index 0000000000..2a2e303ba2 --- /dev/null +++ b/tools/cpp-define-generator/runtime.def @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2018 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#if ASM_DEFINE_INCLUDE_DEPENDENCIES +#include "runtime.h" +#endif + +ASM_DEFINE(RUNTIME_SAVE_ALL_CALLEE_SAVES_METHOD_OFFSET, + art::Runtime::GetCalleeSaveMethodOffset(art::CalleeSaveType::kSaveAllCalleeSaves)) +ASM_DEFINE(RUNTIME_SAVE_EVERYTHING_FOR_CLINIT_METHOD_OFFSET, + art::Runtime::GetCalleeSaveMethodOffset(art::CalleeSaveType::kSaveEverythingForClinit)) +ASM_DEFINE(RUNTIME_SAVE_EVERYTHING_FOR_SUSPEND_CHECK_METHOD_OFFSET, + art::Runtime::GetCalleeSaveMethodOffset(art::CalleeSaveType::kSaveEverythingForSuspendCheck)) +ASM_DEFINE(RUNTIME_SAVE_EVERYTHING_METHOD_OFFSET, + art::Runtime::GetCalleeSaveMethodOffset(art::CalleeSaveType::kSaveEverything)) +ASM_DEFINE(RUNTIME_SAVE_REFS_AND_ARGS_METHOD_OFFSET, + art::Runtime::GetCalleeSaveMethodOffset(art::CalleeSaveType::kSaveRefsAndArgs)) +ASM_DEFINE(RUNTIME_SAVE_REFS_ONLY_METHOD_OFFSET, + art::Runtime::GetCalleeSaveMethodOffset(art::CalleeSaveType::kSaveRefsOnly)) diff --git a/tools/cpp-define-generator/shadow_frame.def b/tools/cpp-define-generator/shadow_frame.def new file mode 100644 index 0000000000..10a309cbdb --- /dev/null +++ b/tools/cpp-define-generator/shadow_frame.def @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2018 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#if ASM_DEFINE_INCLUDE_DEPENDENCIES +#include "interpreter/shadow_frame.h" +#endif + +ASM_DEFINE(SHADOWFRAME_CACHED_HOTNESS_COUNTDOWN_OFFSET, + art::ShadowFrame::CachedHotnessCountdownOffset()) +ASM_DEFINE(SHADOWFRAME_DEX_INSTRUCTIONS_OFFSET, + art::ShadowFrame::DexInstructionsOffset()) +ASM_DEFINE(SHADOWFRAME_DEX_PC_OFFSET, + art::ShadowFrame::DexPCOffset()) +ASM_DEFINE(SHADOWFRAME_DEX_PC_PTR_OFFSET, + art::ShadowFrame::DexPCPtrOffset()) +ASM_DEFINE(SHADOWFRAME_HOTNESS_COUNTDOWN_OFFSET, + art::ShadowFrame::HotnessCountdownOffset()) +ASM_DEFINE(SHADOWFRAME_LINK_OFFSET, + art::ShadowFrame::LinkOffset()) +ASM_DEFINE(SHADOWFRAME_LOCK_COUNT_DATA_OFFSET, + art::ShadowFrame::LockCountDataOffset()) +ASM_DEFINE(SHADOWFRAME_METHOD_OFFSET, + art::ShadowFrame::MethodOffset()) +ASM_DEFINE(SHADOWFRAME_NUMBER_OF_VREGS_OFFSET, + art::ShadowFrame::NumberOfVRegsOffset()) +ASM_DEFINE(SHADOWFRAME_RESULT_REGISTER_OFFSET, + art::ShadowFrame::ResultRegisterOffset()) +ASM_DEFINE(SHADOWFRAME_VREGS_OFFSET, + art::ShadowFrame::VRegsOffset()) diff --git a/tools/cpp-define-generator/thread.def b/tools/cpp-define-generator/thread.def new file mode 100644 index 0000000000..8c91dc8a87 --- /dev/null +++ b/tools/cpp-define-generator/thread.def @@ -0,0 +1,62 @@ +/* + * Copyright (C) 2018 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#if ASM_DEFINE_INCLUDE_DEPENDENCIES +#include "thread.h" +#endif + +ASM_DEFINE(THREAD_CARD_TABLE_OFFSET, + art::Thread::CardTableOffset<art::kRuntimePointerSize>().Int32Value()) +ASM_DEFINE(THREAD_CHECKPOINT_REQUEST, + art::kCheckpointRequest) +ASM_DEFINE(THREAD_CURRENT_IBASE_OFFSET, + art::Thread::MterpCurrentIBaseOffset<art::kRuntimePointerSize>().Int32Value()) +ASM_DEFINE(THREAD_EMPTY_CHECKPOINT_REQUEST, + art::kEmptyCheckpointRequest) +ASM_DEFINE(THREAD_EXCEPTION_OFFSET, + art::Thread::ExceptionOffset<art::kRuntimePointerSize>().Int32Value()) +ASM_DEFINE(THREAD_FLAGS_OFFSET, + art::Thread::ThreadFlagsOffset<art::kRuntimePointerSize>().Int32Value()) +ASM_DEFINE(THREAD_ID_OFFSET, + art::Thread::ThinLockIdOffset<art::kRuntimePointerSize>().Int32Value()) +ASM_DEFINE(THREAD_INTERPRETER_CACHE_OFFSET, + art::Thread::InterpreterCacheOffset<art::kRuntimePointerSize>().Int32Value()) +ASM_DEFINE(THREAD_INTERPRETER_CACHE_SIZE_LOG2, + art::Thread::InterpreterCacheSizeLog2()) +ASM_DEFINE(THREAD_IS_GC_MARKING_OFFSET, + art::Thread::IsGcMarkingOffset<art::kRuntimePointerSize>().Int32Value()) +ASM_DEFINE(THREAD_LOCAL_ALLOC_STACK_END_OFFSET, + art::Thread::ThreadLocalAllocStackEndOffset<art::kRuntimePointerSize>().Int32Value()) +ASM_DEFINE(THREAD_LOCAL_ALLOC_STACK_TOP_OFFSET, + art::Thread::ThreadLocalAllocStackTopOffset<art::kRuntimePointerSize>().Int32Value()) +ASM_DEFINE(THREAD_LOCAL_END_OFFSET, + art::Thread::ThreadLocalEndOffset<art::kRuntimePointerSize>().Int32Value()) +ASM_DEFINE(THREAD_LOCAL_OBJECTS_OFFSET, + art::Thread::ThreadLocalObjectsOffset<art::kRuntimePointerSize>().Int32Value()) +ASM_DEFINE(THREAD_LOCAL_POS_OFFSET, + art::Thread::ThreadLocalPosOffset<art::kRuntimePointerSize>().Int32Value()) +ASM_DEFINE(THREAD_ROSALLOC_RUNS_OFFSET, + art::Thread::RosAllocRunsOffset<art::kRuntimePointerSize>().Int32Value()) +ASM_DEFINE(THREAD_SELF_OFFSET, + art::Thread::SelfOffset<art::kRuntimePointerSize>().Int32Value()) +ASM_DEFINE(THREAD_SUSPEND_OR_CHECKPOINT_REQUEST, + art::kSuspendRequest | art::kCheckpointRequest | art::kEmptyCheckpointRequest) +ASM_DEFINE(THREAD_SUSPEND_REQUEST, + art::kSuspendRequest) +ASM_DEFINE(THREAD_USE_MTERP_OFFSET, + art::Thread::UseMterpOffset<art::kRuntimePointerSize>().Int32Value()) +ASM_DEFINE(THREAD_TOP_QUICK_FRAME_OFFSET, + art::Thread::TopOfManagedStackOffset<art::kRuntimePointerSize>().Int32Value()) diff --git a/tools/cpp-define-generator/verify-asm-support b/tools/cpp-define-generator/verify-asm-support deleted file mode 100755 index 745b1153c9..0000000000 --- a/tools/cpp-define-generator/verify-asm-support +++ /dev/null @@ -1,101 +0,0 @@ -#!/bin/bash -# -# Copyright (C) 2017 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. - -# --------------------------------------------------------------------------- - -# Generates asm_support_gen.h into the $OUT directory in the build. -# Then verifies that it is the same as in runtime/generated/asm_support_gen.h - -# Validates that art/runtime/generated/asm_support_gen.h -# - This must be run after a build since it uses cpp-define-generator-data - -# Path to asm_support_gen.h that we check into our git repository. -ASM_SUPPORT_GEN_CHECKED_IN_COPY="runtime/generated/asm_support_gen.h" -# Instead of producing an error if checked-in copy differs from the generated version, -# overwrite the local checked-in copy instead. -OVERWRITE_CHECKED_IN_COPY_IF_CHANGED="n" - -####################### -####################### - -DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -ART_DIR="$( cd "$DIR/../.." && pwd )" -ABS_ASM_SUPPORT_GEN_CHECKED_IN_COPY="$ART_DIR/runtime/generated/asm_support_gen.h" - -# Sanity check that we haven't moved the file around. -# If we did, perhaps the above constant should be updated. -if ! [[ -f "$ABS_ASM_SUPPORT_GEN_CHECKED_IN_COPY" ]]; then - echo "ERROR: Missing asm_support_gen.h, expected to be in '$ABS_ASM_SUPPORT_GEN_CHECKED_IN_COPY'" >&2 - exit 1 -fi - -# The absolute path to cpp-define-generator is in $1 -# Generate the file as part of the build into the out location specified by $2. - -# Compare that the generated file matches our golden copy that's checked into git. -# If not, it is a fatal error and the user needs to run 'generate-asm-support' to rebuild. - -if [[ $# -lt 2 ]]; then - echo "Usage: $0 [--quiet] [--presubmit] <path-to-cpp-define-generator-data-binary> <output-file>'" >&2 - exit 1 -fi - -# Supress 'chatty' messages during the build. -# If anything is printed in a success case then -# the main Android build can't reuse the same line for -# showing multiple commands being executed. -QUIET=false -if [[ "$1" == "--quiet" ]]; then - QUIET=true - shift -fi - -CPP_DEFINE_GENERATOR_TOOL="$1" -OUTPUT_FILE="$2" - -function pecho() { - if ! $QUIET; then - echo "$@" - fi -} - -# Generate the header. Print the command we're running to console for readability. -pecho "cpp-define-generator-data > \"$OUTPUT_FILE\"" -"$CPP_DEFINE_GENERATOR_TOOL" > "$OUTPUT_FILE" -retval="$?" - -if [[ $retval -ne 0 ]]; then - echo "verify-asm-support: FATAL: Error while running cpp-define-generator-data" >&2 - exit $retval -fi - -if ! diff "$ABS_ASM_SUPPORT_GEN_CHECKED_IN_COPY" "$OUTPUT_FILE"; then - - if [[ $OVERWRITE_CHECKED_IN_COPY_IF_CHANGED == "y" ]]; then - cp "$OUTPUT_FILE" "$ABS_ASM_SUPPORT_GEN_CHECKED_IN_COPY" - echo "verify-asm-support: OK: Overwrote '$ASM_SUPPORT_GEN_CHECKED_IN_COPY' with build copy." - echo " Please 'git add $ASM_SUPPORT_GEN_CHECKED_IN_COPY'." - else - echo "---------------------------------------------------------------------------------------------" >&2 - echo "verify-asm-support: ERROR: Checked-in copy of '$ASM_SUPPORT_GEN_CHECKED_IN_COPY' " >&2 - echo " has diverged from the build copy." >&2 - echo " Please re-run the 'generate-asm-support' command to resync the header." >&2 - [[ -f "$OUTPUT_FILE" ]] && rm "$OUTPUT_FILE" - exit 1 - fi -fi - -pecho "verify-asm-support: SUCCESS. Built '$OUTPUT_FILE' which matches our checked in copy." |