mirror of
				https://github.com/ruby/ruby.git
				synced 2022-11-09 12:17:21 -05:00 
			
		
		
		
	Support RB_BUILTIN in ISeq#to_a
This commit is contained in:
		
							parent
							
								
									0483d01f6b
								
							
						
					
					
						commit
						5c168c7e7f
					
				
					 3 changed files with 24 additions and 2 deletions
				
			
		
							
								
								
									
										15
									
								
								iseq.c
									
										
									
									
									
								
							
							
						
						
									
										15
									
								
								iseq.c
									
										
									
									
									
								
							|  | @ -2802,6 +2802,21 @@ iseq_data_to_ary(const rb_iseq_t *iseq) | |||
| 		    rb_ary_push(ary, val); | ||||
| 		} | ||||
| 		break; | ||||
|               case TS_BUILTIN: | ||||
|                 { | ||||
|                     VALUE val = rb_hash_new(); | ||||
| #if SIZEOF_VALUE <= SIZEOF_LONG | ||||
|                     VALUE func_ptr = LONG2NUM((SIGNED_VALUE)((RB_BUILTIN)*seq)->func_ptr); | ||||
| #else | ||||
|                     VALUE func_ptr = LL2NUM((SIGNED_VALUE)((RB_BUILTIN)*seq)->func_ptr); | ||||
| #endif | ||||
|                     rb_hash_aset(val, ID2SYM(rb_intern("func_ptr")), func_ptr); | ||||
|                     rb_hash_aset(val, ID2SYM(rb_intern("argc")), INT2NUM(((RB_BUILTIN)*seq)->argc)); | ||||
|                     rb_hash_aset(val, ID2SYM(rb_intern("index")), INT2NUM(((RB_BUILTIN)*seq)->index)); | ||||
|                     rb_hash_aset(val, ID2SYM(rb_intern("name")), rb_str_new_cstr(((RB_BUILTIN)*seq)->name)); | ||||
|                     rb_ary_push(ary, val); | ||||
|                 } | ||||
|                 break; | ||||
| 	      default: | ||||
| 		rb_bug("unknown operand: %c", insn_op_type(insn, j)); | ||||
| 	    } | ||||
|  |  | |||
|  | @ -559,4 +559,11 @@ class TestISeq < Test::Unit::TestCase | |||
|       assert_equal iseq1.object_id, iseq2.object_id | ||||
|     } | ||||
|   end | ||||
| 
 | ||||
|   def test_iseq_builtin_to_a | ||||
|     insns = RubyVM::InstructionSequence.of([].method(:pack)).to_a.last | ||||
|     invokebuiltin = insns.find { |insn| insn.is_a?(Array) && insn[0] == :invokebuiltin } | ||||
|     assert_not_nil(invokebuiltin) | ||||
|     assert_equal([:func_ptr, :argc, :index, :name], invokebuiltin[1].keys) | ||||
|   end | ||||
| end | ||||
|  |  | |||
|  | @ -601,8 +601,8 @@ class TestJIT < Test::Unit::TestCase | |||
|   end | ||||
| 
 | ||||
|   def test_compile_insn_invokebuiltin | ||||
|     # insns = collect_insns(RubyVM::InstructionSequence.of([0].method(:pack)).to_a) | ||||
|     # mark_tested_insn(:invokebuiltin, used_insns: insns) | ||||
|     insns = collect_insns(RubyVM::InstructionSequence.of([0].method(:pack)).to_a) | ||||
|     mark_tested_insn(:invokebuiltin, used_insns: insns) | ||||
|     assert_eval_with_jit('print [0].pack("c")', stdout: "\x00", success_count: 1) | ||||
|   end | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Takashi Kokubun
						Takashi Kokubun