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

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

Issue 10894034: Make constants computations instead of values. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 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"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 class FlowGraphAllocator; 46 class FlowGraphAllocator;
47 class FlowGraphCompiler; 47 class FlowGraphCompiler;
48 class FlowGraphVisitor; 48 class FlowGraphVisitor;
49 class Function; 49 class Function;
50 class LocalVariable; 50 class LocalVariable;
51 51
52 // M is a two argument macro. It is applied to each concrete value's 52 // M is a two argument macro. It is applied to each concrete value's
53 // typename and classname. 53 // typename and classname.
54 #define FOR_EACH_VALUE(M) \ 54 #define FOR_EACH_VALUE(M) \
55 M(Use, UseVal) \ 55 M(Use, UseVal) \
56 M(Constant, ConstantVal) \
57 56
58 57
59 // M is a two argument macro. It is applied to each concrete instruction's 58 // M is a two argument macro. It is applied to each concrete instruction's
60 // (including the values) typename and classname. 59 // (including the values) typename and classname.
61 #define FOR_EACH_COMPUTATION(M) \ 60 #define FOR_EACH_COMPUTATION(M) \
62 M(AssertAssignable, AssertAssignableComp) \ 61 M(AssertAssignable, AssertAssignableComp) \
63 M(AssertBoolean, AssertBooleanComp) \ 62 M(AssertBoolean, AssertBooleanComp) \
64 M(CurrentContext, CurrentContextComp) \ 63 M(CurrentContext, CurrentContextComp) \
65 M(StoreContext, StoreContextComp) \ 64 M(StoreContext, StoreContextComp) \
66 M(ClosureCall, ClosureCallComp) \ 65 M(ClosureCall, ClosureCallComp) \
(...skipping 30 matching lines...) Expand all
97 M(BinarySmiOp, BinarySmiOpComp) \ 96 M(BinarySmiOp, BinarySmiOpComp) \
98 M(BinaryMintOp, BinaryMintOpComp) \ 97 M(BinaryMintOp, BinaryMintOpComp) \
99 M(BinaryDoubleOp, BinaryDoubleOpComp) \ 98 M(BinaryDoubleOp, BinaryDoubleOpComp) \
100 M(UnarySmiOp, UnarySmiOpComp) \ 99 M(UnarySmiOp, UnarySmiOpComp) \
101 M(NumberNegate, NumberNegateComp) \ 100 M(NumberNegate, NumberNegateComp) \
102 M(CheckStackOverflow, CheckStackOverflowComp) \ 101 M(CheckStackOverflow, CheckStackOverflowComp) \
103 M(DoubleToDouble, DoubleToDoubleComp) \ 102 M(DoubleToDouble, DoubleToDoubleComp) \
104 M(SmiToDouble, SmiToDoubleComp) \ 103 M(SmiToDouble, SmiToDoubleComp) \
105 M(CheckClass, CheckClassComp) \ 104 M(CheckClass, CheckClassComp) \
106 M(CheckSmi, CheckSmiComp) \ 105 M(CheckSmi, CheckSmiComp) \
107 M(Materialize, MaterializeComp) \ 106 M(Constant, ConstantComp) \
108 M(CheckEitherNonSmi, CheckEitherNonSmiComp) \ 107 M(CheckEitherNonSmi, CheckEitherNonSmiComp) \
109 M(UnboxedDoubleBinaryOp, UnboxedDoubleBinaryOpComp) \ 108 M(UnboxedDoubleBinaryOp, UnboxedDoubleBinaryOpComp) \
110 M(UnboxDouble, UnboxDoubleComp) \ 109 M(UnboxDouble, UnboxDoubleComp) \
111 M(BoxDouble, BoxDoubleComp) 110 M(BoxDouble, BoxDoubleComp)
112 111
113 112
114 #define FORWARD_DECLARATION(ShortName, ClassName) class ClassName; 113 #define FORWARD_DECLARATION(ShortName, ClassName) class ClassName;
115 FOR_EACH_COMPUTATION(FORWARD_DECLARATION) 114 FOR_EACH_COMPUTATION(FORWARD_DECLARATION)
116 FOR_EACH_VALUE(FORWARD_DECLARATION) 115 FOR_EACH_VALUE(FORWARD_DECLARATION)
117 #undef FORWARD_DECLARATION 116 #undef FORWARD_DECLARATION
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
453 private: 452 private:
454 Definition* definition_; 453 Definition* definition_;
455 UseVal* next_use_; 454 UseVal* next_use_;
456 Instruction* instruction_; 455 Instruction* instruction_;
457 intptr_t use_index_; 456 intptr_t use_index_;
458 457
459 DISALLOW_COPY_AND_ASSIGN(UseVal); 458 DISALLOW_COPY_AND_ASSIGN(UseVal);
460 }; 459 };
461 460
462 461
463 class ConstantVal : public Value { 462 #undef DECLARE_VALUE
463
464
465 class ConstantComp : public TemplateComputation<0> {
464 public: 466 public:
465 explicit ConstantVal(const Object& value) 467 explicit ConstantComp(const Object& value) : value_(value) { }
466 : value_(value) {
467 ASSERT(value.IsZoneHandle());
468 ASSERT(value.IsSmi() || value.IsOld());
469 }
470 468
471 DECLARE_VALUE(Constant) 469 DECLARE_COMPUTATION(Constant)
472 470
473 const Object& value() const { return value_; } 471 const Object& value() const { return value_; }
474 472
475 // Returns true if the value represents a constant. 473 virtual void PrintOperandsTo(BufferFormatter* f) const;
476 virtual bool BindsToConstant() const { return true; }
477 virtual const Object& BoundConstant() const { return value(); }
478
479 // Returns true if the value represents constant null.
480 virtual bool BindsToConstantNull() const { return value().IsNull(); }
481 474
482 virtual bool CanDeoptimize() const { return false; } 475 virtual bool CanDeoptimize() const { return false; }
483 476
484 virtual intptr_t ResultCid() const; 477 virtual intptr_t ResultCid() const;
485 478
486 virtual Value* CopyValue() { return this; } 479 virtual bool AttributesEqual(Computation* other) const;
487 480
488 private: 481 private:
489 const Object& value_; 482 const Object& value_;
490 483
491 DISALLOW_COPY_AND_ASSIGN(ConstantVal); 484 DISALLOW_COPY_AND_ASSIGN(ConstantComp);
492 };
493
494 #undef DECLARE_VALUE
495
496
497 class MaterializeComp : public TemplateComputation<0> {
498 public:
499 explicit MaterializeComp(ConstantVal* constant_val)
500 : constant_val_(constant_val) { }
501
502 DECLARE_COMPUTATION(Materialize)
503
504 virtual void PrintOperandsTo(BufferFormatter* f) const;
505
506 virtual bool CanDeoptimize() const { return false; }
507
508 ConstantVal* constant_val() const { return constant_val_; }
509
510 virtual intptr_t ResultCid() const;
511
512 private:
513 ConstantVal* constant_val_;
514 }; 485 };
515 486
516 487
517 class AssertAssignableComp : public TemplateComputation<3> { 488 class AssertAssignableComp : public TemplateComputation<3> {
518 public: 489 public:
519 AssertAssignableComp(intptr_t token_pos, 490 AssertAssignableComp(intptr_t token_pos,
520 intptr_t try_index, 491 intptr_t try_index,
521 Value* value, 492 Value* value,
522 Value* instantiator, 493 Value* instantiator,
523 Value* instantiator_type_arguments, 494 Value* instantiator_type_arguments,
(...skipping 2081 matching lines...) Expand 10 before | Expand all | Expand 10 after
2605 Instruction* Current() const { return current_; } 2576 Instruction* Current() const { return current_; }
2606 2577
2607 private: 2578 private:
2608 BlockEntryInstr* block_entry_; 2579 BlockEntryInstr* block_entry_;
2609 Instruction* current_; 2580 Instruction* current_;
2610 }; 2581 };
2611 2582
2612 2583
2613 class GraphEntryInstr : public BlockEntryInstr { 2584 class GraphEntryInstr : public BlockEntryInstr {
2614 public: 2585 public:
2615 explicit GraphEntryInstr(TargetEntryInstr* normal_entry) 2586 explicit GraphEntryInstr(TargetEntryInstr* normal_entry);
2616 : BlockEntryInstr(),
2617 normal_entry_(normal_entry),
2618 catch_entries_(),
2619 start_env_(NULL),
2620 spill_slot_count_(0) { }
2621 2587
2622 DECLARE_INSTRUCTION(GraphEntry) 2588 DECLARE_INSTRUCTION(GraphEntry)
2623 2589
2624 virtual intptr_t PredecessorCount() const { return 0; } 2590 virtual intptr_t PredecessorCount() const { return 0; }
2625 virtual BlockEntryInstr* PredecessorAt(intptr_t index) const { 2591 virtual BlockEntryInstr* PredecessorAt(intptr_t index) const {
2626 UNREACHABLE(); 2592 UNREACHABLE();
2627 return NULL; 2593 return NULL;
2628 } 2594 }
2629 virtual void AddPredecessor(BlockEntryInstr* predecessor) { UNREACHABLE(); } 2595 virtual void AddPredecessor(BlockEntryInstr* predecessor) { UNREACHABLE(); }
2630 2596
2631 virtual intptr_t SuccessorCount() const; 2597 virtual intptr_t SuccessorCount() const;
2632 virtual BlockEntryInstr* SuccessorAt(intptr_t index) const; 2598 virtual BlockEntryInstr* SuccessorAt(intptr_t index) const;
2633 2599
2634 virtual void DiscoverBlocks( 2600 virtual void DiscoverBlocks(
2635 BlockEntryInstr* current_block, 2601 BlockEntryInstr* current_block,
2636 GrowableArray<BlockEntryInstr*>* preorder, 2602 GrowableArray<BlockEntryInstr*>* preorder,
2637 GrowableArray<BlockEntryInstr*>* postorder, 2603 GrowableArray<BlockEntryInstr*>* postorder,
2638 GrowableArray<intptr_t>* parent, 2604 GrowableArray<intptr_t>* parent,
2639 GrowableArray<BitVector*>* assigned_vars, 2605 GrowableArray<BitVector*>* assigned_vars,
2640 intptr_t variable_count, 2606 intptr_t variable_count,
2641 intptr_t fixed_parameter_count); 2607 intptr_t fixed_parameter_count);
2642 2608
2643 void AddCatchEntry(TargetEntryInstr* entry) { catch_entries_.Add(entry); } 2609 void AddCatchEntry(TargetEntryInstr* entry) { catch_entries_.Add(entry); }
2644 2610
2645 virtual void PrepareEntry(FlowGraphCompiler* compiler); 2611 virtual void PrepareEntry(FlowGraphCompiler* compiler);
2646 2612
2647 Environment* start_env() const { return start_env_; } 2613 Environment* start_env() const { return start_env_; }
2648 void set_start_env(Environment* env) { start_env_ = env; } 2614 void set_start_env(Environment* env) { start_env_ = env; }
2649 2615
2616 Definition* constant_null() const { return constant_null_; }
2617
2650 intptr_t spill_slot_count() const { return spill_slot_count_; } 2618 intptr_t spill_slot_count() const { return spill_slot_count_; }
2651 void set_spill_slot_count(intptr_t count) { 2619 void set_spill_slot_count(intptr_t count) {
2652 ASSERT(count >= 0); 2620 ASSERT(count >= 0);
2653 spill_slot_count_ = count; 2621 spill_slot_count_ = count;
2654 } 2622 }
2655 2623
2656 private: 2624 private:
2657 TargetEntryInstr* normal_entry_; 2625 TargetEntryInstr* normal_entry_;
2658 GrowableArray<TargetEntryInstr*> catch_entries_; 2626 GrowableArray<TargetEntryInstr*> catch_entries_;
2659 Environment* start_env_; 2627 Environment* start_env_;
2628 Definition* constant_null_;
2660 intptr_t spill_slot_count_; 2629 intptr_t spill_slot_count_;
2661 2630
2662 DISALLOW_COPY_AND_ASSIGN(GraphEntryInstr); 2631 DISALLOW_COPY_AND_ASSIGN(GraphEntryInstr);
2663 }; 2632 };
2664 2633
2665 2634
2666 class JoinEntryInstr : public BlockEntryInstr { 2635 class JoinEntryInstr : public BlockEntryInstr {
2667 public: 2636 public:
2668 JoinEntryInstr() 2637 JoinEntryInstr()
2669 : BlockEntryInstr(), 2638 : BlockEntryInstr(),
(...skipping 728 matching lines...) Expand 10 before | Expand all | Expand 10 after
3398 ForwardInstructionIterator* current_iterator_; 3367 ForwardInstructionIterator* current_iterator_;
3399 3368
3400 private: 3369 private:
3401 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); 3370 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor);
3402 }; 3371 };
3403 3372
3404 3373
3405 } // namespace dart 3374 } // namespace dart
3406 3375
3407 #endif // VM_INTERMEDIATE_LANGUAGE_H_ 3376 #endif // VM_INTERMEDIATE_LANGUAGE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698