Phil Wang | 751beff | 2015-08-28 15:17:15 +0800 | [diff] [blame] | 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 | |
Andreas Gampe | 71da487 | 2017-07-26 10:02:07 -0700 | [diff] [blame] | 17 | #ifndef ART_SIMULATOR_INCLUDE_CODE_SIMULATOR_H_ |
| 18 | #define ART_SIMULATOR_INCLUDE_CODE_SIMULATOR_H_ |
Phil Wang | 751beff | 2015-08-28 15:17:15 +0800 | [diff] [blame] | 19 | |
| 20 | #include "arch/instruction_set.h" |
Ulyana Trafimovich | e886d68 | 2020-07-16 15:09:38 +0000 | [diff] [blame^] | 21 | #include "runtime.h" |
Phil Wang | 751beff | 2015-08-28 15:17:15 +0800 | [diff] [blame] | 22 | |
| 23 | namespace art { |
| 24 | |
Ulyana Trafimovich | e886d68 | 2020-07-16 15:09:38 +0000 | [diff] [blame^] | 25 | class ArtMethod; |
| 26 | union JValue; |
| 27 | class Thread; |
| 28 | struct QuickEntryPoints; |
| 29 | |
Phil Wang | 751beff | 2015-08-28 15:17:15 +0800 | [diff] [blame] | 30 | class 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 Trafimovich | e886d68 | 2020-07-16 15:09:38 +0000 | [diff] [blame^] | 44 | 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 Wang | 751beff | 2015-08-28 15:17:15 +0800 | [diff] [blame] | 51 | private: |
| 52 | DISALLOW_COPY_AND_ASSIGN(CodeSimulator); |
| 53 | }; |
| 54 | |
| 55 | extern "C" CodeSimulator* CreateCodeSimulator(InstructionSet target_isa); |
| 56 | |
| 57 | } // namespace art |
| 58 | |
Andreas Gampe | 71da487 | 2017-07-26 10:02:07 -0700 | [diff] [blame] | 59 | #endif // ART_SIMULATOR_INCLUDE_CODE_SIMULATOR_H_ |