Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/Changes b/Changes
- index 9639cc3..151cf97 100644
- --- a/Changes
- +++ b/Changes
- @@ -32,6 +32,8 @@ Runtime system:
- - PR#6517: use ISO C99 types {,u}int{32,64}_t in preference to our homegrown
- types {,u}int{32,64}.
- (Xavier Leroy)
- +- PR#6760: closures can now be marshalled in toplevel.
- + (Peter Zotov)
- Standard library:
- * PR#6494: Add equal function in modules
- diff --git a/byterun/caml/misc.h b/byterun/caml/misc.h
- index df75298..b2d4425 100644
- --- a/byterun/caml/misc.h
- +++ b/byterun/caml/misc.h
- @@ -91,6 +91,7 @@ struct ext_table {
- extern void caml_ext_table_init(struct ext_table * tbl, int init_capa);
- extern int caml_ext_table_add(struct ext_table * tbl, void * data);
- +extern void caml_ext_table_remove(struct ext_table * tbl, void * data);
- extern void caml_ext_table_free(struct ext_table * tbl, int free_entries);
- /* GC flags and messages */
- diff --git a/byterun/meta.c b/byterun/meta.c
- index edec407..fde0b83 100644
- --- a/byterun/meta.c
- +++ b/byterun/meta.c
- @@ -47,6 +47,12 @@ CAMLprim value caml_get_section_table(value unit)
- CAMLprim value caml_reify_bytecode(value prog, value len)
- {
- + struct code_fragment * cf = caml_stat_alloc(sizeof(struct code_fragment));
- + cf->code_start = (char *) prog;
- + cf->code_end = (char *) prog + Long_val(len);
- + cf->digest_computed = 0;
- + caml_ext_table_add(&caml_code_fragments_table, cf);
- +
- value clos;
- #ifdef ARCH_BIG_ENDIAN
- caml_fixup_endianness((code_t) prog, (asize_t) Long_val(len));
- @@ -60,6 +66,34 @@ CAMLprim value caml_reify_bytecode(value prog, value len)
- return clos;
- }
- +/* signal to the interpreter machinery that a bytecode is no more
- + needed (before freeing it) - this might be useful for a JIT
- + implementation */
- +
- +CAMLprim value caml_static_release_bytecode(value prog, value len)
- +{
- + struct code_fragment * cf = NULL, * cfi;
- + int i;
- + for (i = 0; i < caml_code_fragments_table.size; i++) {
- + cfi = (struct code_fragment *) caml_code_fragments_table.contents[i];
- + if (cfi->code_start == (char *) prog &&
- + cfi->code_end == (char *) prog + Long_val(len)) {
- + cf = cfi;
- + break;
- + }
- + }
- + /* Not matched with a caml_reify_bytecode call; impossible. */
- + if (!cf) abort();
- + caml_ext_table_remove(&caml_code_fragments_table, cf);
- +
- +#ifndef NATIVE_CODE
- + caml_release_bytecode((code_t) prog, (asize_t) Long_val(len));
- +#else
- + caml_failwith("Meta.static_release_bytecode impossible with native code");
- +#endif
- + return Val_unit;
- +}
- +
- CAMLprim value caml_register_code_fragment(value prog, value len, value digest)
- {
- struct code_fragment * cf = caml_stat_alloc(sizeof(struct code_fragment));
- diff --git a/byterun/misc.c b/byterun/misc.c
- index 784bdf4..03e5f57 100644
- --- a/byterun/misc.c
- +++ b/byterun/misc.c
- @@ -116,6 +116,19 @@ int caml_ext_table_add(struct ext_table * tbl, void * data)
- return res;
- }
- +void caml_ext_table_remove(struct ext_table * tbl, void * data)
- +{
- + int i;
- + for (i = 0; i < tbl->size; i++) {
- + if (tbl->contents[i] == data) {
- + caml_stat_free(tbl->contents[i]);
- + memmove(&tbl->contents[i], &tbl->contents[i + 1],
- + (tbl->size - i - 1) * sizeof(void *));
- + tbl->size--;
- + }
- + }
- +}
- +
- void caml_ext_table_free(struct ext_table * tbl, int free_entries)
- {
- int i;
- diff --git a/byterun/obj.c b/byterun/obj.c
- index 3a43832..27b50d9 100644
- --- a/byterun/obj.c
- +++ b/byterun/obj.c
- @@ -37,21 +37,6 @@ CAMLprim value caml_static_free(value blk)
- return Val_unit;
- }
- -/* signal to the interpreter machinery that a bytecode is no more
- - needed (before freeing it) - this might be useful for a JIT
- - implementation */
- -
- -CAMLprim value caml_static_release_bytecode(value blk, value size)
- -{
- -#ifndef NATIVE_CODE
- - caml_release_bytecode((code_t) blk, (asize_t) Long_val(size));
- -#else
- - caml_failwith("Meta.static_release_bytecode impossible with native code");
- -#endif
- - return Val_unit;
- -}
- -
- -
- CAMLprim value caml_static_resize(value blk, value new_size)
- {
- return (value) caml_stat_resize((char *) blk, (asize_t) Long_val(new_size));
Add Comment
Please, Sign In to add comment