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