xref: /aosp_15_r20/art/runtime/jit/jit-inl.h (revision 795d594fd825385562da6b089ea9b2033f3abf5a)
1 /*
2  * Copyright 2018 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_JIT_JIT_INL_H_
18 #define ART_RUNTIME_JIT_JIT_INL_H_
19 
20 #include "android-base/macros.h"
21 #include "jit/jit.h"
22 
23 #include "art_method.h"
24 #include "base/bit_utils.h"
25 #include "thread.h"
26 #include "runtime-inl.h"
27 
28 namespace art HIDDEN {
29 namespace jit {
30 
AddSamples(Thread * self,ArtMethod * method)31 inline void Jit::AddSamples(Thread* self, ArtMethod* method) {
32   // `hotness_count_` should always be 0 for intrinsics (which are considered hot from the first
33   // call), and for memory shared methods which use `shared_method_hotness`.
34   DCHECK_IMPLIES(method->IsIntrinsic(), method->CounterIsHot());
35   DCHECK_IMPLIES(method->IsMemorySharedMethod(), method->CounterIsHot());
36 
37   if (method->CounterIsHot()) {
38     if (method->IsMemorySharedMethod()) {
39       // Intrinsics do not use `shared_method_hotness`.
40       if (!method->IsIntrinsic()) {
41         if (self->DecrementSharedMethodHotness() == 0) {
42           self->ResetSharedMethodHotness();
43         } else {
44           return;
45         }
46       }
47     } else {
48       method->ResetCounter(Runtime::Current()->GetJITOptions()->GetWarmupThreshold());
49     }
50     MaybeEnqueueCompilation(method, self);
51   } else {
52     method->UpdateCounter(1);
53   }
54 }
55 
56 }  // namespace jit
57 }  // namespace art
58 
59 #endif  // ART_RUNTIME_JIT_JIT_INL_H_
60