1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Use rb_darray_make in ujit

This commit is contained in:
Alan Wu 2021-02-16 21:03:20 -05:00
parent 2240932b64
commit 0658ab73ee

View file

@ -167,9 +167,12 @@ add_block_version(blockid_t blockid, block_t* block)
// Ensure ujit_blocks is initialized for this iseq // Ensure ujit_blocks is initialized for this iseq
if (rb_darray_size(body->ujit_blocks) == 0) { if (rb_darray_size(body->ujit_blocks) == 0) {
// Initialize ujit_blocks to be as wide as body->iseq_encoded // Initialize ujit_blocks to be as wide as body->iseq_encoded
// TODO: add resize API for dary int32_t casted = (int32_t)body->iseq_size;
while ((unsigned)rb_darray_size(body->ujit_blocks) < body->iseq_size) { if ((unsigned)casted != body->iseq_size) {
(void)rb_darray_append(&body->ujit_blocks, NULL); rb_bug("iseq too large");
}
if (!rb_darray_make(&body->ujit_blocks, casted)) {
rb_bug("allocation failed");
} }
// First block compiled for this iseq // First block compiled for this iseq