Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

接口实现优化 #224

Open
Chronostasys opened this issue Feb 28, 2023 · 0 comments
Open

接口实现优化 #224

Chronostasys opened this issue Feb 28, 2023 · 0 comments
Labels
enhancement New feature or request
Milestone

Comments

@Chronostasys
Copy link
Member

Chronostasys commented Feb 28, 2023

每个类型的接口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 
}

@Chronostasys Chronostasys converted this from a draft issue Feb 28, 2023
@Chronostasys Chronostasys added the enhancement New feature or request label Feb 28, 2023
@Chronostasys Chronostasys added this to the 1.0.0 milestone May 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: 🔖 Ready
Development

No branches or pull requests

1 participant