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.
This commit is contained in:
Andrew Kelley 2019-12-06 15:25:00 -05:00
parent 71b7f4b47f
commit 656cc33f8d
No known key found for this signature in database
GPG Key ID: 7C5F548F728501A9
4 changed files with 16 additions and 27 deletions

View File

@ -6870,16 +6870,6 @@ pub const CallOptions = struct {
/// Equivalent to function call syntax.
auto,
/// Asserts that the function call will not suspend. This allows a
/// non-async function to call an async function.
no_async,
/// The function call will return an async function frame instead of
/// the function's result, which is expected to then be awaited.
/// This is equivalent to using the `async` keyword in front of function
/// call syntax.
async_call,
/// Prevents tail call optimization. This guarantees that the return
/// address will point to the callsite, as opposed to the callsite's
/// callsite. If the call is otherwise required to be tail-called
@ -6890,6 +6880,10 @@ pub const CallOptions = struct {
/// otherwise required to be inlined, a compile error is emitted instead.
never_inline,
/// Asserts that the function call will not suspend. This allows a
/// non-async function to call an async function.
no_async,
/// Guarantees that the call will be generated with tail call optimization.
/// If this is not possible, a compile error is emitted instead.
always_tail,
@ -6938,7 +6932,6 @@ fn targetFunction(x: i32) usize {
}
{#code_end#}
{#header_close#}
{#header_close#}
{#header_open|@cDefine#}

View File

@ -382,16 +382,6 @@ pub const CallOptions = struct {
/// Equivalent to function call syntax.
auto,
/// Asserts that the function call will not suspend. This allows a
/// non-async function to call an async function.
no_async,
/// The function call will return an async function frame instead of
/// the function's result, which is expected to then be awaited.
/// This is equivalent to using the `async` keyword in front of function
/// call syntax.
async_call,
/// Prevents tail call optimization. This guarantees that the return
/// address will point to the callsite, as opposed to the callsite's
/// callsite. If the call is otherwise required to be tail-called
@ -402,6 +392,10 @@ pub const CallOptions = struct {
/// otherwise required to be inlined, a compile error is emitted instead.
never_inline,
/// Asserts that the function call will not suspend. This allows a
/// non-async function to call an async function.
no_async,
/// Guarantees that the call will be generated with tail call optimization.
/// If this is not possible, a compile error is emitted instead.
always_tail,

View File

@ -409,6 +409,9 @@ struct ZigValue {
LLVMValueRef llvm_global;
union {
// populated if special == ConstValSpecialLazy
LazyValue *x_lazy;
// populated if special == ConstValSpecialStatic
BigInt x_bigint;
BigFloat x_bigfloat;
@ -429,7 +432,6 @@ struct ZigValue {
ConstPtrValue x_ptr;
ConstArgTuple x_arg_tuple;
Buf *x_enum_literal;
LazyValue *x_lazy;
// populated if special == ConstValSpecialRuntime
RuntimeHintErrorUnion rh_error_union;
@ -770,16 +772,16 @@ struct AstNodeUnwrapOptional {
// Must be synchronized with std.builtin.CallOptions.Modifier
enum CallModifier {
CallModifierNone,
CallModifierNoAsync,
CallModifierAsync,
CallModifierNeverTail,
CallModifierNeverInline,
CallModifierNoAsync,
CallModifierAlwaysTail,
CallModifierAlwaysInline,
CallModifierCompileTime,
// This is an additional tag in the compiler, but not exposed in the std lib.
// These are additional tags in the compiler, but not exposed in the std lib.
CallModifierBuiltin,
CallModifierAsync,
};
struct AstNodeFnCallExpr {

View File

@ -45,9 +45,9 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
cases.addCase(x: {
var tc = cases.create("call with new stack on unsupported target",
\\var buf: [10]u8 align(16) = undefined;
\\export fn entry() void {
\\ var buf: [10]u8 align(16) = undefined;
\\ @call(.{.stack = &buf}, foo);
\\ @call(.{.stack = &buf}, foo, .{});
\\}
\\fn foo() void {}
, "tmp.zig:3:5: error: target arch 'wasm32' does not support calling with a new stack");