diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2018-07-30 13:42:26 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-07-30 13:42:26 -0400 |
| commit | 5d4a02c350a18a70cf1f92f6638b5d26689c16b4 (patch) | |
| tree | 30c9da2e8dc9a0aaef2ac59c9694291ec0f5c9ab /src/analyze.cpp | |
| parent | 608ff52dc3ea356b23fb6ae92fbca9fbb18c7892 (diff) | |
| parent | cfe03c764de0d2edfbad74a71d7c18f0fd68b506 (diff) | |
| download | zig-5d4a02c350a18a70cf1f92f6638b5d26689c16b4.tar.gz zig-5d4a02c350a18a70cf1f92f6638b5d26689c16b4.zip | |
Merge pull request #1307 from ziglang/cancel-semantics
improved coroutine cancel semantics
Diffstat (limited to 'src/analyze.cpp')
| -rw-r--r-- | src/analyze.cpp | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/analyze.cpp b/src/analyze.cpp index aadee29fc8..03cfa5b67b 100644 --- a/src/analyze.cpp +++ b/src/analyze.cpp @@ -161,7 +161,6 @@ ScopeSuspend *create_suspend_scope(AstNode *node, Scope *parent) { assert(node->type == NodeTypeSuspend); ScopeSuspend *scope = allocate<ScopeSuspend>(1); init_scope(&scope->base, ScopeIdSuspend, node, parent); - scope->name = node->data.suspend.name; return scope; } @@ -519,11 +518,11 @@ TypeTableEntry *get_promise_frame_type(CodeGen *g, TypeTableEntry *return_type) return return_type->promise_frame_parent; } - TypeTableEntry *awaiter_handle_type = get_optional_type(g, g->builtin_types.entry_promise); + TypeTableEntry *atomic_state_type = g->builtin_types.entry_usize; TypeTableEntry *result_ptr_type = get_pointer_to_type(g, return_type, false); ZigList<const char *> field_names = {}; - field_names.append(AWAITER_HANDLE_FIELD_NAME); + field_names.append(ATOMIC_STATE_FIELD_NAME); field_names.append(RESULT_FIELD_NAME); field_names.append(RESULT_PTR_FIELD_NAME); if (g->have_err_ret_tracing) { @@ -533,7 +532,7 @@ TypeTableEntry *get_promise_frame_type(CodeGen *g, TypeTableEntry *return_type) } ZigList<TypeTableEntry *> field_types = {}; - field_types.append(awaiter_handle_type); + field_types.append(atomic_state_type); field_types.append(return_type); field_types.append(result_ptr_type); if (g->have_err_ret_tracing) { @@ -6228,7 +6227,12 @@ uint32_t get_abi_alignment(CodeGen *g, TypeTableEntry *type_entry) { } else if (type_entry->id == TypeTableEntryIdOpaque) { return 1; } else { - return LLVMABIAlignmentOfType(g->target_data_ref, type_entry->type_ref); + uint32_t llvm_alignment = LLVMABIAlignmentOfType(g->target_data_ref, type_entry->type_ref); + // promises have at least alignment 8 so that we can have 3 extra bits when doing atomicrmw + if (type_entry->id == TypeTableEntryIdPromise && llvm_alignment < 8) { + return 8; + } + return llvm_alignment; } } |
