| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 289 | 289 |
| 290 protected: | 290 protected: |
| 291 EmbeddedArray<Value*, N> inputs_; | 291 EmbeddedArray<Value*, N> inputs_; |
| 292 }; | 292 }; |
| 293 | 293 |
| 294 | 294 |
| 295 class Value : public TemplateComputation<0> { | 295 class Value : public TemplateComputation<0> { |
| 296 public: | 296 public: |
| 297 Value() { } | 297 Value() { } |
| 298 | 298 |
| 299 // Returns true if the value represents a constant. |
| 300 virtual bool BindsToConstant() const = 0; |
| 301 |
| 302 // Returns true if the value represents constant null. |
| 303 virtual bool BindsToConstantNull() const = 0; |
| 304 |
| 305 // Reminder: The type of the constant null is the bottom type, which is more |
| 306 // specific than any type. |
| 299 bool CompileTypeIsMoreSpecificThan(const AbstractType& dst_type) const; | 307 bool CompileTypeIsMoreSpecificThan(const AbstractType& dst_type) const; |
| 300 | 308 |
| 301 virtual void RemoveFromUseList() = 0; | 309 virtual void RemoveFromUseList() = 0; |
| 302 | 310 |
| 303 private: | 311 private: |
| 304 DISALLOW_COPY_AND_ASSIGN(Value); | 312 DISALLOW_COPY_AND_ASSIGN(Value); |
| 305 }; | 313 }; |
| 306 | 314 |
| 307 | 315 |
| 308 // Functions defined in all concrete computation classes. | 316 // Functions defined in all concrete computation classes. |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 340 | 348 |
| 341 class UseVal : public Value { | 349 class UseVal : public Value { |
| 342 public: | 350 public: |
| 343 explicit UseVal(Definition* definition); | 351 explicit UseVal(Definition* definition); |
| 344 | 352 |
| 345 DECLARE_VALUE(Use) | 353 DECLARE_VALUE(Use) |
| 346 | 354 |
| 347 inline Definition* definition() const; | 355 inline Definition* definition() const; |
| 348 void SetDefinition(Definition* definition); | 356 void SetDefinition(Definition* definition); |
| 349 | 357 |
| 358 // Returns true if the value represents a constant. |
| 359 virtual bool BindsToConstant() const; |
| 360 |
| 361 // Returns true if the value represents constant null. |
| 362 virtual bool BindsToConstantNull() const; |
| 363 |
| 350 virtual bool CanDeoptimize() const { return false; } | 364 virtual bool CanDeoptimize() const { return false; } |
| 351 | 365 |
| 352 UseVal* next_use() const { return next_use_; } | 366 UseVal* next_use() const { return next_use_; } |
| 353 UseVal* previous_use() const { return previous_use_; } | 367 UseVal* previous_use() const { return previous_use_; } |
| 354 virtual void RemoveFromUseList(); | 368 virtual void RemoveFromUseList(); |
| 355 virtual void RemoveInputUses() { RemoveFromUseList(); } | 369 virtual void RemoveInputUses() { RemoveFromUseList(); } |
| 356 | 370 |
| 357 private: | 371 private: |
| 358 void AddToUseList(); | 372 void AddToUseList(); |
| 359 Definition* definition_; | 373 Definition* definition_; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 371 explicit ConstantVal(const Object& value) | 385 explicit ConstantVal(const Object& value) |
| 372 : value_(value) { | 386 : value_(value) { |
| 373 ASSERT(value.IsZoneHandle()); | 387 ASSERT(value.IsZoneHandle()); |
| 374 ASSERT(value.IsSmi() || value.IsOld()); | 388 ASSERT(value.IsSmi() || value.IsOld()); |
| 375 } | 389 } |
| 376 | 390 |
| 377 DECLARE_VALUE(Constant) | 391 DECLARE_VALUE(Constant) |
| 378 | 392 |
| 379 const Object& value() const { return value_; } | 393 const Object& value() const { return value_; } |
| 380 | 394 |
| 395 // Returns true if the value represents a constant. |
| 396 virtual bool BindsToConstant() const { return true; } |
| 397 |
| 398 // Returns true if the value represents constant null. |
| 399 virtual bool BindsToConstantNull() const { return value().IsNull(); } |
| 400 |
| 381 virtual bool CanDeoptimize() const { return false; } | 401 virtual bool CanDeoptimize() const { return false; } |
| 382 | 402 |
| 383 virtual void RemoveFromUseList() { } | 403 virtual void RemoveFromUseList() { } |
| 384 | 404 |
| 385 private: | 405 private: |
| 386 const Object& value_; | 406 const Object& value_; |
| 387 | 407 |
| 388 DISALLOW_COPY_AND_ASSIGN(ConstantVal); | 408 DISALLOW_COPY_AND_ASSIGN(ConstantVal); |
| 389 }; | 409 }; |
| 390 | 410 |
| (...skipping 2482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2873 | 2893 |
| 2874 DISALLOW_COPY_AND_ASSIGN(Environment); | 2894 DISALLOW_COPY_AND_ASSIGN(Environment); |
| 2875 }; | 2895 }; |
| 2876 | 2896 |
| 2877 | 2897 |
| 2878 // Visitor base class to visit each instruction and computation in a flow | 2898 // Visitor base class to visit each instruction and computation in a flow |
| 2879 // graph as defined by a reversed list of basic blocks. | 2899 // graph as defined by a reversed list of basic blocks. |
| 2880 class FlowGraphVisitor : public ValueObject { | 2900 class FlowGraphVisitor : public ValueObject { |
| 2881 public: | 2901 public: |
| 2882 explicit FlowGraphVisitor(const GrowableArray<BlockEntryInstr*>& block_order) | 2902 explicit FlowGraphVisitor(const GrowableArray<BlockEntryInstr*>& block_order) |
| 2883 : block_order_(block_order) { } | 2903 : block_order_(block_order), current_iterator_(NULL) { } |
| 2884 virtual ~FlowGraphVisitor() { } | 2904 virtual ~FlowGraphVisitor() { } |
| 2885 | 2905 |
| 2906 ForwardInstructionIterator* current_iterator() const { |
| 2907 return current_iterator_; |
| 2908 } |
| 2909 |
| 2886 // Visit each block in the block order, and for each block its | 2910 // Visit each block in the block order, and for each block its |
| 2887 // instructions in order from the block entry to exit. | 2911 // instructions in order from the block entry to exit. |
| 2888 virtual void VisitBlocks(); | 2912 virtual void VisitBlocks(); |
| 2889 | 2913 |
| 2890 // Visit functions for instruction and computation classes, with empty | 2914 // Visit functions for instruction and computation classes, with empty |
| 2891 // default implementations. | 2915 // default implementations. |
| 2892 #define DECLARE_VISIT_COMPUTATION(ShortName, ClassName) \ | 2916 #define DECLARE_VISIT_COMPUTATION(ShortName, ClassName) \ |
| 2893 virtual void Visit##ShortName(ClassName* comp, BindInstr* instr) { } | 2917 virtual void Visit##ShortName(ClassName* comp, BindInstr* instr) { } |
| 2894 | 2918 |
| 2895 #define DECLARE_VISIT_INSTRUCTION(ShortName) \ | 2919 #define DECLARE_VISIT_INSTRUCTION(ShortName) \ |
| 2896 virtual void Visit##ShortName(ShortName##Instr* instr) { } | 2920 virtual void Visit##ShortName(ShortName##Instr* instr) { } |
| 2897 | 2921 |
| 2898 FOR_EACH_COMPUTATION(DECLARE_VISIT_COMPUTATION) | 2922 FOR_EACH_COMPUTATION(DECLARE_VISIT_COMPUTATION) |
| 2899 FOR_EACH_INSTRUCTION(DECLARE_VISIT_INSTRUCTION) | 2923 FOR_EACH_INSTRUCTION(DECLARE_VISIT_INSTRUCTION) |
| 2900 | 2924 |
| 2901 #undef DECLARE_VISIT_COMPUTATION | 2925 #undef DECLARE_VISIT_COMPUTATION |
| 2902 #undef DECLARE_VISIT_INSTRUCTION | 2926 #undef DECLARE_VISIT_INSTRUCTION |
| 2903 | 2927 |
| 2904 protected: | 2928 protected: |
| 2905 const GrowableArray<BlockEntryInstr*>& block_order_; | 2929 const GrowableArray<BlockEntryInstr*>& block_order_; |
| 2930 ForwardInstructionIterator* current_iterator_; |
| 2906 | 2931 |
| 2907 private: | 2932 private: |
| 2908 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); | 2933 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); |
| 2909 }; | 2934 }; |
| 2910 | 2935 |
| 2911 | 2936 |
| 2912 } // namespace dart | 2937 } // namespace dart |
| 2913 | 2938 |
| 2914 #endif // VM_INTERMEDIATE_LANGUAGE_H_ | 2939 #endif // VM_INTERMEDIATE_LANGUAGE_H_ |
| OLD | NEW |