Rename builtin attr :inline to :leaf
This commit is contained in:
parent
0c0c88d383
commit
94da5f7c36
@ -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
|
static int
|
||||||
compile_builtin_attr(rb_iseq_t *iseq, const NODE *node)
|
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;
|
if (!SYMBOL_P(symbol)) goto non_symbol_arg;
|
||||||
|
|
||||||
string = rb_sym_to_s(symbol);
|
string = rb_sym_to_s(symbol);
|
||||||
if (strcmp(RSTRING_PTR(string), "inline") == 0) {
|
if (strcmp(RSTRING_PTR(string), "leaf") == 0) {
|
||||||
ISEQ_BODY(iseq)->builtin_attrs |= BUILTIN_ATTR_INLINE;
|
ISEQ_BODY(iseq)->builtin_attrs |= BUILTIN_ATTR_LEAF;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
goto unknown_arg;
|
goto unknown_arg;
|
||||||
|
@ -16,7 +16,7 @@ module Kernel
|
|||||||
#++
|
#++
|
||||||
#
|
#
|
||||||
def class
|
def class
|
||||||
Primitive.attr! :inline
|
Primitive.attr! :leaf
|
||||||
Primitive.cexpr! 'rb_obj_class(self)'
|
Primitive.cexpr! 'rb_obj_class(self)'
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -65,7 +65,7 @@ module Kernel
|
|||||||
#++
|
#++
|
||||||
#
|
#
|
||||||
def frozen?
|
def frozen?
|
||||||
Primitive.attr! :inline
|
Primitive.attr! :leaf
|
||||||
Primitive.cexpr! 'rb_obj_frozen_p(self)'
|
Primitive.cexpr! 'rb_obj_frozen_p(self)'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
28
numeric.rb
28
numeric.rb
@ -86,7 +86,7 @@ class Integer
|
|||||||
#
|
#
|
||||||
# Returns +int+, negated.
|
# Returns +int+, negated.
|
||||||
def -@
|
def -@
|
||||||
Primitive.attr! :inline
|
Primitive.attr! :leaf
|
||||||
Primitive.cexpr! 'rb_int_uminus(self)'
|
Primitive.cexpr! 'rb_int_uminus(self)'
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -102,7 +102,7 @@ class Integer
|
|||||||
#
|
#
|
||||||
# sprintf("%X", ~0x1122334455) #=> "..FEEDDCCBBAA"
|
# sprintf("%X", ~0x1122334455) #=> "..FEEDDCCBBAA"
|
||||||
def ~
|
def ~
|
||||||
Primitive.attr! :inline
|
Primitive.attr! :leaf
|
||||||
Primitive.cexpr! 'rb_int_comp(self)'
|
Primitive.cexpr! 'rb_int_comp(self)'
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -117,7 +117,7 @@ class Integer
|
|||||||
# 12345.abs #=> 12345
|
# 12345.abs #=> 12345
|
||||||
#
|
#
|
||||||
def abs
|
def abs
|
||||||
Primitive.attr! :inline
|
Primitive.attr! :leaf
|
||||||
Primitive.cexpr! 'rb_int_abs(self)'
|
Primitive.cexpr! 'rb_int_abs(self)'
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -163,7 +163,7 @@ class Integer
|
|||||||
# raise "overflow"
|
# raise "overflow"
|
||||||
# end
|
# end
|
||||||
def bit_length
|
def bit_length
|
||||||
Primitive.attr! :inline
|
Primitive.attr! :leaf
|
||||||
Primitive.cexpr! 'rb_int_bit_length(self)'
|
Primitive.cexpr! 'rb_int_bit_length(self)'
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -172,7 +172,7 @@ class Integer
|
|||||||
#
|
#
|
||||||
# Returns +true+ if +int+ is an even number.
|
# Returns +true+ if +int+ is an even number.
|
||||||
def even?
|
def even?
|
||||||
Primitive.attr! :inline
|
Primitive.attr! :leaf
|
||||||
Primitive.cexpr! 'rb_int_even_p(self)'
|
Primitive.cexpr! 'rb_int_even_p(self)'
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -191,7 +191,7 @@ class Integer
|
|||||||
#
|
#
|
||||||
# Returns +true+ if +int+ is an odd number.
|
# Returns +true+ if +int+ is an odd number.
|
||||||
def odd?
|
def odd?
|
||||||
Primitive.attr! :inline
|
Primitive.attr! :leaf
|
||||||
Primitive.cexpr! 'rb_int_odd_p(self)'
|
Primitive.cexpr! 'rb_int_odd_p(self)'
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -226,7 +226,7 @@ class Integer
|
|||||||
# (256**40 - 1).size #=> 40
|
# (256**40 - 1).size #=> 40
|
||||||
#
|
#
|
||||||
def size
|
def size
|
||||||
Primitive.attr! :inline
|
Primitive.attr! :leaf
|
||||||
Primitive.cexpr! 'rb_int_size(self)'
|
Primitive.cexpr! 'rb_int_size(self)'
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -251,7 +251,7 @@ class Integer
|
|||||||
#
|
#
|
||||||
# Returns +true+ if +int+ has a zero value.
|
# Returns +true+ if +int+ has a zero value.
|
||||||
def zero?
|
def zero?
|
||||||
Primitive.attr! :inline
|
Primitive.attr! :leaf
|
||||||
Primitive.cexpr! 'rb_int_zero_p(self)'
|
Primitive.cexpr! 'rb_int_zero_p(self)'
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -316,12 +316,12 @@ class Float
|
|||||||
# 34.56.abs #=> 34.56
|
# 34.56.abs #=> 34.56
|
||||||
#
|
#
|
||||||
def abs
|
def abs
|
||||||
Primitive.attr! :inline
|
Primitive.attr! :leaf
|
||||||
Primitive.cexpr! 'rb_float_abs(self)'
|
Primitive.cexpr! 'rb_float_abs(self)'
|
||||||
end
|
end
|
||||||
|
|
||||||
def magnitude
|
def magnitude
|
||||||
Primitive.attr! :inline
|
Primitive.attr! :leaf
|
||||||
Primitive.cexpr! 'rb_float_abs(self)'
|
Primitive.cexpr! 'rb_float_abs(self)'
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -332,7 +332,7 @@ class Float
|
|||||||
# Returns +float+, negated.
|
# Returns +float+, negated.
|
||||||
#
|
#
|
||||||
def -@
|
def -@
|
||||||
Primitive.attr! :inline
|
Primitive.attr! :leaf
|
||||||
Primitive.cexpr! 'rb_float_uminus(self)'
|
Primitive.cexpr! 'rb_float_uminus(self)'
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -343,7 +343,7 @@ class Float
|
|||||||
# Returns +true+ if +float+ is 0.0.
|
# Returns +true+ if +float+ is 0.0.
|
||||||
#
|
#
|
||||||
def zero?
|
def zero?
|
||||||
Primitive.attr! :inline
|
Primitive.attr! :leaf
|
||||||
Primitive.cexpr! 'RBOOL(FLOAT_ZERO_P(self))'
|
Primitive.cexpr! 'RBOOL(FLOAT_ZERO_P(self))'
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -354,7 +354,7 @@ class Float
|
|||||||
# Returns +true+ if +float+ is greater than 0.
|
# Returns +true+ if +float+ is greater than 0.
|
||||||
#
|
#
|
||||||
def positive?
|
def positive?
|
||||||
Primitive.attr! :inline
|
Primitive.attr! :leaf
|
||||||
Primitive.cexpr! 'RBOOL(RFLOAT_VALUE(self) > 0.0)'
|
Primitive.cexpr! 'RBOOL(RFLOAT_VALUE(self) > 0.0)'
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -365,7 +365,7 @@ class Float
|
|||||||
# Returns +true+ if +float+ is less than 0.
|
# Returns +true+ if +float+ is less than 0.
|
||||||
#
|
#
|
||||||
def negative?
|
def negative?
|
||||||
Primitive.attr! :inline
|
Primitive.attr! :leaf
|
||||||
Primitive.cexpr! 'RBOOL(RFLOAT_VALUE(self) < 0.0)'
|
Primitive.cexpr! 'RBOOL(RFLOAT_VALUE(self) < 0.0)'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ require_relative 'ruby_vm/helpers/c_escape'
|
|||||||
|
|
||||||
SUBLIBS = {}
|
SUBLIBS = {}
|
||||||
REQUIRED = {}
|
REQUIRED = {}
|
||||||
BUILTIN_ATTRS = %w[inline]
|
BUILTIN_ATTRS = %w[leaf]
|
||||||
|
|
||||||
def string_literal(lit, str = [])
|
def string_literal(lit, str = [])
|
||||||
while lit
|
while lit
|
||||||
@ -46,15 +46,12 @@ end
|
|||||||
|
|
||||||
def inline_attrs(args)
|
def inline_attrs(args)
|
||||||
raise "args was empty" if args.empty?
|
raise "args was empty" if args.empty?
|
||||||
attrs = []
|
|
||||||
args.each do |arg|
|
args.each do |arg|
|
||||||
attr = symbol_literal(arg)
|
attr = symbol_literal(arg)
|
||||||
unless BUILTIN_ATTRS.include?(attr)
|
unless BUILTIN_ATTRS.include?(attr)
|
||||||
raise "attr (#{attr}) was not in: #{BUILTIN_ATTRS.join(', ')}"
|
raise "attr (#{attr}) was not in: #{BUILTIN_ATTRS.join(', ')}"
|
||||||
end
|
end
|
||||||
attrs << attr
|
|
||||||
end
|
end
|
||||||
attrs
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def make_cfunc_name inlines, name, lineno
|
def make_cfunc_name inlines, name, lineno
|
||||||
|
@ -368,7 +368,7 @@ enum rb_iseq_type {
|
|||||||
// Attributes specified by Primitive.attr!
|
// Attributes specified by Primitive.attr!
|
||||||
enum rb_builtin_attr {
|
enum rb_builtin_attr {
|
||||||
// If true, this ISeq does not call methods.
|
// If true, this ISeq does not call methods.
|
||||||
BUILTIN_ATTR_INLINE = 0x01,
|
BUILTIN_ATTR_LEAF = 0x01,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct rb_iseq_constant_body {
|
struct rb_iseq_constant_body {
|
||||||
|
@ -6395,7 +6395,7 @@ lookup_builtin_invoker(int argc)
|
|||||||
static inline VALUE
|
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)
|
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);
|
SETUP_CANARY(canary_p);
|
||||||
VALUE ret = (*lookup_builtin_invoker(bf->argc))(ec, reg_cfp->self, argv, (rb_insn_func_t)bf->func_ptr);
|
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));
|
CHECK_CANARY(canary_p, BIN(invokebuiltin));
|
||||||
|
2
yjit.c
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) &&
|
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[0]) == BIN(opt_invokebuiltin_delegate_leave) &&
|
||||||
rb_vm_insn_addr2opcode((void *)iseq->body->iseq_encoded[invokebuiltin_len]) == BIN(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
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user