blob: 4528e52d5632352619840d51f20406949fe82994 [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:
Brian Carlstrom0755ec52012-01-11 15:19:46 -080015 // Create a CompiledMethod from the oatCompileMethod
Brian Carlstrom3320cf42011-10-04 14:58:28 -070016 CompiledMethod(InstructionSet instruction_set,
Brian Carlstrome7d856b2012-01-11 18:10:55 -080017 const std::vector<uint16_t>& code,
Brian Carlstrom3320cf42011-10-04 14:58:28 -070018 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,
Brian Carlstrome7d856b2012-01-11 18:10:55 -080021 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 Carlstrom3320cf42011-10-04 14:58:28 -070026
Brian Carlstrom0755ec52012-01-11 15:19:46 -080027 // Create a CompiledMethod from the JniCompiler
Brian Carlstrom3320cf42011-10-04 14:58:28 -070028 CompiledMethod(InstructionSet instruction_set,
Brian Carlstrome7d856b2012-01-11 18:10:55 -080029 const std::vector<uint8_t>& code,
Brian Carlstrom3320cf42011-10-04 14:58:28 -070030 const size_t frame_size_in_bytes,
Brian Carlstrom3320cf42011-10-04 14:58:28 -070031 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 Carlstrom3320cf42011-10-04 14:58:28 -070039 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 Carlstrome7d856b2012-01-11 18:10:55 -080043 const std::vector<uint8_t>& GetGcMap() const;
44
Brian Carlstrom3320cf42011-10-04 14:58:28 -070045 // 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 Rogers169c9a72011-11-13 20:13:17 -080062 const InstructionSet instruction_set_;
Brian Carlstrom3320cf42011-10-04 14:58:28 -070063 std::vector<uint8_t> code_;
Ian Rogers169c9a72011-11-13 20:13:17 -080064 const size_t frame_size_in_bytes_;
65 const uint32_t core_spill_mask_;
66 const uint32_t fp_spill_mask_;
Brian Carlstrom3320cf42011-10-04 14:58:28 -070067 std::vector<uint32_t> mapping_table_;
68 std::vector<uint16_t> vmap_table_;
Brian Carlstrome7d856b2012-01-11 18:10:55 -080069 std::vector<uint8_t> gc_map_;
Brian Carlstrom3320cf42011-10-04 14:58:28 -070070};
71
72class CompiledInvokeStub {
73 public:
Elliott Hughesa51a3dd2011-10-17 15:19:26 -070074 explicit CompiledInvokeStub(std::vector<uint8_t>& code);
Brian Carlstrom3320cf42011-10-04 14:58:28 -070075 ~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