VM: fixing small style issues
Like aligning comments and changing //-comments to /* */char-rename
							parent
							
								
									6e83fd4068
								
							
						
					
					
						commit
						c646db3ae5
					
				| 
						 | 
				
			
			@ -92,7 +92,6 @@ code_block* code_heap::code_block_for_address(cell address) {
 | 
			
		|||
cell code_heap::frame_predecessor(cell frame_top) {
 | 
			
		||||
  cell addr = *(cell*)frame_top;
 | 
			
		||||
  FACTOR_ASSERT(seg->in_segment_p(addr));
 | 
			
		||||
  //FACTOR_ASSERT(addr != 0);
 | 
			
		||||
  code_block* owner = code_block_for_address(addr);
 | 
			
		||||
  cell frame_size = owner->stack_frame_size_for_address(addr);
 | 
			
		||||
  return frame_top + frame_size;
 | 
			
		||||
| 
						 | 
				
			
			@ -111,8 +110,8 @@ void code_heap::initialize_all_blocks_set() {
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
/* Update pointers to words referenced from all code blocks.
 | 
			
		||||
Only needed after redefining an existing word.
 | 
			
		||||
If generic words were redefined, inline caches need to be reset. */
 | 
			
		||||
   Only needed after redefining an existing word.
 | 
			
		||||
   If generic words were redefined, inline caches need to be reset. */
 | 
			
		||||
void factor_vm::update_code_heap_words(bool reset_inline_caches) {
 | 
			
		||||
  auto word_updater = [&](code_block* block, cell size) {
 | 
			
		||||
    update_word_references(block, reset_inline_caches);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -2,16 +2,15 @@
 | 
			
		|||
 | 
			
		||||
namespace factor {
 | 
			
		||||
 | 
			
		||||
context::context(cell datastack_size, cell retainstack_size,
 | 
			
		||||
                 cell callstack_size)
 | 
			
		||||
context::context(cell ds_size, cell rs_size, cell cs_size)
 | 
			
		||||
    : callstack_top(0),
 | 
			
		||||
      callstack_bottom(0),
 | 
			
		||||
      datastack(0),
 | 
			
		||||
      retainstack(0),
 | 
			
		||||
      callstack_save(0),
 | 
			
		||||
      datastack_seg(new segment(datastack_size, false)),
 | 
			
		||||
      retainstack_seg(new segment(retainstack_size, false)),
 | 
			
		||||
      callstack_seg(new segment(callstack_size, false)) {
 | 
			
		||||
      datastack_seg(new segment(ds_size, false)),
 | 
			
		||||
      retainstack_seg(new segment(rs_size, false)),
 | 
			
		||||
      callstack_seg(new segment(cs_size, false)) {
 | 
			
		||||
  reset();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,8 +1,7 @@
 | 
			
		|||
namespace factor {
 | 
			
		||||
 | 
			
		||||
// Context object count and identifiers must be kept in sync with:
 | 
			
		||||
//   core/kernel/kernel.factor
 | 
			
		||||
 | 
			
		||||
/* Context object count and identifiers must be kept in sync with:
 | 
			
		||||
     core/kernel/kernel.factor */
 | 
			
		||||
static const cell context_object_count = 4;
 | 
			
		||||
 | 
			
		||||
enum context_object {
 | 
			
		||||
| 
						 | 
				
			
			@ -20,7 +19,7 @@ static const cell stack_reserved = 16384;
 | 
			
		|||
 | 
			
		||||
struct context {
 | 
			
		||||
 | 
			
		||||
  // First 4 fields accessed directly by compiler. See basis/vm/vm.factor
 | 
			
		||||
  /* First 5 fields accessed directly by compiler. See basis/vm/vm.factor */
 | 
			
		||||
 | 
			
		||||
  /* Factor callstack pointers */
 | 
			
		||||
  cell callstack_top;
 | 
			
		||||
| 
						 | 
				
			
			@ -43,7 +42,7 @@ struct context {
 | 
			
		|||
     set-context-object primitives */
 | 
			
		||||
  cell context_objects[context_object_count];
 | 
			
		||||
 | 
			
		||||
  context(cell datastack_size, cell retainstack_size, cell callstack_size);
 | 
			
		||||
  context(cell ds_size, cell rs_size, cell cs_size);
 | 
			
		||||
  ~context();
 | 
			
		||||
 | 
			
		||||
  void reset_datastack();
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -33,8 +33,9 @@ void free_list::add_to_free_list(free_heap_block* block) {
 | 
			
		|||
 | 
			
		||||
free_heap_block* free_list::find_free_block(cell size) {
 | 
			
		||||
  /* Check small free lists */
 | 
			
		||||
  if (size / data_alignment < free_list_count) {
 | 
			
		||||
    std::vector<free_heap_block*>& blocks = small_blocks[size / data_alignment];
 | 
			
		||||
  cell bucket = size / data_alignment;
 | 
			
		||||
  if (bucket < free_list_count) {
 | 
			
		||||
    std::vector<free_heap_block*>& blocks = small_blocks[bucket];
 | 
			
		||||
    if (blocks.size() == 0) {
 | 
			
		||||
      /* Round up to a multiple of 'size' */
 | 
			
		||||
      cell large_block_size = ((allocation_page_size + size - 1) / size) * size;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -109,8 +109,8 @@ template <typename Block> Block* free_list_allocator<Block>::allot(cell size) {
 | 
			
		|||
  if (block) {
 | 
			
		||||
    block = free_blocks.split_free_block(block, size);
 | 
			
		||||
    return (Block*)block;
 | 
			
		||||
  } else
 | 
			
		||||
    return NULL;
 | 
			
		||||
  }
 | 
			
		||||
  return NULL;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
template <typename Block> void free_list_allocator<Block>::free(Block* block) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										13
									
								
								vm/jit.cpp
								
								
								
								
							
							
						
						
									
										13
									
								
								vm/jit.cpp
								
								
								
								
							| 
						 | 
				
			
			@ -3,11 +3,12 @@
 | 
			
		|||
namespace factor {
 | 
			
		||||
 | 
			
		||||
/* Simple code generator used by:
 | 
			
		||||
- quotation compiler (quotations.cpp),
 | 
			
		||||
- megamorphic caches (dispatch.cpp),
 | 
			
		||||
- polymorphic inline caches (inline_cache.cpp) */
 | 
			
		||||
   - quotation compiler (quotations.cpp),
 | 
			
		||||
   - megamorphic caches (dispatch.cpp),
 | 
			
		||||
   - polymorphic inline caches (inline_cache.cpp) */
 | 
			
		||||
 | 
			
		||||
/* Allocates memory (`code` and `relocation` initializers create growable_byte_array) */
 | 
			
		||||
/* Allocates memory (`code` and `relocation` initializers create
 | 
			
		||||
   growable_byte_array) */
 | 
			
		||||
jit::jit(code_block_type type, cell owner, factor_vm* vm)
 | 
			
		||||
    : type(type),
 | 
			
		||||
      owner(owner, vm),
 | 
			
		||||
| 
						 | 
				
			
			@ -105,8 +106,8 @@ bool jit::emit_subprimitive(cell word_, bool tail_call_p, bool stack_frame_p) {
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
/* Facility to convert compiled code offsets to quotation offsets.
 | 
			
		||||
Call jit_compute_offset() with the compiled code offset, then emit
 | 
			
		||||
code, and at the end jit->position is the quotation position. */
 | 
			
		||||
   Call jit_compute_offset() with the compiled code offset, then emit
 | 
			
		||||
   code, and at the end jit->position is the quotation position. */
 | 
			
		||||
void jit::compute_position(cell offset_) {
 | 
			
		||||
  computing_offset_p = true;
 | 
			
		||||
  position = 0;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -14,10 +14,8 @@ struct quotation_jit : public jit {
 | 
			
		|||
 | 
			
		||||
  cell nth(cell index);
 | 
			
		||||
  void init_quotation(cell quot);
 | 
			
		||||
  void emit_mega_cache_lookup(cell methods, fixnum index, cell cache);
 | 
			
		||||
 | 
			
		||||
  bool primitive_call_p(cell i, cell length);
 | 
			
		||||
  void emit_quotation(cell quot);
 | 
			
		||||
  void emit_epilog(bool needed);
 | 
			
		||||
  bool fast_if_p(cell i, cell length);
 | 
			
		||||
  bool fast_dip_p(cell i, cell length);
 | 
			
		||||
  bool fast_2dip_p(cell i, cell length);
 | 
			
		||||
| 
						 | 
				
			
			@ -25,6 +23,11 @@ struct quotation_jit : public jit {
 | 
			
		|||
  bool mega_lookup_p(cell i, cell length);
 | 
			
		||||
  bool declare_p(cell i, cell length);
 | 
			
		||||
  bool special_subprimitive_p(cell obj);
 | 
			
		||||
 | 
			
		||||
  void emit_mega_cache_lookup(cell methods, fixnum index, cell cache);
 | 
			
		||||
  void emit_quotation(cell quot);
 | 
			
		||||
  void emit_epilog(bool needed);
 | 
			
		||||
 | 
			
		||||
  cell word_stack_frame_size(cell obj);
 | 
			
		||||
  bool stack_frame_p();
 | 
			
		||||
  void iterate_quotation();
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -178,19 +178,6 @@ void slot_visitor<Fixup>::visit_object_array(cell* start, cell* end) {
 | 
			
		|||
    visit_handle(start++);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
template <typename Fixup>
 | 
			
		||||
void slot_visitor<Fixup>::visit_partial_objects(cell start,
 | 
			
		||||
                                                cell card_start,
 | 
			
		||||
                                                cell card_end) {
 | 
			
		||||
  cell *scan_start = (cell*)start + 1;
 | 
			
		||||
  cell *scan_end = scan_start + ((object*)start)->slot_count();
 | 
			
		||||
 | 
			
		||||
  scan_start = std::max(scan_start, (cell*)card_start);
 | 
			
		||||
  scan_end = std::min(scan_end, (cell*)card_end);
 | 
			
		||||
 | 
			
		||||
  visit_object_array(scan_start, scan_end);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
template <typename Fixup> void slot_visitor<Fixup>::visit_slots(object* obj) {
 | 
			
		||||
  if (obj->type() == CALLSTACK_TYPE)
 | 
			
		||||
    visit_callstack_object((callstack*)obj);
 | 
			
		||||
| 
						 | 
				
			
			@ -533,6 +520,19 @@ void slot_visitor<Fixup>::visit_instruction_operands(code_block* block,
 | 
			
		|||
  block->each_instruction_operand(visit_func);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
template <typename Fixup>
 | 
			
		||||
void slot_visitor<Fixup>::visit_partial_objects(cell start,
 | 
			
		||||
                                                cell card_start,
 | 
			
		||||
                                                cell card_end) {
 | 
			
		||||
  cell *scan_start = (cell*)start + 1;
 | 
			
		||||
  cell *scan_end = scan_start + ((object*)start)->slot_count();
 | 
			
		||||
 | 
			
		||||
  scan_start = std::max(scan_start, (cell*)card_start);
 | 
			
		||||
  scan_end = std::min(scan_end, (cell*)card_end);
 | 
			
		||||
 | 
			
		||||
  visit_object_array(scan_start, scan_end);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
template <typename Fixup>
 | 
			
		||||
template <typename SourceGeneration>
 | 
			
		||||
cell slot_visitor<Fixup>::visit_card(SourceGeneration* gen,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue