This commit is contained in:
Takashi Kokubun 2023-03-18 21:42:10 -07:00
Родитель 4a8de3fa88
Коммит 8510f33cc1
3 изменённых файлов: 24 добавлений и 3 удалений

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

@ -18,7 +18,7 @@ module RubyVM::RJIT
asm.incr_counter(:rjit_insns_count) asm.incr_counter(:rjit_insns_count)
asm.comment("Insn: #{insn.name}") asm.comment("Insn: #{insn.name}")
# 81/102 # 82/102
case insn.name case insn.name
when :nop then nop(jit, ctx, asm) when :nop then nop(jit, ctx, asm)
when :getlocal then getlocal(jit, ctx, asm) when :getlocal then getlocal(jit, ctx, asm)
@ -45,7 +45,7 @@ module RubyVM::RJIT
when :concatstrings then concatstrings(jit, ctx, asm) when :concatstrings then concatstrings(jit, ctx, asm)
when :anytostring then anytostring(jit, ctx, asm) when :anytostring then anytostring(jit, ctx, asm)
when :toregexp then toregexp(jit, ctx, asm) when :toregexp then toregexp(jit, ctx, asm)
# intern when :intern then intern(jit, ctx, asm)
when :newarray then newarray(jit, ctx, asm) when :newarray then newarray(jit, ctx, asm)
# newarraykwsplat # newarraykwsplat
when :duparray then duparray(jit, ctx, asm) when :duparray then duparray(jit, ctx, asm)
@ -827,7 +827,23 @@ module RubyVM::RJIT
KeepCompiling KeepCompiling
end end
# intern # @param jit [RubyVM::RJIT::JITState]
# @param ctx [RubyVM::RJIT::Context]
# @param asm [RubyVM::RJIT::Assembler]
def intern(jit, ctx, asm)
# Save the PC and SP because we might allocate
jit_prepare_routine_call(jit, ctx, asm);
str = ctx.stack_pop(1)
asm.mov(C_ARGS[0], str)
asm.call(C.rb_str_intern)
# Push the return value
stack_ret = ctx.stack_push
asm.mov(stack_ret, C_RET)
KeepCompiling
end
# @param jit [RubyVM::RJIT::JITState] # @param jit [RubyVM::RJIT::JITState]
# @param ctx [RubyVM::RJIT::Context] # @param ctx [RubyVM::RJIT::Context]

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

@ -593,6 +593,10 @@ module RubyVM::RJIT # :nodoc: all
Primitive.cexpr! %q{ SIZET2NUM((size_t)rb_str_getbyte) } Primitive.cexpr! %q{ SIZET2NUM((size_t)rb_str_getbyte) }
end end
def C.rb_str_intern
Primitive.cexpr! %q{ SIZET2NUM((size_t)rb_str_intern) }
end
def C.rb_vm_bh_to_procval def C.rb_vm_bh_to_procval
Primitive.cexpr! %q{ SIZET2NUM((size_t)rb_vm_bh_to_procval) } Primitive.cexpr! %q{ SIZET2NUM((size_t)rb_vm_bh_to_procval) }
end end

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

@ -541,6 +541,7 @@ generator = BindingGenerator.new(
rb_ary_tmp_new_from_values rb_ary_tmp_new_from_values
rb_reg_new_ary rb_reg_new_ary
rb_ary_clear rb_ary_clear
rb_str_intern
], ],
types: %w[ types: %w[
CALL_DATA CALL_DATA