@@ -82,15 +82,19 @@ inline bool autoreload_is_enabled() {
8282}
8383
8484void  autoreload_trigger () {
85-     if  (autoreload_enabled  &  !autoreload_suspended ) {
86-         last_autoreload_trigger  =  supervisor_ticks_ms32 ();
87-         // Guard against the rare time that ticks is 0; 
88-         if  (last_autoreload_trigger  ==  0 ) {
89-             last_autoreload_trigger  +=  1 ;
90-         }
91-         // Initiate a reload of the VM immediately. Later code will pause to 
92-         // wait for the autoreload to become ready. Doing the VM exit 
93-         // immediately is clearer for the user. 
85+     if  (!autoreload_enabled  ||  autoreload_suspended  !=  0 ) {
86+         return ;
87+     }
88+     bool  reload_initiated  =  autoreload_pending ();
89+     last_autoreload_trigger  =  supervisor_ticks_ms32 ();
90+     // Guard against the rare time that ticks is 0; 
91+     if  (last_autoreload_trigger  ==  0 ) {
92+         last_autoreload_trigger  +=  1 ;
93+     }
94+     // Initiate a reload of the VM immediately. Later code will pause to 
95+     // wait for the autoreload to become ready. Doing the VM exit 
96+     // immediately is clearer for the user. 
97+     if  (!reload_initiated ) {
9498        reload_initiate (RUN_REASON_AUTO_RELOAD );
9599    }
96100}
@@ -111,5 +115,5 @@ bool autoreload_ready() {
111115}
112116
113117bool  autoreload_pending (void ) {
114-     return  last_autoreload_trigger  !=  0 ;
118+     return  last_autoreload_trigger  >  0 ;
115119}
0 commit comments