Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1145)

Unified Diff: runtime/vm/flow_graph.h

Issue 344883009: Use hash map for the SSA builder constant pool. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | runtime/vm/flow_graph.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_;
};
« no previous file with comments | « no previous file | runtime/vm/flow_graph.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698