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 
22 namespace art {
23 
24 enum class DeoptimizationKind {
25   kAotInlineCache = 0,
26   kJitInlineCache,
27   kJitSameTarget,
28   kLoopBoundsBCE,
29   kLoopNullBCE,
30   kBlockBCE,
31   kCHA,
32   kFullFrame,
33   kLast = kFullFrame
34 };
35 
GetDeoptimizationKindName(DeoptimizationKind kind)36 inline const char* GetDeoptimizationKindName(DeoptimizationKind kind) {
37   switch (kind) {
38     case DeoptimizationKind::kAotInlineCache: return "AOT inline cache";
39     case DeoptimizationKind::kJitInlineCache: return "JIT inline cache";
40     case DeoptimizationKind::kJitSameTarget: return "JIT same target";
41     case DeoptimizationKind::kLoopBoundsBCE: return "loop bounds check elimination";
42     case DeoptimizationKind::kLoopNullBCE: return "loop bounds check elimination on null";
43     case DeoptimizationKind::kBlockBCE: return "block bounds check elimination";
44     case DeoptimizationKind::kCHA: return "class hierarchy analysis";
45     case DeoptimizationKind::kFullFrame: return "full frame";
46   }
47   LOG(FATAL) << "Unexpected kind " << static_cast<size_t>(kind);
48   UNREACHABLE();
49 }
50 
51 std::ostream& operator<<(std::ostream& os, const DeoptimizationKind& kind);
52 
53 }  // namespace art
54 
55 #endif  // ART_RUNTIME_DEOPTIMIZATION_KIND_H_
56