aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mjit_compile.c25
1 files changed, 10 insertions, 15 deletions
diff --git a/mjit_compile.c b/mjit_compile.c
index a62eb17238..39609cdf90 100644
--- a/mjit_compile.c
+++ b/mjit_compile.c
@@ -203,24 +203,19 @@ bool
mjit_compile(FILE *f, const rb_iseq_t *iseq, const char *funcname)
{
const struct rb_iseq_constant_body *body = iseq->body;
-
- struct compile_status status;
- status.success = true;
- status.local_stack_p = !body->catch_except_p;
- status.stack_size_for_pos = (int *)alloca(sizeof(int) * body->iseq_size);
+ struct compile_status status = {
+ .success = true,
+ .local_stack_p = !body->catch_except_p,
+ .stack_size_for_pos = (int *)alloca(sizeof(int) * body->iseq_size),
+ .cc_entries = (body->ci_size + body->ci_kw_size) > 0 ?
+ alloca(sizeof(struct rb_call_cache) * (body->ci_size + body->ci_kw_size)) : NULL,
+ .is_entries = (body->is_size > 0) ?
+ alloca(sizeof(union iseq_inline_storage_entry) * body->is_size) : NULL,
+ };
memset(status.stack_size_for_pos, NOT_COMPILED_STACK_SIZE, sizeof(int) * body->iseq_size);
-
- status.cc_entries = NULL;
- if ((body->ci_size + body->ci_kw_size) > 0)
- status.cc_entries = alloca(sizeof(struct rb_call_cache) * (body->ci_size + body->ci_kw_size));
- status.is_entries = NULL;
- if (body->is_size > 0)
- status.is_entries = alloca(sizeof(union iseq_inline_storage_entry) * body->is_size);
-
if ((status.cc_entries != NULL || status.is_entries != NULL)
- && !mjit_copy_cache_from_main_thread(iseq, status.cc_entries, status.is_entries)) {
+ && !mjit_copy_cache_from_main_thread(iseq, status.cc_entries, status.is_entries))
return false;
- }
/* For performance, we verify stack size only on compilation time (mjit_compile.inc.erb) without --jit-debug */
if (!mjit_opts.debug) {