-
Notifications
You must be signed in to change notification settings - Fork 64
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sweep not work correctly on ESP8266 #23
Comments
If the number of frees was zero it means it probably didn't mark anything during the marking phase. Perhaps for some reason it is not finding any pointers on the stack? This is hard to debug without knowing more of the code. |
Thanks for your reply. Currently, it marks correctly in my macOS but does not work when I upload it to the ESP8266 chip.
The implementation which I used. The // Enum
enum mrb_type {
MRB_TYPE_OBJECT,
}
// Structures
typedef struct mrb_state {
// ...
tgc_t gc;
} mrb_state;
typedef struct mb_value {
union {
int i;
void* p;
} value;
mrb_type type;
} mrb_value;
typedef struct RObject {
// ...
kh_iv iv;
} RObject; // Functions
mrb_state* mrb_open() {
mrb_value mrb;
// ...
void* stack;
tgc_start(&mrb->gc, &stack);
return mrb;
}
void mrb_close(mrb_state* mrb) {
// ...
tgc_stop(&mrb->gc);
free(mrb);
}
void mrb_new_object(mrb_state* mrb) {
mrb_value value;
RObject* object = (RObject*)tgc_alloc_opt(&mrb->gc, sizeof(RObject), 0, mrb_free_object);
kh_init(iv, object->iv);
// ...
value.type = MRB_TYPE_OBJECT;
value.value.p = (void*)object;
return value;
} // Usage
int main(int argc, char** argv) {
mrb_state* mrb = mrb_open();
// Inside VM - Begin
mrb_value regs[3];
while(true) {
// ...
case(OP_SEND) {
regs[0] = mrb_new_object(mrb);
continue;
}
// ...
}
// Inside VM - End
mrb_close(mrb);
} |
To me it looks like maybe you need to call |
I have tried to call Does any way to change the stack deep threshold to make it start marking early? The ESP8266 design may be different from the PC cause the stack is not deep enough. |
You can try this tip: https://github.com/orangeduck/tgc#tgc-isnt-working-when-optimisations-are-enabled |
Thanks, I will try it and report the result. |
Thanks for this tiny GC implementation that I can use as an example in my book about implementing a mruby virtual machine.
For the demo of my example, I run it on my macOS and ESP8266 chip.
But the
tgc_sweep
never runs because thegc->nfrees
always be0
in ESP8266.The patch has removed this line to force it run sweep event nothing to be free.
tgc/tgc.c
Line 249 in 3520705
Does anyone have any idea about the root cause to let the GC never work?
The text was updated successfully, but these errors were encountered: