]> gitweb.factorcode.org Git - factor.git/blobdiff - vm/vm.hpp
io.streams.256color: faster by caching styles
[factor.git] / vm / vm.hpp
index 1ff093c28dd10559fba8dc1cc96136d05972e5d1..4bacc4c077322eac297a761837c6ae5b6bf421bc 100644 (file)
--- a/vm/vm.hpp
+++ b/vm/vm.hpp
@@ -35,7 +35,7 @@ struct factor_vm {
   cell signal_handler_addr;
 
   // are we handling a memory error? used to detect double faults
-  cell faulting_p;
+  bool faulting_p;
 
   // Various special objects, accessed by special-object and
   // set-special-object primitives
@@ -70,7 +70,7 @@ struct factor_vm {
   c_to_factor_func_type c_to_factor_func;
 
   // Is profiling enabled?
-  volatile cell sampling_profiler_p;
+  volatile bool sampling_profiler_p;
   fixnum samples_per_second;
 
   // Global variables used to pass fault handler state from signal handler
@@ -86,8 +86,7 @@ struct factor_vm {
 
   // State kept by the sampling profiler
   std::vector<profiling_sample> samples;
-  std::vector<cell> sample_callstacks;
-  volatile profiling_sample_count sample_counts;
+  volatile profiling_sample current_sample;
 
   // GC is off during heap walking
   bool gc_off;
@@ -103,7 +102,7 @@ struct factor_vm {
 
   // Only set if we're performing a GC
   gc_state* current_gc;
-  volatile cell current_gc_p;
+  volatile bool current_gc_p;
 
   // Set if we're in the jit
   volatile fixnum current_jit_count;
@@ -147,14 +146,15 @@ struct factor_vm {
   static bool fatal_erroring_p;
 
   // Two fep_p variants, one might be redundant.
-  volatile cell safepoint_fep_p;
+  volatile bool safepoint_fep_p;
+
+  // Allow Ctrl-Break a busy loop in the Listener, only used on Windows
+  volatile bool stop_on_ctrl_break;
 
   // contexts
   context* new_context();
   void init_context(context* ctx);
   void delete_context();
-  void init_contexts(cell datastack_size_, cell retainstack_size_,
-                     cell callstack_size_);
   cell begin_callback(cell quot);
   void end_callback();
   void primitive_current_callback();
@@ -166,7 +166,6 @@ struct factor_vm {
   void primitive_datastack_for();
   cell retainstack_to_array(context* ctx);
   void primitive_retainstack_for();
-  cell array_to_stack(array* array, cell bottom);
   void primitive_set_datastack();
   void primitive_set_retainstack();
   void primitive_check_datastack();
@@ -183,7 +182,6 @@ struct factor_vm {
   void primitive_set_special_object();
   void primitive_identity_hashcode();
   void primitive_compute_identity_hashcode();
-  cell clone_object(cell obj_);
   void primitive_clone();
   void primitive_become();
 
@@ -191,17 +189,17 @@ struct factor_vm {
   void record_sample(bool prolog_p);
   void start_sampling_profiler(fixnum rate);
   void end_sampling_profiler();
-  void set_sampling_profiler(fixnum rate);
-  void primitive_sampling_profiler();
+  void set_profiling(fixnum rate);
+  void primitive_set_profiling();
   void primitive_get_samples();
+  array* allot_growarr();
+  void growarr_add(array *growarr_, cell value);
 
   // errors
   void general_error(vm_error_type error, cell arg1, cell arg2);
   void type_error(cell type, cell tagged);
-  void not_implemented_error();
   void set_memory_protection_error(cell fault_addr, cell fault_pc);
   void divide_by_zero_error();
-  void primitive_unimplemented();
 
   // bignum
   int bignum_equal_p(bignum* x, bignum* y);
@@ -279,7 +277,6 @@ struct factor_vm {
 
   //data heap
   void set_data_heap(data_heap* data_);
-  void init_data_heap(cell young_size, cell aging_size, cell tenured_size);
   void primitive_size();
   data_heap_room data_room();
   void primitive_data_room();
@@ -343,14 +340,13 @@ struct factor_vm {
   void collect_nursery();
   void collect_aging();
   void collect_to_tenured();
-  void update_code_roots_for_sweep();
   void update_code_roots_for_compaction();
   void collect_mark_impl();
   void collect_sweep_impl();
   void collect_full();
   void collect_compact_impl();
   void collect_compact();
-  void collect_growing_heap(cell requested_size);
+  void collect_growing_data_heap(cell requested_size);
   void gc(gc_op op, cell requested_size);
   void primitive_minor_gc();
   void primitive_full_gc();
@@ -396,6 +392,8 @@ struct factor_vm {
   void factorbug_usage(bool advanced_p);
   void factorbug();
   void primitive_die();
+  void primitive_enable_ctrl_break();
+  void primitive_disable_ctrl_break();
 
   // arrays
   inline void set_array_nth(array* array, cell slot, cell value);
@@ -525,14 +523,13 @@ struct factor_vm {
   }
 
   // io
-  void init_c_io();
   void io_error_if_not_EINTR();
   FILE* safe_fopen(char* filename, const char* mode);
   int safe_fgetc(FILE* stream);
   size_t safe_fread(void* ptr, size_t size, size_t nitems, FILE* stream);
   void safe_fputc(int c, FILE* stream);
   size_t safe_fwrite(void* ptr, size_t size, size_t nitems, FILE* stream);
-  int safe_ftell(FILE* stream);
+  off_t safe_ftell(FILE* stream);
   void safe_fseek(FILE* stream, off_t offset, int whence);
   void safe_fflush(FILE* stream);
   void primitive_fopen();
@@ -663,9 +660,6 @@ struct factor_vm {
   // inline cache
   void deallocate_inline_cache(cell return_address);
   void update_pic_count(cell type);
-  code_block* compile_inline_cache(fixnum index, cell generic_word_,
-                                   cell methods_, cell cache_entries_,
-                                   bool tail_call_p);
   cell add_inline_cache_entry(cell cache_entries_, cell klass_, cell method_);
   void update_pic_transitions(cell pic_size);
   cell inline_cache_miss(cell return_address);
@@ -686,7 +680,6 @@ struct factor_vm {
   void init_factor(vm_parameters* p);
   void pass_args_to_factor(int argc, vm_char** argv);
   void stop_factor();
-  void start_embedded_factor(vm_parameters* p);
   void start_standalone_factor(int argc, vm_char** argv);
   char* factor_eval_string(char* string);
   void factor_eval_free(char* result);
@@ -707,6 +700,11 @@ struct factor_vm {
 
 // os-windows
 #if defined(WINDOWS)
+  /* Id of the main thread we run in. Used for Ctrl-Break handling. */
+  DWORD thread_id;
+
+  HANDLE ctrl_break_thread;
+
   HANDLE sampler_thread;
   void sampler_thread_loop();