Skip to content

Fix GH-9967 Add support for generating custom function, class const, and property attributes in stubs #10170

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 3 commits into from

Conversation

kocsismate
Copy link
Member

No description provided.

Copy link
Member

@TimWolla TimWolla left a comment

Choose a reason for hiding this comment

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

Changes to the stub generator LGTM as far as I can tell. Ideally also add an actual test to zend_test to verify the attribute is applied properly.

@TimWolla TimWolla self-requested a review December 29, 2022 18:28
Copy link
Member

@TimWolla TimWolla left a comment

Choose a reason for hiding this comment

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

LGTM now, thanks!

@kocsismate
Copy link
Member Author

I've just realized that we could add support for generating attributes for class constants and properties as well... So I also implemented this feature.

P.S. Another thing I noticed is that gen_stub.php cannot generate multiple attributes for the same symbol, otherwise there is a variable name collision in the generated code. I'll fix this in a followup PR.

} else {
$template = "\tzend_declare_property_ex(class_entry, $nameCode, &$zvalName, %s, NULL);\n";
Copy link
Member Author

@kocsismate kocsismate Dec 30, 2022

Choose a reason for hiding this comment

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

It was necessary to change to zend_declare_typed_property, because unfortunately zend_declare_property_ex doesn't return the zend_property_info.

if (!$php82MinimumCompatibility) {
$code .= "#if (PHP_VERSION_ID >= " . PHP_82_VERSION_ID . ")\n";
$code .= "#if (PHP_VERSION_ID >= " . PHP_82_VERSION_ID . ")";
Copy link
Member Author

Choose a reason for hiding this comment

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

this endline character was superfluous

@kocsismate
Copy link
Member Author

P.S. Another thing I noticed is that gen_stub.php cannot generate multiple attributes for the same symbol, otherwise there is a variable name collision in the generated code. I'll fix this in a followup PR.

Sorry, it was a false alarm. :)

@kocsismate kocsismate changed the title Fix GH-9967 Add support for generating custom function attributes in stubs Fix GH-9967 Add support for generating custom function, class const, and property attributes in stubs Dec 31, 2022
@kocsismate
Copy link
Member Author

P.S. Another thing I noticed is that gen_stub.php cannot generate multiple attributes for the same symbol, otherwise there is a variable name collision in the generated code. I'll fix this in a followup PR.

Sorry, it was a false alarm. :)

Update: No, it's not when an attribute is repeatable.

@kocsismate
Copy link
Member Author

It seems to me that the new attributes cause some issues in the JIT engine :/

@kocsismate
Copy link
Member Author

Sorry, I rebased to the wrong branch (master instead of PHP-8.2) after a conflict resolution. :/ So I had to squash my previous commits into one and cherry-pick it to PHP-8.2

Copy link
Member

@TimWolla TimWolla left a comment

Choose a reason for hiding this comment

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

I don't have any further remarks.

@kocsismate kocsismate force-pushed the stub-func-attributes branch from d11c94a to bac8040 Compare June 8, 2023 18:32
@kocsismate kocsismate force-pushed the stub-func-attributes branch 5 times, most recently from b2a274f to ff0f695 Compare July 2, 2023 12:03
@kocsismate kocsismate force-pushed the stub-func-attributes branch from ff0f695 to 2abe28b Compare July 2, 2023 19:58
@kocsismate kocsismate closed this in 45a3f17 Jul 3, 2023
@kocsismate kocsismate deleted the stub-func-attributes branch July 3, 2023 09:17
@iluuu1994
Copy link
Member

Unfortunately, as mentioned in the commit comments this caused multiple issues.

  1. It broke compilation of C++ files including arginfo.h files.
  2. It reported a leak that turned out to be harmless.
  3. It broke the ASAN build.

I was able to fix 1 and 2 in this PR. However, I was unable to reproduce the ASAN failure locally and as such could not fix it.

Since Máté is absent atm I reverted the changes for now. Please re-apply the changes to master and check if the build passes once you're back. 🙂

@iluuu1994
Copy link
Member

iluuu1994 commented Jul 4, 2023

Turns out the ASAN error was caused by 9f4bd30 which I also reverted for now. I will try to find the cause tomorrow.

@iluuu1994
Copy link
Member

@kocsismate Reminder: This commit was never re-applied. #11582 contained fixed that should work now, I'd prefer only applying this to master though.

@kocsismate
Copy link
Member Author

@iluuu1994 Thanks for the reminder! I was aware, but was busy with other stuff, and I didn't really know whether there was really an ASAN failure (or just due to 9f4bd30). Could you please re-add your fix? And then I'll reapply my changes in master.

@iluuu1994
Copy link
Member

@kocsismate No worries, I might have a clue why you were buy 😉👶 The ASAN failure was just caused by 9f4bd30 but tbh I completely forgot what I did to fix it. It's best if you apply my fixed in #11582 on top of your changes here in a new PR, so that they can be tested together.

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

Successfully merging this pull request may close these issues.

3 participants