Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(132)

Side by Side Diff: runtime/vm/intermediate_language.h

Issue 12221139: Revert "Remove SminessPropagator and FlowGraphTypePropagator and all associated infrastructure and … (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/vm/il_printer.cc ('k') | runtime/vm/intermediate_language.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 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 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. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #ifndef VM_INTERMEDIATE_LANGUAGE_H_ 5 #ifndef VM_INTERMEDIATE_LANGUAGE_H_
6 #define VM_INTERMEDIATE_LANGUAGE_H_ 6 #define VM_INTERMEDIATE_LANGUAGE_H_
7 7
8 #include "vm/allocation.h" 8 #include "vm/allocation.h"
9 #include "vm/ast.h" 9 #include "vm/ast.h"
10 #include "vm/growable_array.h" 10 #include "vm/growable_array.h"
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 #define DEFINE_ENUM_LIST(class_name, function_name, enum_name, fp) k##enum_name, 70 #define DEFINE_ENUM_LIST(class_name, function_name, enum_name, fp) k##enum_name,
71 RECOGNIZED_LIST(DEFINE_ENUM_LIST) 71 RECOGNIZED_LIST(DEFINE_ENUM_LIST)
72 #undef DEFINE_ENUM_LIST 72 #undef DEFINE_ENUM_LIST
73 }; 73 };
74 74
75 static Kind RecognizeKind(const Function& function); 75 static Kind RecognizeKind(const Function& function);
76 static const char* KindToCString(Kind kind); 76 static const char* KindToCString(Kind kind);
77 }; 77 };
78 78
79 79
80 // CompileType describes type of the value produced by the definition.
81 //
82 // It captures the following properties:
83 // - whether value can potentially be null or it is definitely not null;
84 // - concrete class id of the value or kDynamicCid if unknown statically;
85 // - abstract super type of the value, concrete type of the value in runtime
86 // is guaranteed to be sub type of this type.
87 //
88 // Values of CompileType form a lattice with a None type as a bottom and a
89 // nullable Dynamic type as a top element. Method Union provides a join
90 // operation for the lattice.
91 class CompileType : public ZoneAllocated {
92 public:
93 static const bool kNullable = true;
94 static const bool kNonNullable = false;
95
96 // Return type such that concrete value's type in runtime is guaranteed to
97 // be subtype of it.
98 const AbstractType* ToAbstractType();
99
100 // Return class id such that it is either kDynamicCid or in runtime
101 // value is guaranteed to have an equal class id.
102 intptr_t ToCid();
103
104 // Return class id such that it is either kDynamicCid or in runtime
105 // value is guaranteed to be either null or have an equal class id.
106 intptr_t ToNullableCid();
107
108 // Returns true if the value is guaranteed to be not-null or is known to be
109 // always null.
110 bool HasDecidableNullability();
111
112 // Returns true if the value is known to be always null.
113 bool IsNull();
114
115 // Returns true if this type is more specific than given type.
116 bool IsMoreSpecificThan(const AbstractType& other);
117
118 // Returns true if value of this type is assignable to a location of the
119 // given type.
120 bool IsAssignableTo(const AbstractType& type) {
121 bool is_instance;
122 return CanComputeIsInstanceOf(type, kNullable, &is_instance) &&
123 is_instance;
124 }
125
126 // Create a new CompileType representing given combination of class id and
127 // abstract type. The pair is assumed to be coherent.
128 static CompileType* New(intptr_t cid, const AbstractType& type);
129
130 // Create a new CompileType representing given abstract type. By default
131 // values as assumed to be nullable.
132 static CompileType* FromAbstractType(const AbstractType& type,
133 bool is_nullable = kNullable);
134
135 // Create a new CompileType representing an value with the given class id.
136 // Resulting CompileType is nullable only if cid is kDynamicCid or kNullCid.
137 static CompileType* FromCid(intptr_t cid);
138
139 // Create None CompileType. It is the bottom of the lattice and is used to
140 // represent type of the phi that was not yet inferred.
141 static CompileType* None() {
142 return new CompileType(true, kIllegalCid, NULL);
143 }
144
145 // Create Dynamic CompileType. It is the top of the lattice and is used to
146 // represent unknown type.
147 static CompileType* Dynamic();
148
149 static CompileType* Null();
150
151 // Create non-nullable Bool type.
152 static CompileType* Bool();
153
154 // Create non-nullable Int type.
155 static CompileType* Int();
156
157 // Perform a join operation over the type lattice.
158 void Union(CompileType* other);
159
160 // Returns true if this and other types are the same.
161 bool IsEqualTo(CompileType* other) {
162 return (is_nullable_ == other->is_nullable_) &&
163 (ToNullableCid() == other->ToNullableCid()) &&
164 (ToAbstractType()->Equals(*other->ToAbstractType()));
165 }
166
167 // Replaces this type with other.
168 void ReplaceWith(CompileType* other) {
169 is_nullable_ = other->is_nullable_;
170 cid_ = other->cid_;
171 type_ = other->type_;
172 }
173
174 bool IsNone() const {
175 return (cid_ == kIllegalCid) && (type_ == NULL);
176 }
177
178 void PrintTo(BufferFormatter* f) const;
179 const char* ToCString() const;
180
181 private:
182 CompileType(bool is_nullable, intptr_t cid, const AbstractType* type)
183 : is_nullable_(is_nullable), cid_(cid), type_(type) { }
184
185 bool CanComputeIsInstanceOf(const AbstractType& type,
186 bool is_nullable,
187 bool* is_instance);
188
189 bool is_nullable_;
190 intptr_t cid_;
191 const AbstractType* type_;
192 };
193
194
195 class Value : public ZoneAllocated { 80 class Value : public ZoneAllocated {
196 public: 81 public:
197 // A forward iterator that allows removing the current value from the 82 // A forward iterator that allows removing the current value from the
198 // underlying use list during iteration. 83 // underlying use list during iteration.
199 class Iterator { 84 class Iterator {
200 public: 85 public:
201 explicit Iterator(Value* head) : next_(head) { Advance(); } 86 explicit Iterator(Value* head) : next_(head) { Advance(); }
202 Value* Current() const { return current_; } 87 Value* Current() const { return current_; }
203 bool Done() const { return current_ == NULL; } 88 bool Done() const { return current_ == NULL; }
204 void Advance() { 89 void Advance() {
205 // Pre-fetch next on advance and cache it. 90 // Pre-fetch next on advance and cache it.
206 current_ = next_; 91 current_ = next_;
207 if (next_ != NULL) next_ = next_->next_use(); 92 if (next_ != NULL) next_ = next_->next_use();
208 } 93 }
209 private: 94 private:
210 Value* current_; 95 Value* current_;
211 Value* next_; 96 Value* next_;
212 }; 97 };
213 98
214 explicit Value(Definition* definition) 99 explicit Value(Definition* definition)
215 : definition_(definition), 100 : definition_(definition),
216 previous_use_(NULL), 101 previous_use_(NULL),
217 next_use_(NULL), 102 next_use_(NULL),
218 instruction_(NULL), 103 instruction_(NULL),
219 use_index_(-1), 104 use_index_(-1),
220 reaching_type_(NULL) { } 105 reaching_cid_(kIllegalCid) { }
221 106
222 Definition* definition() const { return definition_; } 107 Definition* definition() const { return definition_; }
223 void set_definition(Definition* definition) { definition_ = definition; } 108 void set_definition(Definition* definition) { definition_ = definition; }
224 109
225 Value* previous_use() const { return previous_use_; } 110 Value* previous_use() const { return previous_use_; }
226 void set_previous_use(Value* previous) { previous_use_ = previous; } 111 void set_previous_use(Value* previous) { previous_use_ = previous; }
227 112
228 Value* next_use() const { return next_use_; } 113 Value* next_use() const { return next_use_; }
229 void set_next_use(Value* next) { next_use_ = next; } 114 void set_next_use(Value* next) { next_use_ = next; }
230 115
231 Instruction* instruction() const { return instruction_; } 116 Instruction* instruction() const { return instruction_; }
232 void set_instruction(Instruction* instruction) { instruction_ = instruction; } 117 void set_instruction(Instruction* instruction) { instruction_ = instruction; }
233 118
234 intptr_t use_index() const { return use_index_; } 119 intptr_t use_index() const { return use_index_; }
235 void set_use_index(intptr_t index) { use_index_ = index; } 120 void set_use_index(intptr_t index) { use_index_ = index; }
236 121
237 static void AddToList(Value* value, Value** list); 122 static void AddToList(Value* value, Value** list);
238 void RemoveFromUseList(); 123 void RemoveFromUseList();
239 124
240 Value* Copy() { return new Value(definition_); } 125 Value* Copy() { return new Value(definition_); }
241 126
242 CompileType* Type(); 127 RawAbstractType* CompileType() const;
243 128 intptr_t ResultCid() const;
244 void SetReachingType(CompileType* type) {
245 reaching_type_ = type;
246 }
247 129
248 void PrintTo(BufferFormatter* f) const; 130 void PrintTo(BufferFormatter* f) const;
249 131
250 const char* DebugName() const { return "Value"; } 132 const char* DebugName() const { return "Value"; }
251 133
252 // Return true if the value represents a constant. 134 // Return true if the value represents a constant.
253 bool BindsToConstant() const; 135 bool BindsToConstant() const;
254 136
255 // Return true if the value represents the constant null. 137 // Return true if the value represents the constant null.
256 bool BindsToConstantNull() const; 138 bool BindsToConstantNull() const;
257 139
258 // Assert if BindsToConstant() is false, otherwise returns the constant value. 140 // Assert if BindsToConstant() is false, otherwise returns the constant value.
259 const Object& BoundConstant() const; 141 const Object& BoundConstant() const;
260 142
143 // Compute a run-time null test at compile-time and set result in is_null.
144 // Return false if the computation is not possible at compile time.
145 bool CanComputeIsNull(bool* is_null) const;
146
147 // Compute a run-time type test at compile-time and set result in is_instance.
148 // Return false if the computation is not possible at compile time.
149 bool CanComputeIsInstanceOf(const AbstractType& type,
150 bool* is_instance) const;
151
261 // Compile time constants, Bool, Smi and Nulls do not need to update 152 // Compile time constants, Bool, Smi and Nulls do not need to update
262 // the store buffer. 153 // the store buffer.
263 bool NeedsStoreBuffer(); 154 bool NeedsStoreBuffer() const;
264 155
265 bool Equals(Value* other) const; 156 bool Equals(Value* other) const;
266 157
158 void set_reaching_cid(intptr_t cid) { reaching_cid_ = cid; }
159 intptr_t reaching_cid() const { return reaching_cid_; }
160
267 private: 161 private:
268 Definition* definition_; 162 Definition* definition_;
269 Value* previous_use_; 163 Value* previous_use_;
270 Value* next_use_; 164 Value* next_use_;
271 Instruction* instruction_; 165 Instruction* instruction_;
272 intptr_t use_index_; 166 intptr_t use_index_;
273 167
274 CompileType* reaching_type_; 168 intptr_t reaching_cid_;
275 169
276 DISALLOW_COPY_AND_ASSIGN(Value); 170 DISALLOW_COPY_AND_ASSIGN(Value);
277 }; 171 };
278 172
279 173
280 enum Representation { 174 enum Representation {
281 kTagged, 175 kTagged,
282 kUnboxedDouble, 176 kUnboxedDouble,
283 kUnboxedMint 177 kUnboxedMint
284 }; 178 };
(...skipping 908 matching lines...) Expand 10 before | Expand all | Expand 10 after
1193 ssa_temp_index_ = index; 1087 ssa_temp_index_ = index;
1194 } 1088 }
1195 bool HasSSATemp() const { return ssa_temp_index_ >= 0; } 1089 bool HasSSATemp() const { return ssa_temp_index_ >= 0; }
1196 void ClearSSATempIndex() { ssa_temp_index_ = -1; } 1090 void ClearSSATempIndex() { ssa_temp_index_ = -1; }
1197 1091
1198 bool is_used() const { return (use_kind_ != kEffect); } 1092 bool is_used() const { return (use_kind_ != kEffect); }
1199 void set_use_kind(UseKind kind) { use_kind_ = kind; } 1093 void set_use_kind(UseKind kind) { use_kind_ = kind; }
1200 1094
1201 // Compile time type of the definition, which may be requested before type 1095 // Compile time type of the definition, which may be requested before type
1202 // propagation during graph building. 1096 // propagation during graph building.
1203 CompileType* Type() { 1097 virtual RawAbstractType* CompileType() const = 0;
1204 if (type_ == NULL) { 1098
1205 type_ = ComputeInitialType(); 1099 virtual intptr_t ResultCid() const = 0;
1100
1101 bool HasPropagatedType() const {
1102 return !propagated_type_.IsNull();
1103 }
1104 RawAbstractType* PropagatedType() const {
1105 ASSERT(HasPropagatedType());
1106 return propagated_type_.raw();
1107 }
1108 // Returns true if the propagated type has changed.
1109 bool SetPropagatedType(const AbstractType& propagated_type) {
1110 if (propagated_type.IsNull()) {
1111 // Not a typed definition, e.g. access to a VM field.
1112 return false;
1206 } 1113 }
1207 return type_; 1114 const bool changed =
1115 propagated_type_.IsNull() || !propagated_type.Equals(propagated_type_);
1116 propagated_type_ = propagated_type.raw();
1117 return changed;
1208 } 1118 }
1209 1119
1210 // Compute initial compile type for this definition. It is safe to use this 1120 bool has_propagated_cid() const { return propagated_cid_ != kIllegalCid; }
1211 // approximation even before type propagator was run (e.g. during graph 1121 intptr_t propagated_cid() const { return propagated_cid_; }
1212 // building).
1213 virtual CompileType* ComputeInitialType() const {
1214 return CompileType::Dynamic();
1215 }
1216 1122
1217 // Update CompileType of the definition. Returns true if the type has changed. 1123 // May compute and set propagated cid.
1218 virtual bool RecomputeType() { 1124 virtual intptr_t GetPropagatedCid();
1219 return false; 1125
1220 } 1126 // Returns true if the propagated cid has changed.
1127 bool SetPropagatedCid(intptr_t cid);
1221 1128
1222 bool HasUses() const { 1129 bool HasUses() const {
1223 return (input_use_list_ != NULL) || (env_use_list_ != NULL); 1130 return (input_use_list_ != NULL) || (env_use_list_ != NULL);
1224 } 1131 }
1225 1132
1226 Value* input_use_list() const { return input_use_list_; } 1133 Value* input_use_list() const { return input_use_list_; }
1227 void set_input_use_list(Value* head) { input_use_list_ = head; } 1134 void set_input_use_list(Value* head) { input_use_list_ = head; }
1228 1135
1229 Value* env_use_list() const { return env_use_list_; } 1136 Value* env_use_list() const { return env_use_list_; }
1230 void set_env_use_list(Value* head) { env_use_list_ = head; } 1137 void set_env_use_list(Value* head) { env_use_list_ = head; }
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
1279 ASSERT(ssa_temp_index_ >= 0); 1186 ASSERT(ssa_temp_index_ >= 0);
1280 ASSERT(WasEliminated()); 1187 ASSERT(WasEliminated());
1281 ssa_temp_index_ = kReplacementMarker; 1188 ssa_temp_index_ = kReplacementMarker;
1282 temp_index_ = reinterpret_cast<intptr_t>(other); 1189 temp_index_ = reinterpret_cast<intptr_t>(other);
1283 } 1190 }
1284 1191
1285 protected: 1192 protected:
1286 friend class RangeAnalysis; 1193 friend class RangeAnalysis;
1287 1194
1288 Range* range_; 1195 Range* range_;
1289 CompileType* type_;
1290 1196
1291 private: 1197 private:
1292 intptr_t temp_index_; 1198 intptr_t temp_index_;
1293 intptr_t ssa_temp_index_; 1199 intptr_t ssa_temp_index_;
1200 // TODO(regis): GrowableArray<const AbstractType*> propagated_types_;
1201 // For now:
1202 AbstractType& propagated_type_;
1203 intptr_t propagated_cid_;
1294 Value* input_use_list_; 1204 Value* input_use_list_;
1295 Value* env_use_list_; 1205 Value* env_use_list_;
1296 UseKind use_kind_; 1206 UseKind use_kind_;
1297 1207
1298 Object& constant_value_; 1208 Object& constant_value_;
1299 1209
1300 DISALLOW_COPY_AND_ASSIGN(Definition); 1210 DISALLOW_COPY_AND_ASSIGN(Definition);
1301 }; 1211 };
1302 1212
1303 1213
1304 class PhiInstr : public Definition { 1214 class PhiInstr : public Definition {
1305 public: 1215 public:
1306 explicit PhiInstr(JoinEntryInstr* block, intptr_t num_inputs) 1216 explicit PhiInstr(JoinEntryInstr* block, intptr_t num_inputs)
1307 : block_(block), 1217 : block_(block),
1308 inputs_(num_inputs), 1218 inputs_(num_inputs),
1309 is_alive_(false), 1219 is_alive_(false),
1310 representation_(kTagged), 1220 representation_(kTagged),
1311 reaching_defs_(NULL) { 1221 reaching_defs_(NULL) {
1312 for (intptr_t i = 0; i < num_inputs; ++i) { 1222 for (intptr_t i = 0; i < num_inputs; ++i) {
1313 inputs_.Add(NULL); 1223 inputs_.Add(NULL);
1314 } 1224 }
1315 } 1225 }
1316 1226
1317 // Get the block entry for that instruction. 1227 // Get the block entry for that instruction.
1318 virtual BlockEntryInstr* GetBlock() const { return block(); } 1228 virtual BlockEntryInstr* GetBlock() const { return block(); }
1319 JoinEntryInstr* block() const { return block_; } 1229 JoinEntryInstr* block() const { return block_; }
1320 1230
1321 virtual CompileType* ComputeInitialType() const; 1231 virtual RawAbstractType* CompileType() const;
1322 virtual bool RecomputeType(); 1232 virtual intptr_t GetPropagatedCid();
1323 1233
1324 virtual intptr_t ArgumentCount() const { return 0; } 1234 virtual intptr_t ArgumentCount() const { return 0; }
1325 1235
1326 intptr_t InputCount() const { return inputs_.length(); } 1236 intptr_t InputCount() const { return inputs_.length(); }
1327 1237
1328 Value* InputAt(intptr_t i) const { return inputs_[i]; } 1238 Value* InputAt(intptr_t i) const { return inputs_[i]; }
1329 1239
1330 void SetInputAt(intptr_t i, Value* value) { inputs_[i] = value; } 1240 void SetInputAt(intptr_t i, Value* value) { inputs_[i] = value; }
1331 1241
1332 virtual bool CanDeoptimize() const { return false; } 1242 virtual bool CanDeoptimize() const { return false; }
1333 1243
1334 virtual bool HasSideEffect() const { return false; } 1244 virtual bool HasSideEffect() const { return false; }
1335 1245
1246 // TODO(regis): This helper will be removed once we support type sets.
1247 RawAbstractType* LeastSpecificInputType() const;
1248
1336 // Phi is alive if it reaches a non-environment use. 1249 // Phi is alive if it reaches a non-environment use.
1337 bool is_alive() const { return is_alive_; } 1250 bool is_alive() const { return is_alive_; }
1338 void mark_alive() { is_alive_ = true; } 1251 void mark_alive() { is_alive_ = true; }
1339 void mark_dead() { is_alive_ = false; } 1252 void mark_dead() { is_alive_ = false; }
1340 1253
1341 virtual Representation RequiredInputRepresentation(intptr_t i) const { 1254 virtual Representation RequiredInputRepresentation(intptr_t i) const {
1342 return representation_; 1255 return representation_;
1343 } 1256 }
1344 1257
1345 virtual Representation representation() const { 1258 virtual Representation representation() const {
1346 return representation_; 1259 return representation_;
1347 } 1260 }
1348 1261
1349 virtual void set_representation(Representation r) { 1262 virtual void set_representation(Representation r) {
1350 representation_ = r; 1263 representation_ = r;
1351 } 1264 }
1352 1265
1353 virtual intptr_t Hashcode() const { 1266 virtual intptr_t Hashcode() const {
1354 UNREACHABLE(); 1267 UNREACHABLE();
1355 return 0; 1268 return 0;
1356 } 1269 }
1357 1270
1271 virtual intptr_t ResultCid() const {
1272 UNREACHABLE();
1273 return kIllegalCid;
1274 }
1275
1358 DECLARE_INSTRUCTION(Phi) 1276 DECLARE_INSTRUCTION(Phi)
1359 1277
1360 virtual void PrintTo(BufferFormatter* f) const; 1278 virtual void PrintTo(BufferFormatter* f) const;
1361 1279
1362 virtual void InferRange(); 1280 virtual void InferRange();
1363 1281
1364 BitVector* reaching_defs() const { 1282 BitVector* reaching_defs() const {
1365 return reaching_defs_; 1283 return reaching_defs_;
1366 } 1284 }
1367 1285
(...skipping 20 matching lines...) Expand all
1388 explicit ParameterInstr(intptr_t index, GraphEntryInstr* block) 1306 explicit ParameterInstr(intptr_t index, GraphEntryInstr* block)
1389 : index_(index), block_(block) { } 1307 : index_(index), block_(block) { }
1390 1308
1391 DECLARE_INSTRUCTION(Parameter) 1309 DECLARE_INSTRUCTION(Parameter)
1392 1310
1393 intptr_t index() const { return index_; } 1311 intptr_t index() const { return index_; }
1394 1312
1395 // Get the block entry for that instruction. 1313 // Get the block entry for that instruction.
1396 virtual BlockEntryInstr* GetBlock() const { return block_; } 1314 virtual BlockEntryInstr* GetBlock() const { return block_; }
1397 1315
1316 // Compile type of the passed-in parameter.
1317 virtual RawAbstractType* CompileType() const;
1318
1319 // No known propagated cid for parameters.
1320 virtual intptr_t GetPropagatedCid();
1321
1398 virtual intptr_t ArgumentCount() const { return 0; } 1322 virtual intptr_t ArgumentCount() const { return 0; }
1399 1323
1400 intptr_t InputCount() const { return 0; } 1324 intptr_t InputCount() const { return 0; }
1401 Value* InputAt(intptr_t i) const { 1325 Value* InputAt(intptr_t i) const {
1402 UNREACHABLE(); 1326 UNREACHABLE();
1403 return NULL; 1327 return NULL;
1404 } 1328 }
1405 void SetInputAt(intptr_t i, Value* value) { UNREACHABLE(); } 1329 void SetInputAt(intptr_t i, Value* value) { UNREACHABLE(); }
1406 1330
1407 virtual bool CanDeoptimize() const { return false; } 1331 virtual bool CanDeoptimize() const { return false; }
1408 1332
1409 virtual bool HasSideEffect() const { return false; } 1333 virtual bool HasSideEffect() const { return false; }
1410 1334
1411 virtual intptr_t Hashcode() const { 1335 virtual intptr_t Hashcode() const {
1412 UNREACHABLE(); 1336 UNREACHABLE();
1413 return 0; 1337 return 0;
1414 } 1338 }
1415 1339
1340 virtual intptr_t ResultCid() const {
1341 UNREACHABLE();
1342 return kIllegalCid;
1343 }
1344
1416 virtual void PrintOperandsTo(BufferFormatter* f) const; 1345 virtual void PrintOperandsTo(BufferFormatter* f) const;
1417 1346
1418 virtual CompileType* ComputeInitialType() const;
1419
1420 private: 1347 private:
1421 const intptr_t index_; 1348 const intptr_t index_;
1422 GraphEntryInstr* block_; 1349 GraphEntryInstr* block_;
1423 1350
1424 DISALLOW_COPY_AND_ASSIGN(ParameterInstr); 1351 DISALLOW_COPY_AND_ASSIGN(ParameterInstr);
1425 }; 1352 };
1426 1353
1427 1354
1428 class PushArgumentInstr : public Definition { 1355 class PushArgumentInstr : public Definition {
1429 public: 1356 public:
1430 explicit PushArgumentInstr(Value* value) : value_(value), locs_(NULL) { 1357 explicit PushArgumentInstr(Value* value) : value_(value), locs_(NULL) {
1431 ASSERT(value != NULL); 1358 ASSERT(value != NULL);
1432 set_use_kind(kEffect); // Override the default. 1359 set_use_kind(kEffect); // Override the default.
1433 } 1360 }
1434 1361
1435 DECLARE_INSTRUCTION(PushArgument) 1362 DECLARE_INSTRUCTION(PushArgument)
1436 1363
1437 intptr_t InputCount() const { return 1; } 1364 intptr_t InputCount() const { return 1; }
1438 Value* InputAt(intptr_t i) const { 1365 Value* InputAt(intptr_t i) const {
1439 ASSERT(i == 0); 1366 ASSERT(i == 0);
1440 return value_; 1367 return value_;
1441 } 1368 }
1442 void SetInputAt(intptr_t i, Value* value) { 1369 void SetInputAt(intptr_t i, Value* value) {
1443 ASSERT(i == 0); 1370 ASSERT(i == 0);
1444 value_ = value; 1371 value_ = value;
1445 } 1372 }
1446 1373
1447 virtual intptr_t ArgumentCount() const { return 0; } 1374 virtual intptr_t ArgumentCount() const { return 0; }
1448 1375
1449 virtual CompileType* ComputeInitialType() const; 1376 virtual RawAbstractType* CompileType() const;
1377 virtual intptr_t GetPropagatedCid() { return propagated_cid(); }
1378 virtual intptr_t ResultCid() const {
1379 UNREACHABLE();
1380 return kIllegalCid;
1381 }
1450 1382
1451 Value* value() const { return value_; } 1383 Value* value() const { return value_; }
1452 1384
1453 virtual LocationSummary* locs() { 1385 virtual LocationSummary* locs() {
1454 if (locs_ == NULL) { 1386 if (locs_ == NULL) {
1455 locs_ = MakeLocationSummary(); 1387 locs_ = MakeLocationSummary();
1456 } 1388 }
1457 return locs_; 1389 return locs_;
1458 } 1390 }
1459 1391
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
1660 1592
1661 1593
1662 class StoreContextInstr : public TemplateInstruction<1> { 1594 class StoreContextInstr : public TemplateInstruction<1> {
1663 public: 1595 public:
1664 explicit StoreContextInstr(Value* value) { 1596 explicit StoreContextInstr(Value* value) {
1665 ASSERT(value != NULL); 1597 ASSERT(value != NULL);
1666 inputs_[0] = value; 1598 inputs_[0] = value;
1667 } 1599 }
1668 1600
1669 DECLARE_INSTRUCTION(StoreContext); 1601 DECLARE_INSTRUCTION(StoreContext);
1602 virtual RawAbstractType* CompileType() const;
1670 1603
1671 virtual intptr_t ArgumentCount() const { return 0; } 1604 virtual intptr_t ArgumentCount() const { return 0; }
1672 1605
1673 Value* value() const { return inputs_[0]; } 1606 Value* value() const { return inputs_[0]; }
1674 1607
1675 virtual bool CanDeoptimize() const { return false; } 1608 virtual bool CanDeoptimize() const { return false; }
1676 1609
1677 virtual bool HasSideEffect() const { return false; } 1610 virtual bool HasSideEffect() const { return false; }
1678 1611
1679 private: 1612 private:
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
1878 inputs_[0] = value; 1811 inputs_[0] = value;
1879 inputs_[1] = NULL; // Dependency. 1812 inputs_[1] = NULL; // Dependency.
1880 } 1813 }
1881 1814
1882 DECLARE_INSTRUCTION(Constraint) 1815 DECLARE_INSTRUCTION(Constraint)
1883 1816
1884 virtual intptr_t InputCount() const { 1817 virtual intptr_t InputCount() const {
1885 return (inputs_[1] == NULL) ? 1 : 2; 1818 return (inputs_[1] == NULL) ? 1 : 2;
1886 } 1819 }
1887 1820
1888 virtual CompileType* ComputeInitialType() const; 1821 virtual RawAbstractType* CompileType() const {
1822 return Type::SmiType();
1823 }
1889 1824
1890 virtual bool CanDeoptimize() const { return false; } 1825 virtual bool CanDeoptimize() const { return false; }
1891 1826
1892 virtual bool HasSideEffect() const { return false; } 1827 virtual bool HasSideEffect() const { return false; }
1893 1828
1829 virtual intptr_t ResultCid() const { return kSmiCid; }
1830
1894 virtual bool AttributesEqual(Instruction* other) const { 1831 virtual bool AttributesEqual(Instruction* other) const {
1895 UNREACHABLE(); 1832 UNREACHABLE();
1896 return false; 1833 return false;
1897 } 1834 }
1898 1835
1899 virtual void PrintOperandsTo(BufferFormatter* f) const; 1836 virtual void PrintOperandsTo(BufferFormatter* f) const;
1900 1837
1901 Value* value() const { return inputs_[0]; } 1838 Value* value() const { return inputs_[0]; }
1902 Range* constraint() const { return constraint_; } 1839 Range* constraint() const { return constraint_; }
1903 1840
(...skipping 21 matching lines...) Expand all
1925 DISALLOW_COPY_AND_ASSIGN(ConstraintInstr); 1862 DISALLOW_COPY_AND_ASSIGN(ConstraintInstr);
1926 }; 1863 };
1927 1864
1928 1865
1929 class ConstantInstr : public TemplateDefinition<0> { 1866 class ConstantInstr : public TemplateDefinition<0> {
1930 public: 1867 public:
1931 explicit ConstantInstr(const Object& value) 1868 explicit ConstantInstr(const Object& value)
1932 : value_(value) { } 1869 : value_(value) { }
1933 1870
1934 DECLARE_INSTRUCTION(Constant) 1871 DECLARE_INSTRUCTION(Constant)
1935 virtual CompileType* ComputeInitialType() const; 1872 virtual RawAbstractType* CompileType() const;
1936 1873
1937 const Object& value() const { return value_; } 1874 const Object& value() const { return value_; }
1938 1875
1939 virtual void PrintOperandsTo(BufferFormatter* f) const; 1876 virtual void PrintOperandsTo(BufferFormatter* f) const;
1940 1877
1941 virtual bool CanDeoptimize() const { return false; } 1878 virtual bool CanDeoptimize() const { return false; }
1942 1879
1943 virtual bool HasSideEffect() const { return false; } 1880 virtual bool HasSideEffect() const { return false; }
1944 1881
1882 virtual intptr_t ResultCid() const;
1883
1945 virtual bool AttributesEqual(Instruction* other) const; 1884 virtual bool AttributesEqual(Instruction* other) const;
1946 virtual bool AffectedBySideEffect() const { return false; } 1885 virtual bool AffectedBySideEffect() const { return false; }
1947 1886
1948 virtual void InferRange(); 1887 virtual void InferRange();
1949 1888
1950 private: 1889 private:
1951 const Object& value_; 1890 const Object& value_;
1952 1891
1953 DISALLOW_COPY_AND_ASSIGN(ConstantInstr); 1892 DISALLOW_COPY_AND_ASSIGN(ConstantInstr);
1954 }; 1893 };
1955 1894
1956 1895
1957 class AssertAssignableInstr : public TemplateDefinition<3> { 1896 class AssertAssignableInstr : public TemplateDefinition<3> {
1958 public: 1897 public:
1959 AssertAssignableInstr(intptr_t token_pos, 1898 AssertAssignableInstr(intptr_t token_pos,
1960 Value* value, 1899 Value* value,
1961 Value* instantiator, 1900 Value* instantiator,
1962 Value* instantiator_type_arguments, 1901 Value* instantiator_type_arguments,
1963 const AbstractType& dst_type, 1902 const AbstractType& dst_type,
1964 const String& dst_name) 1903 const String& dst_name)
1965 : token_pos_(token_pos), 1904 : token_pos_(token_pos),
1966 dst_type_(AbstractType::ZoneHandle(dst_type.raw())), 1905 dst_type_(AbstractType::ZoneHandle(dst_type.raw())),
1967 dst_name_(dst_name) { 1906 dst_name_(dst_name),
1907 is_eliminated_(false) {
1968 ASSERT(value != NULL); 1908 ASSERT(value != NULL);
1969 ASSERT(instantiator != NULL); 1909 ASSERT(instantiator != NULL);
1970 ASSERT(instantiator_type_arguments != NULL); 1910 ASSERT(instantiator_type_arguments != NULL);
1971 ASSERT(!dst_type.IsNull()); 1911 ASSERT(!dst_type.IsNull());
1972 ASSERT(!dst_name.IsNull()); 1912 ASSERT(!dst_name.IsNull());
1973 inputs_[0] = value; 1913 inputs_[0] = value;
1974 inputs_[1] = instantiator; 1914 inputs_[1] = instantiator;
1975 inputs_[2] = instantiator_type_arguments; 1915 inputs_[2] = instantiator_type_arguments;
1976 } 1916 }
1977 1917
1978 DECLARE_INSTRUCTION(AssertAssignable) 1918 DECLARE_INSTRUCTION(AssertAssignable)
1979 virtual CompileType* ComputeInitialType() const; 1919 virtual RawAbstractType* CompileType() const;
1980 virtual bool RecomputeType();
1981 1920
1982 Value* value() const { return inputs_[0]; } 1921 Value* value() const { return inputs_[0]; }
1983 Value* instantiator() const { return inputs_[1]; } 1922 Value* instantiator() const { return inputs_[1]; }
1984 Value* instantiator_type_arguments() const { return inputs_[2]; } 1923 Value* instantiator_type_arguments() const { return inputs_[2]; }
1985 1924
1986 intptr_t token_pos() const { return token_pos_; } 1925 intptr_t token_pos() const { return token_pos_; }
1987 const AbstractType& dst_type() const { return dst_type_; } 1926 const AbstractType& dst_type() const { return dst_type_; }
1988 void set_dst_type(const AbstractType& dst_type) { 1927 void set_dst_type(const AbstractType& dst_type) {
1989 dst_type_ = dst_type.raw(); 1928 dst_type_ = dst_type.raw();
1990 } 1929 }
1991 const String& dst_name() const { return dst_name_; } 1930 const String& dst_name() const { return dst_name_; }
1992 1931
1932 bool is_eliminated() const {
1933 return is_eliminated_;
1934 }
1935 void eliminate() {
1936 ASSERT(!is_eliminated_);
1937 is_eliminated_ = true;
1938 }
1939
1993 virtual void PrintOperandsTo(BufferFormatter* f) const; 1940 virtual void PrintOperandsTo(BufferFormatter* f) const;
1994 1941
1995 virtual bool CanDeoptimize() const { return true; } 1942 virtual bool CanDeoptimize() const { return true; }
1996 1943
1997 virtual bool HasSideEffect() const { return false; } 1944 virtual bool HasSideEffect() const { return false; }
1998 1945
1999 virtual bool AffectedBySideEffect() const { return false; } 1946 virtual bool AffectedBySideEffect() const { return false; }
2000 virtual bool AttributesEqual(Instruction* other) const; 1947 virtual bool AttributesEqual(Instruction* other) const;
2001 1948
1949 virtual intptr_t ResultCid() const { return value()->ResultCid(); }
1950 virtual intptr_t GetPropagatedCid();
1951
2002 virtual Definition* Canonicalize(FlowGraphOptimizer* optimizer); 1952 virtual Definition* Canonicalize(FlowGraphOptimizer* optimizer);
2003 1953
2004 private: 1954 private:
2005 const intptr_t token_pos_; 1955 const intptr_t token_pos_;
2006 AbstractType& dst_type_; 1956 AbstractType& dst_type_;
2007 const String& dst_name_; 1957 const String& dst_name_;
1958 bool is_eliminated_;
2008 1959
2009 DISALLOW_COPY_AND_ASSIGN(AssertAssignableInstr); 1960 DISALLOW_COPY_AND_ASSIGN(AssertAssignableInstr);
2010 }; 1961 };
2011 1962
2012 1963
2013 class AssertBooleanInstr : public TemplateDefinition<1> { 1964 class AssertBooleanInstr : public TemplateDefinition<1> {
2014 public: 1965 public:
2015 AssertBooleanInstr(intptr_t token_pos, Value* value) 1966 AssertBooleanInstr(intptr_t token_pos, Value* value)
2016 : token_pos_(token_pos) { 1967 : token_pos_(token_pos),
1968 is_eliminated_(false) {
2017 ASSERT(value != NULL); 1969 ASSERT(value != NULL);
2018 inputs_[0] = value; 1970 inputs_[0] = value;
2019 } 1971 }
2020 1972
2021 DECLARE_INSTRUCTION(AssertBoolean) 1973 DECLARE_INSTRUCTION(AssertBoolean)
2022 virtual CompileType* ComputeInitialType() const; 1974 virtual RawAbstractType* CompileType() const;
2023 1975
2024 intptr_t token_pos() const { return token_pos_; } 1976 intptr_t token_pos() const { return token_pos_; }
2025 Value* value() const { return inputs_[0]; } 1977 Value* value() const { return inputs_[0]; }
2026 1978
1979 bool is_eliminated() const {
1980 return is_eliminated_;
1981 }
1982 void eliminate() {
1983 ASSERT(!is_eliminated_);
1984 is_eliminated_ = true;
1985 }
1986
2027 virtual void PrintOperandsTo(BufferFormatter* f) const; 1987 virtual void PrintOperandsTo(BufferFormatter* f) const;
2028 1988
2029 virtual bool CanDeoptimize() const { return true; } 1989 virtual bool CanDeoptimize() const { return true; }
2030 1990
2031 virtual bool HasSideEffect() const { return false; } 1991 virtual bool HasSideEffect() const { return false; }
2032 1992
2033 virtual bool AffectedBySideEffect() const { return false; } 1993 virtual bool AffectedBySideEffect() const { return false; }
2034 virtual bool AttributesEqual(Instruction* other) const { return true; } 1994 virtual bool AttributesEqual(Instruction* other) const { return true; }
2035 1995
1996 virtual intptr_t ResultCid() const { return kBoolCid; }
1997
2036 virtual Definition* Canonicalize(FlowGraphOptimizer* optimizer); 1998 virtual Definition* Canonicalize(FlowGraphOptimizer* optimizer);
2037 1999
2038 private: 2000 private:
2039 const intptr_t token_pos_; 2001 const intptr_t token_pos_;
2002 bool is_eliminated_;
2040 2003
2041 DISALLOW_COPY_AND_ASSIGN(AssertBooleanInstr); 2004 DISALLOW_COPY_AND_ASSIGN(AssertBooleanInstr);
2042 }; 2005 };
2043 2006
2044 2007
2045 class ArgumentDefinitionTestInstr : public TemplateDefinition<1> { 2008 class ArgumentDefinitionTestInstr : public TemplateDefinition<1> {
2046 public: 2009 public:
2047 ArgumentDefinitionTestInstr(ArgumentDefinitionTestNode* node, 2010 ArgumentDefinitionTestInstr(ArgumentDefinitionTestNode* node,
2048 Value* saved_arguments_descriptor) 2011 Value* saved_arguments_descriptor)
2049 : ast_node_(*node) { 2012 : ast_node_(*node) {
2050 ASSERT(saved_arguments_descriptor != NULL); 2013 ASSERT(saved_arguments_descriptor != NULL);
2051 inputs_[0] = saved_arguments_descriptor; 2014 inputs_[0] = saved_arguments_descriptor;
2052 } 2015 }
2053 2016
2054 DECLARE_INSTRUCTION(ArgumentDefinitionTest) 2017 DECLARE_INSTRUCTION(ArgumentDefinitionTest)
2055 virtual CompileType* ComputeInitialType() const; 2018 virtual RawAbstractType* CompileType() const;
2056 2019
2057 intptr_t token_pos() const { return ast_node_.token_pos(); } 2020 intptr_t token_pos() const { return ast_node_.token_pos(); }
2058 intptr_t formal_parameter_index() const { 2021 intptr_t formal_parameter_index() const {
2059 return ast_node_.formal_parameter_index(); 2022 return ast_node_.formal_parameter_index();
2060 } 2023 }
2061 const String& formal_parameter_name() const { 2024 const String& formal_parameter_name() const {
2062 return ast_node_.formal_parameter_name(); 2025 return ast_node_.formal_parameter_name();
2063 } 2026 }
2064
2065 Value* saved_arguments_descriptor() const { return inputs_[0]; } 2027 Value* saved_arguments_descriptor() const { return inputs_[0]; }
2066 2028
2067 virtual void PrintOperandsTo(BufferFormatter* f) const; 2029 virtual void PrintOperandsTo(BufferFormatter* f) const;
2068 2030
2069 virtual bool CanDeoptimize() const { return true; } 2031 virtual bool CanDeoptimize() const { return true; }
2070 2032
2071 virtual bool HasSideEffect() const { return true; } 2033 virtual bool HasSideEffect() const { return true; }
2072 2034
2035 virtual intptr_t ResultCid() const { return kBoolCid; }
2036
2073 private: 2037 private:
2074 const ArgumentDefinitionTestNode& ast_node_; 2038 const ArgumentDefinitionTestNode& ast_node_;
2075 2039
2076 DISALLOW_COPY_AND_ASSIGN(ArgumentDefinitionTestInstr); 2040 DISALLOW_COPY_AND_ASSIGN(ArgumentDefinitionTestInstr);
2077 }; 2041 };
2078 2042
2079 2043
2080 // Denotes the current context, normally held in a register. This is 2044 // Denotes the current context, normally held in a register. This is
2081 // a computation, not a value, because it's mutable. 2045 // a computation, not a value, because it's mutable.
2082 class CurrentContextInstr : public TemplateDefinition<0> { 2046 class CurrentContextInstr : public TemplateDefinition<0> {
2083 public: 2047 public:
2084 CurrentContextInstr() { } 2048 CurrentContextInstr() { }
2085 2049
2086 DECLARE_INSTRUCTION(CurrentContext) 2050 DECLARE_INSTRUCTION(CurrentContext)
2087 virtual CompileType* ComputeInitialType() const; 2051 virtual RawAbstractType* CompileType() const;
2088 2052
2089 virtual bool CanDeoptimize() const { return false; } 2053 virtual bool CanDeoptimize() const { return false; }
2090 2054
2091 virtual bool HasSideEffect() const { return false; } 2055 virtual bool HasSideEffect() const { return false; }
2092 2056
2057 virtual intptr_t ResultCid() const { return kDynamicCid; }
2058
2093 private: 2059 private:
2094 DISALLOW_COPY_AND_ASSIGN(CurrentContextInstr); 2060 DISALLOW_COPY_AND_ASSIGN(CurrentContextInstr);
2095 }; 2061 };
2096 2062
2097 2063
2098 class ClosureCallInstr : public TemplateDefinition<0> { 2064 class ClosureCallInstr : public TemplateDefinition<0> {
2099 public: 2065 public:
2100 ClosureCallInstr(ClosureCallNode* node, 2066 ClosureCallInstr(ClosureCallNode* node,
2101 ZoneGrowableArray<PushArgumentInstr*>* arguments) 2067 ZoneGrowableArray<PushArgumentInstr*>* arguments)
2102 : ast_node_(*node), 2068 : ast_node_(*node),
2103 arguments_(arguments) { } 2069 arguments_(arguments) { }
2104 2070
2105 DECLARE_INSTRUCTION(ClosureCall) 2071 DECLARE_INSTRUCTION(ClosureCall)
2072 virtual RawAbstractType* CompileType() const;
2106 2073
2107 const Array& argument_names() const { return ast_node_.arguments()->names(); } 2074 const Array& argument_names() const { return ast_node_.arguments()->names(); }
2108 intptr_t token_pos() const { return ast_node_.token_pos(); } 2075 intptr_t token_pos() const { return ast_node_.token_pos(); }
2109 2076
2110 virtual intptr_t ArgumentCount() const { return arguments_->length(); } 2077 virtual intptr_t ArgumentCount() const { return arguments_->length(); }
2111 PushArgumentInstr* ArgumentAt(intptr_t index) const { 2078 PushArgumentInstr* ArgumentAt(intptr_t index) const {
2112 return (*arguments_)[index]; 2079 return (*arguments_)[index];
2113 } 2080 }
2114 2081
2115 virtual void PrintOperandsTo(BufferFormatter* f) const; 2082 virtual void PrintOperandsTo(BufferFormatter* f) const;
2116 2083
2117 virtual bool CanDeoptimize() const { return true; } 2084 virtual bool CanDeoptimize() const { return true; }
2118 2085
2119 virtual bool HasSideEffect() const { return true; } 2086 virtual bool HasSideEffect() const { return true; }
2120 2087
2088 virtual intptr_t ResultCid() const { return kDynamicCid; }
2089
2121 private: 2090 private:
2122 const ClosureCallNode& ast_node_; 2091 const ClosureCallNode& ast_node_;
2123 ZoneGrowableArray<PushArgumentInstr*>* arguments_; 2092 ZoneGrowableArray<PushArgumentInstr*>* arguments_;
2124 2093
2125 DISALLOW_COPY_AND_ASSIGN(ClosureCallInstr); 2094 DISALLOW_COPY_AND_ASSIGN(ClosureCallInstr);
2126 }; 2095 };
2127 2096
2128 2097
2129 class InstanceCallInstr : public TemplateDefinition<0> { 2098 class InstanceCallInstr : public TemplateDefinition<0> {
2130 public: 2099 public:
(...skipping 16 matching lines...) Expand all
2147 ASSERT(Token::IsBinaryOperator(token_kind) || 2116 ASSERT(Token::IsBinaryOperator(token_kind) ||
2148 Token::IsPrefixOperator(token_kind) || 2117 Token::IsPrefixOperator(token_kind) ||
2149 Token::IsIndexOperator(token_kind) || 2118 Token::IsIndexOperator(token_kind) ||
2150 Token::IsTypeTestOperator(token_kind) || 2119 Token::IsTypeTestOperator(token_kind) ||
2151 token_kind == Token::kGET || 2120 token_kind == Token::kGET ||
2152 token_kind == Token::kSET || 2121 token_kind == Token::kSET ||
2153 token_kind == Token::kILLEGAL); 2122 token_kind == Token::kILLEGAL);
2154 } 2123 }
2155 2124
2156 DECLARE_INSTRUCTION(InstanceCall) 2125 DECLARE_INSTRUCTION(InstanceCall)
2126 virtual RawAbstractType* CompileType() const;
2157 2127
2158 const ICData* ic_data() const { return ic_data_; } 2128 const ICData* ic_data() const { return ic_data_; }
2159 bool HasICData() const { 2129 bool HasICData() const {
2160 return (ic_data() != NULL) && !ic_data()->IsNull(); 2130 return (ic_data() != NULL) && !ic_data()->IsNull();
2161 } 2131 }
2162 2132
2163 // ICData can be replaced by optimizer. 2133 // ICData can be replaced by optimizer.
2164 void set_ic_data(const ICData* value) { ic_data_ = value; } 2134 void set_ic_data(const ICData* value) { ic_data_ = value; }
2165 2135
2166 intptr_t token_pos() const { return token_pos_; } 2136 intptr_t token_pos() const { return token_pos_; }
2167 const String& function_name() const { return function_name_; } 2137 const String& function_name() const { return function_name_; }
2168 Token::Kind token_kind() const { return token_kind_; } 2138 Token::Kind token_kind() const { return token_kind_; }
2169 virtual intptr_t ArgumentCount() const { return arguments_->length(); } 2139 virtual intptr_t ArgumentCount() const { return arguments_->length(); }
2170 PushArgumentInstr* ArgumentAt(intptr_t index) const { 2140 PushArgumentInstr* ArgumentAt(intptr_t index) const {
2171 return (*arguments_)[index]; 2141 return (*arguments_)[index];
2172 } 2142 }
2173 const Array& argument_names() const { return argument_names_; } 2143 const Array& argument_names() const { return argument_names_; }
2174 intptr_t checked_argument_count() const { return checked_argument_count_; } 2144 intptr_t checked_argument_count() const { return checked_argument_count_; }
2175 2145
2176 virtual void PrintOperandsTo(BufferFormatter* f) const; 2146 virtual void PrintOperandsTo(BufferFormatter* f) const;
2177 2147
2178 virtual bool CanDeoptimize() const { return true; } 2148 virtual bool CanDeoptimize() const { return true; }
2179 2149
2180 virtual bool HasSideEffect() const { return true; } 2150 virtual bool HasSideEffect() const { return true; }
2181 2151
2152 virtual intptr_t ResultCid() const { return kDynamicCid; }
2153
2182 protected: 2154 protected:
2183 friend class FlowGraphOptimizer; 2155 friend class FlowGraphOptimizer;
2184 void set_ic_data(ICData* value) { ic_data_ = value; } 2156 void set_ic_data(ICData* value) { ic_data_ = value; }
2185 2157
2186 private: 2158 private:
2187 const ICData* ic_data_; 2159 const ICData* ic_data_;
2188 const intptr_t token_pos_; 2160 const intptr_t token_pos_;
2189 const String& function_name_; 2161 const String& function_name_;
2190 const Token::Kind token_kind_; // Binary op, unary op, kGET or kILLEGAL. 2162 const Token::Kind token_kind_; // Binary op, unary op, kGET or kILLEGAL.
2191 ZoneGrowableArray<PushArgumentInstr*>* const arguments_; 2163 ZoneGrowableArray<PushArgumentInstr*>* const arguments_;
(...skipping 19 matching lines...) Expand all
2211 bool with_checks() const { return with_checks_; } 2183 bool with_checks() const { return with_checks_; }
2212 2184
2213 virtual intptr_t ArgumentCount() const { 2185 virtual intptr_t ArgumentCount() const {
2214 return instance_call()->ArgumentCount(); 2186 return instance_call()->ArgumentCount();
2215 } 2187 }
2216 PushArgumentInstr* ArgumentAt(intptr_t index) const { 2188 PushArgumentInstr* ArgumentAt(intptr_t index) const {
2217 return instance_call()->ArgumentAt(index); 2189 return instance_call()->ArgumentAt(index);
2218 } 2190 }
2219 2191
2220 DECLARE_INSTRUCTION(PolymorphicInstanceCall) 2192 DECLARE_INSTRUCTION(PolymorphicInstanceCall)
2193 virtual RawAbstractType* CompileType() const;
2221 2194
2222 const ICData& ic_data() const { return ic_data_; } 2195 const ICData& ic_data() const { return ic_data_; }
2223 2196
2224 virtual bool CanDeoptimize() const { return true; } 2197 virtual bool CanDeoptimize() const { return true; }
2225 2198
2226 virtual bool HasSideEffect() const { return true; } 2199 virtual bool HasSideEffect() const { return true; }
2227 2200
2201 virtual intptr_t ResultCid() const { return kDynamicCid; }
2202
2228 virtual void PrintOperandsTo(BufferFormatter* f) const; 2203 virtual void PrintOperandsTo(BufferFormatter* f) const;
2229 2204
2230 private: 2205 private:
2231 InstanceCallInstr* instance_call_; 2206 InstanceCallInstr* instance_call_;
2232 const ICData& ic_data_; 2207 const ICData& ic_data_;
2233 const bool with_checks_; 2208 const bool with_checks_;
2234 2209
2235 DISALLOW_COPY_AND_ASSIGN(PolymorphicInstanceCallInstr); 2210 DISALLOW_COPY_AND_ASSIGN(PolymorphicInstanceCallInstr);
2236 }; 2211 };
2237 2212
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
2314 intptr_t i) const { 2289 intptr_t i) const {
2315 return comparison()->RequiredInputRepresentation(i); 2290 return comparison()->RequiredInputRepresentation(i);
2316 } 2291 }
2317 2292
2318 2293
2319 class StrictCompareInstr : public ComparisonInstr { 2294 class StrictCompareInstr : public ComparisonInstr {
2320 public: 2295 public:
2321 StrictCompareInstr(Token::Kind kind, Value* left, Value* right); 2296 StrictCompareInstr(Token::Kind kind, Value* left, Value* right);
2322 2297
2323 DECLARE_INSTRUCTION(StrictCompare) 2298 DECLARE_INSTRUCTION(StrictCompare)
2324 virtual CompileType* ComputeInitialType() const; 2299 virtual RawAbstractType* CompileType() const;
2325 2300
2326 virtual void PrintOperandsTo(BufferFormatter* f) const; 2301 virtual void PrintOperandsTo(BufferFormatter* f) const;
2327 2302
2328 virtual bool CanDeoptimize() const { return false; } 2303 virtual bool CanDeoptimize() const { return false; }
2329 2304
2330 virtual bool HasSideEffect() const { return false; } 2305 virtual bool HasSideEffect() const { return false; }
2331 2306
2332 virtual bool AttributesEqual(Instruction* other) const; 2307 virtual bool AttributesEqual(Instruction* other) const;
2333 virtual bool AffectedBySideEffect() const { return false; } 2308 virtual bool AffectedBySideEffect() const { return false; }
2334 2309
2335 virtual Definition* Canonicalize(FlowGraphOptimizer* optimizer); 2310 virtual Definition* Canonicalize(FlowGraphOptimizer* optimizer);
2336 2311
2312 virtual intptr_t ResultCid() const { return kBoolCid; }
2313
2337 virtual void EmitBranchCode(FlowGraphCompiler* compiler, 2314 virtual void EmitBranchCode(FlowGraphCompiler* compiler,
2338 BranchInstr* branch); 2315 BranchInstr* branch);
2339 2316
2340 bool needs_number_check() const { return needs_number_check_; } 2317 bool needs_number_check() const { return needs_number_check_; }
2341 void set_needs_number_check(bool value) { needs_number_check_ = value; } 2318 void set_needs_number_check(bool value) { needs_number_check_ = value; }
2342 2319
2343 private: 2320 private:
2344 // True if the comparison must check for double, Mint or Bigint and 2321 // True if the comparison must check for double, Mint or Bigint and
2345 // use value comparison instead. 2322 // use value comparison instead.
2346 bool needs_number_check_; 2323 bool needs_number_check_;
(...skipping 10 matching lines...) Expand all
2357 Value* right) 2334 Value* right)
2358 : ComparisonInstr(kind, left, right), 2335 : ComparisonInstr(kind, left, right),
2359 token_pos_(token_pos), 2336 token_pos_(token_pos),
2360 receiver_class_id_(kIllegalCid) { 2337 receiver_class_id_(kIllegalCid) {
2361 // deopt_id() checks receiver_class_id_ value. 2338 // deopt_id() checks receiver_class_id_ value.
2362 ic_data_ = Isolate::Current()->GetICDataForDeoptId(deopt_id()); 2339 ic_data_ = Isolate::Current()->GetICDataForDeoptId(deopt_id());
2363 ASSERT((kind == Token::kEQ) || (kind == Token::kNE)); 2340 ASSERT((kind == Token::kEQ) || (kind == Token::kNE));
2364 } 2341 }
2365 2342
2366 DECLARE_INSTRUCTION(EqualityCompare) 2343 DECLARE_INSTRUCTION(EqualityCompare)
2367 virtual CompileType* ComputeInitialType() const; 2344 virtual RawAbstractType* CompileType() const;
2368 2345
2369 const ICData* ic_data() const { return ic_data_; } 2346 const ICData* ic_data() const { return ic_data_; }
2370 bool HasICData() const { 2347 bool HasICData() const {
2371 return (ic_data() != NULL) && !ic_data()->IsNull(); 2348 return (ic_data() != NULL) && !ic_data()->IsNull();
2372 } 2349 }
2373 2350
2374 intptr_t token_pos() const { return token_pos_; } 2351 intptr_t token_pos() const { return token_pos_; }
2375 2352
2376 // Receiver class id is computed from collected ICData. 2353 // Receiver class id is computed from collected ICData.
2377 void set_receiver_class_id(intptr_t value) { receiver_class_id_ = value; } 2354 void set_receiver_class_id(intptr_t value) { receiver_class_id_ = value; }
2378 intptr_t receiver_class_id() const { return receiver_class_id_; } 2355 intptr_t receiver_class_id() const { return receiver_class_id_; }
2379 2356
2380 bool IsInlinedNumericComparison() const {
2381 return (receiver_class_id() == kDoubleCid)
2382 || (receiver_class_id() == kMintCid)
2383 || (receiver_class_id() == kSmiCid);
2384 }
2385
2386 virtual void PrintOperandsTo(BufferFormatter* f) const; 2357 virtual void PrintOperandsTo(BufferFormatter* f) const;
2387 2358
2388 virtual bool CanDeoptimize() const { 2359 virtual bool CanDeoptimize() const {
2389 return !IsInlinedNumericComparison(); 2360 return (receiver_class_id() != kDoubleCid)
2361 && (receiver_class_id() != kMintCid)
2362 && (receiver_class_id() != kSmiCid);
2363 }
2364 virtual bool HasSideEffect() const {
2365 return (receiver_class_id() != kDoubleCid)
2366 && (receiver_class_id() != kMintCid)
2367 && (receiver_class_id() != kSmiCid);
2390 } 2368 }
2391 2369
2392 virtual bool HasSideEffect() const { 2370 virtual intptr_t ResultCid() const;
2393 return !IsInlinedNumericComparison();
2394 }
2395 2371
2396 virtual void EmitBranchCode(FlowGraphCompiler* compiler, 2372 virtual void EmitBranchCode(FlowGraphCompiler* compiler,
2397 BranchInstr* branch); 2373 BranchInstr* branch);
2398 2374
2399 virtual intptr_t DeoptimizationTarget() const { 2375 virtual intptr_t DeoptimizationTarget() const {
2400 return GetDeoptId(); 2376 return GetDeoptId();
2401 } 2377 }
2402 2378
2403 virtual Representation RequiredInputRepresentation(intptr_t idx) const { 2379 virtual Representation RequiredInputRepresentation(intptr_t idx) const {
2404 ASSERT((idx == 0) || (idx == 1)); 2380 ASSERT((idx == 0) || (idx == 1));
(...skipping 21 matching lines...) Expand all
2426 Value* right) 2402 Value* right)
2427 : ComparisonInstr(kind, left, right), 2403 : ComparisonInstr(kind, left, right),
2428 token_pos_(token_pos), 2404 token_pos_(token_pos),
2429 operands_class_id_(kIllegalCid) { 2405 operands_class_id_(kIllegalCid) {
2430 // deopt_id() checks operands_class_id_ value. 2406 // deopt_id() checks operands_class_id_ value.
2431 ic_data_ = Isolate::Current()->GetICDataForDeoptId(deopt_id()); 2407 ic_data_ = Isolate::Current()->GetICDataForDeoptId(deopt_id());
2432 ASSERT(Token::IsRelationalOperator(kind)); 2408 ASSERT(Token::IsRelationalOperator(kind));
2433 } 2409 }
2434 2410
2435 DECLARE_INSTRUCTION(RelationalOp) 2411 DECLARE_INSTRUCTION(RelationalOp)
2436 virtual CompileType* ComputeInitialType() const; 2412 virtual RawAbstractType* CompileType() const;
2437 2413
2438 const ICData* ic_data() const { return ic_data_; } 2414 const ICData* ic_data() const { return ic_data_; }
2439 bool HasICData() const { 2415 bool HasICData() const {
2440 return (ic_data() != NULL) && !ic_data()->IsNull(); 2416 return (ic_data() != NULL) && !ic_data()->IsNull();
2441 } 2417 }
2442 2418
2443 intptr_t token_pos() const { return token_pos_; } 2419 intptr_t token_pos() const { return token_pos_; }
2444 2420
2445 // TODO(srdjan): instead of class-id pass an enum that can differentiate 2421 // TODO(srdjan): instead of class-id pass an enum that can differentiate
2446 // between boxed and unboxed doubles and integers. 2422 // between boxed and unboxed doubles and integers.
2447 void set_operands_class_id(intptr_t value) { 2423 void set_operands_class_id(intptr_t value) {
2448 operands_class_id_ = value; 2424 operands_class_id_ = value;
2449 } 2425 }
2450 2426
2451 intptr_t operands_class_id() const { return operands_class_id_; } 2427 intptr_t operands_class_id() const { return operands_class_id_; }
2452 2428
2453 bool IsInlinedNumericComparison() const {
2454 return (operands_class_id() == kDoubleCid)
2455 || (operands_class_id() == kMintCid)
2456 || (operands_class_id() == kSmiCid);
2457 }
2458
2459 virtual void PrintOperandsTo(BufferFormatter* f) const; 2429 virtual void PrintOperandsTo(BufferFormatter* f) const;
2460 2430
2461 virtual bool CanDeoptimize() const { 2431 virtual bool CanDeoptimize() const {
2462 return !IsInlinedNumericComparison(); 2432 return (operands_class_id() != kDoubleCid)
2433 && (operands_class_id() != kMintCid)
2434 && (operands_class_id() != kSmiCid);
2463 } 2435 }
2464 virtual bool HasSideEffect() const { 2436 virtual bool HasSideEffect() const {
2465 return !IsInlinedNumericComparison(); 2437 return (operands_class_id() != kDoubleCid)
2438 && (operands_class_id() != kMintCid)
2439 && (operands_class_id() != kSmiCid);
2466 } 2440 }
2467 2441
2442 virtual intptr_t ResultCid() const;
2443
2468 virtual void EmitBranchCode(FlowGraphCompiler* compiler, 2444 virtual void EmitBranchCode(FlowGraphCompiler* compiler,
2469 BranchInstr* branch); 2445 BranchInstr* branch);
2470 2446
2471 2447
2472 virtual intptr_t DeoptimizationTarget() const { 2448 virtual intptr_t DeoptimizationTarget() const {
2473 return GetDeoptId(); 2449 return GetDeoptId();
2474 } 2450 }
2475 2451
2476 virtual Representation RequiredInputRepresentation(intptr_t idx) const { 2452 virtual Representation RequiredInputRepresentation(intptr_t idx) const {
2477 ASSERT((idx == 0) || (idx == 1)); 2453 ASSERT((idx == 0) || (idx == 1));
(...skipping 21 matching lines...) Expand all
2499 function_(function), 2475 function_(function),
2500 argument_names_(argument_names), 2476 argument_names_(argument_names),
2501 arguments_(arguments), 2477 arguments_(arguments),
2502 result_cid_(kDynamicCid), 2478 result_cid_(kDynamicCid),
2503 is_known_constructor_(false) { 2479 is_known_constructor_(false) {
2504 ASSERT(function.IsZoneHandle()); 2480 ASSERT(function.IsZoneHandle());
2505 ASSERT(argument_names.IsZoneHandle()); 2481 ASSERT(argument_names.IsZoneHandle());
2506 } 2482 }
2507 2483
2508 DECLARE_INSTRUCTION(StaticCall) 2484 DECLARE_INSTRUCTION(StaticCall)
2509 virtual CompileType* ComputeInitialType() const; 2485 virtual RawAbstractType* CompileType() const;
2510 2486
2511 // Accessors forwarded to the AST node. 2487 // Accessors forwarded to the AST node.
2512 const Function& function() const { return function_; } 2488 const Function& function() const { return function_; }
2513 const Array& argument_names() const { return argument_names_; } 2489 const Array& argument_names() const { return argument_names_; }
2514 intptr_t token_pos() const { return token_pos_; } 2490 intptr_t token_pos() const { return token_pos_; }
2515 2491
2516 virtual intptr_t ArgumentCount() const { return arguments_->length(); } 2492 virtual intptr_t ArgumentCount() const { return arguments_->length(); }
2517 PushArgumentInstr* ArgumentAt(intptr_t index) const { 2493 PushArgumentInstr* ArgumentAt(intptr_t index) const {
2518 return (*arguments_)[index]; 2494 return (*arguments_)[index];
2519 } 2495 }
2520 2496
2521 virtual void PrintOperandsTo(BufferFormatter* f) const; 2497 virtual void PrintOperandsTo(BufferFormatter* f) const;
2522 2498
2523 virtual bool CanDeoptimize() const { return true; } 2499 virtual bool CanDeoptimize() const { return true; }
2524 2500
2525 virtual bool HasSideEffect() const { return true; } 2501 virtual bool HasSideEffect() const { return true; }
2526 2502
2503 virtual intptr_t ResultCid() const { return result_cid_; }
2527 void set_result_cid(intptr_t value) { result_cid_ = value; } 2504 void set_result_cid(intptr_t value) { result_cid_ = value; }
2528 2505
2529 bool is_known_constructor() const { return is_known_constructor_; } 2506 bool is_known_constructor() const { return is_known_constructor_; }
2530 void set_is_known_constructor(bool is_known_constructor) { 2507 void set_is_known_constructor(bool is_known_constructor) {
2531 is_known_constructor_ = is_known_constructor; 2508 is_known_constructor_ = is_known_constructor;
2532 } 2509 }
2533 2510
2534 private: 2511 private:
2535 const intptr_t token_pos_; 2512 const intptr_t token_pos_;
2536 const Function& function_; 2513 const Function& function_;
2537 const Array& argument_names_; 2514 const Array& argument_names_;
2538 ZoneGrowableArray<PushArgumentInstr*>* arguments_; 2515 ZoneGrowableArray<PushArgumentInstr*>* arguments_;
2539 intptr_t result_cid_; // For some library functions we know the result. 2516 intptr_t result_cid_; // For some library functions we know the result.
2540 2517
2541 // Some library constructors have known semantics. 2518 // Some library constructors have known semantics.
2542 bool is_known_constructor_; 2519 bool is_known_constructor_;
2543 2520
2521
2544 DISALLOW_COPY_AND_ASSIGN(StaticCallInstr); 2522 DISALLOW_COPY_AND_ASSIGN(StaticCallInstr);
2545 }; 2523 };
2546 2524
2547 2525
2548 class LoadLocalInstr : public TemplateDefinition<0> { 2526 class LoadLocalInstr : public TemplateDefinition<0> {
2549 public: 2527 public:
2550 LoadLocalInstr(const LocalVariable& local, intptr_t context_level) 2528 LoadLocalInstr(const LocalVariable& local, intptr_t context_level)
2551 : local_(local), 2529 : local_(local),
2552 context_level_(context_level) { } 2530 context_level_(context_level) { }
2553 2531
2554 DECLARE_INSTRUCTION(LoadLocal) 2532 DECLARE_INSTRUCTION(LoadLocal)
2555 virtual CompileType* ComputeInitialType() const; 2533 virtual RawAbstractType* CompileType() const;
2556 2534
2557 const LocalVariable& local() const { return local_; } 2535 const LocalVariable& local() const { return local_; }
2558 intptr_t context_level() const { return context_level_; } 2536 intptr_t context_level() const { return context_level_; }
2559 2537
2560 virtual void PrintOperandsTo(BufferFormatter* f) const; 2538 virtual void PrintOperandsTo(BufferFormatter* f) const;
2561 2539
2562 virtual bool CanDeoptimize() const { return false; } 2540 virtual bool CanDeoptimize() const { return false; }
2563 2541
2564 virtual bool HasSideEffect() const { 2542 virtual bool HasSideEffect() const {
2565 UNREACHABLE(); 2543 UNREACHABLE();
2566 return false; 2544 return false;
2567 } 2545 }
2568 2546
2547 virtual intptr_t ResultCid() const { return kDynamicCid; }
2548
2569 private: 2549 private:
2570 const LocalVariable& local_; 2550 const LocalVariable& local_;
2571 const intptr_t context_level_; 2551 const intptr_t context_level_;
2572 2552
2573 DISALLOW_COPY_AND_ASSIGN(LoadLocalInstr); 2553 DISALLOW_COPY_AND_ASSIGN(LoadLocalInstr);
2574 }; 2554 };
2575 2555
2576 2556
2577 class StoreLocalInstr : public TemplateDefinition<1> { 2557 class StoreLocalInstr : public TemplateDefinition<1> {
2578 public: 2558 public:
2579 StoreLocalInstr(const LocalVariable& local, 2559 StoreLocalInstr(const LocalVariable& local,
2580 Value* value, 2560 Value* value,
2581 intptr_t context_level) 2561 intptr_t context_level)
2582 : local_(local), 2562 : local_(local),
2583 context_level_(context_level) { 2563 context_level_(context_level) {
2584 ASSERT(value != NULL); 2564 ASSERT(value != NULL);
2585 inputs_[0] = value; 2565 inputs_[0] = value;
2586 } 2566 }
2587 2567
2588 DECLARE_INSTRUCTION(StoreLocal) 2568 DECLARE_INSTRUCTION(StoreLocal)
2589 virtual CompileType* ComputeInitialType() const; 2569 virtual RawAbstractType* CompileType() const;
2590 2570
2591 const LocalVariable& local() const { return local_; } 2571 const LocalVariable& local() const { return local_; }
2592 Value* value() const { return inputs_[0]; } 2572 Value* value() const { return inputs_[0]; }
2593 intptr_t context_level() const { return context_level_; } 2573 intptr_t context_level() const { return context_level_; }
2594 2574
2595 virtual void RecordAssignedVars(BitVector* assigned_vars, 2575 virtual void RecordAssignedVars(BitVector* assigned_vars,
2596 intptr_t fixed_parameter_count); 2576 intptr_t fixed_parameter_count);
2597 2577
2598 virtual void PrintOperandsTo(BufferFormatter* f) const; 2578 virtual void PrintOperandsTo(BufferFormatter* f) const;
2599 2579
2600 virtual bool CanDeoptimize() const { return false; } 2580 virtual bool CanDeoptimize() const { return false; }
2601 2581
2602 virtual bool HasSideEffect() const { 2582 virtual bool HasSideEffect() const {
2603 UNREACHABLE(); 2583 UNREACHABLE();
2604 return false; 2584 return false;
2605 } 2585 }
2606 2586
2587 virtual intptr_t ResultCid() const { return kDynamicCid; }
2588
2607 private: 2589 private:
2608 const LocalVariable& local_; 2590 const LocalVariable& local_;
2609 const intptr_t context_level_; 2591 const intptr_t context_level_;
2610 2592
2611 DISALLOW_COPY_AND_ASSIGN(StoreLocalInstr); 2593 DISALLOW_COPY_AND_ASSIGN(StoreLocalInstr);
2612 }; 2594 };
2613 2595
2614 2596
2615 class NativeCallInstr : public TemplateDefinition<0> { 2597 class NativeCallInstr : public TemplateDefinition<0> {
2616 public: 2598 public:
2617 explicit NativeCallInstr(NativeBodyNode* node) 2599 explicit NativeCallInstr(NativeBodyNode* node)
2618 : ast_node_(*node) {} 2600 : ast_node_(*node) {}
2619 2601
2620 DECLARE_INSTRUCTION(NativeCall) 2602 DECLARE_INSTRUCTION(NativeCall)
2603 virtual RawAbstractType* CompileType() const;
2621 2604
2622 intptr_t token_pos() const { return ast_node_.token_pos(); } 2605 intptr_t token_pos() const { return ast_node_.token_pos(); }
2623 2606
2624 const Function& function() const { return ast_node_.function(); } 2607 const Function& function() const { return ast_node_.function(); }
2625 2608
2626 const String& native_name() const { 2609 const String& native_name() const {
2627 return ast_node_.native_c_function_name(); 2610 return ast_node_.native_c_function_name();
2628 } 2611 }
2629 2612
2630 NativeFunction native_c_function() const { 2613 NativeFunction native_c_function() const {
2631 return ast_node_.native_c_function(); 2614 return ast_node_.native_c_function();
2632 } 2615 }
2633 2616
2634 virtual void PrintOperandsTo(BufferFormatter* f) const; 2617 virtual void PrintOperandsTo(BufferFormatter* f) const;
2635 2618
2636 virtual bool CanDeoptimize() const { return false; } 2619 virtual bool CanDeoptimize() const { return false; }
2637 2620
2638 virtual bool HasSideEffect() const { return true; } 2621 virtual bool HasSideEffect() const { return true; }
2639 2622
2623 virtual intptr_t ResultCid() const { return kDynamicCid; }
2624
2640 private: 2625 private:
2641 const NativeBodyNode& ast_node_; 2626 const NativeBodyNode& ast_node_;
2642 2627
2643 DISALLOW_COPY_AND_ASSIGN(NativeCallInstr); 2628 DISALLOW_COPY_AND_ASSIGN(NativeCallInstr);
2644 }; 2629 };
2645 2630
2646 2631
2647 class StoreInstanceFieldInstr : public TemplateDefinition<2> { 2632 class StoreInstanceFieldInstr : public TemplateDefinition<2> {
2648 public: 2633 public:
2649 StoreInstanceFieldInstr(const Field& field, 2634 StoreInstanceFieldInstr(const Field& field,
2650 Value* instance, 2635 Value* instance,
2651 Value* value, 2636 Value* value,
2652 bool emit_store_barrier) 2637 bool emit_store_barrier)
2653 : field_(field), emit_store_barrier_(emit_store_barrier) { 2638 : field_(field), emit_store_barrier_(emit_store_barrier) {
2654 ASSERT(instance != NULL); 2639 ASSERT(instance != NULL);
2655 ASSERT(value != NULL); 2640 ASSERT(value != NULL);
2656 inputs_[0] = instance; 2641 inputs_[0] = instance;
2657 inputs_[1] = value; 2642 inputs_[1] = value;
2658 } 2643 }
2659 2644
2660 DECLARE_INSTRUCTION(StoreInstanceField) 2645 DECLARE_INSTRUCTION(StoreInstanceField)
2661 virtual CompileType* ComputeInitialType() const; 2646 virtual RawAbstractType* CompileType() const;
2662 2647
2663 const Field& field() const { return field_; } 2648 const Field& field() const { return field_; }
2664 2649
2665 Value* instance() const { return inputs_[0]; } 2650 Value* instance() const { return inputs_[0]; }
2666 Value* value() const { return inputs_[1]; } 2651 Value* value() const { return inputs_[1]; }
2667 bool ShouldEmitStoreBarrier() const { 2652 bool ShouldEmitStoreBarrier() const {
2668 return value()->NeedsStoreBuffer() && emit_store_barrier_; 2653 return value()->NeedsStoreBuffer() && emit_store_barrier_;
2669 } 2654 }
2670 2655
2671 virtual void PrintOperandsTo(BufferFormatter* f) const; 2656 virtual void PrintOperandsTo(BufferFormatter* f) const;
2672 2657
2673 virtual bool CanDeoptimize() const { return false; } 2658 virtual bool CanDeoptimize() const { return false; }
2674 2659
2675 virtual bool HasSideEffect() const { return true; } 2660 virtual bool HasSideEffect() const { return true; }
2676 2661
2662 virtual intptr_t ResultCid() const { return kDynamicCid; }
2663
2677 private: 2664 private:
2678 const Field& field_; 2665 const Field& field_;
2679 const bool emit_store_barrier_; 2666 const bool emit_store_barrier_;
2680 2667
2681 DISALLOW_COPY_AND_ASSIGN(StoreInstanceFieldInstr); 2668 DISALLOW_COPY_AND_ASSIGN(StoreInstanceFieldInstr);
2682 }; 2669 };
2683 2670
2684 2671
2685 class LoadStaticFieldInstr : public TemplateDefinition<0> { 2672 class LoadStaticFieldInstr : public TemplateDefinition<0> {
2686 public: 2673 public:
2687 explicit LoadStaticFieldInstr(const Field& field) : field_(field) {} 2674 explicit LoadStaticFieldInstr(const Field& field) : field_(field) {}
2688 2675
2689 DECLARE_INSTRUCTION(LoadStaticField); 2676 DECLARE_INSTRUCTION(LoadStaticField);
2690 virtual CompileType* ComputeInitialType() const; 2677 virtual RawAbstractType* CompileType() const;
2691 2678
2692 const Field& field() const { return field_; } 2679 const Field& field() const { return field_; }
2693 2680
2694 virtual void PrintOperandsTo(BufferFormatter* f) const; 2681 virtual void PrintOperandsTo(BufferFormatter* f) const;
2695 2682
2696 virtual bool CanDeoptimize() const { return false; } 2683 virtual bool CanDeoptimize() const { return false; }
2697 2684
2698 virtual bool HasSideEffect() const { return false; } 2685 virtual bool HasSideEffect() const { return false; }
2699 2686
2687 virtual intptr_t ResultCid() const { return kDynamicCid; }
2688
2700 virtual bool AffectedBySideEffect() const { return !field().is_final(); } 2689 virtual bool AffectedBySideEffect() const { return !field().is_final(); }
2701 virtual bool AttributesEqual(Instruction* other) const; 2690 virtual bool AttributesEqual(Instruction* other) const;
2702 2691
2703 private: 2692 private:
2704 const Field& field_; 2693 const Field& field_;
2705 2694
2706 DISALLOW_COPY_AND_ASSIGN(LoadStaticFieldInstr); 2695 DISALLOW_COPY_AND_ASSIGN(LoadStaticFieldInstr);
2707 }; 2696 };
2708 2697
2709 2698
2710 class StoreStaticFieldInstr : public TemplateDefinition<1> { 2699 class StoreStaticFieldInstr : public TemplateDefinition<1> {
2711 public: 2700 public:
2712 StoreStaticFieldInstr(const Field& field, Value* value) 2701 StoreStaticFieldInstr(const Field& field, Value* value)
2713 : field_(field) { 2702 : field_(field) {
2714 ASSERT(field.IsZoneHandle()); 2703 ASSERT(field.IsZoneHandle());
2715 ASSERT(value != NULL); 2704 ASSERT(value != NULL);
2716 inputs_[0] = value; 2705 inputs_[0] = value;
2717 } 2706 }
2718 2707
2719 DECLARE_INSTRUCTION(StoreStaticField); 2708 DECLARE_INSTRUCTION(StoreStaticField);
2720 virtual CompileType* ComputeInitialType() const; 2709 virtual RawAbstractType* CompileType() const;
2721 2710
2722 const Field& field() const { return field_; } 2711 const Field& field() const { return field_; }
2723 Value* value() const { return inputs_[0]; } 2712 Value* value() const { return inputs_[0]; }
2724 2713
2725 virtual void PrintOperandsTo(BufferFormatter* f) const; 2714 virtual void PrintOperandsTo(BufferFormatter* f) const;
2726 2715
2727 virtual bool CanDeoptimize() const { return false; } 2716 virtual bool CanDeoptimize() const { return false; }
2728 2717
2729 virtual bool HasSideEffect() const { return true; } 2718 virtual bool HasSideEffect() const { return true; }
2730 2719
2720 virtual intptr_t ResultCid() const { return kDynamicCid; }
2721
2731 private: 2722 private:
2732 const Field& field_; 2723 const Field& field_;
2733 2724
2734 DISALLOW_COPY_AND_ASSIGN(StoreStaticFieldInstr); 2725 DISALLOW_COPY_AND_ASSIGN(StoreStaticFieldInstr);
2735 }; 2726 };
2736 2727
2737 2728
2738 class LoadIndexedInstr : public TemplateDefinition<2> { 2729 class LoadIndexedInstr : public TemplateDefinition<2> {
2739 public: 2730 public:
2740 LoadIndexedInstr(Value* array, 2731 LoadIndexedInstr(Value* array,
2741 Value* index, 2732 Value* index,
2742 intptr_t index_scale, 2733 intptr_t index_scale,
2743 intptr_t class_id, 2734 intptr_t class_id,
2744 intptr_t deopt_id) 2735 intptr_t deopt_id)
2745 : index_scale_(index_scale), class_id_(class_id) { 2736 : index_scale_(index_scale), class_id_(class_id) {
2746 ASSERT(array != NULL); 2737 ASSERT(array != NULL);
2747 ASSERT(index != NULL); 2738 ASSERT(index != NULL);
2748 inputs_[0] = array; 2739 inputs_[0] = array;
2749 inputs_[1] = index; 2740 inputs_[1] = index;
2750 deopt_id_ = deopt_id; 2741 deopt_id_ = deopt_id;
2751 } 2742 }
2752 2743
2753 DECLARE_INSTRUCTION(LoadIndexed) 2744 DECLARE_INSTRUCTION(LoadIndexed)
2754 virtual CompileType* ComputeInitialType() const; 2745 virtual RawAbstractType* CompileType() const;
2755 2746
2756 Value* array() const { return inputs_[0]; } 2747 Value* array() const { return inputs_[0]; }
2757 Value* index() const { return inputs_[1]; } 2748 Value* index() const { return inputs_[1]; }
2758 intptr_t index_scale() const { return index_scale_; } 2749 intptr_t index_scale() const { return index_scale_; }
2759 intptr_t class_id() const { return class_id_; } 2750 intptr_t class_id() const { return class_id_; }
2760 2751
2761 virtual bool CanDeoptimize() const { 2752 virtual bool CanDeoptimize() const {
2762 return deopt_id_ != Isolate::kNoDeoptId; 2753 return deopt_id_ != Isolate::kNoDeoptId;
2763 } 2754 }
2764 2755
2765 virtual bool HasSideEffect() const { return false; } 2756 virtual bool HasSideEffect() const { return false; }
2766 2757
2758 virtual intptr_t ResultCid() const;
2759
2767 virtual Representation representation() const; 2760 virtual Representation representation() const;
2768 2761
2769 virtual bool AttributesEqual(Instruction* other) const; 2762 virtual bool AttributesEqual(Instruction* other) const;
2770 2763
2771 virtual bool AffectedBySideEffect() const { return true; } 2764 virtual bool AffectedBySideEffect() const { return true; }
2772 2765
2773 virtual void InferRange(); 2766 virtual void InferRange();
2774 2767
2775 private: 2768 private:
2776 const intptr_t index_scale_; 2769 const intptr_t index_scale_;
2777 const intptr_t class_id_; 2770 const intptr_t class_id_;
2778 2771
2779 DISALLOW_COPY_AND_ASSIGN(LoadIndexedInstr); 2772 DISALLOW_COPY_AND_ASSIGN(LoadIndexedInstr);
2780 }; 2773 };
2781 2774
2782 2775
2783 class StringFromCharCodeInstr : public TemplateDefinition<1> { 2776 class StringFromCharCodeInstr : public TemplateDefinition<1> {
2784 public: 2777 public:
2785 explicit StringFromCharCodeInstr(Value* char_code, 2778 explicit StringFromCharCodeInstr(Value* char_code,
2786 intptr_t cid) : cid_(cid) { 2779 intptr_t cid) : cid_(cid) {
2787 ASSERT(char_code != NULL); 2780 ASSERT(char_code != NULL);
2788 ASSERT(char_code->definition()->IsLoadIndexed() && 2781 ASSERT(char_code->definition()->IsLoadIndexed() &&
2789 (char_code->definition()->AsLoadIndexed()->class_id() == 2782 (char_code->definition()->AsLoadIndexed()->class_id() ==
2790 kOneByteStringCid)); 2783 kOneByteStringCid));
2791 inputs_[0] = char_code; 2784 inputs_[0] = char_code;
2792 } 2785 }
2793 2786
2794 DECLARE_INSTRUCTION(StringFromCharCode) 2787 DECLARE_INSTRUCTION(StringFromCharCode)
2795 virtual CompileType* ComputeInitialType() const; 2788 virtual RawAbstractType* CompileType() const;
2796 2789
2797 Value* char_code() const { return inputs_[0]; } 2790 Value* char_code() const { return inputs_[0]; }
2798 2791
2799 virtual bool CanDeoptimize() const { return false; } 2792 virtual bool CanDeoptimize() const { return false; }
2800 2793
2801 virtual bool HasSideEffect() const { return false; } 2794 virtual bool HasSideEffect() const { return false; }
2802 2795
2796 virtual intptr_t ResultCid() const { return cid_; }
2797
2803 virtual bool AttributesEqual(Instruction* other) const { return true; } 2798 virtual bool AttributesEqual(Instruction* other) const { return true; }
2804 2799
2805 virtual bool AffectedBySideEffect() const { return false; } 2800 virtual bool AffectedBySideEffect() const { return false; }
2806 2801
2807 private: 2802 private:
2808 const intptr_t cid_; 2803 const intptr_t cid_;
2809 2804
2810 DISALLOW_COPY_AND_ASSIGN(StringFromCharCodeInstr); 2805 DISALLOW_COPY_AND_ASSIGN(StringFromCharCodeInstr);
2811 }; 2806 };
2812 2807
(...skipping 11 matching lines...) Expand all
2824 deopt_id_(deopt_id) { 2819 deopt_id_(deopt_id) {
2825 ASSERT(array != NULL); 2820 ASSERT(array != NULL);
2826 ASSERT(index != NULL); 2821 ASSERT(index != NULL);
2827 ASSERT(value != NULL); 2822 ASSERT(value != NULL);
2828 inputs_[0] = array; 2823 inputs_[0] = array;
2829 inputs_[1] = index; 2824 inputs_[1] = index;
2830 inputs_[2] = value; 2825 inputs_[2] = value;
2831 } 2826 }
2832 2827
2833 DECLARE_INSTRUCTION(StoreIndexed) 2828 DECLARE_INSTRUCTION(StoreIndexed)
2829 virtual RawAbstractType* CompileType() const;
2834 2830
2835 Value* array() const { return inputs_[0]; } 2831 Value* array() const { return inputs_[0]; }
2836 Value* index() const { return inputs_[1]; } 2832 Value* index() const { return inputs_[1]; }
2837 Value* value() const { return inputs_[2]; } 2833 Value* value() const { return inputs_[2]; }
2838 intptr_t class_id() const { return class_id_; } 2834 intptr_t class_id() const { return class_id_; }
2839 2835
2840 bool ShouldEmitStoreBarrier() const { 2836 bool ShouldEmitStoreBarrier() const {
2841 return value()->NeedsStoreBuffer() && emit_store_barrier_; 2837 return value()->NeedsStoreBuffer() && emit_store_barrier_;
2842 } 2838 }
2843 2839
2844 virtual bool CanDeoptimize() const { return false; } 2840 virtual bool CanDeoptimize() const { return false; }
2845 2841
2846 virtual bool HasSideEffect() const { return true; } 2842 virtual bool HasSideEffect() const { return true; }
2847 2843
2844 virtual intptr_t ResultCid() const { return kDynamicCid; }
2845
2848 virtual Representation RequiredInputRepresentation(intptr_t idx) const; 2846 virtual Representation RequiredInputRepresentation(intptr_t idx) const;
2849 2847
2850 virtual intptr_t DeoptimizationTarget() const { 2848 virtual intptr_t DeoptimizationTarget() const {
2851 // Direct access since this instruction cannot deoptimize, and the deopt-id 2849 // Direct access since this instruction cannot deoptimize, and the deopt-id
2852 // was inherited from another instruction that could deoptimize. 2850 // was inherited from another instruction that could deoptimize.
2853 return deopt_id_; 2851 return deopt_id_;
2854 } 2852 }
2855 2853
2856 private: 2854 private:
2857 const bool emit_store_barrier_; 2855 const bool emit_store_barrier_;
2858 const intptr_t class_id_; 2856 const intptr_t class_id_;
2859 const intptr_t deopt_id_; 2857 const intptr_t deopt_id_;
2860 2858
2861 DISALLOW_COPY_AND_ASSIGN(StoreIndexedInstr); 2859 DISALLOW_COPY_AND_ASSIGN(StoreIndexedInstr);
2862 }; 2860 };
2863 2861
2864 2862
2865 // Note overrideable, built-in: value? false : true. 2863 // Note overrideable, built-in: value? false : true.
2866 class BooleanNegateInstr : public TemplateDefinition<1> { 2864 class BooleanNegateInstr : public TemplateDefinition<1> {
2867 public: 2865 public:
2868 explicit BooleanNegateInstr(Value* value) { 2866 explicit BooleanNegateInstr(Value* value) {
2869 ASSERT(value != NULL); 2867 ASSERT(value != NULL);
2870 inputs_[0] = value; 2868 inputs_[0] = value;
2871 } 2869 }
2872 2870
2873 DECLARE_INSTRUCTION(BooleanNegate) 2871 DECLARE_INSTRUCTION(BooleanNegate)
2874 virtual CompileType* ComputeInitialType() const; 2872 virtual RawAbstractType* CompileType() const;
2875 2873
2876 Value* value() const { return inputs_[0]; } 2874 Value* value() const { return inputs_[0]; }
2877 2875
2878 virtual bool CanDeoptimize() const { return false; } 2876 virtual bool CanDeoptimize() const { return false; }
2879 2877
2880 virtual bool HasSideEffect() const { return false; } 2878 virtual bool HasSideEffect() const { return false; }
2881 2879
2880 virtual intptr_t ResultCid() const { return kBoolCid; }
2881
2882 private: 2882 private:
2883 DISALLOW_COPY_AND_ASSIGN(BooleanNegateInstr); 2883 DISALLOW_COPY_AND_ASSIGN(BooleanNegateInstr);
2884 }; 2884 };
2885 2885
2886 2886
2887 class InstanceOfInstr : public TemplateDefinition<3> { 2887 class InstanceOfInstr : public TemplateDefinition<3> {
2888 public: 2888 public:
2889 InstanceOfInstr(intptr_t token_pos, 2889 InstanceOfInstr(intptr_t token_pos,
2890 Value* value, 2890 Value* value,
2891 Value* instantiator, 2891 Value* instantiator,
2892 Value* instantiator_type_arguments, 2892 Value* instantiator_type_arguments,
2893 const AbstractType& type, 2893 const AbstractType& type,
2894 bool negate_result) 2894 bool negate_result)
2895 : token_pos_(token_pos), 2895 : token_pos_(token_pos),
2896 type_(type), 2896 type_(type),
2897 negate_result_(negate_result) { 2897 negate_result_(negate_result) {
2898 ASSERT(value != NULL); 2898 ASSERT(value != NULL);
2899 ASSERT(instantiator != NULL); 2899 ASSERT(instantiator != NULL);
2900 ASSERT(instantiator_type_arguments != NULL); 2900 ASSERT(instantiator_type_arguments != NULL);
2901 ASSERT(!type.IsNull()); 2901 ASSERT(!type.IsNull());
2902 inputs_[0] = value; 2902 inputs_[0] = value;
2903 inputs_[1] = instantiator; 2903 inputs_[1] = instantiator;
2904 inputs_[2] = instantiator_type_arguments; 2904 inputs_[2] = instantiator_type_arguments;
2905 } 2905 }
2906 2906
2907 DECLARE_INSTRUCTION(InstanceOf) 2907 DECLARE_INSTRUCTION(InstanceOf)
2908 virtual CompileType* ComputeInitialType() const; 2908 virtual RawAbstractType* CompileType() const;
2909 2909
2910 Value* value() const { return inputs_[0]; } 2910 Value* value() const { return inputs_[0]; }
2911 Value* instantiator() const { return inputs_[1]; } 2911 Value* instantiator() const { return inputs_[1]; }
2912 Value* instantiator_type_arguments() const { return inputs_[2]; } 2912 Value* instantiator_type_arguments() const { return inputs_[2]; }
2913 2913
2914 bool negate_result() const { return negate_result_; } 2914 bool negate_result() const { return negate_result_; }
2915 const AbstractType& type() const { return type_; } 2915 const AbstractType& type() const { return type_; }
2916 intptr_t token_pos() const { return token_pos_; } 2916 intptr_t token_pos() const { return token_pos_; }
2917 2917
2918 virtual void PrintOperandsTo(BufferFormatter* f) const; 2918 virtual void PrintOperandsTo(BufferFormatter* f) const;
2919 2919
2920 virtual bool CanDeoptimize() const { return true; } 2920 virtual bool CanDeoptimize() const { return true; }
2921 2921
2922 virtual bool HasSideEffect() const { return true; } 2922 virtual bool HasSideEffect() const { return true; }
2923 2923
2924 virtual intptr_t ResultCid() const { return kBoolCid; }
2925
2924 private: 2926 private:
2925 const intptr_t token_pos_; 2927 const intptr_t token_pos_;
2926 Value* value_; 2928 Value* value_;
2927 Value* instantiator_; 2929 Value* instantiator_;
2928 Value* type_arguments_; 2930 Value* type_arguments_;
2929 const AbstractType& type_; 2931 const AbstractType& type_;
2930 const bool negate_result_; 2932 const bool negate_result_;
2931 2933
2932 DISALLOW_COPY_AND_ASSIGN(InstanceOfInstr); 2934 DISALLOW_COPY_AND_ASSIGN(InstanceOfInstr);
2933 }; 2935 };
2934 2936
2935 2937
2936 class AllocateObjectInstr : public TemplateDefinition<0> { 2938 class AllocateObjectInstr : public TemplateDefinition<0> {
2937 public: 2939 public:
2938 AllocateObjectInstr(ConstructorCallNode* node, 2940 AllocateObjectInstr(ConstructorCallNode* node,
2939 ZoneGrowableArray<PushArgumentInstr*>* arguments) 2941 ZoneGrowableArray<PushArgumentInstr*>* arguments)
2940 : ast_node_(*node), 2942 : ast_node_(*node),
2941 arguments_(arguments), 2943 arguments_(arguments),
2942 cid_(Class::Handle(node->constructor().Owner()).id()) { 2944 cid_(Class::Handle(node->constructor().Owner()).id()) {
2943 // Either no arguments or one type-argument and one instantiator. 2945 // Either no arguments or one type-argument and one instantiator.
2944 ASSERT(arguments->is_empty() || (arguments->length() == 2)); 2946 ASSERT(arguments->is_empty() || (arguments->length() == 2));
2945 } 2947 }
2946 2948
2947 DECLARE_INSTRUCTION(AllocateObject) 2949 DECLARE_INSTRUCTION(AllocateObject)
2948 virtual CompileType* ComputeInitialType() const; 2950 virtual RawAbstractType* CompileType() const;
2949 2951
2950 virtual intptr_t ArgumentCount() const { return arguments_->length(); } 2952 virtual intptr_t ArgumentCount() const { return arguments_->length(); }
2951 PushArgumentInstr* ArgumentAt(intptr_t index) const { 2953 PushArgumentInstr* ArgumentAt(intptr_t index) const {
2952 return (*arguments_)[index]; 2954 return (*arguments_)[index];
2953 } 2955 }
2954 2956
2955 const Function& constructor() const { return ast_node_.constructor(); } 2957 const Function& constructor() const { return ast_node_.constructor(); }
2956 intptr_t token_pos() const { return ast_node_.token_pos(); } 2958 intptr_t token_pos() const { return ast_node_.token_pos(); }
2957 2959
2958 virtual void PrintOperandsTo(BufferFormatter* f) const; 2960 virtual void PrintOperandsTo(BufferFormatter* f) const;
2959 2961
2960 virtual bool CanDeoptimize() const { return false; } 2962 virtual bool CanDeoptimize() const { return false; }
2961 2963
2962 virtual bool HasSideEffect() const { return true; } 2964 virtual bool HasSideEffect() const { return true; }
2963 2965
2966 virtual intptr_t ResultCid() const { return cid_; }
2967
2964 private: 2968 private:
2965 const ConstructorCallNode& ast_node_; 2969 const ConstructorCallNode& ast_node_;
2966 ZoneGrowableArray<PushArgumentInstr*>* const arguments_; 2970 ZoneGrowableArray<PushArgumentInstr*>* const arguments_;
2967 const intptr_t cid_; 2971 const intptr_t cid_;
2968 2972
2969 DISALLOW_COPY_AND_ASSIGN(AllocateObjectInstr); 2973 DISALLOW_COPY_AND_ASSIGN(AllocateObjectInstr);
2970 }; 2974 };
2971 2975
2972 2976
2973 class AllocateObjectWithBoundsCheckInstr : public TemplateDefinition<2> { 2977 class AllocateObjectWithBoundsCheckInstr : public TemplateDefinition<2> {
2974 public: 2978 public:
2975 AllocateObjectWithBoundsCheckInstr(ConstructorCallNode* node, 2979 AllocateObjectWithBoundsCheckInstr(ConstructorCallNode* node,
2976 Value* type_arguments, 2980 Value* type_arguments,
2977 Value* instantiator) 2981 Value* instantiator)
2978 : ast_node_(*node) { 2982 : ast_node_(*node) {
2979 ASSERT(type_arguments != NULL); 2983 ASSERT(type_arguments != NULL);
2980 ASSERT(instantiator != NULL); 2984 ASSERT(instantiator != NULL);
2981 inputs_[0] = type_arguments; 2985 inputs_[0] = type_arguments;
2982 inputs_[1] = instantiator; 2986 inputs_[1] = instantiator;
2983 } 2987 }
2984 2988
2985 DECLARE_INSTRUCTION(AllocateObjectWithBoundsCheck) 2989 DECLARE_INSTRUCTION(AllocateObjectWithBoundsCheck)
2990 virtual RawAbstractType* CompileType() const;
2986 2991
2987 const Function& constructor() const { return ast_node_.constructor(); } 2992 const Function& constructor() const { return ast_node_.constructor(); }
2988 intptr_t token_pos() const { return ast_node_.token_pos(); } 2993 intptr_t token_pos() const { return ast_node_.token_pos(); }
2989 2994
2990 virtual void PrintOperandsTo(BufferFormatter* f) const; 2995 virtual void PrintOperandsTo(BufferFormatter* f) const;
2991 2996
2992 virtual bool CanDeoptimize() const { return true; } 2997 virtual bool CanDeoptimize() const { return true; }
2993 2998
2994 virtual bool HasSideEffect() const { return true; } 2999 virtual bool HasSideEffect() const { return true; }
2995 3000
3001 virtual intptr_t ResultCid() const { return kDynamicCid; }
3002
2996 private: 3003 private:
2997 const ConstructorCallNode& ast_node_; 3004 const ConstructorCallNode& ast_node_;
2998 3005
2999 DISALLOW_COPY_AND_ASSIGN(AllocateObjectWithBoundsCheckInstr); 3006 DISALLOW_COPY_AND_ASSIGN(AllocateObjectWithBoundsCheckInstr);
3000 }; 3007 };
3001 3008
3002 3009
3003 class CreateArrayInstr : public TemplateDefinition<1> { 3010 class CreateArrayInstr : public TemplateDefinition<1> {
3004 public: 3011 public:
3005 CreateArrayInstr(intptr_t token_pos, 3012 CreateArrayInstr(intptr_t token_pos,
3006 ZoneGrowableArray<PushArgumentInstr*>* arguments, 3013 ZoneGrowableArray<PushArgumentInstr*>* arguments,
3007 const AbstractType& type, 3014 const AbstractType& type,
3008 Value* element_type) 3015 Value* element_type)
3009 : token_pos_(token_pos), 3016 : token_pos_(token_pos),
3010 arguments_(arguments), 3017 arguments_(arguments),
3011 type_(type) { 3018 type_(type) {
3012 #if defined(DEBUG) 3019 #if defined(DEBUG)
3013 for (int i = 0; i < ArgumentCount(); ++i) { 3020 for (int i = 0; i < ArgumentCount(); ++i) {
3014 ASSERT(ArgumentAt(i) != NULL); 3021 ASSERT(ArgumentAt(i) != NULL);
3015 } 3022 }
3016 ASSERT(element_type != NULL); 3023 ASSERT(element_type != NULL);
3017 ASSERT(type_.IsZoneHandle()); 3024 ASSERT(type_.IsZoneHandle());
3018 ASSERT(!type_.IsNull()); 3025 ASSERT(!type_.IsNull());
3019 ASSERT(type_.IsFinalized()); 3026 ASSERT(type_.IsFinalized());
3020 #endif 3027 #endif
3021 inputs_[0] = element_type; 3028 inputs_[0] = element_type;
3022 } 3029 }
3023 3030
3024 DECLARE_INSTRUCTION(CreateArray) 3031 DECLARE_INSTRUCTION(CreateArray)
3025 virtual CompileType* ComputeInitialType() const; 3032 virtual RawAbstractType* CompileType() const;
3026 3033
3027 virtual intptr_t ArgumentCount() const { return arguments_->length(); } 3034 virtual intptr_t ArgumentCount() const { return arguments_->length(); }
3028 3035
3029 intptr_t token_pos() const { return token_pos_; } 3036 intptr_t token_pos() const { return token_pos_; }
3030 PushArgumentInstr* ArgumentAt(intptr_t i) const { return (*arguments_)[i]; } 3037 PushArgumentInstr* ArgumentAt(intptr_t i) const { return (*arguments_)[i]; }
3031 const AbstractType& type() const { return type_; } 3038 const AbstractType& type() const { return type_; }
3032 Value* element_type() const { return inputs_[0]; } 3039 Value* element_type() const { return inputs_[0]; }
3033 3040
3034 virtual void PrintOperandsTo(BufferFormatter* f) const; 3041 virtual void PrintOperandsTo(BufferFormatter* f) const;
3035 3042
3036 virtual bool CanDeoptimize() const { return false; } 3043 virtual bool CanDeoptimize() const { return false; }
3037 3044
3038 virtual bool HasSideEffect() const { return true; } 3045 virtual bool HasSideEffect() const { return true; }
3039 3046
3047 virtual intptr_t ResultCid() const { return kArrayCid; }
3048
3040 private: 3049 private:
3041 const intptr_t token_pos_; 3050 const intptr_t token_pos_;
3042 ZoneGrowableArray<PushArgumentInstr*>* const arguments_; 3051 ZoneGrowableArray<PushArgumentInstr*>* const arguments_;
3043 const AbstractType& type_; 3052 const AbstractType& type_;
3044 3053
3045 DISALLOW_COPY_AND_ASSIGN(CreateArrayInstr); 3054 DISALLOW_COPY_AND_ASSIGN(CreateArrayInstr);
3046 }; 3055 };
3047 3056
3048 3057
3049 class CreateClosureInstr : public TemplateDefinition<0> { 3058 class CreateClosureInstr : public TemplateDefinition<0> {
3050 public: 3059 public:
3051 CreateClosureInstr(const Function& function, 3060 CreateClosureInstr(const Function& function,
3052 ZoneGrowableArray<PushArgumentInstr*>* arguments, 3061 ZoneGrowableArray<PushArgumentInstr*>* arguments,
3053 intptr_t token_pos) 3062 intptr_t token_pos)
3054 : function_(function), 3063 : function_(function),
3055 arguments_(arguments), 3064 arguments_(arguments),
3056 token_pos_(token_pos) { } 3065 token_pos_(token_pos) { }
3057 3066
3058 DECLARE_INSTRUCTION(CreateClosure) 3067 DECLARE_INSTRUCTION(CreateClosure)
3059 virtual CompileType* ComputeInitialType() const; 3068 virtual RawAbstractType* CompileType() const;
3060 3069
3061 intptr_t token_pos() const { return token_pos_; } 3070 intptr_t token_pos() const { return token_pos_; }
3062 const Function& function() const { return function_; } 3071 const Function& function() const { return function_; }
3063 3072
3064 virtual intptr_t ArgumentCount() const { return arguments_->length(); } 3073 virtual intptr_t ArgumentCount() const { return arguments_->length(); }
3065 PushArgumentInstr* ArgumentAt(intptr_t index) const { 3074 PushArgumentInstr* ArgumentAt(intptr_t index) const {
3066 return (*arguments_)[index]; 3075 return (*arguments_)[index];
3067 } 3076 }
3068 3077
3069 virtual void PrintOperandsTo(BufferFormatter* f) const; 3078 virtual void PrintOperandsTo(BufferFormatter* f) const;
3070 3079
3071 virtual bool CanDeoptimize() const { return false; } 3080 virtual bool CanDeoptimize() const { return false; }
3072 3081
3073 virtual bool HasSideEffect() const { return true; } 3082 virtual bool HasSideEffect() const { return true; }
3074 3083
3084 virtual intptr_t ResultCid() const { return kDynamicCid; }
3085
3075 private: 3086 private:
3076 const Function& function_; 3087 const Function& function_;
3077 ZoneGrowableArray<PushArgumentInstr*>* arguments_; 3088 ZoneGrowableArray<PushArgumentInstr*>* arguments_;
3078 intptr_t token_pos_; 3089 intptr_t token_pos_;
3079 3090
3080 DISALLOW_COPY_AND_ASSIGN(CreateClosureInstr); 3091 DISALLOW_COPY_AND_ASSIGN(CreateClosureInstr);
3081 }; 3092 };
3082 3093
3083 3094
3084 class LoadFieldInstr : public TemplateDefinition<1> { 3095 class LoadFieldInstr : public TemplateDefinition<1> {
3085 public: 3096 public:
3086 LoadFieldInstr(Value* value, 3097 LoadFieldInstr(Value* value,
3087 intptr_t offset_in_bytes, 3098 intptr_t offset_in_bytes,
3088 const AbstractType& type, 3099 const AbstractType& type,
3089 bool immutable = false) 3100 bool immutable = false)
3090 : offset_in_bytes_(offset_in_bytes), 3101 : offset_in_bytes_(offset_in_bytes),
3091 type_(type), 3102 type_(type),
3092 result_cid_(kDynamicCid), 3103 result_cid_(kDynamicCid),
3093 immutable_(immutable), 3104 immutable_(immutable),
3094 recognized_kind_(MethodRecognizer::kUnknown) { 3105 recognized_kind_(MethodRecognizer::kUnknown) {
3095 ASSERT(value != NULL); 3106 ASSERT(value != NULL);
3096 ASSERT(type.IsZoneHandle()); // May be null if field is not an instance. 3107 ASSERT(type.IsZoneHandle()); // May be null if field is not an instance.
3097 inputs_[0] = value; 3108 inputs_[0] = value;
3098 } 3109 }
3099 3110
3100 DECLARE_INSTRUCTION(LoadField) 3111 DECLARE_INSTRUCTION(LoadField)
3101 virtual CompileType* ComputeInitialType() const; 3112 virtual RawAbstractType* CompileType() const;
3102 3113
3103 Value* value() const { return inputs_[0]; } 3114 Value* value() const { return inputs_[0]; }
3104 intptr_t offset_in_bytes() const { return offset_in_bytes_; } 3115 intptr_t offset_in_bytes() const { return offset_in_bytes_; }
3105 const AbstractType& type() const { return type_; } 3116 const AbstractType& type() const { return type_; }
3106 void set_result_cid(intptr_t value) { result_cid_ = value; } 3117 void set_result_cid(intptr_t value) { result_cid_ = value; }
3107 3118
3108 virtual void PrintOperandsTo(BufferFormatter* f) const; 3119 virtual void PrintOperandsTo(BufferFormatter* f) const;
3109 3120
3110 virtual bool CanDeoptimize() const { return false; } 3121 virtual bool CanDeoptimize() const { return false; }
3111 3122
3112 virtual bool HasSideEffect() const { return false; } 3123 virtual bool HasSideEffect() const { return false; }
3113 3124
3125 virtual intptr_t ResultCid() const { return result_cid_; }
3126
3114 virtual bool AttributesEqual(Instruction* other) const; 3127 virtual bool AttributesEqual(Instruction* other) const;
3115 3128
3116 virtual bool AffectedBySideEffect() const { return !immutable_; } 3129 virtual bool AffectedBySideEffect() const { return !immutable_; }
3117 3130
3118 virtual void InferRange(); 3131 virtual void InferRange();
3119 3132
3120 void set_recognized_kind(MethodRecognizer::Kind kind) { 3133 void set_recognized_kind(MethodRecognizer::Kind kind) {
3121 recognized_kind_ = kind; 3134 recognized_kind_ = kind;
3122 } 3135 }
3123 3136
(...skipping 27 matching lines...) Expand all
3151 const AbstractType& type) 3164 const AbstractType& type)
3152 : offset_in_bytes_(offset_in_bytes), type_(type) { 3165 : offset_in_bytes_(offset_in_bytes), type_(type) {
3153 ASSERT(value != NULL); 3166 ASSERT(value != NULL);
3154 ASSERT(dest != NULL); 3167 ASSERT(dest != NULL);
3155 ASSERT(type.IsZoneHandle()); // May be null if field is not an instance. 3168 ASSERT(type.IsZoneHandle()); // May be null if field is not an instance.
3156 inputs_[0] = value; 3169 inputs_[0] = value;
3157 inputs_[1] = dest; 3170 inputs_[1] = dest;
3158 } 3171 }
3159 3172
3160 DECLARE_INSTRUCTION(StoreVMField) 3173 DECLARE_INSTRUCTION(StoreVMField)
3161 virtual CompileType* ComputeInitialType() const; 3174 virtual RawAbstractType* CompileType() const;
3162 3175
3163 Value* value() const { return inputs_[0]; } 3176 Value* value() const { return inputs_[0]; }
3164 Value* dest() const { return inputs_[1]; } 3177 Value* dest() const { return inputs_[1]; }
3165 intptr_t offset_in_bytes() const { return offset_in_bytes_; } 3178 intptr_t offset_in_bytes() const { return offset_in_bytes_; }
3166 const AbstractType& type() const { return type_; } 3179 const AbstractType& type() const { return type_; }
3167 3180
3168 virtual void PrintOperandsTo(BufferFormatter* f) const; 3181 virtual void PrintOperandsTo(BufferFormatter* f) const;
3169 3182
3170 virtual bool CanDeoptimize() const { return false; } 3183 virtual bool CanDeoptimize() const { return false; }
3171 3184
3172 virtual bool HasSideEffect() const { return true; } 3185 virtual bool HasSideEffect() const { return true; }
3173 3186
3187 virtual intptr_t ResultCid() const { return kDynamicCid; }
3188
3174 private: 3189 private:
3175 const intptr_t offset_in_bytes_; 3190 const intptr_t offset_in_bytes_;
3176 const AbstractType& type_; 3191 const AbstractType& type_;
3177 3192
3178 DISALLOW_COPY_AND_ASSIGN(StoreVMFieldInstr); 3193 DISALLOW_COPY_AND_ASSIGN(StoreVMFieldInstr);
3179 }; 3194 };
3180 3195
3181 3196
3182 class InstantiateTypeArgumentsInstr : public TemplateDefinition<1> { 3197 class InstantiateTypeArgumentsInstr : public TemplateDefinition<1> {
3183 public: 3198 public:
3184 InstantiateTypeArgumentsInstr(intptr_t token_pos, 3199 InstantiateTypeArgumentsInstr(intptr_t token_pos,
3185 const AbstractTypeArguments& type_arguments, 3200 const AbstractTypeArguments& type_arguments,
3186 Value* instantiator) 3201 Value* instantiator)
3187 : token_pos_(token_pos), 3202 : token_pos_(token_pos),
3188 type_arguments_(type_arguments) { 3203 type_arguments_(type_arguments) {
3189 ASSERT(type_arguments.IsZoneHandle()); 3204 ASSERT(type_arguments.IsZoneHandle());
3190 ASSERT(instantiator != NULL); 3205 ASSERT(instantiator != NULL);
3191 inputs_[0] = instantiator; 3206 inputs_[0] = instantiator;
3192 } 3207 }
3193 3208
3194 DECLARE_INSTRUCTION(InstantiateTypeArguments) 3209 DECLARE_INSTRUCTION(InstantiateTypeArguments)
3210 virtual RawAbstractType* CompileType() const;
3195 3211
3196 Value* instantiator() const { return inputs_[0]; } 3212 Value* instantiator() const { return inputs_[0]; }
3197 const AbstractTypeArguments& type_arguments() const { 3213 const AbstractTypeArguments& type_arguments() const {
3198 return type_arguments_; 3214 return type_arguments_;
3199 } 3215 }
3200 intptr_t token_pos() const { return token_pos_; } 3216 intptr_t token_pos() const { return token_pos_; }
3201 3217
3202 virtual void PrintOperandsTo(BufferFormatter* f) const; 3218 virtual void PrintOperandsTo(BufferFormatter* f) const;
3203 3219
3204 virtual bool CanDeoptimize() const { return true; } 3220 virtual bool CanDeoptimize() const { return true; }
3205 3221
3206 virtual bool HasSideEffect() const { return true; } 3222 virtual bool HasSideEffect() const { return true; }
3207 3223
3224 virtual intptr_t ResultCid() const { return kDynamicCid; }
3225
3208 private: 3226 private:
3209 const intptr_t token_pos_; 3227 const intptr_t token_pos_;
3210 const AbstractTypeArguments& type_arguments_; 3228 const AbstractTypeArguments& type_arguments_;
3211 3229
3212 DISALLOW_COPY_AND_ASSIGN(InstantiateTypeArgumentsInstr); 3230 DISALLOW_COPY_AND_ASSIGN(InstantiateTypeArgumentsInstr);
3213 }; 3231 };
3214 3232
3215 3233
3216 class ExtractConstructorTypeArgumentsInstr : public TemplateDefinition<1> { 3234 class ExtractConstructorTypeArgumentsInstr : public TemplateDefinition<1> {
3217 public: 3235 public:
3218 ExtractConstructorTypeArgumentsInstr( 3236 ExtractConstructorTypeArgumentsInstr(
3219 intptr_t token_pos, 3237 intptr_t token_pos,
3220 const AbstractTypeArguments& type_arguments, 3238 const AbstractTypeArguments& type_arguments,
3221 Value* instantiator) 3239 Value* instantiator)
3222 : token_pos_(token_pos), 3240 : token_pos_(token_pos),
3223 type_arguments_(type_arguments) { 3241 type_arguments_(type_arguments) {
3224 ASSERT(instantiator != NULL); 3242 ASSERT(instantiator != NULL);
3225 inputs_[0] = instantiator; 3243 inputs_[0] = instantiator;
3226 } 3244 }
3227 3245
3228 DECLARE_INSTRUCTION(ExtractConstructorTypeArguments) 3246 DECLARE_INSTRUCTION(ExtractConstructorTypeArguments)
3247 virtual RawAbstractType* CompileType() const;
3229 3248
3230 Value* instantiator() const { return inputs_[0]; } 3249 Value* instantiator() const { return inputs_[0]; }
3231 const AbstractTypeArguments& type_arguments() const { 3250 const AbstractTypeArguments& type_arguments() const {
3232 return type_arguments_; 3251 return type_arguments_;
3233 } 3252 }
3234 intptr_t token_pos() const { return token_pos_; } 3253 intptr_t token_pos() const { return token_pos_; }
3235 3254
3236 virtual void PrintOperandsTo(BufferFormatter* f) const; 3255 virtual void PrintOperandsTo(BufferFormatter* f) const;
3237 3256
3238 virtual bool CanDeoptimize() const { return false; } 3257 virtual bool CanDeoptimize() const { return false; }
3239 3258
3240 virtual bool HasSideEffect() const { return false; } 3259 virtual bool HasSideEffect() const { return false; }
3241 3260
3261 virtual intptr_t ResultCid() const { return kDynamicCid; }
3262
3242 private: 3263 private:
3243 const intptr_t token_pos_; 3264 const intptr_t token_pos_;
3244 const AbstractTypeArguments& type_arguments_; 3265 const AbstractTypeArguments& type_arguments_;
3245 3266
3246 DISALLOW_COPY_AND_ASSIGN(ExtractConstructorTypeArgumentsInstr); 3267 DISALLOW_COPY_AND_ASSIGN(ExtractConstructorTypeArgumentsInstr);
3247 }; 3268 };
3248 3269
3249 3270
3250 class ExtractConstructorInstantiatorInstr : public TemplateDefinition<1> { 3271 class ExtractConstructorInstantiatorInstr : public TemplateDefinition<1> {
3251 public: 3272 public:
3252 ExtractConstructorInstantiatorInstr(ConstructorCallNode* ast_node, 3273 ExtractConstructorInstantiatorInstr(ConstructorCallNode* ast_node,
3253 Value* instantiator) 3274 Value* instantiator)
3254 : ast_node_(*ast_node) { 3275 : ast_node_(*ast_node) {
3255 ASSERT(instantiator != NULL); 3276 ASSERT(instantiator != NULL);
3256 inputs_[0] = instantiator; 3277 inputs_[0] = instantiator;
3257 } 3278 }
3258 3279
3259 DECLARE_INSTRUCTION(ExtractConstructorInstantiator) 3280 DECLARE_INSTRUCTION(ExtractConstructorInstantiator)
3281 virtual RawAbstractType* CompileType() const;
3260 3282
3261 Value* instantiator() const { return inputs_[0]; } 3283 Value* instantiator() const { return inputs_[0]; }
3262 const AbstractTypeArguments& type_arguments() const { 3284 const AbstractTypeArguments& type_arguments() const {
3263 return ast_node_.type_arguments(); 3285 return ast_node_.type_arguments();
3264 } 3286 }
3265 const Function& constructor() const { return ast_node_.constructor(); } 3287 const Function& constructor() const { return ast_node_.constructor(); }
3266 intptr_t token_pos() const { return ast_node_.token_pos(); } 3288 intptr_t token_pos() const { return ast_node_.token_pos(); }
3267 3289
3268 virtual bool CanDeoptimize() const { return false; } 3290 virtual bool CanDeoptimize() const { return false; }
3269 3291
3270 virtual bool HasSideEffect() const { return false; } 3292 virtual bool HasSideEffect() const { return false; }
3271 3293
3294 virtual intptr_t ResultCid() const { return kDynamicCid; }
3295
3272 private: 3296 private:
3273 const ConstructorCallNode& ast_node_; 3297 const ConstructorCallNode& ast_node_;
3274 3298
3275 DISALLOW_COPY_AND_ASSIGN(ExtractConstructorInstantiatorInstr); 3299 DISALLOW_COPY_AND_ASSIGN(ExtractConstructorInstantiatorInstr);
3276 }; 3300 };
3277 3301
3278 3302
3279 class AllocateContextInstr : public TemplateDefinition<0> { 3303 class AllocateContextInstr : public TemplateDefinition<0> {
3280 public: 3304 public:
3281 AllocateContextInstr(intptr_t token_pos, 3305 AllocateContextInstr(intptr_t token_pos,
3282 intptr_t num_context_variables) 3306 intptr_t num_context_variables)
3283 : token_pos_(token_pos), 3307 : token_pos_(token_pos),
3284 num_context_variables_(num_context_variables) {} 3308 num_context_variables_(num_context_variables) {}
3285 3309
3286 DECLARE_INSTRUCTION(AllocateContext); 3310 DECLARE_INSTRUCTION(AllocateContext);
3287 virtual CompileType* ComputeInitialType() const; 3311 virtual RawAbstractType* CompileType() const;
3288 3312
3289 intptr_t token_pos() const { return token_pos_; } 3313 intptr_t token_pos() const { return token_pos_; }
3290 intptr_t num_context_variables() const { return num_context_variables_; } 3314 intptr_t num_context_variables() const { return num_context_variables_; }
3291 3315
3292 virtual void PrintOperandsTo(BufferFormatter* f) const; 3316 virtual void PrintOperandsTo(BufferFormatter* f) const;
3293 3317
3294 virtual bool CanDeoptimize() const { return false; } 3318 virtual bool CanDeoptimize() const { return false; }
3295 3319
3296 virtual bool HasSideEffect() const { return false; } 3320 virtual bool HasSideEffect() const { return false; }
3297 3321
3322 virtual intptr_t ResultCid() const { return kDynamicCid; }
3323
3298 private: 3324 private:
3299 const intptr_t token_pos_; 3325 const intptr_t token_pos_;
3300 const intptr_t num_context_variables_; 3326 const intptr_t num_context_variables_;
3301 3327
3302 DISALLOW_COPY_AND_ASSIGN(AllocateContextInstr); 3328 DISALLOW_COPY_AND_ASSIGN(AllocateContextInstr);
3303 }; 3329 };
3304 3330
3305 3331
3306 class ChainContextInstr : public TemplateInstruction<1> { 3332 class ChainContextInstr : public TemplateInstruction<1> {
3307 public: 3333 public:
3308 explicit ChainContextInstr(Value* context_value) { 3334 explicit ChainContextInstr(Value* context_value) {
3309 ASSERT(context_value != NULL); 3335 ASSERT(context_value != NULL);
3310 inputs_[0] = context_value; 3336 inputs_[0] = context_value;
3311 } 3337 }
3312 3338
3313 DECLARE_INSTRUCTION(ChainContext) 3339 DECLARE_INSTRUCTION(ChainContext)
3340 virtual RawAbstractType* CompileType() const;
3314 3341
3315 virtual intptr_t ArgumentCount() const { return 0; } 3342 virtual intptr_t ArgumentCount() const { return 0; }
3316 3343
3317 Value* context_value() const { return inputs_[0]; } 3344 Value* context_value() const { return inputs_[0]; }
3318 3345
3319 virtual bool CanDeoptimize() const { return false; } 3346 virtual bool CanDeoptimize() const { return false; }
3320 3347
3321 virtual bool HasSideEffect() const { return true; } 3348 virtual bool HasSideEffect() const { return true; }
3322 3349
3323 private: 3350 private:
3324 DISALLOW_COPY_AND_ASSIGN(ChainContextInstr); 3351 DISALLOW_COPY_AND_ASSIGN(ChainContextInstr);
3325 }; 3352 };
3326 3353
3327 3354
3328 class CloneContextInstr : public TemplateDefinition<1> { 3355 class CloneContextInstr : public TemplateDefinition<1> {
3329 public: 3356 public:
3330 CloneContextInstr(intptr_t token_pos, Value* context_value) 3357 CloneContextInstr(intptr_t token_pos, Value* context_value)
3331 : token_pos_(token_pos) { 3358 : token_pos_(token_pos) {
3332 ASSERT(context_value != NULL); 3359 ASSERT(context_value != NULL);
3333 inputs_[0] = context_value; 3360 inputs_[0] = context_value;
3334 } 3361 }
3335 3362
3336 intptr_t token_pos() const { return token_pos_; } 3363 intptr_t token_pos() const { return token_pos_; }
3337 Value* context_value() const { return inputs_[0]; } 3364 Value* context_value() const { return inputs_[0]; }
3338 3365
3339 DECLARE_INSTRUCTION(CloneContext) 3366 DECLARE_INSTRUCTION(CloneContext)
3340 virtual CompileType* ComputeInitialType() const; 3367 virtual RawAbstractType* CompileType() const;
3341 3368
3342 virtual bool CanDeoptimize() const { return true; } 3369 virtual bool CanDeoptimize() const { return true; }
3343 3370
3344 virtual bool HasSideEffect() const { return false; } 3371 virtual bool HasSideEffect() const { return false; }
3345 3372
3373 virtual intptr_t ResultCid() const { return kContextCid; }
3374
3346 private: 3375 private:
3347 const intptr_t token_pos_; 3376 const intptr_t token_pos_;
3348 3377
3349 DISALLOW_COPY_AND_ASSIGN(CloneContextInstr); 3378 DISALLOW_COPY_AND_ASSIGN(CloneContextInstr);
3350 }; 3379 };
3351 3380
3352 3381
3353 class CatchEntryInstr : public TemplateInstruction<0> { 3382 class CatchEntryInstr : public TemplateInstruction<0> {
3354 public: 3383 public:
3355 CatchEntryInstr(const LocalVariable& exception_var, 3384 CatchEntryInstr(const LocalVariable& exception_var,
3356 const LocalVariable& stacktrace_var) 3385 const LocalVariable& stacktrace_var)
3357 : exception_var_(exception_var), stacktrace_var_(stacktrace_var) {} 3386 : exception_var_(exception_var), stacktrace_var_(stacktrace_var) {}
3358 3387
3359 const LocalVariable& exception_var() const { return exception_var_; } 3388 const LocalVariable& exception_var() const { return exception_var_; }
3360 const LocalVariable& stacktrace_var() const { return stacktrace_var_; } 3389 const LocalVariable& stacktrace_var() const { return stacktrace_var_; }
3361 3390
3362 DECLARE_INSTRUCTION(CatchEntry) 3391 DECLARE_INSTRUCTION(CatchEntry)
3392 virtual RawAbstractType* CompileType() const;
3363 3393
3364 virtual intptr_t ArgumentCount() const { return 0; } 3394 virtual intptr_t ArgumentCount() const { return 0; }
3365 3395
3366 virtual void PrintOperandsTo(BufferFormatter* f) const; 3396 virtual void PrintOperandsTo(BufferFormatter* f) const;
3367 3397
3368 virtual bool CanDeoptimize() const { return false; } 3398 virtual bool CanDeoptimize() const { return false; }
3369 3399
3370 virtual bool HasSideEffect() const { return true; } 3400 virtual bool HasSideEffect() const { return true; }
3371 3401
3372 private: 3402 private:
(...skipping 10 matching lines...) Expand all
3383 Value* right, 3413 Value* right,
3384 InstanceCallInstr* instance_call) { 3414 InstanceCallInstr* instance_call) {
3385 ASSERT(left != NULL); 3415 ASSERT(left != NULL);
3386 ASSERT(right != NULL); 3416 ASSERT(right != NULL);
3387 inputs_[0] = left; 3417 inputs_[0] = left;
3388 inputs_[1] = right; 3418 inputs_[1] = right;
3389 deopt_id_ = instance_call->deopt_id(); 3419 deopt_id_ = instance_call->deopt_id();
3390 } 3420 }
3391 3421
3392 DECLARE_INSTRUCTION(CheckEitherNonSmi) 3422 DECLARE_INSTRUCTION(CheckEitherNonSmi)
3423 virtual RawAbstractType* CompileType() const;
3393 3424
3394 virtual intptr_t ArgumentCount() const { return 0; } 3425 virtual intptr_t ArgumentCount() const { return 0; }
3395 3426
3396 virtual bool CanDeoptimize() const { return true; } 3427 virtual bool CanDeoptimize() const { return true; }
3397 3428
3398 virtual bool HasSideEffect() const { return false; } 3429 virtual bool HasSideEffect() const { return false; }
3399 3430
3400 virtual bool AttributesEqual(Instruction* other) const { return true; } 3431 virtual bool AttributesEqual(Instruction* other) const { return true; }
3401 3432
3402 virtual bool AffectedBySideEffect() const { return false; } 3433 virtual bool AffectedBySideEffect() const { return false; }
(...skipping 21 matching lines...) Expand all
3424 3455
3425 intptr_t token_pos() const { return token_pos_; } 3456 intptr_t token_pos() const { return token_pos_; }
3426 3457
3427 virtual bool CanDeoptimize() const { return false; } 3458 virtual bool CanDeoptimize() const { return false; }
3428 3459
3429 virtual bool HasSideEffect() const { return false; } 3460 virtual bool HasSideEffect() const { return false; }
3430 3461
3431 virtual bool AffectedBySideEffect() const { return false; } 3462 virtual bool AffectedBySideEffect() const { return false; }
3432 virtual bool AttributesEqual(Instruction* other) const { return true; } 3463 virtual bool AttributesEqual(Instruction* other) const { return true; }
3433 3464
3465 virtual intptr_t ResultCid() const;
3466
3434 virtual Representation RequiredInputRepresentation(intptr_t idx) const { 3467 virtual Representation RequiredInputRepresentation(intptr_t idx) const {
3435 ASSERT(idx == 0); 3468 ASSERT(idx == 0);
3436 return kUnboxedDouble; 3469 return kUnboxedDouble;
3437 } 3470 }
3438 3471
3439 DECLARE_INSTRUCTION(BoxDouble) 3472 DECLARE_INSTRUCTION(BoxDouble)
3440 virtual CompileType* ComputeInitialType() const; 3473 virtual RawAbstractType* CompileType() const;
3441 3474
3442 private: 3475 private:
3443 const intptr_t token_pos_; 3476 const intptr_t token_pos_;
3444 3477
3445 DISALLOW_COPY_AND_ASSIGN(BoxDoubleInstr); 3478 DISALLOW_COPY_AND_ASSIGN(BoxDoubleInstr);
3446 }; 3479 };
3447 3480
3448 3481
3449 class BoxIntegerInstr : public TemplateDefinition<1> { 3482 class BoxIntegerInstr : public TemplateDefinition<1> {
3450 public: 3483 public:
3451 explicit BoxIntegerInstr(Value* value) { 3484 explicit BoxIntegerInstr(Value* value) {
3452 ASSERT(value != NULL); 3485 ASSERT(value != NULL);
3453 inputs_[0] = value; 3486 inputs_[0] = value;
3454 } 3487 }
3455 3488
3456 Value* value() const { return inputs_[0]; } 3489 Value* value() const { return inputs_[0]; }
3457 3490
3458 virtual bool CanDeoptimize() const { return false; } 3491 virtual bool CanDeoptimize() const { return false; }
3459 3492
3460 virtual bool HasSideEffect() const { return false; } 3493 virtual bool HasSideEffect() const { return false; }
3461 3494
3462 virtual bool AffectedBySideEffect() const { return false; } 3495 virtual bool AffectedBySideEffect() const { return false; }
3463 virtual bool AttributesEqual(Instruction* other) const { return true; } 3496 virtual bool AttributesEqual(Instruction* other) const { return true; }
3464 3497
3498 virtual intptr_t ResultCid() const;
3499
3465 virtual Representation RequiredInputRepresentation(intptr_t idx) const { 3500 virtual Representation RequiredInputRepresentation(intptr_t idx) const {
3466 ASSERT(idx == 0); 3501 ASSERT(idx == 0);
3467 return kUnboxedMint; 3502 return kUnboxedMint;
3468 } 3503 }
3469 3504
3470 DECLARE_INSTRUCTION(BoxInteger) 3505 DECLARE_INSTRUCTION(BoxInteger)
3471 virtual CompileType* ComputeInitialType() const; 3506 virtual RawAbstractType* CompileType() const;
3472 3507
3473 private: 3508 private:
3474 DISALLOW_COPY_AND_ASSIGN(BoxIntegerInstr); 3509 DISALLOW_COPY_AND_ASSIGN(BoxIntegerInstr);
3475 }; 3510 };
3476 3511
3477 3512
3478 class UnboxDoubleInstr : public TemplateDefinition<1> { 3513 class UnboxDoubleInstr : public TemplateDefinition<1> {
3479 public: 3514 public:
3480 UnboxDoubleInstr(Value* value, intptr_t deopt_id) { 3515 UnboxDoubleInstr(Value* value, intptr_t deopt_id) {
3481 ASSERT(value != NULL); 3516 ASSERT(value != NULL);
3482 inputs_[0] = value; 3517 inputs_[0] = value;
3483 deopt_id_ = deopt_id; 3518 deopt_id_ = deopt_id;
3484 } 3519 }
3485 3520
3486 Value* value() const { return inputs_[0]; } 3521 Value* value() const { return inputs_[0]; }
3487 3522
3488 virtual bool CanDeoptimize() const { 3523 virtual bool CanDeoptimize() const {
3489 return (value()->Type()->ToCid() != kDoubleCid) 3524 return (value()->ResultCid() != kDoubleCid)
3490 && (value()->Type()->ToCid() != kSmiCid); 3525 && (value()->ResultCid() != kSmiCid);
3491 } 3526 }
3492 3527
3493 virtual bool HasSideEffect() const { return false; } 3528 virtual bool HasSideEffect() const { return false; }
3494 3529
3530 // The output is not an instance but when it is boxed it becomes double.
3531 virtual intptr_t ResultCid() const { return kDoubleCid; }
3532
3495 virtual Representation representation() const { 3533 virtual Representation representation() const {
3496 return kUnboxedDouble; 3534 return kUnboxedDouble;
3497 } 3535 }
3498 3536
3499 virtual bool AffectedBySideEffect() const { return false; } 3537 virtual bool AffectedBySideEffect() const { return false; }
3500 virtual bool AttributesEqual(Instruction* other) const { return true; } 3538 virtual bool AttributesEqual(Instruction* other) const { return true; }
3501 3539
3502 DECLARE_INSTRUCTION(UnboxDouble) 3540 DECLARE_INSTRUCTION(UnboxDouble)
3503 virtual CompileType* ComputeInitialType() const; 3541 virtual RawAbstractType* CompileType() const;
3504 3542
3505 private: 3543 private:
3506 DISALLOW_COPY_AND_ASSIGN(UnboxDoubleInstr); 3544 DISALLOW_COPY_AND_ASSIGN(UnboxDoubleInstr);
3507 }; 3545 };
3508 3546
3509 3547
3510 class UnboxIntegerInstr : public TemplateDefinition<1> { 3548 class UnboxIntegerInstr : public TemplateDefinition<1> {
3511 public: 3549 public:
3512 UnboxIntegerInstr(Value* value, intptr_t deopt_id) { 3550 UnboxIntegerInstr(Value* value, intptr_t deopt_id) {
3513 ASSERT(value != NULL); 3551 ASSERT(value != NULL);
3514 inputs_[0] = value; 3552 inputs_[0] = value;
3515 deopt_id_ = deopt_id; 3553 deopt_id_ = deopt_id;
3516 } 3554 }
3517 3555
3518 Value* value() const { return inputs_[0]; } 3556 Value* value() const { return inputs_[0]; }
3519 3557
3520 virtual bool CanDeoptimize() const { 3558 virtual bool CanDeoptimize() const {
3521 return (value()->Type()->ToCid() != kSmiCid) 3559 return (value()->ResultCid() != kMintCid)
3522 && (value()->Type()->ToCid() != kMintCid); 3560 && (value()->ResultCid() != kSmiCid);
3523 } 3561 }
3524 3562
3525 virtual bool HasSideEffect() const { return false; } 3563 virtual bool HasSideEffect() const { return false; }
3526 3564
3527 virtual CompileType* ComputeInitialType() const; 3565 virtual intptr_t ResultCid() const;
3566
3567 virtual RawAbstractType* CompileType() const;
3528 3568
3529 virtual Representation representation() const { 3569 virtual Representation representation() const {
3530 return kUnboxedMint; 3570 return kUnboxedMint;
3531 } 3571 }
3532 3572
3533 3573
3534 virtual bool AffectedBySideEffect() const { return false; } 3574 virtual bool AffectedBySideEffect() const { return false; }
3535 virtual bool AttributesEqual(Instruction* other) const { return true; } 3575 virtual bool AttributesEqual(Instruction* other) const { return true; }
3536 3576
3537 DECLARE_INSTRUCTION(UnboxInteger) 3577 DECLARE_INSTRUCTION(UnboxInteger)
(...skipping 14 matching lines...) Expand all
3552 Value* value() const { return inputs_[0]; } 3592 Value* value() const { return inputs_[0]; }
3553 3593
3554 virtual bool CanDeoptimize() const { return false; } 3594 virtual bool CanDeoptimize() const { return false; }
3555 3595
3556 virtual bool HasSideEffect() const { return false; } 3596 virtual bool HasSideEffect() const { return false; }
3557 3597
3558 virtual bool AttributesEqual(Instruction* other) const { 3598 virtual bool AttributesEqual(Instruction* other) const {
3559 return true; 3599 return true;
3560 } 3600 }
3561 3601
3602 // The output is not an instance but when it is boxed it becomes double.
3603 virtual intptr_t ResultCid() const { return kDoubleCid; }
3604
3562 virtual Representation representation() const { 3605 virtual Representation representation() const {
3563 return kUnboxedDouble; 3606 return kUnboxedDouble;
3564 } 3607 }
3565 3608
3566 virtual Representation RequiredInputRepresentation(intptr_t idx) const { 3609 virtual Representation RequiredInputRepresentation(intptr_t idx) const {
3567 ASSERT(idx == 0); 3610 ASSERT(idx == 0);
3568 return kUnboxedDouble; 3611 return kUnboxedDouble;
3569 } 3612 }
3570 3613
3571 virtual intptr_t DeoptimizationTarget() const { 3614 virtual intptr_t DeoptimizationTarget() const {
3572 // Direct access since this instruction cannot deoptimize, and the deopt-id 3615 // Direct access since this instruction cannot deoptimize, and the deopt-id
3573 // was inherited from another instruction that could deoptimize. 3616 // was inherited from another instruction that could deoptimize.
3574 return deopt_id_; 3617 return deopt_id_;
3575 } 3618 }
3576 3619
3577 DECLARE_INSTRUCTION(MathSqrt) 3620 DECLARE_INSTRUCTION(MathSqrt)
3578 virtual CompileType* ComputeInitialType() const; 3621 virtual RawAbstractType* CompileType() const;
3579 3622
3580 private: 3623 private:
3581 DISALLOW_COPY_AND_ASSIGN(MathSqrtInstr); 3624 DISALLOW_COPY_AND_ASSIGN(MathSqrtInstr);
3582 }; 3625 };
3583 3626
3584 3627
3585 class BinaryDoubleOpInstr : public TemplateDefinition<2> { 3628 class BinaryDoubleOpInstr : public TemplateDefinition<2> {
3586 public: 3629 public:
3587 BinaryDoubleOpInstr(Token::Kind op_kind, 3630 BinaryDoubleOpInstr(Token::Kind op_kind,
3588 Value* left, 3631 Value* left,
(...skipping 17 matching lines...) Expand all
3606 virtual bool CanDeoptimize() const { return false; } 3649 virtual bool CanDeoptimize() const { return false; }
3607 3650
3608 virtual bool HasSideEffect() const { return false; } 3651 virtual bool HasSideEffect() const { return false; }
3609 3652
3610 virtual bool AffectedBySideEffect() const { return false; } 3653 virtual bool AffectedBySideEffect() const { return false; }
3611 3654
3612 virtual bool AttributesEqual(Instruction* other) const { 3655 virtual bool AttributesEqual(Instruction* other) const {
3613 return op_kind() == other->AsBinaryDoubleOp()->op_kind(); 3656 return op_kind() == other->AsBinaryDoubleOp()->op_kind();
3614 } 3657 }
3615 3658
3659 virtual intptr_t ResultCid() const;
3660
3616 virtual Representation representation() const { 3661 virtual Representation representation() const {
3617 return kUnboxedDouble; 3662 return kUnboxedDouble;
3618 } 3663 }
3619 3664
3620 virtual Representation RequiredInputRepresentation(intptr_t idx) const { 3665 virtual Representation RequiredInputRepresentation(intptr_t idx) const {
3621 ASSERT((idx == 0) || (idx == 1)); 3666 ASSERT((idx == 0) || (idx == 1));
3622 return kUnboxedDouble; 3667 return kUnboxedDouble;
3623 } 3668 }
3624 3669
3625 virtual intptr_t DeoptimizationTarget() const { 3670 virtual intptr_t DeoptimizationTarget() const {
3626 // Direct access since this instruction cannot deoptimize, and the deopt-id 3671 // Direct access since this instruction cannot deoptimize, and the deopt-id
3627 // was inherited from another instruction that could deoptimize. 3672 // was inherited from another instruction that could deoptimize.
3628 return deopt_id_; 3673 return deopt_id_;
3629 } 3674 }
3630 3675
3631 DECLARE_INSTRUCTION(BinaryDoubleOp) 3676 DECLARE_INSTRUCTION(BinaryDoubleOp)
3632 virtual CompileType* ComputeInitialType() const; 3677 virtual RawAbstractType* CompileType() const;
3633 3678
3634 virtual Definition* Canonicalize(FlowGraphOptimizer* optimizer); 3679 virtual Definition* Canonicalize(FlowGraphOptimizer* optimizer);
3635 3680
3636 private: 3681 private:
3637 const Token::Kind op_kind_; 3682 const Token::Kind op_kind_;
3638 3683
3639 DISALLOW_COPY_AND_ASSIGN(BinaryDoubleOpInstr); 3684 DISALLOW_COPY_AND_ASSIGN(BinaryDoubleOpInstr);
3640 }; 3685 };
3641 3686
3642 3687
(...skipping 23 matching lines...) Expand all
3666 } 3711 }
3667 3712
3668 virtual bool HasSideEffect() const { return false; } 3713 virtual bool HasSideEffect() const { return false; }
3669 3714
3670 virtual bool AffectedBySideEffect() const { return false; } 3715 virtual bool AffectedBySideEffect() const { return false; }
3671 3716
3672 virtual bool AttributesEqual(Instruction* other) const { 3717 virtual bool AttributesEqual(Instruction* other) const {
3673 return op_kind() == other->AsBinaryMintOp()->op_kind(); 3718 return op_kind() == other->AsBinaryMintOp()->op_kind();
3674 } 3719 }
3675 3720
3676 virtual CompileType* ComputeInitialType() const; 3721 virtual intptr_t ResultCid() const;
3722 virtual RawAbstractType* CompileType() const;
3677 3723
3678 virtual Representation representation() const { 3724 virtual Representation representation() const {
3679 return kUnboxedMint; 3725 return kUnboxedMint;
3680 } 3726 }
3681 3727
3682 virtual Representation RequiredInputRepresentation(intptr_t idx) const { 3728 virtual Representation RequiredInputRepresentation(intptr_t idx) const {
3683 ASSERT((idx == 0) || (idx == 1)); 3729 ASSERT((idx == 0) || (idx == 1));
3684 return kUnboxedMint; 3730 return kUnboxedMint;
3685 } 3731 }
3686 3732
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
3726 virtual bool CanDeoptimize() const { return true; } 3772 virtual bool CanDeoptimize() const { return true; }
3727 3773
3728 virtual bool HasSideEffect() const { return false; } 3774 virtual bool HasSideEffect() const { return false; }
3729 3775
3730 virtual bool AffectedBySideEffect() const { return false; } 3776 virtual bool AffectedBySideEffect() const { return false; }
3731 3777
3732 virtual bool AttributesEqual(Instruction* other) const { 3778 virtual bool AttributesEqual(Instruction* other) const {
3733 return op_kind() == other->AsShiftMintOp()->op_kind(); 3779 return op_kind() == other->AsShiftMintOp()->op_kind();
3734 } 3780 }
3735 3781
3736 virtual CompileType* ComputeInitialType() const; 3782 virtual intptr_t ResultCid() const;
3783 virtual RawAbstractType* CompileType() const;
3737 3784
3738 virtual Representation representation() const { 3785 virtual Representation representation() const {
3739 return kUnboxedMint; 3786 return kUnboxedMint;
3740 } 3787 }
3741 3788
3742 virtual Representation RequiredInputRepresentation(intptr_t idx) const { 3789 virtual Representation RequiredInputRepresentation(intptr_t idx) const {
3743 ASSERT((idx == 0) || (idx == 1)); 3790 ASSERT((idx == 0) || (idx == 1));
3744 return (idx == 0) ? kUnboxedMint : kTagged; 3791 return (idx == 0) ? kUnboxedMint : kTagged;
3745 } 3792 }
3746 3793
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
3780 virtual bool CanDeoptimize() const { return false; } 3827 virtual bool CanDeoptimize() const { return false; }
3781 3828
3782 virtual bool HasSideEffect() const { return false; } 3829 virtual bool HasSideEffect() const { return false; }
3783 3830
3784 virtual bool AffectedBySideEffect() const { return false; } 3831 virtual bool AffectedBySideEffect() const { return false; }
3785 3832
3786 virtual bool AttributesEqual(Instruction* other) const { 3833 virtual bool AttributesEqual(Instruction* other) const {
3787 return op_kind() == other->AsUnaryMintOp()->op_kind(); 3834 return op_kind() == other->AsUnaryMintOp()->op_kind();
3788 } 3835 }
3789 3836
3790 virtual CompileType* ComputeInitialType() const; 3837 virtual intptr_t ResultCid() const;
3838 virtual RawAbstractType* CompileType() const;
3791 3839
3792 virtual Representation representation() const { 3840 virtual Representation representation() const {
3793 return kUnboxedMint; 3841 return kUnboxedMint;
3794 } 3842 }
3795 3843
3796 virtual Representation RequiredInputRepresentation(intptr_t idx) const { 3844 virtual Representation RequiredInputRepresentation(intptr_t idx) const {
3797 ASSERT(idx == 0); 3845 ASSERT(idx == 0);
3798 return kUnboxedMint; 3846 return kUnboxedMint;
3799 } 3847 }
3800 3848
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
3835 Token::Kind op_kind() const { return op_kind_; } 3883 Token::Kind op_kind() const { return op_kind_; }
3836 3884
3837 InstanceCallInstr* instance_call() const { return instance_call_; } 3885 InstanceCallInstr* instance_call() const { return instance_call_; }
3838 3886
3839 const ICData* ic_data() const { return instance_call()->ic_data(); } 3887 const ICData* ic_data() const { return instance_call()->ic_data(); }
3840 3888
3841 virtual void PrintOperandsTo(BufferFormatter* f) const; 3889 virtual void PrintOperandsTo(BufferFormatter* f) const;
3842 3890
3843 DECLARE_INSTRUCTION(BinarySmiOp) 3891 DECLARE_INSTRUCTION(BinarySmiOp)
3844 3892
3845 virtual CompileType* ComputeInitialType() const; 3893 virtual RawAbstractType* CompileType() const;
3846 3894
3847 virtual bool CanDeoptimize() const; 3895 virtual bool CanDeoptimize() const;
3848 3896
3849 virtual bool HasSideEffect() const { return false; } 3897 virtual bool HasSideEffect() const { return false; }
3850 3898
3851 virtual bool AffectedBySideEffect() const { return false; } 3899 virtual bool AffectedBySideEffect() const { return false; }
3852 virtual bool AttributesEqual(Instruction* other) const; 3900 virtual bool AttributesEqual(Instruction* other) const;
3853 3901
3902 virtual intptr_t ResultCid() const;
3903
3854 void set_overflow(bool overflow) { 3904 void set_overflow(bool overflow) {
3855 overflow_ = overflow; 3905 overflow_ = overflow;
3856 } 3906 }
3857 3907
3858 void PrintTo(BufferFormatter* f) const; 3908 void PrintTo(BufferFormatter* f) const;
3859 3909
3860 virtual void InferRange(); 3910 virtual void InferRange();
3861 3911
3862 virtual Definition* Canonicalize(FlowGraphOptimizer* optimizer); 3912 virtual Definition* Canonicalize(FlowGraphOptimizer* optimizer);
3863 3913
(...skipping 22 matching lines...) Expand all
3886 inputs_[0] = value; 3936 inputs_[0] = value;
3887 deopt_id_ = instance_call->deopt_id(); 3937 deopt_id_ = instance_call->deopt_id();
3888 } 3938 }
3889 3939
3890 Value* value() const { return inputs_[0]; } 3940 Value* value() const { return inputs_[0]; }
3891 Token::Kind op_kind() const { return op_kind_; } 3941 Token::Kind op_kind() const { return op_kind_; }
3892 3942
3893 virtual void PrintOperandsTo(BufferFormatter* f) const; 3943 virtual void PrintOperandsTo(BufferFormatter* f) const;
3894 3944
3895 DECLARE_INSTRUCTION(UnarySmiOp) 3945 DECLARE_INSTRUCTION(UnarySmiOp)
3896 virtual CompileType* ComputeInitialType() const; 3946 virtual RawAbstractType* CompileType() const;
3897 3947
3898 virtual bool CanDeoptimize() const { return op_kind() == Token::kNEGATE; } 3948 virtual bool CanDeoptimize() const { return op_kind() == Token::kNEGATE; }
3899 3949
3900 virtual bool HasSideEffect() const { return false; } 3950 virtual bool HasSideEffect() const { return false; }
3901 3951
3952 virtual intptr_t ResultCid() const { return kSmiCid; }
3953
3902 private: 3954 private:
3903 const Token::Kind op_kind_; 3955 const Token::Kind op_kind_;
3904 3956
3905 DISALLOW_COPY_AND_ASSIGN(UnarySmiOpInstr); 3957 DISALLOW_COPY_AND_ASSIGN(UnarySmiOpInstr);
3906 }; 3958 };
3907 3959
3908 3960
3909 class CheckStackOverflowInstr : public TemplateInstruction<0> { 3961 class CheckStackOverflowInstr : public TemplateInstruction<0> {
3910 public: 3962 public:
3911 explicit CheckStackOverflowInstr(intptr_t token_pos) 3963 explicit CheckStackOverflowInstr(intptr_t token_pos)
3912 : token_pos_(token_pos) {} 3964 : token_pos_(token_pos) {}
3913 3965
3914 intptr_t token_pos() const { return token_pos_; } 3966 intptr_t token_pos() const { return token_pos_; }
3915 3967
3916 DECLARE_INSTRUCTION(CheckStackOverflow) 3968 DECLARE_INSTRUCTION(CheckStackOverflow)
3969 virtual RawAbstractType* CompileType() const;
3917 3970
3918 virtual intptr_t ArgumentCount() const { return 0; } 3971 virtual intptr_t ArgumentCount() const { return 0; }
3919 3972
3920 virtual bool CanDeoptimize() const { return true; } 3973 virtual bool CanDeoptimize() const { return true; }
3921 3974
3922 virtual bool HasSideEffect() const { return false; } 3975 virtual bool HasSideEffect() const { return false; }
3923 3976
3924 private: 3977 private:
3925 const intptr_t token_pos_; 3978 const intptr_t token_pos_;
3926 3979
3927 DISALLOW_COPY_AND_ASSIGN(CheckStackOverflowInstr); 3980 DISALLOW_COPY_AND_ASSIGN(CheckStackOverflowInstr);
3928 }; 3981 };
3929 3982
3930 3983
3931 class SmiToDoubleInstr : public TemplateDefinition<0> { 3984 class SmiToDoubleInstr : public TemplateDefinition<0> {
3932 public: 3985 public:
3933 explicit SmiToDoubleInstr(InstanceCallInstr* instance_call) 3986 explicit SmiToDoubleInstr(InstanceCallInstr* instance_call)
3934 : instance_call_(instance_call) { } 3987 : instance_call_(instance_call) { }
3935 3988
3936 InstanceCallInstr* instance_call() const { return instance_call_; } 3989 InstanceCallInstr* instance_call() const { return instance_call_; }
3937 3990
3938 DECLARE_INSTRUCTION(SmiToDouble) 3991 DECLARE_INSTRUCTION(SmiToDouble)
3939 virtual CompileType* ComputeInitialType() const; 3992 virtual RawAbstractType* CompileType() const;
3940 3993
3941 virtual intptr_t ArgumentCount() const { return 1; } 3994 virtual intptr_t ArgumentCount() const { return 1; }
3942 3995
3943 virtual bool CanDeoptimize() const { return true; } 3996 virtual bool CanDeoptimize() const { return true; }
3944 3997
3945 virtual bool HasSideEffect() const { return false; } 3998 virtual bool HasSideEffect() const { return false; }
3946 3999
4000 virtual intptr_t ResultCid() const { return kDoubleCid; }
4001
3947 private: 4002 private:
3948 InstanceCallInstr* instance_call_; 4003 InstanceCallInstr* instance_call_;
3949 4004
3950 DISALLOW_COPY_AND_ASSIGN(SmiToDoubleInstr); 4005 DISALLOW_COPY_AND_ASSIGN(SmiToDoubleInstr);
3951 }; 4006 };
3952 4007
3953 4008
3954 class DoubleToIntegerInstr : public TemplateDefinition<1> { 4009 class DoubleToIntegerInstr : public TemplateDefinition<1> {
3955 public: 4010 public:
3956 DoubleToIntegerInstr(Value* value, InstanceCallInstr* instance_call) 4011 DoubleToIntegerInstr(Value* value, InstanceCallInstr* instance_call)
3957 : instance_call_(instance_call) { 4012 : instance_call_(instance_call) {
3958 ASSERT(value != NULL); 4013 ASSERT(value != NULL);
3959 inputs_[0] = value; 4014 inputs_[0] = value;
3960 } 4015 }
3961 4016
3962 Value* value() const { return inputs_[0]; } 4017 Value* value() const { return inputs_[0]; }
3963 InstanceCallInstr* instance_call() const { return instance_call_; } 4018 InstanceCallInstr* instance_call() const { return instance_call_; }
3964 4019
3965 DECLARE_INSTRUCTION(DoubleToInteger) 4020 DECLARE_INSTRUCTION(DoubleToInteger)
3966 virtual CompileType* ComputeInitialType() const; 4021 virtual RawAbstractType* CompileType() const;
3967 4022
3968 virtual intptr_t ArgumentCount() const { return 1; } 4023 virtual intptr_t ArgumentCount() const { return 1; }
3969 4024
3970 virtual bool CanDeoptimize() const { return true; } 4025 virtual bool CanDeoptimize() const { return true; }
3971 4026
3972 virtual bool HasSideEffect() const { return false; } 4027 virtual bool HasSideEffect() const { return false; }
3973 4028
4029 // Result could be any of the int types.
4030 virtual intptr_t ResultCid() const { return kDynamicCid; }
4031
3974 private: 4032 private:
3975 InstanceCallInstr* instance_call_; 4033 InstanceCallInstr* instance_call_;
3976 4034
3977 DISALLOW_COPY_AND_ASSIGN(DoubleToIntegerInstr); 4035 DISALLOW_COPY_AND_ASSIGN(DoubleToIntegerInstr);
3978 }; 4036 };
3979 4037
3980 4038
3981 // Similar to 'DoubleToIntegerInstr' but expects unboxed double as input 4039 // Similar to 'DoubleToIntegerInstr' but expects unboxed double as input
3982 // and creates a Smi. 4040 // and creates a Smi.
3983 class DoubleToSmiInstr : public TemplateDefinition<1> { 4041 class DoubleToSmiInstr : public TemplateDefinition<1> {
3984 public: 4042 public:
3985 DoubleToSmiInstr(Value* value, InstanceCallInstr* instance_call) { 4043 DoubleToSmiInstr(Value* value, InstanceCallInstr* instance_call) {
3986 ASSERT(value != NULL); 4044 ASSERT(value != NULL);
3987 inputs_[0] = value; 4045 inputs_[0] = value;
3988 deopt_id_ = instance_call->deopt_id(); 4046 deopt_id_ = instance_call->deopt_id();
3989 } 4047 }
3990 4048
3991 Value* value() const { return inputs_[0]; } 4049 Value* value() const { return inputs_[0]; }
3992 4050
3993 DECLARE_INSTRUCTION(DoubleToSmi) 4051 DECLARE_INSTRUCTION(DoubleToSmi)
3994 virtual CompileType* ComputeInitialType() const; 4052 virtual RawAbstractType* CompileType() const;
3995 4053
3996 virtual bool CanDeoptimize() const { return true; } 4054 virtual bool CanDeoptimize() const { return true; }
3997 4055
3998 virtual bool HasSideEffect() const { return false; } 4056 virtual bool HasSideEffect() const { return false; }
3999 4057
4058 virtual intptr_t ResultCid() const { return kSmiCid; }
4059
4000 virtual Representation RequiredInputRepresentation(intptr_t idx) const { 4060 virtual Representation RequiredInputRepresentation(intptr_t idx) const {
4001 ASSERT(idx == 0); 4061 ASSERT(idx == 0);
4002 return kUnboxedDouble; 4062 return kUnboxedDouble;
4003 } 4063 }
4004 4064
4005 virtual intptr_t DeoptimizationTarget() const { return deopt_id_; } 4065 virtual intptr_t DeoptimizationTarget() const { return deopt_id_; }
4006 4066
4007 private: 4067 private:
4008 DISALLOW_COPY_AND_ASSIGN(DoubleToSmiInstr); 4068 DISALLOW_COPY_AND_ASSIGN(DoubleToSmiInstr);
4009 }; 4069 };
4010 4070
4011 4071
4012 class DoubleToDoubleInstr : public TemplateDefinition<1> { 4072 class DoubleToDoubleInstr : public TemplateDefinition<1> {
4013 public: 4073 public:
4014 DoubleToDoubleInstr(Value* value, 4074 DoubleToDoubleInstr(Value* value,
4015 InstanceCallInstr* instance_call, 4075 InstanceCallInstr* instance_call,
4016 MethodRecognizer::Kind recognized_kind) 4076 MethodRecognizer::Kind recognized_kind)
4017 : recognized_kind_(recognized_kind) { 4077 : recognized_kind_(recognized_kind) {
4018 ASSERT(value != NULL); 4078 ASSERT(value != NULL);
4019 inputs_[0] = value; 4079 inputs_[0] = value;
4020 deopt_id_ = instance_call->deopt_id(); 4080 deopt_id_ = instance_call->deopt_id();
4021 } 4081 }
4022 4082
4023 Value* value() const { return inputs_[0]; } 4083 Value* value() const { return inputs_[0]; }
4024 4084
4025 MethodRecognizer::Kind recognized_kind() const { return recognized_kind_; } 4085 MethodRecognizer::Kind recognized_kind() const { return recognized_kind_; }
4026 4086
4027 DECLARE_INSTRUCTION(DoubleToDouble) 4087 DECLARE_INSTRUCTION(DoubleToDouble)
4028 virtual CompileType* ComputeInitialType() const; 4088 virtual RawAbstractType* CompileType() const;
4029 4089
4030 virtual bool CanDeoptimize() const { return false; } 4090 virtual bool CanDeoptimize() const { return false; }
4031 4091
4032 virtual bool HasSideEffect() const { return false; } 4092 virtual bool HasSideEffect() const { return false; }
4033 4093
4094 virtual intptr_t ResultCid() const { return kDoubleCid; }
4095
4034 virtual Representation representation() const { 4096 virtual Representation representation() const {
4035 return kUnboxedDouble; 4097 return kUnboxedDouble;
4036 } 4098 }
4037 4099
4038 virtual Representation RequiredInputRepresentation(intptr_t idx) const { 4100 virtual Representation RequiredInputRepresentation(intptr_t idx) const {
4039 ASSERT(idx == 0); 4101 ASSERT(idx == 0);
4040 return kUnboxedDouble; 4102 return kUnboxedDouble;
4041 } 4103 }
4042 4104
4043 virtual intptr_t DeoptimizationTarget() const { return deopt_id_; } 4105 virtual intptr_t DeoptimizationTarget() const { return deopt_id_; }
(...skipping 15 matching lines...) Expand all
4059 deopt_id_ = instance_call->deopt_id(); 4121 deopt_id_ = instance_call->deopt_id();
4060 } 4122 }
4061 4123
4062 static intptr_t ArgumentCountFor(MethodRecognizer::Kind recognized_kind_); 4124 static intptr_t ArgumentCountFor(MethodRecognizer::Kind recognized_kind_);
4063 4125
4064 const RuntimeEntry& TargetFunction() const; 4126 const RuntimeEntry& TargetFunction() const;
4065 4127
4066 MethodRecognizer::Kind recognized_kind() const { return recognized_kind_; } 4128 MethodRecognizer::Kind recognized_kind() const { return recognized_kind_; }
4067 4129
4068 DECLARE_INSTRUCTION(InvokeMathCFunction) 4130 DECLARE_INSTRUCTION(InvokeMathCFunction)
4069 virtual CompileType* ComputeInitialType() const; 4131 virtual RawAbstractType* CompileType() const;
4070 virtual void PrintOperandsTo(BufferFormatter* f) const; 4132 virtual void PrintOperandsTo(BufferFormatter* f) const;
4071 4133
4072 virtual bool CanDeoptimize() const { return false; } 4134 virtual bool CanDeoptimize() const { return false; }
4073 4135
4074 virtual bool HasSideEffect() const { return false; } 4136 virtual bool HasSideEffect() const { return false; }
4075 4137
4138 virtual intptr_t ResultCid() const { return kDoubleCid; }
4139
4076 virtual Representation representation() const { 4140 virtual Representation representation() const {
4077 return kUnboxedDouble; 4141 return kUnboxedDouble;
4078 } 4142 }
4079 4143
4080 virtual Representation RequiredInputRepresentation(intptr_t idx) const { 4144 virtual Representation RequiredInputRepresentation(intptr_t idx) const {
4081 ASSERT((0 <= idx) && (idx < InputCount())); 4145 ASSERT((0 <= idx) && (idx < InputCount()));
4082 return kUnboxedDouble; 4146 return kUnboxedDouble;
4083 } 4147 }
4084 4148
4085 virtual intptr_t DeoptimizationTarget() const { return deopt_id_; } 4149 virtual intptr_t DeoptimizationTarget() const { return deopt_id_; }
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
4117 }; 4181 };
4118 4182
4119 4183
4120 class CheckClassInstr : public TemplateInstruction<1> { 4184 class CheckClassInstr : public TemplateInstruction<1> {
4121 public: 4185 public:
4122 CheckClassInstr(Value* value, 4186 CheckClassInstr(Value* value,
4123 intptr_t deopt_id, 4187 intptr_t deopt_id,
4124 const ICData& unary_checks); 4188 const ICData& unary_checks);
4125 4189
4126 DECLARE_INSTRUCTION(CheckClass) 4190 DECLARE_INSTRUCTION(CheckClass)
4191 virtual RawAbstractType* CompileType() const;
4127 4192
4128 virtual intptr_t ArgumentCount() const { return 0; } 4193 virtual intptr_t ArgumentCount() const { return 0; }
4129 4194
4130 virtual bool CanDeoptimize() const { return true; } 4195 virtual bool CanDeoptimize() const { return true; }
4131 4196
4132 virtual bool HasSideEffect() const { return false; } 4197 virtual bool HasSideEffect() const { return false; }
4133 4198
4134 virtual bool AttributesEqual(Instruction* other) const; 4199 virtual bool AttributesEqual(Instruction* other) const;
4135 4200
4136 virtual bool AffectedBySideEffect() const; 4201 virtual bool AffectedBySideEffect() const;
(...skipping 16 matching lines...) Expand all
4153 class CheckSmiInstr : public TemplateInstruction<1> { 4218 class CheckSmiInstr : public TemplateInstruction<1> {
4154 public: 4219 public:
4155 CheckSmiInstr(Value* value, intptr_t original_deopt_id) { 4220 CheckSmiInstr(Value* value, intptr_t original_deopt_id) {
4156 ASSERT(value != NULL); 4221 ASSERT(value != NULL);
4157 ASSERT(original_deopt_id != Isolate::kNoDeoptId); 4222 ASSERT(original_deopt_id != Isolate::kNoDeoptId);
4158 inputs_[0] = value; 4223 inputs_[0] = value;
4159 deopt_id_ = original_deopt_id; 4224 deopt_id_ = original_deopt_id;
4160 } 4225 }
4161 4226
4162 DECLARE_INSTRUCTION(CheckSmi) 4227 DECLARE_INSTRUCTION(CheckSmi)
4228 virtual RawAbstractType* CompileType() const;
4163 4229
4164 virtual intptr_t ArgumentCount() const { return 0; } 4230 virtual intptr_t ArgumentCount() const { return 0; }
4165 4231
4166 virtual bool CanDeoptimize() const { return true; } 4232 virtual bool CanDeoptimize() const { return true; }
4167 4233
4168 virtual bool HasSideEffect() const { return false; } 4234 virtual bool HasSideEffect() const { return false; }
4169 4235
4170 virtual bool AttributesEqual(Instruction* other) const { return true; } 4236 virtual bool AttributesEqual(Instruction* other) const { return true; }
4171 4237
4172 virtual bool AffectedBySideEffect() const { return false; } 4238 virtual bool AffectedBySideEffect() const { return false; }
(...skipping 15 matching lines...) Expand all
4188 InstanceCallInstr* instance_call) 4254 InstanceCallInstr* instance_call)
4189 : array_type_(array_type) { 4255 : array_type_(array_type) {
4190 ASSERT(length != NULL); 4256 ASSERT(length != NULL);
4191 ASSERT(index != NULL); 4257 ASSERT(index != NULL);
4192 inputs_[0] = length; 4258 inputs_[0] = length;
4193 inputs_[1] = index; 4259 inputs_[1] = index;
4194 deopt_id_ = instance_call->deopt_id(); 4260 deopt_id_ = instance_call->deopt_id();
4195 } 4261 }
4196 4262
4197 DECLARE_INSTRUCTION(CheckArrayBound) 4263 DECLARE_INSTRUCTION(CheckArrayBound)
4264 virtual RawAbstractType* CompileType() const;
4198 4265
4199 virtual intptr_t ArgumentCount() const { return 0; } 4266 virtual intptr_t ArgumentCount() const { return 0; }
4200 4267
4201 virtual bool CanDeoptimize() const { return true; } 4268 virtual bool CanDeoptimize() const { return true; }
4202 4269
4203 virtual bool HasSideEffect() const { return false; } 4270 virtual bool HasSideEffect() const { return false; }
4204 4271
4205 virtual bool AttributesEqual(Instruction* other) const; 4272 virtual bool AttributesEqual(Instruction* other) const;
4206 4273
4207 virtual bool AffectedBySideEffect() const { return false; } 4274 virtual bool AffectedBySideEffect() const { return false; }
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
4447 ForwardInstructionIterator* current_iterator_; 4514 ForwardInstructionIterator* current_iterator_;
4448 4515
4449 private: 4516 private:
4450 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); 4517 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor);
4451 }; 4518 };
4452 4519
4453 4520
4454 } // namespace dart 4521 } // namespace dart
4455 4522
4456 #endif // VM_INTERMEDIATE_LANGUAGE_H_ 4523 #endif // VM_INTERMEDIATE_LANGUAGE_H_
OLDNEW
« no previous file with comments | « runtime/vm/il_printer.cc ('k') | runtime/vm/intermediate_language.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698