mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
codegen.c: chunk array literals at 64 elements to reduce register pressure
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 mruby/mruby#6731 Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -3821,7 +3821,7 @@ codegen_array(codegen_scope *s, node *varnode, int val)
|
||||
node *elements = array->elements;
|
||||
int regular_elements = 0;
|
||||
int first = 1;
|
||||
int slimit = GEN_VAL_STACK_MAX;
|
||||
int slimit = GEN_LIT_ARY_MAX;
|
||||
|
||||
if (!val) return;
|
||||
|
||||
@@ -3831,7 +3831,7 @@ codegen_array(codegen_scope *s, node *varnode, int val)
|
||||
return;
|
||||
}
|
||||
|
||||
if (cursp() >= GEN_LIT_ARY_MAX) slimit = INT16_MAX;
|
||||
if (cursp() >= slimit) slimit = GEN_VAL_STACK_MAX;
|
||||
|
||||
/* Process each element using cons-list iteration, handling splats */
|
||||
node *current = elements;
|
||||
|
||||
Reference in New Issue
Block a user