ART: Move debug-checks to runtime-debug-flags
Current slow checks:
* Class status checking in ArtMethod
* Read barrier invariant checking
Bug: 35644369
Test: m test-art-host
Change-Id: I66138a9accc601fa0fa675cf600412ad3629d28f
diff --git a/runtime/Android.bp b/runtime/Android.bp
index 9b110eb..46307dd 100644
--- a/runtime/Android.bp
+++ b/runtime/Android.bp
@@ -193,6 +193,7 @@
"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 32946ef..ac433dd 100644
--- a/runtime/art_method.cc
+++ b/runtime/art_method.cc
@@ -55,6 +55,8 @@
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 3a8d279..d537764 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 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 0000000..89ae910
--- /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 2964090..ca77685 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 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.