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

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

Issue 189543013: Add alias identity information to array allocations. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 9 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) 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 1688 matching lines...) Expand 10 before | Expand all | Expand 10 after
1699 const intptr_t catch_try_index_; 1699 const intptr_t catch_try_index_;
1700 GrowableArray<Definition*> initial_definitions_; 1700 GrowableArray<Definition*> initial_definitions_;
1701 const LocalVariable& exception_var_; 1701 const LocalVariable& exception_var_;
1702 const LocalVariable& stacktrace_var_; 1702 const LocalVariable& stacktrace_var_;
1703 const bool needs_stacktrace_; 1703 const bool needs_stacktrace_;
1704 1704
1705 DISALLOW_COPY_AND_ASSIGN(CatchBlockEntryInstr); 1705 DISALLOW_COPY_AND_ASSIGN(CatchBlockEntryInstr);
1706 }; 1706 };
1707 1707
1708 1708
1709 // If the result of the allocation is not stored into any field, passed
1710 // as an argument or used in a phi then it can't alias with any other
1711 // SSA value.
1712 enum AliasIdentity {
1713 kIdentityUnknown,
1714 kIdentityAliased,
1715 kIdentityNotAliased
1716 };
1717
1718
1709 // Abstract super-class of all instructions that define a value (Bind, Phi). 1719 // Abstract super-class of all instructions that define a value (Bind, Phi).
1710 class Definition : public Instruction { 1720 class Definition : public Instruction {
1711 public: 1721 public:
1712 enum UseKind { kEffect, kValue }; 1722 enum UseKind { kEffect, kValue };
1713 1723
1714 Definition(); 1724 Definition();
1715 1725
1716 virtual Definition* AsDefinition() { return this; } 1726 virtual Definition* AsDefinition() { return this; }
1717 1727
1718 bool IsComparison() { return (AsComparison() != NULL); } 1728 bool IsComparison() { return (AsComparison() != NULL); }
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
1836 return this; 1846 return this;
1837 } 1847 }
1838 1848
1839 void SetReplacement(Definition* other) { 1849 void SetReplacement(Definition* other) {
1840 ASSERT(ssa_temp_index_ >= 0); 1850 ASSERT(ssa_temp_index_ >= 0);
1841 ASSERT(WasEliminated()); 1851 ASSERT(WasEliminated());
1842 ssa_temp_index_ = kReplacementMarker; 1852 ssa_temp_index_ = kReplacementMarker;
1843 temp_index_ = reinterpret_cast<intptr_t>(other); 1853 temp_index_ = reinterpret_cast<intptr_t>(other);
1844 } 1854 }
1845 1855
1856 virtual AliasIdentity Identity() const {
1857 // Only implemented for allocation instructions.
1858 UNREACHABLE();
1859 return kIdentityUnknown;
1860 }
1861
1862 virtual void SetIdentity(AliasIdentity identity) {
1863 UNREACHABLE();
1864 }
1865
1846 protected: 1866 protected:
1847 friend class RangeAnalysis; 1867 friend class RangeAnalysis;
1848 friend class Value; 1868 friend class Value;
1849 1869
1850 Range* range_; 1870 Range* range_;
1851 CompileType* type_; 1871 CompileType* type_;
1852 1872
1853 private: 1873 private:
1854 intptr_t temp_index_; 1874 intptr_t temp_index_;
1855 intptr_t ssa_temp_index_; 1875 intptr_t ssa_temp_index_;
(...skipping 1402 matching lines...) Expand 10 before | Expand all | Expand 10 after
3258 const Array& argument_names, 3278 const Array& argument_names,
3259 ZoneGrowableArray<PushArgumentInstr*>* arguments, 3279 ZoneGrowableArray<PushArgumentInstr*>* arguments,
3260 const Array& ic_data_array) 3280 const Array& ic_data_array)
3261 : ic_data_(GetICData(ic_data_array)), 3281 : ic_data_(GetICData(ic_data_array)),
3262 token_pos_(token_pos), 3282 token_pos_(token_pos),
3263 function_(function), 3283 function_(function),
3264 argument_names_(argument_names), 3284 argument_names_(argument_names),
3265 arguments_(arguments), 3285 arguments_(arguments),
3266 result_cid_(kDynamicCid), 3286 result_cid_(kDynamicCid),
3267 is_known_list_constructor_(false), 3287 is_known_list_constructor_(false),
3268 is_native_list_factory_(false) { 3288 is_native_list_factory_(false),
3289 identity_(kIdentityUnknown) {
3269 ASSERT(function.IsZoneHandle()); 3290 ASSERT(function.IsZoneHandle());
3270 ASSERT(argument_names.IsZoneHandle() || argument_names.InVMHeap()); 3291 ASSERT(argument_names.IsZoneHandle() || argument_names.InVMHeap());
3271 } 3292 }
3272 3293
3273 // ICData for static calls carries call count. 3294 // ICData for static calls carries call count.
3274 const ICData* ic_data() const { return ic_data_; } 3295 const ICData* ic_data() const { return ic_data_; }
3275 bool HasICData() const { 3296 bool HasICData() const {
3276 return (ic_data() != NULL) && !ic_data()->IsNull(); 3297 return (ic_data() != NULL) && !ic_data()->IsNull();
3277 } 3298 }
3278 3299
(...skipping 25 matching lines...) Expand all
3304 is_known_list_constructor_ = value; 3325 is_known_list_constructor_ = value;
3305 } 3326 }
3306 3327
3307 bool is_native_list_factory() const { return is_native_list_factory_; } 3328 bool is_native_list_factory() const { return is_native_list_factory_; }
3308 void set_is_native_list_factory(bool value) { 3329 void set_is_native_list_factory(bool value) {
3309 is_native_list_factory_ = value; 3330 is_native_list_factory_ = value;
3310 } 3331 }
3311 3332
3312 virtual bool MayThrow() const { return true; } 3333 virtual bool MayThrow() const { return true; }
3313 3334
3335 virtual AliasIdentity Identity() const { return identity_; }
3336 virtual void SetIdentity(AliasIdentity identity) { identity_ = identity; }
3337
3314 private: 3338 private:
3315 const ICData* ic_data_; 3339 const ICData* ic_data_;
3316 const intptr_t token_pos_; 3340 const intptr_t token_pos_;
3317 const Function& function_; 3341 const Function& function_;
3318 const Array& argument_names_; 3342 const Array& argument_names_;
3319 ZoneGrowableArray<PushArgumentInstr*>* arguments_; 3343 ZoneGrowableArray<PushArgumentInstr*>* arguments_;
3320 intptr_t result_cid_; // For some library functions we know the result. 3344 intptr_t result_cid_; // For some library functions we know the result.
3321 3345
3322 // 'True' for recognized list constructors. 3346 // 'True' for recognized list constructors.
3323 bool is_known_list_constructor_; 3347 bool is_known_list_constructor_;
3324 bool is_native_list_factory_; 3348 bool is_native_list_factory_;
3325 3349
3350 AliasIdentity identity_;
3351
3326 DISALLOW_COPY_AND_ASSIGN(StaticCallInstr); 3352 DISALLOW_COPY_AND_ASSIGN(StaticCallInstr);
3327 }; 3353 };
3328 3354
3329 3355
3330 class LoadLocalInstr : public TemplateDefinition<0> { 3356 class LoadLocalInstr : public TemplateDefinition<0> {
3331 public: 3357 public:
3332 explicit LoadLocalInstr(const LocalVariable& local) 3358 explicit LoadLocalInstr(const LocalVariable& local)
3333 : local_(local), is_last_(false) { } 3359 : local_(local), is_last_(false) { }
3334 3360
3335 DECLARE_INSTRUCTION(LoadLocal) 3361 DECLARE_INSTRUCTION(LoadLocal)
(...skipping 694 matching lines...) Expand 10 before | Expand all | Expand 10 after
4030 4056
4031 4057
4032 class AllocateObjectInstr : public TemplateDefinition<0> { 4058 class AllocateObjectInstr : public TemplateDefinition<0> {
4033 public: 4059 public:
4034 AllocateObjectInstr(intptr_t token_pos, 4060 AllocateObjectInstr(intptr_t token_pos,
4035 const Class& cls, 4061 const Class& cls,
4036 ZoneGrowableArray<PushArgumentInstr*>* arguments) 4062 ZoneGrowableArray<PushArgumentInstr*>* arguments)
4037 : token_pos_(token_pos), 4063 : token_pos_(token_pos),
4038 cls_(cls), 4064 cls_(cls),
4039 arguments_(arguments), 4065 arguments_(arguments),
4040 identity_(kUnknown), 4066 identity_(kIdentityUnknown),
4041 closure_function_(Function::ZoneHandle()) { 4067 closure_function_(Function::ZoneHandle()) {
4042 // Either no arguments or one type-argument and one instantiator. 4068 // Either no arguments or one type-argument and one instantiator.
4043 ASSERT(arguments->is_empty() || (arguments->length() == 1)); 4069 ASSERT(arguments->is_empty() || (arguments->length() == 1));
4044 } 4070 }
4045 4071
4046 DECLARE_INSTRUCTION(AllocateObject) 4072 DECLARE_INSTRUCTION(AllocateObject)
4047 virtual CompileType ComputeType() const; 4073 virtual CompileType ComputeType() const;
4048 4074
4049 virtual intptr_t ArgumentCount() const { return arguments_->length(); } 4075 virtual intptr_t ArgumentCount() const { return arguments_->length(); }
4050 virtual PushArgumentInstr* PushArgumentAt(intptr_t index) const { 4076 virtual PushArgumentInstr* PushArgumentAt(intptr_t index) const {
4051 return (*arguments_)[index]; 4077 return (*arguments_)[index];
4052 } 4078 }
4053 4079
4054 const Class& cls() const { return cls_; } 4080 const Class& cls() const { return cls_; }
4055 intptr_t token_pos() const { return token_pos_; } 4081 intptr_t token_pos() const { return token_pos_; }
4056 4082
4057 const Function& closure_function() const { return closure_function_; } 4083 const Function& closure_function() const { return closure_function_; }
4058 void set_closure_function(const Function& function) { 4084 void set_closure_function(const Function& function) {
4059 closure_function_ ^= function.raw(); 4085 closure_function_ ^= function.raw();
4060 } 4086 }
4061 4087
4062 virtual void PrintOperandsTo(BufferFormatter* f) const; 4088 virtual void PrintOperandsTo(BufferFormatter* f) const;
4063 4089
4064 virtual bool CanDeoptimize() const { return false; } 4090 virtual bool CanDeoptimize() const { return false; }
4065 4091
4066 virtual EffectSet Effects() const { return EffectSet::None(); } 4092 virtual EffectSet Effects() const { return EffectSet::None(); }
4067 4093
4068 virtual bool MayThrow() const { return false; } 4094 virtual bool MayThrow() const { return false; }
4069 4095
4070 // If the result of the allocation is not stored into any field, passed 4096 virtual AliasIdentity Identity() const { return identity_; }
4071 // as an argument or used in a phi then it can't alias with any other 4097 virtual void SetIdentity(AliasIdentity identity) { identity_ = identity; }
4072 // SSA value.
4073 enum Identity {
4074 kUnknown,
4075 kAliased,
4076 kNotAliased
4077 };
4078
4079 Identity identity() const { return identity_; }
4080 void set_identity(Identity identity) { identity_ = identity; }
4081 4098
4082 private: 4099 private:
4083 const intptr_t token_pos_; 4100 const intptr_t token_pos_;
4084 const Class& cls_; 4101 const Class& cls_;
4085 ZoneGrowableArray<PushArgumentInstr*>* const arguments_; 4102 ZoneGrowableArray<PushArgumentInstr*>* const arguments_;
4086 Identity identity_; 4103 AliasIdentity identity_;
4087 Function& closure_function_; 4104 Function& closure_function_;
4088 4105
4089 DISALLOW_COPY_AND_ASSIGN(AllocateObjectInstr); 4106 DISALLOW_COPY_AND_ASSIGN(AllocateObjectInstr);
4090 }; 4107 };
4091 4108
4092 4109
4093 // This instruction captures the state of the object which had its allocation 4110 // This instruction captures the state of the object which had its allocation
4094 // removed during the AllocationSinking pass. 4111 // removed during the AllocationSinking pass.
4095 // It does not produce any real code only deoptimization information. 4112 // It does not produce any real code only deoptimization information.
4096 class MaterializeObjectInstr : public Definition { 4113 class MaterializeObjectInstr : public Definition {
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
4157 4174
4158 DISALLOW_COPY_AND_ASSIGN(MaterializeObjectInstr); 4175 DISALLOW_COPY_AND_ASSIGN(MaterializeObjectInstr);
4159 }; 4176 };
4160 4177
4161 4178
4162 class CreateArrayInstr : public TemplateDefinition<2> { 4179 class CreateArrayInstr : public TemplateDefinition<2> {
4163 public: 4180 public:
4164 CreateArrayInstr(intptr_t token_pos, 4181 CreateArrayInstr(intptr_t token_pos,
4165 Value* element_type, 4182 Value* element_type,
4166 Value* num_elements) 4183 Value* num_elements)
4167 : token_pos_(token_pos) { 4184 : token_pos_(token_pos), identity_(kIdentityUnknown) {
4168 SetInputAt(kElementTypePos, element_type); 4185 SetInputAt(kElementTypePos, element_type);
4169 SetInputAt(kLengthPos, num_elements); 4186 SetInputAt(kLengthPos, num_elements);
4170 } 4187 }
4171 4188
4172 enum { 4189 enum {
4173 kElementTypePos = 0, 4190 kElementTypePos = 0,
4174 kLengthPos = 1 4191 kLengthPos = 1
4175 }; 4192 };
4176 4193
4177 DECLARE_INSTRUCTION(CreateArray) 4194 DECLARE_INSTRUCTION(CreateArray)
4178 virtual CompileType ComputeType() const; 4195 virtual CompileType ComputeType() const;
4179 4196
4180 4197
4181 intptr_t token_pos() const { return token_pos_; } 4198 intptr_t token_pos() const { return token_pos_; }
4182 Value* element_type() const { return inputs_[kElementTypePos]; } 4199 Value* element_type() const { return inputs_[kElementTypePos]; }
4183 Value* num_elements() const { return inputs_[kLengthPos]; } 4200 Value* num_elements() const { return inputs_[kLengthPos]; }
4184 4201
4185 virtual void PrintOperandsTo(BufferFormatter* f) const; 4202 virtual void PrintOperandsTo(BufferFormatter* f) const;
4186 4203
4187 virtual bool CanDeoptimize() const { return false; } 4204 virtual bool CanDeoptimize() const { return false; }
4188 4205
4189 virtual EffectSet Effects() const { return EffectSet::None(); } 4206 virtual EffectSet Effects() const { return EffectSet::None(); }
4190 4207
4191 virtual bool MayThrow() const { return false; } 4208 virtual bool MayThrow() const { return false; }
4192 4209
4210 virtual AliasIdentity Identity() const { return identity_; }
4211 virtual void SetIdentity(AliasIdentity identity) { identity_ = identity; }
4212
4193 private: 4213 private:
4194 const intptr_t token_pos_; 4214 const intptr_t token_pos_;
4215 AliasIdentity identity_;
4195 4216
4196 DISALLOW_COPY_AND_ASSIGN(CreateArrayInstr); 4217 DISALLOW_COPY_AND_ASSIGN(CreateArrayInstr);
4197 }; 4218 };
4198 4219
4199 4220
4200 class LoadUntaggedInstr : public TemplateDefinition<1> { 4221 class LoadUntaggedInstr : public TemplateDefinition<1> {
4201 public: 4222 public:
4202 LoadUntaggedInstr(Value* object, intptr_t offset) : offset_(offset) { 4223 LoadUntaggedInstr(Value* object, intptr_t offset) : offset_(offset) {
4203 SetInputAt(0, object); 4224 SetInputAt(0, object);
4204 } 4225 }
(...skipping 3351 matching lines...) Expand 10 before | Expand all | Expand 10 after
7556 ForwardInstructionIterator* current_iterator_; 7577 ForwardInstructionIterator* current_iterator_;
7557 7578
7558 private: 7579 private:
7559 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); 7580 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor);
7560 }; 7581 };
7561 7582
7562 7583
7563 } // namespace dart 7584 } // namespace dart
7564 7585
7565 #endif // VM_INTERMEDIATE_LANGUAGE_H_ 7586 #endif // VM_INTERMEDIATE_LANGUAGE_H_
OLDNEW
« no previous file with comments | « runtime/vm/flow_graph_optimizer.cc ('k') | tests/language/vm/load_to_load_forwarding_vm_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698