mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Verify builtin inline annotation with VM_CHECK_MODE (#3244)
* Verify builtin inline annotation with VM_CHECK_MODE * Remove static to fix the link issue on MJIT
This commit is contained in:
parent
aec8e6d379
commit
d9f608b686
Notes:
git
2020-06-22 02:27:36 +09:00
Merged-By: k0kubun <takashikkbn@gmail.com>
3 changed files with 16 additions and 13 deletions
|
@ -39,7 +39,7 @@ INSN_ENTRY(<%= insn.name %>)
|
||||||
% if insn.handles_sp?
|
% if insn.handles_sp?
|
||||||
POPN(INSN_ATTR(popn));
|
POPN(INSN_ATTR(popn));
|
||||||
% end
|
% end
|
||||||
<%= insn.handle_canary "SETUP_CANARY()" -%>
|
<%= insn.handle_canary "SETUP_CANARY(leaf)" -%>
|
||||||
COLLECT_USAGE_INSN(INSN_ATTR(bin));
|
COLLECT_USAGE_INSN(INSN_ATTR(bin));
|
||||||
% insn.opes.each_with_index do |ope, i|
|
% insn.opes.each_with_index do |ope, i|
|
||||||
COLLECT_USAGE_OPERAND(INSN_ATTR(bin), <%= i %>, <%= ope[:name] %>);
|
COLLECT_USAGE_OPERAND(INSN_ATTR(bin), <%= i %>, <%= ope[:name] %>);
|
||||||
|
@ -55,7 +55,7 @@ INSN_ENTRY(<%= insn.name %>)
|
||||||
|
|
||||||
/* ### Instruction trailers. ### */
|
/* ### Instruction trailers. ### */
|
||||||
CHECK_VM_STACK_OVERFLOW_FOR_INSN(VM_REG_CFP, INSN_ATTR(retn));
|
CHECK_VM_STACK_OVERFLOW_FOR_INSN(VM_REG_CFP, INSN_ATTR(retn));
|
||||||
<%= insn.handle_canary "CHECK_CANARY()" -%>
|
<%= insn.handle_canary "CHECK_CANARY(leaf, INSN_ATTR(bin))" -%>
|
||||||
% if insn.handles_sp?
|
% if insn.handles_sp?
|
||||||
% insn.rets.reverse_each do |ret|
|
% insn.rets.reverse_each do |ret|
|
||||||
PUSH(<%= insn.cast_to_VALUE ret %>);
|
PUSH(<%= insn.cast_to_VALUE ret %>);
|
||||||
|
|
|
@ -4969,7 +4969,7 @@ vm_trace(rb_execution_context_t *ec, rb_control_frame_t *reg_cfp, const VALUE *p
|
||||||
}
|
}
|
||||||
|
|
||||||
#if VM_CHECK_MODE > 0
|
#if VM_CHECK_MODE > 0
|
||||||
static NORETURN( NOINLINE( COLDFUNC
|
NORETURN( NOINLINE( COLDFUNC
|
||||||
void vm_canary_is_found_dead(enum ruby_vminsn_type i, VALUE c)));
|
void vm_canary_is_found_dead(enum ruby_vminsn_type i, VALUE c)));
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -5165,10 +5165,13 @@ lookup_builtin_invoker(int argc)
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline VALUE
|
static inline VALUE
|
||||||
invoke_bf(rb_execution_context_t *ec, rb_control_frame_t *cfp, const struct rb_builtin_function* bf, const VALUE *argv)
|
invoke_bf(rb_execution_context_t *ec, rb_control_frame_t *reg_cfp, const struct rb_builtin_function* bf, const VALUE *argv)
|
||||||
{
|
{
|
||||||
VALUE self = cfp->self;
|
const bool canary_p = reg_cfp->iseq->body->builtin_inline_p; // Verify an assumption of `Primitive.attr! 'inline'`
|
||||||
return (*lookup_builtin_invoker(bf->argc))(ec, self, argv, (rb_insn_func_t)bf->func_ptr);
|
SETUP_CANARY(canary_p);
|
||||||
|
VALUE ret = (*lookup_builtin_invoker(bf->argc))(ec, reg_cfp->self, argv, (rb_insn_func_t)bf->func_ptr);
|
||||||
|
CHECK_CANARY(canary_p, BIN(invokebuiltin));
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
|
|
|
@ -139,27 +139,27 @@ CC_SET_FASTPATH(const struct rb_callcache *cc, vm_call_handler func, bool enable
|
||||||
/**********************************************************/
|
/**********************************************************/
|
||||||
|
|
||||||
#if VM_CHECK_MODE > 0
|
#if VM_CHECK_MODE > 0
|
||||||
#define SETUP_CANARY() \
|
#define SETUP_CANARY(cond) \
|
||||||
VALUE *canary = 0; \
|
VALUE *canary = 0; \
|
||||||
if (leaf) { \
|
if (cond) { \
|
||||||
canary = GET_SP(); \
|
canary = GET_SP(); \
|
||||||
SET_SV(vm_stack_canary); \
|
SET_SV(vm_stack_canary); \
|
||||||
} \
|
} \
|
||||||
else {\
|
else {\
|
||||||
SET_SV(Qfalse); /* cleanup */ \
|
SET_SV(Qfalse); /* cleanup */ \
|
||||||
}
|
}
|
||||||
#define CHECK_CANARY() \
|
#define CHECK_CANARY(cond, insn) \
|
||||||
if (leaf) { \
|
if (cond) { \
|
||||||
if (*canary == vm_stack_canary) { \
|
if (*canary == vm_stack_canary) { \
|
||||||
*canary = Qfalse; /* cleanup */ \
|
*canary = Qfalse; /* cleanup */ \
|
||||||
} \
|
} \
|
||||||
else { \
|
else { \
|
||||||
vm_canary_is_found_dead(INSN_ATTR(bin), *canary); \
|
vm_canary_is_found_dead(insn, *canary); \
|
||||||
} \
|
} \
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
#define SETUP_CANARY() /* void */
|
#define SETUP_CANARY(cond) /* void */
|
||||||
#define CHECK_CANARY() /* void */
|
#define CHECK_CANARY(cond, insn) /* void */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**********************************************************/
|
/**********************************************************/
|
||||||
|
|
Loading…
Reference in a new issue