Chromium Code Reviews| OLD | NEW |
|---|---|
| 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_FLOW_GRAPH_H_ | 5 #ifndef VM_FLOW_GRAPH_H_ |
| 6 #define VM_FLOW_GRAPH_H_ | 6 #define VM_FLOW_GRAPH_H_ |
| 7 | 7 |
| 8 #include "vm/growable_array.h" | 8 #include "vm/growable_array.h" |
| 9 #include "vm/hash_map.h" | |
| 9 #include "vm/intermediate_language.h" | 10 #include "vm/intermediate_language.h" |
| 10 #include "vm/parser.h" | 11 #include "vm/parser.h" |
| 11 | 12 |
| 12 namespace dart { | 13 namespace dart { |
| 13 | 14 |
| 14 class BlockEffects; | 15 class BlockEffects; |
| 15 class FlowGraphBuilder; | 16 class FlowGraphBuilder; |
| 16 class ValueInliningContext; | 17 class ValueInliningContext; |
| 17 class VariableLivenessAnalysis; | 18 class VariableLivenessAnalysis; |
| 18 | 19 |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 34 bool Done() const { return current_ >= block_order_.length(); } | 35 bool Done() const { return current_ >= block_order_.length(); } |
| 35 | 36 |
| 36 BlockEntryInstr* Current() const { return block_order_[current_]; } | 37 BlockEntryInstr* Current() const { return block_order_[current_]; } |
| 37 | 38 |
| 38 private: | 39 private: |
| 39 const GrowableArray<BlockEntryInstr*>& block_order_; | 40 const GrowableArray<BlockEntryInstr*>& block_order_; |
| 40 intptr_t current_; | 41 intptr_t current_; |
| 41 }; | 42 }; |
| 42 | 43 |
| 43 | 44 |
| 45 struct ConstantPoolTrait { | |
| 46 typedef ConstantInstr* Value; | |
| 47 typedef const Object& Key; | |
| 48 typedef ConstantInstr* Pair; | |
| 49 | |
| 50 static Key KeyOf(Pair kv) { | |
| 51 return kv->value(); | |
| 52 } | |
| 53 | |
| 54 static Value ValueOf(Pair kv) { | |
| 55 return kv; | |
| 56 } | |
| 57 | |
| 58 static inline intptr_t Hashcode(Key key) { | |
| 59 if (key.IsSmi()) { | |
| 60 return Smi::Cast(key).Value(); | |
| 61 } | |
| 62 if (key.IsDouble()) { | |
|
Vyacheslav Egorov (Google)
2014/06/30 12:13:57
Add mint to cover all common number types.
Florian Schneider
2014/06/30 12:38:10
Done.
| |
| 63 return static_cast<intptr_t>( | |
| 64 bit_cast<int32_t, float>( | |
| 65 static_cast<float>(Double::Cast(key).value()))); | |
| 66 } | |
| 67 if (key.IsString()) { | |
| 68 return String::Cast(key).Hash(); | |
| 69 } | |
| 70 return key.GetClassId(); | |
|
Vyacheslav Egorov (Google)
2014/06/30 12:13:58
So we still will degrade to linear search when the
Vyacheslav Egorov (Google)
2014/06/30 12:13:58
So we still will degrade to linear search when the
Florian Schneider
2014/06/30 12:38:10
Yep. Currently, there is no fast, generic hash-cod
| |
| 71 } | |
| 72 | |
| 73 static inline bool IsKeyEqual(Pair kv, Key key) { | |
| 74 return kv->value().raw() == key.raw(); | |
|
Vyacheslav Egorov (Google)
2014/06/30 12:13:58
identity is not the best equality for numbers and
Florian Schneider
2014/06/30 12:38:10
Yes, but this is used mostly for canonicalized con
| |
| 75 } | |
| 76 }; | |
| 77 | |
| 78 | |
| 44 // Class to encapsulate the construction and manipulation of the flow graph. | 79 // Class to encapsulate the construction and manipulation of the flow graph. |
| 45 class FlowGraph : public ZoneAllocated { | 80 class FlowGraph : public ZoneAllocated { |
| 46 public: | 81 public: |
| 47 FlowGraph(const FlowGraphBuilder& builder, | 82 FlowGraph(const FlowGraphBuilder& builder, |
| 48 GraphEntryInstr* graph_entry, | 83 GraphEntryInstr* graph_entry, |
| 49 intptr_t max_block_id); | 84 intptr_t max_block_id); |
| 50 | 85 |
| 51 const FlowGraphBuilder& builder() const { | 86 const FlowGraphBuilder& builder() const { |
| 52 return builder_; | 87 return builder_; |
| 53 } | 88 } |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 294 | 329 |
| 295 BlockEffects* block_effects_; | 330 BlockEffects* block_effects_; |
| 296 bool licm_allowed_; | 331 bool licm_allowed_; |
| 297 | 332 |
| 298 bool use_far_branches_; | 333 bool use_far_branches_; |
| 299 | 334 |
| 300 ZoneGrowableArray<BlockEntryInstr*>* loop_headers_; | 335 ZoneGrowableArray<BlockEntryInstr*>* loop_headers_; |
| 301 ZoneGrowableArray<BitVector*>* loop_invariant_loads_; | 336 ZoneGrowableArray<BitVector*>* loop_invariant_loads_; |
| 302 ZoneGrowableArray<const Field*>* guarded_fields_; | 337 ZoneGrowableArray<const Field*>* guarded_fields_; |
| 303 ZoneGrowableArray<const LibraryPrefix*>* deferred_prefixes_; | 338 ZoneGrowableArray<const LibraryPrefix*>* deferred_prefixes_; |
| 339 DirectChainedHashMap<ConstantPoolTrait> constant_instr_pool_; | |
| 304 }; | 340 }; |
| 305 | 341 |
| 306 | 342 |
| 307 class LivenessAnalysis : public ValueObject { | 343 class LivenessAnalysis : public ValueObject { |
| 308 public: | 344 public: |
| 309 LivenessAnalysis(intptr_t variable_count, | 345 LivenessAnalysis(intptr_t variable_count, |
| 310 const GrowableArray<BlockEntryInstr*>& postorder); | 346 const GrowableArray<BlockEntryInstr*>& postorder); |
| 311 | 347 |
| 312 void Analyze(); | 348 void Analyze(); |
| 313 | 349 |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 403 // Per block sets of available blocks. Block A is available at the block B if | 439 // Per block sets of available blocks. Block A is available at the block B if |
| 404 // and only if A dominates B and all paths from A to B are free of side | 440 // and only if A dominates B and all paths from A to B are free of side |
| 405 // effects. | 441 // effects. |
| 406 GrowableArray<BitVector*> available_at_; | 442 GrowableArray<BitVector*> available_at_; |
| 407 }; | 443 }; |
| 408 | 444 |
| 409 | 445 |
| 410 } // namespace dart | 446 } // namespace dart |
| 411 | 447 |
| 412 #endif // VM_FLOW_GRAPH_H_ | 448 #endif // VM_FLOW_GRAPH_H_ |
| OLD | NEW |