Chromium Code Reviews| Index: runtime/vm/flow_graph.h |
| =================================================================== |
| --- runtime/vm/flow_graph.h (revision 37814) |
| +++ runtime/vm/flow_graph.h (working copy) |
| @@ -6,6 +6,7 @@ |
| #define VM_FLOW_GRAPH_H_ |
| #include "vm/growable_array.h" |
| +#include "vm/hash_map.h" |
| #include "vm/intermediate_language.h" |
| #include "vm/parser.h" |
| @@ -41,6 +42,40 @@ |
| }; |
| +struct ConstantPoolTrait { |
| + typedef ConstantInstr* Value; |
| + typedef const Object& Key; |
| + typedef ConstantInstr* Pair; |
| + |
| + static Key KeyOf(Pair kv) { |
| + return kv->value(); |
| + } |
| + |
| + static Value ValueOf(Pair kv) { |
| + return kv; |
| + } |
| + |
| + static inline intptr_t Hashcode(Key key) { |
| + if (key.IsSmi()) { |
| + return Smi::Cast(key).Value(); |
| + } |
| + 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.
|
| + return static_cast<intptr_t>( |
| + bit_cast<int32_t, float>( |
| + static_cast<float>(Double::Cast(key).value()))); |
| + } |
| + if (key.IsString()) { |
| + return String::Cast(key).Hash(); |
| + } |
| + 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
|
| + } |
| + |
| + static inline bool IsKeyEqual(Pair kv, Key key) { |
| + 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
|
| + } |
| +}; |
| + |
| + |
| // Class to encapsulate the construction and manipulation of the flow graph. |
| class FlowGraph : public ZoneAllocated { |
| public: |
| @@ -301,6 +336,7 @@ |
| ZoneGrowableArray<BitVector*>* loop_invariant_loads_; |
| ZoneGrowableArray<const Field*>* guarded_fields_; |
| ZoneGrowableArray<const LibraryPrefix*>* deferred_prefixes_; |
| + DirectChainedHashMap<ConstantPoolTrait> constant_instr_pool_; |
| }; |