@@ -1988,24 +1988,54 @@ jerry_snapshot_set_offsets (uint8_t *buffer_p, /**< buffer */
19881988 if (bytecode_p -> status_flags & CBC_CODE_FLAGS_FUNCTION )
19891989 {
19901990 lit_cpointer_t * literal_start_p ;
1991+ uint32_t argument_end ;
1992+ uint32_t register_end ;
19911993 uint32_t const_literal_end ;
19921994
19931995 if (bytecode_p -> status_flags & CBC_CODE_FLAGS_UINT16_ARGUMENTS )
19941996 {
19951997 literal_start_p = (lit_cpointer_t * ) (buffer_p + sizeof (cbc_uint16_arguments_t ));
19961998
19971999 cbc_uint16_arguments_t * args_p = (cbc_uint16_arguments_t * ) buffer_p ;
2000+ argument_end = args_p -> argument_end ;
2001+ register_end = args_p -> register_end ;
19982002 const_literal_end = args_p -> const_literal_end ;
19992003 }
20002004 else
20012005 {
20022006 literal_start_p = (lit_cpointer_t * ) (buffer_p + sizeof (cbc_uint8_arguments_t ));
20032007
20042008 cbc_uint8_arguments_t * args_p = (cbc_uint8_arguments_t * ) buffer_p ;
2009+ argument_end = args_p -> argument_end ;
2010+ register_end = args_p -> register_end ;
20052011 const_literal_end = args_p -> const_literal_end ;
20062012 }
20072013
2008- for (uint32_t i = 0 ; i < const_literal_end ; i ++ )
2014+ for (uint32_t i = 0 ; i < register_end ; i ++ )
2015+ {
2016+ literal_start_p [i ] = MEM_CP_NULL ;
2017+ }
2018+
2019+ if ((bytecode_p -> status_flags & CBC_CODE_FLAGS_ARGUMENTS_NEEDED )
2020+ && !(bytecode_p -> status_flags & CBC_CODE_FLAGS_STRICT_MODE ))
2021+ {
2022+ for (uint32_t i = 0 ; i < argument_end ; i ++ )
2023+ {
2024+ lit_mem_to_snapshot_id_map_entry_t * current_p = lit_map_p ;
2025+
2026+ if (literal_start_p [i ] != MEM_CP_NULL )
2027+ {
2028+ while (current_p -> literal_id != literal_start_p [i ])
2029+ {
2030+ current_p ++ ;
2031+ }
2032+
2033+ literal_start_p [i ] = (uint16_t ) current_p -> literal_offset ;
2034+ }
2035+ }
2036+ }
2037+
2038+ for (uint32_t i = register_end ; i < const_literal_end ; i ++ )
20092039 {
20102040 lit_mem_to_snapshot_id_map_entry_t * current_p = lit_map_p ;
20112041
0 commit comments