ruby-changes:56603
From: Yusuke <ko1@a...>
Date: Sat, 20 Jul 2019 09:11:38 +0900 (JST)
Subject: [ruby-changes:56603] Yusuke Endoh: 77bb79b8cf (master): array.c: factor out a complex condition of assert
https://git.ruby-lang.org/ruby.git/commit/?id=77bb79b8cf From 77bb79b8cf69f6504bf0abe2e07a1a631cc4ef32 Mon Sep 17 00:00:00 2001 From: Yusuke Endoh <mame@r...> Date: Sat, 20 Jul 2019 09:08:34 +0900 Subject: array.c: factor out a complex condition of assert ARY_SHARED_P and ARY_EMBED_P included: assert(!FL_TEST((ary), ELTS_SHARED) || !FL_TEST((ary), RARRAY_EMBED_FLAG)), The two predicate macros are used in many other assert conditions, which caused memory bloat during C compilation. This change factors out the assertion above to a function. Now gcc consumes 160 MB instead of 250 MB to compile array.c. diff --git a/array.c b/array.c index 0c5ea0a..7989ade 100644 --- a/array.c +++ b/array.c @@ -40,14 +40,20 @@ should_be_T_ARRAY(VALUE ary) https://github.com/ruby/ruby/blob/trunk/array.c#L40 return RB_TYPE_P(ary, T_ARRAY); } +static int +should_not_be_shared_and_embedded(VALUE ary) +{ + return !FL_TEST((ary), ELTS_SHARED) || !FL_TEST((ary), RARRAY_EMBED_FLAG); +} + #define ARY_SHARED_P(ary) \ (assert(should_be_T_ARRAY((VALUE)(ary))), \ - assert(!FL_TEST((ary), ELTS_SHARED) || !FL_TEST((ary), RARRAY_EMBED_FLAG)), \ + assert(should_not_be_shared_and_embedded((VALUE)ary)), \ FL_TEST_RAW((ary),ELTS_SHARED)!=0) #define ARY_EMBED_P(ary) \ (assert(should_be_T_ARRAY((VALUE)(ary))), \ - assert(!FL_TEST((ary), ELTS_SHARED) || !FL_TEST((ary), RARRAY_EMBED_FLAG)), \ + assert(should_not_be_shared_and_embedded((VALUE)ary)), \ FL_TEST_RAW((ary), RARRAY_EMBED_FLAG) != 0) #define ARY_HEAP_PTR(a) (assert(!ARY_EMBED_P(a)), RARRAY(a)->as.heap.ptr) -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/