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