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 3865 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3876 const intptr_t token_pos_; | 3876 const intptr_t token_pos_; |
3877 const Class& cls_; | 3877 const Class& cls_; |
3878 ZoneGrowableArray<PushArgumentInstr*>* const arguments_; | 3878 ZoneGrowableArray<PushArgumentInstr*>* const arguments_; |
3879 AliasIdentity identity_; | 3879 AliasIdentity identity_; |
3880 Function& closure_function_; | 3880 Function& closure_function_; |
3881 | 3881 |
3882 DISALLOW_COPY_AND_ASSIGN(AllocateObjectInstr); | 3882 DISALLOW_COPY_AND_ASSIGN(AllocateObjectInstr); |
3883 }; | 3883 }; |
3884 | 3884 |
3885 | 3885 |
| 3886 class AllocateUninitializedContextInstr |
| 3887 : public TemplateDefinition<0, NoThrow> { |
| 3888 public: |
| 3889 AllocateUninitializedContextInstr(intptr_t token_pos, |
| 3890 intptr_t num_context_variables) |
| 3891 : token_pos_(token_pos), |
| 3892 num_context_variables_(num_context_variables), |
| 3893 identity_(AliasIdentity::Unknown()) {} |
| 3894 |
| 3895 DECLARE_INSTRUCTION(AllocateUninitializedContext) |
| 3896 virtual CompileType ComputeType() const; |
| 3897 |
| 3898 virtual intptr_t token_pos() const { return token_pos_; } |
| 3899 intptr_t num_context_variables() const { return num_context_variables_; } |
| 3900 |
| 3901 virtual void PrintOperandsTo(BufferFormatter* f) const; |
| 3902 |
| 3903 virtual bool CanDeoptimize() const { return false; } |
| 3904 |
| 3905 virtual EffectSet Effects() const { return EffectSet::None(); } |
| 3906 |
| 3907 virtual AliasIdentity Identity() const { return identity_; } |
| 3908 virtual void SetIdentity(AliasIdentity identity) { identity_ = identity; } |
| 3909 |
| 3910 private: |
| 3911 const intptr_t token_pos_; |
| 3912 const intptr_t num_context_variables_; |
| 3913 AliasIdentity identity_; |
| 3914 |
| 3915 DISALLOW_COPY_AND_ASSIGN(AllocateUninitializedContextInstr); |
| 3916 }; |
| 3917 |
| 3918 |
3886 // This instruction captures the state of the object which had its allocation | 3919 // This instruction captures the state of the object which had its allocation |
3887 // removed during the AllocationSinking pass. | 3920 // removed during the AllocationSinking pass. |
3888 // It does not produce any real code only deoptimization information. | 3921 // It does not produce any real code only deoptimization information. |
3889 class MaterializeObjectInstr : public Definition { | 3922 class MaterializeObjectInstr : public Definition { |
3890 public: | 3923 public: |
3891 MaterializeObjectInstr(AllocateObjectInstr* allocation, | 3924 MaterializeObjectInstr(AllocateObjectInstr* allocation, |
3892 const Class& cls, | |
3893 const ZoneGrowableArray<const Object*>& slots, | 3925 const ZoneGrowableArray<const Object*>& slots, |
3894 ZoneGrowableArray<Value*>* values) | 3926 ZoneGrowableArray<Value*>* values) |
3895 : allocation_(allocation), | 3927 : allocation_(allocation), |
3896 cls_(cls), | 3928 cls_(allocation->cls()), |
| 3929 num_variables_(-1), |
3897 slots_(slots), | 3930 slots_(slots), |
3898 values_(values), | 3931 values_(values), |
3899 locations_(NULL), | 3932 locations_(NULL), |
3900 visited_for_liveness_(false), | 3933 visited_for_liveness_(false), |
3901 registers_remapped_(false) { | 3934 registers_remapped_(false) { |
3902 ASSERT(slots_.length() == values_->length()); | 3935 ASSERT(slots_.length() == values_->length()); |
3903 for (intptr_t i = 0; i < InputCount(); i++) { | 3936 for (intptr_t i = 0; i < InputCount(); i++) { |
3904 InputAt(i)->set_instruction(this); | 3937 InputAt(i)->set_instruction(this); |
3905 InputAt(i)->set_use_index(i); | 3938 InputAt(i)->set_use_index(i); |
3906 } | 3939 } |
3907 } | 3940 } |
3908 | 3941 |
3909 AllocateObjectInstr* allocation() const { return allocation_; } | 3942 MaterializeObjectInstr(AllocateUninitializedContextInstr* allocation, |
| 3943 const ZoneGrowableArray<const Object*>& slots, |
| 3944 ZoneGrowableArray<Value*>* values) |
| 3945 : allocation_(allocation), |
| 3946 cls_(Class::ZoneHandle(Object::context_class())), |
| 3947 num_variables_(allocation->num_context_variables()), |
| 3948 slots_(slots), |
| 3949 values_(values), |
| 3950 locations_(NULL), |
| 3951 visited_for_liveness_(false), |
| 3952 registers_remapped_(false) { |
| 3953 ASSERT(slots_.length() == values_->length()); |
| 3954 for (intptr_t i = 0; i < InputCount(); i++) { |
| 3955 InputAt(i)->set_instruction(this); |
| 3956 InputAt(i)->set_use_index(i); |
| 3957 } |
| 3958 } |
| 3959 |
| 3960 Definition* allocation() const { return allocation_; } |
3910 const Class& cls() const { return cls_; } | 3961 const Class& cls() const { return cls_; } |
| 3962 |
| 3963 intptr_t num_variables() const { |
| 3964 return num_variables_; |
| 3965 } |
| 3966 |
3911 intptr_t FieldOffsetAt(intptr_t i) const { | 3967 intptr_t FieldOffsetAt(intptr_t i) const { |
3912 return slots_[i]->IsField() | 3968 return slots_[i]->IsField() |
3913 ? Field::Cast(*slots_[i]).Offset() | 3969 ? Field::Cast(*slots_[i]).Offset() |
3914 : Smi::Cast(*slots_[i]).Value(); | 3970 : Smi::Cast(*slots_[i]).Value(); |
3915 } | 3971 } |
| 3972 |
3916 const Location& LocationAt(intptr_t i) { | 3973 const Location& LocationAt(intptr_t i) { |
3917 return locations_[i]; | 3974 return locations_[i]; |
3918 } | 3975 } |
3919 | 3976 |
3920 DECLARE_INSTRUCTION(MaterializeObject) | 3977 DECLARE_INSTRUCTION(MaterializeObject) |
3921 virtual void PrintOperandsTo(BufferFormatter* f) const; | 3978 virtual void PrintOperandsTo(BufferFormatter* f) const; |
3922 | 3979 |
3923 virtual intptr_t InputCount() const { | 3980 virtual intptr_t InputCount() const { |
3924 return values_->length(); | 3981 return values_->length(); |
3925 } | 3982 } |
(...skipping 26 matching lines...) Expand all Loading... |
3952 bool was_visited_for_liveness() const { return visited_for_liveness_; } | 4009 bool was_visited_for_liveness() const { return visited_for_liveness_; } |
3953 void mark_visited_for_liveness() { | 4010 void mark_visited_for_liveness() { |
3954 visited_for_liveness_ = true; | 4011 visited_for_liveness_ = true; |
3955 } | 4012 } |
3956 | 4013 |
3957 private: | 4014 private: |
3958 virtual void RawSetInputAt(intptr_t i, Value* value) { | 4015 virtual void RawSetInputAt(intptr_t i, Value* value) { |
3959 (*values_)[i] = value; | 4016 (*values_)[i] = value; |
3960 } | 4017 } |
3961 | 4018 |
3962 AllocateObjectInstr* allocation_; | 4019 Definition* allocation_; |
3963 const Class& cls_; | 4020 const Class& cls_; |
| 4021 intptr_t num_variables_; |
3964 const ZoneGrowableArray<const Object*>& slots_; | 4022 const ZoneGrowableArray<const Object*>& slots_; |
3965 ZoneGrowableArray<Value*>* values_; | 4023 ZoneGrowableArray<Value*>* values_; |
3966 Location* locations_; | 4024 Location* locations_; |
3967 | 4025 |
3968 bool visited_for_liveness_; | 4026 bool visited_for_liveness_; |
3969 bool registers_remapped_; | 4027 bool registers_remapped_; |
3970 | 4028 |
3971 DISALLOW_COPY_AND_ASSIGN(MaterializeObjectInstr); | 4029 DISALLOW_COPY_AND_ASSIGN(MaterializeObjectInstr); |
3972 }; | 4030 }; |
3973 | 4031 |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4243 | 4301 |
4244 DISALLOW_COPY_AND_ASSIGN(InstantiateTypeArgumentsInstr); | 4302 DISALLOW_COPY_AND_ASSIGN(InstantiateTypeArgumentsInstr); |
4245 }; | 4303 }; |
4246 | 4304 |
4247 | 4305 |
4248 class AllocateContextInstr : public TemplateDefinition<0, NoThrow> { | 4306 class AllocateContextInstr : public TemplateDefinition<0, NoThrow> { |
4249 public: | 4307 public: |
4250 AllocateContextInstr(intptr_t token_pos, | 4308 AllocateContextInstr(intptr_t token_pos, |
4251 intptr_t num_context_variables) | 4309 intptr_t num_context_variables) |
4252 : token_pos_(token_pos), | 4310 : token_pos_(token_pos), |
4253 num_context_variables_(num_context_variables) {} | 4311 num_context_variables_(num_context_variables) { } |
4254 | 4312 |
4255 DECLARE_INSTRUCTION(AllocateContext) | 4313 DECLARE_INSTRUCTION(AllocateContext) |
4256 virtual CompileType ComputeType() const; | 4314 virtual CompileType ComputeType() const; |
4257 | 4315 |
4258 virtual intptr_t token_pos() const { return token_pos_; } | 4316 virtual intptr_t token_pos() const { return token_pos_; } |
4259 intptr_t num_context_variables() const { return num_context_variables_; } | 4317 intptr_t num_context_variables() const { return num_context_variables_; } |
4260 | 4318 |
4261 virtual void PrintOperandsTo(BufferFormatter* f) const; | 4319 virtual void PrintOperandsTo(BufferFormatter* f) const; |
4262 | 4320 |
4263 virtual bool CanDeoptimize() const { return false; } | 4321 virtual bool CanDeoptimize() const { return false; } |
(...skipping 26 matching lines...) Expand all Loading... |
4290 virtual EffectSet Effects() const { return EffectSet::All(); } | 4348 virtual EffectSet Effects() const { return EffectSet::All(); } |
4291 virtual Instruction* Canonicalize(FlowGraph* flow_graph); | 4349 virtual Instruction* Canonicalize(FlowGraph* flow_graph); |
4292 | 4350 |
4293 private: | 4351 private: |
4294 const Field& field_; | 4352 const Field& field_; |
4295 | 4353 |
4296 DISALLOW_COPY_AND_ASSIGN(InitStaticFieldInstr); | 4354 DISALLOW_COPY_AND_ASSIGN(InitStaticFieldInstr); |
4297 }; | 4355 }; |
4298 | 4356 |
4299 | 4357 |
4300 class AllocateUninitializedContextInstr | |
4301 : public TemplateDefinition<0, NoThrow> { | |
4302 public: | |
4303 AllocateUninitializedContextInstr(intptr_t token_pos, | |
4304 intptr_t num_context_variables) | |
4305 : token_pos_(token_pos), | |
4306 num_context_variables_(num_context_variables) {} | |
4307 | |
4308 DECLARE_INSTRUCTION(AllocateUninitializedContext) | |
4309 virtual CompileType ComputeType() const; | |
4310 | |
4311 virtual intptr_t token_pos() const { return token_pos_; } | |
4312 intptr_t num_context_variables() const { return num_context_variables_; } | |
4313 | |
4314 virtual void PrintOperandsTo(BufferFormatter* f) const; | |
4315 | |
4316 virtual bool CanDeoptimize() const { return false; } | |
4317 | |
4318 virtual EffectSet Effects() const { return EffectSet::None(); } | |
4319 | |
4320 private: | |
4321 const intptr_t token_pos_; | |
4322 const intptr_t num_context_variables_; | |
4323 | |
4324 DISALLOW_COPY_AND_ASSIGN(AllocateUninitializedContextInstr); | |
4325 }; | |
4326 | |
4327 | |
4328 class CloneContextInstr : public TemplateDefinition<1, NoThrow> { | 4358 class CloneContextInstr : public TemplateDefinition<1, NoThrow> { |
4329 public: | 4359 public: |
4330 CloneContextInstr(intptr_t token_pos, Value* context_value) | 4360 CloneContextInstr(intptr_t token_pos, Value* context_value) |
4331 : TemplateDefinition(Isolate::Current()->GetNextDeoptId()), | 4361 : TemplateDefinition(Isolate::Current()->GetNextDeoptId()), |
4332 token_pos_(token_pos) { | 4362 token_pos_(token_pos) { |
4333 SetInputAt(0, context_value); | 4363 SetInputAt(0, context_value); |
4334 } | 4364 } |
4335 | 4365 |
4336 virtual intptr_t token_pos() const { return token_pos_; } | 4366 virtual intptr_t token_pos() const { return token_pos_; } |
4337 Value* context_value() const { return inputs_[0]; } | 4367 Value* context_value() const { return inputs_[0]; } |
(...skipping 3430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7768 Isolate* isolate, bool opt) const { \ | 7798 Isolate* isolate, bool opt) const { \ |
7769 UNIMPLEMENTED(); \ | 7799 UNIMPLEMENTED(); \ |
7770 return NULL; \ | 7800 return NULL; \ |
7771 } \ | 7801 } \ |
7772 void Name::EmitNativeCode(FlowGraphCompiler* compiler) { UNIMPLEMENTED(); } | 7802 void Name::EmitNativeCode(FlowGraphCompiler* compiler) { UNIMPLEMENTED(); } |
7773 | 7803 |
7774 | 7804 |
7775 } // namespace dart | 7805 } // namespace dart |
7776 | 7806 |
7777 #endif // VM_INTERMEDIATE_LANGUAGE_H_ | 7807 #endif // VM_INTERMEDIATE_LANGUAGE_H_ |
OLD | NEW |