Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure that the jump buffer is appropriately aligned. #86

Open
wants to merge 1 commit into
base: 59-memory-aware
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions code/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,16 @@
#define ATTRIBUTE_UNUSED
#endif

/* Attribute for data structures that need to be allocated at
* addresses with a particular alignment.
* GCC: <https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-aligned-function-attribute>
*/
#if defined(MPS_BUILD_GC) || defined(MPS_BUILD_LL)
#define ATTRIBUTE_ALIGNED(ALIGNMENT) __attribute__((__aligned__(ALIGNMENT)))
#else
#define ATTRIBUTE_ALIGNED(ALIGNMENT)
#endif


/* Compiler extensions */

Expand Down
10 changes: 9 additions & 1 deletion code/ss.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,20 @@
* The jumpBuffer is used to capture most of the mutator's state on
* entry to the MPS, but can't capture it all. See
* <design/stack-scan#.sol.setjmp.scan>.
*
* The stack capturing mechanism in STACK_CONTEXT_BEGIN puts the
* StackContextStruct on the stack, where it will later be scanned
* using TraceScanArea. The jumpBuffer must be allocated on the stack
* at an address with suitable alignment so that TraceScanArea will
* correctly fix any addresses therein. This is vital on platform XCA6
* where jmp_buf is declared as an array of int, which has 4-byte
* alignment, but we need it to have 8-byte alignment.
*/

#include <setjmp.h>

typedef struct StackContextStruct {
jmp_buf jumpBuffer;
ATTRIBUTE_ALIGNED(MPS_PF_ALIGN) jmp_buf jumpBuffer;
} StackContextStruct;


Expand Down