tlds
Transactional Operations for Linked Data Structures
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
StackProtection.h
Go to the documentation of this file.
1 /**
2  * Copyright (C) 2011
3  * University of Rochester Department of Computer Science
4  * and
5  * Lehigh University Department of Computer Science and Engineering
6  *
7  * License: Modified BSD
8  * Please see the file LICENSE.RSTM for licensing information
9  */
10 
11 #ifndef STM_ITM2STM_ARCH_X86_64_STACK_PROTECTION_H
12 #define STM_ITM2STM_ARCH_X86_64_STACK_PROTECTION_H
13 
14 // From x86_64.org's "http://www.x86-64.org/documentation/abi-0.99.pdf"
15 //
16 // Passing Once arguments are classified, the registers get assigned (in
17 // left-to-right order) for passing as follows:
18 //
19 // 1. If the class is MEMORY, pass the argument on the stack.
20 // 2. If the class is INTEGER, the next available register of the sequence %rdi,
21 // %rsi, %rdx, %rcx, %r8 and %r9 is used.
22 // 3. If the class is SSE, the next available vector register is used, the
23 // registers are taken in the order from %xmm0 to %xmm7.
24 // 4. If the class is SSEUP, the eightbyte is passed in the next available
25 // eightbyte chunk of the last used vector register.
26 // 5. If the class is X87, X87UP or COMPLEX_X87, it is passed in memory
27 
28 
29 /// This macro is meant to compute the first stack address that it is safe to
30 /// write to during rollback or commit. Essentially, it forms the second half of
31 /// a [TOP_OF_STACK, END_OF_STACK) range for filtering writes. It is
32 /// calling-convention and architecture specific.
33 ///
34 /// The "+ 2" protects the two words corresponding to the saved caller's frame
35 /// address and the return address.
36 ///
37 /// The 6 is because I believe that 6 parameters are passed in registers (at
38 /// least 6 of the kinds of parameters we're concerned with in itm2stm).
39 ///
40 /// This particular version is for ITM's calling convention, which I *think* is
41 /// equivalent to the default calling convention in x86_64.
42 #define COMPUTE_PROTECTED_STACK_ADDRESS_ITM_FASTCALL(N) \
43  ((void**)__builtin_frame_address(0) + 2 + ((N - 6) >= 0) ? : 0)
44 
45 /// This macro is meant to compute the first stack address that it is safe to
46 /// write to during rollback or commit. Essentially, it forms the second half of
47 /// a [TOP_OF_STACK, END_OF_STACK) range for filtering writes. It is
48 /// calling-convention and architecture specific.
49 ///
50 /// The "+ 2" protects the two words corresponding to the saved caller's frame
51 /// address and the return address.
52 ///
53 /// The 6 is because I believe that 6 parameters are passed in registers (at
54 /// least 6 of the kinds of parameters we're concerned with in itm2stm).
55 ///
56 /// This particular version is for the default calling convention.
57 #define COMPUTE_PROTECTED_STACK_ADDRESS_DEFAULT(N) \
58  ((void**)__builtin_frame_address(0) + 2 + ((N - 6) >= 0) ? : 0)
59 
60 #endif // STM_ITM2STM_ARCH_X86_64_STACK_PROTECTION_H