VM: move the paths out of gc memory so that they arent unnecessarily
added to the imagedb4
parent
a4b14808a0
commit
c69e1a6e93
30
vm/image.cpp
30
vm/image.cpp
|
@ -295,15 +295,19 @@ bool factor_vm::save_image(const vm_char* saving_filename,
|
||||||
}
|
}
|
||||||
|
|
||||||
void factor_vm::primitive_save_image() {
|
void factor_vm::primitive_save_image() {
|
||||||
|
byte_array* path2 = tagged<byte_array>(ctx->pop()).untag_check(this);
|
||||||
|
byte_array* path1 = tagged<byte_array>(ctx->pop()).untag_check(this);
|
||||||
|
|
||||||
|
vm_char* path1_saved = safe_strdup(path1->data<vm_char>());
|
||||||
|
vm_char* path2_saved = safe_strdup(path2->data<vm_char>());
|
||||||
|
|
||||||
/* do a full GC to push everything into tenured space */
|
/* do a full GC to push everything into tenured space */
|
||||||
primitive_compact_gc();
|
primitive_compact_gc();
|
||||||
|
|
||||||
data_root<byte_array> path2(ctx->pop(), this);
|
save_image(path1_saved, path2_saved);
|
||||||
path2.untag_check(this);
|
|
||||||
data_root<byte_array> path1(ctx->pop(), this);
|
free(path1_saved);
|
||||||
path1.untag_check(this);
|
free(path2_saved);
|
||||||
save_image((vm_char*)(path1.untagged() + 1),
|
|
||||||
(vm_char*)(path2.untagged() + 1));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Allocates memory */
|
/* Allocates memory */
|
||||||
|
@ -311,10 +315,13 @@ void factor_vm::primitive_save_image_and_exit() {
|
||||||
/* We unbox this before doing anything else. This is the only point
|
/* We unbox this before doing anything else. This is the only point
|
||||||
where we might throw an error, so we have to throw an error here since
|
where we might throw an error, so we have to throw an error here since
|
||||||
later steps destroy the current image. */
|
later steps destroy the current image. */
|
||||||
data_root<byte_array> path2(ctx->pop(), this);
|
byte_array* path2 = tagged<byte_array>(ctx->pop()).untag_check(this);
|
||||||
path2.untag_check(this);
|
byte_array* path1 = tagged<byte_array>(ctx->pop()).untag_check(this);
|
||||||
data_root<byte_array> path1(ctx->pop(), this);
|
|
||||||
path1.untag_check(this);
|
/* Copy the paths to non-gc memory to avoid them hanging around in
|
||||||
|
the saved image. */
|
||||||
|
vm_char* path1_saved = safe_strdup(path1->data<vm_char>());
|
||||||
|
vm_char* path2_saved = safe_strdup(path2->data<vm_char>());
|
||||||
|
|
||||||
/* strip out special_objects data which is set on startup anyway */
|
/* strip out special_objects data which is set on startup anyway */
|
||||||
for (cell i = 0; i < special_object_count; i++)
|
for (cell i = 0; i < special_object_count; i++)
|
||||||
|
@ -329,8 +336,7 @@ void factor_vm::primitive_save_image_and_exit() {
|
||||||
gc(collect_compact_op, 0 /* requested size */);
|
gc(collect_compact_op, 0 /* requested size */);
|
||||||
|
|
||||||
/* Save the image */
|
/* Save the image */
|
||||||
if (save_image((vm_char*)(path1.untagged() + 1),
|
if (save_image(path1_saved, path2_saved))
|
||||||
(vm_char*)(path2.untagged() + 1)))
|
|
||||||
exit(0);
|
exit(0);
|
||||||
else
|
else
|
||||||
exit(1);
|
exit(1);
|
||||||
|
|
Loading…
Reference in New Issue