| ... | @@ -6824,6 +6824,12 @@ static IrInstruction *ir_gen_await_expr(IrBuilder *irb, Scope *scope, AstNode *n | ... | @@ -6824,6 +6824,12 @@ static IrInstruction *ir_gen_await_expr(IrBuilder *irb, Scope *scope, AstNode *n |
| 6824 | | 6824 | |
| 6825 | IrBasicBlock *already_awaited_block = ir_create_basic_block(irb, scope, "AlreadyAwaited"); | 6825 | IrBasicBlock *already_awaited_block = ir_create_basic_block(irb, scope, "AlreadyAwaited"); |
| 6826 | IrBasicBlock *not_awaited_block = ir_create_basic_block(irb, scope, "NotAwaited"); | 6826 | IrBasicBlock *not_awaited_block = ir_create_basic_block(irb, scope, "NotAwaited"); |
| | 6827 | IrBasicBlock *not_canceled_block = ir_create_basic_block(irb, scope, "NotCanceled"); |
| | 6828 | IrBasicBlock *yes_suspend_block = ir_create_basic_block(irb, scope, "YesSuspend"); |
| | 6829 | IrBasicBlock *no_suspend_block = ir_create_basic_block(irb, scope, "NoSuspend"); |
| | 6830 | IrBasicBlock *merge_block = ir_create_basic_block(irb, scope, "MergeSuspend"); |
| | 6831 | IrBasicBlock *cleanup_block = ir_create_basic_block(irb, scope, "SuspendCleanup"); |
| | 6832 | IrBasicBlock *resume_block = ir_create_basic_block(irb, scope, "SuspendResume"); |
| 6827 | | 6833 | |
| 6828 | Buf *atomic_state_field_name = buf_create_from_str(ATOMIC_STATE_FIELD_NAME); | 6834 | Buf *atomic_state_field_name = buf_create_from_str(ATOMIC_STATE_FIELD_NAME); |
| 6829 | IrInstruction *atomic_state_ptr = ir_build_field_ptr(irb, scope, node, coro_promise_ptr, | 6835 | IrInstruction *atomic_state_ptr = ir_build_field_ptr(irb, scope, node, coro_promise_ptr, |
| ... | @@ -6836,6 +6842,7 @@ static IrInstruction *ir_gen_await_expr(IrBuilder *irb, Scope *scope, AstNode *n | ... | @@ -6836,6 +6842,7 @@ static IrInstruction *ir_gen_await_expr(IrBuilder *irb, Scope *scope, AstNode *n |
| 6836 | IrInstruction *inverted_ptr_mask = ir_build_const_usize(irb, scope, node, 0x7); // 0b111 | 6842 | IrInstruction *inverted_ptr_mask = ir_build_const_usize(irb, scope, node, 0x7); // 0b111 |
| 6837 | IrInstruction *ptr_mask = ir_build_un_op(irb, scope, node, IrUnOpBinNot, inverted_ptr_mask); // 0b111...000 | 6843 | IrInstruction *ptr_mask = ir_build_un_op(irb, scope, node, IrUnOpBinNot, inverted_ptr_mask); // 0b111...000 |
| 6838 | IrInstruction *await_mask = ir_build_const_usize(irb, scope, node, 0x4); // 0b100 | 6844 | IrInstruction *await_mask = ir_build_const_usize(irb, scope, node, 0x4); // 0b100 |
| | 6845 | IrInstruction *is_canceled_mask = ir_build_const_usize(irb, scope, node, 0x1); // 0b001 |
| 6839 | | 6846 | |
| 6840 | VariableTableEntry *result_var = ir_create_var(irb, node, scope, nullptr, | 6847 | VariableTableEntry *result_var = ir_create_var(irb, node, scope, nullptr, |
| 6841 | false, false, true, const_bool_false); | 6848 | false, false, true, const_bool_false); |
| ... | @@ -6861,11 +6868,13 @@ static IrInstruction *ir_gen_await_expr(IrBuilder *irb, Scope *scope, AstNode *n | ... | @@ -6861,11 +6868,13 @@ static IrInstruction *ir_gen_await_expr(IrBuilder *irb, Scope *scope, AstNode *n |
| 6861 | ir_build_unreachable(irb, scope, node); | 6868 | ir_build_unreachable(irb, scope, node); |
| 6862 | | 6869 | |
| 6863 | ir_set_cursor_at_end_and_append_block(irb, not_awaited_block); | 6870 | ir_set_cursor_at_end_and_append_block(irb, not_awaited_block); |
| | 6871 | IrInstruction *is_canceled_value = ir_build_bin_op(irb, scope, node, IrBinOpBinAnd, prev_atomic_value, is_canceled_mask, false); |
| | 6872 | IrInstruction *is_canceled_bool = ir_build_bin_op(irb, scope, node, IrBinOpCmpNotEq, is_canceled_value, zero, false); |
| | 6873 | ir_build_cond_br(irb, scope, node, is_canceled_bool, cleanup_block, not_canceled_block, const_bool_false); |
| | 6874 | |
| | 6875 | ir_set_cursor_at_end_and_append_block(irb, not_canceled_block); |
| 6864 | IrInstruction *await_handle_addr = ir_build_bin_op(irb, scope, node, IrBinOpBinAnd, prev_atomic_value, ptr_mask, false); | 6876 | IrInstruction *await_handle_addr = ir_build_bin_op(irb, scope, node, IrBinOpBinAnd, prev_atomic_value, ptr_mask, false); |
| 6865 | IrInstruction *is_non_null = ir_build_bin_op(irb, scope, node, IrBinOpCmpNotEq, await_handle_addr, zero, false); | 6877 | IrInstruction *is_non_null = ir_build_bin_op(irb, scope, node, IrBinOpCmpNotEq, await_handle_addr, zero, false); |
| 6866 | IrBasicBlock *yes_suspend_block = ir_create_basic_block(irb, scope, "YesSuspend"); | | |
| 6867 | IrBasicBlock *no_suspend_block = ir_create_basic_block(irb, scope, "NoSuspend"); | | |
| 6868 | IrBasicBlock *merge_block = ir_create_basic_block(irb, scope, "MergeSuspend"); | | |
| 6869 | ir_build_cond_br(irb, scope, node, is_non_null, no_suspend_block, yes_suspend_block, const_bool_false); | 6878 | ir_build_cond_br(irb, scope, node, is_non_null, no_suspend_block, yes_suspend_block, const_bool_false); |
| 6870 | | 6879 | |
| 6871 | ir_set_cursor_at_end_and_append_block(irb, no_suspend_block); | 6880 | ir_set_cursor_at_end_and_append_block(irb, no_suspend_block); |
| ... | @@ -6886,8 +6895,6 @@ static IrInstruction *ir_gen_await_expr(IrBuilder *irb, Scope *scope, AstNode *n | ... | @@ -6886,8 +6895,6 @@ static IrInstruction *ir_gen_await_expr(IrBuilder *irb, Scope *scope, AstNode *n |
| 6886 | | 6895 | |
| 6887 | ir_set_cursor_at_end_and_append_block(irb, yes_suspend_block); | 6896 | ir_set_cursor_at_end_and_append_block(irb, yes_suspend_block); |
| 6888 | IrInstruction *suspend_code = ir_build_coro_suspend(irb, scope, node, save_token, const_bool_false); | 6897 | IrInstruction *suspend_code = ir_build_coro_suspend(irb, scope, node, save_token, const_bool_false); |
| 6889 | IrBasicBlock *cleanup_block = ir_create_basic_block(irb, scope, "SuspendCleanup"); | | |
| 6890 | IrBasicBlock *resume_block = ir_create_basic_block(irb, scope, "SuspendResume"); | | |
| 6891 | | 6898 | |
| 6892 | IrInstructionSwitchBrCase *cases = allocate<IrInstructionSwitchBrCase>(2); | 6899 | IrInstructionSwitchBrCase *cases = allocate<IrInstructionSwitchBrCase>(2); |
| 6893 | cases[0].value = ir_build_const_u8(irb, scope, node, 0); | 6900 | cases[0].value = ir_build_const_u8(irb, scope, node, 0); |