Skip to content

Better c zend api #6002

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 65 commits into from
Closed

Better c zend api #6002

wants to merge 65 commits into from

Conversation

Girgias
Copy link
Member

@Girgias Girgias commented Aug 17, 2020

This is an attempt to make the API of the Zend engine easier to use.

Functions which only return SUCCESS and don't need to return such a value due to other engine API are changed to void

Functions which return the values SUCCESS or FAILURE exclusively are changed to return the corresponding enum ZEND_RESULT_CODE as they have boolean semantics but cannot use the native bool type and the return value needs to be compared to SUCCESS/FAILURE

Functions returning/accepting a boolean value are clearly marked so.

I'm aware of the JIT failure, but I would like to know the opinions of others on this change before I pursue fixing them.

@Girgias Girgias force-pushed the better-c-zend-api branch 7 times, most recently from 39d64b2 to 989d9ce Compare August 21, 2020 22:50
@nikic
Copy link
Member

nikic commented Aug 24, 2020

I don't like the ZEND_RESULT_CODE name, type name should not be uppercase... At the least this should be zend_result_code, but maybe zend_result is better, as this is heavily used.

@Girgias
Copy link
Member Author

Girgias commented Aug 24, 2020

I don't like the ZEND_RESULT_CODE name, type name should not be uppercase... At the least this should be zend_result_code, but maybe zend_result is better, as this is heavily used.

Should I typedef ZEND_RESULT_CODE to zend_result and use that?

@Girgias Girgias force-pushed the better-c-zend-api branch 3 times, most recently from da4eb7d to 021babd Compare August 24, 2020 14:34
Copy link
Member

@nikic nikic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From a quick scroll through, this looks reasonable to me.

@@ -1,4 +1,4 @@
/*
/*
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spurious change.

@Girgias Girgias force-pushed the better-c-zend-api branch from eae2061 to fccf5f8 Compare August 25, 2020 14:37
@Girgias
Copy link
Member Author

Girgias commented Aug 25, 2020

@nikic do you have any idea what I would need to do/change in the JIT at line 7930 of zend_jit_x86.dasc ( | EXT_CALL zend_is_true, r0 such that I can change the signature of zend_is_true() from into to bool, as it segfaults currently and I don't exactly see how I can fix the JIT in this regards.
This could also be left to a follow-up PR.

@testAccountDeltas
Copy link

BUG in _str_dtor

https://github.com/php/php-src/blob/master/Zend/zend_string.c#L72

Critical error in zend_hash_destroy function on pointer deallocation

pefree(HT_GET_DATA_ADDR(ht), GC_FLAGS(ht) & IS_ARRAY_PERSISTENT);

When closing the application from

zend_interned_strings_deactivate();

Fix that fixes the error when closing
zend_hash_init(interned_strings, 1024, NULL, NULL, permanent);

Assign emptiness (NULL)

@testAccountDeltas
Copy link

BUG FIX!!!! , 1

ZEND_API void zend_interned_strings_activate(void){
zend_init_interned_strings_ht(&CG(interned_strings), 1);
}

@Girgias
Copy link
Member Author

Girgias commented Oct 31, 2020

Please open a new PR and or a bug ticket

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants