From 00a64c9271322e78a9e1c490b5ea3434d840b1e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Lindqvist?= Date: Mon, 30 May 2016 04:57:14 +0200 Subject: [PATCH] VM: name change no_non_safepoint_words_p -> stack_frame_p It returns true if the quotation should be wrapped in a stack frame. --- vm/quotations.cpp | 29 +++++++++++++---------------- vm/quotations.hpp | 3 +-- 2 files changed, 14 insertions(+), 18 deletions(-) diff --git a/vm/quotations.cpp b/vm/quotations.cpp index 09919adb11..36fa01fbd3 100644 --- a/vm/quotations.cpp +++ b/vm/quotations.cpp @@ -84,24 +84,21 @@ bool quotation_jit::mega_lookup_p(cell i, cell length) { array_nth(elements.untagged(), i + 3) == parent->special_objects[MEGA_LOOKUP_WORD]; } +/* Subprimitives should be flagged with whether they require a stack frame. + See #295. */ bool quotation_jit::special_subprimitive_p(cell obj) { - // Subprimitives should be flagged with whether they require a stack frame. - // See #295. return obj == parent->special_objects[SIGNAL_HANDLER_WORD] || obj == parent->special_objects[LEAF_SIGNAL_HANDLER_WORD] || obj == parent->special_objects[UNWIND_NATIVE_FRAMES_WORD]; } -bool quotation_jit::word_safepoint_p(cell obj) { - return !special_subprimitive_p(obj); -} - -/* true if there are no non-safepoint words in the quoation... */ -bool quotation_jit::no_non_safepoint_words_p() { +/* All quotations wants a stack frame, except those that contain calls + to the special subprimitives. See #295. */ +bool quotation_jit::stack_frame_p() { cell length = array_capacity(elements.untagged()); for (cell i = 0; i < length; i++) { cell obj = array_nth(elements.untagged(), i); - if (TAG(obj) == WORD_TYPE && !word_safepoint_p(obj)) + if (TAG(obj) == WORD_TYPE && special_subprimitive_p(obj)) return false; } return true; @@ -139,11 +136,11 @@ void quotation_jit::emit_quotation(cell quot_) { /* Allocates memory (parameter(), literal(), emit_epilog, emit_with_literal)*/ void quotation_jit::iterate_quotation() { - bool no_non_safepoint_words = no_non_safepoint_words_p(); + bool stack_frame = stack_frame_p(); set_position(0); - if (no_non_safepoint_words) { + if (stack_frame) { emit(parent->special_objects[JIT_SAFEPOINT]); emit(parent->special_objects[JIT_PROLOG]); } @@ -162,10 +159,10 @@ void quotation_jit::iterate_quotation() { if (to_boolean(obj.as()->subprimitive)) { tail_call = emit_subprimitive(obj.value(), /* word */ i == length - 1, /* tail_call_p */ - no_non_safepoint_words); /* stack_frame_p */ + stack_frame); /* stack_frame_p */ } /* Everything else */ else if (i == length - 1) { - emit_epilog(no_non_safepoint_words); + emit_epilog(stack_frame); tail_call = true; word_jump(obj.value()); } else @@ -199,7 +196,7 @@ void quotation_jit::iterate_quotation() { /* 'if' preceded by two literal quotations (this is why if and ? are mutually recursive in the library, but both still work) */ if (fast_if_p(i, length)) { - emit_epilog(no_non_safepoint_words); + emit_epilog(stack_frame); tail_call = true; emit_quotation(array_nth(elements.untagged(), i)); @@ -232,7 +229,7 @@ void quotation_jit::iterate_quotation() { /* Load the object from the datastack, then remove our stack frame. */ emit_with_literal(parent->special_objects[PIC_LOAD], tag_fixnum(-index * sizeof(cell))); - emit_epilog(no_non_safepoint_words); + emit_epilog(stack_frame); tail_call = true; emit_mega_cache_lookup(array_nth(elements.untagged(), i), index, @@ -252,7 +249,7 @@ void quotation_jit::iterate_quotation() { if (!tail_call) { set_position(length); - emit_epilog(no_non_safepoint_words); + emit_epilog(stack_frame); emit(parent->special_objects[JIT_RETURN]); } } diff --git a/vm/quotations.hpp b/vm/quotations.hpp index 68d0a98720..0f794be1e4 100644 --- a/vm/quotations.hpp +++ b/vm/quotations.hpp @@ -25,8 +25,7 @@ struct quotation_jit : public jit { bool declare_p(cell i, cell length); bool special_subprimitive_p(cell obj); cell word_stack_frame_size(cell obj); - bool word_safepoint_p(cell obj); - bool no_non_safepoint_words_p(); + bool stack_frame_p(); void iterate_quotation(); /* Allocates memory */