From 7984c7e65f64ffc7e043d8aae609961def1ca04c Mon Sep 17 00:00:00 2001 From: Ruben Ayrapetyan Date: Mon, 28 Jul 2014 15:17:01 +0400 Subject: [PATCH] Fixing comment about an object's maximum reference counter. Adding runtime check for the counter's overflow. --- src/libecmaobjects/ecma-gc.c | 5 +++++ src/libecmaobjects/ecma-globals.h | 8 +++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/libecmaobjects/ecma-gc.c b/src/libecmaobjects/ecma-gc.c index caacb79c9..4ca47bdc9 100644 --- a/src/libecmaobjects/ecma-gc.c +++ b/src/libecmaobjects/ecma-gc.c @@ -68,6 +68,11 @@ ecma_ref_object(ecma_object_t *object_p) /**< object */ * Check that value was not overflowed */ JERRY_ASSERT(object_p->GCInfo.u.refs > 0); + + if ( unlikely( object_p->GCInfo.u.refs == 0 ) ) + { + JERRY_UNREACHABLE(); + } } /* ecma_ref_object */ /** diff --git a/src/libecmaobjects/ecma-globals.h b/src/libecmaobjects/ecma-globals.h index 5ac352f6c..f414819c9 100644 --- a/src/libecmaobjects/ecma-globals.h +++ b/src/libecmaobjects/ecma-globals.h @@ -246,6 +246,8 @@ typedef struct ecma_property_t { * Description of GC's information layout */ typedef struct { + FIXME( /* Handle cyclic dependencies */ ); + /** * 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. @@ -258,9 +260,9 @@ typedef struct { * Number of refs to the object (if is_object_valid). * * Note: It is not a pointer. Maximum value of reference counter - * willn't be bigger than overall count of variables/objects/properties, - * which is limited by size of address space allocated for JerryScript - * (and, consequently, by ECMA_POINTER_FIELD_WIDTH). + * willn't be bigger than overall count of variables/objects/properties. + * The width of the field will be sufficient in most cases. However, it is not theoretically + * guaranteed. Overflow is handled in ecma_ref_object by stopping the engine. */ unsigned int refs : ECMA_POINTER_FIELD_WIDTH;