Explorar o código

Add extra zero init for IR

gingerBill %!s(int64=7) %!d(string=hai) anos
pai
achega
028d628e9f
Modificáronse 3 ficheiros con 10 adicións e 11 borrados
  1. 5 5
      core/_preload.odin
  2. 1 2
      core/fmt.odin
  3. 4 4
      src/ir.cpp

+ 5 - 5
core/_preload.odin

@@ -639,8 +639,7 @@ __print_type :: proc(fd: os.Handle, ti: ^Type_Info) {
 		case uint:    os.write_string(fd, "uint");
 		case uintptr: os.write_string(fd, "uintptr");
 		case:
-			if info.signed do os.write_byte(fd, 'i');
-			else           do os.write_byte(fd, 'u');
+			os.write_byte(fd, info.signed ? 'i' : 'u');
 			__print_u64(fd, u64(8*ti.size));
 		}
 	case Type_Info_Rune:
@@ -785,8 +784,8 @@ assert :: proc "contextless" (condition: bool, message := "", using loc := #call
 		if len(message) > 0 {
 			os.write_string(fd, ": ");
 			os.write_string(fd, message);
-			os.write_byte(fd, '\n');
 		}
+		os.write_byte(fd, '\n');
 		__debug_trap();
 	}
 	return condition;
@@ -799,8 +798,8 @@ panic :: proc "contextless" (message := "", using loc := #caller_location) {
 	if len(message) > 0 {
 		os.write_string(fd, ": ");
 		os.write_string(fd, message);
-		os.write_byte(fd, '\n');
 	}
+	os.write_byte(fd, '\n');
 	__debug_trap();
 }
 
@@ -1230,7 +1229,8 @@ __dynamic_map_set :: proc(h: __Map_Header, key: __Map_Key, value: rawptr, loc :=
 
 
 __dynamic_map_grow :: proc(using h: __Map_Header, loc := #caller_location) {
-	new_count := max(2*m.entries.cap + 8, __INITIAL_MAP_CAP);
+	// TODO(bill): Determine an efficient growing rate
+	new_count := max(4*m.entries.cap + 7, __INITIAL_MAP_CAP);
 	__dynamic_map_rehash(h, new_count, loc);
 }
 

+ 1 - 2
core/fmt.odin

@@ -165,8 +165,7 @@ write_type :: proc(buf: ^String_Buffer, ti: ^Type_Info) {
 		case uint:    write_string(buf, "uint");
 		case uintptr: write_string(buf, "uintptr");
 		case:
-			if info.signed do write_byte(buf, 'i');
-			else           do write_byte(buf, 'u');
+			write_byte(buf, info.signed ? 'i' : 'u');
 			write_i64(buf, i64(8*ti.size), 10);
 		}
 	case Type_Info_Rune:

+ 4 - 4
src/ir.cpp

@@ -778,7 +778,7 @@ Array<irValue *> *ir_value_referrers(irValue *v) {
 ////////////////////////////////////////////////////////////////
 
 void     ir_module_add_value    (irModule *m, Entity *e, irValue *v);
-irValue *ir_emit_zero_init      (irProcedure *p, irValue *address, AstNode *expr);
+void     ir_emit_zero_init      (irProcedure *p, irValue *address, AstNode *expr);
 irValue *ir_emit_comment        (irProcedure *p, String text);
 irValue *ir_emit_store          (irProcedure *p, irValue *address, irValue *value);
 irValue *ir_emit_load           (irProcedure *p, irValue *address);
@@ -1595,14 +1595,14 @@ void ir_add_debug_location_to_value(irProcedure *proc, irValue *v, AstNode *e) {
 	}
 }
 
-irValue *ir_emit_zero_init(irProcedure *p, irValue *address, AstNode *expr) {
+void ir_emit_zero_init(irProcedure *p, irValue *address, AstNode *expr) {
 	gbAllocator a = p->module->allocator;
 	Type *t = type_deref(ir_type(address));
 	irValue **args = gb_alloc_array(a, irValue *, 2);
 	args[0] = ir_emit_conv(p, address, t_rawptr);
 	args[1] = ir_const_int(a, type_size_of(a, t));
-	return ir_emit_global_call(p, "__mem_zero", args, 2, expr);
-	// return ir_emit(p, ir_instr_zero_init(p, address));
+	ir_emit(p, ir_instr_zero_init(p, address));
+	ir_emit_global_call(p, "__mem_zero", args, 2, expr);
 }
 
 irValue *ir_emit_comment(irProcedure *p, String text) {