| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 RUNTIME_VM_PRECOMPILER_H_ | 5 #ifndef RUNTIME_VM_PRECOMPILER_H_ |
| 6 #define RUNTIME_VM_PRECOMPILER_H_ | 6 #define RUNTIME_VM_PRECOMPILER_H_ |
| 7 | 7 |
| 8 #include "vm/allocation.h" | 8 #include "vm/allocation.h" |
| 9 #include "vm/hash_map.h" | 9 #include "vm/hash_map.h" |
| 10 #include "vm/hash_table.h" | 10 #include "vm/hash_table.h" |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 } | 174 } |
| 175 | 175 |
| 176 static inline bool IsKeyEqual(Pair pair, Key key) { | 176 static inline bool IsKeyEqual(Pair pair, Key key) { |
| 177 return (pair->target_name() == key->target_name()) && | 177 return (pair->target_name() == key->target_name()) && |
| 178 (pair->args_descriptor() == key->args_descriptor()); | 178 (pair->args_descriptor() == key->args_descriptor()); |
| 179 } | 179 } |
| 180 }; | 180 }; |
| 181 | 181 |
| 182 typedef DirectChainedHashMap<UnlinkedCallKeyValueTrait> UnlinkedCallSet; | 182 typedef DirectChainedHashMap<UnlinkedCallKeyValueTrait> UnlinkedCallSet; |
| 183 | 183 |
| 184 static inline intptr_t SimplePointerHash(void* ptr) { |
| 185 return reinterpret_cast<intptr_t>(ptr) * 2654435761UL; |
| 186 } |
| 184 | 187 |
| 185 class FunctionKeyValueTrait { | 188 class FunctionKeyValueTrait { |
| 186 public: | 189 public: |
| 187 // Typedefs needed for the DirectChainedHashMap template. | 190 // Typedefs needed for the DirectChainedHashMap template. |
| 188 typedef const Function* Key; | 191 typedef const Function* Key; |
| 189 typedef const Function* Value; | 192 typedef const Function* Value; |
| 190 typedef const Function* Pair; | 193 typedef const Function* Pair; |
| 191 | 194 |
| 192 static Key KeyOf(Pair kv) { return kv; } | 195 static Key KeyOf(Pair kv) { return kv; } |
| 193 | 196 |
| 194 static Value ValueOf(Pair kv) { return kv; } | 197 static Value ValueOf(Pair kv) { return kv; } |
| 195 | 198 |
| 196 static inline intptr_t Hashcode(Key key) { return key->token_pos().value(); } | 199 static inline intptr_t Hashcode(Key key) { |
| 200 // We are using pointer hash for objects originating from Kernel because |
| 201 // Fasta currently does not assign any position information to them. |
| 202 if (key->kernel_function() != NULL) { |
| 203 return SimplePointerHash(key->kernel_function()); |
| 204 } else { |
| 205 return key->token_pos().value(); |
| 206 } |
| 207 } |
| 197 | 208 |
| 198 static inline bool IsKeyEqual(Pair pair, Key key) { | 209 static inline bool IsKeyEqual(Pair pair, Key key) { |
| 199 return pair->raw() == key->raw(); | 210 return pair->raw() == key->raw(); |
| 200 } | 211 } |
| 201 }; | 212 }; |
| 202 | 213 |
| 203 typedef DirectChainedHashMap<FunctionKeyValueTrait> FunctionSet; | 214 typedef DirectChainedHashMap<FunctionKeyValueTrait> FunctionSet; |
| 204 | 215 |
| 205 | 216 |
| 206 class FieldKeyValueTrait { | 217 class FieldKeyValueTrait { |
| 207 public: | 218 public: |
| 208 // Typedefs needed for the DirectChainedHashMap template. | 219 // Typedefs needed for the DirectChainedHashMap template. |
| 209 typedef const Field* Key; | 220 typedef const Field* Key; |
| 210 typedef const Field* Value; | 221 typedef const Field* Value; |
| 211 typedef const Field* Pair; | 222 typedef const Field* Pair; |
| 212 | 223 |
| 213 static Key KeyOf(Pair kv) { return kv; } | 224 static Key KeyOf(Pair kv) { return kv; } |
| 214 | 225 |
| 215 static Value ValueOf(Pair kv) { return kv; } | 226 static Value ValueOf(Pair kv) { return kv; } |
| 216 | 227 |
| 217 static inline intptr_t Hashcode(Key key) { return key->token_pos().value(); } | 228 static inline intptr_t Hashcode(Key key) { |
| 229 // We are using pointer hash for objects originating from Kernel because |
| 230 // Fasta currently does not assign any position information to them. |
| 231 if (key->kernel_field() != NULL) { |
| 232 return SimplePointerHash(key->kernel_field()); |
| 233 } else { |
| 234 return key->token_pos().value(); |
| 235 } |
| 236 } |
| 218 | 237 |
| 219 static inline bool IsKeyEqual(Pair pair, Key key) { | 238 static inline bool IsKeyEqual(Pair pair, Key key) { |
| 220 return pair->raw() == key->raw(); | 239 return pair->raw() == key->raw(); |
| 221 } | 240 } |
| 222 }; | 241 }; |
| 223 | 242 |
| 224 typedef DirectChainedHashMap<FieldKeyValueTrait> FieldSet; | 243 typedef DirectChainedHashMap<FieldKeyValueTrait> FieldSet; |
| 225 | 244 |
| 226 | 245 |
| 227 class ClassKeyValueTrait { | 246 class ClassKeyValueTrait { |
| (...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 561 } | 580 } |
| 562 static RawObject* NewKey(const Function& function) { return function.raw(); } | 581 static RawObject* NewKey(const Function& function) { return function.raw(); } |
| 563 }; | 582 }; |
| 564 | 583 |
| 565 typedef UnorderedHashSet<FunctionsTraits> UniqueFunctionsSet; | 584 typedef UnorderedHashSet<FunctionsTraits> UniqueFunctionsSet; |
| 566 | 585 |
| 567 | 586 |
| 568 } // namespace dart | 587 } // namespace dart |
| 569 | 588 |
| 570 #endif // RUNTIME_VM_PRECOMPILER_H_ | 589 #endif // RUNTIME_VM_PRECOMPILER_H_ |
| OLD | NEW |