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

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

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

Powered by Google App Engine
This is Rietveld 408576698