-
-
Save MasterDuke17/df4f8c79ddeaebf2b3035a2b233ae294 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/6model/reprs/VMArray.c b/src/6model/reprs/VMArray.c | |
index b1eaf19c..1ddd68c3 100644 | |
--- a/src/6model/reprs/VMArray.c | |
+++ b/src/6model/reprs/VMArray.c | |
@@ -92,7 +92,10 @@ static void gc_mark(MVMThreadContext *tc, MVMSTable *st, void *data, MVMGCWorkli | |
/* Called by the VM in order to free memory associated with this object. */ | |
static void gc_free(MVMThreadContext *tc, MVMObject *obj) { | |
MVMArray *arr = (MVMArray *)obj; | |
- MVM_free(arr->body.slots.any); | |
+ if (arr->body.fsa) | |
+ MVM_fixed_size_free(tc, tc->instance->fsa, arr->body.ssize, arr->body.slots.any); | |
+ else | |
+ MVM_free(arr->body.slots.any); | |
} | |
/* Marks the representation data in an STable.*/ | |
diff --git a/src/6model/reprs/VMArray.h b/src/6model/reprs/VMArray.h | |
index 6191356f..c96f6a5c 100644 | |
--- a/src/6model/reprs/VMArray.h | |
+++ b/src/6model/reprs/VMArray.h | |
@@ -32,6 +32,7 @@ struct MVMArrayBody { | |
void *any; | |
} slots; | |
+ MVMuint8 fsa; | |
#if MVM_ARRAY_CONC_DEBUG | |
AO_t in_use; | |
#endif | |
diff --git a/src/io/procops.c b/src/io/procops.c | |
index 2d0b28ba..2ed420b8 100644 | |
--- a/src/io/procops.c | |
+++ b/src/io/procops.c | |
@@ -505,8 +505,9 @@ static void async_spawn_on_exit(uv_process_t *req, MVMint64 exit_status, int ter | |
/* Allocates a buffer of the suggested size. */ | |
static void on_alloc(uv_handle_t *handle, size_t suggested_size, uv_buf_t *buf) { | |
- size_t size = suggested_size > 0 ? suggested_size : 4; | |
- buf->base = MVM_malloc(size); | |
+ size_t size = 1024; | |
+ MVMThreadContext *tc = (MVMThreadContext *)((SpawnInfo *)handle->data)->tc; | |
+ buf->base = MVM_fixed_size_alloc(tc, tc->instance->fsa, size); | |
buf->len = size; | |
} | |
@@ -534,6 +535,7 @@ static void async_read(uv_stream_t *handle, ssize_t nread, const uv_buf_t *buf, | |
MVMObject *buf_type = MVM_repr_at_key_o(tc, si->callbacks, | |
tc->instance->str_consts.buf_type); | |
MVMArray *res_buf = (MVMArray *)MVM_repr_alloc_init(tc, buf_type); | |
+ res_buf->body.fsa = 1; | |
res_buf->body.slots.i8 = (MVMint8 *)buf->base; | |
res_buf->body.start = 0; | |
res_buf->body.ssize = buf->len; | |
@@ -571,7 +573,7 @@ static void async_read(uv_stream_t *handle, ssize_t nread, const uv_buf_t *buf, | |
}); | |
}); | |
if (buf->base) | |
- MVM_free(buf->base); | |
+ MVM_fixed_size_free(tc, tc->instance->fsa, buf->len, buf->base); | |
uv_close((uv_handle_t *)handle, NULL); | |
if (--si->using == 0) | |
MVM_io_eventloop_remove_active_work(tc, &(si->work_idx)); | |
@@ -589,7 +591,7 @@ static void async_read(uv_stream_t *handle, ssize_t nread, const uv_buf_t *buf, | |
}); | |
}); | |
if (buf->base) | |
- MVM_free(buf->base); | |
+ MVM_fixed_size_free(tc, tc->instance->fsa, buf->len, buf->base); | |
uv_close((uv_handle_t *)handle, NULL); | |
if (--si->using == 0) | |
MVM_io_eventloop_remove_active_work(tc, &(si->work_idx)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment