blob: b09a762f11b0b4548e8404afe009129791d0d654 [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,
Brian Carlstrom3320cf42011-10-04 14:58:28 -070019 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 Carlstrom3320cf42011-10-04 14:58:28 -070028 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 Carlstrom3320cf42011-10-04 14:58:28 -070036 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 Carlstrom3320cf42011-10-04 14:58:28 -070040 // 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 Rogers169c9a72011-11-13 20:13:17 -080057 const InstructionSet instruction_set_;
Brian Carlstrom3320cf42011-10-04 14:58:28 -070058 std::vector<uint8_t> code_;
Ian Rogers169c9a72011-11-13 20:13:17 -080059 const size_t frame_size_in_bytes_;
60 const uint32_t core_spill_mask_;
61 const uint32_t fp_spill_mask_;
Brian Carlstrom3320cf42011-10-04 14:58:28 -070062 std::vector<uint32_t> mapping_table_;
63 std::vector<uint16_t> vmap_table_;
64};
65
66class CompiledInvokeStub {
67 public:
Elliott Hughesa51a3dd2011-10-17 15:19:26 -070068 explicit CompiledInvokeStub(std::vector<uint8_t>& code);
Brian Carlstrom3320cf42011-10-04 14:58:28 -070069 ~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