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

Unified Diff: runtime/vm/precompiler.h

Issue 2739623002: VM: [Kernel, Precompiler] Improve Function and Field hashes for objects originating from Kernel. (Closed)
Patch Set: Add comment Created 3 years, 9 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/precompiler.h
diff --git a/runtime/vm/precompiler.h b/runtime/vm/precompiler.h
index 788182a2eb9f5712cb22ed995dda6968fc51ed52..3989c1feae6b6a30e678ccb5d297c5ca27e565bf 100644
--- a/runtime/vm/precompiler.h
+++ b/runtime/vm/precompiler.h
@@ -181,6 +181,9 @@ class UnlinkedCallKeyValueTrait {
typedef DirectChainedHashMap<UnlinkedCallKeyValueTrait> UnlinkedCallSet;
+static inline intptr_t SimplePointerHash(void* ptr) {
+ return reinterpret_cast<intptr_t>(ptr) * 2654435761UL;
+}
class FunctionKeyValueTrait {
public:
@@ -193,7 +196,15 @@ class FunctionKeyValueTrait {
static Value ValueOf(Pair kv) { return kv; }
- static inline intptr_t Hashcode(Key key) { return key->token_pos().value(); }
+ static inline intptr_t Hashcode(Key key) {
+ // We are using pointer hash for objects originating from Kernel because
+ // Fasta currently does not assign any position information to them.
+ if (key->kernel_function() != NULL) {
+ return SimplePointerHash(key->kernel_function());
+ } else {
+ return key->token_pos().value();
+ }
+ }
static inline bool IsKeyEqual(Pair pair, Key key) {
return pair->raw() == key->raw();
@@ -214,7 +225,15 @@ class FieldKeyValueTrait {
static Value ValueOf(Pair kv) { return kv; }
- static inline intptr_t Hashcode(Key key) { return key->token_pos().value(); }
+ static inline intptr_t Hashcode(Key key) {
+ // We are using pointer hash for objects originating from Kernel because
+ // Fasta currently does not assign any position information to them.
+ if (key->kernel_field() != NULL) {
+ return SimplePointerHash(key->kernel_field());
+ } else {
+ return key->token_pos().value();
+ }
+ }
static inline bool IsKeyEqual(Pair pair, Key key) {
return pair->raw() == key->raw();
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698