mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-02-17 01:11:45 +00:00
Move method function defs into the far data space.
As they are never referenced directly by instructions, there's no need for them to be in the near data space, taking precious def locations.
This commit is contained in:
parent
5252d72856
commit
4336fc2c73
6 changed files with 39 additions and 26 deletions
|
@ -92,20 +92,21 @@ struct type_s *parse_params (struct type_s *type, param_t *params);
|
|||
param_t *check_params (param_t *params);
|
||||
|
||||
enum storage_class_e;
|
||||
struct defspace_s;
|
||||
void make_function (struct symbol_s *sym, const char *nice_name,
|
||||
enum storage_class_e storage);
|
||||
struct defspace_s *space, enum storage_class_e storage);
|
||||
struct symbol_s *function_symbol (struct symbol_s *sym,
|
||||
int overload, int create);
|
||||
struct expr_s *find_function (struct expr_s *fexpr, struct expr_s *params);
|
||||
function_t *new_function (const char *name, const char *nice_name);
|
||||
void add_function (function_t *f);
|
||||
function_t *begin_function (struct symbol_s *sym, const char *nicename,
|
||||
struct symtab_s *parent);
|
||||
struct symtab_s *parent, int far);
|
||||
function_t *build_code_function (struct symbol_s *fsym,
|
||||
struct expr_s *state_expr,
|
||||
struct expr_s *statements);
|
||||
function_t *build_builtin_function (struct symbol_s *sym,
|
||||
struct expr_s *bi_val);
|
||||
struct expr_s *bi_val, int far);
|
||||
void build_function (function_t *f);
|
||||
void finish_function (function_t *f);
|
||||
void emit_function (function_t *f, struct expr_s *e);
|
||||
|
|
|
@ -1176,7 +1176,8 @@ class_finish_module (void)
|
|||
exec_class_sym = new_symbol_type ("__obj_exec_class",
|
||||
&type_obj_exec_class);
|
||||
exec_class_sym = function_symbol (exec_class_sym, 0, 1);
|
||||
make_function (exec_class_sym, 0, st_extern);
|
||||
make_function (exec_class_sym, 0, exec_class_sym->table->space,
|
||||
st_extern);
|
||||
}
|
||||
|
||||
init_sym = new_symbol_type (".ctor", &type_function);
|
||||
|
@ -1189,7 +1190,7 @@ class_finish_module (void)
|
|||
address_expr (new_symbol_expr (module_sym),
|
||||
0, 0)));
|
||||
|
||||
current_func = begin_function (init_sym, 0, current_symtab);
|
||||
current_func = begin_function (init_sym, 0, current_symtab, 1);
|
||||
build_code_function (init_sym, 0, init_expr);;
|
||||
current_func = 0;
|
||||
}
|
||||
|
|
|
@ -492,7 +492,8 @@ new_function (const char *name, const char *nice_name)
|
|||
}
|
||||
|
||||
void
|
||||
make_function (symbol_t *sym, const char *nice_name, storage_class_t storage)
|
||||
make_function (symbol_t *sym, const char *nice_name, defspace_t *space,
|
||||
storage_class_t storage)
|
||||
{
|
||||
if (sym->sy_type != sy_func)
|
||||
internal_error (0, "%s is not a function", sym->name);
|
||||
|
@ -508,8 +509,7 @@ make_function (symbol_t *sym, const char *nice_name, storage_class_t storage)
|
|||
sym->s.func->def = 0;
|
||||
}
|
||||
if (!sym->s.func->def)
|
||||
sym->s.func->def = new_def (sym->name, sym->type, sym->table->space,
|
||||
storage);
|
||||
sym->s.func->def = new_def (sym->name, sym->type, space, storage);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -523,8 +523,11 @@ add_function (function_t *f)
|
|||
}
|
||||
|
||||
function_t *
|
||||
begin_function (symbol_t *sym, const char *nicename, symtab_t *parent)
|
||||
begin_function (symbol_t *sym, const char *nicename, symtab_t *parent,
|
||||
int far)
|
||||
{
|
||||
defspace_t *space;
|
||||
|
||||
if (sym->sy_type != sy_func) {
|
||||
error (0, "%s is not a function", sym->name);
|
||||
sym = new_symbol_type (sym->name, &type_function);
|
||||
|
@ -535,7 +538,10 @@ begin_function (symbol_t *sym, const char *nicename, symtab_t *parent)
|
|||
sym = new_symbol_type (sym->name, sym->type);
|
||||
sym = function_symbol (sym, 1, 1);
|
||||
}
|
||||
make_function (sym, nicename, current_storage);
|
||||
space = sym->table->space;
|
||||
if (far)
|
||||
space = pr.far_data;
|
||||
make_function (sym, nicename, space, current_storage);
|
||||
if (!sym->s.func->def->external) {
|
||||
sym->s.func->def->initialized = 1;
|
||||
sym->s.func->def->constant = 1;
|
||||
|
@ -575,9 +581,10 @@ build_code_function (symbol_t *fsym, expr_t *state_expr, expr_t *statements)
|
|||
}
|
||||
|
||||
function_t *
|
||||
build_builtin_function (symbol_t *sym, expr_t *bi_val)
|
||||
build_builtin_function (symbol_t *sym, expr_t *bi_val, int far)
|
||||
{
|
||||
int bi;
|
||||
defspace_t *space;
|
||||
|
||||
if (sym->sy_type != sy_func) {
|
||||
error (bi_val, "%s is not a function", sym->name);
|
||||
|
@ -591,7 +598,10 @@ build_builtin_function (symbol_t *sym, expr_t *bi_val)
|
|||
error (bi_val, "invalid constant for = #");
|
||||
return 0;
|
||||
}
|
||||
make_function (sym, 0, current_storage);
|
||||
space = sym->table->space;
|
||||
if (far)
|
||||
space = pr.far_data;
|
||||
make_function (sym, 0, space, current_storage);
|
||||
if (sym->s.func->def->external)
|
||||
return 0;
|
||||
|
||||
|
|
|
@ -175,7 +175,7 @@ method_symbol (class_type_t *class_type, method_t *method)
|
|||
//printf ("%s %s %s %ld\n", method->name, method->types, str->str,
|
||||
// str->size);
|
||||
sym = new_symbol_type (str->str, method->type);
|
||||
sym = function_symbol (sym, 0, 1);//FIXME put in far data and make static
|
||||
sym = function_symbol (sym, 0, 1);
|
||||
sym->params = method->params;
|
||||
dstring_delete (str);
|
||||
return sym;
|
||||
|
@ -265,7 +265,7 @@ send_message (int super)
|
|||
if (!sym) {
|
||||
sym = new_symbol_type (sm_name, sm_type);
|
||||
sym = function_symbol (sym, 0, 1);
|
||||
make_function (sym, 0, st_extern);
|
||||
make_function (sym, 0, sym->table->space, st_extern);
|
||||
}
|
||||
return new_symbol_expr (sym);
|
||||
}
|
||||
|
|
|
@ -331,7 +331,7 @@ function_body
|
|||
}
|
||||
{
|
||||
$<symtab>$ = current_symtab;
|
||||
current_func = begin_function ($<symbol>2, 0, current_symtab);
|
||||
current_func = begin_function ($<symbol>2, 0, current_symtab, 0);
|
||||
current_symtab = current_func->symtab;
|
||||
current_storage = st_local;
|
||||
}
|
||||
|
@ -348,7 +348,7 @@ function_body
|
|||
|
||||
sym->type = find_type (append_type (sym->type, $<spec>-1.type));
|
||||
sym = function_symbol (sym, $<spec>-1.is_overload, 1);
|
||||
build_builtin_function (sym, $3);
|
||||
build_builtin_function (sym, $3, 0);
|
||||
}
|
||||
;
|
||||
|
||||
|
@ -394,7 +394,7 @@ external_decl
|
|||
specifier_t spec = $<spec>0;
|
||||
$1->type = find_type (append_type ($1->type, spec.type));
|
||||
$1 = function_symbol ($1, spec.is_overload, 1);
|
||||
make_function ($1, 0, spec.storage);
|
||||
make_function ($1, 0, $1->table->space, spec.storage);
|
||||
}
|
||||
;
|
||||
|
||||
|
@ -833,11 +833,12 @@ overloaded_identifier
|
|||
non_code_func
|
||||
: '=' '#' fexpr
|
||||
{
|
||||
build_builtin_function ($<symbol>0, $3);
|
||||
build_builtin_function ($<symbol>0, $3, 0);
|
||||
}
|
||||
| /* emtpy */
|
||||
{
|
||||
make_function ($<symbol>0, 0, current_storage);
|
||||
symbol_t *sym = $<symbol>0;
|
||||
make_function (sym, 0, sym->table->space, current_storage);
|
||||
}
|
||||
;
|
||||
|
||||
|
@ -845,7 +846,7 @@ code_func
|
|||
: '=' optional_state_expr
|
||||
{
|
||||
$<symtab>$ = current_symtab;
|
||||
current_func = begin_function ($<symbol>0, 0, current_symtab);
|
||||
current_func = begin_function ($<symbol>0, 0, current_symtab, 0);
|
||||
current_symtab = current_func->symtab;
|
||||
current_storage = st_local;
|
||||
}
|
||||
|
@ -1492,7 +1493,7 @@ methoddef
|
|||
$<symtab>$ = current_symtab;
|
||||
|
||||
ivar_scope = class_ivar_scope (current_class, current_symtab);
|
||||
current_func = begin_function (sym, nicename, ivar_scope);
|
||||
current_func = begin_function (sym, nicename, ivar_scope, 1);
|
||||
class_finish_ivar_scope (current_class, ivar_scope,
|
||||
current_func->symtab);
|
||||
method->def = sym->s.func->def;
|
||||
|
@ -1514,7 +1515,7 @@ methoddef
|
|||
method->instance = $1;
|
||||
method = class_find_method (current_class, method);
|
||||
sym = method_symbol (current_class, method);
|
||||
build_builtin_function (sym, $5);
|
||||
build_builtin_function (sym, $5, 1);
|
||||
method->def = sym->s.func->def;
|
||||
}
|
||||
;
|
||||
|
|
|
@ -173,7 +173,7 @@ program
|
|||
symtab_removesymbol (current_symtab, $1);
|
||||
symtab_addsymbol (current_symtab, $1);
|
||||
|
||||
current_func = begin_function ($1, 0, current_symtab);
|
||||
current_func = begin_function ($1, 0, current_symtab, 0);
|
||||
current_symtab = current_func->symtab;
|
||||
build_code_function ($1, 0, $4);
|
||||
current_symtab = st;
|
||||
|
@ -183,7 +183,7 @@ program
|
|||
$1->params = 0;
|
||||
$1->type = parse_params (&type_void, 0);
|
||||
$1 = function_symbol ($1, 0, 1);
|
||||
current_func = begin_function ($1, 0, current_symtab);
|
||||
current_func = begin_function ($1, 0, current_symtab, 0);
|
||||
current_symtab = current_func->symtab;
|
||||
build_code_function ($1, 0, $4);
|
||||
current_symtab = st;
|
||||
|
@ -255,7 +255,7 @@ subprogram_declaration
|
|||
{
|
||||
$<storage>$ = current_storage;
|
||||
current_storage = st_local;
|
||||
current_func = begin_function ($1, 0, current_symtab);
|
||||
current_func = begin_function ($1, 0, current_symtab, 0);
|
||||
current_symtab = current_func->symtab;
|
||||
}
|
||||
declarations compound_statement ';'
|
||||
|
@ -266,7 +266,7 @@ subprogram_declaration
|
|||
}
|
||||
| subprogram_head ASSIGNOP '#' CONST ';'
|
||||
{
|
||||
build_builtin_function ($1, $4);
|
||||
build_builtin_function ($1, $4, 0);
|
||||
}
|
||||
;
|
||||
|
||||
|
|
Loading…
Reference in a new issue