• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2015 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_SIMULATOR_CODE_SIMULATOR_CONTAINER_H_
18 #define ART_SIMULATOR_CODE_SIMULATOR_CONTAINER_H_
19 
20 #include <android-base/logging.h>
21 
22 #include "arch/instruction_set.h"
23 
24 namespace art {
25 
26 class CodeSimulator;
27 
28 // This container dynamically opens and closes libart-simulator.
29 class CodeSimulatorContainer {
30  public:
31   explicit CodeSimulatorContainer(InstructionSet target_isa);
32   ~CodeSimulatorContainer();
33 
CanSimulate()34   bool CanSimulate() const {
35     return simulator_ != nullptr;
36   }
37 
Get()38   CodeSimulator* Get() {
39     DCHECK(CanSimulate());
40     return simulator_;
41   }
42 
Get()43   const CodeSimulator* Get() const {
44     DCHECK(CanSimulate());
45     return simulator_;
46   }
47 
48  private:
49   void* libart_simulator_handle_;
50   CodeSimulator* simulator_;
51 
52   DISALLOW_COPY_AND_ASSIGN(CodeSimulatorContainer);
53 };
54 
55 }  // namespace art
56 
57 #endif  // ART_SIMULATOR_CODE_SIMULATOR_CONTAINER_H_
58