| ... | ... | @@ -6791,9 +6791,15 @@ static IrInstruction *ir_gen_await_expr(IrBuilder *irb, Scope *scope, AstNode *n |
| 6791 | 6791 | atomic_state_field_name); |
| 6792 | 6792 | |
| 6793 | 6793 | IrInstruction *const_bool_false = ir_build_const_bool(irb, scope, node, false); |
| 6794 | IrInstruction *undefined_value = ir_build_const_undefined(irb, scope, node); |
| 6795 | IrInstruction *usize_type_val = ir_build_const_type(irb, scope, node, irb->codegen->builtin_types.entry_usize); |
| 6796 | IrInstruction *zero = ir_build_const_usize(irb, scope, node, 0); |
| 6797 | IrInstruction *inverted_ptr_mask = ir_build_const_usize(irb, scope, node, 0x7); // 0b111 |
| 6798 | IrInstruction *ptr_mask = ir_build_un_op(irb, scope, node, IrUnOpBinNot, inverted_ptr_mask); // 0b111...000 |
| 6799 | IrInstruction *await_mask = ir_build_const_usize(irb, scope, node, 0x4); // 0b100 |
| 6800 | |
| 6794 | 6801 | VariableTableEntry *result_var = ir_create_var(irb, node, scope, nullptr, |
| 6795 | 6802 | false, false, true, const_bool_false); |
| 6796 | | IrInstruction *undefined_value = ir_build_const_undefined(irb, scope, node); |
| 6797 | 6803 | IrInstruction *target_promise_type = ir_build_typeof(irb, scope, node, target_inst); |
| 6798 | 6804 | IrInstruction *promise_result_type = ir_build_promise_result_type(irb, scope, node, target_promise_type); |
| 6799 | 6805 | ir_build_await_bookkeeping(irb, scope, node, promise_result_type); |
| ... | ... | @@ -6801,14 +6807,12 @@ static IrInstruction *ir_gen_await_expr(IrBuilder *irb, Scope *scope, AstNode *n |
| 6801 | 6807 | IrInstruction *my_result_var_ptr = ir_build_var_ptr(irb, scope, node, result_var); |
| 6802 | 6808 | ir_build_store_ptr(irb, scope, node, result_ptr_field_ptr, my_result_var_ptr); |
| 6803 | 6809 | IrInstruction *save_token = ir_build_coro_save(irb, scope, node, irb->exec->coro_handle); |
| 6804 | | IrInstruction *usize_type_val = ir_build_const_type(irb, scope, node, irb->codegen->builtin_types.entry_usize); |
| 6810 | |
| 6805 | 6811 | IrInstruction *coro_handle_addr = ir_build_ptr_to_int(irb, scope, node, irb->exec->coro_handle); |
| 6812 | IrInstruction *mask_bits = ir_build_bin_op(irb, scope, node, IrBinOpBinOr, coro_handle_addr, await_mask, false); |
| 6806 | 6813 | IrInstruction *prev_atomic_value = ir_build_atomic_rmw(irb, scope, node, |
| 6807 | | usize_type_val, atomic_state_ptr, nullptr, coro_handle_addr, nullptr, |
| 6814 | usize_type_val, atomic_state_ptr, nullptr, mask_bits, nullptr, |
| 6808 | 6815 | AtomicRmwOp_or, AtomicOrderSeqCst); |
| 6809 | | IrInstruction *zero = ir_build_const_usize(irb, scope, node, 0); |
| 6810 | | IrInstruction *inverted_ptr_mask = ir_build_const_usize(irb, scope, node, 0x7); // 0b111 |
| 6811 | | IrInstruction *ptr_mask = ir_build_un_op(irb, scope, node, IrUnOpBinNot, inverted_ptr_mask); // 0b111...000 |
| 6812 | 6816 | IrInstruction *await_handle_addr = ir_build_bin_op(irb, scope, node, IrBinOpBinAnd, prev_atomic_value, ptr_mask, false); |
| 6813 | 6817 | IrInstruction *is_non_null = ir_build_bin_op(irb, scope, node, IrBinOpCmpNotEq, await_handle_addr, zero, false); |
| 6814 | 6818 | IrBasicBlock *yes_suspend_block = ir_create_basic_block(irb, scope, "YesSuspend"); |