diff options
author | Takashi Kokubun <takashikkbn@gmail.com> | 2023-03-18 21:20:37 -0700 |
---|---|---|
committer | Takashi Kokubun <takashikkbn@gmail.com> | 2023-03-18 21:20:58 -0700 |
commit | 81e19b7d9988ced02c80a19ef2ec0f3b7cd8c456 (patch) | |
tree | 0ea21fa364d83f222962661885bedf284f37e550 | |
parent | 9f8e914943f812a5036d92648386169079daf51b (diff) | |
download | ruby-81e19b7d9988ced02c80a19ef2ec0f3b7cd8c456.tar.gz |
RJIT: Implement getglobal
-rw-r--r-- | lib/ruby_vm/rjit/insn_compiler.rb | 24 | ||||
-rw-r--r-- | rjit_c.rb | 4 | ||||
-rwxr-xr-x | tool/rjit/bindgen.rb | 1 |
3 files changed, 26 insertions, 3 deletions
diff --git a/lib/ruby_vm/rjit/insn_compiler.rb b/lib/ruby_vm/rjit/insn_compiler.rb index aff61afc65..326607d9c4 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}") - # 78/102 + # 79/102 case insn.name when :nop then nop(jit, ctx, asm) when :getlocal then getlocal(jit, ctx, asm) @@ -35,7 +35,7 @@ module RubyVM::RJIT when :opt_getconstant_path then opt_getconstant_path(jit, ctx, asm) when :getconstant then getconstant(jit, ctx, asm) # setconstant - # getglobal + when :getglobal then getglobal(jit, ctx, asm) # setglobal when :putnil then putnil(jit, ctx, asm) when :putself then putself(jit, ctx, asm) @@ -649,7 +649,25 @@ module RubyVM::RJIT end # setconstant - # getglobal + + # @param jit [RubyVM::RJIT::JITState] + # @param ctx [RubyVM::RJIT::Context] + # @param asm [RubyVM::RJIT::Assembler] + def getglobal(jit, ctx, asm) + gid = jit.operand(0) + + # Save the PC and SP because we might make a Ruby call for warning + jit_prepare_routine_call(jit, ctx, asm) + + asm.mov(C_ARGS[0], gid) + asm.call(C.rb_gvar_get) + + top = ctx.stack_push + asm.mov(top, C_RET) + + KeepCompiling + end + # setglobal # @param jit [RubyVM::RJIT::JITState] @@ -505,6 +505,10 @@ module RubyVM::RJIT # :nodoc: all Primitive.cexpr! %q{ SIZET2NUM((size_t)rb_get_symbol_id) } end + def C.rb_gvar_get + Primitive.cexpr! %q{ SIZET2NUM((size_t)rb_gvar_get) } + end + def C.rb_hash_aref Primitive.cexpr! %q{ SIZET2NUM((size_t)rb_hash_aref) } end diff --git a/tool/rjit/bindgen.rb b/tool/rjit/bindgen.rb index ad2e5f9e1e..639031afe1 100755 --- a/tool/rjit/bindgen.rb +++ b/tool/rjit/bindgen.rb @@ -536,6 +536,7 @@ generator = BindingGenerator.new( rb_reg_match_post rb_reg_match_last rb_reg_nth_match + rb_gvar_get ], types: %w[ CALL_DATA |