OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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" |
11 #include "vm/handles_impl.h" | 11 #include "vm/handles_impl.h" |
12 #include "vm/locations.h" | 12 #include "vm/locations.h" |
13 #include "vm/object.h" | 13 #include "vm/object.h" |
14 | 14 |
15 namespace dart { | 15 namespace dart { |
16 | 16 |
| 17 class BindInstr; |
17 class BitVector; | 18 class BitVector; |
18 class BlockEntryInstr; | 19 class BlockEntryInstr; |
19 class BufferFormatter; | 20 class BufferFormatter; |
20 class ComparisonInstr; | 21 class ComparisonComp; |
| 22 class ConstantComp; |
| 23 class Computation; |
21 class ControlInstruction; | 24 class ControlInstruction; |
22 class Definition; | 25 class Definition; |
23 class Environment; | 26 class Environment; |
24 class FlowGraphCompiler; | 27 class FlowGraphCompiler; |
25 class FlowGraphVisitor; | 28 class FlowGraphVisitor; |
26 class Instruction; | 29 class Instruction; |
27 class LocalVariable; | 30 class LocalVariable; |
28 | 31 |
29 | 32 |
30 // TODO(srdjan): Add _ByteArrayBase, get:length. | 33 // TODO(srdjan): Add _ByteArrayBase, get:length. |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 // Instructions. | 178 // Instructions. |
176 | 179 |
177 // M is a single argument macro. It is applied to each concrete instruction | 180 // M is a single argument macro. It is applied to each concrete instruction |
178 // type name. The concrete instruction classes are the name with Instr | 181 // type name. The concrete instruction classes are the name with Instr |
179 // concatenated. | 182 // concatenated. |
180 #define FOR_EACH_INSTRUCTION(M) \ | 183 #define FOR_EACH_INSTRUCTION(M) \ |
181 M(GraphEntry) \ | 184 M(GraphEntry) \ |
182 M(JoinEntry) \ | 185 M(JoinEntry) \ |
183 M(TargetEntry) \ | 186 M(TargetEntry) \ |
184 M(Phi) \ | 187 M(Phi) \ |
| 188 M(Bind) \ |
185 M(Parameter) \ | 189 M(Parameter) \ |
186 M(ParallelMove) \ | 190 M(ParallelMove) \ |
187 M(PushArgument) \ | 191 M(PushArgument) \ |
188 M(Return) \ | 192 M(Return) \ |
189 M(Throw) \ | 193 M(Throw) \ |
190 M(ReThrow) \ | 194 M(ReThrow) \ |
191 M(Goto) \ | 195 M(Goto) \ |
192 M(Branch) \ | 196 M(Branch) \ |
193 M(AssertAssignable) \ | |
194 M(AssertBoolean) \ | |
195 M(ArgumentDefinitionTest) \ | |
196 M(CurrentContext) \ | |
197 M(StoreContext) \ | |
198 M(ClosureCall) \ | |
199 M(InstanceCall) \ | |
200 M(PolymorphicInstanceCall) \ | |
201 M(StaticCall) \ | |
202 M(LoadLocal) \ | |
203 M(StoreLocal) \ | |
204 M(StrictCompare) \ | |
205 M(EqualityCompare) \ | |
206 M(RelationalOp) \ | |
207 M(NativeCall) \ | |
208 M(LoadIndexed) \ | |
209 M(StoreIndexed) \ | |
210 M(LoadInstanceField) \ | |
211 M(StoreInstanceField) \ | |
212 M(LoadStaticField) \ | |
213 M(StoreStaticField) \ | |
214 M(BooleanNegate) \ | |
215 M(InstanceOf) \ | |
216 M(CreateArray) \ | |
217 M(CreateClosure) \ | |
218 M(AllocateObject) \ | |
219 M(AllocateObjectWithBoundsCheck) \ | |
220 M(LoadVMField) \ | |
221 M(StoreVMField) \ | |
222 M(InstantiateTypeArguments) \ | |
223 M(ExtractConstructorTypeArguments) \ | |
224 M(ExtractConstructorInstantiator) \ | |
225 M(AllocateContext) \ | |
226 M(ChainContext) \ | |
227 M(CloneContext) \ | |
228 M(CatchEntry) \ | |
229 M(BinarySmiOp) \ | |
230 M(BinaryMintOp) \ | |
231 M(UnarySmiOp) \ | |
232 M(NumberNegate) \ | |
233 M(CheckStackOverflow) \ | |
234 M(DoubleToDouble) \ | |
235 M(SmiToDouble) \ | |
236 M(CheckClass) \ | |
237 M(CheckSmi) \ | |
238 M(Constant) \ | |
239 M(CheckEitherNonSmi) \ | |
240 M(UnboxedDoubleBinaryOp) \ | |
241 M(UnboxDouble) \ | |
242 M(BoxDouble) \ | |
243 M(CheckArrayBound) \ | |
244 | 197 |
245 | 198 |
246 #define FORWARD_DECLARATION(type) class type##Instr; | 199 #define FORWARD_DECLARATION(type) class type##Instr; |
247 FOR_EACH_INSTRUCTION(FORWARD_DECLARATION) | 200 FOR_EACH_INSTRUCTION(FORWARD_DECLARATION) |
248 #undef FORWARD_DECLARATION | 201 #undef FORWARD_DECLARATION |
249 | 202 |
250 | 203 |
251 // Functions required in all concrete instruction classes. | 204 // Functions required in all concrete instruction classes. |
252 #define DECLARE_INSTRUCTION(type) \ | 205 #define DECLARE_INSTRUCTION(type) \ |
253 virtual Tag tag() const { return k##type; } \ | |
254 virtual void Accept(FlowGraphVisitor* visitor); \ | 206 virtual void Accept(FlowGraphVisitor* visitor); \ |
255 virtual type##Instr* As##type() { return this; } \ | 207 virtual type##Instr* As##type() { return this; } \ |
256 virtual const char* DebugName() const { return #type; } \ | 208 virtual const char* DebugName() const { return #type; } \ |
257 virtual LocationSummary* MakeLocationSummary() const; \ | 209 virtual void PrintTo(BufferFormatter* f) const; \ |
258 virtual void EmitNativeCode(FlowGraphCompiler* compiler); \ | 210 virtual void PrintToVisualizer(BufferFormatter* f) const; |
259 | 211 |
260 | 212 |
261 class Instruction : public ZoneAllocated { | 213 class Instruction : public ZoneAllocated { |
262 public: | 214 public: |
263 #define DECLARE_TAG(type) k##type, | |
264 enum Tag { | |
265 FOR_EACH_INSTRUCTION(DECLARE_TAG) | |
266 }; | |
267 #undef DECLARE_TAG | |
268 | |
269 Instruction() | 215 Instruction() |
270 : deopt_id_(Isolate::Current()->GetNextDeoptId()), | 216 : lifetime_position_(-1), previous_(NULL), next_(NULL), env_(NULL) { } |
271 lifetime_position_(-1), | |
272 previous_(NULL), | |
273 next_(NULL), | |
274 env_(NULL) { } | |
275 | |
276 virtual Tag tag() const = 0; | |
277 | |
278 intptr_t deopt_id() const { return deopt_id_; } | |
279 | 217 |
280 bool IsBlockEntry() { return (AsBlockEntry() != NULL); } | 218 bool IsBlockEntry() { return (AsBlockEntry() != NULL); } |
281 virtual BlockEntryInstr* AsBlockEntry() { return NULL; } | 219 virtual BlockEntryInstr* AsBlockEntry() { return NULL; } |
282 | 220 |
283 bool IsDefinition() { return (AsDefinition() != NULL); } | 221 bool IsDefinition() { return (AsDefinition() != NULL); } |
284 virtual Definition* AsDefinition() { return NULL; } | 222 virtual Definition* AsDefinition() { return NULL; } |
285 | 223 |
286 bool IsControl() { return (AsControl() != NULL); } | 224 bool IsControl() { return (AsControl() != NULL); } |
287 virtual ControlInstruction* AsControl() { return NULL; } | 225 virtual ControlInstruction* AsControl() { return NULL; } |
288 | 226 |
289 virtual intptr_t InputCount() const = 0; | 227 virtual intptr_t InputCount() const = 0; |
290 virtual Value* InputAt(intptr_t i) const = 0; | 228 virtual Value* InputAt(intptr_t i) const = 0; |
291 virtual void SetInputAt(intptr_t i, Value* value) = 0; | 229 virtual void SetInputAt(intptr_t i, Value* value) = 0; |
292 | 230 |
293 // Call instructions override this function and return the number of | 231 // Call instructions override this function and return the |
294 // pushed arguments. | 232 // number of pushed arguments. |
295 virtual intptr_t ArgumentCount() const = 0; | 233 virtual intptr_t ArgumentCount() const = 0; |
296 | 234 |
297 // Returns true, if this instruction can deoptimize. | 235 // Returns true, if this instruction can deoptimize. |
298 virtual bool CanDeoptimize() const = 0; | 236 virtual bool CanDeoptimize() const = 0; |
299 | 237 |
300 // Visiting support. | 238 // Visiting support. |
301 virtual void Accept(FlowGraphVisitor* visitor) = 0; | 239 virtual void Accept(FlowGraphVisitor* visitor) = 0; |
302 | 240 |
303 Instruction* previous() const { return previous_; } | 241 Instruction* previous() const { return previous_; } |
304 void set_previous(Instruction* instr) { | 242 void set_previous(Instruction* instr) { |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
354 intptr_t fixed_parameter_count) { | 292 intptr_t fixed_parameter_count) { |
355 // Never called for instructions except block entries and branches. | 293 // Never called for instructions except block entries and branches. |
356 UNREACHABLE(); | 294 UNREACHABLE(); |
357 } | 295 } |
358 | 296 |
359 // Mutate assigned_vars to add the local variable index for all | 297 // Mutate assigned_vars to add the local variable index for all |
360 // frame-allocated locals assigned to by the instruction. | 298 // frame-allocated locals assigned to by the instruction. |
361 virtual void RecordAssignedVars(BitVector* assigned_vars, | 299 virtual void RecordAssignedVars(BitVector* assigned_vars, |
362 intptr_t fixed_parameter_count); | 300 intptr_t fixed_parameter_count); |
363 | 301 |
364 virtual const char* DebugName() const = 0; | |
365 | |
366 // Printing support. | 302 // Printing support. |
367 virtual void PrintTo(BufferFormatter* f) const = 0; | 303 virtual void PrintTo(BufferFormatter* f) const = 0; |
368 virtual void PrintToVisualizer(BufferFormatter* f) const = 0; | 304 virtual void PrintToVisualizer(BufferFormatter* f) const = 0; |
369 | 305 |
370 #define INSTRUCTION_TYPE_CHECK(type) \ | 306 #define INSTRUCTION_TYPE_CHECK(type) \ |
371 bool Is##type() { return (As##type() != NULL); } \ | 307 bool Is##type() { return (As##type() != NULL); } \ |
372 virtual type##Instr* As##type() { return NULL; } | 308 virtual type##Instr* As##type() { return NULL; } |
373 FOR_EACH_INSTRUCTION(INSTRUCTION_TYPE_CHECK) | 309 FOR_EACH_INSTRUCTION(INSTRUCTION_TYPE_CHECK) |
374 #undef INSTRUCTION_TYPE_CHECK | 310 #undef INSTRUCTION_TYPE_CHECK |
375 | 311 |
376 // Returns structure describing location constraints required | 312 // Returns structure describing location constraints required |
377 // to emit native code for this instruction. | 313 // to emit native code for this instruction. |
378 virtual LocationSummary* locs() { | 314 virtual LocationSummary* locs() { |
379 // TODO(vegorov): This should be pure virtual method. | 315 // TODO(vegorov): This should be pure virtual method. |
380 // However we are temporary using NULL for instructions that | 316 // However we are temporary using NULL for instructions that |
381 // were not converted to the location based code generation yet. | 317 // were not converted to the location based code generation yet. |
382 return NULL; | 318 return NULL; |
383 } | 319 } |
384 | 320 |
385 virtual LocationSummary* MakeLocationSummary() const = 0; | |
386 | |
387 static LocationSummary* MakeCallSummary(); | |
388 | |
389 virtual void EmitNativeCode(FlowGraphCompiler* compiler) { | 321 virtual void EmitNativeCode(FlowGraphCompiler* compiler) { |
390 UNIMPLEMENTED(); | 322 UNIMPLEMENTED(); |
391 } | 323 } |
392 | 324 |
393 Environment* env() const { return env_; } | 325 Environment* env() const { return env_; } |
394 void set_env(Environment* env) { env_ = env; } | 326 void set_env(Environment* env) { env_ = env; } |
395 | 327 |
396 intptr_t lifetime_position() const { return lifetime_position_; } | 328 intptr_t lifetime_position() const { return lifetime_position_; } |
397 void set_lifetime_position(intptr_t pos) { | 329 void set_lifetime_position(intptr_t pos) { |
398 lifetime_position_ = pos; | 330 lifetime_position_ = pos; |
(...skipping 14 matching lines...) Expand all Loading... |
413 } | 345 } |
414 | 346 |
415 // Returns deoptimization id that corresponds to the deoptimization target | 347 // Returns deoptimization id that corresponds to the deoptimization target |
416 // that input operands conversions inserted for this instruction can jump | 348 // that input operands conversions inserted for this instruction can jump |
417 // to. | 349 // to. |
418 virtual intptr_t DeoptimizationTarget() const { | 350 virtual intptr_t DeoptimizationTarget() const { |
419 UNREACHABLE(); | 351 UNREACHABLE(); |
420 return Isolate::kNoDeoptId; | 352 return Isolate::kNoDeoptId; |
421 } | 353 } |
422 | 354 |
423 protected: | |
424 // Fetch deopt id without checking if this computation can deoptimize. | |
425 intptr_t GetDeoptId() const { | |
426 return deopt_id_; | |
427 } | |
428 | |
429 private: | 355 private: |
430 friend class Definition; // Needed for InsertBefore, InsertAfter. | 356 friend class Definition; // Needed for InsertBefore, InsertAfter. |
431 | 357 |
432 // Classes that set deopt_id_. | |
433 friend class UnboxDoubleInstr; | |
434 friend class UnboxedDoubleBinaryOpInstr; | |
435 friend class CheckClassInstr; | |
436 friend class CheckSmiInstr; | |
437 friend class CheckNonSmiInstr; | |
438 friend class CheckArrayBoundInstr; | |
439 friend class CheckEitherNonSmiInstr; | |
440 | |
441 intptr_t deopt_id_; | |
442 intptr_t lifetime_position_; // Position used by register allocator. | 358 intptr_t lifetime_position_; // Position used by register allocator. |
443 Instruction* previous_; | 359 Instruction* previous_; |
444 Instruction* next_; | 360 Instruction* next_; |
445 Environment* env_; | 361 Environment* env_; |
446 DISALLOW_COPY_AND_ASSIGN(Instruction); | 362 DISALLOW_COPY_AND_ASSIGN(Instruction); |
447 }; | 363 }; |
448 | 364 |
449 | 365 |
450 template<intptr_t N> | 366 template<intptr_t N> |
451 class TemplateInstruction: public Instruction { | 367 class TemplateInstruction: public Instruction { |
452 public: | 368 public: |
453 TemplateInstruction<N>() : locs_(NULL) { } | 369 TemplateInstruction<N>() : locs_(NULL) { } |
454 | 370 |
455 virtual intptr_t InputCount() const { return N; } | 371 virtual intptr_t InputCount() const { return N; } |
456 virtual Value* InputAt(intptr_t i) const { return inputs_[i]; } | 372 virtual Value* InputAt(intptr_t i) const { return inputs_[i]; } |
457 virtual void SetInputAt(intptr_t i, Value* value) { | 373 virtual void SetInputAt(intptr_t i, Value* value) { |
458 ASSERT(value != NULL); | 374 ASSERT(value != NULL); |
459 inputs_[i] = value; | 375 inputs_[i] = value; |
460 } | 376 } |
461 | 377 |
462 virtual LocationSummary* locs() { | 378 virtual LocationSummary* locs() { |
463 if (locs_ == NULL) { | 379 if (locs_ == NULL) { |
464 locs_ = MakeLocationSummary(); | 380 locs_ = MakeLocationSummary(); |
465 } | 381 } |
466 return locs_; | 382 return locs_; |
467 } | 383 } |
468 | 384 |
| 385 virtual LocationSummary* MakeLocationSummary() const = 0; |
| 386 |
469 protected: | 387 protected: |
470 EmbeddedArray<Value*, N> inputs_; | 388 EmbeddedArray<Value*, N> inputs_; |
471 | 389 |
472 private: | 390 private: |
473 LocationSummary* locs_; | 391 LocationSummary* locs_; |
474 }; | 392 }; |
475 | 393 |
476 | 394 |
477 class MoveOperands : public ZoneAllocated { | 395 class MoveOperands : public ZoneAllocated { |
478 public: | 396 public: |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
548 return move; | 466 return move; |
549 } | 467 } |
550 | 468 |
551 MoveOperands* MoveOperandsAt(intptr_t index) const { return moves_[index]; } | 469 MoveOperands* MoveOperandsAt(intptr_t index) const { return moves_[index]; } |
552 | 470 |
553 void SetSrcSlotAt(intptr_t index, const Location& loc); | 471 void SetSrcSlotAt(intptr_t index, const Location& loc); |
554 void SetDestSlotAt(intptr_t index, const Location& loc); | 472 void SetDestSlotAt(intptr_t index, const Location& loc); |
555 | 473 |
556 intptr_t NumMoves() const { return moves_.length(); } | 474 intptr_t NumMoves() const { return moves_.length(); } |
557 | 475 |
558 virtual void PrintTo(BufferFormatter* f) const; | 476 LocationSummary* MakeLocationSummary() const { return NULL; } |
559 virtual void PrintToVisualizer(BufferFormatter* f) const; | 477 |
| 478 void EmitNativeCode(FlowGraphCompiler* compiler) { UNREACHABLE(); } |
560 | 479 |
561 private: | 480 private: |
562 GrowableArray<MoveOperands*> moves_; // Elements cannot be null. | 481 GrowableArray<MoveOperands*> moves_; // Elements cannot be null. |
563 | 482 |
564 DISALLOW_COPY_AND_ASSIGN(ParallelMoveInstr); | 483 DISALLOW_COPY_AND_ASSIGN(ParallelMoveInstr); |
565 }; | 484 }; |
566 | 485 |
567 | 486 |
568 // Basic block entries are administrative nodes. There is a distinguished | 487 // Basic block entries are administrative nodes. There is a distinguished |
569 // graph entry with no predecessor. Joins are the only nodes with multiple | 488 // graph entry with no predecessor. Joins are the only nodes with multiple |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
688 void Advance() { | 607 void Advance() { |
689 ASSERT(!Done()); | 608 ASSERT(!Done()); |
690 current_ = current_->next(); | 609 current_ = current_->next(); |
691 } | 610 } |
692 | 611 |
693 bool Done() const { return current_ == NULL; } | 612 bool Done() const { return current_ == NULL; } |
694 | 613 |
695 // Removes 'current_' from graph and sets 'current_' to previous instruction. | 614 // Removes 'current_' from graph and sets 'current_' to previous instruction. |
696 void RemoveCurrentFromGraph(); | 615 void RemoveCurrentFromGraph(); |
697 | 616 |
698 // Inserts replaces 'current_', which must be a definition, with another | |
699 // definition. The new definition becomes 'current_'. | |
700 void ReplaceCurrentWith(Definition* other); | |
701 | |
702 Instruction* Current() const { return current_; } | 617 Instruction* Current() const { return current_; } |
703 | 618 |
704 private: | 619 private: |
705 BlockEntryInstr* block_entry_; | 620 BlockEntryInstr* block_entry_; |
706 Instruction* current_; | 621 Instruction* current_; |
707 }; | 622 }; |
708 | 623 |
709 | 624 |
710 class BackwardInstructionIterator : public ValueObject { | 625 class BackwardInstructionIterator : public ValueObject { |
711 public: | 626 public: |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
754 intptr_t variable_count, | 669 intptr_t variable_count, |
755 intptr_t fixed_parameter_count); | 670 intptr_t fixed_parameter_count); |
756 | 671 |
757 void AddCatchEntry(TargetEntryInstr* entry) { catch_entries_.Add(entry); } | 672 void AddCatchEntry(TargetEntryInstr* entry) { catch_entries_.Add(entry); } |
758 | 673 |
759 virtual void PrepareEntry(FlowGraphCompiler* compiler); | 674 virtual void PrepareEntry(FlowGraphCompiler* compiler); |
760 | 675 |
761 Environment* start_env() const { return start_env_; } | 676 Environment* start_env() const { return start_env_; } |
762 void set_start_env(Environment* env) { start_env_ = env; } | 677 void set_start_env(Environment* env) { start_env_ = env; } |
763 | 678 |
764 ConstantInstr* constant_null() const { return constant_null_; } | 679 Definition* constant_null() const { return constant_null_; } |
765 | 680 |
766 intptr_t spill_slot_count() const { return spill_slot_count_; } | 681 intptr_t spill_slot_count() const { return spill_slot_count_; } |
767 void set_spill_slot_count(intptr_t count) { | 682 void set_spill_slot_count(intptr_t count) { |
768 ASSERT(count >= 0); | 683 ASSERT(count >= 0); |
769 spill_slot_count_ = count; | 684 spill_slot_count_ = count; |
770 } | 685 } |
771 | 686 |
772 TargetEntryInstr* normal_entry() const { return normal_entry_; } | 687 TargetEntryInstr* normal_entry() const { return normal_entry_; } |
773 | 688 |
774 virtual void PrintTo(BufferFormatter* f) const; | |
775 virtual void PrintToVisualizer(BufferFormatter* f) const; | |
776 | |
777 private: | 689 private: |
778 TargetEntryInstr* normal_entry_; | 690 TargetEntryInstr* normal_entry_; |
779 GrowableArray<TargetEntryInstr*> catch_entries_; | 691 GrowableArray<TargetEntryInstr*> catch_entries_; |
780 Environment* start_env_; | 692 Environment* start_env_; |
781 ConstantInstr* constant_null_; | 693 Definition* constant_null_; |
782 intptr_t spill_slot_count_; | 694 intptr_t spill_slot_count_; |
783 | 695 |
784 DISALLOW_COPY_AND_ASSIGN(GraphEntryInstr); | 696 DISALLOW_COPY_AND_ASSIGN(GraphEntryInstr); |
785 }; | 697 }; |
786 | 698 |
787 | 699 |
788 class JoinEntryInstr : public BlockEntryInstr { | 700 class JoinEntryInstr : public BlockEntryInstr { |
789 public: | 701 public: |
790 explicit JoinEntryInstr(intptr_t try_index) | 702 explicit JoinEntryInstr(intptr_t try_index) |
791 : BlockEntryInstr(try_index), | 703 : BlockEntryInstr(try_index), |
(...skipping 16 matching lines...) Expand all Loading... |
808 | 720 |
809 ZoneGrowableArray<PhiInstr*>* phis() const { return phis_; } | 721 ZoneGrowableArray<PhiInstr*>* phis() const { return phis_; } |
810 | 722 |
811 virtual void PrepareEntry(FlowGraphCompiler* compiler); | 723 virtual void PrepareEntry(FlowGraphCompiler* compiler); |
812 | 724 |
813 void InsertPhi(intptr_t var_index, intptr_t var_count); | 725 void InsertPhi(intptr_t var_index, intptr_t var_count); |
814 void RemoveDeadPhis(); | 726 void RemoveDeadPhis(); |
815 | 727 |
816 intptr_t phi_count() const { return phi_count_; } | 728 intptr_t phi_count() const { return phi_count_; } |
817 | 729 |
818 virtual void PrintTo(BufferFormatter* f) const; | |
819 virtual void PrintToVisualizer(BufferFormatter* f) const; | |
820 | |
821 private: | 730 private: |
822 GrowableArray<BlockEntryInstr*> predecessors_; | 731 GrowableArray<BlockEntryInstr*> predecessors_; |
823 ZoneGrowableArray<PhiInstr*>* phis_; | 732 ZoneGrowableArray<PhiInstr*>* phis_; |
824 intptr_t phi_count_; | 733 intptr_t phi_count_; |
825 | 734 |
826 DISALLOW_COPY_AND_ASSIGN(JoinEntryInstr); | 735 DISALLOW_COPY_AND_ASSIGN(JoinEntryInstr); |
827 }; | 736 }; |
828 | 737 |
829 | 738 |
830 class TargetEntryInstr : public BlockEntryInstr { | 739 class TargetEntryInstr : public BlockEntryInstr { |
(...skipping 30 matching lines...) Expand all Loading... |
861 | 770 |
862 // Returns try index for the try block to which this catch handler | 771 // Returns try index for the try block to which this catch handler |
863 // corresponds. | 772 // corresponds. |
864 intptr_t catch_try_index() const { | 773 intptr_t catch_try_index() const { |
865 ASSERT(IsCatchEntry()); | 774 ASSERT(IsCatchEntry()); |
866 return catch_try_index_; | 775 return catch_try_index_; |
867 } | 776 } |
868 | 777 |
869 virtual void PrepareEntry(FlowGraphCompiler* compiler); | 778 virtual void PrepareEntry(FlowGraphCompiler* compiler); |
870 | 779 |
871 virtual void PrintTo(BufferFormatter* f) const; | |
872 virtual void PrintToVisualizer(BufferFormatter* f) const; | |
873 | |
874 private: | 780 private: |
875 BlockEntryInstr* predecessor_; | 781 BlockEntryInstr* predecessor_; |
876 const intptr_t catch_try_index_; | 782 const intptr_t catch_try_index_; |
877 | 783 |
878 DISALLOW_COPY_AND_ASSIGN(TargetEntryInstr); | 784 DISALLOW_COPY_AND_ASSIGN(TargetEntryInstr); |
879 }; | 785 }; |
880 | 786 |
881 | 787 |
882 // Abstract super-class of all instructions that define a value (Bind, Phi). | 788 // Abstract super-class of all instructions that define a value (Bind, Phi). |
883 class Definition : public Instruction { | 789 class Definition : public Instruction { |
884 public: | 790 public: |
885 enum UseKind { kEffect, kValue }; | 791 enum UseKind { kEffect, kValue }; |
886 | 792 |
887 Definition() | 793 Definition() |
888 : temp_index_(-1), | 794 : temp_index_(-1), |
889 ssa_temp_index_(-1), | 795 ssa_temp_index_(-1), |
890 propagated_type_(AbstractType::Handle()), | 796 propagated_type_(AbstractType::Handle()), |
891 propagated_cid_(kIllegalCid), | 797 propagated_cid_(kIllegalCid), |
892 input_use_list_(NULL), | 798 input_use_list_(NULL), |
893 env_use_list_(NULL), | 799 env_use_list_(NULL), |
894 use_kind_(kValue) { // Phis and parameters rely on this default. | 800 use_kind_(kValue) { // Phis and parameters rely on this default. |
895 } | 801 } |
896 | 802 |
897 virtual Definition* AsDefinition() { return this; } | 803 virtual Definition* AsDefinition() { return this; } |
898 | 804 |
899 bool IsComparison() { return (AsComparison() != NULL); } | |
900 virtual ComparisonInstr* AsComparison() { return NULL; } | |
901 | |
902 // Overridden by definitions that push arguments. | |
903 virtual intptr_t ArgumentCount() const { return 0; } | |
904 | |
905 intptr_t temp_index() const { return temp_index_; } | 805 intptr_t temp_index() const { return temp_index_; } |
906 void set_temp_index(intptr_t index) { temp_index_ = index; } | 806 void set_temp_index(intptr_t index) { temp_index_ = index; } |
907 | 807 |
908 intptr_t ssa_temp_index() const { return ssa_temp_index_; } | 808 intptr_t ssa_temp_index() const { return ssa_temp_index_; } |
909 void set_ssa_temp_index(intptr_t index) { | 809 void set_ssa_temp_index(intptr_t index) { |
910 ASSERT(index >= 0); | 810 ASSERT(index >= 0); |
911 ASSERT(is_used()); | 811 ASSERT(is_used()); |
912 ssa_temp_index_ = index; | 812 ssa_temp_index_ = index; |
913 } | 813 } |
914 bool HasSSATemp() const { return ssa_temp_index_ >= 0; } | 814 bool HasSSATemp() const { return ssa_temp_index_ >= 0; } |
915 | 815 |
916 bool is_used() const { return (use_kind_ != kEffect); } | 816 bool is_used() const { return (use_kind_ != kEffect); } |
917 void set_use_kind(UseKind kind) { use_kind_ = kind; } | 817 void set_use_kind(UseKind kind) { use_kind_ = kind; } |
918 | 818 |
919 // Compile time type of the definition, which may be requested before type | 819 // Compile time type of the definition, which may be requested before type |
920 // propagation during graph building. | 820 // propagation during graph building. |
921 virtual RawAbstractType* CompileType() const = 0; | 821 virtual RawAbstractType* CompileType() const = 0; |
922 | 822 |
923 virtual intptr_t ResultCid() const = 0; | |
924 | |
925 bool HasPropagatedType() const { | 823 bool HasPropagatedType() const { |
926 return !propagated_type_.IsNull(); | 824 return !propagated_type_.IsNull(); |
927 } | 825 } |
928 RawAbstractType* PropagatedType() const { | 826 RawAbstractType* PropagatedType() const { |
929 ASSERT(HasPropagatedType()); | 827 ASSERT(HasPropagatedType()); |
930 return propagated_type_.raw(); | 828 return propagated_type_.raw(); |
931 } | 829 } |
932 // Returns true if the propagated type has changed. | 830 // Returns true if the propagated type has changed. |
933 bool SetPropagatedType(const AbstractType& propagated_type) { | 831 bool SetPropagatedType(const AbstractType& propagated_type) { |
934 if (propagated_type.IsNull()) { | 832 if (propagated_type.IsNull()) { |
935 // Not a typed definition, e.g. access to a VM field. | 833 // Not a typed definition, e.g. access to a VM field. |
936 return false; | 834 return false; |
937 } | 835 } |
938 const bool changed = | 836 const bool changed = |
939 propagated_type_.IsNull() || !propagated_type.Equals(propagated_type_); | 837 propagated_type_.IsNull() || !propagated_type.Equals(propagated_type_); |
940 propagated_type_ = propagated_type.raw(); | 838 propagated_type_ = propagated_type.raw(); |
941 return changed; | 839 return changed; |
942 } | 840 } |
943 | 841 |
944 bool has_propagated_cid() const { return propagated_cid_ != kIllegalCid; } | 842 bool has_propagated_cid() const { return propagated_cid_ != kIllegalCid; } |
945 intptr_t propagated_cid() const { return propagated_cid_; } | 843 intptr_t propagated_cid() const { return propagated_cid_; } |
946 | |
947 // May compute and set propagated cid. | 844 // May compute and set propagated cid. |
948 virtual intptr_t GetPropagatedCid(); | 845 virtual intptr_t GetPropagatedCid() = 0; |
949 | 846 |
950 // Returns true if the propagated cid has changed. | 847 // Returns true if the propagated cid has changed. |
951 bool SetPropagatedCid(intptr_t cid); | 848 bool SetPropagatedCid(intptr_t cid); |
952 | 849 |
953 // Returns true if the definition may have side effects. | |
954 // TODO(fschneider): Make this abstract and implement for all definitions | |
955 // instead of returning the safe default (true). | |
956 virtual bool HasSideEffect() const { return true; } | |
957 | |
958 Value* input_use_list() { return input_use_list_; } | 850 Value* input_use_list() { return input_use_list_; } |
959 void set_input_use_list(Value* head) { input_use_list_ = head; } | 851 void set_input_use_list(Value* head) { input_use_list_ = head; } |
960 | 852 |
961 Value* env_use_list() { return env_use_list_; } | 853 Value* env_use_list() { return env_use_list_; } |
962 void set_env_use_list(Value* head) { env_use_list_ = head; } | 854 void set_env_use_list(Value* head) { env_use_list_ = head; } |
963 | 855 |
964 // Returns a replacement for the definition or NULL if the definition can | |
965 // be eliminated. By default returns the definition (input parameter) | |
966 // which means no change. | |
967 virtual Definition* Canonicalize(); | |
968 | |
969 // Replace uses of this definition with uses of other definition or value. | 856 // Replace uses of this definition with uses of other definition or value. |
970 // Precondition: use lists must be properly calculated. | 857 // Precondition: use lists must be properly calculated. |
971 // Postcondition: use lists and use values are still valid. | 858 // Postcondition: use lists and use values are still valid. |
972 void ReplaceUsesWith(Definition* other); | 859 void ReplaceUsesWith(Definition* other); |
973 | 860 |
974 // Replace this definition and all uses with another definition. If | |
975 // replacing during iteration, pass the iterator so that the instruction | |
976 // can be replaced without affecting iteration order, otherwise pass a | |
977 // NULL iterator. | |
978 void ReplaceWith(Definition* other, ForwardInstructionIterator* iterator); | |
979 | |
980 // Insert this definition before 'next'. | 861 // Insert this definition before 'next'. |
981 void InsertBefore(Instruction* next); | 862 void InsertBefore(Instruction* next); |
982 | 863 |
983 // Insert this definition after 'prev'. | 864 // Insert this definition after 'prev'. |
984 void InsertAfter(Instruction* prev); | 865 void InsertAfter(Instruction* prev); |
985 | 866 |
986 // Compares two definitions. Returns true, iff: | 867 // If this definition is a bind of a constant return it. |
987 // 1. They have the same tag. | 868 // Otherwise return NULL. |
988 // 2. All input operands are Equals. | 869 ConstantComp* AsConstant(); |
989 // 3. They satisfy AttributesEqual. | |
990 bool Equals(Definition* other) const; | |
991 | |
992 // Compare attributes of a definition (except input operands and tag). | |
993 // All definition that participate in CSE have to override this function. | |
994 // This function can assume that the argument has the same type as this. | |
995 virtual bool AttributesEqual(Definition* other) const { | |
996 UNREACHABLE(); | |
997 return false; | |
998 } | |
999 | |
1000 // Returns a hash code for use with hash maps. | |
1001 virtual intptr_t Hashcode() const; | |
1002 | |
1003 virtual void RecordAssignedVars(BitVector* assigned_vars, | |
1004 intptr_t fixed_parameter_count); | |
1005 | |
1006 // Printing support. These functions are sometimes overridden for custom | |
1007 // formatting. Otherwise, it prints in the format "opcode(op1, op2, op3)". | |
1008 virtual void PrintTo(BufferFormatter* f) const; | |
1009 virtual void PrintOperandsTo(BufferFormatter* f) const; | |
1010 virtual void PrintToVisualizer(BufferFormatter* f) const; | |
1011 | 870 |
1012 private: | 871 private: |
1013 intptr_t temp_index_; | 872 intptr_t temp_index_; |
1014 intptr_t ssa_temp_index_; | 873 intptr_t ssa_temp_index_; |
1015 // TODO(regis): GrowableArray<const AbstractType*> propagated_types_; | 874 // TODO(regis): GrowableArray<const AbstractType*> propagated_types_; |
1016 // For now: | 875 // For now: |
1017 AbstractType& propagated_type_; | 876 AbstractType& propagated_type_; |
1018 intptr_t propagated_cid_; | 877 intptr_t propagated_cid_; |
1019 Value* input_use_list_; | 878 Value* input_use_list_; |
1020 Value* env_use_list_; | 879 Value* env_use_list_; |
1021 UseKind use_kind_; | 880 UseKind use_kind_; |
1022 | 881 |
1023 DISALLOW_COPY_AND_ASSIGN(Definition); | 882 DISALLOW_COPY_AND_ASSIGN(Definition); |
1024 }; | 883 }; |
1025 | 884 |
1026 | 885 |
| 886 class BindInstr : public Definition { |
| 887 public: |
| 888 BindInstr(UseKind used, Computation* computation) |
| 889 : computation_(computation) { |
| 890 ASSERT(computation != NULL); |
| 891 set_use_kind(used); |
| 892 } |
| 893 |
| 894 DECLARE_INSTRUCTION(Bind) |
| 895 |
| 896 // Overridden functions from class Instruction. |
| 897 virtual intptr_t ArgumentCount() const; |
| 898 intptr_t InputCount() const; |
| 899 Value* InputAt(intptr_t i) const; |
| 900 void SetInputAt(intptr_t i, Value* value); |
| 901 virtual bool CanDeoptimize() const; |
| 902 virtual void RecordAssignedVars(BitVector* assigned_vars, |
| 903 intptr_t fixed_parameter_count); |
| 904 virtual LocationSummary* locs(); |
| 905 virtual void EmitNativeCode(FlowGraphCompiler* compiler); |
| 906 virtual Representation RequiredInputRepresentation(intptr_t i) const; |
| 907 virtual Representation representation() const; |
| 908 virtual intptr_t DeoptimizationTarget() const; |
| 909 |
| 910 Computation* computation() const { return computation_; } |
| 911 void set_computation(Computation* value) { computation_ = value; } |
| 912 |
| 913 // Overridden functions from class Definition. |
| 914 virtual RawAbstractType* CompileType() const; |
| 915 virtual intptr_t GetPropagatedCid(); |
| 916 |
| 917 // Other functions that forward to the computation. |
| 918 intptr_t Hashcode() const; |
| 919 bool Equals(BindInstr* other) const; |
| 920 |
| 921 private: |
| 922 Computation* computation_; |
| 923 |
| 924 DISALLOW_COPY_AND_ASSIGN(BindInstr); |
| 925 }; |
| 926 |
| 927 |
1027 class PhiInstr : public Definition { | 928 class PhiInstr : public Definition { |
1028 public: | 929 public: |
1029 explicit PhiInstr(JoinEntryInstr* block, intptr_t num_inputs) | 930 explicit PhiInstr(JoinEntryInstr* block, intptr_t num_inputs) |
1030 : block_(block), | 931 : block_(block), |
1031 inputs_(num_inputs), | 932 inputs_(num_inputs), |
1032 is_alive_(false), | 933 is_alive_(false), |
1033 representation_(kTagged) { | 934 representation_(kTagged) { |
1034 for (intptr_t i = 0; i < num_inputs; ++i) { | 935 for (intptr_t i = 0; i < num_inputs; ++i) { |
1035 inputs_.Add(NULL); | 936 inputs_.Add(NULL); |
1036 } | 937 } |
1037 } | 938 } |
1038 | 939 |
1039 JoinEntryInstr* block() const { return block_; } | 940 JoinEntryInstr* block() const { return block_; } |
1040 | 941 |
1041 virtual RawAbstractType* CompileType() const; | 942 virtual RawAbstractType* CompileType() const; |
1042 virtual intptr_t GetPropagatedCid(); | 943 virtual intptr_t GetPropagatedCid() { return propagated_cid(); } |
1043 | 944 |
1044 virtual intptr_t ArgumentCount() const { return 0; } | 945 virtual intptr_t ArgumentCount() const { return 0; } |
1045 | 946 |
1046 intptr_t InputCount() const { return inputs_.length(); } | 947 intptr_t InputCount() const { return inputs_.length(); } |
1047 | 948 |
1048 Value* InputAt(intptr_t i) const { return inputs_[i]; } | 949 Value* InputAt(intptr_t i) const { return inputs_[i]; } |
1049 | 950 |
1050 void SetInputAt(intptr_t i, Value* value) { inputs_[i] = value; } | 951 void SetInputAt(intptr_t i, Value* value) { inputs_[i] = value; } |
1051 | 952 |
1052 virtual bool CanDeoptimize() const { return false; } | 953 virtual bool CanDeoptimize() const { return false; } |
(...skipping 10 matching lines...) Expand all Loading... |
1063 } | 964 } |
1064 | 965 |
1065 virtual Representation representation() const { | 966 virtual Representation representation() const { |
1066 return representation_; | 967 return representation_; |
1067 } | 968 } |
1068 | 969 |
1069 virtual void set_representation(Representation r) { | 970 virtual void set_representation(Representation r) { |
1070 representation_ = r; | 971 representation_ = r; |
1071 } | 972 } |
1072 | 973 |
1073 virtual intptr_t Hashcode() const { | |
1074 UNREACHABLE(); | |
1075 return 0; | |
1076 } | |
1077 | |
1078 virtual intptr_t ResultCid() const { | |
1079 UNREACHABLE(); | |
1080 return kIllegalCid; | |
1081 } | |
1082 | |
1083 DECLARE_INSTRUCTION(Phi) | 974 DECLARE_INSTRUCTION(Phi) |
1084 | 975 |
1085 virtual void PrintTo(BufferFormatter* f) const; | |
1086 virtual void PrintToVisualizer(BufferFormatter* f) const; | |
1087 | |
1088 private: | 976 private: |
1089 JoinEntryInstr* block_; | 977 JoinEntryInstr* block_; |
1090 GrowableArray<Value*> inputs_; | 978 GrowableArray<Value*> inputs_; |
1091 bool is_alive_; | 979 bool is_alive_; |
1092 Representation representation_; | 980 Representation representation_; |
1093 | 981 |
1094 DISALLOW_COPY_AND_ASSIGN(PhiInstr); | 982 DISALLOW_COPY_AND_ASSIGN(PhiInstr); |
1095 }; | 983 }; |
1096 | 984 |
1097 | 985 |
1098 class ParameterInstr : public Definition { | 986 class ParameterInstr : public Definition { |
1099 public: | 987 public: |
1100 explicit ParameterInstr(intptr_t index) : index_(index) { } | 988 explicit ParameterInstr(intptr_t index) : index_(index) { } |
1101 | 989 |
1102 DECLARE_INSTRUCTION(Parameter) | 990 DECLARE_INSTRUCTION(Parameter) |
1103 | 991 |
1104 intptr_t index() const { return index_; } | 992 intptr_t index() const { return index_; } |
1105 | 993 |
1106 // Compile type of the passed-in parameter. | 994 // Compile type of the passed-in parameter. |
1107 virtual RawAbstractType* CompileType() const; | 995 virtual RawAbstractType* CompileType() const; |
1108 | |
1109 // No known propagated cid for parameters. | 996 // No known propagated cid for parameters. |
1110 virtual intptr_t GetPropagatedCid(); | 997 virtual intptr_t GetPropagatedCid() { return propagated_cid(); } |
1111 | 998 |
1112 virtual intptr_t ArgumentCount() const { return 0; } | 999 virtual intptr_t ArgumentCount() const { return 0; } |
1113 | 1000 |
1114 intptr_t InputCount() const { return 0; } | 1001 intptr_t InputCount() const { return 0; } |
1115 Value* InputAt(intptr_t i) const { | 1002 Value* InputAt(intptr_t i) const { |
1116 UNREACHABLE(); | 1003 UNREACHABLE(); |
1117 return NULL; | 1004 return NULL; |
1118 } | 1005 } |
1119 void SetInputAt(intptr_t i, Value* value) { UNREACHABLE(); } | 1006 void SetInputAt(intptr_t i, Value* value) { UNREACHABLE(); } |
1120 | 1007 |
1121 virtual bool CanDeoptimize() const { return false; } | 1008 virtual bool CanDeoptimize() const { return false; } |
1122 | 1009 |
1123 virtual intptr_t Hashcode() const { | |
1124 UNREACHABLE(); | |
1125 return 0; | |
1126 } | |
1127 | |
1128 virtual intptr_t ResultCid() const { | |
1129 UNREACHABLE(); | |
1130 return kIllegalCid; | |
1131 } | |
1132 | |
1133 virtual void PrintTo(BufferFormatter* f) const; | |
1134 virtual void PrintToVisualizer(BufferFormatter* f) const; | |
1135 | |
1136 private: | 1010 private: |
1137 const intptr_t index_; | 1011 const intptr_t index_; |
1138 | 1012 |
1139 DISALLOW_COPY_AND_ASSIGN(ParameterInstr); | 1013 DISALLOW_COPY_AND_ASSIGN(ParameterInstr); |
1140 }; | 1014 }; |
1141 | 1015 |
1142 | 1016 |
1143 class PushArgumentInstr : public Definition { | 1017 class PushArgumentInstr : public Definition { |
1144 public: | 1018 public: |
1145 explicit PushArgumentInstr(Value* value) : value_(value), locs_(NULL) { | 1019 explicit PushArgumentInstr(Value* value) : value_(value), locs_(NULL) { |
1146 ASSERT(value != NULL); | 1020 ASSERT(value != NULL); |
1147 set_use_kind(kEffect); // Override the default. | |
1148 } | 1021 } |
1149 | 1022 |
1150 DECLARE_INSTRUCTION(PushArgument) | 1023 DECLARE_INSTRUCTION(PushArgument) |
1151 | 1024 |
1152 intptr_t InputCount() const { return 1; } | 1025 intptr_t InputCount() const { return 1; } |
1153 Value* InputAt(intptr_t i) const { | 1026 Value* InputAt(intptr_t i) const { |
1154 ASSERT(i == 0); | 1027 ASSERT(i == 0); |
1155 return value_; | 1028 return value_; |
1156 } | 1029 } |
1157 void SetInputAt(intptr_t i, Value* value) { | 1030 void SetInputAt(intptr_t i, Value* value) { |
1158 ASSERT(i == 0); | 1031 ASSERT(i == 0); |
1159 value_ = value; | 1032 value_ = value; |
1160 } | 1033 } |
1161 | 1034 |
1162 virtual intptr_t ArgumentCount() const { return 0; } | 1035 virtual intptr_t ArgumentCount() const { return 0; } |
1163 | 1036 |
1164 virtual RawAbstractType* CompileType() const; | 1037 virtual RawAbstractType* CompileType() const; |
1165 virtual intptr_t GetPropagatedCid() { return propagated_cid(); } | 1038 virtual intptr_t GetPropagatedCid() { return propagated_cid(); } |
1166 virtual intptr_t ResultCid() const { | |
1167 UNREACHABLE(); | |
1168 return kIllegalCid; | |
1169 } | |
1170 | 1039 |
1171 Value* value() const { return value_; } | 1040 Value* value() const { return value_; } |
1172 | 1041 |
1173 virtual LocationSummary* locs() { | 1042 virtual LocationSummary* locs() { |
1174 if (locs_ == NULL) { | 1043 if (locs_ == NULL) { |
1175 locs_ = MakeLocationSummary(); | 1044 locs_ = MakeLocationSummary(); |
1176 } | 1045 } |
1177 return locs_; | 1046 return locs_; |
1178 } | 1047 } |
1179 | 1048 |
1180 virtual intptr_t Hashcode() const { | 1049 LocationSummary* MakeLocationSummary() const; |
1181 UNREACHABLE(); | 1050 |
1182 return 0; | 1051 virtual void EmitNativeCode(FlowGraphCompiler* compiler); |
1183 } | |
1184 | 1052 |
1185 virtual bool CanDeoptimize() const { return false; } | 1053 virtual bool CanDeoptimize() const { return false; } |
1186 | 1054 |
1187 virtual void PrintTo(BufferFormatter* f) const; | |
1188 virtual void PrintToVisualizer(BufferFormatter* f) const; | |
1189 | |
1190 private: | 1055 private: |
1191 Value* value_; | 1056 Value* value_; |
1192 LocationSummary* locs_; | 1057 LocationSummary* locs_; |
1193 | 1058 |
1194 DISALLOW_COPY_AND_ASSIGN(PushArgumentInstr); | 1059 DISALLOW_COPY_AND_ASSIGN(PushArgumentInstr); |
1195 }; | 1060 }; |
1196 | 1061 |
1197 | 1062 |
1198 class ReturnInstr : public TemplateInstruction<1> { | 1063 class ReturnInstr : public TemplateInstruction<1> { |
1199 public: | 1064 public: |
1200 ReturnInstr(intptr_t token_pos, Value* value) | 1065 ReturnInstr(intptr_t token_pos, Value* value) |
1201 : token_pos_(token_pos) { | 1066 : deopt_id_(Isolate::Current()->GetNextDeoptId()), |
| 1067 token_pos_(token_pos) { |
1202 ASSERT(value != NULL); | 1068 ASSERT(value != NULL); |
1203 inputs_[0] = value; | 1069 inputs_[0] = value; |
1204 } | 1070 } |
1205 | 1071 |
1206 DECLARE_INSTRUCTION(Return) | 1072 DECLARE_INSTRUCTION(Return) |
1207 | 1073 |
1208 virtual intptr_t ArgumentCount() const { return 0; } | 1074 virtual intptr_t ArgumentCount() const { return 0; } |
1209 | 1075 |
| 1076 intptr_t deopt_id() const { return deopt_id_; } |
1210 intptr_t token_pos() const { return token_pos_; } | 1077 intptr_t token_pos() const { return token_pos_; } |
1211 Value* value() const { return inputs_[0]; } | 1078 Value* value() const { return inputs_[0]; } |
1212 | 1079 |
| 1080 virtual LocationSummary* MakeLocationSummary() const; |
| 1081 |
| 1082 virtual void EmitNativeCode(FlowGraphCompiler* compiler); |
| 1083 |
1213 virtual bool CanDeoptimize() const { return false; } | 1084 virtual bool CanDeoptimize() const { return false; } |
1214 | 1085 |
1215 virtual void PrintTo(BufferFormatter* f) const; | |
1216 virtual void PrintToVisualizer(BufferFormatter* f) const; | |
1217 | |
1218 private: | 1086 private: |
| 1087 const intptr_t deopt_id_; |
1219 const intptr_t token_pos_; | 1088 const intptr_t token_pos_; |
1220 | 1089 |
1221 DISALLOW_COPY_AND_ASSIGN(ReturnInstr); | 1090 DISALLOW_COPY_AND_ASSIGN(ReturnInstr); |
1222 }; | 1091 }; |
1223 | 1092 |
1224 | 1093 |
1225 class ThrowInstr : public TemplateInstruction<0> { | 1094 class ThrowInstr : public TemplateInstruction<0> { |
1226 public: | 1095 public: |
1227 explicit ThrowInstr(intptr_t token_pos) : token_pos_(token_pos) { } | 1096 explicit ThrowInstr(intptr_t token_pos) : token_pos_(token_pos) { } |
1228 | 1097 |
1229 DECLARE_INSTRUCTION(Throw) | 1098 DECLARE_INSTRUCTION(Throw) |
1230 | 1099 |
1231 virtual intptr_t ArgumentCount() const { return 1; } | 1100 virtual intptr_t ArgumentCount() const { return 1; } |
1232 | 1101 |
1233 intptr_t token_pos() const { return token_pos_; } | 1102 intptr_t token_pos() const { return token_pos_; } |
1234 | 1103 |
| 1104 virtual LocationSummary* MakeLocationSummary() const; |
| 1105 |
| 1106 virtual void EmitNativeCode(FlowGraphCompiler* compiler); |
| 1107 |
1235 virtual bool CanDeoptimize() const { return false; } | 1108 virtual bool CanDeoptimize() const { return false; } |
1236 | 1109 |
1237 virtual void PrintTo(BufferFormatter* f) const; | |
1238 virtual void PrintToVisualizer(BufferFormatter* f) const; | |
1239 | |
1240 private: | 1110 private: |
1241 const intptr_t token_pos_; | 1111 const intptr_t token_pos_; |
1242 | 1112 |
1243 DISALLOW_COPY_AND_ASSIGN(ThrowInstr); | 1113 DISALLOW_COPY_AND_ASSIGN(ThrowInstr); |
1244 }; | 1114 }; |
1245 | 1115 |
1246 | 1116 |
1247 class ReThrowInstr : public TemplateInstruction<0> { | 1117 class ReThrowInstr : public TemplateInstruction<0> { |
1248 public: | 1118 public: |
1249 explicit ReThrowInstr(intptr_t token_pos) : token_pos_(token_pos) { } | 1119 explicit ReThrowInstr(intptr_t token_pos) : token_pos_(token_pos) { } |
1250 | 1120 |
1251 DECLARE_INSTRUCTION(ReThrow) | 1121 DECLARE_INSTRUCTION(ReThrow) |
1252 | 1122 |
1253 virtual intptr_t ArgumentCount() const { return 2; } | 1123 virtual intptr_t ArgumentCount() const { return 2; } |
1254 | 1124 |
1255 intptr_t token_pos() const { return token_pos_; } | 1125 intptr_t token_pos() const { return token_pos_; } |
1256 | 1126 |
| 1127 virtual LocationSummary* MakeLocationSummary() const; |
| 1128 |
| 1129 virtual void EmitNativeCode(FlowGraphCompiler* compiler); |
| 1130 |
1257 virtual bool CanDeoptimize() const { return false; } | 1131 virtual bool CanDeoptimize() const { return false; } |
1258 | 1132 |
1259 virtual void PrintTo(BufferFormatter* f) const; | |
1260 virtual void PrintToVisualizer(BufferFormatter* f) const; | |
1261 | |
1262 private: | 1133 private: |
1263 const intptr_t token_pos_; | 1134 const intptr_t token_pos_; |
1264 | 1135 |
1265 DISALLOW_COPY_AND_ASSIGN(ReThrowInstr); | 1136 DISALLOW_COPY_AND_ASSIGN(ReThrowInstr); |
1266 }; | 1137 }; |
1267 | 1138 |
1268 | 1139 |
1269 class GotoInstr : public TemplateInstruction<0> { | 1140 class GotoInstr : public TemplateInstruction<0> { |
1270 public: | 1141 public: |
1271 explicit GotoInstr(JoinEntryInstr* entry) | 1142 explicit GotoInstr(JoinEntryInstr* entry) |
1272 : successor_(entry), | 1143 : successor_(entry), |
1273 parallel_move_(NULL) { } | 1144 parallel_move_(NULL) { } |
1274 | 1145 |
1275 DECLARE_INSTRUCTION(Goto) | 1146 DECLARE_INSTRUCTION(Goto) |
1276 | 1147 |
1277 virtual intptr_t ArgumentCount() const { return 0; } | 1148 virtual intptr_t ArgumentCount() const { return 0; } |
1278 | 1149 |
1279 JoinEntryInstr* successor() const { return successor_; } | 1150 JoinEntryInstr* successor() const { return successor_; } |
1280 void set_successor(JoinEntryInstr* successor) { successor_ = successor; } | 1151 void set_successor(JoinEntryInstr* successor) { successor_ = successor; } |
1281 virtual intptr_t SuccessorCount() const; | 1152 virtual intptr_t SuccessorCount() const; |
1282 virtual BlockEntryInstr* SuccessorAt(intptr_t index) const; | 1153 virtual BlockEntryInstr* SuccessorAt(intptr_t index) const; |
1283 | 1154 |
| 1155 virtual LocationSummary* MakeLocationSummary() const; |
| 1156 |
| 1157 virtual void EmitNativeCode(FlowGraphCompiler* compiler); |
| 1158 |
1284 virtual bool CanDeoptimize() const { return false; } | 1159 virtual bool CanDeoptimize() const { return false; } |
1285 | 1160 |
1286 ParallelMoveInstr* parallel_move() const { | 1161 ParallelMoveInstr* parallel_move() const { |
1287 return parallel_move_; | 1162 return parallel_move_; |
1288 } | 1163 } |
1289 | 1164 |
1290 bool HasParallelMove() const { | 1165 bool HasParallelMove() const { |
1291 return parallel_move_ != NULL; | 1166 return parallel_move_ != NULL; |
1292 } | 1167 } |
1293 | 1168 |
1294 ParallelMoveInstr* GetParallelMove() { | 1169 ParallelMoveInstr* GetParallelMove() { |
1295 if (parallel_move_ == NULL) { | 1170 if (parallel_move_ == NULL) { |
1296 parallel_move_ = new ParallelMoveInstr(); | 1171 parallel_move_ = new ParallelMoveInstr(); |
1297 } | 1172 } |
1298 return parallel_move_; | 1173 return parallel_move_; |
1299 } | 1174 } |
1300 | 1175 |
1301 virtual void PrintTo(BufferFormatter* f) const; | |
1302 virtual void PrintToVisualizer(BufferFormatter* f) const; | |
1303 | |
1304 private: | 1176 private: |
1305 JoinEntryInstr* successor_; | 1177 JoinEntryInstr* successor_; |
1306 | 1178 |
1307 // Parallel move that will be used by linear scan register allocator to | 1179 // Parallel move that will be used by linear scan register allocator to |
1308 // connect live ranges at the end of the block and resolve phis. | 1180 // connect live ranges at the end of the block and resolve phis. |
1309 ParallelMoveInstr* parallel_move_; | 1181 ParallelMoveInstr* parallel_move_; |
1310 }; | 1182 }; |
1311 | 1183 |
1312 | 1184 |
1313 class ControlInstruction : public Instruction { | 1185 class ControlInstruction : public Instruction { |
(...skipping 27 matching lines...) Expand all Loading... |
1341 private: | 1213 private: |
1342 TargetEntryInstr* true_successor_; | 1214 TargetEntryInstr* true_successor_; |
1343 TargetEntryInstr* false_successor_; | 1215 TargetEntryInstr* false_successor_; |
1344 | 1216 |
1345 DISALLOW_COPY_AND_ASSIGN(ControlInstruction); | 1217 DISALLOW_COPY_AND_ASSIGN(ControlInstruction); |
1346 }; | 1218 }; |
1347 | 1219 |
1348 | 1220 |
1349 class BranchInstr : public ControlInstruction { | 1221 class BranchInstr : public ControlInstruction { |
1350 public: | 1222 public: |
1351 explicit BranchInstr(ComparisonInstr* comparison) | 1223 explicit BranchInstr(ComparisonComp* computation) |
1352 : comparison_(comparison) { } | 1224 : computation_(computation), locs_(NULL) { } |
1353 | 1225 |
1354 DECLARE_INSTRUCTION(Branch) | 1226 DECLARE_INSTRUCTION(Branch) |
1355 | 1227 |
1356 virtual intptr_t ArgumentCount() const; | 1228 virtual intptr_t ArgumentCount() const; |
1357 intptr_t InputCount() const; | 1229 intptr_t InputCount() const; |
1358 Value* InputAt(intptr_t i) const; | 1230 Value* InputAt(intptr_t i) const; |
1359 void SetInputAt(intptr_t i, Value* value); | 1231 void SetInputAt(intptr_t i, Value* value); |
1360 virtual bool CanDeoptimize() const; | 1232 virtual bool CanDeoptimize() const; |
1361 | 1233 |
1362 ComparisonInstr* comparison() const { return comparison_; } | 1234 ComparisonComp* computation() const { return computation_; } |
1363 void set_comparison(ComparisonInstr* value) { comparison_ = value; } | 1235 void set_computation(ComparisonComp* value) { computation_ = value; } |
| 1236 |
| 1237 virtual void EmitNativeCode(FlowGraphCompiler* compiler); |
1364 | 1238 |
1365 virtual LocationSummary* locs(); | 1239 virtual LocationSummary* locs(); |
1366 virtual intptr_t DeoptimizationTarget() const; | 1240 virtual intptr_t DeoptimizationTarget() const; |
1367 virtual Representation RequiredInputRepresentation(intptr_t i) const; | 1241 virtual Representation RequiredInputRepresentation(intptr_t i) const; |
1368 | 1242 |
1369 // Replace the comparison with another, leaving the branch intact. | |
1370 void ReplaceWith(ComparisonInstr* other, | |
1371 ForwardInstructionIterator* ignored) { | |
1372 comparison_ = other; | |
1373 } | |
1374 | |
1375 virtual void PrintTo(BufferFormatter* f) const; | |
1376 virtual void PrintToVisualizer(BufferFormatter* f) const; | |
1377 | |
1378 private: | 1243 private: |
1379 ComparisonInstr* comparison_; | 1244 ComparisonComp* computation_; |
| 1245 LocationSummary* locs_; |
1380 | 1246 |
1381 DISALLOW_COPY_AND_ASSIGN(BranchInstr); | 1247 DISALLOW_COPY_AND_ASSIGN(BranchInstr); |
1382 }; | 1248 }; |
1383 | 1249 |
1384 | 1250 |
1385 template<intptr_t N> | 1251 #undef DECLARE_INSTRUCTION |
1386 class TemplateDefinition : public Definition { | 1252 |
| 1253 |
| 1254 // M is a two argument macro. It is applied to each concrete instruction's |
| 1255 // (including the values) typename and classname. |
| 1256 #define FOR_EACH_COMPUTATION(M) \ |
| 1257 M(AssertAssignable, AssertAssignableComp) \ |
| 1258 M(AssertBoolean, AssertBooleanComp) \ |
| 1259 M(ArgumentDefinitionTest, ArgumentDefinitionTestComp) \ |
| 1260 M(CurrentContext, CurrentContextComp) \ |
| 1261 M(StoreContext, StoreContextComp) \ |
| 1262 M(ClosureCall, ClosureCallComp) \ |
| 1263 M(InstanceCall, InstanceCallComp) \ |
| 1264 M(PolymorphicInstanceCall, PolymorphicInstanceCallComp) \ |
| 1265 M(StaticCall, StaticCallComp) \ |
| 1266 M(LoadLocal, LoadLocalComp) \ |
| 1267 M(StoreLocal, StoreLocalComp) \ |
| 1268 M(StrictCompare, StrictCompareComp) \ |
| 1269 M(EqualityCompare, EqualityCompareComp) \ |
| 1270 M(RelationalOp, RelationalOpComp) \ |
| 1271 M(NativeCall, NativeCallComp) \ |
| 1272 M(LoadIndexed, LoadIndexedComp) \ |
| 1273 M(StoreIndexed, StoreIndexedComp) \ |
| 1274 M(LoadInstanceField, LoadInstanceFieldComp) \ |
| 1275 M(StoreInstanceField, StoreInstanceFieldComp) \ |
| 1276 M(LoadStaticField, LoadStaticFieldComp) \ |
| 1277 M(StoreStaticField, StoreStaticFieldComp) \ |
| 1278 M(BooleanNegate, BooleanNegateComp) \ |
| 1279 M(InstanceOf, InstanceOfComp) \ |
| 1280 M(CreateArray, CreateArrayComp) \ |
| 1281 M(CreateClosure, CreateClosureComp) \ |
| 1282 M(AllocateObject, AllocateObjectComp) \ |
| 1283 M(AllocateObjectWithBoundsCheck, AllocateObjectWithBoundsCheckComp) \ |
| 1284 M(LoadVMField, LoadVMFieldComp) \ |
| 1285 M(StoreVMField, StoreVMFieldComp) \ |
| 1286 M(InstantiateTypeArguments, InstantiateTypeArgumentsComp) \ |
| 1287 M(ExtractConstructorTypeArguments, ExtractConstructorTypeArgumentsComp) \ |
| 1288 M(ExtractConstructorInstantiator, ExtractConstructorInstantiatorComp) \ |
| 1289 M(AllocateContext, AllocateContextComp) \ |
| 1290 M(ChainContext, ChainContextComp) \ |
| 1291 M(CloneContext, CloneContextComp) \ |
| 1292 M(CatchEntry, CatchEntryComp) \ |
| 1293 M(BinarySmiOp, BinarySmiOpComp) \ |
| 1294 M(BinaryMintOp, BinaryMintOpComp) \ |
| 1295 M(UnarySmiOp, UnarySmiOpComp) \ |
| 1296 M(NumberNegate, NumberNegateComp) \ |
| 1297 M(CheckStackOverflow, CheckStackOverflowComp) \ |
| 1298 M(DoubleToDouble, DoubleToDoubleComp) \ |
| 1299 M(SmiToDouble, SmiToDoubleComp) \ |
| 1300 M(CheckClass, CheckClassComp) \ |
| 1301 M(CheckSmi, CheckSmiComp) \ |
| 1302 M(Constant, ConstantComp) \ |
| 1303 M(CheckEitherNonSmi, CheckEitherNonSmiComp) \ |
| 1304 M(UnboxedDoubleBinaryOp, UnboxedDoubleBinaryOpComp) \ |
| 1305 M(UnboxDouble, UnboxDoubleComp) \ |
| 1306 M(BoxDouble, BoxDoubleComp) \ |
| 1307 M(CheckArrayBound, CheckArrayBoundComp) |
| 1308 |
| 1309 |
| 1310 #define FORWARD_DECLARATION(ShortName, ClassName) class ClassName; |
| 1311 FOR_EACH_COMPUTATION(FORWARD_DECLARATION) |
| 1312 #undef FORWARD_DECLARATION |
| 1313 |
| 1314 |
| 1315 class Computation : public ZoneAllocated { |
1387 public: | 1316 public: |
1388 TemplateDefinition<N>() : locs_(NULL) { } | 1317 Computation() |
| 1318 : deopt_id_(Isolate::Current()->GetNextDeoptId()), locs_(NULL) { } |
1389 | 1319 |
1390 virtual intptr_t InputCount() const { return N; } | 1320 // Unique id used for deoptimization. |
1391 virtual Value* InputAt(intptr_t i) const { return inputs_[i]; } | 1321 virtual intptr_t deopt_id() const { |
1392 virtual void SetInputAt(intptr_t i, Value* value) { | 1322 ASSERT(CanDeoptimize()); |
1393 ASSERT(value != NULL); | 1323 return deopt_id_; |
1394 inputs_[i] = value; | |
1395 } | 1324 } |
1396 | 1325 |
1397 // Returns a structure describing the location constraints required | 1326 // Visiting support. |
1398 // to emit native code for this definition. | 1327 virtual void Accept(FlowGraphVisitor* visitor, BindInstr* instr) = 0; |
| 1328 |
| 1329 virtual intptr_t InputCount() const = 0; |
| 1330 virtual Value* InputAt(intptr_t i) const = 0; |
| 1331 virtual void SetInputAt(intptr_t i, Value* value) = 0; |
| 1332 |
| 1333 // Call computations override this function and return the |
| 1334 // number of pushed arguments. |
| 1335 virtual intptr_t ArgumentCount() const = 0; |
| 1336 |
| 1337 // Returns true, if this computation can deoptimize. |
| 1338 virtual bool CanDeoptimize() const = 0; |
| 1339 |
| 1340 // Returns a replacement for the instruction that wraps this computation. |
| 1341 // Returns NULL if instr can be eliminated. |
| 1342 // By default returns instr (input parameter) which means no change. |
| 1343 virtual Definition* TryReplace(BindInstr* instr) const; |
| 1344 |
| 1345 // Compares two computations. Returns true, if: |
| 1346 // 1. They are of the same kind. |
| 1347 // 2. All input operands match. |
| 1348 // 3. All other attributes match. |
| 1349 bool Equals(Computation* other) const; |
| 1350 |
| 1351 // Returns a hash code for use with hash maps. |
| 1352 virtual intptr_t Hashcode() const; |
| 1353 |
| 1354 // Compare attributes of an computation (except input operands and kind). |
| 1355 // All computations that participate in CSE have to override this function. |
| 1356 virtual bool AttributesEqual(Computation* other) const { |
| 1357 UNREACHABLE(); |
| 1358 return false; |
| 1359 } |
| 1360 |
| 1361 // Returns true if the instruction may have side effects. |
| 1362 // TODO(fschneider): Make this abstract and implement for all computations |
| 1363 // instead of returning the safe default (true). |
| 1364 virtual bool HasSideEffect() const { return true; } |
| 1365 |
| 1366 // Compile time type of the computation, which typically depends on the |
| 1367 // compile time types (and possibly propagated types) of its inputs. |
| 1368 virtual RawAbstractType* CompileType() const = 0; |
| 1369 virtual intptr_t ResultCid() const = 0; |
| 1370 |
| 1371 // Mutate assigned_vars to add the local variable index for all |
| 1372 // frame-allocated locals assigned to by the computation. |
| 1373 virtual void RecordAssignedVars(BitVector* assigned_vars, |
| 1374 intptr_t fixed_parameter_count); |
| 1375 |
| 1376 virtual const char* DebugName() const = 0; |
| 1377 |
| 1378 // Printing support. These functions are sometimes overridden for custom |
| 1379 // formatting. Otherwise, it prints in the format "opcode(op1, op2, op3)". |
| 1380 virtual void PrintTo(BufferFormatter* f) const; |
| 1381 virtual void PrintOperandsTo(BufferFormatter* f) const; |
| 1382 |
| 1383 // Returns structure describing location constraints required |
| 1384 // to emit native code for this computation. |
1399 LocationSummary* locs() { | 1385 LocationSummary* locs() { |
1400 if (locs_ == NULL) { | 1386 if (locs_ == NULL) { |
1401 locs_ = MakeLocationSummary(); | 1387 locs_ = MakeLocationSummary(); |
1402 } | 1388 } |
1403 return locs_; | 1389 return locs_; |
1404 } | 1390 } |
1405 | 1391 |
| 1392 virtual ComparisonComp* AsComparison() { return NULL; } |
| 1393 |
| 1394 // Create a location summary for this computation. |
| 1395 // TODO(fschneider): Temporarily returns NULL for instructions |
| 1396 // that are not yet converted to the location based code generation. |
| 1397 virtual LocationSummary* MakeLocationSummary() const = 0; |
| 1398 |
| 1399 // TODO(fschneider): Make EmitNativeCode and locs const. |
| 1400 virtual void EmitNativeCode(FlowGraphCompiler* compiler) = 0; |
| 1401 |
| 1402 virtual void EmitBranchCode(FlowGraphCompiler* compiler, |
| 1403 BranchInstr* branch) { |
| 1404 UNREACHABLE(); |
| 1405 } |
| 1406 |
| 1407 static LocationSummary* MakeCallSummary(); |
| 1408 |
| 1409 // Declare an enum value used to define kind-test predicates. |
| 1410 enum ComputationKind { |
| 1411 #define DECLARE_COMPUTATION_KIND(ShortName, ClassName) k##ShortName, |
| 1412 |
| 1413 FOR_EACH_COMPUTATION(DECLARE_COMPUTATION_KIND) |
| 1414 |
| 1415 #undef DECLARE_COMPUTATION_KIND |
| 1416 }; |
| 1417 |
| 1418 virtual ComputationKind computation_kind() const = 0; |
| 1419 |
| 1420 // Returns representation expected for the input operand at the given index. |
| 1421 virtual Representation RequiredInputRepresentation(intptr_t idx) const { |
| 1422 return kTagged; |
| 1423 } |
| 1424 |
| 1425 // Representation of the value produced by this computation. |
| 1426 virtual Representation representation() const { |
| 1427 return kTagged; |
| 1428 } |
| 1429 |
| 1430 // Returns deoptimization id that corresponds to the deoptimization target |
| 1431 // that input operands conversions inserted for this instruction can jump |
| 1432 // to. Can return kNoDeoptId. |
| 1433 virtual intptr_t DeoptimizationTarget() const { |
| 1434 UNREACHABLE(); |
| 1435 return Isolate::kNoDeoptId; |
| 1436 } |
| 1437 |
| 1438 // Declare predicate for each computation. |
| 1439 #define DECLARE_PREDICATE(ShortName, ClassName) \ |
| 1440 inline bool Is##ShortName() const; \ |
| 1441 inline const ClassName* As##ShortName() const; \ |
| 1442 inline ClassName* As##ShortName(); |
| 1443 FOR_EACH_COMPUTATION(DECLARE_PREDICATE) |
| 1444 #undef DECLARE_PREDICATE |
| 1445 |
| 1446 protected: |
| 1447 // Fetch deopt id without checking if this computation can deoptimize. |
| 1448 intptr_t GetDeoptId() const { |
| 1449 return deopt_id_; |
| 1450 } |
| 1451 |
| 1452 private: |
| 1453 friend class BranchInstr; |
| 1454 |
| 1455 intptr_t deopt_id_; |
| 1456 LocationSummary* locs_; |
| 1457 |
| 1458 DISALLOW_COPY_AND_ASSIGN(Computation); |
| 1459 }; |
| 1460 |
| 1461 |
| 1462 // Inlined functions from class BindInstr that forward to their computation. |
| 1463 inline intptr_t BindInstr::ArgumentCount() const { |
| 1464 return computation()->ArgumentCount(); |
| 1465 } |
| 1466 |
| 1467 |
| 1468 inline intptr_t BindInstr::InputCount() const { |
| 1469 return computation()->InputCount(); |
| 1470 } |
| 1471 |
| 1472 |
| 1473 inline Value* BindInstr::InputAt(intptr_t i) const { |
| 1474 return computation()->InputAt(i); |
| 1475 } |
| 1476 |
| 1477 |
| 1478 inline void BindInstr::SetInputAt(intptr_t i, Value* value) { |
| 1479 computation()->SetInputAt(i, value); |
| 1480 } |
| 1481 |
| 1482 inline bool BindInstr::CanDeoptimize() const { |
| 1483 return computation()->CanDeoptimize(); |
| 1484 } |
| 1485 |
| 1486 |
| 1487 inline intptr_t BindInstr::Hashcode() const { |
| 1488 return computation()->Hashcode(); |
| 1489 } |
| 1490 |
| 1491 |
| 1492 inline bool BindInstr::Equals(BindInstr* other) const { |
| 1493 return computation()->Equals(other->computation()); |
| 1494 } |
| 1495 |
| 1496 |
| 1497 inline LocationSummary* BindInstr::locs() { |
| 1498 return computation()->locs(); |
| 1499 } |
| 1500 |
| 1501 |
| 1502 inline Representation BindInstr::RequiredInputRepresentation(intptr_t i) const { |
| 1503 return computation()->RequiredInputRepresentation(i); |
| 1504 } |
| 1505 |
| 1506 |
| 1507 inline Representation BindInstr::representation() const { |
| 1508 return computation()->representation(); |
| 1509 } |
| 1510 |
| 1511 |
| 1512 inline intptr_t BindInstr::DeoptimizationTarget() const { |
| 1513 return computation()->DeoptimizationTarget(); |
| 1514 } |
| 1515 |
| 1516 |
| 1517 template<intptr_t N> |
| 1518 class TemplateComputation : public Computation { |
| 1519 public: |
| 1520 virtual intptr_t InputCount() const { return N; } |
| 1521 virtual Value* InputAt(intptr_t i) const { return inputs_[i]; } |
| 1522 virtual void SetInputAt(intptr_t i, Value* value) { |
| 1523 ASSERT(value != NULL); |
| 1524 inputs_[i] = value; |
| 1525 } |
| 1526 |
1406 protected: | 1527 protected: |
1407 EmbeddedArray<Value*, N> inputs_; | 1528 EmbeddedArray<Value*, N> inputs_; |
1408 | |
1409 private: | |
1410 friend class BranchInstr; | |
1411 | |
1412 LocationSummary* locs_; | |
1413 }; | 1529 }; |
1414 | 1530 |
1415 | 1531 |
1416 class ConstantInstr : public TemplateDefinition<0> { | 1532 // Functions defined in all concrete computation classes. |
| 1533 #define DECLARE_COMPUTATION(ShortName) \ |
| 1534 virtual void Accept(FlowGraphVisitor* visitor, BindInstr* instr); \ |
| 1535 virtual ComputationKind computation_kind() const { \ |
| 1536 return Computation::k##ShortName; \ |
| 1537 } \ |
| 1538 virtual intptr_t ArgumentCount() const { return 0; } \ |
| 1539 virtual const char* DebugName() const { return #ShortName; } \ |
| 1540 virtual RawAbstractType* CompileType() const; \ |
| 1541 virtual LocationSummary* MakeLocationSummary() const; \ |
| 1542 virtual void EmitNativeCode(FlowGraphCompiler* compiler); |
| 1543 |
| 1544 |
| 1545 // Function defined in all call computation classes. |
| 1546 #define DECLARE_CALL_COMPUTATION(ShortName) \ |
| 1547 virtual void Accept(FlowGraphVisitor* visitor, BindInstr* instr); \ |
| 1548 virtual ComputationKind computation_kind() const { \ |
| 1549 return Computation::k##ShortName; \ |
| 1550 } \ |
| 1551 virtual const char* DebugName() const { return #ShortName; } \ |
| 1552 virtual RawAbstractType* CompileType() const; \ |
| 1553 virtual LocationSummary* MakeLocationSummary() const; \ |
| 1554 virtual void EmitNativeCode(FlowGraphCompiler* compiler); |
| 1555 |
| 1556 |
| 1557 class ConstantComp : public TemplateComputation<0> { |
1417 public: | 1558 public: |
1418 explicit ConstantInstr(const Object& value) : value_(value) { } | 1559 explicit ConstantComp(const Object& value) : value_(value) { } |
1419 | 1560 |
1420 DECLARE_INSTRUCTION(Constant) | 1561 DECLARE_COMPUTATION(Constant) |
1421 virtual RawAbstractType* CompileType() const; | |
1422 | 1562 |
1423 const Object& value() const { return value_; } | 1563 const Object& value() const { return value_; } |
1424 | 1564 |
1425 virtual void PrintOperandsTo(BufferFormatter* f) const; | 1565 virtual void PrintOperandsTo(BufferFormatter* f) const; |
1426 | 1566 |
1427 virtual bool CanDeoptimize() const { return false; } | 1567 virtual bool CanDeoptimize() const { return false; } |
1428 | 1568 |
1429 virtual intptr_t ResultCid() const; | 1569 virtual intptr_t ResultCid() const; |
1430 | 1570 |
1431 virtual bool AttributesEqual(Definition* other) const; | 1571 virtual bool AttributesEqual(Computation* other) const; |
1432 | 1572 |
1433 private: | 1573 private: |
1434 const Object& value_; | 1574 const Object& value_; |
1435 | 1575 |
1436 DISALLOW_COPY_AND_ASSIGN(ConstantInstr); | 1576 DISALLOW_COPY_AND_ASSIGN(ConstantComp); |
1437 }; | 1577 }; |
1438 | 1578 |
1439 | 1579 |
1440 class AssertAssignableInstr : public TemplateDefinition<3> { | 1580 class AssertAssignableComp : public TemplateComputation<3> { |
1441 public: | 1581 public: |
1442 AssertAssignableInstr(intptr_t token_pos, | 1582 AssertAssignableComp(intptr_t token_pos, |
1443 Value* value, | 1583 Value* value, |
1444 Value* instantiator, | 1584 Value* instantiator, |
1445 Value* instantiator_type_arguments, | 1585 Value* instantiator_type_arguments, |
1446 const AbstractType& dst_type, | 1586 const AbstractType& dst_type, |
1447 const String& dst_name) | 1587 const String& dst_name) |
1448 : token_pos_(token_pos), | 1588 : token_pos_(token_pos), |
1449 dst_type_(dst_type), | 1589 dst_type_(dst_type), |
1450 dst_name_(dst_name), | 1590 dst_name_(dst_name), |
1451 is_eliminated_(false) { | 1591 is_eliminated_(false) { |
1452 ASSERT(value != NULL); | 1592 ASSERT(value != NULL); |
1453 ASSERT(instantiator != NULL); | 1593 ASSERT(instantiator != NULL); |
1454 ASSERT(instantiator_type_arguments != NULL); | 1594 ASSERT(instantiator_type_arguments != NULL); |
1455 ASSERT(!dst_type.IsNull()); | 1595 ASSERT(!dst_type.IsNull()); |
1456 ASSERT(!dst_name.IsNull()); | 1596 ASSERT(!dst_name.IsNull()); |
1457 inputs_[0] = value; | 1597 inputs_[0] = value; |
1458 inputs_[1] = instantiator; | 1598 inputs_[1] = instantiator; |
1459 inputs_[2] = instantiator_type_arguments; | 1599 inputs_[2] = instantiator_type_arguments; |
1460 } | 1600 } |
1461 | 1601 |
1462 DECLARE_INSTRUCTION(AssertAssignable) | 1602 DECLARE_COMPUTATION(AssertAssignable) |
1463 virtual RawAbstractType* CompileType() const; | |
1464 | 1603 |
1465 Value* value() const { return inputs_[0]; } | 1604 Value* value() const { return inputs_[0]; } |
1466 Value* instantiator() const { return inputs_[1]; } | 1605 Value* instantiator() const { return inputs_[1]; } |
1467 Value* instantiator_type_arguments() const { return inputs_[2]; } | 1606 Value* instantiator_type_arguments() const { return inputs_[2]; } |
1468 | 1607 |
1469 intptr_t token_pos() const { return token_pos_; } | 1608 intptr_t token_pos() const { return token_pos_; } |
1470 const AbstractType& dst_type() const { return dst_type_; } | 1609 const AbstractType& dst_type() const { return dst_type_; } |
1471 const String& dst_name() const { return dst_name_; } | 1610 const String& dst_name() const { return dst_name_; } |
1472 | 1611 |
1473 bool is_eliminated() const { | 1612 bool is_eliminated() const { |
1474 return is_eliminated_; | 1613 return is_eliminated_; |
1475 } | 1614 } |
1476 void eliminate() { | 1615 void eliminate() { |
1477 ASSERT(!is_eliminated_); | 1616 ASSERT(!is_eliminated_); |
1478 is_eliminated_ = true; | 1617 is_eliminated_ = true; |
1479 } | 1618 } |
1480 | 1619 |
1481 virtual void PrintOperandsTo(BufferFormatter* f) const; | 1620 virtual void PrintOperandsTo(BufferFormatter* f) const; |
1482 | 1621 |
1483 virtual bool CanDeoptimize() const { return false; } | 1622 virtual bool CanDeoptimize() const { return false; } |
1484 virtual intptr_t ResultCid() const { return kDynamicCid; } | 1623 virtual intptr_t ResultCid() const { return kDynamicCid; } |
1485 | 1624 |
1486 private: | 1625 private: |
1487 const intptr_t token_pos_; | 1626 const intptr_t token_pos_; |
1488 const AbstractType& dst_type_; | 1627 const AbstractType& dst_type_; |
1489 const String& dst_name_; | 1628 const String& dst_name_; |
1490 bool is_eliminated_; | 1629 bool is_eliminated_; |
1491 | 1630 |
1492 DISALLOW_COPY_AND_ASSIGN(AssertAssignableInstr); | 1631 DISALLOW_COPY_AND_ASSIGN(AssertAssignableComp); |
1493 }; | 1632 }; |
1494 | 1633 |
1495 | 1634 |
1496 class AssertBooleanInstr : public TemplateDefinition<1> { | 1635 class AssertBooleanComp : public TemplateComputation<1> { |
1497 public: | 1636 public: |
1498 AssertBooleanInstr(intptr_t token_pos, Value* value) | 1637 AssertBooleanComp(intptr_t token_pos, |
| 1638 Value* value) |
1499 : token_pos_(token_pos), | 1639 : token_pos_(token_pos), |
1500 is_eliminated_(false) { | 1640 is_eliminated_(false) { |
1501 ASSERT(value != NULL); | 1641 ASSERT(value != NULL); |
1502 inputs_[0] = value; | 1642 inputs_[0] = value; |
1503 } | 1643 } |
1504 | 1644 |
1505 DECLARE_INSTRUCTION(AssertBoolean) | 1645 DECLARE_COMPUTATION(AssertBoolean) |
1506 virtual RawAbstractType* CompileType() const; | |
1507 | 1646 |
1508 intptr_t token_pos() const { return token_pos_; } | 1647 intptr_t token_pos() const { return token_pos_; } |
1509 Value* value() const { return inputs_[0]; } | 1648 Value* value() const { return inputs_[0]; } |
1510 | 1649 |
1511 bool is_eliminated() const { | 1650 bool is_eliminated() const { |
1512 return is_eliminated_; | 1651 return is_eliminated_; |
1513 } | 1652 } |
1514 void eliminate() { | 1653 void eliminate() { |
1515 ASSERT(!is_eliminated_); | 1654 ASSERT(!is_eliminated_); |
1516 is_eliminated_ = true; | 1655 is_eliminated_ = true; |
1517 } | 1656 } |
1518 | 1657 |
1519 virtual void PrintOperandsTo(BufferFormatter* f) const; | 1658 virtual void PrintOperandsTo(BufferFormatter* f) const; |
1520 | 1659 |
1521 virtual bool CanDeoptimize() const { return false; } | 1660 virtual bool CanDeoptimize() const { return false; } |
1522 virtual intptr_t ResultCid() const { return kBoolCid; } | 1661 virtual intptr_t ResultCid() const { return kBoolCid; } |
1523 | 1662 |
1524 private: | 1663 private: |
1525 const intptr_t token_pos_; | 1664 const intptr_t token_pos_; |
1526 bool is_eliminated_; | 1665 bool is_eliminated_; |
1527 | 1666 |
1528 DISALLOW_COPY_AND_ASSIGN(AssertBooleanInstr); | 1667 DISALLOW_COPY_AND_ASSIGN(AssertBooleanComp); |
1529 }; | 1668 }; |
1530 | 1669 |
1531 | 1670 |
1532 class ArgumentDefinitionTestInstr : public TemplateDefinition<1> { | 1671 class ArgumentDefinitionTestComp : public TemplateComputation<1> { |
1533 public: | 1672 public: |
1534 ArgumentDefinitionTestInstr(ArgumentDefinitionTestNode* node, | 1673 ArgumentDefinitionTestComp(ArgumentDefinitionTestNode* node, |
1535 Value* saved_arguments_descriptor) | 1674 Value* saved_arguments_descriptor) |
1536 : ast_node_(*node) { | 1675 : ast_node_(*node) { |
1537 ASSERT(saved_arguments_descriptor != NULL); | 1676 ASSERT(saved_arguments_descriptor != NULL); |
1538 inputs_[0] = saved_arguments_descriptor; | 1677 inputs_[0] = saved_arguments_descriptor; |
1539 } | 1678 } |
1540 | 1679 |
1541 DECLARE_INSTRUCTION(ArgumentDefinitionTest) | 1680 DECLARE_COMPUTATION(ArgumentDefinitionTest) |
1542 virtual RawAbstractType* CompileType() const; | |
1543 | 1681 |
1544 intptr_t token_pos() const { return ast_node_.token_pos(); } | 1682 intptr_t token_pos() const { return ast_node_.token_pos(); } |
1545 intptr_t formal_parameter_index() const { | 1683 intptr_t formal_parameter_index() const { |
1546 return ast_node_.formal_parameter_index(); | 1684 return ast_node_.formal_parameter_index(); |
1547 } | 1685 } |
1548 const String& formal_parameter_name() const { | 1686 const String& formal_parameter_name() const { |
1549 return ast_node_.formal_parameter_name(); | 1687 return ast_node_.formal_parameter_name(); |
1550 } | 1688 } |
1551 Value* saved_arguments_descriptor() const { return inputs_[0]; } | 1689 Value* saved_arguments_descriptor() const { return inputs_[0]; } |
1552 | 1690 |
1553 virtual void PrintOperandsTo(BufferFormatter* f) const; | 1691 virtual void PrintOperandsTo(BufferFormatter* f) const; |
1554 | 1692 |
1555 virtual bool CanDeoptimize() const { return false; } | 1693 virtual bool CanDeoptimize() const { return false; } |
1556 virtual intptr_t ResultCid() const { return kBoolCid; } | 1694 virtual intptr_t ResultCid() const { return kBoolCid; } |
1557 | 1695 |
1558 private: | 1696 private: |
1559 const ArgumentDefinitionTestNode& ast_node_; | 1697 const ArgumentDefinitionTestNode& ast_node_; |
1560 | 1698 |
1561 DISALLOW_COPY_AND_ASSIGN(ArgumentDefinitionTestInstr); | 1699 DISALLOW_COPY_AND_ASSIGN(ArgumentDefinitionTestComp); |
1562 }; | 1700 }; |
1563 | 1701 |
1564 | 1702 |
1565 // Denotes the current context, normally held in a register. This is | 1703 // Denotes the current context, normally held in a register. This is |
1566 // a computation, not a value, because it's mutable. | 1704 // a computation, not a value, because it's mutable. |
1567 class CurrentContextInstr : public TemplateDefinition<0> { | 1705 class CurrentContextComp : public TemplateComputation<0> { |
1568 public: | 1706 public: |
1569 CurrentContextInstr() { } | 1707 CurrentContextComp() { } |
1570 | 1708 |
1571 DECLARE_INSTRUCTION(CurrentContext) | 1709 DECLARE_COMPUTATION(CurrentContext) |
1572 virtual RawAbstractType* CompileType() const; | |
1573 | 1710 |
1574 virtual bool CanDeoptimize() const { return false; } | 1711 virtual bool CanDeoptimize() const { return false; } |
1575 virtual intptr_t ResultCid() const { return kDynamicCid; } | 1712 virtual intptr_t ResultCid() const { return kDynamicCid; } |
1576 | 1713 |
1577 private: | 1714 private: |
1578 DISALLOW_COPY_AND_ASSIGN(CurrentContextInstr); | 1715 DISALLOW_COPY_AND_ASSIGN(CurrentContextComp); |
1579 }; | 1716 }; |
1580 | 1717 |
1581 | 1718 |
1582 class StoreContextInstr : public TemplateDefinition<1> { | 1719 class StoreContextComp : public TemplateComputation<1> { |
1583 public: | 1720 public: |
1584 explicit StoreContextInstr(Value* value) { | 1721 explicit StoreContextComp(Value* value) { |
1585 ASSERT(value != NULL); | 1722 ASSERT(value != NULL); |
1586 inputs_[0] = value; | 1723 inputs_[0] = value; |
1587 } | 1724 } |
1588 | 1725 |
1589 DECLARE_INSTRUCTION(StoreContext); | 1726 DECLARE_COMPUTATION(StoreContext); |
1590 virtual RawAbstractType* CompileType() const; | |
1591 | 1727 |
1592 Value* value() const { return inputs_[0]; } | 1728 Value* value() const { return inputs_[0]; } |
1593 | 1729 |
1594 virtual bool CanDeoptimize() const { return false; } | 1730 virtual bool CanDeoptimize() const { return false; } |
1595 virtual intptr_t ResultCid() const { return kIllegalCid; } | 1731 virtual intptr_t ResultCid() const { return kIllegalCid; } |
1596 | 1732 |
1597 private: | 1733 private: |
1598 DISALLOW_COPY_AND_ASSIGN(StoreContextInstr); | 1734 DISALLOW_COPY_AND_ASSIGN(StoreContextComp); |
1599 }; | 1735 }; |
1600 | 1736 |
1601 | 1737 |
1602 class ClosureCallInstr : public TemplateDefinition<0> { | 1738 class ClosureCallComp : public TemplateComputation<0> { |
1603 public: | 1739 public: |
1604 ClosureCallInstr(ClosureCallNode* node, | 1740 ClosureCallComp(ClosureCallNode* node, |
1605 ZoneGrowableArray<PushArgumentInstr*>* arguments) | 1741 ZoneGrowableArray<PushArgumentInstr*>* arguments) |
1606 : ast_node_(*node), | 1742 : ast_node_(*node), |
1607 arguments_(arguments) { } | 1743 arguments_(arguments) { } |
1608 | 1744 |
1609 DECLARE_INSTRUCTION(ClosureCall) | 1745 DECLARE_CALL_COMPUTATION(ClosureCall) |
1610 virtual RawAbstractType* CompileType() const; | |
1611 | 1746 |
1612 const Array& argument_names() const { return ast_node_.arguments()->names(); } | 1747 const Array& argument_names() const { return ast_node_.arguments()->names(); } |
1613 intptr_t token_pos() const { return ast_node_.token_pos(); } | 1748 intptr_t token_pos() const { return ast_node_.token_pos(); } |
1614 | 1749 |
1615 virtual intptr_t ArgumentCount() const { return arguments_->length(); } | 1750 virtual intptr_t ArgumentCount() const { return arguments_->length(); } |
1616 PushArgumentInstr* ArgumentAt(intptr_t index) const { | 1751 PushArgumentInstr* ArgumentAt(intptr_t index) const { |
1617 return (*arguments_)[index]; | 1752 return (*arguments_)[index]; |
1618 } | 1753 } |
1619 | 1754 |
1620 virtual void PrintOperandsTo(BufferFormatter* f) const; | 1755 virtual void PrintOperandsTo(BufferFormatter* f) const; |
1621 | 1756 |
1622 virtual bool CanDeoptimize() const { return true; } | 1757 virtual bool CanDeoptimize() const { return true; } |
1623 virtual intptr_t ResultCid() const { return kDynamicCid; } | 1758 virtual intptr_t ResultCid() const { return kDynamicCid; } |
1624 | 1759 |
1625 private: | 1760 private: |
1626 const ClosureCallNode& ast_node_; | 1761 const ClosureCallNode& ast_node_; |
1627 ZoneGrowableArray<PushArgumentInstr*>* arguments_; | 1762 ZoneGrowableArray<PushArgumentInstr*>* arguments_; |
1628 | 1763 |
1629 DISALLOW_COPY_AND_ASSIGN(ClosureCallInstr); | 1764 DISALLOW_COPY_AND_ASSIGN(ClosureCallComp); |
1630 }; | 1765 }; |
1631 | 1766 |
1632 | 1767 |
1633 class InstanceCallInstr : public TemplateDefinition<0> { | 1768 class InstanceCallComp : public TemplateComputation<0> { |
1634 public: | 1769 public: |
1635 InstanceCallInstr(intptr_t token_pos, | 1770 InstanceCallComp(intptr_t token_pos, |
1636 const String& function_name, | 1771 const String& function_name, |
1637 Token::Kind token_kind, | 1772 Token::Kind token_kind, |
1638 ZoneGrowableArray<PushArgumentInstr*>* arguments, | 1773 ZoneGrowableArray<PushArgumentInstr*>* arguments, |
1639 const Array& argument_names, | 1774 const Array& argument_names, |
1640 intptr_t checked_argument_count) | 1775 intptr_t checked_argument_count) |
1641 : ic_data_(Isolate::Current()->GetICDataForDeoptId(deopt_id())), | 1776 : ic_data_(Isolate::Current()->GetICDataForDeoptId(deopt_id())), |
1642 token_pos_(token_pos), | 1777 token_pos_(token_pos), |
1643 function_name_(function_name), | 1778 function_name_(function_name), |
1644 token_kind_(token_kind), | 1779 token_kind_(token_kind), |
1645 arguments_(arguments), | 1780 arguments_(arguments), |
1646 argument_names_(argument_names), | 1781 argument_names_(argument_names), |
1647 checked_argument_count_(checked_argument_count) { | 1782 checked_argument_count_(checked_argument_count) { |
1648 ASSERT(function_name.IsZoneHandle()); | 1783 ASSERT(function_name.IsZoneHandle()); |
1649 ASSERT(!arguments->is_empty()); | 1784 ASSERT(!arguments->is_empty()); |
1650 ASSERT(argument_names.IsZoneHandle()); | 1785 ASSERT(argument_names.IsZoneHandle()); |
1651 ASSERT(Token::IsBinaryToken(token_kind) || | 1786 ASSERT(Token::IsBinaryToken(token_kind) || |
1652 Token::IsUnaryToken(token_kind) || | 1787 Token::IsUnaryToken(token_kind) || |
1653 Token::IsIndexOperator(token_kind) || | 1788 Token::IsIndexOperator(token_kind) || |
1654 token_kind == Token::kGET || | 1789 token_kind == Token::kGET || |
1655 token_kind == Token::kSET || | 1790 token_kind == Token::kSET || |
1656 token_kind == Token::kILLEGAL); | 1791 token_kind == Token::kILLEGAL); |
1657 } | 1792 } |
1658 | 1793 |
1659 DECLARE_INSTRUCTION(InstanceCall) | 1794 DECLARE_CALL_COMPUTATION(InstanceCall) |
1660 virtual RawAbstractType* CompileType() const; | |
1661 | 1795 |
1662 const ICData* ic_data() const { return ic_data_; } | 1796 const ICData* ic_data() const { return ic_data_; } |
1663 bool HasICData() const { | 1797 bool HasICData() const { |
1664 return (ic_data() != NULL) && !ic_data()->IsNull(); | 1798 return (ic_data() != NULL) && !ic_data()->IsNull(); |
1665 } | 1799 } |
1666 | 1800 |
1667 intptr_t token_pos() const { return token_pos_; } | 1801 intptr_t token_pos() const { return token_pos_; } |
1668 const String& function_name() const { return function_name_; } | 1802 const String& function_name() const { return function_name_; } |
1669 Token::Kind token_kind() const { return token_kind_; } | 1803 Token::Kind token_kind() const { return token_kind_; } |
1670 virtual intptr_t ArgumentCount() const { return arguments_->length(); } | 1804 virtual intptr_t ArgumentCount() const { return arguments_->length(); } |
(...skipping 10 matching lines...) Expand all Loading... |
1681 | 1815 |
1682 private: | 1816 private: |
1683 const ICData* ic_data_; | 1817 const ICData* ic_data_; |
1684 const intptr_t token_pos_; | 1818 const intptr_t token_pos_; |
1685 const String& function_name_; | 1819 const String& function_name_; |
1686 const Token::Kind token_kind_; // Binary op, unary op, kGET or kILLEGAL. | 1820 const Token::Kind token_kind_; // Binary op, unary op, kGET or kILLEGAL. |
1687 ZoneGrowableArray<PushArgumentInstr*>* const arguments_; | 1821 ZoneGrowableArray<PushArgumentInstr*>* const arguments_; |
1688 const Array& argument_names_; | 1822 const Array& argument_names_; |
1689 const intptr_t checked_argument_count_; | 1823 const intptr_t checked_argument_count_; |
1690 | 1824 |
1691 DISALLOW_COPY_AND_ASSIGN(InstanceCallInstr); | 1825 DISALLOW_COPY_AND_ASSIGN(InstanceCallComp); |
1692 }; | 1826 }; |
1693 | 1827 |
1694 | 1828 |
1695 class PolymorphicInstanceCallInstr : public TemplateDefinition<0> { | 1829 class PolymorphicInstanceCallComp : public TemplateComputation<0> { |
1696 public: | 1830 public: |
1697 PolymorphicInstanceCallInstr(InstanceCallInstr* instance_call, | 1831 PolymorphicInstanceCallComp(InstanceCallComp* comp, |
1698 const ICData& ic_data, | 1832 const ICData& ic_data, |
1699 bool with_checks) | 1833 bool with_checks) |
1700 : instance_call_(instance_call), | 1834 : instance_call_(comp), ic_data_(ic_data), with_checks_(with_checks) { |
1701 ic_data_(ic_data), | |
1702 with_checks_(with_checks) { | |
1703 ASSERT(instance_call_ != NULL); | 1835 ASSERT(instance_call_ != NULL); |
1704 } | 1836 } |
1705 | 1837 |
1706 InstanceCallInstr* instance_call() const { return instance_call_; } | 1838 InstanceCallComp* instance_call() const { return instance_call_; } |
1707 bool with_checks() const { return with_checks_; } | 1839 bool with_checks() const { return with_checks_; } |
1708 | 1840 |
| 1841 void PrintTo(BufferFormatter* f) const; |
| 1842 |
1709 virtual intptr_t ArgumentCount() const { | 1843 virtual intptr_t ArgumentCount() const { |
1710 return instance_call()->ArgumentCount(); | 1844 return instance_call()->ArgumentCount(); |
1711 } | 1845 } |
1712 | 1846 |
1713 DECLARE_INSTRUCTION(PolymorphicInstanceCall) | 1847 DECLARE_CALL_COMPUTATION(PolymorphicInstanceCall) |
1714 virtual RawAbstractType* CompileType() const; | |
1715 | 1848 |
1716 const ICData& ic_data() const { return ic_data_; } | 1849 const ICData& ic_data() const { return ic_data_; } |
1717 | 1850 |
1718 virtual bool CanDeoptimize() const { return true; } | 1851 virtual bool CanDeoptimize() const { return true; } |
1719 virtual intptr_t ResultCid() const { return kDynamicCid; } | 1852 virtual intptr_t ResultCid() const { return kDynamicCid; } |
1720 | 1853 |
1721 virtual void PrintTo(BufferFormatter* f) const; | |
1722 | |
1723 private: | 1854 private: |
1724 InstanceCallInstr* instance_call_; | 1855 InstanceCallComp* instance_call_; |
1725 const ICData& ic_data_; | 1856 const ICData& ic_data_; |
1726 const bool with_checks_; | 1857 const bool with_checks_; |
1727 | 1858 |
1728 DISALLOW_COPY_AND_ASSIGN(PolymorphicInstanceCallInstr); | 1859 DISALLOW_COPY_AND_ASSIGN(PolymorphicInstanceCallComp); |
1729 }; | 1860 }; |
1730 | 1861 |
1731 | 1862 |
1732 class ComparisonInstr : public TemplateDefinition<2> { | 1863 class ComparisonComp : public TemplateComputation<2> { |
1733 public: | 1864 public: |
1734 ComparisonInstr(Token::Kind kind, Value* left, Value* right) : kind_(kind) { | 1865 ComparisonComp(Token::Kind kind, Value* left, Value* right) : kind_(kind) { |
1735 ASSERT(left != NULL); | 1866 ASSERT(left != NULL); |
1736 ASSERT(right != NULL); | 1867 ASSERT(right != NULL); |
1737 inputs_[0] = left; | 1868 inputs_[0] = left; |
1738 inputs_[1] = right; | 1869 inputs_[1] = right; |
1739 } | 1870 } |
1740 | 1871 |
1741 Value* left() const { return inputs_[0]; } | 1872 Value* left() const { return inputs_[0]; } |
1742 Value* right() const { return inputs_[1]; } | 1873 Value* right() const { return inputs_[1]; } |
1743 | 1874 |
1744 virtual ComparisonInstr* AsComparison() { return this; } | 1875 virtual ComparisonComp* AsComparison() { return this; } |
1745 | 1876 |
1746 Token::Kind kind() const { return kind_; } | 1877 Token::Kind kind() const { return kind_; } |
1747 | 1878 |
1748 virtual void EmitBranchCode(FlowGraphCompiler* compiler, | |
1749 BranchInstr* branch) = 0; | |
1750 | |
1751 private: | 1879 private: |
1752 Token::Kind kind_; | 1880 Token::Kind kind_; |
1753 }; | 1881 }; |
1754 | 1882 |
1755 | 1883 |
1756 // Inlined functions from class BranchInstr that forward to their comparison. | 1884 // Inlined functions from class BranchInstr that forward to their comparison. |
1757 inline intptr_t BranchInstr::ArgumentCount() const { | 1885 inline intptr_t BranchInstr::ArgumentCount() const { |
1758 return comparison()->ArgumentCount(); | 1886 return computation()->ArgumentCount(); |
1759 } | 1887 } |
1760 | 1888 |
1761 | 1889 |
1762 inline intptr_t BranchInstr::InputCount() const { | 1890 inline intptr_t BranchInstr::InputCount() const { |
1763 return comparison()->InputCount(); | 1891 return computation()->InputCount(); |
1764 } | 1892 } |
1765 | 1893 |
1766 | 1894 |
1767 inline Value* BranchInstr::InputAt(intptr_t i) const { | 1895 inline Value* BranchInstr::InputAt(intptr_t i) const { |
1768 return comparison()->InputAt(i); | 1896 return computation()->InputAt(i); |
1769 } | 1897 } |
1770 | 1898 |
1771 | 1899 |
1772 inline void BranchInstr::SetInputAt(intptr_t i, Value* value) { | 1900 inline void BranchInstr::SetInputAt(intptr_t i, Value* value) { |
1773 comparison()->SetInputAt(i, value); | 1901 computation()->SetInputAt(i, value); |
1774 } | 1902 } |
1775 | 1903 |
1776 | 1904 |
1777 inline bool BranchInstr::CanDeoptimize() const { | 1905 inline bool BranchInstr::CanDeoptimize() const { |
1778 return comparison()->CanDeoptimize(); | 1906 return computation()->CanDeoptimize(); |
1779 } | 1907 } |
1780 | 1908 |
1781 | 1909 |
1782 inline LocationSummary* BranchInstr::locs() { | 1910 inline LocationSummary* BranchInstr::locs() { |
1783 if (comparison()->locs_ == NULL) { | 1911 if (computation_->locs_ == NULL) { |
1784 LocationSummary* summary = comparison()->MakeLocationSummary(); | 1912 LocationSummary* summary = computation_->MakeLocationSummary(); |
1785 // Branches don't produce a result. | 1913 // Branches don't produce a result. |
1786 summary->set_out(Location::NoLocation()); | 1914 summary->set_out(Location::NoLocation()); |
1787 comparison()->locs_ = summary; | 1915 computation_->locs_ = summary; |
1788 } | 1916 } |
1789 return comparison()->locs_; | 1917 return computation_->locs_; |
1790 } | 1918 } |
1791 | 1919 |
1792 | 1920 |
1793 inline intptr_t BranchInstr::DeoptimizationTarget() const { | 1921 inline intptr_t BranchInstr::DeoptimizationTarget() const { |
1794 return comparison()->DeoptimizationTarget(); | 1922 return computation_->DeoptimizationTarget(); |
1795 } | 1923 } |
1796 | 1924 |
1797 | 1925 |
1798 inline Representation BranchInstr::RequiredInputRepresentation( | 1926 inline Representation BranchInstr::RequiredInputRepresentation( |
1799 intptr_t i) const { | 1927 intptr_t i) const { |
1800 return comparison()->RequiredInputRepresentation(i); | 1928 return computation()->RequiredInputRepresentation(i); |
1801 } | 1929 } |
1802 | 1930 |
1803 | 1931 |
1804 class StrictCompareInstr : public ComparisonInstr { | 1932 class StrictCompareComp : public ComparisonComp { |
1805 public: | 1933 public: |
1806 StrictCompareInstr(Token::Kind kind, Value* left, Value* right) | 1934 StrictCompareComp(Token::Kind kind, Value* left, Value* right) |
1807 : ComparisonInstr(kind, left, right) { | 1935 : ComparisonComp(kind, left, right) { |
1808 ASSERT((kind == Token::kEQ_STRICT) || (kind == Token::kNE_STRICT)); | 1936 ASSERT((kind == Token::kEQ_STRICT) || (kind == Token::kNE_STRICT)); |
1809 } | 1937 } |
1810 | 1938 |
1811 DECLARE_INSTRUCTION(StrictCompare) | 1939 DECLARE_COMPUTATION(StrictCompare) |
1812 virtual RawAbstractType* CompileType() const; | |
1813 | 1940 |
1814 virtual void PrintOperandsTo(BufferFormatter* f) const; | 1941 virtual void PrintOperandsTo(BufferFormatter* f) const; |
1815 | 1942 |
1816 virtual bool CanDeoptimize() const { return false; } | 1943 virtual bool CanDeoptimize() const { return false; } |
1817 | 1944 |
1818 virtual Definition* Canonicalize(); | 1945 virtual Definition* TryReplace(BindInstr* instr) const; |
1819 | 1946 |
1820 virtual intptr_t ResultCid() const { return kBoolCid; } | 1947 virtual intptr_t ResultCid() const { return kBoolCid; } |
1821 | 1948 |
1822 virtual void EmitBranchCode(FlowGraphCompiler* compiler, | 1949 virtual void EmitBranchCode(FlowGraphCompiler* compiler, |
1823 BranchInstr* branch); | 1950 BranchInstr* branch); |
1824 | 1951 |
1825 private: | 1952 private: |
1826 DISALLOW_COPY_AND_ASSIGN(StrictCompareInstr); | 1953 DISALLOW_COPY_AND_ASSIGN(StrictCompareComp); |
1827 }; | 1954 }; |
1828 | 1955 |
1829 | 1956 |
1830 class EqualityCompareInstr : public ComparisonInstr { | 1957 class EqualityCompareComp : public ComparisonComp { |
1831 public: | 1958 public: |
1832 EqualityCompareInstr(intptr_t token_pos, | 1959 EqualityCompareComp(intptr_t token_pos, |
1833 Token::Kind kind, | 1960 Token::Kind kind, |
1834 Value* left, | 1961 Value* left, |
1835 Value* right) | 1962 Value* right) |
1836 : ComparisonInstr(kind, left, right), | 1963 : ComparisonComp(kind, left, right), |
1837 ic_data_(Isolate::Current()->GetICDataForDeoptId(deopt_id())), | 1964 ic_data_(Isolate::Current()->GetICDataForDeoptId(deopt_id())), |
1838 token_pos_(token_pos), | 1965 token_pos_(token_pos), |
1839 receiver_class_id_(kIllegalCid) { | 1966 receiver_class_id_(kIllegalCid) { |
1840 ASSERT((kind == Token::kEQ) || (kind == Token::kNE)); | 1967 ASSERT((kind == Token::kEQ) || (kind == Token::kNE)); |
1841 } | 1968 } |
1842 | 1969 |
1843 DECLARE_INSTRUCTION(EqualityCompare) | 1970 DECLARE_COMPUTATION(EqualityCompare) |
1844 virtual RawAbstractType* CompileType() const; | |
1845 | 1971 |
1846 const ICData* ic_data() const { return ic_data_; } | 1972 const ICData* ic_data() const { return ic_data_; } |
1847 bool HasICData() const { | 1973 bool HasICData() const { |
1848 return (ic_data() != NULL) && !ic_data()->IsNull(); | 1974 return (ic_data() != NULL) && !ic_data()->IsNull(); |
1849 } | 1975 } |
1850 | 1976 |
1851 intptr_t token_pos() const { return token_pos_; } | 1977 intptr_t token_pos() const { return token_pos_; } |
1852 | 1978 |
1853 // Receiver class id is computed from collected ICData. | 1979 // Receiver class id is computed from collected ICData. |
1854 void set_receiver_class_id(intptr_t value) { receiver_class_id_ = value; } | 1980 void set_receiver_class_id(intptr_t value) { receiver_class_id_ = value; } |
(...skipping 18 matching lines...) Expand all Loading... |
1873 virtual Representation RequiredInputRepresentation(intptr_t idx) const { | 1999 virtual Representation RequiredInputRepresentation(intptr_t idx) const { |
1874 ASSERT((idx == 0) || (idx == 1)); | 2000 ASSERT((idx == 0) || (idx == 1)); |
1875 return (receiver_class_id() == kDoubleCid) ? kUnboxedDouble : kTagged; | 2001 return (receiver_class_id() == kDoubleCid) ? kUnboxedDouble : kTagged; |
1876 } | 2002 } |
1877 | 2003 |
1878 private: | 2004 private: |
1879 const ICData* ic_data_; | 2005 const ICData* ic_data_; |
1880 const intptr_t token_pos_; | 2006 const intptr_t token_pos_; |
1881 intptr_t receiver_class_id_; // Set by optimizer. | 2007 intptr_t receiver_class_id_; // Set by optimizer. |
1882 | 2008 |
1883 DISALLOW_COPY_AND_ASSIGN(EqualityCompareInstr); | 2009 DISALLOW_COPY_AND_ASSIGN(EqualityCompareComp); |
1884 }; | 2010 }; |
1885 | 2011 |
1886 | 2012 |
1887 class RelationalOpInstr : public ComparisonInstr { | 2013 class RelationalOpComp : public ComparisonComp { |
1888 public: | 2014 public: |
1889 RelationalOpInstr(intptr_t token_pos, | 2015 RelationalOpComp(intptr_t token_pos, |
1890 Token::Kind kind, | 2016 Token::Kind kind, |
1891 Value* left, | 2017 Value* left, |
1892 Value* right) | 2018 Value* right) |
1893 : ComparisonInstr(kind, left, right), | 2019 : ComparisonComp(kind, left, right), |
1894 ic_data_(Isolate::Current()->GetICDataForDeoptId(deopt_id())), | 2020 ic_data_(Isolate::Current()->GetICDataForDeoptId(deopt_id())), |
1895 token_pos_(token_pos), | 2021 token_pos_(token_pos), |
1896 operands_class_id_(kIllegalCid) { | 2022 operands_class_id_(kIllegalCid) { |
1897 ASSERT(Token::IsRelationalOperator(kind)); | 2023 ASSERT(Token::IsRelationalOperator(kind)); |
1898 } | 2024 } |
1899 | 2025 |
1900 DECLARE_INSTRUCTION(RelationalOp) | 2026 DECLARE_COMPUTATION(RelationalOp) |
1901 virtual RawAbstractType* CompileType() const; | |
1902 | 2027 |
1903 const ICData* ic_data() const { return ic_data_; } | 2028 const ICData* ic_data() const { return ic_data_; } |
1904 bool HasICData() const { | 2029 bool HasICData() const { |
1905 return (ic_data() != NULL) && !ic_data()->IsNull(); | 2030 return (ic_data() != NULL) && !ic_data()->IsNull(); |
1906 } | 2031 } |
1907 | 2032 |
1908 intptr_t token_pos() const { return token_pos_; } | 2033 intptr_t token_pos() const { return token_pos_; } |
1909 | 2034 |
1910 // TODO(srdjan): instead of class-id pass an enum that can differentiate | 2035 // TODO(srdjan): instead of class-id pass an enum that can differentiate |
1911 // between boxed and unboxed doubles and integers. | 2036 // between boxed and unboxed doubles and integers. |
(...skipping 23 matching lines...) Expand all Loading... |
1935 virtual Representation RequiredInputRepresentation(intptr_t idx) const { | 2060 virtual Representation RequiredInputRepresentation(intptr_t idx) const { |
1936 ASSERT((idx == 0) || (idx == 1)); | 2061 ASSERT((idx == 0) || (idx == 1)); |
1937 return (operands_class_id() == kDoubleCid) ? kUnboxedDouble : kTagged; | 2062 return (operands_class_id() == kDoubleCid) ? kUnboxedDouble : kTagged; |
1938 } | 2063 } |
1939 | 2064 |
1940 private: | 2065 private: |
1941 const ICData* ic_data_; | 2066 const ICData* ic_data_; |
1942 const intptr_t token_pos_; | 2067 const intptr_t token_pos_; |
1943 intptr_t operands_class_id_; // class id of both operands. | 2068 intptr_t operands_class_id_; // class id of both operands. |
1944 | 2069 |
1945 DISALLOW_COPY_AND_ASSIGN(RelationalOpInstr); | 2070 DISALLOW_COPY_AND_ASSIGN(RelationalOpComp); |
1946 }; | 2071 }; |
1947 | 2072 |
1948 | 2073 |
1949 class StaticCallInstr : public TemplateDefinition<0> { | 2074 class StaticCallComp : public TemplateComputation<0> { |
1950 public: | 2075 public: |
1951 StaticCallInstr(intptr_t token_pos, | 2076 StaticCallComp(intptr_t token_pos, |
1952 const Function& function, | 2077 const Function& function, |
1953 const Array& argument_names, | 2078 const Array& argument_names, |
1954 ZoneGrowableArray<PushArgumentInstr*>* arguments) | 2079 ZoneGrowableArray<PushArgumentInstr*>* arguments) |
1955 : token_pos_(token_pos), | 2080 : token_pos_(token_pos), |
1956 function_(function), | 2081 function_(function), |
1957 argument_names_(argument_names), | 2082 argument_names_(argument_names), |
1958 arguments_(arguments), | 2083 arguments_(arguments), |
1959 recognized_(MethodRecognizer::kUnknown) { | 2084 recognized_(MethodRecognizer::kUnknown) { |
1960 ASSERT(function.IsZoneHandle()); | 2085 ASSERT(function.IsZoneHandle()); |
1961 ASSERT(argument_names.IsZoneHandle()); | 2086 ASSERT(argument_names.IsZoneHandle()); |
1962 } | 2087 } |
1963 | 2088 |
1964 DECLARE_INSTRUCTION(StaticCall) | 2089 DECLARE_CALL_COMPUTATION(StaticCall) |
1965 virtual RawAbstractType* CompileType() const; | |
1966 | 2090 |
1967 // Accessors forwarded to the AST node. | 2091 // Accessors forwarded to the AST node. |
1968 const Function& function() const { return function_; } | 2092 const Function& function() const { return function_; } |
1969 const Array& argument_names() const { return argument_names_; } | 2093 const Array& argument_names() const { return argument_names_; } |
1970 intptr_t token_pos() const { return token_pos_; } | 2094 intptr_t token_pos() const { return token_pos_; } |
1971 | 2095 |
1972 virtual intptr_t ArgumentCount() const { return arguments_->length(); } | 2096 virtual intptr_t ArgumentCount() const { return arguments_->length(); } |
1973 PushArgumentInstr* ArgumentAt(intptr_t index) const { | 2097 PushArgumentInstr* ArgumentAt(intptr_t index) const { |
1974 return (*arguments_)[index]; | 2098 return (*arguments_)[index]; |
1975 } | 2099 } |
1976 | 2100 |
1977 MethodRecognizer::Kind recognized() const { return recognized_; } | 2101 MethodRecognizer::Kind recognized() const { return recognized_; } |
1978 void set_recognized(MethodRecognizer::Kind kind) { recognized_ = kind; } | 2102 void set_recognized(MethodRecognizer::Kind kind) { recognized_ = kind; } |
1979 | 2103 |
1980 virtual void PrintOperandsTo(BufferFormatter* f) const; | 2104 virtual void PrintOperandsTo(BufferFormatter* f) const; |
1981 | 2105 |
1982 virtual bool CanDeoptimize() const { return true; } | 2106 virtual bool CanDeoptimize() const { return true; } |
1983 virtual intptr_t ResultCid() const { return kDynamicCid; } | 2107 virtual intptr_t ResultCid() const { return kDynamicCid; } |
1984 | 2108 |
1985 private: | 2109 private: |
1986 const intptr_t token_pos_; | 2110 const intptr_t token_pos_; |
1987 const Function& function_; | 2111 const Function& function_; |
1988 const Array& argument_names_; | 2112 const Array& argument_names_; |
1989 ZoneGrowableArray<PushArgumentInstr*>* arguments_; | 2113 ZoneGrowableArray<PushArgumentInstr*>* arguments_; |
1990 MethodRecognizer::Kind recognized_; | 2114 MethodRecognizer::Kind recognized_; |
1991 | 2115 |
1992 DISALLOW_COPY_AND_ASSIGN(StaticCallInstr); | 2116 DISALLOW_COPY_AND_ASSIGN(StaticCallComp); |
1993 }; | 2117 }; |
1994 | 2118 |
1995 | 2119 |
1996 class LoadLocalInstr : public TemplateDefinition<0> { | 2120 class LoadLocalComp : public TemplateComputation<0> { |
1997 public: | 2121 public: |
1998 LoadLocalInstr(const LocalVariable& local, intptr_t context_level) | 2122 LoadLocalComp(const LocalVariable& local, intptr_t context_level) |
1999 : local_(local), | 2123 : local_(local), |
2000 context_level_(context_level) { } | 2124 context_level_(context_level) { } |
2001 | 2125 |
2002 DECLARE_INSTRUCTION(LoadLocal) | 2126 DECLARE_COMPUTATION(LoadLocal) |
2003 virtual RawAbstractType* CompileType() const; | |
2004 | 2127 |
2005 const LocalVariable& local() const { return local_; } | 2128 const LocalVariable& local() const { return local_; } |
2006 intptr_t context_level() const { return context_level_; } | 2129 intptr_t context_level() const { return context_level_; } |
2007 | 2130 |
2008 virtual void PrintOperandsTo(BufferFormatter* f) const; | 2131 virtual void PrintOperandsTo(BufferFormatter* f) const; |
2009 | 2132 |
2010 virtual bool CanDeoptimize() const { return false; } | 2133 virtual bool CanDeoptimize() const { return false; } |
2011 virtual intptr_t ResultCid() const { return kDynamicCid; } | 2134 virtual intptr_t ResultCid() const { return kDynamicCid; } |
2012 | 2135 |
2013 private: | 2136 private: |
2014 const LocalVariable& local_; | 2137 const LocalVariable& local_; |
2015 const intptr_t context_level_; | 2138 const intptr_t context_level_; |
2016 | 2139 |
2017 DISALLOW_COPY_AND_ASSIGN(LoadLocalInstr); | 2140 DISALLOW_COPY_AND_ASSIGN(LoadLocalComp); |
2018 }; | 2141 }; |
2019 | 2142 |
2020 | 2143 |
2021 class StoreLocalInstr : public TemplateDefinition<1> { | 2144 class StoreLocalComp : public TemplateComputation<1> { |
2022 public: | 2145 public: |
2023 StoreLocalInstr(const LocalVariable& local, | 2146 StoreLocalComp(const LocalVariable& local, |
2024 Value* value, | 2147 Value* value, |
2025 intptr_t context_level) | 2148 intptr_t context_level) |
2026 : local_(local), | 2149 : local_(local), |
2027 context_level_(context_level) { | 2150 context_level_(context_level) { |
2028 ASSERT(value != NULL); | 2151 ASSERT(value != NULL); |
2029 inputs_[0] = value; | 2152 inputs_[0] = value; |
2030 } | 2153 } |
2031 | 2154 |
2032 DECLARE_INSTRUCTION(StoreLocal) | 2155 DECLARE_COMPUTATION(StoreLocal) |
2033 virtual RawAbstractType* CompileType() const; | |
2034 | 2156 |
2035 const LocalVariable& local() const { return local_; } | 2157 const LocalVariable& local() const { return local_; } |
2036 Value* value() const { return inputs_[0]; } | 2158 Value* value() const { return inputs_[0]; } |
2037 intptr_t context_level() const { return context_level_; } | 2159 intptr_t context_level() const { return context_level_; } |
2038 | 2160 |
2039 virtual void RecordAssignedVars(BitVector* assigned_vars, | 2161 virtual void RecordAssignedVars(BitVector* assigned_vars, |
2040 intptr_t fixed_parameter_count); | 2162 intptr_t fixed_parameter_count); |
2041 | 2163 |
2042 virtual void PrintOperandsTo(BufferFormatter* f) const; | 2164 virtual void PrintOperandsTo(BufferFormatter* f) const; |
2043 | 2165 |
2044 virtual bool CanDeoptimize() const { return false; } | 2166 virtual bool CanDeoptimize() const { return false; } |
2045 virtual intptr_t ResultCid() const { return kDynamicCid; } | 2167 virtual intptr_t ResultCid() const { return kDynamicCid; } |
2046 | 2168 |
2047 private: | 2169 private: |
2048 const LocalVariable& local_; | 2170 const LocalVariable& local_; |
2049 const intptr_t context_level_; | 2171 const intptr_t context_level_; |
2050 | 2172 |
2051 DISALLOW_COPY_AND_ASSIGN(StoreLocalInstr); | 2173 DISALLOW_COPY_AND_ASSIGN(StoreLocalComp); |
2052 }; | 2174 }; |
2053 | 2175 |
2054 | 2176 |
2055 class NativeCallInstr : public TemplateDefinition<0> { | 2177 class NativeCallComp : public TemplateComputation<0> { |
2056 public: | 2178 public: |
2057 explicit NativeCallInstr(NativeBodyNode* node) | 2179 explicit NativeCallComp(NativeBodyNode* node) |
2058 : ast_node_(*node) {} | 2180 : ast_node_(*node) {} |
2059 | 2181 |
2060 DECLARE_INSTRUCTION(NativeCall) | 2182 DECLARE_COMPUTATION(NativeCall) |
2061 virtual RawAbstractType* CompileType() const; | |
2062 | 2183 |
2063 intptr_t token_pos() const { return ast_node_.token_pos(); } | 2184 intptr_t token_pos() const { return ast_node_.token_pos(); } |
2064 | 2185 |
2065 const String& native_name() const { | 2186 const String& native_name() const { |
2066 return ast_node_.native_c_function_name(); | 2187 return ast_node_.native_c_function_name(); |
2067 } | 2188 } |
2068 | 2189 |
2069 NativeFunction native_c_function() const { | 2190 NativeFunction native_c_function() const { |
2070 return ast_node_.native_c_function(); | 2191 return ast_node_.native_c_function(); |
2071 } | 2192 } |
2072 | 2193 |
2073 intptr_t argument_count() const { return ast_node_.argument_count(); } | 2194 intptr_t argument_count() const { return ast_node_.argument_count(); } |
2074 | 2195 |
2075 bool has_optional_parameters() const { | 2196 bool has_optional_parameters() const { |
2076 return ast_node_.has_optional_parameters(); | 2197 return ast_node_.has_optional_parameters(); |
2077 } | 2198 } |
2078 | 2199 |
2079 bool is_native_instance_closure() const { | 2200 bool is_native_instance_closure() const { |
2080 return ast_node_.is_native_instance_closure(); | 2201 return ast_node_.is_native_instance_closure(); |
2081 } | 2202 } |
2082 | 2203 |
2083 virtual void PrintOperandsTo(BufferFormatter* f) const; | 2204 virtual void PrintOperandsTo(BufferFormatter* f) const; |
2084 | 2205 |
2085 virtual bool CanDeoptimize() const { return false; } | 2206 virtual bool CanDeoptimize() const { return false; } |
2086 virtual intptr_t ResultCid() const { return kDynamicCid; } | 2207 virtual intptr_t ResultCid() const { return kDynamicCid; } |
2087 | 2208 |
2088 private: | 2209 private: |
2089 const NativeBodyNode& ast_node_; | 2210 const NativeBodyNode& ast_node_; |
2090 | 2211 |
2091 DISALLOW_COPY_AND_ASSIGN(NativeCallInstr); | 2212 DISALLOW_COPY_AND_ASSIGN(NativeCallComp); |
2092 }; | 2213 }; |
2093 | 2214 |
2094 | 2215 |
2095 class LoadInstanceFieldInstr : public TemplateDefinition<1> { | 2216 class LoadInstanceFieldComp : public TemplateComputation<1> { |
2096 public: | 2217 public: |
2097 LoadInstanceFieldInstr(const Field& field, Value* instance) : field_(field) { | 2218 LoadInstanceFieldComp(const Field& field, Value* instance) : field_(field) { |
2098 ASSERT(instance != NULL); | 2219 ASSERT(instance != NULL); |
2099 inputs_[0] = instance; | 2220 inputs_[0] = instance; |
2100 } | 2221 } |
2101 | 2222 |
2102 DECLARE_INSTRUCTION(LoadInstanceField) | 2223 DECLARE_COMPUTATION(LoadInstanceField) |
2103 virtual RawAbstractType* CompileType() const; | |
2104 | 2224 |
2105 const Field& field() const { return field_; } | 2225 const Field& field() const { return field_; } |
2106 Value* instance() const { return inputs_[0]; } | 2226 Value* instance() const { return inputs_[0]; } |
2107 | 2227 |
2108 virtual void PrintOperandsTo(BufferFormatter* f) const; | 2228 virtual void PrintOperandsTo(BufferFormatter* f) const; |
2109 | 2229 |
2110 virtual bool CanDeoptimize() const { return false; } | 2230 virtual bool CanDeoptimize() const { return false; } |
2111 virtual intptr_t ResultCid() const { return kDynamicCid; } | 2231 virtual intptr_t ResultCid() const { return kDynamicCid; } |
2112 | 2232 |
2113 private: | 2233 private: |
2114 const Field& field_; | 2234 const Field& field_; |
2115 | 2235 |
2116 DISALLOW_COPY_AND_ASSIGN(LoadInstanceFieldInstr); | 2236 DISALLOW_COPY_AND_ASSIGN(LoadInstanceFieldComp); |
2117 }; | 2237 }; |
2118 | 2238 |
2119 | 2239 |
2120 class StoreInstanceFieldInstr : public TemplateDefinition<2> { | 2240 class StoreInstanceFieldComp : public TemplateComputation<2> { |
2121 public: | 2241 public: |
2122 StoreInstanceFieldInstr(const Field& field, Value* instance, Value* value) | 2242 StoreInstanceFieldComp(const Field& field, |
| 2243 Value* instance, |
| 2244 Value* value) |
2123 : field_(field) { | 2245 : field_(field) { |
2124 ASSERT(instance != NULL); | 2246 ASSERT(instance != NULL); |
2125 ASSERT(value != NULL); | 2247 ASSERT(value != NULL); |
2126 inputs_[0] = instance; | 2248 inputs_[0] = instance; |
2127 inputs_[1] = value; | 2249 inputs_[1] = value; |
2128 } | 2250 } |
2129 | 2251 |
2130 DECLARE_INSTRUCTION(StoreInstanceField) | 2252 DECLARE_COMPUTATION(StoreInstanceField) |
2131 virtual RawAbstractType* CompileType() const; | |
2132 | 2253 |
2133 const Field& field() const { return field_; } | 2254 const Field& field() const { return field_; } |
2134 | 2255 |
2135 Value* instance() const { return inputs_[0]; } | 2256 Value* instance() const { return inputs_[0]; } |
2136 Value* value() const { return inputs_[1]; } | 2257 Value* value() const { return inputs_[1]; } |
2137 | 2258 |
2138 virtual void PrintOperandsTo(BufferFormatter* f) const; | 2259 virtual void PrintOperandsTo(BufferFormatter* f) const; |
2139 | 2260 |
2140 virtual bool CanDeoptimize() const { return false; } | 2261 virtual bool CanDeoptimize() const { return false; } |
2141 virtual intptr_t ResultCid() const { return kDynamicCid; } | 2262 virtual intptr_t ResultCid() const { return kDynamicCid; } |
2142 | 2263 |
2143 private: | 2264 private: |
2144 const Field& field_; | 2265 const Field& field_; |
2145 | 2266 |
2146 DISALLOW_COPY_AND_ASSIGN(StoreInstanceFieldInstr); | 2267 DISALLOW_COPY_AND_ASSIGN(StoreInstanceFieldComp); |
2147 }; | 2268 }; |
2148 | 2269 |
2149 | 2270 |
2150 class LoadStaticFieldInstr : public TemplateDefinition<0> { | 2271 class LoadStaticFieldComp : public TemplateComputation<0> { |
2151 public: | 2272 public: |
2152 explicit LoadStaticFieldInstr(const Field& field) : field_(field) {} | 2273 explicit LoadStaticFieldComp(const Field& field) : field_(field) {} |
2153 | 2274 |
2154 DECLARE_INSTRUCTION(LoadStaticField); | 2275 DECLARE_COMPUTATION(LoadStaticField); |
2155 virtual RawAbstractType* CompileType() const; | |
2156 | 2276 |
2157 const Field& field() const { return field_; } | 2277 const Field& field() const { return field_; } |
2158 | 2278 |
2159 virtual void PrintOperandsTo(BufferFormatter* f) const; | 2279 virtual void PrintOperandsTo(BufferFormatter* f) const; |
2160 | 2280 |
2161 virtual bool CanDeoptimize() const { return false; } | 2281 virtual bool CanDeoptimize() const { return false; } |
2162 virtual intptr_t ResultCid() const { return kDynamicCid; } | 2282 virtual intptr_t ResultCid() const { return kDynamicCid; } |
2163 | 2283 |
2164 private: | 2284 private: |
2165 const Field& field_; | 2285 const Field& field_; |
2166 | 2286 |
2167 DISALLOW_COPY_AND_ASSIGN(LoadStaticFieldInstr); | 2287 DISALLOW_COPY_AND_ASSIGN(LoadStaticFieldComp); |
2168 }; | 2288 }; |
2169 | 2289 |
2170 | 2290 |
2171 class StoreStaticFieldInstr : public TemplateDefinition<1> { | 2291 class StoreStaticFieldComp : public TemplateComputation<1> { |
2172 public: | 2292 public: |
2173 StoreStaticFieldInstr(const Field& field, Value* value) | 2293 StoreStaticFieldComp(const Field& field, Value* value) |
2174 : field_(field) { | 2294 : field_(field) { |
2175 ASSERT(field.IsZoneHandle()); | 2295 ASSERT(field.IsZoneHandle()); |
2176 ASSERT(value != NULL); | 2296 ASSERT(value != NULL); |
2177 inputs_[0] = value; | 2297 inputs_[0] = value; |
2178 } | 2298 } |
2179 | 2299 |
2180 DECLARE_INSTRUCTION(StoreStaticField); | 2300 DECLARE_COMPUTATION(StoreStaticField); |
2181 virtual RawAbstractType* CompileType() const; | |
2182 | 2301 |
2183 const Field& field() const { return field_; } | 2302 const Field& field() const { return field_; } |
2184 Value* value() const { return inputs_[0]; } | 2303 Value* value() const { return inputs_[0]; } |
2185 | 2304 |
2186 virtual void PrintOperandsTo(BufferFormatter* f) const; | 2305 virtual void PrintOperandsTo(BufferFormatter* f) const; |
2187 | 2306 |
2188 virtual bool CanDeoptimize() const { return false; } | 2307 virtual bool CanDeoptimize() const { return false; } |
2189 virtual intptr_t ResultCid() const { return kDynamicCid; } | 2308 virtual intptr_t ResultCid() const { return kDynamicCid; } |
2190 | 2309 |
2191 private: | 2310 private: |
2192 const Field& field_; | 2311 const Field& field_; |
2193 | 2312 |
2194 DISALLOW_COPY_AND_ASSIGN(StoreStaticFieldInstr); | 2313 DISALLOW_COPY_AND_ASSIGN(StoreStaticFieldComp); |
2195 }; | 2314 }; |
2196 | 2315 |
2197 | 2316 |
2198 class LoadIndexedInstr : public TemplateDefinition<2> { | 2317 class LoadIndexedComp : public TemplateComputation<2> { |
2199 public: | 2318 public: |
2200 LoadIndexedInstr(Value* array, Value* index, intptr_t receiver_type) | 2319 LoadIndexedComp(Value* array, |
| 2320 Value* index, |
| 2321 intptr_t receiver_type) |
2201 : receiver_type_(receiver_type) { | 2322 : receiver_type_(receiver_type) { |
2202 ASSERT(array != NULL); | 2323 ASSERT(array != NULL); |
2203 ASSERT(index != NULL); | 2324 ASSERT(index != NULL); |
2204 inputs_[0] = array; | 2325 inputs_[0] = array; |
2205 inputs_[1] = index; | 2326 inputs_[1] = index; |
2206 } | 2327 } |
2207 | 2328 |
2208 DECLARE_INSTRUCTION(LoadIndexed) | 2329 DECLARE_COMPUTATION(LoadIndexed) |
2209 virtual RawAbstractType* CompileType() const; | |
2210 | 2330 |
2211 Value* array() const { return inputs_[0]; } | 2331 Value* array() const { return inputs_[0]; } |
2212 Value* index() const { return inputs_[1]; } | 2332 Value* index() const { return inputs_[1]; } |
2213 | 2333 |
2214 intptr_t receiver_type() const { return receiver_type_; } | 2334 intptr_t receiver_type() const { return receiver_type_; } |
2215 | 2335 |
2216 virtual bool CanDeoptimize() const { return false; } | 2336 virtual bool CanDeoptimize() const { return false; } |
2217 virtual intptr_t ResultCid() const { return kDynamicCid; } | 2337 virtual intptr_t ResultCid() const { return kDynamicCid; } |
2218 | 2338 |
2219 private: | 2339 private: |
2220 intptr_t receiver_type_; | 2340 intptr_t receiver_type_; |
2221 | 2341 |
2222 DISALLOW_COPY_AND_ASSIGN(LoadIndexedInstr); | 2342 DISALLOW_COPY_AND_ASSIGN(LoadIndexedComp); |
2223 }; | 2343 }; |
2224 | 2344 |
2225 | 2345 |
2226 class StoreIndexedInstr : public TemplateDefinition<3> { | 2346 class StoreIndexedComp : public TemplateComputation<3> { |
2227 public: | 2347 public: |
2228 StoreIndexedInstr(Value* array, | 2348 StoreIndexedComp(Value* array, |
2229 Value* index, | 2349 Value* index, |
2230 Value* value, | 2350 Value* value, |
2231 intptr_t receiver_type) | 2351 intptr_t receiver_type) |
2232 : receiver_type_(receiver_type) { | 2352 : receiver_type_(receiver_type) { |
2233 ASSERT(array != NULL); | 2353 ASSERT(array != NULL); |
2234 ASSERT(index != NULL); | 2354 ASSERT(index != NULL); |
2235 ASSERT(value != NULL); | 2355 ASSERT(value != NULL); |
2236 inputs_[0] = array; | 2356 inputs_[0] = array; |
2237 inputs_[1] = index; | 2357 inputs_[1] = index; |
2238 inputs_[2] = value; | 2358 inputs_[2] = value; |
2239 } | 2359 } |
2240 | 2360 |
2241 DECLARE_INSTRUCTION(StoreIndexed) | 2361 DECLARE_COMPUTATION(StoreIndexed) |
2242 virtual RawAbstractType* CompileType() const; | |
2243 | 2362 |
2244 Value* array() const { return inputs_[0]; } | 2363 Value* array() const { return inputs_[0]; } |
2245 Value* index() const { return inputs_[1]; } | 2364 Value* index() const { return inputs_[1]; } |
2246 Value* value() const { return inputs_[2]; } | 2365 Value* value() const { return inputs_[2]; } |
2247 | 2366 |
2248 intptr_t receiver_type() const { return receiver_type_; } | 2367 intptr_t receiver_type() const { return receiver_type_; } |
2249 | 2368 |
2250 virtual bool CanDeoptimize() const { return false; } | 2369 virtual bool CanDeoptimize() const { return false; } |
2251 virtual intptr_t ResultCid() const { return kDynamicCid; } | 2370 virtual intptr_t ResultCid() const { return kDynamicCid; } |
2252 | 2371 |
2253 private: | 2372 private: |
2254 intptr_t receiver_type_; | 2373 intptr_t receiver_type_; |
2255 | 2374 |
2256 DISALLOW_COPY_AND_ASSIGN(StoreIndexedInstr); | 2375 DISALLOW_COPY_AND_ASSIGN(StoreIndexedComp); |
2257 }; | 2376 }; |
2258 | 2377 |
2259 | 2378 |
2260 // Note overrideable, built-in: value? false : true. | 2379 // Note overrideable, built-in: value? false : true. |
2261 class BooleanNegateInstr : public TemplateDefinition<1> { | 2380 class BooleanNegateComp : public TemplateComputation<1> { |
2262 public: | 2381 public: |
2263 explicit BooleanNegateInstr(Value* value) { | 2382 explicit BooleanNegateComp(Value* value) { |
2264 ASSERT(value != NULL); | 2383 ASSERT(value != NULL); |
2265 inputs_[0] = value; | 2384 inputs_[0] = value; |
2266 } | 2385 } |
2267 | 2386 |
2268 DECLARE_INSTRUCTION(BooleanNegate) | 2387 DECLARE_COMPUTATION(BooleanNegate) |
2269 virtual RawAbstractType* CompileType() const; | |
2270 | 2388 |
2271 Value* value() const { return inputs_[0]; } | 2389 Value* value() const { return inputs_[0]; } |
2272 | 2390 |
2273 virtual bool CanDeoptimize() const { return false; } | 2391 virtual bool CanDeoptimize() const { return false; } |
2274 virtual intptr_t ResultCid() const { return kBoolCid; } | 2392 virtual intptr_t ResultCid() const { return kBoolCid; } |
2275 | 2393 |
2276 private: | 2394 private: |
2277 DISALLOW_COPY_AND_ASSIGN(BooleanNegateInstr); | 2395 DISALLOW_COPY_AND_ASSIGN(BooleanNegateComp); |
2278 }; | 2396 }; |
2279 | 2397 |
2280 | 2398 |
2281 class InstanceOfInstr : public TemplateDefinition<3> { | 2399 class InstanceOfComp : public TemplateComputation<3> { |
2282 public: | 2400 public: |
2283 InstanceOfInstr(intptr_t token_pos, | 2401 InstanceOfComp(intptr_t token_pos, |
2284 Value* value, | 2402 Value* value, |
2285 Value* instantiator, | 2403 Value* instantiator, |
2286 Value* instantiator_type_arguments, | 2404 Value* instantiator_type_arguments, |
2287 const AbstractType& type, | 2405 const AbstractType& type, |
2288 bool negate_result) | 2406 bool negate_result) |
2289 : token_pos_(token_pos), | 2407 : token_pos_(token_pos), |
2290 type_(type), | 2408 type_(type), |
2291 negate_result_(negate_result) { | 2409 negate_result_(negate_result) { |
2292 ASSERT(value != NULL); | 2410 ASSERT(value != NULL); |
2293 ASSERT(instantiator != NULL); | 2411 ASSERT(instantiator != NULL); |
2294 ASSERT(instantiator_type_arguments != NULL); | 2412 ASSERT(instantiator_type_arguments != NULL); |
2295 ASSERT(!type.IsNull()); | 2413 ASSERT(!type.IsNull()); |
2296 inputs_[0] = value; | 2414 inputs_[0] = value; |
2297 inputs_[1] = instantiator; | 2415 inputs_[1] = instantiator; |
2298 inputs_[2] = instantiator_type_arguments; | 2416 inputs_[2] = instantiator_type_arguments; |
2299 } | 2417 } |
2300 | 2418 |
2301 DECLARE_INSTRUCTION(InstanceOf) | 2419 DECLARE_COMPUTATION(InstanceOf) |
2302 virtual RawAbstractType* CompileType() const; | |
2303 | 2420 |
2304 Value* value() const { return inputs_[0]; } | 2421 Value* value() const { return inputs_[0]; } |
2305 Value* instantiator() const { return inputs_[1]; } | 2422 Value* instantiator() const { return inputs_[1]; } |
2306 Value* instantiator_type_arguments() const { return inputs_[2]; } | 2423 Value* instantiator_type_arguments() const { return inputs_[2]; } |
2307 | 2424 |
2308 bool negate_result() const { return negate_result_; } | 2425 bool negate_result() const { return negate_result_; } |
2309 const AbstractType& type() const { return type_; } | 2426 const AbstractType& type() const { return type_; } |
2310 intptr_t token_pos() const { return token_pos_; } | 2427 intptr_t token_pos() const { return token_pos_; } |
2311 | 2428 |
2312 virtual void PrintOperandsTo(BufferFormatter* f) const; | 2429 virtual void PrintOperandsTo(BufferFormatter* f) const; |
2313 | 2430 |
2314 virtual bool CanDeoptimize() const { return false; } | 2431 virtual bool CanDeoptimize() const { return false; } |
2315 virtual intptr_t ResultCid() const { return kBoolCid; } | 2432 virtual intptr_t ResultCid() const { return kBoolCid; } |
2316 | 2433 |
2317 private: | 2434 private: |
2318 const intptr_t token_pos_; | 2435 const intptr_t token_pos_; |
2319 Value* value_; | 2436 Value* value_; |
2320 Value* instantiator_; | 2437 Value* instantiator_; |
2321 Value* type_arguments_; | 2438 Value* type_arguments_; |
2322 const AbstractType& type_; | 2439 const AbstractType& type_; |
2323 const bool negate_result_; | 2440 const bool negate_result_; |
2324 | 2441 |
2325 DISALLOW_COPY_AND_ASSIGN(InstanceOfInstr); | 2442 DISALLOW_COPY_AND_ASSIGN(InstanceOfComp); |
2326 }; | 2443 }; |
2327 | 2444 |
2328 | 2445 |
2329 class AllocateObjectInstr : public TemplateDefinition<0> { | 2446 class AllocateObjectComp : public TemplateComputation<0> { |
2330 public: | 2447 public: |
2331 AllocateObjectInstr(ConstructorCallNode* node, | 2448 AllocateObjectComp(ConstructorCallNode* node, |
2332 ZoneGrowableArray<PushArgumentInstr*>* arguments) | 2449 ZoneGrowableArray<PushArgumentInstr*>* arguments) |
2333 : ast_node_(*node), arguments_(arguments) { | 2450 : ast_node_(*node), arguments_(arguments) { |
2334 // Either no arguments or one type-argument and one instantiator. | 2451 // Either no arguments or one type-argument and one instantiator. |
2335 ASSERT(arguments->is_empty() || (arguments->length() == 2)); | 2452 ASSERT(arguments->is_empty() || (arguments->length() == 2)); |
2336 } | 2453 } |
2337 | 2454 |
2338 DECLARE_INSTRUCTION(AllocateObject) | 2455 DECLARE_CALL_COMPUTATION(AllocateObject) |
2339 virtual RawAbstractType* CompileType() const; | |
2340 | 2456 |
2341 virtual intptr_t ArgumentCount() const { return arguments_->length(); } | 2457 virtual intptr_t ArgumentCount() const { return arguments_->length(); } |
2342 PushArgumentInstr* ArgumentAt(intptr_t index) const { | 2458 PushArgumentInstr* ArgumentAt(intptr_t index) const { |
2343 return (*arguments_)[index]; | 2459 return (*arguments_)[index]; |
2344 } | 2460 } |
2345 | 2461 |
2346 const Function& constructor() const { return ast_node_.constructor(); } | 2462 const Function& constructor() const { return ast_node_.constructor(); } |
2347 intptr_t token_pos() const { return ast_node_.token_pos(); } | 2463 intptr_t token_pos() const { return ast_node_.token_pos(); } |
2348 | 2464 |
2349 virtual void PrintOperandsTo(BufferFormatter* f) const; | 2465 virtual void PrintOperandsTo(BufferFormatter* f) const; |
2350 | 2466 |
2351 virtual bool CanDeoptimize() const { return false; } | 2467 virtual bool CanDeoptimize() const { return false; } |
2352 virtual intptr_t ResultCid() const { return kDynamicCid; } | 2468 virtual intptr_t ResultCid() const { return kDynamicCid; } |
2353 | 2469 |
2354 private: | 2470 private: |
2355 const ConstructorCallNode& ast_node_; | 2471 const ConstructorCallNode& ast_node_; |
2356 ZoneGrowableArray<PushArgumentInstr*>* const arguments_; | 2472 ZoneGrowableArray<PushArgumentInstr*>* const arguments_; |
2357 | 2473 |
2358 DISALLOW_COPY_AND_ASSIGN(AllocateObjectInstr); | 2474 DISALLOW_COPY_AND_ASSIGN(AllocateObjectComp); |
2359 }; | 2475 }; |
2360 | 2476 |
2361 | 2477 |
2362 class AllocateObjectWithBoundsCheckInstr : public TemplateDefinition<2> { | 2478 class AllocateObjectWithBoundsCheckComp : public TemplateComputation<2> { |
2363 public: | 2479 public: |
2364 AllocateObjectWithBoundsCheckInstr(ConstructorCallNode* node, | 2480 AllocateObjectWithBoundsCheckComp(ConstructorCallNode* node, |
2365 Value* type_arguments, | 2481 Value* type_arguments, |
2366 Value* instantiator) | 2482 Value* instantiator) |
2367 : ast_node_(*node) { | 2483 : ast_node_(*node) { |
2368 ASSERT(type_arguments != NULL); | 2484 ASSERT(type_arguments != NULL); |
2369 ASSERT(instantiator != NULL); | 2485 ASSERT(instantiator != NULL); |
2370 inputs_[0] = type_arguments; | 2486 inputs_[0] = type_arguments; |
2371 inputs_[1] = instantiator; | 2487 inputs_[1] = instantiator; |
2372 } | 2488 } |
2373 | 2489 |
2374 DECLARE_INSTRUCTION(AllocateObjectWithBoundsCheck) | 2490 DECLARE_COMPUTATION(AllocateObjectWithBoundsCheck) |
2375 virtual RawAbstractType* CompileType() const; | |
2376 | 2491 |
2377 const Function& constructor() const { return ast_node_.constructor(); } | 2492 const Function& constructor() const { return ast_node_.constructor(); } |
2378 intptr_t token_pos() const { return ast_node_.token_pos(); } | 2493 intptr_t token_pos() const { return ast_node_.token_pos(); } |
2379 | 2494 |
2380 virtual void PrintOperandsTo(BufferFormatter* f) const; | 2495 virtual void PrintOperandsTo(BufferFormatter* f) const; |
2381 | 2496 |
2382 virtual bool CanDeoptimize() const { return false; } | 2497 virtual bool CanDeoptimize() const { return false; } |
2383 virtual intptr_t ResultCid() const { return kDynamicCid; } | 2498 virtual intptr_t ResultCid() const { return kDynamicCid; } |
2384 | 2499 |
2385 private: | 2500 private: |
2386 const ConstructorCallNode& ast_node_; | 2501 const ConstructorCallNode& ast_node_; |
2387 | 2502 |
2388 DISALLOW_COPY_AND_ASSIGN(AllocateObjectWithBoundsCheckInstr); | 2503 DISALLOW_COPY_AND_ASSIGN(AllocateObjectWithBoundsCheckComp); |
2389 }; | 2504 }; |
2390 | 2505 |
2391 | 2506 |
2392 class CreateArrayInstr : public TemplateDefinition<1> { | 2507 class CreateArrayComp : public TemplateComputation<1> { |
2393 public: | 2508 public: |
2394 CreateArrayInstr(intptr_t token_pos, | 2509 CreateArrayComp(intptr_t token_pos, |
2395 ZoneGrowableArray<PushArgumentInstr*>* arguments, | 2510 ZoneGrowableArray<PushArgumentInstr*>* arguments, |
2396 const AbstractType& type, | 2511 const AbstractType& type, |
2397 Value* element_type) | 2512 Value* element_type) |
2398 : token_pos_(token_pos), | 2513 : token_pos_(token_pos), |
2399 arguments_(arguments), | 2514 arguments_(arguments), |
2400 type_(type) { | 2515 type_(type) { |
2401 #if defined(DEBUG) | 2516 #if defined(DEBUG) |
2402 for (int i = 0; i < ArgumentCount(); ++i) { | 2517 for (int i = 0; i < ArgumentCount(); ++i) { |
2403 ASSERT(ArgumentAt(i) != NULL); | 2518 ASSERT(ArgumentAt(i) != NULL); |
2404 } | 2519 } |
2405 ASSERT(element_type != NULL); | 2520 ASSERT(element_type != NULL); |
2406 ASSERT(type_.IsZoneHandle()); | 2521 ASSERT(type_.IsZoneHandle()); |
2407 ASSERT(!type_.IsNull()); | 2522 ASSERT(!type_.IsNull()); |
2408 ASSERT(type_.IsFinalized()); | 2523 ASSERT(type_.IsFinalized()); |
2409 #endif | 2524 #endif |
2410 inputs_[0] = element_type; | 2525 inputs_[0] = element_type; |
2411 } | 2526 } |
2412 | 2527 |
2413 DECLARE_INSTRUCTION(CreateArray) | 2528 DECLARE_CALL_COMPUTATION(CreateArray) |
2414 virtual RawAbstractType* CompileType() const; | |
2415 | 2529 |
2416 virtual intptr_t ArgumentCount() const { return arguments_->length(); } | 2530 virtual intptr_t ArgumentCount() const { return arguments_->length(); } |
2417 | 2531 |
2418 intptr_t token_pos() const { return token_pos_; } | 2532 intptr_t token_pos() const { return token_pos_; } |
2419 PushArgumentInstr* ArgumentAt(intptr_t i) const { return (*arguments_)[i]; } | 2533 PushArgumentInstr* ArgumentAt(intptr_t i) const { return (*arguments_)[i]; } |
2420 const AbstractType& type() const { return type_; } | 2534 const AbstractType& type() const { return type_; } |
2421 Value* element_type() const { return inputs_[0]; } | 2535 Value* element_type() const { return inputs_[0]; } |
2422 | 2536 |
2423 virtual void PrintOperandsTo(BufferFormatter* f) const; | 2537 virtual void PrintOperandsTo(BufferFormatter* f) const; |
2424 | 2538 |
2425 virtual bool CanDeoptimize() const { return false; } | 2539 virtual bool CanDeoptimize() const { return false; } |
2426 virtual intptr_t ResultCid() const { return kDynamicCid; } | 2540 virtual intptr_t ResultCid() const { return kDynamicCid; } |
2427 | 2541 |
2428 private: | 2542 private: |
2429 const intptr_t token_pos_; | 2543 const intptr_t token_pos_; |
2430 ZoneGrowableArray<PushArgumentInstr*>* const arguments_; | 2544 ZoneGrowableArray<PushArgumentInstr*>* const arguments_; |
2431 const AbstractType& type_; | 2545 const AbstractType& type_; |
2432 | 2546 |
2433 DISALLOW_COPY_AND_ASSIGN(CreateArrayInstr); | 2547 DISALLOW_COPY_AND_ASSIGN(CreateArrayComp); |
2434 }; | 2548 }; |
2435 | 2549 |
2436 | 2550 |
2437 class CreateClosureInstr : public TemplateDefinition<0> { | 2551 class CreateClosureComp : public TemplateComputation<0> { |
2438 public: | 2552 public: |
2439 CreateClosureInstr(ClosureNode* node, | 2553 CreateClosureComp(ClosureNode* node, |
2440 ZoneGrowableArray<PushArgumentInstr*>* arguments) | 2554 ZoneGrowableArray<PushArgumentInstr*>* arguments) |
2441 : ast_node_(*node), | 2555 : ast_node_(*node), |
2442 arguments_(arguments) { } | 2556 arguments_(arguments) { } |
2443 | 2557 |
2444 DECLARE_INSTRUCTION(CreateClosure) | 2558 DECLARE_CALL_COMPUTATION(CreateClosure) |
2445 virtual RawAbstractType* CompileType() const; | |
2446 | 2559 |
2447 intptr_t token_pos() const { return ast_node_.token_pos(); } | 2560 intptr_t token_pos() const { return ast_node_.token_pos(); } |
2448 const Function& function() const { return ast_node_.function(); } | 2561 const Function& function() const { return ast_node_.function(); } |
2449 | 2562 |
2450 virtual intptr_t ArgumentCount() const { return arguments_->length(); } | 2563 virtual intptr_t ArgumentCount() const { return arguments_->length(); } |
2451 PushArgumentInstr* ArgumentAt(intptr_t index) const { | 2564 PushArgumentInstr* ArgumentAt(intptr_t index) const { |
2452 return (*arguments_)[index]; | 2565 return (*arguments_)[index]; |
2453 } | 2566 } |
2454 | 2567 |
2455 virtual void PrintOperandsTo(BufferFormatter* f) const; | 2568 virtual void PrintOperandsTo(BufferFormatter* f) const; |
2456 | 2569 |
2457 virtual bool CanDeoptimize() const { return false; } | 2570 virtual bool CanDeoptimize() const { return false; } |
2458 virtual intptr_t ResultCid() const { return kDynamicCid; } | 2571 virtual intptr_t ResultCid() const { return kDynamicCid; } |
2459 | 2572 |
2460 private: | 2573 private: |
2461 const ClosureNode& ast_node_; | 2574 const ClosureNode& ast_node_; |
2462 ZoneGrowableArray<PushArgumentInstr*>* arguments_; | 2575 ZoneGrowableArray<PushArgumentInstr*>* arguments_; |
2463 | 2576 |
2464 DISALLOW_COPY_AND_ASSIGN(CreateClosureInstr); | 2577 DISALLOW_COPY_AND_ASSIGN(CreateClosureComp); |
2465 }; | 2578 }; |
2466 | 2579 |
2467 | 2580 |
2468 class LoadVMFieldInstr : public TemplateDefinition<1> { | 2581 class LoadVMFieldComp : public TemplateComputation<1> { |
2469 public: | 2582 public: |
2470 LoadVMFieldInstr(Value* value, | 2583 LoadVMFieldComp(Value* value, |
2471 intptr_t offset_in_bytes, | 2584 intptr_t offset_in_bytes, |
2472 const AbstractType& type) | 2585 const AbstractType& type) |
2473 : offset_in_bytes_(offset_in_bytes), | 2586 : offset_in_bytes_(offset_in_bytes), |
2474 type_(type), | 2587 type_(type), |
2475 result_cid_(kDynamicCid) { | 2588 result_cid_(kDynamicCid) { |
2476 ASSERT(value != NULL); | 2589 ASSERT(value != NULL); |
2477 ASSERT(type.IsZoneHandle()); // May be null if field is not an instance. | 2590 ASSERT(type.IsZoneHandle()); // May be null if field is not an instance. |
2478 inputs_[0] = value; | 2591 inputs_[0] = value; |
2479 } | 2592 } |
2480 | 2593 |
2481 DECLARE_INSTRUCTION(LoadVMField) | 2594 DECLARE_COMPUTATION(LoadVMField) |
2482 virtual RawAbstractType* CompileType() const; | |
2483 | 2595 |
2484 Value* value() const { return inputs_[0]; } | 2596 Value* value() const { return inputs_[0]; } |
2485 intptr_t offset_in_bytes() const { return offset_in_bytes_; } | 2597 intptr_t offset_in_bytes() const { return offset_in_bytes_; } |
2486 const AbstractType& type() const { return type_; } | 2598 const AbstractType& type() const { return type_; } |
2487 void set_result_cid(intptr_t value) { result_cid_ = value; } | 2599 void set_result_cid(intptr_t value) { result_cid_ = value; } |
2488 | 2600 |
2489 virtual void PrintOperandsTo(BufferFormatter* f) const; | 2601 virtual void PrintOperandsTo(BufferFormatter* f) const; |
2490 | 2602 |
2491 virtual bool CanDeoptimize() const { return false; } | 2603 virtual bool CanDeoptimize() const { return false; } |
2492 virtual intptr_t ResultCid() const { return result_cid_; } | 2604 virtual intptr_t ResultCid() const { return result_cid_; } |
2493 | 2605 |
2494 private: | 2606 private: |
2495 const intptr_t offset_in_bytes_; | 2607 const intptr_t offset_in_bytes_; |
2496 const AbstractType& type_; | 2608 const AbstractType& type_; |
2497 intptr_t result_cid_; | 2609 intptr_t result_cid_; |
2498 | 2610 |
2499 DISALLOW_COPY_AND_ASSIGN(LoadVMFieldInstr); | 2611 DISALLOW_COPY_AND_ASSIGN(LoadVMFieldComp); |
2500 }; | 2612 }; |
2501 | 2613 |
2502 | 2614 |
2503 class StoreVMFieldInstr : public TemplateDefinition<2> { | 2615 class StoreVMFieldComp : public TemplateComputation<2> { |
2504 public: | 2616 public: |
2505 StoreVMFieldInstr(Value* dest, | 2617 StoreVMFieldComp(Value* dest, |
2506 intptr_t offset_in_bytes, | 2618 intptr_t offset_in_bytes, |
2507 Value* value, | 2619 Value* value, |
2508 const AbstractType& type) | 2620 const AbstractType& type) |
2509 : offset_in_bytes_(offset_in_bytes), type_(type) { | 2621 : offset_in_bytes_(offset_in_bytes), type_(type) { |
2510 ASSERT(value != NULL); | 2622 ASSERT(value != NULL); |
2511 ASSERT(dest != NULL); | 2623 ASSERT(dest != NULL); |
2512 ASSERT(type.IsZoneHandle()); // May be null if field is not an instance. | 2624 ASSERT(type.IsZoneHandle()); // May be null if field is not an instance. |
2513 inputs_[0] = value; | 2625 inputs_[0] = value; |
2514 inputs_[1] = dest; | 2626 inputs_[1] = dest; |
2515 } | 2627 } |
2516 | 2628 |
2517 DECLARE_INSTRUCTION(StoreVMField) | 2629 DECLARE_COMPUTATION(StoreVMField) |
2518 virtual RawAbstractType* CompileType() const; | |
2519 | 2630 |
2520 Value* value() const { return inputs_[0]; } | 2631 Value* value() const { return inputs_[0]; } |
2521 Value* dest() const { return inputs_[1]; } | 2632 Value* dest() const { return inputs_[1]; } |
2522 intptr_t offset_in_bytes() const { return offset_in_bytes_; } | 2633 intptr_t offset_in_bytes() const { return offset_in_bytes_; } |
2523 const AbstractType& type() const { return type_; } | 2634 const AbstractType& type() const { return type_; } |
2524 | 2635 |
2525 virtual void PrintOperandsTo(BufferFormatter* f) const; | 2636 virtual void PrintOperandsTo(BufferFormatter* f) const; |
2526 | 2637 |
2527 virtual bool CanDeoptimize() const { return false; } | 2638 virtual bool CanDeoptimize() const { return false; } |
2528 virtual intptr_t ResultCid() const { return kDynamicCid; } | 2639 virtual intptr_t ResultCid() const { return kDynamicCid; } |
2529 | 2640 |
2530 private: | 2641 private: |
2531 const intptr_t offset_in_bytes_; | 2642 const intptr_t offset_in_bytes_; |
2532 const AbstractType& type_; | 2643 const AbstractType& type_; |
2533 | 2644 |
2534 DISALLOW_COPY_AND_ASSIGN(StoreVMFieldInstr); | 2645 DISALLOW_COPY_AND_ASSIGN(StoreVMFieldComp); |
2535 }; | 2646 }; |
2536 | 2647 |
2537 | 2648 |
2538 class InstantiateTypeArgumentsInstr : public TemplateDefinition<1> { | 2649 class InstantiateTypeArgumentsComp : public TemplateComputation<1> { |
2539 public: | 2650 public: |
2540 InstantiateTypeArgumentsInstr(intptr_t token_pos, | 2651 InstantiateTypeArgumentsComp(intptr_t token_pos, |
2541 const AbstractTypeArguments& type_arguments, | 2652 const AbstractTypeArguments& type_arguments, |
2542 Value* instantiator) | 2653 Value* instantiator) |
2543 : token_pos_(token_pos), | 2654 : token_pos_(token_pos), |
2544 type_arguments_(type_arguments) { | 2655 type_arguments_(type_arguments) { |
2545 ASSERT(type_arguments.IsZoneHandle()); | 2656 ASSERT(type_arguments.IsZoneHandle()); |
2546 ASSERT(instantiator != NULL); | 2657 ASSERT(instantiator != NULL); |
2547 inputs_[0] = instantiator; | 2658 inputs_[0] = instantiator; |
2548 } | 2659 } |
2549 | 2660 |
2550 DECLARE_INSTRUCTION(InstantiateTypeArguments) | 2661 DECLARE_COMPUTATION(InstantiateTypeArguments) |
2551 virtual RawAbstractType* CompileType() const; | |
2552 | 2662 |
2553 Value* instantiator() const { return inputs_[0]; } | 2663 Value* instantiator() const { return inputs_[0]; } |
2554 const AbstractTypeArguments& type_arguments() const { | 2664 const AbstractTypeArguments& type_arguments() const { |
2555 return type_arguments_; | 2665 return type_arguments_; |
2556 } | 2666 } |
2557 intptr_t token_pos() const { return token_pos_; } | 2667 intptr_t token_pos() const { return token_pos_; } |
2558 | 2668 |
2559 virtual void PrintOperandsTo(BufferFormatter* f) const; | 2669 virtual void PrintOperandsTo(BufferFormatter* f) const; |
2560 | 2670 |
2561 virtual bool CanDeoptimize() const { return false; } | 2671 virtual bool CanDeoptimize() const { return false; } |
2562 virtual intptr_t ResultCid() const { return kDynamicCid; } | 2672 virtual intptr_t ResultCid() const { return kDynamicCid; } |
2563 | 2673 |
2564 private: | 2674 private: |
2565 const intptr_t token_pos_; | 2675 const intptr_t token_pos_; |
2566 const AbstractTypeArguments& type_arguments_; | 2676 const AbstractTypeArguments& type_arguments_; |
2567 | 2677 |
2568 DISALLOW_COPY_AND_ASSIGN(InstantiateTypeArgumentsInstr); | 2678 DISALLOW_COPY_AND_ASSIGN(InstantiateTypeArgumentsComp); |
2569 }; | 2679 }; |
2570 | 2680 |
2571 | 2681 |
2572 class ExtractConstructorTypeArgumentsInstr : public TemplateDefinition<1> { | 2682 class ExtractConstructorTypeArgumentsComp : public TemplateComputation<1> { |
2573 public: | 2683 public: |
2574 ExtractConstructorTypeArgumentsInstr( | 2684 ExtractConstructorTypeArgumentsComp( |
2575 intptr_t token_pos, | 2685 intptr_t token_pos, |
2576 const AbstractTypeArguments& type_arguments, | 2686 const AbstractTypeArguments& type_arguments, |
2577 Value* instantiator) | 2687 Value* instantiator) |
2578 : token_pos_(token_pos), | 2688 : token_pos_(token_pos), |
2579 type_arguments_(type_arguments) { | 2689 type_arguments_(type_arguments) { |
2580 ASSERT(instantiator != NULL); | 2690 ASSERT(instantiator != NULL); |
2581 inputs_[0] = instantiator; | 2691 inputs_[0] = instantiator; |
2582 } | 2692 } |
2583 | 2693 |
2584 DECLARE_INSTRUCTION(ExtractConstructorTypeArguments) | 2694 DECLARE_COMPUTATION(ExtractConstructorTypeArguments) |
2585 virtual RawAbstractType* CompileType() const; | |
2586 | 2695 |
2587 Value* instantiator() const { return inputs_[0]; } | 2696 Value* instantiator() const { return inputs_[0]; } |
2588 const AbstractTypeArguments& type_arguments() const { | 2697 const AbstractTypeArguments& type_arguments() const { |
2589 return type_arguments_; | 2698 return type_arguments_; |
2590 } | 2699 } |
2591 intptr_t token_pos() const { return token_pos_; } | 2700 intptr_t token_pos() const { return token_pos_; } |
2592 | 2701 |
2593 virtual void PrintOperandsTo(BufferFormatter* f) const; | 2702 virtual void PrintOperandsTo(BufferFormatter* f) const; |
2594 | 2703 |
2595 virtual bool CanDeoptimize() const { return false; } | 2704 virtual bool CanDeoptimize() const { return false; } |
2596 virtual intptr_t ResultCid() const { return kDynamicCid; } | 2705 virtual intptr_t ResultCid() const { return kDynamicCid; } |
2597 | 2706 |
2598 private: | 2707 private: |
2599 const intptr_t token_pos_; | 2708 const intptr_t token_pos_; |
2600 const AbstractTypeArguments& type_arguments_; | 2709 const AbstractTypeArguments& type_arguments_; |
2601 | 2710 |
2602 DISALLOW_COPY_AND_ASSIGN(ExtractConstructorTypeArgumentsInstr); | 2711 DISALLOW_COPY_AND_ASSIGN(ExtractConstructorTypeArgumentsComp); |
2603 }; | 2712 }; |
2604 | 2713 |
2605 | 2714 |
2606 class ExtractConstructorInstantiatorInstr : public TemplateDefinition<1> { | 2715 class ExtractConstructorInstantiatorComp : public TemplateComputation<1> { |
2607 public: | 2716 public: |
2608 ExtractConstructorInstantiatorInstr(ConstructorCallNode* ast_node, | 2717 ExtractConstructorInstantiatorComp(ConstructorCallNode* ast_node, |
2609 Value* instantiator) | 2718 Value* instantiator) |
2610 : ast_node_(*ast_node) { | 2719 : ast_node_(*ast_node) { |
2611 ASSERT(instantiator != NULL); | 2720 ASSERT(instantiator != NULL); |
2612 inputs_[0] = instantiator; | 2721 inputs_[0] = instantiator; |
2613 } | 2722 } |
2614 | 2723 |
2615 DECLARE_INSTRUCTION(ExtractConstructorInstantiator) | 2724 DECLARE_COMPUTATION(ExtractConstructorInstantiator) |
2616 virtual RawAbstractType* CompileType() const; | |
2617 | 2725 |
2618 Value* instantiator() const { return inputs_[0]; } | 2726 Value* instantiator() const { return inputs_[0]; } |
2619 const AbstractTypeArguments& type_arguments() const { | 2727 const AbstractTypeArguments& type_arguments() const { |
2620 return ast_node_.type_arguments(); | 2728 return ast_node_.type_arguments(); |
2621 } | 2729 } |
2622 const Function& constructor() const { return ast_node_.constructor(); } | 2730 const Function& constructor() const { return ast_node_.constructor(); } |
2623 intptr_t token_pos() const { return ast_node_.token_pos(); } | 2731 intptr_t token_pos() const { return ast_node_.token_pos(); } |
2624 | 2732 |
2625 virtual bool CanDeoptimize() const { return false; } | 2733 virtual bool CanDeoptimize() const { return false; } |
2626 virtual intptr_t ResultCid() const { return kDynamicCid; } | 2734 virtual intptr_t ResultCid() const { return kDynamicCid; } |
2627 | 2735 |
2628 private: | 2736 private: |
2629 const ConstructorCallNode& ast_node_; | 2737 const ConstructorCallNode& ast_node_; |
2630 | 2738 |
2631 DISALLOW_COPY_AND_ASSIGN(ExtractConstructorInstantiatorInstr); | 2739 DISALLOW_COPY_AND_ASSIGN(ExtractConstructorInstantiatorComp); |
2632 }; | 2740 }; |
2633 | 2741 |
2634 | 2742 |
2635 class AllocateContextInstr : public TemplateDefinition<0> { | 2743 class AllocateContextComp : public TemplateComputation<0> { |
2636 public: | 2744 public: |
2637 AllocateContextInstr(intptr_t token_pos, | 2745 AllocateContextComp(intptr_t token_pos, |
2638 intptr_t num_context_variables) | 2746 intptr_t num_context_variables) |
2639 : token_pos_(token_pos), | 2747 : token_pos_(token_pos), |
2640 num_context_variables_(num_context_variables) {} | 2748 num_context_variables_(num_context_variables) {} |
2641 | 2749 |
2642 DECLARE_INSTRUCTION(AllocateContext); | 2750 DECLARE_COMPUTATION(AllocateContext); |
2643 virtual RawAbstractType* CompileType() const; | |
2644 | 2751 |
2645 intptr_t token_pos() const { return token_pos_; } | 2752 intptr_t token_pos() const { return token_pos_; } |
2646 intptr_t num_context_variables() const { return num_context_variables_; } | 2753 intptr_t num_context_variables() const { return num_context_variables_; } |
2647 | 2754 |
2648 virtual void PrintOperandsTo(BufferFormatter* f) const; | 2755 virtual void PrintOperandsTo(BufferFormatter* f) const; |
2649 | 2756 |
2650 virtual bool CanDeoptimize() const { return false; } | 2757 virtual bool CanDeoptimize() const { return false; } |
2651 virtual intptr_t ResultCid() const { return kDynamicCid; } | 2758 virtual intptr_t ResultCid() const { return kDynamicCid; } |
2652 | 2759 |
2653 private: | 2760 private: |
2654 const intptr_t token_pos_; | 2761 const intptr_t token_pos_; |
2655 const intptr_t num_context_variables_; | 2762 const intptr_t num_context_variables_; |
2656 | 2763 |
2657 DISALLOW_COPY_AND_ASSIGN(AllocateContextInstr); | 2764 DISALLOW_COPY_AND_ASSIGN(AllocateContextComp); |
2658 }; | 2765 }; |
2659 | 2766 |
2660 | 2767 |
2661 class ChainContextInstr : public TemplateDefinition<1> { | 2768 class ChainContextComp : public TemplateComputation<1> { |
2662 public: | 2769 public: |
2663 explicit ChainContextInstr(Value* context_value) { | 2770 explicit ChainContextComp(Value* context_value) { |
2664 ASSERT(context_value != NULL); | 2771 ASSERT(context_value != NULL); |
2665 inputs_[0] = context_value; | 2772 inputs_[0] = context_value; |
2666 } | 2773 } |
2667 | 2774 |
2668 DECLARE_INSTRUCTION(ChainContext) | 2775 DECLARE_COMPUTATION(ChainContext) |
2669 virtual RawAbstractType* CompileType() const; | |
2670 | 2776 |
2671 Value* context_value() const { return inputs_[0]; } | 2777 Value* context_value() const { return inputs_[0]; } |
2672 | 2778 |
2673 virtual bool CanDeoptimize() const { return false; } | 2779 virtual bool CanDeoptimize() const { return false; } |
2674 virtual intptr_t ResultCid() const { return kIllegalCid; } | 2780 virtual intptr_t ResultCid() const { return kIllegalCid; } |
2675 | 2781 |
2676 private: | 2782 private: |
2677 DISALLOW_COPY_AND_ASSIGN(ChainContextInstr); | 2783 DISALLOW_COPY_AND_ASSIGN(ChainContextComp); |
2678 }; | 2784 }; |
2679 | 2785 |
2680 | 2786 |
2681 class CloneContextInstr : public TemplateDefinition<1> { | 2787 class CloneContextComp : public TemplateComputation<1> { |
2682 public: | 2788 public: |
2683 CloneContextInstr(intptr_t token_pos, Value* context_value) | 2789 CloneContextComp(intptr_t token_pos, |
| 2790 Value* context_value) |
2684 : token_pos_(token_pos) { | 2791 : token_pos_(token_pos) { |
2685 ASSERT(context_value != NULL); | 2792 ASSERT(context_value != NULL); |
2686 inputs_[0] = context_value; | 2793 inputs_[0] = context_value; |
2687 } | 2794 } |
2688 | 2795 |
2689 intptr_t token_pos() const { return token_pos_; } | 2796 intptr_t token_pos() const { return token_pos_; } |
2690 Value* context_value() const { return inputs_[0]; } | 2797 Value* context_value() const { return inputs_[0]; } |
2691 | 2798 |
2692 DECLARE_INSTRUCTION(CloneContext) | 2799 DECLARE_COMPUTATION(CloneContext) |
2693 virtual RawAbstractType* CompileType() const; | |
2694 | 2800 |
2695 virtual bool CanDeoptimize() const { return false; } | 2801 virtual bool CanDeoptimize() const { return false; } |
2696 virtual intptr_t ResultCid() const { return kIllegalCid; } | 2802 virtual intptr_t ResultCid() const { return kIllegalCid; } |
2697 | 2803 |
2698 private: | 2804 private: |
2699 const intptr_t token_pos_; | 2805 const intptr_t token_pos_; |
2700 | 2806 |
2701 DISALLOW_COPY_AND_ASSIGN(CloneContextInstr); | 2807 DISALLOW_COPY_AND_ASSIGN(CloneContextComp); |
2702 }; | 2808 }; |
2703 | 2809 |
2704 | 2810 |
2705 class CatchEntryInstr : public TemplateDefinition<0> { | 2811 class CatchEntryComp : public TemplateComputation<0> { |
2706 public: | 2812 public: |
2707 CatchEntryInstr(const LocalVariable& exception_var, | 2813 CatchEntryComp(const LocalVariable& exception_var, |
2708 const LocalVariable& stacktrace_var) | 2814 const LocalVariable& stacktrace_var) |
2709 : exception_var_(exception_var), stacktrace_var_(stacktrace_var) {} | 2815 : exception_var_(exception_var), stacktrace_var_(stacktrace_var) {} |
2710 | 2816 |
2711 const LocalVariable& exception_var() const { return exception_var_; } | 2817 const LocalVariable& exception_var() const { return exception_var_; } |
2712 const LocalVariable& stacktrace_var() const { return stacktrace_var_; } | 2818 const LocalVariable& stacktrace_var() const { return stacktrace_var_; } |
2713 | 2819 |
2714 DECLARE_INSTRUCTION(CatchEntry) | 2820 DECLARE_COMPUTATION(CatchEntry) |
2715 virtual RawAbstractType* CompileType() const; | |
2716 | 2821 |
2717 virtual void PrintOperandsTo(BufferFormatter* f) const; | 2822 virtual void PrintOperandsTo(BufferFormatter* f) const; |
2718 | 2823 |
2719 virtual bool CanDeoptimize() const { return false; } | 2824 virtual bool CanDeoptimize() const { return false; } |
2720 virtual intptr_t ResultCid() const { return kIllegalCid; } | 2825 virtual intptr_t ResultCid() const { return kIllegalCid; } |
2721 | 2826 |
2722 private: | 2827 private: |
2723 const LocalVariable& exception_var_; | 2828 const LocalVariable& exception_var_; |
2724 const LocalVariable& stacktrace_var_; | 2829 const LocalVariable& stacktrace_var_; |
2725 | 2830 |
2726 DISALLOW_COPY_AND_ASSIGN(CatchEntryInstr); | 2831 DISALLOW_COPY_AND_ASSIGN(CatchEntryComp); |
2727 }; | 2832 }; |
2728 | 2833 |
2729 | 2834 |
2730 class CheckEitherNonSmiInstr : public TemplateDefinition<2> { | 2835 class CheckEitherNonSmiComp : public TemplateComputation<2> { |
2731 public: | 2836 public: |
2732 CheckEitherNonSmiInstr(Value* left, | 2837 CheckEitherNonSmiComp(Value* left, |
2733 Value* right, | 2838 Value* right, |
2734 InstanceCallInstr* instance_call) { | 2839 InstanceCallComp* instance_call) |
| 2840 : instance_call_(instance_call) { |
2735 ASSERT(left != NULL); | 2841 ASSERT(left != NULL); |
2736 ASSERT(right != NULL); | 2842 ASSERT(right != NULL); |
2737 inputs_[0] = left; | 2843 inputs_[0] = left; |
2738 inputs_[1] = right; | 2844 inputs_[1] = right; |
2739 deopt_id_ = instance_call->deopt_id(); | |
2740 } | 2845 } |
2741 | 2846 |
2742 DECLARE_INSTRUCTION(CheckEitherNonSmi) | 2847 DECLARE_COMPUTATION(CheckEitherNonSmi) |
2743 virtual RawAbstractType* CompileType() const; | |
2744 | 2848 |
2745 virtual bool CanDeoptimize() const { return true; } | 2849 virtual bool CanDeoptimize() const { return true; } |
2746 virtual intptr_t ResultCid() const { return kIllegalCid; } | 2850 virtual intptr_t ResultCid() const { return kIllegalCid; } |
2747 | 2851 |
2748 virtual bool AttributesEqual(Definition* other) const { return true; } | 2852 virtual bool AttributesEqual(Computation* other) const { return true; } |
2749 | 2853 |
2750 virtual bool HasSideEffect() const { return false; } | 2854 virtual bool HasSideEffect() const { return false; } |
2751 | 2855 |
2752 Value* left() const { return inputs_[0]; } | 2856 Value* left() const { return inputs_[0]; } |
2753 | 2857 |
2754 Value* right() const { return inputs_[1]; } | 2858 Value* right() const { return inputs_[1]; } |
2755 | 2859 |
2756 virtual Definition* Canonicalize(); | 2860 virtual Definition* TryReplace(BindInstr* instr) const; |
2757 | 2861 |
2758 private: | 2862 private: |
2759 DISALLOW_COPY_AND_ASSIGN(CheckEitherNonSmiInstr); | 2863 InstanceCallComp* instance_call_; |
| 2864 |
| 2865 DISALLOW_COPY_AND_ASSIGN(CheckEitherNonSmiComp); |
2760 }; | 2866 }; |
2761 | 2867 |
2762 | 2868 |
2763 class BoxDoubleInstr : public TemplateDefinition<1> { | 2869 class BoxDoubleComp : public TemplateComputation<1> { |
2764 public: | 2870 public: |
2765 BoxDoubleInstr(Value* value, InstanceCallInstr* instance_call) | 2871 BoxDoubleComp(Value* value, InstanceCallComp* instance_call) |
2766 : token_pos_((instance_call != NULL) ? instance_call->token_pos() : 0) { | 2872 : token_pos_((instance_call != NULL) ? instance_call->token_pos() : 0) { |
2767 ASSERT(value != NULL); | 2873 ASSERT(value != NULL); |
2768 inputs_[0] = value; | 2874 inputs_[0] = value; |
2769 } | 2875 } |
2770 | 2876 |
2771 Value* value() const { return inputs_[0]; } | 2877 Value* value() const { return inputs_[0]; } |
2772 | 2878 |
2773 intptr_t token_pos() const { return token_pos_; } | 2879 intptr_t token_pos() const { return token_pos_; } |
2774 | 2880 |
2775 virtual bool CanDeoptimize() const { return false; } | 2881 virtual bool CanDeoptimize() const { return false; } |
2776 virtual bool HasSideEffect() const { return false; } | 2882 virtual bool HasSideEffect() const { return false; } |
2777 virtual bool AttributesEqual(Definition* other) const { return true; } | 2883 virtual bool AttributesEqual(Computation* other) const { return true; } |
2778 | 2884 |
2779 virtual intptr_t ResultCid() const; | 2885 virtual intptr_t ResultCid() const; |
2780 | 2886 |
2781 virtual Representation RequiredInputRepresentation(intptr_t idx) const { | 2887 virtual Representation RequiredInputRepresentation(intptr_t idx) const { |
2782 ASSERT(idx == 0); | 2888 ASSERT(idx == 0); |
2783 return kUnboxedDouble; | 2889 return kUnboxedDouble; |
2784 } | 2890 } |
2785 | 2891 |
2786 DECLARE_INSTRUCTION(BoxDouble) | 2892 DECLARE_COMPUTATION(BoxDouble) |
2787 virtual RawAbstractType* CompileType() const; | |
2788 | 2893 |
2789 private: | 2894 private: |
2790 const intptr_t token_pos_; | 2895 const intptr_t token_pos_; |
2791 | 2896 |
2792 DISALLOW_COPY_AND_ASSIGN(BoxDoubleInstr); | 2897 DISALLOW_COPY_AND_ASSIGN(BoxDoubleComp); |
2793 }; | 2898 }; |
2794 | 2899 |
2795 | 2900 |
2796 class UnboxDoubleInstr : public TemplateDefinition<1> { | 2901 class UnboxDoubleComp : public TemplateComputation<1> { |
2797 public: | 2902 public: |
2798 UnboxDoubleInstr(Value* value, intptr_t deopt_id) { | 2903 UnboxDoubleComp(Value* value, intptr_t deopt_id) |
| 2904 : deopt_id_(deopt_id) { |
2799 ASSERT(value != NULL); | 2905 ASSERT(value != NULL); |
2800 inputs_[0] = value; | 2906 inputs_[0] = value; |
2801 deopt_id_ = deopt_id; | |
2802 } | 2907 } |
2803 | 2908 |
2804 Value* value() const { return inputs_[0]; } | 2909 Value* value() const { return inputs_[0]; } |
2805 | 2910 |
2806 virtual bool CanDeoptimize() const { | 2911 virtual bool CanDeoptimize() const { |
2807 return value()->ResultCid() != kDoubleCid; | 2912 return value()->ResultCid() != kDoubleCid; |
2808 } | 2913 } |
2809 | 2914 |
2810 // The output is not an instance but when it is boxed it becomes double. | 2915 // The output is not an instance but when it is boxed it becomes double. |
2811 virtual intptr_t ResultCid() const { return kDoubleCid; } | 2916 virtual intptr_t ResultCid() const { return kDoubleCid; } |
2812 | 2917 |
2813 virtual Representation representation() const { | 2918 virtual Representation representation() const { |
2814 return kUnboxedDouble; | 2919 return kUnboxedDouble; |
2815 } | 2920 } |
2816 | 2921 |
2817 virtual bool HasSideEffect() const { return false; } | 2922 virtual bool HasSideEffect() const { return false; } |
2818 virtual bool AttributesEqual(Definition* other) const { return true; } | 2923 virtual bool AttributesEqual(Computation* other) const { return true; } |
2819 | 2924 |
2820 DECLARE_INSTRUCTION(UnboxDouble) | 2925 DECLARE_COMPUTATION(UnboxDouble) |
2821 virtual RawAbstractType* CompileType() const; | |
2822 | 2926 |
2823 private: | 2927 private: |
2824 DISALLOW_COPY_AND_ASSIGN(UnboxDoubleInstr); | 2928 const intptr_t deopt_id_; |
| 2929 |
| 2930 DISALLOW_COPY_AND_ASSIGN(UnboxDoubleComp); |
2825 }; | 2931 }; |
2826 | 2932 |
2827 | 2933 |
2828 class UnboxedDoubleBinaryOpInstr : public TemplateDefinition<2> { | 2934 class UnboxedDoubleBinaryOpComp : public TemplateComputation<2> { |
2829 public: | 2935 public: |
2830 UnboxedDoubleBinaryOpInstr(Token::Kind op_kind, | 2936 UnboxedDoubleBinaryOpComp(Token::Kind op_kind, |
2831 Value* left, | 2937 Value* left, |
2832 Value* right, | 2938 Value* right, |
2833 InstanceCallInstr* instance_call) | 2939 InstanceCallComp* call) |
2834 : op_kind_(op_kind) { | 2940 : op_kind_(op_kind), deopt_id_(call->deopt_id()) { |
2835 ASSERT(left != NULL); | 2941 ASSERT(left != NULL); |
2836 ASSERT(right != NULL); | 2942 ASSERT(right != NULL); |
2837 inputs_[0] = left; | 2943 inputs_[0] = left; |
2838 inputs_[1] = right; | 2944 inputs_[1] = right; |
2839 deopt_id_ = instance_call->deopt_id(); | |
2840 } | 2945 } |
2841 | 2946 |
2842 Value* left() const { return inputs_[0]; } | 2947 Value* left() const { return inputs_[0]; } |
2843 Value* right() const { return inputs_[1]; } | 2948 Value* right() const { return inputs_[1]; } |
2844 | 2949 |
2845 Token::Kind op_kind() const { return op_kind_; } | 2950 Token::Kind op_kind() const { return op_kind_; } |
2846 | 2951 |
2847 virtual void PrintOperandsTo(BufferFormatter* f) const; | 2952 virtual void PrintOperandsTo(BufferFormatter* f) const; |
2848 | 2953 |
2849 virtual bool CanDeoptimize() const { return false; } | 2954 virtual bool CanDeoptimize() const { return false; } |
2850 virtual bool HasSideEffect() const { return false; } | 2955 virtual bool HasSideEffect() const { return false; } |
2851 | 2956 |
2852 virtual bool AttributesEqual(Definition* other) const { | 2957 virtual bool AttributesEqual(Computation* other) const { |
2853 return op_kind() == other->AsUnboxedDoubleBinaryOp()->op_kind(); | 2958 return op_kind() == other->AsUnboxedDoubleBinaryOp()->op_kind(); |
2854 } | 2959 } |
2855 | 2960 |
2856 // The output is not an instance but when it is boxed it becomes double. | 2961 // The output is not an instance but when it is boxed it becomes double. |
2857 virtual intptr_t ResultCid() const { return kDoubleCid; } | 2962 virtual intptr_t ResultCid() const { return kDoubleCid; } |
2858 | 2963 |
2859 virtual Representation representation() const { | 2964 virtual Representation representation() const { |
2860 return kUnboxedDouble; | 2965 return kUnboxedDouble; |
2861 } | 2966 } |
2862 | 2967 |
2863 virtual Representation RequiredInputRepresentation(intptr_t idx) const { | 2968 virtual Representation RequiredInputRepresentation(intptr_t idx) const { |
2864 ASSERT((idx == 0) || (idx == 1)); | 2969 ASSERT((idx == 0) || (idx == 1)); |
2865 return kUnboxedDouble; | 2970 return kUnboxedDouble; |
2866 } | 2971 } |
2867 | 2972 |
2868 virtual intptr_t DeoptimizationTarget() const { | 2973 virtual intptr_t DeoptimizationTarget() const { |
2869 return deopt_id(); | 2974 return deopt_id_; |
2870 } | 2975 } |
2871 | 2976 |
2872 DECLARE_INSTRUCTION(UnboxedDoubleBinaryOp) | 2977 DECLARE_COMPUTATION(UnboxedDoubleBinaryOp) |
2873 virtual RawAbstractType* CompileType() const; | |
2874 | 2978 |
2875 private: | 2979 private: |
2876 const Token::Kind op_kind_; | 2980 const Token::Kind op_kind_; |
| 2981 const intptr_t deopt_id_; |
2877 | 2982 |
2878 DISALLOW_COPY_AND_ASSIGN(UnboxedDoubleBinaryOpInstr); | 2983 DISALLOW_COPY_AND_ASSIGN(UnboxedDoubleBinaryOpComp); |
2879 }; | 2984 }; |
2880 | 2985 |
2881 | 2986 |
2882 class BinarySmiOpInstr : public TemplateDefinition<2> { | 2987 class BinarySmiOpComp : public TemplateComputation<2> { |
2883 public: | 2988 public: |
2884 BinarySmiOpInstr(Token::Kind op_kind, | 2989 BinarySmiOpComp(Token::Kind op_kind, |
2885 InstanceCallInstr* instance_call, | 2990 InstanceCallComp* instance_call, |
2886 Value* left, | 2991 Value* left, |
2887 Value* right) | 2992 Value* right) |
2888 : op_kind_(op_kind), | 2993 : op_kind_(op_kind), |
2889 instance_call_(instance_call) { | 2994 instance_call_(instance_call) { |
2890 ASSERT(left != NULL); | 2995 ASSERT(left != NULL); |
2891 ASSERT(right != NULL); | 2996 ASSERT(right != NULL); |
2892 inputs_[0] = left; | 2997 inputs_[0] = left; |
2893 inputs_[1] = right; | 2998 inputs_[1] = right; |
2894 } | 2999 } |
2895 | 3000 |
2896 Value* left() const { return inputs_[0]; } | 3001 Value* left() const { return inputs_[0]; } |
2897 Value* right() const { return inputs_[1]; } | 3002 Value* right() const { return inputs_[1]; } |
2898 | 3003 |
2899 Token::Kind op_kind() const { return op_kind_; } | 3004 Token::Kind op_kind() const { return op_kind_; } |
2900 | 3005 |
2901 InstanceCallInstr* instance_call() const { return instance_call_; } | 3006 InstanceCallComp* instance_call() const { return instance_call_; } |
2902 | 3007 |
2903 const ICData* ic_data() const { return instance_call()->ic_data(); } | 3008 const ICData* ic_data() const { return instance_call()->ic_data(); } |
2904 | 3009 |
2905 virtual void PrintOperandsTo(BufferFormatter* f) const; | 3010 virtual void PrintOperandsTo(BufferFormatter* f) const; |
2906 | 3011 |
2907 DECLARE_INSTRUCTION(BinarySmiOp) | 3012 DECLARE_COMPUTATION(BinarySmiOp) |
2908 virtual RawAbstractType* CompileType() const; | |
2909 | 3013 |
2910 virtual bool CanDeoptimize() const; | 3014 virtual bool CanDeoptimize() const; |
2911 | 3015 |
2912 virtual intptr_t ResultCid() const; | 3016 virtual intptr_t ResultCid() const; |
2913 | 3017 |
2914 private: | 3018 private: |
2915 const Token::Kind op_kind_; | 3019 const Token::Kind op_kind_; |
2916 InstanceCallInstr* instance_call_; | 3020 InstanceCallComp* instance_call_; |
2917 | 3021 |
2918 DISALLOW_COPY_AND_ASSIGN(BinarySmiOpInstr); | 3022 DISALLOW_COPY_AND_ASSIGN(BinarySmiOpComp); |
2919 }; | 3023 }; |
2920 | 3024 |
2921 | 3025 |
2922 class BinaryMintOpInstr : public TemplateDefinition<2> { | 3026 class BinaryMintOpComp : public TemplateComputation<2> { |
2923 public: | 3027 public: |
2924 BinaryMintOpInstr(Token::Kind op_kind, | 3028 BinaryMintOpComp(Token::Kind op_kind, |
2925 InstanceCallInstr* instance_call, | 3029 InstanceCallComp* instance_call, |
2926 Value* left, | 3030 Value* left, |
2927 Value* right) | 3031 Value* right) |
2928 : op_kind_(op_kind), | 3032 : op_kind_(op_kind), |
2929 instance_call_(instance_call) { | 3033 instance_call_(instance_call) { |
2930 ASSERT(left != NULL); | 3034 ASSERT(left != NULL); |
2931 ASSERT(right != NULL); | 3035 ASSERT(right != NULL); |
2932 inputs_[0] = left; | 3036 inputs_[0] = left; |
2933 inputs_[1] = right; | 3037 inputs_[1] = right; |
2934 } | 3038 } |
2935 | 3039 |
2936 Value* left() const { return inputs_[0]; } | 3040 Value* left() const { return inputs_[0]; } |
2937 Value* right() const { return inputs_[1]; } | 3041 Value* right() const { return inputs_[1]; } |
2938 | 3042 |
2939 Token::Kind op_kind() const { return op_kind_; } | 3043 Token::Kind op_kind() const { return op_kind_; } |
2940 | 3044 |
2941 InstanceCallInstr* instance_call() const { return instance_call_; } | 3045 InstanceCallComp* instance_call() const { return instance_call_; } |
2942 | 3046 |
2943 const ICData* ic_data() const { return instance_call()->ic_data(); } | 3047 const ICData* ic_data() const { return instance_call()->ic_data(); } |
2944 | 3048 |
2945 virtual void PrintOperandsTo(BufferFormatter* f) const; | 3049 virtual void PrintOperandsTo(BufferFormatter* f) const; |
2946 | 3050 |
2947 DECLARE_INSTRUCTION(BinaryMintOp) | 3051 DECLARE_COMPUTATION(BinaryMintOp) |
2948 virtual RawAbstractType* CompileType() const; | |
2949 | 3052 |
2950 virtual bool CanDeoptimize() const { return true; } | 3053 virtual bool CanDeoptimize() const { return true; } |
2951 virtual intptr_t ResultCid() const; | 3054 virtual intptr_t ResultCid() const; |
2952 | 3055 |
2953 private: | 3056 private: |
2954 const Token::Kind op_kind_; | 3057 const Token::Kind op_kind_; |
2955 InstanceCallInstr* instance_call_; | 3058 InstanceCallComp* instance_call_; |
2956 | 3059 |
2957 DISALLOW_COPY_AND_ASSIGN(BinaryMintOpInstr); | 3060 DISALLOW_COPY_AND_ASSIGN(BinaryMintOpComp); |
2958 }; | 3061 }; |
2959 | 3062 |
2960 | 3063 |
2961 // Handles both Smi operations: BIT_OR and NEGATE. | 3064 // Handles both Smi operations: BIT_OR and NEGATE. |
2962 class UnarySmiOpInstr : public TemplateDefinition<1> { | 3065 class UnarySmiOpComp : public TemplateComputation<1> { |
2963 public: | 3066 public: |
2964 UnarySmiOpInstr(Token::Kind op_kind, | 3067 UnarySmiOpComp(Token::Kind op_kind, |
2965 InstanceCallInstr* instance_call, | 3068 InstanceCallComp* instance_call, |
2966 Value* value) | 3069 Value* value) |
2967 : op_kind_(op_kind), instance_call_(instance_call) { | 3070 : op_kind_(op_kind), instance_call_(instance_call) { |
2968 ASSERT((op_kind == Token::kNEGATE) || (op_kind == Token::kBIT_NOT)); | 3071 ASSERT((op_kind == Token::kNEGATE) || (op_kind == Token::kBIT_NOT)); |
2969 ASSERT(value != NULL); | 3072 ASSERT(value != NULL); |
2970 inputs_[0] = value; | 3073 inputs_[0] = value; |
2971 } | 3074 } |
2972 | 3075 |
2973 Value* value() const { return inputs_[0]; } | 3076 Value* value() const { return inputs_[0]; } |
2974 Token::Kind op_kind() const { return op_kind_; } | 3077 Token::Kind op_kind() const { return op_kind_; } |
2975 | 3078 |
2976 InstanceCallInstr* instance_call() const { return instance_call_; } | 3079 InstanceCallComp* instance_call() const { return instance_call_; } |
2977 | 3080 |
2978 virtual void PrintOperandsTo(BufferFormatter* f) const; | 3081 virtual void PrintOperandsTo(BufferFormatter* f) const; |
2979 | 3082 |
2980 DECLARE_INSTRUCTION(UnarySmiOp) | 3083 DECLARE_COMPUTATION(UnarySmiOp) |
2981 virtual RawAbstractType* CompileType() const; | |
2982 | 3084 |
2983 virtual bool CanDeoptimize() const { return op_kind() == Token::kNEGATE; } | 3085 virtual bool CanDeoptimize() const { return op_kind() == Token::kNEGATE; } |
2984 virtual intptr_t ResultCid() const { return kSmiCid; } | 3086 virtual intptr_t ResultCid() const { return kSmiCid; } |
2985 | 3087 |
2986 private: | 3088 private: |
2987 const Token::Kind op_kind_; | 3089 const Token::Kind op_kind_; |
2988 InstanceCallInstr* instance_call_; | 3090 InstanceCallComp* instance_call_; |
2989 | 3091 |
2990 DISALLOW_COPY_AND_ASSIGN(UnarySmiOpInstr); | 3092 DISALLOW_COPY_AND_ASSIGN(UnarySmiOpComp); |
2991 }; | 3093 }; |
2992 | 3094 |
2993 | 3095 |
2994 // Handles non-Smi NEGATE operations | 3096 // Handles non-Smi NEGATE operations |
2995 class NumberNegateInstr : public TemplateDefinition<1> { | 3097 class NumberNegateComp : public TemplateComputation<1> { |
2996 public: | 3098 public: |
2997 NumberNegateInstr(InstanceCallInstr* instance_call, Value* value) | 3099 NumberNegateComp(InstanceCallComp* instance_call, |
2998 : instance_call_(instance_call) { | 3100 Value* value) : instance_call_(instance_call) { |
2999 ASSERT(value != NULL); | 3101 ASSERT(value != NULL); |
3000 inputs_[0] = value; | 3102 inputs_[0] = value; |
3001 } | 3103 } |
3002 | 3104 |
3003 Value* value() const { return inputs_[0]; } | 3105 Value* value() const { return inputs_[0]; } |
3004 | 3106 |
3005 InstanceCallInstr* instance_call() const { return instance_call_; } | 3107 InstanceCallComp* instance_call() const { return instance_call_; } |
3006 | 3108 |
3007 const ICData* ic_data() const { return instance_call()->ic_data(); } | 3109 const ICData* ic_data() const { return instance_call()->ic_data(); } |
3008 | 3110 |
3009 DECLARE_INSTRUCTION(NumberNegate) | 3111 DECLARE_COMPUTATION(NumberNegate) |
3010 virtual RawAbstractType* CompileType() const; | |
3011 | 3112 |
3012 virtual bool CanDeoptimize() const { return true; } | 3113 virtual bool CanDeoptimize() const { return true; } |
3013 virtual intptr_t ResultCid() const { return kDoubleCid; } | 3114 virtual intptr_t ResultCid() const { return kDoubleCid; } |
3014 | 3115 |
3015 private: | 3116 private: |
3016 InstanceCallInstr* instance_call_; | 3117 InstanceCallComp* instance_call_; |
3017 | 3118 |
3018 DISALLOW_COPY_AND_ASSIGN(NumberNegateInstr); | 3119 DISALLOW_COPY_AND_ASSIGN(NumberNegateComp); |
3019 }; | 3120 }; |
3020 | 3121 |
3021 | 3122 |
3022 class CheckStackOverflowInstr : public TemplateDefinition<0> { | 3123 class CheckStackOverflowComp : public TemplateComputation<0> { |
3023 public: | 3124 public: |
3024 explicit CheckStackOverflowInstr(intptr_t token_pos) | 3125 explicit CheckStackOverflowComp(intptr_t token_pos) |
3025 : token_pos_(token_pos) {} | 3126 : token_pos_(token_pos) {} |
3026 | 3127 |
3027 intptr_t token_pos() const { return token_pos_; } | 3128 intptr_t token_pos() const { return token_pos_; } |
3028 | 3129 |
3029 DECLARE_INSTRUCTION(CheckStackOverflow) | 3130 DECLARE_COMPUTATION(CheckStackOverflow) |
3030 virtual RawAbstractType* CompileType() const; | |
3031 | 3131 |
3032 virtual bool CanDeoptimize() const { return false; } | 3132 virtual bool CanDeoptimize() const { return false; } |
3033 virtual intptr_t ResultCid() const { return kIllegalCid; } | 3133 virtual intptr_t ResultCid() const { return kIllegalCid; } |
3034 | 3134 |
3035 private: | 3135 private: |
3036 const intptr_t token_pos_; | 3136 const intptr_t token_pos_; |
3037 | 3137 |
3038 DISALLOW_COPY_AND_ASSIGN(CheckStackOverflowInstr); | 3138 DISALLOW_COPY_AND_ASSIGN(CheckStackOverflowComp); |
3039 }; | 3139 }; |
3040 | 3140 |
3041 | 3141 |
3042 class DoubleToDoubleInstr : public TemplateDefinition<1> { | 3142 class DoubleToDoubleComp : public TemplateComputation<1> { |
3043 public: | 3143 public: |
3044 DoubleToDoubleInstr(Value* value, InstanceCallInstr* instance_call) | 3144 DoubleToDoubleComp(Value* value, InstanceCallComp* instance_call) |
3045 : instance_call_(instance_call) { | 3145 : instance_call_(instance_call) { |
3046 ASSERT(value != NULL); | 3146 ASSERT(value != NULL); |
3047 inputs_[0] = value; | 3147 inputs_[0] = value; |
3048 } | 3148 } |
3049 | 3149 |
3050 Value* value() const { return inputs_[0]; } | 3150 Value* value() const { return inputs_[0]; } |
3051 | 3151 |
3052 InstanceCallInstr* instance_call() const { return instance_call_; } | 3152 InstanceCallComp* instance_call() const { return instance_call_; } |
3053 | 3153 |
3054 DECLARE_INSTRUCTION(DoubleToDouble) | 3154 DECLARE_COMPUTATION(DoubleToDouble) |
3055 virtual RawAbstractType* CompileType() const; | |
3056 | 3155 |
3057 virtual bool CanDeoptimize() const { return true; } | 3156 virtual bool CanDeoptimize() const { return true; } |
3058 virtual intptr_t ResultCid() const { return kDoubleCid; } | 3157 virtual intptr_t ResultCid() const { return kDoubleCid; } |
3059 | 3158 |
3060 private: | 3159 private: |
3061 InstanceCallInstr* instance_call_; | 3160 InstanceCallComp* instance_call_; |
3062 | 3161 |
3063 DISALLOW_COPY_AND_ASSIGN(DoubleToDoubleInstr); | 3162 DISALLOW_COPY_AND_ASSIGN(DoubleToDoubleComp); |
3064 }; | 3163 }; |
3065 | 3164 |
3066 | 3165 |
3067 class SmiToDoubleInstr : public TemplateDefinition<0> { | 3166 class SmiToDoubleComp : public TemplateComputation<0> { |
3068 public: | 3167 public: |
3069 explicit SmiToDoubleInstr(InstanceCallInstr* instance_call) | 3168 explicit SmiToDoubleComp(InstanceCallComp* instance_call) |
3070 : instance_call_(instance_call) { } | 3169 : instance_call_(instance_call) { } |
3071 | 3170 |
3072 InstanceCallInstr* instance_call() const { return instance_call_; } | 3171 InstanceCallComp* instance_call() const { return instance_call_; } |
3073 | 3172 |
3074 DECLARE_INSTRUCTION(SmiToDouble) | 3173 DECLARE_CALL_COMPUTATION(SmiToDouble) |
3075 virtual RawAbstractType* CompileType() const; | |
3076 | 3174 |
3077 virtual intptr_t ArgumentCount() const { return 1; } | 3175 virtual intptr_t ArgumentCount() const { return 1; } |
3078 | 3176 |
3079 virtual bool CanDeoptimize() const { return true; } | 3177 virtual bool CanDeoptimize() const { return true; } |
3080 virtual intptr_t ResultCid() const { return kDoubleCid; } | 3178 virtual intptr_t ResultCid() const { return kDoubleCid; } |
3081 | 3179 |
3082 private: | 3180 private: |
3083 InstanceCallInstr* instance_call_; | 3181 InstanceCallComp* instance_call_; |
3084 | 3182 |
3085 DISALLOW_COPY_AND_ASSIGN(SmiToDoubleInstr); | 3183 DISALLOW_COPY_AND_ASSIGN(SmiToDoubleComp); |
3086 }; | 3184 }; |
3087 | 3185 |
3088 | 3186 |
3089 class CheckClassInstr : public TemplateDefinition<1> { | 3187 class CheckClassComp : public TemplateComputation<1> { |
3090 public: | 3188 public: |
3091 CheckClassInstr(Value* value, | 3189 CheckClassComp(Value* value, |
3092 InstanceCallInstr* instance_call, | 3190 InstanceCallComp* instance_call, |
3093 const ICData& unary_checks) | 3191 const ICData& unary_checks) |
3094 : unary_checks_(unary_checks) { | 3192 : instance_call_(instance_call), |
| 3193 unary_checks_(unary_checks) { |
3095 ASSERT(value != NULL); | 3194 ASSERT(value != NULL); |
3096 inputs_[0] = value; | 3195 inputs_[0] = value; |
3097 deopt_id_ = instance_call->deopt_id(); | |
3098 } | 3196 } |
3099 | 3197 |
3100 DECLARE_INSTRUCTION(CheckClass) | 3198 DECLARE_COMPUTATION(CheckClass) |
3101 virtual RawAbstractType* CompileType() const; | |
3102 | 3199 |
3103 virtual bool CanDeoptimize() const { return true; } | 3200 virtual bool CanDeoptimize() const { return true; } |
3104 virtual intptr_t ResultCid() const { return kIllegalCid; } | 3201 virtual intptr_t ResultCid() const { return kIllegalCid; } |
3105 | 3202 |
3106 virtual bool AttributesEqual(Definition* other) const; | 3203 virtual bool AttributesEqual(Computation* other) const; |
3107 | 3204 |
3108 virtual bool HasSideEffect() const { return false; } | 3205 virtual bool HasSideEffect() const { return false; } |
3109 | 3206 |
3110 Value* value() const { return inputs_[0]; } | 3207 Value* value() const { return inputs_[0]; } |
3111 | 3208 |
3112 const ICData& unary_checks() const { return unary_checks_; } | 3209 const ICData& unary_checks() const { return unary_checks_; } |
3113 | 3210 |
3114 virtual Definition* Canonicalize(); | 3211 virtual intptr_t deopt_id() const { return instance_call_->deopt_id(); } |
| 3212 |
| 3213 virtual Definition* TryReplace(BindInstr* instr) const; |
3115 | 3214 |
3116 virtual void PrintOperandsTo(BufferFormatter* f) const; | 3215 virtual void PrintOperandsTo(BufferFormatter* f) const; |
3117 | 3216 |
3118 private: | 3217 private: |
| 3218 InstanceCallComp* instance_call_; |
3119 const ICData& unary_checks_; | 3219 const ICData& unary_checks_; |
3120 | 3220 |
3121 DISALLOW_COPY_AND_ASSIGN(CheckClassInstr); | 3221 DISALLOW_COPY_AND_ASSIGN(CheckClassComp); |
3122 }; | 3222 }; |
3123 | 3223 |
3124 | 3224 |
3125 class CheckSmiInstr : public TemplateDefinition<1> { | 3225 class CheckSmiComp : public TemplateComputation<1> { |
3126 public: | 3226 public: |
3127 CheckSmiInstr(Value* value, intptr_t original_deopt_id) { | 3227 CheckSmiComp(Value* value, intptr_t original_deopt_id) |
| 3228 : original_deopt_id_(original_deopt_id) { |
3128 ASSERT(value != NULL); | 3229 ASSERT(value != NULL); |
3129 ASSERT(original_deopt_id != Isolate::kNoDeoptId); | 3230 ASSERT(original_deopt_id != Isolate::kNoDeoptId); |
3130 inputs_[0] = value; | 3231 inputs_[0] = value; |
3131 deopt_id_ = original_deopt_id; | |
3132 } | 3232 } |
3133 | 3233 |
3134 DECLARE_INSTRUCTION(CheckSmi) | 3234 DECLARE_COMPUTATION(CheckSmi) |
3135 virtual RawAbstractType* CompileType() const; | |
3136 | 3235 |
3137 virtual bool CanDeoptimize() const { return true; } | 3236 virtual bool CanDeoptimize() const { return true; } |
3138 virtual intptr_t ResultCid() const { return kIllegalCid; } | 3237 virtual intptr_t ResultCid() const { return kIllegalCid; } |
3139 | 3238 |
3140 virtual bool AttributesEqual(Definition* other) const { return true; } | 3239 virtual bool AttributesEqual(Computation* other) const { return true; } |
3141 | 3240 |
3142 virtual bool HasSideEffect() const { return false; } | 3241 virtual bool HasSideEffect() const { return false; } |
3143 | 3242 |
3144 virtual Definition* Canonicalize(); | 3243 virtual Definition* TryReplace(BindInstr* instr) const; |
3145 | 3244 |
3146 Value* value() const { return inputs_[0]; } | 3245 Value* value() const { return inputs_[0]; } |
3147 | 3246 |
| 3247 virtual intptr_t deopt_id() const { return original_deopt_id_; } |
| 3248 |
3148 private: | 3249 private: |
3149 DISALLOW_COPY_AND_ASSIGN(CheckSmiInstr); | 3250 const intptr_t original_deopt_id_; |
| 3251 |
| 3252 DISALLOW_COPY_AND_ASSIGN(CheckSmiComp); |
3150 }; | 3253 }; |
3151 | 3254 |
3152 | 3255 |
3153 class CheckArrayBoundInstr : public TemplateDefinition<2> { | 3256 class CheckArrayBoundComp : public TemplateComputation<2> { |
3154 public: | 3257 public: |
3155 CheckArrayBoundInstr(Value* array, | 3258 CheckArrayBoundComp(Value* array, |
3156 Value* index, | 3259 Value* index, |
3157 intptr_t array_type, | 3260 intptr_t array_type, |
3158 InstanceCallInstr* instance_call) | 3261 InstanceCallComp* instance_call) |
3159 : array_type_(array_type) { | 3262 : array_type_(array_type), instance_call_(instance_call) { |
3160 ASSERT(array != NULL); | 3263 ASSERT(array != NULL); |
3161 ASSERT(index != NULL); | 3264 ASSERT(index != NULL); |
3162 inputs_[0] = array; | 3265 inputs_[0] = array; |
3163 inputs_[1] = index; | 3266 inputs_[1] = index; |
3164 deopt_id_ = instance_call->deopt_id(); | |
3165 } | 3267 } |
3166 | 3268 |
3167 DECLARE_INSTRUCTION(CheckArrayBound) | 3269 DECLARE_COMPUTATION(CheckArrayBound) |
3168 virtual RawAbstractType* CompileType() const; | |
3169 | 3270 |
3170 virtual bool CanDeoptimize() const { return true; } | 3271 virtual bool CanDeoptimize() const { return true; } |
3171 virtual intptr_t ResultCid() const { return kIllegalCid; } | 3272 virtual intptr_t ResultCid() const { return kIllegalCid; } |
3172 | 3273 |
3173 virtual bool AttributesEqual(Definition* other) const; | 3274 virtual bool AttributesEqual(Computation* other) const; |
3174 | 3275 |
3175 virtual bool HasSideEffect() const { return false; } | 3276 virtual bool HasSideEffect() const { return false; } |
3176 | 3277 |
3177 Value* array() const { return inputs_[0]; } | 3278 Value* array() const { return inputs_[0]; } |
3178 Value* index() const { return inputs_[1]; } | 3279 Value* index() const { return inputs_[1]; } |
3179 | 3280 |
3180 intptr_t array_type() const { return array_type_; } | 3281 intptr_t array_type() const { return array_type_; } |
3181 | 3282 |
| 3283 virtual intptr_t deopt_id() const { return instance_call_->deopt_id(); } |
| 3284 |
3182 private: | 3285 private: |
3183 intptr_t array_type_; | 3286 intptr_t array_type_; |
| 3287 InstanceCallComp* instance_call_; |
3184 | 3288 |
3185 DISALLOW_COPY_AND_ASSIGN(CheckArrayBoundInstr); | 3289 DISALLOW_COPY_AND_ASSIGN(CheckArrayBoundComp); |
3186 }; | 3290 }; |
3187 | 3291 |
3188 | 3292 |
3189 #undef DECLARE_INSTRUCTION | 3293 #undef DECLARE_COMPUTATION |
| 3294 |
| 3295 |
| 3296 // Implementation of type testers and cast functins. |
| 3297 #define DEFINE_COMPUTATION_PREDICATE(ShortName, ClassName) \ |
| 3298 bool Computation::Is##ShortName() const { \ |
| 3299 return computation_kind() == k##ShortName; \ |
| 3300 } \ |
| 3301 const ClassName* Computation::As##ShortName() const { \ |
| 3302 if (!Is##ShortName()) return NULL; \ |
| 3303 return static_cast<const ClassName*>(this); \ |
| 3304 } \ |
| 3305 ClassName* Computation::As##ShortName() { \ |
| 3306 if (!Is##ShortName()) return NULL; \ |
| 3307 return static_cast<ClassName*>(this); \ |
| 3308 } |
| 3309 FOR_EACH_COMPUTATION(DEFINE_COMPUTATION_PREDICATE) |
| 3310 #undef DEFINE_COMPUTATION_PREDICATE |
3190 | 3311 |
3191 | 3312 |
3192 class Environment : public ZoneAllocated { | 3313 class Environment : public ZoneAllocated { |
3193 public: | 3314 public: |
3194 // Construct an environment by constructing uses from an array of definitions. | 3315 // Construct an environment by constructing uses from an array of definitions. |
3195 Environment(const GrowableArray<Definition*>& definitions, | 3316 Environment(const GrowableArray<Definition*>& definitions, |
3196 intptr_t fixed_parameter_count); | 3317 intptr_t fixed_parameter_count); |
3197 | 3318 |
3198 void set_locations(Location* locations) { | 3319 void set_locations(Location* locations) { |
3199 ASSERT(locations_ == NULL); | 3320 ASSERT(locations_ == NULL); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3249 virtual ~FlowGraphVisitor() { } | 3370 virtual ~FlowGraphVisitor() { } |
3250 | 3371 |
3251 ForwardInstructionIterator* current_iterator() const { | 3372 ForwardInstructionIterator* current_iterator() const { |
3252 return current_iterator_; | 3373 return current_iterator_; |
3253 } | 3374 } |
3254 | 3375 |
3255 // Visit each block in the block order, and for each block its | 3376 // Visit each block in the block order, and for each block its |
3256 // instructions in order from the block entry to exit. | 3377 // instructions in order from the block entry to exit. |
3257 virtual void VisitBlocks(); | 3378 virtual void VisitBlocks(); |
3258 | 3379 |
3259 // Visit functions for instruction classes, with an empty default | 3380 // Visit functions for instruction and computation classes, with empty |
3260 // implementation. | 3381 // default implementations. |
| 3382 #define DECLARE_VISIT_COMPUTATION(ShortName, ClassName) \ |
| 3383 virtual void Visit##ShortName(ClassName* comp, BindInstr* instr) { } |
| 3384 |
3261 #define DECLARE_VISIT_INSTRUCTION(ShortName) \ | 3385 #define DECLARE_VISIT_INSTRUCTION(ShortName) \ |
3262 virtual void Visit##ShortName(ShortName##Instr* instr) { } | 3386 virtual void Visit##ShortName(ShortName##Instr* instr) { } |
3263 | 3387 |
| 3388 FOR_EACH_COMPUTATION(DECLARE_VISIT_COMPUTATION) |
3264 FOR_EACH_INSTRUCTION(DECLARE_VISIT_INSTRUCTION) | 3389 FOR_EACH_INSTRUCTION(DECLARE_VISIT_INSTRUCTION) |
3265 | 3390 |
| 3391 #undef DECLARE_VISIT_COMPUTATION |
3266 #undef DECLARE_VISIT_INSTRUCTION | 3392 #undef DECLARE_VISIT_INSTRUCTION |
3267 | 3393 |
3268 protected: | 3394 protected: |
3269 const GrowableArray<BlockEntryInstr*>& block_order_; | 3395 const GrowableArray<BlockEntryInstr*>& block_order_; |
3270 ForwardInstructionIterator* current_iterator_; | 3396 ForwardInstructionIterator* current_iterator_; |
3271 | 3397 |
3272 private: | 3398 private: |
3273 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); | 3399 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); |
3274 }; | 3400 }; |
3275 | 3401 |
3276 | 3402 |
3277 } // namespace dart | 3403 } // namespace dart |
3278 | 3404 |
3279 #endif // VM_INTERMEDIATE_LANGUAGE_H_ | 3405 #endif // VM_INTERMEDIATE_LANGUAGE_H_ |
OLD | NEW |