OLD | NEW |
| (Empty) |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | |
2 // for details. All rights reserved. Use of this source code is governed by a | |
3 // BSD-style license that can be found in the LICENSE file. | |
4 // Classes that describe assembly patterns as used by inline caches. | |
5 | |
6 #ifndef RUNTIME_VM_INSTRUCTIONS_MIPS_H_ | |
7 #define RUNTIME_VM_INSTRUCTIONS_MIPS_H_ | |
8 | |
9 #ifndef RUNTIME_VM_INSTRUCTIONS_H_ | |
10 #error Do not include instructions_mips.h directly; use instructions.h instead. | |
11 #endif | |
12 | |
13 #include "vm/constants_mips.h" | |
14 #include "vm/native_entry.h" | |
15 #include "vm/object.h" | |
16 | |
17 namespace dart { | |
18 | |
19 class InstructionPattern : public AllStatic { | |
20 public: | |
21 // Decodes a load sequence ending at 'end' (the last instruction of the | |
22 // load sequence is the instruction before the one at end). Returns the | |
23 // address of the first instruction in the sequence. Returns the register | |
24 // being loaded and the loaded object in the output parameters 'reg' and | |
25 // 'obj' respectively. | |
26 static uword DecodeLoadObject(uword end, | |
27 const ObjectPool& object_pool, | |
28 Register* reg, | |
29 Object* obj); | |
30 | |
31 // Decodes a load sequence ending at 'end' (the last instruction of the | |
32 // load sequence is the instruction before the one at end). Returns the | |
33 // address of the first instruction in the sequence. Returns the register | |
34 // being loaded and the loaded immediate value in the output parameters | |
35 // 'reg' and 'value' respectively. | |
36 static uword DecodeLoadWordImmediate(uword end, | |
37 Register* reg, | |
38 intptr_t* value); | |
39 | |
40 // Decodes a load sequence ending at 'end' (the last instruction of the | |
41 // load sequence is the instruction before the one at end). Returns the | |
42 // address of the first instruction in the sequence. Returns the register | |
43 // being loaded and the index in the pool being read from in the output | |
44 // parameters 'reg' and 'index' respectively. | |
45 static uword DecodeLoadWordFromPool(uword end, | |
46 Register* reg, | |
47 intptr_t* index); | |
48 }; | |
49 | |
50 | |
51 class CallPattern : public ValueObject { | |
52 public: | |
53 CallPattern(uword pc, const Code& code); | |
54 | |
55 RawICData* IcData(); | |
56 | |
57 RawCode* TargetCode() const; | |
58 void SetTargetCode(const Code& target) const; | |
59 | |
60 private: | |
61 const ObjectPool& object_pool_; | |
62 | |
63 uword end_; | |
64 uword ic_data_load_end_; | |
65 | |
66 intptr_t target_code_pool_index_; | |
67 ICData& ic_data_; | |
68 | |
69 DISALLOW_COPY_AND_ASSIGN(CallPattern); | |
70 }; | |
71 | |
72 | |
73 class NativeCallPattern : public ValueObject { | |
74 public: | |
75 NativeCallPattern(uword pc, const Code& code); | |
76 | |
77 RawCode* target() const; | |
78 void set_target(const Code& target) const; | |
79 | |
80 NativeFunction native_function() const; | |
81 void set_native_function(NativeFunction target) const; | |
82 | |
83 private: | |
84 const ObjectPool& object_pool_; | |
85 | |
86 uword end_; | |
87 intptr_t native_function_pool_index_; | |
88 intptr_t target_code_pool_index_; | |
89 | |
90 DISALLOW_COPY_AND_ASSIGN(NativeCallPattern); | |
91 }; | |
92 | |
93 | |
94 // Instance call that can switch between a direct monomorphic call, an IC call, | |
95 // and a megamorphic call. | |
96 // load guarded cid load ICData load MegamorphicCache | |
97 // load monomorphic target <-> load ICLookup stub -> load MMLookup stub | |
98 // call target.entry call stub.entry call stub.entry | |
99 class SwitchableCallPattern : public ValueObject { | |
100 public: | |
101 SwitchableCallPattern(uword pc, const Code& code); | |
102 | |
103 RawObject* data() const; | |
104 RawCode* target() const; | |
105 void SetData(const Object& data) const; | |
106 void SetTarget(const Code& target) const; | |
107 | |
108 private: | |
109 const ObjectPool& object_pool_; | |
110 intptr_t data_pool_index_; | |
111 intptr_t target_pool_index_; | |
112 | |
113 DISALLOW_COPY_AND_ASSIGN(SwitchableCallPattern); | |
114 }; | |
115 | |
116 | |
117 class ReturnPattern : public ValueObject { | |
118 public: | |
119 explicit ReturnPattern(uword pc); | |
120 | |
121 // jr(RA) = 1 | |
122 static const int kLengthInBytes = 1 * Instr::kInstrSize; | |
123 | |
124 int pattern_length_in_bytes() const { return kLengthInBytes; } | |
125 | |
126 bool IsValid() const; | |
127 | |
128 private: | |
129 const uword pc_; | |
130 }; | |
131 | |
132 } // namespace dart | |
133 | |
134 #endif // RUNTIME_VM_INSTRUCTIONS_MIPS_H_ | |
OLD | NEW |