blob: 22bac1e83fc14358bb9ea99e0fc9786362ef8e71 [file] [log] [blame]
Phil Wang751beff2015-08-28 15:17:15 +08001/*
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
Andreas Gampe71da4872017-07-26 10:02:07 -070017#ifndef ART_SIMULATOR_INCLUDE_CODE_SIMULATOR_H_
18#define ART_SIMULATOR_INCLUDE_CODE_SIMULATOR_H_
Phil Wang751beff2015-08-28 15:17:15 +080019
20#include "arch/instruction_set.h"
Ulyana Trafimoviche886d682020-07-16 15:09:38 +000021#include "runtime.h"
Phil Wang751beff2015-08-28 15:17:15 +080022
23namespace art {
24
Ulyana Trafimoviche886d682020-07-16 15:09:38 +000025class ArtMethod;
26union JValue;
27class Thread;
28struct QuickEntryPoints;
29
Phil Wang751beff2015-08-28 15:17:15 +080030class CodeSimulator {
31 public:
32 CodeSimulator() {}
33 virtual ~CodeSimulator() {}
34 // Returns a null pointer if a simulator cannot be found for target_isa.
35 static CodeSimulator* CreateCodeSimulator(InstructionSet target_isa);
36
37 virtual void RunFrom(intptr_t code_buffer) = 0;
38
39 // Get return value according to C ABI.
40 virtual bool GetCReturnBool() const = 0;
41 virtual int32_t GetCReturnInt32() const = 0;
42 virtual int64_t GetCReturnInt64() const = 0;
43
Ulyana Trafimoviche886d682020-07-16 15:09:38 +000044 virtual bool CanSimulate(ArtMethod* method) REQUIRES_SHARED(Locks::mutator_lock_) = 0;
45 virtual void Invoke(ArtMethod* method, uint32_t* args, uint32_t args_size, Thread* self,
46 JValue* result, const char* shorty, bool isStatic)
47 REQUIRES_SHARED(Locks::mutator_lock_) = 0;
48
49 virtual void InitEntryPoints(QuickEntryPoints* qpoints) = 0;
50
Phil Wang751beff2015-08-28 15:17:15 +080051 private:
52 DISALLOW_COPY_AND_ASSIGN(CodeSimulator);
53};
54
55extern "C" CodeSimulator* CreateCodeSimulator(InstructionSet target_isa);
56
57} // namespace art
58
Andreas Gampe71da4872017-07-26 10:02:07 -070059#endif // ART_SIMULATOR_INCLUDE_CODE_SIMULATOR_H_