summaryrefslogtreecommitdiff
path: root/compiler/optimizing/code_generator.h
diff options
context:
space:
mode:
author Vladimir Marko <vmarko@google.com> 2023-10-27 11:05:27 +0200
committer VladimĂ­r Marko <vmarko@google.com> 2023-10-30 15:37:52 +0000
commitfe7f7aa33d085ed3097ab499277c63aafdfd0e5c (patch)
treee7c3b5dd11b3a9d459a70dd933d77cb76d48dae5 /compiler/optimizing/code_generator.h
parent178e647cfc23649acd4340fb60ce4d0f5207a526 (diff)
Replace `gUseReadBarrier` with compiler option in compiler.
Leave a few `gUseReadBarrier` uses in JNI macro assemblers. We shall deaal with these later. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Test: run-gtests.sh Test: testrunner.py --target --optimizing Bug: 289805127 Change-Id: I9d2aa245cee4c650129f169a82beda7dc0dd6a35
Diffstat (limited to 'compiler/optimizing/code_generator.h')
-rw-r--r--compiler/optimizing/code_generator.h31
1 files changed, 14 insertions, 17 deletions
diff --git a/compiler/optimizing/code_generator.h b/compiler/optimizing/code_generator.h
index 7e46966247..ee2653ec55 100644
--- a/compiler/optimizing/code_generator.h
+++ b/compiler/optimizing/code_generator.h
@@ -59,13 +59,6 @@ static int32_t constexpr kPrimIntMax = 0x7fffffff;
// Maximum value for a primitive long.
static int64_t constexpr kPrimLongMax = INT64_C(0x7fffffffffffffff);
-// Depending on configuration, `gUseReadBarrier` can be a static const variable.
-// Static variable initialization order across different compilation units is not defined,
-// so function is used instead of static variable `gCompilerReadBarrierOption`.
-inline ReadBarrierOption GetCompilerReadBarrierOption() {
- return gUseReadBarrier ? kWithReadBarrier : kWithoutReadBarrier;
-}
-
constexpr size_t status_lsb_position = SubtypeCheckBits::BitStructSizeOf();
constexpr size_t status_byte_offset =
mirror::Class::StatusOffset().SizeValue() + (status_lsb_position / kBitsPerByte);
@@ -275,8 +268,6 @@ class CodeGenerator : public DeletableArenaObject<kArenaAllocCodeGenerator> {
virtual void DumpFloatingPointRegister(std::ostream& stream, int reg) const = 0;
virtual InstructionSet GetInstructionSet() const = 0;
- const CompilerOptions& GetCompilerOptions() const { return compiler_options_; }
-
// Saves the register in the stack. Returns the size taken on stack.
virtual size_t SaveCoreRegister(size_t stack_index, uint32_t reg_id) = 0;
// Restores the register from the stack. Returns the size taken on stack.
@@ -383,6 +374,12 @@ class CodeGenerator : public DeletableArenaObject<kArenaAllocCodeGenerator> {
// TODO: Replace with a catch-entering instruction that records the environment.
void RecordCatchBlockInfo();
+ const CompilerOptions& GetCompilerOptions() const { return compiler_options_; }
+ bool EmitReadBarrier() const;
+ bool EmitBakerReadBarrier() const;
+ bool EmitNonBakerReadBarrier() const;
+ ReadBarrierOption GetCompilerReadBarrierOption() const;
+
// Get the ScopedArenaAllocator used for codegen memory allocation.
ScopedArenaAllocator* GetScopedAllocator();
@@ -454,7 +451,7 @@ class CodeGenerator : public DeletableArenaObject<kArenaAllocCodeGenerator> {
Location to2,
DataType::Type type2);
- static bool InstanceOfNeedsReadBarrier(HInstanceOf* instance_of) {
+ bool InstanceOfNeedsReadBarrier(HInstanceOf* instance_of) {
// Used only for kExactCheck, kAbstractClassCheck, kClassHierarchyCheck and kArrayObjectCheck.
DCHECK(instance_of->GetTypeCheckKind() == TypeCheckKind::kExactCheck ||
instance_of->GetTypeCheckKind() == TypeCheckKind::kAbstractClassCheck ||
@@ -464,14 +461,14 @@ class CodeGenerator : public DeletableArenaObject<kArenaAllocCodeGenerator> {
// If the target class is in the boot image, it's non-moveable and it doesn't matter
// if we compare it with a from-space or to-space reference, the result is the same.
// It's OK to traverse a class hierarchy jumping between from-space and to-space.
- return gUseReadBarrier && !instance_of->GetTargetClass()->IsInBootImage();
+ return EmitReadBarrier() && !instance_of->GetTargetClass()->IsInBootImage();
}
- static ReadBarrierOption ReadBarrierOptionForInstanceOf(HInstanceOf* instance_of) {
+ ReadBarrierOption ReadBarrierOptionForInstanceOf(HInstanceOf* instance_of) {
return InstanceOfNeedsReadBarrier(instance_of) ? kWithReadBarrier : kWithoutReadBarrier;
}
- static bool IsTypeCheckSlowPathFatal(HCheckCast* check_cast) {
+ bool IsTypeCheckSlowPathFatal(HCheckCast* check_cast) {
switch (check_cast->GetTypeCheckKind()) {
case TypeCheckKind::kExactCheck:
case TypeCheckKind::kAbstractClassCheck:
@@ -479,7 +476,7 @@ class CodeGenerator : public DeletableArenaObject<kArenaAllocCodeGenerator> {
case TypeCheckKind::kArrayObjectCheck:
case TypeCheckKind::kInterfaceCheck: {
bool needs_read_barrier =
- gUseReadBarrier && !check_cast->GetTargetClass()->IsInBootImage();
+ EmitReadBarrier() && !check_cast->GetTargetClass()->IsInBootImage();
// We do not emit read barriers for HCheckCast, so we can get false negatives
// and the slow path shall re-check and simply return if the cast is actually OK.
return !needs_read_barrier;
@@ -494,7 +491,7 @@ class CodeGenerator : public DeletableArenaObject<kArenaAllocCodeGenerator> {
UNREACHABLE();
}
- static LocationSummary::CallKind GetCheckCastCallKind(HCheckCast* check_cast) {
+ LocationSummary::CallKind GetCheckCastCallKind(HCheckCast* check_cast) {
return (IsTypeCheckSlowPathFatal(check_cast) && !check_cast->CanThrowIntoCatchBlock())
? LocationSummary::kNoCall // In fact, call on a fatal (non-returning) slow path.
: LocationSummary::kCallOnSlowPath;
@@ -672,7 +669,7 @@ class CodeGenerator : public DeletableArenaObject<kArenaAllocCodeGenerator> {
virtual HLoadClass::LoadKind GetSupportedLoadClassKind(
HLoadClass::LoadKind desired_class_load_kind) = 0;
- static LocationSummary::CallKind GetLoadStringCallKind(HLoadString* load) {
+ LocationSummary::CallKind GetLoadStringCallKind(HLoadString* load) {
switch (load->GetLoadKind()) {
case HLoadString::LoadKind::kBssEntry:
DCHECK(load->NeedsEnvironment());
@@ -682,7 +679,7 @@ class CodeGenerator : public DeletableArenaObject<kArenaAllocCodeGenerator> {
return LocationSummary::kCallOnMainOnly;
case HLoadString::LoadKind::kJitTableAddress:
DCHECK(!load->NeedsEnvironment());
- return gUseReadBarrier
+ return EmitReadBarrier()
? LocationSummary::kCallOnSlowPath
: LocationSummary::kNoCall;
break;