codegen.c: chunk array literals at 64 elements to reduce register pressure#6734
codegen.c: chunk array literals at 64 elements to reduce register pressure#6734
Conversation
…ssure Array literals were being built by loading all elements into registers before constructing the array, requiring nregs proportional to the array size (e.g. nregs=99 for 100 elements). This exceeds mruby/c's register limit. Restore 3.4-era chunking at GEN_LIT_ARY_MAX (64) elements. fixes #6731 Co-authored-by: Claude <noreply@anthropic.com>
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request optimizes the code generation process for array literals by re-implementing a chunking strategy. This modification ensures that large array literals do not consume an excessive number of registers, thereby improving performance and compatibility, particularly for systems with constrained register resources. The core change involves adjusting the limits and logic used during the compilation of array elements. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request addresses an issue with excessive register usage for large array literals by reintroducing chunking. The change restores behavior from an older version, capping the number of registers used and fixing compatibility with platforms like mruby/c. The logic appears sound and correctly implements the intended fix. I have one minor suggestion to improve code clarity.
| } | ||
|
|
||
| if (cursp() >= GEN_LIT_ARY_MAX) slimit = INT16_MAX; | ||
| if (cursp() >= slimit) slimit = GEN_VAL_STACK_MAX; |
There was a problem hiding this comment.
Summary
GEN_LIT_ARY_MAX(64 elements), cappingnregsat 64 for any-size array literalfixes #6731
Co-authored-by: Claude noreply@anthropic.com