diff options
| author | Takashi Kokubun <takashikkbn@gmail.com> | 2023-03-18 21:42:10 -0700 |
|---|---|---|
| committer | Takashi Kokubun <takashikkbn@gmail.com> | 2023-03-18 21:42:20 -0700 |
| commit | 8510f33cc1d7f6b5148d596cfea3fbf734661cd8 (patch) | |
| tree | 8a9d758ff601da2f4a50e97e99eb9dd77b03447a /lib/ruby_vm | |
| parent | 4a8de3fa8872ed43b33f1ae81ae4767f4334283a (diff) | |
RJIT: Implement intern
Diffstat (limited to 'lib/ruby_vm')
| -rw-r--r-- | lib/ruby_vm/rjit/insn_compiler.rb | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/lib/ruby_vm/rjit/insn_compiler.rb b/lib/ruby_vm/rjit/insn_compiler.rb index ba645d2374..347319dd35 100644 --- a/lib/ruby_vm/rjit/insn_compiler.rb +++ b/lib/ruby_vm/rjit/insn_compiler.rb @@ -18,7 +18,7 @@ module RubyVM::RJIT asm.incr_counter(:rjit_insns_count) asm.comment("Insn: #{insn.name}") - # 81/102 + # 82/102 case insn.name when :nop then nop(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 :anytostring then anytostring(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) # newarraykwsplat when :duparray then duparray(jit, ctx, asm) @@ -827,7 +827,23 @@ module RubyVM::RJIT KeepCompiling 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 ctx [RubyVM::RJIT::Context] |
