VM: the jit class doesn't need to store the code block type
							parent
							
								
									453eca66c4
								
							
						
					
					
						commit
						51408b66cb
					
				| 
						 | 
					@ -32,8 +32,7 @@ void factor_vm::update_pic_count(cell type) {
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct inline_cache_jit : public jit {
 | 
					struct inline_cache_jit : public jit {
 | 
				
			||||||
  inline_cache_jit(cell generic_word, factor_vm* vm)
 | 
					  inline_cache_jit(cell generic_word, factor_vm* vm) : jit(generic_word, vm) {}
 | 
				
			||||||
      : jit(CODE_BLOCK_PIC, generic_word, vm) {}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  void emit_check_and_jump(cell ic_type, cell i, cell klass, cell method);
 | 
					  void emit_check_and_jump(cell ic_type, cell i, cell klass, cell method);
 | 
				
			||||||
  void emit_inline_cache(fixnum index, cell generic_word_, cell methods_,
 | 
					  void emit_inline_cache(fixnum index, cell generic_word_, cell methods_,
 | 
				
			||||||
| 
						 | 
					@ -119,7 +118,7 @@ code_block* factor_vm::compile_inline_cache(fixnum index, cell generic_word_,
 | 
				
			||||||
  inline_cache_jit jit(generic_word.value(), this);
 | 
					  inline_cache_jit jit(generic_word.value(), this);
 | 
				
			||||||
  jit.emit_inline_cache(index, generic_word.value(), methods.value(),
 | 
					  jit.emit_inline_cache(index, generic_word.value(), methods.value(),
 | 
				
			||||||
                        cache_entries.value(), tail_call_p);
 | 
					                        cache_entries.value(), tail_call_p);
 | 
				
			||||||
  code_block* code = jit.to_code_block(JIT_FRAME_SIZE);
 | 
					  code_block* code = jit.to_code_block(CODE_BLOCK_PIC, JIT_FRAME_SIZE);
 | 
				
			||||||
  initialize_code_block(code);
 | 
					  initialize_code_block(code);
 | 
				
			||||||
  return code;
 | 
					  return code;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -9,9 +9,8 @@ namespace factor {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Allocates memory (`code` and `relocation` initializers create
 | 
					// Allocates memory (`code` and `relocation` initializers create
 | 
				
			||||||
// growable_byte_array)
 | 
					// growable_byte_array)
 | 
				
			||||||
jit::jit(code_block_type type, cell owner, factor_vm* vm)
 | 
					jit::jit(cell owner, factor_vm* vm)
 | 
				
			||||||
    : type(type),
 | 
					    : owner(owner, vm),
 | 
				
			||||||
      owner(owner, vm),
 | 
					 | 
				
			||||||
      code(vm),
 | 
					      code(vm),
 | 
				
			||||||
      relocation(vm),
 | 
					      relocation(vm),
 | 
				
			||||||
      parameters(vm),
 | 
					      parameters(vm),
 | 
				
			||||||
| 
						 | 
					@ -115,7 +114,7 @@ void jit::compute_position(cell offset_) {
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Allocates memory (trim(), add_code_block)
 | 
					// Allocates memory (trim(), add_code_block)
 | 
				
			||||||
code_block* jit::to_code_block(cell frame_size) {
 | 
					code_block* jit::to_code_block(code_block_type type, cell frame_size) {
 | 
				
			||||||
  // Emit dummy GC info
 | 
					  // Emit dummy GC info
 | 
				
			||||||
  code.grow_bytes(alignment_for(code.count + 4, data_alignment));
 | 
					  code.grow_bytes(alignment_for(code.count + 4, data_alignment));
 | 
				
			||||||
  uint32_t dummy_gc_info = 0;
 | 
					  uint32_t dummy_gc_info = 0;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,7 +1,6 @@
 | 
				
			||||||
namespace factor {
 | 
					namespace factor {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct jit {
 | 
					struct jit {
 | 
				
			||||||
  code_block_type type;
 | 
					 | 
				
			||||||
  data_root<object> owner;
 | 
					  data_root<object> owner;
 | 
				
			||||||
  growable_byte_array code;
 | 
					  growable_byte_array code;
 | 
				
			||||||
  growable_byte_array relocation;
 | 
					  growable_byte_array relocation;
 | 
				
			||||||
| 
						 | 
					@ -12,7 +11,7 @@ struct jit {
 | 
				
			||||||
  cell offset;
 | 
					  cell offset;
 | 
				
			||||||
  factor_vm* parent;
 | 
					  factor_vm* parent;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  jit(code_block_type type, cell owner, factor_vm* parent);
 | 
					  jit(cell owner, factor_vm* parent);
 | 
				
			||||||
  ~jit();
 | 
					  ~jit();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  void compute_position(cell offset);
 | 
					  void compute_position(cell offset);
 | 
				
			||||||
| 
						 | 
					@ -51,7 +50,7 @@ struct jit {
 | 
				
			||||||
      position = position_;
 | 
					      position = position_;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  code_block* to_code_block(cell frame_size);
 | 
					  code_block* to_code_block(code_block_type type, cell frame_size);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
private:
 | 
					private:
 | 
				
			||||||
  jit(const jit&);
 | 
					  jit(const jit&);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -293,8 +293,8 @@ code_block* factor_vm::jit_compile_quotation(cell owner_, cell quot_,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  cell frame_size = compiler.word_stack_frame_size(owner_);
 | 
					  cell frame_size = compiler.word_stack_frame_size(owner_);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  code_block* compiled = compiler.to_code_block(frame_size);
 | 
					  code_block* compiled = compiler.to_code_block(CODE_BLOCK_UNOPTIMIZED,
 | 
				
			||||||
 | 
					                                                frame_size);
 | 
				
			||||||
  if (relocating)
 | 
					  if (relocating)
 | 
				
			||||||
    initialize_code_block(compiled);
 | 
					    initialize_code_block(compiled);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -6,7 +6,7 @@ struct quotation_jit : public jit {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // Allocates memory
 | 
					  // Allocates memory
 | 
				
			||||||
  quotation_jit(cell owner, bool compiling, bool relocate, factor_vm* vm)
 | 
					  quotation_jit(cell owner, bool compiling, bool relocate, factor_vm* vm)
 | 
				
			||||||
      : jit(CODE_BLOCK_UNOPTIMIZED, owner, vm),
 | 
					      : jit(owner, vm),
 | 
				
			||||||
        elements(false_object, vm),
 | 
					        elements(false_object, vm),
 | 
				
			||||||
        compiling(compiling),
 | 
					        compiling(compiling),
 | 
				
			||||||
        relocate(relocate) {}
 | 
					        relocate(relocate) {}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue