1 /*
2  * Copyright (C) 2013 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_COMPILER_DEX_QUICK_DEX_FILE_TO_METHOD_INLINER_MAP_H_
18 #define ART_COMPILER_DEX_QUICK_DEX_FILE_TO_METHOD_INLINER_MAP_H_
19 
20 #include <map>
21 #include <vector>
22 #include "base/macros.h"
23 #include "base/mutex.h"
24 
25 #include "dex/quick/dex_file_method_inliner.h"
26 
27 namespace art {
28 
29 class CompilerDriver;
30 class DexFile;
31 
32 /**
33  * Map each DexFile to its DexFileMethodInliner.
34  *
35  * The method inliner is created and initialized the first time it's requested
36  * for a particular DexFile.
37  */
38 class DexFileToMethodInlinerMap {
39   public:
40     DexFileToMethodInlinerMap();
41     ~DexFileToMethodInlinerMap();
42 
43     DexFileMethodInliner* GetMethodInliner(const DexFile* dex_file) NO_THREAD_SAFETY_ANALYSIS;
44         // TODO: There is an irregular non-scoped use of locks that defeats annotalysis with -O0.
45         // Fix the NO_THREAD_SAFETY_ANALYSIS when this works and add the appropriate LOCKS_EXCLUDED.
46 
47   private:
48     ReaderWriterMutex lock_;
49     std::map<const DexFile*, DexFileMethodInliner*> inliners_ GUARDED_BY(lock_);
50 
51     DISALLOW_COPY_AND_ASSIGN(DexFileToMethodInlinerMap);
52 };
53 
54 }  // namespace art
55 
56 #endif  // ART_COMPILER_DEX_QUICK_DEX_FILE_TO_METHOD_INLINER_MAP_H_
57