1 ;; Copyright (C) 2013 Google Inc. All rights reserved.
3 ;; Redistribution and use in source and binary forms, with or without
4 ;; modification, are permitted provided that the following conditions are
7 ;; * Redistributions of source code must retain the above copyright
8 ;; notice, this list of conditions and the following disclaimer.
9 ;; * Redistributions in binary form must reproduce the above
10 ;; copyright notice, this list of conditions and the following disclaimer
11 ;; in the documentation and/or other materials provided with the
13 ;; * Neither the name of Google Inc. nor the names of its
14 ;; contributors may be used to endorse or promote products derived from
15 ;; this software without specific prior written permission.
17 ;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 ;; "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 ;; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 ;; A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 ;; OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 ;; SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 ;; LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 ;; DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 ;; THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 ;; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 ;; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
46 ;; Prefix symbols by '_' if PREFIX is defined.
48 %define mangle(x) _ %+ x
54 ; PRIVATE makes a symbol private.
55 %ifidn __OUTPUT_FORMAT__,elf32
56 %define PRIVATE :hidden
57 %elifidn __OUTPUT_FORMAT__,elf64
58 %define PRIVATE :hidden
59 %elifidn __OUTPUT_FORMAT__,elfx32
60 %define PRIVATE :hidden
64 %define PRIVATE :private_extern
67 ;; typedef void (*PushAllRegistersCallback)(SafePointBarrier*, ThreadState*, intptr_t*);
68 ;; extern "C" void pushAllRegisters(SafePointBarrier*, ThreadState*, PushAllRegistersCallback)
70 global mangle(pushAllRegisters) PRIVATE
74 mangle(pushAllRegisters):
75 ;; Push all callee-saves registers to get them
76 ;; on the stack for conservative stack scanning.
77 ;; We maintain 16-byte alignment at calls (required on Mac).
78 ;; There is an 8-byte return address on the stack and we push
79 ;; 56 bytes which maintains 16-byte stack alignment
88 ;; Pass the two first arguments unchanged (rdi, rsi)
89 ;; and the stack pointer after pushing callee-saved
90 ;; registers to the callback.
94 ;; Pop the callee-saved registers. None of them were
95 ;; modified so no restoring is needed.
101 mangle(pushAllRegisters):
102 ;; Push all callee-saves registers to get them
103 ;; on the stack for conservative stack scanning.
112 ;; Pass the two first arguments unchanged (rcx, rdx)
113 ;; and the stack pointer after pushing callee-saved
114 ;; registers to the callback.
118 ;; Pop the callee-saved registers. None of them were
119 ;; modified so no restoring is needed.
125 mangle(pushAllRegisters):
126 ;; Push all callee-saves registers to get them
127 ;; on the stack for conservative stack scanning.
128 ;; We maintain 16-byte alignment at calls (required on
129 ;; Mac). There is a 4-byte return address on the stack
130 ;; and we push 28 bytes which maintains 16-byte alignment
136 ;; Pass the two first arguments unchanged and the
137 ;; stack pointer after pushing callee-save registers
141 push dword [esp + 28]
142 push dword [esp + 28]
144 ;; Pop arguments and the callee-saved registers.
145 ;; None of the callee-saved registers were modified
146 ;; so we do not need to restore them.
152 %error "Yasm does not support arm. Use SaveRegisters_arm.S on arm."
154 %error "Unsupported platform."