LEFT | RIGHT |
1 // -*- C++ -*- | 1 // -*- C++ -*- |
2 #ifndef OPCODE_ATTRIBUTES_H_ | 2 #ifndef OPCODE_ATTRIBUTES_H_ |
3 #define OPCODE_ATTRIBUTES_H_ | 3 #define OPCODE_ATTRIBUTES_H_ |
4 | 4 |
5 #ifndef __cplusplus | 5 #ifndef __cplusplus |
6 #error This header expects to be included only in C++ source | 6 #error This header expects to be included only in C++ source |
7 #endif | 7 #endif |
8 | 8 |
9 #include "llvm/Support/IRBuilder.h" | 9 #include "llvm/Support/IRBuilder.h" |
10 #include "llvm/Support/TargetFolder.h" | 10 #include "llvm/Support/TargetFolder.h" |
11 | 11 |
12 namespace llvm { | 12 namespace llvm { |
13 class BasicBlock; | 13 class BasicBlock; |
14 class Value; | 14 class Value; |
15 } | 15 } |
16 | 16 |
| 17 class PyGlobalLlvmData; |
| 18 |
17 namespace py { | 19 namespace py { |
18 | 20 |
19 class LlvmFunctionBuilder; | 21 class LlvmFunctionBuilder; |
20 class LlvmFunctionState; | 22 class LlvmFunctionState; |
21 | 23 |
22 | 24 |
23 // Specifies which kind of attribute access we are performing, either load | 25 // Specifies which kind of attribute access we are performing, either load |
24 // or store. Eventually we may support delete, but they are rare enough | 26 // or store. Eventually we may support delete, but they are rare enough |
25 // that it is unlikely to be worth it. | 27 // that it is unlikely to be worth it. |
26 enum AttrAccessKind { | 28 enum AttrAccessKind { |
27 ATTR_ACCESS_LOAD, | 29 ATTR_ACCESS_LOAD, |
28 ATTR_ACCESS_STORE | 30 ATTR_ACCESS_STORE |
29 }; | 31 }; |
30 | |
31 | 32 |
32 // This class encapsulates the common data and code for doing optimized | 33 // This class encapsulates the common data and code for doing optimized |
33 // attribute access. This object helps perform checks, generate guard | 34 // attribute access. This object helps perform checks, generate guard |
34 // code, and register invalidation listeners when generating an optimized | 35 // code, and register invalidation listeners when generating an optimized |
35 // LOAD_ATTR or STORE_ATTR opcode. | 36 // LOAD_ATTR or STORE_ATTR opcode. |
36 class AttributeAccessor { | 37 class AttributeAccessor { |
37 public: | 38 public: |
38 // Construct an attribute accessor object. "name" is a reference to | 39 // Construct an attribute accessor object. "name" is a reference to |
39 // the attribute to access borrowed from co_names, and access_kind | 40 // the attribute to access borrowed from co_names, and access_kind |
40 // determines whether we are generating a LOAD_ATTR or STORE_ATTR | 41 // determines whether we are generating a LOAD_ATTR or STORE_ATTR |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 // LOAD/STORE_ATTR_safe always works, while LOAD/STORE_ATTR_fast is | 137 // LOAD/STORE_ATTR_safe always works, while LOAD/STORE_ATTR_fast is |
137 // optimized to skip the descriptor/method lookup on the type if the object | 138 // optimized to skip the descriptor/method lookup on the type if the object |
138 // type matches. It will return false if it fails. | 139 // type matches. It will return false if it fails. |
139 void LOAD_ATTR_safe(int names_index); | 140 void LOAD_ATTR_safe(int names_index); |
140 bool LOAD_ATTR_fast(int names_index); | 141 bool LOAD_ATTR_fast(int names_index); |
141 void STORE_ATTR_safe(int names_index); | 142 void STORE_ATTR_safe(int names_index); |
142 bool STORE_ATTR_fast(int names_index); | 143 bool STORE_ATTR_fast(int names_index); |
143 bool LOAD_METHOD_known(int names_index); | 144 bool LOAD_METHOD_known(int names_index); |
144 bool LOAD_METHOD_unknown(int names_index); | 145 bool LOAD_METHOD_unknown(int names_index); |
145 | 146 |
146 LlvmFunctionBuilder *fbuilder_; | 147 typedef llvm::IRBuilder<true, llvm::TargetFolder> BuilderT; |
| 148 |
| 149 LlvmFunctionBuilder *const fbuilder_; |
147 LlvmFunctionState *state_; | 150 LlvmFunctionState *state_; |
| 151 BuilderT &builder_; |
| 152 PyGlobalLlvmData *const llvm_data_; |
148 }; | 153 }; |
149 | 154 |
150 } | 155 } |
151 | 156 |
152 #endif /* OPCODE_ATTRIBUTES_H_ */ | 157 #endif /* OPCODE_ATTRIBUTES_H_ */ |
LEFT | RIGHT |