-
Notifications
You must be signed in to change notification settings - Fork 544
Commit
…ance
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -446,10 +446,21 @@ static ObjClosure* compileInModule(WrenVM* vm, Value name, const char* source, | |
{ | ||
module = wrenNewModule(vm, AS_STRING(name)); | ||
|
||
// It's possible for the map set call below to resize the modules map, | ||
// and trigger a GC while doing so. When this happens and there are enough | ||
// objects and modules, it will collect the module we've just created. | ||
// wrenPushRoot isn't an option when there are enough modules to exhaust | ||
// WREN_MAX_TEMP_ROOTS, however handles are also not collected by GC. | ||
// Note that this only affects the module until it's in the map, because | ||
// then it has a reference to it, and won't be collected. | ||
WrenHandle* moduleHandle = wrenMakeHandle(vm, OBJ_VAL(module)); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
ruby0x1
Author
Member
|
||
|
||
// Store it in the VM's module registry so we don't load the same module | ||
// multiple times. | ||
wrenMapSet(vm, vm->modules, name, OBJ_VAL(module)); | ||
|
||
wrenReleaseHandle(vm, moduleHandle); | ||
|
||
// Implicitly import the core module. | ||
ObjModule* coreModule = getModule(vm, NULL_VAL); | ||
for (int i = 0; i < coreModule->variables.count; i++) | ||
|
This solution sounds really sub-optimal.
Can you elaborate more on why you think using
wrenPushRoot
is not an option ?The scope of the push/pop is really centered around
wrenMapSet
and I don't see how it can sanely lead to an exhaust of roots. But I rember WREN_MAX_TEMP_ROOTS was defined to be the minimal amount required so the engine works. I would prefered WREN_MAX_TEMP_ROOTS to be some power of 2 than that random 5. So please revert use wrenPushRoot and increase WREN_MAX_TEMP_ROOTS.