Skip to content

Commit

Permalink
literal storage using hashmap
Browse files Browse the repository at this point in the history
  • Loading branch information
ronanj committed Mar 18, 2024
1 parent 4cb9e27 commit c038811
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 8 deletions.
4 changes: 3 additions & 1 deletion jerry-core/ecma/base/ecma-literal-storage.c
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,9 @@ ecma_find_empty_literal_string_slot (void)
* @return jmem_cpointer_t slot pointer
*/

#if !JERRY_LIT_HASHMAP
static jmem_cpointer_t *
ecma_find_empty_or_same_literal_string_slot (ecma_string_t *string_p)
ecma_find_empty_or_same_literal_string_slot (ecma_string_t *string_p /**< string to be searched */)
{
jmem_cpointer_t string_list_cp = JERRY_CONTEXT (string_list_first_cp);
jmem_cpointer_t *empty_cpointer_p = NULL;
Expand Down Expand Up @@ -250,6 +251,7 @@ ecma_find_empty_or_same_literal_string_slot (ecma_string_t *string_p)

return ecma_allocate_new_string_slot ();
} /* ecma_find_empty_or_same_literal_string_slot */
#endif

/**
* Find or create a literal string.
Expand Down
6 changes: 5 additions & 1 deletion jerry-core/lit/lit-hashmap-internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,13 @@
#define HASHMAP_ALWAYS_INLINE __attribute__ ((always_inline)) inline
#define HASHMAP_LINEAR_PROBE_LENGTH (8)

/**
* hashmap creation options.
*/

typedef struct hashmap_create_options_s
{
hashmap_uint32_t initial_capacity;
hashmap_uint32_t initial_capacity; /**< initial hashmap capacity */
} hashmap_create_options_t;

/// @brief Create a hashmap.
Expand Down
20 changes: 14 additions & 6 deletions jerry-core/lit/lit-hashmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,26 @@ typedef uint8_t hashmap_uint8_t;
typedef uint32_t hashmap_uint32_t;
typedef uint64_t hashmap_uint64_t;

/**
* hashmap element
*/

typedef struct hashmap_element_s
{
const ecma_string_t *data;
const ecma_string_t *data; /**< point to a literal */
} hashmap_element_t;

/**
* hashmap structure
*/

typedef struct hashmap_s
{
hashmap_uint32_t log2_capacity;
hashmap_uint32_t size;
struct hashmap_element_s *data;
size_t alloc_size;
uint8_t initialized;
hashmap_uint32_t log2_capacity; /**< hashmap capacity */
hashmap_uint32_t size; /**< hashmap size*/
struct hashmap_element_s *data; /**< element array */
size_t alloc_size; /**< allocated size */
uint8_t initialized; /**< 0 if not initialized */
} hashmap_t;

/// @brief Initialize the hashmap.
Expand Down

0 comments on commit c038811

Please sign in to comment.