Chromium Code Reviews| Index: runtime/vm/assembler_x64.h |
| =================================================================== |
| --- runtime/vm/assembler_x64.h (revision 42727) |
| +++ runtime/vm/assembler_x64.h (working copy) |
| @@ -1026,34 +1026,44 @@ |
| // Pair type parameter for DirectChainedHashMap. |
| class ObjIndexPair { |
| public: |
| - // TODO(zra): A WeakTable should be used here instead, but then it would |
| - // also have to be possible to register and de-register WeakTables with the |
| - // heap. Also, the Assembler would need to become a StackResource. |
| - // Issue 13305. In the meantime... |
| - // CAUTION: the RawObject* below is only safe because: |
| - // The HashMap that will use this pair type will not contain any RawObject* |
| - // keys that are not in the object_pool_ array. Since the keys will be |
| - // visited by the GC when it visits the object_pool_, and since all objects |
| - // in the object_pool_ are Old (and so will not be moved) the GC does not |
| - // also need to visit the keys here in the HashMap. |
| - |
| // Typedefs needed for the DirectChainedHashMap template. |
| - typedef RawObject* Key; |
| + typedef const Object* Key; |
| typedef intptr_t Value; |
| typedef ObjIndexPair Pair; |
| - ObjIndexPair(Key key, Value value) : key_(key), value_(value) { } |
| + explicit ObjIndexPair(Value value) : key_(NULL), value_(NoValue()) { } |
| + ObjIndexPair(Key key, Value value) |
| + : key_(key->IsNotTemporaryScopedHandle() |
| + ? key : &Object::ZoneHandle(key->raw())), |
|
zra
2015/01/12 17:33:59
I'm not sure I understand what the implications ar
Florian Schneider
2015/01/13 09:54:19
The zone goes away as soon as compilation is finis
|
| + 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) { |
| - return reinterpret_cast<intptr_t>(key) >> kObjectAlignmentLog2; |
| + 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(); |
| + } |
| + return key->GetClassId(); |
|
zra
2015/01/12 17:33:59
So, Bool::True and Bool::False will end up in the
Florian Schneider
2015/01/13 09:54:19
So, for Object::null, Bool::True/False we don't ev
|
| } |
| static inline bool IsKeyEqual(Pair kv, Key key) { |
| - return kv.key_ == key; |
| + return kv.key_->raw() == key->raw(); |
| } |
| private: |