Hot Reload: fix new global not initialized #725
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In the following code based on #145 , uncomment
trace
after launch willfoo
,entrypoint
, newhaxe.Log.formatOutput
,haxe.Log.trace
),hl.Api.checkReload
after the first reload, the program runs correctly.haxe.Log.formatOutput
,haxe.Log.trace
) at the beginning offoo()
, probablyglobal 2, 9 field 1,2[6]
withglobal 9: haxe.$Log
.When debugging, I saw that additional global values are forced reset in
hl_module_patch
every timememset(m2->globals_data+m1->globals_size,0,gsize - m1->globals_size)
and are initialized byhl_module_init_constant(m2, c)
andm2->functions_ptrs[c->entrypoint]
.However, on the second reload, entrypoint function was not modified and is not called, leaving some global values to 0 (likely
haxe.$Log
,hl.CoreType
,hl.CoreEnum
).This PR try to fix it by re-call the last entrypoint function.
(I think it does not work if no change is detected, for example if new functions are memorized by m1 in the future; but for now if a new type is added, there are likely some new functions)