| 1 |
// { dg-do compile } |
| 2 |
// { dg-require-effective-target c++20 } |
| 3 |
|
| 4 |
void *operator new(__SIZE_TYPE__, void *__p) { return __p; } |
| 5 |
template <typename _Head> struct _Head_base { |
| 6 |
_Head _M_head_impl; |
| 7 |
}; |
| 8 |
template <unsigned long, typename...> struct _Tuple_impl; |
| 9 |
template <unsigned long _Idx, typename _Head, typename... _Tail> |
| 10 |
struct _Tuple_impl<_Idx, _Head, _Tail...> : _Tuple_impl<_Idx + 1, _Tail...>, |
| 11 |
_Head_base<_Head> { |
| 12 |
template <typename _UHead, typename... _UTail> |
| 13 |
_Tuple_impl(_UHead __head, _UTail... __tail) |
| 14 |
: _Tuple_impl<_Idx + 1, _Tail...>(__tail...), _Head_base<_Head>(__head) {} |
| 15 |
}; |
| 16 |
template <unsigned long _Idx, typename _Head> struct _Tuple_impl<_Idx, _Head> { |
| 17 |
template <typename _UHead> _Tuple_impl(_UHead); |
| 18 |
}; |
| 19 |
template <typename... _Elements> struct tuple : _Tuple_impl<0, _Elements...> { |
| 20 |
template <typename... _UElements> |
| 21 |
tuple(_UElements... __elements) |
| 22 |
: _Tuple_impl<0, _Elements...>(__elements...) {} |
| 23 |
}; |
| 24 |
unsigned long position_; |
| 25 |
struct Zone { |
| 26 |
template <typename T, typename... Args> T *New(Args... args) { |
| 27 |
return new (reinterpret_cast<void *>(position_)) T(args...); |
| 28 |
} |
| 29 |
}; |
| 30 |
struct Label { |
| 31 |
int pos_; |
| 32 |
int near_link_pos_; |
| 33 |
}; |
| 34 |
enum Condition { below_equal }; |
| 35 |
void bind(Label *); |
| 36 |
Zone *zone(); |
| 37 |
unsigned long deopt_info_address(); |
| 38 |
int MakeDeferredCode___trans_tmp_2, MakeDeferredCode___trans_tmp_3, |
| 39 |
Prologue___trans_tmp_6, MakeDeferredCode___trans_tmp_1; |
| 40 |
struct MaglevAssembler { |
| 41 |
template <typename Function, typename... Args> |
| 42 |
void MakeDeferredCode(Function &&, Args &&...); |
| 43 |
template <typename Function, typename... Args> |
| 44 |
void JumpToDeferredIf(Condition, Function, Args... args) { |
| 45 |
MakeDeferredCode(Function(), args...); |
| 46 |
} |
| 47 |
void Prologue(); |
| 48 |
}; |
| 49 |
struct ZoneLabelRef { |
| 50 |
ZoneLabelRef(Zone *zone) : label_(zone->New<Label>()) {} |
| 51 |
ZoneLabelRef(MaglevAssembler *) : ZoneLabelRef(zone()) {} |
| 52 |
Label *operator*() { return label_; } |
| 53 |
Label *label_; |
| 54 |
}; |
| 55 |
template <typename Function> |
| 56 |
struct FunctionArgumentsTupleHelper |
| 57 |
: FunctionArgumentsTupleHelper<decltype(&Function::operator())> {}; |
| 58 |
template <typename C, typename R, typename... A> |
| 59 |
struct FunctionArgumentsTupleHelper<R (C::*)(A...) const> { |
| 60 |
using Tuple = tuple<A...>; |
| 61 |
}; |
| 62 |
template <typename> struct StripFirstTupleArg; |
| 63 |
template <typename T1, typename... T> |
| 64 |
struct StripFirstTupleArg<tuple<T1, T...>> { |
| 65 |
using Stripped = tuple<T...>; |
| 66 |
}; |
| 67 |
template <typename Function> struct DeferredCodeInfoImpl { |
| 68 |
template <typename... InArgs> |
| 69 |
DeferredCodeInfoImpl(int *, int, int, Function, InArgs... args) |
| 70 |
: args(args...) {} |
| 71 |
StripFirstTupleArg< |
| 72 |
typename FunctionArgumentsTupleHelper<Function>::Tuple>::Stripped args; |
| 73 |
}; |
| 74 |
template <typename Function, typename... Args> |
| 75 |
void MaglevAssembler::MakeDeferredCode(Function &&deferred_code_gen, |
| 76 |
Args &&...args) { |
| 77 |
zone()->New<DeferredCodeInfoImpl<Function>>( |
| 78 |
&MakeDeferredCode___trans_tmp_1, MakeDeferredCode___trans_tmp_2, |
| 79 |
MakeDeferredCode___trans_tmp_3, deferred_code_gen, args...); |
| 80 |
} |
| 81 |
void MaglevAssembler::Prologue() { |
| 82 |
int *__trans_tmp_9; |
| 83 |
ZoneLabelRef deferred_call_stack_guard_return(this); |
| 84 |
__trans_tmp_9 = reinterpret_cast<int *>(deopt_info_address()); |
| 85 |
JumpToDeferredIf( |
| 86 |
below_equal, [](MaglevAssembler, int *, ZoneLabelRef, int, int) {}, |
| 87 |
__trans_tmp_9, deferred_call_stack_guard_return, Prologue___trans_tmp_6, |
| 88 |
0); |
| 89 |
Label __trans_tmp_7 = **deferred_call_stack_guard_return; |
| 90 |
bind(&__trans_tmp_7); |
| 91 |
} |