| 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 3843 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3854 const intptr_t token_pos_; | 3854 const intptr_t token_pos_; |
| 3855 const Class& cls_; | 3855 const Class& cls_; |
| 3856 ZoneGrowableArray<PushArgumentInstr*>* const arguments_; | 3856 ZoneGrowableArray<PushArgumentInstr*>* const arguments_; |
| 3857 AliasIdentity identity_; | 3857 AliasIdentity identity_; |
| 3858 Function& closure_function_; | 3858 Function& closure_function_; |
| 3859 | 3859 |
| 3860 DISALLOW_COPY_AND_ASSIGN(AllocateObjectInstr); | 3860 DISALLOW_COPY_AND_ASSIGN(AllocateObjectInstr); |
| 3861 }; | 3861 }; |
| 3862 | 3862 |
| 3863 | 3863 |
| 3864 class AllocateUninitializedContextInstr |
| 3865 : public TemplateDefinition<0, NoThrow> { |
| 3866 public: |
| 3867 AllocateUninitializedContextInstr(intptr_t token_pos, |
| 3868 intptr_t num_context_variables) |
| 3869 : token_pos_(token_pos), |
| 3870 num_context_variables_(num_context_variables), |
| 3871 identity_(AliasIdentity::Unknown()) {} |
| 3872 |
| 3873 DECLARE_INSTRUCTION(AllocateUninitializedContext) |
| 3874 virtual CompileType ComputeType() const; |
| 3875 |
| 3876 virtual intptr_t token_pos() const { return token_pos_; } |
| 3877 intptr_t num_context_variables() const { return num_context_variables_; } |
| 3878 |
| 3879 virtual void PrintOperandsTo(BufferFormatter* f) const; |
| 3880 |
| 3881 virtual bool CanDeoptimize() const { return false; } |
| 3882 |
| 3883 virtual EffectSet Effects() const { return EffectSet::None(); } |
| 3884 |
| 3885 virtual AliasIdentity Identity() const { return identity_; } |
| 3886 virtual void SetIdentity(AliasIdentity identity) { identity_ = identity; } |
| 3887 |
| 3888 private: |
| 3889 const intptr_t token_pos_; |
| 3890 const intptr_t num_context_variables_; |
| 3891 AliasIdentity identity_; |
| 3892 |
| 3893 DISALLOW_COPY_AND_ASSIGN(AllocateUninitializedContextInstr); |
| 3894 }; |
| 3895 |
| 3896 |
| 3864 // This instruction captures the state of the object which had its allocation | 3897 // This instruction captures the state of the object which had its allocation |
| 3865 // removed during the AllocationSinking pass. | 3898 // removed during the AllocationSinking pass. |
| 3866 // It does not produce any real code only deoptimization information. | 3899 // It does not produce any real code only deoptimization information. |
| 3867 class MaterializeObjectInstr : public Definition { | 3900 class MaterializeObjectInstr : public Definition { |
| 3868 public: | 3901 public: |
| 3869 MaterializeObjectInstr(AllocateObjectInstr* allocation, | 3902 MaterializeObjectInstr(AllocateObjectInstr* allocation, |
| 3870 const Class& cls, | |
| 3871 const ZoneGrowableArray<const Object*>& slots, | 3903 const ZoneGrowableArray<const Object*>& slots, |
| 3872 ZoneGrowableArray<Value*>* values) | 3904 ZoneGrowableArray<Value*>* values) |
| 3873 : allocation_(allocation), | 3905 : allocation_(allocation), |
| 3874 cls_(cls), | 3906 cls_(allocation->cls()), |
| 3907 num_variables_(-1), |
| 3875 slots_(slots), | 3908 slots_(slots), |
| 3876 values_(values), | 3909 values_(values), |
| 3877 locations_(NULL), | 3910 locations_(NULL), |
| 3878 visited_for_liveness_(false), | 3911 visited_for_liveness_(false), |
| 3879 registers_remapped_(false) { | 3912 registers_remapped_(false) { |
| 3880 ASSERT(slots_.length() == values_->length()); | 3913 ASSERT(slots_.length() == values_->length()); |
| 3881 for (intptr_t i = 0; i < InputCount(); i++) { | 3914 for (intptr_t i = 0; i < InputCount(); i++) { |
| 3882 InputAt(i)->set_instruction(this); | 3915 InputAt(i)->set_instruction(this); |
| 3883 InputAt(i)->set_use_index(i); | 3916 InputAt(i)->set_use_index(i); |
| 3884 } | 3917 } |
| 3885 } | 3918 } |
| 3886 | 3919 |
| 3887 AllocateObjectInstr* allocation() const { return allocation_; } | 3920 MaterializeObjectInstr(AllocateUninitializedContextInstr* allocation, |
| 3921 const ZoneGrowableArray<const Object*>& slots, |
| 3922 ZoneGrowableArray<Value*>* values) |
| 3923 : allocation_(allocation), |
| 3924 cls_(Class::ZoneHandle(Object::context_class())), |
| 3925 num_variables_(allocation->num_context_variables()), |
| 3926 slots_(slots), |
| 3927 values_(values), |
| 3928 locations_(NULL), |
| 3929 visited_for_liveness_(false), |
| 3930 registers_remapped_(false) { |
| 3931 ASSERT(slots_.length() == values_->length()); |
| 3932 for (intptr_t i = 0; i < InputCount(); i++) { |
| 3933 InputAt(i)->set_instruction(this); |
| 3934 InputAt(i)->set_use_index(i); |
| 3935 } |
| 3936 } |
| 3937 |
| 3938 Definition* allocation() const { return allocation_; } |
| 3888 const Class& cls() const { return cls_; } | 3939 const Class& cls() const { return cls_; } |
| 3940 |
| 3941 intptr_t num_variables() const { |
| 3942 return num_variables_; |
| 3943 } |
| 3944 |
| 3889 intptr_t FieldOffsetAt(intptr_t i) const { | 3945 intptr_t FieldOffsetAt(intptr_t i) const { |
| 3890 return slots_[i]->IsField() | 3946 return slots_[i]->IsField() |
| 3891 ? Field::Cast(*slots_[i]).Offset() | 3947 ? Field::Cast(*slots_[i]).Offset() |
| 3892 : Smi::Cast(*slots_[i]).Value(); | 3948 : Smi::Cast(*slots_[i]).Value(); |
| 3893 } | 3949 } |
| 3950 |
| 3894 const Location& LocationAt(intptr_t i) { | 3951 const Location& LocationAt(intptr_t i) { |
| 3895 return locations_[i]; | 3952 return locations_[i]; |
| 3896 } | 3953 } |
| 3897 | 3954 |
| 3898 DECLARE_INSTRUCTION(MaterializeObject) | 3955 DECLARE_INSTRUCTION(MaterializeObject) |
| 3899 virtual void PrintOperandsTo(BufferFormatter* f) const; | 3956 virtual void PrintOperandsTo(BufferFormatter* f) const; |
| 3900 | 3957 |
| 3901 virtual intptr_t InputCount() const { | 3958 virtual intptr_t InputCount() const { |
| 3902 return values_->length(); | 3959 return values_->length(); |
| 3903 } | 3960 } |
| (...skipping 26 matching lines...) Expand all Loading... |
| 3930 bool was_visited_for_liveness() const { return visited_for_liveness_; } | 3987 bool was_visited_for_liveness() const { return visited_for_liveness_; } |
| 3931 void mark_visited_for_liveness() { | 3988 void mark_visited_for_liveness() { |
| 3932 visited_for_liveness_ = true; | 3989 visited_for_liveness_ = true; |
| 3933 } | 3990 } |
| 3934 | 3991 |
| 3935 private: | 3992 private: |
| 3936 virtual void RawSetInputAt(intptr_t i, Value* value) { | 3993 virtual void RawSetInputAt(intptr_t i, Value* value) { |
| 3937 (*values_)[i] = value; | 3994 (*values_)[i] = value; |
| 3938 } | 3995 } |
| 3939 | 3996 |
| 3940 AllocateObjectInstr* allocation_; | 3997 Definition* allocation_; |
| 3941 const Class& cls_; | 3998 const Class& cls_; |
| 3999 intptr_t num_variables_; |
| 3942 const ZoneGrowableArray<const Object*>& slots_; | 4000 const ZoneGrowableArray<const Object*>& slots_; |
| 3943 ZoneGrowableArray<Value*>* values_; | 4001 ZoneGrowableArray<Value*>* values_; |
| 3944 Location* locations_; | 4002 Location* locations_; |
| 3945 | 4003 |
| 3946 bool visited_for_liveness_; | 4004 bool visited_for_liveness_; |
| 3947 bool registers_remapped_; | 4005 bool registers_remapped_; |
| 3948 | 4006 |
| 3949 DISALLOW_COPY_AND_ASSIGN(MaterializeObjectInstr); | 4007 DISALLOW_COPY_AND_ASSIGN(MaterializeObjectInstr); |
| 3950 }; | 4008 }; |
| 3951 | 4009 |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4221 | 4279 |
| 4222 DISALLOW_COPY_AND_ASSIGN(InstantiateTypeArgumentsInstr); | 4280 DISALLOW_COPY_AND_ASSIGN(InstantiateTypeArgumentsInstr); |
| 4223 }; | 4281 }; |
| 4224 | 4282 |
| 4225 | 4283 |
| 4226 class AllocateContextInstr : public TemplateDefinition<0, NoThrow> { | 4284 class AllocateContextInstr : public TemplateDefinition<0, NoThrow> { |
| 4227 public: | 4285 public: |
| 4228 AllocateContextInstr(intptr_t token_pos, | 4286 AllocateContextInstr(intptr_t token_pos, |
| 4229 intptr_t num_context_variables) | 4287 intptr_t num_context_variables) |
| 4230 : token_pos_(token_pos), | 4288 : token_pos_(token_pos), |
| 4231 num_context_variables_(num_context_variables) {} | 4289 num_context_variables_(num_context_variables) { } |
| 4232 | 4290 |
| 4233 DECLARE_INSTRUCTION(AllocateContext) | 4291 DECLARE_INSTRUCTION(AllocateContext) |
| 4234 virtual CompileType ComputeType() const; | 4292 virtual CompileType ComputeType() const; |
| 4235 | 4293 |
| 4236 virtual intptr_t token_pos() const { return token_pos_; } | 4294 virtual intptr_t token_pos() const { return token_pos_; } |
| 4237 intptr_t num_context_variables() const { return num_context_variables_; } | 4295 intptr_t num_context_variables() const { return num_context_variables_; } |
| 4238 | 4296 |
| 4239 virtual void PrintOperandsTo(BufferFormatter* f) const; | 4297 virtual void PrintOperandsTo(BufferFormatter* f) const; |
| 4240 | 4298 |
| 4241 virtual bool CanDeoptimize() const { return false; } | 4299 virtual bool CanDeoptimize() const { return false; } |
| (...skipping 25 matching lines...) Expand all Loading... |
| 4267 virtual EffectSet Effects() const { return EffectSet::All(); } | 4325 virtual EffectSet Effects() const { return EffectSet::All(); } |
| 4268 virtual Instruction* Canonicalize(FlowGraph* flow_graph); | 4326 virtual Instruction* Canonicalize(FlowGraph* flow_graph); |
| 4269 | 4327 |
| 4270 private: | 4328 private: |
| 4271 const Field& field_; | 4329 const Field& field_; |
| 4272 | 4330 |
| 4273 DISALLOW_COPY_AND_ASSIGN(InitStaticFieldInstr); | 4331 DISALLOW_COPY_AND_ASSIGN(InitStaticFieldInstr); |
| 4274 }; | 4332 }; |
| 4275 | 4333 |
| 4276 | 4334 |
| 4277 class AllocateUninitializedContextInstr | |
| 4278 : public TemplateDefinition<0, NoThrow> { | |
| 4279 public: | |
| 4280 AllocateUninitializedContextInstr(intptr_t token_pos, | |
| 4281 intptr_t num_context_variables) | |
| 4282 : token_pos_(token_pos), | |
| 4283 num_context_variables_(num_context_variables) {} | |
| 4284 | |
| 4285 DECLARE_INSTRUCTION(AllocateUninitializedContext) | |
| 4286 virtual CompileType ComputeType() const; | |
| 4287 | |
| 4288 virtual intptr_t token_pos() const { return token_pos_; } | |
| 4289 intptr_t num_context_variables() const { return num_context_variables_; } | |
| 4290 | |
| 4291 virtual void PrintOperandsTo(BufferFormatter* f) const; | |
| 4292 | |
| 4293 virtual bool CanDeoptimize() const { return false; } | |
| 4294 | |
| 4295 virtual EffectSet Effects() const { return EffectSet::None(); } | |
| 4296 | |
| 4297 private: | |
| 4298 const intptr_t token_pos_; | |
| 4299 const intptr_t num_context_variables_; | |
| 4300 | |
| 4301 DISALLOW_COPY_AND_ASSIGN(AllocateUninitializedContextInstr); | |
| 4302 }; | |
| 4303 | |
| 4304 | |
| 4305 class CloneContextInstr : public TemplateDefinition<1, NoThrow> { | 4335 class CloneContextInstr : public TemplateDefinition<1, NoThrow> { |
| 4306 public: | 4336 public: |
| 4307 CloneContextInstr(intptr_t token_pos, Value* context_value) | 4337 CloneContextInstr(intptr_t token_pos, Value* context_value) |
| 4308 : TemplateDefinition(Isolate::Current()->GetNextDeoptId()), | 4338 : TemplateDefinition(Isolate::Current()->GetNextDeoptId()), |
| 4309 token_pos_(token_pos) { | 4339 token_pos_(token_pos) { |
| 4310 SetInputAt(0, context_value); | 4340 SetInputAt(0, context_value); |
| 4311 } | 4341 } |
| 4312 | 4342 |
| 4313 virtual intptr_t token_pos() const { return token_pos_; } | 4343 virtual intptr_t token_pos() const { return token_pos_; } |
| 4314 Value* context_value() const { return inputs_[0]; } | 4344 Value* context_value() const { return inputs_[0]; } |
| (...skipping 3425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7740 Isolate* isolate, bool opt) const { \ | 7770 Isolate* isolate, bool opt) const { \ |
| 7741 UNIMPLEMENTED(); \ | 7771 UNIMPLEMENTED(); \ |
| 7742 return NULL; \ | 7772 return NULL; \ |
| 7743 } \ | 7773 } \ |
| 7744 void Name::EmitNativeCode(FlowGraphCompiler* compiler) { UNIMPLEMENTED(); } | 7774 void Name::EmitNativeCode(FlowGraphCompiler* compiler) { UNIMPLEMENTED(); } |
| 7745 | 7775 |
| 7746 | 7776 |
| 7747 } // namespace dart | 7777 } // namespace dart |
| 7748 | 7778 |
| 7749 #endif // VM_INTERMEDIATE_LANGUAGE_H_ | 7779 #endif // VM_INTERMEDIATE_LANGUAGE_H_ |
| OLD | NEW |