Last active
May 3, 2025 20:26
-
-
Save lovely-error/24779c0f18420acb45c08ecf6409281b to your computer and use it in GitHub Desktop.
homogenise the repr of generics / dyn Trait / (*mut/*const/&/&mut) dyn Trait
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
homogenise the repr of generics / dyn Trait / (*mut/*const/&/&mut) dyn Trait | |
abstract value = (generic / dyn Trait / (*mut/*const/&/&mut) dyn Trait) value; | |
abstracted function = (takes at least one arg that is abstract or returns abstract value) and the fun is nonspecialisible; | |
at the 'lower level' abstract args are represented by wide pointers; | |
devise some opt passes to 'degeneralise' uses of abstracted funs at some sites; | |
specifically: | |
1. uses within an 'inner world' (libs with visible impl) | |
2. cross bondry code must be generated to adhere to the wide pointer repr tho | |
syntax has to be changed to make abstracted fun pointers expressible at surface level | |
fn_ptr as fn <T>(T) -> T where T: Debug should be valid syntax | |
by default abstracted funs are noninlineable unless | |
1. marked #[inline] | |
2. called with inline_call!() macro | |
let _ = inline_call!(abstracted_fun_ident(...)); // ok | |
let _ = inline_call!(fn_ptr as fn <T>(T) -> T where ...); // compile time error | |
Two cases of ret vals | |
1. fn <...>(...) -> Sized -- actually not a problem at all! | |
2. fn <...>(...) -> Unsized -- unknown retval size in general case | |
(u32,u32)[u8;?] | |
size ^ | |
align fn_ptr points here | |
funs returning dynsized retvals are invokable only through indirect_call!() macro | |
let layout = unsized_fun_retval_layout!(unsized_fun_ptr); // ask how much space is needed for return value | |
let mut retval_storage_ptr = ...; | |
let () = indirect_call!(abstracted_fun_ptr, (args...), &raw mut retval_storage_ptr); | |
rdylib2 format | |
1. os/cpu-arch dependent output! | |
2. should contain ty mtd by default (alt: making type binding unsafe is undesirable) | |
3. lang builtins to query symbols in the rdylib2 ? | |
try_get_sym_by_name(lib_start_addr:*mut (), name:&'static str) -> Option<OpaqueSymRef> | |
try_bind_type<T>(sym_ref:OpaqueSymRef) -> Option<SymRef<T>> | |
try_bind_type_unchecked<T>(sym_ref:OpaqueSymRef) -> SymRef<T> | |
[lib_mtd] | |
magic_num (4bytes 'rdl2') | |
lib_name (len:u16, chars:[u8;len]) | |
lib_format (v1 = name_hash:u64, ty_hash:u64, code_section_offset:u64) | |
[sym_tab] | |
(name_hash) | |
... | |
(ty_hash, code_section_offset) | |
... | |
[code] | |
... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment