| 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_FLOW_GRAPH_BUILDER_H_ | 5 #ifndef VM_FLOW_GRAPH_BUILDER_H_ |
| 6 #define VM_FLOW_GRAPH_BUILDER_H_ | 6 #define VM_FLOW_GRAPH_BUILDER_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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 FlowGraph* caller_graph_; | 94 FlowGraph* caller_graph_; |
| 95 Definition* call_; | 95 Definition* call_; |
| 96 GrowableArray<Data> exits_; | 96 GrowableArray<Data> exits_; |
| 97 }; | 97 }; |
| 98 | 98 |
| 99 | 99 |
| 100 // Build a flow graph from a parsed function's AST. | 100 // Build a flow graph from a parsed function's AST. |
| 101 class FlowGraphBuilder: public ValueObject { | 101 class FlowGraphBuilder: public ValueObject { |
| 102 public: | 102 public: |
| 103 // The inlining context is NULL if not inlining. | 103 // The inlining context is NULL if not inlining. |
| 104 FlowGraphBuilder(const ParsedFunction& parsed_function, | 104 FlowGraphBuilder(ParsedFunction* parsed_function, |
| 105 const Array& ic_data_array, | 105 const Array& ic_data_array, |
| 106 InlineExitCollector* exit_collector); | 106 InlineExitCollector* exit_collector); |
| 107 | 107 |
| 108 FlowGraph* BuildGraph(); | 108 FlowGraph* BuildGraph(); |
| 109 | 109 |
| 110 const ParsedFunction& parsed_function() const { return parsed_function_; } | 110 ParsedFunction* parsed_function() const { return parsed_function_; } |
| 111 const Array& ic_data_array() const { return ic_data_array_; } | 111 const Array& ic_data_array() const { return ic_data_array_; } |
| 112 | 112 |
| 113 void Bailout(const char* reason); | 113 void Bailout(const char* reason); |
| 114 | 114 |
| 115 intptr_t AllocateBlockId() { return ++last_used_block_id_; } | 115 intptr_t AllocateBlockId() { return ++last_used_block_id_; } |
| 116 void SetInitialBlockId(intptr_t id) { last_used_block_id_ = id; } | 116 void SetInitialBlockId(intptr_t id) { last_used_block_id_ = id; } |
| 117 | 117 |
| 118 void set_context_level(intptr_t value) { context_level_ = value; } | 118 void set_context_level(intptr_t value) { context_level_ = value; } |
| 119 intptr_t context_level() const { return context_level_; } | 119 intptr_t context_level() const { return context_level_; } |
| 120 | 120 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 144 void add_args_pushed(intptr_t n) { args_pushed_ += n; } | 144 void add_args_pushed(intptr_t n) { args_pushed_ += n; } |
| 145 | 145 |
| 146 private: | 146 private: |
| 147 intptr_t parameter_count() const { | 147 intptr_t parameter_count() const { |
| 148 return num_copied_params_ + num_non_copied_params_; | 148 return num_copied_params_ + num_non_copied_params_; |
| 149 } | 149 } |
| 150 intptr_t variable_count() const { | 150 intptr_t variable_count() const { |
| 151 return parameter_count() + num_stack_locals_; | 151 return parameter_count() + num_stack_locals_; |
| 152 } | 152 } |
| 153 | 153 |
| 154 const ParsedFunction& parsed_function_; | 154 ParsedFunction* parsed_function_; |
| 155 const Array& ic_data_array_; | 155 const Array& ic_data_array_; |
| 156 | 156 |
| 157 const intptr_t num_copied_params_; | 157 const intptr_t num_copied_params_; |
| 158 const intptr_t num_non_copied_params_; | 158 const intptr_t num_non_copied_params_; |
| 159 const intptr_t num_stack_locals_; // Does not include any parameters. | 159 const intptr_t num_stack_locals_; // Does not include any parameters. |
| 160 InlineExitCollector* const exit_collector_; | 160 InlineExitCollector* const exit_collector_; |
| 161 | 161 |
| 162 intptr_t last_used_block_id_; | 162 intptr_t last_used_block_id_; |
| 163 intptr_t context_level_; | 163 intptr_t context_level_; |
| 164 intptr_t last_used_try_index_; | 164 intptr_t last_used_try_index_; |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 334 | 334 |
| 335 void BuildStoreContext(const LocalVariable& variable); | 335 void BuildStoreContext(const LocalVariable& variable); |
| 336 void BuildLoadContext(const LocalVariable& variable); | 336 void BuildLoadContext(const LocalVariable& variable); |
| 337 | 337 |
| 338 void BuildThrowNode(ThrowNode* node); | 338 void BuildThrowNode(ThrowNode* node); |
| 339 | 339 |
| 340 StaticCallInstr* BuildStaticNoSuchMethodCall( | 340 StaticCallInstr* BuildStaticNoSuchMethodCall( |
| 341 const Class& target_class, | 341 const Class& target_class, |
| 342 AstNode* receiver, | 342 AstNode* receiver, |
| 343 const String& method_name, | 343 const String& method_name, |
| 344 ArgumentListNode* method_arguments); | 344 ArgumentListNode* method_arguments, |
| 345 bool save_last_arg); |
| 345 | 346 |
| 346 StaticCallInstr* BuildThrowNoSuchMethodError(intptr_t token_pos, | 347 StaticCallInstr* BuildThrowNoSuchMethodError(intptr_t token_pos, |
| 347 const Class& function_class, | 348 const Class& function_class, |
| 348 const String& function_name, | 349 const String& function_name, |
| 349 int invocation_type); | 350 int invocation_type); |
| 350 | 351 |
| 351 void BuildStaticSetter(StaticSetterNode* node, bool result_is_needed); | 352 void BuildStaticSetter(StaticSetterNode* node, bool result_is_needed); |
| 352 Definition* BuildStoreStaticField(StoreStaticFieldNode* node, | 353 Definition* BuildStoreStaticField(StoreStaticFieldNode* node, |
| 353 bool result_is_needed); | 354 bool result_is_needed); |
| 354 | 355 |
| 355 ClosureCallInstr* BuildClosureCall(ClosureCallNode* node); | 356 ClosureCallInstr* BuildClosureCall(ClosureCallNode* node); |
| 356 | 357 |
| 357 Value* BuildNullValue(); | 358 Value* BuildNullValue(); |
| 358 | 359 |
| 359 // Returns true if the run-time type check can be eliminated. | 360 // Returns true if the run-time type check can be eliminated. |
| 360 bool CanSkipTypeCheck(intptr_t token_pos, | 361 bool CanSkipTypeCheck(intptr_t token_pos, |
| 361 Value* value, | 362 Value* value, |
| 362 const AbstractType& dst_type, | 363 const AbstractType& dst_type, |
| 363 const String& dst_name); | 364 const String& dst_name); |
| 364 | 365 |
| 366 // Helpers for allocating and deallocating temporary locals on top of the |
| 367 // expression stack. |
| 368 LocalVariable* EnterTempLocalScope(Value* value); |
| 369 Definition* ExitTempLocalScope(LocalVariable* var); |
| 370 |
| 365 void BuildLetTempExpressions(LetNode* node); | 371 void BuildLetTempExpressions(LetNode* node); |
| 366 | 372 |
| 367 private: | 373 private: |
| 368 friend class TempLocalScope; // For ReturnDefinition. | 374 friend class TempLocalScope; // For ReturnDefinition. |
| 369 | 375 |
| 370 // Specify a definition of the final result. Adds the definition to | 376 // Specify a definition of the final result. Adds the definition to |
| 371 // the graph, but normally overridden in subclasses. | 377 // the graph, but normally overridden in subclasses. |
| 372 virtual void ReturnDefinition(Definition* definition) { | 378 virtual void ReturnDefinition(Definition* definition) { |
| 373 Do(definition); | 379 Do(definition); |
| 374 } | 380 } |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 496 // Output parameters. | 502 // Output parameters. |
| 497 GrowableArray<TargetEntryInstr**> true_successor_addresses_; | 503 GrowableArray<TargetEntryInstr**> true_successor_addresses_; |
| 498 GrowableArray<TargetEntryInstr**> false_successor_addresses_; | 504 GrowableArray<TargetEntryInstr**> false_successor_addresses_; |
| 499 | 505 |
| 500 intptr_t condition_token_pos_; | 506 intptr_t condition_token_pos_; |
| 501 }; | 507 }; |
| 502 | 508 |
| 503 } // namespace dart | 509 } // namespace dart |
| 504 | 510 |
| 505 #endif // VM_FLOW_GRAPH_BUILDER_H_ | 511 #endif // VM_FLOW_GRAPH_BUILDER_H_ |
| OLD | NEW |