Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build_runner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
matrix:
include:
- zig-version: mach-latest
build-runner-file: master.zig
build-runner-file: mach-latest.zig
# Zig master is handled by 'zig build test' in the main CI
runs-on: ubuntu-22.04

Expand Down
8 changes: 4 additions & 4 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const builtin = @import("builtin");
const zls_version: std.SemanticVersion = .{ .major = 0, .minor = 14, .patch = 0, .pre = "dev" };

/// Specify the minimum Zig version that is required to compile and test ZLS:
/// compiler,std: implement ZON support
/// std.ArrayList: popOrNull() -> pop() [v2]
///
/// If you do not use Nix, a ZLS maintainer can take care of this.
/// Whenever this version is increased, run the following command:
Expand All @@ -15,17 +15,17 @@ const zls_version: std.SemanticVersion = .{ .major = 0, .minor = 14, .patch = 0,
/// ```
///
/// Also update the `minimum_zig_version` in `build.zig.zon`.
const minimum_build_zig_version = "0.14.0-dev.3042+317722b37";
const minimum_build_zig_version = "0.14.0-dev.3181+914248237";

/// Specify the minimum Zig version that is required to run ZLS:
/// std.Build: add new functions to create artifacts/Step.Compile from existing module
/// std.ArrayList: popOrNull() -> pop() [v2]
///
/// Examples of reasons that would cause the minimum runtime version to be bumped are:
/// - breaking change to the Zig Syntax
/// - breaking change to AstGen (i.e `zig ast-check`)
///
/// A breaking change to the Zig Build System should be handled by updating ZLS's build runner (see src\build_runner)
const minimum_runtime_zig_version = "0.14.0-dev.2534+12d64c456";
const minimum_runtime_zig_version = "0.14.0-dev.3181+914248237";

const release_targets = [_]std.Target.Query{
.{ .cpu_arch = .x86_64, .os_tag = .windows },
Expand Down
2 changes: 1 addition & 1 deletion build.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
.version = "0.14.0-dev",
// Must be kept in line with the `minimum_build_zig_version` in `build.zig`.
// Should be a Zig version that is downloadable from https://ziglang.org/download/ or a mirror.
.minimum_zig_version = "0.14.0-dev.3046+08d661fcf",
.minimum_zig_version = "0.14.0-dev.3181+914248237",
// If you do not use Nix, a ZLS maintainer can take care of this.
// Whenever the dependencies are updated, run the following command:
// ```bash
Expand Down
2 changes: 1 addition & 1 deletion src/DiagnosticsCollection.zig
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ pub fn publishDiagnostics(collection: *DiagnosticsCollection) (std.mem.Allocator
collection.mutex.lock();
defer collection.mutex.unlock();

const entry = collection.outdated_files.popOrNull() orelse break;
const entry = collection.outdated_files.pop() orelse break;
defer collection.allocator.free(entry.key);
const document_uri = entry.key;

Expand Down
2 changes: 1 addition & 1 deletion src/analysis.zig
Original file line number Diff line number Diff line change
Expand Up @@ -3737,7 +3737,7 @@ pub fn getPositionContext(
}
}

if (stack.popOrNull()) |state| {
if (stack.pop()) |state| {
switch (state.ctx) {
.parens_expr => |loc| return .{ .var_access = loc },
.var_access => |loc| {
Expand Down
46 changes: 34 additions & 12 deletions src/binned_allocator.zig
Original file line number Diff line number Diff line change
Expand Up @@ -69,22 +69,27 @@ pub fn BinnedAllocator(comptime config: Config) type {
.alloc = alloc,
.resize = resize,
.free = free,
.remap = remap,
},
};
}

fn alloc(ctx: *anyopaque, len: usize, log2_align: u8, ret_addr: usize) ?[*]u8 {
fn alloc(
ctx: *anyopaque,
len: usize,
alignment: std.mem.Alignment,
ret_addr: usize,
) ?[*]u8 {
const self: *Self = @ptrCast(@alignCast(ctx));

const align_ = @as(usize, 1) << @as(std.math.Log2Int(usize), @intCast(log2_align));
const size = @max(len, align_);
const size = @max(len, alignment.toByteUnits());
inline for (&self.bins) |*bin| {
if (size <= bin.size) {
return bin.alloc(self.backing_allocator);
}
}

if (self.backing_allocator.rawAlloc(len, log2_align, ret_addr)) |ptr| {
if (self.backing_allocator.rawAlloc(len, alignment, ret_addr)) |ptr| {
if (config.report_leaks) {
self.large_count.increment();
}
Expand All @@ -94,13 +99,18 @@ pub fn BinnedAllocator(comptime config: Config) type {
}
}

fn resize(ctx: *anyopaque, buf: []u8, log2_align: u8, new_len: usize, ret_addr: usize) bool {
fn resize(
ctx: *anyopaque,
buf: []u8,
alignment: std.mem.Alignment,
new_len: usize,
ret_addr: usize,
) bool {
const self: *Self = @ptrCast(@alignCast(ctx));

const align_ = @as(usize, 1) << @as(std.math.Log2Int(usize), @intCast(log2_align));
comptime var prev_size: usize = 0;
inline for (&self.bins) |*bin| {
if (buf.len <= bin.size and align_ <= bin.size) {
if (buf.len <= bin.size and alignment.toByteUnits() <= bin.size) {
// Check it still fits
return new_len > prev_size and new_len <= bin.size;
}
Expand All @@ -109,27 +119,39 @@ pub fn BinnedAllocator(comptime config: Config) type {

// Assuming it's a large alloc
if (new_len <= prev_size) return false; // New size fits into a bin
return self.backing_allocator.rawResize(buf, log2_align, new_len, ret_addr);
return self.backing_allocator.rawResize(buf, alignment, new_len, ret_addr);
}

fn free(ctx: *anyopaque, buf: []u8, log2_align: u8, ret_addr: usize) void {
fn free(ctx: *anyopaque, buf: []u8, alignment: std.mem.Alignment, ret_addr: usize) void {
const self: *Self = @ptrCast(@alignCast(ctx));

const align_ = @as(usize, 1) << @as(std.math.Log2Int(usize), @intCast(log2_align));
inline for (&self.bins) |*bin| {
if (buf.len <= bin.size and align_ <= bin.size) {
if (buf.len <= bin.size and alignment.toByteUnits() <= bin.size) {
bin.free(buf.ptr);
return;
}
}

// Assuming it's a large alloc
self.backing_allocator.rawFree(buf, log2_align, ret_addr);
self.backing_allocator.rawFree(buf, alignment, ret_addr);
if (config.report_leaks) {
self.large_count.decrement();
}
}

fn remap(
ctx: *anyopaque,
memory: []u8,
alignment: std.mem.Alignment,
new_len: usize,
ret_addr: usize,
) ?[*]u8 {
return if (resize(ctx, memory, alignment, new_len, ret_addr))
memory.ptr
else
null;
}

const Mutex = if (config.thread_safe)
std.Thread.Mutex
else
Expand Down
Loading