xref: /aosp_15_r20/art/runtime/deoptimization_kind.h (revision 795d594fd825385562da6b089ea9b2033f3abf5a)
1*795d594fSAndroid Build Coastguard Worker /*
2*795d594fSAndroid Build Coastguard Worker  * Copyright (C) 2017 The Android Open Source Project
3*795d594fSAndroid Build Coastguard Worker  *
4*795d594fSAndroid Build Coastguard Worker  * Licensed under the Apache License, Version 2.0 (the "License");
5*795d594fSAndroid Build Coastguard Worker  * you may not use this file except in compliance with the License.
6*795d594fSAndroid Build Coastguard Worker  * You may obtain a copy of the License at
7*795d594fSAndroid Build Coastguard Worker  *
8*795d594fSAndroid Build Coastguard Worker  *      http://www.apache.org/licenses/LICENSE-2.0
9*795d594fSAndroid Build Coastguard Worker  *
10*795d594fSAndroid Build Coastguard Worker  * Unless required by applicable law or agreed to in writing, software
11*795d594fSAndroid Build Coastguard Worker  * distributed under the License is distributed on an "AS IS" BASIS,
12*795d594fSAndroid Build Coastguard Worker  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13*795d594fSAndroid Build Coastguard Worker  * See the License for the specific language governing permissions and
14*795d594fSAndroid Build Coastguard Worker  * limitations under the License.
15*795d594fSAndroid Build Coastguard Worker  */
16*795d594fSAndroid Build Coastguard Worker 
17*795d594fSAndroid Build Coastguard Worker #ifndef ART_RUNTIME_DEOPTIMIZATION_KIND_H_
18*795d594fSAndroid Build Coastguard Worker #define ART_RUNTIME_DEOPTIMIZATION_KIND_H_
19*795d594fSAndroid Build Coastguard Worker 
20*795d594fSAndroid Build Coastguard Worker #include "base/logging.h"
21*795d594fSAndroid Build Coastguard Worker #include "base/macros.h"
22*795d594fSAndroid Build Coastguard Worker 
23*795d594fSAndroid Build Coastguard Worker namespace art HIDDEN {
24*795d594fSAndroid Build Coastguard Worker 
25*795d594fSAndroid Build Coastguard Worker enum class DeoptimizationKind {
26*795d594fSAndroid Build Coastguard Worker   kAotInlineCache = 0,
27*795d594fSAndroid Build Coastguard Worker   kJitInlineCache,
28*795d594fSAndroid Build Coastguard Worker   kJitSameTarget,
29*795d594fSAndroid Build Coastguard Worker   kLoopBoundsBCE,
30*795d594fSAndroid Build Coastguard Worker   kLoopNullBCE,
31*795d594fSAndroid Build Coastguard Worker   kBlockBCE,
32*795d594fSAndroid Build Coastguard Worker   kCHA,
33*795d594fSAndroid Build Coastguard Worker   kDebugging,
34*795d594fSAndroid Build Coastguard Worker   kFullFrame,
35*795d594fSAndroid Build Coastguard Worker   kLast = kFullFrame
36*795d594fSAndroid Build Coastguard Worker };
37*795d594fSAndroid Build Coastguard Worker 
GetDeoptimizationKindName(DeoptimizationKind kind)38*795d594fSAndroid Build Coastguard Worker inline const char* GetDeoptimizationKindName(DeoptimizationKind kind) {
39*795d594fSAndroid Build Coastguard Worker   switch (kind) {
40*795d594fSAndroid Build Coastguard Worker     case DeoptimizationKind::kAotInlineCache: return "AOT inline cache";
41*795d594fSAndroid Build Coastguard Worker     case DeoptimizationKind::kJitInlineCache: return "JIT inline cache";
42*795d594fSAndroid Build Coastguard Worker     case DeoptimizationKind::kJitSameTarget: return "JIT same target";
43*795d594fSAndroid Build Coastguard Worker     case DeoptimizationKind::kLoopBoundsBCE: return "loop bounds check elimination";
44*795d594fSAndroid Build Coastguard Worker     case DeoptimizationKind::kLoopNullBCE: return "loop bounds check elimination on null";
45*795d594fSAndroid Build Coastguard Worker     case DeoptimizationKind::kBlockBCE: return "block bounds check elimination";
46*795d594fSAndroid Build Coastguard Worker     case DeoptimizationKind::kCHA: return "class hierarchy analysis";
47*795d594fSAndroid Build Coastguard Worker     case DeoptimizationKind::kDebugging: return "Deopt requested for debug support";
48*795d594fSAndroid Build Coastguard Worker     case DeoptimizationKind::kFullFrame: return "full frame";
49*795d594fSAndroid Build Coastguard Worker   }
50*795d594fSAndroid Build Coastguard Worker   LOG(FATAL) << "Unexpected kind " << static_cast<size_t>(kind);
51*795d594fSAndroid Build Coastguard Worker   UNREACHABLE();
52*795d594fSAndroid Build Coastguard Worker }
53*795d594fSAndroid Build Coastguard Worker 
54*795d594fSAndroid Build Coastguard Worker std::ostream& operator<<(std::ostream& os, const DeoptimizationKind& kind);
55*795d594fSAndroid Build Coastguard Worker 
56*795d594fSAndroid Build Coastguard Worker // We use a DeoptimizationStackSlot to record if a deoptimization is required
57*795d594fSAndroid Build Coastguard Worker // for functions that are already on stack. The value in the slot specifies the
58*795d594fSAndroid Build Coastguard Worker // reason we need to deoptimize.
59*795d594fSAndroid Build Coastguard Worker enum class DeoptimizeFlagValue: uint8_t {
60*795d594fSAndroid Build Coastguard Worker   kCHA = 0b001,
61*795d594fSAndroid Build Coastguard Worker   kForceDeoptForRedefinition = 0b010,
62*795d594fSAndroid Build Coastguard Worker   kCheckCallerForDeopt = 0b100,
63*795d594fSAndroid Build Coastguard Worker   kAll = kCHA | kForceDeoptForRedefinition | kCheckCallerForDeopt
64*795d594fSAndroid Build Coastguard Worker };
65*795d594fSAndroid Build Coastguard Worker 
66*795d594fSAndroid Build Coastguard Worker }  // namespace art
67*795d594fSAndroid Build Coastguard Worker 
68*795d594fSAndroid Build Coastguard Worker #endif  // ART_RUNTIME_DEOPTIMIZATION_KIND_H_
69