diff options
author | Aaron Patterson <tenderlove@ruby-lang.org> | 2022-10-12 14:37:02 -0700 |
---|---|---|
committer | Aaron Patterson <tenderlove@ruby-lang.org> | 2022-10-13 13:11:01 -0700 |
commit | e5058b58c22e19d559b1122d94af5af3931aa416 (patch) | |
tree | 6bfd4dba20d8905436ee0c8c9e1992cb10117d83 /mjit_c.rb | |
parent | 1b0c9d0e3d6dc3630072dc16c143e0d79886b7a0 (diff) |
Only expose Ruby Shape API if VM_CHECK_MODE is enabled
Diffstat (limited to 'mjit_c.rb')
-rw-r--r-- | mjit_c.rb | 25 |
1 files changed, 23 insertions, 2 deletions
@@ -6,11 +6,11 @@ module RubyVM::MJIT class << C def SHAPE_BITS - RubyVM::Shape::SHAPE_BITS + Primitive.cexpr! 'UINT2NUM(SHAPE_BITS)' end def SHAPE_FLAG_SHIFT - RubyVM::Shape::SHAPE_FLAG_SHIFT + Primitive.cexpr! 'UINT2NUM(SHAPE_FLAG_SHIFT)' end def ROBJECT_EMBED_LEN_MAX @@ -29,6 +29,12 @@ module RubyVM::MJIT Primitive.has_cache_for_send(cc.to_i, insn) end + def rb_shape_get_shape_by_id(shape_id) + _shape_id = shape_id.to_i + shape_addr = Primitive.cexpr! 'PTR2NUM((VALUE)rb_shape_get_shape_by_id((shape_id_t)NUM2UINT(_shape_id)))' + rb_shape_t.new(shape_addr) + end + def rb_iseq_check(iseq) _iseq_addr = iseq.to_i iseq_addr = Primitive.cexpr! 'PTR2NUM((VALUE)rb_iseq_check((rb_iseq_t *)NUM2PTR(_iseq_addr)))' @@ -595,6 +601,21 @@ module RubyVM::MJIT @rb_serial_t ||= CType::Immediate.parse("unsigned long long") end + def C.rb_shape + @rb_shape ||= CType::Struct.new( + "rb_shape", Primitive.cexpr!("SIZEOF(struct rb_shape)"), + edges: [CType::Pointer.new { self.rb_id_table }, Primitive.cexpr!("OFFSETOF((*((struct rb_shape *)NULL)), edges)")], + edge_name: [self.ID, Primitive.cexpr!("OFFSETOF((*((struct rb_shape *)NULL)), edge_name)")], + iv_count: [self.attr_index_t, Primitive.cexpr!("OFFSETOF((*((struct rb_shape *)NULL)), iv_count)")], + type: [CType::Immediate.parse("uint8_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_shape *)NULL)), type)")], + parent_id: [self.shape_id_t, Primitive.cexpr!("OFFSETOF((*((struct rb_shape *)NULL)), parent_id)")], + ) + end + + def C.rb_shape_t + @rb_shape_t ||= self.rb_shape + end + def C.VALUE @VALUE ||= CType::Immediate.find(Primitive.cexpr!("SIZEOF(VALUE)"), Primitive.cexpr!("SIGNED_TYPE_P(VALUE)")) end |