| ... | @@ -6831,6 +6831,8 @@ static IrInstruction *ir_gen_await_expr(IrBuilder *irb, Scope *scope, AstNode *n | ... | @@ -6831,6 +6831,8 @@ static IrInstruction *ir_gen_await_expr(IrBuilder *irb, Scope *scope, AstNode *n |
| 6831 | IrBasicBlock *cleanup_block = ir_create_basic_block(irb, scope, "SuspendCleanup"); | 6831 | IrBasicBlock *cleanup_block = ir_create_basic_block(irb, scope, "SuspendCleanup"); |
| 6832 | IrBasicBlock *resume_block = ir_create_basic_block(irb, scope, "SuspendResume"); | 6832 | IrBasicBlock *resume_block = ir_create_basic_block(irb, scope, "SuspendResume"); |
| 6833 | IrBasicBlock *cancel_target_block = ir_create_basic_block(irb, scope, "CancelTarget"); | 6833 | IrBasicBlock *cancel_target_block = ir_create_basic_block(irb, scope, "CancelTarget"); |
| | 6834 | IrBasicBlock *do_cancel_block = ir_create_basic_block(irb, scope, "DoCancel"); |
| | 6835 | IrBasicBlock *do_defers_block = ir_create_basic_block(irb, scope, "DoDefers"); |
| 6834 | | 6836 | |
| 6835 | Buf *atomic_state_field_name = buf_create_from_str(ATOMIC_STATE_FIELD_NAME); | 6837 | Buf *atomic_state_field_name = buf_create_from_str(ATOMIC_STATE_FIELD_NAME); |
| 6836 | IrInstruction *atomic_state_ptr = ir_build_field_ptr(irb, scope, node, coro_promise_ptr, | 6838 | IrInstruction *atomic_state_ptr = ir_build_field_ptr(irb, scope, node, coro_promise_ptr, |
| ... | @@ -6912,6 +6914,20 @@ static IrInstruction *ir_gen_await_expr(IrBuilder *irb, Scope *scope, AstNode *n | ... | @@ -6912,6 +6914,20 @@ static IrInstruction *ir_gen_await_expr(IrBuilder *irb, Scope *scope, AstNode *n |
| 6912 | ir_mark_gen(ir_build_br(irb, scope, node, cleanup_block, const_bool_false)); | 6914 | ir_mark_gen(ir_build_br(irb, scope, node, cleanup_block, const_bool_false)); |
| 6913 | | 6915 | |
| 6914 | ir_set_cursor_at_end_and_append_block(irb, cleanup_block); | 6916 | ir_set_cursor_at_end_and_append_block(irb, cleanup_block); |
| | 6917 | IrInstruction *my_mask_bits = ir_build_bin_op(irb, scope, node, IrBinOpBinOr, ptr_mask, is_canceled_mask, false); |
| | 6918 | IrInstruction *my_prev_atomic_value = ir_build_atomic_rmw(irb, scope, node, |
| | 6919 | usize_type_val, irb->exec->atomic_state_field_ptr, nullptr, my_mask_bits, nullptr, |
| | 6920 | AtomicRmwOp_or, AtomicOrderSeqCst); |
| | 6921 | IrInstruction *my_await_handle_addr = ir_build_bin_op(irb, scope, node, IrBinOpBinAnd, my_prev_atomic_value, ptr_mask, false); |
| | 6922 | IrInstruction *have_my_await_handle = ir_build_bin_op(irb, scope, node, IrBinOpCmpNotEq, my_await_handle_addr, zero, false); |
| | 6923 | ir_build_cond_br(irb, scope, node, have_my_await_handle, do_cancel_block, do_defers_block, const_bool_false); |
| | 6924 | |
| | 6925 | ir_set_cursor_at_end_and_append_block(irb, do_cancel_block); |
| | 6926 | IrInstruction *my_await_handle = ir_build_int_to_ptr(irb, scope, node, promise_type_val, my_await_handle_addr); |
| | 6927 | ir_gen_cancel_target(irb, scope, node, my_await_handle); |
| | 6928 | ir_mark_gen(ir_build_br(irb, scope, node, do_defers_block, const_bool_false)); |
| | 6929 | |
| | 6930 | ir_set_cursor_at_end_and_append_block(irb, do_defers_block); |
| 6915 | ir_gen_defers_for_block(irb, scope, outer_scope, true); | 6931 | ir_gen_defers_for_block(irb, scope, outer_scope, true); |
| 6916 | ir_mark_gen(ir_build_br(irb, scope, node, irb->exec->coro_final_cleanup_block, const_bool_false)); | 6932 | ir_mark_gen(ir_build_br(irb, scope, node, irb->exec->coro_final_cleanup_block, const_bool_false)); |
| 6917 | | 6933 | |