Fixing comment about an object's maximum reference counter. Adding runtime check for the counter's overflow.

This commit is contained in:
Ruben Ayrapetyan 2014-07-28 15:17:01 +04:00
parent 27f6d2b552
commit 7984c7e65f
2 changed files with 10 additions and 3 deletions

View File

@ -68,6 +68,11 @@ ecma_ref_object(ecma_object_t *object_p) /**< object */
* Check that value was not overflowed * Check that value was not overflowed
*/ */
JERRY_ASSERT(object_p->GCInfo.u.refs > 0); JERRY_ASSERT(object_p->GCInfo.u.refs > 0);
if ( unlikely( object_p->GCInfo.u.refs == 0 ) )
{
JERRY_UNREACHABLE();
}
} /* ecma_ref_object */ } /* ecma_ref_object */
/** /**

View File

@ -246,6 +246,8 @@ typedef struct ecma_property_t {
* Description of GC's information layout * Description of GC's information layout
*/ */
typedef struct { typedef struct {
FIXME( /* Handle cyclic dependencies */ );
/** /**
* Flag that indicates if the object is valid for normal usage. * Flag that indicates if the object is valid for normal usage.
* If the flag is zero, then the object is not valid and is queued for GC. * If the flag is zero, then the object is not valid and is queued for GC.
@ -258,9 +260,9 @@ typedef struct {
* Number of refs to the object (if is_object_valid). * Number of refs to the object (if is_object_valid).
* *
* Note: It is not a pointer. Maximum value of reference counter * Note: It is not a pointer. Maximum value of reference counter
* willn't be bigger than overall count of variables/objects/properties, * willn't be bigger than overall count of variables/objects/properties.
* which is limited by size of address space allocated for JerryScript * The width of the field will be sufficient in most cases. However, it is not theoretically
* (and, consequently, by ECMA_POINTER_FIELD_WIDTH). * guaranteed. Overflow is handled in ecma_ref_object by stopping the engine.
*/ */
unsigned int refs : ECMA_POINTER_FIELD_WIDTH; unsigned int refs : ECMA_POINTER_FIELD_WIDTH;