-
Notifications
You must be signed in to change notification settings - Fork 516
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
79 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
* Object property table slot cache. | ||
*/ | ||
|
||
#include "duk_internal.h" | ||
|
||
DUK_INTERNAL duk_uint32_t duk_heap_slotcache_lookup(duk_heap *heap, duk_hobject *obj, duk_hstring *key) { | ||
duk_uint32_t idx; | ||
duk_slotcache_entry *ent; | ||
|
||
DUK_ASSERT(heap != NULL); | ||
DUK_ASSERT(obj != NULL); | ||
DUK_ASSERT(key != NULL); | ||
|
||
/* FIXME: assert: hashlimit <= 256 */ | ||
|
||
idx = ((duk_uint32_t) obj) ^ DUK_HSTRING_GET_HASH(key); | ||
ent = heap->slotcache + (idx & (DUK_HEAP_SLOTCACHE_SIZE - 1)); | ||
return ent->slot; | ||
} | ||
|
||
DUK_INTERNAL void duk_heap_slotcache_insert(duk_heap *heap, duk_hobject *obj, duk_hstring *key, duk_uint32_t slot) { | ||
duk_uint32_t idx; | ||
duk_slotcache_entry *ent; | ||
|
||
/* FIXME: assert: hashlimit <= 256 */ | ||
/* FIXME: skip check if hash part present and hashlimit correct */ | ||
if (DUK_UNLIKELY(slot >= DUK_UINT16_MAX)) { | ||
return; | ||
} | ||
idx = ((duk_uint32_t) obj) ^ DUK_HSTRING_GET_HASH(key); | ||
ent = heap->slotcache + (idx & (DUK_HEAP_SLOTCACHE_SIZE - 1)); | ||
ent->slot = (duk_uint16_t) slot; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters