2016-03-01 15:57:46 -07:00
|
|
|
// Copyright 2013 The Go Authors. All rights reserved.
|
2013-08-07 11:23:24 -06:00
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
// This file defines flags attached to various functions
|
2016-03-01 16:21:55 -07:00
|
|
|
// and data objects. The compilers, assemblers, and linker must
|
2013-08-07 11:23:24 -06:00
|
|
|
// all agree on these values.
|
2016-03-10 14:15:26 -07:00
|
|
|
//
|
|
|
|
// Keep in sync with src/cmd/internal/obj/textflag.go.
|
2013-08-07 11:23:24 -06:00
|
|
|
|
2016-03-01 16:21:55 -07:00
|
|
|
// Don't profile the marked routine. This flag is deprecated.
|
2013-08-29 13:36:59 -06:00
|
|
|
#define NOPROF 1
|
2016-03-01 16:21:55 -07:00
|
|
|
// It is ok for the linker to get multiple of these symbols. It will
|
2013-08-07 11:23:24 -06:00
|
|
|
// pick one of the duplicates to use.
|
2013-08-29 13:36:59 -06:00
|
|
|
#define DUPOK 2
|
2013-08-07 11:23:24 -06:00
|
|
|
// Don't insert stack check preamble.
|
2013-08-29 13:36:59 -06:00
|
|
|
#define NOSPLIT 4
|
2013-08-07 11:23:24 -06:00
|
|
|
// Put this data in a read-only section.
|
2013-08-29 13:36:59 -06:00
|
|
|
#define RODATA 8
|
2013-08-07 11:23:24 -06:00
|
|
|
// This data contains no pointers.
|
2013-08-29 13:36:59 -06:00
|
|
|
#define NOPTR 16
|
runtime, cmd/gc, cmd/ld: ignore method wrappers in recover
Bug #1:
Issue 5406 identified an interesting case:
defer iface.M()
may end up calling a wrapper that copies an indirect receiver
from the iface value and then calls the real M method. That's
two calls down, not just one, and so recover() == nil always
in the real M method, even during a panic.
[For the purposes of this entire discussion, a wrapper's
implementation is a function containing an ordinary call, not
the optimized tail call form that is somtimes possible. The
tail call does not create a second frame, so it is already
handled correctly.]
Fix this bug by introducing g->panicwrap, which counts the
number of bytes on current stack segment that are due to
wrapper calls that should not count against the recover
check. All wrapper functions must now adjust g->panicwrap up
on entry and back down on exit. This adds slightly to their
expense; on the x86 it is a single instruction at entry and
exit; on the ARM it is three. However, the alternative is to
make a call to recover depend on being able to walk the stack,
which I very much want to avoid. We have enough problems
walking the stack for garbage collection and profiling.
Also, if performance is critical in a specific case, it is already
faster to use a pointer receiver and avoid this kind of wrapper
entirely.
Bug #2:
The old code, which did not consider the possibility of two
calls, already contained a check to see if the call had split
its stack and so the panic-created segment was one behind the
current segment. In the wrapper case, both of the two calls
might split their stacks, so the panic-created segment can be
two behind the current segment.
Fix this by propagating the Stktop.panic flag forward during
stack splits instead of looking backward during recover.
Fixes #5406.
R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/13367052
2013-09-12 12:00:16 -06:00
|
|
|
// This is a wrapper function and should not count as disabling 'recover'.
|
|
|
|
#define WRAPPER 32
|
2014-03-04 11:53:08 -07:00
|
|
|
// This function uses its incoming context register.
|
|
|
|
#define NEEDCTXT 64
|
2015-08-10 18:29:00 -06:00
|
|
|
// Allocate a word of thread local storage and store the offset from the
|
|
|
|
// thread local base to the thread local storage in this variable.
|
|
|
|
#define TLSBSS 256
|
2015-10-08 17:44:27 -06:00
|
|
|
// Do not insert instructions to allocate a stack frame for this function.
|
|
|
|
// Only valid on functions that declare a frame size of 0.
|
|
|
|
// TODO(mwhudson): only implemented for ppc64x at present.
|
|
|
|
#define NOFRAME 512
|
2016-03-10 14:15:26 -07:00
|
|
|
// Function can call reflect.Type.Method or reflect.Type.MethodByName.
|
|
|
|
#define REFLECTMETHOD = 1024
|