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

Unified Diff: runtime/vm/assembler.h

Issue 848703002: Improve constant pool implementation in the assembler. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: updated test status file Created 5 years, 11 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/assembler_arm.h » ('j') | runtime/vm/hash_map.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/assembler.h
===================================================================
--- runtime/vm/assembler.h (revision 42801)
+++ runtime/vm/assembler.h (working copy)
@@ -205,6 +205,57 @@
friend class AssemblerFixup;
};
+
+// Pair type parameter for DirectChainedHashMap used for the constant pool.
+class ObjIndexPair {
+ public:
+ // Typedefs needed for the DirectChainedHashMap template.
+ typedef const Object* Key;
+ typedef intptr_t Value;
+ typedef ObjIndexPair Pair;
+
+ explicit ObjIndexPair(Value value) : key_(NULL), value_(NoValue()) { }
Vyacheslav Egorov (Google) 2015/01/13 13:47:30 I think parameter is redundant. Just provide defau
Florian Schneider 2015/01/13 14:09:08 Done.
+
+ ObjIndexPair(Key key, Value value)
+ : key_(key->IsNotTemporaryScopedHandle()
+ ? key : &Object::ZoneHandle(key->raw())),
+ value_(value) { }
+
+ static Key KeyOf(Pair kv) { return kv.key_; }
+
+ static Value ValueOf(Pair kv) { return kv.value_; }
+
+ static Value NoValue() { return -1; }
+
+ static intptr_t Hashcode(Key key) {
+ if (key->IsSmi()) {
+ return Smi::Cast(*key).Value();
+ }
+ if (key->IsDouble()) {
+ return static_cast<intptr_t>(
+ bit_cast<int32_t, float>(
+ static_cast<float>(Double::Cast(*key).value())));
+ }
+ if (key->IsMint()) {
+ return static_cast<intptr_t>(Mint::Cast(*key).value());
+ }
+ if (key->IsString()) {
+ return String::Cast(*key).Hash();
+ }
+ // TODO(fschneider): Add hash function for other classes commonly used as
+ // compile-time constants.
+ return key->GetClassId();
+ }
+
+ static inline bool IsKeyEqual(Pair kv, Key key) {
+ return kv.key_->raw() == key->raw();
+ }
+
+ private:
+ Key key_;
+ Value value_;
+};
+
} // namespace dart
« no previous file with comments | « no previous file | runtime/vm/assembler_arm.h » ('j') | runtime/vm/hash_map.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698