From 1a180b7e18a2d415282df637e27a446c71246ef7 Mon Sep 17 00:00:00 2001 From: Jemma Issroff Date: Tue, 25 Jan 2022 16:04:17 -0500 Subject: Streamline cached attr reader / writer indexes This commit removes the need to increment and decrement the indexes used by vm_cc_attr_index getters and setters. It also introduces a vm_cc_attr_index_p predicate function, and a vm_cc_attr_index_initalize function. --- vm_callinfo.h | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'vm_callinfo.h') diff --git a/vm_callinfo.h b/vm_callinfo.h index 09f755c818..3d41e039c9 100644 --- a/vm_callinfo.h +++ b/vm_callinfo.h @@ -353,7 +353,14 @@ static inline unsigned int vm_cc_attr_index(const struct rb_callcache *cc) { VM_ASSERT(IMEMO_TYPE_P(cc, imemo_callcache)); - return cc->aux_.attr_index; + return cc->aux_.attr_index - 1; +} + +static inline bool +vm_cc_attr_index_p(const struct rb_callcache *cc) +{ + VM_ASSERT(IMEMO_TYPE_P(cc, imemo_callcache)); + return cc->aux_.attr_index > 0; } static inline unsigned int @@ -406,7 +413,15 @@ vm_cc_attr_index_set(const struct rb_callcache *cc, int index) { VM_ASSERT(IMEMO_TYPE_P(cc, imemo_callcache)); VM_ASSERT(cc != vm_cc_empty()); - *(int *)&cc->aux_.attr_index = index; + *(int *)&cc->aux_.attr_index = index + 1; +} + +static inline void +vm_cc_attr_index_initialize(const struct rb_callcache *cc) +{ + VM_ASSERT(IMEMO_TYPE_P(cc, imemo_callcache)); + VM_ASSERT(cc != vm_cc_empty()); + *(int *)&cc->aux_.attr_index = 0; } static inline void -- cgit v1.2.3