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

ruby-changes:69048

From: John <ko1@a...>
Date: Thu, 21 Oct 2021 08:20:39 +0900 (JST)
Subject: [ruby-changes:69048] 6d852e847e (master): Fix stack size check for ctx_get_opnd_type

https://git.ruby-lang.org/ruby.git/commit/?id=6d852e847e

From 6d852e847e163fad0f2ccebe59c57d6921d3c472 Mon Sep 17 00:00:00 2001
From: John Hawthorn <john@h...>
Date: Mon, 9 Aug 2021 02:11:05 -0700
Subject: Fix stack size check for ctx_get_opnd_type

Previously all stack operands would become unknown once the stack grew
beyond a certain size. This worked, but unnecessarily hid available
information.
---
 yjit_core.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/yjit_core.c b/yjit_core.c
index a08be3cc74..3f866b0a2b 100644
--- a/yjit_core.c
+++ b/yjit_core.c
@@ -135,11 +135,14 @@ ctx_get_opnd_type(const ctx_t* ctx, insn_opnd_t opnd) https://github.com/ruby/ruby/blob/trunk/yjit_core.c#L135
     if (opnd.is_self)
         return ctx->self_type;
 
-    if (ctx->stack_size >= MAX_TEMP_TYPES)
+    RUBY_ASSERT(opnd.idx < ctx->stack_size);
+    int stack_idx = ctx->stack_size - 1 - opnd.idx;
+
+    // If outside of tracked range, do nothing
+    if (stack_idx >= MAX_TEMP_TYPES)
         return TYPE_UNKNOWN;
 
-    RUBY_ASSERT(opnd.idx < ctx->stack_size);
-    temp_mapping_t mapping = ctx->temp_mapping[ctx->stack_size - 1 - opnd.idx];
+    temp_mapping_t mapping = ctx->temp_mapping[stack_idx];
 
     switch (mapping.kind)
     {
-- 
cgit v1.2.1


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

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