Commit 6fc49c18 authored by Keith Randall's avatar Keith Randall

runtime: cleanup: use ArgsSizeUnknown to mark all functions

whose argument size is unknown (C vararg functions, and
assembly code without an explicit specification).

We used to use 0 to mean "unknown" and 1 to mean "zero".
Now we use ArgsSizeUnknown (0x80000000) to mean "unknown".

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/11590043
parent eb04df75
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
#include <stdio.h> /* if we don't, bison will, and a.h re-#defines getc */ #include <stdio.h> /* if we don't, bison will, and a.h re-#defines getc */
#include <libc.h> #include <libc.h>
#include "a.h" #include "a.h"
#include "../../pkg/runtime/funcdata.h"
%} %}
%union %union
{ {
...@@ -217,18 +218,18 @@ inst: ...@@ -217,18 +218,18 @@ inst:
*/ */
| LTYPEB name ',' imm | LTYPEB name ',' imm
{ {
$4.type = D_CONST2;
$4.offset2 = ArgsSizeUnknown;
outcode($1, Always, &$2, 0, &$4); outcode($1, Always, &$2, 0, &$4);
} }
| LTYPEB name ',' con ',' imm | LTYPEB name ',' con ',' imm
{ {
$6.type = D_CONST2;
$6.offset2 = ArgsSizeUnknown;
outcode($1, Always, &$2, $4, &$6); outcode($1, Always, &$2, $4, &$6);
} }
| LTYPEB name ',' con ',' imm '-' con | LTYPEB name ',' con ',' imm '-' con
{ {
// Change explicit 0 argument size to 1
// so that we can distinguish it from missing.
if($8 == 0)
$8 = 1;
$6.type = D_CONST2; $6.type = D_CONST2;
$6.offset2 = $8; $6.offset2 = $8;
outcode($1, Always, &$2, $4, &$6); outcode($1, Always, &$2, $4, &$6);
......
This diff is collapsed.
/* A Bison parser, made by GNU Bison 2.3. */ /* A Bison parser, made by GNU Bison 2.5. */
/* Skeleton interface for Bison's Yacc-like parsers in C /* Bison interface for Yacc-like parsers in C
Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 Copyright (C) 1984, 1989-1990, 2000-2011 Free Software Foundation, Inc.
Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option) the Free Software Foundation, either version 3 of the License, or
any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program. If not, see <http://www.gnu.org/licenses/>. */
Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA. */
/* As a special exception, you may create a larger work that contains /* As a special exception, you may create a larger work that contains
part or all of the Bison parser skeleton and distribute that work part or all of the Bison parser skeleton and distribute that work
...@@ -29,10 +26,11 @@ ...@@ -29,10 +26,11 @@
special exception, which will cause the skeleton and the resulting special exception, which will cause the skeleton and the resulting
Bison output files to be licensed under the GNU General Public Bison output files to be licensed under the GNU General Public
License without this special exception. License without this special exception.
This special exception was added by the Free Software Foundation in This special exception was added by the Free Software Foundation in
version 2.2 of Bison. */ version 2.2 of Bison. */
/* Tokens. */ /* Tokens. */
#ifndef YYTOKENTYPE #ifndef YYTOKENTYPE
# define YYTOKENTYPE # define YYTOKENTYPE
...@@ -144,21 +142,27 @@ ...@@ -144,21 +142,27 @@
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
typedef union YYSTYPE typedef union YYSTYPE
#line 38 "a.y"
{ {
/* Line 2068 of yacc.c */
#line 39 "a.y"
Sym *sym; Sym *sym;
int32 lval; int32 lval;
double dval; double dval;
char sval[8]; char sval[8];
Gen gen; Gen gen;
}
/* Line 1529 of yacc.c. */
#line 157 "y.tab.h"
YYSTYPE; /* Line 2068 of yacc.c */
#line 160 "y.tab.h"
} YYSTYPE;
# define YYSTYPE_IS_TRIVIAL 1
# define yystype YYSTYPE /* obsolescent; will be withdrawn */ # define yystype YYSTYPE /* obsolescent; will be withdrawn */
# define YYSTYPE_IS_DECLARED 1 # define YYSTYPE_IS_DECLARED 1
# define YYSTYPE_IS_TRIVIAL 1
#endif #endif
extern YYSTYPE yylval; extern YYSTYPE yylval;
...@@ -35,16 +35,9 @@ Prog* ...@@ -35,16 +35,9 @@ Prog*
gtext(Sym *s, int32 stkoff) gtext(Sym *s, int32 stkoff)
{ {
int32 a; int32 a;
a = 0; a = argsize();
if(!(textflag & NOSPLIT) || !hasdotdotdot()) { if((textflag & NOSPLIT) != 0 && stkoff >= 128)
a = argsize();
// Change argsize 0 to 1 to be mark that
// the argument size is present.
if(a == 0)
a = 1;
}
else if(stkoff >= 128)
yyerror("stack frame too large for NOSPLIT function"); yyerror("stack frame too large for NOSPLIT function");
gpseudo(ATEXT, s, nodconst(stkoff)); gpseudo(ATEXT, s, nodconst(stkoff));
......
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
#include <stdio.h> /* if we don't, bison will, and a.h re-#defines getc */ #include <stdio.h> /* if we don't, bison will, and a.h re-#defines getc */
#include <libc.h> #include <libc.h>
#include "a.h" #include "a.h"
#include "../../pkg/runtime/funcdata.h"
%} %}
%union { %union {
Sym *sym; Sym *sym;
...@@ -620,27 +621,21 @@ con: ...@@ -620,27 +621,21 @@ con:
con2: con2:
LCONST LCONST
{ {
$$ = $1 & 0xffffffffLL; $$ = ($1 & 0xffffffffLL) +
((vlong)ArgsSizeUnknown << 32);
} }
| '-' LCONST | '-' LCONST
{ {
$$ = -$2 & 0xffffffffLL; $$ = (-$2 & 0xffffffffLL) +
((vlong)ArgsSizeUnknown << 32);
} }
| LCONST '-' LCONST | LCONST '-' LCONST
{ {
// Change explicit 0 argument size to 1
// so that we can distinguish it from missing.
if($3 == 0)
$3 = 1;
$$ = ($1 & 0xffffffffLL) + $$ = ($1 & 0xffffffffLL) +
(($3 & 0xffffLL) << 32); (($3 & 0xffffLL) << 32);
} }
| '-' LCONST '-' LCONST | '-' LCONST '-' LCONST
{ {
// Change explicit 0 argument size to 1
// so that we can distinguish it from missing.
if($4 == 0)
$4 = 1;
$$ = (-$2 & 0xffffffffLL) + $$ = (-$2 & 0xffffffffLL) +
(($4 & 0xffffLL) << 32); (($4 & 0xffffLL) << 32);
} }
......
This diff is collapsed.
/* A Bison parser, made by GNU Bison 2.3. */ /* A Bison parser, made by GNU Bison 2.5. */
/* Skeleton interface for Bison's Yacc-like parsers in C /* Bison interface for Yacc-like parsers in C
Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 Copyright (C) 1984, 1989-1990, 2000-2011 Free Software Foundation, Inc.
Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option) the Free Software Foundation, either version 3 of the License, or
any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program. If not, see <http://www.gnu.org/licenses/>. */
Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA. */
/* As a special exception, you may create a larger work that contains /* As a special exception, you may create a larger work that contains
part or all of the Bison parser skeleton and distribute that work part or all of the Bison parser skeleton and distribute that work
...@@ -29,10 +26,11 @@ ...@@ -29,10 +26,11 @@
special exception, which will cause the skeleton and the resulting special exception, which will cause the skeleton and the resulting
Bison output files to be licensed under the GNU General Public Bison output files to be licensed under the GNU General Public
License without this special exception. License without this special exception.
This special exception was added by the Free Software Foundation in This special exception was added by the Free Software Foundation in
version 2.2 of Bison. */ version 2.2 of Bison. */
/* Tokens. */ /* Tokens. */
#ifndef YYTOKENTYPE #ifndef YYTOKENTYPE
# define YYTOKENTYPE # define YYTOKENTYPE
...@@ -118,22 +116,28 @@ ...@@ -118,22 +116,28 @@
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
typedef union YYSTYPE typedef union YYSTYPE
#line 37 "a.y"
{ {
/* Line 2068 of yacc.c */
#line 38 "a.y"
Sym *sym; Sym *sym;
vlong lval; vlong lval;
double dval; double dval;
char sval[8]; char sval[8];
Gen gen; Gen gen;
Gen2 gen2; Gen2 gen2;
}
/* Line 1529 of yacc.c. */
#line 132 "y.tab.h"
YYSTYPE; /* Line 2068 of yacc.c */
#line 135 "y.tab.h"
} YYSTYPE;
# define YYSTYPE_IS_TRIVIAL 1
# define yystype YYSTYPE /* obsolescent; will be withdrawn */ # define yystype YYSTYPE /* obsolescent; will be withdrawn */
# define YYSTYPE_IS_DECLARED 1 # define YYSTYPE_IS_DECLARED 1
# define YYSTYPE_IS_TRIVIAL 1
#endif #endif
extern YYSTYPE yylval; extern YYSTYPE yylval;
...@@ -36,16 +36,7 @@ gtext(Sym *s, int32 stkoff) ...@@ -36,16 +36,7 @@ gtext(Sym *s, int32 stkoff)
{ {
vlong v; vlong v;
v = 0; v = (argsize() << 32) | (stkoff & 0xffffffff);
if(!(textflag & NOSPLIT) || !hasdotdotdot()) {
v = argsize();
// Change argsize 0 to 1 to be mark that
// the argument size is present.
if(v == 0)
v = 1;
v <<= 32;
}
v |= stkoff & 0xffffffff;
if((textflag & NOSPLIT) && stkoff >= 128) if((textflag & NOSPLIT) && stkoff >= 128)
yyerror("stack frame too large for NOSPLIT function"); yyerror("stack frame too large for NOSPLIT function");
......
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
#include <stdio.h> /* if we don't, bison will, and a.h re-#defines getc */ #include <stdio.h> /* if we don't, bison will, and a.h re-#defines getc */
#include <libc.h> #include <libc.h>
#include "a.h" #include "a.h"
#include "../../pkg/runtime/funcdata.h"
%} %}
%union { %union {
Sym *sym; Sym *sym;
...@@ -470,28 +471,20 @@ con2: ...@@ -470,28 +471,20 @@ con2:
LCONST LCONST
{ {
$$.v1 = $1; $$.v1 = $1;
$$.v2 = 0; $$.v2 = ArgsSizeUnknown;
} }
| '-' LCONST | '-' LCONST
{ {
$$.v1 = -$2; $$.v1 = -$2;
$$.v2 = 0; $$.v2 = ArgsSizeUnknown;
} }
| LCONST '-' LCONST | LCONST '-' LCONST
{ {
// Change explicit 0 argument size to 1
// so that we can distinguish it from missing.
if($3 == 0)
$3 = 1;
$$.v1 = $1; $$.v1 = $1;
$$.v2 = $3; $$.v2 = $3;
} }
| '-' LCONST '-' LCONST | '-' LCONST '-' LCONST
{ {
// Change explicit 0 argument size to 1
// so that we can distinguish it from missing.
if($4 == 0)
$4 = 1;
$$.v1 = -$2; $$.v1 = -$2;
$$.v2 = $4; $$.v2 = $4;
} }
......
This diff is collapsed.
This diff is collapsed.
...@@ -35,15 +35,8 @@ gtext(Sym *s, int32 stkoff) ...@@ -35,15 +35,8 @@ gtext(Sym *s, int32 stkoff)
{ {
int32 a; int32 a;
a = 0; a = argsize();
if(!(textflag & NOSPLIT) || !hasdotdotdot()) { if((textflag & NOSPLIT) != 0 && stkoff >= 128)
a = argsize();
// Change argsize 0 to 1 to be mark that
// the argument size is present.
if(a == 0)
a = 1;
}
else if(stkoff >= 128)
yyerror("stack frame too large for NOSPLIT function"); yyerror("stack frame too large for NOSPLIT function");
gpseudo(ATEXT, s, nodconst(stkoff)); gpseudo(ATEXT, s, nodconst(stkoff));
......
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
// THE SOFTWARE. // THE SOFTWARE.
#include "gc.h" #include "gc.h"
#include "../../pkg/runtime/funcdata.h"
int int
hasdotdotdot(void) hasdotdotdot(void)
...@@ -54,9 +55,9 @@ argsize(void) ...@@ -54,9 +55,9 @@ argsize(void)
case TVOID: case TVOID:
break; break;
case TDOT: case TDOT:
yyerror("function takes ... without textflag NOSPLIT"); if((textflag & NOSPLIT) == 0)
s += 64; yyerror("function takes ... without textflag NOSPLIT");
break; return ArgsSizeUnknown;
default: default:
s = align(s, t, Aarg1, nil); s = align(s, t, Aarg1, nil);
s = align(s, t, Aarg2, nil); s = align(s, t, Aarg2, nil);
......
This diff is collapsed.
...@@ -81,13 +81,6 @@ enum ...@@ -81,13 +81,6 @@ enum
NHASH = 100003, NHASH = 100003,
}; };
enum
{
// This value is known to the garbage collector and should be kept in
// sync with runtime/pkg/runtime.h
ArgsSizeUnknown = 0x80000000
};
typedef struct Library Library; typedef struct Library Library;
struct Library struct Library
{ {
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment