Moving label descriptor from ecma_completion_value_t to separate structure on heap (fixing performance degradation that occured in commit 5d92544db57203603a6ed53b5c18562065a70b77).

This commit is contained in:
Ruben Ayrapetyan 2014-09-04 14:27:40 +04:00
parent 50371ddf20
commit 31b5451b50
4 changed files with 46 additions and 12 deletions

View File

@ -30,6 +30,7 @@ JERRY_STATIC_ASSERT (sizeof (ecma_collection_header_t) == sizeof (uint64_t));
JERRY_STATIC_ASSERT (sizeof (ecma_collection_chunk_t) == sizeof (uint64_t));
JERRY_STATIC_ASSERT (sizeof (ecma_string_t) == sizeof (uint64_t));
JERRY_STATIC_ASSERT (sizeof (ecma_completion_value_t) == sizeof (uint32_t));
JERRY_STATIC_ASSERT (sizeof (ecma_label_descriptor_t) == sizeof (uint64_t));
/** \addtogroup ecma ECMA
* @{
@ -101,6 +102,7 @@ DECLARE_ROUTINES_FOR (number)
DECLARE_ROUTINES_FOR (collection_header)
DECLARE_ROUTINES_FOR (collection_chunk)
DECLARE_ROUTINES_FOR (string)
DECLARE_ROUTINES_FOR (label_descriptor)
/**
* @}

View File

@ -97,6 +97,18 @@ extern ecma_string_t *ecma_alloc_string (void);
*/
extern void ecma_dealloc_string (ecma_string_t *string_p);
/**
* Allocate memory for label descriptor
*
* @return pointer to allocated memory
*/
extern ecma_label_descriptor_t *ecma_alloc_label_descriptor (void);
/**
* Dealloc memory from label descriptor
*/
extern void ecma_dealloc_label_descriptor (ecma_label_descriptor_t *label_desc_p);
#endif /* JERRY_ECMA_ALLOC_H */
/**

View File

@ -132,7 +132,10 @@ typedef struct
typedef struct
{
/** Type (ecma_completion_type_t) */
unsigned int type : 8;
uint8_t type;
/** Just padding for the structure */
uint8_t padding;
union
{
@ -148,16 +151,23 @@ typedef struct
*
* Used for break and continue completion types.
*/
struct
{
/** Levels to label left */
uint8_t depth;
uint16_t label_desc_cp;
} u;
} ecma_completion_value_t;
/** Target's offset */
uint16_t offset;
} __packed target;
} __packed u;
} __packed ecma_completion_value_t;
/**
* Label
*
* Used for break and continue completion types.
*/
typedef struct
{
/** Target's offset */
uint32_t offset;
/** Levels to label left */
uint32_t depth;
} ecma_label_descriptor_t;
/**
* Target value indicating that target field

View File

@ -319,9 +319,15 @@ ecma_make_label_completion_value (ecma_completion_type_t type, /**< type */
ecma_completion_value_t ret_value;
ecma_label_descriptor_t *label_desc_p = ecma_alloc_label_descriptor ();
*label_desc_p = (ecma_label_descriptor_t)
{
.offset = offset,
.depth = depth_level
};
ret_value.type = type;
ret_value.u.target.depth = depth_level;
ret_value.u.target.offset = offset;
ECMA_SET_POINTER (ret_value.u.label_desc_cp, label_desc_p);
return ret_value;
} /* ecma_make_label_completion_value */
@ -470,6 +476,10 @@ ecma_free_completion_value (ecma_completion_value_t completion_value) /**< compl
}
case ECMA_COMPLETION_TYPE_CONTINUE:
case ECMA_COMPLETION_TYPE_BREAK:
{
ecma_dealloc_label_descriptor (ECMA_GET_POINTER (completion_value.u.label_desc_cp));
break;
}
case ECMA_COMPLETION_TYPE_META:
{
JERRY_UNREACHABLE ();