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