authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-12-06 15:25:00-05:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-12-06 15:25:00-05:00
log656cc33f8d49cb5e79cd3f9f8f56963747d43ed6
treee35ada7d719c2ab2e486f4bd6ba32261a35e40be
parent71b7f4b47f69e9b3241e9d44554572258f5eb5b1
signature Commit is signed but in an unrecognized format.

allow calling with a new stack to regress a bit

Calling with a new stack, with a runtime-known stack pointer (e.g. not a global variable) is regressed with this branch. It is now a compile-error, due to the Runtime Hint system not being smart enough to mix a compile-time modifier field with a runtime stack field. I'm OK with this regression because this feature is flawed (see #3268) and may be deleted from the language.

4 files changed, 16 insertions(+), 27 deletions(-)

doc/langref.html.in+4-11
......@@ -6870,16 +6870,6 @@ pub const CallOptions = struct {
68706870 /// Equivalent to function call syntax.
68716871 auto,
68726872
6873 /// Asserts that the function call will not suspend. This allows a
6874 /// non-async function to call an async function.
6875 no_async,
6876
6877 /// The function call will return an async function frame instead of
6878 /// the function's result, which is expected to then be awaited.
6879 /// This is equivalent to using the `async` keyword in front of function
6880 /// call syntax.
6881 async_call,
6882
68836873 /// Prevents tail call optimization. This guarantees that the return
68846874 /// address will point to the callsite, as opposed to the callsite's
68856875 /// callsite. If the call is otherwise required to be tail-called
......@@ -6890,6 +6880,10 @@ pub const CallOptions = struct {
68906880 /// otherwise required to be inlined, a compile error is emitted instead.
68916881 never_inline,
68926882
6883 /// Asserts that the function call will not suspend. This allows a
6884 /// non-async function to call an async function.
6885 no_async,
6886
68936887 /// Guarantees that the call will be generated with tail call optimization.
68946888 /// If this is not possible, a compile error is emitted instead.
68956889 always_tail,
......@@ -6938,7 +6932,6 @@ fn targetFunction(x: i32) usize {
69386932}
69396933 {#code_end#}
69406934 {#header_close#}
6941
69426935 {#header_close#}
69436936
69446937 {#header_open|@cDefine#}
lib/std/builtin.zig+4-10
......@@ -382,16 +382,6 @@ pub const CallOptions = struct {
382382 /// Equivalent to function call syntax.
383383 auto,
384384
385 /// Asserts that the function call will not suspend. This allows a
386 /// non-async function to call an async function.
387 no_async,
388
389 /// The function call will return an async function frame instead of
390 /// the function's result, which is expected to then be awaited.
391 /// This is equivalent to using the `async` keyword in front of function
392 /// call syntax.
393 async_call,
394
395385 /// Prevents tail call optimization. This guarantees that the return
396386 /// address will point to the callsite, as opposed to the callsite's
397387 /// callsite. If the call is otherwise required to be tail-called
......@@ -402,6 +392,10 @@ pub const CallOptions = struct {
402392 /// otherwise required to be inlined, a compile error is emitted instead.
403393 never_inline,
404394
395 /// Asserts that the function call will not suspend. This allows a
396 /// non-async function to call an async function.
397 no_async,
398
405399 /// Guarantees that the call will be generated with tail call optimization.
406400 /// If this is not possible, a compile error is emitted instead.
407401 always_tail,
src/all_types.hpp+6-4
......@@ -409,6 +409,9 @@ struct ZigValue {
409409 LLVMValueRef llvm_global;
410410
411411 union {
412 // populated if special == ConstValSpecialLazy
413 LazyValue *x_lazy;
414
412415 // populated if special == ConstValSpecialStatic
413416 BigInt x_bigint;
414417 BigFloat x_bigfloat;
......@@ -429,7 +432,6 @@ struct ZigValue {
429432 ConstPtrValue x_ptr;
430433 ConstArgTuple x_arg_tuple;
431434 Buf *x_enum_literal;
432 LazyValue *x_lazy;
433435
434436 // populated if special == ConstValSpecialRuntime
435437 RuntimeHintErrorUnion rh_error_union;
......@@ -770,16 +772,16 @@ struct AstNodeUnwrapOptional {
770772// Must be synchronized with std.builtin.CallOptions.Modifier
771773enum CallModifier {
772774 CallModifierNone,
773 CallModifierNoAsync,
774 CallModifierAsync,
775775 CallModifierNeverTail,
776776 CallModifierNeverInline,
777 CallModifierNoAsync,
777778 CallModifierAlwaysTail,
778779 CallModifierAlwaysInline,
779780 CallModifierCompileTime,
780781
781 // This is an additional tag in the compiler, but not exposed in the std lib.
782 // These are additional tags in the compiler, but not exposed in the std lib.
782783 CallModifierBuiltin,
784 CallModifierAsync,
783785};
784786
785787struct AstNodeFnCallExpr {
test/compile_errors.zig+2-2
......@@ -45,9 +45,9 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
4545
4646 cases.addCase(x: {
4747 var tc = cases.create("call with new stack on unsupported target",
48 \\var buf: [10]u8 align(16) = undefined;
4849 \\export fn entry() void {
49 \\ var buf: [10]u8 align(16) = undefined;
50 \\ @call(.{.stack = &buf}, foo);
50 \\ @call(.{.stack = &buf}, foo, .{});
5151 \\}
5252 \\fn foo() void {}
5353 , "tmp.zig:3:5: error: target arch 'wasm32' does not support calling with a new stack");