diff options
| -rw-r--r-- | runtime/Android.bp | 1 | ||||
| -rw-r--r-- | runtime/art_method.cc | 2 | ||||
| -rw-r--r-- | runtime/art_method.h | 4 | ||||
| -rw-r--r-- | runtime/read_barrier.cc | 24 | ||||
| -rw-r--r-- | runtime/read_barrier.h | 12 |
5 files changed, 38 insertions, 5 deletions
diff --git a/runtime/Android.bp b/runtime/Android.bp index 9b110ebc7f..46307ddde8 100644 --- a/runtime/Android.bp +++ b/runtime/Android.bp @@ -193,6 +193,7 @@ cc_defaults { "plugin.cc", "primitive.cc", "quick_exception_handler.cc", + "read_barrier.cc", "reference_table.cc", "reflection.cc", "runtime.cc", diff --git a/runtime/art_method.cc b/runtime/art_method.cc index 32946ef0b4..ac433dd403 100644 --- a/runtime/art_method.cc +++ b/runtime/art_method.cc @@ -55,6 +55,8 @@ extern "C" void art_quick_invoke_stub(ArtMethod*, uint32_t*, uint32_t, Thread*, extern "C" void art_quick_invoke_static_stub(ArtMethod*, uint32_t*, uint32_t, Thread*, JValue*, const char*); +DEFINE_RUNTIME_DEBUG_FLAG(ArtMethod, kCheckDeclaringClassState); + // Enforce that we he have the right index for runtime methods. static_assert(ArtMethod::kRuntimeMethodDexMethodIndex == DexFile::kDexNoIndex, "Wrong runtime-method dex method index"); diff --git a/runtime/art_method.h b/runtime/art_method.h index 3a8d279606..d537764cac 100644 --- a/runtime/art_method.h +++ b/runtime/art_method.h @@ -22,6 +22,7 @@ #include "base/bit_utils.h" #include "base/casts.h" #include "base/enums.h" +#include "base/logging.h" #include "dex_file.h" #include "gc_root.h" #include "modifiers.h" @@ -56,7 +57,8 @@ class String; class ArtMethod FINAL { public: - static constexpr bool kCheckDeclaringClassState = kIsDebugBuild; + // Should the class state be checked on sensitive operations? + DECLARE_RUNTIME_DEBUG_FLAG(kCheckDeclaringClassState); // The runtime dex_method_index is kDexNoIndex. To lower dependencies, we use this // constexpr, and ensure that the value is correct in art_method.cc. diff --git a/runtime/read_barrier.cc b/runtime/read_barrier.cc new file mode 100644 index 0000000000..89ae91040a --- /dev/null +++ b/runtime/read_barrier.cc @@ -0,0 +1,24 @@ +/* + * 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. + */ + +#include "read_barrier.h" + +namespace art { + +DEFINE_RUNTIME_DEBUG_FLAG(ReadBarrier, kEnableToSpaceInvariantChecks); +DEFINE_RUNTIME_DEBUG_FLAG(ReadBarrier, kEnableReadBarrierInvariantChecks); + +} // namespace art diff --git a/runtime/read_barrier.h b/runtime/read_barrier.h index 296409014e..ca776854cb 100644 --- a/runtime/read_barrier.h +++ b/runtime/read_barrier.h @@ -17,6 +17,7 @@ #ifndef ART_RUNTIME_READ_BARRIER_H_ #define ART_RUNTIME_READ_BARRIER_H_ +#include "base/logging.h" #include "base/mutex.h" #include "base/macros.h" #include "gc_root.h" @@ -37,10 +38,13 @@ class ArtMethod; class ReadBarrier { public: - // Enable the to-space invariant checks. - static constexpr bool kEnableToSpaceInvariantChecks = kIsDebugBuild; - // Enable the read barrier checks. - static constexpr bool kEnableReadBarrierInvariantChecks = kIsDebugBuild; + // Enable the to-space invariant checks. This is slow and happens very often. Do not enable in + // fast-debug environment. + DECLARE_RUNTIME_DEBUG_FLAG(kEnableToSpaceInvariantChecks); + + // Enable the read barrier checks. This is slow and happens very often. Do not enable in + // fast-debug environment. + DECLARE_RUNTIME_DEBUG_FLAG(kEnableReadBarrierInvariantChecks); // It's up to the implementation whether the given field gets updated whereas the return value // must be an updated reference unless kAlwaysUpdateField is true. |