Chromium Code Reviews| 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_COMPILER_H_ | 5 #ifndef VM_FLOW_GRAPH_COMPILER_H_ |
| 6 #define VM_FLOW_GRAPH_COMPILER_H_ | 6 #define VM_FLOW_GRAPH_COMPILER_H_ |
| 7 | 7 |
| 8 #include "vm/allocation.h" | 8 #include "vm/allocation.h" |
| 9 #include "vm/assembler.h" | 9 #include "vm/assembler.h" |
| 10 #include "vm/code_descriptors.h" | 10 #include "vm/code_descriptors.h" |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 154 intptr_t count; | 154 intptr_t count; |
| 155 CidTarget(intptr_t cid_arg, | 155 CidTarget(intptr_t cid_arg, |
| 156 Function* target_arg, | 156 Function* target_arg, |
| 157 intptr_t count_arg) | 157 intptr_t count_arg) |
| 158 : cid(cid_arg), target(target_arg), count(count_arg) {} | 158 : cid(cid_arg), target(target_arg), count(count_arg) {} |
| 159 }; | 159 }; |
| 160 | 160 |
| 161 | 161 |
| 162 class FlowGraphCompiler : public ValueObject { | 162 class FlowGraphCompiler : public ValueObject { |
| 163 private: | 163 private: |
| 164 struct BlockInfo : public ZoneAllocated { | 164 class BlockInfo : public ZoneAllocated { |
| 165 public: | 165 public: |
| 166 BlockInfo() : label() { } | 166 BlockInfo() |
| 167 Label label; | 167 : jump_label_(&block_label_), |
| 168 block_label_(), | |
| 169 fallthrough_label_(NULL), | |
| 170 is_marked_(false) {} | |
| 171 | |
| 172 Label* jump_label() const { return jump_label_; } | |
| 173 void set_jump_label(Label* label) { jump_label_ = label; } | |
| 174 | |
| 175 Label* fallthrough_label() const { return fallthrough_label_; } | |
|
srdjan
2013/03/08 19:02:31
ASSERT that is not NULL?
Vyacheslav Egorov (Google)
2013/03/08 19:04:23
It can be NULL for the last block which has no fal
srdjan
2013/03/08 19:08:08
Right. Maybe add a comment that it is NULL for blo
Vyacheslav Egorov (Google)
2013/03/08 19:10:11
Done.
| |
| 176 void set_fallthrough_label(Label* fallthrough_label) { | |
| 177 fallthrough_label_ = fallthrough_label; | |
| 178 } | |
| 179 | |
| 180 bool WasCompacted() const { | |
| 181 return jump_label_ != &block_label_; | |
| 182 } | |
| 183 | |
| 184 bool is_marked() const { return is_marked_; } | |
| 185 void mark() { is_marked_ = true; } | |
| 186 | |
| 187 private: | |
| 188 Label* jump_label_; | |
| 189 Label block_label_; | |
| 190 | |
| 191 Label* fallthrough_label_; | |
| 192 | |
| 193 bool is_marked_; | |
| 168 }; | 194 }; |
| 169 | 195 |
| 170 public: | 196 public: |
| 171 FlowGraphCompiler(Assembler* assembler, | 197 FlowGraphCompiler(Assembler* assembler, |
| 172 const FlowGraph& flow_graph, | 198 const FlowGraph& flow_graph, |
| 173 bool is_optimizing); | 199 bool is_optimizing); |
| 174 | 200 |
| 175 ~FlowGraphCompiler(); | 201 ~FlowGraphCompiler(); |
| 176 | 202 |
| 177 static bool SupportsUnboxedMints(); | 203 static bool SupportsUnboxedMints(); |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 314 void EmitEqualityRegRegCompare(Register left, | 340 void EmitEqualityRegRegCompare(Register left, |
| 315 Register right, | 341 Register right, |
| 316 bool needs_number_check); | 342 bool needs_number_check); |
| 317 // Implement equality: if any of the arguments is null do identity check. | 343 // Implement equality: if any of the arguments is null do identity check. |
| 318 // Fallthrough calls super equality. | 344 // Fallthrough calls super equality. |
| 319 void EmitSuperEqualityCallPrologue(Register result, Label* skip_call); | 345 void EmitSuperEqualityCallPrologue(Register result, Label* skip_call); |
| 320 | 346 |
| 321 intptr_t StackSize() const; | 347 intptr_t StackSize() const; |
| 322 | 348 |
| 323 // Returns assembler label associated with the given block entry. | 349 // Returns assembler label associated with the given block entry. |
| 324 Label* GetBlockLabel(BlockEntryInstr* block_entry) const; | 350 Label* GetJumpLabel(BlockEntryInstr* block_entry) const; |
| 351 bool WasCompacted(BlockEntryInstr* block_entry) const; | |
| 325 | 352 |
| 326 // Returns true if there is a next block after the current one in | 353 // Returns true if there is a next block after the current one in |
| 327 // the block order and if it is the given block. | 354 // the block order and if it is the given block. |
| 328 bool IsNextBlock(BlockEntryInstr* block_entry) const; | 355 bool CanFallThroughTo(BlockEntryInstr* block_entry) const; |
| 329 | 356 |
| 330 void AddExceptionHandler(intptr_t try_index, | 357 void AddExceptionHandler(intptr_t try_index, |
| 331 intptr_t outer_try_index, | 358 intptr_t outer_try_index, |
| 332 intptr_t pc_offset, | 359 intptr_t pc_offset, |
| 333 const Array& handler_types); | 360 const Array& handler_types); |
| 334 void AddCurrentDescriptor(PcDescriptors::Kind kind, | 361 void AddCurrentDescriptor(PcDescriptors::Kind kind, |
| 335 intptr_t deopt_id, | 362 intptr_t deopt_id, |
| 336 intptr_t token_pos); | 363 intptr_t token_pos); |
| 337 | 364 |
| 338 void RecordSafepoint(LocationSummary* locs); | 365 void RecordSafepoint(LocationSummary* locs); |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 481 // block_order for reverse iterations. | 508 // block_order for reverse iterations. |
| 482 intptr_t reverse_index(intptr_t index) const { | 509 intptr_t reverse_index(intptr_t index) const { |
| 483 return block_order_.length() - index - 1; | 510 return block_order_.length() - index - 1; |
| 484 } | 511 } |
| 485 | 512 |
| 486 // Returns 'sorted' array in decreasing count order. | 513 // Returns 'sorted' array in decreasing count order. |
| 487 // The expected number of elements to sort is less than 10. | 514 // The expected number of elements to sort is less than 10. |
| 488 static void SortICDataByCount(const ICData& ic_data, | 515 static void SortICDataByCount(const ICData& ic_data, |
| 489 GrowableArray<CidTarget>* sorted); | 516 GrowableArray<CidTarget>* sorted); |
| 490 | 517 |
| 518 void CompactBlock(BlockEntryInstr* block); | |
| 519 void CompactBlocks(); | |
| 520 | |
|
srdjan
2013/03/08 19:02:31
Remove one line
Vyacheslav Egorov (Google)
2013/03/08 19:04:23
Done.
| |
| 521 | |
| 491 class Assembler* assembler_; | 522 class Assembler* assembler_; |
| 492 const ParsedFunction& parsed_function_; | 523 const ParsedFunction& parsed_function_; |
| 493 const GrowableArray<BlockEntryInstr*>& block_order_; | 524 const GrowableArray<BlockEntryInstr*>& block_order_; |
| 494 | 525 |
| 495 // Compiler specific per-block state. Indexed by postorder block number | 526 // Compiler specific per-block state. Indexed by postorder block number |
| 496 // for convenience. This is not the block's index in the block order, | 527 // for convenience. This is not the block's index in the block order, |
| 497 // which is reverse postorder. | 528 // which is reverse postorder. |
| 498 BlockEntryInstr* current_block_; | 529 BlockEntryInstr* current_block_; |
| 499 ExceptionHandlerList* exception_handlers_list_; | 530 ExceptionHandlerList* exception_handlers_list_; |
| 500 DescriptorList* pc_descriptors_list_; | 531 DescriptorList* pc_descriptors_list_; |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 517 // that should be used when deoptimizing we store it in this variable. | 548 // that should be used when deoptimizing we store it in this variable. |
| 518 // In future AddDeoptStub should be moved out of the instruction template. | 549 // In future AddDeoptStub should be moved out of the instruction template. |
| 519 Environment* pending_deoptimization_env_; | 550 Environment* pending_deoptimization_env_; |
| 520 | 551 |
| 521 DISALLOW_COPY_AND_ASSIGN(FlowGraphCompiler); | 552 DISALLOW_COPY_AND_ASSIGN(FlowGraphCompiler); |
| 522 }; | 553 }; |
| 523 | 554 |
| 524 } // namespace dart | 555 } // namespace dart |
| 525 | 556 |
| 526 #endif // VM_FLOW_GRAPH_COMPILER_H_ | 557 #endif // VM_FLOW_GRAPH_COMPILER_H_ |
| OLD | NEW |