1
0
mirror of https://github.com/golang/go synced 2024-11-26 18:06:55 -07:00

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
This commit is contained in:
Keith Randall 2013-07-19 11:19:18 -07:00
parent eb04df75cd
commit 6fc49c1854
19 changed files with 2412 additions and 1629 deletions

View File

@ -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:
*/ */
| 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);

File diff suppressed because it is too large Load Diff

View File

@ -1,14 +1,13 @@
/* 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
@ -16,9 +15,7 @@
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
@ -33,6 +30,7 @@
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 @@
#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;

View File

@ -36,15 +36,8 @@ gtext(Sym *s, int32 stkoff)
{ {
int32 a; int32 a;
a = 0;
if(!(textflag & NOSPLIT) || !hasdotdotdot()) {
a = argsize(); a = argsize();
// Change argsize 0 to 1 to be mark that if((textflag & NOSPLIT) != 0 && stkoff >= 128)
// 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));

View File

@ -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:
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);
} }

File diff suppressed because it is too large Load Diff

View File

@ -1,14 +1,13 @@
/* 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
@ -16,9 +15,7 @@
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
@ -33,6 +30,7 @@
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 @@
#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;

View File

@ -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");

View File

@ -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:
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;
} }

File diff suppressed because it is too large Load Diff

View File

@ -1,14 +1,13 @@
/* 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
@ -16,9 +15,7 @@
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
@ -33,6 +30,7 @@
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
@ -114,8 +112,11 @@
#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;
int32 lval; int32 lval;
struct { struct {
@ -126,14 +127,17 @@ typedef union YYSTYPE
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;

View File

@ -35,15 +35,8 @@ gtext(Sym *s, int32 stkoff)
{ {
int32 a; int32 a;
a = 0;
if(!(textflag & NOSPLIT) || !hasdotdotdot()) {
a = argsize(); a = argsize();
// Change argsize 0 to 1 to be mark that if((textflag & NOSPLIT) != 0 && stkoff >= 128)
// 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));

View File

@ -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)
case TVOID: case TVOID:
break; break;
case TDOT: case TDOT:
if((textflag & NOSPLIT) == 0)
yyerror("function takes ... without textflag NOSPLIT"); yyerror("function takes ... without textflag NOSPLIT");
s += 64; return ArgsSizeUnknown;
break;
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);

View File

@ -33,6 +33,7 @@
#include "lib.h" #include "lib.h"
#include "../ld/elf.h" #include "../ld/elf.h"
#include "../../pkg/runtime/stack.h" #include "../../pkg/runtime/stack.h"
#include "../../pkg/runtime/funcdata.h"
#include <ar.h> #include <ar.h>
@ -2414,13 +2415,9 @@ pclntab(void)
// args int32 // args int32
// TODO: Move into funcinfo. // TODO: Move into funcinfo.
if(cursym->text == nil || (cursym->text->textflag & NOSPLIT) && cursym->args == 0 && cursym->nptrs < 0) { if(cursym->text == nil)
// This might be a vararg function and have no
// predetermined argument size. This check is
// approximate and will also match 0 argument
// nosplit functions compiled by 6c.
off = setuint32(ftab, off, ArgsSizeUnknown); off = setuint32(ftab, off, ArgsSizeUnknown);
} else else
off = setuint32(ftab, off, cursym->args); off = setuint32(ftab, off, cursym->args);
// locals int32 // locals int32

View File

@ -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
{ {

View File

@ -11,3 +11,9 @@
// To be used in assembly. // To be used in assembly.
#define ARGSIZE(n) PCDATA $PCDATA_ArgSize, $n #define ARGSIZE(n) PCDATA $PCDATA_ArgSize, $n
// ArgsSizeUnknown is set in Func.argsize to mark all functions
// whose argument size is unknown (C vararg functions, and
// assembly code without an explicit specification).
// This value is generated by the compiler, assembler, or linker.
#define ArgsSizeUnknown 0x80000000

View File

@ -148,12 +148,6 @@ enum
// Global <-> per-M stack segment cache transfer batch size. // Global <-> per-M stack segment cache transfer batch size.
StackCacheBatch = 16, StackCacheBatch = 16,
}; };
enum
{
// This value is generated by the linker and should be kept in
// sync with cmd/ld/lib.h
ArgsSizeUnknown = 0x80000000,
};
/* /*
* structures * structures
*/ */

View File

@ -5,6 +5,7 @@
#include "runtime.h" #include "runtime.h"
#include "arch_GOARCH.h" #include "arch_GOARCH.h"
#include "malloc.h" #include "malloc.h"
#include "funcdata.h"
void runtime·sigpanic(void); void runtime·sigpanic(void);

View File

@ -7,6 +7,7 @@
#include "runtime.h" #include "runtime.h"
#include "arch_GOARCH.h" #include "arch_GOARCH.h"
#include "malloc.h" #include "malloc.h"
#include "funcdata.h"
void runtime·deferproc(void); void runtime·deferproc(void);
void runtime·newproc(void); void runtime·newproc(void);