authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-07-27 17:47:15-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-07-27 17:47:27-04:00
log341bd0dfa42a729aefff56e48a67a21cb3ea0822
treeca9fe645b90bb03b48f9732d5107969035fb274b
parent0b7a9c072203c2f9999ddcc2231a42334cd028e3

await sets the await bit


1 files changed, 10 insertions(+), 6 deletions(-)

src/ir.cpp+10-6
......@@ -6791,9 +6791,15 @@ static IrInstruction *ir_gen_await_expr(IrBuilder *irb, Scope *scope, AstNode *n
67916791 atomic_state_field_name);
67926792
67936793 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
67946801 VariableTableEntry *result_var = ir_create_var(irb, node, scope, nullptr,
67956802 false, false, true, const_bool_false);
6796 IrInstruction *undefined_value = ir_build_const_undefined(irb, scope, node);
67976803 IrInstruction *target_promise_type = ir_build_typeof(irb, scope, node, target_inst);
67986804 IrInstruction *promise_result_type = ir_build_promise_result_type(irb, scope, node, target_promise_type);
67996805 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
68016807 IrInstruction *my_result_var_ptr = ir_build_var_ptr(irb, scope, node, result_var);
68026808 ir_build_store_ptr(irb, scope, node, result_ptr_field_ptr, my_result_var_ptr);
68036809 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
68056811 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);
68066813 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,
68086815 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
68126816 IrInstruction *await_handle_addr = ir_build_bin_op(irb, scope, node, IrBinOpBinAnd, prev_atomic_value, ptr_mask, false);
68136817 IrInstruction *is_non_null = ir_build_bin_op(irb, scope, node, IrBinOpCmpNotEq, await_handle_addr, zero, false);
68146818 IrBasicBlock *yes_suspend_block = ir_create_basic_block(irb, scope, "YesSuspend");