diff options
author | 2018-10-02 17:12:24 +0100 | |
---|---|---|
committer | 2018-10-12 03:22:29 +0100 | |
commit | 766e74f58312af149219473a691c6f2d9bcca428 (patch) | |
tree | 4c216f5ebd128075f20d0857afb383d31da20c5a | |
parent | 0adf4d80ca1c673e5f7c5249faabadccdc1ddbbd (diff) |
Cleanup the cpp-define-generator definitions.
Test: test-art-host-gtest-arch_test
Change-Id: Ifda7a51d19156b1eb62bc39b16ec559d609744e5
38 files changed, 494 insertions, 979 deletions
diff --git a/runtime/arch/arch_test.cc b/runtime/arch/arch_test.cc index 01b65bc572..dcc3affb6b 100644 --- a/runtime/arch/arch_test.cc +++ b/runtime/arch/arch_test.cc @@ -17,36 +17,16 @@ #include <stdint.h> #include "art_method-inl.h" +#include "asm_defines.h" #include "base/callee_save_type.h" #include "entrypoints/quick/callee_save_frame.h" #include "common_runtime_test.h" #include "quick/quick_method_frame_info.h" -// asm_support.h declares tests next to the #defines. We use asm_support_check.h to (safely) -// generate CheckAsmSupportOffsetsAndSizes using gtest's EXPECT for the tests. We also use the -// RETURN_TYPE, HEADER and FOOTER defines from asm_support_check.h to try to ensure that any -// tests are actually generated. - -// Let CheckAsmSupportOffsetsAndSizes return a size_t (the count). -#define ASM_SUPPORT_CHECK_RETURN_TYPE size_t - -// Declare the counter that will be updated per test. -#define ASM_SUPPORT_CHECK_HEADER size_t count = 0; - -// Use EXPECT_EQ for tests, and increment the counter. -#define ADD_TEST_EQ(x, y) EXPECT_EQ(x, y); count++; - -// Return the counter at the end of CheckAsmSupportOffsetsAndSizes. -#define ASM_SUPPORT_CHECK_FOOTER return count; - -// Generate CheckAsmSupportOffsetsAndSizes(). -#include "asm_support_check.h" - // Static asserts to check the values of generated #defines for assembly. -#define DEFINE_INCLUDE_DEPENDENCIES -#include "offsets_all.def" -#define DEFINE_EXPR(NAME, TYPE, EXPR) static_assert(NAME == EXPR, "Unexpected value of " #NAME); -#include "offsets_all.def" +#define ASM_DEFINE(NAME, EXPR) static_assert((NAME) == (EXPR), "Unexpected value of " #NAME); +#include "asm_defines.def" +#undef ASM_DEFINE namespace art { @@ -66,11 +46,6 @@ class ArchTest : public CommonRuntimeTest { } }; -TEST_F(ArchTest, CheckCommonOffsetsAndSizes) { - size_t test_count = CheckAsmSupportOffsetsAndSizes(); - EXPECT_GT(test_count, 0u); -} - // Grab architecture specific constants. namespace arm { #include "arch/arm/asm_support_arm.h" diff --git a/runtime/asm_support.h b/runtime/asm_support.h index 5247a0edc2..eac985685d 100644 --- a/runtime/asm_support.h +++ b/runtime/asm_support.h @@ -20,216 +20,7 @@ #include "heap_poisoning.h" #include "read_barrier_config.h" -// To generate tests related to the constants in this header, either define ADD_TEST_EQ before -// including, or use asm_support_check.h. -#ifndef ADD_TEST_EQ // Allow #include-r to replace with their own. -#define DEFINED_ADD_TEST_EQ 1 -#define ADD_TEST_EQ(x, y) -#endif - -// Rounds the value n up to the nearest multiple of sz. sz must be a multiple of two. -#define ALIGN_UP(n, sz) (((n) + (sz - 1)) & ~((sz) - 1)) - -#if defined(__LP64__) -#define POINTER_SIZE_SHIFT 3 -#define POINTER_SIZE art::PointerSize::k64 -#else -#define POINTER_SIZE_SHIFT 2 -#define POINTER_SIZE art::PointerSize::k32 -#endif -ADD_TEST_EQ(static_cast<size_t>(1U << POINTER_SIZE_SHIFT), - static_cast<size_t>(__SIZEOF_POINTER__)) - -// Import platform-independent constant defines from our autogenerated list. -// Export new defines (for assembly use) by editing cpp-define-generator def files. -#define DEFINE_CHECK_EQ ADD_TEST_EQ -#include "asm_support_gen.h" -#undef DEFINE_CHECK_EQ - -// Offset of field Thread::tlsPtr_.exception. -#define THREAD_EXCEPTION_OFFSET (THREAD_CARD_TABLE_OFFSET + __SIZEOF_POINTER__) -ADD_TEST_EQ(THREAD_EXCEPTION_OFFSET, - art::Thread::ExceptionOffset<POINTER_SIZE>().Int32Value()) - -// Offset of field Thread::tlsPtr_.managed_stack.top_quick_frame_. -#define THREAD_TOP_QUICK_FRAME_OFFSET (THREAD_CARD_TABLE_OFFSET + (3 * __SIZEOF_POINTER__)) -ADD_TEST_EQ(THREAD_TOP_QUICK_FRAME_OFFSET, - art::Thread::TopOfManagedStackOffset<POINTER_SIZE>().Int32Value()) - -// Offset of field Thread::tlsPtr_.self. -#define THREAD_SELF_OFFSET (THREAD_CARD_TABLE_OFFSET + (9 * __SIZEOF_POINTER__)) -ADD_TEST_EQ(THREAD_SELF_OFFSET, - art::Thread::SelfOffset<POINTER_SIZE>().Int32Value()) - -// Offset of field Thread::tlsPtr_.thread_local_pos. -#define THREAD_LOCAL_POS_OFFSET (THREAD_CARD_TABLE_OFFSET + 34 * __SIZEOF_POINTER__) -ADD_TEST_EQ(THREAD_LOCAL_POS_OFFSET, - art::Thread::ThreadLocalPosOffset<POINTER_SIZE>().Int32Value()) -// Offset of field Thread::tlsPtr_.thread_local_end. -#define THREAD_LOCAL_END_OFFSET (THREAD_LOCAL_POS_OFFSET + __SIZEOF_POINTER__) -ADD_TEST_EQ(THREAD_LOCAL_END_OFFSET, - art::Thread::ThreadLocalEndOffset<POINTER_SIZE>().Int32Value()) -// Offset of field Thread::tlsPtr_.thread_local_objects. -#define THREAD_LOCAL_OBJECTS_OFFSET (THREAD_LOCAL_END_OFFSET + 2 * __SIZEOF_POINTER__) -ADD_TEST_EQ(THREAD_LOCAL_OBJECTS_OFFSET, - art::Thread::ThreadLocalObjectsOffset<POINTER_SIZE>().Int32Value()) - -// Offset of field Thread::tlsPtr_.mterp_current_ibase. -#define THREAD_CURRENT_IBASE_OFFSET \ - (THREAD_LOCAL_OBJECTS_OFFSET + __SIZEOF_SIZE_T__ + (1 + 166) * __SIZEOF_POINTER__) -ADD_TEST_EQ(THREAD_CURRENT_IBASE_OFFSET, - art::Thread::MterpCurrentIBaseOffset<POINTER_SIZE>().Int32Value()) -// Offset of field Thread::tlsPtr_.mterp_default_ibase. -#define THREAD_DEFAULT_IBASE_OFFSET (THREAD_CURRENT_IBASE_OFFSET + __SIZEOF_POINTER__) -ADD_TEST_EQ(THREAD_DEFAULT_IBASE_OFFSET, - art::Thread::MterpDefaultIBaseOffset<POINTER_SIZE>().Int32Value()) -// Offset of field Thread::tlsPtr_.mterp_alt_ibase. -#define THREAD_ALT_IBASE_OFFSET (THREAD_DEFAULT_IBASE_OFFSET + __SIZEOF_POINTER__) -ADD_TEST_EQ(THREAD_ALT_IBASE_OFFSET, - art::Thread::MterpAltIBaseOffset<POINTER_SIZE>().Int32Value()) -// Offset of field Thread::tlsPtr_.rosalloc_runs. -#define THREAD_ROSALLOC_RUNS_OFFSET (THREAD_ALT_IBASE_OFFSET + __SIZEOF_POINTER__) -ADD_TEST_EQ(THREAD_ROSALLOC_RUNS_OFFSET, - art::Thread::RosAllocRunsOffset<POINTER_SIZE>().Int32Value()) -// Offset of field Thread::tlsPtr_.thread_local_alloc_stack_top. -#define THREAD_LOCAL_ALLOC_STACK_TOP_OFFSET (THREAD_ROSALLOC_RUNS_OFFSET + 16 * __SIZEOF_POINTER__) -ADD_TEST_EQ(THREAD_LOCAL_ALLOC_STACK_TOP_OFFSET, - art::Thread::ThreadLocalAllocStackTopOffset<POINTER_SIZE>().Int32Value()) -// Offset of field Thread::tlsPtr_.thread_local_alloc_stack_end. -#define THREAD_LOCAL_ALLOC_STACK_END_OFFSET (THREAD_ROSALLOC_RUNS_OFFSET + 17 * __SIZEOF_POINTER__) -ADD_TEST_EQ(THREAD_LOCAL_ALLOC_STACK_END_OFFSET, - art::Thread::ThreadLocalAllocStackEndOffset<POINTER_SIZE>().Int32Value()) -// Offset of field Thread::interpreter_cache_. This is aligned on a 16 byte boundary so we need to -// round up depending on the size of tlsPtr_. -#define THREAD_INTERPRETER_CACHE_OFFSET \ - (ALIGN_UP((THREAD_CARD_TABLE_OFFSET + 301 * __SIZEOF_POINTER__), 16)) -ADD_TEST_EQ(THREAD_INTERPRETER_CACHE_OFFSET, - art::Thread::InterpreterCacheOffset<POINTER_SIZE>().Int32Value()) - -// Offsets within ShadowFrame. -#define SHADOWFRAME_LINK_OFFSET 0 -ADD_TEST_EQ(SHADOWFRAME_LINK_OFFSET, - static_cast<int32_t>(art::ShadowFrame::LinkOffset())) -#define SHADOWFRAME_METHOD_OFFSET (SHADOWFRAME_LINK_OFFSET + 1 * __SIZEOF_POINTER__) -ADD_TEST_EQ(SHADOWFRAME_METHOD_OFFSET, - static_cast<int32_t>(art::ShadowFrame::MethodOffset())) -#define SHADOWFRAME_RESULT_REGISTER_OFFSET (SHADOWFRAME_LINK_OFFSET + 2 * __SIZEOF_POINTER__) -ADD_TEST_EQ(SHADOWFRAME_RESULT_REGISTER_OFFSET, - static_cast<int32_t>(art::ShadowFrame::ResultRegisterOffset())) -#define SHADOWFRAME_DEX_PC_PTR_OFFSET (SHADOWFRAME_LINK_OFFSET + 3 * __SIZEOF_POINTER__) -ADD_TEST_EQ(SHADOWFRAME_DEX_PC_PTR_OFFSET, - static_cast<int32_t>(art::ShadowFrame::DexPCPtrOffset())) -#define SHADOWFRAME_DEX_INSTRUCTIONS_OFFSET (SHADOWFRAME_LINK_OFFSET + 4 * __SIZEOF_POINTER__) -ADD_TEST_EQ(SHADOWFRAME_DEX_INSTRUCTIONS_OFFSET, - static_cast<int32_t>(art::ShadowFrame::DexInstructionsOffset())) -#define SHADOWFRAME_LOCK_COUNT_DATA_OFFSET (SHADOWFRAME_LINK_OFFSET + 5 * __SIZEOF_POINTER__) -ADD_TEST_EQ(SHADOWFRAME_LOCK_COUNT_DATA_OFFSET, - static_cast<int32_t>(art::ShadowFrame::LockCountDataOffset())) -#define SHADOWFRAME_NUMBER_OF_VREGS_OFFSET (SHADOWFRAME_LINK_OFFSET + 6 * __SIZEOF_POINTER__) -ADD_TEST_EQ(SHADOWFRAME_NUMBER_OF_VREGS_OFFSET, - static_cast<int32_t>(art::ShadowFrame::NumberOfVRegsOffset())) -#define SHADOWFRAME_DEX_PC_OFFSET (SHADOWFRAME_NUMBER_OF_VREGS_OFFSET + 4) -ADD_TEST_EQ(SHADOWFRAME_DEX_PC_OFFSET, - static_cast<int32_t>(art::ShadowFrame::DexPCOffset())) -#define SHADOWFRAME_CACHED_HOTNESS_COUNTDOWN_OFFSET (SHADOWFRAME_NUMBER_OF_VREGS_OFFSET + 8) -ADD_TEST_EQ(SHADOWFRAME_CACHED_HOTNESS_COUNTDOWN_OFFSET, - static_cast<int32_t>(art::ShadowFrame::CachedHotnessCountdownOffset())) -#define SHADOWFRAME_HOTNESS_COUNTDOWN_OFFSET (SHADOWFRAME_NUMBER_OF_VREGS_OFFSET + 10) -ADD_TEST_EQ(SHADOWFRAME_HOTNESS_COUNTDOWN_OFFSET, - static_cast<int32_t>(art::ShadowFrame::HotnessCountdownOffset())) -#define SHADOWFRAME_VREGS_OFFSET (SHADOWFRAME_NUMBER_OF_VREGS_OFFSET + 16) -ADD_TEST_EQ(SHADOWFRAME_VREGS_OFFSET, - static_cast<int32_t>(art::ShadowFrame::VRegsOffset())) - -#if defined(USE_BROOKS_READ_BARRIER) -#define MIRROR_OBJECT_HEADER_SIZE 16 -#else -#define MIRROR_OBJECT_HEADER_SIZE 8 -#endif -ADD_TEST_EQ(size_t(MIRROR_OBJECT_HEADER_SIZE), sizeof(art::mirror::Object)) - -// Offsets within java.lang.Class. -#define MIRROR_CLASS_COMPONENT_TYPE_OFFSET (4 + MIRROR_OBJECT_HEADER_SIZE) -ADD_TEST_EQ(MIRROR_CLASS_COMPONENT_TYPE_OFFSET, - art::mirror::Class::ComponentTypeOffset().Int32Value()) -#define MIRROR_CLASS_IF_TABLE_OFFSET (16 + MIRROR_OBJECT_HEADER_SIZE) -ADD_TEST_EQ(MIRROR_CLASS_IF_TABLE_OFFSET, - art::mirror::Class::IfTableOffset().Int32Value()) -#define MIRROR_CLASS_ACCESS_FLAGS_OFFSET (56 + MIRROR_OBJECT_HEADER_SIZE) -ADD_TEST_EQ(MIRROR_CLASS_ACCESS_FLAGS_OFFSET, - art::mirror::Class::AccessFlagsOffset().Int32Value()) -#define MIRROR_CLASS_OBJECT_SIZE_OFFSET (88 + MIRROR_OBJECT_HEADER_SIZE) -ADD_TEST_EQ(MIRROR_CLASS_OBJECT_SIZE_OFFSET, - art::mirror::Class::ObjectSizeOffset().Int32Value()) -#define MIRROR_CLASS_OBJECT_SIZE_ALLOC_FAST_PATH_OFFSET (92 + MIRROR_OBJECT_HEADER_SIZE) -ADD_TEST_EQ(MIRROR_CLASS_OBJECT_SIZE_ALLOC_FAST_PATH_OFFSET, - art::mirror::Class::ObjectSizeAllocFastPathOffset().Int32Value()) -#define MIRROR_CLASS_OBJECT_PRIMITIVE_TYPE_OFFSET (96 + MIRROR_OBJECT_HEADER_SIZE) -ADD_TEST_EQ(MIRROR_CLASS_OBJECT_PRIMITIVE_TYPE_OFFSET, - art::mirror::Class::PrimitiveTypeOffset().Int32Value()) -#define MIRROR_CLASS_STATUS_OFFSET (104 + MIRROR_OBJECT_HEADER_SIZE) -ADD_TEST_EQ(MIRROR_CLASS_STATUS_OFFSET, - art::mirror::Class::StatusOffset().Int32Value()) - -#define PRIMITIVE_TYPE_SIZE_SHIFT_SHIFT 16 -ADD_TEST_EQ(PRIMITIVE_TYPE_SIZE_SHIFT_SHIFT, - static_cast<int>(art::mirror::Class::kPrimitiveTypeSizeShiftShift)) - -// Array offsets. -#define MIRROR_ARRAY_LENGTH_OFFSET MIRROR_OBJECT_HEADER_SIZE -ADD_TEST_EQ(MIRROR_ARRAY_LENGTH_OFFSET, art::mirror::Array::LengthOffset().Int32Value()) - -#define MIRROR_CHAR_ARRAY_DATA_OFFSET (4 + MIRROR_OBJECT_HEADER_SIZE) -ADD_TEST_EQ(MIRROR_CHAR_ARRAY_DATA_OFFSET, - art::mirror::Array::DataOffset(sizeof(uint16_t)).Int32Value()) - -#define MIRROR_BOOLEAN_ARRAY_DATA_OFFSET MIRROR_CHAR_ARRAY_DATA_OFFSET -ADD_TEST_EQ(MIRROR_BOOLEAN_ARRAY_DATA_OFFSET, - art::mirror::Array::DataOffset(sizeof(uint8_t)).Int32Value()) - -#define MIRROR_BYTE_ARRAY_DATA_OFFSET MIRROR_CHAR_ARRAY_DATA_OFFSET -ADD_TEST_EQ(MIRROR_BYTE_ARRAY_DATA_OFFSET, - art::mirror::Array::DataOffset(sizeof(int8_t)).Int32Value()) - -#define MIRROR_SHORT_ARRAY_DATA_OFFSET MIRROR_CHAR_ARRAY_DATA_OFFSET -ADD_TEST_EQ(MIRROR_SHORT_ARRAY_DATA_OFFSET, - art::mirror::Array::DataOffset(sizeof(int16_t)).Int32Value()) - -#define MIRROR_INT_ARRAY_DATA_OFFSET MIRROR_CHAR_ARRAY_DATA_OFFSET -ADD_TEST_EQ(MIRROR_INT_ARRAY_DATA_OFFSET, - art::mirror::Array::DataOffset(sizeof(int32_t)).Int32Value()) - -#define MIRROR_WIDE_ARRAY_DATA_OFFSET (8 + MIRROR_OBJECT_HEADER_SIZE) -ADD_TEST_EQ(MIRROR_WIDE_ARRAY_DATA_OFFSET, - art::mirror::Array::DataOffset(sizeof(uint64_t)).Int32Value()) - -#define MIRROR_OBJECT_ARRAY_DATA_OFFSET (4 + MIRROR_OBJECT_HEADER_SIZE) -ADD_TEST_EQ(MIRROR_OBJECT_ARRAY_DATA_OFFSET, - art::mirror::Array::DataOffset( - sizeof(art::mirror::HeapReference<art::mirror::Object>)).Int32Value()) - -#define MIRROR_OBJECT_ARRAY_COMPONENT_SIZE 4 -ADD_TEST_EQ(static_cast<size_t>(MIRROR_OBJECT_ARRAY_COMPONENT_SIZE), - sizeof(art::mirror::HeapReference<art::mirror::Object>)) - -#define MIRROR_LONG_ARRAY_DATA_OFFSET (8 + MIRROR_OBJECT_HEADER_SIZE) -ADD_TEST_EQ(MIRROR_LONG_ARRAY_DATA_OFFSET, - art::mirror::Array::DataOffset(sizeof(uint64_t)).Int32Value()) - -// Offsets within java.lang.String. -#define MIRROR_STRING_COUNT_OFFSET MIRROR_OBJECT_HEADER_SIZE -ADD_TEST_EQ(MIRROR_STRING_COUNT_OFFSET, art::mirror::String::CountOffset().Int32Value()) - -#define MIRROR_STRING_VALUE_OFFSET (8 + MIRROR_OBJECT_HEADER_SIZE) -ADD_TEST_EQ(MIRROR_STRING_VALUE_OFFSET, art::mirror::String::ValueOffset().Int32Value()) - -// String compression feature. -#define STRING_COMPRESSION_FEATURE 1 -ADD_TEST_EQ(STRING_COMPRESSION_FEATURE, art::mirror::kUseStringCompression); - -#ifdef DEFINED_ADD_TEST_EQ -#undef ADD_TEST_EQ -#undef DEFINED_ADD_TEST_EQ -#endif +// Automatically generated header based on the asm_defines.def file. +#include "asm_defines.h" #endif // ART_RUNTIME_ASM_SUPPORT_H_ diff --git a/runtime/asm_support_check.h b/runtime/asm_support_check.h deleted file mode 100644 index 3163506e72..0000000000 --- a/runtime/asm_support_check.h +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ART_RUNTIME_ASM_SUPPORT_CHECK_H_ -#define ART_RUNTIME_ASM_SUPPORT_CHECK_H_ - -#include "art_method.h" -#include "base/bit_utils.h" -#include "base/callee_save_type.h" -#include "gc/accounting/card_table.h" -#include "gc/allocator/rosalloc.h" -#include "gc/heap.h" -#include "jit/jit.h" -#include "lock_word.h" -#include "mirror/class.h" -#include "mirror/dex_cache.h" -#include "mirror/string.h" -#include "runtime.h" -#include "stack.h" -#include "thread.h" -#include "utils/dex_cache_arrays_layout.h" - -#ifndef ADD_TEST_EQ -#define ADD_TEST_EQ(x, y) CHECK_EQ(x, y); -#endif - -#ifndef ASM_SUPPORT_CHECK_RETURN_TYPE -#define ASM_SUPPORT_CHECK_RETURN_TYPE void -#endif - -// Prepare for re-include of asm_support.h. -#ifdef ART_RUNTIME_ASM_SUPPORT_H_ -#undef ART_RUNTIME_ASM_SUPPORT_H_ -#endif - -namespace art { - -static inline ASM_SUPPORT_CHECK_RETURN_TYPE CheckAsmSupportOffsetsAndSizes() { -#ifdef ASM_SUPPORT_CHECK_HEADER - ASM_SUPPORT_CHECK_HEADER -#endif - -#include "asm_support.h" - -#ifdef ASM_SUPPORT_CHECK_FOOTER - ASM_SUPPORT_CHECK_FOOTER -#endif -} - -} // namespace art - -#endif // ART_RUNTIME_ASM_SUPPORT_CHECK_H_ diff --git a/runtime/runtime.cc b/runtime/runtime.cc index c9131b5899..027193765a 100644 --- a/runtime/runtime.cc +++ b/runtime/runtime.cc @@ -49,7 +49,6 @@ #include "art_field-inl.h" #include "art_method-inl.h" #include "asm_support.h" -#include "asm_support_check.h" #include "base/aborting.h" #include "base/arena_allocator.h" #include "base/atomic.h" @@ -278,7 +277,6 @@ Runtime::Runtime() static_assert(Runtime::kCalleeSaveSize == static_cast<uint32_t>(CalleeSaveType::kLastCalleeSaveType), "Unexpected size"); - CheckAsmSupportOffsetsAndSizes(); std::fill(callee_save_methods_, callee_save_methods_ + arraysize(callee_save_methods_), 0u); interpreter::CheckInterpreterAsmConstants(); callbacks_.reset(new RuntimeCallbacks()); diff --git a/tools/cpp-define-generator/Android.bp b/tools/cpp-define-generator/Android.bp index 0d3943e141..027f128561 100644 --- a/tools/cpp-define-generator/Android.bp +++ b/tools/cpp-define-generator/Android.bp @@ -41,7 +41,7 @@ cc_genrule { host_supported: true, device_supported: true, srcs: [":asm_defines.s"], - out: ["asm_support_gen.h"], + out: ["asm_defines.h"], tool_files: ["make_header.py"], cmd: "$(location make_header.py) \"$(in)\" > \"$(out)\"", } 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 index de67f1b47f..c105c1a7ce 100644 --- a/tools/cpp-define-generator/asm_defines.cc +++ b/tools/cpp-define-generator/asm_defines.cc @@ -14,18 +14,23 @@ * limitations under the License. */ -// Art Offset file dependencies -#define DEFINE_INCLUDE_DEPENDENCIES -#include "offsets_all.def" +// +// 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 DEFINE_EXPR(NAME, TYPE, EXPR) \ +#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 "offsets_all.def" +#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_card_table.def b/tools/cpp-define-generator/constant_card_table.def deleted file mode 100644 index ae3e8f399f..0000000000 --- a/tools/cpp-define-generator/constant_card_table.def +++ /dev/null @@ -1,25 +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. - */ - -// Export heap values. - -#if defined(DEFINE_INCLUDE_DEPENDENCIES) -#include "gc/accounting/card_table.h" -#endif - -// Size of references to the heap on the stack. -DEFINE_EXPR(CARD_TABLE_CARD_SHIFT, size_t, art::gc::accounting::CardTable::kCardShift) - 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_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 7e1df6b267..0000000000 --- a/tools/cpp-define-generator/constant_thread.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. - */ - -// 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) -DEFINE_THREAD_CONSTANT(INTERPRETER_CACHE_SIZE_LOG2, int32_t, art::Thread::InterpreterCacheSizeLog2()) diff --git a/tools/cpp-define-generator/globals.def b/tools/cpp-define-generator/globals.def new file mode 100644 index 0000000000..2324f5168e --- /dev/null +++ b/tools/cpp-define-generator/globals.def @@ -0,0 +1,66 @@ +/* + * 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 "jit/jit.h" +#include "mirror/object.h" +#include "mirror/object_reference.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(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/make_header.py b/tools/cpp-define-generator/make_header.py index 95ef7bc56d..1b13923b50 100755 --- a/tools/cpp-define-generator/make_header.py +++ b/tools/cpp-define-generator/make_header.py @@ -47,7 +47,6 @@ def convert(input): # 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)) - output.append("#define {0} {1:#x}".format(name.upper(), value)) return "\n".join(output) if __name__ == "__main__": diff --git a/tools/cpp-define-generator/make_header_test.py b/tools/cpp-define-generator/make_header_test.py index eec1c68186..a484285e5c 100755 --- a/tools/cpp-define-generator/make_header_test.py +++ b/tools/cpp-define-generator/make_header_test.py @@ -36,12 +36,8 @@ bx lr test_output = r''' #define JIT_CHECK_OSR -0x1 -#define JIT_CHECK_OSR -0x1 -#define MIRROR_OBJECT_LOCK_WORD_OFFSET 0x4 #define MIRROR_OBJECT_LOCK_WORD_OFFSET 0x4 #define OBJECT_ALIGNMENT_MASK_TOGGLED 0xfffffff8 -#define OBJECT_ALIGNMENT_MASK_TOGGLED 0xfffffff8 -#define OBJECT_ALIGNMENT_MASK_TOGGLED64 0xfffffffffffffff8 #define OBJECT_ALIGNMENT_MASK_TOGGLED64 0xfffffffffffffff8 ''' 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/constant_heap.def b/tools/cpp-define-generator/mirror_object.def index dc76736505..facb037c97 100644 --- a/tools/cpp-define-generator/constant_heap.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,12 +14,13 @@ * limitations under the License. */ -// Export heap values. - -#if defined(DEFINE_INCLUDE_DEPENDENCIES) -#include "gc/heap.h" +#if ASM_DEFINE_INCLUDE_DEPENDENCIES +#include "mirror/object.h" #endif -// Size of references to the heap on the stack. -DEFINE_EXPR(MIN_LARGE_OBJECT_THRESHOLD, size_t, art::gc::Heap::kMinLargeObjectThreshold) - +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/common.def b/tools/cpp-define-generator/mirror_string.def index 76c64c97c2..3632b96d5c 100644 --- a/tools/cpp-define-generator/common.def +++ b/tools/cpp-define-generator/mirror_string.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/string.h" #endif +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/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..2dd90fae3f --- /dev/null +++ b/tools/cpp-define-generator/thread.def @@ -0,0 +1,64 @@ +/* + * 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_ALT_IBASE_OFFSET, + art::Thread::MterpAltIBaseOffset<art::kRuntimePointerSize>().Int32Value()) +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_DEFAULT_IBASE_OFFSET, + art::Thread::MterpDefaultIBaseOffset<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_TOP_QUICK_FRAME_OFFSET, + art::Thread::TopOfManagedStackOffset<art::kRuntimePointerSize>().Int32Value()) |