Rename builtin attr :inline to :leaf

This commit is contained in:
Takashi Kokubun 2023-03-11 14:25:11 -08:00
Родитель 0c0c88d383
Коммит 94da5f7c36
7 изменённых файлов: 23 добавлений и 26 удалений

Просмотреть файл

@ -8214,7 +8214,7 @@ delegate_call_p(const rb_iseq_t *iseq, unsigned int argc, const LINK_ANCHOR *arg
}
}
// Compile Primitive.attr! :inline, ...
// Compile Primitive.attr! :leaf, ...
static int
compile_builtin_attr(rb_iseq_t *iseq, const NODE *node)
{
@ -8233,8 +8233,8 @@ compile_builtin_attr(rb_iseq_t *iseq, const NODE *node)
if (!SYMBOL_P(symbol)) goto non_symbol_arg;
string = rb_sym_to_s(symbol);
if (strcmp(RSTRING_PTR(string), "inline") == 0) {
ISEQ_BODY(iseq)->builtin_attrs |= BUILTIN_ATTR_INLINE;
if (strcmp(RSTRING_PTR(string), "leaf") == 0) {
ISEQ_BODY(iseq)->builtin_attrs |= BUILTIN_ATTR_LEAF;
}
else {
goto unknown_arg;

Просмотреть файл

@ -16,7 +16,7 @@ module Kernel
#++
#
def class
Primitive.attr! :inline
Primitive.attr! :leaf
Primitive.cexpr! 'rb_obj_class(self)'
end
@ -65,7 +65,7 @@ module Kernel
#++
#
def frozen?
Primitive.attr! :inline
Primitive.attr! :leaf
Primitive.cexpr! 'rb_obj_frozen_p(self)'
end

Просмотреть файл

@ -86,7 +86,7 @@ class Integer
#
# Returns +int+, negated.
def -@
Primitive.attr! :inline
Primitive.attr! :leaf
Primitive.cexpr! 'rb_int_uminus(self)'
end
@ -102,7 +102,7 @@ class Integer
#
# sprintf("%X", ~0x1122334455) #=> "..FEEDDCCBBAA"
def ~
Primitive.attr! :inline
Primitive.attr! :leaf
Primitive.cexpr! 'rb_int_comp(self)'
end
@ -117,7 +117,7 @@ class Integer
# 12345.abs #=> 12345
#
def abs
Primitive.attr! :inline
Primitive.attr! :leaf
Primitive.cexpr! 'rb_int_abs(self)'
end
@ -163,7 +163,7 @@ class Integer
# raise "overflow"
# end
def bit_length
Primitive.attr! :inline
Primitive.attr! :leaf
Primitive.cexpr! 'rb_int_bit_length(self)'
end
@ -172,7 +172,7 @@ class Integer
#
# Returns +true+ if +int+ is an even number.
def even?
Primitive.attr! :inline
Primitive.attr! :leaf
Primitive.cexpr! 'rb_int_even_p(self)'
end
@ -191,7 +191,7 @@ class Integer
#
# Returns +true+ if +int+ is an odd number.
def odd?
Primitive.attr! :inline
Primitive.attr! :leaf
Primitive.cexpr! 'rb_int_odd_p(self)'
end
@ -226,7 +226,7 @@ class Integer
# (256**40 - 1).size #=> 40
#
def size
Primitive.attr! :inline
Primitive.attr! :leaf
Primitive.cexpr! 'rb_int_size(self)'
end
@ -251,7 +251,7 @@ class Integer
#
# Returns +true+ if +int+ has a zero value.
def zero?
Primitive.attr! :inline
Primitive.attr! :leaf
Primitive.cexpr! 'rb_int_zero_p(self)'
end
@ -316,12 +316,12 @@ class Float
# 34.56.abs #=> 34.56
#
def abs
Primitive.attr! :inline
Primitive.attr! :leaf
Primitive.cexpr! 'rb_float_abs(self)'
end
def magnitude
Primitive.attr! :inline
Primitive.attr! :leaf
Primitive.cexpr! 'rb_float_abs(self)'
end
@ -332,7 +332,7 @@ class Float
# Returns +float+, negated.
#
def -@
Primitive.attr! :inline
Primitive.attr! :leaf
Primitive.cexpr! 'rb_float_uminus(self)'
end
@ -343,7 +343,7 @@ class Float
# Returns +true+ if +float+ is 0.0.
#
def zero?
Primitive.attr! :inline
Primitive.attr! :leaf
Primitive.cexpr! 'RBOOL(FLOAT_ZERO_P(self))'
end
@ -354,7 +354,7 @@ class Float
# Returns +true+ if +float+ is greater than 0.
#
def positive?
Primitive.attr! :inline
Primitive.attr! :leaf
Primitive.cexpr! 'RBOOL(RFLOAT_VALUE(self) > 0.0)'
end
@ -365,7 +365,7 @@ class Float
# Returns +true+ if +float+ is less than 0.
#
def negative?
Primitive.attr! :inline
Primitive.attr! :leaf
Primitive.cexpr! 'RBOOL(RFLOAT_VALUE(self) < 0.0)'
end

Просмотреть файл

@ -6,7 +6,7 @@ require_relative 'ruby_vm/helpers/c_escape'
SUBLIBS = {}
REQUIRED = {}
BUILTIN_ATTRS = %w[inline]
BUILTIN_ATTRS = %w[leaf]
def string_literal(lit, str = [])
while lit
@ -46,15 +46,12 @@ end
def inline_attrs(args)
raise "args was empty" if args.empty?
attrs = []
args.each do |arg|
attr = symbol_literal(arg)
unless BUILTIN_ATTRS.include?(attr)
raise "attr (#{attr}) was not in: #{BUILTIN_ATTRS.join(', ')}"
end
attrs << attr
end
attrs
end
def make_cfunc_name inlines, name, lineno

Просмотреть файл

@ -368,7 +368,7 @@ enum rb_iseq_type {
// Attributes specified by Primitive.attr!
enum rb_builtin_attr {
// If true, this ISeq does not call methods.
BUILTIN_ATTR_INLINE = 0x01,
BUILTIN_ATTR_LEAF = 0x01,
};
struct rb_iseq_constant_body {

Просмотреть файл

@ -6395,7 +6395,7 @@ lookup_builtin_invoker(int argc)
static inline VALUE
invoke_bf(rb_execution_context_t *ec, rb_control_frame_t *reg_cfp, const struct rb_builtin_function* bf, const VALUE *argv)
{
const bool canary_p = ISEQ_BODY(reg_cfp->iseq)->builtin_attrs & BUILTIN_ATTR_INLINE; // Verify an assumption of `Primitive.attr! :inline`
const bool canary_p = ISEQ_BODY(reg_cfp->iseq)->builtin_attrs & BUILTIN_ATTR_LEAF; // Verify an assumption of `Primitive.attr! :leaf`
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));

2
yjit.c
Просмотреть файл

@ -735,7 +735,7 @@ rb_leaf_invokebuiltin_iseq_p(const rb_iseq_t *iseq)
return (iseq->body->iseq_size == (invokebuiltin_len + leave_len) &&
rb_vm_insn_addr2opcode((void *)iseq->body->iseq_encoded[0]) == BIN(opt_invokebuiltin_delegate_leave) &&
rb_vm_insn_addr2opcode((void *)iseq->body->iseq_encoded[invokebuiltin_len]) == BIN(leave) &&
(iseq->body->builtin_attrs & BUILTIN_ATTR_INLINE) != 0
(iseq->body->builtin_attrs & BUILTIN_ATTR_LEAF) != 0
);
}