xref: /aosp_15_r20/art/compiler/jni/quick/jni_compiler.h (revision 795d594fd825385562da6b089ea9b2033f3abf5a)
1*795d594fSAndroid Build Coastguard Worker /*
2*795d594fSAndroid Build Coastguard Worker  * Copyright (C) 2011 The Android Open Source Project
3*795d594fSAndroid Build Coastguard Worker  *
4*795d594fSAndroid Build Coastguard Worker  * Licensed under the Apache License, Version 2.0 (the "License");
5*795d594fSAndroid Build Coastguard Worker  * you may not use this file except in compliance with the License.
6*795d594fSAndroid Build Coastguard Worker  * You may obtain a copy of the License at
7*795d594fSAndroid Build Coastguard Worker  *
8*795d594fSAndroid Build Coastguard Worker  *      http://www.apache.org/licenses/LICENSE-2.0
9*795d594fSAndroid Build Coastguard Worker  *
10*795d594fSAndroid Build Coastguard Worker  * Unless required by applicable law or agreed to in writing, software
11*795d594fSAndroid Build Coastguard Worker  * distributed under the License is distributed on an "AS IS" BASIS,
12*795d594fSAndroid Build Coastguard Worker  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13*795d594fSAndroid Build Coastguard Worker  * See the License for the specific language governing permissions and
14*795d594fSAndroid Build Coastguard Worker  * limitations under the License.
15*795d594fSAndroid Build Coastguard Worker  */
16*795d594fSAndroid Build Coastguard Worker 
17*795d594fSAndroid Build Coastguard Worker #ifndef ART_COMPILER_JNI_QUICK_JNI_COMPILER_H_
18*795d594fSAndroid Build Coastguard Worker #define ART_COMPILER_JNI_QUICK_JNI_COMPILER_H_
19*795d594fSAndroid Build Coastguard Worker 
20*795d594fSAndroid Build Coastguard Worker #include <vector>
21*795d594fSAndroid Build Coastguard Worker 
22*795d594fSAndroid Build Coastguard Worker #include "arch/instruction_set.h"
23*795d594fSAndroid Build Coastguard Worker #include "base/array_ref.h"
24*795d594fSAndroid Build Coastguard Worker #include "base/macros.h"
25*795d594fSAndroid Build Coastguard Worker 
26*795d594fSAndroid Build Coastguard Worker namespace art HIDDEN {
27*795d594fSAndroid Build Coastguard Worker 
28*795d594fSAndroid Build Coastguard Worker class ArenaAllocator;
29*795d594fSAndroid Build Coastguard Worker class ArtMethod;
30*795d594fSAndroid Build Coastguard Worker class CompilerOptions;
31*795d594fSAndroid Build Coastguard Worker class DexFile;
32*795d594fSAndroid Build Coastguard Worker 
33*795d594fSAndroid Build Coastguard Worker class JniCompiledMethod {
34*795d594fSAndroid Build Coastguard Worker  public:
JniCompiledMethod(InstructionSet instruction_set,std::vector<uint8_t> && code,uint32_t frame_size,uint32_t core_spill_mask,uint32_t fp_spill_mask,ArrayRef<const uint8_t> cfi)35*795d594fSAndroid Build Coastguard Worker   JniCompiledMethod(InstructionSet instruction_set,
36*795d594fSAndroid Build Coastguard Worker                     std::vector<uint8_t>&& code,
37*795d594fSAndroid Build Coastguard Worker                     uint32_t frame_size,
38*795d594fSAndroid Build Coastguard Worker                     uint32_t core_spill_mask,
39*795d594fSAndroid Build Coastguard Worker                     uint32_t fp_spill_mask,
40*795d594fSAndroid Build Coastguard Worker                     ArrayRef<const uint8_t> cfi)
41*795d594fSAndroid Build Coastguard Worker       : instruction_set_(instruction_set),
42*795d594fSAndroid Build Coastguard Worker         code_(std::move(code)),
43*795d594fSAndroid Build Coastguard Worker         frame_size_(frame_size),
44*795d594fSAndroid Build Coastguard Worker         core_spill_mask_(core_spill_mask),
45*795d594fSAndroid Build Coastguard Worker         fp_spill_mask_(fp_spill_mask),
46*795d594fSAndroid Build Coastguard Worker         cfi_(cfi.begin(), cfi.end()) {}
47*795d594fSAndroid Build Coastguard Worker 
48*795d594fSAndroid Build Coastguard Worker   JniCompiledMethod(JniCompiledMethod&& other) = default;
49*795d594fSAndroid Build Coastguard Worker   ~JniCompiledMethod() = default;
50*795d594fSAndroid Build Coastguard Worker 
GetInstructionSet()51*795d594fSAndroid Build Coastguard Worker   InstructionSet GetInstructionSet() const { return instruction_set_; }
GetCode()52*795d594fSAndroid Build Coastguard Worker   ArrayRef<const uint8_t> GetCode() const { return ArrayRef<const uint8_t>(code_); }
GetFrameSize()53*795d594fSAndroid Build Coastguard Worker   uint32_t GetFrameSize() const { return frame_size_; }
GetCoreSpillMask()54*795d594fSAndroid Build Coastguard Worker   uint32_t GetCoreSpillMask() const { return core_spill_mask_; }
GetFpSpillMask()55*795d594fSAndroid Build Coastguard Worker   uint32_t GetFpSpillMask() const { return fp_spill_mask_; }
GetCfi()56*795d594fSAndroid Build Coastguard Worker   ArrayRef<const uint8_t> GetCfi() const { return ArrayRef<const uint8_t>(cfi_); }
57*795d594fSAndroid Build Coastguard Worker 
58*795d594fSAndroid Build Coastguard Worker  private:
59*795d594fSAndroid Build Coastguard Worker   InstructionSet instruction_set_;
60*795d594fSAndroid Build Coastguard Worker   std::vector<uint8_t> code_;
61*795d594fSAndroid Build Coastguard Worker   uint32_t frame_size_;
62*795d594fSAndroid Build Coastguard Worker   uint32_t core_spill_mask_;
63*795d594fSAndroid Build Coastguard Worker   uint32_t fp_spill_mask_;
64*795d594fSAndroid Build Coastguard Worker   std::vector<uint8_t> cfi_;
65*795d594fSAndroid Build Coastguard Worker };
66*795d594fSAndroid Build Coastguard Worker 
67*795d594fSAndroid Build Coastguard Worker JniCompiledMethod ArtQuickJniCompileMethod(const CompilerOptions& compiler_options,
68*795d594fSAndroid Build Coastguard Worker                                            std::string_view shorty,
69*795d594fSAndroid Build Coastguard Worker                                            uint32_t access_flags,
70*795d594fSAndroid Build Coastguard Worker                                            ArenaAllocator* allocator);
71*795d594fSAndroid Build Coastguard Worker 
72*795d594fSAndroid Build Coastguard Worker }  // namespace art
73*795d594fSAndroid Build Coastguard Worker 
74*795d594fSAndroid Build Coastguard Worker #endif  // ART_COMPILER_JNI_QUICK_JNI_COMPILER_H_
75