blob: e228ca8a9e6c96cdf98f0885db553bf390d0acf5 [file] [log] [blame]
Brian Carlstrom3320cf42011-10-04 14:58:28 -07001// 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
11namespace art {
12
13class 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,
19 const size_t return_pc_offset_in_bytes,
20 const uint32_t core_spill_mask,
21 const uint32_t fp_spill_mask,
22 std::vector<uint32_t>& mapping_table,
23 std::vector<uint16_t>& vmap_table);
24
25 // Create an CompiledMethod from the JniCompiler
26 CompiledMethod(InstructionSet instruction_set,
27 std::vector<uint8_t>& code,
28 const size_t frame_size_in_bytes,
29 const size_t return_pc_offset_in_bytes,
30 const uint32_t core_spill_mask,
31 const uint32_t fp_spill_mask);
32
33 ~CompiledMethod();
34
35 InstructionSet GetInstructionSet() const;
36 const std::vector<uint8_t>& GetCode() const;
37 size_t GetFrameSizeInBytes() const;
38 size_t GetReturnPcOffsetInBytes() const;
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;
43
44 // Aligns an offset from a page aligned value to make it suitable
45 // for code storage. important to ensure that PC relative value
46 // computations work out as expected on ARM.
47 uint32_t AlignCode(uint32_t offset) const;
48 static uint32_t AlignCode(uint32_t offset, InstructionSet instruction_set);
49
50 // returns the difference between the code address and a usable PC.
51 // mainly to cope with kThumb2 where the lower bit must be set.
52 size_t CodeDelta() const;
53
54 // Returns a pointer suitable for invoking the code at the argument
55 // code_pointer address. Mainly to cope with kThumb2 where the
56 // lower bit must be set to indicate Thumb mode.
57 static const void* CodePointer(const void* code_pointer,
58 InstructionSet instruction_set);
59
60 private:
61 InstructionSet instruction_set_;
62 std::vector<uint8_t> code_;
63 size_t frame_size_in_bytes_;
64 size_t return_pc_offset_in_bytes_;
65 uint32_t core_spill_mask_;
66 uint32_t fp_spill_mask_;
67 std::vector<uint32_t> mapping_table_;
68 std::vector<uint16_t> vmap_table_;
69};
70
71class CompiledInvokeStub {
72 public:
73 CompiledInvokeStub(std::vector<uint8_t>& code);
74 ~CompiledInvokeStub();
75 const std::vector<uint8_t>& GetCode() const;
76 private:
77 std::vector<uint8_t> code_;
78};
79
80} // namespace art
81
82#endif // ART_SRC_COMPILED_METHOD_H_
83