Elliott Hughes | 2faa5f1 | 2012-01-30 14:42:07 -0800 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright (C) 2011 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 | */ |
Brian Carlstrom | 3320cf4 | 2011-10-04 14:58:28 -0700 | [diff] [blame] | 16 | |
| 17 | #ifndef ART_SRC_COMPILED_METHOD_H_ |
| 18 | #define ART_SRC_COMPILED_METHOD_H_ |
| 19 | |
| 20 | #include <vector> |
| 21 | |
| 22 | #include "constants.h" |
| 23 | #include "utils.h" |
| 24 | |
| 25 | namespace art { |
| 26 | |
| 27 | class CompiledMethod { |
| 28 | public: |
Brian Carlstrom | 0755ec5 | 2012-01-11 15:19:46 -0800 | [diff] [blame] | 29 | // Create a CompiledMethod from the oatCompileMethod |
Brian Carlstrom | 3320cf4 | 2011-10-04 14:58:28 -0700 | [diff] [blame] | 30 | CompiledMethod(InstructionSet instruction_set, |
Brian Carlstrom | e7d856b | 2012-01-11 18:10:55 -0800 | [diff] [blame] | 31 | const std::vector<uint16_t>& code, |
Brian Carlstrom | 3320cf4 | 2011-10-04 14:58:28 -0700 | [diff] [blame] | 32 | const size_t frame_size_in_bytes, |
Brian Carlstrom | 3320cf4 | 2011-10-04 14:58:28 -0700 | [diff] [blame] | 33 | const uint32_t core_spill_mask, |
| 34 | const uint32_t fp_spill_mask, |
Brian Carlstrom | e7d856b | 2012-01-11 18:10:55 -0800 | [diff] [blame] | 35 | const std::vector<uint32_t>& mapping_table, |
| 36 | const std::vector<uint16_t>& vmap_table); |
| 37 | |
| 38 | // Add a GC map to a CompiledMethod created by oatCompileMethod |
| 39 | void SetGcMap(const std::vector<uint8_t>& gc_map); |
Brian Carlstrom | 3320cf4 | 2011-10-04 14:58:28 -0700 | [diff] [blame] | 40 | |
Brian Carlstrom | 0755ec5 | 2012-01-11 15:19:46 -0800 | [diff] [blame] | 41 | // Create a CompiledMethod from the JniCompiler |
Brian Carlstrom | 3320cf4 | 2011-10-04 14:58:28 -0700 | [diff] [blame] | 42 | CompiledMethod(InstructionSet instruction_set, |
Brian Carlstrom | e7d856b | 2012-01-11 18:10:55 -0800 | [diff] [blame] | 43 | const std::vector<uint8_t>& code, |
Brian Carlstrom | 3320cf4 | 2011-10-04 14:58:28 -0700 | [diff] [blame] | 44 | const size_t frame_size_in_bytes, |
Brian Carlstrom | 3320cf4 | 2011-10-04 14:58:28 -0700 | [diff] [blame] | 45 | const uint32_t core_spill_mask, |
| 46 | const uint32_t fp_spill_mask); |
| 47 | |
| 48 | ~CompiledMethod(); |
| 49 | |
| 50 | InstructionSet GetInstructionSet() const; |
| 51 | const std::vector<uint8_t>& GetCode() const; |
| 52 | size_t GetFrameSizeInBytes() const; |
Brian Carlstrom | 3320cf4 | 2011-10-04 14:58:28 -0700 | [diff] [blame] | 53 | uint32_t GetCoreSpillMask() const; |
| 54 | uint32_t GetFpSpillMask() const; |
| 55 | const std::vector<uint32_t>& GetMappingTable() const; |
| 56 | const std::vector<uint16_t>& GetVmapTable() const; |
Brian Carlstrom | e7d856b | 2012-01-11 18:10:55 -0800 | [diff] [blame] | 57 | const std::vector<uint8_t>& GetGcMap() const; |
| 58 | |
Brian Carlstrom | 3320cf4 | 2011-10-04 14:58:28 -0700 | [diff] [blame] | 59 | // Aligns an offset from a page aligned value to make it suitable |
| 60 | // for code storage. important to ensure that PC relative value |
| 61 | // computations work out as expected on ARM. |
| 62 | uint32_t AlignCode(uint32_t offset) const; |
| 63 | static uint32_t AlignCode(uint32_t offset, InstructionSet instruction_set); |
| 64 | |
| 65 | // returns the difference between the code address and a usable PC. |
| 66 | // mainly to cope with kThumb2 where the lower bit must be set. |
| 67 | size_t CodeDelta() const; |
| 68 | |
| 69 | // Returns a pointer suitable for invoking the code at the argument |
| 70 | // code_pointer address. Mainly to cope with kThumb2 where the |
| 71 | // lower bit must be set to indicate Thumb mode. |
| 72 | static const void* CodePointer(const void* code_pointer, |
| 73 | InstructionSet instruction_set); |
| 74 | |
| 75 | private: |
Ian Rogers | 169c9a7 | 2011-11-13 20:13:17 -0800 | [diff] [blame] | 76 | const InstructionSet instruction_set_; |
Brian Carlstrom | 3320cf4 | 2011-10-04 14:58:28 -0700 | [diff] [blame] | 77 | std::vector<uint8_t> code_; |
Ian Rogers | 169c9a7 | 2011-11-13 20:13:17 -0800 | [diff] [blame] | 78 | const size_t frame_size_in_bytes_; |
| 79 | const uint32_t core_spill_mask_; |
| 80 | const uint32_t fp_spill_mask_; |
Brian Carlstrom | 3320cf4 | 2011-10-04 14:58:28 -0700 | [diff] [blame] | 81 | std::vector<uint32_t> mapping_table_; |
| 82 | std::vector<uint16_t> vmap_table_; |
Brian Carlstrom | e7d856b | 2012-01-11 18:10:55 -0800 | [diff] [blame] | 83 | std::vector<uint8_t> gc_map_; |
Brian Carlstrom | 3320cf4 | 2011-10-04 14:58:28 -0700 | [diff] [blame] | 84 | }; |
| 85 | |
| 86 | class CompiledInvokeStub { |
| 87 | public: |
Elliott Hughes | a51a3dd | 2011-10-17 15:19:26 -0700 | [diff] [blame] | 88 | explicit CompiledInvokeStub(std::vector<uint8_t>& code); |
Brian Carlstrom | 3320cf4 | 2011-10-04 14:58:28 -0700 | [diff] [blame] | 89 | ~CompiledInvokeStub(); |
| 90 | const std::vector<uint8_t>& GetCode() const; |
| 91 | private: |
| 92 | std::vector<uint8_t> code_; |
| 93 | }; |
| 94 | |
| 95 | } // namespace art |
| 96 | |
| 97 | #endif // ART_SRC_COMPILED_METHOD_H_ |
| 98 | |