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

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

Issue 3010673002: [vm] Implement gradual refinement of types (Closed)
Patch Set: Address review comments Created 3 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
« no previous file with comments | « runtime/vm/flow_graph_type_propagator.cc ('k') | runtime/vm/redundancy_elimination.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 RUNTIME_VM_INTERMEDIATE_LANGUAGE_H_ 5 #ifndef RUNTIME_VM_INTERMEDIATE_LANGUAGE_H_
6 #define RUNTIME_VM_INTERMEDIATE_LANGUAGE_H_ 6 #define RUNTIME_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/flags.h" 10 #include "vm/flags.h"
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 142
143 // Create non-nullable Smi type. 143 // Create non-nullable Smi type.
144 static CompileType Smi(); 144 static CompileType Smi();
145 145
146 // Create non-nullable String type. 146 // Create non-nullable String type.
147 static CompileType String(); 147 static CompileType String();
148 148
149 // Perform a join operation over the type lattice. 149 // Perform a join operation over the type lattice.
150 void Union(CompileType* other); 150 void Union(CompileType* other);
151 151
152 // Refine old type with newly inferred type (it could be more or less
153 // specific, or even unrelated to an old type in case of unreachable code).
154 // May return 'old_type', 'new_type' or create a new CompileType instance.
155 static CompileType* ComputeRefinedType(CompileType* old_type,
156 CompileType* new_type);
157
152 // Returns true if this and other types are the same. 158 // Returns true if this and other types are the same.
153 bool IsEqualTo(CompileType* other) { 159 bool IsEqualTo(CompileType* other) {
154 return (is_nullable_ == other->is_nullable_) && 160 return (is_nullable_ == other->is_nullable_) &&
155 (ToNullableCid() == other->ToNullableCid()) && 161 (ToNullableCid() == other->ToNullableCid()) &&
156 (ToAbstractType()->Equals(*other->ToAbstractType())); 162 (ToAbstractType()->Equals(*other->ToAbstractType()));
157 } 163 }
158 164
159 bool IsNone() const { return (cid_ == kIllegalCid) && (type_ == NULL); } 165 bool IsNone() const { return (cid_ == kIllegalCid) && (type_ == NULL); }
160 166
161 bool IsInt() { 167 bool IsInt() {
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 233
228 static void AddToList(Value* value, Value** list); 234 static void AddToList(Value* value, Value** list);
229 void RemoveFromUseList(); 235 void RemoveFromUseList();
230 236
231 // Change the definition after use lists have been computed. 237 // Change the definition after use lists have been computed.
232 inline void BindTo(Definition* definition); 238 inline void BindTo(Definition* definition);
233 inline void BindToEnvironment(Definition* definition); 239 inline void BindToEnvironment(Definition* definition);
234 240
235 Value* Copy(Zone* zone) { return new (zone) Value(definition_); } 241 Value* Copy(Zone* zone) { return new (zone) Value(definition_); }
236 242
237 // This function must only be used when the new Value is dominated by 243 // CopyWithType() must only be used when the new Value is dominated by
238 // the original Value. 244 // the original Value.
239 Value* CopyWithType() { 245 Value* CopyWithType(Zone* zone) {
240 Value* copy = new Value(definition_); 246 Value* copy = new (zone) Value(definition_);
241 copy->reaching_type_ = reaching_type_; 247 copy->reaching_type_ = reaching_type_;
242 return copy; 248 return copy;
243 } 249 }
250 Value* CopyWithType() { return CopyWithType(Thread::Current()->zone()); }
244 251
245 CompileType* Type(); 252 CompileType* Type();
246 253
247 void SetReachingType(CompileType* type) { reaching_type_ = type; } 254 void SetReachingType(CompileType* type) { reaching_type_ = type; }
255 void RefineReachingType(CompileType* type);
248 256
249 void PrintTo(BufferFormatter* f) const; 257 void PrintTo(BufferFormatter* f) const;
250 258
251 const char* ToCString() const; 259 const char* ToCString() const;
252 260
253 bool IsSmiValue() { return Type()->ToCid() == kSmiCid; } 261 bool IsSmiValue() { return Type()->ToCid() == kSmiCid; }
254 262
255 // Return true if the value represents a constant. 263 // Return true if the value represents a constant.
256 bool BindsToConstant() const; 264 bool BindsToConstant() const;
257 265
(...skipping 7797 matching lines...) Expand 10 before | Expand all | Expand 10 after
8055 #define DEFINE_UNIMPLEMENTED_INSTRUCTION(Name) \ 8063 #define DEFINE_UNIMPLEMENTED_INSTRUCTION(Name) \
8056 LocationSummary* Name::MakeLocationSummary(Zone* zone, bool opt) const { \ 8064 LocationSummary* Name::MakeLocationSummary(Zone* zone, bool opt) const { \
8057 UNIMPLEMENTED(); \ 8065 UNIMPLEMENTED(); \
8058 return NULL; \ 8066 return NULL; \
8059 } \ 8067 } \
8060 void Name::EmitNativeCode(FlowGraphCompiler* compiler) { UNIMPLEMENTED(); } 8068 void Name::EmitNativeCode(FlowGraphCompiler* compiler) { UNIMPLEMENTED(); }
8061 8069
8062 } // namespace dart 8070 } // namespace dart
8063 8071
8064 #endif // RUNTIME_VM_INTERMEDIATE_LANGUAGE_H_ 8072 #endif // RUNTIME_VM_INTERMEDIATE_LANGUAGE_H_
OLDNEW
« no previous file with comments | « runtime/vm/flow_graph_type_propagator.cc ('k') | runtime/vm/redundancy_elimination.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698