Changeset 98151 in vbox for trunk/src/VBox/Runtime/common/compiler/vcc/stack-vcc.asm
- Timestamp:
- Jan 20, 2023 9:16:34 AM (2 years ago)
- svn:sync-xref-src-repo-rev:
- 155324
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/common/compiler/vcc/stack-vcc.asm
r98103 r98151 124 124 %endif 125 125 126 127 128 ;;129 ; Probe stack to trigger guard faults, and for x86 to allocate stack space.130 ;131 ; @param xAX Frame size.132 ; @uses AMD64: Probably nothing. EAX is certainly not supposed to change.133 ; x86: ESP = ESP - EAX; EFLAGS, nothing else134 ;135 ALIGNCODE(64)136 GLOBALNAME_RAW __alloca_probe, __alloca_probe, function137 BEGINPROC_RAW __chkstk138 push xBP139 SEH64_PUSH_xBP140 mov xBP, xSP141 SEH64_SET_FRAME_xBP 0142 push xAX143 SEH64_PUSH_GREG xAX144 push xBX145 SEH64_PUSH_GREG xBX146 SEH64_END_PROLOGUE147 148 ;149 ; Adjust eax so we're relative to [xBP - xCB*2].150 ;151 sub xAX, xCB * 4152 jle .touch_loop_done ; jump if rax < xCB*4, very unlikely153 154 ;155 ; Subtract what's left of the current page from eax and only engage156 ; the touch loop if (int)xAX > 0.157 ;158 lea ebx, [ebp - xCB * 2]159 and ebx, PAGE_SIZE - 1160 sub xAX, xBX161 jnl .touch_loop ; jump if pages to touch.162 163 .touch_loop_done:164 pop xBX165 pop xAX166 leave167 %ifndef RT_ARCH_X86168 ret169 %else170 ;171 ; Do the stack space allocation and jump to the return location.172 ;173 sub esp, eax174 add esp, 4175 jmp dword [esp + eax - 4]176 %endif177 178 ;179 ; The touch loop.180 ;181 .touch_loop:182 sub xBX, PAGE_SIZE183 %if 1184 mov [xBP + xBX - xCB * 2], bl185 %else186 or byte [xBP + xBX - xCB * 2], 0 ; non-destructive variant...187 %endif188 sub xAX, PAGE_SIZE189 jnl .touch_loop190 jmp .touch_loop_done191 ENDPROC_RAW __chkstk192 193 194 %ifdef RT_ARCH_X86195 ;;196 ; 8 and 16 byte aligned alloca w/ probing.197 ;198 ; This routine adjusts the allocation size so __chkstk will return a199 ; correctly aligned allocation.200 ;201 ; @param xAX Unaligned allocation size.202 ;203 %macro __alloc_probe_xxx 1204 ALIGNCODE(16)205 BEGINPROC_RAW __alloca_probe_ %+ %1206 push ecx207 208 ;209 ; Calc the ESP address after the allocation and adjust EAX so that it210 ; will be aligned as desired.211 ;212 lea ecx, [esp + 8]213 sub ecx, eax214 and ecx, %1 - 1215 add eax, ecx216 jc .bad_alloc_size217 .continue:218 219 pop ecx220 jmp __alloca_probe221 222 .bad_alloc_size:223 %ifdef RT_STRICT224 int3225 %endif226 or eax, 0xfffffff0227 jmp .continue228 ENDPROC_RAW __alloca_probe_ %+ %1229 %endmacro230 231 __alloc_probe_xxx 16232 __alloc_probe_xxx 8233 %endif ; RT_ARCH_X86234 126 235 127
Note:
See TracChangeset
for help on using the changeset viewer.