[COMPILER]
* OPT: Write in the bytecode file if a function uses the IsMissing() native routine. [INTERPRETER] * OPT: Don't use a stack slot for missing arguments if the IsMissing() function is not used. git-svn-id: svn://localhost/gambas/trunk@6274 867c0c6c-44f3-4631-809d-bfa615b0a4ec
This commit is contained in:
parent
16bdab0b55
commit
337e7c9329
@ -92,7 +92,8 @@ typedef
|
||||
char npmin; // Minimum number of arguments
|
||||
unsigned vararg : 1; // If this function accepts extra arguments
|
||||
unsigned fast : 1; // If this function is jit compiled
|
||||
unsigned _reserved : 14;
|
||||
unsigned use_is_missing : 1; // If this function uses IsMissing()
|
||||
unsigned _reserved : 13;
|
||||
short nlocal; // Local variable count
|
||||
short nctrl; // Control structure variable count
|
||||
|
||||
|
@ -800,6 +800,7 @@ static void output_method(void)
|
||||
{
|
||||
int i, n;
|
||||
FUNCTION *func;
|
||||
uchar flag;
|
||||
/*SYMBOL *sym;*/
|
||||
|
||||
n = ARRAY_count(Class->function);
|
||||
@ -814,7 +815,13 @@ static void output_method(void)
|
||||
write_byte(func->nparam);
|
||||
write_byte(func->npmin);
|
||||
write_byte(func->vararg);
|
||||
write_byte(func->fast || Class->all_fast);
|
||||
|
||||
flag = func->fast || Class->all_fast;
|
||||
if (func->use_is_missing)
|
||||
flag += 2;
|
||||
|
||||
write_byte(flag);
|
||||
|
||||
write_short(func->nlocal);
|
||||
write_short(func->nctrl);
|
||||
write_short(func->stack);
|
||||
|
@ -271,6 +271,7 @@ static void trans_subr(int subr, short nparam)
|
||||
}
|
||||
else if (subr == SUBR_IsMissing)
|
||||
{
|
||||
JOB->func->use_is_missing = TRUE;
|
||||
if (CODE_check_ismissing())
|
||||
THROW("IsMissing() requires a function argument");
|
||||
}
|
||||
|
@ -101,7 +101,8 @@ typedef
|
||||
char vararg;
|
||||
unsigned fast : 1;
|
||||
unsigned optional : 1;
|
||||
unsigned _reserved : 6;
|
||||
unsigned use_is_missing : 1;
|
||||
unsigned _reserved : 5;
|
||||
short n_local;
|
||||
short n_ctrl;
|
||||
short stack_usage;
|
||||
@ -114,6 +115,17 @@ typedef
|
||||
PACKED
|
||||
FUNCTION;
|
||||
|
||||
typedef
|
||||
struct {
|
||||
TYPE type;
|
||||
char n_param;
|
||||
char npmin;
|
||||
char vararg;
|
||||
unsigned char flag;
|
||||
}
|
||||
PACKED
|
||||
FUNCTION_FLAG;
|
||||
|
||||
typedef
|
||||
struct {
|
||||
TYPE type;
|
||||
|
@ -496,6 +496,7 @@ static void load_and_relocate(CLASS *class, int len_data, CLASS_DESC **pstart, i
|
||||
char *name;
|
||||
int len;
|
||||
bool have_jit_functions = FALSE;
|
||||
uchar flag;
|
||||
|
||||
ALLOC_ZERO(&class->load, sizeof(CLASS_LOAD));
|
||||
|
||||
@ -576,6 +577,13 @@ static void load_and_relocate(CLASS *class, int len_data, CLASS_DESC **pstart, i
|
||||
{
|
||||
func = &class->load->func[i];
|
||||
func->code = (ushort *)get_section("code", §ion, NULL, _s);
|
||||
|
||||
flag = ((FUNCTION_FLAG *)func)->flag;
|
||||
|
||||
func->fast = (flag & 1) != 0;
|
||||
func->optional = (func->npmin < func->n_param);
|
||||
func->use_is_missing = (flag & 2) != 0;
|
||||
|
||||
if (func->fast)
|
||||
{
|
||||
func->fast = JIT_load();
|
||||
@ -583,8 +591,7 @@ static void load_and_relocate(CLASS *class, int len_data, CLASS_DESC **pstart, i
|
||||
have_jit_functions = TRUE;
|
||||
}
|
||||
|
||||
func->optional = (func->npmin < func->n_param);
|
||||
if (func->optional)
|
||||
if (func->use_is_missing)
|
||||
{
|
||||
func->stack_usage++;
|
||||
func->n_ctrl++;
|
||||
|
@ -109,7 +109,7 @@ typedef
|
||||
char n_param;
|
||||
char npmin;
|
||||
char vararg;
|
||||
char _reserved;
|
||||
char flag;
|
||||
short n_local;
|
||||
short n_ctrl;
|
||||
short stack_usage;
|
||||
|
@ -542,7 +542,7 @@ void EXEC_enter(void)
|
||||
}
|
||||
|
||||
// Optional argument map
|
||||
if (optional)
|
||||
if (optional && func->use_is_missing)
|
||||
{
|
||||
SP--;
|
||||
SP->type = T_LONG;
|
||||
|
Loading…
x
Reference in New Issue
Block a user