Skip to content

接口实现优化 #224

Description

@Chronostasys

每个类型的接口impl使用全局vtable变量

目前来说,我们的接口实现的vtable是存在本地接口变量中的,例如接口A有函数B和C,那么底层该接口如下:

{
  gcrtti i64
  real_ptr *i8
  B i64(指针转的)
  C i64
}

实际上,我们希望他是这样的:

{
  gcrtti i64
  real_ptr *i8
  _vtable *i8
}

_vtable指向一个全局变量,这个全局变量在每个结构体实现一个接口的时候会生成一个对应的:

impl A for D {
  fn B...
  fn C...
}

global impl_A_D {
  B i64
  C i64
}

接口变量内存布局:
{
  gcrtti i64
  real_ptr *i8
  _vtable *i8 -> impl_A_D 
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions