diff --git a/doc/langref.html.in b/doc/langref.html.in index 7915f82d61..079270aa1e 100644 --- a/doc/langref.html.in +++ b/doc/langref.html.in @@ -7001,40 +7001,6 @@ pub const CallOptions = struct { }; }; {#code_end#} - - {#header_open|Calling with a New Stack#} -
- When the {#syntax#}stack{#endsyntax#} option is provided, instead of using the same stack as the caller, the function uses the provided stack. -
- {#code_begin|test|new_stack_call#} -const std = @import("std"); -const assert = std.debug.assert; - -var new_stack_bytes: [1024]u8 align(16) = undefined; - -test "calling a function with a new stack" { - const arg = 1234; - - const a = @call(.{.stack = new_stack_bytes[0..512]}, targetFunction, .{arg}); - const b = @call(.{.stack = new_stack_bytes[512..]}, targetFunction, .{arg}); - _ = targetFunction(arg); - - assert(arg == 1234); - assert(a < b); -} - -fn targetFunction(x: i32) usize { - assert(x == 1234); - - var local_variable: i32 = 42; - const ptr = &local_variable; - ptr.* += 1; - - assert(local_variable == 43); - return @ptrToInt(ptr); -} - {#code_end#} - {#header_close#} {#header_close#} {#header_open|@cDefine#} diff --git a/lib/std/builtin.zig b/lib/std/builtin.zig index d8f24753d3..de2b800ea9 100644 --- a/lib/std/builtin.zig +++ b/lib/std/builtin.zig @@ -408,6 +408,8 @@ pub const Version = struct { /// therefore must be kept in sync with the compiler implementation. pub const CallOptions = struct { modifier: Modifier = .auto, + + /// Only valid when `Modifier` is `Modifier.async_kw`. stack: ?[]align(std.Target.stack_align) u8 = null, pub const Modifier = enum { diff --git a/src/all_types.hpp b/src/all_types.hpp index 651ea807ad..368309adcc 100644 --- a/src/all_types.hpp +++ b/src/all_types.hpp @@ -1767,7 +1767,6 @@ enum BuiltinFnId { BuiltinFnIdFieldParentPtr, BuiltinFnIdByteOffsetOf, BuiltinFnIdBitOffsetOf, - BuiltinFnIdNewStackCall, BuiltinFnIdAsyncCall, BuiltinFnIdTypeId, BuiltinFnIdShlExact, diff --git a/src/codegen.cpp b/src/codegen.cpp index 72858a704f..e64a44bd13 100644 --- a/src/codegen.cpp +++ b/src/codegen.cpp @@ -8215,7 +8215,6 @@ static void define_builtin_fns(CodeGen *g) { create_builtin_fn(g, BuiltinFnIdNearbyInt, "nearbyInt", 1); create_builtin_fn(g, BuiltinFnIdRound, "round", 1); create_builtin_fn(g, BuiltinFnIdMulAdd, "mulAdd", 4); - create_builtin_fn(g, BuiltinFnIdNewStackCall, "newStackCall", SIZE_MAX); create_builtin_fn(g, BuiltinFnIdAsyncCall, "asyncCall", SIZE_MAX); create_builtin_fn(g, BuiltinFnIdTypeId, "typeId", 1); create_builtin_fn(g, BuiltinFnIdShlExact, "shlExact", 2); diff --git a/src/ir.cpp b/src/ir.cpp index ef3426d111..4742d81b23 100644 --- a/src/ir.cpp +++ b/src/ir.cpp @@ -7145,39 +7145,6 @@ static IrInstSrc *ir_gen_builtin_fn_call(IrBuilderSrc *irb, Scope *scope, AstNod IrInstSrc *offset_of = ir_build_bit_offset_of(irb, scope, node, arg0_value, arg1_value); return ir_lval_wrap(irb, scope, offset_of, lval, result_loc); } - case BuiltinFnIdNewStackCall: - { - if (node->data.fn_call_expr.params.length < 2) { - add_node_error(irb->codegen, node, - buf_sprintf("expected at least 2 arguments, found %" ZIG_PRI_usize, - node->data.fn_call_expr.params.length)); - return irb->codegen->invalid_inst_src; - } - - AstNode *new_stack_node = node->data.fn_call_expr.params.at(0); - IrInstSrc *new_stack = ir_gen_node(irb, new_stack_node, scope); - if (new_stack == irb->codegen->invalid_inst_src) - return new_stack; - - AstNode *fn_ref_node = node->data.fn_call_expr.params.at(1); - IrInstSrc *fn_ref = ir_gen_node(irb, fn_ref_node, scope); - if (fn_ref == irb->codegen->invalid_inst_src) - return fn_ref; - - size_t arg_count = node->data.fn_call_expr.params.length - 2; - - IrInstSrc **args = allocate