diff --git a/src/libecmaobjects/ecma-alloc.c b/src/libecmaobjects/ecma-alloc.c index 2a88d8f9b..f443ff5fa 100644 --- a/src/libecmaobjects/ecma-alloc.c +++ b/src/libecmaobjects/ecma-alloc.c @@ -65,16 +65,20 @@ ecma_alloc_ ## ecma_type (void) \ return p ## ecma_type; \ } \ \ - ecma_gc_run( ECMA_GC_GEN_0 ); \ - \ - p ## ecma_type = (ecma_ ## ecma_type ## _t *) \ - mem_pools_alloc( mem_size_to_pool_chunk_type( sizeof(ecma_ ## ecma_type ## _t))); \ - \ - if ( likely( p ## ecma_type != NULL ) ) \ + for ( ecma_gc_gen_t gen_id = ECMA_GC_GEN_0; \ + gen_id < ECMA_GC_GEN_COUNT; \ + gen_id++ ) \ { \ - return p ## ecma_type; \ + ecma_gc_run( gen_id ); \ + \ + p ## ecma_type = (ecma_ ## ecma_type ## _t *) \ + mem_pools_alloc( mem_size_to_pool_chunk_type( sizeof(ecma_ ## ecma_type ## _t))); \ + \ + if ( likely( p ## ecma_type != NULL ) ) \ + { \ + return p ## ecma_type; \ + } \ } \ - \ JERRY_UNREACHABLE(); \ } diff --git a/src/libecmaobjects/ecma-gc.c b/src/libecmaobjects/ecma-gc.c index 580ab9802..6bfca5358 100644 --- a/src/libecmaobjects/ecma-gc.c +++ b/src/libecmaobjects/ecma-gc.c @@ -323,8 +323,6 @@ ecma_gc_run( ecma_gc_gen_t max_gen_to_collect) /**< maximum generation to run co { JERRY_ASSERT( max_gen_to_collect < ECMA_GC_GEN_COUNT ); - bool was_something_sweeped = false; - /* clearing visited flags for all objects of generations to be processed */ for ( ecma_gc_gen_t gen_id = 0; gen_id <= max_gen_to_collect; gen_id++ ) { @@ -386,8 +384,6 @@ ecma_gc_run( ecma_gc_gen_t max_gen_to_collect) /**< maximum generation to run co if ( !obj_iter_p->gc_info.visited ) { - was_something_sweeped = true; - ecma_gc_sweep( obj_iter_p); if ( likely( obj_prev_p != NULL ) ) @@ -450,12 +446,6 @@ ecma_gc_run( ecma_gc_gen_t max_gen_to_collect) /**< maximum generation to run co } } #endif /* !JERRY_NDEBUG */ - - if ( !was_something_sweeped - && max_gen_to_collect != ECMA_GC_GEN_COUNT - 1 ) - { - ecma_gc_run( max_gen_to_collect + 1); - } } /* ecma_gc_run */ /**