[前][次][番号順一覧][スレッド一覧]

ruby-changes:68780

From: Alan <ko1@a...>
Date: Thu, 21 Oct 2021 08:13:32 +0900 (JST)
Subject: [ruby-changes:68780] 0658ab73ee (master): Use rb_darray_make in ujit

https://git.ruby-lang.org/ruby.git/commit/?id=0658ab73ee

From 0658ab73eed9bb5b0a867424492a51120c83de41 Mon Sep 17 00:00:00 2001
From: Alan Wu <XrXr@u...>
Date: Tue, 16 Feb 2021 21:03:20 -0500
Subject: Use rb_darray_make in ujit

---
 ujit_core.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/ujit_core.c b/ujit_core.c
index 4f20477c50..1729011641 100644
--- a/ujit_core.c
+++ b/ujit_core.c
@@ -167,9 +167,12 @@ add_block_version(blockid_t blockid, block_t* block) https://github.com/ruby/ruby/blob/trunk/ujit_core.c#L167
     // Ensure ujit_blocks is initialized for this iseq
     if (rb_darray_size(body->ujit_blocks) == 0) {
         // Initialize ujit_blocks to be as wide as body->iseq_encoded
-        // TODO: add resize API for dary
-        while ((unsigned)rb_darray_size(body->ujit_blocks) < body->iseq_size) {
-            (void)rb_darray_append(&body->ujit_blocks, NULL);
+        int32_t casted = (int32_t)body->iseq_size;
+        if ((unsigned)casted != body->iseq_size) {
+            rb_bug("iseq too large");
+        }
+        if (!rb_darray_make(&body->ujit_blocks, casted)) {
+            rb_bug("allocation failed");
         }
 
         // First block compiled for this iseq
-- 
cgit v1.2.1


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]