@@ -38,7 +38,6 @@ typedef struct _zend_closure {
38
38
zend_object std ;
39
39
zend_function func ;
40
40
zval this_ptr ;
41
- HashTable * debug_info ;
42
41
} zend_closure ;
43
42
44
43
/* non-static since it needs to be referenced */
@@ -269,11 +268,6 @@ static void zend_closure_free_storage(zend_object *object) /* {{{ */
269
268
destroy_op_array (& closure -> func .op_array );
270
269
}
271
270
272
- if (closure -> debug_info != NULL ) {
273
- zend_hash_destroy (closure -> debug_info );
274
- efree (closure -> debug_info );
275
- }
276
-
277
271
if (Z_TYPE (closure -> this_ptr ) != IS_UNDEF ) {
278
272
zval_ptr_dtor (& closure -> this_ptr );
279
273
}
@@ -335,71 +329,63 @@ static HashTable *zend_closure_get_debug_info(zval *object, int *is_temp) /* {{{
335
329
zend_closure * closure = (zend_closure * )Z_OBJ_P (object );
336
330
zval val ;
337
331
struct _zend_arg_info * arg_info = closure -> func .common .arg_info ;
332
+ HashTable * debug_info ;
333
+
334
+ * is_temp = 1 ;
338
335
339
- * is_temp = 0 ;
336
+ ALLOC_HASHTABLE (debug_info );
337
+ zend_hash_init (debug_info , 8 , NULL , ZVAL_PTR_DTOR , 0 );
340
338
341
- if (closure -> debug_info == NULL ) {
342
- ALLOC_HASHTABLE (closure -> debug_info );
343
- zend_hash_init (closure -> debug_info , 8 , NULL , ZVAL_PTR_DTOR , 0 );
339
+ if (closure -> func .type == ZEND_USER_FUNCTION && closure -> func .op_array .static_variables ) {
340
+ HashTable * static_variables = closure -> func .op_array .static_variables ;
341
+ ZVAL_ARR (& val , zend_array_dup (static_variables ));
342
+ zend_hash_str_update (debug_info , "static" , sizeof ("static" )- 1 , & val );
344
343
}
345
- if (closure -> debug_info -> u .v .nApplyCount == 0 ) {
346
- if (closure -> func .type == ZEND_USER_FUNCTION && closure -> func .op_array .static_variables ) {
347
- HashTable * static_variables = closure -> func .op_array .static_variables ;
348
- ZVAL_ARR (& val , zend_array_dup (static_variables ));
349
- zend_hash_str_update (closure -> debug_info , "static" , sizeof ("static" )- 1 , & val );
350
- }
351
344
352
- if (Z_TYPE (closure -> this_ptr ) != IS_UNDEF ) {
353
- Z_ADDREF (closure -> this_ptr );
354
- zend_hash_str_update (closure -> debug_info , "this" , sizeof ("this" )- 1 , & closure -> this_ptr );
355
- }
345
+ if (Z_TYPE (closure -> this_ptr ) != IS_UNDEF ) {
346
+ Z_ADDREF (closure -> this_ptr );
347
+ zend_hash_str_update (debug_info , "this" , sizeof ("this" )- 1 , & closure -> this_ptr );
348
+ }
356
349
357
- if (arg_info &&
358
- (closure -> func .common .num_args ||
359
- (closure -> func .common .fn_flags & ZEND_ACC_VARIADIC ))) {
360
- uint32_t i , num_args , required = closure -> func .common .required_num_args ;
350
+ if (arg_info &&
351
+ (closure -> func .common .num_args ||
352
+ (closure -> func .common .fn_flags & ZEND_ACC_VARIADIC ))) {
353
+ uint32_t i , num_args , required = closure -> func .common .required_num_args ;
361
354
362
- array_init (& val );
355
+ array_init (& val );
363
356
364
- num_args = closure -> func .common .num_args ;
365
- if (closure -> func .common .fn_flags & ZEND_ACC_VARIADIC ) {
366
- num_args ++ ;
367
- }
368
- for (i = 0 ; i < num_args ; i ++ ) {
369
- zend_string * name ;
370
- zval info ;
371
- if (arg_info -> name ) {
372
- name = zend_strpprintf (0 , "%s$%s" ,
373
- arg_info -> pass_by_reference ? "&" : "" ,
374
- arg_info -> name -> val );
375
- } else {
376
- name = zend_strpprintf (0 , "%s$param%d" ,
377
- arg_info -> pass_by_reference ? "&" : "" ,
378
- i + 1 );
379
- }
380
- ZVAL_NEW_STR (& info , zend_strpprintf (0 , "%s" , i >= required ? "<optional>" : "<required>" ));
381
- zend_hash_update (Z_ARRVAL (val ), name , & info );
382
- zend_string_release (name );
383
- arg_info ++ ;
357
+ num_args = closure -> func .common .num_args ;
358
+ if (closure -> func .common .fn_flags & ZEND_ACC_VARIADIC ) {
359
+ num_args ++ ;
360
+ }
361
+ for (i = 0 ; i < num_args ; i ++ ) {
362
+ zend_string * name ;
363
+ zval info ;
364
+ if (arg_info -> name ) {
365
+ name = zend_strpprintf (0 , "%s$%s" ,
366
+ arg_info -> pass_by_reference ? "&" : "" ,
367
+ arg_info -> name -> val );
368
+ } else {
369
+ name = zend_strpprintf (0 , "%s$param%d" ,
370
+ arg_info -> pass_by_reference ? "&" : "" ,
371
+ i + 1 );
384
372
}
385
- zend_hash_str_update (closure -> debug_info , "parameter" , sizeof ("parameter" )- 1 , & val );
373
+ ZVAL_NEW_STR (& info , zend_strpprintf (0 , "%s" , i >= required ? "<optional>" : "<required>" ));
374
+ zend_hash_update (Z_ARRVAL (val ), name , & info );
375
+ zend_string_release (name );
376
+ arg_info ++ ;
386
377
}
378
+ zend_hash_str_update (debug_info , "parameter" , sizeof ("parameter" )- 1 , & val );
387
379
}
388
380
389
- return closure -> debug_info ;
381
+ return debug_info ;
390
382
}
391
383
/* }}} */
392
384
393
385
static HashTable * zend_closure_get_gc (zval * obj , zval * * table , int * n ) /* {{{ */
394
386
{
395
387
zend_closure * closure = (zend_closure * )Z_OBJ_P (obj );
396
388
397
- if (closure -> debug_info != NULL ) {
398
- zend_hash_destroy (closure -> debug_info );
399
- efree (closure -> debug_info );
400
- closure -> debug_info = NULL ;
401
- }
402
-
403
389
* table = Z_TYPE (closure -> this_ptr ) != IS_NULL ? & closure -> this_ptr : NULL ;
404
390
* n = Z_TYPE (closure -> this_ptr ) != IS_NULL ? 1 : 0 ;
405
391
return (closure -> func .type == ZEND_USER_FUNCTION ) ?
0 commit comments