| 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 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 typedef const Function* Value; | 101 typedef const Function* Value; |
| 102 typedef const Function* Pair; | 102 typedef const Function* Pair; |
| 103 | 103 |
| 104 static Key KeyOf(Pair kv) { return kv; } | 104 static Key KeyOf(Pair kv) { return kv; } |
| 105 | 105 |
| 106 static Value ValueOf(Pair kv) { return kv; } | 106 static Value ValueOf(Pair kv) { return kv; } |
| 107 | 107 |
| 108 static inline intptr_t Hashcode(Key key) { | 108 static inline intptr_t Hashcode(Key key) { |
| 109 // We are using pointer hash for objects originating from Kernel because | 109 // We are using pointer hash for objects originating from Kernel because |
| 110 // Fasta currently does not assign any position information to them. | 110 // Fasta currently does not assign any position information to them. |
| 111 if (key->kernel_function() != NULL) { | 111 if (key->kernel_offset() > 0) { |
| 112 return SimplePointerHash(key->kernel_function()); | 112 return key->kernel_offset(); |
| 113 } else { | 113 } else { |
| 114 return key->token_pos().value(); | 114 return key->token_pos().value(); |
| 115 } | 115 } |
| 116 } | 116 } |
| 117 | 117 |
| 118 static inline bool IsKeyEqual(Pair pair, Key key) { | 118 static inline bool IsKeyEqual(Pair pair, Key key) { |
| 119 return pair->raw() == key->raw(); | 119 return pair->raw() == key->raw(); |
| 120 } | 120 } |
| 121 }; | 121 }; |
| 122 | 122 |
| 123 typedef DirectChainedHashMap<FunctionKeyValueTrait> FunctionSet; | 123 typedef DirectChainedHashMap<FunctionKeyValueTrait> FunctionSet; |
| 124 | 124 |
| 125 | 125 |
| 126 class FieldKeyValueTrait { | 126 class FieldKeyValueTrait { |
| 127 public: | 127 public: |
| 128 // Typedefs needed for the DirectChainedHashMap template. | 128 // Typedefs needed for the DirectChainedHashMap template. |
| 129 typedef const Field* Key; | 129 typedef const Field* Key; |
| 130 typedef const Field* Value; | 130 typedef const Field* Value; |
| 131 typedef const Field* Pair; | 131 typedef const Field* Pair; |
| 132 | 132 |
| 133 static Key KeyOf(Pair kv) { return kv; } | 133 static Key KeyOf(Pair kv) { return kv; } |
| 134 | 134 |
| 135 static Value ValueOf(Pair kv) { return kv; } | 135 static Value ValueOf(Pair kv) { return kv; } |
| 136 | 136 |
| 137 static inline intptr_t Hashcode(Key key) { | 137 static inline intptr_t Hashcode(Key key) { |
| 138 // We are using pointer hash for objects originating from Kernel because | 138 // We are using pointer hash for objects originating from Kernel because |
| 139 // Fasta currently does not assign any position information to them. | 139 // Fasta currently does not assign any position information to them. |
| 140 if (key->kernel_field() != NULL) { | 140 if (key->kernel_offset() > 0) { |
| 141 return SimplePointerHash(key->kernel_field()); | 141 return key->kernel_offset(); |
| 142 } else { | 142 } else { |
| 143 return key->token_pos().value(); | 143 return key->token_pos().value(); |
| 144 } | 144 } |
| 145 } | 145 } |
| 146 | 146 |
| 147 static inline bool IsKeyEqual(Pair pair, Key key) { | 147 static inline bool IsKeyEqual(Pair pair, Key key) { |
| 148 return pair->raw() == key->raw(); | 148 return pair->raw() == key->raw(); |
| 149 } | 149 } |
| 150 }; | 150 }; |
| 151 | 151 |
| (...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 485 } | 485 } |
| 486 static RawObject* NewKey(const Function& function) { return function.raw(); } | 486 static RawObject* NewKey(const Function& function) { return function.raw(); } |
| 487 }; | 487 }; |
| 488 | 488 |
| 489 typedef UnorderedHashSet<FunctionsTraits> UniqueFunctionsSet; | 489 typedef UnorderedHashSet<FunctionsTraits> UniqueFunctionsSet; |
| 490 | 490 |
| 491 | 491 |
| 492 } // namespace dart | 492 } // namespace dart |
| 493 | 493 |
| 494 #endif // RUNTIME_VM_PRECOMPILER_H_ | 494 #endif // RUNTIME_VM_PRECOMPILER_H_ |
| OLD | NEW |