VM: new primitive free-callback which is able to free a callback
previously allocated using <callback>db4
parent
a338fa08e7
commit
e00798cd2a
|
@ -418,6 +418,7 @@ M: object infer-call* \ call bad-macro-input ;
|
|||
\ fpu-state { } { } define-primitive
|
||||
\ fputc { object alien } { } define-primitive
|
||||
\ fread-unsafe { integer c-ptr alien } { integer } define-primitive
|
||||
\ free-callback { alien } { } define-primitive
|
||||
\ fseek { integer integer alien } { } define-primitive
|
||||
\ ftell { alien } { integer } define-primitive
|
||||
\ fwrite { c-ptr integer alien } { } define-primitive
|
||||
|
|
|
@ -450,6 +450,7 @@ tuple
|
|||
{ "fgetc" "io.streams.c" "primitive_fgetc" ( alien -- byte/f ) }
|
||||
{ "fputc" "io.streams.c" "primitive_fputc" ( byte alien -- ) }
|
||||
{ "fread-unsafe" "io.streams.c" "primitive_fread" ( n buf alien -- count ) }
|
||||
{ "free-callback" "alien" "primitive_free_callback" ( alien -- ) }
|
||||
{ "fseek" "io.streams.c" "primitive_fseek" ( alien offset whence -- ) }
|
||||
{ "ftell" "io.streams.c" "primitive_ftell" ( alien -- n ) }
|
||||
{ "fwrite" "io.streams.c" "primitive_fwrite" ( data length alien -- ) }
|
||||
|
|
|
@ -136,6 +136,12 @@ void factor_vm::primitive_callback() {
|
|||
ctx->push(allot_alien(func));
|
||||
}
|
||||
|
||||
void factor_vm::primitive_free_callback() {
|
||||
void* entry_point = alien_offset(ctx->pop());
|
||||
code_block* stub = (code_block*)entry_point - 1;
|
||||
callbacks->allocator->free(stub);
|
||||
}
|
||||
|
||||
/* Allocates memory */
|
||||
void factor_vm::primitive_callback_room() {
|
||||
allocator_room room = callbacks->allocator->as_allocator_room();
|
||||
|
|
|
@ -9,9 +9,9 @@ namespace factor {
|
|||
_(bignum_less) _(bignum_lesseq) _(bignum_log2) _(bignum_mod) \
|
||||
_(bignum_gcd) _(bignum_multiply) _(bignum_not) _(bignum_or) \
|
||||
_(bignum_shift) _(bignum_subtract) _(bignum_to_fixnum) \
|
||||
_(bignum_to_fixnum_strict) _(bignum_xor) \
|
||||
_(bits_double) _(bits_float) _(byte_array) _(callback) _(callback_room) \
|
||||
_(callstack) _(callstack_bounds) _(callstack_for) _(callstack_to_array) \
|
||||
_(bignum_to_fixnum_strict) _(bignum_xor) _(bits_double) _(bits_float) \
|
||||
_(byte_array) _(callback) _(callback_room) _(callstack) \
|
||||
_(callstack_bounds) _(callstack_for) _(callstack_to_array) \
|
||||
_(check_datastack) _(clear_samples) _(clone) _(code_blocks) _(code_room) \
|
||||
_(compact_gc) _(compute_identity_hashcode) _(context_object) \
|
||||
_(context_object_for) _(current_callback) _(data_room) _(datastack) \
|
||||
|
@ -23,19 +23,20 @@ namespace factor {
|
|||
_(float_bits) _(float_divfloat) _(float_eq) _(float_greater) \
|
||||
_(float_greatereq) _(float_less) _(float_lesseq) _(float_multiply) \
|
||||
_(float_subtract) _(float_to_bignum) _(float_to_fixnum) _(fopen) \
|
||||
_(format_float) _(fputc) _(fread) _(fseek) _(ftell) _(full_gc) _(fwrite) \
|
||||
_(get_samples) _(identity_hashcode) _(innermost_stack_frame_executing) \
|
||||
_(innermost_stack_frame_scan) _(jit_compile) _(load_locals) \
|
||||
_(lookup_method) _(mega_cache_miss) _(minor_gc) _(modify_code_heap) \
|
||||
_(nano_count) _(optimized_p) _(quot_compiled_p) _(quotation_code) \
|
||||
_(reset_dispatch_stats) _(resize_array) _(resize_byte_array) \
|
||||
_(resize_string) _(retainstack) _(retainstack_for) _(sampling_profiler) \
|
||||
_(save_image) _(save_image_and_exit) _(set_context_object) \
|
||||
_(set_datastack) _(set_innermost_stack_frame_quot) _(set_retainstack) \
|
||||
_(set_slot) _(set_special_object) _(set_string_nth_fast) _(size) \
|
||||
_(sleep) _(special_object) _(string) _(strip_stack_traces) _(tuple) \
|
||||
_(tuple_boa) _(unimplemented) _(uninitialized_byte_array) _(word) \
|
||||
_(word_code) _(wrapper)
|
||||
_(format_float) _(fputc) _(fread) _(free_callback) _(fseek) _(ftell) \
|
||||
_(full_gc) _(fwrite) _(get_samples) _(identity_hashcode) \
|
||||
_(innermost_stack_frame_executing) _(innermost_stack_frame_scan) \
|
||||
_(jit_compile) _(load_locals) _(lookup_method) _(mega_cache_miss) \
|
||||
_(minor_gc) _(modify_code_heap) _(nano_count) _(optimized_p) \
|
||||
_(quot_compiled_p) _(quotation_code) _(reset_dispatch_stats) \
|
||||
_(resize_array) _(resize_byte_array) _(resize_string) _(retainstack) \
|
||||
_(retainstack_for) _(sampling_profiler) _(save_image) \
|
||||
_(save_image_and_exit) _(set_context_object) _(set_datastack) \
|
||||
_(set_innermost_stack_frame_quot) _(set_retainstack) _(set_slot) \
|
||||
_(set_special_object) _(set_string_nth_fast) _(size) _(sleep) \
|
||||
_(special_object) _(string) _(strip_stack_traces) _(tuple) _(tuple_boa) \
|
||||
_(unimplemented) _(uninitialized_byte_array) _(word) _(word_code) \
|
||||
_(wrapper)
|
||||
|
||||
#define EACH_ALIEN_PRIMITIVE(_) \
|
||||
_(signed_cell, fixnum, from_signed_cell, to_fixnum) \
|
||||
|
|
Loading…
Reference in New Issue