Verified Commit 5532bf1c authored by Camil Staps's avatar Camil Staps 🚀

Use GraphCopy function replace_desc_numbers_by_descs to resolve interpreter...

Use GraphCopy function replace_desc_numbers_by_descs to resolve interpreter symbols when deserializing
parent 62d27cc9
Pipeline #20231 passed with stages
in 11 minutes and 54 seconds
...@@ -102,62 +102,63 @@ deserialize` strict dsets {graph,descinfo,modules,bytecode} thisexe w ...@@ -102,62 +102,63 @@ deserialize` strict dsets {graph,descinfo,modules,bytecode} thisexe w
heap dsets.heap_size stack dsets.stack_size heap dsets.heap_size stack dsets.stack_size
asp bsp csp heap asp bsp csp heap
strict strict
# graph_node = string_to_interpreter int_syms graph ie_settings # graph = replace_desc_numbers_by_descs 0 graph int_syms 0 0
# graph_node = string_to_interpreter graph ie_settings
#! (ie,_) = make_finalizer ie_settings #! (ie,_) = make_finalizer ie_settings
# ie = {ie_finalizer=ie, ie_snode_ptr=0, ie_snodes=create_array_ 1} # ie = {ie_finalizer=ie, ie_snode_ptr=0, ie_snodes=create_array_ 1}
= (Just (interpret ie (Finalizer 0 0 (graph_node + if strict 2 0))), w) = (Just (interpret ie (Finalizer 0 0 (graph_node + if strict 2 0))), w)
where where
getInterpreterSymbols :: !Pointer -> [Symbol] string_to_interpreter :: !String !Pointer -> Pointer
getInterpreterSymbols pgm = takeWhile (\s -> size s.symbol_name <> 0) string_to_interpreter graph ie = code {
[getSymbol i \\ i <- [0..get_symbol_table_size pgm-1]] ccall string_to_interpreter "Sp:p"
where }
symbol_table = get_symbol_table pgm
getInterpreterSymbols :: !Pointer -> [Symbol]
getSymbol :: !Int -> Symbol getInterpreterSymbols pgm = takeWhile (\s -> size s.symbol_name <> 0)
getSymbol i [getSymbol i \\ i <- [0..get_symbol_table_size pgm-1]]
#! offset = symbol_table + i * IF_INT_64_OR_32 16 8 /* size of struct host_symbol */ where
#! loc = derefInt offset symbol_table = get_symbol_table pgm
#! name = derefString (derefInt (offset + IF_INT_64_OR_32 8 4))
= {symbol_name=name, symbol_value=loc} getSymbol :: !Int -> Symbol
getSymbol i
get_symbol_table_size :: !Pointer -> Int #! offset = symbol_table + i * IF_INT_64_OR_32 16 8 /* size of struct host_symbol */
get_symbol_table_size pgm = code { #! loc = derefInt offset
ccall get_symbol_table_size "p:I" #! name = derefString (derefInt (offset + IF_INT_64_OR_32 8 4))
} = {symbol_name=name, symbol_value=loc}
get_symbol_table :: !Pointer -> Pointer get_symbol_table_size :: !Pointer -> Int
get_symbol_table pgm = code { get_symbol_table_size pgm = code {
ccall get_symbol_table "p:p" ccall get_symbol_table_size "p:I"
}
string_to_interpreter :: !{#Int} !String !Pointer -> Pointer
string_to_interpreter symbol_values graph ie = code {
ccall string_to_interpreter "ASp:p"
} }
lookup_symbol_value :: !DescInfo !{#String} !{#Symbol} -> Int get_symbol_table :: !Pointer -> Pointer
lookup_symbol_value {di_prefix_arity_and_mod,di_name} mod_a symbols get_symbol_table pgm = code {
# prefix_n = di_prefix_arity_and_mod bitand 0xff ccall get_symbol_table "p:p"
# module_n = (di_prefix_arity_and_mod >> 8)-1 }
# module_name = mod_a.[module_n]
| prefix_n<PREFIX_D lookup_symbol_value :: !DescInfo !{#String} !{#Symbol} -> Int
# symbol_name = make_symbol_name module_name di_name prefix_n lookup_symbol_value {di_prefix_arity_and_mod,di_name} mod_a symbols
# symbol_value = get_symbol_value symbol_name symbols # prefix_n = di_prefix_arity_and_mod bitand 0xff
| prefix_n<=1 # module_n = (di_prefix_arity_and_mod >> 8)-1
| symbol_value== -1 # module_name = mod_a.[module_n]
= abort ("lookup_desc_info not found "+++symbol_name+++"\n") | prefix_n<PREFIX_D
= symbol_value # symbol_name = make_symbol_name module_name di_name prefix_n
| symbol_value== -1 # symbol_value = get_symbol_value symbol_name symbols
= abort ("lookup_desc_info not found "+++symbol_name+++"\n") | prefix_n<=1
= symbol_value+2
# symbol_name = make_symbol_name module_name di_name PREFIX_D
# symbol_value = get_symbol_value symbol_name symbols
| symbol_value== -1 | symbol_value== -1
= abort ("lookup_desc_info not found "+++symbol_name+++"\n") = abort ("lookup_desc_info not found "+++symbol_name+++"\n")
# arity = prefix_n - PREFIX_D = symbol_value
= symbol_value+(arity*8*2)+2 | symbol_value== -1
where = abort ("lookup_desc_info not found "+++symbol_name+++"\n")
PREFIX_D = 4 = symbol_value+2
# symbol_name = make_symbol_name module_name di_name PREFIX_D
# symbol_value = get_symbol_value symbol_name symbols
| symbol_value== -1
= abort ("lookup_desc_info not found "+++symbol_name+++"\n")
# arity = prefix_n - PREFIX_D
= symbol_value+(arity*8*2)+2
where
PREFIX_D = 4
get_start_rule_as_expression :: !DeserializationSettings !String !String !*World -> *(Maybe a, !*World) get_start_rule_as_expression :: !DeserializationSettings !String !String !*World -> *(Maybe a, !*World)
get_start_rule_as_expression dsets filename prog w get_start_rule_as_expression dsets filename prog w
......
...@@ -83,8 +83,7 @@ BC_WORD *build_start_node(struct interpretation_environment *ie) { ...@@ -83,8 +83,7 @@ BC_WORD *build_start_node(struct interpretation_environment *ie) {
return hp; return hp;
} }
BC_WORD *string_to_interpreter(BC_WORD *descriptors, uint64_t *clean_string, BC_WORD *string_to_interpreter(uint64_t *clean_string, struct interpretation_environment *ie) {
struct interpretation_environment *ie) {
int len = *(int*)clean_string; int len = *(int*)clean_string;
uint64_t *s = &clean_string[1]; uint64_t *s = &clean_string[1];
BC_WORD *node = ie->hp; BC_WORD *node = ie->hp;
...@@ -117,8 +116,6 @@ BC_WORD *string_to_interpreter(BC_WORD *descriptors, uint64_t *clean_string, ...@@ -117,8 +116,6 @@ BC_WORD *string_to_interpreter(BC_WORD *descriptors, uint64_t *clean_string,
continue; continue;
} }
desc=descriptors[desc-1];
#if DEBUG_CLEAN_LINKS > 1 #if DEBUG_CLEAN_LINKS > 1
EPRINTF("\t"); EPRINTF("\t");
for (int16_t *a=(int16_t*)ie->bsp-1; a>a_size_stack; a--) for (int16_t *a=(int16_t*)ie->bsp-1; a>a_size_stack; a--)
...@@ -163,7 +160,6 @@ BC_WORD *string_to_interpreter(BC_WORD *descriptors, uint64_t *clean_string, ...@@ -163,7 +160,6 @@ BC_WORD *string_to_interpreter(BC_WORD *descriptors, uint64_t *clean_string,
EPRINTF("; __ARRAY__ " BC_WORD_FMT,size); EPRINTF("; __ARRAY__ " BC_WORD_FMT,size);
#endif #endif
BC_WORD elem_desc=(BC_WORD)s[i+2]; BC_WORD elem_desc=(BC_WORD)s[i+2];
elem_desc=elem_desc==0 ? 0 : descriptors[elem_desc-1];
**ptr_stack--=(BC_WORD)ie->hp; **ptr_stack--=(BC_WORD)ie->hp;
ie->hp[0]=desc; ie->hp[0]=desc;
ie->hp[1]=size; ie->hp[1]=size;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment