Stack Limit as an Argument Purpose (#372)
* Initial approach. * Move stack_limit check before opening the frame * Account for GPRs and frame pointer in stack check * Check stack_limit example. * Remove stack_limit attribute code. Amends #359 * fmt
This commit is contained in:
committed by
Dan Gohman
parent
217786e969
commit
9dbfbbde10
@@ -546,17 +546,6 @@ instructions before instruction selection::
|
||||
When Cranelift code is running in a sandbox, it can also be necessary to include
|
||||
stack overflow checks in the prologue.
|
||||
|
||||
.. inst:: stack_limit = GV
|
||||
|
||||
Set the stack limit of the current function.
|
||||
|
||||
If set, in the preamble read the stack limit from ``GV`` and compare it to the stack pointer. If
|
||||
the stack pointer has reached or exceeded the limit, generate a trap with a
|
||||
``stk_ovf`` code.
|
||||
|
||||
Setting `stack_limit` is an alternative way to detect stack overflow, when using
|
||||
a calling convention that doesn't perform stack probes.
|
||||
|
||||
Global values
|
||||
-------------
|
||||
|
||||
|
||||
@@ -228,3 +228,28 @@ ebb4:
|
||||
; check: function %divert
|
||||
; check: regmove v5, %rcx -> %rbx
|
||||
; check: [Op1popq#58,%rbx] v15 = x86_pop.i64
|
||||
|
||||
; Stack limit checking
|
||||
|
||||
function %stack_limit(i64 stack_limit) {
|
||||
ss0 = explicit_slot 168
|
||||
ebb0(v0: i64):
|
||||
return
|
||||
}
|
||||
|
||||
; check: function %stack_limit(i64 stack_limit [%rdi], i64 fp [%rbp]) -> i64 fp [%rbp] fast {
|
||||
; nextln: ss0 = explicit_slot 168, offset -184
|
||||
; nextln: ss1 = incoming_arg 16, offset -16
|
||||
; nextln:
|
||||
; nextln: ebb0(v0: i64 [%rdi], v4: i64 [%rbp]):
|
||||
; nextln: v1 = copy v0
|
||||
; nextln: v2 = iadd_imm v1, 16
|
||||
; nextln: v3 = ifcmp_sp v2
|
||||
; nextln: trapif uge v3, stk_ovf
|
||||
; nextln: x86_push v4
|
||||
; nextln: copy_special %rsp -> %rbp
|
||||
; nextln: adjust_sp_down_imm 176
|
||||
; nextln: adjust_sp_up_imm 176
|
||||
; nextln: v5 = x86_pop.i64
|
||||
; nextln: return v5
|
||||
; nextln: }
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
test cat
|
||||
|
||||
; Verify parsing of stack_limit.
|
||||
function %minimal(i64 vmctx) {
|
||||
gv0 = vmctx
|
||||
; Stack limit
|
||||
stack_limit = gv0
|
||||
|
||||
ebb0:
|
||||
trap user0
|
||||
}
|
||||
; sameln: function %minimal(i64 vmctx) fast {
|
||||
; nextln: gv0 = vmctx
|
||||
; nextln: stack_limit = gv0
|
||||
; nextln:
|
||||
; nextln: ebb0:
|
||||
; nextln: trap user0
|
||||
; nextln: }
|
||||
Reference in New Issue
Block a user