parent
e3afc78fde
commit
9a7061dfab
2 changed files with 5 additions and 11 deletions
|
@ -48,21 +48,16 @@ rust_crate_cache::get_type_desc(size_t size,
|
||||||
void**
|
void**
|
||||||
rust_crate_cache::get_dict(size_t n_fields, void** dict) {
|
rust_crate_cache::get_dict(size_t n_fields, void** dict) {
|
||||||
rust_hashable_dict *found = NULL;
|
rust_hashable_dict *found = NULL;
|
||||||
uintptr_t key = 0;
|
size_t dictsz = sizeof(void*) * n_fields;
|
||||||
for (size_t i = 0; i < n_fields; ++i) key ^= (uintptr_t)dict[i];
|
HASH_FIND(hh, this->dicts, dict, dictsz, found);
|
||||||
size_t keysz = sizeof(uintptr_t);
|
if (found) return &(found->fields[0]);
|
||||||
HASH_FIND(hh, this->dicts, &key, keysz, found);
|
|
||||||
if (found) { printf("found!\n"); return &(found->fields[0]); }
|
|
||||||
printf("not found\n");
|
|
||||||
size_t dictsz = n_fields * sizeof(void*);
|
|
||||||
found = (rust_hashable_dict*)
|
found = (rust_hashable_dict*)
|
||||||
sched->kernel->malloc(keysz + sizeof(UT_hash_handle) + dictsz,
|
sched->kernel->malloc(sizeof(UT_hash_handle) + dictsz,
|
||||||
"crate cache dict");
|
"crate cache dict");
|
||||||
if (!found) return NULL;
|
if (!found) return NULL;
|
||||||
found->key = key;
|
|
||||||
void** retptr = &(found->fields[0]);
|
void** retptr = &(found->fields[0]);
|
||||||
memcpy(retptr, dict, dictsz);
|
memcpy(retptr, dict, dictsz);
|
||||||
HASH_ADD(hh, this->dicts, key, keysz, found);
|
HASH_ADD_KEYPTR(hh, this->dicts, retptr, dictsz, found);
|
||||||
return retptr;
|
return retptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,6 @@
|
||||||
struct rust_scheduler;
|
struct rust_scheduler;
|
||||||
|
|
||||||
struct rust_hashable_dict {
|
struct rust_hashable_dict {
|
||||||
uintptr_t key;
|
|
||||||
UT_hash_handle hh;
|
UT_hash_handle hh;
|
||||||
void* fields[0];
|
void* fields[0];
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue