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 @@
#include <stdio.h> /* if we don't, bison will, and a.h re-#defines getc */
#include <libc.h>
#include "a.h"
#include "../../pkg/runtime/funcdata.h"
%}
%union
{
......@@ -217,18 +218,18 @@ inst:
*/
| LTYPEB name ',' imm
{
$4.type = D_CONST2;
$4.offset2 = ArgsSizeUnknown;
outcode($1, Always, &$2, 0, &$4);
}
| LTYPEB name ',' con ',' imm
{
$6.type = D_CONST2;
$6.offset2 = ArgsSizeUnknown;
outcode($1, Always, &$2, $4, &$6);
}
| 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.offset2 = $8;
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
Free Software Foundation, Inc.
Copyright (C) 1984, 1989-1990, 2000-2011 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
the Free Software Foundation; either version 2, or (at your option)
any later version.
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
......@@ -16,9 +15,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA. */
along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* As a special exception, you may create a larger work that contains
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
version 2.2 of Bison. */
/* Tokens. */
#ifndef YYTOKENTYPE
# define YYTOKENTYPE
......@@ -144,21 +142,27 @@
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
typedef union YYSTYPE
#line 38 "a.y"
{
/* Line 2068 of yacc.c */
#line 39 "a.y"
Sym *sym;
int32 lval;
double dval;
char sval[8];
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_IS_DECLARED 1
# define YYSTYPE_IS_TRIVIAL 1
#endif
extern YYSTYPE yylval;
......@@ -36,15 +36,8 @@ gtext(Sym *s, int32 stkoff)
{
int32 a;
a = 0;
if(!(textflag & NOSPLIT) || !hasdotdotdot()) {
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)
if((textflag & NOSPLIT) != 0 && stkoff >= 128)
yyerror("stack frame too large for NOSPLIT function");
gpseudo(ATEXT, s, nodconst(stkoff));
......
......@@ -33,6 +33,7 @@
#include <stdio.h> /* if we don't, bison will, and a.h re-#defines getc */
#include <libc.h>
#include "a.h"
#include "../../pkg/runtime/funcdata.h"
%}
%union {
Sym *sym;
......@@ -620,27 +621,21 @@ con:
con2:
LCONST
{
$$ = $1 & 0xffffffffLL;
$$ = ($1 & 0xffffffffLL) +
((vlong)ArgsSizeUnknown << 32);
}
| '-' LCONST
{
$$ = -$2 & 0xffffffffLL;
$$ = (-$2 & 0xffffffffLL) +
((vlong)ArgsSizeUnknown << 32);
}
| LCONST '-' LCONST
{
// Change explicit 0 argument size to 1
// so that we can distinguish it from missing.
if($3 == 0)
$3 = 1;
$$ = ($1 & 0xffffffffLL) +
(($3 & 0xffffLL) << 32);
}
| '-' LCONST '-' LCONST
{
// Change explicit 0 argument size to 1
// so that we can distinguish it from missing.
if($4 == 0)
$4 = 1;
$$ = (-$2 & 0xffffffffLL) +
(($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
Free Software Foundation, Inc.
Copyright (C) 1984, 1989-1990, 2000-2011 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
the Free Software Foundation; either version 2, or (at your option)
any later version.
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
......@@ -16,9 +15,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA. */
along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* As a special exception, you may create a larger work that contains
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
version 2.2 of Bison. */
/* Tokens. */
#ifndef YYTOKENTYPE
# define YYTOKENTYPE
......@@ -118,22 +116,28 @@
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
typedef union YYSTYPE
#line 37 "a.y"
{
/* Line 2068 of yacc.c */
#line 38 "a.y"
Sym *sym;
vlong lval;
double dval;
char sval[8];
Gen gen;
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_IS_DECLARED 1
# define YYSTYPE_IS_TRIVIAL 1
#endif
extern YYSTYPE yylval;
......@@ -36,16 +36,7 @@ gtext(Sym *s, int32 stkoff)
{
vlong v;
v = 0;
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;
v = (argsize() << 32) | (stkoff & 0xffffffff);
if((textflag & NOSPLIT) && stkoff >= 128)
yyerror("stack frame too large for NOSPLIT function");
......
......@@ -33,6 +33,7 @@
#include <stdio.h> /* if we don't, bison will, and a.h re-#defines getc */
#include <libc.h>
#include "a.h"
#include "../../pkg/runtime/funcdata.h"
%}
%union {
Sym *sym;
......@@ -470,28 +471,20 @@ con2:
LCONST
{
$$.v1 = $1;
$$.v2 = 0;
$$.v2 = ArgsSizeUnknown;
}
| '-' LCONST
{
$$.v1 = -$2;
$$.v2 = 0;
$$.v2 = ArgsSizeUnknown;
}
| LCONST '-' LCONST
{
// Change explicit 0 argument size to 1
// so that we can distinguish it from missing.
if($3 == 0)
$3 = 1;
$$.v1 = $1;
$$.v2 = $3;
}
| '-' LCONST '-' LCONST
{
// Change explicit 0 argument size to 1
// so that we can distinguish it from missing.
if($4 == 0)
$4 = 1;
$$.v1 = -$2;
$$.v2 = $4;
}
......
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
Free Software Foundation, Inc.
Copyright (C) 1984, 1989-1990, 2000-2011 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
the Free Software Foundation; either version 2, or (at your option)
any later version.
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
......@@ -16,9 +15,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA. */
along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* As a special exception, you may create a larger work that contains
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
version 2.2 of Bison. */
/* Tokens. */
#ifndef YYTOKENTYPE
# define YYTOKENTYPE
......@@ -114,8 +112,11 @@
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
typedef union YYSTYPE
#line 37 "a.y"
{
/* Line 2068 of yacc.c */
#line 38 "a.y"
Sym *sym;
int32 lval;
struct {
......@@ -126,14 +127,17 @@ typedef union YYSTYPE
char sval[8];
Gen gen;
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_IS_DECLARED 1
# define YYSTYPE_IS_TRIVIAL 1
#endif
extern YYSTYPE yylval;
......@@ -35,15 +35,8 @@ gtext(Sym *s, int32 stkoff)
{
int32 a;
a = 0;
if(!(textflag & NOSPLIT) || !hasdotdotdot()) {
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)
if((textflag & NOSPLIT) != 0 && stkoff >= 128)
yyerror("stack frame too large for NOSPLIT function");
gpseudo(ATEXT, s, nodconst(stkoff));
......
......@@ -29,6 +29,7 @@
// THE SOFTWARE.
#include "gc.h"
#include "../../pkg/runtime/funcdata.h"
int
hasdotdotdot(void)
......@@ -54,9 +55,9 @@ argsize(void)
case TVOID:
break;
case TDOT:
if((textflag & NOSPLIT) == 0)
yyerror("function takes ... without textflag NOSPLIT");
s += 64;
break;
return ArgsSizeUnknown;
default:
s = align(s, t, Aarg1, nil);
s = align(s, t, Aarg2, nil);
......
......@@ -33,6 +33,7 @@
#include "lib.h"
#include "../ld/elf.h"
#include "../../pkg/runtime/stack.h"
#include "../../pkg/runtime/funcdata.h"
#include <ar.h>
......@@ -2414,13 +2415,9 @@ pclntab(void)
// args int32
// TODO: Move into funcinfo.
if(cursym->text == nil || (cursym->text->textflag & NOSPLIT) && cursym->args == 0 && cursym->nptrs < 0) {
// 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.
if(cursym->text == nil)
off = setuint32(ftab, off, ArgsSizeUnknown);
} else
else
off = setuint32(ftab, off, cursym->args);
// locals int32
......
......@@ -81,13 +81,6 @@ enum
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;
struct Library
{
......
......@@ -11,3 +11,9 @@
// To be used in assembly.
#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
......@@ -148,12 +148,6 @@ enum
// Global <-> per-M stack segment cache transfer batch size.
StackCacheBatch = 16,
};
enum
{
// This value is generated by the linker and should be kept in
// sync with cmd/ld/lib.h
ArgsSizeUnknown = 0x80000000,
};
/*
* structures
*/
......
......@@ -5,6 +5,7 @@
#include "runtime.h"
#include "arch_GOARCH.h"
#include "malloc.h"
#include "funcdata.h"
void runtime·sigpanic(void);
......
......@@ -7,6 +7,7 @@
#include "runtime.h"
#include "arch_GOARCH.h"
#include "malloc.h"
#include "funcdata.h"
void runtime·deferproc(void);
void runtime·newproc(void);
......
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