authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2017-01-31 16:04:26-05:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2017-01-31 16:04:26-05:00
logd13cec6894aa01b6a5dbf6a7cf9b071fa9c68666
tree3bf96fabf7d9df63ee9cc463ebd8c96207f8af23
parent88a253c64dc148a6f09e4e872e3abbcd37fcc18a

fix var args allocating wrong amount of memory in compiler


3 files changed, 7 insertions(+), 7 deletions(-)

src/analyze.cpp+3-3
...@@ -898,7 +898,7 @@ static TypeTableEntry *get_generic_fn_type(CodeGen *g, FnTypeId *fn_type_id) {...@@ -898,7 +898,7 @@ static TypeTableEntry *get_generic_fn_type(CodeGen *g, FnTypeId *fn_type_id) {
898 return fn_type;898 return fn_type;
899}899}
900900
901void init_fn_type_id(FnTypeId *fn_type_id, AstNode *proto_node) {901void init_fn_type_id(FnTypeId *fn_type_id, AstNode *proto_node, size_t param_count_alloc) {
902 assert(proto_node->type == NodeTypeFnProto);902 assert(proto_node->type == NodeTypeFnProto);
903 AstNodeFnProto *fn_proto = &proto_node->data.fn_proto;903 AstNodeFnProto *fn_proto = &proto_node->data.fn_proto;
904904
...@@ -906,7 +906,7 @@ void init_fn_type_id(FnTypeId *fn_type_id, AstNode *proto_node) {...@@ -906,7 +906,7 @@ void init_fn_type_id(FnTypeId *fn_type_id, AstNode *proto_node) {
906 fn_type_id->is_naked = fn_proto->is_nakedcc;906 fn_type_id->is_naked = fn_proto->is_nakedcc;
907 fn_type_id->is_cold = fn_proto->is_coldcc;907 fn_type_id->is_cold = fn_proto->is_coldcc;
908 fn_type_id->param_count = fn_proto->params.length;908 fn_type_id->param_count = fn_proto->params.length;
909 fn_type_id->param_info = allocate_nonzero<FnTypeParamInfo>(fn_type_id->param_count);909 fn_type_id->param_info = allocate_nonzero<FnTypeParamInfo>(param_count_alloc);
910 fn_type_id->next_param_index = 0;910 fn_type_id->next_param_index = 0;
911 fn_type_id->is_var_args = fn_proto->is_var_args;911 fn_type_id->is_var_args = fn_proto->is_var_args;
912}912}
...@@ -916,7 +916,7 @@ static TypeTableEntry *analyze_fn_type(CodeGen *g, AstNode *proto_node, Scope *c...@@ -916,7 +916,7 @@ static TypeTableEntry *analyze_fn_type(CodeGen *g, AstNode *proto_node, Scope *c
916 AstNodeFnProto *fn_proto = &proto_node->data.fn_proto;916 AstNodeFnProto *fn_proto = &proto_node->data.fn_proto;
917917
918 FnTypeId fn_type_id = {0};918 FnTypeId fn_type_id = {0};
919 init_fn_type_id(&fn_type_id, proto_node);919 init_fn_type_id(&fn_type_id, proto_node, proto_node->data.fn_proto.params.length);
920920
921 for (; fn_type_id.next_param_index < fn_type_id.param_count; fn_type_id.next_param_index += 1) {921 for (; fn_type_id.next_param_index < fn_type_id.param_count; fn_type_id.next_param_index += 1) {
922 AstNode *param_node = fn_proto->params.at(fn_type_id.next_param_index);922 AstNode *param_node = fn_proto->params.at(fn_type_id.next_param_index);
src/analyze.hpp+1-1
...@@ -70,7 +70,7 @@ VariableTableEntry *add_variable(CodeGen *g, AstNode *source_node, Scope *parent...@@ -70,7 +70,7 @@ VariableTableEntry *add_variable(CodeGen *g, AstNode *source_node, Scope *parent
70TypeTableEntry *analyze_type_expr(CodeGen *g, Scope *scope, AstNode *node);70TypeTableEntry *analyze_type_expr(CodeGen *g, Scope *scope, AstNode *node);
71FnTableEntry *create_fn(AstNode *proto_node);71FnTableEntry *create_fn(AstNode *proto_node);
72FnTableEntry *create_fn_raw(FnInline inline_value, bool internal_linkage);72FnTableEntry *create_fn_raw(FnInline inline_value, bool internal_linkage);
73void init_fn_type_id(FnTypeId *fn_type_id, AstNode *proto_node);73void init_fn_type_id(FnTypeId *fn_type_id, AstNode *proto_node, size_t param_count_alloc);
74AstNode *get_param_decl_node(FnTableEntry *fn_entry, size_t index);74AstNode *get_param_decl_node(FnTableEntry *fn_entry, size_t index);
75FnTableEntry *scope_get_fn_if_root(Scope *scope);75FnTableEntry *scope_get_fn_if_root(Scope *scope);
76bool type_requires_comptime(TypeTableEntry *type_entry);76bool type_requires_comptime(TypeTableEntry *type_entry);
src/ir.cpp+3-3
...@@ -7866,7 +7866,7 @@ static TypeTableEntry *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCall *cal...@@ -7866,7 +7866,7 @@ static TypeTableEntry *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCall *cal
7866 impl_fn->fndef_scope = create_fndef_scope(impl_fn->fn_def_node, parent_scope, impl_fn);7866 impl_fn->fndef_scope = create_fndef_scope(impl_fn->fn_def_node, parent_scope, impl_fn);
7867 impl_fn->child_scope = &impl_fn->fndef_scope->base;7867 impl_fn->child_scope = &impl_fn->fndef_scope->base;
7868 FnTypeId inst_fn_type_id = {0};7868 FnTypeId inst_fn_type_id = {0};
7869 init_fn_type_id(&inst_fn_type_id, fn_proto_node);7869 init_fn_type_id(&inst_fn_type_id, fn_proto_node, call_param_count);
7870 inst_fn_type_id.param_count = 0;7870 inst_fn_type_id.param_count = 0;
7871 inst_fn_type_id.is_var_args = false;7871 inst_fn_type_id.is_var_args = false;
78727872
...@@ -7875,7 +7875,7 @@ static TypeTableEntry *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCall *cal...@@ -7875,7 +7875,7 @@ static TypeTableEntry *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCall *cal
7875 GenericFnTypeId *generic_id = allocate<GenericFnTypeId>(1);7875 GenericFnTypeId *generic_id = allocate<GenericFnTypeId>(1);
7876 generic_id->fn_entry = fn_entry;7876 generic_id->fn_entry = fn_entry;
7877 generic_id->param_count = 0;7877 generic_id->param_count = 0;
7878 generic_id->params = allocate<ConstExprValue>(src_param_count);7878 generic_id->params = allocate<ConstExprValue>(call_param_count);
7879 size_t next_proto_i = 0;7879 size_t next_proto_i = 0;
78807880
7881 if (first_arg_ptr) {7881 if (first_arg_ptr) {
...@@ -11483,7 +11483,7 @@ static TypeTableEntry *ir_analyze_instruction_fn_proto(IrAnalyze *ira, IrInstruc...@@ -11483,7 +11483,7 @@ static TypeTableEntry *ir_analyze_instruction_fn_proto(IrAnalyze *ira, IrInstruc
11483 assert(proto_node->type == NodeTypeFnProto);11483 assert(proto_node->type == NodeTypeFnProto);
1148411484
11485 FnTypeId fn_type_id = {0};11485 FnTypeId fn_type_id = {0};
11486 init_fn_type_id(&fn_type_id, proto_node);11486 init_fn_type_id(&fn_type_id, proto_node, proto_node->data.fn_proto.params.length);
1148711487
11488 bool depends_on_compile_var = false;11488 bool depends_on_compile_var = false;
1148911489