Remove additional function pointers that never change

Remove additional cached function pointers which point to static
variables which are never actually changed.  Just refer to the global
variable instead.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
This commit is contained in:
H. Peter Anvin 2016-02-18 01:25:46 -08:00
parent 36034ec652
commit cd7893d02d
6 changed files with 12 additions and 35 deletions

22
eval.c
View file

@ -1,6 +1,6 @@
/* ----------------------------------------------------------------------- *
*
* Copyright 1996-2012 The NASM Authors - All Rights Reserved
* Copyright 1996-2016 The NASM Authors - All Rights Reserved
* See the file AUTHORS included with the NASM distribution for
* the specific copyright holders.
*
@ -54,7 +54,6 @@
#define TEMPEXPR_DELTA 8
static scanner scan; /* Address of scanner routine */
static lfunc labelfunc; /* Address of label routine */
static expr **tempexprs = NULL;
static int ntempexprs;
@ -68,7 +67,6 @@ static struct tokenval *tokval; /* The current token */
static int i; /* The t_type of tokval */
static void *scpriv;
static struct location *location; /* Pointer to current line's segment,offset */
static int *opflags;
static struct eval_hints *hint;
@ -890,11 +888,11 @@ static expr *expr6(int critical)
case TOKEN_HERE:
case TOKEN_BASE:
/*
* If !location->known, this indicates that no
* If !location.known, this indicates that no
* symbol, Here or Base references are valid because we
* are in preprocess-only mode.
*/
if (!location->known) {
if (!location.known) {
nasm_error(ERR_NONFATAL,
"%s not supported in preprocess-only mode",
(i == TOKEN_HERE ? "`$'" :
@ -906,13 +904,13 @@ static expr *expr6(int critical)
type = EXPR_SIMPLE; /* might get overridden by UNKNOWN */
if (i == TOKEN_BASE) {
label_seg = in_abs_seg ? abs_seg : location->segment;
label_seg = in_abs_seg ? abs_seg : location.segment;
label_ofs = 0;
} else if (i == TOKEN_HERE) {
label_seg = in_abs_seg ? abs_seg : location->segment;
label_ofs = in_abs_seg ? abs_offset : location->offset;
label_seg = in_abs_seg ? abs_seg : location.segment;
label_ofs = in_abs_seg ? abs_offset : location.offset;
} else {
if (!labelfunc(tokval->t_charptr, &label_seg, &label_ofs)) {
if (!lookup_label(tokval->t_charptr, &label_seg, &label_ofs)) {
scope = local_scope(tokval->t_charptr);
if (critical == 2) {
nasm_error(ERR_NONFATAL, "symbol `%s%s' undefined",
@ -951,12 +949,6 @@ static expr *expr6(int critical)
}
}
void eval_global_info(lfunc lookup_label, struct location * locp)
{
labelfunc = lookup_label;
location = locp;
}
expr *evaluate(scanner sc, void *scprivate, struct tokenval *tv,
int *fwref, int critical, struct eval_hints *hints)
{

7
eval.h
View file

@ -38,13 +38,6 @@
#ifndef NASM_EVAL_H
#define NASM_EVAL_H
/*
* Called once to tell the evaluator what output format is
* providing segment-base details, and what function can be used to
* look labels up.
*/
void eval_global_info(lfunc lookup_label, struct location * locp);
/*
* The evaluator itself.
*/

4
nasm.c
View file

@ -116,7 +116,7 @@ int64_t global_offset_changed; /* referenced in labels.c */
int64_t prev_offset_changed;
int32_t stall_count;
static struct location location;
struct location location;
int in_abs_seg; /* Flag we are in ABSOLUTE seg */
int32_t abs_seg; /* ABSOLUTE segment basis */
int32_t abs_offset; /* ABSOLUTE offset */
@ -364,8 +364,6 @@ int main(int argc, char **argv)
if (ofmt->stdmac)
preproc->extra_stdmac(ofmt->stdmac);
parser_global_info(&location);
eval_global_info(ofmt, lookup_label, &location);
/* define some macros dependent of command-line */
define_macros_late();

1
nasm.h
View file

@ -220,6 +220,7 @@ struct location {
int32_t segment;
int known;
};
extern struct location location;
/*
* Expression-evaluator datatype. Expressions, within the

View file

@ -61,12 +61,6 @@ static int is_comma_next(void);
static int i;
static struct tokenval tokval;
static struct location *location; /* Pointer to current line's segment,offset */
void parser_global_info(struct location * locp)
{
location = locp;
}
static int prefix_slot(int prefix)
{
@ -431,14 +425,14 @@ restart_parse:
}
if (i != TOKEN_INSN || tokval.t_integer != I_EQU) {
/*
* FIXME: location->segment could be NO_SEG, in which case
* FIXME: location.segment could be NO_SEG, in which case
* it is possible we should be passing 'abs_seg'. Look into this.
* Work out whether that is *really* what we should be doing.
* Generally fix things. I think this is right as it is, but
* am still not certain.
*/
ldef(result->label, in_abs_seg ? abs_seg : location->segment,
location->offset, NULL, true, false);
ldef(result->label, in_abs_seg ? abs_seg : location.segment,
location.offset, NULL, true, false);
}
}

View file

@ -39,7 +39,6 @@
#ifndef NASM_PARSER_H
#define NASM_PARSER_H
void parser_global_info(struct location *locp);
insn *parse_line(int pass, char *buffer, insn *result, ldfunc ldef);
void cleanup_insn(insn *instruction);