From ad106749949cd43154a8bfdf3c5aacb0184e7086 Mon Sep 17 00:00:00 2001 From: Jarred Sumner Date: Mon, 24 Feb 2025 02:39:29 -0800 Subject: [PATCH] More --- src/js_lexer.zig | 13 ++++++++++--- src/string_immutable.zig | 16 ++++++++++++---- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/src/js_lexer.zig b/src/js_lexer.zig index 12f245e18f..0f3678a59d 100644 --- a/src/js_lexer.zig +++ b/src/js_lexer.zig @@ -1251,7 +1251,7 @@ fn NewLexer_( } }, - .open_paren, + inline .open_paren, .close_paren, .open_bracket, .close_bracket, @@ -1267,7 +1267,7 @@ fn NewLexer_( lexer.token = @enumFromInt(@intFromEnum(token)); if (comptime is_json) { - switch (token) { + switch (comptime token) { .semicolon => { @branchHint(.unlikely); return lexer.addUnsupportedSyntaxError("Semicolons are not allowed in JSON"); @@ -1484,7 +1484,14 @@ fn NewLexer_( -1 => { break :singleLineComment; }, - else => {}, + else => { + if (comptime Environment.enableSIMD) { + if (strings.indexOfNewlineOrNonASCIICheckStart(lexer.source.contents[lexer.current..], 0, false)) |i| { + lexer.current += i; + continue :singleLineComment; + } + } + }, } } diff --git a/src/string_immutable.zig b/src/string_immutable.zig index 2613d5c5df..cc2491a2fb 100644 --- a/src/string_immutable.zig +++ b/src/string_immutable.zig @@ -4195,7 +4195,9 @@ pub fn firstNonASCIIWithType(comptime Type: type, slice: Type) ?u32 { } } - if (comptime Environment.allow_assert) assert(remaining.len < 8); + // This is a compiler optimization! + // Force clang to not auto-vectorize the loop below. + bun.unsafeAssert(remaining.len < 8); for (remaining) |*char| { if (char.* > 127) { @@ -4232,7 +4234,9 @@ pub fn indexOfNewlineOrNonASCIIOrANSI(slice_: []const u8, offset: u32) ?u32 { remaining = remaining[ascii_vector_size..]; } - if (comptime Environment.allow_assert) assert(remaining.len < ascii_vector_size); + // This is a compiler optimization! + // Force clang to not auto-vectorize the loop below. + bun.unsafeAssert(remaining.len < ascii_vector_size); } for (remaining) |*char_| { @@ -4280,7 +4284,9 @@ pub fn indexOfNewlineOrNonASCIICheckStart(slice_: []const u8, offset: u32, compt remaining = remaining[ascii_vector_size..]; } - if (comptime Environment.allow_assert) assert(remaining.len < ascii_vector_size); + // This is a compiler optimization! + // Force clang to not auto-vectorize the loop below. + bun.unsafeAssert(remaining.len < ascii_vector_size); } for (remaining) |*char_| { @@ -4315,7 +4321,9 @@ pub fn containsNewlineOrNonASCIIOrQuote(slice_: []const u8) bool { remaining = remaining[ascii_vector_size..]; } - if (comptime Environment.allow_assert) assert(remaining.len < ascii_vector_size); + // This is a compiler optimization! + // Force clang to not auto-vectorize the loop below. + bun.unsafeAssert(remaining.len < ascii_vector_size); } for (remaining) |*char_| {