@@ -37,6 +37,9 @@ void php_v8_heap_statistics_create_from_heap_statistics(zval *return_value, v8::
37
37
zend_update_property_double (this_ce, return_value, ZEND_STRL (" peak_malloced_memory" ), hs->peak_malloced_memory ());
38
38
39
39
zend_update_property_bool (this_ce, return_value, ZEND_STRL (" does_zap_garbage" ), static_cast <zend_long>(hs->does_zap_garbage ()));
40
+
41
+ zend_update_property_double (this_ce, return_value, ZEND_STRL (" number_of_native_contexts" ), hs->number_of_native_contexts ());
42
+ zend_update_property_double (this_ce, return_value, ZEND_STRL (" number_of_detached_contexts" ), hs->number_of_detached_contexts ());
40
43
}
41
44
42
45
static PHP_METHOD (HeapStatistics, __construct) {
@@ -51,10 +54,14 @@ static PHP_METHOD(HeapStatistics, __construct) {
51
54
52
55
zend_bool does_zap_garbage = ' 0円 ' ;
53
56
54
- if (zend_parse_parameters (ZEND_NUM_ARGS (), " |" " dddd" " dddd" " b" ,
57
+ double number_of_native_contexts = 0 ;
58
+ double number_of_detached_contexts = 0 ;
59
+
60
+ if (zend_parse_parameters (ZEND_NUM_ARGS (), " |" " dddd" " dddd" " b" " dd" ,
55
61
&total_heap_size, &total_heap_size_executable, &total_physical_size, &total_available_size,
56
62
&used_heap_size, &heap_size_limit, &malloced_memory, &peak_malloced_memory,
57
- &does_zap_garbage) == FAILURE) {
63
+ &does_zap_garbage,
64
+ &number_of_native_contexts, &number_of_detached_contexts) == FAILURE) {
58
65
return ;
59
66
}
60
67
@@ -68,6 +75,9 @@ static PHP_METHOD(HeapStatistics, __construct) {
68
75
zend_update_property_double (this_ce, getThis (), ZEND_STRL (" peak_malloced_memory" ), peak_malloced_memory);
69
76
70
77
zend_update_property_bool (this_ce, getThis (), ZEND_STRL (" does_zap_garbage" ), does_zap_garbage);
78
+
79
+ zend_update_property_double (this_ce, getThis (), ZEND_STRL (" number_of_native_contexts" ), number_of_native_contexts);
80
+ zend_update_property_double (this_ce, getThis (), ZEND_STRL (" number_of_detached_contexts" ), number_of_detached_contexts);
71
81
}
72
82
73
83
static PHP_METHOD (HeapStatistics, getTotalHeapSize) {
@@ -160,6 +170,26 @@ static PHP_METHOD(HeapStatistics, doesZapGarbage) {
160
170
RETVAL_ZVAL (zend_read_property (this_ce, getThis (), ZEND_STRL (" does_zap_garbage" ), 0 , &rv), 1 , 0 );
161
171
}
162
172
173
+ static PHP_METHOD (HeapStatistics, getNumberOfNativeContexts) {
174
+ zval rv;
175
+
176
+ if (zend_parse_parameters_none () == FAILURE) {
177
+ return ;
178
+ }
179
+
180
+ RETVAL_ZVAL (zend_read_property (this_ce, getThis (), ZEND_STRL (" number_of_native_contexts" ), 0 , &rv), 1 , 0 );
181
+ }
182
+
183
+ static PHP_METHOD (HeapStatistics, getNumberOfDetachedContexts) {
184
+ zval rv;
185
+
186
+ if (zend_parse_parameters_none () == FAILURE) {
187
+ return ;
188
+ }
189
+
190
+ RETVAL_ZVAL (zend_read_property (this_ce, getThis (), ZEND_STRL (" number_of_detached_contexts" ), 0 , &rv), 1 , 0 );
191
+ }
192
+
163
193
164
194
PHP_V8_ZEND_BEGIN_ARG_WITH_CONSTRUCTOR_INFO_EX (arginfo___construct, 0 )
165
195
ZEND_ARG_TYPE_INFO(0 , total_heap_size, IS_DOUBLE, 0 )
@@ -202,6 +232,12 @@ ZEND_END_ARG_INFO()
202
232
PHP_V8_ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_doesZapGarbage, ZEND_RETURN_VALUE, 0 , _IS_BOOL, 0 )
203
233
ZEND_END_ARG_INFO()
204
234
235
+ PHP_V8_ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_getNumberOfNativeContexts, ZEND_RETURN_VALUE, 0 , IS_DOUBLE, 0 )
236
+ ZEND_END_ARG_INFO()
237
+
238
+ PHP_V8_ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_getNumberOfDetachedContexts, ZEND_RETURN_VALUE, 0 , IS_DOUBLE, 0 )
239
+ ZEND_END_ARG_INFO()
240
+
205
241
206
242
static const zend_function_entry php_v8_heap_statistics_methods[] = {
207
243
PHP_V8_ME (HeapStatistics, __construct, ZEND_ACC_PUBLIC | ZEND_ACC_CTOR)
@@ -215,6 +251,8 @@ static const zend_function_entry php_v8_heap_statistics_methods[] = {
215
251
PHP_V8_ME (HeapStatistics, getMallocedMemory, ZEND_ACC_PUBLIC)
216
252
PHP_V8_ME (HeapStatistics, getPeakMallocedMemory, ZEND_ACC_PUBLIC)
217
253
PHP_V8_ME (HeapStatistics, doesZapGarbage, ZEND_ACC_PUBLIC)
254
+ PHP_V8_ME (HeapStatistics, getNumberOfNativeContexts, ZEND_ACC_PUBLIC)
255
+ PHP_V8_ME (HeapStatistics, getNumberOfDetachedContexts, ZEND_ACC_PUBLIC)
218
256
219
257
PHP_FE_END
220
258
};
@@ -236,5 +274,8 @@ PHP_MINIT_FUNCTION (php_v8_heap_statistics) {
236
274
237
275
zend_declare_property_bool (this_ce, ZEND_STRL (" does_zap_garbage" ), false , ZEND_ACC_PRIVATE);
238
276
277
+ zend_declare_property_double (this_ce, ZEND_STRL (" number_of_native_contexts" ), 0 , ZEND_ACC_PRIVATE);
278
+ zend_declare_property_double (this_ce, ZEND_STRL (" number_of_detached_contexts" ), 0 , ZEND_ACC_PRIVATE);
279
+
239
280
return SUCCESS;
240
281
}
0 commit comments