| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef VM_INTERMEDIATE_LANGUAGE_H_ | 5 #ifndef VM_INTERMEDIATE_LANGUAGE_H_ |
| 6 #define VM_INTERMEDIATE_LANGUAGE_H_ | 6 #define VM_INTERMEDIATE_LANGUAGE_H_ |
| 7 | 7 |
| 8 #include "vm/allocation.h" | 8 #include "vm/allocation.h" |
| 9 #include "vm/ast.h" | 9 #include "vm/ast.h" |
| 10 #include "vm/growable_array.h" | 10 #include "vm/growable_array.h" |
| (...skipping 538 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 549 intptr_t use_index() const { return use_index_; } | 549 intptr_t use_index() const { return use_index_; } |
| 550 void set_use_index(intptr_t index) { use_index_ = index; } | 550 void set_use_index(intptr_t index) { use_index_ = index; } |
| 551 | 551 |
| 552 static void AddToList(Value* value, Value** list); | 552 static void AddToList(Value* value, Value** list); |
| 553 void RemoveFromUseList(); | 553 void RemoveFromUseList(); |
| 554 | 554 |
| 555 // Change the definition after use lists have been computed. | 555 // Change the definition after use lists have been computed. |
| 556 inline void BindTo(Definition* definition); | 556 inline void BindTo(Definition* definition); |
| 557 inline void BindToEnvironment(Definition* definition); | 557 inline void BindToEnvironment(Definition* definition); |
| 558 | 558 |
| 559 Value* Copy() { return new Value(definition_); } | 559 Value* Copy(Isolate* isolate) { return new(isolate) Value(definition_); } |
| 560 | 560 |
| 561 // This function must only be used when the new Value is dominated by | 561 // This function must only be used when the new Value is dominated by |
| 562 // the original Value. | 562 // the original Value. |
| 563 Value* CopyWithType() { | 563 Value* CopyWithType() { |
| 564 Value* copy = new Value(definition_); | 564 Value* copy = new Value(definition_); |
| 565 copy->reaching_type_ = reaching_type_; | 565 copy->reaching_type_ = reaching_type_; |
| 566 return copy; | 566 return copy; |
| 567 } | 567 } |
| 568 | 568 |
| 569 CompileType* Type(); | 569 CompileType* Type(); |
| (...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1019 bool Equals(Instruction* other) const; | 1019 bool Equals(Instruction* other) const; |
| 1020 | 1020 |
| 1021 // Compare attributes of a instructions (except input operands and tag). | 1021 // Compare attributes of a instructions (except input operands and tag). |
| 1022 // All instructions that participate in CSE have to override this function. | 1022 // All instructions that participate in CSE have to override this function. |
| 1023 // This function can assume that the argument has the same type as this. | 1023 // This function can assume that the argument has the same type as this. |
| 1024 virtual bool AttributesEqual(Instruction* other) const { | 1024 virtual bool AttributesEqual(Instruction* other) const { |
| 1025 UNREACHABLE(); | 1025 UNREACHABLE(); |
| 1026 return false; | 1026 return false; |
| 1027 } | 1027 } |
| 1028 | 1028 |
| 1029 virtual void InheritDeoptTarget(Instruction* other); | 1029 virtual void InheritDeoptTarget(Isolate* isolate, Instruction* other); |
| 1030 | 1030 |
| 1031 bool NeedsEnvironment() const { | 1031 bool NeedsEnvironment() const { |
| 1032 return CanDeoptimize() || CanBecomeDeoptimizationTarget(); | 1032 return CanDeoptimize() || CanBecomeDeoptimizationTarget(); |
| 1033 } | 1033 } |
| 1034 | 1034 |
| 1035 virtual bool CanBecomeDeoptimizationTarget() const { | 1035 virtual bool CanBecomeDeoptimizationTarget() const { |
| 1036 return false; | 1036 return false; |
| 1037 } | 1037 } |
| 1038 | 1038 |
| 1039 void InheritDeoptTargetAfter(Instruction* other); | 1039 void InheritDeoptTargetAfter(Isolate* isolate, Instruction* other); |
| 1040 | 1040 |
| 1041 virtual bool MayThrow() const = 0; | 1041 virtual bool MayThrow() const = 0; |
| 1042 | 1042 |
| 1043 protected: | 1043 protected: |
| 1044 // Fetch deopt id without checking if this computation can deoptimize. | 1044 // Fetch deopt id without checking if this computation can deoptimize. |
| 1045 intptr_t GetDeoptId() const { | 1045 intptr_t GetDeoptId() const { |
| 1046 return deopt_id_; | 1046 return deopt_id_; |
| 1047 } | 1047 } |
| 1048 | 1048 |
| 1049 private: | 1049 private: |
| (...skipping 1359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2409 } | 2409 } |
| 2410 | 2410 |
| 2411 void set_constant_target(TargetEntryInstr* target) { | 2411 void set_constant_target(TargetEntryInstr* target) { |
| 2412 ASSERT(target == true_successor() || target == false_successor()); | 2412 ASSERT(target == true_successor() || target == false_successor()); |
| 2413 constant_target_ = target; | 2413 constant_target_ = target; |
| 2414 } | 2414 } |
| 2415 TargetEntryInstr* constant_target() const { | 2415 TargetEntryInstr* constant_target() const { |
| 2416 return constant_target_; | 2416 return constant_target_; |
| 2417 } | 2417 } |
| 2418 | 2418 |
| 2419 virtual void InheritDeoptTarget(Instruction* other); | 2419 virtual void InheritDeoptTarget(Isolate* isolate, Instruction* other); |
| 2420 | 2420 |
| 2421 virtual bool MayThrow() const { | 2421 virtual bool MayThrow() const { |
| 2422 return comparison()->MayThrow(); | 2422 return comparison()->MayThrow(); |
| 2423 } | 2423 } |
| 2424 | 2424 |
| 2425 TargetEntryInstr* true_successor() const { return true_successor_; } | 2425 TargetEntryInstr* true_successor() const { return true_successor_; } |
| 2426 TargetEntryInstr* false_successor() const { return false_successor_; } | 2426 TargetEntryInstr* false_successor() const { return false_successor_; } |
| 2427 | 2427 |
| 2428 TargetEntryInstr** true_successor_address() { return &true_successor_; } | 2428 TargetEntryInstr** true_successor_address() { return &true_successor_; } |
| 2429 TargetEntryInstr** false_successor_address() { return &false_successor_; } | 2429 TargetEntryInstr** false_successor_address() { return &false_successor_; } |
| (...skipping 5411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7841 void SkipDone() { | 7841 void SkipDone() { |
| 7842 while (!Done() && iterator_.Done()) { | 7842 while (!Done() && iterator_.Done()) { |
| 7843 iterator_ = ShallowIterator(iterator_.environment()->outer()); | 7843 iterator_ = ShallowIterator(iterator_.environment()->outer()); |
| 7844 } | 7844 } |
| 7845 } | 7845 } |
| 7846 | 7846 |
| 7847 ShallowIterator iterator_; | 7847 ShallowIterator iterator_; |
| 7848 }; | 7848 }; |
| 7849 | 7849 |
| 7850 // Construct an environment by constructing uses from an array of definitions. | 7850 // Construct an environment by constructing uses from an array of definitions. |
| 7851 static Environment* From(const GrowableArray<Definition*>& definitions, | 7851 static Environment* From(Isolate* isolate, |
| 7852 const GrowableArray<Definition*>& definitions, |
| 7852 intptr_t fixed_parameter_count, | 7853 intptr_t fixed_parameter_count, |
| 7853 const Code& code); | 7854 const Code& code); |
| 7854 | 7855 |
| 7855 void set_locations(Location* locations) { | 7856 void set_locations(Location* locations) { |
| 7856 ASSERT(locations_ == NULL); | 7857 ASSERT(locations_ == NULL); |
| 7857 locations_ = locations; | 7858 locations_ = locations; |
| 7858 } | 7859 } |
| 7859 | 7860 |
| 7860 void set_deopt_id(intptr_t deopt_id) { deopt_id_ = deopt_id; } | 7861 void set_deopt_id(intptr_t deopt_id) { deopt_id_ = deopt_id; } |
| 7861 intptr_t deopt_id() const { return deopt_id_; } | 7862 intptr_t deopt_id() const { return deopt_id_; } |
| (...skipping 23 matching lines...) Expand all Loading... |
| 7885 } | 7886 } |
| 7886 return env->ValueAt(index); | 7887 return env->ValueAt(index); |
| 7887 } | 7888 } |
| 7888 | 7889 |
| 7889 intptr_t fixed_parameter_count() const { | 7890 intptr_t fixed_parameter_count() const { |
| 7890 return fixed_parameter_count_; | 7891 return fixed_parameter_count_; |
| 7891 } | 7892 } |
| 7892 | 7893 |
| 7893 const Code& code() const { return code_; } | 7894 const Code& code() const { return code_; } |
| 7894 | 7895 |
| 7895 Environment* DeepCopy() const { return DeepCopy(Length()); } | 7896 Environment* DeepCopy(Isolate* isolate) const { |
| 7897 return DeepCopy(isolate, Length()); |
| 7898 } |
| 7896 | 7899 |
| 7897 void DeepCopyTo(Instruction* instr) const; | 7900 void DeepCopyTo(Isolate* isolate, Instruction* instr) const; |
| 7898 void DeepCopyToOuter(Instruction* instr) const; | 7901 void DeepCopyToOuter(Isolate* isolate, Instruction* instr) const; |
| 7899 | 7902 |
| 7900 void PrintTo(BufferFormatter* f) const; | 7903 void PrintTo(BufferFormatter* f) const; |
| 7901 const char* ToCString() const; | 7904 const char* ToCString() const; |
| 7902 | 7905 |
| 7903 // Deep copy an environment. The 'length' parameter may be less than the | 7906 // Deep copy an environment. The 'length' parameter may be less than the |
| 7904 // environment's length in order to drop values (e.g., passed arguments) | 7907 // environment's length in order to drop values (e.g., passed arguments) |
| 7905 // from the copy. | 7908 // from the copy. |
| 7906 Environment* DeepCopy(intptr_t length) const; | 7909 Environment* DeepCopy(Isolate* isolate, intptr_t length) const; |
| 7907 | 7910 |
| 7908 private: | 7911 private: |
| 7909 friend class ShallowIterator; | 7912 friend class ShallowIterator; |
| 7910 | 7913 |
| 7911 Environment(intptr_t length, | 7914 Environment(intptr_t length, |
| 7912 intptr_t fixed_parameter_count, | 7915 intptr_t fixed_parameter_count, |
| 7913 intptr_t deopt_id, | 7916 intptr_t deopt_id, |
| 7914 const Code& code, | 7917 const Code& code, |
| 7915 Environment* outer) | 7918 Environment* outer) |
| 7916 : values_(length), | 7919 : values_(length), |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7962 ForwardInstructionIterator* current_iterator_; | 7965 ForwardInstructionIterator* current_iterator_; |
| 7963 | 7966 |
| 7964 private: | 7967 private: |
| 7965 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); | 7968 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); |
| 7966 }; | 7969 }; |
| 7967 | 7970 |
| 7968 | 7971 |
| 7969 } // namespace dart | 7972 } // namespace dart |
| 7970 | 7973 |
| 7971 #endif // VM_INTERMEDIATE_LANGUAGE_H_ | 7974 #endif // VM_INTERMEDIATE_LANGUAGE_H_ |
| OLD | NEW |